[Libreoffice-commits] core.git: Branch 'aoo/trunk' - sw/source

Oliver-Rainer Wittmann orw at apache.org
Mon Jun 16 03:08:47 PDT 2014


 sw/source/core/txtnode/ndtxt.cxx |   24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

New commits:
commit 6895a55d74fe6a3b70ba15f77050652d3afee821
Author: Oliver-Rainer Wittmann <orw at apache.org>
Date:   Mon Jun 16 08:40:28 2014 +0000

    125055: follow-up of fix for issue 124338 - adjust condition to trigger sort of bookmarks in order to avoid serious performance decrease
    
    Kudos to Ariel for his analysis

diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 75b2aa0..d5967ea 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -1080,6 +1080,8 @@ void SwTxtNode::Update(
         // Bookmarks must never grow to either side, when editing (directly) to the left or right (#i29942#)!
         // And a bookmark with same start and end must remain to the left of the inserted text (used in XML import).
         {
+            bool bAtLeastOneBookmarkMoved = false;
+            bool bAtLeastOneExpandedBookmarkAtInsertionPosition = false;
             const IDocumentMarkAccess* const pMarkAccess = getIDocumentMarkAccess();
             for ( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getAllMarksBegin();
                 ppMark != pMarkAccess->getAllMarksEnd();
@@ -1087,14 +1089,28 @@ void SwTxtNode::Update(
             {
                 const ::sw::mark::IMark* const pMark = ppMark->get();
                 const SwPosition* pEnd = &pMark->GetMarkEnd();
-                SwIndex & rIdx = const_cast<SwIndex&>(pEnd->nContent);
+                SwIndex & rEndIdx = const_cast<SwIndex&>(pEnd->nContent);
                 if( this == &pEnd->nNode.GetNode() &&
-                    rPos.GetIndex() == rIdx.GetIndex() )
+                    rPos.GetIndex() == rEndIdx.GetIndex() )
                 {
-                    rIdx.Assign( &aTmpIdxReg, rIdx.GetIndex() );
-                    bSortMarks = true;
+                    rEndIdx.Assign( &aTmpIdxReg, rEndIdx.GetIndex() );
+                    bAtLeastOneBookmarkMoved = true;
+                }
+                else if ( !bAtLeastOneExpandedBookmarkAtInsertionPosition )
+                {
+                    if ( pMark->IsExpanded() )
+                    {
+                        const SwPosition* pStart = &pMark->GetMarkStart();
+                        if ( this == &pStart->nNode.GetNode()
+                             && rPos.GetIndex() == pStart->nContent.GetIndex() )
+                        {
+                            bAtLeastOneExpandedBookmarkAtInsertionPosition = true;
+                        }
+                    }
                 }
             }
+
+            bSortMarks = bAtLeastOneBookmarkMoved && bAtLeastOneExpandedBookmarkAtInsertionPosition;
         }
     }
 


More information about the Libreoffice-commits mailing list