summaryrefslogtreecommitdiffstats
path: root/odk/examples/DevelopersGuide/Drawing
diff options
context:
space:
mode:
authorRĂ¼diger Timm <rt@openoffice.org>2005-01-31 15:21:17 +0000
committerRĂ¼diger Timm <rt@openoffice.org>2005-01-31 15:21:17 +0000
commitaba8925175f3ebe86b6aa0e3fc2188125b582607 (patch)
treec9617d4b8a2a8eb2decb49cfdc3d3de45bb77e1e /odk/examples/DevelopersGuide/Drawing
parentINTEGRATION: CWS sdksample (1.5.4); FILE MERGED (diff)
downloadcore-aba8925175f3ebe86b6aa0e3fc2188125b582607.tar.gz
core-aba8925175f3ebe86b6aa0e3fc2188125b582607.zip
INTEGRATION: CWS sdksample (1.4.40); FILE MERGED
2004/06/16 08:49:14 jsc 1.4.40.2: #i29308# explicit imports 2004/06/10 10:05:51 jsc 1.4.40.1: #i29308# use of new UNO bootstrap feature
Diffstat (limited to 'odk/examples/DevelopersGuide/Drawing')
-rw-r--r--odk/examples/DevelopersGuide/Drawing/ChangeOrderDemo.java46
-rw-r--r--odk/examples/DevelopersGuide/Drawing/ControlAndSelectDemo.java68
2 files changed, 53 insertions, 61 deletions
diff --git a/odk/examples/DevelopersGuide/Drawing/ChangeOrderDemo.java b/odk/examples/DevelopersGuide/Drawing/ChangeOrderDemo.java
index 1eb092f5f013..7f0de16b30a8 100644
--- a/odk/examples/DevelopersGuide/Drawing/ChangeOrderDemo.java
+++ b/odk/examples/DevelopersGuide/Drawing/ChangeOrderDemo.java
@@ -2,9 +2,9 @@
*
* $RCSfile: ChangeOrderDemo.java,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: hr $ $Date: 2004-02-02 19:52:33 $
+ * last change: $Author: rt $ $Date: 2005-01-31 16:21:03 $
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
@@ -40,31 +40,20 @@
// __________ Imports __________
-// base classes
import com.sun.star.uno.UnoRuntime;
-import com.sun.star.lang.*;
+import com.sun.star.lang.XComponent;
-// property access
-import com.sun.star.beans.*;
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
-// name access
-import com.sun.star.container.*;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
-// text
-import com.sun.star.text.*;
-import com.sun.star.style.*;
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.drawing.XDrawPage;
-// application specific classes
-import com.sun.star.drawing.*;
-
-// presentation specific classes
-import com.sun.star.presentation.*;
-
-// Point, Size, ..
-import com.sun.star.awt.*;
-import java.io.File;
-
// __________ Implementation __________
@@ -79,22 +68,19 @@ public class ChangeOrderDemo
XComponent xDrawDoc = null;
try
{
- String sConnection;
- if ( args.length >= 1 )
- sConnection = args[ 1 ];
- else
- sConnection = "uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager";
- XMultiServiceFactory xServiceFactory =
- Helper.connect( sConnection );
+ // get the remote office context of a running office (a new office
+ // instance is started if necessary)
+ com.sun.star.uno.XComponentContext xOfficeContext = Helper.connect();
// suppress Presentation Autopilot when opening the document
- // properties are the same as described for com.sun.star.document.MediaDescriptor
+ // properties are the same as described for
+ // com.sun.star.document.MediaDescriptor
PropertyValue[] pPropValues = new PropertyValue[ 1 ];
pPropValues[ 0 ] = new PropertyValue();
pPropValues[ 0 ].Name = "Silent";
pPropValues[ 0 ].Value = new Boolean( true );
- xDrawDoc = Helper.createDocument( xServiceFactory,
+ xDrawDoc = Helper.createDocument( xOfficeContext,
"private:factory/sdraw", "_blank", 0, pPropValues );
// create two rectangles
diff --git a/odk/examples/DevelopersGuide/Drawing/ControlAndSelectDemo.java b/odk/examples/DevelopersGuide/Drawing/ControlAndSelectDemo.java
index f3c3a5ed4879..f67252b9af30 100644
--- a/odk/examples/DevelopersGuide/Drawing/ControlAndSelectDemo.java
+++ b/odk/examples/DevelopersGuide/Drawing/ControlAndSelectDemo.java
@@ -2,9 +2,9 @@
*
* $RCSfile: ControlAndSelectDemo.java,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: hr $ $Date: 2004-02-02 19:52:50 $
+ * last change: $Author: rt $ $Date: 2005-01-31 16:21:17 $
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
@@ -40,24 +40,27 @@
// __________ Imports __________
-// base classes
import com.sun.star.uno.UnoRuntime;
-import com.sun.star.lang.*;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
-// property access
-import com.sun.star.beans.*;
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+import com.sun.star.awt.XControlModel;
-// application specific classes
-import com.sun.star.drawing.*;
+import com.sun.star.beans.PropertyValue;
-// XModel, XController
-import com.sun.star.frame.*;
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.drawing.XControlShape;
+import com.sun.star.drawing.XDrawPage;
+import com.sun.star.drawing.XDrawPages;
+import com.sun.star.drawing.XDrawPagesSupplier;
-// Point, Size
-import com.sun.star.awt.*;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XController;
-//
-import com.sun.star.view.*;
+import com.sun.star.view.XSelectionSupplier;
// __________ Implementation __________
@@ -76,22 +79,19 @@ public class ControlAndSelectDemo
XComponent xComponent = null;
try
{
- String sConnection;
- if ( args.length >= 1 )
- sConnection = args[ 0 ];
- else
- sConnection = "uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager";
- XMultiServiceFactory xServiceFactory =
- Helper.connect( sConnection );
+ // get the remote office context of a running office (a new office
+ // instance is started if necessary)
+ com.sun.star.uno.XComponentContext xOfficeContext = Helper.connect();
// suppress Presentation Autopilot when opening the document
- // properties are the same as described for com.sun.star.document.MediaDescriptor
+ // properties are the same as described for
+ // com.sun.star.document.MediaDescriptor
PropertyValue[] pPropValues = new PropertyValue[ 1 ];
pPropValues[ 0 ] = new PropertyValue();
pPropValues[ 0 ].Name = "Silent";
pPropValues[ 0 ].Value = new Boolean( true );
- xComponent = Helper.createDocument( xServiceFactory,
+ xComponent = Helper.createDocument( xOfficeContext,
"private:factory/sdraw", "_blank", 0, pPropValues );
XMultiServiceFactory xFactory =
@@ -104,33 +104,39 @@ public class ControlAndSelectDemo
XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages();
XDrawPage xDrawPage = (XDrawPage)UnoRuntime.queryInterface(
XDrawPage.class, xDrawPages.getByIndex( 0 ));
- XShapes xShapes = (XShapes)UnoRuntime.queryInterface( XShapes.class, xDrawPage );
+ XShapes xShapes = (XShapes)UnoRuntime.queryInterface(XShapes.class,
+ xDrawPage );
// create and insert the ControlShape
- Object xObj = xFactory.createInstance( "com.sun.star.drawing.ControlShape" );
+ Object xObj = xFactory.createInstance(
+ "com.sun.star.drawing.ControlShape" );
XShape xShape = (XShape)UnoRuntime.queryInterface( XShape.class, xObj );
xShape.setPosition( new Point( 1000, 1000 ) );
xShape.setSize( new Size( 2000, 2000 ) );
xShapes.add( xShape );
// create and set the control
- XControlModel xControlModel = (XControlModel)UnoRuntime.queryInterface( XControlModel.class,
+ XControlModel xControlModel = (XControlModel)UnoRuntime.queryInterface(
+ XControlModel.class,
xFactory.createInstance( "com.sun.star.form.component.GroupBox" ) );
- XControlShape xControlShape = (XControlShape)UnoRuntime.queryInterface( XControlShape.class, xShape );
+ XControlShape xControlShape = (XControlShape)UnoRuntime.queryInterface(
+ XControlShape.class, xShape );
xControlShape.setControl( xControlModel );
// the following code will demonstrate how to
// make a selection that contains our new created ControlShape
- XModel xModel = (XModel)UnoRuntime.queryInterface( XModel.class, xComponent );
+ XModel xModel = (XModel)UnoRuntime.queryInterface( XModel.class,
+ xComponent );
XController xController = xModel.getCurrentController();
XSelectionSupplier xSelectionSupplier =(XSelectionSupplier)
UnoRuntime.queryInterface( XSelectionSupplier.class, xController );
- // take care to use the global service factory only and not the one that is
- // provided by the component if you create the ShapeColletion
+ // take care to use the global service factory only and not the one
+ // that is provided by the component if you create the ShapeColletion
XShapes xSelection = (XShapes)UnoRuntime.queryInterface( XShapes.class,
- xServiceFactory.createInstance( "com.sun.star.drawing.ShapeCollection" ) );
+ xOfficeContext.getServiceManager().createInstanceWithContext(
+ "com.sun.star.drawing.ShapeCollection", xOfficeContext ) );
xSelection.add( xShape );
xSelectionSupplier.select( xSelection );
}