desktop/qa/desktop_lib/test_desktop_lib.cxx | 5 ++++- desktop/source/lib/init.cxx | 7 +++++++ include/vcl/ITiledRenderable.hxx | 3 +++ sc/inc/docuno.hxx | 3 +++ sc/source/ui/unoobj/docuno.cxx | 13 +++++++++++++ sd/source/ui/inc/unomodel.hxx | 2 ++ sd/source/ui/unoidl/unomodel.cxx | 11 +++++++++++ sw/inc/unotxdoc.hxx | 2 ++ sw/source/uibase/uno/unotxdoc.cxx | 12 ++++++++++++ 9 files changed, 57 insertions(+), 1 deletion(-)
New commits: commit 5b4c29b1b15dcebfe4e76aaa8bdb2dd45e2b67f3 Author: Miklos Vajna <[email protected]> Date: Mon Oct 26 13:42:02 2015 +0100 sc: implement vcl::ITiledRenderable::isMimeTypeSupported() Change-Id: I0b9de068ddf0f4ff92d8fbf003b7529516f1f80a diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx index 3301b77..4fa2338 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 3369cbe..92cf89f 100644 --- a/sc/inc/docuno.hxx +++ b/sc/inc/docuno.hxx @@ -415,6 +415,9 @@ public: /// @see vcl::ITiledRenderable::getWindow(). virtual vcl::Window* getWindow() override; + + /// @see vcl::ITiledRenderable::isMimeTypeSupported(). + virtual bool isMimeTypeSupported() override; }; class ScDrawPagesObj : public cppu::WeakImplHelper< diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index cfd7957..d89d0ae 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -856,6 +856,19 @@ vcl::Window* ScModelObj::getWindow() 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 a8eec89..d414582 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3191,6 +3191,8 @@ vcl::Window* SwXTextDocument::getWindow() bool SwXTextDocument::isMimeTypeSupported() { + SolarMutexGuard aGuard; + SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); if (!pWrtShell) return false; commit b08546eb23aa8dfc2f139731f800031f147e32d7 Author: Miklos Vajna <[email protected]> Date: Mon Oct 26 11:41:54 2015 +0100 sd: implement vcl::ITiledRenderable::isMimeTypeSupported() Change-Id: I528ac9f9f687d2940c6477b1d33264f1e523051f diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx index 0042826..03dc445 100644 --- a/sd/source/ui/inc/unomodel.hxx +++ b/sd/source/ui/inc/unomodel.hxx @@ -261,6 +261,8 @@ public: virtual void resetSelection() override; /// @see vcl::ITiledRenderable::getWindow(). virtual vcl::Window* getWindow() override; + /// @see vcl::ITiledRenderable::isMimeTypeSupported(). + virtual bool isMimeTypeSupported() override; // XComponent diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 8580fea..8c3d0a3 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -2544,6 +2544,17 @@ vcl::Window* SdXImpressDocument::getWindow() return pViewShell->GetActiveWindow(); } +bool SdXImpressDocument::isMimeTypeSupported() +{ + SolarMutexGuard aGuard; + DrawViewShell* pViewShell = GetViewShell(); + if (!pViewShell) + return false; + + TransferableDataHelper aDataHelper(TransferableDataHelper::CreateFromSystemClipboard(pViewShell->GetActiveWindow())); + return EditEngine::HasValidData(aDataHelper.GetTransferable()); +} + uno::Reference< i18n::XForbiddenCharacters > SdXImpressDocument::getForbiddenCharsTable() { uno::Reference< i18n::XForbiddenCharacters > xForb(mxForbidenCharacters); commit 7efbbe98d7fe951909234dcacd37f67975f00da2 Author: Miklos Vajna <[email protected]> Date: Mon Oct 26 11:28:55 2015 +0100 lok::Document::paste: check if the given mime type is supported Change-Id: Ib59ea43700815c53cdd4be819e2e9cf35c6f89e9 diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 5585ec6..4d13bb33 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -331,12 +331,15 @@ void DesktopLOKTest::testPasteWriter() LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); OString aText("hello"); - pDocument->pClass->paste(pDocument, "text/plain;charset=utf-8", aText.getStr(), aText.getLength()); + CPPUNIT_ASSERT(pDocument->pClass->paste(pDocument, "text/plain;charset=utf-8", aText.getStr(), aText.getLength())); pDocument->pClass->postUnoCommand(pDocument, ".uno:SelectAll", 0); char* pText = pDocument->pClass->getTextSelection(pDocument, "text/plain;charset=utf-8", 0); CPPUNIT_ASSERT_EQUAL(OString("hello"), OString(pText)); free(pText); + + CPPUNIT_ASSERT(!pDocument->pClass->paste(pDocument, "textt/plain;charset=utf-8", aText.getStr(), aText.getLength())); + comphelper::LibreOfficeKit::setActive(false); } diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 9ac9347..85ed95d 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1017,6 +1017,13 @@ static bool doc_paste(LibreOfficeKitDocument* pThis, const char* pMimeType, cons } pWindow->SetClipboard(xClipboard); + if (!pDoc->isMimeTypeSupported()) + { + if (gImpl) + gImpl->maLastExceptionMsg = "Document doesn't support this mime type"; + return false; + } + OUString aCommand(".uno:Paste"); uno::Sequence<beans::PropertyValue> aPropertyValues; if (!comphelper::dispatchCommand(aCommand, aPropertyValues)) diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx index 5b3d468..3301b77 100644 --- a/include/vcl/ITiledRenderable.hxx +++ b/include/vcl/ITiledRenderable.hxx @@ -150,6 +150,11 @@ public: /// Returns the current vcl::Window of the component. virtual vcl::Window* getWindow() = 0; + + virtual bool isMimeTypeSupported() + { + return false; + } }; } // namespace vcl diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 31ef514..f34d0a9 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -433,6 +433,8 @@ public: virtual OUString getPartPageRectangles() override; /// @see vcl::ITiledRenderable::getWindow(). virtual vcl::Window* getWindow() override; + /// @see vcl::ITiledRenderable::isMimeTypeSupported(). + virtual bool isMimeTypeSupported() override; // ::com::sun::star::tiledrendering::XTiledRenderable virtual void SAL_CALL paintTile( const ::css::uno::Any& Parent, ::sal_Int32 nOutputWidth, ::sal_Int32 nOutputHeight, ::sal_Int32 nTilePosX, ::sal_Int32 nTilePosY, ::sal_Int32 nTileWidth, ::sal_Int32 nTileHeight ) throw (::css::uno::RuntimeException, ::std::exception) override; diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index d7e7b3f..a8eec89 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3189,6 +3189,16 @@ vcl::Window* SwXTextDocument::getWindow() return &pDocShell->GetView()->GetEditWin(); } +bool SwXTextDocument::isMimeTypeSupported() +{ + SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); + if (!pWrtShell) + return false; + + TransferableDataHelper aDataHelper(TransferableDataHelper::CreateFromSystemClipboard(&pWrtShell->GetView().GetEditWin())); + return aDataHelper.GetXTransferable().is() && SwTransferable::IsPaste(*pWrtShell, aDataHelper); +} + int SwXTextDocument::getPart() { SolarMutexGuard aGuard; _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
