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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Feb 25 18:29:11 UTC 2019


 include/oox/drawingml/shape.hxx                     |    7 +++++
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |    6 ++--
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx |   27 ++++++++++++--------
 oox/source/drawingml/diagram/layoutatomvisitors.cxx |    4 ++
 oox/source/drawingml/diagram/layoutnodecontext.cxx  |    1 
 oox/source/drawingml/shape.cxx                      |    1 
 6 files changed, 33 insertions(+), 13 deletions(-)

New commits:
commit a1e10b7968fbf4dba962349be8a6dfb0cb1d3176
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Feb 25 16:46:15 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Feb 25 19:28:46 2019 +0100

    oox smartart, picture strip: expose aspect ratio of children for snake algo
    
    The aspect ratio request of the Shape is not yet used in
    AlgAtom::layoutShape(), though.
    
    The heavy-lifting is needed, because the number of cols/rows in the
    snake algorithm depends on the aspect ratio request from the child
    algorithm, so need to transfer the aspect ratio from child algorithm ->
    layout node -> shape -> parent algorithm.
    
    Still no functional changes intended.
    
    Change-Id: I8cbe53cfac0965ab5d8c05f75fe27e819de6836a
    Reviewed-on: https://gerrit.libreoffice.org/68354
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx
index c8ffa1b278df..0e3263179fa6 100644
--- a/include/oox/drawingml/shape.hxx
+++ b/include/oox/drawingml/shape.hxx
@@ -220,6 +220,10 @@ public:
 
     sal_Int32 getDataNodeType() const { return mnDataNodeType; }
 
+    void setAspectRatio(double fAspectRatio) { mfAspectRatio = fAspectRatio; }
+
+    double getAspectRatio() const { return mfAspectRatio; }
+
     /// Changes reference semantics to value semantics for fill properties.
     void cloneFillProperties();
 
@@ -347,6 +351,9 @@ private:
 
     /// Type of data node for an in-diagram shape.
     sal_Int32 mnDataNodeType = 0;
+
+    /// Aspect ratio for an in-diagram shape.
+    double mfAspectRatio = 0;
 };
 
 } }
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 837755e189d4..5af87e0851b8 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -245,7 +245,7 @@ void LayoutAtom::dump(int level)
         pAtom->dump(level + 1);
 }
 
-ForEachAtom::ForEachAtom(const LayoutNode& rLayoutNode, const Reference< XFastAttributeList >& xAttributes) :
+ForEachAtom::ForEachAtom(LayoutNode& rLayoutNode, const Reference< XFastAttributeList >& xAttributes) :
     LayoutAtom(rLayoutNode)
 {
     maIter.loadFromXAttr(xAttributes);
@@ -272,7 +272,7 @@ const std::vector<LayoutAtomPtr>& ChooseAtom::getChildren() const
     return maEmptyChildren;
 }
 
