summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-02-26 15:36:09 +0100
committerMiklos Vajna <vmiklos@suse.cz>2013-02-26 15:41:01 +0100
commit0805b222f87bf99ec0c53ca678d1c670eb5293a2 (patch)
tree7725e025d3f889e2a8c5e1525bc9f123f2e18b17
parent627f220bc1aaa3d5bacdf0e886a1af5cc3f3bff8 (diff)
fdo#61507 import RTF_UPR and RTF_UD
It turns out Word wraps document title with these destinations if they contain something that isn't possible to describe using legacy charsets. Change-Id: Ic9417d0f23d44149acb3ae3dc9d4c281058a1b36
-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 14c74869e78a..926650563747 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1517,7 +1517,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;
@@ -1615,6 +1619,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
@@ -3808,10 +3819,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());
@@ -4234,6 +4241,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