diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-06-03 20:18:59 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2014-06-03 20:57:06 +0200 |
commit | eb0505ef3507876781ff7fadae2b1d1cd1348220 (patch) | |
tree | 6fa97be4a8db24a0e6ab752b88162774caef935a /writerfilter | |
parent | 1063b8e8c122a819e844a2209a7136a8a9be31fd (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.
Change-Id: I60e69130e6e5aed1f5d237f64b1656c3141e402a
(cherry picked from commit 36246aa9fb57c9fe4e546c91a8274d8828b1424e)
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 23 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.hxx | 2 |
2 files changed, 20 insertions, 5 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 7c99b85aa00d..2b346ba2b195 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -2825,8 +2825,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; @@ -3493,11 +3495,20 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) { case RTF_F: case RTF_AF: - if (nKeyword == RTF_F) - nSprm = NS_ooxml::LN_CT_Fonts_ascii; + if (m_aStates.top().isRightToLeft + || m_aStates.top().eRunType == RTFParserState::HICH) + { + nSprm = NS_ooxml::LN_CT_Fonts_cs; + } + else if (m_aStates.top().eRunType == RTFParserState::DBCH) + { + nSprm = NS_ooxml::LN_CT_Fonts_eastAsia; + } else - nSprm = (m_aStates.top().eRunType == RTFParserState::HICH - ? NS_ooxml::LN_CT_Fonts_eastAsia : NS_ooxml::LN_CT_Fonts_cs); + { + assert(m_aStates.top().eRunType == RTFParserState::LOCH); + nSprm = NS_ooxml::LN_CT_Fonts_ascii; + } if (m_aStates.top().nDestinationState == DESTINATION_FONTTABLE || m_aStates.top().nDestinationState == DESTINATION_FONTENTRY) { m_aFontIndexes.push_back(nParam); @@ -3521,7 +3532,8 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) m_nCurrentFontIndex = getFontIndex(nParam); RTFValue::Pointer_t pValue(new RTFValue(getFontName(m_nCurrentFontIndex))); lcl_putNestedAttribute(m_aStates.top().aCharacterSprms, NS_ooxml::LN_EG_RPrBase_rFonts, nSprm, pValue); - m_aStates.top().nCurrentEncoding = getEncoding(m_nCurrentFontIndex); + if (nKeyword == RTF_F) + m_aStates.top().nCurrentEncoding = getEncoding(m_nCurrentFontIndex); } break; case RTF_RED: @@ -5741,6 +5753,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 d069baa2ca1d..b86c54f950ae 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -257,6 +257,8 @@ public: /// CJK or CTL? enum { LOCH, HICH, DBCH } eRunType; + /// ltrch or rtlch + bool isRightToLeft; // Info group. int nYear; |