sc/inc/document.hxx                           |    7 -
 sc/inc/scabstdlg.hxx                          |    4 -
 sc/qa/uitest/conditional_format/tdf100793.py  |   13 +--
 sc/qa/uitest/conditional_format/tdf105544.py  |    4 -
 sc/qa/uitest/conditional_format/tdf96453.py   |    1 
 sc/qa/uitest/pasteSpecial/tdf86253.py         |    2 
 sc/sdi/cellsh.sdi                             |    4 -
 sc/source/core/data/documen2.cxx              |    2 
 sc/source/ui/attrdlg/scdlgfact.cxx            |    9 +-
 sc/source/ui/attrdlg/scdlgfact.hxx            |    3 
 sc/source/ui/condformat/condformateasydlg.cxx |   49 -------------
 sc/source/ui/condformat/condformathelper.cxx  |   89 ++++++++++++------------
 sc/source/ui/condformat/condformatmgr.cxx     |   93 ++++++++------------------
 sc/source/ui/inc/condformateasydlg.hxx        |    2 
 sc/source/ui/inc/condformathelper.hxx         |    2 
 sc/source/ui/inc/condformatmgr.hxx            |    7 -
 sc/source/ui/view/cellsh1.cxx                 |   16 +++-
 sc/source/ui/view/cellsh3.cxx                 |   13 ---
 sc/uiconfig/scalc/ui/condformatmanager.ui     |    2 
 19 files changed, 119 insertions(+), 203 deletions(-)

New commits:
commit 70b9e65eae31abcc5d88773565059ba8dae44468
Author:     Pranam Lashkari <[email protected]>
AuthorDate: Mon Nov 25 19:43:44 2024 +0530
Commit:     Pranam Lashkari <[email protected]>
CommitDate: Tue Dec 3 16:08:11 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]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177336
    Tested-by: Jenkins

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 fa39f3bfebfe..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 separate 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 39e183278666..95d54756bcac 100644
--- a/sc/source/ui/condformat/condformathelper.cxx
+++ b/sc/source/ui/condformat/condformathelper.cxx
@@ -137,67 +137,64 @@ 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)
+            case ScFormatEntry::Type::Condition:
+            case ScFormatEntry::Type::ExtCondition:
             {
-                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(pEntry->GetExpression(rPos, 0) + " " + 
ScResId(STR_COND_AND)
-                                   + " " + pEntry->GetExpression(rPos, 1));
+                    aBuffer.append(getTextForType(FORMULA) + " " + 
pEntry->GetExpression(rPos, 0));
                 }
-                else if (eMode <= ScConditionMode::NotEqual || eMode >= 
ScConditionMode::BeginsWith)
+                else
                 {
-                    aBuffer.append(pEntry->GetExpression(rPos, 0));
+                    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));
+                    }
+                }
                 }
-            }
-        }
 
-        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;
+                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*>(rFormat.GetEntry(0))
+                            ->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 bf79fc2cf849..c74087daa5a2 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,10 @@ 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 +82,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()
@@ -281,7 +254,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 1098b56e4663..1a2379ad2d57 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>
commit 36108acc124efd73a5e69f5780e8e8220cf0875c
Author:     Pranam Lashkari <[email protected]>
AuthorDate: Mon Nov 25 19:42:55 2024 +0530
Commit:     Pranam Lashkari <[email protected]>
CommitDate: Tue Dec 3 16:08:04 2024 +0100

    Revert "sc: now conditions can be edited from easy conditional format 
dialog"
    
    This reverts commit 8115c82f1f7f2621e2d99c93e1a3b2196279602a.
    
    Change-Id: Ie3f389561ee8f734ac76b3dec352382281f91c30
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177284
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177335
    Tested-by: Pranam Lashkari <[email protected]>

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index b1e80798410b..e7d67bc7d4b0 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -229,16 +229,11 @@ struct ScConditionEasyDialogData
 {
     ScConditionMode* Mode = nullptr;
     bool IsManaged : 1 = false;
-    sal_Int32 FormatKey = -1;
-    sal_Int32 EntryIndex = -1;
     OUString Formula;
 
-    ScConditionEasyDialogData(ScConditionMode* mode, bool isManaged, sal_Int32 
formatKey,
-                              sal_Int32 entryIndex, const OUString& formula = 
"")
+    ScConditionEasyDialogData(ScConditionMode* mode, bool isManaged, const 
OUString& formula = "")
         : Mode(mode)
         , IsManaged(isManaged)
-        , FormatKey(formatKey)
-        , EntryIndex(entryIndex)
         , Formula(formula)
     {
     }
diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index 1d297a58f22b..eeb1061fa1d2 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -93,9 +93,11 @@ public:
     virtual std::unique_ptr<ScConditionalFormatList> 
GetConditionalFormatList() = 0;
 
     virtual bool CondFormatsChanged() const = 0;
-    virtual void ShowEasyConditionalDialog(bool isEdit = false) = 0;
+    virtual void ShowEasyConditionalDialog() = 0;
 
     virtual void SetModified() = 0;
+
+    virtual ScConditionalFormat* GetCondFormatSelected() = 0;
 };
 
 class AbstractScDataPilotDatabaseDlg  :public VclAbstractDialog
diff --git a/sc/qa/uitest/conditional_format/tdf100793.py 
b/sc/qa/uitest/conditional_format/tdf100793.py
index b7d253ea2ba4..f0d2c3854db7 100644
--- a/sc/qa/uitest/conditional_format/tdf100793.py
+++ b/sc/qa/uitest/conditional_format/tdf100793.py
@@ -5,6 +5,7 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
 
 from uitest.framework import UITestCase
 from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file
@@ -38,7 +39,7 @@ class tdf100793(UITestCase):
                 with self.ui_test.execute_dialog_through_action(xEditBtn, 
"CLICK", event_name = "ModelessDialogVisible") as xCondFormatDlg:
 
                     #modify textbox
-                    xedassign = xCondFormatDlg.getChild("entryRange")
+                    xedassign = xCondFormatDlg.getChild("edassign")
                     #go at the beginning
                     xedassign.executeAction("TYPE", 
mkPropertyValues({"KEYCODE": "END"}))
                     xedassign.executeAction("TYPE", 
mkPropertyValues({"KEYCODE": "HOME"}))
@@ -66,7 +67,7 @@ class tdf100793(UITestCase):
                 list_state = get_state_as_dict(xList)
                 self.assertEqual(list_state['Children'], '3')
 
-                self.assertEqual(conditional_format_list.getLength(), 2)
+                self.assertEqual(conditional_format_list.getLength(), 1)
 
                 # close the conditional format manager
                 xOKBtn = xCondFormatMgr.getChild("ok")
@@ -74,11 +75,9 @@ class tdf100793(UITestCase):
 
             #verify - reopen, check range
             with 
self.ui_test.execute_dialog_through_command(".uno:ConditionalFormatManagerDialog",
 close_button="") as xCondFormatMgr:
-                xCondFormatMgr.getChild("CONTAINER").executeAction("TYPE", 
mkPropertyValues({"KEYCODE": "DOWN"}))
-                xCondFormatMgr.getChild("CONTAINER").executeAction("TYPE", 
mkPropertyValues({"KEYCODE": "DOWN"}))
                 xEditBtn = xCondFormatMgr.getChild("edit")
                 with self.ui_test.execute_dialog_through_action(xEditBtn, 
"CLICK", event_name = "ModelessDialogVisible") as xCondFormatDlg:
-                    xedassign = xCondFormatDlg.getChild("entryRange")
+                    xedassign = xCondFormatDlg.getChild("edassign")
                     self.assertEqual(get_state_as_dict(xedassign)["Text"], 
"G18:K29,F18:K33,F20:F29")
 
                 xCondFormatMgr = self.xUITest.getTopFocusWindow()
diff --git a/sc/qa/uitest/conditional_format/tdf96453.py 
b/sc/qa/uitest/conditional_format/tdf96453.py
index bcb602ad3452..50ba86e51eec 100644
--- a/sc/qa/uitest/conditional_format/tdf96453.py
+++ b/sc/qa/uitest/conditional_format/tdf96453.py
@@ -11,6 +11,7 @@ from uitest.framework import UITestCase
 from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file
 from libreoffice.calc.document import get_sheet_from_doc
 from libreoffice.calc.conditional_format import 
get_conditional_format_from_sheet
+import sys
 
 class ConditionalFormatDlgTest(UITestCase):
 
diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi
index 6e39cda9a7c3..017e26028376 100644
--- a/sc/sdi/cellsh.sdi
+++ b/sc/sdi/cellsh.sdi
@@ -221,9 +221,7 @@ interface CellSelection
     (
         SfxInt16Item FormatRule FN_PARAM_1,
         SfxBoolItem  Managed FN_PARAM_2,
-        SfxInt32Item FormatKey FN_PARAM_3,
-        SfxInt32Item EntryIndex FN_PARAM_4,
-        SfxStringItem Formula FN_PARAM_5
+        SfxStringItem Formula FN_PARAM_3
     )
     [
         ExecMethod = Execute;
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 2fe0a63ec09a..aca2b03e0148 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -1190,8 +1190,6 @@ void ScDocument::SetEasyConditionalFormatDialogData(const 
ScConditionEasyDialogD
     pConditionalFormatDialogData.Mode = data.Mode;
     pConditionalFormatDialogData.IsManaged = data.IsManaged;
     pConditionalFormatDialogData.Formula = data.Formula;
-    pConditionalFormatDialogData.FormatKey = data.FormatKey;
-    pConditionalFormatDialogData.EntryIndex = data.EntryIndex;
 }
 
 void ScDocument::SetChangeViewSettings(const ScChangeViewSettings& rNew)
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx 
b/sc/source/ui/attrdlg/scdlgfact.cxx
index 9f8c1a32bae2..e70283b4b5ce 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -734,9 +734,14 @@ void AbstractScCondFormatManagerDlg_Impl::SetModified()
     return m_xDlg->SetModified();
 }
 
-void AbstractScCondFormatManagerDlg_Impl::ShowEasyConditionalDialog(bool 
isEdit)
+ScConditionalFormat* 
AbstractScCondFormatManagerDlg_Impl::GetCondFormatSelected()
 {
-    m_xDlg->ShowEasyConditionalDialog(isEdit);
+    return m_xDlg->GetCondFormatSelected();
+}
+
+void AbstractScCondFormatManagerDlg_Impl::ShowEasyConditionalDialog()
+{
+    m_xDlg->ShowEasyConditionalDialog();
 }
 
 int AbstractScMetricInputDlg_Impl::GetInputValue() const
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx 
b/sc/source/ui/attrdlg/scdlgfact.hxx
index 77cd3e217cf7..7e9761180ef9 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -115,7 +115,8 @@ public:
     virtual std::unique_ptr<ScConditionalFormatList> 
GetConditionalFormatList() override;
     virtual bool CondFormatsChanged() const override;
     virtual void SetModified() override;
-    virtual void ShowEasyConditionalDialog(bool isEdit = false) override;
+    virtual ScConditionalFormat* GetCondFormatSelected() override;
+    virtual void ShowEasyConditionalDialog() override;
 };
 
 class AbstractScDataPilotDatabaseDlg_Impl  :public 
AbstractScDataPilotDatabaseDlg
diff --git a/sc/source/ui/condformat/condformateasydlg.cxx 
b/sc/source/ui/condformat/condformateasydlg.cxx
index 372db3791df5..51f79ff31108 100644
--- a/sc/source/ui/condformat/condformateasydlg.cxx
+++ b/sc/source/ui/condformat/condformateasydlg.cxx
@@ -73,8 +73,6 @@ 
ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings,
     , mpViewData(pViewData)
     , mrDocument(mpViewData->GetDocument())
     , mbIsManaged(false)
