Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Hi,

Today's RTF regression fix. :-)

See
http://cgit.freedesktop.org/libreoffice/core/commit/?id=116016d

It depends on a trivial refactoring:
http://cgit.freedesktop.org/libreoffice/core/commit/?id=f1fdcde

I'm attaching a backport of both.

Thanks,

Miklos
From 3db2211850ec4b1f07ad0208942945719ef344ad Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@suse.cz>
Date: Wed, 25 Apr 2012 11:28:49 +0200
Subject: [PATCH 1/2] avoid code duplication by introducing
 RTFDocumentImpl::singleChar

---
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   86 ++++++------------------
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |    2 +
 2 files changed, 24 insertions(+), 64 deletions(-)

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index f36e763..0a93829a 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -886,6 +886,24 @@ bool RTFFrame::inFrame()
         || nY > 0;
 }
 
+void RTFDocumentImpl::singleChar(sal_uInt8 nValue)
+{
+    sal_uInt8 sValue[] = { nValue };
+    if (!m_pCurrentBuffer)
+    {
+        Mapper().startCharacterGroup();
+        Mapper().text(sValue, 1);
+        Mapper().endCharacterGroup();
+    }
+    else
+    {
+        m_pCurrentBuffer->push_back(make_pair(BUFFER_STARTRUN, RTFValue::Pointer_t()));
+        RTFValue::Pointer_t pValue(new RTFValue(*sValue));
+        m_pCurrentBuffer->push_back(make_pair(BUFFER_TEXT, pValue));
+        m_pCurrentBuffer->push_back(make_pair(BUFFER_ENDRUN, RTFValue::Pointer_t()));
+    }
+}
+
 void RTFDocumentImpl::text(OUString& rString)
 {
     bool bRet = true;
@@ -1137,22 +1155,7 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
                 if (aBuf.toString().equals("EQ"))
                     m_bEq = true;
                 else
-                {
-                    sal_uInt8 sFieldStart[] = { 0x13 };
-                    if (!m_pCurrentBuffer)
-                    {
-                        Mapper().startCharacterGroup();
-                        Mapper().text(sFieldStart, 1);
-                        Mapper().endCharacterGroup();
-                    }
-                    else
-                    {
-                        m_pCurrentBuffer->push_back(make_pair(BUFFER_STARTRUN, 
RTFValue::Pointer_t()));
-                        RTFValue::Pointer_t pValue(new RTFValue(*sFieldStart));
-                        m_pCurrentBuffer->push_back(make_pair(BUFFER_TEXT, pValue));
-                        m_pCurrentBuffer->push_back(make_pair(BUFFER_ENDRUN, 
RTFValue::Pointer_t()));
-                    }
-                }
+                    singleChar(0x13);
                 m_aStates.top().nDestinationState = DESTINATION_FIELDINSTRUCTION;
             }
             break;
@@ -3096,42 +3099,12 @@ int RTFDocumentImpl::popState()
             m_aFormfieldSprms->clear();
         }
         if (!m_bEq)
-        {
-            sal_uInt8 sFieldSep[] = { 0x14 };
-            if (!m_pCurrentBuffer)
-            {
-                Mapper().startCharacterGroup();
-                Mapper().text(sFieldSep, 1);
-                Mapper().endCharacterGroup();
-            }
-            else
-            {
-                m_pCurrentBuffer->push_back(make_pair(BUFFER_STARTRUN, RTFValue::Pointer_t()));
-                RTFValue::Pointer_t pValue(new RTFValue(*sFieldSep));
-                m_pCurrentBuffer->push_back(make_pair(BUFFER_TEXT, pValue));
-                m_pCurrentBuffer->push_back(make_pair(BUFFER_ENDRUN, RTFValue::Pointer_t()));
-            }
-        }
+            singleChar(0x14);
     }
     else if (m_aStates.top().nDestinationState == DESTINATION_FIELDRESULT)
     {
         if (!m_bEq)
-        {
-            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()));
-            }
-        }
+            singleChar(0x15);
         else
             m_bEq = false;
     }
@@ -3542,22 +3515,7 @@ int RTFDocumentImpl::popState()
     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()));
-            }
-        }
+            singleChar(0x15);
     }
     else if (bPopShapeProperties)
     {
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 885f75a..84ac9f3 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -398,6 +398,8 @@ namespace writerfilter {
                 void resolveSubstream(sal_uInt32 nPos, Id nId, rtl::OUString& rIgnoreFirst);
 
                 void text(rtl::OUString& rString);
+                // Sends a single character to dmapper, taking care of buffering.
+                void singleChar(sal_uInt8 nValue);
                 void parBreak();
                 void tableBreak();
                 void checkNeedPap();
-- 
1.7.7

From 1535f48e22ecc5a5c613e2b21ae180db0dbe00ea Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@suse.cz>
Date: Mon, 7 May 2012 09:50:02 +0200
Subject: [PATCH 2/2] fdo#38786 implement RTF_CHPGN

Change-Id: I0ae693193b4fc8ed155e2d71b06daa80d46da47c
---
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 0a93829a..330bc25 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1606,6 +1606,15 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
                     parBreak();
             }
             break;
+        case RTF_CHPGN:
+            {
+                OUString aStr(RTL_CONSTASCII_USTRINGPARAM("PAGE"));
+                singleChar(0x13);
+                text(aStr);
+                singleChar(0x14);
+                singleChar(0x15);
+            }
+            break;
         default:
 #if OSL_DEBUG_LEVEL > 1
             OSL_TRACE("%s: TODO handle symbol '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword));
-- 
1.7.7


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.