summaryrefslogtreecommitdiff
path: root/desktop
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 /desktop
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 'desktop')
-rw-r--r--desktop/inc/lib/init.hxx3
-rw-r--r--desktop/source/lib/init.cxx14
2 files changed, 13 insertions, 4 deletions
diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index 5957f56ed344..237a17a59eee 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -149,8 +149,9 @@ namespace desktop {
css::uno::Reference<css::lang::XComponent> mxComponent;
std::shared_ptr< LibreOfficeKitDocumentClass > m_pDocumentClass;
std::map<size_t, std::shared_ptr<CallbackFlushHandler>> mpCallbackFlushHandlers;
+ const int mnDocumentId;
- explicit LibLODocument_Impl(const css::uno::Reference <css::lang::XComponent> &xComponent);
+ explicit LibLODocument_Impl(const css::uno::Reference <css::lang::XComponent> &xComponent, int nDocumentId = -1);
~LibLODocument_Impl();
};
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 6afdd5fbe955..b34f814ff472 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1197,8 +1197,9 @@ VclPtr<Window> getSidebarWindow()
} // anonymous namespace
-LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent)
+LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent, int nDocumentId)
: mxComponent(xComponent)
+ , mnDocumentId(nDocumentId)
{
if (!(m_pDocumentClass = gDocumentClass.lock()))
{
@@ -2140,6 +2141,8 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis,
SolarMutexGuard aGuard;
+ static int nDocumentIdCounter = 0;
+
LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
pLib->maLastExceptionMsg.clear();
@@ -2236,7 +2239,10 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis,
return nullptr;
}
- LibLODocument_Impl* pDocument = new LibLODocument_Impl(xComponent);
+ LibLODocument_Impl* pDocument = new LibLODocument_Impl(xComponent, nDocumentIdCounter++);
+
+ // Do we know that after loading the document, its initial view is the "current" view?
+ SfxLokHelper::setDocumentIdOfView(pDocument->mnDocumentId);
if (pLib->mpCallback)
{
int nState = doc_getSignatureState(pDocument);
@@ -3127,7 +3133,9 @@ static void doc_paintPartTile(LibreOfficeKitDocument* pThis,
{
// tile painting always needs a SfxViewShell::Current(), but actually
// it does not really matter which one - all of them should paint the
- // same thing.
+ // same thing. It's important to get a view for the correct document,
+ // though.
+ // doc_getViewsCount() returns the count of views for the document in the current view.
int viewCount = doc_getViewsCount(pThis);
if (viewCount == 0)
return;