diff options
author | Pranam Lashkari <lpranam@collabora.com> | 2024-06-26 00:07:23 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-08-15 12:28:10 +0200 |
commit | 20350c7f1085b0a73191e318e14f2dbd69553e0b (patch) | |
tree | 56424d3e35758dc039003648ec76bf964ec23598 /sc | |
parent | f8da93d33ddadb6f60c385b5ee93a55d303d916f (diff) |
sc: tdf#162475 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>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170910
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sc')
-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 | 17 | ||||
-rw-r--r-- | sc/source/ui/condformat/condformatmgr.cxx | 32 | ||||
-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, 156 insertions, 25 deletions
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<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 @@ -714,8 +727,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 40cf91404518..7ff8b9ca5471 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 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<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 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 <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, @@ -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<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 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<ScCondFormatDlgData>( - 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 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<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> |