cui/source/inc/cuitabarea.hxx | 51 ++++++++++++++++++----------------------- cui/source/tabpages/tparea.cxx | 4 +-- 2 files changed, 25 insertions(+), 30 deletions(-)
New commits: commit 6ee0a0a3b29d4f63544801578219f16ebf17d2e6 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Mon Aug 11 14:16:14 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Tue Aug 12 06:36:42 2025 +0200 cui: Merge area tab page's ButtonBox::SelectButton{,Impl} Change-Id: If1ae48e2c78870aff8718492ae842a5dc3609a64 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189369 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx index de84893cd048..5be6f1695d16 100644 --- a/cui/source/inc/cuitabarea.hxx +++ b/cui/source/inc/cuitabarea.hxx @@ -41,15 +41,6 @@ class ButtonBox sal_Int32 mnCurrentButton; std::vector<weld::ToggleButton*> maButtonList; std::map<weld::Toggleable*, sal_Int32 > maButtonToPos; - void SelectButtonImpl( sal_Int32 nPos ) - { - if(mnCurrentButton != NO_BUTTON_SELECTED) - { - maButtonList[mnCurrentButton]->set_active(false); - } - mnCurrentButton = nPos; - maButtonList[mnCurrentButton]->set_active(true); - }; public: ButtonBox() { @@ -71,7 +62,13 @@ class ButtonBox { const sal_Int32 nPos = GetButtonPos(rButton); assert(nPos >= 0 && "Invalid button position"); - SelectButtonImpl(nPos); + + if (mnCurrentButton != NO_BUTTON_SELECTED) + { + maButtonList[mnCurrentButton]->set_active(false); + } + mnCurrentButton = nPos; + maButtonList[mnCurrentButton]->set_active(true); } }; commit c7c2812b06dd2247d869e74b54de33125fe0b571 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Mon Aug 11 14:11:03 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Tue Aug 12 06:36:35 2025 +0200 cui: Add some asserts for SvxAreaTabPage button handling Assert that only known/valid buttons are getting passed to some of the ButtonBox methods instead of having checks + fallback code paths. Since the SvxAreaTabPage ctor both adds the buttons to the ButtonBox and connects a signal handler to the single buttons, there shouldn't ever be a (valid) case where another button gets passed. Change-Id: I78e17b145ff5f490646e0ed9cc65a92ff99d89ee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189368 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx index 20ca1500e0d8..de84893cd048 100644 --- a/cui/source/inc/cuitabarea.hxx +++ b/cui/source/inc/cuitabarea.hxx @@ -61,19 +61,17 @@ class ButtonBox maButtonToPos.insert( std::make_pair(pButton, maButtonList.size() - 1) ); } sal_Int32 GetCurrentButtonPos() const { return mnCurrentButton; } - sal_Int32 GetButtonPos(weld::Toggleable* pButton) + sal_Int32 GetButtonPos(weld::Toggleable& rButton) { - std::map<weld::Toggleable*, sal_Int32>::const_iterator aBtnPos = maButtonToPos.find(pButton); - if(aBtnPos != maButtonToPos.end()) - return aBtnPos->second; - else - return -1; + std::map<weld::Toggleable*, sal_Int32>::const_iterator aBtnPos = maButtonToPos.find(&rButton); + assert(aBtnPos != maButtonToPos.end() && "Unknown button"); + return aBtnPos->second; } - void SelectButton(weld::Toggleable* pButton) + void SelectButton(weld::Toggleable& rButton) { - sal_Int32 nPos = GetButtonPos(pButton); - if(nPos != -1) - SelectButtonImpl(nPos); + const sal_Int32 nPos = GetButtonPos(rButton); + assert(nPos >= 0 && "Invalid button position"); + SelectButtonImpl(nPos); } }; diff --git a/cui/source/tabpages/tparea.cxx b/cui/source/tabpages/tparea.cxx index 068d08283f70..acf2aadf30d0 100644 --- a/cui/source/tabpages/tparea.cxx +++ b/cui/source/tabpages/tparea.cxx @@ -438,10 +438,10 @@ void SvxAreaTabPage::SelectFillType(weld::Toggleable& rButton, const SfxItemSet* if (_pSet) m_rXFSet.Set(*_pSet); - sal_Int32 nPos = maBox.GetButtonPos(&rButton); + sal_Int32 nPos = maBox.GetButtonPos(rButton); if (nPos != -1 && (_pSet || nPos != maBox.GetCurrentButtonPos())) { - maBox.SelectButton(&rButton); + maBox.SelectButton(rButton); FillType eFillType = static_cast<FillType>(maBox.GetCurrentButtonPos()); m_xFillTabPage = lcl_CreateFillStyleTabPage(eFillType, m_xFillTab.get(), GetDialogController(), m_rXFSet); if (m_xFillTabPage) commit 0887b81bebdff667fcc76bc7f02debeab5084eb0 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Mon Aug 11 13:52:38 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Tue Aug 12 06:36:29 2025 +0200 cui: Use ToggleButton members in SvxAreaTabPage The ctor already uses weld::Builder::weld_toggle_button which returns a unique_ptr to the more specific weld::ToggleButton subclass. Use that for the corresponding SvxAreaTabPage members and a ButtonBox one, too, to make clear these are only meant to be used with the buttons. Change-Id: I8c3cf6b70a6d208ab97cf85f882dd9b3a0b02b16 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189367 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx index 0a143528f7fc..20ca1500e0d8 100644 --- a/cui/source/inc/cuitabarea.hxx +++ b/cui/source/inc/cuitabarea.hxx @@ -39,7 +39,7 @@ class ButtonBox { private: sal_Int32 mnCurrentButton; - std::vector<weld::Toggleable*> maButtonList; + std::vector<weld::ToggleButton*> maButtonList; std::map<weld::Toggleable*, sal_Int32 > maButtonToPos; void SelectButtonImpl( sal_Int32 nPos ) { @@ -55,7 +55,7 @@ class ButtonBox { mnCurrentButton = NO_BUTTON_SELECTED; }; - void AddButton(weld::Toggleable* pButton) + void AddButton(weld::ToggleButton* pButton) { maButtonList.push_back(pButton); maButtonToPos.insert( std::make_pair(pButton, maButtonList.size() - 1) ); @@ -240,13 +240,13 @@ private: protected: std::unique_ptr<weld::Container> m_xFillTab; - std::unique_ptr<weld::Toggleable> m_xBtnNone; - std::unique_ptr<weld::Toggleable> m_xBtnColor; - std::unique_ptr<weld::Toggleable> m_xBtnGradient; - std::unique_ptr<weld::Toggleable> m_xBtnHatch; - std::unique_ptr<weld::Toggleable> m_xBtnBitmap; - std::unique_ptr<weld::Toggleable> m_xBtnPattern; - std::unique_ptr<weld::Toggleable> m_xBtnUseBackground; + std::unique_ptr<weld::ToggleButton> m_xBtnNone; + std::unique_ptr<weld::ToggleButton> m_xBtnColor; + std::unique_ptr<weld::ToggleButton> m_xBtnGradient; + std::unique_ptr<weld::ToggleButton> m_xBtnHatch; + std::unique_ptr<weld::ToggleButton> m_xBtnBitmap; + std::unique_ptr<weld::ToggleButton> m_xBtnPattern; + std::unique_ptr<weld::ToggleButton> m_xBtnUseBackground; void SetOptimalSize(weld::DialogController* pController);