diff options
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/global.hxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/tiledrendering/tiledrendering.cxx | 28 | ||||
-rw-r--r-- | sc/source/core/data/global.cxx | 11 |
3 files changed, 39 insertions, 2 deletions
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index 089611e5ee6b..e140a7fb6ef0 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -575,7 +575,7 @@ public: * Open the specified URL. * @param bIgnoreSettings - If true, ignore security settings (Ctrl-Click) and just open the URL. */ - static void OpenURL(const OUString& rURL, const OUString& rTarget, bool bIgnoreSettings = false); + SC_DLLPUBLIC static void OpenURL(const OUString& rURL, const OUString& rTarget, bool bIgnoreSettings = false); /// Whether the URL can be opened according to current security options (Click/Ctrl-Click) static bool ShouldOpenURL(); SC_DLLPUBLIC static OUString GetAbsDocName( const OUString& rFileName, diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 27950831a1f3..d72cb6457fb4 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -435,6 +435,7 @@ public: TextSelectionMessage m_aTextSelectionResult; OString m_sInvalidateHeader; OString m_sInvalidateSheetGeometry; + OString m_aHyperlinkClicked; OString m_ShapeSelection; TestLokCallbackWrapper m_callbackWrapper; @@ -571,6 +572,11 @@ public: m_aInvalidateCursorResult.parseMessage(pPayload); } break; + case LOK_CALLBACK_HYPERLINK_CLICKED: + { + m_aHyperlinkClicked = pPayload; + } + break; case LOK_CALLBACK_TEXT_SELECTION: { m_aTextSelectionResult.parseMessage(pPayload); @@ -3113,6 +3119,28 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testGetViewRenderState) CPPUNIT_ASSERT_EQUAL(";Default"_ostr, pModelObj->getViewRenderState()); } +CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testOpenURL) +{ + // Given a document that has 2 views: + createDoc("empty.ods"); + int nView1 = SfxLokHelper::getView(); + ViewCallback aView1; + SfxLokHelper::createView(); + ViewCallback aView2; + + // When clicking on a link in view 2, but switching to view 1 before processing async events: + ScGlobal::OpenURL(/*aUrl=*/u"http://www.example.com/"_ustr, /*aTarget=*/u""_ustr, + /*bIgnoreSettings=*/true); + SfxLokHelper::setView(nView1); + Scheduler::ProcessEventsToIdle(); + + // Then make sure view 2 gets the callback, not view 1: + // Without the accompanying fix in place, this test would have failed, view 1 got the hyperlink + // callback. + CPPUNIT_ASSERT(aView1.m_aHyperlinkClicked.isEmpty()); + CPPUNIT_ASSERT(!aView2.m_aHyperlinkClicked.isEmpty()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index 29a616c6b6e8..15fdc7dfb39d 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -879,8 +879,17 @@ void ScGlobal::OpenURL(const OUString& rURL, const OUString& rTarget, bool bIgno SfxBoolItem aBrowsing( SID_BROWSE, true ); // No SID_SILENT anymore + SfxCallMode nCall = SfxCallMode::RECORD; + if (comphelper::LibreOfficeKit::isActive()) + { + nCall |= SfxCallMode::SYNCHRON; + } + else + { + nCall |= SfxCallMode::ASYNCHRON; + } pViewFrm->GetDispatcher()->ExecuteList(SID_OPENDOC, - SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, + nCall, { &aUrl, &aTarget, &aFrm, &aReferer, &aNewView, &aBrowsing }); } |