diff options
-rw-r--r-- | oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 70 | ||||
-rw-r--r-- | oox/source/drawingml/diagram/diagramlayoutatoms.hxx | 10 |
2 files changed, 48 insertions, 32 deletions
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index 6a33148a7993..58f6da680f97 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -440,6 +440,43 @@ void SnakeAlg::layoutShapeChildren(const AlgAtom::ParamMap& rMap, const ShapePtr } } +void PyraAlg::layoutShapeChildren(const ShapePtr& rShape) +{ + if (rShape->getChildren().empty() || rShape->getSize().Width == 0 + || rShape->getSize().Height == 0) + return; + + // const sal_Int32 nDir = maMap.count(XML_linDir) ? maMap.find(XML_linDir)->second : XML_fromT; + // const sal_Int32 npyraAcctPos = maMap.count(XML_pyraAcctPos) ? maMap.find(XML_pyraAcctPos)->second : XML_bef; + // const sal_Int32 ntxDir = maMap.count(XML_txDir) ? maMap.find(XML_txDir)->second : XML_fromT; + // const sal_Int32 npyraLvlNode = maMap.count(XML_pyraLvlNode) ? maMap.find(XML_pyraLvlNode)->second : XML_level; + // uncomment when use in code. + + sal_Int32 nCount = rShape->getChildren().size(); + double fAspectRatio = 0.32; + + awt::Size aChildSize = rShape->getSize(); + aChildSize.Width /= nCount; + aChildSize.Height /= nCount; + + awt::Point aCurrPos(0, 0); + aCurrPos.X = fAspectRatio * aChildSize.Width * (nCount - 1); + aCurrPos.Y = fAspectRatio * aChildSize.Height; + + for (auto& aCurrShape : rShape->getChildren()) + { + aCurrShape->setPosition(aCurrPos); + if (nCount > 1) + { + aCurrPos.X -= aChildSize.Height / (nCount - 1); + } + aChildSize.Width += aChildSize.Height; + aCurrShape->setSize(aChildSize); + aCurrShape->setChildSize(aChildSize); + aCurrPos.Y += (aChildSize.Height); + } +} + IteratorAttr::IteratorAttr( ) : mnCnt( -1 ) , mbHideLastTrans( true ) @@ -1594,38 +1631,7 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector<Constraint>& case XML_pyra: { - if (rShape->getChildren().empty() || rShape->getSize().Width == 0 || rShape->getSize().Height == 0) - break; - - // const sal_Int32 nDir = maMap.count(XML_linDir) ? maMap.find(XML_linDir)->second : XML_fromT; - // const sal_Int32 npyraAcctPos = maMap.count(XML_pyraAcctPos) ? maMap.find(XML_pyraAcctPos)->second : XML_bef; - // const sal_Int32 ntxDir = maMap.count(XML_txDir) ? maMap.find(XML_txDir)->second : XML_fromT; - // const sal_Int32 npyraLvlNode = maMap.count(XML_pyraLvlNode) ? maMap.find(XML_pyraLvlNode)->second : XML_level; - // uncomment when use in code. - - sal_Int32 nCount = rShape->getChildren().size(); - double fAspectRatio = 0.32; - - awt::Size aChildSize = rShape->getSize(); - aChildSize.Width /= nCount; - aChildSize.Height /= nCount; - - awt::Point aCurrPos(0, 0); - aCurrPos.X = fAspectRatio*aChildSize.Width*(nCount-1); - aCurrPos.Y = fAspectRatio*aChildSize.Height; - - for (auto & aCurrShape : rShape->getChildren()) - { - aCurrShape->setPosition(aCurrPos); - if (nCount > 1) - { - aCurrPos.X -= aChildSize.Height / (nCount - 1); - } - aChildSize.Width += aChildSize.Height; - aCurrShape->setSize(aChildSize); - aCurrShape->setChildSize(aChildSize); - aCurrPos.Y += (aChildSize.Height); - } + PyraAlg::layoutShapeChildren(rShape); break; } diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx index 571cca641d78..80f6b2d9bb0d 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx @@ -210,6 +210,16 @@ public: const std::vector<Constraint>& rConstraints); }; +/** + * Lays out child layout nodes along a vertical path and works with the trapezoid shape to create a + * pyramid. + */ +class PyraAlg +{ +public: + static void layoutShapeChildren(const ShapePtr& rShape); +}; + class ForEachAtom : public LayoutAtom { |