sw: GetSelectableFromAny() broken for SwXTextRange
The function unnecessarily uses an intermediate XUnoTunnel variable to
handle SwXTextRange, but the implementation of XUnoTunnel was removed.
(regression from commit 635448a996714a81cb15b41ac4bb0c73cabfb74f)
Change-Id: I90dd7acbd259e8ca562a534ad0bc9a5b85356553
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165162
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx
index 381fe0d..3e52b12 100644
--- a/sw/qa/core/unocore/unocore.cxx
+++ b/sw/qa/core/unocore/unocore.cxx
@@ -78,6 +78,33 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testTdf119081)
CPPUNIT_ASSERT_EQUAL(OUString("x"), pWrtShell->GetCurrentShellCursor().GetText());
}
CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, selectTextRange)
{
createSwDoc();
uno::Reference<text::XTextDocument> const xTD(mxComponent, uno::UNO_QUERY_THROW);
uno::Reference<text::XText> const xText(xTD->getText());
uno::Reference<text::XTextCursor> const xCursor(xText->createTextCursor());
xText->insertString(xCursor, "test", /*bAbsorb=*/false);
xCursor->gotoStart(false);
xCursor->gotoEnd(true);
CPPUNIT_ASSERT_EQUAL(OUString("test"), xCursor->getString());
uno::Reference<lang::XMultiServiceFactory> const xMSF(mxComponent, uno::UNO_QUERY_THROW);
uno::Reference<text::XTextSection> const xSection(
xMSF->createInstance("com.sun.star.text.TextSection"), uno::UNO_QUERY_THROW);
xText->insertTextContent(xCursor, xSection, true);
uno::Reference<text::XTextRange> const xAnchor(xSection->getAnchor());
uno::Reference<view::XSelectionSupplier> const xView(xTD->getCurrentController(),
uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("test"), xAnchor->getString());
CPPUNIT_ASSERT(xView->select(uno::Any(xAnchor)));
uno::Reference<container::XIndexAccess> xSel;
CPPUNIT_ASSERT(xView->getSelection() >>= xSel);
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSel->getCount());
uno::Reference<text::XTextRange> xSelRange;
CPPUNIT_ASSERT(xSel->getByIndex(0) >>= xSelRange);
CPPUNIT_ASSERT_EQUAL(OUString("test"), xSelRange->getString());
}
CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, flyAtParaAnchor)
{
createSwDoc();
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx
index 5f3c88f..9821f94 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -226,7 +226,7 @@ void GetSelectableFromAny(uno::Reference<uno::XInterface> const& xIfc,
return;
}
uno::Reference<text::XTextRange> const xTextRange(xTunnel, UNO_QUERY);
uno::Reference<text::XTextRange> const xTextRange(xIfc, UNO_QUERY);
if (xTextRange.is())
{
SwUnoInternalPaM aPam(rTargetDoc);