sc/inc/document.hxx | 12 -------- sc/inc/scabstdlg.hxx | 2 - sc/qa/uitest/conditional_format/tdf100793.py | 9 ++---- sc/qa/uitest/conditional_format/tdf96453.py | 1 sc/sdi/cellsh.sdi | 4 -- sc/source/core/data/documen2.cxx | 2 - sc/source/ui/attrdlg/scdlgfact.cxx | 4 +- sc/source/ui/attrdlg/scdlgfact.hxx | 2 - sc/source/ui/condformat/condformateasydlg.cxx | 20 ------------- sc/source/ui/condformat/condformatmgr.cxx | 38 ++++++-------------------- sc/source/ui/inc/condformateasydlg.hxx | 2 - sc/source/ui/inc/condformatmgr.hxx | 6 +--- sc/source/ui/view/cellsh1.cxx | 12 ++++++-- sc/source/ui/view/cellsh3.cxx | 13 +------- 14 files changed, 35 insertions(+), 92 deletions(-)
New commits: commit 529524cdb1847f40e0aebaa904f58e3f8a1bdde2 Author: Pranam Lashkari <[email protected]> AuthorDate: Mon Nov 25 19:42:55 2024 +0530 Commit: Caolán McNamara <[email protected]> CommitDate: Tue Nov 26 09:37:00 2024 +0100 Revert "sc: now conditions can be edited from easy conditional format dialog" This reverts commit 8115c82f1f7f2621e2d99c93e1a3b2196279602a. Change-Id: Ie3f389561ee8f734ac76b3dec352382281f91c30 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177284 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index ea956dbbaa97..0173a02766d4 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -216,8 +216,6 @@ struct ScConditionEasyDialogData { ScConditionMode* Mode = nullptr; bool IsManaged : 1 = false; - sal_Int32 FormatKey = -1; - sal_Int32 EntryIndex = -1; OUString Formula; ScConditionEasyDialogData(ScConditionMode* mode, bool isManaged, const OUString& formula = "") @@ -227,16 +225,6 @@ struct ScConditionEasyDialogData { } - ScConditionEasyDialogData(ScConditionMode* mode, bool isManaged, sal_Int32 formatKey, - sal_Int32 entryIndex, const OUString& formula = "") - : Mode(mode) - , IsManaged(isManaged) - , FormatKey(formatKey) - , EntryIndex(entryIndex) - , Formula(formula) - { - } - ScConditionEasyDialogData() {} }; diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx index bb758f4729a5..eec2414b503f 100644 --- a/sc/inc/scabstdlg.hxx +++ b/sc/inc/scabstdlg.hxx @@ -93,7 +93,7 @@ public: virtual std::unique_ptr<ScConditionalFormatList> GetConditionalFormatList() = 0; virtual bool CondFormatsChanged() const = 0; - virtual void ShowEasyConditionalDialog(bool isEdit = false) = 0; + virtual void ShowEasyConditionalDialog() = 0; virtual void SetModified() = 0; diff --git a/sc/qa/uitest/conditional_format/tdf100793.py b/sc/qa/uitest/conditional_format/tdf100793.py index b7d253ea2ba4..f0d2c3854db7 100644 --- a/sc/qa/uitest/conditional_format/tdf100793.py +++ b/sc/qa/uitest/conditional_format/tdf100793.py @@ -5,6 +5,7 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +# from uitest.framework import UITestCase from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file @@ -38,7 +39,7 @@ class tdf100793(UITestCase): with self.ui_test.execute_dialog_through_action(xEditBtn, "CLICK", event_name = "ModelessDialogVisible") as xCondFormatDlg: #modify textbox - xedassign = xCondFormatDlg.getChild("entryRange") + xedassign = xCondFormatDlg.getChild("edassign") #go at the beginning xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "END"})) xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "HOME"})) @@ -66,7 +67,7 @@ class tdf100793(UITestCase): list_state = get_state_as_dict(xList) self.assertEqual(list_state['Children'], '3') - self.assertEqual(conditional_format_list.getLength(), 2) + self.assertEqual(conditional_format_list.getLength(), 1) # close the conditional format manager xOKBtn = xCondFormatMgr.getChild("ok") @@ -74,11 +75,9 @@ class tdf100793(UITestCase): #verify - reopen, check range with self.ui_test.execute_dialog_through_command(".uno:ConditionalFormatManagerDialog", close_button="") as xCondFormatMgr: - xCondFormatMgr.getChild("CONTAINER").executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - xCondFormatMgr.getChild("CONTAINER").executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) xEditBtn = xCondFormatMgr.getChild("edit") with self.ui_test.execute_dialog_through_action(xEditBtn, "CLICK", event_name = "ModelessDialogVisible") as xCondFormatDlg: - xedassign = xCondFormatDlg.getChild("entryRange") + xedassign = xCondFormatDlg.getChild("edassign") self.assertEqual(get_state_as_dict(xedassign)["Text"], "G18:K29,F18:K33,F20:F29") xCondFormatMgr = self.xUITest.getTopFocusWindow() diff --git a/sc/qa/uitest/conditional_format/tdf96453.py b/sc/qa/uitest/conditional_format/tdf96453.py index bcb602ad3452..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): diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi index 8dcd11b63f36..d3d7a4dfec3d 100644 --- a/sc/sdi/cellsh.sdi +++ b/sc/sdi/cellsh.sdi @@ -220,9 +220,7 @@ interface CellSelection ( SfxInt16Item FormatRule FN_PARAM_1, SfxBoolItem Managed FN_PARAM_2, - SfxInt32Item FormatKey FN_PARAM_3, - SfxInt32Item EntryIndex FN_PARAM_4, - SfxStringItem Formula FN_PARAM_5 + SfxStringItem Formula FN_PARAM_3 ) [ ExecMethod = Execute; diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index ecc503b8cd30..9abcda14e745 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -1175,8 +1175,6 @@ void ScDocument::SetEasyConditionalFormatDialogData(const ScConditionEasyDialogD pConditionalFormatDialogData.Mode = data.Mode; pConditionalFormatDialogData.IsManaged = data.IsManaged; pConditionalFormatDialogData.Formula = data.Formula; - pConditionalFormatDialogData.FormatKey = data.FormatKey; - pConditionalFormatDialogData.EntryIndex = data.EntryIndex; } void ScDocument::SetChangeViewSettings(const ScChangeViewSettings& rNew) diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx index 438a4e2856e3..91470d768eba 100644 --- a/sc/source/ui/attrdlg/scdlgfact.cxx +++ b/sc/source/ui/attrdlg/scdlgfact.cxx @@ -719,9 +719,9 @@ ScConditionalFormat* AbstractScCondFormatManagerDlg_Impl::GetCondFormatSelected( return m_xDlg->GetCondFormatSelected(); } -void AbstractScCondFormatManagerDlg_Impl::ShowEasyConditionalDialog(bool isEdit) +void AbstractScCondFormatManagerDlg_Impl::ShowEasyConditionalDialog() { - m_xDlg->ShowEasyConditionalDialog(isEdit); + m_xDlg->ShowEasyConditionalDialog(); } int AbstractScMetricInputDlg_Impl::GetInputValue() const diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx index 9de4a2535a32..c01f99a132d7 100644 --- a/sc/source/ui/attrdlg/scdlgfact.hxx +++ b/sc/source/ui/attrdlg/scdlgfact.hxx @@ -115,7 +115,7 @@ public: virtual bool CondFormatsChanged() const override; virtual void SetModified() override; virtual ScConditionalFormat* GetCondFormatSelected() override; - virtual void ShowEasyConditionalDialog(bool isEdit = false) 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 3e1bb5e015b2..48b712cf1fe2 100644 --- a/sc/source/ui/condformat/condformateasydlg.cxx +++ b/sc/source/ui/condformat/condformateasydlg.cxx @@ -63,8 +63,6 @@ ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings, , mpViewData(pViewData) , mpDocument(&mpViewData->GetDocument()) , mbIsManaged(false) - , mnFormatKey(0) - , mnEntryIndex(0) , mxNumberEntry(m_xBuilder->weld_entry("entryNumber")) , mxNumberEntry2(m_xBuilder->weld_entry("entryNumber2")) , mxAllInputs(m_xBuilder->weld_container("allInputs")) @@ -93,8 +91,6 @@ ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings, meMode = *CurrentData.Mode; mbIsManaged = CurrentData.IsManaged; msFormula = CurrentData.Formula; - mnFormatKey = CurrentData.FormatKey; - mnEntryIndex = CurrentData.EntryIndex; } mxNumberEntry2->hide(); switch (meMode) @@ -253,21 +249,12 @@ ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings, ScRangeList aRange; mpViewData->GetMarkData().FillRangeListWithMarks(&aRange, false); - ScConditionalFormat* format - = mpDocument->GetCondFormList(mpViewData->GetTabNo())->GetFormat(mnFormatKey); - if (aRange.empty() && mnFormatKey != -1 && mnEntryIndex != -1) - { - aRange = format->GetRangeList(); - } - else if (aRange.empty()) + if (aRange.empty()) { ScAddress aPosition(mpViewData->GetCurX(), mpViewData->GetCurY(), mpViewData->GetTabNo()); aRange.push_back(ScRange(aPosition)); } maPosition = aRange.GetTopLeftCorner(); - // FIX me: Tab is always 0 in some cases - // Refer to test tdf100793 - maPosition.SetTab(mpViewData->GetTabNo()); OUString sRangeString; aRange.Format(sRangeString, ScRefFlags::VALID, *mpDocument, mpDocument->GetAddressConvention()); @@ -324,11 +311,6 @@ IMPL_LINK(ConditionalFormatEasyDialog, ButtonPressed, weld::Button&, rButton, vo { if (&rButton == mxButtonOk.get()) { - if (mnEntryIndex != -1 && mnFormatKey != -1) // isEdit - mpDocument->GetCondFormList(maPosition.Tab()) - ->GetFormat(mnFormatKey) - ->RemoveEntry(mnEntryIndex); - std::unique_ptr<ScConditionalFormat> pFormat(new ScConditionalFormat(0, mpDocument)); OUString sExpression1 = (mxNumberEntry->get_visible() && mxAllInputs->get_visible() diff --git a/sc/source/ui/condformat/condformatmgr.cxx b/sc/source/ui/condformat/condformatmgr.cxx index 495d325d8fc3..13a4c49cfc79 100644 --- a/sc/source/ui/condformat/condformatmgr.cxx +++ b/sc/source/ui/condformat/condformatmgr.cxx @@ -102,30 +102,15 @@ ScConditionalFormat* ScCondFormatManagerWindow::GetSelection() return mpFormatList->GetFormat(nKey); } -const ScFormatEntry* ScCondFormatManagerWindow::GetSelectedEntry() const -{ - sal_Int32 nKey = GetSelectedFormatKey(); - sal_Int32 nEntryIndex = GetSelectedEntryIndex(); - - if (nKey == -1 || nEntryIndex == -1) - return nullptr; - return mpFormatList->GetFormat(nKey)->GetEntry(nEntryIndex); -} - -sal_Int32 ScCondFormatManagerWindow::GetSelectedFormatKey() const +const ScFormatEntry* ScCondFormatManagerWindow::GetSelectedEntry() { OUString id = mrTreeView.get_selected_id(); if (id.isEmpty()) - return -1; - return getKeyFromId(id); -} + return nullptr; -sal_Int32 ScCondFormatManagerWindow::GetSelectedEntryIndex() const -{ - OUString id = mrTreeView.get_selected_id(); - if (id.isEmpty()) - return -1; - return getEntryIndexFromId(id); + sal_Int32 nKey = getKeyFromId(id); + sal_Int32 nEntryIndex = getEntryIndexFromId(id); + return mpFormatList->GetFormat(nKey)->GetEntry(nEntryIndex); } void ScCondFormatManagerWindow::setColSizes() @@ -164,7 +149,6 @@ ScCondFormatManagerDlg::ScCondFormatManagerDlg(weld::Window* pParent, ScDocument m_xDialog->set_window_state(aDlgOpt.GetWindowState()); UpdateButtonSensitivity(); - this->EntryFocus(*m_xTreeView); } ScCondFormatManagerDlg::~ScCondFormatManagerDlg() @@ -193,12 +177,10 @@ ScConditionalFormat* ScCondFormatManagerDlg::GetCondFormatSelected() return m_xCtrlManager->GetSelection(); } -void ScCondFormatManagerDlg::ShowEasyConditionalDialog(bool isEdit) +void ScCondFormatManagerDlg::ShowEasyConditionalDialog() { auto id = m_xConditionalType->get_active(); SfxBoolItem IsManaged(FN_PARAM_2, true); - SfxInt32Item FormatKey(FN_PARAM_3, isEdit ? m_xCtrlManager->GetSelectedFormatKey() : -1); - SfxInt32Item EntryIndex(FN_PARAM_4, isEdit ? m_xCtrlManager->GetSelectedEntryIndex() : -1); switch (id) { case 0: // Cell value @@ -207,16 +189,16 @@ void ScCondFormatManagerDlg::ShowEasyConditionalDialog(bool isEdit) m_xConditionalCellValue->get_active_id().toUInt32()); SfxViewShell::Current()->GetDispatcher()->ExecuteList( SID_EASY_CONDITIONAL_FORMAT_DIALOG, SfxCallMode::ASYNCHRON, - { &FormatRule, &IsManaged, &FormatKey, &EntryIndex }); + { &FormatRule, &IsManaged }); } break; case 1: // Formula { SfxInt16Item FormatRule(FN_PARAM_1, static_cast<sal_Int16>(ScConditionMode::Formula)); - SfxStringItem Formula(FN_PARAM_5, m_xConditionalFormula->GetText()); + SfxStringItem Formula(FN_PARAM_3, m_xConditionalFormula->GetText()); SfxViewShell::Current()->GetDispatcher()->ExecuteList( SID_EASY_CONDITIONAL_FORMAT_DIALOG, SfxCallMode::ASYNCHRON, - { &FormatRule, &IsManaged, &FormatKey, &EntryIndex, &Formula }); + { &FormatRule, &IsManaged, &Formula }); } break; case 2: // Date @@ -224,7 +206,7 @@ void ScCondFormatManagerDlg::ShowEasyConditionalDialog(bool isEdit) SfxInt16Item FormatRule(FN_PARAM_1, m_xConditionalDate->get_active_id().toUInt32()); SfxViewShell::Current()->GetDispatcher()->ExecuteList( SID_EASY_CONDITIONAL_FORMAT_DIALOG, SfxCallMode::ASYNCHRON, - { &FormatRule, &IsManaged, &FormatKey, &EntryIndex }); + { &FormatRule, &IsManaged }); } break; default: diff --git a/sc/source/ui/inc/condformateasydlg.hxx b/sc/source/ui/inc/condformateasydlg.hxx index 8bc21215b178..efb2f03aafde 100644 --- a/sc/source/ui/inc/condformateasydlg.hxx +++ b/sc/source/ui/inc/condformateasydlg.hxx @@ -46,8 +46,6 @@ private: bool mbIsManaged; OUString msFormula; ScAddress maPosition; - sal_Int32 mnFormatKey; - sal_Int32 mnEntryIndex; SvxFontPrevWindow maWdPreview; std::unique_ptr<weld::Entry> mxNumberEntry; diff --git a/sc/source/ui/inc/condformatmgr.hxx b/sc/source/ui/inc/condformatmgr.hxx index 564415186ac0..09b6c571e562 100644 --- a/sc/source/ui/inc/condformatmgr.hxx +++ b/sc/source/ui/inc/condformatmgr.hxx @@ -32,9 +32,7 @@ public: void DeleteSelection(); ScConditionalFormat* GetSelection(); - const ScFormatEntry* GetSelectedEntry() const; - sal_Int32 GetSelectedFormatKey() const; - sal_Int32 GetSelectedEntryIndex() const; + const ScFormatEntry* GetSelectedEntry(); }; class ScCondFormatManagerDlg : public weld::GenericDialogController @@ -49,7 +47,7 @@ public: void SetModified(); ScConditionalFormat* GetCondFormatSelected(); - void ShowEasyConditionalDialog(bool isEdit = false); + void ShowEasyConditionalDialog(); private: bool m_bModified; diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 7c09aaf404c2..38d1e4682111 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -2918,7 +2918,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) if (pDlgItem) pDlg->SetModified(); - pDlg->StartExecuteAsync([pDlg, &rData, pTabViewShell, pDlgItem, aPos](sal_Int32 nRet){ + pDlg->StartExecuteAsync([this, pDlg, &rData, pTabViewShell, pDlgItem, aPos](sal_Int32 nRet){ std::unique_ptr<ScConditionalFormatList> pCondFormatList = pDlg->GetConditionalFormatList(); if(nRet == RET_OK && pDlg->CondFormatsChanged()) { @@ -2930,7 +2930,15 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) } else if (nRet == DLG_RET_EDIT) { - pDlg->ShowEasyConditionalDialog(true); + ScConditionalFormat* pFormat = pDlg->GetCondFormatSelected(); + sal_Int32 nIndex = pFormat ? pFormat->GetKey() : -1; + // Put the xml string parameter to initialize the + // Conditional Format Dialog. ( edit selected conditional format ) + pTabViewShell->GetPool().DirectPutItemInPool(ScCondFormatDlgItem( + std::shared_ptr<ScConditionalFormatList>(pCondFormatList.release()), nIndex, true)); + + // Queue message to open Conditional Format Dialog + GetViewData().GetDispatcher().Execute( SID_OPENDLG_CONDFRMT, SfxCallMode::ASYNCHRON ); } else pCondFormatList.reset(); diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx index de6a7167f388..6df959030245 100644 --- a/sc/source/ui/view/cellsh3.cxx +++ b/sc/source/ui/view/cellsh3.cxx @@ -470,22 +470,13 @@ void ScCellShell::Execute( SfxRequest& rReq ) const SfxPoolItem* pFormula; OUString formula; - if (pReqArgs->HasItem(FN_PARAM_5, &pFormula)) + if (pReqArgs->HasItem(FN_PARAM_3, &pFormula)) { formula = static_cast<const SfxStringItem*>(pFormula)->GetValue(); } - const SfxPoolItem *pFormatKey, *pEntryIndex; - sal_Int32 nFormatKey = -1, nEntryIndex = -1; - if (pReqArgs->HasItem(FN_PARAM_3, &pFormatKey) - && pReqArgs->HasItem(FN_PARAM_4, &pEntryIndex)) - { - nFormatKey = static_cast<const SfxInt32Item*>(pFormatKey)->GetValue(); - nEntryIndex = static_cast<const SfxInt32Item*>(pEntryIndex)->GetValue(); - } GetViewData().GetDocument().SetEasyConditionalFormatDialogData( - ScConditionEasyDialogData(&nFormat, bManaged, nFormatKey, nEntryIndex, - formula)); + ScConditionEasyDialogData(&nFormat, bManaged, formula)); pScMod->SetRefDialog( nId, pWindow == nullptr ); }
