summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-02-26 15:36:09 +0100
committerCaolán McNamara <caolanm@redhat.com>2013-02-28 15:11:57 +0000
commit3209bc81245452ef6976c77818186b05c3026438 (patch)
tree84face5b12c25994325b03a79b3d6809ba65edb8 /writerfilter
parent4ffa2ddf2490005347a6567fcd2f619f06c33025 (diff)
fdo#61507 import/export RTF_UPR and RTF_UD
In short, these commits make the RTF filter import and export unicode characters in document title properly. Previously we failed to import such files from Word, and the export result caused problems in Wordpad (Word handled it fine). (cherry picked from commits 0805b222f87bf99ec0c53ca678d1c670eb5293a2, 3a934d928e455eca38f124072c20a624a64aa225 and 5de52551a963b932cc23c2ea75f709fa1924520b) Change-Id: Ic9417d0f23d44149acb3ae3dc9d4c281058a1b36 Reviewed-on: https://gerrit.libreoffice.org/2436 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx25
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx1
2 files changed, 21 insertions, 5 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index cf1a1aa8eb49..d966275dd93b 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1516,7 +1516,11 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
m_aStates.top().nDestinationState = DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE;
break;
case RTF_TITLE:
- m_aStates.top().nDestinationState = DESTINATION_TITLE;
+ // \title inside \upr but outside \ud should be ignored.
+ if (m_aStates.top().nDestinationState != DESTINATION_UPR)
+ m_aStates.top().nDestinationState = DESTINATION_TITLE;
+ else
+ m_aStates.top().nDestinationState = DESTINATION_SKIP;
break;
case RTF_SUBJECT:
m_aStates.top().nDestinationState = DESTINATION_SUBJECT;
@@ -1614,6 +1618,13 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
OPEN_M_TOKEN(SPREPR, sPrePr);
OPEN_M_TOKEN(BOX, box);
OPEN_M_TOKEN(EQARR, eqArr);
+ case RTF_UPR:
+ m_aStates.top().nDestinationState = DESTINATION_UPR;
+ break;
+ case RTF_UD:
+ // Anything inside \ud is just normal Unicode content.
+ m_aStates.top().nDestinationState = DESTINATION_NORMAL;
+ break;
default:
SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle destination '" << lcl_RtfToString(nKeyword) << "'");
// Make sure we skip destinations (even without \*) till we don't handle them
@@ -3807,10 +3818,6 @@ int RTFDocumentImpl::popState()
if (m_xDocumentProperties.is())
m_xDocumentProperties->setGenerator(m_aStates.top().aDestinationText.makeStringAndClear());
break;
- case DESTINATION_TITLE:
- if (m_xDocumentProperties.is())
- m_xDocumentProperties->setTitle(m_aStates.top().aDestinationText.makeStringAndClear());
- break;
case DESTINATION_SUBJECT:
if (m_xDocumentProperties.is())
m_xDocumentProperties->setSubject(m_aStates.top().aDestinationText.makeStringAndClear());
@@ -4233,6 +4240,14 @@ int RTFDocumentImpl::popState()
aState.nDestinationState == DESTINATION_SHPPICT ||
aState.nDestinationState == DESTINATION_SHAPE)
m_aStates.top().aFrame = aState.aFrame;
+ else if (aState.nDestinationState == DESTINATION_TITLE)
+ {
+ if (m_aStates.top().nDestinationState == DESTINATION_TITLE)
+ // The parent is a title as well, just append what we have so far.
+ m_aStates.top().aDestinationText.append(aState.aDestinationText.makeStringAndClear());
+ else if (m_xDocumentProperties.is())
+ m_xDocumentProperties->setTitle(aState.aDestinationText.makeStringAndClear());
+ }
if (m_pCurrentBuffer == &m_aSuperBuffer)
{
if (!m_bHasFootnote)
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 82490eba072f..a26d3ff7679e 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -178,6 +178,7 @@ namespace writerfilter {
DESTINATION_MGROW,
DESTINATION_MBOX,
DESTINATION_MEQARR,
+ DESTINATION_UPR,
};
enum RTFBorderState