summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2013-11-15 15:05:02 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-11-15 15:45:20 +0100
commit9389cf78e304a5a99bcf1745b9388e14ac36281a (patch)
tree68f528d4aaf725c6fb7dea4b2e49e5f10faa6845
parentb7f38c8f6d63798714b9881ac8ff2da11c72799b (diff)
cp#1000018 RTF import: empty para at the end of footnote text got lost
Updated 3 testcases, in all cases first checked that the new behavior matches what Word does. Also added a new test, to check that empty para at footnote end is now kept. Change-Id: I96b8788feb4d730b5a64ba3a743311a0180ab41f
-rw-r--r--sw/qa/extras/rtfexport/rtfexport.cxx2
-rw-r--r--sw/qa/extras/rtfimport/data/copypaste-footnote.rtf2
-rw-r--r--sw/qa/extras/rtfimport/data/cp1000018.rtf27
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx14
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx1
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx12
6 files changed, 44 insertions, 14 deletions
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 72beefc730ff..58df4b5af9d7 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -344,7 +344,7 @@ DECLARE_RTFEXPORT_TEST(testFdo55939, "fdo55939.odt")
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."),
+ CPPUNIT_ASSERT_EQUAL(OUString("Footnote text.\n"),
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/qa/extras/rtfimport/data/copypaste-footnote.rtf b/sw/qa/extras/rtfimport/data/copypaste-footnote.rtf
index 93e4613397e5..1420878ef5d4 100644
--- a/sw/qa/extras/rtfimport/data/copypaste-footnote.rtf
+++ b/sw/qa/extras/rtfimport/data/copypaste-footnote.rtf
@@ -1,6 +1,6 @@
{\rtf1
aaa
{\super \chftn
-{\*\footnote \chftn\pard\plain \li339\fi-339 \par}
+{\*\footnote \chftn\pard\plain \li339\fi-339}
}
\par }
diff --git a/sw/qa/extras/rtfimport/data/cp1000018.rtf b/sw/qa/extras/rtfimport/data/cp1000018.rtf
new file mode 100644
index 000000000000..725d21e94bc2
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/cp1000018.rtf
@@ -0,0 +1,27 @@
+{\rtf1\ansi\deff3\adeflang1025
+{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\froman\fprq2\fcharset2 Symbol;}{\f2\fswiss\fprq2\fcharset0 Arial;}{\f3\froman\fprq2\fcharset0 Times New Roman;}{\f4\fswiss\fprq2\fcharset0 Arial;}{\f5\fnil\fprq2\fcharset0 DejaVu Sans;}}
+{\colortbl;\red0\green0\blue0;\red128\green128\blue128;}
+{\stylesheet{\s0\snext0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ltrpar\cf0\kerning1\dbch\af5\langfe2052\dbch\af5\afs24\alang1081\loch\f3\fs24\lang1038 Normal;}
+{\*\cs15\snext15 Footnote Characters;}
+{\*\cs16\snext16\super Footnote Anchor;}
+{\*\cs17\snext17\super Endnote Anchor;}
+{\*\cs18\snext18 Endnote Characters;}
+{\s19\sbasedon0\snext20\sb240\sa120\keepn\dbch\af5\dbch\af5\afs28\loch\f4\fs28 Heading;}
+{\s20\sbasedon0\snext20\sb0\sa120 Text Body;}
+{\s21\sbasedon20\snext21\sb0\sa120 List;}
+{\s22\sbasedon0\snext22\sb120\sa120\noline\i\afs24\ai\fs24 Caption;}
+{\s23\sbasedon0\snext23\noline Index;}
+{\s24\sbasedon0\snext24\li339\ri0\lin339\rin0\fi-339\noline\afs20\fs20 Footnote;}
+}{\info{\creatim\yr2010\mo6\dy1\hr16\min51}{\revtim\yr2013\mo11\dy15\hr14\min22}{\printim\yr0\mo0\dy0\hr0\min0}{\comment LibreOfficeDev}{\vern67239936}}\deftab709
+\viewscale100
+{\*\pgdsctbl
+{\pgdsc0\pgdscuse451\pgwsxn11906\pghsxn5499\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\pgdscnxt0 Default Style;}}
+\formshade\paperh5499\paperw11906\margl1134\margr1134\margt1134\margb1134\sectd\sbknone\sectunlocked1\pgndec\pgwsxn11906\pghsxn5499\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc
+\pgndec\pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ltrpar\cf0\kerning1\dbch\af5\langfe2052\dbch\af5\afs24\alang1081\loch\f3\fs24\lang1038{\rtlch \ltrch\loch
+Hello world!}{{\super \chftn{\*\footnote \chftn\pard\plain \s24\li339\ri0\lin339\rin0\fi-339\noline\afs20\fs20{\rtlch \ltrch\loch\rtlch \ltrch\loch
+\tab Footnote }{\rtlch \ltrch\loch
+first line}{\rtlch \ltrch\loch
+.}
+\par }}
+}
+\par } \ No newline at end of file
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 24708c4e6c8c..f1db5f6e600a 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -357,7 +357,7 @@ DECLARE_RTFIMPORT_TEST(testFdo45182, "fdo45182.rtf")
uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
// Encoding in the footnote was wrong.
- OUString aExpected("\xc5\xbeivnost\xc3\xad", 10, RTL_TEXTENCODING_UTF8);
+ OUString aExpected("\xc5\xbeivnost\xc3\xad\n", 11, RTL_TEXTENCODING_UTF8);
CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
}
@@ -1353,6 +1353,18 @@ DECLARE_RTFIMPORT_TEST(testFdo70221, "fdo70221.rtf")
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
}
+DECLARE_RTFIMPORT_TEST(testCp1000018, "cp1000018.rtf")
+{
+ // The problem was that the empty paragraph at the end of the footnote got
+ // lost during import.
+ uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
+ // Why the tab has to be removed here?
+ OUString aExpected("Footnote first line.\n");
+ CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString().replaceAll("\t", ""));
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 2bbff8193bd5..cc2486b9d184 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1625,7 +1625,6 @@ void DomainMapper_Impl::PushAnnotation()
void DomainMapper_Impl::PopFootOrEndnote()
{
- RemoveLastParagraph();
if (!m_aTextAppendStack.empty())
m_aTextAppendStack.pop();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 6169f91ae31e..b77cbbb427b4 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -331,14 +331,6 @@ bool RTFDocumentImpl::isSubstream() const
void RTFDocumentImpl::finishSubstream()
{
checkUnicode(/*bUnicode =*/ true, /*bHex =*/ true);
- // At the end of a footnote stream, we need to emit a run break when importing from Word.
- // We can't do so unconditionally, as Writer already writes a \par at the end of the footnote.
- if (m_bNeedCr)
- {
- Mapper().startCharacterGroup();
- runBreak();
- Mapper().endCharacterGroup();
- }
}
void RTFDocumentImpl::setIgnoreFirst(OUString& rIgnoreFirst)
@@ -529,7 +521,7 @@ void RTFDocumentImpl::sectBreak(bool bFinal = false)
bool bContinuous = pBreak.get() && pBreak->getInt() == 0;
// If there is no paragraph in this section, then insert a dummy one, as required by Writer,
// unless this is the end of the doc, we had nothing since the last section break and this is not a continuous one.
- if (m_bNeedPar && !(bFinal && !m_bNeedSect && !bContinuous))
+ if (m_bNeedPar && !(bFinal && !m_bNeedSect && !bContinuous) && !isSubstream())
dispatchSymbol(RTF_PAR);
// It's allowed to not have a non-table paragraph at the end of an RTF doc, add it now if required.
if (m_bNeedFinalPar && bFinal)
@@ -4517,7 +4509,7 @@ int RTFDocumentImpl::popState()
// This is the end of the doc, see if we need to close the last section.
if (m_pTokenizer->getGroup() == 1 && !m_bFirstRun)
{
- if (m_bNeedCr)
+ if (m_bNeedCr && !isSubstream())
dispatchSymbol(RTF_PAR);
sectBreak(true);
}