[Libreoffice-commits] core.git: 23 commits - android/Bootstrap desktop/Library_sofficeapp.mk desktop/source libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk libreofficekit/Executable_lokconf_init.mk libreofficekit/Module_libreofficekit.mk libreofficekit/qa sd/source solenv/gbuild svx/source UnoControls/Makefile vcl/source

Tomaž Vajngerl tomaz.vajngerl at collabora.com
Thu Dec 4 03:23:25 PST 2014


 UnoControls/Makefile                                          |   14 -
 android/Bootstrap/Makefile.shared                             |    2 
 android/Bootstrap/src/org/libreoffice/kit/LibreOfficeKit.java |    8 -
 desktop/Library_sofficeapp.mk                                 |    8 +
 desktop/source/app/cmdlineargs.cxx                            |   12 +
 desktop/source/app/officeipcthread.cxx                        |   29 ++-
 desktop/source/app/officeipcthread.hxx                        |    4 
 desktop/source/lib/init.cxx                                   |   79 +++++++++-
 libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk   |    3 
 libreofficekit/Executable_lokconf_init.mk                     |   42 +++++
 libreofficekit/Module_libreofficekit.mk                       |    4 
 libreofficekit/qa/lokconf_init/lokconf_init.cxx               |   42 +++++
 libreofficekit/qa/unit/tiledrendering.cxx                     |    3 
 sd/source/ui/remotecontrol/Server.cxx                         |   15 +
 solenv/gbuild/CppunitTest.mk                                  |    8 +
 svx/source/sdr/contact/objectcontactofpageview.cxx            |    2 
 vcl/source/window/window.cxx                                  |    2 
 17 files changed, 245 insertions(+), 32 deletions(-)

New commits:
commit 12491e11f05b56130e33ab6ed637cf1fe01ca9fc
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Thu Dec 4 11:25:43 2014 +0100

    android: force create directory assets/gz.unpack/program
    
    It can happen that this directory doesn't exist and the copy
    script fails (especially on a clean install). The script has been
    modified to force create this directory before trying to copy
    stuff into it.
    
    Change-Id: Iedf3caef07e6896405750aea9e8f211b1e80dc3a

diff --git a/android/Bootstrap/Makefile.shared b/android/Bootstrap/Makefile.shared
index c798fd6..2429dea 100644
--- a/android/Bootstrap/Makefile.shared
+++ b/android/Bootstrap/Makefile.shared
@@ -122,7 +122,7 @@ copy-stuff:
 # android/qa/desktop/Makefile (mmeeks's desktop demo, also works to some
 # extent).
 #
-	mkdir -p assets/lib assets/program/services assets/ComponentTarget/i18npool/util
+	mkdir -p assets/lib assets/program/services assets/ComponentTarget/i18npool/util assets/gz.unpack/program
 	gzip -9 <$(INSTDIR)/$(LIBO_ETC_FOLDER)/types/offapi.rdb >assets/gz.unpack/program/offapi.rdb
 	gzip -9 <$(INSTDIR)/$(LIBO_ETC_FOLDER)/types/oovbaapi.rdb >assets/gz.unpack/program/oovbaapi.rdb
 	gzip -9 <$(INSTDIR)/$(LIBO_URE_MISC_FOLDER)/types.rdb >assets/gz.unpack/program/udkapi.rdb
commit 7915b3fcafd0fea249d924f053f0a775206a22f4
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Fri Sep 26 09:12:56 2014 +0100

    Add more lok debug output.
    
    This should allow as at least to see if soffice_main thread
    initialisation gets stuck (which we'd otherwise have a hard time
    determining if we are trying to debug e.g. on Android).
    
    Change-Id: I0baa211c015318c4e0fcf78a4e86a0ba8b895d5f

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 598bfdc..8040f54 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -695,9 +695,12 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
         // to LOK in an external program).
         if (!osl_areCommandArgsSet())
         {
+            SAL_INFO("lok", "commandArgs not previously set");
             osl_setCommandArgs(2, pArgs);
         }
+        SAL_INFO("lok", "attempting to initalize UNO");
         initialize_uno(aAppURL);
+        SAL_INFO("lok", "uno successfully initalized");
         force_c_locale();
 
         // Force headless -- this is only for bitmap rendering.
@@ -719,9 +722,13 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
         // the Thread from wherever (it's done again in Desktop::Main), and can
         // then use it to wait until we're definitely ready to continue.
 
+        SAL_INFO("lok", "enabling OfficeIPCThread");
         OfficeIPCThread::EnableOfficeIPCThread();
+        SAL_INFO("lok", "starting soffice_main");
         pthread_create(&(pLib->maThread), 0, lo_startmain, NULL);
+        SAL_INFO("lok", "waiting for OfficeIPCThread");
         OfficeIPCThread::WaitForReady();
+        SAL_INFO("lok", "OfficeIPCThread ready -- continuing");
 
         // If the Thread has been disabled again that indicates that a
         // restart is required (or in any case we don't have a useable
commit 663a8c79700da18e45ed5f69391f5fc1f2406229
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Fri Sep 26 09:11:53 2014 +0100

    Don't use this quick hack on Android.
    
    It *seems* to cause missing areas (at least in Impress).
    
    (i.e. the bottom half or right side of headers on slides can sometimes
     go missing, not using this hack fixes the problem for me).
    
    Change-Id: I205531666e0ad12470020e5ff2568ebf16bc2f01

diff --git a/svx/source/sdr/contact/objectcontactofpageview.cxx b/svx/source/sdr/contact/objectcontactofpageview.cxx
index 1d2c154..4722632 100644
--- a/svx/source/sdr/contact/objectcontactofpageview.cxx
+++ b/svx/source/sdr/contact/objectcontactofpageview.cxx
@@ -243,7 +243,7 @@ namespace sdr
             updateViewInformation2D(aNewViewInformation2D);
 
             drawinglayer::primitive2d::Primitive2DSequence xPrimitiveSequence;
-#if HAVE_FEATURE_DESKTOP
+#if defined( HAVE_FEATURE_DESKTOP ) || defined( ANDROID )
             // get whole Primitive2DSequence; this will already make use of updated ViewInformation2D
             // and may use the MapMode from the Target OutDev in the DisplayInfo
             xPrimitiveSequence = rDrawPageVOContact.getPrimitive2DSequenceHierarchy(rDisplayInfo);
commit b5937b71cbf2cdec6379b9caf5376ac2a1ad79df
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Wed Dec 3 17:40:14 2014 +0100

    Enable OfficeIPCThread for LOK on Android in a safer way
    
    Change-Id: Ie4227bba37500ca755207b64a928a19f46419ff0

diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx
index cc30141..39e9034 100644
--- a/desktop/source/app/officeipcthread.cxx
+++ b/desktop/source/app/officeipcthread.cxx
@@ -57,7 +57,7 @@ const int OfficeIPCThread::sc_nShSeqLength = 5;
 
 namespace {
 
-//#if HAVE_FEATURE_DESKTOP
+#if HAVE_FEATURE_DESKTOP || defined(ANDROID)
 
 static char const ARGUMENT_PREFIX[] = "InternalIPC::Arguments";
 static char const SEND_ARGUMENTS[] = "InternalIPC::SendArguments";
@@ -87,7 +87,7 @@ OString readStringFromPipe(osl::StreamPipe & pipe) {
     }
 }
 
-//#endif
+#endif
 
 }
 
@@ -104,7 +104,7 @@ namespace desktop
 
 namespace {
 
-//#if HAVE_FEATURE_DESKTOP
+#if HAVE_FEATURE_DESKTOP || defined(ANDROID)
 
 class Parser: public CommandLineArgs::Supplier {
 public:
@@ -241,7 +241,7 @@ bool addArgument(OStringBuffer &rArguments, char prefix,
     return true;
 }
 
-//#endif
+#endif
 
 }
 
@@ -449,7 +449,7 @@ void OfficeIPCThread::RequestsCompleted( int nCount )
 
 OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
 {
-//#if HAVE_FEATURE_DESKTOP
+#if HAVE_FEATURE_DESKTOP || defined(ANDROID)
     ::osl::MutexGuard   aGuard( GetMutex() );
 
     if( pGlobalOfficeIPCThread.is() )
@@ -604,15 +604,15 @@ OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
 
         return IPC_STATUS_2ND_OFFICE;
     }
-// #else
-//     pGlobalOfficeIPCThread = rtl::Reference< OfficeIPCThread >(new OfficeIPCThread);
-// #endif
+#else
+    pGlobalOfficeIPCThread = rtl::Reference< OfficeIPCThread >(new OfficeIPCThread);
+#endif
     return IPC_STATUS_OK;
 }
 
 void OfficeIPCThread::DisableOfficeIPCThread(bool join)
 {
-//#if HAVE_FEATURE_DESKTOP
+#if HAVE_FEATURE_DESKTOP || defined(ANDROID)
     osl::ClearableMutexGuard aMutex( GetMutex() );
 
     if( pGlobalOfficeIPCThread.is() )
@@ -635,9 +635,9 @@ void OfficeIPCThread::DisableOfficeIPCThread(bool join)
             pOfficeIPCThread->join();
         }
     }
-//#else
-//     (void) join;
-// #endif
+#else
+     (void) join;
+#endif
 }
 
 OfficeIPCThread::OfficeIPCThread() :
@@ -689,7 +689,7 @@ bool OfficeIPCThread::IsEnabled()
 
 void OfficeIPCThread::execute()
 {
-//#if HAVE_FEATURE_DESKTOP
+#if HAVE_FEATURE_DESKTOP || defined(ANDROID)
     do
     {
         osl::StreamPipe aStreamPipe;
@@ -967,7 +967,7 @@ void OfficeIPCThread::execute()
             salhelper::Thread::wait( tval );
         }
     } while( schedule() );
-//#endif
+#endif
 }
 
 static void AddToDispatchList(
commit 4bf156f6523567517d9abd4df5941066d83d5a4e
Author: Andrzej Hunt <andrzej at ahunt.org>
Date:   Thu Sep 25 10:08:54 2014 +0100

    TEMPORARY: We need OfficeIPCThread for LOK on Android for now.
    
    LOK uses the OfficeIPCThread to know that soffice_main is ready --
    we should have some form of separate condition instead since I don't
    think we need any of the actual functionality here for Android.
    
    Change-Id: I27030383aae4d7895725c2161c53617f896a5f83

diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx
index df00bdb..cc30141 100644
--- a/desktop/source/app/officeipcthread.cxx
+++ b/desktop/source/app/officeipcthread.cxx
@@ -57,7 +57,7 @@ const int OfficeIPCThread::sc_nShSeqLength = 5;
 
 namespace {
 
-#if HAVE_FEATURE_DESKTOP
+//#if HAVE_FEATURE_DESKTOP
 
 static char const ARGUMENT_PREFIX[] = "InternalIPC::Arguments";
 static char const SEND_ARGUMENTS[] = "InternalIPC::SendArguments";
@@ -87,7 +87,7 @@ OString readStringFromPipe(osl::StreamPipe & pipe) {
     }
 }
 
-#endif
+//#endif
 
 }
 
@@ -104,7 +104,7 @@ namespace desktop
 
 namespace {
 
-#if HAVE_FEATURE_DESKTOP
+//#if HAVE_FEATURE_DESKTOP
 
 class Parser: public CommandLineArgs::Supplier {
 public:
@@ -241,7 +241,7 @@ bool addArgument(OStringBuffer &rArguments, char prefix,
     return true;
 }
 
-#endif
+//#endif
 
 }
 
@@ -449,7 +449,7 @@ void OfficeIPCThread::RequestsCompleted( int nCount )
 
 OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
 {
-#if HAVE_FEATURE_DESKTOP
+//#if HAVE_FEATURE_DESKTOP
     ::osl::MutexGuard   aGuard( GetMutex() );
 
     if( pGlobalOfficeIPCThread.is() )
@@ -604,15 +604,15 @@ OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
 
         return IPC_STATUS_2ND_OFFICE;
     }
-#else
-    pGlobalOfficeIPCThread = rtl::Reference< OfficeIPCThread >(new OfficeIPCThread);
-#endif
+// #else
+//     pGlobalOfficeIPCThread = rtl::Reference< OfficeIPCThread >(new OfficeIPCThread);
+// #endif
     return IPC_STATUS_OK;
 }
 
 void OfficeIPCThread::DisableOfficeIPCThread(bool join)
 {
-#if HAVE_FEATURE_DESKTOP
+//#if HAVE_FEATURE_DESKTOP
     osl::ClearableMutexGuard aMutex( GetMutex() );
 
     if( pGlobalOfficeIPCThread.is() )
@@ -635,9 +635,9 @@ void OfficeIPCThread::DisableOfficeIPCThread(bool join)
             pOfficeIPCThread->join();
         }
     }
-#else
-    (void) join;
-#endif
+//#else
+//     (void) join;
+// #endif
 }
 
 OfficeIPCThread::OfficeIPCThread() :
@@ -689,7 +689,7 @@ bool OfficeIPCThread::IsEnabled()
 
 void OfficeIPCThread::execute()
 {
-#if HAVE_FEATURE_DESKTOP
+//#if HAVE_FEATURE_DESKTOP
     do
     {
         osl::StreamPipe aStreamPipe;
@@ -967,7 +967,7 @@ void OfficeIPCThread::execute()
             salhelper::Thread::wait( tval );
         }
     } while( schedule() );
