diff options
author | Pranam Lashkari <lpranam@collabora.com> | 2024-06-26 05:29:10 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-08-15 12:44:11 +0200 |
commit | 1e29baa755f2d46304563bb2d3578866b5d8364a (patch) | |
tree | 2c7bdf10248266d39b17684f04a2882d3268eb43 | |
parent | 723e035e1fbafdedf7ed64b8de4c14ef0ef038ea (diff) |
sc: now formula conditions can be managed from condition format manager
Change-Id: I52cab33f5486c835dd13720eff93b497331561ff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169536
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170912
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
-rw-r--r-- | sc/inc/document.hxx | 4 | ||||
-rw-r--r-- | sc/sdi/cellsh.sdi | 3 | ||||
-rw-r--r-- | sc/source/core/data/documen2.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/condformat/condformateasydlg.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/condformat/condformatmgr.cxx | 29 | ||||
-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/cellsh3.cxx | 9 | ||||
-rw-r--r-- | sc/uiconfig/scalc/ui/condformatmanager.ui | 1 |
9 files changed, 41 insertions, 15 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 6b5ada729d07..8cf3091a9b7b 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -229,10 +229,12 @@ struct ScConditionEasyDialogData { ScConditionMode* Mode = nullptr; bool IsManaged : 1 = false; + OUString Formula; - ScConditionEasyDialogData(ScConditionMode* mode, bool isManaged) + ScConditionEasyDialogData(ScConditionMode* mode, bool isManaged, const OUString& formula = "") : Mode(mode) , IsManaged(isManaged) + , Formula(formula) { } diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi index 8908dc424e23..017e26028376 100644 --- a/sc/sdi/cellsh.sdi +++ b/sc/sdi/cellsh.sdi @@ -220,7 +220,8 @@ interface CellSelection SfxVoidItem ConditionalFormatEasy SID_EASY_CONDITIONAL_FORMAT_DIALOG ( SfxInt16Item FormatRule FN_PARAM_1, - SfxBoolItem Managed FN_PARAM_2 + SfxBoolItem Managed FN_PARAM_2, + SfxStringItem Formula FN_PARAM_3 ) [ ExecMethod = Execute; diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index f7f5d0be02ea..e06be41b3419 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -1189,6 +1189,7 @@ void ScDocument::SetEasyConditionalFormatDialogData(const ScConditionEasyDialogD { pConditionalFormatDialogData.Mode = data.Mode; pConditionalFormatDialogData.IsManaged = data.IsManaged; + pConditionalFormatDialogData.Formula = data.Formula; } void ScDocument::SetChangeViewSettings(const ScChangeViewSettings& rNew) diff --git a/sc/source/ui/condformat/condformateasydlg.cxx b/sc/source/ui/condformat/condformateasydlg.cxx index dc80a085536e..fcf011efe06a 100644 --- a/sc/source/ui/condformat/condformateasydlg.cxx +++ b/sc/source/ui/condformat/condformateasydlg.cxx @@ -109,6 +109,7 @@ ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings, { meMode = *CurrentData.Mode; mbIsManaged = CurrentData.IsManaged; + msFormula = CurrentData.Formula; } mxNumberEntry2->hide(); switch (meMode) @@ -365,8 +366,8 @@ IMPL_LINK(ConditionalFormatEasyDialog, ButtonPressed, weld::Button&, rButton, vo } else if (meMode == ScConditionMode::Formula) { - pEntry = new ScCondFormatEntry(ScConditionMode::Direct, "", OUString(), *mpDocument, - maPosition, mxStyles->get_active_text()); + pEntry = new ScCondFormatEntry(ScConditionMode::Direct, msFormula, OUString(), + *mpDocument, maPosition, mxStyles->get_active_text()); } else { diff --git a/sc/source/ui/condformat/condformatmgr.cxx b/sc/source/ui/condformat/condformatmgr.cxx index f5441f4edf08..5dd7d2142b25 100644 --- a/sc/source/ui/condformat/condformatmgr.cxx +++ b/sc/source/ui/condformat/condformatmgr.cxx @@ -20,6 +20,7 @@ #include <sfx2/viewsh.hxx> #include <svl/eitem.hxx> #include <svl/intitem.hxx> +#include <svl/stritem.hxx> #include <unotools/viewoptions.hxx> #include <iostream> @@ -99,7 +100,7 @@ ScCondFormatManagerDlg::ScCondFormatManagerDlg(weld::Window* pParent, ScDocument , m_xFormatList( pFormatList ? new ScConditionalFormatList(*pFormatList) : nullptr) , m_xConditionalType(m_xBuilder->weld_combo_box("type")) , m_xConditionalCellValue(m_xBuilder->weld_combo_box("typeis")) - , m_xConditionalFormula(m_xBuilder->weld_entry("formula")) + , m_xConditionalFormula(new formula::RefEdit(m_xBuilder->weld_entry("formula"))) , m_xConditionalDate(m_xBuilder->weld_combo_box("datetype")) , m_xBtnAdd(m_xBuilder->weld_button(u"add"_ustr)) , m_xBtnRemove(m_xBuilder->weld_button(u"remove"_ustr)) @@ -168,9 +169,10 @@ void ScCondFormatManagerDlg::ShowEasyConditionalDialog() case 1: // Formula { SfxInt16Item FormatRule(FN_PARAM_1, static_cast<sal_Int16>(ScConditionMode::Formula)); + SfxStringItem Formula(FN_PARAM_3, m_xConditionalFormula->GetText()); SfxViewShell::Current()->GetDispatcher()->ExecuteList( SID_EASY_CONDITIONAL_FORMAT_DIALOG, SfxCallMode::ASYNCHRON, - { &FormatRule, &IsManaged }); + { &FormatRule, &IsManaged, &Formula }); } break; case 2: // Date @@ -225,21 +227,21 @@ IMPL_LINK_NOARG(ScCondFormatManagerDlg, ComboHdl, weld::ComboBox&, void) case 0: { m_xConditionalCellValue->set_visible(true); - m_xConditionalFormula->set_visible(false); + m_xConditionalFormula->GetWidget()->set_visible(false); m_xConditionalDate->set_visible(false); } break; case 1: { m_xConditionalCellValue->set_visible(false); - m_xConditionalFormula->set_visible(true); + m_xConditionalFormula->GetWidget()->set_visible(true); m_xConditionalDate->set_visible(false); } break; case 2: { m_xConditionalCellValue->set_visible(false); - m_xConditionalFormula->set_visible(false); + m_xConditionalFormula->GetWidget()->set_visible(false); m_xConditionalDate->set_visible(true); } break; @@ -264,9 +266,20 @@ IMPL_LINK_NOARG(ScCondFormatManagerDlg, EntryFocus, weld::TreeView&, void) { const ScCondFormatEntry* conditionEntry = dynamic_cast<const ScCondFormatEntry*>(entry); auto conditionType = conditionEntry->GetOperation(); - m_xConditionalType->set_active(0); - this->ComboHdl(*m_xConditionalType); - m_xConditionalCellValue->set_active(static_cast<int>(conditionType)); + + if (conditionType == ScConditionMode::Direct) // Formula conditions + { + m_xConditionalType->set_active(1); + this->ComboHdl(*m_xConditionalType); + m_xConditionalFormula->SetText( + conditionEntry->GetExpression(conditionEntry->GetSrcPos(), 0)); + } + else + { + m_xConditionalType->set_active(0); + this->ComboHdl(*m_xConditionalType); + m_xConditionalCellValue->set_active(static_cast<int>(conditionType)); + } } else if (type == ScFormatEntry::Type::Date) { diff --git a/sc/source/ui/inc/condformateasydlg.hxx b/sc/source/ui/inc/condformateasydlg.hxx index a9d27c9a1001..e9d2f24a80a9 100644 --- a/sc/source/ui/inc/condformateasydlg.hxx +++ b/sc/source/ui/inc/condformateasydlg.hxx @@ -40,6 +40,7 @@ private: ScDocument* mpDocument; ScConditionMode meMode; bool mbIsManaged; + OUString msFormula; 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 7361fb6830c7..26345d55894a 100644 --- a/sc/source/ui/inc/condformatmgr.hxx +++ b/sc/source/ui/inc/condformatmgr.hxx @@ -10,6 +10,7 @@ #pragma once #include <vcl/weld.hxx> +#include <formula/funcutl.hxx> class ScDocument; class ScConditionalFormat; @@ -52,7 +53,7 @@ private: std::unique_ptr<weld::ComboBox> m_xConditionalType; std::unique_ptr<weld::ComboBox> m_xConditionalCellValue; - std::unique_ptr<weld::Entry> m_xConditionalFormula; + std::unique_ptr<formula::RefEdit> m_xConditionalFormula; std::unique_ptr<weld::ComboBox> m_xConditionalDate; std::unique_ptr<weld::Button> m_xBtnAdd; std::unique_ptr<weld::Button> m_xBtnRemove; diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx index e6f07d92423d..ffced295b5be 100644 --- a/sc/source/ui/view/cellsh3.cxx +++ b/sc/source/ui/view/cellsh3.cxx @@ -468,8 +468,15 @@ void ScCellShell::Execute( SfxRequest& rReq ) bManaged = static_cast<const SfxBoolItem*>(pManaged)->GetValue(); } + const SfxPoolItem* pFormula; + OUString formula; + if (pReqArgs->HasItem(FN_PARAM_3, &pFormula)) + { + formula = static_cast<const SfxStringItem*>(pFormula)->GetValue(); + } + GetViewData().GetDocument().SetEasyConditionalFormatDialogData( - ScConditionEasyDialogData(&nFormat, bManaged)); + ScConditionEasyDialogData(&nFormat, bManaged, formula)); pScMod->SetRefDialog( nId, pWindow == nullptr ); } diff --git a/sc/uiconfig/scalc/ui/condformatmanager.ui b/sc/uiconfig/scalc/ui/condformatmanager.ui index b0ce20a5d756..f6bad84e5e7c 100644 --- a/sc/uiconfig/scalc/ui/condformatmanager.ui +++ b/sc/uiconfig/scalc/ui/condformatmanager.ui @@ -229,7 +229,6 @@ <property name="can-focus">True</property> <property name="no-show-all">True</property> <property name="hexpand">True</property> - <property name="visibility">False</property> <property name="truncate-multiline">True</property> <child internal-child="accessible"> <object class="AtkObject" id="formula-atkobject"> |