summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatarina Behrens <Katarina.Behrens@cib.de>2015-12-15 14:44:44 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-12-21 14:19:13 +0000
commit8cb4fe7ff4ea5227ebe416617c16c9abfa437ff0 (patch)
treeacd3a004545bb7c583adc1aa4539ef1779eb664e
parente1693595443f0a7b6974c065219b7b474dea2bee (diff)
tdf#86784: Pass custom options to Java bootstrap
Reviewed-on: https://gerrit.libreoffice.org/20720 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com> (cherry picked from commit 02002f83f156117cf178532d48abaa9319ee8cb4) Change-Id: I9e9c78387627e173dea8062e4a3f16bc396e8115 Reviewed-on: https://gerrit.libreoffice.org/20801 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: David Ostrovsky <david@ostrovsky.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--javaunohelper/com/sun/star/comp/helper/Bootstrap.java58
1 files changed, 51 insertions, 7 deletions
diff --git a/javaunohelper/com/sun/star/comp/helper/Bootstrap.java b/javaunohelper/com/sun/star/comp/helper/Bootstrap.java
index a36f16c9b25d..475b84bf0f58 100644
--- a/javaunohelper/com/sun/star/comp/helper/Bootstrap.java
+++ b/javaunohelper/com/sun/star/comp/helper/Bootstrap.java
@@ -92,6 +92,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 UDK 5.1.0
+ */
+ public static final String[] getDefaultOptions()
+ {
+ return new String[]
+ {
+ "--nologo",
+ "--nodefault",
+ "--norestore",
+ "--nolockcheck"
+ };
+ }
+
+ /**
* backwards compatibility stub.
*/
public static XComponentContext createInitialComponentContext( Hashtable<String, Object> context_entries )
@@ -248,6 +276,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 UDK 5.1.0
+ */
+ public static final XComponentContext bootstrap( String[] argArray )
+ throws BootstrapException {
+
XComponentContext xContext = null;
try {
@@ -271,13 +317,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 );