diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-10-26 11:28:55 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-10-26 13:38:33 +0100 |
commit | 7efbbe98d7fe951909234dcacd37f67975f00da2 (patch) | |
tree | 997e4823038a31d2a685a27fb6b0d6cd6a19b7da /desktop | |
parent | 2e61410d2545c1dee0c5aad4ea01b29f0a907e61 (diff) |
lok::Document::paste: check if the given mime type is supported
Change-Id: Ib59ea43700815c53cdd4be819e2e9cf35c6f89e9
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 5 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 7 |
2 files changed, 11 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)) |