[Libreoffice-commits] .: sw/qa sw/source

Miklos Vajna vmiklos at kemper.freedesktop.org
Fri Jun 22 07:11:32 PDT 2012


 sw/qa/extras/rtfexport/data/fdo50831.rtf     |   11 +++++++++++
 sw/qa/extras/rtfexport/rtfexport.cxx         |   15 +++++++++++++++
 sw/source/filter/ww8/attributeoutputbase.hxx |    2 +-
 sw/source/filter/ww8/docxattributeoutput.cxx |    2 +-
 sw/source/filter/ww8/docxattributeoutput.hxx |    2 +-
 sw/source/filter/ww8/rtfattributeoutput.cxx  |   12 ++++++++----
 sw/source/filter/ww8/rtfattributeoutput.hxx  |    5 ++++-
 sw/source/filter/ww8/wrtw8nds.cxx            |    7 ++++---
 sw/source/filter/ww8/ww8atr.cxx              |    2 +-
 sw/source/filter/ww8/ww8attributeoutput.hxx  |    2 +-
 10 files changed, 47 insertions(+), 13 deletions(-)

New commits:
commit 7f916b90500033193226332d52930ab23dd79284
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Jun 22 15:41:37 2012 +0200

    fdo#50831 fix RTF export of direct run formatting for empty paragraphs
    
    Change-Id: I5f0e7aefdea80bbb9cf61b991c5b706bd2023dfa

diff --git a/sw/qa/extras/rtfexport/data/fdo50831.rtf b/sw/qa/extras/rtfexport/data/fdo50831.rtf
new file mode 100644
index 0000000..476a82f
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/fdo50831.rtf
@@ -0,0 +1,11 @@
+{\rtf1\ansi\deff3\adeflang1025
+{\fonttbl
+{\f0\froman\fprq2\fcharset0 Times New Roman;}
+{\f4\fswiss\fprq2\fcharset0 Arial;}
+}
+\pard\plain
+\fs20\loch\f4
+\par \pard\plain
+{\fs20\f4
+Foo}
+\par}
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 6df0aec..428b7e1 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -48,6 +48,7 @@ public:
     void testFdo49683();
     void testFdo44174();
     void testFdo50087();
+    void testFdo50831();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -56,6 +57,7 @@ public:
     CPPUNIT_TEST(testFdo49683);
     CPPUNIT_TEST(testFdo44174);
     CPPUNIT_TEST(testFdo50087);
+    CPPUNIT_TEST(testFdo50831);
 #endif
     CPPUNIT_TEST_SUITE_END();
 
@@ -129,6 +131,19 @@ void Test::testFdo50087()
     CPPUNIT_ASSERT_EQUAL(OUString("First line.\nSecond line."), xDocumentProperties->getDescription());
 }
 
+void Test::testFdo50831()
+{
+    roundtrip("fdo50831.rtf");
+
+    uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
+    uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
+    uno::Reference<beans::XPropertySet> xPropertySet(xParaEnum->nextElement(), uno::UNO_QUERY);
+    float fValue = 0;
+    xPropertySet->getPropertyValue("CharHeight") >>= fValue;
+    CPPUNIT_ASSERT_EQUAL(10.f, fValue);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx
index 6e35bd4..9d6daf4 100644
--- a/sw/source/filter/ww8/attributeoutputbase.hxx
+++ b/sw/source/filter/ww8/attributeoutputbase.hxx
@@ -156,7 +156,7 @@ public:
     virtual void EmptyParagraph() = 0;
 
     /// Start of the text run.
-    virtual void StartRun( const SwRedlineData* pRedlineData ) = 0;
+    virtual void StartRun( const SwRedlineData* pRedlineData, bool bSingleEmptyRun = false ) = 0;
 
     /// End of the text run.
     virtual void EndRun() = 0;
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 4abaed0..ba345a2 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -491,7 +491,7 @@ void DocxAttributeOutput::EndParagraphProperties()
     m_pSerializer->mergeTopMarks( sax_fastparser::MERGE_MARKS_PREPEND );
 }
 
