vcl/source/window/builder.cxx |   36 +++++++++++++++---------------------
 1 file changed, 15 insertions(+), 21 deletions(-)

New commits:
commit 0d3433d74f1e9f1e6b3fc8b110c3892186d4aa71
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Sep 20 12:11:06 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Sat Sep 21 09:07:30 2024 +0200

    tdf#130857 VclBuilder: Use existing toBool helper
    
    Don't duplicate the logic here.
    
    Change-Id: I83f1b964c74f097563d8d1c33a2fce7d9fe7f7f1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173712
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 1ad849ee684a..7369507515c0 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -3848,7 +3848,7 @@ void VclBuilder::applyPackingProperty(vcl::Window 
*pCurrent,
 
             if (sKey == u"expand"_ustr || sKey == u"resize"_ustr)
             {
-                bool bTrue = (!sValue.isEmpty() && (sValue[0] == 't' || 
sValue[0] == 'T' || sValue[0] == '1'));
+                bool bTrue = toBool(sValue);
                 if (pToolBoxParent)
                     
pToolBoxParent->SetItemExpand(m_pVclParserState->m_nLastToolbarId, bTrue);
                 else
@@ -3861,8 +3861,7 @@ void VclBuilder::applyPackingProperty(vcl::Window 
*pCurrent,
 
             if (sKey == u"fill"_ustr)
             {
-                bool bTrue = (!sValue.isEmpty() && (sValue[0] == 't' || 
sValue[0] == 'T' || sValue[0] == '1'));
-                pCurrent->set_fill(bTrue);
+                pCurrent->set_fill(toBool(sValue));
             }
             else if (sKey == u"pack-type"_ustr)
             {
commit b6049f4758b76a2d1c704725b4c06a5f42ce8e7e
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Sep 20 12:04:56 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Sat Sep 21 09:07:21 2024 +0200

    tdf#130857 VclBuilder: Use OUString instead of OString
    
    Use OUString here as well, and drop the now
    unused toBool variant taking a `std::string_view`
    instead of a `std::u16_string_view`.
    
    Change-Id: I8879b4dcf170db4911fd0f0a2759cbb8c067f4e1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173711
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 3215c89f3e2c..1ad849ee684a 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -89,11 +89,6 @@
 #include <dlfcn.h>
 #endif
 
-static bool toBool(std::string_view rValue)
-{
-    return (!rValue.empty() && (rValue[0] == 't' || rValue[0] == 'T' || 
rValue[0] == '1'));
-}
-
 bool toBool(std::u16string_view rValue)
 {
     return (!rValue.empty() && (rValue[0] == 't' || rValue[0] == 'T' || 
rValue[0] == '1'));
@@ -3845,13 +3840,13 @@ void VclBuilder::applyPackingProperty(vcl::Window 
*pCurrent,
         if (name == "name")
         {
             name = reader.getAttributeValue(false);
-            OString sKey(name.begin, name.length);
+            OUString sKey(name.begin, name.length, RTL_TEXTENCODING_UTF8);
             sKey = sKey.replace('_', '-');
             (void)reader.nextItem(
                 xmlreader::XmlReader::Text::Raw, &name, &nsId);
-            OString sValue(name.begin, name.length);
+            OUString sValue(name.begin, name.length, RTL_TEXTENCODING_UTF8);
 
-            if (sKey == "expand" || sKey == "resize")
+            if (sKey == u"expand"_ustr || sKey == u"resize"_ustr)
             {
                 bool bTrue = (!sValue.isEmpty() && (sValue[0] == 't' || 
sValue[0] == 'T' || sValue[0] == '1'));
                 if (pToolBoxParent)
@@ -3864,45 +3859,45 @@ void VclBuilder::applyPackingProperty(vcl::Window 
*pCurrent,
             if (pToolBoxParent)
                 continue;
 
-            if (sKey == "fill")
+            if (sKey == u"fill"_ustr)
             {
                 bool bTrue = (!sValue.isEmpty() && (sValue[0] == 't' || 
sValue[0] == 'T' || sValue[0] == '1'));
                 pCurrent->set_fill(bTrue);
             }
-            else if (sKey == "pack-type")
+            else if (sKey == u"pack-type"_ustr)
             {
                 VclPackType ePackType = (!sValue.isEmpty() && (sValue[0] == 
'e' || sValue[0] == 'E')) ? VclPackType::End : VclPackType::Start;
                 pCurrent->set_pack_type(ePackType);
             }
-            else if (sKey == "left-attach")
+            else if (sKey == u"left-attach"_ustr)
             {
                 pCurrent->set_grid_left_attach(sValue.toInt32());
             }
-            else if (sKey == "top-attach")
+            else if (sKey == u"top-attach"_ustr)
             {
                 pCurrent->set_grid_top_attach(sValue.toInt32());
             }
-            else if (sKey == "width")
+            else if (sKey == u"width"_ustr)
             {
                 pCurrent->set_grid_width(sValue.toInt32());
             }
-            else if (sKey == "height")
+            else if (sKey == u"height"_ustr)
             {
                 pCurrent->set_grid_height(sValue.toInt32());
             }
-            else if (sKey == "padding")
+            else if (sKey == u"padding"_ustr)
             {
                 pCurrent->set_padding(sValue.toInt32());
             }
-            else if (sKey == "position")
+            else if (sKey == u"position"_ustr)
             {
                 set_window_packing_position(pCurrent, sValue.toInt32());
             }
-            else if (sKey == "secondary")
+            else if (sKey == u"secondary"_ustr)
             {
                 pCurrent->set_secondary(toBool(sValue));
             }
-            else if (sKey == "non-homogeneous")
+            else if (sKey == u"non-homogeneous"_ustr)
             {
                 pCurrent->set_non_homogeneous(toBool(sValue));
             }

Reply via email to