From 44f6329330e8c8f000cb310b04ac13777e8bfff3 Mon Sep 17 00:00:00 2001 From: Ashod Nakashian Date: Fri, 24 Jul 2020 11:33:46 -0400 Subject: sfx2: lok: refactor notifications and const correctness This reduces the stringification and reuses the notificaiton helpers to reduce code duplication. Change-Id: Icf9f9c50f3eeee61a0ded741d39fed37cfcc8da1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99972 Tested-by: Jenkins CollaboraOffice Reviewed-by: Ashod Nakashian Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106221 Tested-by: Jenkins Reviewed-by: Tor Lillqvist --- include/sfx2/lokhelper.hxx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index 79052a0d6e04..2aad968681b8 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -51,7 +51,7 @@ public: /// Set a view shell as current one. static void setView(int nId); /// Get the currently active view. - static int getView(SfxViewShell* pViewShell = nullptr); + static int getView(const SfxViewShell* pViewShell = nullptr); /// Get the number of views of the current object shell. static std::size_t getViewsCount(); /// Get viewIds of views of the current object shell. @@ -72,17 +72,24 @@ public: static LOKDeviceFormFactor getDeviceFormFactor(); /// Set the device form factor that should be used for a new view. static void setDeviceFormFactor(const OUString& rDeviceFormFactor); + /// Iterate over any view shell, except pThisViewShell, passing it to the f function. template static void forEachOtherView(ViewShellType* pThisViewShell, FunctionType f); + /// Invoke the LOK callback of all other views showing the same document as pThisView, with a payload of rKey-rPayload. - static void notifyOtherViews(SfxViewShell* pThisView, int nType, const OString& rKey, const OString& rPayload); + static void notifyOtherViews(const SfxViewShell* pThisView, int nType, const OString& rKey, + const OString& rPayload); /// Invoke the LOK callback of all views except pThisView, with a JSON payload created from the given property tree. - static void notifyOtherViews(SfxViewShell* pThisView, int nType, const boost::property_tree::ptree& rTree); + static void notifyOtherViews(const SfxViewShell* pThisView, int nType, + const boost::property_tree::ptree& rTree); /// Same as notifyOtherViews(), but works on a selected "other" view, not on all of them. - static void notifyOtherView(SfxViewShell* pThisView, SfxViewShell const* pOtherView, int nType, const OString& rKey, const OString& rPayload); + static void notifyOtherView(const SfxViewShell* pThisView, SfxViewShell const* pOtherView, + int nType, const OString& rKey, const OString& rPayload); /// Same as notifyOtherViews(), the property-tree version, but works on a selected "other" view, not on all of them. - static void notifyOtherView(SfxViewShell* pThisView, SfxViewShell const* pOtherView, int nType, const boost::property_tree::ptree& rTree); + static void notifyOtherView(const SfxViewShell* pThisView, SfxViewShell const* pOtherView, + int nType, const boost::property_tree::ptree& rTree); + /// Emits a LOK_CALLBACK_STATE_CHANGED static void sendUnoStatus(const SfxViewShell* pShell, const SfxPoolItem* pItem); /// Emits a LOK_CALLBACK_WINDOW -- cgit v1.2.3