Kaydet (Commit) a1e10b79 authored tarafından Miklos Vajna's avatar Miklos Vajna

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/68354Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
üst 3d58288e
...@@ -220,6 +220,10 @@ public: ...@@ -220,6 +220,10 @@ public:
sal_Int32 getDataNodeType() const { return mnDataNodeType; } 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. /// Changes reference semantics to value semantics for fill properties.
void cloneFillProperties(); void cloneFillProperties();
...@@ -347,6 +351,9 @@ private: ...@@ -347,6 +351,9 @@ private:
/// Type of data node for an in-diagram shape. /// Type of data node for an in-diagram shape.
sal_Int32 mnDataNodeType = 0; sal_Int32 mnDataNodeType = 0;
/// Aspect ratio for an in-diagram shape.
double mfAspectRatio = 0;
}; };
} } } }
......
...@@ -245,7 +245,7 @@ void LayoutAtom::dump(int level) ...@@ -245,7 +245,7 @@ void LayoutAtom::dump(int level)
pAtom->dump(level + 1); pAtom->dump(level + 1);
} }
ForEachAtom::ForEachAtom(const LayoutNode& rLayoutNode, const Reference< XFastAttributeList >& xAttributes) : ForEachAtom::ForEachAtom(LayoutNode& rLayoutNode, const Reference< XFastAttributeList >& xAttributes) :
LayoutAtom(rLayoutNode) LayoutAtom(rLayoutNode)
{ {
maIter.loadFromXAttr(xAttributes); maIter.loadFromXAttr(xAttributes);
...@@ -272,7 +272,7 @@ const std::vector<LayoutAtomPtr>& ChooseAtom::getChildren() const ...@@ -272,7 +272,7 @@ const std::vector<LayoutAtomPtr>& ChooseAtom::getChildren() const
return maEmptyChildren; 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), LayoutAtom(rLayoutNode),
mIsElse(isElse) mIsElse(isElse)
{ {
...@@ -463,7 +463,7 @@ void AlgAtom::accept( LayoutAtomVisitor& rVisitor ) ...@@ -463,7 +463,7 @@ void AlgAtom::accept( LayoutAtomVisitor& rVisitor )
} }
void AlgAtom::layoutShape( const ShapePtr& rShape, 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. // Algorithm result may depend on the parent constraints as well.
std::vector<Constraint> aMergedConstraints; std::vector<Constraint> aMergedConstraints;
......
...@@ -91,10 +91,10 @@ typedef std::shared_ptr< LayoutAtom > LayoutAtomPtr; ...@@ -91,10 +91,10 @@ typedef std::shared_ptr< LayoutAtom > LayoutAtomPtr;
class LayoutAtom class LayoutAtom
{ {
public: public:
LayoutAtom(const LayoutNode& rLayoutNode) : mrLayoutNode(rLayoutNode) {} LayoutAtom(LayoutNode& rLayoutNode) : mrLayoutNode(rLayoutNode) {}
virtual ~LayoutAtom() { } virtual ~LayoutAtom() { }
const LayoutNode& getLayoutNode() const LayoutNode& getLayoutNode()
{ return mrLayoutNode; } { return mrLayoutNode; }
/** visitor acceptance /** visitor acceptance
...@@ -127,7 +127,7 @@ public: ...@@ -127,7 +127,7 @@ public:
void dump(int level = 0); void dump(int level = 0);
protected: protected:
const LayoutNode& mrLayoutNode; LayoutNode& mrLayoutNode;
std::vector< LayoutAtomPtr > mpChildNodes; std::vector< LayoutAtomPtr > mpChildNodes;
std::weak_ptr<LayoutAtom> mpParent; std::weak_ptr<LayoutAtom> mpParent;
OUString msName; OUString msName;
...@@ -137,7 +137,7 @@ class ConstraintAtom ...@@ -137,7 +137,7 @@ class ConstraintAtom
: public LayoutAtom : public LayoutAtom
{ {
public: public:
ConstraintAtom(const LayoutNode& rLayoutNode) : LayoutAtom(rLayoutNode) {} ConstraintAtom(LayoutNode& rLayoutNode) : LayoutAtom(rLayoutNode) {}
virtual void accept( LayoutAtomVisitor& ) override; virtual void accept( LayoutAtomVisitor& ) override;
Constraint& getConstraint() Constraint& getConstraint()
{ return maConstraint; } { return maConstraint; }
...@@ -150,7 +150,7 @@ class AlgAtom ...@@ -150,7 +150,7 @@ class AlgAtom
: public LayoutAtom : public LayoutAtom
{ {
public: 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; typedef std::map<sal_Int32,sal_Int32> ParamMap;
...@@ -161,7 +161,7 @@ public: ...@@ -161,7 +161,7 @@ public:
void addParam( sal_Int32 nType, sal_Int32 nVal ) void addParam( sal_Int32 nType, sal_Int32 nVal )
{ maMap[nType]=nVal; } { maMap[nType]=nVal; }
void layoutShape( const ShapePtr& rShape, void layoutShape( const ShapePtr& rShape,
const std::vector<Constraint>& rConstraints ) const; const std::vector<Constraint>& rConstraints );
/// Gives access to <dgm:alg type="..."/>. /// Gives access to <dgm:alg type="..."/>.
sal_Int32 getType() const { return mnType; } sal_Int32 getType() const { return mnType; }
...@@ -171,6 +171,8 @@ public: ...@@ -171,6 +171,8 @@ public:
void setAspectRatio(double fAspectRatio) { mfAspectRatio = fAspectRatio; } void setAspectRatio(double fAspectRatio) { mfAspectRatio = fAspectRatio; }
double getAspectRatio() const { return mfAspectRatio; }
private: private:
sal_Int32 mnType; sal_Int32 mnType;
ParamMap maMap; ParamMap maMap;
...@@ -184,7 +186,7 @@ class ForEachAtom ...@@ -184,7 +186,7 @@ class ForEachAtom
: public LayoutAtom : public LayoutAtom
{ {
public: 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() IteratorAttr & iterator()
{ return maIter; } { return maIter; }
...@@ -200,7 +202,7 @@ class ConditionAtom ...@@ -200,7 +202,7 @@ class ConditionAtom
: public LayoutAtom : public LayoutAtom
{ {
public: 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; virtual void accept( LayoutAtomVisitor& ) override;
bool getDecision() const; bool getDecision() const;
private: private:
...@@ -220,7 +222,7 @@ class ChooseAtom ...@@ -220,7 +222,7 @@ class ChooseAtom
: public LayoutAtom : public LayoutAtom
{ {
public: public:
ChooseAtom(const LayoutNode& rLayoutNode) ChooseAtom(LayoutNode& rLayoutNode)
: LayoutAtom(rLayoutNode) : LayoutAtom(rLayoutNode)
#if defined __clang__ && __clang_major__ == 3 && __clang_minor__ == 8 #if defined __clang__ && __clang_major__ == 3 && __clang_minor__ == 8
, maEmptyChildren() , maEmptyChildren()
...@@ -264,6 +266,10 @@ public: ...@@ -264,6 +266,10 @@ public:
const LayoutNode* getParentLayoutNode() const; const LayoutNode* getParentLayoutNode() const;
void setAlgAtom(AlgAtomPtr pAlgAtom) { mpAlgAtom = pAlgAtom; }
AlgAtomPtr getAlgAtom() const { return mpAlgAtom.lock(); }
private: private:
const Diagram& mrDgm; const Diagram& mrDgm;
VarMap mVariables; VarMap mVariables;
...@@ -272,6 +278,7 @@ private: ...@@ -272,6 +278,7 @@ private:
ShapePtr mpExistingShape; ShapePtr mpExistingShape;
std::vector<ShapePtr> mpNodeShapes; std::vector<ShapePtr> mpNodeShapes;
sal_Int32 mnChildOrder; sal_Int32 mnChildOrder;
std::weak_ptr<AlgAtom> mpAlgAtom;
}; };
typedef std::shared_ptr< LayoutNode > LayoutNodePtr; typedef std::shared_ptr< LayoutNode > LayoutNodePtr;
...@@ -280,7 +287,7 @@ class ShapeAtom ...@@ -280,7 +287,7 @@ class ShapeAtom
: public LayoutAtom : public LayoutAtom
{ {
public: 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; virtual void accept( LayoutAtomVisitor& ) override;
const ShapePtr& getShapeTemplate() const const ShapePtr& getShapeTemplate() const
{ return mpShapeTemplate; } { return mpShapeTemplate; }
......
...@@ -133,6 +133,8 @@ void ShapeCreationVisitor::visit(LayoutNode& rAtom) ...@@ -133,6 +133,8 @@ void ShapeCreationVisitor::visit(LayoutNode& rAtom)
if (rAtom.setupShape(pShape, pNewNode)) if (rAtom.setupShape(pShape, pNewNode))
{ {
pShape->setInternalName(rAtom.getName()); pShape->setInternalName(rAtom.getName());
if (AlgAtomPtr pAlgAtom = rAtom.getAlgAtom())
pShape->setAspectRatio(pAlgAtom->getAspectRatio());
rAtom.addNodeShape(pShape); rAtom.addNodeShape(pShape);
} }
} }
...@@ -153,6 +155,8 @@ void ShapeCreationVisitor::visit(LayoutNode& rAtom) ...@@ -153,6 +155,8 @@ void ShapeCreationVisitor::visit(LayoutNode& rAtom)
if (rAtom.setupShape(pShape, pNewNode)) if (rAtom.setupShape(pShape, pNewNode))
{ {
pShape->setInternalName(rAtom.getName()); pShape->setInternalName(rAtom.getName());
if (AlgAtomPtr pAlgAtom = rAtom.getAlgAtom())
pShape->setAspectRatio(pAlgAtom->getAspectRatio());
pCurrParent->addChild(pShape); pCurrParent->addChild(pShape);
pCurrParent = pShape; pCurrParent = pShape;
rAtom.addNodeShape(pShape); rAtom.addNodeShape(pShape);
......
...@@ -231,6 +231,7 @@ LayoutNodeContext::onCreateContext( ::sal_Int32 aElement, ...@@ -231,6 +231,7 @@ LayoutNodeContext::onCreateContext( ::sal_Int32 aElement,
// CT_Algorithm // CT_Algorithm
AlgAtomPtr pAtom( new AlgAtom(mpNode->getLayoutNode()) ); AlgAtomPtr pAtom( new AlgAtom(mpNode->getLayoutNode()) );
LayoutAtom::connect(mpNode, pAtom); LayoutAtom::connect(mpNode, pAtom);
mpNode->getLayoutNode().setAlgAtom(pAtom);
return new AlgorithmContext( *this, rAttribs, pAtom ); return new AlgorithmContext( *this, rAttribs, pAtom );
} }
case DGM_TOKEN( choose ): case DGM_TOKEN( choose ):
......
...@@ -179,6 +179,7 @@ Shape::Shape( const ShapePtr& pSourceShape ) ...@@ -179,6 +179,7 @@ Shape::Shape( const ShapePtr& pSourceShape )
, mnZOrder(pSourceShape->mnZOrder) , mnZOrder(pSourceShape->mnZOrder)
, mnZOrderOff(pSourceShape->mnZOrderOff) , mnZOrderOff(pSourceShape->mnZOrderOff)
, mnDataNodeType(pSourceShape->mnDataNodeType) , mnDataNodeType(pSourceShape->mnDataNodeType)
, mfAspectRatio(pSourceShape->mfAspectRatio)
{} {}
Shape::~Shape() Shape::~Shape()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment