[Libreoffice-commits] core.git: Branch 'libreoffice-5-0' - javaunohelper/com

Katarina Behrens Katarina.Behrens at cib.de
Tue Dec 22 06:41:01 PST 2015


 javaunohelper/com/sun/star/comp/helper/Bootstrap.java |   58 +++++++++++++++---
 1 file changed, 51 insertions(+), 7 deletions(-)

New commits:
commit bb6939cc689a44c1039508935312df98e12f4081
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Tue Dec 15 14:44:44 2015 +0100

    tdf#86784: Pass custom options to Java bootstrap
    
    Reviewed-on: https://gerrit.libreoffice.org/20720
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
    Tested-by: Noel Grandin <noelgrandin at gmail.com>
    (cherry picked from commit 02002f83f156117cf178532d48abaa9319ee8cb4)
    
    Change-Id: I9e9c78387627e173dea8062e4a3f16bc396e8115
    Reviewed-on: https://gerrit.libreoffice.org/20802
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
    Tested-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/javaunohelper/com/sun/star/comp/helper/Bootstrap.java b/javaunohelper/com/sun/star/comp/helper/Bootstrap.java
index 537959b..ba06ea9 100644
--- a/javaunohelper/com/sun/star/comp/helper/Bootstrap.java
+++ b/javaunohelper/com/sun/star/comp/helper/Bootstrap.java
@@ -91,6 +91,34 @@ public class Bootstrap {
     }
 
     /**
+     * Returns an array of default commandline options to start bootstrapped
+     * instance of soffice with. You may use it in connection with bootstrap
+     * method for example like this:
+     * <pre>
+     *     List list = Arrays.asList( Bootstrap.getDefaultOptions() );
+     *     list.remove("--nologo");
+     *     list.remove("--nodefault");
+     *     list.add("--invisible");
+     *
+     *     Bootstrap.bootstrap( list.toArray( new String[list.size()] );
+     * </pre>
+     *
+     * @return an array of default commandline options
+     * @see #bootstrap( String[] )
+     * @since LibreOffice 5.1
+     */
+    public static final String[] getDefaultOptions()
+    {
+        return new String[]
+        {
+            "--nologo",
+            "--nodefault",
+            "--norestore",
+            "--nolockcheck"
+        };
+    }
+
+    /**
      * backwards compatibility stub.
      */
     static public XComponentContext createInitialComponentContext( Hashtable<String, Object> context_entries )
@@ -247,6 +275,24 @@ public class Bootstrap {
     public static final XComponentContext bootstrap()
         throws BootstrapException {
 
+        String[] defaultArgArray = getDefaultOptions();
+        return bootstrap( defaultArgArray );
+    }
+
+    /**
+     * Bootstraps the component context from a UNO installation.
+     *
+     * @param argArray
+     *        an array of strings - commandline options to start instance of
+     *        soffice with
+     * @see #getDefaultOptions()
+     * @return a bootstrapped component context.
+     *
+     * @since LibreOffice 5.1
+     */
+    public static final XComponentContext bootstrap( String[] argArray )
+        throws BootstrapException {
+
         XComponentContext xContext = null;
 
         try {
@@ -270,13 +316,11 @@ public class Bootstrap {
                 Long.toString( (new Random()).nextLong() & 0x7fffffffffffffffL );
 
             // create call with arguments
-            String[] cmdArray = new String[] {
-                fOffice.getPath(),
-                "--nologo",
-                "--nodefault",
-                "--norestore",
-                "--nolockcheck",
-                "--accept=pipe,name=" + sPipeName + ";urp;" };
+            String[] cmdArray = new String[ argArray.length + 2 ];
+            cmdArray[0] = fOffice.getPath();
+            cmdArray[1] = ( "--accept=pipe,name=" + sPipeName + ";urp;" );
+
+            System.arraycopy( argArray, 0, cmdArray, 2, argArray.length );
 
             // start office process
             Process p = Runtime.getRuntime().exec( cmdArray );


More information about the Libreoffice-commits mailing list