diff options
author | Tibor Nagy <nagy.tibor2@nisz.hu> | 2021-11-19 12:36:42 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-12-03 15:52:50 +0100 |
commit | fc1e5202cbfb36b28b0e597811f39895c19ae6ba (patch) | |
tree | e822e178dee5b43888802587d27c2b5d8030d44f | |
parent | 41f736f9bea66657bde2f41afe506e376fe8548e (diff) |
tdf#129430 PPTX export: fix workaround for "At least" line spacing
to avoid bad overlapping lines.
PPTX does not have the option "At least", so line spacing
with this setting is converted to fixed line spacing.
Improve this workaround to use single line spacing, if the
"At least" value is lower than the size of the characters,
like "At least" is handled by Impress.
Change-Id: I29b41225d48fd9a447e7f6ef3a8a7cc7ba9ef354
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125553
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r-- | include/oox/export/drawingml.hxx | 2 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 11 | ||||
-rw-r--r-- | sd/qa/unit/data/odp/tdf129430.odp | bin | 0 -> 10697 bytes | |||
-rw-r--r-- | sd/qa/unit/export-tests-ooxml3.cxx | 15 |
4 files changed, 25 insertions, 3 deletions
diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx index 516287293580..b71490752708 100644 --- a/include/oox/export/drawingml.hxx +++ b/include/oox/export/drawingml.hxx @@ -262,7 +262,7 @@ public: void WriteXGraphicStretch(css::uno::Reference<css::beans::XPropertySet> const & rXPropSet, css::uno::Reference<css::graphic::XGraphic> const & rxGraphic); - void WriteLinespacing( const css::style::LineSpacing& rLineSpacing ); + void WriteLinespacing(const css::style::LineSpacing& rLineSpacing, float fFirstCharHeight); OUString WriteXGraphicBlip(css::uno::Reference<css::beans::XPropertySet> const & rXPropSet, css::uno::Reference<css::graphic::XGraphic> const & rxGraphic, diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 7217efe0e5c9..0c8235a3a1da 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -2894,13 +2894,20 @@ const char* DrawingML::GetAlignment( style::ParagraphAdjust nAlignment ) return sAlignment; } -void DrawingML::WriteLinespacing( const LineSpacing& rSpacing ) +void DrawingML::WriteLinespacing(const LineSpacing& rSpacing, float fFirstCharHeight) { if( rSpacing.Mode == LineSpacingMode::PROP ) { mpFS->singleElementNS( XML_a, XML_spcPct, XML_val, OString::number(static_cast<sal_Int32>(rSpacing.Height)*1000)); } + else if (rSpacing.Mode == LineSpacingMode::MINIMUM + && fFirstCharHeight > static_cast<float>(rSpacing.Height) * 0.001 * 72.0 / 2.54) + { + // 100% proportional line spacing = single line spacing + mpFS->singleElementNS(XML_a, XML_spcPct, XML_val, + OString::number(static_cast<sal_Int32>(100000))); + } else { mpFS->singleElementNS( XML_a, XML_spcPts, @@ -2988,7 +2995,7 @@ bool DrawingML::WriteParagraphProperties( const Reference< XTextContent >& rPara if( bHasLinespacing ) { mpFS->startElementNS(XML_a, XML_lnSpc); - WriteLinespacing( aLineSpacing ); + WriteLinespacing(aLineSpacing, fFirstCharHeight); mpFS->endElementNS( XML_a, XML_lnSpc ); } diff --git a/sd/qa/unit/data/odp/tdf129430.odp b/sd/qa/unit/data/odp/tdf129430.odp Binary files differnew file mode 100644 index 000000000000..f5304f75cf26 --- /dev/null +++ b/sd/qa/unit/data/odp/tdf129430.odp diff --git a/sd/qa/unit/export-tests-ooxml3.cxx b/sd/qa/unit/export-tests-ooxml3.cxx index 900716e20093..375922511661 100644 --- a/sd/qa/unit/export-tests-ooxml3.cxx +++ b/sd/qa/unit/export-tests-ooxml3.cxx @@ -51,6 +51,7 @@ class SdOOXMLExportTest3 : public SdModelTestBaseXML { public: + void testTdf129430(); void testTdf114848(); void testTdf68759(); void testTdf127901(); @@ -125,6 +126,7 @@ public: CPPUNIT_TEST_SUITE(SdOOXMLExportTest3); + CPPUNIT_TEST(testTdf129430); CPPUNIT_TEST(testTdf114848); CPPUNIT_TEST(testTdf68759); CPPUNIT_TEST(testTdf127901); @@ -203,6 +205,19 @@ public: } }; +void SdOOXMLExportTest3::testTdf129430() +{ + sd::DrawDocShellRef xDocShRef + = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf129430.odp"), ODP); + utl::TempFile tempFile; + xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile); + xDocShRef->DoClose(); + + xmlDocUniquePtr pXmlDoc1 = parseExport(tempFile, "ppt/slides/slide1.xml"); + assertXPath(pXmlDoc1, "/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p[2]/a:pPr/a:lnSpc/a:spcPct", + "val", "100000"); +} + void SdOOXMLExportTest3::testTdf114848() { ::sd::DrawDocShellRef xDocShRef |