include/sfx2/lokhelper.hxx | 3 +++ sfx2/source/view/lokhelper.cxx | 20 +++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-)
New commits: commit b978634572fe5cf5dd2f8f1a144a757d0774755a Author: Caolán McNamara <[email protected]> AuthorDate: Wed Jul 23 16:46:41 2025 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Mon Jul 28 09:50:27 2025 +0200 split ambiguous SfxLokHelper::getView into unambiguous parts keep the original for the moment Change-Id: I3832a1ebce9ac93f77fdf0d32fbdaae65538b5e6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188273 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index a3db5bada7d6..e4b5dba73428 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -103,7 +103,10 @@ public: static void setEditMode(int nMode, vcl::ITiledRenderable* pDoc); /// Get view shell with id static SfxViewShell* getViewOfId(int nId); + /// Get view id of view shell + static int getView(const SfxViewShell& rViewShell); /// Get the currently active view. + static int getCurrentView(); static int getView(const SfxViewShell* pViewShell = nullptr); /// Get the number of views of the current DocId. static std::size_t getViewsCount(int nDocId); diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index d9184e33e5bb..0483099993b0 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -245,15 +245,25 @@ SfxViewShell* SfxLokHelper::getViewOfId(int nId) return nullptr; } -int SfxLokHelper::getView(const SfxViewShell* pViewShell) +int SfxLokHelper::getView(const SfxViewShell& rViewShell) { - if (!pViewShell) - pViewShell = SfxViewShell::Current(); - // Still no valid view shell? Then no idea. + return static_cast<sal_Int32>(rViewShell.GetViewShellId()); +} + +int SfxLokHelper::getCurrentView() +{ + SfxViewShell* pViewShell = SfxViewShell::Current(); + // No valid view shell? Then no idea. if (!pViewShell) return -1; + return SfxLokHelper::getView(*pViewShell); +} - return static_cast<sal_Int32>(pViewShell->GetViewShellId()); +int SfxLokHelper::getView(const SfxViewShell* pViewShell) +{ + if (pViewShell) + return SfxLokHelper::getView(*pViewShell); + return SfxLokHelper::getCurrentView(); } std::size_t SfxLokHelper::getViewsCount(int nDocId)
