Kaydet (Commit) 411f9007 authored tarafından Miklos Vajna's avatar Miklos Vajna

fdo#55939 fix RTF export of footnotes

Regression from d4069372.

Change-Id: I58e8d48ac3222b795f7edfd0e74ecd86ea36f380
üst 638bb3a6
...@@ -66,6 +66,7 @@ public: ...@@ -66,6 +66,7 @@ public:
void testMathVerticalstacks(); void testMathVerticalstacks();
void testMathRuns(); void testMathRuns();
void testFdo53113(); void testFdo53113();
void testFdo55939();
CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT) #if !defined(MACOSX) && !defined(WNT)
...@@ -106,6 +107,7 @@ void Test::run() ...@@ -106,6 +107,7 @@ void Test::run()
{"math-vertical-stacks.rtf", &Test::testMathVerticalstacks}, {"math-vertical-stacks.rtf", &Test::testMathVerticalstacks},
{"math-runs.rtf", &Test::testMathRuns}, {"math-runs.rtf", &Test::testMathRuns},
{"fdo53113.odt", &Test::testFdo53113}, {"fdo53113.odt", &Test::testFdo53113},
{"fdo55939.odt", &Test::testFdo55939},
}; };
// Don't test the first import of these, for some reason those tests fail // Don't test the first import of these, for some reason those tests fail
const char* aBlacklist[] = { const char* aBlacklist[] = {
...@@ -426,6 +428,17 @@ void Test::testFdo53113() ...@@ -426,6 +428,17 @@ void Test::testFdo53113()
CPPUNIT_ASSERT_EQUAL(sal_Int32(102), aPairs[1].Second.Value.get<sal_Int32>()); CPPUNIT_ASSERT_EQUAL(sal_Int32(102), aPairs[1].Second.Value.get<sal_Int32>());
} }
void Test::testFdo55939()
{
// The problem was that the exported RTF was invalid.
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."),
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.
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -2331,17 +2331,20 @@ void RtfAttributeOutput::TextFootnote_Impl( const SwFmtFtn& rFootnote ) ...@@ -2331,17 +2331,20 @@ void RtfAttributeOutput::TextFootnote_Impl( const SwFmtFtn& rFootnote )
/* /*
* The footnote contains a whole paragraph, so we have to: * The footnote contains a whole paragraph, so we have to:
* 1) Reset, then later restore the contents of our run buffer. * 1) Reset, then later restore the contents of our run buffer and run state.
* 2) Buffer the output of the whole paragraph, as we do so for section headers already. * 2) Buffer the output of the whole paragraph, as we do so for section headers already.
*/ */
const SwNodeIndex* pIndex = rFootnote.GetTxtFtn()->GetStartNode(); const SwNodeIndex* pIndex = rFootnote.GetTxtFtn()->GetStartNode();
RtfStringBuffer aRun = m_aRun; RtfStringBuffer aRun = m_aRun;
m_aRun.clear(); m_aRun.clear();
bool bInRunOrig = m_bInRun;
m_bInRun = false;
m_bBufferSectionHeaders = true; m_bBufferSectionHeaders = true;
m_rExport.WriteSpecialText( pIndex->GetIndex() + 1, m_rExport.WriteSpecialText( pIndex->GetIndex() + 1,
pIndex->GetNode().EndOfSectionIndex(), pIndex->GetNode().EndOfSectionIndex(),
!rFootnote.IsEndNote() ? TXT_FTN : TXT_EDN); !rFootnote.IsEndNote() ? TXT_FTN : TXT_EDN);
m_bBufferSectionHeaders = false; m_bBufferSectionHeaders = false;
m_bInRun = bInRunOrig;
m_aRun = aRun; m_aRun = aRun;
m_aRun->append(m_aSectionHeaders.makeStringAndClear()); m_aRun->append(m_aSectionHeaders.makeStringAndClear());
......
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