summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2020-06-02 12:46:51 +0300
committerTor Lillqvist <tml@collabora.com>2020-06-24 13:28:33 +0200
commit3d9e60524fcb4d62fbf17af0ccd1f9613b1b8470 (patch)
tree45a34362940690ac0e050ce5a698fb2746bf4b6c /include
parentdc13c656dc25ed35c31bec7b6c8ae7d0c6b258e3 (diff)
tdf#128502: Try to support multiple documents in LibreOfficeKit-using process
The LibreOfficeKit-specific code typically has assumed that all the "views" (SfxViewShell instances) are for the same document, because all LibreOfficeKit-based application processes (including the "kit" processes in Online and the iOS app) so far have only had one document open at a time. It is now possible to pass several document file names on the command line to gtktiledviewer and that is an easy way to demonstrate how badly it still works even with this patch. Introduce a unique numeric document id that is increased in the LibLODocument_Impl constructor. Add APIs to access that. When iterating over views, try to skip views that are not of the document visible in the "current" view, if we know what the "current" view is. Also add a couple of FIXMEs at places where it is a bit unclear (to me) whether it is correct to iterate over all views, or whether only views for the "current" document are what we would want. Change-Id: Id5ebb92a115723cdeb23907163d5b5f282016252 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95353 Tested-by: Jenkins Reviewed-by: Tor Lillqvist <tml@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96356 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'include')
-rw-r--r--include/editeng/outliner.hxx2
-rw-r--r--include/sfx2/lokhelper.hxx12
-rw-r--r--include/sfx2/viewsh.hxx2
-rw-r--r--include/svl/undo.hxx2
4 files changed, 14 insertions, 4 deletions
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index 68b13a311f36..05a1aae85851 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -376,6 +376,8 @@ class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI OutlinerViewShell
public:
virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) const = 0;
virtual ViewShellId GetViewShellId() const = 0;
+ virtual void SetDocId(ViewShellDocId nId) = 0;
+ virtual ViewShellDocId GetDocId() const = 0;
/// Wrapper around SfxLokHelper::notifyOtherViews().
virtual void NotifyOtherViews(int nType, const OString& rKey, const OString& rPayload) = 0;
/// Wrapper around SfxLokHelper::notifyOtherView().
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 63c88b988b2e..d88ae25adcff 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -53,8 +53,12 @@ public:
static int getView(SfxViewShell* pViewShell = nullptr);
/// Get the number of views of the current object shell.
static std::size_t getViewsCount();
- /// Get viewIds of all existing views.
+ /// Get viewIds of views of the current object shell.
static bool getViewIds(int* pArray, size_t nSize);
+ /// Set the document id of the currently active view
+ static void setDocumentIdOfView(int nId);
+ /// Get the document id for a view
+ static int getDocumentIdOfView(int nViewId);
/// Get the default language that should be used for views
static LanguageTag getDefaultLanguage();
/// Set language of the given view.
@@ -70,7 +74,7 @@ public:
/// Iterate over any view shell, except pThisViewShell, passing it to the f function.
template<typename ViewShellType, typename FunctionType>
static void forEachOtherView(ViewShellType* pThisViewShell, FunctionType f);
- /// Invoke the LOK callback of all views except pThisView, with a payload of rKey-rPayload.
+ /// 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);
/// 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);
@@ -83,7 +87,7 @@ public:
const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>());
/// Emits a LOK_CALLBACK_DOCUMENT_SIZE_CHANGED - if @bInvalidateAll - first invalidates all parts
static void notifyDocumentSizeChanged(SfxViewShell const* pThisView, const OString& rPayload, vcl::ITiledRenderable* pDoc, bool bInvalidateAll = true);
- /// Emits a LOK_CALLBACK_DOCUMENT_SIZE_CHANGED for all views - if @bInvalidateAll - first invalidates all parts
+ /// Emits a LOK_CALLBACK_DOCUMENT_SIZE_CHANGED for all views of the same document - if @bInvalidateAll - first invalidates all parts
static void notifyDocumentSizeChangedAllViews(vcl::ITiledRenderable* pDoc, bool bInvalidateAll = true);
/// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed.
static void notifyInvalidation(SfxViewShell const* pThisView, const OString& rPayload);
@@ -118,7 +122,7 @@ void SfxLokHelper::forEachOtherView(ViewShellType* pThisViewShell, FunctionType
while (pViewShell)
{
auto pOtherViewShell = dynamic_cast<ViewShellType*>(pViewShell);
- if (pOtherViewShell != nullptr && pOtherViewShell != pThisViewShell)
+ if (pOtherViewShell != nullptr && pOtherViewShell != pThisViewShell && pOtherViewShell->GetDocId() == pThisViewShell->GetDocId())
{
f(pOtherViewShell);
}
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index 6628b7f822aa..a54909ace2b5 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -341,6 +341,8 @@ public:
virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const;
/// See OutlinerViewShell::GetViewShellId().
ViewShellId GetViewShellId() const override;
+ void SetDocId(ViewShellDocId nId) override;
+ ViewShellDocId GetDocId() const override;
/// See OutlinerViewShell::NotifyOtherViews().
void NotifyOtherViews(int nType, const OString& rKey, const OString& rPayload) override;
/// See OutlinerViewShell::NotifyOtherView().
diff --git a/include/svl/undo.hxx b/include/svl/undo.hxx
index c2862b886c6f..1ca989fd4a5d 100644
--- a/include/svl/undo.hxx
+++ b/include/svl/undo.hxx
@@ -28,6 +28,8 @@
#include <vector>
typedef o3tl::strong_int<sal_Int32, struct ViewShellIdTag> ViewShellId;
+typedef o3tl::strong_int<int, struct ViewShellDocIdTag> ViewShellDocId;
+
class SVL_DLLPUBLIC SfxRepeatTarget
{