diff options
author | Grzegorz Araminowicz <grzegorz.araminowicz@collabora.com> | 2019-04-11 14:56:37 +0200 |
---|---|---|
committer | Grzegorz Araminowicz <grzegorz.araminowicz@collabora.com> | 2019-07-11 10:27:56 +0200 |
commit | e222aa0d7882d5365e6ea28e82613795f5a8629a (patch) | |
tree | 2a45b30fc54f31c4002e9951a3b6efca11cc474a /oox | |
parent | 338630cdaf6121c057a3f6e519a281315ee2778b (diff) |
SmartArt: better detecting connector arrow type
* basing on provided conn alg params
* also moved setting arrow direction from getConnectorType() to algorithms
Change-Id: I76898a4ccad961edd389677c31e7d8c05bcdf5fe
Reviewed-on: https://gerrit.libreoffice.org/70598
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/75395
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Grzegorz Araminowicz <grzegorz.araminowicz@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 76 | ||||
-rw-r--r-- | oox/source/drawingml/diagram/diagramlayoutatoms.hxx | 3 |
2 files changed, 28 insertions, 51 deletions
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index 8d569bc8fa3b..9c83d95fea5d 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -87,56 +87,6 @@ sal_Int32 getPropertyFromConstraint(sal_Int32 nConstraint) return 0; } -/// Determines the connector shape type from a linear alg. -sal_Int32 getConnectorType(const oox::drawingml::LayoutNode* pNode) -{ - sal_Int32 nType = oox::XML_rightArrow; - - if (!pNode) - return nType; - - // This is cheaper than visiting the whole sub-tree. - if (pNode->getName().startsWith("hierChild")) - return oox::XML_bentConnector3; - - for (const auto& pChild : pNode->getChildren()) - { - auto pAlgAtom = dynamic_cast<oox::drawingml::AlgAtom*>(pChild.get()); - if (!pAlgAtom) - continue; - - switch (pAlgAtom->getType()) - { - case oox::XML_lin: - { - sal_Int32 nDir = oox::XML_fromL; - if (pAlgAtom->getMap().count(oox::XML_linDir)) - nDir = pAlgAtom->getMap().find(oox::XML_linDir)->second; - - switch (nDir) - { - case oox::XML_fromL: - nType = oox::XML_rightArrow; - break; - case oox::XML_fromR: - nType = oox::XML_leftArrow; - break; - } - break; - } - case oox::XML_hierChild: - { - // TODO <dgm:param type="connRout" val="..."/> should be able - // to customize this. - nType = oox::XML_bentConnector3; - break; - } - } - } - - return nType; -} - /** * Determines if pShape is (or contains) a presentation of a data node of type * nType. @@ -444,6 +394,30 @@ void AlgAtom::accept( LayoutAtomVisitor& rVisitor ) rVisitor.visit(*this); } +sal_Int32 AlgAtom::getConnectorType() +{ + sal_Int32 nConnRout = 0; + sal_Int32 nBegSty = 0; + sal_Int32 nEndSty = 0; + if (maMap.count(oox::XML_connRout)) + nConnRout = maMap.find(oox::XML_connRout)->second; + if (maMap.count(oox::XML_begSty)) + nBegSty = maMap.find(oox::XML_begSty)->second; + if (maMap.count(oox::XML_endSty)) + nEndSty = maMap.find(oox::XML_endSty)->second; + + if (nConnRout == oox::XML_bend) + return oox::XML_bentConnector3; + if (nBegSty == oox::XML_arr && nEndSty == oox::XML_arr) + return oox::XML_leftRightArrow; + if (nBegSty == oox::XML_arr) + return oox::XML_leftArrow; + if (nEndSty == oox::XML_arr) + return oox::XML_rightArrow; + + return oox::XML_rightArrow; +} + void AlgAtom::layoutShape( const ShapePtr& rShape, const std::vector<Constraint>& rConstraints ) { @@ -559,7 +533,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape, { // There is no shape type "conn", replace it by an arrow based // on the direction of the parent linear layout. - sal_Int32 nType = getConnectorType(getLayoutNode().getParentLayoutNode()); + sal_Int32 nType = getConnectorType(); rShape->setSubType(nType); rShape->getCustomShapeProperties()->setShapePresetType(nType); diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx index 726e75e2b01e..c742f604a409 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx @@ -178,6 +178,9 @@ private: ParamMap maMap; /// Aspect ratio is not integer, so not part of maMap. double mfAspectRatio = 0; + + /// Determines the connector shape type for conn algorithm + sal_Int32 getConnectorType(); }; typedef std::shared_ptr< AlgAtom > AlgAtomPtr; |