summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-04-08 09:07:07 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-04-08 18:39:54 +0000
commitb23d55ccc24a37c60d39061a4e497181b9609e9b (patch)
treeef2229daa31bbe5d1dc53c48c84d8c7b2bfbb4e8 /sw
parent098d08d6af951afa4f20f6f7883f6c9d34e87e11 (diff)
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 <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/IDocumentContentOperations.hxx7
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx4
-rw-r--r--sw/source/core/doc/doccomp.cxx4
-rw-r--r--sw/source/core/doc/docglos.cxx2
-rw-r--r--sw/source/core/doc/doclay.cxx3
-rw-r--r--sw/source/core/doc/docnew.cxx2
-rw-r--r--sw/source/core/doc/docnum.cxx2
-rw-r--r--sw/source/core/doc/docredln.cxx4
-rw-r--r--sw/source/core/docnode/section.cxx3
-rw-r--r--sw/source/core/edit/acorrect.cxx2
-rw-r--r--sw/source/core/edit/eddel.cxx2
-rw-r--r--sw/source/core/edit/edglss.cxx6
-rw-r--r--sw/source/core/frmedt/fecopy.cxx4
-rw-r--r--sw/source/core/inc/DocumentContentOperationsManager.hxx2
-rw-r--r--sw/source/core/undo/untblk.cxx2
-rw-r--r--sw/source/core/unocore/unotext.cxx2
-rw-r--r--sw/source/filter/ww8/ww8glsy.cxx2
-rw-r--r--sw/source/filter/xml/xmltbli.cxx2
-rw-r--r--sw/source/uibase/uno/unoatxt.cxx2
19 files changed, 31 insertions, 26 deletions
diff --git a/sw/inc/IDocumentContentOperations.hxx b/sw/inc/IDocumentContentOperations.hxx
index 38c900a92825..9a866e600d4a 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 136d3c6490f9..e940caf60a96 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 aab09cc90c96..c9d59c971447 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 894c631994b2..a5299483e3f2 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 a9e82f90b9d0..c1a16273b933 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 b45451f2147c..3830d107c4e3 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 40a35c9a226c..1f45c4927f0d 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 edc074a1c432..4488e4944a4b 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 70bb3b89302c..00e52c0fe3c3 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 6a032ce5d1ae..cc879ba8482d 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 b5f2db961c2e..0cbd8f22c931 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 80c5729906f1..63bcf4e1911b 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 bf37b0806991..0e36a90abc63 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 c2e72fc76976..f2ad52b9c1f2 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 52611e56626b..7490daec5780 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 6d6c74233013..3374de07a4e5 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 e77e9fa7c30e..a92c548eb61d 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 46b098be870c..42b9437aa075 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 497b95df2df3..6eca90ae8e04 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();