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

INTEGRATION: CWS sdksample (1.4.40); FILE MERGED

2004/06/16 08:49:16 jsc 1.4.40.2: #i29308# explicit imports
2004/06/10 10:05:54 jsc 1.4.40.1: #i29308# use of new UNO bootstrap feature
üst 3f6949f3
......@@ -2,9 +2,9 @@
*
* $RCSfile: LayerDemo.java,v $
*
* $Revision: 1.4 $
* $Revision: 1.5 $
*
* last change: $Author: hr $ $Date: 2004-02-02 19:55:22 $
* last change: $Author: rt $ $Date: 2005-01-31 16:23:20 $
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
......@@ -40,30 +40,25 @@
// __________ 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.container.XNameAccess;
import com.sun.star.style.ParagraphAdjust;
// 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;
import com.sun.star.drawing.XShape;
import com.sun.star.drawing.XShapes;
import com.sun.star.drawing.XDrawPage;
import com.sun.star.drawing.XLayer;
import com.sun.star.drawing.XLayerManager;
import com.sun.star.drawing.XLayerSupplier;
// __________ Implementation __________
......@@ -79,22 +74,19 @@ public class LayerDemo
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 );
......@@ -113,10 +105,15 @@ public class LayerDemo
xShapes.add( xRect1 );
xShapes.add( xRect2 );
XPropertySet xTextProp = ShapeHelper.addPortion( xRect2, "this shape is locked", false );
XPropertySet xTextProp = ShapeHelper.addPortion( xRect2,
"this shape is locked",
false );
xTextProp.setPropertyValue( "ParaAdjust", ParagraphAdjust.CENTER );
ShapeHelper.addPortion( xRect2, "and the shape above is not visible", true );
ShapeHelper.addPortion( xRect2, "(switch to the layer view to gain access)", true );
ShapeHelper.addPortion( xRect2, "and the shape above is not visible",
true );
ShapeHelper.addPortion( xRect2,
"(switch to the layer view to gain access)",
true );
// query for the XLayerManager
......@@ -130,7 +127,9 @@ public class LayerDemo
// create a layer and set its properties
XPropertySet xLayerPropSet;
XLayer xNotVisibleAndEditable = xLayerManager.insertNewByIndex( xLayerManager.getCount() );
XLayer xNotVisibleAndEditable = xLayerManager.insertNewByIndex(
xLayerManager.getCount() );
xLayerPropSet = (XPropertySet)
(XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, xNotVisibleAndEditable );
......@@ -139,7 +138,9 @@ public class LayerDemo
xLayerPropSet.setPropertyValue( "IsLocked", new Boolean( true ) );
// create a second layer
XLayer xNotEditable = xLayerManager.insertNewByIndex( xLayerManager.getCount() );
XLayer xNotEditable = xLayerManager.insertNewByIndex(
xLayerManager.getCount() );
xLayerPropSet = (XPropertySet)
(XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, xNotEditable );
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: ObjectTransformationDemo.java,v $
*
* $Revision: 1.4 $
* $Revision: 1.5 $
*
* last change: $Author: hr $ $Date: 2004-02-02 19:55:45 $
* last change: $Author: rt $ $Date: 2005-01-31 16:23:56 $
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
......@@ -40,29 +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;
import com.sun.star.drawing.XShape;
import com.sun.star.drawing.XShapes;
import com.sun.star.drawing.XDrawPage;
import com.sun.star.drawing.HomogenMatrix3;
// 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;
//
import java.awt.geom.AffineTransform;
// __________ Implementation __________
......@@ -78,26 +69,23 @@ public class ObjectTransformationDemo
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/simpress", "_blank", 0, pPropValues );
XDrawPage xPage = PageHelper.getDrawPageByIndex( xDrawDoc, 0 );
XPropertySet xPagePropSet= (XPropertySet)
XDrawPage xPage = PageHelper.getDrawPageByIndex( xDrawDoc, 0 );
XPropertySet xPagePropSet= (XPropertySet)
UnoRuntime.queryInterface( XPropertySet.class, xPage );
XShapes xShapes = (XShapes)
......@@ -112,11 +100,14 @@ public class ObjectTransformationDemo
XPropertySet xPropSet = (XPropertySet)
UnoRuntime.queryInterface( XPropertySet.class, xShape );
HomogenMatrix3 aHomogenMatrix3 = (HomogenMatrix3)xPropSet.getPropertyValue( "Transformation" );
java.awt.geom.AffineTransform aOriginalMatrix = new java.awt.geom.AffineTransform(
aHomogenMatrix3.Line1.Column1, aHomogenMatrix3.Line2.Column1,
HomogenMatrix3 aHomogenMatrix3 = (HomogenMatrix3)
xPropSet.getPropertyValue( "Transformation" );
java.awt.geom.AffineTransform aOriginalMatrix =
new java.awt.geom.AffineTransform(
aHomogenMatrix3.Line1.Column1, aHomogenMatrix3.Line2.Column1,
aHomogenMatrix3.Line1.Column2, aHomogenMatrix3.Line2.Column2,
aHomogenMatrix3.Line1.Column3, aHomogenMatrix3.Line2.Column3 );
aHomogenMatrix3.Line1.Column3, aHomogenMatrix3.Line2.Column3 );
AffineTransform aNewMatrix1 = new AffineTransform();
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: Organigram.java,v $
*
* $Revision: 1.4 $
* $Revision: 1.5 $
*
* last change: $Author: hr $ $Date: 2004-02-02 19:56:05 $
* last change: $Author: rt $ $Date: 2005-01-31 16:24:11 $
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
......@@ -38,15 +38,20 @@
*
*************************************************************************/
import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet;
import com.sun.star.bridge.XUnoUrlResolver;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.XComponentContext;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.beans.XPropertySet;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.beans.PropertyValue;
/*
* OpenQuery.java
......@@ -83,30 +88,38 @@ public class Organigram {
}
}
public void drawOrganigram() throws java.lang.Exception {
xRemoteServiceManager = this.getRemoteServiceManager(
"uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager");
// get the remote office component context
xRemoteContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
System.out.println("Connected to a running office ...");
// get the remote service manager
xRemoteServiceManager = xRemoteContext.getServiceManager();
Object desktop = xRemoteServiceManager.createInstanceWithContext(
"com.sun.star.frame.Desktop", xRemoteContext);
XComponentLoader xComponentLoader = (XComponentLoader)UnoRuntime.queryInterface(
XComponentLoader.class, desktop);
XComponentLoader xComponentLoader = (XComponentLoader)
UnoRuntime.queryInterface(XComponentLoader.class, desktop);
PropertyValue[] loadProps = new PropertyValue[0];
XComponent xDrawComponent = xComponentLoader.loadComponentFromURL("private:factory/sdraw", "_blank", 0, loadProps);
XComponent xDrawComponent = xComponentLoader.loadComponentFromURL(
"private:factory/sdraw", "_blank", 0, loadProps);
// get draw page by index
com.sun.star.drawing.XDrawPagesSupplier xDrawPagesSupplier = (com.sun.star.drawing.XDrawPagesSupplier)UnoRuntime.queryInterface(
com.sun.star.drawing.XDrawPagesSupplier.class, xDrawComponent );
com.sun.star.drawing.XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages();
com.sun.star.drawing.XDrawPagesSupplier xDrawPagesSupplier =
(com.sun.star.drawing.XDrawPagesSupplier)UnoRuntime.queryInterface(
com.sun.star.drawing.XDrawPagesSupplier.class, xDrawComponent );
com.sun.star.drawing.XDrawPages xDrawPages =
xDrawPagesSupplier.getDrawPages();
Object drawPage = xDrawPages.getByIndex(0);
com.sun.star.drawing.XDrawPage xDrawPage = (com.sun.star.drawing.XDrawPage)
UnoRuntime.queryInterface(com.sun.star.drawing.XDrawPage.class, drawPage);
UnoRuntime.queryInterface(com.sun.star.drawing.XDrawPage.class,
drawPage);
com.sun.star.lang.XMultiServiceFactory xDocumentFactory = (com.sun.star.lang.XMultiServiceFactory)
UnoRuntime.queryInterface(
com.sun.star.lang.XMultiServiceFactory xDocumentFactory =
(com.sun.star.lang.XMultiServiceFactory)UnoRuntime.queryInterface(
com.sun.star.lang.XMultiServiceFactory.class, xDrawComponent);
com.sun.star.beans.XPropertySet xPageProps = (com.sun.star.beans.XPropertySet)
UnoRuntime.queryInterface(
com.sun.star.beans.XPropertySet xPageProps =
(com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface(
com.sun.star.beans.XPropertySet.class, xDrawPage);
int pageWidth = AnyConverter.toInt(xPageProps.getPropertyValue("Width"));
......@@ -141,7 +154,9 @@ public class Organigram {
for (int level = 0; level <= 1; level++) {
levelY = pageBorderTop + 2000 + level * (shapeHeight + verSpace);
for (int i = levelCount[level] - 1; i > -1; i--) {
shapeX = horCenter - (levelCount[level] * shapeWidth + (levelCount[level] - 1) * horSpace) / 2 + i * shapeWidth + i * horSpace;
shapeX = horCenter - (levelCount[level] * shapeWidth +
(levelCount[level] - 1) * horSpace) / 2
+ i * shapeWidth + i * horSpace;
Object shape = xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
com.sun.star.drawing.XShape xShape = (com.sun.star.drawing.XShape)
UnoRuntime.queryInterface(
......@@ -162,51 +177,21 @@ public class Organigram {
if (level == 1) {
Object connector = xDocumentFactory.createInstance("com.sun.star.drawing.ConnectorShape");
com.sun.star.beans.XPropertySet xConnectorProps = (com.sun.star.beans.XPropertySet)
UnoRuntime.queryInterface(
com.sun.star.beans.XPropertySet xConnectorProps =
(com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface(
com.sun.star.beans.XPropertySet.class, connector);
com.sun.star.drawing.XShape xConnector = (com.sun.star.drawing.XShape)
UnoRuntime.queryInterface(
com.sun.star.drawing.XShape xConnector =
(com.sun.star.drawing.XShape)UnoRuntime.queryInterface(
com.sun.star.drawing.XShape.class, connector);
xDrawPage.add(xConnector);
xConnectorProps.setPropertyValue("StartShape", xStartShape);
xConnectorProps.setPropertyValue("EndShape", xShape);
xConnectorProps.setPropertyValue("StartGluePointIndex", new Integer(2)); // 2 = bottom glue point
xConnectorProps.setPropertyValue("EndGluePointIndex", new Integer(0)); // 0 = top glue point
xConnectorProps.setPropertyValue("StartGluePointIndex",
new Integer(2)); // 2 = bottom glue point
xConnectorProps.setPropertyValue("EndGluePointIndex",
new Integer(0)); // 0 = top glue point
}
}
}
}
protected XMultiComponentFactory getRemoteServiceManager(String unoUrl) throws java.lang.Exception {
if (xRemoteContext == null) {
// First step: create local component context, get local servicemanager and
// ask it to create a UnoUrlResolver object with an XUnoUrlResolver interface
XComponentContext xLocalContext =
com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(null);
XMultiComponentFactory xLocalServiceManager = xLocalContext.getServiceManager();
Object urlResolver = xLocalServiceManager.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver", xLocalContext );
// query XUnoUrlResolver interface from urlResolver object
XUnoUrlResolver xUnoUrlResolver = (XUnoUrlResolver) UnoRuntime.queryInterface(
XUnoUrlResolver.class, urlResolver );
//XUnoUrlResolver xUnoUrlResolver = (XUnoUrlResolver)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();
}
}
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