[Libreoffice-commits] core.git: 3 commits - sw/qa writerfilter/source
Michael Stahl
mstahl at redhat.com
Fri Jul 18 15:29:05 PDT 2014
sw/qa/extras/rtfimport/data/fdo78502.rtf | 11 +++++++++++
sw/qa/extras/rtfimport/rtfimport.cxx | 6 ++++++
writerfilter/source/rtftok/rtfcontrolwords.hxx | 1 +
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 23 +++++++++++++++++++----
4 files changed, 37 insertions(+), 4 deletions(-)
New commits:
commit ab18e62bd7a0a05970323509a2ce22a94c70b7bf
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Jul 18 23:43:40 2014 +0200
writerfilter: RTF import: ignore \listname destination differently
This adds a skeleton for \listname but not immediately obvious what it
should do...
Change-Id: Icd8dd3b5d597f1c4038044ec2eba8b63718e0d3d
diff --git a/writerfilter/source/rtftok/rtfcontrolwords.hxx b/writerfilter/source/rtftok/rtfcontrolwords.hxx
index f89e4cf..b55c2f2 100644
--- a/writerfilter/source/rtftok/rtfcontrolwords.hxx
+++ b/writerfilter/source/rtftok/rtfcontrolwords.hxx
@@ -33,6 +33,7 @@ enum RTFDestinationState
DESTINATION_LISTTABLE,
DESTINATION_LISTPICTURE,
DESTINATION_LISTENTRY,
+ DESTINATION_LISTNAME,
DESTINATION_LISTOVERRIDETABLE,
DESTINATION_LISTOVERRIDEENTRY,
DESTINATION_LISTLEVEL,
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index d8e12d0..5946642 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1097,6 +1097,7 @@ void RTFDocumentImpl::text(OUString& rString)
case DESTINATION_FONTENTRY:
case DESTINATION_STYLESHEET:
case DESTINATION_STYLEENTRY:
+ case DESTINATION_LISTNAME:
case DESTINATION_REVISIONTABLE:
case DESTINATION_REVISIONENTRY:
{
@@ -1156,6 +1157,10 @@ void RTFDocumentImpl::text(OUString& rString)
else
SAL_INFO("writerfilter", "no RTF style type defined, ignoring");
break;
+ case DESTINATION_LISTNAME:
+ // TODO: what can be done with a list name?
+ m_aStates.top().aDestinationText.makeStringAndClear();
+ break;
case DESTINATION_REVISIONTABLE:
case DESTINATION_REVISIONENTRY:
m_aAuthors[m_aAuthors.size()] = m_aStates.top().aDestinationText.makeStringAndClear();
@@ -1494,6 +1499,9 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
case RTF_LIST:
m_aStates.top().nDestinationState = DESTINATION_LISTENTRY;
break;
+ case RTF_LISTNAME:
+ m_aStates.top().nDestinationState = DESTINATION_LISTNAME;
+ break;
case RTF_LFOLEVEL:
m_aStates.top().nDestinationState = DESTINATION_LFOLEVEL;
m_aStates.top().aTableSprms.clear();
@@ -5563,6 +5571,8 @@ int RTFDocumentImpl::popState()
m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_LevelText_val, pValue);
}
break;
+ case DESTINATION_LISTNAME:
+ break;
case DESTINATION_LISTLEVEL:
{
RTFValue::Pointer_t pInnerValue(new RTFValue(m_aStates.top().nListLevelNum++));
commit e93f0852477b44df986807860c821319a921b199
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Jul 18 23:40:40 2014 +0200
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
diff --git a/sw/qa/extras/rtfimport/data/fdo78502.rtf b/sw/qa/extras/rtfimport/data/fdo78502.rtf
new file mode 100644
index 0000000..37749e8
--- /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 ed4bc8b..ea9742a 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 a409172..d8e12d0 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:
commit b94bd40b915ab32d18d43fc60dfda932e4e00ca8
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Jul 18 22:07:02 2014 +0200
(related: fdo#78502) writerfilter: RTF import: fix invalid string copy
... in leveltext destination.
Change-Id: I74de6d14170130bf33923854a0c9851dc7cc390f
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index e7e3a42..a409172 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -4827,7 +4827,7 @@ int RTFDocumentImpl::popState()
// The first character is the length of the string (the rest should be ignored).
sal_Int32 nLength(aStr.toChar());
OUString aValue;
- if (nLength <= aStr.getLength())
+ if (nLength < aStr.getLength())
aValue = aStr.copy(1, nLength);
else
aValue = aStr;
More information about the Libreoffice-commits
mailing list