summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2017-02-15 19:21:06 +0200
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2017-04-12 13:56:17 +0200
commit9e43f32b19df707a68307a693014df10f4645d98 (patch)
tree93af96cad9a8cf54492992fd4a2423b0100ca382
parent37e5ac5f54bfb14af435fa1ab30400176133dc6f (diff)
tdf#106304: Fix newline and empty paragraph font size issues in .pptx export
Output <a:br> instead of &#10; for hard newlines. This fixes the problem that the line before the hard newline in the .pptx export is not centred. The fix for the sd_export_tests is a bit hacky, but then so is the code in question. Don't unnecessarily use bogus default char size for a:endParaRPr. Instead use the size last used for an a:rPr below the same WriteText() call. I am not exactly sure about how this hangs together, but this has the desired effect on the exported .pptx. Change-Id: Ie23e0c33e6efb303b183d3b2efce6866d0dda4e8 Reviewed-on: https://gerrit.libreoffice.org/34888 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-rw-r--r--include/oox/export/drawingml.hxx9
-rw-r--r--oox/source/export/chartexport.cxx11
-rw-r--r--oox/source/export/drawingml.cxx75
-rw-r--r--sd/qa/unit/export-tests.cxx6
4 files changed, 66 insertions, 35 deletions
diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index dc1c06d88879..51a4604fa5a6 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -194,12 +194,15 @@ public:
sal_Int32 nXmlNamespace, bool bFlipH = false, bool bFlipV = false, sal_Int32 nRotation = 0 );
void WriteText( const css::uno::Reference< css::uno::XInterface >& rXIface, const OUString& presetWarp, bool bBodyPr = true, bool bText = true, sal_Int32 nXmlNamespace = 0);
- void WriteParagraph( const css::uno::Reference< css::text::XTextContent >& rParagraph );
+ void WriteParagraph( const css::uno::Reference< css::text::XTextContent >& rParagraph,
+ bool& rbOverridingCharHeight, sal_Int32& rnCharHeight );
void WriteParagraphProperties( const css::uno::Reference< css::text::XTextContent >& rParagraph );
void WriteParagraphNumbering( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
sal_Int16 nLevel );
- void WriteRun( const css::uno::Reference< css::text::XTextRange >& rRun );
- void WriteRunProperties( const css::uno::Reference< css::beans::XPropertySet >& rRun, bool bIsField, sal_Int32 nElement = XML_rPr ,bool bCheckDirect = true);
+ void WriteRun( const css::uno::Reference< css::text::XTextRange >& rRun,
+ bool& rbOverridingCharHeight, sal_Int32& rnCharHeight );
+ void WriteRunProperties( const css::uno::Reference< css::beans::XPropertySet >& rRun, bool bIsField, sal_Int32 nElement, bool bCheckDirect,
+ bool& rbOverridingCharHeight, sal_Int32& rnCharHeight );
void WritePresetShape( const char* pShape );
void WritePresetShape( const char* pShape, MSO_SPT eShapeType, bool bPredefinedHandlesUsed, sal_Int32 nAdjustmentsWhichNeedsToBeConverted, const css::beans::PropertyValue& rProp );
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index b8172f99ec62..c3be54951ed3 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -1102,13 +1102,16 @@ void ChartExport::exportTitle( const Reference< XShape >& xShape )
pFS->startElement( FSNS( XML_a, XML_pPr ),
FSEND );
- WriteRunProperties(xPropSet, false, XML_defRPr);
+ bool bDummy = false;
+ sal_Int32 nDummy;
+ WriteRunProperties(xPropSet, false, XML_defRPr, true, bDummy, nDummy );
pFS->endElement( FSNS( XML_a, XML_pPr ) );
pFS->startElement( FSNS( XML_a, XML_r ),
FSEND );
- WriteRunProperties( xPropSet, false );
+ bDummy = false;
+ WriteRunProperties( xPropSet, false, XML_rPr, true, bDummy, nDummy );
pFS->startElement( FSNS( XML_a, XML_t ),
FSEND );
pFS->writeEscaped( sText );
@@ -2390,7 +2393,9 @@ void ChartExport::exportTextProps(const Reference<XPropertySet>& xPropSet)
pFS->startElement(FSNS(XML_a, XML_p), FSEND);
pFS->startElement(FSNS(XML_a, XML_pPr), FSEND);
- WriteRunProperties(xPropSet, false, XML_defRPr);
+ bool bDummy = false;
+ sal_Int32 nDummy;
+ WriteRunProperties(xPropSet, false, XML_defRPr, true, bDummy, nDummy);
pFS->endElement(FSNS(XML_a, XML_pPr));
pFS->endElement(FSNS(XML_a, XML_p));
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index d6751a23392f..d114b23a33c8 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1203,7 +1203,8 @@ void DrawingML::WriteShapeTransformation( const Reference< XShape >& rXShape, sa
WriteTransformation( Rectangle( Point( aPos.X, aPos.Y ), Size( aSize.Width, aSize.Height ) ), nXmlNamespace, bFlipH, bFlipV, OOX_DRAWINGML_EXPORT_ROTATE_CLOCKWISIFY(nRotation) );
}
-void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, bool bIsField, sal_Int32 nElement /*= XML_rPr*/, bool bCheckDirect/* = true */)
+void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, bool bIsField, sal_Int32 nElement, bool bCheckDirect,
+ bool& rbOverridingCharHeight, sal_Int32& rnCharHeight )
{
Reference< XPropertySet > rXPropSet( rRun, UNO_QUERY );
Reference< XPropertyState > rXPropState( rRun, UNO_QUERY );
@@ -1220,8 +1221,19 @@ void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, bool
sal_Int32 nCharEscapement = 0;
sal_Int32 nCharKerning = 0;
- if( GETA( CharHeight ) )
+ if ( nElement == XML_endParaRPr && rbOverridingCharHeight )
+ {
+ nSize = rnCharHeight;
+ }
+ else if( GETA( CharHeight ) )
+ {
nSize = (sal_Int32) (100*(*static_cast<float const *>(mAny.getValue())));
+ if ( nElement == XML_rPr )
+ {
+ rbOverridingCharHeight = true;
+ rnCharHeight = nSize;
+ }
+ }
if( GETA( CharKerning ) )
nCharKerning = (sal_Int32)(*static_cast<short const *>(mAny.getValue()));
@@ -1578,7 +1590,8 @@ OString DrawingML::GetUUID()
return OString(str, SAL_N_ELEMENTS(str));
}
-void DrawingML::WriteRun( const Reference< XTextRange >& rRun )
+void DrawingML::WriteRun( const Reference< XTextRange >& rRun,
+ bool& rbOverridingCharHeight, sal_Int32& rnCharHeight)
{
Reference< XPropertySet > rXPropSet( rRun, UNO_QUERY );
sal_Int16 nLevel = -1;
@@ -1617,29 +1630,37 @@ void DrawingML::WriteRun( const Reference< XTextRange >& rRun )
}
}
- if( ( bWriteField ) )
+ if (sText == "\n")
{
- OString sUUID(GetUUID());
- mpFS->startElementNS( XML_a, XML_fld,
- XML_id, sUUID.getStr(),
- XML_type, OUStringToOString( sFieldValue, RTL_TEXTENCODING_UTF8 ).getStr(),
- FSEND );
+ mpFS->singleElementNS( XML_a, XML_br,
+ FSEND );
}
else
{
- mpFS->startElementNS( XML_a, XML_r, FSEND );
- }
+ if( ( bWriteField ) )
+ {
+ OString sUUID(GetUUID());
+ mpFS->startElementNS( XML_a, XML_fld,
+ XML_id, sUUID.getStr(),
+ XML_type, OUStringToOString( sFieldValue, RTL_TEXTENCODING_UTF8 ).getStr(),
+ FSEND );
+ }
+ else
+ {
+ mpFS->startElementNS( XML_a, XML_r, FSEND );
+ }
- Reference< XPropertySet > xPropSet( rRun, uno::UNO_QUERY );
- WriteRunProperties( xPropSet, bIsURLField );
- mpFS->startElementNS( XML_a, XML_t, FSEND );
- mpFS->writeEscaped( sText );
- mpFS->endElementNS( XML_a, XML_t );
+ Reference< XPropertySet > xPropSet( rRun, uno::UNO_QUERY );
+ WriteRunProperties( xPropSet, bIsURLField, XML_rPr, true, rbOverridingCharHeight, rnCharHeight );
+ mpFS->startElementNS( XML_a, XML_t, FSEND );
+ mpFS->writeEscaped( sText );
+ mpFS->endElementNS( XML_a, XML_t );
- if( bWriteField )
- mpFS->endElementNS( XML_a, XML_fld );
- else
- mpFS->endElementNS( XML_a, XML_r );
+ if( bWriteField )
+ mpFS->endElementNS( XML_a, XML_fld );
+ else
+ mpFS->endElementNS( XML_a, XML_r );
+ }
}
OUString GetAutoNumType(sal_Int16 nNumberingType, bool bSDot, bool bPBehind, bool bPBoth)
@@ -2021,7 +2042,8 @@ void DrawingML::WriteParagraphProperties( const Reference< XTextContent >& rPara
}
}
-void DrawingML::WriteParagraph( const Reference< XTextContent >& rParagraph )
+void DrawingML::WriteParagraph( const Reference< XTextContent >& rParagraph,
+ bool& rbOverridingCharHeight, sal_Int32& rnCharHeight )
{
Reference< XEnumerationAccess > access( rParagraph, UNO_QUERY );
if( !access.is() )
@@ -2033,7 +2055,6 @@ void DrawingML::WriteParagraph( const Reference< XTextContent >& rParagraph )
mpFS->startElementNS( XML_a, XML_p, FSEND );
-
bool bPropertiesWritten = false;
while( enumeration->hasMoreElements() )
{
@@ -2047,11 +2068,11 @@ void DrawingML::WriteParagraph( const Reference< XTextContent >& rParagraph )
WriteParagraphProperties( rParagraph );
bPropertiesWritten = true;
}
- WriteRun( run );
+ WriteRun( run, rbOverridingCharHeight, rnCharHeight );
}
}
Reference< XPropertySet > rXPropSet( rParagraph, UNO_QUERY );
- WriteRunProperties( rXPropSet , false, XML_endParaRPr, false );
+ WriteRunProperties( rXPropSet, false, XML_endParaRPr, false, rbOverridingCharHeight, rnCharHeight );
mpFS->endElementNS( XML_a, XML_p );
}
@@ -2222,15 +2243,17 @@ void DrawingML::WriteText( const Reference< XInterface >& rXIface, const OUStrin
return;
}
+ bool bOverridingCharHeight = false;
+ sal_Int32 nCharHeight;
+
while( enumeration->hasMoreElements() )
{
Reference< XTextContent > paragraph;
Any any ( enumeration->nextElement() );
if( any >>= paragraph)
- WriteParagraph( paragraph );
+ WriteParagraph( paragraph, bOverridingCharHeight, nCharHeight );
}
-
}
void DrawingML::WritePresetShape( const char* pShape )
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index c23d098a1b90..d4fd59dae66f 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -392,11 +392,11 @@ void SdExportTest::testN828390_4()
SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
CPPUNIT_ASSERT( pTxtObj );
const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
- aEdit.GetCharAttribs(1, rLst);
+ aEdit.GetCharAttribs(0, rLst);
for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it)
{
const SvxFontHeightItem * pFontHeight = dynamic_cast<const SvxFontHeightItem *>((*it).pAttr);
- if( pFontHeight )
+ if( pFontHeight && (*it).nStart == 18 )
CPPUNIT_ASSERT_MESSAGE( "Font height is wrong", pFontHeight->GetHeight() == 1129 );
const SvxFontItem *pFont = dynamic_cast<const SvxFontItem *>((*it).pAttr);
if( pFont )
@@ -405,7 +405,7 @@ void SdExportTest::testN828390_4()
bPassed = true;
}
const SvxWeightItem *pWeight = dynamic_cast<const SvxWeightItem *>((*it).pAttr);
- if( pWeight )
+ if( pWeight && (*it).nStart == 18 )
CPPUNIT_ASSERT_MESSAGE( "Font Weight is wrong", pWeight->GetWeight() == WEIGHT_BOLD);
}
}