[Libreoffice-commits] core.git: oox/source sd/qa
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Nov 30 23:10:51 UTC 2018
oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 46 ++++++++++++++++++++
oox/source/drawingml/diagram/diagramlayoutatoms.hxx | 7 +++
sd/qa/unit/import-tests-smartart.cxx | 13 +++++
3 files changed, 66 insertions(+)
New commits:
commit 7f66a340933339974b5c6d70af4ae3c17e4f001a
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Nov 30 16:40:58 2018 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Sat Dec 1 00:10:20 2018 +0100
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 at collabora.com>
Tested-by: Jenkins
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());
More information about the Libreoffice-commits
mailing list