-void DocxAttributeOutput::StartRun( const SwRedlineData* pRedlineData )
+void DocxAttributeOutput::StartRun( const SwRedlineData* pRedlineData, bool /*bSingleEmptyRun*/ )
 {
     // if there is some redlining in the document, output it
     StartRedline( pRedlineData );
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 9fc093e..d8c52a0 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -81,7 +81,7 @@ public:
     virtual void EndParagraphProperties();
 
     /// Start of the text run.
-    virtual void StartRun( const SwRedlineData* pRedlineData );
+    virtual void StartRun( const SwRedlineData* pRedlineData, bool bSingleEmptyRun = false );
 
     /// End of the text run.
     virtual void EndRun();
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index f5cfd8c..0614492 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -379,11 +379,13 @@ void RtfAttributeOutput::EndParagraphProperties()
     m_rExport.Strm() << m_aStyles.makeStringAndClear().getStr();
 }
 
-void RtfAttributeOutput::StartRun( const SwRedlineData* pRedlineData )
+void RtfAttributeOutput::StartRun( const SwRedlineData* pRedlineData, bool bSingleEmptyRun )
 {
     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
 
-    m_aRun->append('{');
+    m_bSingleEmptyRun = bSingleEmptyRun;
+    if (!m_bSingleEmptyRun)
+        m_aRun->append('{');
 
     // if there is some redlining in the document, output it
     Redline( pRedlineData );
@@ -396,7 +398,8 @@ void RtfAttributeOutput::EndRun()
     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     m_aRun->append(m_rExport.sNewLine);
     m_aRun.appendAndClear(m_aRunText);
-    m_aRun->append('}');
+    if (!m_bSingleEmptyRun)
+        m_aRun->append('}');
 }
 
 void RtfAttributeOutput::StartRunProperties()
@@ -3025,7 +3028,8 @@ RtfAttributeOutput::RtfAttributeOutput( RtfExport &rExport )
     m_bWroteCellInfo( false ),
     m_bHadFieldResult( false ),
     m_bTableRowEnded( false ),
-    m_aCells()
+    m_aCells(),
+    m_bSingleEmptyRun(false)
 {
     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
 }
diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx
index 2c145f8..a6430f1 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.hxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.hxx
@@ -64,7 +64,7 @@ public:
     virtual void EndParagraphProperties();
 
     /// Start of the text run.
-    virtual void StartRun( const SwRedlineData* pRedlineData );
+    virtual void StartRun( const SwRedlineData* pRedlineData, bool bSingleEmptyRun = false );
 
     /// End of the text run.
     virtual void EndRun();
@@ -540,6 +540,9 @@ private:
 
     /// Number of cells from the table definition, by depth.
     std::map<sal_uInt32,sal_uInt32> m_aCells;
+
+    /// If we're in a paragraph that has a single empty run only.
+    bool m_bSingleEmptyRun;
 public:
     RtfAttributeOutput( RtfExport &rExport );
 
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index b444324..f3efd16 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -1806,12 +1806,13 @@ void MSWordExportBase::OutputTextNode( const SwTxtNode& rNode )
     do {
         const SwRedlineData* pRedlineData = aAttrIter.GetRedline( nAktPos );
 
-        AttrOutput().StartRun( pRedlineData );
+        xub_StrLen nNextAttr = GetNextPos( &aAttrIter, rNode, nAktPos );
+        // Is this the only run in this paragraph and it's empty?
+        bool bSingleEmptyRun = nAktPos == 0 && nNextAttr == 0;
+        AttrOutput().StartRun( pRedlineData, bSingleEmptyRun );
         if( nTxtTyp == TXT_FTN || nTxtTyp == TXT_EDN )
             AttrOutput().FootnoteEndnoteRefTag();
 
-        xub_StrLen nNextAttr = GetNextPos( &aAttrIter, rNode, nAktPos );
-
         if( nNextAttr > nEnd )
             nNextAttr = nEnd;
 
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 17cd539..bd24598 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -973,7 +973,7 @@ void WW8AttributeOutput::StartRunProperties()
 }
 
 
-void WW8AttributeOutput::StartRun( const SwRedlineData* pRedlineData )
+void WW8AttributeOutput::StartRun( const SwRedlineData* pRedlineData, bool /*bSingleEmptyRun*/ )
 {
     if (pRedlineData)
     {
diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx
index fa9c170..f32a038 100644
--- a/sw/source/filter/ww8/ww8attributeoutput.hxx
+++ b/sw/source/filter/ww8/ww8attributeoutput.hxx
@@ -55,7 +55,7 @@ public:
 
     /// Start of the text run.
     ///
-    virtual void StartRun( const SwRedlineData* pRedlineData );
+    virtual void StartRun( const SwRedlineData* pRedlineData, bool bSingleEmptyRun = false );
 
     /// End of the text run.
     ///


More information about the Libreoffice-commits mailing list