include/vcl/builder.hxx | 47 +++++++++++++++++++++++------------------- vcl/source/window/builder.cxx | 28 +++++++++++++++---------- 2 files changed, 43 insertions(+), 32 deletions(-)
New commits: commit 612d20103f4fd26020c7f5ab7af80a4f504f06a3 Author: Michael Weghorn <[email protected]> AuthorDate: Tue Aug 13 13:33:47 2024 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Tue Aug 13 19:31:15 2024 +0200 tdf#130857 VclBuilder: Move handleItems to base class Let the base class do the parsing for items and return a `ComboBoxTextItem`. It has nothing `vcl::Window` specific. (`vcl::Window` specific part is only when this gets applied in `insertItems`, which could probably be reimplemented differently for other subclasses). Change-Id: Ica2f435b48c69fbdfff450b713d91a6fbe985de6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171820 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx index 85a32d3fb5e6..0e2426149b07 100644 --- a/include/vcl/builder.hxx +++ b/include/vcl/builder.hxx @@ -103,6 +103,8 @@ protected: OUString finalizeValue(const OString& rContext, const OString& rValue, const bool bTranslate) const; + + std::vector<ComboBoxTextItem> handleItems(xmlreader::XmlReader& reader) const; void handleListStore(xmlreader::XmlReader& reader, const OUString& rID, std::u16string_view rClass); void handleRow(xmlreader::XmlReader& reader, const OUString& rID); const ListStore* get_model_by_name(const OUString& sID) const; @@ -393,7 +395,6 @@ private: void handleTabChild(vcl::Window *pParent, xmlreader::XmlReader &reader); void handleMenu(xmlreader::XmlReader& reader, vcl::Window* pParent, const OUString& rID, bool bMenuBar); - std::vector<ComboBoxTextItem> handleItems(xmlreader::XmlReader &reader) const; stringmap handleAtkObject(xmlreader::XmlReader &reader) const; diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 41aa5943067d..a68b4b6a0bf6 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -3168,7 +3168,7 @@ void VclBuilder::applyAtkProperties(vcl::Window *pWindow, const stringmap& rProp } } -std::vector<ComboBoxTextItem> VclBuilder::handleItems(xmlreader::XmlReader &reader) const +std::vector<ComboBoxTextItem> BuilderBase::handleItems(xmlreader::XmlReader& reader) const { int nLevel = 1; commit 2833ba26c85b468960f69133941182be0c4ad74e Author: Michael Weghorn <[email protected]> AuthorDate: Tue Aug 13 13:23:59 2024 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Tue Aug 13 19:31:08 2024 +0200 tdf#130857 VclBuilder: Move size group parsing to base class Move the parsing of size groups from `VclBuilder` to the base class, `BuilderBase` and add a getter, `BuilderBase::getSizeGroups` that currently gets used from `VclBuilder`. Since the parsing is not specific to vcl::Window, make it possible to reuse it from other subclasses. It could e.g. be useful for the WIP QtInstanceBuilder from Omkar's WIP change [1]. [1] https://gerrit.libreoffice.org/c/core/+/161831 Change-Id: I0c44bfda1d5c850679695ab6bd436e4e487df9c0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171819 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx index 8a3debe11919..85a32d3fb5e6 100644 --- a/include/vcl/builder.hxx +++ b/include/vcl/builder.hxx @@ -79,6 +79,13 @@ protected: std::vector<row> m_aEntries; }; + struct SizeGroup + { + std::vector<OUString> m_aWidgets; + stringmap m_aProperties; + SizeGroup() {} + }; + static void collectPangoAttribute(xmlreader::XmlReader& reader, stringmap& rMap); static void collectAtkRelationAttribute(xmlreader::XmlReader& reader, stringmap& rMap); static void collectAtkRoleAttribute(xmlreader::XmlReader& reader, stringmap& rMap); @@ -91,6 +98,8 @@ protected: bool isLegacy() { return m_bLegacy; } const std::locale& getResLocale() const; + const std::vector<SizeGroup>& getSizeGroups() const; + OUString finalizeValue(const OString& rContext, const OString& rValue, const bool bTranslate) const; @@ -98,6 +107,8 @@ protected: void handleRow(xmlreader::XmlReader& reader, const OUString& rID); const ListStore* get_model_by_name(const OUString& sID) const; + void handleSizeGroup(xmlreader::XmlReader& reader); + virtual void resetParserState(); private: @@ -106,6 +117,7 @@ private: std::locale m_aResLocale; std::map<OUString, ListStore> m_aModels; + std::vector<SizeGroup> m_aSizeGroups; }; std::unique_ptr<ParserState> m_pParserState; @@ -263,12 +275,6 @@ private: typedef std::map<OUString, int> ImageSizeMap; - struct SizeGroup - { - std::vector<OUString> m_aWidgets; - stringmap m_aProperties; - SizeGroup() {} - }; struct VclParserState @@ -294,8 +300,6 @@ private: std::map<VclPtr<vcl::Window>, VclPtr<vcl::Window>> m_aRedundantParentWidgets; - std::vector<SizeGroup> m_aSizeGroups; - std::map<VclPtr<vcl::Window>, stringmap> m_aAtkInfo; std::vector<MnemonicWidgetMap> m_aMnemonicWidgetMaps; @@ -391,8 +395,6 @@ private: bool bMenuBar); std::vector<ComboBoxTextItem> handleItems(xmlreader::XmlReader &reader) const; - void handleSizeGroup(xmlreader::XmlReader &reader); - stringmap handleAtkObject(xmlreader::XmlReader &reader) const; // if bToolbarItem=true, pParent is the ToolBox that the item belongs to, since there's no widget for the item itself diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 0b08fe291340..41aa5943067d 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -457,6 +457,12 @@ const std::locale& BuilderBase::getResLocale() const return m_pParserState->m_aResLocale; } +const std::vector<BuilderBase::SizeGroup>& BuilderBase::getSizeGroups() const +{ + assert(m_pParserState && "parser state no more valid"); + return m_pParserState->m_aSizeGroups; +} + OUString BuilderBase::finalizeValue(const OString& rContext, const OString& rValue, const bool bTranslate) const { @@ -652,7 +658,7 @@ VclBuilder::VclBuilder(vcl::Window* pParent, const OUString& sUIDir, const OUStr } //Set size-groups when all widgets have been imported - for (auto const& sizeGroup : m_pVclParserState->m_aSizeGroups) + for (auto const& sizeGroup : getSizeGroups()) { std::shared_ptr<VclSizeGroup> xGroup(std::make_shared<VclSizeGroup>()); @@ -3399,10 +3405,10 @@ void VclBuilder::handleMenuObject(Menu *pParent, xmlreader::XmlReader &reader) insertMenuObject(pParent, pSubMenu, sClass, sID, aProperties, aAtkProperties, aAccelerators); } -void VclBuilder::handleSizeGroup(xmlreader::XmlReader &reader) +void BuilderBase::handleSizeGroup(xmlreader::XmlReader& reader) { - m_pVclParserState->m_aSizeGroups.emplace_back(); - SizeGroup &rSizeGroup = m_pVclParserState->m_aSizeGroups.back(); + m_pParserState->m_aSizeGroups.emplace_back(); + SizeGroup &rSizeGroup = m_pParserState->m_aSizeGroups.back(); int nLevel = 1; commit e19683d65a678a1c47c4af709c761531354d7d25 Author: Michael Weghorn <[email protected]> AuthorDate: Tue Aug 13 13:10:18 2024 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Tue Aug 13 19:31:02 2024 +0200 tdf#130857 VclBuilder: Move list store handling to base class This has has nothing vcl::Window specific, so make it reusable by other subclasses, like the WIP QtInstanceBuilder from Omkar's WIP change [1]. [1] https://gerrit.libreoffice.org/c/core/+/161831 Change-Id: I8ef00b9534c8f9d6bf756371133401ac06c05168 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171818 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx index e26aaeb7974b..8a3debe11919 100644 --- a/include/vcl/builder.hxx +++ b/include/vcl/builder.hxx @@ -73,6 +73,12 @@ public: protected: BuilderBase(bool bLegacy); + struct ListStore + { + typedef std::vector<OUString> row; + std::vector<row> m_aEntries; + }; + static void collectPangoAttribute(xmlreader::XmlReader& reader, stringmap& rMap); static void collectAtkRelationAttribute(xmlreader::XmlReader& reader, stringmap& rMap); static void collectAtkRoleAttribute(xmlreader::XmlReader& reader, stringmap& rMap); @@ -88,12 +94,18 @@ protected: OUString finalizeValue(const OString& rContext, const OString& rValue, const bool bTranslate) const; + void handleListStore(xmlreader::XmlReader& reader, const OUString& rID, std::u16string_view rClass); + void handleRow(xmlreader::XmlReader& reader, const OUString& rID); + const ListStore* get_model_by_name(const OUString& sID) const; + virtual void resetParserState(); private: struct ParserState { std::locale m_aResLocale; + + std::map<OUString, ListStore> m_aModels; }; std::unique_ptr<ParserState> m_pParserState; @@ -232,13 +244,6 @@ private: } }; - struct ListStore - { - typedef std::vector<OUString> row; - std::vector<row> m_aEntries; - }; - - const ListStore* get_model_by_name(const OUString& sID) const; void mungeModel(ListBox &rTarget, const ListStore &rStore, sal_uInt16 nActiveId); void mungeModel(ComboBox &rTarget, const ListStore &rStore, sal_uInt16 nActiveId); void mungeModel(SvTabListBox &rTarget, const ListStore &rStore, sal_uInt16 nActiveId); @@ -271,7 +276,6 @@ private: std::vector<RadioButtonGroupMap> m_aGroupMaps; std::vector<ComboBoxModelMap> m_aModelMaps; - std::map<OUString, ListStore> m_aModels; std::vector<TextBufferMap> m_aTextBufferMaps; std::map<OUString, TextBuffer> m_aTextBuffers; @@ -382,8 +386,6 @@ private: void handleMenuChild(Menu *pParent, xmlreader::XmlReader &reader); void handleMenuObject(Menu *pParent, xmlreader::XmlReader &reader); - void handleListStore(xmlreader::XmlReader &reader, const OUString &rID, std::u16string_view rClass); - void handleRow(xmlreader::XmlReader &reader, const OUString &rID); void handleTabChild(vcl::Window *pParent, xmlreader::XmlReader &reader); void handleMenu(xmlreader::XmlReader& reader, vcl::Window* pParent, const OUString& rID, bool bMenuBar); diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index ec870da2c9c5..0b08fe291340 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -2990,7 +2990,7 @@ void BuilderBase::collectAtkRoleAttribute(xmlreader::XmlReader& reader, stringma rMap[u"role"_ustr] = sProperty; } -void VclBuilder::handleRow(xmlreader::XmlReader &reader, const OUString &rID) +void BuilderBase::handleRow(xmlreader::XmlReader& reader, const OUString& rID) { int nLevel = 1; @@ -3063,10 +3063,10 @@ void VclBuilder::handleRow(xmlreader::XmlReader &reader, const OUString &rID) break; } - m_pVclParserState->m_aModels[rID].m_aEntries.push_back(aRow); + m_pParserState->m_aModels[rID].m_aEntries.push_back(aRow); } -void VclBuilder::handleListStore(xmlreader::XmlReader &reader, const OUString &rID, std::u16string_view rClass) +void BuilderBase::handleListStore(xmlreader::XmlReader& reader, const OUString& rID, std::u16string_view rClass) { int nLevel = 1; @@ -4225,10 +4225,10 @@ void VclBuilder::set_window_packing_position(const vcl::Window *pWindow, sal_Int } } -const VclBuilder::ListStore *VclBuilder::get_model_by_name(const OUString& sID) const +const BuilderBase::ListStore* BuilderBase::get_model_by_name(const OUString& sID) const { - const auto aI = m_pVclParserState->m_aModels.find(sID); - if (aI != m_pVclParserState->m_aModels.end()) + const auto aI = m_pParserState->m_aModels.find(sID); + if (aI != m_pParserState->m_aModels.end()) return &(aI->second); return nullptr; }
