[Libreoffice-commits] core.git: oox/source sd/qa

Tor Lillqvist tml at collabora.com
Sat Mar 4 15:03:37 UTC 2017


 oox/source/export/drawingml.cxx    |   42 ++++++++++++++++++++++---------------
 sd/qa/unit/export-tests-ooxml1.cxx |    6 ++---
 2 files changed, 28 insertions(+), 20 deletions(-)

New commits:
commit 1154cda87d518156d1e52dfb81d5e23b32ab23d5
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Feb 15 19:21:06 2017 +0200

    tdf#106304: Output <a:br> instead of 
 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_ooxml1 test is a bit hacky, but then so is
    the code in question.
    
    Change-Id: I4f89e9d0177ab3b16e8ec624a99fce9e2f8ef730

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 36c460a..3a57532 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1631,29 +1631,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 );
+        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(SvxNumType nNumberingType, bool bSDot, bool bPBehind, bool bPBoth)
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx
index 8f2ef49..2fc233b 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -254,11 +254,11 @@ void SdOOXMLExportTest1::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_EQUAL_MESSAGE( "Font height is wrong", static_cast<sal_uInt32>(1129), pFontHeight->GetHeight() );
             const SvxFontItem *pFont = dynamic_cast<const SvxFontItem *>((*it).pAttr);
             if( pFont )
@@ -267,7 +267,7 @@ void SdOOXMLExportTest1::testN828390_4()
                 bPassed = true;
             }
             const SvxWeightItem *pWeight = dynamic_cast<const SvxWeightItem *>((*it).pAttr);
-            if( pWeight )
+            if( pWeight && (*it).nStart == 18 )
                 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Font Weight is wrong", WEIGHT_BOLD, pWeight->GetWeight() );
         }
     }


More information about the Libreoffice-commits mailing list