[Libreoffice-commits] core.git: writerfilter/source

Miklos Vajna vmiklos at suse.cz
Thu Jul 18 02:08:20 PDT 2013


 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   15 ++++++++++++---
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |    1 +
 2 files changed, 13 insertions(+), 3 deletions(-)

New commits:
commit 54518a209d0ffe00f8e391472da92e398c474392
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Thu Jul 18 10:41:34 2013 +0200

    fdo#65632 RTF import: send NS_ooxml::LN_trackchange only once for one range
    
    The problem was that in case we had
    {\deleted foo\b bar}
    then both "foo" and "bar" triggered a trackchange, but "}" only ended
    one, resulting in overlapping redline ranges. This was cought by core,
    but caused a performance problem.
    
    For the first bugdoc, before:
    real    3m57.803s
    after:
    real    0m3.072s
    
    Change-Id: Ibf6f2db30109f0b9a2571d2e4fb3cc76294f68d1

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index bd6971b..249e51b 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -470,6 +470,15 @@ void RTFDocumentImpl::runProps()
         RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aCharacterAttributes, m_aStates.top().aCharacterSprms));
         m_aStates.top().pCurrentBuffer->push_back(make_pair(BUFFER_PROPS, pValue));
     }
+
+    // Delete the sprm, so the trackchange range will be started only once.
+    // OTOH set a boolean flag, so we'll know we need to end the range later.
+    RTFValue::Pointer_t pTrackchange = m_aStates.top().aCharacterSprms.find(NS_ooxml::LN_trackchange);
+    if (pTrackchange.get())
+    {
+        m_aStates.top().bStartedTrackchange = true;
+        m_aStates.top().aCharacterSprms.erase(NS_ooxml::LN_trackchange);
+    }
 }
 
 void RTFDocumentImpl::runBreak()
@@ -4429,8 +4438,7 @@ int RTFDocumentImpl::popState()
     }
 
     // See if we need to end a track change
-    RTFValue::Pointer_t pTrackchange = aState.aCharacterSprms.find(NS_ooxml::LN_trackchange);
-    if (pTrackchange.get())
+    if (aState.bStartedTrackchange)
     {
         RTFSprms aTCSprms;
         RTFValue::Pointer_t pValue(new RTFValue(0));
@@ -4795,7 +4803,8 @@ RTFParserState::RTFParserState(RTFDocumentImpl *pDocumentImpl)
     bInBackground(false),
     bHadShapeText(false),
     bInShapeGroup(false),
-    bCreatedShapeGroup(false)
+    bCreatedShapeGroup(false),
+    bStartedTrackchange(false)
 {
 }
 
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 6d05b90..d55572e 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -264,6 +264,7 @@ namespace writerfilter {
                 bool bHadShapeText;
                 bool bInShapeGroup; ///< If we're inside a \shpgrp group.
                 bool bCreatedShapeGroup; ///< A GroupShape was created and pushed to the parent stack.
+                bool bStartedTrackchange; ///< Track change is started, need to end it before popping.
         };
 
         class RTFTokenizer;


More information about the Libreoffice-commits mailing list