diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-09-17 17:28:23 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-09-18 07:32:32 +0200 |
commit | 58fd872ffb4f81e58a764545fcefc93d39adb906 (patch) | |
tree | 1b6c56dd24d057d7c63e3d968eaa5ed8a8250610 | |
parent | 3bd4a797724cf432d09a7d8ffe5f4a53a1e7c78d (diff) |
tdf#130857 VclBuilder: Move class/id/custom prop extraction to helper
Extract parsing of these attributes from `VclBuilder::handleObject`
to a new helper method `BaseBuilder::extractClassAndIdAndCustomProperty`
in the base class.
Change-Id: I248448407db446fd61bf91bf13c9bc187e0706d6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162918
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
-rw-r--r-- | include/vcl/builder.hxx | 2 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 27 |
2 files changed, 19 insertions, 10 deletions
diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx index 0e93033499da..0ceb8aca68a6 100644 --- a/include/vcl/builder.hxx +++ b/include/vcl/builder.hxx @@ -91,6 +91,8 @@ protected: static void collectAtkRoleAttribute(xmlreader::XmlReader& reader, stringmap& rMap); static void collectAccelerator(xmlreader::XmlReader& reader, accelmap& rMap); void collectProperty(xmlreader::XmlReader& rReader, stringmap& rMap) const; + void extractClassAndIdAndCustomProperty(xmlreader::XmlReader& reader, OUString& rClass, + OUString& rId, OUString& rCustomProperty); void handleInterfaceDomain(xmlreader::XmlReader& rReader); static bool isToolbarItemClass(std::u16string_view sClass); static std::vector<vcl::EnumContext::Context> handleStyle(xmlreader::XmlReader &reader, int &nPriority); diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index f597496647b4..2e4c6a20f563 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -3597,12 +3597,9 @@ template<typename T> static bool insertItems(vcl::Window *pWindow, VclBuilder::s return true; } -VclPtr<vcl::Window> VclBuilder::handleObject(vcl::Window *pParent, stringmap *pAtkProps, xmlreader::XmlReader &reader, bool bToolbarItem) +void BuilderBase::extractClassAndIdAndCustomProperty(xmlreader::XmlReader& reader, OUString& rClass, + OUString& rId, OUString& rCustomProperty) { - OUString sClass; - OUString sID; - OUString sCustomProperty; - xmlreader::Span name; int nsId; @@ -3611,23 +3608,31 @@ VclPtr<vcl::Window> VclBuilder::handleObject(vcl::Window *pParent, stringmap *pA if (name == "class") { name = reader.getAttributeValue(false); - sClass = OUString(name.begin, name.length, RTL_TEXTENCODING_UTF8); + rClass = OUString(name.begin, name.length, RTL_TEXTENCODING_UTF8); } else if (name == "id") { name = reader.getAttributeValue(false); - sID = OUString(name.begin, name.length, RTL_TEXTENCODING_UTF8); + rId = OUString(name.begin, name.length, RTL_TEXTENCODING_UTF8); if (isLegacy()) { - sal_Int32 nDelim = sID.indexOf(':'); + sal_Int32 nDelim = rId.indexOf(':'); if (nDelim != -1) { - sCustomProperty = sID.subView(nDelim+1); - sID = sID.copy(0, nDelim); + rCustomProperty = rId.subView(nDelim+1); + rId = rId.copy(0, nDelim); } } } } +} + +VclPtr<vcl::Window> VclBuilder::handleObject(vcl::Window *pParent, stringmap *pAtkProps, xmlreader::XmlReader &reader, bool bToolbarItem) +{ + OUString sClass; + OUString sID; + OUString sCustomProperty; + extractClassAndIdAndCustomProperty(reader, sClass, sID, sCustomProperty); if (sClass == "GtkListStore" || sClass == "GtkTreeStore") { @@ -3673,6 +3678,8 @@ VclPtr<vcl::Window> VclBuilder::handleObject(vcl::Window *pParent, stringmap *pA VclPtr<vcl::Window> pCurrentChild; while(true) { + xmlreader::Span name; + int nsId; xmlreader::XmlReader::Result res = reader.nextItem( xmlreader::XmlReader::Text::NONE, &name, &nsId); |