-#endif
+//#endif
 }
 
 static void AddToDispatchList(
commit 17b0cc20a8559fcd2adb625c816448cf685ab074
Author: Andrzej Hunt <andrzej at ahunt.org>
Date:   Thu Sep 25 09:25:47 2014 +0100

    Don't use ImplDoTiledRendering for Android.
    
    With svp this causes images not to be rendered for tiled rendering,
    however this could potentially cause issues with SmartArt (however
    SmartArt support for Tiled Rendering is possibly problematic in any case).
    
    Change-Id: Iccbdce7b6d5353966892fbde3d3d10eb49164df9

diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index b211057..e559f70 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3940,7 +3940,7 @@ Any Window::GetSystemDataAny() const
 
 bool ImplDoTiledRendering()
 {
-#if !HAVE_FEATURE_DESKTOP
+#if !HAVE_FEATURE_DESKTOP && !ANDROID
     // We do tiled rendering only for iOS at the moment, actually, but
     // let's see what happens if we assume it for Android, too.
     return true;
commit 885a578b2c48667cff6958ea5ec2705d48954a2e
Author: Andrzej Hunt <andrzej at ahunt.org>
Date:   Thu Sep 25 09:20:56 2014 +0100

    LOK Android: don't initialise until TMPDIR is set.
    
    As part of LOK initialisation we now start soffice_main, this
    requires TMPDIR access, and will fail if we haven't set TMPDIR
    (as by default it attemps to access /tmp which is not allowed on
    Android).
    
    Change-Id: I63bd7bce9b52c898c60fda6eea33ee919349a109

diff --git a/android/Bootstrap/src/org/libreoffice/kit/LibreOfficeKit.java b/android/Bootstrap/src/org/libreoffice/kit/LibreOfficeKit.java
index e520039..afd81b3 100644
--- a/android/Bootstrap/src/org/libreoffice/kit/LibreOfficeKit.java
+++ b/android/Bootstrap/src/org/libreoffice/kit/LibreOfficeKit.java
@@ -67,10 +67,6 @@ public final class LibreOfficeKit
         String cacheDir = activity.getApplication().getCacheDir().getAbsolutePath();
         String apkFile = activity.getApplication().getPackageResourcePath();
 
-        if (!initializeNative(dataDir, cacheDir, apkFile)) {
-            return;
-        }
-
         // If we notice that a fonts.conf file was extracted, automatically
         // set the FONTCONFIG_FILE env var.
         InputStream inputStream = null;
@@ -88,6 +84,10 @@ public final class LibreOfficeKit
         // TMPDIR is used by osl_getTempDirURL()
         putenv("TMPDIR=" + activity.getCacheDir().getAbsolutePath());
 
+        if (!initializeNative(dataDir, cacheDir, apkFile)) {
+            return;
+        }
+
         initializeDone = true;
     }
 
commit eefdd2ee550605f8f78ece452ad5bdabf0a1de9d
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Wed Jul 30 19:52:46 2014 +0200

    Make common paths member variables.
    
    We'll need these for other tests too.
    
    Change-Id: Ia99c2e60f5e5bb24a83875a9dcf85a6b4f54beb4

diff --git a/libreofficekit/qa/unit/tiledrendering.cxx b/libreofficekit/qa/unit/tiledrendering.cxx
index 5d61000..d6529f5 100644
--- a/libreofficekit/qa/unit/tiledrendering.cxx
+++ b/libreofficekit/qa/unit/tiledrendering.cxx
@@ -157,6 +157,9 @@ void TiledRenderingTest::testOverlay( Office* pOffice )
     // test it's entirely possible that an unwanted lock file will remain.
     // Hence forcefully remove it here.
     remove( sLockFile.c_str() );
+    scoped_ptr< Office > pOffice( lok_cpp_init(
+                                      m_sLOPath.c_str() ) );
+    assert( pOffice.get() );
 
     scoped_ptr< Document> pDocument( pOffice->documentLoad(
                                          sDocPath.c_str() ) );
commit 4b8122318c9d07e36c23a2c9cbd98d4087db18de
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Tue Jul 29 07:18:28 2014 +0200

    Upgrade lokconf_init to LibreOfficeKitInit.h
    
    Change-Id: I0581a107c3eefd33c25b003afe9f7be217598441

diff --git a/libreofficekit/qa/lokconf_init/lokconf_init.cxx b/libreofficekit/qa/lokconf_init/lokconf_init.cxx
index 9677159..aa12bc9 100644
--- a/libreofficekit/qa/lokconf_init/lokconf_init.cxx
+++ b/libreofficekit/qa/lokconf_init/lokconf_init.cxx
@@ -14,6 +14,7 @@
 #include <sal/main.h>
 
 #include <LibreOfficeKit/LibreOfficeKit.h>
+#include <LibreOfficeKit/LibreOfficeKitInit.h>
 
 using namespace std;
 
commit 75b0e1f9c0d18429d0073d7130d0fbad52d8ff71
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Mon Jul 28 20:23:03 2014 +0200

    Kill the libreofficekit static library / shim.c.
    
    It looks like the cleanest method of getting lok_init into
    a LibreOfficeKitInit.h header (in a c89 compatible way) is to
    have it as a static function.
    
    (inline is only available in C99 or later -- this is actually
     available on Linux which is the only place that we can actually
     use lok_init anyways currently, however given we have to keep
     c89 for the C code (for MSVC) compatibility, selectively enabling
     c99 would likely be more messy.)
    
    Conflicts:
    	libreofficekit/Module_libreofficekit.mk
    
    Change-Id: I0493e7a68ed5397479220bb6ba8c3db870b6dd32

diff --git a/UnoControls/Makefile b/UnoControls/Makefile
deleted file mode 100644
index 0997e62..0000000
--- a/UnoControls/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-
-module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
-
-include $(module_directory)/../solenv/gbuild/partial_build.mk
-
-# vim: set noet sw=4 ts=4:
commit 9d7e08bcb9a578651d5d93d7af7ebcab2c75ed27
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Mon Jul 28 16:18:57 2014 +0200

    LOK: do clean main thread shutdown cleanly.
    
    Change-Id: If44971f67a489f6b50dee6c1683707c47e695de4

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index da488ee..598bfdc 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -248,6 +248,7 @@ struct LibLibreOffice_Impl : public _LibreOfficeKit
 {
     OUString maLastExceptionMsg;
     shared_ptr< LibreOfficeKitClass > m_pOfficeClass;
+    pthread_t maThread;
 
     LibLibreOffice_Impl()
     {
@@ -651,7 +652,7 @@ static void* lo_startmain(void*)
 
 static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
 {
-    (void) pThis;
+    LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
 
     static bool bInitialized = false;
     if (bInitialized)
@@ -719,8 +720,7 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
         // then use it to wait until we're definitely ready to continue.
 
         OfficeIPCThread::EnableOfficeIPCThread();
-        pthread_t thread;
-        pthread_create(&thread, 0, lo_startmain, NULL);
+        pthread_create(&(pLib->maThread), 0, lo_startmain, NULL);
         OfficeIPCThread::WaitForReady();
 
         // If the Thread has been disabled again that indicates that a
@@ -764,8 +764,12 @@ SAL_DLLPUBLIC_EXPORT LibreOfficeKit *libreofficekit_hook(const char* install_pat
 static void lo_destroy(LibreOfficeKit *pThis)
 {
     LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
-    delete pLib;
     gImpl = NULL;
+
+    Application::Quit();
+    pthread_join(pLib->maThread, NULL);
+
+    delete pLib;
 }
 
 }
commit 541a7ad29b53e406282b45c1b7d84cb06ce06106
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Fri Jul 25 21:03:19 2014 +0200

    Make sure LOK is actually headless.
    
    This prevents e.g. the document recovery dialog from trying to be shown.
    
    Change-Id: I253720f7fa1abd1c053670434f8394473517b670

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index edea4e5..da488ee 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -677,6 +677,25 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
 
     try
     {
+        // We specifically need to make sure we have the "headless"
+        // command arg set (various code specifically checks via
+        // CommandLineArgs). We could alternatively add some other
+        // flag elsewhere to indicate headlessness, which would
+        // then be set from here or via CommandLineArgs.
+        // (The first argument is treated specially by osl_setCommandArgs
+        // however it is valid to make it \0 instead.)
+        char sName[] = "";
+        char sHeadless[] = "--headless";
+        char* pArgs[2] = { sName, sHeadless };
+
+        // If we've set up the command args elsewhere then we cannot do it
+        // again (as an assert will fire), this will be the case e.g.
+        // for unit tests (and possibly if UNO is being used in addition
+        // to LOK in an external program).
+        if (!osl_areCommandArgsSet())
+        {
+            osl_setCommandArgs(2, pArgs);
+        }
         initialize_uno(aAppURL);
         force_c_locale();
 
commit 6ee3c10947cdee2ba2113f0e683b8147076f129b
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Fri Jul 25 20:56:18 2014 +0200

    Don't fail on --protector.
    
    If we have any "unknown" command line arguments Desktop init will fail,
    however our LOK Tiled Rendering test uses Desktop (via soffice_main).
    (Other unit tests don't use soffice_main hence this check never
    comes into play.) It looks like it's most reliable simply to ignore
    --protector here, rather than try to filter it out elsewhere (which
    is difficult as it is passed to osl via SAL_IMPLEMENT_MAIN).
    
    Change-Id: I95d047892851ba2cf9edd2e26bacc6efa0320f71

diff --git a/desktop/source/app/cmdlineargs.cxx b/desktop/source/app/cmdlineargs.cxx
index 2cecabc..d3271fd 100644
--- a/desktop/source/app/cmdlineargs.cxx
+++ b/desktop/source/app/cmdlineargs.cxx
@@ -259,6 +259,18 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier )
             {
                 m_helpmath = true;
             }
+            else if ( oArg == "protector" )
+            {
+                // Not relevant for us here, but can be used in unit tests.
+                // Usually unit tests would not end up here, but e.g. the
+                // LOK Tiled Rendering tests end up running a full soffice
+                // process, and we can't bail on the use of --protector.
+
+                // We specifically need to consume the following 2 arguments
+                // for --protector
+                assert( supplier.next( &aArg ) );
+                assert( supplier.next( &aArg ) );
+            }
             else if ( oArg == "version" )
             {
                 m_version = true;
commit 40f7990037dd70b6b2885635052d19ea5d52dc51
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Mon Jul 21 21:16:09 2014 +0200

    Don't start Impress Remote server in headless mode.
    
    Change-Id: Ibafe57413a60745e949dc3146fbc843c52c029d6

diff --git a/sd/source/ui/remotecontrol/Server.cxx b/sd/source/ui/remotecontrol/Server.cxx
index 7404bbd..d110832 100644
--- a/sd/source/ui/remotecontrol/Server.cxx
+++ b/sd/source/ui/remotecontrol/Server.cxx
@@ -364,6 +364,21 @@ void RemoteServer::deauthoriseClient( ::boost::shared_ptr< ClientInfo > pClient
 void SdDLL::RegisterRemotes()
 {
     SAL_INFO( "sdremote", "SdDLL::RegisterRemotes called" );
+
+    // The remote server is likely of no use in headless mode. And as only
+    // one instance of the server can actually own the appropriate ports its
+    // probably best to not even try to do so from our headless instance
+    // (i.e. as to avoid blocking expected usage).
+    // It could perhaps be argued that we would still need the remote
+    // server for tiled rendering of presentations, but even then this
+    // implementation would not be of much use, i.e. would be controlling
+    // the purely imaginary headless presentation -- instead we'd need
+    // to have some sort of mechanism of plugging in our tiled rendering
+    // client to be controlled by the remote server, or provide an
+    // alternative implementation.
+    if ( Application::IsHeadlessModeEnabled() )
+        return;
+
     uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
     if ( xContext.is()  && !officecfg::Office::Impress::Misc::Start::EnableSdremote::get( xContext ) )
         return;
commit 9f699caddf27e276bb8772a02d917ba6c1fbdba3
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Mon Jul 21 19:36:11 2014 +0200

    Use gb_CppunitTest_use_confpreinit for LOK tiled rendering.
    
    Now that we use the event loop for LOK we need to make sure that
    it is able to run successfully first time, as unit tests start
    with a completely clean config.
    
    Change-Id: If9ddcb75fe8286381d71ecdc76ac7eb3697960d0

diff --git a/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk b/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk
index cd03abe..acc708f 100644
--- a/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk
+++ b/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk
@@ -29,7 +29,6 @@ $(eval $(call gb_CppunitTest_use_libraries,libreofficekit_tiledrendering, \
 	$(gb_UWINAPI) \
 ))
 
-
 # 	unotest \
 
 ifeq ($(OS),LINUX)
@@ -50,4 +49,6 @@ $(eval $(call gb_CppunitTest_use_rdb,libreofficekit_tiledrendering,services))
 
 $(eval $(call gb_CppunitTest_use_configuration,libreofficekit_tiledrendering))
 
+$(eval $(call gb_CppunitTest_use_confpreinit,libreofficekit_tiledrendering))
+
 # vim: set noet sw=4 ts=4:
commit b1646178d84bca6fc8cf3310b4c61560ec856f33
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Mon Jul 21 19:35:13 2014 +0200

    Add gb_CppunitTest_use_confpreinit:
    
    For unit tests that use the VCL event loop we can use this to
    avoid the otherwise required restart.
    
    Change-Id: I48265d7e7188a4efaa6f87432c762320331c0c78

diff --git a/solenv/gbuild/CppunitTest.mk b/solenv/gbuild/CppunitTest.mk
index 4f00f81..4e3d54a 100644
--- a/solenv/gbuild/CppunitTest.mk
+++ b/solenv/gbuild/CppunitTest.mk
@@ -82,6 +82,8 @@ $(call gb_CppunitTest_get_target,%) :| $(gb_CppunitTest_CPPTESTDEPS)
 	$(call gb_Helper_abbreviate_dirs,\
 		mkdir -p $(dir $@) && \
 		rm -fr $@.user && mkdir $@.user && \
+		$(if $(gb_CppunitTest__use_confpreinit), \
+		    $(INSTDIR)/program/lokconf_init $(call gb_CppunitTest__make_args) &&) \
 		$(if $(gb_CppunitTest__interactive),, \
 			$(if $(value gb_CppunitTest_postprocess), \
 				rm -fr $@.core && mkdir $@.core && cd $@.core &&)) \
@@ -177,6 +179,12 @@ endif
 
 endef
 
+define gb_CppunitTest_use_confpreinit
+$(call gb_CppunitTest_use_executable,$(1),lokconf_init)
+$(call gb_CppunitTest_get_target,$(1)) : gb_CppunitTest__use_confpreinit := TRUE
+
+endef
+
 define gb_CppunitTest_use_vcl
 $(call gb_CppunitTest__use_vcl,$(1),$(true))
 
commit 5acadbfb0c79fe51f8025b065b46b0ccd25c804d
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Mon Jul 21 19:34:09 2014 +0200

    Implement lokconf_init.
    
    This is a simple executable which can be used to ensure there is a
    pe-pared configuration for unit-tests to avoid the usually required
    re-start on the first run.
    
    Change-Id: I49b706e8daa93bc34db508a24615b63b9babddba

diff --git a/libreofficekit/Executable_lokconf_init.mk b/libreofficekit/Executable_lokconf_init.mk
new file mode 100644
index 0000000..3e25f13
--- /dev/null
+++ b/libreofficekit/Executable_lokconf_init.mk
@@ -0,0 +1,42 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Executable_Executable,lokconf_init))
+
+$(eval $(call gb_Executable_set_include,lokconf_init,\
+    $$(INCLUDE) \
+))
+
+$(eval $(call gb_Executable_use_libraries,lokconf_init, \
+	cppu \
+	sal \
+))
+
+$(eval $(call gb_Executable_use_static_libraries,lokconf_init,\
+    libreofficekit \
+))
+
+$(eval $(call gb_Executable_add_libs,lokconf_init,\
+    -lSM \
+    -lICE \
+))
+
+ifeq ($(OS),LINUX)
+$(eval $(call gb_Executable_add_libs,lokconf_init,\
+    -lm \
+    -ldl \
+    -lpthread \
+))
+endif
+
+$(eval $(call gb_Executable_add_exception_objects,lokconf_init,\
+    libreofficekit/qa/lokconf_init/lokconf_init \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/libreofficekit/Module_libreofficekit.mk b/libreofficekit/Module_libreofficekit.mk
index fe5ee15..2ad2d16 100644
--- a/libreofficekit/Module_libreofficekit.mk
+++ b/libreofficekit/Module_libreofficekit.mk
@@ -11,6 +11,10 @@ $(eval $(call gb_Module_Module,libreofficekit))
 
 ifeq ($(OS),LINUX)
 
+$(eval $(call gb_Module_add_targets,libreofficekit,\
+    Executable_lokconf_init \
+))
+
 # $(eval $(call gb_Module_add_check_targets,libreofficekit,\
 #     CppunitTest_libreofficekit_tiledrendering \
 # ))
diff --git a/libreofficekit/qa/lokconf_init/lokconf_init.cxx b/libreofficekit/qa/lokconf_init/lokconf_init.cxx
new file mode 100644
index 0000000..9677159
--- /dev/null
+++ b/libreofficekit/qa/lokconf_init/lokconf_init.cxx
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <stdio.h>
+#include <string>
+#include <string.h>
+
+#include <sal/main.h>
+
+#include <LibreOfficeKit/LibreOfficeKit.h>
+
+using namespace std;
+
+// Using SAL_IMPLEMENT_MAIN means that we can directly use the same
+// arguments as would be provided to cppunittester, i.e. ensuring
+// that we're operating with the correct directories etc.
+SAL_IMPLEMENT_MAIN()
+{
+    string sPath( getenv("INSTDIR") );
+    sPath += "/program";
+
+    LibreOfficeKit* pOffice = lok_init( sPath.c_str() );
+
+    // As this is the first init, pOffice should be NULL.
+    // However there's no reason we shouldn't be able to operate
+    // even if it isn't the first init.
+    if ( pOffice )
+    {
+        pOffice->pClass->destroy( pOffice );
+        pOffice = 0;
+    }
+    return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 5296fbbc53bcd9c8e177c899417ad1044ecb689f
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Fri Jul 18 13:12:25 2014 +0200

    Fail LOK initialisation if restart is required.
    
    Change-Id: Ia13a3523666147f002b5a5177fd6962d55556f56

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 96313e4..edea4e5 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -704,6 +704,15 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
         pthread_create(&thread, 0, lo_startmain, NULL);
         OfficeIPCThread::WaitForReady();
 
+        // If the Thread has been disabled again that indicates that a
+        // restart is required (or in any case we don't have a useable
+        // process around).
+        if (!OfficeIPCThread::IsEnabled())
+        {
+            fprintf(stderr, "LOK init failed -- restart required\n");
+            return false;
+        }
+
         Application::EnableHeadlessMode(true);
 
         ErrorHandler::RegisterDisplay(aBasicErrorFunc);
commit d5b01426f3f8b80e93ff5dec6c159624f51c8dcb
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Fri Jul 18 13:10:14 2014 +0200

    Add OfficeIPCThread::IsEnabled.
    
    This lets us easily check whether Desktop::Main has shut down,
    i.e. which happens on the first restart-requiring initialisation.
    
    Change-Id: I7fe5699a4bf59e2c3b891ac73abd9b147773d22e

diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx
index 1789fbd..df00bdb 100644
--- a/desktop/source/app/officeipcthread.cxx
+++ b/desktop/source/app/officeipcthread.cxx
@@ -682,6 +682,11 @@ void OfficeIPCThread::WaitForReady(
     }
 }
 
+bool OfficeIPCThread::IsEnabled()
+{
+    return pGlobalOfficeIPCThread.is();
+}
+
 void OfficeIPCThread::execute()
 {
 #if HAVE_FEATURE_DESKTOP
diff --git a/desktop/source/app/officeipcthread.hxx b/desktop/source/app/officeipcthread.hxx
index 9b3f1fd..a6b48c1 100644
--- a/desktop/source/app/officeipcthread.hxx
+++ b/desktop/source/app/officeipcthread.hxx
@@ -129,6 +129,7 @@ class OfficeIPCThread : public salhelper::Thread
     static void                 WaitForReady(
         rtl::Reference< OfficeIPCThread > const & pThread =
             rtl::Reference< OfficeIPCThread >());
+    static bool                 IsEnabled();
 
     bool                        AreRequestsEnabled() const { return mbRequestsEnabled && ! mbDowning; }
 };
commit 5ffdcea247f64e36f56cfbfa3ba2bde0777945d6
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Fri Jul 18 10:02:48 2014 +0200

    Use OfficeIPCThread::WaitForReady rather than sleeping.
    
    This way we actually continue when we're ready to, rather than
    dumbly hoping we wait for long enough.
    
    This isn't entirely unproblematic though -- if we have no config
    pre-prepared (i.e. first-run), then we just end up hanging on this
    since soffice_main exits without doing anything to the OfficeIPCThread.
    (Which is especially problematic for unit tests which specifically run
     on an empty config.)
    
    Change-Id: I064fb500a224cfe37a0d3ba24b6154ffd72a71a3

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index cb5533e..96313e4 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -61,9 +61,11 @@
 
 // We also need to hackily be able to start the main libreoffice thread
 #include "../app/sofficemain.h"
+#include "../app/officeipcthread.hxx"
 
 using namespace css;
 using namespace vcl;
+using namespace desktop;
 using namespace utl;
 
 using namespace boost;
@@ -680,22 +682,27 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
 
         // Force headless -- this is only for bitmap rendering.
         rtl::Bootstrap::set("SAL_USE_VCLPLUGIN", "svp");
-//         InitVCL();
-        // InitVCL() happens in soffice_main for us -- and we can't call InitVCL twice
-        // unfortunately -- which is annoying since (see below)
 
+        // We could use InitVCL() here -- and used to before using soffice_main,
+        // however that now deals with the initialisation for us (and it's not
+        // possible to try to set up VCL twice.
+
+        // Instead VCL init is done for us by soffice_main in a separate thread,
+        // however we specifically can't proceed until this setup is complete
+        // (or you get segfaults trying to use VCL and/or deadlocks due to other
+        //  setup within soffice_main). Specifically the various Application::
+        // functions depend on VCL being ready -- the deadlocks would happen
+        // if you try to use loadDocument too early.
+
+        // The OfficeIPCThread is specifically set to be read when all the other
+        // init in Desktop::Main (run from soffice_main) is done. We can "enable"
+        // the Thread from wherever (it's done again in Desktop::Main), and can
+        // then use it to wait until we're definitely ready to continue.
+
+        OfficeIPCThread::EnableOfficeIPCThread();
         pthread_t thread;
         pthread_create(&thread, 0, lo_startmain, NULL);
-        sleep(10);
-        // We'll segfault trying to access Application if we're too fast...
-        // Specifically pImplSVData doesn't exist until InitVCL has been called,
-        // and that won't be immediate, but we can't call InitVCL ourselves
-        // as soffice_main already does so, but InitVCL would then fail
-        // within soffice_main if we have already called it earlier.
-        //
-        // And there's also a chance of deadlock if we try to open documents
-        // too early -- when running in a debugger we therefore need quite
-        // a large delay here (for now).
+        OfficeIPCThread::WaitForReady();
 
         Application::EnableHeadlessMode(true);
 
commit 9001834224d6ded520505653c03333259c0fc963
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Fri Jul 18 10:00:42 2014 +0200

    Bin outdated / incorrect comment.
    
    Change-Id: I7b8f97377b9606a2228f172f772d8051a64703d2

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index cc29721..cb5533e 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -678,10 +678,7 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
         initialize_uno(aAppURL);
         force_c_locale();
 
-        // Force headless
-        // the "svp" headless vcl backend isn't able to do tiled rendering for
-        // us -- we need to use a full featured backend, i.e. "gen" or "gtk",
-        // gtk seems to be somewhat better.
+        // Force headless -- this is only for bitmap rendering.
         rtl::Bootstrap::set("SAL_USE_VCLPLUGIN", "svp");
 //         InitVCL();
         // InitVCL() happens in soffice_main for us -- and we can't call InitVCL twice
commit ad2c68fbe853f585041133b86fb687203777503b
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Fri Jul 18 09:48:47 2014 +0200

    Add OfficeIPCThread::WaitForReady.
    
    For LibreOfficeKit we need to start up the event loop, and can't continue
    initialisation until all the related (VCL etc.) setup is complete -- the
    OfficeIPCThread is also enabled as one of the last items, and can be
    used to indicate whether or not we can start actually working with VCL.
    
    Change-Id: I0450b65584ddf6e8d02ce0c6e66e06f47841d1b7

diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx
index 2c4e9d1..1789fbd 100644
--- a/desktop/source/app/officeipcthread.cxx
+++ b/desktop/source/app/officeipcthread.cxx
@@ -670,6 +670,18 @@ void OfficeIPCThread::SetReady(
     }
 }
 
+void OfficeIPCThread::WaitForReady(
+    rtl::Reference< OfficeIPCThread > const & pThread)
+
+{
+    rtl::Reference< OfficeIPCThread > const & t(
+        pThread.is() ? pThread : pGlobalOfficeIPCThread);
+    if (t.is())
+    {
+        t->cReady.wait();
+    }
+}
+
 void OfficeIPCThread::execute()
 {
 #if HAVE_FEATURE_DESKTOP
diff --git a/desktop/source/app/officeipcthread.hxx b/desktop/source/app/officeipcthread.hxx
index 921da49..9b3f1fd 100644
--- a/desktop/source/app/officeipcthread.hxx
+++ b/desktop/source/app/officeipcthread.hxx
@@ -126,6 +126,9 @@ class OfficeIPCThread : public salhelper::Thread
     static void                 SetReady(
         rtl::Reference< OfficeIPCThread > const & pThread =
             rtl::Reference< OfficeIPCThread >());
+    static void                 WaitForReady(
+        rtl::Reference< OfficeIPCThread > const & pThread =
+            rtl::Reference< OfficeIPCThread >());
 
     bool                        AreRequestsEnabled() const { return mbRequestsEnabled && ! mbDowning; }
 };
commit 13fced388e20278c8ebb8a12b88aad63c0fd6b9c
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Sat Jul 26 16:06:04 2014 +0200

    Hack soffice_main into LOK.
    
    Change-Id: I86e13192ddb5904afabca38d3a201f17f145de09

diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index da37f9a..80479b4 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -17,6 +17,13 @@ $(eval $(call gb_Library_set_include,sofficeapp,\
     -I$(SRCDIR)/vcl/inc \
 ))
 
+$(eval $(call gb_Library_add_libs,sofficeapp,\
+    $(if $(filter $(OS),LINUX), \
+        -ldl \
+        -lpthread \
+    ) \
+))
+
 $(eval $(call gb_Library_use_external,sofficeapp,boost_headers))
 
 $(eval $(call gb_Library_use_custom_headers,sofficeapp,\
@@ -47,6 +54,7 @@ $(eval $(call gb_Library_use_libraries,sofficeapp,\
     sfx \
     svl \
     svt \
+    sw \
     tk \
     tl \
     ucbhelper \
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 261b2f6..cc29721 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -59,6 +59,9 @@
 #include <basebmp/bitmapdevice.hxx>
 #endif
 
+// We also need to hackily be able to start the main libreoffice thread
+#include "../app/sofficemain.h"
+
 using namespace css;
 using namespace vcl;
 using namespace utl;
@@ -638,6 +641,12 @@ static void initialize_uno(const OUString &aAppProgramURL)
     // configmgr setup ?
 }
 
+static void* lo_startmain(void*)
+{
+    soffice_main();
+    return 0;
+}
+
 static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
 {
     (void) pThis;
@@ -670,8 +679,27 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
         force_c_locale();
 
         // Force headless
+        // the "svp" headless vcl backend isn't able to do tiled rendering for
+        // us -- we need to use a full featured backend, i.e. "gen" or "gtk",
+        // gtk seems to be somewhat better.
         rtl::Bootstrap::set("SAL_USE_VCLPLUGIN", "svp");
-        InitVCL();
+//         InitVCL();
+        // InitVCL() happens in soffice_main for us -- and we can't call InitVCL twice
+        // unfortunately -- which is annoying since (see below)
+
+        pthread_t thread;
+        pthread_create(&thread, 0, lo_startmain, NULL);
+        sleep(10);
+        // We'll segfault trying to access Application if we're too fast...
+        // Specifically pImplSVData doesn't exist until InitVCL has been called,
+        // and that won't be immediate, but we can't call InitVCL ourselves
+        // as soffice_main already does so, but InitVCL would then fail
+        // within soffice_main if we have already called it earlier.
+        //
+        // And there's also a chance of deadlock if we try to open documents
+        // too early -- when running in a debugger we therefore need quite
+        // a large delay here (for now).
+
         Application::EnableHeadlessMode(true);
 
         ErrorHandler::RegisterDisplay(aBasicErrorFunc);


More information about the Libreoffice-commits mailing list