Blob Blame History Raw
From ce5f6c1ac1880ff18eb3b663a2862f742a6ddad4 Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@collabora.co.uk>
Date: Mon, 26 Oct 2015 13:42:02 +0100
Subject: [PATCH 231/398] sc: implement
 vcl::ITiledRenderable::isMimeTypeSupported()

(cherry picked from commit 5b4c29b1b15dcebfe4e76aaa8bdb2dd45e2b67f3)

Change-Id: I0b9de068ddf0f4ff92d8fbf003b7529516f1f80a
---
 include/vcl/ITiledRenderable.hxx  |  6 ++----
 sc/inc/docuno.hxx                 |  8 +++++++-
 sc/source/ui/unoobj/docuno.cxx    | 24 ++++++++++++++++++++++++
 sw/source/uibase/uno/unotxdoc.cxx |  2 ++
 4 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 3301b7754f15..4fa23386bfbc 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -151,10 +151,8 @@ public:
     /// Returns the current vcl::Window of the component.
     virtual vcl::Window* getWindow() = 0;
 
-    virtual bool isMimeTypeSupported()
-    {
-        return false;
-    }
+    /// If the current contents of the clipboard is something we can paste.
+    virtual bool isMimeTypeSupported() = 0;
 };
 
 } // namespace vcl
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index cc132278bdf8..1e3aae1d302b 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -414,7 +414,13 @@ public:
     virtual void setGraphicSelection(int nType, int nX, int nY) SAL_OVERRIDE;
 
     /// @see lok::Document::resetSelection().
-    virtual void resetSelection() SAL_OVERRIDE;
+    virtual void resetSelection() override;
+
+    /// @see vcl::ITiledRenderable::getWindow().
+    virtual vcl::Window* getWindow() override;
+
+    /// @see vcl::ITiledRenderable::isMimeTypeSupported().
+    virtual bool isMimeTypeSupported() override;
 };
 
 class ScDrawPagesObj : public cppu::WeakImplHelper2<
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 958495f7ea7b..af6bd11ba742 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -846,6 +846,30 @@ void ScModelObj::resetSelection()
     pDocShell->GetDocument().GetDrawLayer()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, "");
 }
 
+vcl::Window* ScModelObj::getWindow()
+{
+    SolarMutexGuard aGuard;
+
+    ScViewData* pViewData = ScDocShell::GetViewData();
+    if (!pViewData)
+        return 0;
+
+    return pViewData->GetActiveWin();
+}
+
+bool ScModelObj::isMimeTypeSupported()
+{
+    SolarMutexGuard aGuard;
+
+    ScViewData* pViewData = ScDocShell::GetViewData();
+    if (!pViewData)
+        return 0;
+
+
+    TransferableDataHelper aDataHelper(TransferableDataHelper::CreateFromSystemClipboard(pViewData->GetActiveWin()));
+    return EditEngine::HasValidData(aDataHelper.GetTransferable());
+}
+
 void ScModelObj::initializeForTiledRendering()
 {
     SolarMutexGuard aGuard;
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 618e6b373162..68ec3df2a9c0 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3197,6 +3197,8 @@ vcl::Window* SwXTextDocument::getWindow()
 
 bool SwXTextDocument::isMimeTypeSupported()
 {
+    SolarMutexGuard aGuard;
+
     SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
     if (!pWrtShell)
         return false;
-- 
2.12.0