summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2018-02-14 02:15:54 +0100
committerAndras Timar <andras.timar@collabora.com>2018-02-15 13:15:19 +0100
commit173944948522854a7a1df89e48c20c83113ca77d (patch)
tree82670f8b5b0e5de8108a5e712d44f133ffe8170c
parent5024d7dbb364dec4fc90979251e5f29bc5ed3f5b (diff)
tdf#51340: Line spacing is imported incorrectly from PPTX
Move the line spacing member to the TextParagraphProperties class which is used to do the inheritance from master / layout slides. Reviewed-on: https://gerrit.libreoffice.org/49692 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com> (cherry picked from commit 53551d49d3be2301985f2cf2d8bb23ff374ecfd1) Change-Id: I0bf92420963163eae78e06ebc7fdfa1f2c72fdf8 Reviewed-on: https://gerrit.libreoffice.org/49746 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--oox/inc/drawingml/textparagraphproperties.hxx4
-rw-r--r--oox/inc/drawingml/textparagraphpropertiescontext.hxx1
-rw-r--r--oox/source/drawingml/textparagraphproperties.cxx11
-rw-r--r--oox/source/drawingml/textparagraphpropertiescontext.cxx17
-rwxr-xr-xsd/qa/unit/data/pptx/tdf51340.pptxbin0 -> 16503 bytes
-rw-r--r--sd/qa/unit/import-tests.cxx42
6 files changed, 66 insertions, 9 deletions
diff --git a/oox/inc/drawingml/textparagraphproperties.hxx b/oox/inc/drawingml/textparagraphproperties.hxx
index fb9f3ccf2acb..9ca5f3e6ceda 100644
--- a/oox/inc/drawingml/textparagraphproperties.hxx
+++ b/oox/inc/drawingml/textparagraphproperties.hxx
@@ -96,6 +96,9 @@ public:
boost::optional< sal_Int16 >& getParaAdjust() { return moParaAdjust; }
void setParaAdjust( sal_Int16 nParaAdjust ) { moParaAdjust = nParaAdjust; }
+ TextSpacing& getLineSpacing() { return maLineSpacing; }
+ void setLineSpacing( const TextSpacing& rLineSpacing ) { maLineSpacing = rLineSpacing; }
+
void apply( const TextParagraphProperties& rSourceProps );
void pushToPropSet( const ::oox::core::XmlFilterBase* pFilterBase,
const css::uno::Reference < css::beans::XPropertySet > & xPropSet,
@@ -125,6 +128,7 @@ protected:
boost::optional< sal_Int32 > moFirstLineIndentation;
boost::optional< sal_Int16 > moParaAdjust;
sal_Int16 mnLevel;
+ TextSpacing maLineSpacing;
};
} }
diff --git a/oox/inc/drawingml/textparagraphpropertiescontext.hxx b/oox/inc/drawingml/textparagraphpropertiescontext.hxx
index ba3fe098db1b..4c37c470e565 100644
--- a/oox/inc/drawingml/textparagraphpropertiescontext.hxx
+++ b/oox/inc/drawingml/textparagraphpropertiescontext.hxx
@@ -42,7 +42,6 @@ public:
protected:
TextParagraphProperties& mrTextParagraphProperties;
- TextSpacing maLineSpacing;
BulletList& mrBulletList;
std::list< css::style::TabStop > maTabList;
std::shared_ptr< BlipFillProperties > mxBlipProps;
diff --git a/oox/source/drawingml/textparagraphproperties.cxx b/oox/source/drawingml/textparagraphproperties.cxx
index 4d281c052bd1..f165be19bb40 100644
--- a/oox/source/drawingml/textparagraphproperties.cxx
+++ b/oox/source/drawingml/textparagraphproperties.cxx
@@ -387,6 +387,8 @@ void TextParagraphProperties::apply( const TextParagraphProperties& rSourceProps
mnLevel = rSourceProps.mnLevel;
if( rSourceProps.moParaAdjust )
moParaAdjust = rSourceProps.moParaAdjust;
+ if( rSourceProps.maLineSpacing.bHasValue )
+ maLineSpacing = rSourceProps.maLineSpacing;
}
void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase* pFilterBase,
@@ -493,6 +495,15 @@ void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase* p
{
aPropSet.setProperty( PROP_ParaAdjust, css::style::ParagraphAdjust_LEFT);
}
+
+ if ( maLineSpacing.bHasValue )
+ {
+ aPropSet.setProperty( PROP_ParaLineSpacing, maLineSpacing.toLineSpacing());
+ }
+ else
+ {
+ aPropSet.setProperty( PROP_ParaLineSpacing, css::style::LineSpacing( css::style::LineSpacingMode::PROP, 100 ));
+ }
}
float TextParagraphProperties::getCharHeightPoints( float fDefault ) const
diff --git a/oox/source/drawingml/textparagraphpropertiescontext.cxx b/oox/source/drawingml/textparagraphpropertiescontext.cxx
index 3a0eb4156849..051bfd989119 100644
--- a/oox/source/drawingml/textparagraphpropertiescontext.cxx
+++ b/oox/source/drawingml/textparagraphpropertiescontext.cxx
@@ -133,8 +133,8 @@ TextParagraphPropertiesContext::TextParagraphPropertiesContext( ContextHandler2H
TextParagraphPropertiesContext::~TextParagraphPropertiesContext()
{
PropertyMap& rPropertyMap( mrTextParagraphProperties.getTextParagraphPropertyMap() );
- if ( maLineSpacing.bHasValue )
- rPropertyMap.setProperty( PROP_ParaLineSpacing, maLineSpacing.toLineSpacing());
+ if ( mrTextParagraphProperties.getLineSpacing().bHasValue )
+ rPropertyMap.setProperty( PROP_ParaLineSpacing, mrTextParagraphProperties.getLineSpacing().toLineSpacing());
else
rPropertyMap.setProperty( PROP_ParaLineSpacing, css::style::LineSpacing( css::style::LineSpacingMode::PROP, 100 ));
@@ -167,7 +167,7 @@ ContextHandlerRef TextParagraphPropertiesContext::onCreateContext( sal_Int32 aEl
switch( aElementToken )
{
case A_TOKEN( lnSpc ): // CT_TextSpacing
- return new TextSpacingContext( *this, maLineSpacing );
+ return new TextSpacingContext( *this, mrTextParagraphProperties.getLineSpacing() );
case A_TOKEN( spcBef ): // CT_TextSpacing
return new TextSpacingContext( *this, mrTextParagraphProperties.getParaTopMargin() );
case A_TOKEN( spcAft ): // CT_TextSpacing
@@ -316,17 +316,18 @@ ContextHandlerRef TextParagraphPropertiesContext::onCreateContext( sal_Int32 aEl
OptValue<sal_Int32> oLineSpacing = rAttribs.getInteger(W_TOKEN(line));
if (oLineSpacing.has())
{
+ TextSpacing& rLineSpacing = mrTextParagraphProperties.getLineSpacing();
if( !oLineRule.has() || oLineRule.get() == "auto" )
{
- maLineSpacing.nUnit = TextSpacing::PERCENT;
- maLineSpacing.nValue = oLineSpacing.get() * MAX_PERCENT / 240;
+ rLineSpacing.nUnit = TextSpacing::PERCENT;
+ rLineSpacing.nValue = oLineSpacing.get() * MAX_PERCENT / 240;
}
else
{
- maLineSpacing.nUnit = TextSpacing::POINTS;
- maLineSpacing.nValue = TWIPS_TO_MM(oLineSpacing.get());
+ rLineSpacing.nUnit = TextSpacing::POINTS;
+ rLineSpacing.nValue = TWIPS_TO_MM(oLineSpacing.get());
}
- maLineSpacing.bHasValue = true;
+ rLineSpacing.bHasValue = true;
}
}
break;
diff --git a/sd/qa/unit/data/pptx/tdf51340.pptx b/sd/qa/unit/data/pptx/tdf51340.pptx
new file mode 100755
index 000000000000..090ea1be182a
--- /dev/null
+++ b/sd/qa/unit/data/pptx/tdf51340.pptx
Binary files differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 221a92a5478a..1212eee9495d 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -68,6 +68,8 @@
#include <com/sun/star/table/BorderLineStyle.hpp>
#include <com/sun/star/table/BorderLine2.hpp>
#include <com/sun/star/style/ParagraphAdjust.hpp>
+#include <com/sun/star/style/LineSpacing.hpp>
+#include <com/sun/star/style/LineSpacingMode.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/table/XTableRows.hpp>
#include <com/sun/star/style/NumberingType.hpp>
@@ -154,6 +156,7 @@ public:
void testTdf115394();
void testTdf115394PPT();
void testTdf114821();
+ void testTdf51340();
bool checkPattern(sd::DrawDocShellRef& rDocRef, int nShapeNumber, std::vector<sal_uInt8>& rExpected);
void testPatternImport();
@@ -226,6 +229,7 @@ public:
CPPUNIT_TEST(testTdf115394);
CPPUNIT_TEST(testTdf115394PPT);
CPPUNIT_TEST(testTdf114821);
+ CPPUNIT_TEST(testTdf51340);
CPPUNIT_TEST_SUITE_END();
};
@@ -2367,6 +2371,44 @@ void SdImportTest::testTdf114821()
xDocShRef->DoClose();
}
+void SdImportTest::testTdf51340()
+{
+ // Line spacing was not inherited from upper levels (slide layout, master slide)
+ sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf51340.pptx"), PPTX);
+ uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 1, 0, xDocShRef ) );
+
+ // First paragraph has a 90% line spacing set on master slide
+ uno::Reference<text::XTextRange> xParagraph( getParagraphFromShape( 0, xShape ) );
+ uno::Reference< beans::XPropertySet > xPropSet( xParagraph, uno::UNO_QUERY_THROW );
+ css::style::LineSpacing aSpacing;
+ xPropSet->getPropertyValue( "ParaLineSpacing" ) >>= aSpacing;
+ CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(css::style::LineSpacingMode::PROP), aSpacing.Mode );
+ CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(90), aSpacing.Height );
+
+ // Second paragraph has a 125% line spacing set on slide layout
+ xParagraph.set( getParagraphFromShape( 1, xShape ) );
+ xPropSet.set( xParagraph, uno::UNO_QUERY_THROW );
+ xPropSet->getPropertyValue( "ParaLineSpacing" ) >>= aSpacing;
+ CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(css::style::LineSpacingMode::PROP), aSpacing.Mode );
+ CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(125), aSpacing.Height );
+
+ // Third paragraph has a 70% line spacing set directly on normal slide (master slide property ir overriden)
+ xParagraph.set( getParagraphFromShape( 2, xShape ) );
+ xPropSet.set( xParagraph, uno::UNO_QUERY_THROW );
+ xPropSet->getPropertyValue( "ParaLineSpacing" ) >>= aSpacing;
+ CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(css::style::LineSpacingMode::PROP), aSpacing.Mode );
+ CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(70), aSpacing.Height );
+
+ // Fourth paragraph has a 190% line spacing set directly on normal slide (slide layout property is overriden)
+ xParagraph.set( getParagraphFromShape( 3, xShape ) );
+ xPropSet.set( xParagraph, uno::UNO_QUERY_THROW );
+ xPropSet->getPropertyValue( "ParaLineSpacing" ) >>= aSpacing;
+ CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(css::style::LineSpacingMode::PROP), aSpacing.Mode );
+ CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(190), aSpacing.Height );
+
+ xDocShRef->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
CPPUNIT_PLUGIN_IMPLEMENT();