-    , mnFormatKey(0)
-    , mnEntryIndex(0)
     , mxNumberEntry(m_xBuilder->weld_entry(u"entryNumber"_ustr))
     , mxNumberEntry2(m_xBuilder->weld_entry(u"entryNumber2"_ustr))
     , mxAllInputs(m_xBuilder->weld_container(u"allInputs"_ustr))
@@ -103,8 +101,6 @@ 
ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings,
         meMode = *CurrentData.Mode;
         mbIsManaged = CurrentData.IsManaged;
         msFormula = CurrentData.Formula;
-        mnFormatKey = CurrentData.FormatKey;
-        mnEntryIndex = CurrentData.EntryIndex;
     }
     mxNumberEntry2->hide();
     switch (meMode)
@@ -263,21 +259,12 @@ 
ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings,
 
     ScRangeList aRange;
     mpViewData->GetMarkData().FillRangeListWithMarks(&aRange, false);
-    ScConditionalFormat* format
-        = 
mrDocument.GetCondFormList(mpViewData->GetTabNo())->GetFormat(mnFormatKey);
-    if (aRange.empty() && mnFormatKey != -1 && mnEntryIndex != -1)
-    {
-        aRange = format->GetRangeList();
-    }
-    else if (aRange.empty())
+    if (aRange.empty())
     {
         ScAddress aPosition(mpViewData->GetCurX(), mpViewData->GetCurY(), 
mpViewData->GetTabNo());
         aRange.push_back(ScRange(aPosition));
     }
     maPosition = aRange.GetTopLeftCorner();
