summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-06-03 20:18:59 +0200
committerAndras Timar <andras.timar@collabora.com>2014-06-10 22:09:51 +0200
commit33aefc7d578965a2a9366d4366c2e1f8dd2e5875 (patch)
tree4486cd9b3cf8c6a59a766d7526f6f1d95a707d05 /writerfilter
parent99aaac23717ccddfae4e3917325a1464c152295d (diff)
RTF import: fix handling of \loch \hich \dbch \ltrch \rtlch
The logic is not immediately obvious from the RTF spec; let's do what the editengine RTF import does, but without the unnecessary complexity. (cherry picked from commit 36246aa9fb57c9fe4e546c91a8274d8828b1424e) Conflicts: writerfilter/source/rtftok/rtfdocumentimpl.cxx writerfilter/source/rtftok/rtfdocumentimpl.hxx Change-Id: I60e69130e6e5aed1f5d237f64b1656c3141e402a Reviewed-on: https://gerrit.libreoffice.org/9634 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx23
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx2
2 files changed, 20 insertions, 5 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index f1ac1d102cc9..920b19f8108d 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2626,8 +2626,10 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
break;
case RTF_LTRCH:
// dmapper does not support this.
+ m_aStates.top().isRightToLeft = false;
break;
case RTF_RTLCH:
+ m_aStates.top().isRightToLeft = true;
if (m_aDefaultState.nCurrentEncoding == RTL_TEXTENCODING_MS_1255)
m_aStates.top().nCurrentEncoding = m_aDefaultState.nCurrentEncoding;
break;
@@ -3187,11 +3189,20 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
{
case RTF_F:
case RTF_AF:
- if (nKeyword == RTF_F)
- nSprm = NS_sprm::LN_CRgFtc0;
+ if (m_aStates.top().isRightToLeft
+ || m_aStates.top().eRunType == RTFParserState::HICH)
+ {
+ nSprm = NS_sprm::LN_CRgFtc2;
+ }
+ else if (m_aStates.top().eRunType == RTFParserState::DBCH)
+ {
+ nSprm = NS_sprm::LN_CRgFtc1;
+ }
else
- nSprm = (m_aStates.top().eRunType == RTFParserState::HICH
- ? NS_sprm::LN_CRgFtc1 : NS_sprm::LN_CRgFtc2);
+ {
+ assert(m_aStates.top().eRunType == RTFParserState::LOCH);
+ nSprm = NS_sprm::LN_CRgFtc0;
+ }
if (m_aStates.top().nDestinationState == DESTINATION_FONTTABLE || m_aStates.top().nDestinationState == DESTINATION_FONTENTRY)
{
m_aFontIndexes.push_back(nParam);
@@ -3215,7 +3226,8 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
int nFontIndex = getFontIndex(nParam);
RTFValue::Pointer_t pValue(new RTFValue(nFontIndex));
m_aStates.top().aCharacterSprms.set(nSprm, pValue);
- m_aStates.top().nCurrentEncoding = getEncoding(nFontIndex);
+ if (nKeyword == RTF_F)
+ m_aStates.top().nCurrentEncoding = getEncoding(nFontIndex);
}
break;
case RTF_RED:
@@ -5198,6 +5210,7 @@ RTFParserState::RTFParserState(RTFDocumentImpl *pDocumentImpl)
aDrawingObject(),
aFrame(this),
eRunType(LOCH),
+ isRightToLeft(false),
nYear(0),
nMonth(0),
nDay(0),
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index a6e44067ea30..07571d27c069 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -255,6 +255,8 @@ namespace writerfilter {
/// CJK or CTL?
enum { LOCH, HICH, DBCH } eRunType;
+ /// ltrch or rtlch
+ bool isRightToLeft;
// Info group.
int nYear;