desktop/Library_sofficeapp.mk        |    2 +-
 desktop/source/lib/init.cxx          |   22 ++++++++++++++++++++++
 vcl/source/components/dtranscomp.cxx |    4 ++++
 3 files changed, 27 insertions(+), 1 deletion(-)

New commits:
commit 6bcf00763402fc0969486e852634b5559fa044ba
Author:     Tor Lillqvist <t...@iki.fi>
AuthorDate: Tue Jan 4 16:33:16 2022 +0200
Commit:     Tor Lillqvist <t...@collabora.com>
CommitDate: Thu Jan 6 13:52:00 2022 +0100

    We don't want or need any LOKClipboard on iOS
    
    Try to make the code more like in the co-2021 branch, where copy/paste
    between Collabora Office and other iOS apps currently works again, in
    both directions, both for text and images. Sadly something is broken
    or missing either here in core or in online as it doesn't fully work
    in a Collabora Office based on the master branch of core, even after
    this commit, though.
    
    We use only the system clipboard on iOS. (It is actually called the
    "pasteboard" in Apple's operating systems.) The code to interface with
    the system clipboard is in vcl. It has worked fine to copy and paste
    between the Collabora Office iOS app and other iOS apps without any
    LOKClipboard being involved. If LOKClipboard is used it doesn't work
    at all.
    
    Change-Id: I0d3b4e3eabe17b633390e071701225e1d356a75a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128037
    Reviewed-by: Tor Lillqvist <t...@collabora.com>
    Tested-by: Tor Lillqvist <t...@collabora.com>

diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index c9785eb059cf..d10c4f3c3403 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -132,7 +132,7 @@ ifneq ($(filter $(OS),ANDROID iOS MACOSX WNT),)
 $(eval $(call gb_Library_add_exception_objects,sofficeapp,\
        desktop/source/lib/init \
        desktop/source/lib/lokinteractionhandler \
-       $(if $(filter-out $(OS),IOS), \
+       $(if $(filter-out $(OS),iOS), \
                desktop/source/lib/lokclipboard) \
        $(if $(filter $(OS),ANDROID), \
                desktop/source/lib/lokandroid) \
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index fc43e606d7bb..407c1c0ebf33 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2352,7 +2352,9 @@ static void doc_destroy(LibreOfficeKitDocument *pThis)
 
     SolarMutexGuard aGuard;
 
+#ifndef IOS
     LOKClipboardFactory::releaseClipboardForView(-1);
+#endif
 
     LibLODocument_Impl *pDocument = static_cast<LibLODocument_Impl*>(pThis);
     delete pDocument;
@@ -4706,6 +4708,18 @@ static int doc_getClipboard(LibreOfficeKitDocument* 
pThis,
                             size_t     **pOutSizes,
                             char      ***pOutStreams)
 {
+#ifdef IOS
+    (void) pThis;
+    (void) pMimeTypes;
+    (void) pOutCount;
+    (void) pOutMimeTypes;
+    (void) pOutSizes;
+    (void) pOutStreams;
+
+    assert(!"doc_getClipboard should not be called on iOS");
+
+    return 0;
+#else
     comphelper::ProfileZone aZone("doc_getClipboard");
 
     SolarMutexGuard aGuard;
@@ -4782,6 +4796,7 @@ static int doc_getClipboard(LibreOfficeKitDocument* pThis,
     }
 
     return 1;
+#endif
 }
 
 static int doc_setClipboard(LibreOfficeKitDocument* pThis,
@@ -5529,7 +5544,9 @@ static void doc_destroyView(SAL_UNUSED_PARAMETER 
LibreOfficeKitDocument* pThis,
     SolarMutexGuard aGuard;
     SetLastExceptionMsg();
 
+#ifndef IOS
     LOKClipboardFactory::releaseClipboardForView(nId);
+#endif
 
     SfxLokHelper::destroyView(nId);
 
@@ -5796,6 +5813,7 @@ static void doc_postWindow(LibreOfficeKitDocument* 
/*pThis*/, unsigned nLOKWindo
     }
     else if (nAction == LOK_WINDOW_PASTE)
     {
+#ifndef IOS
         OUString aMimeType;
         css::uno::Sequence<sal_Int8> aData;
         std::vector<beans::PropertyValue> 
aArgs(jsonToPropertyValuesVector(pData));
@@ -5817,6 +5835,10 @@ static void doc_postWindow(LibreOfficeKitDocument* 
/*pThis*/, unsigned nLOKWindo
         }
         else
             SetLastExceptionMsg("Window command 'paste': wrong parameters.");
+#else
+        (void) pData;
+        assert(!"doc_postWindow() with LOK_WINDOW_PASTE should not be called 
on iOS");
+#endif
     }
 }
 
diff --git a/vcl/source/components/dtranscomp.cxx 
b/vcl/source/components/dtranscomp.cxx
index 645e50625ba3..acd03cc01912 100644
--- a/vcl/source/components/dtranscomp.cxx
+++ b/vcl/source/components/dtranscomp.cxx
@@ -416,6 +416,9 @@ Reference< XInterface > SalInstance::CreateClipboard( const 
Sequence< Any >& arg
         throw css::lang::IllegalArgumentException(
             "non-empty SalInstance::CreateClipboard arguments", {}, -1);
     }
+#ifdef IOS
+    return Reference< XInterface >( static_cast<cppu::OWeakObject *>(new 
vcl::GenericClipboard()) );
+#else
     if (comphelper::LibreOfficeKit::isActive()) {
         // In LOK, each document view shall have its own clipboard instance, 
and the way that
         // (happens to?) work is that apparently this function is called at 
most once for each such
@@ -425,6 +428,7 @@ Reference< XInterface > SalInstance::CreateClipboard( const 
Sequence< Any >& arg
         // SAL_USE_VCLPLUGIN=svp and the clipboard"):
         return Reference< XInterface >( static_cast<cppu::OWeakObject *>(new 
vcl::GenericClipboard()) );
     }
+#endif
     DBG_TESTSOLARMUTEX();
     if (!m_clipboard.is()) {
         m_clipboard = static_cast<cppu::OWeakObject *>(new 
vcl::GenericClipboard());

Reply via email to