[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - 2 commits - oox/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Wed Jan 20 13:57:25 UTC 2021


 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |  106 ++++++++++----------
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx |   10 +
 2 files changed, 66 insertions(+), 50 deletions(-)

New commits:
commit 6845a140ad6fb6640f9209e34cf7aa0865b8aea6
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Aug 10 20:47:32 2020 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Jan 20 14:57:07 2021 +0100

    loplugin:flatten
    
    (cherry picked from commit 2d582244680e7f6dec6e4a466e276f93ccb01dc9)
    
    Change-Id: I6560756eb63856a22b43e3e65a7b7843cd2d5376
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109702
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 58f6da680f97..6e9626c2f9fe 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -836,26 +836,26 @@ void ApplyConstraintToLayout(const Constraint& rConstraint, LayoutPropertyMap& r
     }
 
     const LayoutPropertyMap::const_iterator aRef = rProperties.find(rConstraint.msRefForName);
-    if (aRef != rProperties.end())
+    if (aRef == rProperties.end())
+        return;
+
+    const LayoutProperty::const_iterator aRefType = aRef->second.find(rConstraint.mnRefType);
+    if (aRefType != aRef->second.end())
+        rProperties[rConstraint.msForName][rConstraint.mnType]
+            = aRefType->second * rConstraint.mfFactor;
+    else
     {
-        const LayoutProperty::const_iterator aRefType = aRef->second.find(rConstraint.mnRefType);
-        if (aRefType != aRef->second.end())
-            rProperties[rConstraint.msForName][rConstraint.mnType]
-                = aRefType->second * rConstraint.mfFactor;
+        // Values are never in EMU, while oox::drawingml::Shape position and size are always in
+        // EMU.
+        double fUnitFactor = 0;
+        if (isFontUnit(rConstraint.mnRefType))
+            // Points -> EMU.
+            fUnitFactor = EMU_PER_PT;
         else
-        {
-            // Values are never in EMU, while oox::drawingml::Shape position and size are always in
-            // EMU.
-            double fUnitFactor = 0;
-            if (isFontUnit(rConstraint.mnRefType))
-                // Points -> EMU.
-                fUnitFactor = EMU_PER_PT;
-            else
-                // Millimeters -> EMU.
-                fUnitFactor = EMU_PER_HMM * 100;
-            rProperties[rConstraint.msForName][rConstraint.mnType]
-                = rConstraint.mfValue * fUnitFactor;
-        }
+            // Millimeters -> EMU.
+            fUnitFactor = EMU_PER_HMM * 100;
+        rProperties[rConstraint.msForName][rConstraint.mnType]
+            = rConstraint.mfValue * fUnitFactor;
     }
 }
 
commit 26fc0fb9b2c66c94078c27ac07ded465cdc50325
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Jan 13 15:10:48 2021 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Jan 20 14:56:51 2021 +0100

    oox smartart: extract pyra algo from AlgAtom::layoutShape()
    
    AlgAtom::layoutShape() is more or less the single function where all
    layouting happens for all algoritms. Extract the pyra algorithm part
    from it to a separate PyraAlg::layoutShapeChildren() before that
    function grows too large.
    
    (cherry picked from commit 318438a680e6bf5c2c592d5e997f6f45a4ae8e5f)
    
    Change-Id: I097ac9ed6110536bbeb8a26ab35a8ee8a79d5b33
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109701
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 6a33148a7993..58f6da680f97 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -440,6 +440,43 @@ void SnakeAlg::layoutShapeChildren(const AlgAtom::ParamMap& rMap, const ShapePtr
     }
 }
 
