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-30 08:25:42 +0000
commit9f31376e9c55a00905da8f025083d307bc7afa42 (patch)
treea8d3ee986b73cf1c6ba7fb7d6b13e171e1d31593
parentb50f1343fb51baf244761c424f3bb64be8125e42 (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/10398 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.cxx7
3 files changed, 24 insertions, 1 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 73ac0c91f7d4..ad23410ff6a4 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -961,6 +961,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 continous section, on title page.
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 73eb3f271df7..9a711d83fca0 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -3466,8 +3466,13 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
// static_cast() will do the right thing.
if ((SAL_MIN_INT16 <= nParam) && (nParam <= SAL_MAX_UINT16))
{
+ 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));
- if (m_aStates.top().nDestinationState != DESTINATION_LEVELTEXT)
m_aStates.top().nCharsToSkip = m_aStates.top().nUc;
}
break;