From 20350c7f1085b0a73191e318e14f2dbd69553e0b Mon Sep 17 00:00:00 2001 From: Pranam Lashkari Date: Wed, 26 Jun 2024 00:07:23 +0100 Subject: sc: tdf#162475 manage conditional format with simpler dialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit now we can add new conitions for formating from manage conditional formating dialog Change-Id: I69660f108068a64e66301d62a61c485c81e8b97b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169322 Tested-by: Jenkins CollaboraOffice Reviewed-by: Szymon Kłos Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170910 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- 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 | 32 +++++++++++++ sc/source/ui/inc/condformateasydlg.hxx | 1 + sc/source/ui/inc/condformatmgr.hxx | 3 ++ sc/source/ui/view/cellsh1.cxx | 7 +-- sc/source/ui/view/cellsh3.cxx | 13 +++++- sc/uiconfig/scalc/ui/condformatmanager.ui | 66 +++++++++++++++++++++++++-- 14 files changed, 156 insertions(+), 25 deletions(-) (limited to 'sc') diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 17d75b0b4240..6b5ada729d07 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -225,6 +225,19 @@ 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 { @@ -466,7 +479,7 @@ private: std::unique_ptr pExtDocOptions; // for import etc. std::unique_ptr mpClipOptions; // clipboard options std::unique_ptr pConsolidateDlgData; - std::unique_ptr pConditionalFormatDialogMode; + ScConditionEasyDialogData pConditionalFormatDialogData; std::unique_ptr pAutoNameCache; // for automatic name lookup during CompileXML @@ -714,8 +727,11 @@ public: void SetConsolidateDlgData( std::unique_ptr pData ); const ScConsolidateParam* GetConsolidateDlgData() const { return pConsolidateDlgData.get(); } - void SetEasyConditionalFormatDialogData(std::unique_ptr pMode); - const ScConditionMode* GetEasyConditionalFormatDialogData() const { return pConditionalFormatDialogMode.get(); } + void SetEasyConditionalFormatDialogData(const ScConditionEasyDialogData& data); + ScConditionEasyDialogData GetEasyConditionalFormatDialogData() const + { + return pConditionalFormatDialogData; + } void Clear( bool bFromDestructor = false ); diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx index 40cf91404518..7ff8b9ca5471 100644 --- a/sc/inc/scabstdlg.hxx +++ b/sc/inc/scabstdlg.hxx @@ -93,6 +93,7 @@ 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 453a9ff48eb5..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): @@ -53,9 +54,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'], '2') + self.assertEqual(list_state['Children'], '3') - self.assertEqual(conditional_format_list.getLength(), 2) + self.assertEqual(conditional_format_list.getLength(), 3) # close the conditional format manager xCancelBtn = xCondFormatMgr.getChild("cancel") diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi index 44e87cd69119..8908dc424e23 100644 --- a/sc/sdi/cellsh.sdi +++ b/sc/sdi/cellsh.sdi @@ -219,7 +219,8 @@ interface CellSelection SID_POPUP_EASY_CONDITIONAL_FORMAT [] SfxVoidItem ConditionalFormatEasy SID_EASY_CONDITIONAL_FORMAT_DIALOG ( - SfxInt16Item FormatRule FN_PARAM_1 + SfxInt16Item FormatRule FN_PARAM_1, + SfxBoolItem Managed FN_PARAM_2 ) [ ExecMethod = Execute; diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index e1455e735e88..f7f5d0be02ea 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -1185,9 +1185,10 @@ void ScDocument::SetConsolidateDlgData( std::unique_ptr pDat pConsolidateDlgData = std::move(pData); } -void ScDocument::SetEasyConditionalFormatDialogData(std::unique_ptr pMode) +void ScDocument::SetEasyConditionalFormatDialogData(const ScConditionEasyDialogData& data) { - pConditionalFormatDialogMode = std::move(pMode); + pConditionalFormatDialogData.Mode = data.Mode; + pConditionalFormatDialogData.IsManaged = data.IsManaged; } void ScDocument::SetChangeViewSettings(const ScChangeViewSettings& rNew) diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx index 79f725011804..80abea22829e 100644 --- a/sc/source/ui/attrdlg/scdlgfact.cxx +++ b/sc/source/ui/attrdlg/scdlgfact.cxx @@ -739,6 +739,11 @@ 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 e1c2d0f52df3..3c57277a54d2 100644 --- a/sc/source/ui/attrdlg/scdlgfact.hxx +++ b/sc/source/ui/attrdlg/scdlgfact.hxx @@ -116,6 +116,7 @@ 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 a7a3d6907306..cbab60c26ee4 100644 --- a/sc/source/ui/condformat/condformateasydlg.cxx +++ b/sc/source/ui/condformat/condformateasydlg.cxx @@ -49,6 +49,7 @@ ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings, u"CondFormatEasyDlg"_ustr) , mpViewData(pViewData) , mpDocument(&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)) @@ -60,9 +61,9 @@ ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings, , mxButtonCancel(m_xBuilder->weld_button(u"cancel"_ustr)) { mxButtonRangeEdit->SetReferences(this, mxRangeEntry.get()); - const ScConditionMode* pCurrentMode + const ScConditionEasyDialogData CurrentData = pViewData->GetDocument().GetEasyConditionalFormatDialogData(); - if (!pCurrentMode) + if (!CurrentData.Mode) { SAL_WARN( "sc", @@ -71,7 +72,8 @@ ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings, } else { - meMode = *pCurrentMode; + meMode = *CurrentData.Mode; + mbIsManaged = CurrentData.IsManaged; } mxNumberEntry2->hide(); switch (meMode) @@ -188,7 +190,14 @@ ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings, mxStyles->set_active(1); } -ConditionalFormatEasyDialog::~ConditionalFormatEasyDialog() {} +ConditionalFormatEasyDialog::~ConditionalFormatEasyDialog() +{ + if (mbIsManaged) + { + GetBindings().GetDispatcher()->Execute(SID_OPENDLG_CONDFRMT_MANAGER, + SfxCallMode::ASYNCHRON); + } +} void ConditionalFormatEasyDialog::Notify(SfxBroadcaster&, const SfxHint& rHint) { diff --git a/sc/source/ui/condformat/condformatmgr.cxx b/sc/source/ui/condformat/condformatmgr.cxx index 5a445c2abde0..16456d7fd7b6 100644 --- a/sc/source/ui/condformat/condformatmgr.cxx +++ b/sc/source/ui/condformat/condformatmgr.cxx @@ -8,11 +8,18 @@ */ #include +#include #include #include #include #include +#include #include +#include +#include +#include +#include +#include #include ScCondFormatManagerWindow::ScCondFormatManagerWindow(weld::TreeView& rTreeView, @@ -89,6 +96,8 @@ ScCondFormatManagerDlg::ScCondFormatManagerDlg(weld::Window* pParent, ScDocument : GenericDialogController(pParent, u"modules/scalc/ui/condformatmanager.ui"_ustr, 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)) @@ -133,6 +142,29 @@ ScConditionalFormat* ScCondFormatManagerDlg::GetCondFormatSelected() return m_xCtrlManager->GetSelection(); } +void ScCondFormatManagerDlg::ShowEasyConditionalDialog() +{ + if (!SfxViewShell::Current()) + 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 ad7501c1bd3b..a9d27c9a1001 100644 --- a/sc/source/ui/inc/condformateasydlg.hxx +++ b/sc/source/ui/inc/condformateasydlg.hxx @@ -39,6 +39,7 @@ private: ScViewData* mpViewData; ScDocument* mpDocument; 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 ca9f16e8a55f..51a251416b27 100644 --- a/sc/source/ui/inc/condformatmgr.hxx +++ b/sc/source/ui/inc/condformatmgr.hxx @@ -44,11 +44,14 @@ 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 0746215ee8ab..2848bac154fa 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -2940,12 +2940,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) } else if(nRet == DLG_RET_ADD) { - // 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 ); + pDlg->ShowEasyConditionalDialog(); } else if (nRet == DLG_RET_EDIT) { diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx index dfb7b4d5e92b..e6f07d92423d 100644 --- a/sc/source/ui/view/cellsh3.cxx +++ b/sc/source/ui/view/cellsh3.cxx @@ -456,11 +456,20 @@ void ScCellShell::Execute( SfxRequest& rReq ) const SfxPoolItem* pFormat; if (pReqArgs->HasItem( FN_PARAM_1, &pFormat)) { - sal_Int16 nFormat = static_cast(pFormat)->GetValue(); + ScConditionMode nFormat = static_cast( + static_cast(pFormat)->GetValue()); sal_uInt16 nId = sc::ConditionalFormatEasyDialogWrapper::GetChildWindowId(); SfxViewFrame& rViewFrame = pTabViewShell->GetViewFrame(); SfxChildWindow* pWindow = rViewFrame.GetChildWindow( nId ); - GetViewData().GetDocument().SetEasyConditionalFormatDialogData(std::make_unique(static_cast(nFormat))); + const SfxPoolItem* pManaged; + bool bManaged = false; + if (pReqArgs->HasItem(FN_PARAM_2, &pManaged)) + { + bManaged = static_cast(pManaged)->GetValue(); + } + + GetViewData().GetDocument().SetEasyConditionalFormatDialogData( + ScConditionEasyDialogData(&nFormat, bManaged)); pScMod->SetRefDialog( nId, pWindow == nullptr ); } diff --git a/sc/uiconfig/scalc/ui/condformatmanager.ui b/sc/uiconfig/scalc/ui/condformatmanager.ui index c9aead73ba61..74ea3d33bda9 100644 --- a/sc/uiconfig/scalc/ui/condformatmanager.ui +++ b/sc/uiconfig/scalc/ui/condformatmanager.ui @@ -163,11 +163,67 @@ - + True False 12 - start + + + 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 + + Add @@ -183,7 +239,7 @@ False True - 0 + 2 @@ -201,7 +257,7 @@ False True - 1 + 3 @@ -219,7 +275,7 @@ False True - 2 + 4 -- cgit