diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2024-07-15 14:40:24 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2024-07-15 17:11:00 +0200 |
commit | dc3e022866893d8c0950f2269c0c8d61c24ed9bf (patch) | |
tree | 329e54f0c782302eec2a0a06811829bf46fb518d /sw/source/uibase/dochdl | |
parent | 272f776b322cfd017506a6b67638ae7d2b83c014 (diff) |
cool#9504 sw: don't invalidate num rules when pasting into a non-num paragraph
The bugdoc has ~300 pages of content, most of that is bullets, but
otherwise not complex, pasting a trivial string at doc end (which is not
a bulleted paragraph) takes a noticeable time:
debug:20449:20330: SwLayAction::InternalAction: start
debug:20449:20330: SwLayAction::InternalAction: end, took 268 ms
Profiling points out that we re-layout the internal document, which is
not expected: we just pasted on the first page, causing no layout change
on page 2 and later pages. Watching who turns on m_bInvalidContent on
the page frames, it can be noticed that SwReader::Read() invalidates all
numberings after pasting.
Fix the problem by not doing that in case we paste plain text and we
know the insertion point is not in a numbering: the invalidation is not
useful in this case and fixes the unexpected delay.
Other related ideas are 1) don't do the layout for all pages in one go
2) recognize that the bullets need no invalidation, unlike an actual
numbering with numbers. Neither of these are done in this commit yet.
Change-Id: Id7b2c022b31acb358f42ddd77195db70ae451109
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170499
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/source/uibase/dochdl')
-rw-r--r-- | sw/source/uibase/dochdl/swdtflvr.cxx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index 29e3d74984be..e9cbe2fe675d 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -2152,11 +2152,22 @@ bool SwTransferable::PasteFileContent( const TransferableDataHelper& rData, SvStream* pStream = nullptr; Reader* pRead = nullptr; OUString sData; + bool bSkipInvalidateNumRules = false; switch( nFormat ) { case SotClipboardFormatId::STRING: { pRead = ReadAscii; + + const SwPosition& rInsertPosition = *rSh.GetCursor()->Start(); + SwTextNode* pTextNode = rInsertPosition.GetNode().GetTextNode(); + if (pTextNode && !pTextNode->GetNum()) + { + // Insertion point is not a numbering and we paste plain text: then no need to + // invalidate all numberings. + bSkipInvalidateNumRules = true; + } + if( rData.GetString( nFormat, sData ) ) { pStream = new SvMemoryStream( const_cast<sal_Unicode *>(sData.getStr()), @@ -2216,6 +2227,10 @@ bool SwTransferable::PasteFileContent( const TransferableDataHelper& rData, if (bIgnoreComments) pRead->SetIgnoreHTMLComments(true); + if (bSkipInvalidateNumRules) + { + aReader.SetSkipInvalidateNumRules(bSkipInvalidateNumRules); + } if( aReader.Read( *pRead ).IsError() ) pResId = STR_ERROR_CLPBRD_READ; |