summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2013-11-18 11:32:57 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-11-18 11:37:41 +0100
commit8299924b750f74f799dc683134788a285b38bd72 (patch)
tree8456e54a91b045636d92e6e8ec082efb1ab36222 /sw
parent86fd7fd4f634d5a8a566500ec4248785ea2e790e (diff)
cp#1000018 RTF export: avoid additional paragraph at footnote end
Change-Id: I430a7d705208f197050a7d521c9c20b267c33f26
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/rtfexport/rtfexport.cxx3
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx14
-rw-r--r--sw/source/filter/ww8/rtfexport.cxx5
-rw-r--r--sw/source/filter/ww8/rtfexport.hxx2
4 files changed, 20 insertions, 4 deletions
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 58df4b5af9d7..b6084cbed641 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -341,10 +341,11 @@ DECLARE_RTFEXPORT_TEST(testFdo53113, "fdo53113.odt")
DECLARE_RTFEXPORT_TEST(testFdo55939, "fdo55939.odt")
{
// The problem was that the exported RTF was invalid.
+ // Also, the 'Footnote text.' had an additional newline at its end.
uno::Reference<text::XTextRange> xParagraph(getParagraph(1));
getRun(xParagraph, 1, "Main text before footnote.");
// Why the tab has to be removed here?
- CPPUNIT_ASSERT_EQUAL(OUString("Footnote text.\n"),
+ CPPUNIT_ASSERT_EQUAL(OUString("Footnote text."),
getProperty< uno::Reference<text::XTextRange> >(getRun(xParagraph, 2), "Footnote")->getText()->getString().replaceAll("\t", ""));
getRun(xParagraph, 3, " Text after the footnote."); // However, this leading space is intentional and OK.
}
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 1b466e6a9f42..3415be73901c 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -297,6 +297,12 @@ void RtfAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pTextN
void RtfAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner )
{
SAL_INFO("sw.rtf", OSL_THIS_FUNC);
+ bool bLastPara = false;
+ if (m_rExport.nTxtTyp == TXT_FTN || m_rExport.nTxtTyp == TXT_EDN)
+ {
+ // We're ending a paragraph that is the last paragraph of a footnote or endnote.
+ bLastPara = m_rExport.m_nCurrentNodeIndex && m_rExport.m_nCurrentNodeIndex == m_rExport.pCurPam->End()->nNode.GetIndex();
+ }
FinishTableRowCell( pTextNodeInfoInner );
@@ -309,8 +315,12 @@ void RtfAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTe
else
{
aParagraph->append(SAL_NEWLINE_STRING);
- aParagraph->append(OOO_STRING_SVTOOLS_RTF_PAR);
- aParagraph->append(' ');
+ // RTF_PAR at the end of the footnote would cause an additional empty paragraph.
+ if (!bLastPara)
+ {
+ aParagraph->append(OOO_STRING_SVTOOLS_RTF_PAR);
+ aParagraph->append(' ');
+ }
}
if (m_nColBreakNeeded)
{
diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx
index e061d1a49583..05647b99eb2d 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -765,8 +765,10 @@ void RtfExport::OutputLinkedOLE( const OUString& )
void RtfExport::OutputTextNode( const SwTxtNode& rNode )
{
+ m_nCurrentNodeIndex = rNode.GetIndex();
if ( !m_bOutOutlineOnly || rNode.IsOutline( ) )
MSWordExportBase::OutputTextNode( rNode );
+ m_nCurrentNodeIndex = 0;
}
void RtfExport::AppendSection( const SwPageDesc* pPageDesc, const SwSectionFmt* pFmt, sal_uLong nLnNum )
@@ -789,7 +791,8 @@ RtfExport::RtfExport( RtfExportFilter *pFilter, SwDoc *pDocument, SwPaM *pCurren
rtl_getTextEncodingFromWindowsCharset(
sw::ms::rtl_TextEncodingToWinCharset(DEF_ENCODING))),
eCurrentEncoding(eDefaultEncoding),
- bRTFFlySyntax(false)
+ bRTFFlySyntax(false),
+ m_nCurrentNodeIndex(0)
{
mbExportModeRTF = true;
// the attribute output for the document
diff --git a/sw/source/filter/ww8/rtfexport.hxx b/sw/source/filter/ww8/rtfexport.hxx
index 930c45a2d98d..e77adf9d4331 100644
--- a/sw/source/filter/ww8/rtfexport.hxx
+++ b/sw/source/filter/ww8/rtfexport.hxx
@@ -148,6 +148,8 @@ public:
rtl_TextEncoding eCurrentEncoding;
/// This is used by OutputFlyFrame_Impl() to control the written syntax
bool bRTFFlySyntax;
+ /// Index of the current SwTxtNode, if any.
+ sal_uLong m_nCurrentNodeIndex;
SvStream& Strm();
SvStream& OutULong( sal_uLong nVal );