From ce67331daa101ce1d8fc81fe1c843d8810f7a33c Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Fri, 13 Dec 2024 22:11:34 +0100 Subject: [PATCH] tdf#130857 VclBuilder: Store radio button groups in BuilderBase Move the std::vector and the method to extract and add to that map from VclBuilder to its base class, BuilderBase. Add a getter, BuilderBase::getRadioButtonGroupMaps instead of accessing the base class member directly in the VclBuilder subclass. Change-Id: Ic0d2abbd9faa41760d542ab22a80f2ba23136ccf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178442 Tested-by: Jenkins Reviewed-by: Michael Weghorn --- include/vcl/builder.hxx | 5 ----- include/vcl/builderbase.hxx | 5 +++++ vcl/source/window/builder.cxx | 13 +++++++++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx index 254b4e52d328..38e9aab01dcc 100644 --- a/include/vcl/builder.hxx +++ b/include/vcl/builder.hxx @@ -127,8 +127,6 @@ private: }; std::vector m_aChildren; - typedef StringPair RadioButtonGroupMap; - struct ButtonImageWidgetMap { OUString m_sID; @@ -179,8 +177,6 @@ private: struct VclParserState { - std::vector m_aGroupMaps; - std::vector m_aModelMaps; std::vector m_aTextBufferMaps; @@ -254,7 +250,6 @@ private: static int getImageSize(const stringmap &rMap); - void extractGroup(const OUString &id, stringmap &rVec); void extractModel(const OUString &id, stringmap &rVec); void extractBuffer(const OUString &id, stringmap &rVec); static bool extractAdjustmentToMap(const OUString &id, stringmap &rVec, std::vector& rAdjustmentMap); diff --git a/include/vcl/builderbase.hxx b/include/vcl/builderbase.hxx index 573817315f72..eb3aa847199f 100644 --- a/include/vcl/builderbase.hxx +++ b/include/vcl/builderbase.hxx @@ -77,6 +77,7 @@ protected: }; typedef StringPair MnemonicWidgetMap; + typedef StringPair RadioButtonGroupMap; static void collectPangoAttribute(xmlreader::XmlReader& reader, stringmap& rMap); static void collectAtkRelationAttribute(xmlreader::XmlReader& reader, stringmap& rMap); @@ -112,6 +113,9 @@ protected: void extractMnemonicWidget(const OUString& id, stringmap& rMap); const std::vector& getMnemonicWidgetMaps() const; + void extractRadioButtonGroup(const OUString& id, stringmap& rVec); + const std::vector& getRadioButtonGroupMaps() const; + OUString finalizeValue(const OString& rContext, const OString& rValue, const bool bTranslate) const; @@ -149,6 +153,7 @@ private: std::map m_aTextBuffers; std::vector m_aMnemonicWidgetMaps; + std::vector m_aRadioButtonGroupMaps; }; std::unique_ptr m_pParserState; diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index ccfb68ca9f9e..8172e3d30e99 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -481,6 +481,11 @@ const std::vector& BuilderBase::getMnemonicWidge return m_pParserState->m_aMnemonicWidgetMaps; } +const std::vector& BuilderBase::getRadioButtonGroupMaps() const { + assert(m_pParserState && "parser state no more valid"); + return m_pParserState->m_aRadioButtonGroupMaps; +} + OUString BuilderBase::finalizeValue(const OString& rContext, const OString& rValue, const bool bTranslate) const { @@ -554,7 +559,7 @@ VclBuilder::VclBuilder(vcl::Window* pParent, std::u16string_view sUIDir, const O } //Set radiobutton groups when everything has been imported - for (auto const& elem : m_pVclParserState->m_aGroupMaps) + for (auto const& elem : getRadioButtonGroupMaps()) { RadioButton *pOne = get(elem.m_sID); RadioButton *pOther = get(elem.m_sValue); @@ -1098,7 +1103,7 @@ namespace } } -void VclBuilder::extractGroup(const OUString &id, stringmap &rMap) +void BuilderBase::extractRadioButtonGroup(const OUString &id, stringmap &rMap) { VclBuilder::stringmap::iterator aFind = rMap.find(u"group"_ustr); if (aFind != rMap.end()) @@ -1107,7 +1112,7 @@ void VclBuilder::extractGroup(const OUString &id, stringmap &rMap) sal_Int32 nDelim = sID.indexOf(':'); if (nDelim != -1) sID = sID.copy(0, nDelim); - m_pVclParserState->m_aGroupMaps.emplace_back(id, sID); + m_pParserState->m_aRadioButtonGroupMaps.emplace_back(id, sID); rMap.erase(aFind); } } @@ -1603,7 +1608,7 @@ VclPtr VclBuilder::makeObject(vcl::Window *pParent, const OUString } else if (name == "GtkRadioButton") { - extractGroup(id, rMap); + extractRadioButtonGroup(id, rMap); WinBits nBits = WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK; VclPtr xButton = VclPtr::Create(pParent, true, nBits); xButton->SetImageAlign(ImageAlign::Left); //default to left