diff options
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 5 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 7 | ||||
-rw-r--r-- | include/vcl/ITiledRenderable.hxx | 5 | ||||
-rw-r--r-- | sw/inc/unotxdoc.hxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 10 |
5 files changed, 28 insertions, 1 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 5585ec600e91..4d13bb33749f 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 9ac9347d35c0..85ed95d17dc6 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 5b3d4681088a..3301b7754f15 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 31ef514ab73b..f34d0a9172a4 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 d7e7b3fd88f1..a8eec89917dc 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; |