sw/inc/IDocumentContentOperations.hxx | 7 ++++++- sw/source/core/doc/DocumentContentOperationsManager.cxx | 4 ++-- sw/source/core/doc/doccomp.cxx | 4 ++-- sw/source/core/doc/docglos.cxx | 2 +- sw/source/core/doc/doclay.cxx | 3 ++- sw/source/core/doc/docnew.cxx | 2 +- sw/source/core/doc/docnum.cxx | 2 +- sw/source/core/doc/docredln.cxx | 4 ++-- sw/source/core/docnode/section.cxx | 3 +-- sw/source/core/edit/acorrect.cxx | 2 +- sw/source/core/edit/eddel.cxx | 2 +- sw/source/core/edit/edglss.cxx | 6 +++--- sw/source/core/frmedt/fecopy.cxx | 4 ++-- sw/source/core/inc/DocumentContentOperationsManager.hxx | 2 +- sw/source/core/undo/untblk.cxx | 2 +- sw/source/core/unocore/unotext.cxx | 2 +- sw/source/filter/ww8/ww8glsy.cxx | 2 +- sw/source/filter/xml/xmltbli.cxx | 2 +- sw/source/uibase/uno/unoatxt.cxx | 2 +- 19 files changed, 31 insertions(+), 26 deletions(-)
New commits: commit b23d55ccc24a37c60d39061a4e497181b9609e9b Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed Apr 8 09:07:07 2015 +0200 tdf#88812 sw: speed up SwDoc::MakeFlyAndMove() In this function the anchor is not set by the time CopyRange() is called, so the check always returns false, but in worst case it's O(n^3) wrt. the number of fly frames in the document, so it's a significant cost to perform that check. Before: $ time OOO_EXIT_POST_STARTUP=1 instdir/program/soffice.bin --headless /home/vmiklos/orig.rtf real 0m46.833s After: $ time OOO_EXIT_POST_STARTUP=1 instdir/program/soffice.bin --headless /home/vmiklos/orig.rtf real 0m26.832s Change-Id: I7ab9565634e4df7e0adc701908815f778dc59d32 Reviewed-on: https://gerrit.libreoffice.org/15197 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> diff --git a/sw/inc/IDocumentContentOperations.hxx b/sw/inc/IDocumentContentOperations.hxx index 38c900a..9a866e6 100644 --- a/sw/inc/IDocumentContentOperations.hxx +++ b/sw/inc/IDocumentContentOperations.hxx @@ -99,8 +99,13 @@ public: @param rPos The target copy destination + + @param bCheckPos + If this function should check if rPos is in a fly frame anchored in + rPam. If false, then no such check will be performed, and it is assumed + that the caller took care of verifying this constraint already. */ - virtual bool CopyRange(SwPaM& rPam, SwPosition& rPos, const bool bCopyAll ) const = 0; + virtual bool CopyRange(SwPaM& rPam, SwPosition& rPos, const bool bCopyAll, bool bCheckPos ) const = 0; /** Delete section containing the node. */ diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 136d3c6..e940caf 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -1576,7 +1576,7 @@ DocumentContentOperationsManager::DocumentContentOperationsManager( SwDoc& i_rSw // Copy an area into this document or into another document bool -DocumentContentOperationsManager::CopyRange( SwPaM& rPam, SwPosition& rPos, const bool bCopyAll ) const +DocumentContentOperationsManager::CopyRange( SwPaM& rPam, SwPosition& rPos, const bool bCopyAll, bool bCheckPos ) const { const SwPosition *pStt = rPam.Start(), *pEnd = rPam.End(); @@ -1588,7 +1588,7 @@ DocumentContentOperationsManager::CopyRange( SwPaM& rPam, SwPosition& rPos, cons return false; // Prevent copying in Flys that are anchored in the area - if( pDoc == &m_rDoc ) + if( pDoc == &m_rDoc && bCheckPos ) { // Correct the Start-/EndNode sal_uLong nStt = pStt->nNode.GetIndex(), diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx index aab09cc..c9d59c9 100644 --- a/sw/source/core/doc/doccomp.cxx +++ b/sw/source/core/doc/doccomp.cxx @@ -1393,7 +1393,7 @@ bool SwCompareLine::ChangesInLine( const SwCompareLine& rLine, aCpyPam.SetMark(); aCpyPam.GetPoint()->nContent = nSrcTo; aCpyPam.GetDoc()->getIDocumentContentOperations().CopyRange( aCpyPam, *aPam.GetPoint(), - false ); + /*bCopyAll=*/false, /*bCheckPos=*/true ); pDstDoc->GetIDocumentUndoRedo().DoUndo( bUndo ); SwPaM* pTmp = new SwPaM( *aPam.GetPoint(), rpDelRing ); @@ -1931,7 +1931,7 @@ sal_uInt16 SaveMergeRedline::InsertRedline(SwPaM* pLastDestRedline) pSrcRedl->GetDoc()->getIDocumentContentOperations().CopyRange( *const_cast<SwPaM*>(static_cast<const SwPaM*>(pSrcRedl)), - *pDestRedl->GetPoint(), false ); + *pDestRedl->GetPoint(), /*bCopyAll=*/false, /*bCheckPos=*/true ); pDoc->getIDocumentRedlineAccess().SetRedlineMode_intern( eOld ); diff --git a/sw/source/core/doc/docglos.cxx b/sw/source/core/doc/docglos.cxx index 894c631..a529948 100644 --- a/sw/source/core/doc/docglos.cxx +++ b/sw/source/core/doc/docglos.cxx @@ -187,7 +187,7 @@ bool SwDoc::InsertGlossary( SwTextBlocks& rBlock, const OUString& rEntry, SwDontExpandItem aACD; aACD.SaveDontExpandItems( rInsPos ); - pGDoc->getIDocumentContentOperations().CopyRange( aCpyPam, rInsPos, false ); + pGDoc->getIDocumentContentOperations().CopyRange( aCpyPam, rInsPos, /*bCopyAll=*/false, /*bCheckPos=*/true ); aACD.RestoreDontExpandItems( rInsPos ); if( pShell ) diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index a9e82f9..c1a1627 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -441,7 +441,8 @@ SwFlyFrmFmt* SwDoc::MakeFlyAndMove( const SwPaM& rPam, const SfxItemSet& rSet, if( rTmp.HasMark() && *rTmp.GetPoint() != *rTmp.GetMark() ) { - getIDocumentContentOperations().CopyRange( *const_cast<SwPaM*>(&rTmp), aPos, false ); + // aPos is the newly created fly section, so definitely outside rPam, it's pointless to check that again. + getIDocumentContentOperations().CopyRange( *const_cast<SwPaM*>(&rTmp), aPos, /*bCopyAll=*/false, /*bCheckPos=*/false ); } } getIDocumentRedlineAccess().SetRedlineMove(bOldRedlineMove); diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index b45451f..3830d10 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -987,7 +987,7 @@ SwNodeIndex SwDoc::AppendDoc(const SwDoc& rSource, sal_uInt16 const nStartPageNu #ifdef DBG_UTIL SAL_INFO( "sw.docappend", "CopyRange In: " << CNTNT_DOC( this ) ); #endif - rSource.getIDocumentContentOperations().CopyRange( aCpyPam, rInsPos, true ); + rSource.getIDocumentContentOperations().CopyRange( aCpyPam, rInsPos, /*bCopyAll=*/true, /*bCheckPos=*/true ); // Note: aCpyPam is invalid now #ifdef DBG_UTIL SAL_INFO( "sw.docappend", "CopyRange Out: " << CNTNT_DOC( this ) ); diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index 40a35c9..1f45c49 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -1914,7 +1914,7 @@ bool SwDoc::MoveParagraph( const SwPaM& rPam, long nOffset, bool bIsOutlMv ) } } - getIDocumentContentOperations().CopyRange( aPam, aInsPos, false ); + getIDocumentContentOperations().CopyRange( aPam, aInsPos, /*bCopyAll=*/false, /*bCheckPos=*/true ); if( bDelLastPara ) { // We need to remove the last empty Node again diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index edc074a1..4488e49 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -1220,7 +1220,7 @@ void SwRangeRedline::CopyToSection() SwNodeIndex aNdIdx( *pSttNd, 1 ); SwTxtNode* pTxtNd = aNdIdx.GetNode().GetTxtNode(); SwPosition aPos( aNdIdx, SwIndex( pTxtNd )); - pDoc->getIDocumentContentOperations().CopyRange( *this, aPos, false ); + pDoc->getIDocumentContentOperations().CopyRange( *this, aPos, /*bCopyAll=*/false, /*bCheckPos=*/true ); // Take over the style from the EndNode if needed // We don't want this in Doc::Copy @@ -1244,7 +1244,7 @@ void SwRangeRedline::CopyToSection() if( pCEndNd ) { SwPosition aPos( *pSttNd->EndOfSectionNode() ); - pDoc->getIDocumentContentOperations().CopyRange( *this, aPos, false ); + pDoc->getIDocumentContentOperations().CopyRange( *this, aPos, /*bCopyAll=*/false, /*bCheckPos=*/true ); } else { diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index 70bb3b8..00e52c0 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -1333,8 +1333,7 @@ static void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd ) pCpyPam->Start()->nNode > rInsPos || rInsPos >= pCpyPam->End()->nNode ) { - pSrcDoc->getIDocumentContentOperations().CopyRange( *pCpyPam, *pPam->GetPoint(), - false ); + pSrcDoc->getIDocumentContentOperations().CopyRange( *pCpyPam, *pPam->GetPoint(), /*bCopyAll=*/false, /*bCheckPos=*/true ); } delete pCpyPam; } diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx index 6a032ce..cc879ba 100644 --- a/sw/source/core/edit/acorrect.cxx +++ b/sw/source/core/edit/acorrect.cxx @@ -377,7 +377,7 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos, SwDontExpandItem aExpItem; aExpItem.SaveDontExpandItems( *aPam.GetPoint() ); - pAutoDoc->getIDocumentContentOperations().CopyRange( aCpyPam, *aPam.GetPoint(), false ); + pAutoDoc->getIDocumentContentOperations().CopyRange( aCpyPam, *aPam.GetPoint(), /*bCopyAll=*/false, /*bCheckPos=*/true ); aExpItem.RestoreDontExpandItems( *aPam.GetPoint() ); diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx index b5f2db9..0cbd8f2 100644 --- a/sw/source/core/edit/eddel.cxx +++ b/sw/source/core/edit/eddel.cxx @@ -244,7 +244,7 @@ long SwEditShell::Copy( SwEditShell* pDestShell ) bFirstMove = false; } - const bool bSuccess( GetDoc()->getIDocumentContentOperations().CopyRange( rPaM, *pPos, false ) ); + const bool bSuccess( GetDoc()->getIDocumentContentOperations().CopyRange( rPaM, *pPos, /*bCopyAll=*/false, /*bCheckPos=*/true ) ); if (!bSuccess) continue; diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx index 80c5729..63bcf4e 100644 --- a/sw/source/core/edit/edglss.cxx +++ b/sw/source/core/edit/edglss.cxx @@ -146,7 +146,7 @@ sal_uInt16 SwEditShell::SaveGlossaryDoc( SwTextBlocks& rBlock, aStt = pGDoc->GetNodes().GetEndOfExtras(); pCntntNd = pGDoc->GetNodes().GoNext( &aStt ); SwPosition aInsPos( aStt, SwIndex( pCntntNd )); - pMyDoc->getIDocumentContentOperations().CopyRange( aCpyPam, aInsPos, false ); + pMyDoc->getIDocumentContentOperations().CopyRange( aCpyPam, aInsPos, /*bCopyAll=*/false, /*bCheckPos=*/true ); nRet = rBlock.PutDoc(); } @@ -226,7 +226,7 @@ bool SwEditShell::_CopySelToDoc( SwDoc* pInsDoc, SwNodeIndex* pSttNd ) { rPaM.SetMark(); rPaM.Move( fnMoveForward, fnGoCntnt ); - bRet = GetDoc()->getIDocumentContentOperations().CopyRange( rPaM, aPos, false ) + bRet = GetDoc()->getIDocumentContentOperations().CopyRange( rPaM, aPos, /*bCopyAll=*/false, /*bCheckPos=*/true ) || bRet; rPaM.Exchange(); rPaM.DeleteMark(); @@ -245,7 +245,7 @@ bool SwEditShell::_CopySelToDoc( SwDoc* pInsDoc, SwNodeIndex* pSttNd ) // the first cell as well. aPaM.Start()->nNode = aPaM.Start()->nNode.GetNode().FindTableNode()->GetIndex(); } - bRet = GetDoc()->getIDocumentContentOperations().CopyRange( aPaM, aPos, false ) || bRet; + bRet = GetDoc()->getIDocumentContentOperations().CopyRange( aPaM, aPos, /*bCopyAll=*/false, /*bCheckPos=*/true ) || bRet; } } } diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index bf37b08..0e36a90 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -798,7 +798,7 @@ bool SwFEShell::Paste( SwDoc* pClpDoc, bool bIncludingPageFrames ) { SwNodeIndex aIndexBefore(rInsPos.nNode); --aIndexBefore; - pClpDoc->getIDocumentContentOperations().CopyRange( rCopy, rInsPos, false ); + pClpDoc->getIDocumentContentOperations().CopyRange( rCopy, rInsPos, /*bCopyAll=*/false, /*bCheckPos=*/true ); { ++aIndexBefore; SwPaM aPaM(SwPosition(aIndexBefore), @@ -1049,7 +1049,7 @@ bool SwFEShell::Paste( SwDoc* pClpDoc, bool bIncludingPageFrames ) --aIndexBefore; - pClpDoc->getIDocumentContentOperations().CopyRange( aCpyPam, rInsPos, false ); + pClpDoc->getIDocumentContentOperations().CopyRange( aCpyPam, rInsPos, /*bCopyAll=*/false, /*bCheckPos=*/true ); // Note: aCpyPam is invalid now ++aIndexBefore; diff --git a/sw/source/core/inc/DocumentContentOperationsManager.hxx b/sw/source/core/inc/DocumentContentOperationsManager.hxx index c2e72fc..f2ad52b 100644 --- a/sw/source/core/inc/DocumentContentOperationsManager.hxx +++ b/sw/source/core/inc/DocumentContentOperationsManager.hxx @@ -39,7 +39,7 @@ public: DocumentContentOperationsManager( SwDoc& i_rSwdoc ); //Interface methods: - bool CopyRange(SwPaM&, SwPosition&, const bool bCopyAll ) const SAL_OVERRIDE; + bool CopyRange(SwPaM&, SwPosition&, const bool bCopyAll, bool bCheckPos ) const SAL_OVERRIDE; void DeleteSection(SwNode* pNode) SAL_OVERRIDE; diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx index 52611e5..7490dae 100644 --- a/sw/source/core/undo/untblk.cxx +++ b/sw/source/core/undo/untblk.cxx @@ -308,7 +308,7 @@ void SwUndoInserts::RepeatImpl(::sw::RepeatContext & rContext) SwPaM aPam( rContext.GetDoc().GetNodes().GetEndOfContent() ); SetPaM( aPam ); SwPaM & rRepeatPaM( rContext.GetRepeatPaM() ); - aPam.GetDoc()->getIDocumentContentOperations().CopyRange( aPam, *rRepeatPaM.GetPoint(), false ); + aPam.GetDoc()->getIDocumentContentOperations().CopyRange( aPam, *rRepeatPaM.GetPoint(), /*bCopyAll=*/false, /*bCheckPos=*/true ); } SwUndoInsDoc::SwUndoInsDoc( const SwPaM& rPam ) diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 6d6c742..3374de0 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -2356,7 +2356,7 @@ throw (uno::RuntimeException, std::exception) SwNodeIndex rNdIndex( *GetStartNode( ), 1 ); SwPosition rPos( rNdIndex ); - m_pImpl->m_pDoc->getIDocumentContentOperations().CopyRange( *pCursor->GetPaM(), rPos, false ); + m_pImpl->m_pDoc->getIDocumentContentOperations().CopyRange( *pCursor->GetPaM(), rPos, /*bCopyAll=*/false, /*bCheckPos=*/true ); } SwXBodyText::SwXBodyText(SwDoc *const pDoc) diff --git a/sw/source/filter/ww8/ww8glsy.cxx b/sw/source/filter/ww8/ww8glsy.cxx index e77e9fa..a92c548 100644 --- a/sw/source/filter/ww8/ww8glsy.cxx +++ b/sw/source/filter/ww8/ww8glsy.cxx @@ -169,7 +169,7 @@ bool WW8Glossary::MakeEntries(SwDoc *pD, SwTextBlocks &rBlocks, -1 ); pCNd = aIdx.GetNode().GetCntntNode(); SwPosition aPos(aIdx, SwIndex(pCNd, (pCNd) ? pCNd->Len() : 0)); - pD->getIDocumentContentOperations().CopyRange( aPam, aPos, false ); + pD->getIDocumentContentOperations().CopyRange( aPam, aPos, /*bCopyAll=*/false, /*bCheckPos=*/true ); rBlocks.PutDoc(); } } diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx index 46b098b..42b9437 100644 --- a/sw/source/filter/xml/xmltbli.cxx +++ b/sw/source/filter/xml/xmltbli.cxx @@ -708,7 +708,7 @@ void SwXMLTableCellContext_Impl::EndElement() assert(pDstTxtCrsr && "SwXTextCursor missing"); SwPaM aSrcPaM(*pSrcPaM->GetMark(), *pSrcPaM->GetPoint()); SwPosition aDstPos( *pDstTxtCrsr->GetPaM()->GetPoint() ); - pDoc->getIDocumentContentOperations().CopyRange( aSrcPaM, aDstPos, false ); + pDoc->getIDocumentContentOperations().CopyRange( aSrcPaM, aDstPos, /*bCopyAll=*/false, /*bCheckPos=*/true ); nColRepeat--; } diff --git a/sw/source/uibase/uno/unoatxt.cxx b/sw/source/uibase/uno/unoatxt.cxx index 497b95d..6eca90a 100644 --- a/sw/source/uibase/uno/unoatxt.cxx +++ b/sw/source/uibase/uno/unoatxt.cxx @@ -328,7 +328,7 @@ static bool lcl_CopySelToDoc( SwDoc* pInsDoc, OTextCursorHelper* pxCursor, SwXTe } } if (!pPam) { return false; } - bRet = pDoc->getIDocumentContentOperations().CopyRange( *pPam, aPos, false ) || bRet; + bRet = pDoc->getIDocumentContentOperations().CopyRange( *pPam, aPos, /*bCopyAll=*/false, /*bCheckPos=*/true ) || bRet; } pInsDoc->getIDocumentFieldsAccess().UnlockExpFlds(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits