[PATCH] fdo#48193 fix RTF import of fields without a result

Miklos Vajna vmiklos at suse.cz
Wed Apr 25 02:21:06 PDT 2012


---
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   26 +++++++++++++++++++++++-
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |    9 ++++++++
 2 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index b74b26e..23df13f 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1097,7 +1097,7 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
             m_aStates.top().nDestinationState = DESTINATION_STYLESHEET;
             break;
         case RTF_FIELD:
-            // A field consists of an fldinst and an fldrslt group.
+            m_aStates.top().nDestinationState = DESTINATION_FIELD;
             break;
         case RTF_FLDINST:
             {
@@ -3526,6 +3526,30 @@ int RTFDocumentImpl::popState()
     }
     else if (bLevelNumbersEnd)
         m_aStates.top().aTableSprms = aSprms;
+    else if (aState.nDestinationState == DESTINATION_FIELDINSTRUCTION)
+        m_aStates.top().nFieldStatus = FIELD_INSTRUCTION;
+    else if (aState.nDestinationState == DESTINATION_FIELDRESULT)
+        m_aStates.top().nFieldStatus = FIELD_RESULT;
+    else if (aState.nDestinationState == DESTINATION_FIELD)
+    {
+        if (aState.nFieldStatus == FIELD_INSTRUCTION)
+        {
+            sal_uInt8 sFieldEnd[] = { 0x15 };
+            if (!m_pCurrentBuffer)
+            {
+                Mapper().startCharacterGroup();
+                Mapper().text(sFieldEnd, 1);
+                Mapper().endCharacterGroup();
+            }
+            else
+            {
+                m_pCurrentBuffer->push_back(make_pair(BUFFER_STARTRUN, RTFValue::Pointer_t()));
+                RTFValue::Pointer_t pValue(new RTFValue(*sFieldEnd));
+                m_pCurrentBuffer->push_back(make_pair(BUFFER_TEXT, pValue));
+                m_pCurrentBuffer->push_back(make_pair(BUFFER_ENDRUN, RTFValue::Pointer_t()));
+            }
+        }
+    }
     else if (bPopShapeProperties)
     {
         m_aStates.top().aShape = aShape;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 1d0a37d..885f75a 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -65,6 +65,7 @@ namespace writerfilter {
             DESTINATION_STYLESHEET,
             DESTINATION_STYLEENTRY,
             DESTINATION_EQINSTRUCTION,
+            DESTINATION_FIELD,
             DESTINATION_FIELDINSTRUCTION,
             DESTINATION_FIELDRESULT,
             DESTINATION_LISTTABLE,
@@ -162,6 +163,13 @@ namespace writerfilter {
             BMPSTYLE_PNG
         };
 
+        enum RTFFieldStatus
+        {
+            FIELD_NONE,
+            FIELD_INSTRUCTION,
+            FIELD_RESULT
+        };
+
         /// A buffer storing dmapper calls.
         typedef std::deque< std::pair<RTFBufferTypes, RTFValue::Pointer_t> > RTFBuffer_t;
 
@@ -245,6 +253,7 @@ namespace writerfilter {
                 RTFDocumentImpl* m_pDocumentImpl;
                 RTFInternalState nInternalState;
                 RTFDesitnationState nDestinationState;
+                RTFFieldStatus nFieldStatus;
                 RTFBorderState nBorderState;
                 // font table, stylesheet table
                 RTFSprms aTableSprms;
-- 
1.7.7


--X1bOJ3K7DJ5YkBrT--


More information about the LibreOffice mailing list