summaryrefslogtreecommitdiff
path: root/odk/examples/DevelopersGuide/Charts
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2005-01-31 15:10:43 +0000
committerRüdiger Timm <rt@openoffice.org>2005-01-31 15:10:43 +0000
commit7cc3bd185b6dbcc6f5bb3c439b1425251c97908e (patch)
tree0d0bc31683709917bbacbdd403e8c52fed337b1e /odk/examples/DevelopersGuide/Charts
parent96e796f9bfa16e4e3636b4b40d2e0a25334a46cb (diff)
INTEGRATION: CWS sdksample (1.4.40); FILE MERGED
2004/08/06 14:36:52 jsc 1.4.40.2: #i29308# use System.err for error output 2004/06/07 14:25:56 jsc 1.4.40.1: #i29308# use new bootstrap feature
Diffstat (limited to 'odk/examples/DevelopersGuide/Charts')
-rw-r--r--odk/examples/DevelopersGuide/Charts/Helper.java65
1 files changed, 22 insertions, 43 deletions
diff --git a/odk/examples/DevelopersGuide/Charts/Helper.java b/odk/examples/DevelopersGuide/Charts/Helper.java
index 87fe0acf3660..a8c16d37d1d7 100644
--- a/odk/examples/DevelopersGuide/Charts/Helper.java
+++ b/odk/examples/DevelopersGuide/Charts/Helper.java
@@ -2,9 +2,9 @@
*
* $RCSfile: Helper.java,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: hr $ $Date: 2004-02-02 19:50:13 $
+ * last change: $Author: rt $ $Date: 2005-01-31 16:10:43 $
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
@@ -45,6 +45,7 @@ import java.util.Random;
// base classes
import com.sun.star.uno.XInterface;
import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
import com.sun.star.lang.*;
// factory for creating components
@@ -85,20 +86,18 @@ public class Helper
public Helper( String[] args )
{
// connect to a running office and get the ServiceManager
- try
- {
- String sConnectString;
- if( args.length > 0 )
- sConnectString = args[ 0 ];
- else
- sConnectString = new String( "socket,host=localhost,port=2083" );
+ try {
+ // get the remote office component context
+ maContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
- maMSFactory = connect( "uno:" + sConnectString + ";urp;StarOffice.ServiceManager" );
+ // get the remote office service manager
+ maMCFactory = maContext.getServiceManager();
}
- catch( Exception ex )
- {
- System.out.println( "Couldn't get ServiceManager: " + ex );
- System.exit( 0 );
+ catch( Exception e) {
+ System.out.println( "Couldn't get ServiceManager: " + e );
+ e.printStackTrace();
+ System.exit(1);
}
}
@@ -138,9 +137,10 @@ public class Helper
XModel aResult = null;
try
{
- XComponentLoader aLoader = (XComponentLoader) UnoRuntime.queryInterface(
- XComponentLoader.class,
- maMSFactory.createInstance( "com.sun.star.frame.Desktop" ) );
+ XComponentLoader aLoader = (XComponentLoader)
+ UnoRuntime.queryInterface(XComponentLoader.class,
+ maMCFactory.createInstanceWithContext("com.sun.star.frame.Desktop",
+ maContext) );
aResult = (XModel) UnoRuntime.queryInterface(
XModel.class,
@@ -149,9 +149,10 @@ public class Helper
0,
new PropertyValue[ 0 ] ) );
}
- catch( Exception ex )
+ catch( Exception e )
{
- System.out.println( "Couldn't create Document of type " + sDocType + ": " + ex );
+ System.err.println("Couldn't create Document of type "+ sDocType +": "+e);
+ e.printStackTrace();
System.exit( 0 );
}
@@ -164,29 +165,7 @@ public class Helper
private final String msChartSheetName = "Chart";
private final String msChartName = "SampleChart";
- private XMultiServiceFactory maMSFactory;
+ private XComponentContext maContext;
+ private XMultiComponentFactory maMCFactory;
private XSpreadsheetDocument maSpreadSheetDoc;
-
-
- // ____________________
-
- /** Connect to a running office that is accepting connections
- and return the ServiceManager to instantiate office components
- */
- private XMultiServiceFactory connect( String sConnectString )
- throws RuntimeException, Exception
- {
- XMultiServiceFactory aLocalServiceManager =
- com.sun.star.comp.helper.Bootstrap.createSimpleServiceManager();
-
- XUnoUrlResolver aURLResolver = (XUnoUrlResolver) UnoRuntime.queryInterface(
- XUnoUrlResolver.class,
- aLocalServiceManager.createInstance( "com.sun.star.bridge.UnoUrlResolver" ) );
-
- XMultiServiceFactory aServiceManager = (XMultiServiceFactory) UnoRuntime.queryInterface(
- XMultiServiceFactory.class,
- aURLResolver.resolve( sConnectString ) );
-
- return aServiceManager;
- }
}