-    // FIX me: Tab is always 0 in some cases
-    // Refer to test tdf100793
-    maPosition.SetTab(mpViewData->GetTabNo());
 
     OUString sRangeString;
     aRange.Format(sRangeString, ScRefFlags::VALID, mrDocument, 
mrDocument.GetAddressConvention());
@@ -335,11 +322,6 @@ IMPL_LINK(ConditionalFormatEasyDialog, ButtonPressed, 
weld::Button&, rButton, vo
 {
     if (&rButton == mxButtonOk.get())
     {
-        if (mnEntryIndex != -1 && mnFormatKey != -1) // isEdit
-            mrDocument.GetCondFormList(maPosition.Tab())
-                ->GetFormat(mnFormatKey)
-                ->RemoveEntry(mnEntryIndex);
-
         std::unique_ptr<ScConditionalFormat> pFormat(new 
ScConditionalFormat(0, &mrDocument));
 
         OUString sExpression1 = (mxNumberEntry->get_visible() && 
mxAllInputs->get_visible()
diff --git a/sc/source/ui/condformat/condformatmgr.cxx 
b/sc/source/ui/condformat/condformatmgr.cxx
index f5add41fda9d..bf79fc2cf849 100644
--- a/sc/source/ui/condformat/condformatmgr.cxx
+++ b/sc/source/ui/condformat/condformatmgr.cxx
@@ -102,30 +102,15 @@ ScConditionalFormat* 
ScCondFormatManagerWindow::GetSelection()
     return mpFormatList->GetFormat(nKey);
 }
 
-const ScFormatEntry* ScCondFormatManagerWindow::GetSelectedEntry() const
-{
-    sal_Int32 nKey = GetSelectedFormatKey();
-    sal_Int32 nEntryIndex = GetSelectedEntryIndex();
-
-    if (nKey == -1 || nEntryIndex == -1)
-        return nullptr;
-    return mpFormatList->GetFormat(nKey)->GetEntry(nEntryIndex);
-}
-
-sal_Int32 ScCondFormatManagerWindow::GetSelectedFormatKey() const
+const ScFormatEntry* ScCondFormatManagerWindow::GetSelectedEntry()
 {
     OUString id = mrTreeView.get_selected_id();
     if (id.isEmpty())
-        return -1;
-    return getKeyFromId(id);
-}
+        return nullptr;
 
-sal_Int32 ScCondFormatManagerWindow::GetSelectedEntryIndex() const
-{
-    OUString id = mrTreeView.get_selected_id();
-    if (id.isEmpty())
-        return -1;
-    return getEntryIndexFromId(id);
+    sal_Int32 nKey = getKeyFromId(id);
+    sal_Int32 nEntryIndex = getEntryIndexFromId(id);
+    return mpFormatList->GetFormat(nKey)->GetEntry(nEntryIndex);
 }
 
 void ScCondFormatManagerWindow::setColSizes()
@@ -163,7 +148,6 @@ 
ScCondFormatManagerDlg::ScCondFormatManagerDlg(weld::Window* pParent, ScDocument
         m_xDialog->set_window_state(aDlgOpt.GetWindowState());
 
     UpdateButtonSensitivity();
-    EntryFocus(*m_xTreeView);
 }
 
 ScCondFormatManagerDlg::~ScCondFormatManagerDlg()
@@ -185,7 +169,14 @@ void ScCondFormatManagerDlg::UpdateButtonSensitivity()
     m_xBtnEdit->set_sensitive(bNewSensitivity);
 }
 
-void ScCondFormatManagerDlg::ShowEasyConditionalDialog(bool isEdit)
+// Get the current conditional format selected.
+//
+ScConditionalFormat* ScCondFormatManagerDlg::GetCondFormatSelected()
+{
+    return m_xCtrlManager->GetSelection();
+}
+
+void ScCondFormatManagerDlg::ShowEasyConditionalDialog()
 {
     SfxViewShell* pViewShell = SfxViewShell::Current();
     if (!pViewShell)
@@ -193,34 +184,32 @@ void 
ScCondFormatManagerDlg::ShowEasyConditionalDialog(bool isEdit)
 
     auto id = m_xConditionalType->get_active();
     SfxBoolItem IsManaged(FN_PARAM_2, true);
-    SfxInt32Item FormatKey(FN_PARAM_3, isEdit ? 
m_xCtrlManager->GetSelectedFormatKey() : -1);
-    SfxInt32Item EntryIndex(FN_PARAM_4, isEdit ? 
m_xCtrlManager->GetSelectedEntryIndex() : -1);
     switch (id)
     {
         case 0: // Cell value
         {
             SfxInt16Item FormatRule(FN_PARAM_1,
                                     
m_xConditionalCellValue->get_active_id().toUInt32());
-            pViewShell->GetDispatcher()->ExecuteList(
-                SID_EASY_CONDITIONAL_FORMAT_DIALOG, SfxCallMode::ASYNCHRON,
-                { &FormatRule, &IsManaged, &FormatKey, &EntryIndex });
+            
pViewShell->GetDispatcher()->ExecuteList(SID_EASY_CONDITIONAL_FORMAT_DIALOG,
+                                                     SfxCallMode::ASYNCHRON,
+                                                     { &FormatRule, &IsManaged 
});
         }
         break;
         case 1: // Formula
         {
             SfxInt16Item FormatRule(FN_PARAM_1, 
static_cast<sal_Int16>(ScConditionMode::Formula));
-            SfxStringItem Formula(FN_PARAM_5, 
m_xConditionalFormula->GetText());
-            pViewShell->GetDispatcher()->ExecuteList(
+            SfxStringItem Formula(FN_PARAM_3, 
m_xConditionalFormula->GetText());
+            SfxViewShell::Current()->GetDispatcher()->ExecuteList(
                 SID_EASY_CONDITIONAL_FORMAT_DIALOG, SfxCallMode::ASYNCHRON,
-                { &FormatRule, &IsManaged, &FormatKey, &EntryIndex, &Formula 
});
+                { &FormatRule, &IsManaged, &Formula });
         }
         break;
         case 2: // Date
         {
             SfxInt16Item FormatRule(FN_PARAM_1, 
m_xConditionalDate->get_active_id().toUInt32());
-            pViewShell->GetDispatcher()->ExecuteList(
-                SID_EASY_CONDITIONAL_FORMAT_DIALOG, SfxCallMode::ASYNCHRON,
-                { &FormatRule, &IsManaged, &FormatKey, &EntryIndex });
+            
pViewShell->GetDispatcher()->ExecuteList(SID_EASY_CONDITIONAL_FORMAT_DIALOG,
+                                                     SfxCallMode::ASYNCHRON,
+                                                     { &FormatRule, &IsManaged 
});
         }
         break;
         default:
diff --git a/sc/source/ui/inc/condformateasydlg.hxx 
b/sc/source/ui/inc/condformateasydlg.hxx
index 6dfa19c37752..e2824539fd5f 100644
--- a/sc/source/ui/inc/condformateasydlg.hxx
+++ b/sc/source/ui/inc/condformateasydlg.hxx
@@ -46,8 +46,6 @@ private:
     bool mbIsManaged;
     OUString msFormula;
     ScAddress maPosition;
-    sal_Int32 mnFormatKey;
-    sal_Int32 mnEntryIndex;
 
     SvxFontPrevWindow maWdPreview;
     std::unique_ptr<weld::Entry> mxNumberEntry;
diff --git a/sc/source/ui/inc/condformatmgr.hxx 
b/sc/source/ui/inc/condformatmgr.hxx
index 301f74499063..09b6c571e562 100644
--- a/sc/source/ui/inc/condformatmgr.hxx
+++ b/sc/source/ui/inc/condformatmgr.hxx
@@ -32,9 +32,7 @@ public:
 
     void DeleteSelection();
     ScConditionalFormat* GetSelection();
-    const ScFormatEntry* GetSelectedEntry() const;
-    sal_Int32 GetSelectedFormatKey() const;
-    sal_Int32 GetSelectedEntryIndex() const;
+    const ScFormatEntry* GetSelectedEntry();
 };
 
 class ScCondFormatManagerDlg : public weld::GenericDialogController
@@ -48,7 +46,8 @@ public:
     bool CondFormatsChanged() const;
     void SetModified();
 
-    void ShowEasyConditionalDialog(bool isEdit = false);
+    ScConditionalFormat* GetCondFormatSelected();
+    void ShowEasyConditionalDialog();
 
 private:
     bool m_bModified;
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 7593b037020c..331ba8a5efca 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2933,7 +2933,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                     pDlg->SetModified();
 
                 pDlg->StartExecuteAsync(
-                    [pDlg, &rData, pTabViewShell, rDlgItem, aPos](sal_Int32 
nRet)
+                    [this, pDlg, &rData, pTabViewShell, rDlgItem, 
aPos](sal_Int32 nRet)
                     {
                         std::unique_ptr<ScConditionalFormatList> 
pCondFormatList
                             = pDlg->GetConditionalFormatList();
@@ -2948,7 +2948,19 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                         }
                         else if (nRet == DLG_RET_EDIT)
                         {
-                            pDlg->ShowEasyConditionalDialog(true);
+                            ScConditionalFormat* pFormat = 
pDlg->GetCondFormatSelected();
+                            sal_Int32 nIndex = pFormat ? pFormat->GetKey() : 
-1;
+                            // Put the xml string parameter to initialize the
+                            // Conditional Format Dialog. ( edit selected 
conditional format )
+                            pTabViewShell->setScCondFormatDlgItem(
+                                std::make_shared<ScCondFormatDlgData>(
+                                    std::shared_ptr<ScConditionalFormatList>(
+                                        pCondFormatList.release()),
+                                    nIndex, true));
+
+                            // Queue message to open Conditional Format Dialog
+                            
GetViewData().GetDispatcher().Execute(SID_OPENDLG_CONDFRMT,
+                                                                  
SfxCallMode::ASYNCHRON);
                         }
                         else
                             pCondFormatList.reset();
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index 2e36d876bf33..6206ace72f65 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -470,22 +470,13 @@ void ScCellShell::Execute( SfxRequest& rReq )
 
                         const SfxPoolItem* pFormula;
                         OUString formula;
-                        if (pReqArgs->HasItem(FN_PARAM_5, &pFormula))
+                        if (pReqArgs->HasItem(FN_PARAM_3, &pFormula))
                         {
                             formula = static_cast<const 
SfxStringItem*>(pFormula)->GetValue();
                         }
-                        const SfxPoolItem *pFormatKey, *pEntryIndex;
-                        sal_Int32 nFormatKey = -1, nEntryIndex = -1;
-                        if (pReqArgs->HasItem(FN_PARAM_3, &pFormatKey)
-                            && pReqArgs->HasItem(FN_PARAM_4, &pEntryIndex))
-                        {
-                            nFormatKey = static_cast<const 
SfxInt32Item*>(pFormatKey)->GetValue();
-                            nEntryIndex = static_cast<const 
SfxInt32Item*>(pEntryIndex)->GetValue();
-                        }
 
                         
GetViewData().GetDocument().SetEasyConditionalFormatDialogData(
-                            ScConditionEasyDialogData(&nFormat, bManaged, 
nFormatKey, nEntryIndex,
-                                                      formula));
+                            ScConditionEasyDialogData(&nFormat, bManaged, 
formula));
 
                         pScMod->SetRefDialog( nId, pWindow == nullptr );
                     }
commit dcf48b9d2dab74412b024ec1a3c12a6348f0c5f1
Author:     Pranam Lashkari <[email protected]>
AuthorDate: Mon Nov 25 19:41:37 2024 +0530
Commit:     Pranam Lashkari <[email protected]>
CommitDate: Tue Dec 3 16:07:56 2024 +0100

    Revert "sc: prefill easy condition dialog with editing condition data"
    
    This reverts commit 598e93b1b11f4cdff96f6117c2a7d35f3698fd23.
    
    Change-Id: Ifdbc8920f232d388eac2a07cd6e2e2dece204a7a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177283
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177334
    Tested-by: Jenkins

diff --git a/sc/source/ui/condformat/condformateasydlg.cxx 
b/sc/source/ui/condformat/condformateasydlg.cxx
index 677d10c3b9d5..372db3791df5 100644
--- a/sc/source/ui/condformat/condformateasydlg.cxx
+++ b/sc/source/ui/condformat/condformateasydlg.cxx
@@ -283,35 +283,10 @@ 
ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings,
     aRange.Format(sRangeString, ScRefFlags::VALID, mrDocument, 
mrDocument.GetAddressConvention());
     mxRangeEntry->SetText(sRangeString);
 
-    OUString sStyleName;
-    if (format)
-    {
-        const ScFormatEntry* entry = format->GetEntry(mnEntryIndex);
-        if (!entry)
-            return;
-        ScFormatEntry::Type type = entry->GetType();
-        if (type == ScFormatEntry::Type::Condition)
-        {
-            const ScCondFormatEntry* condEntry = static_cast<const 
ScCondFormatEntry*>(entry);
-            sStyleName = condEntry->GetStyle();
-            if (mxNumberEntry->get_visible())
-                
mxNumberEntry->set_text(condEntry->GetExpression(aRange.GetTopLeftCorner(), 0));
-            if (mxNumberEntry2->get_visible())
-                
mxNumberEntry2->set_text(condEntry->GetExpression(aRange.GetTopLeftCorner(), 
1));
-        }
-        else if (type == ScFormatEntry::Type::Date)
-        {
-            const ScCondDateFormatEntry* dateEntry
-                = static_cast<const ScCondDateFormatEntry*>(entry);
-            sStyleName = dateEntry->GetStyleName();
-        }
-    }
-
-    StartListening(*mrDocument.GetStyleSheetPool(), 
DuplicateHandling::Prevent);
+    StartListening(*(mrDocument.GetStyleSheetPool()), 
DuplicateHandling::Prevent);
     ScCondFormatHelper::FillStyleListBox(mrDocument, *mxStyles);
 
-    mxStyles->set_active_text(sStyleName);
-    StyleSelectHdl(*mxStyles);
+    mxStyles->set_active(1);
     mxWdPreviewWin->show();
 }
 

Reply via email to