+void PyraAlg::layoutShapeChildren(const ShapePtr& rShape)
+{
+    if (rShape->getChildren().empty() || rShape->getSize().Width == 0
+        || rShape->getSize().Height == 0)
+        return;
+
+    // const sal_Int32 nDir = maMap.count(XML_linDir) ? maMap.find(XML_linDir)->second : XML_fromT;
+    // const sal_Int32 npyraAcctPos = maMap.count(XML_pyraAcctPos) ? maMap.find(XML_pyraAcctPos)->second : XML_bef;
+    // const sal_Int32 ntxDir = maMap.count(XML_txDir) ? maMap.find(XML_txDir)->second : XML_fromT;
+    // const sal_Int32 npyraLvlNode = maMap.count(XML_pyraLvlNode) ? maMap.find(XML_pyraLvlNode)->second : XML_level;
+    // uncomment when use in code.
+
+    sal_Int32 nCount = rShape->getChildren().size();
+    double fAspectRatio = 0.32;
+
+    awt::Size aChildSize = rShape->getSize();
+    aChildSize.Width /= nCount;
+    aChildSize.Height /= nCount;
+
+    awt::Point aCurrPos(0, 0);
+    aCurrPos.X = fAspectRatio * aChildSize.Width * (nCount - 1);
+    aCurrPos.Y = fAspectRatio * aChildSize.Height;
+
+    for (auto& aCurrShape : rShape->getChildren())
+    {
+        aCurrShape->setPosition(aCurrPos);
+        if (nCount > 1)
+        {
+            aCurrPos.X -= aChildSize.Height / (nCount - 1);
+        }
+        aChildSize.Width += aChildSize.Height;
+        aCurrShape->setSize(aChildSize);
+        aCurrShape->setChildSize(aChildSize);
+        aCurrPos.Y += (aChildSize.Height);
+    }
+}
+
 IteratorAttr::IteratorAttr( )
     : mnCnt( -1 )
     , mbHideLastTrans( true )
@@ -1594,38 +1631,7 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector<Constraint>&
 
         case XML_pyra:
         {
-            if (rShape->getChildren().empty() || rShape->getSize().Width == 0 || rShape->getSize().Height == 0)
-                break;
-
-            // const sal_Int32 nDir = maMap.count(XML_linDir) ? maMap.find(XML_linDir)->second : XML_fromT;
-            // const sal_Int32 npyraAcctPos = maMap.count(XML_pyraAcctPos) ? maMap.find(XML_pyraAcctPos)->second : XML_bef;
-            // const sal_Int32 ntxDir = maMap.count(XML_txDir) ? maMap.find(XML_txDir)->second : XML_fromT;
-            // const sal_Int32 npyraLvlNode = maMap.count(XML_pyraLvlNode) ? maMap.find(XML_pyraLvlNode)->second : XML_level;
-            // uncomment when use in code.
-
-            sal_Int32 nCount = rShape->getChildren().size();
-            double fAspectRatio = 0.32;
-
-            awt::Size aChildSize = rShape->getSize();
-            aChildSize.Width /= nCount;
-            aChildSize.Height /= nCount;
-
-            awt::Point aCurrPos(0, 0);
-            aCurrPos.X = fAspectRatio*aChildSize.Width*(nCount-1);
-            aCurrPos.Y = fAspectRatio*aChildSize.Height;
-
-            for (auto & aCurrShape : rShape->getChildren())
-            {
-                aCurrShape->setPosition(aCurrPos);
-                if (nCount > 1)
-                {
-                    aCurrPos.X -= aChildSize.Height / (nCount - 1);
-                }
-                aChildSize.Width += aChildSize.Height;
-                aCurrShape->setSize(aChildSize);
-                aCurrShape->setChildSize(aChildSize);
-                aCurrPos.Y += (aChildSize.Height);
-            }
+            PyraAlg::layoutShapeChildren(rShape);
             break;
         }
 
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
index 571cca641d78..80f6b2d9bb0d 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
@@ -210,6 +210,16 @@ public:
                                     const std::vector<Constraint>& rConstraints);
 };
 
+/**
+ * Lays out child layout nodes along a vertical path and works with the trapezoid shape to create a
+ * pyramid.
+ */
+class PyraAlg
+{
+public:
+    static void layoutShapeChildren(const ShapePtr& rShape);
+};
+
 class ForEachAtom
     : public LayoutAtom
 {


More information about the Libreoffice-commits mailing list