diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2012-06-22 15:41:37 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2012-06-22 16:12:27 +0200 |
commit | 7f916b90500033193226332d52930ab23dd79284 (patch) | |
tree | e100bc5dda5f43bd4edffb2b033cd52490804865 /sw | |
parent | 2a5fc950439d484d1227a736bea6566e86e73b7c (diff) |
fdo#50831 fix RTF export of direct run formatting for empty paragraphs
Change-Id: I5f0e7aefdea80bbb9cf61b991c5b706bd2023dfa
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/rtfexport/data/fdo50831.rtf | 11 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport.cxx | 15 | ||||
-rw-r--r-- | sw/source/filter/ww8/attributeoutputbase.hxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfattributeoutput.cxx | 12 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfattributeoutput.hxx | 5 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8nds.cxx | 7 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8attributeoutput.hxx | 2 |
10 files changed, 47 insertions, 13 deletions
diff --git a/sw/qa/extras/rtfexport/data/fdo50831.rtf b/sw/qa/extras/rtfexport/data/fdo50831.rtf new file mode 100644 index 000000000000..476a82f76e00 --- /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 6df0aec4c988..428b7e158b6c 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 6e35bd4837bd..9d6daf4f78e4 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 4abaed0aa83d..ba345a2cc959 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 9fc093ef5aaa..d8c52a09c1ce 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 f5cfd8ccf5fb..061449222226 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 2c145f8d8516..a6430f17414b 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 b4443249b53d..f3efd160ef2b 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 17cd53905b6e..bd24598b87f9 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 fa9c1703e3b7..f32a038eedc6 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. /// |