From 58fd872ffb4f81e58a764545fcefc93d39adb906 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Tue, 17 Sep 2024 17:28:23 +0200 Subject: 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 Tested-by: Jenkins --- include/vcl/builder.hxx | 2 ++ 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 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 static bool insertItems(vcl::Window *pWindow, VclBuilder::s return true; } -VclPtr 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 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 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 VclBuilder::handleObject(vcl::Window *pParent, stringmap *pA VclPtr pCurrentChild; while(true) { + xmlreader::Span name; + int nsId; xmlreader::XmlReader::Result res = reader.nextItem( xmlreader::XmlReader::Text::NONE, &name, &nsId); -- cgit