[Libreoffice-commits] core.git: oox/source sd/qa

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Jan 18 19:43:26 UTC 2019


 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   40 +++++++++++++-------
 sd/qa/unit/import-tests-smartart.cxx                |    4 ++
 2 files changed, 30 insertions(+), 14 deletions(-)

New commits:
commit 1791e08e9f27453ac5563ef400c715e30c791133
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Jan 18 15:48:57 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Jan 18 20:43:00 2019 +0100

    oox smartart, org chart: fix shape type of connectors
    
    PowerPoint renders these as bent connectors, not as arrow shapes.
    
    Also add a bit of vertical spacing between the nodes, otherwise the
    connectors have no way to be visible. Their position is still incorrect,
    though.
    
    Change-Id: I995930c0bbc1bdb1014face2490be392571548a2
    Reviewed-on: https://gerrit.libreoffice.org/66627
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 4495ae8a570d..f7da2cc03515 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -79,21 +79,32 @@ sal_Int32 getConnectorType(const oox::drawingml::LayoutNode* pNode)
         if (!pAlgAtom)
             continue;
 
-        if (pAlgAtom->getType() != oox::XML_lin)
-            continue;
-
-        sal_Int32 nDir = oox::XML_fromL;
-        if (pAlgAtom->getMap().count(oox::XML_linDir))
-            nDir = pAlgAtom->getMap().find(oox::XML_linDir)->second;
-
-        switch (nDir)
+        switch (pAlgAtom->getType())
         {
-            case oox::XML_fromL:
-                nType = oox::XML_rightArrow;
+            case oox::XML_lin:
+            {
+                sal_Int32 nDir = oox::XML_fromL;
+                if (pAlgAtom->getMap().count(oox::XML_linDir))
+                    nDir = pAlgAtom->getMap().find(oox::XML_linDir)->second;
+
+                switch (nDir)
+                {
+                    case oox::XML_fromL:
+                        nType = oox::XML_rightArrow;
+                        break;
+                    case oox::XML_fromR:
+                        nType = oox::XML_leftArrow;
+                        break;
+                }
                 break;
-            case oox::XML_fromR:
-                nType = oox::XML_leftArrow;
+            }
+            case oox::XML_hierChild:
+            {
+                // TODO <dgm:param type="connRout" val="..."/> should be able
+                // to customize this.
+                nType = oox::XML_bentConnector3;
                 break;
+            }
         }
     }
 
@@ -618,6 +629,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
                 break;
 
             sal_Int32 nCount = rShape->getChildren().size();
+            double fSpace = 0.3;
 
             if (mnType == XML_hierChild)
             {
@@ -652,7 +664,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
             awt::Size aChildSize = rShape->getSize();
             if (nDir == XML_fromT)
             {
-                aChildSize.Height /= nCount;
+                aChildSize.Height /= (nCount + nCount * fSpace);
             }
             else
                 aChildSize.Width /= nCount;
@@ -672,7 +684,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
                     continue;
 
                 if (nDir == XML_fromT)
-                    aChildPos.Y += aChildSize.Height;
+                    aChildPos.Y += aChildSize.Height + aChildSize.Height * fSpace;
                 else
                     aChildPos.X += aChildSize.Width;
             }
diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx
index 34b9ea439544..ee25c47fbd8e 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -796,6 +796,10 @@ void SdImportTestSmartArt::testOrgChart()
     // manager2 has no assistants / employees.
     CPPUNIT_ASSERT_GREATER(aManagerSize.Width, aEmployeeSize.Width + aEmployee2Size.Width);
 
+    // Without the accompanying fix in place, this test would have failed: an
+    // employee was exactly the third of the total height, without any spacing.
+    CPPUNIT_ASSERT_LESS(xGroup->getSize().Height / 3, aEmployeeSize.Height);
+
     xDocShRef->DoClose();
 }
 


More information about the Libreoffice-commits mailing list