sfx2/source/view/lokhelper.cxx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
New commits: commit 0d8572fd7c065a4497080ae8db738c555225f67a Author: Caolán McNamara <[email protected]> AuthorDate: Wed Nov 5 10:57:28 2025 +0000 Commit: Miklos Vajna <[email protected]> CommitDate: Fri Nov 7 14:23:00 2025 +0100 assert on creating a new view that there is an XInteractionHandler we install one when we create a document, so detect if that was removed by something, which has happened historically on save, or export of a selected element, but we want the original XInteractionHandler to be restored when those complete. Change-Id: I0886dd038a9167fd1b53e0b382fd52e6cb8a7610 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193455 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 31303a95a781..5466d2a0fd20 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -36,6 +36,7 @@ #include <vcl/window.hxx> #include <sal/log.hxx> #include <sfx2/app.hxx> +#include <sfx2/docfile.hxx> #include <sfx2/msg.hxx> #include <sfx2/viewsh.hxx> #include <sfx2/request.hxx> @@ -100,10 +101,30 @@ const std::size_t g_logNotifierCacheMaxSize = 50; ::std::list<::std::string> g_logNotifierCache; } +#if !defined NDEBUG +static bool isSfxMediumMissingInteractionHandled(SfxViewFrame& rViewFrame) +{ + const SfxObjectShell* pObjSh = rViewFrame.GetObjectShell(); + const SfxMedium* pMed = pObjSh ? pObjSh->GetMedium() : nullptr; + if (!pMed) + { + // In this unlikely case it's not going to matter. + return false; + } + const SfxUnoAnyItem *pItem = pMed->GetItemSet().GetItemIfSet(SID_INTERACTIONHANDLER, false); + return !pItem || !pItem->GetValue().hasValue(); +} +#endif + int SfxLokHelper::createView(SfxViewFrame& rViewFrame, ViewShellDocId docId) { assert(docId >= ViewShellDocId(0) && "Cannot createView for invalid (negative) DocId."); + // The XInteractionHandler installed during the original lo_documentLoad + // should still be present when new views are created. If it is not + // something has likely cleared the original SID_INTERACTIONHANDLER + assert(!isSfxMediumMissingInteractionHandled(rViewFrame) && "original XInteractionHandler missing"); + SfxViewShell::SetCurrentDocId(docId); SfxRequest aRequest(rViewFrame, SID_NEWWINDOW); rViewFrame.ExecView_Impl(aRequest);
