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-20 11:02:04 +0100
commit155956a22846ba7a65c2abe2a0aa9d62cc860cf7 (patch)
treef66c21a69d7a0667cb8cfa44f131fa9694ceec3f
parent19ca75ec8e27a6651e36f2578bfa77de587899a5 (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 a118cac1833b..705ef3f1fc0b 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 3cc08cbfe741..dd223890464b 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 = 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 )