include/sfx2/sfxbasecontroller.hxx | 4 ++++ include/sfx2/viewsh.hxx | 1 + sfx2/source/view/sfxbasecontroller.cxx | 12 ++++++++++++ sfx2/source/view/viewsh.cxx | 5 +++++ starmath/inc/view.hxx | 1 + starmath/source/view.cxx | 21 +++++++++++++++++++++ 6 files changed, 44 insertions(+)
New commits: commit bb6c70f7a9af806347a1e1401a9cce2ad41bc81b Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Mon Aug 15 14:31:15 2022 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Wed Aug 17 07:19:01 2022 +0200 lok: register view callback also for nested sm view This allows to send context change events that originate in the embedded views. Change-Id: I574ca347a2ffa67f9645a2ee790e42088ad8721f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138303 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/include/sfx2/sfxbasecontroller.hxx b/include/sfx2/sfxbasecontroller.hxx index ac4950e5a45a..978cd5669d45 100644 --- a/include/sfx2/sfxbasecontroller.hxx +++ b/include/sfx2/sfxbasecontroller.hxx @@ -196,6 +196,10 @@ public: SAL_DLLPRIVATE bool HasMouseClickListeners_Impl() const; SAL_DLLPRIVATE void SetCreationArguments_Impl( const css::uno::Sequence< css::beans::PropertyValue >& i_rCreationArgs ); SAL_DLLPRIVATE css::uno::Reference< css::frame::XTitle > impl_getTitleHelper (); + +protected: + void CopyLokViewCallbackFromFrameCreator(); + private: enum ConnectSfxFrame { diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx index 3faf7aeb2071..ea431a687b49 100644 --- a/include/sfx2/viewsh.hxx +++ b/include/sfx2/viewsh.hxx @@ -342,6 +342,7 @@ public: /// Set up a more efficient internal callback instead of LibreOfficeKitCallback. void setLibreOfficeKitViewCallback(SfxLokCallbackInterface* pCallback); + SfxLokCallbackInterface* getLibreOfficeKitViewCallback() const; /// dump view state for diagnostics void dumpLibreOfficeKitViewState(rtl::OStringBuffer &rState); /// Invokes the registered callback, if there are any. diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx index e7c098fcda27..6db3b5570ec1 100644 --- a/sfx2/source/view/sfxbasecontroller.cxx +++ b/sfx2/source/view/sfxbasecontroller.cxx @@ -1021,6 +1021,18 @@ void SfxBaseController::ReleaseShell_Impl() attachFrame( aXFrame ); } +void SfxBaseController::CopyLokViewCallbackFromFrameCreator() +{ + if (!m_pData->m_pViewShell) + return; + SfxLokCallbackInterface* pCallback = nullptr; + if (m_pData->m_xFrame) + if (auto xCreator = m_pData->m_xFrame->getCreator()) + if (auto parentVS = SfxViewShell::Get(xCreator->getController())) + pCallback = parentVS->getLibreOfficeKitViewCallback(); + m_pData->m_pViewShell->setLibreOfficeKitViewCallback(pCallback); +} + SfxViewShell* SfxBaseController::GetViewShell_Impl() const { return m_pData->m_pViewShell; diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index d1f326c68b7f..bd04697fab89 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -1435,6 +1435,11 @@ void SfxViewShell::setLibreOfficeKitViewCallback(SfxLokCallbackInterface* pCallb } } +SfxLokCallbackInterface* SfxViewShell::getLibreOfficeKitViewCallback() const +{ + return pImpl->m_pLibreOfficeKitViewCallback; +} + void SfxViewShell::dumpLibreOfficeKitViewState(rtl::OStringBuffer &rState) { if (pImpl->m_pLibreOfficeKitViewCallback) diff --git a/starmath/inc/view.hxx b/starmath/inc/view.hxx index 45df0f425574..0a18e0084435 100644 --- a/starmath/inc/view.hxx +++ b/starmath/inc/view.hxx @@ -289,6 +289,7 @@ class SmViewShell final : public SfxViewShell virtual void OuterResizePixel(const Point &rOfs, const Size &rSize) override; virtual void QueryObjAreaPixel( tools::Rectangle& rRect ) const override; virtual void SetZoomFactor( const Fraction &rX, const Fraction &rY ) override; + virtual OString getLOKPayload(int nType, int nViewId, bool* ignore) const override; public: diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index 39676971a93f..add20227a808 100644 --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -32,6 +32,7 @@ #include <comphelper/storagehelper.hxx> #include <comphelper/string.hxx> #include <i18nutil/unicode.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <officecfg/Office/Common.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/docfile.hxx> @@ -2121,6 +2122,9 @@ public: { SfxBaseController::attachFrame(xFrame); + if (comphelper::LibreOfficeKit::isActive()) + CopyLokViewCallbackFromFrameCreator(); + // No need to call mpSelectionChangeHandler->Connect() unless SmController implements XSelectionSupplier mpSelectionChangeHandler->selectionChanged({}); // Installs the correct context } @@ -2271,4 +2275,21 @@ void SmViewShell::ZoomByItemSet(const SfxItemSet *pSet) } } +OString SmViewShell::getLOKPayload(int nType, int nViewId, bool* ignore) const +{ + switch (nType) + { + case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR: + case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR: + case LOK_CALLBACK_TEXT_SELECTION: + case LOK_CALLBACK_TEXT_SELECTION_START: + case LOK_CALLBACK_TEXT_SELECTION_END: + case LOK_CALLBACK_TEXT_VIEW_SELECTION: + if (ignore) + *ignore = true; + return {}; + } + return SfxViewShell::getLOKPayload(nType, nViewId, ignore); // aborts +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */