diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2019-06-25 23:45:37 -0400 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2019-08-02 11:41:49 -0400 |
commit | c3816a0c85839404d3042ce46635a11ada8a41e3 (patch) | |
tree | 51e7b1906456fd439f16d271f8596af891755a62 /sw/source/uibase/dochdl/swdtflvr.cxx | |
parent | ff90a487276fa98d1868fdeda4d14dceae5f75b5 (diff) |
LOK: Improved selection complexity detection
Only Graphics and OLE now unconditionally
trigger 'complex' case, and for all others,
we actually tally the number of text characters.
Currently anything above 512KB is flagged as 'complex'.
Change-Id: I19fbef72f2eb725648b2a18c1ee41b1612d2bac0
Diffstat (limited to 'sw/source/uibase/dochdl/swdtflvr.cxx')
-rw-r--r-- | sw/source/uibase/dochdl/swdtflvr.cxx | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index 223ed806bc32..798b3dd23e3a 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -421,15 +421,6 @@ namespace sal_Bool SwTransferable::isComplex() { - const SelectionType nSelectionType = m_pWrtShell->GetSelectionType(); - - // Anything other than text is complex by definition. - if (nSelectionType != SelectionType::Text) - return true; - - if (m_pWrtShell->IsFrameSelected() || m_pWrtShell->IsObjSelected()) - return true; - // 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); @@ -439,21 +430,29 @@ sal_Bool SwTransferable::isComplex() .LockExpFields(); // never update fields - leave text as it is lclOverWriteDoc(*m_pWrtShell, *pTmpDoc); - bool isComplex = false; + 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) { SwNode& rNd = *aNodes[nIndex]; - if (rNd.IsContentNode() && !rNd.IsTextNode()) - { - isComplex = true; + if (&rNd == pEndOfContent) break; + + if (rNd.IsOLENode() || rNd.IsGrfNode()) + return true; // Complex + + SwTextNode* pTextNode = rNd.GetTextNode(); + if (pTextNode) + { + nTextLength += pTextNode->GetText().getLength(); + if (nTextLength >= 1024 * 512) + return true; // Complex } - else if (&rNd == &m_pWrtShell->GetDoc()->GetNodes().GetEndOfContent()) - break; } - return isComplex; + // Simple + return false; } bool SwTransferable::GetData( const DataFlavor& rFlavor, const OUString& rDestDoc ) |