From f643a98b2b60ccad63f7b4647ff6bc0141df0718 Mon Sep 17 00:00:00 2001 From: Pranam Lashkari Date: Mon, 25 Nov 2024 19:47:26 +0530 Subject: [PATCH] Revert "sc: manage conditional format with simpler dialog" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 58c3f70c514ef4ce0de5419ab7daa3bebfb96f37. Change-Id: I500a96508684547c158cdd1814540a4b24f667d9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177290 Reviewed-by: Caolán McNamara Tested-by: Jenkins CollaboraOffice Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177341 Tested-by: Jenkins --- sc/inc/document.hxx | 22 ++----- sc/inc/scabstdlg.hxx | 1 - sc/qa/uitest/conditional_format/tdf96453.py | 5 +- sc/sdi/cellsh.sdi | 3 +- sc/source/core/data/documen2.cxx | 5 +- sc/source/ui/attrdlg/scdlgfact.cxx | 5 -- sc/source/ui/attrdlg/scdlgfact.hxx | 1 - sc/source/ui/condformat/condformateasydlg.cxx | 17 ++--- sc/source/ui/condformat/condformatmgr.cxx | 33 ---------- sc/source/ui/inc/condformateasydlg.hxx | 1 - sc/source/ui/inc/condformatmgr.hxx | 3 - sc/source/ui/view/cellsh1.cxx | 12 +++- sc/source/ui/view/cellsh3.cxx | 15 ++--- sc/uiconfig/scalc/ui/condformatmanager.ui | 66 ++----------------- 14 files changed, 32 insertions(+), 157 deletions(-) diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 678652e47fe7..7908be80dcc7 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -225,20 +225,6 @@ struct ScSheetLimits; struct ScDataAreaExtras; enum class ScConditionMode; -struct ScConditionEasyDialogData -{ - ScConditionMode* Mode = nullptr; - bool IsManaged : 1 = false; - - ScConditionEasyDialogData(ScConditionMode* mode, bool isManaged) - : Mode(mode) - , IsManaged(isManaged) - { - } - - ScConditionEasyDialogData() {} -}; - namespace sc { typedef std::map IconSetBitmapMap; @@ -479,7 +465,7 @@ private: std::unique_ptr pExtDocOptions; // for import etc. std::unique_ptr mpClipOptions; // clipboard options std::unique_ptr pConsolidateDlgData; - ScConditionEasyDialogData pConditionalFormatDialogData; + std::unique_ptr pConditionalFormatDialogMode; std::unique_ptr pAutoNameCache; // for automatic name lookup during CompileXML @@ -727,10 +713,10 @@ public: void SetConsolidateDlgData( std::unique_ptr pData ); const ScConsolidateParam* GetConsolidateDlgData() const { return pConsolidateDlgData.get(); } - void SetEasyConditionalFormatDialogData(const ScConditionEasyDialogData& data); - const ScConditionEasyDialogData & GetEasyConditionalFormatDialogData() const + void SetEasyConditionalFormatDialogData(std::unique_ptr pMode); + const ScConditionMode* GetEasyConditionalFormatDialogData() const { - return pConditionalFormatDialogData; + return pConditionalFormatDialogMode.get(); } void Clear( bool bFromDestructor = false ); diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx index eeb1061fa1d2..245869363f2e 100644 --- a/sc/inc/scabstdlg.hxx +++ b/sc/inc/scabstdlg.hxx @@ -93,7 +93,6 @@ public: virtual std::unique_ptr GetConditionalFormatList() = 0; virtual bool CondFormatsChanged() const = 0; - virtual void ShowEasyConditionalDialog() = 0; virtual void SetModified() = 0; diff --git a/sc/qa/uitest/conditional_format/tdf96453.py b/sc/qa/uitest/conditional_format/tdf96453.py index 50ba86e51eec..453a9ff48eb5 100644 --- a/sc/qa/uitest/conditional_format/tdf96453.py +++ b/sc/qa/uitest/conditional_format/tdf96453.py @@ -11,7 +11,6 @@ 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): @@ -54,9 +53,9 @@ class ConditionalFormatDlgTest(UITestCase): # and still only 2 conditional formats 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'], '2') - self.assertEqual(conditional_format_list.getLength(), 3) + self.assertEqual(conditional_format_list.getLength(), 2) # close the conditional format manager xCancelBtn = xCondFormatMgr.getChild("cancel") diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi index 8908dc424e23..44e87cd69119 100644 --- a/sc/sdi/cellsh.sdi +++ b/sc/sdi/cellsh.sdi @@ -219,8 +219,7 @@ interface CellSelection SID_POPUP_EASY_CONDITIONAL_FORMAT [] SfxVoidItem ConditionalFormatEasy SID_EASY_CONDITIONAL_FORMAT_DIALOG ( - SfxInt16Item FormatRule FN_PARAM_1, - SfxBoolItem Managed FN_PARAM_2 + SfxInt16Item FormatRule FN_PARAM_1 ) [ ExecMethod = Execute; diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index bab0668a38e9..3890a5194e85 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -1185,10 +1185,9 @@ void ScDocument::SetConsolidateDlgData( std::unique_ptr pDat pConsolidateDlgData = std::move(pData); } -void ScDocument::SetEasyConditionalFormatDialogData(const ScConditionEasyDialogData& data) +void ScDocument::SetEasyConditionalFormatDialogData(std::unique_ptr pMode) { - pConditionalFormatDialogData.Mode = data.Mode; - pConditionalFormatDialogData.IsManaged = data.IsManaged; + pConditionalFormatDialogMode = std::move(pMode); } void ScDocument::SetChangeViewSettings(const ScChangeViewSettings& rNew) diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx index e70283b4b5ce..c088322f01a2 100644 --- a/sc/source/ui/attrdlg/scdlgfact.cxx +++ b/sc/source/ui/attrdlg/scdlgfact.cxx @@ -739,11 +739,6 @@ ScConditionalFormat* AbstractScCondFormatManagerDlg_Impl::GetCondFormatSelected( return m_xDlg->GetCondFormatSelected(); } -void AbstractScCondFormatManagerDlg_Impl::ShowEasyConditionalDialog() -{ - m_xDlg->ShowEasyConditionalDialog(); -} - int AbstractScMetricInputDlg_Impl::GetInputValue() const { return m_xDlg->GetInputValue(); diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx index 7e9761180ef9..fe60d59bc8e6 100644 --- a/sc/source/ui/attrdlg/scdlgfact.hxx +++ b/sc/source/ui/attrdlg/scdlgfact.hxx @@ -116,7 +116,6 @@ public: virtual bool CondFormatsChanged() const override; virtual void SetModified() 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 bf745747fee4..71ae8745df53 100644 --- a/sc/source/ui/condformat/condformateasydlg.cxx +++ b/sc/source/ui/condformat/condformateasydlg.cxx @@ -58,7 +58,6 @@ ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings, u"CondFormatEasyDlg"_ustr) , mpViewData(pViewData) , mrDocument(mpViewData->GetDocument()) - , mbIsManaged(false) , mxNumberEntry(m_xBuilder->weld_entry(u"entryNumber"_ustr)) , mxNumberEntry2(m_xBuilder->weld_entry(u"entryNumber2"_ustr)) , mxAllInputs(m_xBuilder->weld_container(u"allInputs"_ustr)) @@ -70,9 +69,9 @@ ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings, , mxButtonCancel(m_xBuilder->weld_button(u"cancel"_ustr)) { mxButtonRangeEdit->SetReferences(this, mxRangeEntry.get()); - const ScConditionEasyDialogData CurrentData + const ScConditionMode* pCurrentMode = pViewData->GetDocument().GetEasyConditionalFormatDialogData(); - if (!CurrentData.Mode) + if (!pCurrentMode) { SAL_WARN( "sc", @@ -81,8 +80,7 @@ ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings, } else { - meMode = *CurrentData.Mode; - mbIsManaged = CurrentData.IsManaged; + meMode = *pCurrentMode; } mxNumberEntry2->hide(); switch (meMode) @@ -199,14 +197,7 @@ ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings, mxStyles->set_active(1); } -ConditionalFormatEasyDialog::~ConditionalFormatEasyDialog() -{ - if (mbIsManaged) - { - GetBindings().GetDispatcher()->Execute(SID_OPENDLG_CONDFRMT_MANAGER, - SfxCallMode::ASYNCHRON); - } -} +ConditionalFormatEasyDialog::~ConditionalFormatEasyDialog() {} void ConditionalFormatEasyDialog::Notify(SfxBroadcaster&, const SfxHint& rHint) { diff --git a/sc/source/ui/condformat/condformatmgr.cxx b/sc/source/ui/condformat/condformatmgr.cxx index 9ddae34551a3..2e5cef3a01a0 100644 --- a/sc/source/ui/condformat/condformatmgr.cxx +++ b/sc/source/ui/condformat/condformatmgr.cxx @@ -8,18 +8,11 @@ */ #include -#include #include #include #include #include -#include #include -#include -#include -#include -#include -#include #include ScCondFormatManagerWindow::ScCondFormatManagerWindow(weld::TreeView& rTreeView, @@ -99,8 +92,6 @@ ScCondFormatManagerDlg::ScCondFormatManagerDlg(weld::Window* pParent, ScDocument u"CondFormatManager"_ustr) , m_bModified(false) , m_xFormatList(pFormatList ? new ScConditionalFormatList(*pFormatList) : nullptr) - , m_xConditionalType(m_xBuilder->weld_combo_box("type")) - , m_xConditionalCellValue(m_xBuilder->weld_combo_box("typeis")) , m_xBtnAdd(m_xBuilder->weld_button(u"add"_ustr)) , m_xBtnRemove(m_xBuilder->weld_button(u"remove"_ustr)) , m_xBtnEdit(m_xBuilder->weld_button(u"edit"_ustr)) @@ -145,30 +136,6 @@ ScConditionalFormat* ScCondFormatManagerDlg::GetCondFormatSelected() return m_xCtrlManager->GetSelection(); } -void ScCondFormatManagerDlg::ShowEasyConditionalDialog() -{ - SfxViewShell* pViewShell = SfxViewShell::Current(); - if (!pViewShell) - return; - - auto id = m_xConditionalType->get_active(); - switch (id) - { - case 0: // Cell value - { - SfxInt16Item FormatRule(FN_PARAM_1, - m_xConditionalCellValue->get_active_id().toUInt32()); - SfxBoolItem IsManaged(FN_PARAM_2, true); - SfxViewShell::Current()->GetDispatcher()->ExecuteList( - SID_EASY_CONDITIONAL_FORMAT_DIALOG, SfxCallMode::ASYNCHRON, - { &FormatRule, &IsManaged }); - } - break; - default: - break; - } -} - IMPL_LINK_NOARG(ScCondFormatManagerDlg, RemoveBtnHdl, weld::Button&, void) { m_xCtrlManager->DeleteSelection(); diff --git a/sc/source/ui/inc/condformateasydlg.hxx b/sc/source/ui/inc/condformateasydlg.hxx index 772312040c88..933d2e51e207 100644 --- a/sc/source/ui/inc/condformateasydlg.hxx +++ b/sc/source/ui/inc/condformateasydlg.hxx @@ -39,7 +39,6 @@ private: ScViewData* mpViewData; ScDocument& mrDocument; ScConditionMode meMode; - bool mbIsManaged; ScAddress maPosition; std::unique_ptr mxNumberEntry; diff --git a/sc/source/ui/inc/condformatmgr.hxx b/sc/source/ui/inc/condformatmgr.hxx index 51a251416b27..ca9f16e8a55f 100644 --- a/sc/source/ui/inc/condformatmgr.hxx +++ b/sc/source/ui/inc/condformatmgr.hxx @@ -44,14 +44,11 @@ public: void SetModified(); ScConditionalFormat* GetCondFormatSelected(); - void ShowEasyConditionalDialog(); private: bool m_bModified; std::unique_ptr m_xFormatList; - std::unique_ptr m_xConditionalType; - std::unique_ptr m_xConditionalCellValue; std::unique_ptr m_xBtnAdd; std::unique_ptr m_xBtnRemove; std::unique_ptr m_xBtnEdit; diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 331ba8a5efca..4b94a67eed1a 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -2944,7 +2944,16 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) } else if (nRet == DLG_RET_ADD) { - pDlg->ShowEasyConditionalDialog(); + // Put the xml string parameter to initialize the + // Conditional Format Dialog. ( add new ) + pTabViewShell->setScCondFormatDlgItem( + std::make_shared( + std::shared_ptr( + pCondFormatList.release()), + -1, true)); + // Queue message to open Conditional Format Dialog + GetViewData().GetDispatcher().Execute(SID_OPENDLG_CONDFRMT, + SfxCallMode::ASYNCHRON); } else if (nRet == DLG_RET_EDIT) { @@ -2957,7 +2966,6 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) std::shared_ptr( pCondFormatList.release()), nIndex, true)); - // Queue message to open Conditional Format Dialog GetViewData().GetDispatcher().Execute(SID_OPENDLG_CONDFRMT, SfxCallMode::ASYNCHRON); diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx index 98a67f26e32a..033ecf8982cb 100644 --- a/sc/source/ui/view/cellsh3.cxx +++ b/sc/source/ui/view/cellsh3.cxx @@ -456,20 +456,13 @@ void ScCellShell::Execute( SfxRequest& rReq ) const SfxPoolItem* pFormat; if (pReqArgs->HasItem( FN_PARAM_1, &pFormat)) { - ScConditionMode nFormat = static_cast( - static_cast(pFormat)->GetValue()); + sal_Int16 nFormat = static_cast(pFormat)->GetValue(); sal_uInt16 nId = sc::ConditionalFormatEasyDialogWrapper::GetChildWindowId(); SfxViewFrame& rViewFrame = pTabViewShell->GetViewFrame(); - SfxChildWindow* pWindow = rViewFrame.GetChildWindow( nId ); - const SfxPoolItem* pManaged; - bool bManaged = false; - if (pReqArgs->HasItem(FN_PARAM_2, &pManaged)) - { - bManaged = static_cast(pManaged)->GetValue(); - } - + SfxChildWindow* pWindow = rViewFrame.GetChildWindow(nId); GetViewData().GetDocument().SetEasyConditionalFormatDialogData( - ScConditionEasyDialogData(&nFormat, bManaged)); + std::make_unique( + static_cast(nFormat))); pScMod->SetRefDialog( nId, pWindow == nullptr ); } diff --git a/sc/uiconfig/scalc/ui/condformatmanager.ui b/sc/uiconfig/scalc/ui/condformatmanager.ui index 74ea3d33bda9..c9aead73ba61 100644 --- a/sc/uiconfig/scalc/ui/condformatmanager.ui +++ b/sc/uiconfig/scalc/ui/condformatmanager.ui @@ -163,67 +163,11 @@ - + True False 12 - - - True - False - 0 - - Cell value - Formula is - Date is - - - - True - True - 0 - - - - - False - True - True - 0 - - is equal to - is less than - is greater than - is less than or equal to - is greater than or equal to - is not equal to - is between - is not between - is duplicate - is not duplicate - - is in top N elements - is in bottom N elements - is in top N percent - is in bottom N percent - is above average - is below average - is above or equal average - is below or equal average - is error - is not error - begins with - ends with - contains - does not contain - - - - True - True - 1 - - + start Add @@ -239,7 +183,7 @@ False True - 2 + 0 @@ -257,7 +201,7 @@ False True - 3 + 1 @@ -275,7 +219,7 @@ False True - 4 + 2