include/oox/export/drawingml.hxx | 2 +- oox/inc/drawingml/textspacing.hxx | 14 +++++++++----- oox/source/drawingml/textspacingcontext.cxx | 1 + oox/source/export/drawingml.cxx | 4 ++-- sd/qa/unit/data/odp/tdf112647.odp |binary sd/qa/unit/export-tests-ooxml2.cxx | 19 +++++++++++++++++++ 6 files changed, 32 insertions(+), 8 deletions(-)
New commits: commit 4645eefaf4afa1382cf20374a1f4323b418e431d Author: Tamás Zolnai <tamas.zol...@collabora.com> Date: Tue Sep 26 16:01:34 2017 +0200 tdf#112647: Fixed line spacing is saved incorrectly to PPTX The values were not converted to the right unit. Also the spcPts attribute means an exact value not a minimum one. Reviewed-on: https://gerrit.libreoffice.org/42763 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> (cherry picked from commit ef2e9b19a52e04ae0ed45900bcf64bf375a910ef) Change-Id: Ia49683e66153611e96a830f821e3a2487adec505 Reviewed-on: https://gerrit.libreoffice.org/42814 Reviewed-by: Michael Stahl <mst...@redhat.com> Tested-by: Michael Stahl <mst...@redhat.com> diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx index 9c442d66a452..732d0fc613e3 100644 --- a/include/oox/export/drawingml.hxx +++ b/include/oox/export/drawingml.hxx @@ -185,7 +185,7 @@ public: void WriteSrcRect( const css::uno::Reference< css::beans::XPropertySet >&, const OUString& ); void WriteOutline( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet ); void WriteStretch( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, const OUString& rURL ); - void WriteLinespacing( css::style::LineSpacing& rLineSpacing ); + void WriteLinespacing( const css::style::LineSpacing& rLineSpacing ); OUString WriteBlip( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, const OUString& rURL, bool bRelPathToMedia = false , const Graphic *pGraphic=nullptr ); diff --git a/oox/inc/drawingml/textspacing.hxx b/oox/inc/drawingml/textspacing.hxx index efe0dab06674..fa7e7ad657a1 100644 --- a/oox/inc/drawingml/textspacing.hxx +++ b/oox/inc/drawingml/textspacing.hxx @@ -38,16 +38,19 @@ namespace oox { namespace drawingml { PERCENT }; TextSpacing() - : nUnit( POINTS ), nValue( 0 ), bHasValue( false ) + : nUnit( POINTS ), nValue( 0 ), bHasValue( false ), bExactValue( false ) { } - TextSpacing( sal_Int32 nPoints ) : nUnit( POINTS ), nValue( nPoints ), bHasValue( true ){}; + TextSpacing( sal_Int32 nPoints ) : nUnit( POINTS ), nValue( nPoints ), bHasValue( true ), bExactValue ( false ){}; css::style::LineSpacing toLineSpacing() const { css::style::LineSpacing aSpacing; - aSpacing.Mode = ( nUnit == PERCENT - ? css::style::LineSpacingMode::PROP - : css::style::LineSpacingMode::MINIMUM ); + if (nUnit == PERCENT) + aSpacing.Mode = css::style::LineSpacingMode::PROP; + else if (bExactValue) + aSpacing.Mode = css::style::LineSpacingMode::FIX; + else + aSpacing.Mode = css::style::LineSpacingMode::MINIMUM; aSpacing.Height = static_cast< sal_Int16 >( nUnit == PERCENT ? nValue / 1000 : nValue ); return aSpacing; } @@ -61,6 +64,7 @@ namespace oox { namespace drawingml { sal_Int32 nUnit; sal_Int32 nValue; bool bHasValue; + bool bExactValue; }; } } diff --git a/oox/source/drawingml/textspacingcontext.cxx b/oox/source/drawingml/textspacingcontext.cxx index fc6dfd813139..bf85fc3b11a6 100644 --- a/oox/source/drawingml/textspacingcontext.cxx +++ b/oox/source/drawingml/textspacingcontext.cxx @@ -49,6 +49,7 @@ namespace oox { namespace drawingml { case A_TOKEN( spcPts ): maSpacing.nUnit = TextSpacing::POINTS; maSpacing.nValue = GetTextSpacingPoint( rAttribs.getString( XML_val ).get() ); + maSpacing.bExactValue = true; break; default: break; diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 9aacad6e7aa2..4f1aa7223ee1 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1918,7 +1918,7 @@ const char* DrawingML::GetAlignment( sal_Int32 nAlignment ) return sAlignment; } -void DrawingML::WriteLinespacing( LineSpacing& rSpacing ) +void DrawingML::WriteLinespacing( const LineSpacing& rSpacing ) { if( rSpacing.Mode == LineSpacingMode::PROP ) { @@ -1929,7 +1929,7 @@ void DrawingML::WriteLinespacing( LineSpacing& rSpacing ) else { mpFS->singleElementNS( XML_a, XML_spcPts, - XML_val, I32S( rSpacing.Height ), + XML_val, I32S( std::lround(rSpacing.Height / 25.4 * 72) ), FSEND ); } } diff --git a/sd/qa/unit/data/odp/tdf112647.odp b/sd/qa/unit/data/odp/tdf112647.odp new file mode 100755 index 000000000000..72a6621b8e86 Binary files /dev/null and b/sd/qa/unit/data/odp/tdf112647.odp differ diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index c9190914ef67..4b467568921b 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -66,6 +66,8 @@ #include <com/sun/star/drawing/FillStyle.hpp> #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> +#include <com/sun/star/style/LineSpacing.hpp> +#include <com/sun/star/style/LineSpacingMode.hpp> #include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/table/XTable.hpp> #include <com/sun/star/table/XMergeableCell.hpp> @@ -105,6 +107,7 @@ public: void testTdf59046(); void testTdf105739(); void testTdf112552(); + void testTdf112647(); CPPUNIT_TEST_SUITE(SdOOXMLExportTest2); @@ -133,6 +136,7 @@ public: CPPUNIT_TEST(testTdf59046); CPPUNIT_TEST(testTdf105739); CPPUNIT_TEST(testTdf112552); + CPPUNIT_TEST(testTdf112647); CPPUNIT_TEST_SUITE_END(); @@ -808,6 +812,21 @@ void SdOOXMLExportTest2::testTdf112552() xDocShRef->DoClose(); } +void SdOOXMLExportTest2::testTdf112647() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/odp/tdf112647.odp"), ODP); + xDocShRef = saveAndReload( xDocShRef.get(), PPTX ); + uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) ); + uno::Reference<text::XTextRange> xParagraph( getParagraphFromShape( 0, xShape ) ); + uno::Reference< beans::XPropertySet > xPropSet( xParagraph, uno::UNO_QUERY_THROW ); + + css::style::LineSpacing aLineSpacing; + xPropSet->getPropertyValue("ParaLineSpacing") >>= aLineSpacing; + CPPUNIT_ASSERT_EQUAL(sal_Int16(css::style::LineSpacingMode::FIX), aLineSpacing.Mode); + CPPUNIT_ASSERT_EQUAL(sal_Int16(2117), aLineSpacing.Height); + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2); CPPUNIT_PLUGIN_IMPLEMENT();
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits