[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - writerfilter/source
Michael Stahl
mstahl at redhat.com
Wed Jun 4 00:40:26 PDT 2014
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 23 ++++++++++++++++++-----
writerfilter/source/rtftok/rtfdocumentimpl.hxx | 2 ++
2 files changed, 20 insertions(+), 5 deletions(-)
New commits:
commit 743bcdebef21deeb73f0111b4e6e047c88fd7b8f
Author: Michael Stahl <mstahl at redhat.com>
Date: Tue Jun 3 20:18:59 2014 +0200
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 at collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index f1ac1d1..920b19f 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 a6e4406..07571d2 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;
More information about the Libreoffice-commits
mailing list