diff options
-rw-r--r-- | oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 46 | ||||
-rw-r--r-- | oox/source/drawingml/diagram/diagramlayoutatoms.hxx | 7 | ||||
-rw-r--r-- | sd/qa/unit/import-tests-smartart.cxx | 13 |
3 files changed, 66 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; diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx index aa8498b73ce9..be8ac42d3b45 100644 --- a/sd/qa/unit/import-tests-smartart.cxx +++ b/sd/qa/unit/import-tests-smartart.cxx @@ -14,6 +14,8 @@ #include <com/sun/star/style/ParagraphAdjust.hpp> #include <com/sun/star/text/XText.hpp> +#include <comphelper/sequenceashashmap.hxx> + using namespace ::com::sun::star; class SdImportTestSmartArt : public SdModelTestBase @@ -490,6 +492,17 @@ void SdImportTestSmartArt::testAccentProcess() // below xFirstParent (a good position is 9081). CPPUNIT_ASSERT_LESS(nFirstChildTop, nFirstParentTop); + // Make sure that we have an arrow shape between the two pairs. + uno::Reference<beans::XPropertySet> xArrow(xGroup->getByIndex(1), uno::UNO_QUERY); + CPPUNIT_ASSERT(xArrow.is()); + comphelper::SequenceAsHashMap aCustomShapeGeometry( + xArrow->getPropertyValue("CustomShapeGeometry")); + // Without the accompanying fix in place, this test would have failed, i.e. + // the custom shape lacked a type -> arrow was not visible. + CPPUNIT_ASSERT(aCustomShapeGeometry["Type"].has<OUString>()); + OUString aType = aCustomShapeGeometry["Type"].get<OUString>(); + CPPUNIT_ASSERT_EQUAL(OUString("ooxml-rightArrow"), aType); + uno::Reference<drawing::XShapes> xSecondPair(xGroup->getByIndex(2), uno::UNO_QUERY); CPPUNIT_ASSERT(xSecondPair.is()); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xSecondPair->getCount()); |