summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2019-06-25 23:45:37 -0400
committerMichael Meeks <michael.meeks@collabora.com>2019-07-27 14:17:21 -0400
commit16e3c75fd8ec6f5d6df3dd83a58a3c54bce8a99e (patch)
treeeb57b9afdcdafeaec9701816af45cdf4f83cc7fa
parenta8223bde357c7d961df93ffe1097f40eb92605dd (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
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.hxx2
-rw-r--r--sw/source/uibase/dochdl/swdtflvr.cxx31
2 files changed, 16 insertions, 17 deletions
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index bd6609c321a4..517a38a50527 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -356,7 +356,7 @@ public:
*
* @return an element of the LibreOfficeKitSelectionType enum.
*/
- int getSelectionType(LibreOfficeKitDocument* /*pThis*/)
+ int getSelectionType()
{
return mpDoc->pClass->getSelectionType(mpDoc);
}
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 )