[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - oox/source sd/qa

Grzegorz Araminowicz (via logerrit) logerrit at kemper.freedesktop.org
Thu Jul 11 08:28:38 UTC 2019


 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   76 ++++++--------------
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx |    3 
 2 files changed, 28 insertions(+), 51 deletions(-)

New commits:
commit e222aa0d7882d5365e6ea28e82613795f5a8629a
Author:     Grzegorz Araminowicz <grzegorz.araminowicz at collabora.com>
AuthorDate: Thu Apr 11 14:56:37 2019 +0200
Commit:     Grzegorz Araminowicz <grzegorz.araminowicz at collabora.com>
CommitDate: Thu Jul 11 10:27:56 2019 +0200

    SmartArt: better detecting connector arrow type
    
    * basing on provided conn alg params
    * also moved setting arrow direction from getConnectorType() to algorithms
    
    Change-Id: I76898a4ccad961edd389677c31e7d8c05bcdf5fe
    Reviewed-on: https://gerrit.libreoffice.org/70598
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/75395
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Grzegorz Araminowicz <grzegorz.araminowicz at collabora.com>

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 8d569bc8fa3b..9c83d95fea5d 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -87,56 +87,6 @@ sal_Int32 getPropertyFromConstraint(sal_Int32 nConstraint)
     return 0;
 }
 
-/// Determines the connector shape type from a linear alg.
-sal_Int32 getConnectorType(const oox::drawingml::LayoutNode* pNode)
-{
-    sal_Int32 nType = oox::XML_rightArrow;
-
-    if (!pNode)
-        return nType;
-
-    // This is cheaper than visiting the whole sub-tree.
-    if (pNode->getName().startsWith("hierChild"))
-        return oox::XML_bentConnector3;
-
-    for (const auto& pChild : pNode->getChildren())
-    {
-        auto pAlgAtom = dynamic_cast<oox::drawingml::AlgAtom*>(pChild.get());
-        if (!pAlgAtom)
-            continue;
-
-        switch (pAlgAtom->getType())
-        {
-            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_hierChild:
-            {
-                // TODO <dgm:param type="connRout" val="..."/> should be able
-                // to customize this.
-                nType = oox::XML_bentConnector3;
-                break;
-            }
-        }
-    }
-
-    return nType;
-}
-
 /**
  * Determines if pShape is (or contains) a presentation of a data node of type
  * nType.
@@ -444,6 +394,30 @@ void AlgAtom::accept( LayoutAtomVisitor& rVisitor )
     rVisitor.visit(*this);
 }
 
+sal_Int32 AlgAtom::getConnectorType()
+{
+    sal_Int32 nConnRout = 0;
+    sal_Int32 nBegSty = 0;
+    sal_Int32 nEndSty = 0;
+    if (maMap.count(oox::XML_connRout))
+        nConnRout = maMap.find(oox::XML_connRout)->second;
+    if (maMap.count(oox::XML_begSty))
+        nBegSty = maMap.find(oox::XML_begSty)->second;
+    if (maMap.count(oox::XML_endSty))
+        nEndSty = maMap.find(oox::XML_endSty)->second;
+
+    if (nConnRout == oox::XML_bend)
+        return oox::XML_bentConnector3;
+    if (nBegSty == oox::XML_arr && nEndSty == oox::XML_arr)
+        return oox::XML_leftRightArrow;
+    if (nBegSty == oox::XML_arr)
+        return oox::XML_leftArrow;
+    if (nEndSty == oox::XML_arr)
+        return oox::XML_rightArrow;
+
+    return oox::XML_rightArrow;
+}
+
 void AlgAtom::layoutShape( const ShapePtr& rShape,
                            const std::vector<Constraint>& rConstraints )
 {
@@ -559,7 +533,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
             {
                 // There is no shape type "conn", replace it by an arrow based
                 // on the direction of the parent linear layout.
-                sal_Int32 nType = getConnectorType(getLayoutNode().getParentLayoutNode());
+                sal_Int32 nType = getConnectorType();
 
                 rShape->setSubType(nType);
                 rShape->getCustomShapeProperties()->setShapePresetType(nType);
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
index 726e75e2b01e..c742f604a409 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
@@ -178,6 +178,9 @@ private:
     ParamMap  maMap;
     /// Aspect ratio is not integer, so not part of maMap.
     double mfAspectRatio = 0;
+
+    /// Determines the connector shape type for conn algorithm
+    sal_Int32 getConnectorType();
 };
 
 typedef std::shared_ptr< AlgAtom > AlgAtomPtr;
diff --git a/sd/qa/unit/data/pptx/smartart-mutidirectional.pptx b/sd/qa/unit/data/pptx/smartart-multidirectional.pptx
similarity index 100%
rename from sd/qa/unit/data/pptx/smartart-mutidirectional.pptx
rename to sd/qa/unit/data/pptx/smartart-multidirectional.pptx


More information about the Libreoffice-commits mailing list