summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-06-19 11:16:21 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-06-19 15:06:25 +0200
commit0b532178a4936cb6014eba10aa6d5e1f33682e6e (patch)
tree4a07f81362b458b87daad7cf49c571472b78b21c /sw
parent340592693fd419e614df37fb957abb8306456cae (diff)
SwXTextDocument::getTextSelection: fix crash on unsupported mime type
SdXImpressDocument didn't have this problem, FWIW. Change-Id: Ic88311596b7b92a8e972f366b9e82cca850244f8
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx3
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx3
2 files changed, 6 insertions, 0 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 989e1c7bfb46..1006ef989fcd 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -221,6 +221,9 @@ void SwTiledRenderingTest::testGetTextSelection()
comphelper::LibreOfficeKit::setActive();
SwXTextDocument* pXTextDocument = createDoc("shape-with-text.fodt");
+ // No crash, just empty output for unexpected mime type.
+ CPPUNIT_ASSERT_EQUAL(OString(), pXTextDocument->getTextSelection("foo/bar"));
+
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
// Move the cursor into the first word.
pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false);
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index b2e6adb5656d..9c9f15fac0eb 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3295,6 +3295,9 @@ OString SwXTextDocument::getTextSelection(const char* pMimeType)
else
aFlavor.DataType = cppu::UnoType< uno::Sequence<sal_Int8> >::get();
+ if (!xTransferable->isDataFlavorSupported(aFlavor))
+ return OString();
+
uno::Any aAny(xTransferable->getTransferData(aFlavor));
OString aRet;