summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2018-11-30 16:40:58 +0100
committerMiklos Vajna <vmiklos@collabora.com>2018-12-17 15:39:44 +0100
commitbe78a50a883e646e9d4830e3024554395dd12b9e (patch)
tree09391976935c6eac86dec9efdb7f60135272101f /oox
parent467a2ab7e52be376ee7f0dee9bd44f7a4ed38267 (diff)
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 <vmiklos@collabora.com> Tested-by: Jenkins (cherry picked from commit 7f66a340933339974b5c6d70af4ae3c17e4f001a) Reviewed-on: https://gerrit.libreoffice.org/65251
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/diagram/diagramlayoutatoms.cxx46
-rw-r--r--oox/source/drawingml/diagram/diagramlayoutatoms.hxx7
2 files changed, 53 insertions, 0 deletions
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<oox::drawingml::AlgAtom*>(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<Constraint>& rConstraints ) const;
+
+ /// Gives access to <dgm:alg type="..."/>.
+ sal_Int32 getType() const { return mnType; }
+
+ /// Gives access to <dgm:param type="..." val="..."/>.
+ const ParamMap& getMap() const { return maMap; }
+
private:
sal_Int32 mnType;
ParamMap maMap;