diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-09-18 17:53:33 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-09-18 20:12:00 +0200 |
commit | 10bb02efd8afd42e633e370480104e2575546d8e (patch) | |
tree | 5e95cb9f12cd64a48b99325938e05e58cdb06bbe /oox/qa/unit | |
parent | cb15d181b6446003ddc5a13eff9dfb14fc5a8179 (diff) |
tdf#129685 PPTX import: fix unexpected centering of shape text
Regression from commit 89f0af144c18efafe2573801641689a1432c0cae (tdf#113198 set
default shape paragraph alignment.., 2019-11-19), the old bugdoc had this
markup:
<a:bodyPr ... anchor="ctr"/> (centered)
The new bugdoc has 2 shapes with text:
<a:bodyPr .../> (aligned to left)
<a:bodyPr ... anchorCtr="1"/> (should be centered)
"anchor" is about vertical, "anchorCtr" is about horizontal centering of text.
Checking what the binary filter does, it maps horizontal centering to
TextHorizontalAdjust, so fix the original bug differently, by leaving
ParaAdjust alone, and tweaking TextHorizontalAdjust intead: this keeps the old
bugdoc working but fixes the new one.
This caused a number of "change detector" XML-based tests to fail: all of them
are unchanged visually, so the XML files are adapted to the new state.
The tdf#113198 fix itself was fixing a regression from tdf#104722, and that
commit had no testcase, I tested that we don't regress there, manually.
Change-Id: I81a7b3e8c76bfbce5c5569d16d5238958ac20f75
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103012
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'oox/qa/unit')
-rw-r--r-- | oox/qa/unit/data/shape-text-alignment.pptx | bin | 0 -> 30844 bytes | |||
-rw-r--r-- | oox/qa/unit/drawingml.cxx | 20 |
2 files changed, 20 insertions, 0 deletions
diff --git a/oox/qa/unit/data/shape-text-alignment.pptx b/oox/qa/unit/data/shape-text-alignment.pptx Binary files differnew file mode 100644 index 000000000000..ff4ff06f2fdf --- /dev/null +++ b/oox/qa/unit/data/shape-text-alignment.pptx diff --git a/oox/qa/unit/drawingml.cxx b/oox/qa/unit/drawingml.cxx index d88f91797304..43609435c468 100644 --- a/oox/qa/unit/drawingml.cxx +++ b/oox/qa/unit/drawingml.cxx @@ -24,6 +24,7 @@ #include <com/sun/star/chart2/XChartTypeContainer.hpp> #include <com/sun/star/chart2/XDataSeriesContainer.hpp> #include <com/sun/star/chart2/XDataPointCustomLabelField.hpp> +#include <com/sun/star/style/ParagraphAdjust.hpp> #include <unotools/mediadescriptor.hxx> #include <unotools/tempfile.hxx> @@ -226,6 +227,25 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testGradientMultiStepTransparency) CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xffffff), aTransparence.EndColor); } +CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testShapeTextAlignment) +{ + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "shape-text-alignment.pptx"; + load(aURL); + + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), + uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); + sal_Int16 nParaAdjust = -1; + CPPUNIT_ASSERT(xShape->getPropertyValue("ParaAdjust") >>= nParaAdjust); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 0 + // - Actual : 3 + // i.e. text which is meant to be left-aligned was centered at a paragraph level. + CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_LEFT, + static_cast<style::ParagraphAdjust>(nParaAdjust)); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |