summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-07-18 23:40:40 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-07-29 11:32:07 +0000
commitbd300cfba34ee8d4cc479cbbe9cf8703590c74b6 (patch)
treec375a73de1ff758920d8443062a5d4c52d61f86d
parent217d0ed1cdb492def7220859ecb4931d90d8022c (diff)
fdo#78502: writerfilter: RTF import: handle \u keyword inside levelnumbers
The ";" terminates an entry and shall not be inserted as text, even if some over-engineered producer encodes it as {\uc1 \u59 ?}. Also, remove the special-casing of the \leveltext destination, since the bugdoc does contain \uc inside it and it's not obvious why that should be ignored. (cherry picked from commit e93f0852477b44df986807860c821319a921b199) fdo#78502: actually empty parameter to getParagraph() is not tested (cherry picked from commit b9dca968c6fd0ab5ca140c65b0e54d153cd34986) Change-Id: I1e19c9df39597cb1b22bbda97853c829d7812e29 Reviewed-on: https://gerrit.libreoffice.org/10396 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/qa/extras/rtfimport/data/fdo78502.rtf12
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx6
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx11
3 files changed, 26 insertions, 3 deletions
diff --git a/sw/qa/extras/rtfimport/data/fdo78502.rtf b/sw/qa/extras/rtfimport/data/fdo78502.rtf
new file mode 100644
index 000000000000..2a1baf3e3550
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo78502.rtf
@@ -0,0 +1,12 @@
+{\rtf \ansi \ansicpg0 \deff0
+{\fonttbl {\f0 \froman \fcharset0 \fprq2 Times New Roman{\*\falt Times New Roman};}{\f1 \fnil \fcharset134 \fprq0 {\uc1 \u23435 ?}{\uc1 \u20307 ?}{\*\falt {\uc1 \u23435 ?}{\uc1 \u20307 ?}};}{\f2 \froman \fcharset0 \fprq0 Symbol{\*\falt Symbol};}}
+{\*\listtable
+{\list \listtemplateid300746803 \listhybrid
+{\listlevel \levelnfc23 \levelnfcn23 \leveljc0 \leveljcn0 \levelstartat1 \levelfollow0 \levelspace0 \levelindent0 \levellegal0 \levelnorestart0 {\leveltext {\uc1 \u1 ?}{\uc1 \u61623 ?}{\uc1 \u59 ?}}{\levelnumbers {\uc1 \u59 ?}}\fs20 \dbch \af1 \hich \af2 \loch \f2 \li720 \lin720 \fi-360 \jclisttab \tx720 }
+{\listlevel \levelnfc23 \levelnfcn23 \leveljc0 \leveljcn0 \levelstartat1 \levelfollow0 \levelspace0 \levelindent0 \levellegal0 \levelnorestart0 {\leveltext {\uc1 \u1 ?}{\uc1 \u61623 ?}{\uc1 \u59 ?}}{\levelnumbers {\uc1 \u59 ?}}\fs20 \dbch \af1 \hich \af2 \loch \f2 \li1440 \lin1440 \fi-360 \jclisttab \tx1440 }
+{\listlevel \levelnfc23 \levelnfcn23 \leveljc0 \leveljcn0 \levelstartat1 \levelfollow0 \levelspace0 \levelindent0 \levellegal0 \levelnorestart0 {\leveltext {\uc1 \u1 ?}{\uc1 \u61623 ?}{\uc1 \u59 ?}}{\levelnumbers {\uc1 \u59 ?}}\fs20 \dbch \af1 \hich \af2 \loch \f2 \li2160 \lin2160 \fi-360 \jclisttab \tx2160 }
+{\listname ;}
+\listid297210762 }
+}
+foo
+\par }
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index a6474fc9c00f..128e2a3b1069 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -980,6 +980,12 @@ DECLARE_RTFIMPORT_TEST(testFdo58646line, "fdo58646line.rtf")
getParagraph(1, "foo\nbar");
}
+DECLARE_RTFIMPORT_TEST(testFdo78502, "fdo78502.rtf")
+{
+ // ";" separators were inserted as text
+ getParagraph(1, "foo");
+}
+
DECLARE_RTFIMPORT_TEST(testFdo58646, "fdo58646.rtf")
{
// Page break was ignored inside a continuous section, on title page.
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 1210aa16d559..bdd54c7449c5 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -3829,9 +3829,14 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
// static_cast() will do the right thing.
if ((SAL_MIN_INT16 <= nParam) && (nParam <= SAL_MAX_UINT16))
{
- m_aUnicodeBuffer.append(static_cast<sal_Unicode>(nParam));
- if (m_aStates.top().nDestinationState != DESTINATION_LEVELTEXT)
- m_aStates.top().nCharsToSkip = m_aStates.top().nUc;
+ if (m_aStates.top().nDestinationState == DESTINATION_LEVELNUMBERS)
+ {
+ if (nParam != ';')
+ m_aStates.top().aLevelNumbers.push_back(sal_Int32(nParam));
+ }
+ else
+ m_aUnicodeBuffer.append(static_cast<sal_Unicode>(nParam));
+ m_aStates.top().nCharsToSkip = m_aStates.top().nUc;
}
break;
case RTF_LEVELFOLLOW: