tdf#162475 sc: display all the conditions of same ranges in conditional format manager

Change-Id: I775f96f4cea19e8da34c2d64ac601e5ea3fc5c43
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169482
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170914
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
This commit is contained in:
Pranam Lashkari
2024-08-15 14:53:59 +02:00
committed by Caolán McNamara
parent 367c2319a8
commit 8090d7a54f
8 changed files with 93 additions and 67 deletions
+2 -2
View File
@@ -32,7 +32,7 @@ class tdf100793(UITestCase):
# check that we have exactly one conditional formats in the beginning
xList = xCondFormatMgr.getChild("CONTAINER")
list_state = get_state_as_dict(xList)
self.assertEqual(list_state['Children'], '1')
self.assertEqual(list_state['Children'], '3')
#3) Click Edit & try to change to intended one, F18:K33
xEditBtn = xCondFormatMgr.getChild("edit")
@@ -65,7 +65,7 @@ class tdf100793(UITestCase):
# and still only 1 conditional format in the document
xList = xCondFormatMgr.getChild("CONTAINER")
list_state = get_state_as_dict(xList)
self.assertEqual(list_state['Children'], '1')
self.assertEqual(list_state['Children'], '3')
self.assertEqual(conditional_format_list.getLength(), 1)
+2 -2
View File
@@ -27,7 +27,7 @@ class tdf105544(UITestCase):
# check that we have exactly four conditional formats in the beginning
xList = xCondFormatMgr.getChild("CONTAINER")
list_state = get_state_as_dict(xList)
self.assertEqual(list_state['Children'], '4')
self.assertEqual(list_state['Children'], '5')
#select B3:B37 range and click edit, then click yes
xList.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) #2nd position in the list
@@ -41,7 +41,7 @@ class tdf105544(UITestCase):
# check again that we still have 4 entry in the list
xList = xCondFormatMgr.getChild("CONTAINER")
list_state = get_state_as_dict(xList)
self.assertEqual(list_state['Children'], '4')
self.assertEqual(list_state['Children'], '5')
# close the conditional format manager
xOKBtn = xCondFormatMgr.getChild("ok")
+1 -1
View File
@@ -44,7 +44,7 @@ class tdf86253(UITestCase):
# check that we have exactly 1 conditional format and range is C1:C17
xList = xCondFormatMgr.getChild("CONTAINER")
list_state = get_state_as_dict(xList)
self.assertEqual(list_state['Children'], '1')
self.assertEqual(list_state['Children'], '2') # We can now display both condition seprate on same range
xTreeEntry = xList.getChild('0')
self.assertEqual(get_state_as_dict(xTreeEntry)["Text"], "A1:A6,C1:C17\tCell value >= 0")
+48 -49
View File
@@ -136,68 +136,67 @@ OUString getDateString(sal_Int32 nIndex)
}
OUString ScCondFormatHelper::GetExpression(const ScConditionalFormat& rFormat, const ScAddress& rPos)
OUString ScCondFormatHelper::GetExpression(const ScFormatEntry* rEntry, const ScAddress& rPos)
{
OUStringBuffer aBuffer;
if(!rFormat.IsEmpty())
switch (rEntry->GetType())
{
switch(rFormat.GetEntry(0)->GetType())
case ScFormatEntry::Type::Condition:
case ScFormatEntry::Type::ExtCondition:
{
case ScFormatEntry::Type::Condition:
case ScFormatEntry::Type::ExtCondition:
const ScConditionEntry* pEntry = static_cast<const ScConditionEntry*>(rEntry);
ScConditionMode eMode = pEntry->GetOperation();
if (eMode == ScConditionMode::Direct)
{
aBuffer.append(getTextForType(FORMULA) + " " + pEntry->GetExpression(rPos, 0));
}
else
{
aBuffer.append(getTextForType(CONDITION) + " "
+ getExpression(static_cast<sal_Int32>(eMode)) + " ");
if (eMode == ScConditionMode::Between || eMode == ScConditionMode::NotBetween)
{
const ScConditionEntry* pEntry = static_cast<const ScConditionEntry*>(rFormat.GetEntry(0));
ScConditionMode eMode = pEntry->GetOperation();
if(eMode == ScConditionMode::Direct)
{
aBuffer.append(getTextForType(FORMULA)
+ " "
+ pEntry->GetExpression(rPos, 0));
}
else
{
aBuffer.append(getTextForType(CONDITION)
+ " "
+ getExpression(static_cast<sal_Int32>(eMode))
+ " ");
if(eMode == ScConditionMode::Between || eMode == ScConditionMode::NotBetween)
{
aBuffer.append(pEntry->GetExpression(rPos, 0)
+ " "
+ ScResId(STR_COND_AND)
+ " "
+ pEntry->GetExpression(rPos, 1));
}
else if(eMode <= ScConditionMode::NotEqual || eMode >= ScConditionMode::BeginsWith)
{
aBuffer.append(pEntry->GetExpression(rPos, 0));
}
}
aBuffer.append(pEntry->GetExpression(rPos, 0) + " " + ScResId(STR_COND_AND)
+ " " + pEntry->GetExpression(rPos, 1));
}
break;
case ScFormatEntry::Type::Databar:
aBuffer.append(getTextForType(DATABAR));
break;
case ScFormatEntry::Type::Colorscale:
aBuffer.append(getTextForType(COLORSCALE));
break;
case ScFormatEntry::Type::Iconset:
aBuffer.append(getTextForType(ICONSET));
break;
case ScFormatEntry::Type::Date:
else if (eMode <= ScConditionMode::NotEqual || eMode >= ScConditionMode::BeginsWith)
{
sal_Int32 nDateEntry = static_cast<sal_Int32>(static_cast<const ScCondDateFormatEntry*>(rFormat.GetEntry(0))->GetDateType());
aBuffer.append(getTextForType(DATE)
+ " "
+ getDateString(nDateEntry));
aBuffer.append(pEntry->GetExpression(rPos, 0));
}
break;
}
}
break;
case ScFormatEntry::Type::Databar:
aBuffer.append(getTextForType(DATABAR));
break;
case ScFormatEntry::Type::Colorscale:
aBuffer.append(getTextForType(COLORSCALE));
break;
case ScFormatEntry::Type::Iconset:
aBuffer.append(getTextForType(ICONSET));
break;
case ScFormatEntry::Type::Date:
{
sal_Int32 nDateEntry = static_cast<sal_Int32>(
static_cast<const ScCondDateFormatEntry*>(rEntry)->GetDateType());
aBuffer.append(getTextForType(DATE) + " " + getDateString(nDateEntry));
}
break;
}
return aBuffer.makeStringAndClear();
}
OUString ScCondFormatHelper::GetExpression(const ScConditionalFormat& rFormat,
const ScAddress& rPos)
{
if (!rFormat.IsEmpty())
{
return ScCondFormatHelper::GetExpression(rFormat.GetEntry(0), rPos);
}
return "";
}
OUString ScCondFormatHelper::GetExpression( ScCondFormatEntryType eType, sal_Int32 nIndex,
std::u16string_view aStr1, std::u16string_view aStr2 )
{
+35 -12
View File
@@ -22,7 +22,19 @@
#include <svl/intitem.hxx>
#include <svl/stritem.hxx>
#include <unotools/viewoptions.hxx>
#include <iostream>
#include <o3tl/string_view.hxx>
namespace
{
OUString generateEntryId(sal_uInt32 key, sal_uInt32 index)
{
return OUString::number(key) + "_" + OUString::number(index);
}
sal_Int32 getKeyFromId(std::u16string_view id) { return o3tl::toInt32(o3tl::getToken(id, 0, '_')); }
sal_Int32 getEntryIndexFromId(std::u16string_view id) { return o3tl::toInt32(o3tl::getToken(id, 1, '_')); }
}
ScCondFormatManagerWindow::ScCondFormatManagerWindow(weld::TreeView& rTreeView,
ScDocument& rDoc, ScConditionalFormatList* pFormatList)
@@ -51,9 +63,14 @@ void ScCondFormatManagerWindow::Init()
{
const ScRangeList& aRange = rItem->GetRange();
aRange.Format(sRangeStr, ScRefFlags::VALID, mrDoc, mrDoc.GetAddressConvention());
mrTreeView.append(OUString::number(rItem->GetKey()), sRangeStr);
mrTreeView.set_text(nRow, ScCondFormatHelper::GetExpression(*rItem, aRange.GetTopLeftCorner()), 1);
++nRow;
for (size_t i = 0; i < rItem->size(); i++)
{
mrTreeView.append(generateEntryId(rItem->GetKey(), i), sRangeStr);
mrTreeView.set_text(nRow++,
ScCondFormatHelper::GetExpression(rItem->GetEntry(i),
aRange.GetTopLeftCorner()),
1);
}
}
}
@@ -81,8 +98,19 @@ ScConditionalFormat* ScCondFormatManagerWindow::GetSelection()
if (nEntry == -1)
return nullptr;
sal_Int32 nIndex = mrTreeView.get_id(nEntry).toInt32();
return mpFormatList->GetFormat(nIndex);
sal_Int32 nKey = getKeyFromId(mrTreeView.get_id(nEntry));
return mpFormatList->GetFormat(nKey);
}
const ScFormatEntry* ScCondFormatManagerWindow::GetSelectedEntry()
{
OUString id = mrTreeView.get_selected_id();
if (id.isEmpty())
return nullptr;
sal_Int32 nKey = getKeyFromId(id);
sal_Int32 nEntryIndex = getEntryIndexFromId(id);
return mpFormatList->GetFormat(nKey)->GetEntry(nEntryIndex);
}
void ScCondFormatManagerWindow::setColSizes()
@@ -252,12 +280,7 @@ IMPL_LINK_NOARG(ScCondFormatManagerDlg, ComboHdl, weld::ComboBox&, void)
IMPL_LINK_NOARG(ScCondFormatManagerDlg, EntryFocus, weld::TreeView&, void)
{
ScConditionalFormat* conditionFrmt = m_xCtrlManager->GetSelection();
if (!conditionFrmt)
return;
const ScFormatEntry* entry = conditionFrmt->GetEntry(0);
const ScFormatEntry* entry = m_xCtrlManager->GetSelectedEntry();
if (!entry)
return;
auto type = entry->GetType();
+2
View File
@@ -14,6 +14,7 @@
#include <svx/fntctrl.hxx>
class ScConditionalFormat;
class ScFormatEntry;
enum ScCondFormatEntryType
{
@@ -28,6 +29,7 @@ enum ScCondFormatEntryType
class ScCondFormatHelper
{
public:
static SC_DLLPUBLIC OUString GetExpression(const ScFormatEntry* rEntry, const ScAddress& rPos);
static SC_DLLPUBLIC OUString GetExpression(const ScConditionalFormat& rFormat, const ScAddress& rPos);
static SC_DLLPUBLIC OUString GetExpression( ScCondFormatEntryType eType, sal_Int32 nIndex,
+2
View File
@@ -15,6 +15,7 @@
class ScDocument;
class ScConditionalFormat;
class ScConditionalFormatList;
class ScFormatEntry;
class ScCondFormatManagerWindow
{
@@ -31,6 +32,7 @@ public:
void DeleteSelection();
ScConditionalFormat* GetSelection();
const ScFormatEntry* GetSelectedEntry();
};
class ScCondFormatManagerDlg : public weld::GenericDialogController
+1 -1
View File
@@ -139,7 +139,7 @@
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
<property name="resizable">True</property>
<property name="spacing">6</property>
<property name="title" translatable="yes" context="condformatmanager|STR_HEADER_FIRST_CONDITION">First Condition</property>
<property name="title" translatable="yes" context="condformatmanager|STR_HEADER_FIRST_CONDITION">Condition</property>
<child>
<object class="GtkCellRendererText" id="cellrenderer2"/>
<attributes>