-ConditionAtom::ConditionAtom(const LayoutNode& rLayoutNode, bool isElse, const Reference< XFastAttributeList >& xAttributes) :
+ConditionAtom::ConditionAtom(LayoutNode& rLayoutNode, bool isElse, const Reference< XFastAttributeList >& xAttributes) :
     LayoutAtom(rLayoutNode),
     mIsElse(isElse)
 {
@@ -463,7 +463,7 @@ void AlgAtom::accept( LayoutAtomVisitor& rVisitor )
 }
 
 void AlgAtom::layoutShape( const ShapePtr& rShape,
-                           const std::vector<Constraint>& rOwnConstraints ) const
+                           const std::vector<Constraint>& rOwnConstraints )
 {
     // Algorithm result may depend on the parent constraints as well.
     std::vector<Constraint> aMergedConstraints;
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
index f056e4f7e637..d70878e063aa 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
@@ -91,10 +91,10 @@ typedef std::shared_ptr< LayoutAtom > LayoutAtomPtr;
 class LayoutAtom
 {
 public:
-    LayoutAtom(const LayoutNode& rLayoutNode) : mrLayoutNode(rLayoutNode) {}
+    LayoutAtom(LayoutNode& rLayoutNode) : mrLayoutNode(rLayoutNode) {}
     virtual ~LayoutAtom() { }
 
-    const LayoutNode& getLayoutNode() const
+    LayoutNode& getLayoutNode()
         { return mrLayoutNode; }
 
     /** visitor acceptance
@@ -127,7 +127,7 @@ public:
     void dump(int level = 0);
 
 protected:
-    const LayoutNode&            mrLayoutNode;
+    LayoutNode&            mrLayoutNode;
     std::vector< LayoutAtomPtr > mpChildNodes;
     std::weak_ptr<LayoutAtom> mpParent;
     OUString                     msName;
@@ -137,7 +137,7 @@ class ConstraintAtom
     : public LayoutAtom
 {
 public:
-    ConstraintAtom(const LayoutNode& rLayoutNode) : LayoutAtom(rLayoutNode) {}
+    ConstraintAtom(LayoutNode& rLayoutNode) : LayoutAtom(rLayoutNode) {}
     virtual void accept( LayoutAtomVisitor& ) override;
     Constraint& getConstraint()
         { return maConstraint; }
@@ -150,7 +150,7 @@ class AlgAtom
     : public LayoutAtom
 {
 public:
-    AlgAtom(const LayoutNode& rLayoutNode) : LayoutAtom(rLayoutNode), mnType(0), maMap() {}
+    AlgAtom(LayoutNode& rLayoutNode) : LayoutAtom(rLayoutNode), mnType(0), maMap() {}
 
     typedef std::map<sal_Int32,sal_Int32> ParamMap;
 
@@ -161,7 +161,7 @@ public:
     void addParam( sal_Int32 nType, sal_Int32 nVal )
         { maMap[nType]=nVal; }
     void layoutShape( const ShapePtr& rShape,
-                      const std::vector<Constraint>& rConstraints ) const;
+                      const std::vector<Constraint>& rConstraints );
 
     /// Gives access to <dgm:alg type="..."/>.
     sal_Int32 getType() const { return mnType; }
@@ -171,6 +171,8 @@ public:
 
     void setAspectRatio(double fAspectRatio) { mfAspectRatio = fAspectRatio; }
 
+    double getAspectRatio() const { return mfAspectRatio; }
+
 private:
     sal_Int32 mnType;
     ParamMap  maMap;
@@ -184,7 +186,7 @@ class ForEachAtom
     : public LayoutAtom
 {
 public:
-    explicit ForEachAtom(const LayoutNode& rLayoutNode, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttributes);
+    explicit ForEachAtom(LayoutNode& rLayoutNode, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttributes);
 
     IteratorAttr & iterator()
         { return maIter; }
@@ -200,7 +202,7 @@ class ConditionAtom
     : public LayoutAtom
 {
 public:
-    explicit ConditionAtom(const LayoutNode& rLayoutNode, bool isElse, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttributes);
+    explicit ConditionAtom(LayoutNode& rLayoutNode, bool isElse, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttributes);
     virtual void accept( LayoutAtomVisitor& ) override;
     bool getDecision() const;
 private:
@@ -220,7 +222,7 @@ class ChooseAtom
     : public LayoutAtom
 {
 public:
-    ChooseAtom(const LayoutNode& rLayoutNode)
+    ChooseAtom(LayoutNode& rLayoutNode)
         : LayoutAtom(rLayoutNode)
 #if defined __clang__ && __clang_major__ == 3 && __clang_minor__ == 8
         , maEmptyChildren()
@@ -264,6 +266,10 @@ public:
 
     const LayoutNode* getParentLayoutNode() const;
 
+    void setAlgAtom(AlgAtomPtr pAlgAtom) { mpAlgAtom = pAlgAtom; }
+
+    AlgAtomPtr getAlgAtom() const { return mpAlgAtom.lock(); }
+
 private:
     const Diagram&               mrDgm;
     VarMap                       mVariables;
@@ -272,6 +278,7 @@ private:
     ShapePtr                     mpExistingShape;
     std::vector<ShapePtr>        mpNodeShapes;
     sal_Int32                    mnChildOrder;
+    std::weak_ptr<AlgAtom>       mpAlgAtom;
 };
 
 typedef std::shared_ptr< LayoutNode > LayoutNodePtr;
@@ -280,7 +287,7 @@ class ShapeAtom
     : public LayoutAtom
 {
 public:
-    ShapeAtom(const LayoutNode& rLayoutNode, const ShapePtr& pShape) : LayoutAtom(rLayoutNode), mpShapeTemplate(pShape) {}
+    ShapeAtom(LayoutNode& rLayoutNode, const ShapePtr& pShape) : LayoutAtom(rLayoutNode), mpShapeTemplate(pShape) {}
     virtual void accept( LayoutAtomVisitor& ) override;
     const ShapePtr& getShapeTemplate() const
         { return mpShapeTemplate; }
diff --git a/oox/source/drawingml/diagram/layoutatomvisitors.cxx b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
index ff37f816d789..a45317f9ffe4 100644
--- a/oox/source/drawingml/diagram/layoutatomvisitors.cxx
+++ b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
@@ -133,6 +133,8 @@ void ShapeCreationVisitor::visit(LayoutNode& rAtom)
         if (rAtom.setupShape(pShape, pNewNode))
         {
             pShape->setInternalName(rAtom.getName());
+            if (AlgAtomPtr pAlgAtom = rAtom.getAlgAtom())
+                pShape->setAspectRatio(pAlgAtom->getAspectRatio());
             rAtom.addNodeShape(pShape);
         }
     }
@@ -153,6 +155,8 @@ void ShapeCreationVisitor::visit(LayoutNode& rAtom)
             if (rAtom.setupShape(pShape, pNewNode))
             {
                 pShape->setInternalName(rAtom.getName());
+                if (AlgAtomPtr pAlgAtom = rAtom.getAlgAtom())
+                    pShape->setAspectRatio(pAlgAtom->getAspectRatio());
                 pCurrParent->addChild(pShape);
                 pCurrParent = pShape;
                 rAtom.addNodeShape(pShape);
diff --git a/oox/source/drawingml/diagram/layoutnodecontext.cxx b/oox/source/drawingml/diagram/layoutnodecontext.cxx
index ff508a24fcae..10070063c8ec 100644
--- a/oox/source/drawingml/diagram/layoutnodecontext.cxx
+++ b/oox/source/drawingml/diagram/layoutnodecontext.cxx
@@ -231,6 +231,7 @@ LayoutNodeContext::onCreateContext( ::sal_Int32 aElement,
         // CT_Algorithm
         AlgAtomPtr pAtom( new AlgAtom(mpNode->getLayoutNode()) );
         LayoutAtom::connect(mpNode, pAtom);
+        mpNode->getLayoutNode().setAlgAtom(pAtom);
         return new AlgorithmContext( *this, rAttribs, pAtom );
     }
     case DGM_TOKEN( choose ):
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index ac137e6f7d2f..e35a9b2e7703 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -179,6 +179,7 @@ Shape::Shape( const ShapePtr& pSourceShape )
 , mnZOrder(pSourceShape->mnZOrder)
 , mnZOrderOff(pSourceShape->mnZOrderOff)
 , mnDataNodeType(pSourceShape->mnDataNodeType)
+, mfAspectRatio(pSourceShape->mfAspectRatio)
 {}
 
 Shape::~Shape()


More information about the Libreoffice-commits mailing list