summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-09-11 17:30:27 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-09-15 14:39:02 +0200
commitc22ab1cba13d59d7982d8972ece7e8a64e9a74fa (patch)
treefea69aef87ac5ba7b88aaa155a440adee7a6961d /sd
parent618b12b768eaffd40fcd98eb0ed55d0e7850b64c (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. (cherry picked from commit 1bd3474c7c7945e1182dfbaca89be05ea98dd3e8) Conflicts: include/oox/core/xmlfilterbase.hxx Change-Id: I6c591eadc7166c7c42752650afdb7ee1e416cff6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102711 Tested-by: Jenkins Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/data/pptx/smartart-autofit-sync.pptxbin0 -> 45546 bytes
-rw-r--r--sd/qa/unit/import-tests-smartart.cxx30
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
new file mode 100644
index 000000000000..f682c143f584
--- /dev/null
+++ b/sd/qa/unit/data/pptx/smartart-autofit-sync.pptx
Binary files differ
diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx
index 28dafbc1d9af..254e209acbac 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -110,6 +110,7 @@ public:
void testTdf131553();
void testFillColorList();
void testLinearRule();
+ void testAutofitSync();
CPPUNIT_TEST_SUITE(SdImportTestSmartArt);
@@ -157,6 +158,7 @@ public:
CPPUNIT_TEST(testTdf131553);
CPPUNIT_TEST(testFillColorList);
CPPUNIT_TEST(testLinearRule);
+ CPPUNIT_TEST(testAutofitSync);
CPPUNIT_TEST_SUITE_END();
};
@@ -1548,6 +1550,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();