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-09 17:24:17 +0200
commita22cba07a470385dcb930c56c90cba81b317773e (patch)
treefb198486ab849c2c5f99f4bc5aeb56177de53d73 /desktop
parentdadba793c107cbf2ccadfbd7b41b6187ff06d4b8 (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>
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 568c1fe9e3e1..69dd6103a5bd 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 5a9bd8c94a85..1b8013350983 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1173,8 +1173,9 @@ rtl::Reference<LOKClipboard> forceSetClipboardForCurrentView(LibreOfficeKitDocum
} // 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)
{
m_pDocumentClass = gDocumentClass.lock();
if (!m_pDocumentClass)
@@ -2114,6 +2115,8 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis,
SolarMutexGuard aGuard;
+ static int nDocumentIdCounter = 0;
+
LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
pLib->maLastExceptionMsg.clear();
@@ -2210,7 +2213,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);
@@ -3081,7 +3087,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;