summaryrefslogtreecommitdiff
path: root/include/sfx2
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 14:29:35 +0200
commit984bd2d5e4e1277cab47f8c1053bdf9369b23935 (patch)
tree986c3a846e7310218409533670716aa5b18c42f5 /include/sfx2
parent13bcb15f359d2c616cc375a160a5474b230a66ab (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/+/97024 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'include/sfx2')
-rw-r--r--include/sfx2/lokhelper.hxx12
-rw-r--r--include/sfx2/viewsh.hxx2
2 files changed, 10 insertions, 4 deletions
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 89b4972d8914..032c656f1a4d 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -52,8 +52,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.
@@ -69,7 +73,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);
@@ -82,7 +86,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);
@@ -117,7 +121,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 f416dcf07706..e9964a20adfb 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -340,6 +340,8 @@ public:
virtual void dumpAsXml(xmlTextWriterPtr 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().