summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2005-01-31 15:25:38 +0000
committerRüdiger Timm <rt@openoffice.org>2005-01-31 15:25:38 +0000
commit2b474afb5d4928e97193fe673057fbd62b4624d7 (patch)
treefb7c1fa554d725f9013209ed76fecd32b511b1cf
parente863826c14fb2d459a8ea682a3e9176e8015501f (diff)
INTEGRATION: CWS sdksample (1.4.40); FILE MERGED
2004/06/16 08:49:17 jsc 1.4.40.2: #i29308# explicit imports 2004/06/10 10:05:55 jsc 1.4.40.1: #i29308# use of new UNO bootstrap feature
-rw-r--r--odk/examples/DevelopersGuide/Drawing/PresentationDemo.java61
-rw-r--r--odk/examples/DevelopersGuide/Drawing/StyleDemo.java76
-rw-r--r--odk/examples/DevelopersGuide/Drawing/TextDemo.java74
3 files changed, 108 insertions, 103 deletions
diff --git a/odk/examples/DevelopersGuide/Drawing/PresentationDemo.java b/odk/examples/DevelopersGuide/Drawing/PresentationDemo.java
index 69f63a98b603..5404ec6ed953 100644
--- a/odk/examples/DevelopersGuide/Drawing/PresentationDemo.java
+++ b/odk/examples/DevelopersGuide/Drawing/PresentationDemo.java
@@ -2,9 +2,9 @@
*
* $RCSfile: PresentationDemo.java,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: hr $ $Date: 2004-02-02 19:56:29 $
+ * last change: $Author: rt $ $Date: 2005-01-31 16:24:39 $
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
@@ -40,25 +40,25 @@
// __________ 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.XServiceInfo;
-// 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.text.*;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
-// application specific classes
-import com.sun.star.drawing.*;
+import com.sun.star.container.XNamed;
-// presentation specific classes
-import com.sun.star.presentation.*;
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.drawing.XDrawPage;
+
+import com.sun.star.presentation.XPresentation;
+import com.sun.star.presentation.XPresentationSupplier;
-// Point, Size, ..
-import com.sun.star.awt.*;
// __________ Implementation __________
@@ -80,22 +80,19 @@ public class PresentationDemo
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 );
@@ -122,10 +119,11 @@ public class PresentationDemo
xShapePropSet = ShapeHelper.createAndInsertShape( xDrawDoc,
xShapes,new Point( 1000, 1000 ), new Size( 5000, 5000 ),
"com.sun.star.drawing.RectangleShape" );
- xShapePropSet.setPropertyValue(
- "Effect", com.sun.star.presentation.AnimationEffect.WAVYLINE_FROM_BOTTOM );
+ xShapePropSet.setPropertyValue("Effect",
+ com.sun.star.presentation.AnimationEffect.WAVYLINE_FROM_BOTTOM );
- /* the following three properties provokes that the shape is dimmed to red
+ /* the following three properties provokes that the shape is dimmed
+ to red
after the animation has been finished */
xShapePropSet.setPropertyValue( "DimHide", new Boolean( false ) );
xShapePropSet.setPropertyValue( "DimPrevious", new Boolean( true ) );
@@ -169,8 +167,8 @@ public class PresentationDemo
ShapeHelper.addPortion( xShape, "to first page", true );
xShapePropSet = (XPropertySet)
UnoRuntime.queryInterface( XPropertySet.class, xShape );
- xShapePropSet.setPropertyValue(
- "Effect", com.sun.star.presentation.AnimationEffect.FADE_FROM_BOTTOM );
+ xShapePropSet.setPropertyValue("Effect",
+ com.sun.star.presentation.AnimationEffect.FADE_FROM_BOTTOM );
xShapePropSet.setPropertyValue(
"OnClick", com.sun.star.presentation.ClickAction.FIRSTPAGE );
@@ -183,8 +181,9 @@ public class PresentationDemo
ShapeHelper.addPortion( xShape, "to the second page", true );
xShapePropSet = (XPropertySet)
UnoRuntime.queryInterface( XPropertySet.class, xShape );
- xShapePropSet.setPropertyValue(
- "Effect", com.sun.star.presentation.AnimationEffect.FADE_FROM_BOTTOM );
+ xShapePropSet.setPropertyValue("Effect",
+ com.sun.star.presentation.AnimationEffect.FADE_FROM_BOTTOM );
+
xShapePropSet.setPropertyValue(
"OnClick", com.sun.star.presentation.ClickAction.BOOKMARK );
// set the name of page two, and use it with the bookmark action
diff --git a/odk/examples/DevelopersGuide/Drawing/StyleDemo.java b/odk/examples/DevelopersGuide/Drawing/StyleDemo.java
index a9adfff50467..c90e50ed7a3a 100644
--- a/odk/examples/DevelopersGuide/Drawing/StyleDemo.java
+++ b/odk/examples/DevelopersGuide/Drawing/StyleDemo.java
@@ -2,9 +2,9 @@
*
* $RCSfile: StyleDemo.java,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: hr $ $Date: 2004-02-02 19:57:05 $
+ * last change: $Author: rt $ $Date: 2005-01-31 16:25:23 $
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
@@ -40,24 +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;
+import com.sun.star.beans.XPropertySetInfo;
-// application specific classes
-import com.sun.star.drawing.*;
+import com.sun.star.container.XNameAccess;
-// size, point
-import com.sun.star.awt.*;
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.drawing.XDrawPage;
+import com.sun.star.drawing.XDrawPages;
+import com.sun.star.drawing.XDrawPagesSupplier;
-// XModel
-import com.sun.star.frame.*;
+import com.sun.star.frame.XModel;
@@ -74,22 +75,19 @@ public class StyleDemo
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/simpress", "_blank", 0, pPropValues );
@@ -101,8 +99,11 @@ public class StyleDemo
XModel xModel =
(XModel)UnoRuntime.queryInterface(
XModel.class, xComponent );
- com.sun.star.style.XStyleFamiliesSupplier xSFS = (com.sun.star.style.XStyleFamiliesSupplier)
- UnoRuntime.queryInterface( com.sun.star.style.XStyleFamiliesSupplier.class, xModel );
+ com.sun.star.style.XStyleFamiliesSupplier xSFS =
+ (com.sun.star.style.XStyleFamiliesSupplier)
+ UnoRuntime.queryInterface(
+ com.sun.star.style.XStyleFamiliesSupplier.class, xModel );
+
com.sun.star.container.XNameAccess xFamilies = xSFS.getStyleFamilies();
// the element should now contain at least two Styles. The first is
@@ -115,23 +116,28 @@ public class StyleDemo
// and now all available styles
Object aFamilyObj = xFamilies.getByName( Families[ i ] );
- com.sun.star.container.XNameAccess xStyles = (com.sun.star.container.XNameAccess)
- UnoRuntime.queryInterface( com.sun.star.container.XNameAccess.class, aFamilyObj );
+ com.sun.star.container.XNameAccess xStyles =
+ (com.sun.star.container.XNameAccess)
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XNameAccess.class, aFamilyObj );
String[] Styles = xStyles.getElementNames();
for( int j = 0; j < Styles.length; j++ )
{
System.out.println( " " + Styles[ j ] );
Object aStyleObj = xStyles.getByName( Styles[ j ] );
com.sun.star.style.XStyle xStyle = (com.sun.star.style.XStyle)
- UnoRuntime.queryInterface( com.sun.star.style.XStyle.class, aStyleObj );
- // now we have the XStyle Interface and the CharColor for all styles
- // is exemplary be set to red.
+ UnoRuntime.queryInterface(
+ com.sun.star.style.XStyle.class, aStyleObj );
+ // now we have the XStyle Interface and the CharColor for
+ // all styles is exemplary be set to red.
XPropertySet xStylePropSet = (XPropertySet)
UnoRuntime.queryInterface( XPropertySet.class, xStyle );
- XPropertySetInfo xStylePropSetInfo = xStylePropSet.getPropertySetInfo();
+ XPropertySetInfo xStylePropSetInfo =
+ xStylePropSet.getPropertySetInfo();
if ( xStylePropSetInfo.hasPropertyByName( "CharColor" ) )
{
- xStylePropSet.setPropertyValue( "CharColor", new Integer( 0xff0000 ) );
+ xStylePropSet.setPropertyValue( "CharColor",
+ new Integer( 0xff0000 ) );
}
}
}
@@ -143,7 +149,8 @@ public class StyleDemo
Object obj = xFamilies.getByName( "graphics" );
com.sun.star.container.XNameAccess xStyles = (XNameAccess)
- UnoRuntime.queryInterface( com.sun.star.container.XNameAccess.class, obj );
+ UnoRuntime.queryInterface(com.sun.star.container.XNameAccess.class,
+ obj );
obj = xStyles.getByName( "title1" );
com.sun.star.style.XStyle xTitle1Style = (com.sun.star.style.XStyle)
UnoRuntime.queryInterface( com.sun.star.style.XStyle.class, obj );
@@ -154,7 +161,8 @@ public class StyleDemo
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 );
XShape xShape = ShapeHelper.createShape( xComponent, new Point( 0, 0 ),
new Size( 5000, 5000 ), "com.sun.star.drawing.RectangleShape" );
xShapes.add( xShape );
diff --git a/odk/examples/DevelopersGuide/Drawing/TextDemo.java b/odk/examples/DevelopersGuide/Drawing/TextDemo.java
index 27fcab18e34b..c65e2abea7f3 100644
--- a/odk/examples/DevelopersGuide/Drawing/TextDemo.java
+++ b/odk/examples/DevelopersGuide/Drawing/TextDemo.java
@@ -2,9 +2,9 @@
*
* $RCSfile: TextDemo.java,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: hr $ $Date: 2004-02-02 19:57:37 $
+ * last change: $Author: rt $ $Date: 2005-01-31 16:25:38 $
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
@@ -40,29 +40,24 @@
// __________ 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;
+import com.sun.star.drawing.TextFitToSizeType;
-// application specific classes
-import com.sun.star.drawing.*;
+import com.sun.star.style.LineSpacing;
+import com.sun.star.style.LineSpacingMode;
+import com.sun.star.style.ParagraphAdjust;
-// presentation specific classes
-import com.sun.star.presentation.*;
-
-// Point, Size, ..
-import com.sun.star.awt.*;
-import java.io.File;
// __________ Implementation __________
@@ -78,22 +73,19 @@ public class TextDemo
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 );
XDrawPage xPage = PageHelper.getDrawPageByIndex( xDrawDoc, 0 );
@@ -124,13 +116,15 @@ public class TextDemo
xTextPropSet = ShapeHelper.addPortion( xRectangle, "Portion2", false );
xTextPropSet.setPropertyValue( "CharColor", new Integer( 0x8080ff ) );
aLineSpacing.Height = 100;
- ShapeHelper.setPropertyForLastParagraph( xRectangle, "ParaLineSpacing", aLineSpacing );
+ ShapeHelper.setPropertyForLastParagraph( xRectangle, "ParaLineSpacing",
+ aLineSpacing );
// second paragraph
xTextPropSet = ShapeHelper.addPortion( xRectangle, "Portion3", true );
xTextPropSet.setPropertyValue( "CharColor", new Integer( 0xff ) );
aLineSpacing.Height = 200;
- ShapeHelper.setPropertyForLastParagraph( xRectangle, "ParaLineSpacing", aLineSpacing );
+ ShapeHelper.setPropertyForLastParagraph( xRectangle, "ParaLineSpacing",
+ aLineSpacing );
@@ -142,15 +136,19 @@ public class TextDemo
xShapes.add( xRectangle );
xShapePropSet = (XPropertySet)
UnoRuntime.queryInterface( XPropertySet.class, xRectangle );
- xShapePropSet.setPropertyValue( "TextFitToSize", TextFitToSizeType.PROPORTIONAL );
- xShapePropSet.setPropertyValue( "TextLeftDistance", new Integer( 2500 ) );
- xShapePropSet.setPropertyValue( "TextRightDistance", new Integer( 2500 ) );
- xShapePropSet.setPropertyValue( "TextUpperDistance", new Integer( 2500 ) );
- xShapePropSet.setPropertyValue( "TextLowerDistance", new Integer( 2500 ) );
- xTextPropSet = ShapeHelper.addPortion( xRectangle, "using TextFitToSize", false );
+ xShapePropSet.setPropertyValue( "TextFitToSize",
+ TextFitToSizeType.PROPORTIONAL );
+ xShapePropSet.setPropertyValue( "TextLeftDistance", new Integer(2500));
+ xShapePropSet.setPropertyValue( "TextRightDistance", new Integer(2500));
+ xShapePropSet.setPropertyValue( "TextUpperDistance", new Integer(2500));
+ xShapePropSet.setPropertyValue( "TextLowerDistance", new Integer(2500));
+ xTextPropSet = ShapeHelper.addPortion( xRectangle,
+ "using TextFitToSize", false );
xTextPropSet.setPropertyValue( "ParaAdjust", ParagraphAdjust.CENTER );
- xTextPropSet.setPropertyValue( "CharColor", new Integer( 0xff00 ) );
- xTextPropSet = ShapeHelper.addPortion( xRectangle, "and a Border distance of 2,5 cm", true );
+ xTextPropSet.setPropertyValue( "CharColor", new Integer(0xff00));
+ xTextPropSet = ShapeHelper.addPortion(xRectangle,
+ "and a Border distance of 2,5 cm",
+ true );
xTextPropSet.setPropertyValue( "CharColor", new Integer( 0xff0000 ) );
}