sc/qa/uitest/conditional_format/tdf100793.py | 4 - sc/qa/uitest/conditional_format/tdf105544.py | 4 - sc/qa/uitest/pasteSpecial/tdf86253.py | 2 sc/source/ui/condformat/condformathelper.cxx | 97 +++++++++++++-------------- sc/source/ui/condformat/condformatmgr.cxx | 47 +++---------- sc/source/ui/inc/condformathelper.hxx | 2 sc/source/ui/inc/condformatmgr.hxx | 2 sc/uiconfig/scalc/ui/condformatmanager.ui | 2 8 files changed, 67 insertions(+), 93 deletions(-)
New commits: commit 08f1fdc0c4fba34973a263ebac0acc81d66cdeb8 Author: Pranam Lashkari <[email protected]> AuthorDate: Mon Nov 25 19:43:44 2024 +0530 Commit: Caolán McNamara <[email protected]> CommitDate: Tue Nov 26 09:37:35 2024 +0100 Revert "sc: display all the conditions of same ranges ...in conditional format manager" This reverts commit 399253ca8ca391504ff1f6a3709fb41d438ce2d6. Change-Id: I3c0a79ee0a34364d0a51ab4736810f35efe4bfdc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177285 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/sc/qa/uitest/conditional_format/tdf100793.py b/sc/qa/uitest/conditional_format/tdf100793.py index f0d2c3854db7..692c3c8109b2 100644 --- a/sc/qa/uitest/conditional_format/tdf100793.py +++ b/sc/qa/uitest/conditional_format/tdf100793.py @@ -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'], '3') + self.assertEqual(list_state['Children'], '1') #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'], '3') + self.assertEqual(list_state['Children'], '1') self.assertEqual(conditional_format_list.getLength(), 1) diff --git a/sc/qa/uitest/conditional_format/tdf105544.py b/sc/qa/uitest/conditional_format/tdf105544.py index 3e5fd6730277..b172d4067a1d 100644 --- a/sc/qa/uitest/conditional_format/tdf105544.py +++ b/sc/qa/uitest/conditional_format/tdf105544.py @@ -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'], '5') + self.assertEqual(list_state['Children'], '4') #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'], '5') + self.assertEqual(list_state['Children'], '4') # close the conditional format manager xOKBtn = xCondFormatMgr.getChild("ok") diff --git a/sc/qa/uitest/pasteSpecial/tdf86253.py b/sc/qa/uitest/pasteSpecial/tdf86253.py index c405a24ccdfe..6e6e1bcd4983 100644 --- a/sc/qa/uitest/pasteSpecial/tdf86253.py +++ b/sc/qa/uitest/pasteSpecial/tdf86253.py @@ -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'], '2') # We can now display both condition seprate on same range + self.assertEqual(list_state['Children'], '1') xTreeEntry = xList.getChild('0') self.assertEqual(get_state_as_dict(xTreeEntry)["Text"], "A1:A6,C1:C17 Cell value >= 0") diff --git a/sc/source/ui/condformat/condformathelper.cxx b/sc/source/ui/condformat/condformathelper.cxx index a78047cdece2..24537dec69b3 100644 --- a/sc/source/ui/condformat/condformathelper.cxx +++ b/sc/source/ui/condformat/condformathelper.cxx @@ -138,67 +138,68 @@ OUString getDateString(sal_Int32 nIndex) } -OUString ScCondFormatHelper::GetExpression(const ScFormatEntry* rEntry, const ScAddress& rPos) +OUString ScCondFormatHelper::GetExpression(const ScConditionalFormat& rFormat, const ScAddress& rPos) { OUStringBuffer aBuffer; - switch (rEntry->GetType()) + if(!rFormat.IsEmpty()) { - case ScFormatEntry::Type::Condition: - case ScFormatEntry::Type::ExtCondition: + switch(rFormat.GetEntry(0)->GetType()) { - 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) + case ScFormatEntry::Type::Condition: + case ScFormatEntry::Type::ExtCondition: { - aBuffer.append(pEntry->GetExpression(rPos, 0) + " " + ScResId(STR_COND_AND) - + " " + pEntry->GetExpression(rPos, 1)); + 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)); + } + } } - else if (eMode <= ScConditionMode::NotEqual || eMode >= ScConditionMode::BeginsWith) + + 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: { - aBuffer.append(pEntry->GetExpression(rPos, 0)); + sal_Int32 nDateEntry = static_cast<sal_Int32>(static_cast<const ScCondDateFormatEntry*>(rFormat.GetEntry(0))->GetDateType()); + aBuffer.append(getTextForType(DATE) + + " " + + getDateString(nDateEntry)); } - } - } - - 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; } - 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 ) { diff --git a/sc/source/ui/condformat/condformatmgr.cxx b/sc/source/ui/condformat/condformatmgr.cxx index 13a4c49cfc79..09b68f457b39 100644 --- a/sc/source/ui/condformat/condformatmgr.cxx +++ b/sc/source/ui/condformat/condformatmgr.cxx @@ -22,19 +22,7 @@ #include <svl/intitem.hxx> #include <svl/stritem.hxx> #include <unotools/viewoptions.hxx> -#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, '_')); } -} +#include <iostream> ScCondFormatManagerWindow::ScCondFormatManagerWindow(weld::TreeView& rTreeView, ScDocument& rDoc, ScConditionalFormatList* pFormatList) @@ -63,14 +51,9 @@ void ScCondFormatManagerWindow::Init() { const ScRangeList& aRange = rItem->GetRange(); aRange.Format(sRangeStr, ScRefFlags::VALID, mrDoc, mrDoc.GetAddressConvention()); - 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); - } + mrTreeView.append(OUString::number(rItem->GetKey()), sRangeStr); + mrTreeView.set_text(nRow, ScCondFormatHelper::GetExpression(*rItem, aRange.GetTopLeftCorner()), 1); + ++nRow; } } @@ -98,19 +81,8 @@ ScConditionalFormat* ScCondFormatManagerWindow::GetSelection() if (nEntry == -1) return nullptr; - 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); + sal_Int32 nIndex = mrTreeView.get_id(nEntry).toInt32(); + return mpFormatList->GetFormat(nIndex); } void ScCondFormatManagerWindow::setColSizes() @@ -278,7 +250,12 @@ IMPL_LINK_NOARG(ScCondFormatManagerDlg, ComboHdl, weld::ComboBox&, void) IMPL_LINK_NOARG(ScCondFormatManagerDlg, EntryFocus, weld::TreeView&, void) { - const ScFormatEntry* entry = m_xCtrlManager->GetSelectedEntry(); + ScConditionalFormat* conditionFrmt = m_xCtrlManager->GetSelection(); + + if (!conditionFrmt) + return; + + const ScFormatEntry* entry = conditionFrmt->GetEntry(0); if (!entry) return; auto type = entry->GetType(); diff --git a/sc/source/ui/inc/condformathelper.hxx b/sc/source/ui/inc/condformathelper.hxx index f3bd7b2a2013..34c619db364a 100644 --- a/sc/source/ui/inc/condformathelper.hxx +++ b/sc/source/ui/inc/condformathelper.hxx @@ -14,7 +14,6 @@ #include <svx/fntctrl.hxx> class ScConditionalFormat; -class ScFormatEntry; enum ScCondFormatEntryType { @@ -29,7 +28,6 @@ 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, diff --git a/sc/source/ui/inc/condformatmgr.hxx b/sc/source/ui/inc/condformatmgr.hxx index 09b6c571e562..26345d55894a 100644 --- a/sc/source/ui/inc/condformatmgr.hxx +++ b/sc/source/ui/inc/condformatmgr.hxx @@ -15,7 +15,6 @@ class ScDocument; class ScConditionalFormat; class ScConditionalFormatList; -class ScFormatEntry; class ScCondFormatManagerWindow { @@ -32,7 +31,6 @@ public: void DeleteSelection(); ScConditionalFormat* GetSelection(); - const ScFormatEntry* GetSelectedEntry(); }; class ScCondFormatManagerDlg : public weld::GenericDialogController diff --git a/sc/uiconfig/scalc/ui/condformatmanager.ui b/sc/uiconfig/scalc/ui/condformatmanager.ui index 57a8b03ae3c1..a0160fa8aa67 100644 --- a/sc/uiconfig/scalc/ui/condformatmanager.ui +++ b/sc/uiconfig/scalc/ui/condformatmanager.ui @@ -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">Condition</property> + <property name="title" translatable="yes" context="condformatmanager|STR_HEADER_FIRST_CONDITION">First Condition</property> <child> <object class="GtkCellRendererText" id="cellrenderer2"/> <attributes>
