include/vcl/builder.hxx       |    1 +
 vcl/source/window/builder.cxx |   40 ++++++++++++++++++++--------------------
 2 files changed, 21 insertions(+), 20 deletions(-)

New commits:
commit f23081f61950e67a911e8afb1271636f3733a66f
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Tue Sep 17 11:27:51 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Sep 17 20:09:24 2024 +0200

    tdf#130857 VclBuilder: Turn extractOrientation into static helper
    
    Turn the `extractOrientation` helper function into
    a static helper method `BuilderBase::hasOrientationVertical`
    for reuse in the pending WIP Gerrit change to implement
    a `QtBuilder` [1], which currently duplicates this method
    in patch set 18.
    
    [1] https://gerrit.libreoffice.org/c/core/+/161831/18
    
    Change-Id: I8255188ae66727d0832e8d6b41952649de07a679
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173546
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx
index e6f20884ee80..0e93033499da 100644
--- a/include/vcl/builder.hxx
+++ b/include/vcl/builder.hxx
@@ -95,6 +95,7 @@ protected:
     static bool isToolbarItemClass(std::u16string_view sClass);
     static std::vector<vcl::EnumContext::Context> 
handleStyle(xmlreader::XmlReader &reader, int &nPriority);
     static OUString getStyleClass(xmlreader::XmlReader &reader);
+    static bool hasOrientationVertical(stringmap &rMap);
 
     bool isLegacy() { return m_bLegacy; }
     const std::locale& getResLocale() const;
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 51df1bac77fd..f597496647b4 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -997,18 +997,6 @@ namespace
         return bHasEntry;
     }
 
-    bool extractOrientation(VclBuilder::stringmap &rMap)
-    {
-        bool bVertical = false;
-        VclBuilder::stringmap::iterator aFind = rMap.find(u"orientation"_ustr);
-        if (aFind != rMap.end())
-        {
-            bVertical = aFind->second.equalsIgnoreAsciiCase("vertical");
-            rMap.erase(aFind);
-        }
-        return bVertical;
-    }
-
     bool extractVerticalTabPos(VclBuilder::stringmap &rMap)
     {
         bool bVertical = false;
@@ -1726,7 +1714,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window 
*pParent, const OUString
     }
     else if (name == "GtkBox" || name == "GtkStatusbar")
     {
-        bVertical = extractOrientation(rMap);
+        bVertical = hasOrientationVertical(rMap);
         if (bVertical)
             xWindow = VclPtr<VclVBox>::Create(pParent);
         else
@@ -1737,7 +1725,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window 
*pParent, const OUString
     }
     else if (name == "GtkPaned")
     {
-        bVertical = extractOrientation(rMap);
+        bVertical = hasOrientationVertical(rMap);
         if (bVertical)
             xWindow = VclPtr<VclVPaned>::Create(pParent);
         else
@@ -1749,7 +1737,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window 
*pParent, const OUString
         xWindow = VclPtr<VclVBox>::Create(pParent);
     else if (name == "GtkButtonBox")
     {
-        bVertical = extractOrientation(rMap);
+        bVertical = hasOrientationVertical(rMap);
         if (bVertical)
             xWindow = VclPtr<VclVButtonBox>::Create(pParent);
         else
@@ -2064,25 +2052,25 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window 
*pParent, const OUString
     }
     else if (name == "GtkSeparator")
     {
-        bVertical = extractOrientation(rMap);
+        bVertical = hasOrientationVertical(rMap);
         xWindow = VclPtr<FixedLine>::Create(pParent, bVertical ? WB_VERT : 
WB_HORZ);
     }
     else if (name == "GtkScrollbar")
     {
         extractAdjustmentToMap(id, rMap, 
m_pVclParserState->m_aScrollAdjustmentMaps);
-        bVertical = extractOrientation(rMap);
+        bVertical = hasOrientationVertical(rMap);
         xWindow = VclPtr<ScrollBar>::Create(pParent, bVertical ? WB_VERT : 
WB_HORZ);
     }
     else if (name == "GtkProgressBar")
     {
         extractAdjustmentToMap(id, rMap, 
m_pVclParserState->m_aScrollAdjustmentMaps);
-        bVertical = extractOrientation(rMap);
+        bVertical = hasOrientationVertical(rMap);
         xWindow = VclPtr<ProgressBar>::Create(pParent, bVertical ? WB_VERT : 
WB_HORZ, ProgressBar::BarStyle::Progress);
     }
     else if (name == "GtkLevelBar")
     {
         extractAdjustmentToMap(id, rMap, 
m_pVclParserState->m_aScrollAdjustmentMaps);
-        bVertical = extractOrientation(rMap);
+        bVertical = hasOrientationVertical(rMap);
         xWindow = VclPtr<ProgressBar>::Create(pParent, bVertical ? WB_VERT : 
WB_HORZ, ProgressBar::BarStyle::Level);
     }
     else if (name == "GtkScrolledWindow")
@@ -2140,7 +2128,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window 
*pParent, const OUString
             OUString sValuePos = extractValuePos(rMap);
             (void)sValuePos;
         }
-        bVertical = extractOrientation(rMap);
+        bVertical = hasOrientationVertical(rMap);
 
         WinBits nWinStyle = bVertical ? WB_VERT : WB_HORZ;
 
@@ -3989,6 +3977,18 @@ OUString BuilderBase::getStyleClass(xmlreader::XmlReader 
&reader)
     return aRet;
 }
 
+bool BuilderBase::hasOrientationVertical(VclBuilder::stringmap &rMap)
+{
+    bool bVertical = false;
+    VclBuilder::stringmap::iterator aFind = rMap.find(u"orientation"_ustr);
+    if (aFind != rMap.end())
+    {
+        bVertical = aFind->second.equalsIgnoreAsciiCase("vertical");
+        rMap.erase(aFind);
+    }
+    return bVertical;
+}
+
 void BuilderBase::collectProperty(xmlreader::XmlReader& reader, stringmap& 
rMap) const
 {
     xmlreader::Span name;

Reply via email to