Kaydet (Commit) f1d65b13 authored tarafından Grzegorz Araminowicz's avatar Grzegorz Araminowicz Kaydeden (comit) Jan Holesovsky

SmartArt: support cnt function

it was necessary to introduce in LayoutAtoms reference to containing
LayoutNode passed by constructors, so that ConditionAtom can
access LayoutNode's name and diagram data

Change-Id: I35c9cb9061f23eb15e7a9372476530e2ead5d0dc
Reviewed-on: https://gerrit.libreoffice.org/41108Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJan Holesovsky <kendy@collabora.com>
üst 8cba023c
...@@ -50,7 +50,7 @@ ConstraintListContext::onCreateContext( ::sal_Int32 aElement, ...@@ -50,7 +50,7 @@ ConstraintListContext::onCreateContext( ::sal_Int32 aElement,
{ {
case DGM_TOKEN( constr ): case DGM_TOKEN( constr ):
{ {
std::shared_ptr< ConstraintAtom > pNode( new ConstraintAtom() ); std::shared_ptr< ConstraintAtom > pNode( new ConstraintAtom(mpNode->getLayoutNode()) );
mpNode->addChild( pNode ); mpNode->addChild( pNode );
pNode->setFor( rAttribs.getToken( XML_for, XML_none ) ); pNode->setFor( rAttribs.getToken( XML_for, XML_none ) );
......
...@@ -419,7 +419,7 @@ void loadDiagram( ShapePtr const & pShape, ...@@ -419,7 +419,7 @@ void loadDiagram( ShapePtr const & pShape,
DiagramDataPtr pData( new DiagramData() ); DiagramDataPtr pData( new DiagramData() );
pDiagram->setData( pData ); pDiagram->setData( pData );
DiagramLayoutPtr pLayout( new DiagramLayout ); DiagramLayoutPtr pLayout( new DiagramLayout(*pDiagram) );
pDiagram->setLayout( pLayout ); pDiagram->setLayout( pLayout );
// data // data
...@@ -516,7 +516,7 @@ void loadDiagram( const ShapePtr& pShape, ...@@ -516,7 +516,7 @@ void loadDiagram( const ShapePtr& pShape,
DiagramDataPtr pData( new DiagramData() ); DiagramDataPtr pData( new DiagramData() );
pDiagram->setData( pData ); pDiagram->setData( pData );
DiagramLayoutPtr pLayout( new DiagramLayout ); DiagramLayoutPtr pLayout( new DiagramLayout(*pDiagram) );
pDiagram->setLayout( pLayout ); pDiagram->setLayout( pLayout );
// data // data
......
...@@ -147,6 +147,7 @@ typedef std::vector< Point > Points; ...@@ -147,6 +147,7 @@ typedef std::vector< Point > Points;
} }
class Diagram;
class LayoutNode; class LayoutNode;
typedef std::shared_ptr< LayoutNode > LayoutNodePtr; typedef std::shared_ptr< LayoutNode > LayoutNodePtr;
...@@ -197,6 +198,7 @@ typedef std::shared_ptr< DiagramData > DiagramDataPtr; ...@@ -197,6 +198,7 @@ typedef std::shared_ptr< DiagramData > DiagramDataPtr;
class DiagramLayout class DiagramLayout
{ {
public: public:
DiagramLayout(const Diagram& rDgm) : mrDgm(rDgm) {}
void setDefStyle( const OUString & sDefStyle ) void setDefStyle( const OUString & sDefStyle )
{ msDefStyle = sDefStyle; } { msDefStyle = sDefStyle; }
void setMinVer( const OUString & sMinVer ) void setMinVer( const OUString & sMinVer )
...@@ -207,6 +209,8 @@ public: ...@@ -207,6 +209,8 @@ public:
{ msTitle = sTitle; } { msTitle = sTitle; }
void setDesc( const OUString & sDesc ) void setDesc( const OUString & sDesc )
{ msDesc = sDesc; } { msDesc = sDesc; }
const Diagram& getDiagram() const
{ return mrDgm; }
LayoutNodePtr & getNode() LayoutNodePtr & getNode()
{ return mpNode; } { return mpNode; }
const LayoutNodePtr & getNode() const const LayoutNodePtr & getNode() const
...@@ -221,6 +225,7 @@ public: ...@@ -221,6 +225,7 @@ public:
{ return mpStyleData; } { return mpStyleData; }
private: private:
const Diagram& mrDgm;
OUString msDefStyle; OUString msDefStyle;
OUString msMinVer; OUString msMinVer;
OUString msUniqueId; OUString msUniqueId;
......
...@@ -67,7 +67,7 @@ DiagramDefinitionContext::onCreateContext( ::sal_Int32 aElement, ...@@ -67,7 +67,7 @@ DiagramDefinitionContext::onCreateContext( ::sal_Int32 aElement,
break; break;
case DGM_TOKEN( layoutNode ): case DGM_TOKEN( layoutNode ):
{ {
LayoutNodePtr pNode( new LayoutNode() ); LayoutNodePtr pNode( new LayoutNode(mpLayout->getDiagram()) );
mpLayout->getNode() = pNode; mpLayout->getNode() = pNode;
pNode->setChildOrder( rAttribs.getToken( XML_chOrder, XML_b ) ); pNode->setChildOrder( rAttribs.getToken( XML_chOrder, XML_b ) );
pNode->setMoveWith( rAttribs.getString( XML_moveWith ).get() ); pNode->setMoveWith( rAttribs.getString( XML_moveWith ).get() );
......
...@@ -85,7 +85,8 @@ void LayoutAtom::dump(int level) ...@@ -85,7 +85,8 @@ void LayoutAtom::dump(int level)
pAtom->dump(level + 1); pAtom->dump(level + 1);
} }
ForEachAtom::ForEachAtom(const Reference< XFastAttributeList >& xAttributes) ForEachAtom::ForEachAtom(const LayoutNode& rLayoutNode, const Reference< XFastAttributeList >& xAttributes) :
LayoutAtom(rLayoutNode)
{ {
maIter.loadFromXAttr(xAttributes); maIter.loadFromXAttr(xAttributes);
} }
...@@ -100,13 +101,55 @@ void ChooseAtom::accept( LayoutAtomVisitor& rVisitor ) ...@@ -100,13 +101,55 @@ void ChooseAtom::accept( LayoutAtomVisitor& rVisitor )
rVisitor.visit(*this); rVisitor.visit(*this);
} }
ConditionAtom::ConditionAtom(const Reference< XFastAttributeList >& xAttributes) : ConditionAtom::ConditionAtom(const LayoutNode& rLayoutNode, const Reference< XFastAttributeList >& xAttributes) :
LayoutAtom(rLayoutNode),
mbElse( false ) mbElse( false )
{ {
maIter.loadFromXAttr( xAttributes ); maIter.loadFromXAttr( xAttributes );
maCond.loadFromXAttr( xAttributes ); maCond.loadFromXAttr( xAttributes );
} }
bool ConditionAtom::compareResult(sal_Int32 nOperator, sal_Int32 nFirst, sal_Int32 nSecond)
{
switch (nOperator)
{
case XML_equ: return nFirst == nSecond;
case XML_gt: return nFirst > nSecond;
case XML_gte: return nFirst >= nSecond;
case XML_lt: return nFirst < nSecond;
case XML_lte: return nFirst <= nSecond;
case XML_neq: return nFirst != nSecond;
default:
SAL_WARN("oox.drawingml", "unsupported operator: " << nOperator);
return false;
}
}
sal_Int32 ConditionAtom::getNodeCount() const
{
sal_Int32 nCount = 0;
const DiagramData::PointsNameMap& rPoints = mrLayoutNode.getDiagram().getData()->getPointsPresNameMap();
DiagramData::PointsNameMap::const_iterator aDataNode = rPoints.find(mrLayoutNode.getName());
if (aDataNode != rPoints.end())
{
SAL_WARN_IF(aDataNode->second.size() > 1, "oox.drawingml", "multiple nodes found; calculating cnt for first one");
const dgm::Point* pPoint = aDataNode->second.front();
OUString sNodeId = "";
for (const auto& aCxn : mrLayoutNode.getDiagram().getData()->getConnections())
if (aCxn.mnType == XML_presOf && aCxn.msDestId == pPoint->msModelId)
sNodeId = aCxn.msSourceId;
if (!sNodeId.isEmpty())
{
for (const auto& aCxn : mrLayoutNode.getDiagram().getData()->getConnections())
if (aCxn.mnType == XML_parOf && aCxn.msSourceId == sNodeId)
nCount++;
}
}
return nCount;
}
const std::vector<LayoutAtomPtr>& ConditionAtom::getChildren() const const std::vector<LayoutAtomPtr>& ConditionAtom::getChildren() const
{ {
bool bDecisionVar=true; bool bDecisionVar=true;
...@@ -114,6 +157,9 @@ const std::vector<LayoutAtomPtr>& ConditionAtom::getChildren() const ...@@ -114,6 +157,9 @@ const std::vector<LayoutAtomPtr>& ConditionAtom::getChildren() const
if( maCond.mnFunc == XML_var && maCond.mnArg == XML_dir && maCond.mnOp == XML_equ && maCond.msVal != "norm" ) if( maCond.mnFunc == XML_var && maCond.mnArg == XML_dir && maCond.mnOp == XML_equ && maCond.msVal != "norm" )
bDecisionVar=false; bDecisionVar=false;
if (maCond.mnFunc == XML_cnt)
bDecisionVar = compareResult(maCond.mnOp, getNodeCount(), maCond.msVal.toInt32());
if( bDecisionVar ) if( bDecisionVar )
return mpChildNodes; return mpChildNodes;
else else
...@@ -143,8 +189,7 @@ void AlgAtom::accept( LayoutAtomVisitor& rVisitor ) ...@@ -143,8 +189,7 @@ void AlgAtom::accept( LayoutAtomVisitor& rVisitor )
rVisitor.visit(*this); rVisitor.visit(*this);
} }
void AlgAtom::layoutShape( const ShapePtr& rShape, void AlgAtom::layoutShape( const ShapePtr& rShape ) const
const OUString& rName ) const
{ {
switch(mnType) switch(mnType)
{ {
...@@ -347,7 +392,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape, ...@@ -347,7 +392,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
SAL_INFO( SAL_INFO(
"oox.drawingml", "oox.drawingml",
"Layouting shape " << rName << ", alg type: " << mnType << ", (" "Layouting shape " << mrLayoutNode.getName() << ", alg type: " << mnType << ", ("
<< rShape->getPosition().X << "," << rShape->getPosition().Y << "," << rShape->getPosition().X << "," << rShape->getPosition().Y << ","
<< rShape->getSize().Width << "," << rShape->getSize().Height << ")"); << rShape->getSize().Width << "," << rShape->getSize().Height << ")");
} }
...@@ -357,7 +402,7 @@ void LayoutNode::accept( LayoutAtomVisitor& rVisitor ) ...@@ -357,7 +402,7 @@ void LayoutNode::accept( LayoutAtomVisitor& rVisitor )
rVisitor.visit(*this); rVisitor.visit(*this);
} }
bool LayoutNode::setupShape( const ShapePtr& rShape, const Diagram& rDgm, const dgm::Point* pPresNode ) const bool LayoutNode::setupShape( const ShapePtr& rShape, const dgm::Point* pPresNode ) const
{ {
SAL_INFO( SAL_INFO(
"oox.drawingml", "oox.drawingml",
...@@ -365,15 +410,15 @@ bool LayoutNode::setupShape( const ShapePtr& rShape, const Diagram& rDgm, const ...@@ -365,15 +410,15 @@ bool LayoutNode::setupShape( const ShapePtr& rShape, const Diagram& rDgm, const
<< "\", modelId \"" << pPresNode->msModelId << "\""); << "\", modelId \"" << pPresNode->msModelId << "\"");
// have the presentation node - now, need the actual data node: // have the presentation node - now, need the actual data node:
const DiagramData::StringMap::const_iterator aNodeName = rDgm.getData()->getPresOfNameMap().find( const DiagramData::StringMap::const_iterator aNodeName = mrDgm.getData()->getPresOfNameMap().find(
pPresNode->msModelId); pPresNode->msModelId);
if( aNodeName != rDgm.getData()->getPresOfNameMap().end() ) if( aNodeName != mrDgm.getData()->getPresOfNameMap().end() )
{ {
DiagramData::StringMap::value_type::second_type::const_iterator aVecIter=aNodeName->second.begin(); DiagramData::StringMap::value_type::second_type::const_iterator aVecIter=aNodeName->second.begin();
const DiagramData::StringMap::value_type::second_type::const_iterator aVecEnd=aNodeName->second.end(); const DiagramData::StringMap::value_type::second_type::const_iterator aVecEnd=aNodeName->second.end();
while( aVecIter != aVecEnd ) while( aVecIter != aVecEnd )
{ {
DiagramData::PointNameMap& rMap = rDgm.getData()->getPointNameMap(); DiagramData::PointNameMap& rMap = mrDgm.getData()->getPointNameMap();
DiagramData::PointNameMap::const_iterator aDataNode2 = rMap.find(aVecIter->first); DiagramData::PointNameMap::const_iterator aDataNode2 = rMap.find(aVecIter->first);
if (aDataNode2 == rMap.end()) if (aDataNode2 == rMap.end())
{ {
...@@ -451,8 +496,8 @@ bool LayoutNode::setupShape( const ShapePtr& rShape, const Diagram& rDgm, const ...@@ -451,8 +496,8 @@ bool LayoutNode::setupShape( const ShapePtr& rShape, const Diagram& rDgm, const
aStyleLabel = msStyleLabel; aStyleLabel = msStyleLabel;
if( !aStyleLabel.isEmpty() ) if( !aStyleLabel.isEmpty() )
{ {
const DiagramQStyleMap::const_iterator aStyle = rDgm.getStyles().find(aStyleLabel); const DiagramQStyleMap::const_iterator aStyle = mrDgm.getStyles().find(aStyleLabel);
if( aStyle != rDgm.getStyles().end() ) if( aStyle != mrDgm.getStyles().end() )
{ {
const DiagramStyle& rStyle = aStyle->second; const DiagramStyle& rStyle = aStyle->second;
rShape->getShapeStyleRefs()[XML_fillRef] = rStyle.maFillStyle; rShape->getShapeStyleRefs()[XML_fillRef] = rStyle.maFillStyle;
...@@ -465,8 +510,8 @@ bool LayoutNode::setupShape( const ShapePtr& rShape, const Diagram& rDgm, const ...@@ -465,8 +510,8 @@ bool LayoutNode::setupShape( const ShapePtr& rShape, const Diagram& rDgm, const
SAL_WARN("oox.drawingml", "Style " << aStyleLabel << " not found"); SAL_WARN("oox.drawingml", "Style " << aStyleLabel << " not found");
} }
const DiagramColorMap::const_iterator aColor = rDgm.getColors().find(aStyleLabel); const DiagramColorMap::const_iterator aColor = mrDgm.getColors().find(aStyleLabel);
if( aColor != rDgm.getColors().end() ) if( aColor != mrDgm.getColors().end() )
{ {
const DiagramColor& rColor=aColor->second; const DiagramColor& rColor=aColor->second;
if( rColor.maFillColor.isUsed() ) if( rColor.maFillColor.isUsed() )
......
...@@ -66,6 +66,7 @@ struct ConditionAttr ...@@ -66,6 +66,7 @@ struct ConditionAttr
struct LayoutAtomVisitor; struct LayoutAtomVisitor;
class LayoutAtom; class LayoutAtom;
class LayoutNode;
typedef std::shared_ptr< LayoutAtom > LayoutAtomPtr; typedef std::shared_ptr< LayoutAtom > LayoutAtomPtr;
...@@ -73,8 +74,12 @@ typedef std::shared_ptr< LayoutAtom > LayoutAtomPtr; ...@@ -73,8 +74,12 @@ typedef std::shared_ptr< LayoutAtom > LayoutAtomPtr;
class LayoutAtom class LayoutAtom
{ {
public: public:
LayoutAtom(const LayoutNode& rLayoutNode) : mrLayoutNode(rLayoutNode) {}
virtual ~LayoutAtom() { } virtual ~LayoutAtom() { }
const LayoutNode& getLayoutNode() const
{ return mrLayoutNode; }
/** visitor acceptance /** visitor acceptance
*/ */
virtual void accept( LayoutAtomVisitor& ) = 0; virtual void accept( LayoutAtomVisitor& ) = 0;
...@@ -91,7 +96,9 @@ public: ...@@ -91,7 +96,9 @@ public:
// dump for debug // dump for debug
void dump(int level = 0); void dump(int level = 0);
protected: protected:
const LayoutNode& mrLayoutNode;
std::vector< LayoutAtomPtr > mpChildNodes; std::vector< LayoutAtomPtr > mpChildNodes;
OUString msName; OUString msName;
}; };
...@@ -100,7 +107,7 @@ class ConstraintAtom ...@@ -100,7 +107,7 @@ class ConstraintAtom
: public LayoutAtom : public LayoutAtom
{ {
public: public:
ConstraintAtom() : ConstraintAtom(const LayoutNode& rLayoutNode) : LayoutAtom(rLayoutNode),
mnFor(-1), msForName(), mnPointType(-1), mnType(-1), mnRefFor(-1), msRefForName(), mnFor(-1), msForName(), mnPointType(-1), mnType(-1), mnRefFor(-1), msRefForName(),
mnRefType(-1), mnRefPointType(-1), mfFactor(1.0), mfValue(0.0), mnOperator(0) mnRefType(-1), mnRefPointType(-1), mfFactor(1.0), mfValue(0.0), mnOperator(0)
{} {}
...@@ -147,7 +154,7 @@ class AlgAtom ...@@ -147,7 +154,7 @@ class AlgAtom
: public LayoutAtom : public LayoutAtom
{ {
public: public:
AlgAtom() : mnType(0), maMap() {} AlgAtom(const LayoutNode& rLayoutNode) : LayoutAtom(rLayoutNode), mnType(0), maMap() {}
typedef std::map<sal_Int32,sal_Int32> ParamMap; typedef std::map<sal_Int32,sal_Int32> ParamMap;
...@@ -157,8 +164,7 @@ public: ...@@ -157,8 +164,7 @@ public:
{ mnType = nToken; } { mnType = nToken; }
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;
const OUString& rName ) const;
private: private:
sal_Int32 mnType; sal_Int32 mnType;
ParamMap maMap; ParamMap maMap;
...@@ -170,7 +176,7 @@ class ForEachAtom ...@@ -170,7 +176,7 @@ class ForEachAtom
: public LayoutAtom : public LayoutAtom
{ {
public: public:
explicit ForEachAtom(const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttributes); explicit ForEachAtom(const LayoutNode& rLayoutNode, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttributes);
IteratorAttr & iterator() IteratorAttr & iterator()
{ return maIter; } { return maIter; }
...@@ -186,12 +192,14 @@ class ConditionAtom ...@@ -186,12 +192,14 @@ class ConditionAtom
: public LayoutAtom : public LayoutAtom
{ {
public: public:
explicit ConditionAtom(const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttributes); explicit ConditionAtom(const LayoutNode& rLayoutNode, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttributes);
virtual void accept( LayoutAtomVisitor& ) override; virtual void accept( LayoutAtomVisitor& ) override;
void readElseBranch() void readElseBranch()
{ mbElse=true; } { mbElse=true; }
virtual void addChild( const LayoutAtomPtr & pNode ) override; virtual void addChild( const LayoutAtomPtr & pNode ) override;
virtual const std::vector<LayoutAtomPtr>& getChildren() const override; virtual const std::vector<LayoutAtomPtr>& getChildren() const override;
static bool compareResult(sal_Int32 nOperator, sal_Int32 nFirst, sal_Int32 nSecond);
sal_Int32 getNodeCount() const;
private: private:
bool mbElse; bool mbElse;
IteratorAttr maIter; IteratorAttr maIter;
...@@ -206,6 +214,7 @@ class ChooseAtom ...@@ -206,6 +214,7 @@ class ChooseAtom
: public LayoutAtom : public LayoutAtom
{ {
public: public:
ChooseAtom(const LayoutNode& rLayoutNode) : LayoutAtom(rLayoutNode) {}
virtual void accept( LayoutAtomVisitor& ) override; virtual void accept( LayoutAtomVisitor& ) override;
}; };
...@@ -228,7 +237,9 @@ public: ...@@ -228,7 +237,9 @@ public:
// the use of Any allow having empty values // the use of Any allow having empty values
typedef std::array<css::uno::Any, 9> VarMap; typedef std::array<css::uno::Any, 9> VarMap;
LayoutNode() : mnChildOrder(0) {} LayoutNode(const Diagram& rDgm) : LayoutAtom(*this), mrDgm(rDgm), mnChildOrder(0) {}
const Diagram& getDiagram() const
{ return mrDgm; }
virtual void accept( LayoutAtomVisitor& ) override; virtual void accept( LayoutAtomVisitor& ) override;
VarMap & variables() VarMap & variables()
{ return mVariables; } { return mVariables; }
...@@ -242,14 +253,16 @@ public: ...@@ -242,14 +253,16 @@ public:
{ mpExistingShape = pShape; } { mpExistingShape = pShape; }
const ShapePtr& getExistingShape() const const ShapePtr& getExistingShape() const
{ return mpExistingShape; } { return mpExistingShape; }
std::vector<ShapePtr> & getNodeShapes() const std::vector<ShapePtr> & getNodeShapes() const
{ return mpNodeShapes; } { return mpNodeShapes; }
void addNodeShape(const ShapePtr& pShape)
{ mpNodeShapes.push_back(pShape); }
bool setupShape( const ShapePtr& rShape, bool setupShape( const ShapePtr& rShape,
const Diagram& rDgm,
const dgm::Point* pPresNode ) const; const dgm::Point* pPresNode ) const;
private: private:
const Diagram& mrDgm;
VarMap mVariables; VarMap mVariables;
OUString msMoveWith; OUString msMoveWith;
OUString msStyleLabel; OUString msStyleLabel;
...@@ -264,7 +277,7 @@ class ShapeAtom ...@@ -264,7 +277,7 @@ class ShapeAtom
: public LayoutAtom : public LayoutAtom
{ {
public: public:
ShapeAtom(const ShapePtr& pShape) : mpShapeTemplate(pShape) {} ShapeAtom(const 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; }
......
...@@ -116,8 +116,8 @@ void ShapeCreationVisitor::visit(LayoutNode& rAtom) ...@@ -116,8 +116,8 @@ void ShapeCreationVisitor::visit(LayoutNode& rAtom)
if (rAtom.getExistingShape()) if (rAtom.getExistingShape())
{ {
// reuse existing shape // reuse existing shape
if (rAtom.setupShape(rAtom.getExistingShape(), mrDgm, pNewNode)) if (rAtom.setupShape(rAtom.getExistingShape(), pNewNode))
rAtom.getNodeShapes().push_back(rAtom.getExistingShape()); rAtom.addNodeShape(rAtom.getExistingShape());
} }
else else
{ {
...@@ -133,11 +133,11 @@ void ShapeCreationVisitor::visit(LayoutNode& rAtom) ...@@ -133,11 +133,11 @@ void ShapeCreationVisitor::visit(LayoutNode& rAtom)
<< (pShape->getCustomShapeProperties() << (pShape->getCustomShapeProperties()
->getShapePresetType())); ->getShapePresetType()));
if (rAtom.setupShape(pShape, mrDgm, pNewNode)) if (rAtom.setupShape(pShape, pNewNode))
{ {
pCurrParent->addChild(pShape); pCurrParent->addChild(pShape);
pCurrParent = pShape; pCurrParent = pShape;
rAtom.getNodeShapes().push_back(pShape); rAtom.addNodeShape(pShape);
} }
} }
else else
...@@ -238,10 +238,10 @@ void ShapeLayoutingVisitor::visit(ConstraintAtom& /*rAtom*/) ...@@ -238,10 +238,10 @@ void ShapeLayoutingVisitor::visit(ConstraintAtom& /*rAtom*/)
void ShapeLayoutingVisitor::visit(AlgAtom& rAtom) void ShapeLayoutingVisitor::visit(AlgAtom& rAtom)
{ {
if (mbLookForAlg && mpCurrentLayoutNode) if (mbLookForAlg)
{ {
for (const auto& pShape : mpCurrentLayoutNode->getNodeShapes()) for (const auto& pShape : rAtom.getLayoutNode().getNodeShapes())
rAtom.layoutShape(pShape, mpCurrentLayoutNode->getName()); rAtom.layoutShape(pShape);
} }
} }
...@@ -265,16 +265,11 @@ void ShapeLayoutingVisitor::visit(LayoutNode& rAtom) ...@@ -265,16 +265,11 @@ void ShapeLayoutingVisitor::visit(LayoutNode& rAtom)
if (mbLookForAlg) if (mbLookForAlg)
return; return;
LayoutNode* pPreviousLayoutNode = mpCurrentLayoutNode;
mpCurrentLayoutNode = &rAtom;
// process alg atoms first, nested layout nodes afterwards // process alg atoms first, nested layout nodes afterwards
mbLookForAlg = true; mbLookForAlg = true;
defaultVisit(rAtom); defaultVisit(rAtom);
mbLookForAlg = false; mbLookForAlg = false;
defaultVisit(rAtom); defaultVisit(rAtom);
mpCurrentLayoutNode = pPreviousLayoutNode;
} }
void ShapeLayoutingVisitor::visit(ShapeAtom& /*rAtom*/) void ShapeLayoutingVisitor::visit(ShapeAtom& /*rAtom*/)
......
...@@ -74,7 +74,6 @@ public: ...@@ -74,7 +74,6 @@ public:
class ShapeLayoutingVisitor : public LayoutAtomVisitor class ShapeLayoutingVisitor : public LayoutAtomVisitor
{ {
LayoutNode* mpCurrentLayoutNode;
bool mbLookForAlg; bool mbLookForAlg;
void defaultVisit(LayoutAtom const & rAtom); void defaultVisit(LayoutAtom const & rAtom);
...@@ -88,7 +87,6 @@ class ShapeLayoutingVisitor : public LayoutAtomVisitor ...@@ -88,7 +87,6 @@ class ShapeLayoutingVisitor : public LayoutAtomVisitor
public: public:
ShapeLayoutingVisitor() : ShapeLayoutingVisitor() :
mpCurrentLayoutNode(nullptr),
mbLookForAlg(false) mbLookForAlg(false)
{} {}
}; };
......
...@@ -105,7 +105,7 @@ public: ...@@ -105,7 +105,7 @@ public:
case DGM_TOKEN( if ): case DGM_TOKEN( if ):
{ {
// CT_When // CT_When
mpConditionNode.reset( new ConditionAtom(rAttribs.getFastAttributeList()) ); mpConditionNode.reset( new ConditionAtom(mpNode->getLayoutNode(), rAttribs.getFastAttributeList()) );
mpNode->addChild( mpConditionNode ); mpNode->addChild( mpConditionNode );
return new IfContext( *this, rAttribs, mpConditionNode ); return new IfContext( *this, rAttribs, mpConditionNode );
} }
...@@ -237,7 +237,7 @@ LayoutNodeContext::onCreateContext( ::sal_Int32 aElement, ...@@ -237,7 +237,7 @@ LayoutNodeContext::onCreateContext( ::sal_Int32 aElement,
{ {
case DGM_TOKEN( layoutNode ): case DGM_TOKEN( layoutNode ):
{ {
LayoutNodePtr pNode( new LayoutNode() ); LayoutNodePtr pNode( new LayoutNode(mpNode->getLayoutNode().getDiagram()) );
mpNode->addChild( pNode ); mpNode->addChild( pNode );
pNode->setChildOrder( rAttribs.getToken( XML_chOrder, XML_b ) ); pNode->setChildOrder( rAttribs.getToken( XML_chOrder, XML_b ) );
pNode->setMoveWith( rAttribs.getString( XML_moveWith ).get() ); pNode->setMoveWith( rAttribs.getString( XML_moveWith ).get() );
...@@ -263,7 +263,7 @@ LayoutNodeContext::onCreateContext( ::sal_Int32 aElement, ...@@ -263,7 +263,7 @@ LayoutNodeContext::onCreateContext( ::sal_Int32 aElement,
pShape.reset( new Shape("com.sun.star.drawing.GroupShape") ); pShape.reset( new Shape("com.sun.star.drawing.GroupShape") );
} }
ShapeAtomPtr pAtom( new ShapeAtom(pShape) ); ShapeAtomPtr pAtom( new ShapeAtom(mpNode->getLayoutNode(), pShape) );
mpNode->addChild( pAtom ); mpNode->addChild( pAtom );
return new ShapeContext( *this, ShapePtr(), pShape ); return new ShapeContext( *this, ShapePtr(), pShape );
} }
...@@ -272,21 +272,21 @@ LayoutNodeContext::onCreateContext( ::sal_Int32 aElement, ...@@ -272,21 +272,21 @@ LayoutNodeContext::onCreateContext( ::sal_Int32 aElement,
case DGM_TOKEN( alg ): case DGM_TOKEN( alg ):
{ {
// CT_Algorithm // CT_Algorithm
AlgAtomPtr pAtom( new AlgAtom ); AlgAtomPtr pAtom( new AlgAtom(mpNode->getLayoutNode()) );
mpNode->addChild( pAtom ); mpNode->addChild( pAtom );
return new AlgorithmContext( *this, rAttribs, pAtom ); return new AlgorithmContext( *this, rAttribs, pAtom );
} }
case DGM_TOKEN( choose ): case DGM_TOKEN( choose ):
{ {
// CT_Choose // CT_Choose
LayoutAtomPtr pAtom( new ChooseAtom ); LayoutAtomPtr pAtom( new ChooseAtom(mpNode->getLayoutNode()) );
mpNode->addChild( pAtom ); mpNode->addChild( pAtom );
return new ChooseContext( *this, rAttribs, pAtom ); return new ChooseContext( *this, rAttribs, pAtom );
} }
case DGM_TOKEN( forEach ): case DGM_TOKEN( forEach ):
{ {
// CT_ForEach // CT_ForEach
ForEachAtomPtr pAtom( new ForEachAtom(rAttribs.getFastAttributeList()) ); ForEachAtomPtr pAtom( new ForEachAtom(mpNode->getLayoutNode(), rAttribs.getFastAttributeList()) );
mpNode->addChild( pAtom ); mpNode->addChild( pAtom );
return new ForEachContext( *this, rAttribs, pAtom ); return new ForEachContext( *this, rAttribs, pAtom );
} }
......
...@@ -166,6 +166,7 @@ public: ...@@ -166,6 +166,7 @@ public:
void testSmartArt1(); void testSmartArt1();
void testSmartArtChildren(); void testSmartArtChildren();
void testSmartArtText(); void testSmartArtText();
void testSmartArtCnt();
void testTdf109223(); void testTdf109223();
void testTdf109187(); void testTdf109187();
...@@ -241,6 +242,7 @@ public: ...@@ -241,6 +242,7 @@ public:
CPPUNIT_TEST(testSmartArt1); CPPUNIT_TEST(testSmartArt1);
CPPUNIT_TEST(testSmartArtChildren); CPPUNIT_TEST(testSmartArtChildren);
CPPUNIT_TEST(testSmartArtText); CPPUNIT_TEST(testSmartArtText);
CPPUNIT_TEST(testSmartArtCnt);
CPPUNIT_TEST(testTdf109223); CPPUNIT_TEST(testTdf109223);
CPPUNIT_TEST(testTdf109187); CPPUNIT_TEST(testTdf109187);
...@@ -2316,6 +2318,23 @@ void SdImportTest::testSmartArtText() ...@@ -2316,6 +2318,23 @@ void SdImportTest::testSmartArtText()
xDocShRef->DoClose(); xDocShRef->DoClose();
} }
void SdImportTest::testSmartArtCnt()
{
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-cnt.pptx"), PPTX);
uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
sal_Int32 nCount = xShapeGroup->getCount();
sal_Int32 nCorrect = 0;
for (sal_Int32 i=0; i<nCount; i++)
{
uno::Reference<text::XText> xText(xShapeGroup->getByIndex(i), uno::UNO_QUERY);
if (xText.is() && !xText->getString().isEmpty())
nCorrect++;
}
CPPUNIT_ASSERT_EQUAL(sal_Int32(3), nCorrect);
xDocShRef->DoClose();
}
void SdImportTest::testTdf109223() void SdImportTest::testTdf109223()
{ {
// In the test document flipV attribute is defined for a group shape // In the test document flipV attribute is defined for a group 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