Kaydet (Commit) 8299924b authored tarafından Miklos Vajna's avatar Miklos Vajna

cp#1000018 RTF export: avoid additional paragraph at footnote end

Change-Id: I430a7d705208f197050a7d521c9c20b267c33f26
üst 86fd7fd4
......@@ -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.
}
......
......@@ -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)
{
......
......@@ -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
......
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment