Author: orw Date: Mon Jun 16 09:58:58 2014 New Revision: 1602833 URL: http://svn.apache.org/r1602833 Log: 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
cherry-picked from trunk Modified: openoffice/branches/AOO410/ (props changed) openoffice/branches/AOO410/main/ (props changed) openoffice/branches/AOO410/main/sw/source/core/txtnode/ndtxt.cxx Propchange: openoffice/branches/AOO410/ ------------------------------------------------------------------------------ Merged /openoffice/trunk:r1602823 Propchange: openoffice/branches/AOO410/main/ ------------------------------------------------------------------------------ Merged /openoffice/trunk/main:r1602823 Modified: openoffice/branches/AOO410/main/sw/source/core/txtnode/ndtxt.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/source/core/txtnode/ndtxt.cxx?rev=1602833&r1=1602832&r2=1602833&view=diff ============================================================================== --- openoffice/branches/AOO410/main/sw/source/core/txtnode/ndtxt.cxx (original) +++ openoffice/branches/AOO410/main/sw/source/core/txtnode/ndtxt.cxx Mon Jun 16 09:58:58 2014 @@ -1075,6 +1075,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(); @@ -1082,14 +1084,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; } }