summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-07-18 23:40:40 +0200
committerMichael Stahl <mstahl@redhat.com>2014-07-19 00:23:11 +0200
commite93f0852477b44df986807860c821319a921b199 (patch)
treeb8e4eb7c926fab70c841da05161874a3cccd93b7
parentb94bd40b915ab32d18d43fc60dfda932e4e00ca8 (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. Change-Id: I1e19c9df39597cb1b22bbda97853c829d7812e29
-rw-r--r--sw/qa/extras/rtfimport/data/fdo78502.rtf11
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx6
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx11
3 files changed, 25 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..37749e80033a
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo78502.rtf
@@ -0,0 +1,11 @@
+{\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 }
+}
+\par }
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index ed4bc8bfd264..ea9742a3f5cc 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1041,6 +1041,12 @@ DECLARE_RTFIMPORT_TEST(testFdo58646line, "fdo58646line.rtf")
getParagraph(1, "foo\nbar");
}
+DECLARE_RTFIMPORT_TEST(testFdo78502, "fdo78502.rtf")
+{
+ // ";" separators were inserted as text
+ getParagraph(1, "");
+}
+
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 a40917246c6b..d8e12d0be435 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -3810,9 +3810,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: