Kaydet (Commit) dc1efa90 authored tarafından Rüdiger Timm's avatar Rüdiger Timm

INTEGRATION: CWS sdksample (1.4.40); FILE MERGED

2005/01/21 10:57:44 jsc 1.4.40.5: #i29308# remove unnecessary comment
2005/01/11 11:09:58 jsc 1.4.40.4: #i36756# enable all three demos
2004/11/26 15:07:01 jsc 1.4.40.3: #i36756# set properties of shape object to old defaults
2004/08/06 14:37:02 jsc 1.4.40.2: #i29308# use System.err for error output
2004/06/10 13:24:39 jsc 1.4.40.1: #i29308# use of new UNO bootstrap feature
üst bfaf08f3
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: HelloTextTableShape.java,v $ * $RCSfile: HelloTextTableShape.java,v $
* *
* $Revision: 1.4 $ * $Revision: 1.5 $
* *
* last change: $Author: hr $ $Date: 2004-02-02 19:58:48 $ * last change: $Author: rt $ $Date: 2005-01-31 16:26:49 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* the BSD license. * the BSD license.
...@@ -82,12 +82,6 @@ import com.sun.star.container.XNamed; ...@@ -82,12 +82,6 @@ import com.sun.star.container.XNamed;
import com.sun.star.text.XBookmarksSupplier; import com.sun.star.text.XBookmarksSupplier;
import com.sun.star.text.XTextRange; import com.sun.star.text.XTextRange;
/*
* HelloTextTableShape.java
*
* Created on 5. April 2002, 21:25
*/
/** /**
* *
* @author dschulten * @author dschulten
...@@ -96,8 +90,6 @@ public class HelloTextTableShape { ...@@ -96,8 +90,6 @@ public class HelloTextTableShape {
private XComponentContext xRemoteContext = null; private XComponentContext xRemoteContext = null;
private XMultiComponentFactory xRemoteServiceManager = null; private XMultiComponentFactory xRemoteServiceManager = null;
private String unoUrl =
"uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager";
/** Creates a new instance of HelloTextTableShape */ /** Creates a new instance of HelloTextTableShape */
public HelloTextTableShape() { public HelloTextTableShape() {
...@@ -112,7 +104,7 @@ public class HelloTextTableShape { ...@@ -112,7 +104,7 @@ public class HelloTextTableShape {
helloTextTableShape1.useDocuments(); helloTextTableShape1.useDocuments();
} }
catch (java.lang.Exception e){ catch (java.lang.Exception e){
System.out.println(e.getMessage()); System.err.println(e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
finally { finally {
...@@ -431,22 +423,24 @@ public class HelloTextTableShape { ...@@ -431,22 +423,24 @@ public class HelloTextTableShape {
theLine = bord.TopLine; theLine = bord.TopLine;
int col = theLine.Color; int col = theLine.Color;
System.out.println(col); System.out.println(col);
} }
protected void manipulateShape(XShape xShape) throws com.sun.star.uno.Exception { protected void manipulateShape(XShape xShape) throws com.sun.star.uno.Exception {
XPropertySet xShapeProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xShape); XPropertySet xShapeProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xShape);
xShapeProps.setPropertyValue("FillColor", new Integer(0x99CCFF)); xShapeProps.setPropertyValue("FillColor", new Integer(0x99CCFF));
xShapeProps.setPropertyValue("LineColor", new Integer(0x000099)); xShapeProps.setPropertyValue("LineColor", new Integer(0x000099));
xShapeProps.setPropertyValue("RotateAngle", new Integer(3000)); xShapeProps.setPropertyValue("RotateAngle", new Integer(3000));
xShapeProps.setPropertyValue("TextLeftDistance", new Integer(0));
xShapeProps.setPropertyValue("TextRightDistance", new Integer(0));
xShapeProps.setPropertyValue("TextUpperDistance", new Integer(0));
xShapeProps.setPropertyValue("TextLowerDistance", new Integer(0));
} }
protected XComponent newDocComponent(String docType) throws java.lang.Exception { protected XComponent newDocComponent(String docType) throws java.lang.Exception {
String loadUrl = "private:factory/" + docType; String loadUrl = "private:factory/" + docType;
xRemoteServiceManager = this.getRemoteServiceManager(unoUrl); xRemoteServiceManager = this.getRemoteServiceManager();
Object desktop = xRemoteServiceManager.createInstanceWithContext( Object desktop = xRemoteServiceManager.createInstanceWithContext(
"com.sun.star.frame.Desktop", xRemoteContext); "com.sun.star.frame.Desktop", xRemoteContext);
XComponentLoader xComponentLoader = (XComponentLoader)UnoRuntime.queryInterface( XComponentLoader xComponentLoader = (XComponentLoader)UnoRuntime.queryInterface(
...@@ -455,31 +449,20 @@ public class HelloTextTableShape { ...@@ -455,31 +449,20 @@ public class HelloTextTableShape {
return xComponentLoader.loadComponentFromURL(loadUrl, "_blank", 0, loadProps); return xComponentLoader.loadComponentFromURL(loadUrl, "_blank", 0, loadProps);
} }
protected XMultiComponentFactory getRemoteServiceManager(String unoUrl) throws java.lang.Exception { protected XMultiComponentFactory getRemoteServiceManager() throws java.lang.Exception {
if (xRemoteContext == null) { if (xRemoteContext == null && xRemoteServiceManager == null) {
// First step: create local component context, get local servicemanager and try {
// ask it to create a UnoUrlResolver object with an XUnoUrlResolver interface // First step: get the remote office component context
XComponentContext xLocalContext = xRemoteContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(null); System.out.println("Connected to a running office ...");
XMultiComponentFactory xLocalServiceManager = xLocalContext.getServiceManager(); xRemoteServiceManager = xRemoteContext.getServiceManager();
}
Object urlResolver = xLocalServiceManager.createInstanceWithContext( catch( Exception e) {
"com.sun.star.bridge.UnoUrlResolver", xLocalContext ); e.printStackTrace();
// query XUnoUrlResolver interface from urlResolver object System.exit(1);
XUnoUrlResolver xUnoUrlResolver = (XUnoUrlResolver) UnoRuntime.queryInterface( }
XUnoUrlResolver.class, urlResolver );
// Second step: use xUrlResolver interface to import the remote StarOffice.ServiceManager,
// retrieve its property DefaultContext and get the remote servicemanager
Object initialObject = xUnoUrlResolver.resolve( unoUrl );
XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, initialObject);
Object context = xPropertySet.getPropertyValue("DefaultContext");
xRemoteContext = (XComponentContext)UnoRuntime.queryInterface(
XComponentContext.class, context);
} }
return xRemoteContext.getServiceManager(); return xRemoteServiceManager;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment