[Libreoffice-commits] core.git: oox/source sd/qa
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Dec 12 21:55:14 UTC 2018
oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 29 ++++++-----
sd/qa/unit/data/pptx/smartart-continuous-block-process.pptx |binary
sd/qa/unit/import-tests-smartart.cxx | 31 ++++++++++++
3 files changed, 47 insertions(+), 13 deletions(-)
New commits:
commit ee6787fc5597b7f730c4ee3a1f2a1b261d0a5644
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Dec 12 18:09:12 2018 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Dec 12 22:54:45 2018 +0100
oox smartart, continuous block process: read space width from constraint
The information is needed by the linear layout, but it's provided by a
child algorithm of type "space", with possibly multiple foreach atoms
in-between.
So start supporting a custom space factor by reading it from
constraints, but still assume a fixed layout node name, as it's tricky
to look that up.
Change-Id: I2aa8db8823694618d8ca6707ddcd71715a65b831
Reviewed-on: https://gerrit.libreoffice.org/65049
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 f99126be9bed..bea44faf8784 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -536,22 +536,9 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
const sal_Int32 nIncX = nDir==XML_fromL ? 1 : (nDir==XML_fromR ? -1 : 0);
const sal_Int32 nIncY = nDir==XML_fromT ? 1 : (nDir==XML_fromB ? -1 : 0);
- // TODO: get values from constraints
sal_Int32 nCount = rShape->getChildren().size();
double fSpace = 0.3;
- awt::Size aChildSize = rShape->getSize();
- if (nDir == XML_fromL || nDir == XML_fromR)
- aChildSize.Width /= (nCount + (nCount-1)*fSpace);
- else if (nDir == XML_fromT || nDir == XML_fromB)
- aChildSize.Height /= (nCount + (nCount-1)*fSpace);
-
- awt::Point aCurrPos(0, 0);
- if (nIncX == -1)
- aCurrPos.X = rShape->getSize().Width - aChildSize.Width;
- if (nIncY == -1)
- aCurrPos.Y = rShape->getSize().Height - aChildSize.Height;
-
// Find out which constraint is relevant for which (internal) name.
LayoutPropertyMap aProperties;
for (const auto& rConstraint : rConstraints)
@@ -562,8 +549,24 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
LayoutProperty& rProperty = aProperties[rConstraint.msForName];
if (rConstraint.mnType == XML_w)
rProperty[XML_w] = rShape->getSize().Width * rConstraint.mfFactor;
+
+ // TODO: get values from differently named constraints as well
+ if (rConstraint.msForName == "sibTrans" && rConstraint.mnType == XML_w)
+ fSpace = rConstraint.mfFactor;
}
+ awt::Size aChildSize = rShape->getSize();
+ if (nDir == XML_fromL || nDir == XML_fromR)
+ aChildSize.Width /= (nCount + (nCount-1)*fSpace);
+ else if (nDir == XML_fromT || nDir == XML_fromB)
+ aChildSize.Height /= (nCount + (nCount-1)*fSpace);
+
+ awt::Point aCurrPos(0, 0);
+ if (nIncX == -1)
+ aCurrPos.X = rShape->getSize().Width - aChildSize.Width;
+ if (nIncY == -1)
+ aCurrPos.Y = rShape->getSize().Height - aChildSize.Height;
+
// See if children requested more than 100% space in total: scale
// down in that case.
sal_Int32 nTotalWidth = 0;
diff --git a/sd/qa/unit/data/pptx/smartart-continuous-block-process.pptx b/sd/qa/unit/data/pptx/smartart-continuous-block-process.pptx
new file mode 100644
index 000000000000..b2ef58f0bbb3
Binary files /dev/null and b/sd/qa/unit/data/pptx/smartart-continuous-block-process.pptx differ
diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx
index 1f30ba36e394..5eda257f6bf0 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -47,6 +47,7 @@ public:
void testVertialBracketList();
void testTableList();
void testAccentProcess();
+ void testContinuousBlockProcess();
CPPUNIT_TEST_SUITE(SdImportTestSmartArt);
@@ -76,6 +77,7 @@ public:
CPPUNIT_TEST(testVertialBracketList);
CPPUNIT_TEST(testTableList);
CPPUNIT_TEST(testAccentProcess);
+ CPPUNIT_TEST(testContinuousBlockProcess);
CPPUNIT_TEST_SUITE_END();
};
@@ -619,6 +621,35 @@ void SdImportTestSmartArt::testAccentProcess()
xDocShRef->DoClose();
}
+void SdImportTestSmartArt::testContinuousBlockProcess()
+{
+ sd::DrawDocShellRef xDocShRef = loadURL(
+ m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-continuous-block-process.pptx"),
+ PPTX);
+ uno::Reference<drawing::XShapes> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xGroup.is());
+ // 2 children: background, foreground.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xGroup->getCount());
+
+ uno::Reference<drawing::XShapes> xLinear(xGroup->getByIndex(1), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xLinear.is());
+ // 3 children: A, B and C.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xLinear->getCount());
+
+ uno::Reference<text::XText> xA(xLinear->getByIndex(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xA.is());
+ CPPUNIT_ASSERT_EQUAL(OUString("A"), xA->getString());
+ uno::Reference<drawing::XShape> xAShape(xA, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xAShape.is());
+ // Without the accompanying fix in place, this test would have failed: the
+ // theoretically correct value is 5462 mm100 (16933 is the total width, and
+ // need to divide that to 1, 0.5, 1, 0.5 and 1 units), while the old value
+ // was 4703 and the new one is 5461.
+ CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(5000), xAShape->getSize().Width);
+
+ xDocShRef->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTestSmartArt);
CPPUNIT_PLUGIN_IMPLEMENT();
More information about the Libreoffice-commits
mailing list