sw/CppunitTest_sw_subsequent_rtfexport.mk | 2 + sw/qa/extras/rtfexport/data/fdo48335.odt |binary sw/qa/extras/rtfexport/rtfexport.cxx | 30 ++++++++++++++++++++++++++++ sw/source/filter/ww8/rtfattributeoutput.cxx | 5 +++- sw/source/filter/ww8/rtfattributeoutput.hxx | 3 ++ sw/source/filter/ww8/rtfexport.cxx | 4 ++- 6 files changed, 42 insertions(+), 2 deletions(-)
New commits: commit 87d29c4506093680eaf5300fa0ed95a6897120d1 Author: Miklos Vajna <vmik...@suse.cz> Date: Wed Jun 27 12:11:05 2012 +0200 fdo#48335 testcase Change-Id: I032ff9b65ec9c4d70a2247c7311c2c7292a411c7 diff --git a/sw/CppunitTest_sw_subsequent_rtfexport.mk b/sw/CppunitTest_sw_subsequent_rtfexport.mk index e55af88..bdc47cd 100644 --- a/sw/CppunitTest_sw_subsequent_rtfexport.mk +++ b/sw/CppunitTest_sw_subsequent_rtfexport.mk @@ -69,7 +69,9 @@ $(eval $(call gb_CppunitTest_use_components,sw_subsequent_rtfexport,\ filter/source/config/cache/filterconfig1 \ framework/util/fwk \ i18npool/util/i18npool \ + package/source/xstor/xstor \ package/util/package2 \ + sax/source/expatwrap/expwrap \ sfx2/util/sfx \ svl/source/fsstor/fsstorage \ svtools/util/svt \ diff --git a/sw/qa/extras/rtfexport/data/fdo48335.odt b/sw/qa/extras/rtfexport/data/fdo48335.odt new file mode 100644 index 0000000..4259f98 Binary files /dev/null and b/sw/qa/extras/rtfexport/data/fdo48335.odt differ diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index 428b7e1..599b5b6 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -49,6 +49,7 @@ public: void testFdo44174(); void testFdo50087(); void testFdo50831(); + void testFdo48335(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -58,6 +59,7 @@ public: CPPUNIT_TEST(testFdo44174); CPPUNIT_TEST(testFdo50087); CPPUNIT_TEST(testFdo50831); + CPPUNIT_TEST(testFdo48335); #endif CPPUNIT_TEST_SUITE_END(); @@ -144,6 +146,34 @@ void Test::testFdo50831() CPPUNIT_ASSERT_EQUAL(10.f, fValue); } +void Test::testFdo48335() +{ + /* + * The problem was that we exported a fake pagebreak, make sure it's just a soft one now. + * + * oParas = ThisComponent.Text.createEnumeration + * oPara = oParas.nextElement + * oPara = oParas.nextElement + * oPara = oParas.nextElement + * oRuns = oPara.createEnumeration + * oRun = oRuns.nextElement + * xray oRun.TextPortionType 'was Text, should be SoftPageBreak + */ + roundtrip("fdo48335.odt"); + + 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(); + for (int i = 0; i < 2; i++) + xParaEnum->nextElement(); + uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration(); + uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY); + OUString aValue; + xPropertySet->getPropertyValue("TextPortionType") >>= aValue; + CPPUNIT_ASSERT_EQUAL(OUString("SoftPageBreak"), aValue); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); commit a03895986308206cc13a6f5ae25138d4b4ad5d43 Author: Miklos Vajna <vmik...@suse.cz> Date: Wed Jun 27 11:16:55 2012 +0200 fdo#48335 RTF export: avoid fake page breaks on page style changes The problem was that a page break has been always exported when the page style changed -- but in case the page style changes just because of "first page"-like styles, we don't need that. Change-Id: I15527c8d3a2d1c441b4817cf94d61ea68dc5f92c diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index c390ef7..113c6d2 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -350,6 +350,8 @@ void RtfAttributeOutput::StartParagraphProperties( const SwTxtNode& rNode ) { const SwTxtNode* pTxtNode = static_cast< SwTxtNode* >( &aNextIndex.GetNode() ); m_rExport.OutputSectionBreaks( pTxtNode->GetpSwAttrSet(), *pTxtNode ); + // Save the current page description for now, so later we will be able to access the previous one. + m_pPrevPageDesc = pTxtNode->FindPageDesc(sal_False); } else if ( aNextIndex.GetNode().IsTableNode() ) { @@ -3031,7 +3033,8 @@ RtfAttributeOutput::RtfAttributeOutput( RtfExport &rExport ) m_bTableRowEnded( false ), m_aCells(), m_bSingleEmptyRun(false), - m_bInRun(false) + m_bInRun(false), + m_pPrevPageDesc(0) { SAL_INFO("sw.rtf", OSL_THIS_FUNC); } diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx index 56c31b6..cf05b97 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.hxx +++ b/sw/source/filter/ww8/rtfattributeoutput.hxx @@ -555,6 +555,9 @@ public: rtl::OStringBuffer m_aTabStop; + /// Access to the page style of the previous paragraph. + const SwPageDesc* m_pPrevPageDesc; + // These are used by wwFont::WriteRtf() /// Start the font. void StartFont( const String& rFamilyName ) const; diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx index f816eb1..117711b 100644 --- a/sw/source/filter/ww8/rtfexport.cxx +++ b/sw/source/filter/ww8/rtfexport.cxx @@ -706,7 +706,9 @@ void RtfExport::PrepareNewPageDesc( const SfxItemSet* pSet, else if ( pNewPgDesc ) m_pSections->AppendSection( pNewPgDesc, rNd, pFmt, nLnNm ); - AttrOutput().SectionBreak( msword::PageBreak, m_pSections->CurrentSectionInfo() ); + // Don't insert a page break, when we're changing page style just because the next page has to be a different one. + if (!m_pAttrOutput->m_pPrevPageDesc || m_pAttrOutput->m_pPrevPageDesc->GetFollow() != pNewPgDesc) + AttrOutput().SectionBreak( msword::PageBreak, m_pSections->CurrentSectionInfo() ); } bool RtfExport::DisallowInheritingOutlineNumbering( const SwFmt& rFmt ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits