[PATCH] fdo#45182 fix RTF import of character encoding in footnotes

Miklos Vajna vmiklos at suse.cz
Tue Apr 3 07:49:41 PDT 2012


There were two problems here:

1) \plain reset the character properties, but did not touch the current encoding
2) the default properties were not passed to substreams
---
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   17 +++++++++++++++--
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |    2 ++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index a117ec6..1a7f8b9 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -569,6 +569,14 @@ int RTFDocumentImpl::getFontIndex(int nIndex)
         return m_pSuperstream->getFontIndex(nIndex);
 }
 
+RTFParserState& RTFDocumentImpl::getDefaultState()
+{
+    if (!m_pSuperstream)
+        return m_aDefaultState;
+    else
+        return m_pSuperstream->getDefaultState();
+}
+
 void RTFDocumentImpl::resolve(Stream & rMapper)
 {
     m_pMapperStream = &rMapper;
@@ -1763,8 +1771,13 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
             m_aStates.top().nCurrentEncoding = RTL_TEXTENCODING_MS_1252;
             break;
         case RTF_PLAIN:
-            m_aStates.top().aCharacterSprms = m_aDefaultState.aCharacterSprms;
-            m_aStates.top().aCharacterAttributes = m_aDefaultState.aCharacterAttributes;
+            {
+                m_aStates.top().aCharacterSprms = getDefaultState().aCharacterSprms;
+                RTFValue::Pointer_t pValue = m_aStates.top().aCharacterSprms.find(NS_sprm::LN_CRgFtc0);
+                if (pValue.get())
+                    m_aStates.top().nCurrentEncoding = getEncoding(pValue->getInt());
+                m_aStates.top().aCharacterAttributes = getDefaultState().aCharacterAttributes;
+            }
             break;
         case RTF_PARD:
             m_aStates.top().aParagraphSprms = m_aDefaultState.aParagraphSprms;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 461b88e..676d75e 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -369,6 +369,8 @@ namespace writerfilter {
                 int getFontIndex(int nIndex);
                 /// Return the encoding associated with a dmapper font index.
                 rtl_TextEncoding getEncoding(sal_uInt32 nFontIndex);
+                /// Get the default parser state.
+                RTFParserState& getDefaultState();
 
             private:
                 SvStream& Strm();
-- 
1.7.7


--k1lZvvs/B4yU6o8G--


More information about the LibreOffice mailing list