summaryrefslogtreecommitdiff
path: root/dtrans
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-05-29 18:15:30 +0200
committerAndras Timar <andras.timar@collabora.com>2020-06-11 13:17:16 +0200
commit3c9f3feaa4811125611316ef5345fa2a77e7e371 (patch)
tree53daf9f7c338b45b941e610110361220b6f5e1f0 /dtrans
parente855aab53c0674664f4296bf69d31910d55c0a10 (diff)
cache foreign content in win32 clipboard code (tdf#133267)
The slowness in tdf#133267 on Windows is because the Calc operation repeatedly calls ScDocument::IsClipboardSource(), which calls ScModule::GetClipDoc(), which proceeds to fetch the clipboard content, which means fetching it from the system clipboard if it's not owned by LO. Other LO clipboard implementations such as gtk3 or qt5 already do caching, and it seems that it's easy to do for the win32 code. Change-Id: I4696cc7488d66803fd5dd2963d27900957decdec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95163 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Luboš Luňák <l.lunak@collabora.com> (cherry picked from commit fda6ad1458fcd5087c3dde56300b9d0367af6db5) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95246 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> (cherry picked from commit 9b311cabd908c6bc9e7f7d461ee11eaf0ea6b18c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95749 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'dtrans')
-rw-r--r--dtrans/source/win32/clipb/WinClipbImpl.cxx12
-rw-r--r--dtrans/source/win32/clipb/WinClipbImpl.hxx1
2 files changed, 13 insertions, 0 deletions
diff --git a/dtrans/source/win32/clipb/WinClipbImpl.cxx b/dtrans/source/win32/clipb/WinClipbImpl.cxx
index 003a266f84bc..8d59be7ca430 100644
--- a/dtrans/source/win32/clipb/WinClipbImpl.cxx
+++ b/dtrans/source/win32/clipb/WinClipbImpl.cxx
@@ -83,6 +83,10 @@ Reference< XTransferable > CWinClipbImpl::getContents( )
return m_pCurrentClipContent->m_XTransferable;
}
+ // Content cached?
+ if (m_foreignContent.is())
+ return m_foreignContent;
+
// release the mutex, so that the variable may be
// changed by other threads
}
@@ -101,6 +105,9 @@ Reference< XTransferable > CWinClipbImpl::getContents( )
// remember pIDo destroys itself due to the smart pointer
rClipContent = CDOTransferable::create( m_pWinClipboard->m_xContext, pIDo );
+
+ MutexGuard aGuard(m_ClipContentMutex);
+ m_foreignContent = rClipContent;
}
return rClipContent;
@@ -117,6 +124,8 @@ void CWinClipbImpl::setContents(
{
MutexGuard aGuard(m_ClipContentMutex);
+ m_foreignContent.clear();
+
m_pCurrentClipContent
= new CXNotifyingDataObject(CDTransObjFactory::createDataObjFromTransferable(
m_pWinClipboard->m_xContext, xTransferable),
@@ -176,7 +185,10 @@ void WINAPI CWinClipbImpl::onClipboardContentChanged()
// reassociation to instance through static member
if ( nullptr != s_pCWinClipbImpl )
+ {
+ s_pCWinClipbImpl->m_foreignContent.clear();
s_pCWinClipbImpl->m_pWinClipboard->notifyAllClipboardListener( );
+ }
}
void CWinClipbImpl::onReleaseDataObject( CXNotifyingDataObject* theCaller )
diff --git a/dtrans/source/win32/clipb/WinClipbImpl.hxx b/dtrans/source/win32/clipb/WinClipbImpl.hxx
index 55a9d8d600bc..cd5878e6b794 100644
--- a/dtrans/source/win32/clipb/WinClipbImpl.hxx
+++ b/dtrans/source/win32/clipb/WinClipbImpl.hxx
@@ -87,6 +87,7 @@ private:
CMtaOleClipboard m_MtaOleClipboard;
CWinClipboard* m_pWinClipboard;
CXNotifyingDataObject* m_pCurrentClipContent;
+ com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable > m_foreignContent;
osl::Mutex m_ClipContentMutex;
static osl::Mutex s_aMutex;