cui/source/inc/numpages.hxx | 2 + cui/source/tabpages/numpages.cxx | 22 ++++++++++++------- include/sfx2/tabdlg.hxx | 9 +++++++ sfx2/source/dialog/tabdlg.cxx | 14 ++++++++++++ sw/qa/uitest/writer_tests2/formatBulletsNumbering.py | 16 ++++++------- sw/source/ui/misc/num.cxx | 9 +++++++ sw/source/uibase/inc/num.hxx | 1 sw/source/uibase/wrtsh/wrtsh1.cxx | 20 ++++++----------- 8 files changed, 66 insertions(+), 27 deletions(-)
New commits: commit c793a99d67f1963fe46062bc5d2313a05885de50 Author: Samuel Mehrbrodt <[email protected]> AuthorDate: Thu Jul 11 12:48:29 2024 +0200 Commit: Thorsten Behrens <[email protected]> CommitDate: Mon Jul 15 12:18:20 2024 +0200 Use configured bullet symbol when clicking bullets button Instead of the generic default symbol Change-Id: I0923d4ede5d7cc09d61bb57d5cb6dbf6f2af8058 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170377 Reviewed-by: Thorsten Behrens <[email protected]> Tested-by: allotropia jenkins <[email protected]> diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx index 0054eca4cb34..df2e0f487231 100644 --- a/sw/source/uibase/wrtsh/wrtsh1.cxx +++ b/sw/source/uibase/wrtsh/wrtsh1.cxx @@ -1573,11 +1573,6 @@ void SwWrtShell::NumOrBulletOn(bool bNum) // Append the character template at the numbering. SwCharFormat* pChrFormat; SwDocShell* pDocSh = GetView().GetDocShell(); - // #i63395# - // Only apply user defined default bullet font - const vcl::Font* pFnt = numfunc::IsDefBulletFontUserDefined() - ? &numfunc::GetDefBulletFont() - : nullptr; if (bNum) { @@ -1604,13 +1599,14 @@ void SwWrtShell::NumOrBulletOn(bool bNum) if (! bNum) { - // #i63395# - // Only apply user defined default bullet font - if ( pFnt ) - { - aFormat.SetBulletFont( pFnt ); - } - aFormat.SetBulletChar( numfunc::GetBulletChar(nLvl) ); + uno::Sequence<OUString> aBulletSymbols( + officecfg::Office::Common::BulletsNumbering::DefaultBullets::get()); + uno::Sequence<OUString> aBulletSymbolsFonts( + officecfg::Office::Common::BulletsNumbering::DefaultBulletsFonts::get()); + aFormat.SetBulletChar(aBulletSymbols[0].toChar()); + vcl::Font aFont; + aFont.SetFamilyName(aBulletSymbolsFonts[0]); + aFormat.SetBulletFont(&aFont); aFormat.SetNumberingType(SVX_NUM_CHAR_SPECIAL); // #i93908# clear suffix for bullet lists aFormat.SetListFormat("", "", nLvl); commit e49df43afba38442b48353c118c504be947d50e4 Author: Samuel Mehrbrodt <[email protected]> AuthorDate: Thu Jul 11 10:15:31 2024 +0200 Commit: Thorsten Behrens <[email protected]> CommitDate: Mon Jul 15 12:18:09 2024 +0200 Don't save bullet changes when dialog was cancelled Change-Id: Ia2a7feb2f47a59f7c693e2023f9c2c8b3b934f81 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170337 Tested-by: allotropia jenkins <[email protected]> Reviewed-by: Thorsten Behrens <[email protected]> diff --git a/cui/source/inc/numpages.hxx b/cui/source/inc/numpages.hxx index 615f84bfdfe9..04c46ebb2fff 100644 --- a/cui/source/inc/numpages.hxx +++ b/cui/source/inc/numpages.hxx @@ -98,6 +98,8 @@ class SvxBulletPickTabPage final : public SfxTabPage std::unique_ptr<weld::Button> m_xBtChangeBullet; std::unique_ptr<SvxNumValueSet> m_xExamplesVS; std::unique_ptr<weld::CustomWeld> m_xExamplesVSWin; + css::uno::Sequence<OUString> m_aBulletSymbols; + css::uno::Sequence<OUString> m_aBulletSymbolsFonts; DECL_LINK(NumSelectHdl_Impl, ValueSet*, void); DECL_LINK(DoubleClickHdl_Impl, ValueSet*, void); diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx index c9fb1c094373..211bb3f550a2 100644 --- a/cui/source/tabpages/numpages.cxx +++ b/cui/source/tabpages/numpages.cxx @@ -397,6 +397,14 @@ void SvxBulletPickTabPage::ActivatePage(const SfxItemSet& rSet) DeactivateRC SvxBulletPickTabPage::DeactivatePage(SfxItemSet *_pSet) { + if (IsCancelMode()) + { + // Dialog cancelled, restore previous bullets + std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::BulletsNumbering::DefaultBullets::set(m_aBulletSymbols, batch); + officecfg::Office::Common::BulletsNumbering::DefaultBulletsFonts::set(m_aBulletSymbolsFonts, batch); + batch->commit(); + } if(_pSet) FillItemSet(_pSet); return DeactivateRC::LeavePage; @@ -519,15 +527,15 @@ IMPL_LINK_NOARG(SvxBulletPickTabPage, ClickAddChangeHdl_Impl, weld::Button&, voi _nMask <<= 1; } - css::uno::Sequence<OUString> aBulletSymbols(officecfg::Office::Common::BulletsNumbering::DefaultBullets::get()); - css::uno::Sequence<OUString> aBulletSymbolsFonts(officecfg::Office::Common::BulletsNumbering::DefaultBulletsFonts::get()); - css::uno::Sequence<OUString> aBulletSymbolsList(aBulletSymbols.size()); - css::uno::Sequence<OUString> aBulletSymbolsFontsList(aBulletSymbolsFonts.size()); + m_aBulletSymbols = officecfg::Office::Common::BulletsNumbering::DefaultBullets::get(); + m_aBulletSymbolsFonts = officecfg::Office::Common::BulletsNumbering::DefaultBulletsFonts::get(); + css::uno::Sequence<OUString> aBulletSymbolsList(m_aBulletSymbols.size()); + css::uno::Sequence<OUString> aBulletSymbolsFontsList(m_aBulletSymbolsFonts.size()); auto aBulletSymbolsListRange = asNonConstRange(aBulletSymbolsList); auto aBulletSymbolsFontsListRange = asNonConstRange(aBulletSymbolsFontsList); sal_uInt16 nIndex = m_xExamplesVS->GetSelectedItemId() - 1; - for (size_t i = 0; i < aBulletSymbols.size(); ++i) + for (size_t i = 0; i < m_aBulletSymbols.size(); ++i) { if (i == nIndex) { @@ -536,8 +544,8 @@ IMPL_LINK_NOARG(SvxBulletPickTabPage, ClickAddChangeHdl_Impl, weld::Button&, voi } else { - aBulletSymbolsListRange[i] = aBulletSymbols[i]; - aBulletSymbolsFontsListRange[i] = aBulletSymbolsFonts[i]; + aBulletSymbolsListRange[i] = m_aBulletSymbols[i]; + aBulletSymbolsFontsListRange[i] = m_aBulletSymbolsFonts[i]; } } diff --git a/include/sfx2/tabdlg.hxx b/include/sfx2/tabdlg.hxx index 1b2bbadd999f..4bc44e555265 100644 --- a/include/sfx2/tabdlg.hxx +++ b/include/sfx2/tabdlg.hxx @@ -107,6 +107,11 @@ protected: */ bool PrepareLeaveCurrentPage(); + /** Called before user cancels the dialog. + Calls DeactivatePage of all tab pages with IsCancelMode() set to true + */ + void PrepareCancel(); + /** save the position of the TabDialog and which tab page is the currently active one */ void SavePosAndId(); @@ -192,6 +197,7 @@ private: const SfxItemSet* mpSet; OUString maUserString; bool mbHasExchangeSupport; + bool mbCancel; std::unordered_map<OUString, css::uno::Any> maAdditionalProperties; std::unique_ptr<TabPageImpl> mpImpl; @@ -258,6 +264,9 @@ public: } virtual void FillUserData(); virtual bool IsReadOnly() const; + // Whether the user has canceled the dialog. Allows to restore settings, etc. + virtual bool IsCancelMode() { return mbCancel; } + virtual void SetCancelMode(bool bCancel) { mbCancel = bCancel; } virtual void PageCreated (const SfxAllItemSet& aSet); virtual void ChangesApplied(); static const SfxPoolItem* GetItem( const SfxItemSet& rSet, sal_uInt16 nSlot, bool bDeep = true ); diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx index 39d0245637ca..743058bd3608 100644 --- a/sfx2/source/dialog/tabdlg.cxx +++ b/sfx2/source/dialog/tabdlg.cxx @@ -143,6 +143,7 @@ SfxTabPage::SfxTabPage(weld::Container* pPage, weld::DialogController* pControll && SfxViewShell::Current()->isLOKMobilePhone()) , mpSet(rAttrSet) , mbHasExchangeSupport(false) + , mbCancel(false) , mpImpl(new TabPageImpl) { mpImpl->mpSfxDialogController = dynamic_cast<SfxOkDialogController*>(m_pDialogController); @@ -672,6 +673,19 @@ bool SfxTabDialogController::PrepareLeaveCurrentPage() return bEnd; } +void SfxTabDialogController::PrepareCancel() +{ + for (auto pDataObject : m_pImpl->aData) + { + if (!pDataObject->xTabPage) + continue; + + SfxTabPage* pPage = pDataObject->xTabPage.get(); + pPage->SetCancelMode(true); + pPage->DeactivatePage(nullptr); + } +} + const WhichRangesContainer & SfxTabDialogController::GetInputRanges(const SfxItemPool& rPool) /* [Description] diff --git a/sw/qa/uitest/writer_tests2/formatBulletsNumbering.py b/sw/qa/uitest/writer_tests2/formatBulletsNumbering.py index e5ff843fa0f6..d0b78525c1c6 100644 --- a/sw/qa/uitest/writer_tests2/formatBulletsNumbering.py +++ b/sw/qa/uitest/writer_tests2/formatBulletsNumbering.py @@ -75,7 +75,7 @@ class formatBulletsNumbering(UITestCase): xindentatmf.executeAction("UP", tuple()) - with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="cancel") as xDialog: + with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="ok") as xDialog: xTabs = xDialog.getChild("tabcontrol") select_pos(xTabs, "4") xalignedatmf = xDialog.getChild("alignedatmf") @@ -100,7 +100,7 @@ class formatBulletsNumbering(UITestCase): select_by_text(xnumfollowedbylb, "Space") - with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="cancel") as xDialog: + with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="ok") as xDialog: xTabs = xDialog.getChild("tabcontrol") select_pos(xTabs, "4") xnumfollowedbylb = xDialog.getChild("numfollowedbylb") @@ -130,7 +130,7 @@ class formatBulletsNumbering(UITestCase): xallsame.executeAction("CLICK", tuple()) - with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="cancel") as xDialog: + with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="ok") as xDialog: xTabs = xDialog.getChild("tabcontrol") select_pos(xTabs, "5") xnumfmtlb = xDialog.getChild("numfmtlb") @@ -151,7 +151,7 @@ class formatBulletsNumbering(UITestCase): with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="user") as xDialog: pass - with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="cancel") as xDialog: + with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="ok") as xDialog: xTabs = xDialog.getChild("tabcontrol") select_pos(xTabs, "5") xnumfmtlb = xDialog.getChild("numfmtlb") @@ -185,7 +185,7 @@ class formatBulletsNumbering(UITestCase): xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) #TAB to move indent right - with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="cancel") as xDialog: + with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="ok") as xDialog: xTabs = xDialog.getChild("tabcontrol") select_pos(xTabs, "4") xindentatmf = xDialog.getChild("indentatmf") @@ -193,7 +193,7 @@ class formatBulletsNumbering(UITestCase): self.assertEqual(indentValue < indentValue2 , True) xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) - with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="cancel") as xDialog: + with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="ok") as xDialog: xTabs = xDialog.getChild("tabcontrol") select_pos(xTabs, "4") xindentatmf = xDialog.getChild("indentatmf") @@ -214,7 +214,7 @@ class formatBulletsNumbering(UITestCase): self.xUITest.executeCommand(".uno:DecrementSubLevels") - with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="cancel") as xDialog: + with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="ok") as xDialog: xTabs = xDialog.getChild("tabcontrol") select_pos(xTabs, "4") xindentatmf = xDialog.getChild("indentatmf") @@ -222,7 +222,7 @@ class formatBulletsNumbering(UITestCase): self.assertEqual(indentValue < indentValue2 , True) self.xUITest.executeCommand(".uno:IncrementLevel") - with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="cancel") as xDialog: + with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="ok") as xDialog: xTabs = xDialog.getChild("tabcontrol") select_pos(xTabs, "4") xindentatmf = xDialog.getChild("indentatmf") diff --git a/sw/source/ui/misc/num.cxx b/sw/source/ui/misc/num.cxx index fadef2466205..2429582a9fee 100644 --- a/sw/source/ui/misc/num.cxx +++ b/sw/source/ui/misc/num.cxx @@ -870,6 +870,8 @@ SwSvxNumBulletTabDialog::SwSvxNumBulletTabDialog(weld::Window* pParent, weld::Button* pButton = GetUserButton(); pButton->connect_clicked(LINK(this, SwSvxNumBulletTabDialog, RemoveNumberingHdl)); pButton->set_sensitive(m_rWrtSh.GetNumRuleAtCurrCursorPos() != nullptr); + weld::Button& pCancelButton = GetCancelButton(); + pCancelButton.connect_clicked(LINK(this, SwSvxNumBulletTabDialog, CancelHdl)); AddTabPage("singlenum", RID_SVXPAGE_PICK_SINGLE_NUM ); AddTabPage("bullets", RID_SVXPAGE_PICK_BULLET ); AddTabPage("outlinenum", RID_SVXPAGE_PICK_NUM ); @@ -946,4 +948,11 @@ IMPL_LINK_NOARG(SwSvxNumBulletTabDialog, RemoveNumberingHdl, weld::Button&, void m_xDialog->response(RET_USER); } +IMPL_LINK_NOARG(SwSvxNumBulletTabDialog, CancelHdl, weld::Button&, void) +{ + PrepareCancel(); + + m_xDialog->response(RET_CANCEL); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/inc/num.hxx b/sw/source/uibase/inc/num.hxx index 9dfa2bf9ea4f..1799ad3296cc 100644 --- a/sw/source/uibase/inc/num.hxx +++ b/sw/source/uibase/inc/num.hxx @@ -124,6 +124,7 @@ class SwSvxNumBulletTabDialog final : public SfxTabDialogController virtual short Ok() override; virtual void PageCreated(const OUString& rPageId, SfxTabPage& rPage) override; DECL_LINK(RemoveNumberingHdl, weld::Button&, void); + DECL_LINK(CancelHdl, weld::Button&, void); std::unique_ptr<weld::ComboBox> m_xDummyCombo;
