diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2019-02-19 17:58:42 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-02-19 19:36:31 +0100 |
commit | ecb733da58b74714eb66d2063a2835ce5c471870 (patch) | |
tree | fc251161ced6f76acda7be863bcd6eef7ecc6d6a /oox | |
parent | 92849660e21d5a13fb671339e52cbc30335ab842 (diff) |
oox smartart, cycle matrix: handle destination order in connections
It is possible to have connections from multiple data nodes to the same
presentation node with a presOf type. We use to order these based on as
they appear in the data XML, but we need to order them according to the
destOrd attribute.
Introduce an std::map for that, so get ordering automatically as we
iterate. Turn the std::pair into a struct to make the code a bit more
readable.
Change-Id: I3d2bb047ed3f171a194851f89151bd94071a8176
Reviewed-on: https://gerrit.libreoffice.org/68027
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/diagram/diagram.cxx | 8 | ||||
-rw-r--r-- | oox/source/drawingml/diagram/diagram.hxx | 8 | ||||
-rw-r--r-- | oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 11 |
3 files changed, 16 insertions, 11 deletions
diff --git a/oox/source/drawingml/diagram/diagram.cxx b/oox/source/drawingml/diagram/diagram.cxx index 64dc5dde6d91..97f967280631 100644 --- a/oox/source/drawingml/diagram/diagram.cxx +++ b/oox/source/drawingml/diagram/diagram.cxx @@ -271,8 +271,7 @@ void Diagram::build( ) if( connection.mnType == XML_presOf ) { DiagramData::StringMap::value_type::second_type& rVec=getData()->getPresOfNameMap()[connection.msDestId]; - rVec.emplace_back( - connection.msSourceId,sal_Int32(0)); + rVec[connection.mnDestOrder] = { connection.msSourceId, sal_Int32(0) }; } } @@ -282,9 +281,8 @@ void Diagram::build( ) { for (auto & elem : elemPresOf.second) { - const sal_Int32 nDepth=calcDepth(elem.first, - getData()->getConnections()); - elem.second = nDepth != 0 ? nDepth : -1; + const sal_Int32 nDepth = calcDepth(elem.second.msSourceId, getData()->getConnections()); + elem.second.mnDepth = nDepth != 0 ? nDepth : -1; if (nDepth > getData()->getMaxDepth()) getData()->setMaxDepth(nDepth); } diff --git a/oox/source/drawingml/diagram/diagram.hxx b/oox/source/drawingml/diagram/diagram.hxx index 242ff09fa152..a0955b124230 100644 --- a/oox/source/drawingml/diagram/diagram.hxx +++ b/oox/source/drawingml/diagram/diagram.hxx @@ -160,8 +160,14 @@ public: typedef std::map< OUString, std::vector<dgm::Point*> > PointsNameMap; typedef std::map< OUString, const dgm::Connection* > ConnectionNameMap; + struct SourceIdAndDepth + { + OUString msSourceId; + sal_Int32 mnDepth = 0; + }; + /// Tracks connections: destination id -> {destination order, details} map. typedef std::map< OUString, - std::vector<std::pair<OUString,sal_Int32> > > StringMap; + std::map<sal_Int32, SourceIdAndDepth > > StringMap; DiagramData(); FillPropertiesPtr & getFillProperties() diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index e57a0115e129..b26c32b6fb4b 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -1168,11 +1168,12 @@ bool LayoutNode::setupShape( const ShapePtr& rShape, const dgm::Point* pPresNode pPresNode->msModelId); if( aNodeName != mrDgm.getData()->getPresOfNameMap().end() ) { - for( const auto& rItem : aNodeName->second ) + for (const auto& rPair : aNodeName->second) { + const DiagramData::SourceIdAndDepth& rItem = rPair.second; DiagramData::PointNameMap& rMap = mrDgm.getData()->getPointNameMap(); // pPresNode is the presentation node of the aDataNode2 data node. - DiagramData::PointNameMap::const_iterator aDataNode2 = rMap.find(rItem.first); + DiagramData::PointNameMap::const_iterator aDataNode2 = rMap.find(rItem.msSourceId); if (aDataNode2 == rMap.end()) { //busted, skip it @@ -1181,7 +1182,7 @@ bool LayoutNode::setupShape( const ShapePtr& rShape, const dgm::Point* pPresNode rShape->setDataNodeType(aDataNode2->second->mnType); - if( rItem.second == 0 ) + if (rItem.mnDepth == 0) { // grab shape attr from topmost element(s) rShape->getShapeProperties() = aDataNode2->second->mpShape->getShapeProperties(); @@ -1223,8 +1224,8 @@ bool LayoutNode::setupShape( const ShapePtr& rShape, const dgm::Point* pPresNode for (const auto& pSourceParagraph : rSourceParagraphs) { TextParagraph& rPara = pTextBody->addParagraph(); - if (rItem.second != -1) - rPara.getProperties().setLevel(rItem.second); + if (rItem.mnDepth != -1) + rPara.getProperties().setLevel(rItem.mnDepth); for (const auto& pRun : pSourceParagraph->getRuns()) rPara.addRun(pRun); |