diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2019-01-09 17:49:14 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-01-10 09:07:04 +0100 |
commit | 22086e70c4f3bb41620ff81ecaf57fd2af6ccbce (patch) | |
tree | 9a9be940814d8c28842315f79b90fc195e8839f0 /oox | |
parent | f0f462bfa5465aa978c82e6c4aad058d9b760e93 (diff) |
oox smartart, org chart: fix vertical order of assistant nodes
It seems the manager -> assistant -> employees ordering is not part of
the file format. The order is stored twice in the file: the hierRoot
algorithm has 3 layout nodes as a children, and also the data model has
an order of the presentation nodes: both describe that employees go
before assistant nodes.
In contrast to that, PowerPoint orders XML_asst nodes before XML_node
ones, so teach the hierRoot algorithm about this.
This requires tracking the data model node type for each in-diagram
drawingML shape, so that layout can determine if a hierRoot algorithm
children has an assistant node or not.
Change-Id: Ib81f3666fb092ed3b036d830f69ba7e1b94f8331
Reviewed-on: https://gerrit.libreoffice.org/66048
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 30 | ||||
-rw-r--r-- | oox/source/drawingml/shape.cxx | 1 |
2 files changed, 31 insertions, 0 deletions
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index 056164276283..dd762a9bc77a 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -99,6 +99,24 @@ sal_Int32 getConnectorType(const oox::drawingml::LayoutNode* pNode) return nType; } + +/** + * Determines if pShape is (or contains) a presentation of a data node of type + * nType. + */ +bool containsDataNodeType(const oox::drawingml::ShapePtr& pShape, sal_Int32 nType) +{ + if (pShape->getDataNodeType() == nType) + return true; + + for (const auto& pChild : pShape->getChildren()) + { + if (containsDataNodeType(pChild, nType)) + return true; + } + + return false; +} } namespace oox { namespace drawingml { @@ -534,6 +552,15 @@ void AlgAtom::layoutShape( const ShapePtr& rShape, sal_Int32 nCount = rShape->getChildren().size(); + if (mnType == XML_hierRoot && nCount == 3) + { + // Order assistant nodes above employee nodes. + std::vector<ShapePtr>& rChildren = rShape->getChildren(); + if (!containsDataNodeType(rChildren[1], XML_asst) + && containsDataNodeType(rChildren[2], XML_asst)) + std::swap(rChildren[1], rChildren[2]); + } + awt::Size aChildSize = rShape->getSize(); if (nDir == XML_fromT) aChildSize.Height /= nCount; @@ -972,6 +999,7 @@ bool LayoutNode::setupShape( const ShapePtr& rShape, const dgm::Point* pPresNode while( aVecIter != aVecEnd ) { DiagramData::PointNameMap& rMap = mrDgm.getData()->getPointNameMap(); + // pPresNode is the presentation node of the aDataNode2 data node. DiagramData::PointNameMap::const_iterator aDataNode2 = rMap.find(aVecIter->first); if (aDataNode2 == rMap.end()) { @@ -980,6 +1008,8 @@ bool LayoutNode::setupShape( const ShapePtr& rShape, const dgm::Point* pPresNode continue; } + rShape->setDataNodeType(aDataNode2->second->mnType); + if( aVecIter->second == 0 ) { // grab shape attr from topmost element(s) diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 8449082bc774..a3891cb44746 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -178,6 +178,7 @@ Shape::Shape( const ShapePtr& pSourceShape ) , maDiagramDoms( pSourceShape->maDiagramDoms ) , mnZOrder(pSourceShape->mnZOrder) , mnZOrderOff(pSourceShape->mnZOrderOff) +, mnDataNodeType(pSourceShape->mnDataNodeType) {} Shape::~Shape() |