diff options
author | Pranam Lashkari <lpranam@collabora.com> | 2024-06-26 00:07:23 +0100 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2024-06-28 18:09:18 +0200 |
commit | 58c3f70c514ef4ce0de5419ab7daa3bebfb96f37 (patch) | |
tree | 9a0b9133c0ea24dc5ae146052b65d32e8d3e76ff | |
parent | 3e28c7a6ab7ca6182446d66902c3685bd2435b5c (diff) |
sc: manage conditional format with simpler dialog
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 <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
-rw-r--r-- | sc/inc/document.hxx | 22 | ||||
-rw-r--r-- | sc/inc/scabstdlg.hxx | 1 | ||||
-rw-r--r-- | sc/qa/uitest/conditional_format/tdf96453.py | 5 | ||||
-rw-r--r-- | sc/sdi/cellsh.sdi | 3 | ||||
-rw-r--r-- | sc/source/core/data/documen2.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/attrdlg/scdlgfact.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/attrdlg/scdlgfact.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/condformat/condformateasydlg.cxx | 16 | ||||
-rw-r--r-- | sc/source/ui/condformat/condformatmgr.cxx | 34 | ||||
-rw-r--r-- | sc/source/ui/inc/condformateasydlg.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/inc/condformatmgr.hxx | 3 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh1.cxx | 7 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh3.cxx | 13 | ||||
-rw-r--r-- | sc/uiconfig/scalc/ui/condformatmanager.ui | 66 |
14 files changed, 155 insertions, 27 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 52fd5a4a509f..6915415bc4f5 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -212,6 +212,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 { @@ -426,7 +439,7 @@ private: std::unique_ptr<ScExtDocOptions> pExtDocOptions; // for import etc. std::unique_ptr<ScClipOptions> mpClipOptions; // clipboard options std::unique_ptr<ScConsolidateParam> pConsolidateDlgData; - std::unique_ptr<ScConditionMode> pConditionalFormatDialogMode; + ScConditionEasyDialogData pConditionalFormatDialogData; std::unique_ptr<ScAutoNameCache> pAutoNameCache; // for automatic name lookup during CompileXML @@ -654,8 +667,11 @@ public: void SetConsolidateDlgData( std::unique_ptr<ScConsolidateParam> pData ); const ScConsolidateParam* GetConsolidateDlgData() const { return pConsolidateDlgData.get(); } - void SetEasyConditionalFormatDialogData(std::unique_ptr<ScConditionMode> 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 7a94af5f6fe9..6ea7a913c88c 100644 --- a/sc/inc/scabstdlg.hxx +++ b/sc/inc/scabstdlg.hxx @@ -93,6 +93,7 @@ public: virtual std::unique_ptr<ScConditionalFormatList> 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 7370d142607e..d5398737c8e9 100644 --- a/sc/sdi/cellsh.sdi +++ b/sc/sdi/cellsh.sdi @@ -215,7 +215,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 1fac12dbebba..cc939eba38a4 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -1170,9 +1170,10 @@ void ScDocument::SetConsolidateDlgData( std::unique_ptr<ScConsolidateParam> pDat pConsolidateDlgData = std::move(pData); } -void ScDocument::SetEasyConditionalFormatDialogData(std::unique_ptr<ScConditionMode> 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 7fe3435d1bce..bc8422d0fc3e 100644 --- a/sc/source/ui/attrdlg/scdlgfact.cxx +++ b/sc/source/ui/attrdlg/scdlgfact.cxx @@ -719,6 +719,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 880c1f153652..e2b27738f53a 100644 --- a/sc/source/ui/attrdlg/scdlgfact.hxx +++ b/sc/source/ui/attrdlg/scdlgfact.hxx @@ -115,6 +115,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 2e0b0b0815a3..e796b83eddb6 100644 --- a/sc/source/ui/condformat/condformateasydlg.cxx +++ b/sc/source/ui/condformat/condformateasydlg.cxx @@ -59,9 +59,9 @@ ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings, , mxButtonCancel(m_xBuilder->weld_button("cancel")) { mxButtonRangeEdit->SetReferences(this, mxRangeEntry.get()); - const ScConditionMode* pCurrentMode + const ScConditionEasyDialogData CurrentData = pViewData->GetDocument().GetEasyConditionalFormatDialogData(); - if (!pCurrentMode) + if (!CurrentData.Mode) { SAL_WARN( "sc", @@ -70,7 +70,8 @@ ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings, } else { - meMode = *pCurrentMode; + meMode = *CurrentData.Mode; + mbIsManaged = CurrentData.IsManaged; } mxNumberEntry2->hide(); switch (meMode) @@ -187,7 +188,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 31e16ab8c08c..d77e57b79f85 100644 --- a/sc/source/ui/condformat/condformatmgr.cxx +++ b/sc/source/ui/condformat/condformatmgr.cxx @@ -8,11 +8,18 @@ */ #include <condformatmgr.hxx> +#include <condformateasydlg.hxx> #include <condformathelper.hxx> #include <condformatdlg.hxx> #include <document.hxx> #include <conditio.hxx> +#include <sc.hrc> #include <o3tl/safeint.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/sfxsids.hrc> +#include <sfx2/viewsh.hxx> +#include <svl/eitem.hxx> +#include <svl/intitem.hxx> #include <unotools/viewoptions.hxx> ScCondFormatManagerWindow::ScCondFormatManagerWindow(weld::TreeView& rTreeView, @@ -85,10 +92,13 @@ void ScCondFormatManagerWindow::setColSizes() mrTreeView.set_column_fixed_widths(aWidths); } -ScCondFormatManagerDlg::ScCondFormatManagerDlg(weld::Window* pParent, ScDocument& rDoc, const ScConditionalFormatList* pFormatList) +ScCondFormatManagerDlg::ScCondFormatManagerDlg(weld::Window* pParent, ScDocument& rDoc, + const ScConditionalFormatList* pFormatList) : GenericDialogController(pParent, "modules/scalc/ui/condformatmanager.ui", "CondFormatManager") , m_bModified(false) - , m_xFormatList( pFormatList ? new ScConditionalFormatList(*pFormatList) : nullptr) + , 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("add")) , m_xBtnRemove(m_xBuilder->weld_button("remove")) , m_xBtnEdit(m_xBuilder->weld_button("edit")) @@ -133,6 +143,26 @@ ScConditionalFormat* ScCondFormatManagerDlg::GetCondFormatSelected() return m_xCtrlManager->GetSelection(); } +void ScCondFormatManagerDlg::ShowEasyConditionalDialog() +{ + 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<weld::Entry> 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<ScConditionalFormatList> m_xFormatList; + std::unique_ptr<weld::ComboBox> m_xConditionalType; + std::unique_ptr<weld::ComboBox> m_xConditionalCellValue; std::unique_ptr<weld::Button> m_xBtnAdd; std::unique_ptr<weld::Button> m_xBtnRemove; std::unique_ptr<weld::Button> m_xBtnEdit; diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index dfdcb2281251..500ad80f0781 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -2924,12 +2924,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->GetPool().DirectPutItemInPool(ScCondFormatDlgItem( - std::shared_ptr<ScConditionalFormatList>(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 b7bd2daa4450..e5ef913e3ff9 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<const SfxInt16Item*>(pFormat)->GetValue(); + ScConditionMode nFormat = static_cast<ScConditionMode>( + static_cast<const SfxInt16Item*>(pFormat)->GetValue()); sal_uInt16 nId = sc::ConditionalFormatEasyDialogWrapper::GetChildWindowId(); SfxViewFrame& rViewFrame = pTabViewShell->GetViewFrame(); SfxChildWindow* pWindow = rViewFrame.GetChildWindow( nId ); - GetViewData().GetDocument().SetEasyConditionalFormatDialogData(std::make_unique<ScConditionMode>(static_cast<ScConditionMode>(nFormat))); + const SfxPoolItem* pManaged; + bool bManaged = false; + if (pReqArgs->HasItem(FN_PARAM_2, &pManaged)) + { + bManaged = static_cast<const SfxBoolItem*>(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 @@ </packing> </child> <child> - <object class="GtkButtonBox" id="buttonbox2"> + <object class="GtkBox" id="buttonbox2"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">12</property> - <property name="layout_style">start</property> + <child> + <object class="GtkComboBoxText" id="type"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="active">0</property> + <items> + <item translatable="yes" context="condformatmanager|typex">Cell value</item> + <item translatable="yes" context="condformatmanager|typex">Formula is</item> + <item translatable="yes" context="condformatmanager|typex">Date is</item> + </items> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="typeis"> + <property name="can_focus">False</property> + <property name="visible">True</property> + <property name="no_show_all">True</property> + <property name="active">0</property> + <items> + <item translatable="yes" context="condformatmanager|typeis" id="0">is equal to</item> + <item translatable="yes" context="condformatmanager|typeis" id="1">is less than</item> + <item translatable="yes" context="condformatmanager|typeis" id="2">is greater than</item> + <item translatable="yes" context="condformatmanager|typeis" id="3">is less than or equal to</item> + <item translatable="yes" context="condformatmanager|typeis" id="4">is greater than or equal to</item> + <item translatable="yes" context="condformatmanager|typeis" id="5">is not equal to</item> + <item translatable="yes" context="condformatmanager|typeis" id="6">is between</item> + <item translatable="yes" context="condformatmanager|typeis" id="7">is not between</item> + <item translatable="yes" context="condformatmanager|typeis" id="8">is duplicate</item> + <item translatable="yes" context="condformatmanager|typeis" id="9">is not duplicate</item> + <!-- <item translatable="yes" context="condformatmanager|typeis" id="10" >is direct</item> --> + <item translatable="yes" context="condformatmanager|typeis" id="11">is in top N elements</item> + <item translatable="yes" context="condformatmanager|typeis" id="12">is in bottom N elements</item> + <item translatable="yes" context="condformatmanager|typeis" id="13">is in top N percent</item> + <item translatable="yes" context="condformatmanager|typeis" id="14">is in bottom N percent</item> + <item translatable="yes" context="condformatmanager|typeis" id="15">is above average</item> + <item translatable="yes" context="condformatmanager|typeis" id="16">is below average</item> + <item translatable="yes" context="condformatmanager|typeis" id="17">is above or equal average</item> + <item translatable="yes" context="condformatmanager|typeis" id="18">is below or equal average</item> + <item translatable="yes" context="condformatmanager|typeis" id="19">is error</item> + <item translatable="yes" context="condformatmanager|typeis" id="20">is not error</item> + <item translatable="yes" context="condformatmanager|typeis" id="21">begins with</item> + <item translatable="yes" context="condformatmanager|typeis" id="22">ends with</item> + <item translatable="yes" context="condformatmanager|typeis" id="23">contains</item> + <item translatable="yes" context="condformatmanager|typeis" id="24">does not contain</item> + </items> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> <child> <object class="GtkButton" id="add"> <property name="label" translatable="yes" context="condformatmanager|add">Add</property> @@ -183,7 +239,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">0</property> + <property name="position">2</property> </packing> </child> <child> @@ -201,7 +257,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">1</property> + <property name="position">3</property> </packing> </child> <child> @@ -219,7 +275,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">2</property> + <property name="position">4</property> </packing> </child> </object> |