From be78a50a883e646e9d4830e3024554395dd12b9e Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 30 Nov 2018 16:40:58 +0100 Subject: oox smartart, accent process: handle connector shape between pairs The shape was created, but we literally tried to create a "conn" type, while that has to be resolved to the relevant arrow type based on the context. This means now arrows show up between the parent-child pairs (but their size is not yet correct). Change-Id: I82594e46579e4ef723093e1dd0ba31bfcbbec4a0 Reviewed-on: https://gerrit.libreoffice.org/64348 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit 7f66a340933339974b5c6d70af4ae3c17e4f001a) Reviewed-on: https://gerrit.libreoffice.org/65251 --- .../drawingml/diagram/diagramlayoutatoms.cxx | 46 ++++++++++++++++++++++ .../drawingml/diagram/diagramlayoutatoms.hxx | 7 ++++ 2 files changed, 53 insertions(+) (limited to 'oox') diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index 52a05ccdb53d..f5a7b410de03 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -64,6 +64,41 @@ bool isFontUnit(sal_Int32 nUnit) { return nUnit == oox::XML_primFontSz || nUnit == oox::XML_secFontSz; } + +/// 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; + + for (const auto& pChild : pNode->getChildren()) + { + auto pAlgAtom = dynamic_cast(pChild.get()); + if (!pAlgAtom) + continue; + + if (pAlgAtom->getType() != oox::XML_lin) + continue; + + 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; + } + } + + return nType; +} } namespace oox { namespace drawingml { @@ -399,7 +434,18 @@ void AlgAtom::layoutShape( const ShapePtr& rShape, } case XML_conn: + { + if (rShape->getSubType() == XML_conn) + { + // There is no shape type "conn", replace it by an arrow based + // on the direction of the parent linear layout. + sal_Int32 nType = getConnectorType(pParent); + + rShape->setSubType(nType); + rShape->getCustomShapeProperties()->setShapePresetType(nType); + } break; + } case XML_cycle: { diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx index 50ff8a300ac5..024cdaa1b61a 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx @@ -162,6 +162,13 @@ public: { maMap[nType]=nVal; } void layoutShape( const ShapePtr& rShape, const std::vector& rConstraints ) const; + + /// Gives access to . + sal_Int32 getType() const { return mnType; } + + /// Gives access to . + const ParamMap& getMap() const { return maMap; } + private: sal_Int32 mnType; ParamMap maMap; -- cgit v1.2.3