[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sw/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Tue Feb 23 11:28:58 UTC 2021
sw/source/uibase/dochdl/swdtflvr.cxx | 48 ++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 23 deletions(-)
New commits:
commit 70bc089fe9bec46ef4ca0417518ee06302c65f4c
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Feb 23 10:04:03 2021 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Feb 23 12:28:21 2021 +0100
sw lok: simplify SwTransferable::isComplex()
Commit 169a87563a3940299811d874b4df0ad13591771c (LOK: Implement
getSelectionType, 2019-06-24) implemented detecting complex selections
by copying the selection to a new SwDoc, which probably had two
benefits: first, the created SwPaM instance didn't touch the document;
second, this means no bounds has to be set when scanning nodes: the
entire document is the selection.
Later commit 7fe30d1cb00c576469d6cbe5606268a9cdf35bd3 (LOK: detect
Graphics in isComplex for Writer, 2019-06-25) got rid of the SwPaM
(which would register itself into text nodes), so now it's possible to
not touch the document, even if we work on the original document.
Instead, solve the partial scanning by iterating over the list of
selections. This is meant to be faster, and also less likely to crash in
case some internal document model invariant is broken.
No testcase, testComplexSelection in CppunitTest_desktop_lib already
covers thie behavior.
(cherry picked from commit 7a8dc25defee31edbb75a2f8c35f92ee2d3f3a83)
Conflicts:
sw/source/uibase/dochdl/swdtflvr.cxx
Change-Id: Ia528c06a48defd06c5e34ed7d61621e5ce10bb06
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111385
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index a58d4140ccd1..187332ba64f3 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -134,6 +134,7 @@
#include <iodetect.hxx>
#include <unotextrange.hxx>
#include <unoframe.hxx>
+#include <txatbase.hxx>
#include <vcl/uitest/logger.hxx>
#include <vcl/uitest/eventdescription.hxx>
@@ -434,33 +435,34 @@ namespace
sal_Bool SAL_CALL SwTransferable::isComplex()
{
- // Copy into a new Doc so we don't mess with the existing one.
- //FIXME: We *should* be able to avoid this and improve the performance.
- m_pClpDocFac.reset(new SwDocFac);
- SwDoc* const pTmpDoc = lcl_GetDoc(*m_pClpDocFac);
-
- pTmpDoc->getIDocumentFieldsAccess()
- .LockExpFields(); // never update fields - leave text as it is
- lclOverWriteDoc(*m_pWrtShell, *pTmpDoc);
-
sal_Int32 nTextLength = 0;
- const SwNode* pEndOfContent = &m_pWrtShell->GetDoc()->GetNodes().GetEndOfContent();
- SwNodes& aNodes = pTmpDoc->GetNodes();
- for( sal_uLong nIndex = 0; nIndex < aNodes.Count(); ++nIndex)
+ SwNodes& aNodes = m_pWrtShell->GetDoc()->GetNodes();
+ for (SwPaM& rPaM : m_pWrtShell->GetCursor()->GetRingContainer())
{
- SwNode& rNd = *aNodes[nIndex];
- if (&rNd == pEndOfContent)
- break;
+ for (sal_uLong nIndex = rPaM.GetMark()->nNode.GetIndex();
+ nIndex <= rPaM.GetPoint()->nNode.GetIndex(); ++nIndex)
+ {
+ SwNode& rNd = *aNodes[nIndex];
- if (rNd.IsOLENode() || rNd.IsGrfNode())
- return true; // Complex
+ SwTextNode* pTextNode = rNd.GetTextNode();
+ if (pTextNode)
+ {
+ if (pTextNode->HasHints())
+ {
+ for (size_t nHint = 0; pTextNode->GetSwpHints().Count(); ++nHint)
+ {
+ SwTextAttr* pHint = pTextNode->GetSwpHints().Get(nHint);
+ if (pHint->Which() == RES_TXTATR_FLYCNT)
+ {
+ return true; // Complex
+ }
+ }
+ }
- SwTextNode* pTextNode = rNd.GetTextNode();
- if (pTextNode)
- {
- nTextLength += pTextNode->GetText().getLength();
- if (nTextLength >= 1024 * 512)
- return true; // Complex
+ nTextLength += pTextNode->GetText().getLength();
+ if (nTextLength >= 1024 * 512)
+ return true; // Complex
+ }
}
}
More information about the Libreoffice-commits
mailing list