diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-09-11 17:30:27 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-09-11 20:07:17 +0200 |
commit | 1bd3474c7c7945e1182dfbaca89be05ea98dd3e8 (patch) | |
tree | 2a8908c145c132cf8d635a1051b10f129a6a8b13 /sd/qa/unit | |
parent | e9b9044f7b7b44b45dd582885cad0b0a7d44f88b (diff) |
oox smartart: add support for syncing font heights of multiple shapes
When 2 or more shapes have their text set to autofit and they have a
constraint like:
<dgm:constr type="primFontSz" for="des" forName="node" op="equ"/>
Then make sure that the automatic font size is the same for all shapes
and all content fits, by using the smallest scaling factor from all
relevant shapes.
Some rework is needed, because normally oox::drawingml::Shapes don't
have access to their parents, at the same time there can be multiple
SmartArts on a single slide, so storing the grouping info in the filter
is problematic, too. Solve this by storing the grouping in the toplevel
oox::drawingml::Shape and exposing them in XmlFilterBase just during the
time the children of the toplevel shape of the SmartArt are added.
This works, because we know SmartArts can't be nested.
Change-Id: I6c591eadc7166c7c42752650afdb7ee1e416cff6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102490
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sd/qa/unit')
-rw-r--r-- | sd/qa/unit/data/pptx/smartart-autofit-sync.pptx | bin | 0 -> 45546 bytes | |||
-rw-r--r-- | sd/qa/unit/import-tests-smartart.cxx | 30 |
2 files changed, 30 insertions, 0 deletions
diff --git a/sd/qa/unit/data/pptx/smartart-autofit-sync.pptx b/sd/qa/unit/data/pptx/smartart-autofit-sync.pptx Binary files differnew file mode 100644 index 000000000000..f682c143f584 --- /dev/null +++ b/sd/qa/unit/data/pptx/smartart-autofit-sync.pptx diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx index bdf320ce831f..ddc0bb9579e2 100644 --- a/sd/qa/unit/import-tests-smartart.cxx +++ b/sd/qa/unit/import-tests-smartart.cxx @@ -111,6 +111,7 @@ public: void testFillColorList(); void testTdf134221(); void testLinearRule(); + void testAutofitSync(); CPPUNIT_TEST_SUITE(SdImportTestSmartArt); @@ -159,6 +160,7 @@ public: CPPUNIT_TEST(testFillColorList); CPPUNIT_TEST(testTdf134221); CPPUNIT_TEST(testLinearRule); + CPPUNIT_TEST(testAutofitSync); CPPUNIT_TEST_SUITE_END(); }; @@ -1564,6 +1566,34 @@ void SdImportTestSmartArt::testLinearRule() xDocShRef->DoClose(); } +void SdImportTestSmartArt::testAutofitSync() +{ + sd::DrawDocShellRef xDocShRef = loadURL( + m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-autofit-sync.pptx"), PPTX); + + uno::Reference<drawing::XShape> xDiagram(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY); + uno::Reference<drawing::XShape> xMiddle = getChildShape(xDiagram, 2); + uno::Reference<beans::XPropertySet> xFirstInner(getChildShape(getChildShape(xMiddle, 0), 0), + uno::UNO_QUERY); + sal_Int16 nFirstScale = 0; + CPPUNIT_ASSERT(xFirstInner->getPropertyValue("TextFitToSizeScale") >>= nFirstScale); + CPPUNIT_ASSERT_GREATER(static_cast<sal_Int16>(0), nFirstScale); + uno::Reference<beans::XPropertySet> xSecondInner(getChildShape(getChildShape(xMiddle, 2), 0), + uno::UNO_QUERY); + sal_Int16 nSecondScale = 0; + CPPUNIT_ASSERT(xSecondInner->getPropertyValue("TextFitToSizeScale") >>= nSecondScale); + CPPUNIT_ASSERT_GREATER(static_cast<sal_Int16>(0), nSecondScale); + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 56 + // - Actual : 100 + // i.e. the left shape had no scale-down and the right shape was scaled down, even if it was + // requested that their scaling matches. + CPPUNIT_ASSERT_EQUAL(nSecondScale, nFirstScale); + + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTestSmartArt); CPPUNIT_PLUGIN_IMPLEMENT(); |