[Libreoffice-commits] core.git: vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri May 14 07:57:02 UTC 2021


 vcl/unx/gtk3/gtkinst.cxx |   41 ++++++++++++++++++++++++++++++++++++-----
 1 file changed, 36 insertions(+), 5 deletions(-)

New commits:
commit 738a39c175f46d62102556423349e416f01c7993
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu May 13 21:00:27 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri May 14 09:56:18 2021 +0200

    gtk4: move border width down to first child as margins
    
    Change-Id: I7bd1df9abd047780e6fe52c9a2acd56f5df25e4c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115572
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 7c8caee2a4d6..f9294c6b9be7 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -17546,12 +17546,14 @@ void ConvertTree(const Reference<css::xml::dom::XNode>& xNode)
     css::uno::Reference<css::xml::dom::XNodeList> xNodeList = xNode->getChildNodes();
     if (!xNodeList.is())
         return;
+
     std::vector<css::uno::Reference<css::xml::dom::XNode>> xRemoveList;
-    sal_Int32 nNodeCount = xNodeList->getLength();
-    for (sal_Int32 i = 0; i < nNodeCount; ++i)
-    {
-        css::uno::Reference<css::xml::dom::XNode> xChild = xNodeList->item(i);
 
+    OUString sBorderWidth;
+
+    for (css::uno::Reference<css::xml::dom::XNode> xChild = xNode->getFirstChild();
+         xChild.is(); xChild = xChild->getNextSibling())
+    {
         if (xChild->getNodeName() == "requires")
         {
             css::uno::Reference<css::xml::dom::XNamedNodeMap> xMap = xChild->getAttributes();
@@ -17567,6 +17569,10 @@ void ConvertTree(const Reference<css::xml::dom::XNode>& xNode)
             css::uno::Reference<css::xml::dom::XNamedNodeMap> xMap = xChild->getAttributes();
             css::uno::Reference<css::xml::dom::XNode> xName = xMap->getNamedItem("name");
             OUString sName(xName->getNodeValue().replace('_', '-'));
+
+            if (sName == "border-width")
+                sBorderWidth = OUString::number(12);
+
             if (sName == "type-hint" || sName == "skip-taskbar-hint" ||
                 sName == "can-default" || sName == "has-default" ||
                 sName == "border-width" || sName == "layout-style" ||
@@ -17578,6 +17584,32 @@ void ConvertTree(const Reference<css::xml::dom::XNode>& xNode)
         }
         else if (xChild->getNodeName() == "child")
         {
+            if (!sBorderWidth.isEmpty())
+            {
+                for (css::uno::Reference<css::xml::dom::XNode> xObjectCandidate = xChild->getFirstChild();
+                     xObjectCandidate.is();
+                     xObjectCandidate = xObjectCandidate->getNextSibling())
+                {
+                    if (xObjectCandidate->getNodeName() == "object")
+                    {
+                        auto xDoc = xChild->getOwnerDocument();
+                        auto xMarginEnd = CreateProperty(xDoc, "margin-end", sBorderWidth);
+
+                        auto xFirstChild = xObjectCandidate->getFirstChild();
+                        if (xFirstChild.is())
+                            xObjectCandidate->insertBefore(xMarginEnd, xFirstChild);
+                        else
+                            xObjectCandidate->appendChild(xMarginEnd);
+
+                        xObjectCandidate->insertBefore(CreateProperty(xDoc, "margin-top", sBorderWidth), xMarginEnd);
+                        xObjectCandidate->insertBefore(CreateProperty(xDoc, "margin-bottom", sBorderWidth), xMarginEnd);
+                        xObjectCandidate->insertBefore(CreateProperty(xDoc, "margin-start", sBorderWidth), xMarginEnd);
+                        break;
+                    }
+                }
+                sBorderWidth.clear();
+            }
+
             css::uno::Reference<css::xml::dom::XNamedNodeMap> xMap = xChild->getAttributes();
             css::uno::Reference<css::xml::dom::XNode> xName = xMap->getNamedItem("internal-child");
             if (xName)
@@ -17649,7 +17681,6 @@ void ConvertTree(const Reference<css::xml::dom::XNode>& xNode)
                 // go back to parent and find the object child and insert this "layout" as a
                 // new child of the object
                 auto xParent = xChild->getParentNode();
-                auto xInsertIn = xParent->getFirstChild();
                 for (css::uno::Reference<css::xml::dom::XNode> xObjectCandidate = xParent->getFirstChild();
                      xObjectCandidate.is();
                      xObjectCandidate = xObjectCandidate->getNextSibling())


More information about the Libreoffice-commits mailing list