diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2019-02-25 16:46:15 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-02-25 19:28:46 +0100 |
commit | a1e10b7968fbf4dba962349be8a6dfb0cb1d3176 (patch) | |
tree | 6c3b70d0d3c30680da676b99f60fd3378885c6f4 /oox | |
parent | 3d58288eae759565c5417223af80926098312328 (diff) |
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@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 6 | ||||
-rw-r--r-- | oox/source/drawingml/diagram/diagramlayoutatoms.hxx | 27 | ||||
-rw-r--r-- | oox/source/drawingml/diagram/layoutatomvisitors.cxx | 4 | ||||
-rw-r--r-- | oox/source/drawingml/diagram/layoutnodecontext.cxx | 1 | ||||
-rw-r--r-- | oox/source/drawingml/shape.cxx | 1 |
5 files changed, 26 insertions, 13 deletions
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() |