summaryrefslogtreecommitdiff
path: root/odk/examples/java
diff options
context:
space:
mode:
Diffstat (limited to 'odk/examples/java')
-rw-r--r--odk/examples/java/ConverterServlet/ConverterServlet.java28
-rw-r--r--odk/examples/java/DocumentHandling/DocumentConverter.java17
-rw-r--r--odk/examples/java/DocumentHandling/DocumentLoader.java5
-rw-r--r--odk/examples/java/DocumentHandling/DocumentPrinter.java9
-rw-r--r--odk/examples/java/DocumentHandling/DocumentSaver.java19
-rw-r--r--odk/examples/java/Drawing/SDraw.java49
-rw-r--r--odk/examples/java/NotesAccess/NotesAccess.java19
-rw-r--r--odk/examples/java/Spreadsheet/CalcAddins.java4
-rw-r--r--odk/examples/java/Spreadsheet/ChartTypeChange.java65
-rw-r--r--odk/examples/java/Spreadsheet/EuroAdaption.java46
-rw-r--r--odk/examples/java/Spreadsheet/SCalc.java53
-rw-r--r--odk/examples/java/Storage/StorageFunctionality.java27
-rw-r--r--odk/examples/java/Storage/Test01.java8
-rw-r--r--odk/examples/java/Storage/Test02.java8
-rw-r--r--odk/examples/java/Storage/Test03.java8
-rw-r--r--odk/examples/java/Storage/Test04.java10
-rw-r--r--odk/examples/java/Storage/Test05.java6
-rw-r--r--odk/examples/java/Storage/Test06.java4
-rw-r--r--odk/examples/java/Storage/Test07.java10
-rw-r--r--odk/examples/java/Storage/Test08.java12
-rw-r--r--odk/examples/java/Storage/Test09.java8
-rw-r--r--odk/examples/java/Storage/TestHelper.java44
-rw-r--r--odk/examples/java/Text/BookmarkInsertion.java50
-rw-r--r--odk/examples/java/Text/GraphicsInserter.java27
-rw-r--r--odk/examples/java/Text/HardFormatting.java42
-rw-r--r--odk/examples/java/Text/SWriter.java42
-rw-r--r--odk/examples/java/Text/StyleCreation.java34
-rw-r--r--odk/examples/java/Text/StyleInitialization.java59
-rw-r--r--odk/examples/java/Text/TextDocumentStructure.java58
-rw-r--r--odk/examples/java/Text/TextReplace.java33
-rw-r--r--odk/examples/java/Text/WriterSelector.java48
31 files changed, 382 insertions, 470 deletions
diff --git a/odk/examples/java/ConverterServlet/ConverterServlet.java b/odk/examples/java/ConverterServlet/ConverterServlet.java
index 526e9281ef01..2a3688c4ead9 100644
--- a/odk/examples/java/ConverterServlet/ConverterServlet.java
+++ b/odk/examples/java/ConverterServlet/ConverterServlet.java
@@ -228,9 +228,8 @@ public class ConverterServlet extends HttpServlet {
"com.sun.star.bridge.UnoUrlResolver", xcomponentcontext );
// Create a new url resolver
- XUnoUrlResolver xurlresolver = ( XUnoUrlResolver )
- UnoRuntime.queryInterface( XUnoUrlResolver.class,
- objectUrlResolver );
+ XUnoUrlResolver xurlresolver = UnoRuntime.queryInterface( XUnoUrlResolver.class,
+ objectUrlResolver );
// Resolves an object that is specified as follow:
// uno:<connection description>;<protocol description>;<initial object name>
@@ -239,29 +238,26 @@ public class ConverterServlet extends HttpServlet {
";urp;StarOffice.ServiceManager" );
// Create a service manager from the initial object
- xmulticomponentfactory = ( XMultiComponentFactory )
- UnoRuntime.queryInterface( XMultiComponentFactory.class, objectInitial );
+ xmulticomponentfactory = UnoRuntime.queryInterface( XMultiComponentFactory.class, objectInitial );
// Query for the XPropertySet interface.
- XPropertySet xpropertysetMultiComponentFactory = ( XPropertySet )
- UnoRuntime.queryInterface( XPropertySet.class, xmulticomponentfactory );
+ XPropertySet xpropertysetMultiComponentFactory = UnoRuntime.queryInterface( XPropertySet.class, xmulticomponentfactory );
// Get the default context from the office server.
Object objectDefaultContext =
xpropertysetMultiComponentFactory.getPropertyValue( "DefaultContext" );
// Query for the interface XComponentContext.
- xcomponentcontext = ( XComponentContext ) UnoRuntime.queryInterface(
+ xcomponentcontext = UnoRuntime.queryInterface(
XComponentContext.class, objectDefaultContext );
/* A desktop environment contains tasks with one or more
frames in which components can be loaded. Desktop is the
environment for components which can instanciate within
frames. */
- XComponentLoader xcomponentloader = ( XComponentLoader )
- UnoRuntime.queryInterface( XComponentLoader.class,
- xmulticomponentfactory.createInstanceWithContext(
- "com.sun.star.frame.Desktop", xcomponentcontext ) );
+ XComponentLoader xcomponentloader = UnoRuntime.queryInterface( XComponentLoader.class,
+ xmulticomponentfactory.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xcomponentcontext ) );
// Preparing properties for loading the document
PropertyValue propertyvalue[] = new PropertyValue[ 1 ];
@@ -277,8 +273,8 @@ public class ConverterServlet extends HttpServlet {
// Getting an object that will offer a simple way to store a document to a URL.
XStorable xstorable =
- ( XStorable ) UnoRuntime.queryInterface( XStorable.class,
- objectDocumentToStore );
+ UnoRuntime.queryInterface( XStorable.class,
+ objectDocumentToStore );
// Preparing properties for converting the document
propertyvalue = new PropertyValue[ 2 ];
@@ -302,7 +298,7 @@ public class ConverterServlet extends HttpServlet {
// Storing and converting the document
xstorable.storeAsURL( stringConvertedFile, propertyvalue );
- XCloseable xcloseable = (XCloseable)UnoRuntime.queryInterface( XCloseable.class,xstorable );
+ XCloseable xcloseable = UnoRuntime.queryInterface( XCloseable.class,xstorable );
// Closing the converted document
if ( xcloseable != null )
@@ -310,7 +306,7 @@ public class ConverterServlet extends HttpServlet {
else {
// If Xcloseable is not supported (older versions,
// use dispose() for closing the document
- XComponent xComponent = ( XComponent ) UnoRuntime.queryInterface(
+ XComponent xComponent = UnoRuntime.queryInterface(
XComponent.class, xstorable );
xComponent.dispose();
}
diff --git a/odk/examples/java/DocumentHandling/DocumentConverter.java b/odk/examples/java/DocumentHandling/DocumentConverter.java
index b6bbdbe7d957..aeb6f022d2ca 100644
--- a/odk/examples/java/DocumentHandling/DocumentConverter.java
+++ b/odk/examples/java/DocumentHandling/DocumentConverter.java
@@ -112,8 +112,8 @@ public class DocumentConverter {
// Getting an object that will offer a simple way to store
// a document to a URL.
com.sun.star.frame.XStorable xStorable =
- (com.sun.star.frame.XStorable)UnoRuntime.queryInterface(
- com.sun.star.frame.XStorable.class, oDocToStore );
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XStorable.class, oDocToStore );
// Preparing properties for converting the document
propertyValues = new com.sun.star.beans.PropertyValue[2];
@@ -138,15 +138,15 @@ public class DocumentConverter {
// Closing the converted document. Use XCloseable.clsoe if the
// interface is supported, otherwise use XComponent.dispose
com.sun.star.util.XCloseable xCloseable =
- (com.sun.star.util.XCloseable)UnoRuntime.queryInterface(
- com.sun.star.util.XCloseable.class, xStorable);
+ UnoRuntime.queryInterface(
+ com.sun.star.util.XCloseable.class, xStorable);
if ( xCloseable != null ) {
xCloseable.close(false);
} else {
com.sun.star.lang.XComponent xComp =
- (com.sun.star.lang.XComponent)UnoRuntime.queryInterface(
- com.sun.star.lang.XComponent.class, xStorable);
+ UnoRuntime.queryInterface(
+ com.sun.star.lang.XComponent.class, xStorable);
xComp.dispose();
}
@@ -194,9 +194,8 @@ public class DocumentConverter {
Object oDesktop = xMCF.createInstanceWithContext(
"com.sun.star.frame.Desktop", xContext);
- xCompLoader = (com.sun.star.frame.XComponentLoader)
- UnoRuntime.queryInterface(com.sun.star.frame.XComponentLoader.class,
- oDesktop);
+ xCompLoader = UnoRuntime.queryInterface(com.sun.star.frame.XComponentLoader.class,
+ oDesktop);
// Getting the given starting directory
File file = new File(args[0]);
diff --git a/odk/examples/java/DocumentHandling/DocumentLoader.java b/odk/examples/java/DocumentHandling/DocumentLoader.java
index 8185cbf6da5f..2f01046d21b4 100644
--- a/odk/examples/java/DocumentHandling/DocumentLoader.java
+++ b/odk/examples/java/DocumentHandling/DocumentLoader.java
@@ -63,9 +63,8 @@ public class DocumentLoader {
"com.sun.star.frame.Desktop", xContext);
com.sun.star.frame.XComponentLoader xCompLoader =
- (com.sun.star.frame.XComponentLoader)
- UnoRuntime.queryInterface(
- com.sun.star.frame.XComponentLoader.class, oDesktop);
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XComponentLoader.class, oDesktop);
String sUrl = args[0];
if ( sUrl.indexOf("private:") != 0) {
diff --git a/odk/examples/java/DocumentHandling/DocumentPrinter.java b/odk/examples/java/DocumentHandling/DocumentPrinter.java
index e6a7a1430d4e..cc851123efc2 100644
--- a/odk/examples/java/DocumentHandling/DocumentPrinter.java
+++ b/odk/examples/java/DocumentHandling/DocumentPrinter.java
@@ -61,9 +61,8 @@ public class DocumentPrinter {
"com.sun.star.frame.Desktop", xContext);
com.sun.star.frame.XComponentLoader xCompLoader =
- (com.sun.star.frame.XComponentLoader)
- UnoRuntime.queryInterface(
- com.sun.star.frame.XComponentLoader.class, oDesktop);
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XComponentLoader.class, oDesktop);
java.io.File sourceFile = new java.io.File(args[1]);
StringBuffer sUrl = new StringBuffer("file:///");
@@ -76,8 +75,8 @@ public class DocumentPrinter {
// Querying for the interface XPrintable on the loaded document
com.sun.star.view.XPrintable xPrintable =
- (com.sun.star.view.XPrintable)UnoRuntime.queryInterface(
- com.sun.star.view.XPrintable.class, xComp);
+ UnoRuntime.queryInterface(
+ com.sun.star.view.XPrintable.class, xComp);
// Setting the property "Name" for the favoured printer (name of
// IP address)
diff --git a/odk/examples/java/DocumentHandling/DocumentSaver.java b/odk/examples/java/DocumentHandling/DocumentSaver.java
index f6f21ea48228..052b344a3d2e 100644
--- a/odk/examples/java/DocumentHandling/DocumentSaver.java
+++ b/odk/examples/java/DocumentHandling/DocumentSaver.java
@@ -71,9 +71,8 @@ public class DocumentSaver {
"com.sun.star.frame.Desktop", xContext);
com.sun.star.frame.XComponentLoader xCompLoader =
- (com.sun.star.frame.XComponentLoader)
- UnoRuntime.queryInterface(
- com.sun.star.frame.XComponentLoader.class, oDesktop);
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XComponentLoader.class, oDesktop);
java.io.File sourceFile = new java.io.File(args[0]);
StringBuffer sLoadUrl = new StringBuffer("file:///");
@@ -92,8 +91,8 @@ public class DocumentSaver {
Object oDocToStore = xCompLoader.loadComponentFromURL(
sLoadUrl.toString(), "_blank", 0, propertyValue );
com.sun.star.frame.XStorable xStorable =
- (com.sun.star.frame.XStorable)UnoRuntime.queryInterface(
- com.sun.star.frame.XStorable.class, oDocToStore );
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XStorable.class, oDocToStore );
propertyValue = new com.sun.star.beans.PropertyValue[ 2 ];
propertyValue[0] = new com.sun.star.beans.PropertyValue();
@@ -107,17 +106,15 @@ public class DocumentSaver {
System.out.println("\nDocument \"" + sLoadUrl + "\" saved under \"" +
sSaveUrl + "\"\n");
- com.sun.star.util.XCloseable xCloseable = (com.sun.star.util.XCloseable)
- UnoRuntime.queryInterface(com.sun.star.util.XCloseable.class,
- oDocToStore );
+ com.sun.star.util.XCloseable xCloseable = UnoRuntime.queryInterface(com.sun.star.util.XCloseable.class,
+ oDocToStore );
if (xCloseable != null ) {
xCloseable.close(false);
} else
{
- com.sun.star.lang.XComponent xComp = (com.sun.star.lang.XComponent)
- UnoRuntime.queryInterface(
- com.sun.star.lang.XComponent.class, oDocToStore );
+ com.sun.star.lang.XComponent xComp = UnoRuntime.queryInterface(
+ com.sun.star.lang.XComponent.class, oDocToStore );
xComp.dispose();
}
System.out.println("document closed!");
diff --git a/odk/examples/java/Drawing/SDraw.java b/odk/examples/java/Drawing/SDraw.java
index dfb544e3db02..5f56dc25d541 100644
--- a/odk/examples/java/Drawing/SDraw.java
+++ b/odk/examples/java/Drawing/SDraw.java
@@ -92,13 +92,13 @@ public class SDraw {
try {
System.out.println( "getting Drawpage" );
com.sun.star.drawing.XDrawPagesSupplier xDPS =
- (com.sun.star.drawing.XDrawPagesSupplier)UnoRuntime.queryInterface(
- com.sun.star.drawing.XDrawPagesSupplier.class, xDrawDoc);
+ UnoRuntime.queryInterface(
+ com.sun.star.drawing.XDrawPagesSupplier.class, xDrawDoc);
com.sun.star.drawing.XDrawPages xDPn = xDPS.getDrawPages();
com.sun.star.container.XIndexAccess xDPi =
- (com.sun.star.container.XIndexAccess)UnoRuntime.queryInterface(
- com.sun.star.container.XIndexAccess.class, xDPn);
- xDrawPage = (com.sun.star.drawing.XDrawPage)UnoRuntime.queryInterface(
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XIndexAccess.class, xDPn);
+ xDrawPage = UnoRuntime.queryInterface(
com.sun.star.drawing.XDrawPage.class, xDPi.getByIndex(0));
} catch ( Exception e ) {
System.err.println( "Couldn't create document"+ e );
@@ -109,9 +109,8 @@ public class SDraw {
//put something on the drawpage
System.out.println( "inserting some Shapes" );
- com.sun.star.drawing.XShapes xShapes = (com.sun.star.drawing.XShapes)
- UnoRuntime.queryInterface(
- com.sun.star.drawing.XShapes.class, xDrawPage);
+ com.sun.star.drawing.XShapes xShapes = UnoRuntime.queryInterface(
+ com.sun.star.drawing.XShapes.class, xDrawPage);
xShapes.add(createShape(xDrawDoc,2000,1500,1000,1000,"Line",0));
xShapes.add(createShape(xDrawDoc,3000,4500,15000,1000,"Ellipse",16711680));
xShapes.add(createShape(xDrawDoc,5000,3500,7500,5000,"Rectangle",6710932));
@@ -136,9 +135,8 @@ public class SDraw {
Object oDesktop = xMCF.createInstanceWithContext(
"com.sun.star.frame.Desktop", xContext);
- xCLoader = (com.sun.star.frame.XComponentLoader)
- UnoRuntime.queryInterface(com.sun.star.frame.XComponentLoader.class,
- oDesktop);
+ xCLoader = UnoRuntime.queryInterface(com.sun.star.frame.XComponentLoader.class,
+ oDesktop);
com.sun.star.beans.PropertyValue szEmptyArgs[] =
new com.sun.star.beans.PropertyValue[0];
String strDoc = "private:factory/sdraw";
@@ -163,13 +161,13 @@ public class SDraw {
//get MSF
com.sun.star.lang.XMultiServiceFactory xDocMSF =
- (com.sun.star.lang.XMultiServiceFactory) UnoRuntime.queryInterface(
- com.sun.star.lang.XMultiServiceFactory.class, xDocComp );
+ UnoRuntime.queryInterface(
+ com.sun.star.lang.XMultiServiceFactory.class, xDocComp );
try {
Object oInt = xDocMSF.createInstance("com.sun.star.drawing."
+kind + "Shape");
- xShape = (com.sun.star.drawing.XShape)UnoRuntime.queryInterface(
+ xShape = UnoRuntime.queryInterface(
com.sun.star.drawing.XShape.class, oInt);
size.Height = height;
size.Width = width;
@@ -183,9 +181,8 @@ public class SDraw {
e.printStackTrace(System.err);
}
- com.sun.star.beans.XPropertySet xSPS = (com.sun.star.beans.XPropertySet)
- UnoRuntime.queryInterface(
- com.sun.star.beans.XPropertySet.class, xShape);
+ com.sun.star.beans.XPropertySet xSPS = UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xShape);
try {
xSPS.setPropertyValue("FillColor", new Integer(col));
@@ -203,8 +200,7 @@ public class SDraw {
com.sun.star.awt.Size size = new com.sun.star.awt.Size();
com.sun.star.awt.Point position = new com.sun.star.awt.Point();
com.sun.star.drawing.XShape xShape = null;
- com.sun.star.drawing.XShapes xShapes = (com.sun.star.drawing.XShapes)
- UnoRuntime.queryInterface(com.sun.star.drawing.XShapes.class, xDP);
+ com.sun.star.drawing.XShapes xShapes = UnoRuntime.queryInterface(com.sun.star.drawing.XShapes.class, xDP);
int height = 3000;
int width = 3500;
int x = 1900;
@@ -216,13 +212,13 @@ public class SDraw {
//get MSF
com.sun.star.lang.XMultiServiceFactory xDocMSF =
- (com.sun.star.lang.XMultiServiceFactory)UnoRuntime.queryInterface(
- com.sun.star.lang.XMultiServiceFactory.class, xDocComp );
+ UnoRuntime.queryInterface(
+ com.sun.star.lang.XMultiServiceFactory.class, xDocComp );
for (int i=0; i<370; i=i+25) {
try{
oInt = xDocMSF.createInstance("com.sun.star.drawing.EllipseShape");
- xShape = (com.sun.star.drawing.XShape)UnoRuntime.queryInterface(
+ xShape = UnoRuntime.queryInterface(
com.sun.star.drawing.XShape.class, oInt);
size.Height = height;
size.Width = width;
@@ -240,9 +236,8 @@ public class SDraw {
b=b+8;
- com.sun.star.beans.XPropertySet xSPS = (com.sun.star.beans.XPropertySet)
- UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class,
- xShape);
+ com.sun.star.beans.XPropertySet xSPS = UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class,
+ xShape);
try {
xSPS.setPropertyValue("FillColor", new Integer(getCol(r,g,b)));
@@ -255,8 +250,8 @@ public class SDraw {
}
com.sun.star.drawing.XShapeGrouper xSGrouper =
- (com.sun.star.drawing.XShapeGrouper)UnoRuntime.queryInterface(
- com.sun.star.drawing.XShapeGrouper.class, xDP);
+ UnoRuntime.queryInterface(
+ com.sun.star.drawing.XShapeGrouper.class, xDP);
xShape = xSGrouper.group(xShapes);
diff --git a/odk/examples/java/NotesAccess/NotesAccess.java b/odk/examples/java/NotesAccess/NotesAccess.java
index 63af5a66caf0..a8b221ee0ef5 100644
--- a/odk/examples/java/NotesAccess/NotesAccess.java
+++ b/odk/examples/java/NotesAccess/NotesAccess.java
@@ -111,14 +111,14 @@ public class NotesAccess implements Runnable {
NotesAccess notesaccess = new NotesAccess();
// Allowing only local calls to the Domino classes.
- thread = new NotesThread( ( Runnable ) notesaccess );
+ thread = new NotesThread( notesaccess );
}
else {
// Extracting the host, user, and password.
NotesAccess notesaccess = new NotesAccess();
// Allowing remote calls to the Domino classes.
- thread = new Thread( ( Runnable ) notesaccess );
+ thread = new Thread( notesaccess );
}
// Starting the thread.
@@ -147,10 +147,9 @@ public class NotesAccess implements Runnable {
frames in which components can be loaded. Desktop is the
environment for components which can instanciate within
frames. */
- XComponentLoader xLoader = ( XComponentLoader )
- UnoRuntime.queryInterface(XComponentLoader.class,
- xMCF.createInstanceWithContext(
- "com.sun.star.frame.Desktop", xContext));
+ XComponentLoader xLoader = UnoRuntime.queryInterface(XComponentLoader.class,
+ xMCF.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xContext));
// Load a Writer document, which will be automaticly displayed
XComponent xComponent = xLoader.loadComponentFromURL(
@@ -159,18 +158,18 @@ public class NotesAccess implements Runnable {
// Querying for the interface XSpreadsheetDocument
XSpreadsheetDocument xSpreadsheetDoc =
- (XSpreadsheetDocument) UnoRuntime.queryInterface(
- XSpreadsheetDocument.class, xComponent);
+ UnoRuntime.queryInterface(
+ XSpreadsheetDocument.class, xComponent);
// Getting all sheets from the spreadsheet document.
XSpreadsheets xSpreadsheets = xSpreadsheetDoc.getSheets() ;
// Querying for the interface XIndexAccess.
- XIndexAccess xIndexAccess = (XIndexAccess) UnoRuntime.queryInterface(
+ XIndexAccess xIndexAccess = UnoRuntime.queryInterface(
XIndexAccess.class, xSpreadsheets);
// Getting the first spreadsheet.
- XSpreadsheet xSpreadsheet = (XSpreadsheet) UnoRuntime.queryInterface(
+ XSpreadsheet xSpreadsheet = UnoRuntime.queryInterface(
XSpreadsheet.class, xIndexAccess.getByIndex(0));
Session session;
diff --git a/odk/examples/java/Spreadsheet/CalcAddins.java b/odk/examples/java/Spreadsheet/CalcAddins.java
index 0a417acae50e..d658a4f4fafa 100644
--- a/odk/examples/java/Spreadsheet/CalcAddins.java
+++ b/odk/examples/java/Spreadsheet/CalcAddins.java
@@ -100,14 +100,14 @@ public class CalcAddins {
public int getMyFirstValue(
com.sun.star.beans.XPropertySet xOptions
) {
- return (int) 1;
+ return 1;
}
public int getMySecondValue(
com.sun.star.beans.XPropertySet xOptions,
int intDummy
) {
- return( (int) ( 2 + intDummy ) );
+ return( 2 + intDummy );
}
diff --git a/odk/examples/java/Spreadsheet/ChartTypeChange.java b/odk/examples/java/Spreadsheet/ChartTypeChange.java
index 7b14ab3716f9..98a143762cab 100644
--- a/odk/examples/java/Spreadsheet/ChartTypeChange.java
+++ b/odk/examples/java/Spreadsheet/ChartTypeChange.java
@@ -151,19 +151,17 @@ public class ChartTypeChange {
*/
public void changeChartType( String stringType, boolean booleanIs3D )
throws Exception {
- XEmbeddedObjectSupplier xEmbeddedObjSupplier = (XEmbeddedObjectSupplier)
- UnoRuntime.queryInterface(XEmbeddedObjectSupplier.class, xtablechart);
+ XEmbeddedObjectSupplier xEmbeddedObjSupplier = UnoRuntime.queryInterface(XEmbeddedObjectSupplier.class, xtablechart);
XInterface xInterface = xEmbeddedObjSupplier.getEmbeddedObject();
- XChartDocument xChartDoc = (XChartDocument)UnoRuntime.queryInterface(
+ XChartDocument xChartDoc = UnoRuntime.queryInterface(
XChartDocument.class, xInterface);
- XDiagram xDiagram = (XDiagram) xChartDoc.getDiagram();
- XMultiServiceFactory xMSF = (XMultiServiceFactory)
- UnoRuntime.queryInterface( XMultiServiceFactory.class, xChartDoc );
+ XDiagram xDiagram = xChartDoc.getDiagram();
+ XMultiServiceFactory xMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, xChartDoc );
Object object = xMSF.createInstance( stringType );
- xDiagram = (XDiagram) UnoRuntime.queryInterface(XDiagram.class, object);
+ xDiagram = UnoRuntime.queryInterface(XDiagram.class, object);
- XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet xPropSet = UnoRuntime.queryInterface(
XPropertySet.class, xDiagram );
xPropSet.setPropertyValue( "Dim3D", new Boolean( booleanIs3D ) );
@@ -181,10 +179,9 @@ public class ChartTypeChange {
frames in which components can be loaded. Desktop is the
environment for components which can instanciate within
frames. */
- XComponentLoader xComponentloader = (XComponentLoader)
- UnoRuntime.queryInterface( XComponentLoader.class,
- xMCF.createInstanceWithContext("com.sun.star.frame.Desktop",
- xCompContext ) );
+ XComponentLoader xComponentloader = UnoRuntime.queryInterface( XComponentLoader.class,
+ xMCF.createInstanceWithContext("com.sun.star.frame.Desktop",
+ xCompContext ) );
// Load a Writer document, which will be automaticly displayed
XComponent xComponent = xComponentloader.loadComponentFromURL(
@@ -192,24 +189,21 @@ public class ChartTypeChange {
new PropertyValue[0] );
// Query for the interface XSpreadsheetDocument
- XSpreadsheetDocument xSpreadSheetDocument = ( XSpreadsheetDocument )
- UnoRuntime.queryInterface( XSpreadsheetDocument.class, xComponent );
+ XSpreadsheetDocument xSpreadSheetDocument = UnoRuntime.queryInterface( XSpreadsheetDocument.class, xComponent );
XSpreadsheets xSpreadsheets = xSpreadSheetDocument.getSheets() ;
- XIndexAccess xIndexAccess = (XIndexAccess)
- UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets );
+ XIndexAccess xIndexAccess = UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets );
- XSpreadsheet xSpreadsheet = (XSpreadsheet) UnoRuntime.queryInterface(
+ XSpreadsheet xSpreadsheet = UnoRuntime.queryInterface(
XSpreadsheet.class, xIndexAccess.getByIndex(0));
- XTableChartsSupplier xTableChartsSupplier = ( XTableChartsSupplier )
- UnoRuntime.queryInterface( XTableChartsSupplier.class, xSpreadsheet );
+ XTableChartsSupplier xTableChartsSupplier = UnoRuntime.queryInterface( XTableChartsSupplier.class, xSpreadsheet );
- xIndexAccess = (XIndexAccess) UnoRuntime.queryInterface(
+ xIndexAccess = UnoRuntime.queryInterface(
XIndexAccess.class, xTableChartsSupplier.getCharts() );
- this.xtablechart = (XTableChart) UnoRuntime.queryInterface(
+ this.xtablechart = UnoRuntime.queryInterface(
XTableChart.class, xIndexAccess.getByIndex( 0 ) );
}
catch( Exception exception ) {
@@ -227,11 +221,10 @@ public class ChartTypeChange {
frames in which components can be loaded. Desktop is the
environment for components which can instanciate within
frames. */
- XComponentLoader xcomponentloader = ( XComponentLoader )
- UnoRuntime.queryInterface( XComponentLoader.class,
- xMCF.createInstanceWithContext(
- "com.sun.star.frame.Desktop",
- xCompContext ) );
+ XComponentLoader xcomponentloader = UnoRuntime.queryInterface( XComponentLoader.class,
+ xMCF.createInstanceWithContext(
+ "com.sun.star.frame.Desktop",
+ xCompContext ) );
// Create an empty calc document, which will be automaticly displayed
XComponent xComponent = xcomponentloader.loadComponentFromURL(
@@ -239,18 +232,17 @@ public class ChartTypeChange {
new PropertyValue[0] );
// Query for the interface XSpreadsheetDocument
- XSpreadsheetDocument xspreadsheetdocument = ( XSpreadsheetDocument )
- UnoRuntime.queryInterface( XSpreadsheetDocument.class, xComponent );
+ XSpreadsheetDocument xspreadsheetdocument = UnoRuntime.queryInterface( XSpreadsheetDocument.class, xComponent );
// Get all sheets of the spreadsheet document.
XSpreadsheets xspreadsheets = xspreadsheetdocument.getSheets() ;
// Get the index of the spreadsheet document.
- XIndexAccess xindexaccess = (XIndexAccess) UnoRuntime.queryInterface(
+ XIndexAccess xindexaccess = UnoRuntime.queryInterface(
XIndexAccess.class, xspreadsheets );
// Get the first spreadsheet.
- XSpreadsheet xspreadsheet = (XSpreadsheet) UnoRuntime.queryInterface(
+ XSpreadsheet xspreadsheet = UnoRuntime.queryInterface(
XSpreadsheet.class, xindexaccess.getByIndex(0));
// The double array will written to the spreadsheet
@@ -271,7 +263,7 @@ public class ChartTypeChange {
rectangle.Height = 11000;
// Get the cell range of the spreadsheet.
- XCellRange xcellrange = ( XCellRange ) UnoRuntime.queryInterface(
+ XCellRange xcellrange = UnoRuntime.queryInterface(
XCellRange.class, xspreadsheet );
// Create the Unicode of the character for the column name.
@@ -291,7 +283,7 @@ public class ChartTypeChange {
// Get the addressable cell range.
XCellRangeAddressable xcellrangeaddressable =
- ( XCellRangeAddressable ) UnoRuntime.queryInterface(
+ UnoRuntime.queryInterface(
XCellRangeAddressable.class, xcellrangeChart );
// Get the cell range address.
@@ -303,8 +295,7 @@ public class ChartTypeChange {
cellrangeaddressChart[ 0 ] = cellrangeaddress;
// Get the table charts supplier of the spreadsheet.
- XTableChartsSupplier xtablechartssupplier = ( XTableChartsSupplier )
- UnoRuntime.queryInterface( XTableChartsSupplier.class, xspreadsheet );
+ XTableChartsSupplier xtablechartssupplier = UnoRuntime.queryInterface( XTableChartsSupplier.class, xspreadsheet );
// Get all table charts of the spreadsheet.
XTableCharts xtablecharts = xtablechartssupplier.getCharts();
@@ -314,9 +305,9 @@ public class ChartTypeChange {
cellrangeaddressChart, true, true );
// Get the created table chart.
- this.xtablechart = ( XTableChart ) UnoRuntime.queryInterface(
- XTableChart.class, (( XNameAccess ) UnoRuntime.queryInterface(
- XNameAccess.class, xtablecharts ) ).getByName( "Example" ));
+ this.xtablechart = UnoRuntime.queryInterface(
+ XTableChart.class, UnoRuntime.queryInterface(
+ XNameAccess.class, xtablecharts ).getByName( "Example" ));
}
catch( Exception exception ) {
System.err.println( exception );
diff --git a/odk/examples/java/Spreadsheet/EuroAdaption.java b/odk/examples/java/Spreadsheet/EuroAdaption.java
index 11727c2ea415..2f4f1d4f95e6 100644
--- a/odk/examples/java/Spreadsheet/EuroAdaption.java
+++ b/odk/examples/java/Spreadsheet/EuroAdaption.java
@@ -85,17 +85,17 @@ public class EuroAdaption {
// create a sheet document
XSpreadsheetDocument xSheetdocument = null;
- xSheetdocument = ( XSpreadsheetDocument ) createSheetdocument( xDesktop );
+ xSheetdocument = createSheetdocument( xDesktop );
System.out.println( "Create a new Spreadsheet" );
// get the collection of all sheets from the document
XSpreadsheets xSheets = null;
- xSheets = (XSpreadsheets) xSheetdocument.getSheets();
+ xSheets = xSheetdocument.getSheets();
// the Action Interface provides methods to hide actions,
// like inserting data, on a sheet, that increase the performance
XActionLockable xActionInterface = null;
- xActionInterface = (XActionLockable) UnoRuntime.queryInterface(
+ xActionInterface = UnoRuntime.queryInterface(
XActionLockable.class, xSheetdocument );
// lock all actions
@@ -104,11 +104,11 @@ public class EuroAdaption {
com.sun.star.sheet.XSpreadsheet xSheet = null;
try {
// get via the index access the first sheet
- XIndexAccess xElements = (XIndexAccess) UnoRuntime.queryInterface(
+ XIndexAccess xElements = UnoRuntime.queryInterface(
XIndexAccess.class, xSheets );
// specify the first sheet from the spreadsheet
- xSheet = (XSpreadsheet) UnoRuntime.queryInterface(
+ xSheet = UnoRuntime.queryInterface(
XSpreadsheet.class, xElements.getByIndex( 0 ));
}
catch( Exception e) {
@@ -117,7 +117,7 @@ public class EuroAdaption {
// get the interface to apply and create new numberformats
XNumberFormatsSupplier xNumberFormatSupplier = null;
- xNumberFormatSupplier = (XNumberFormatsSupplier) UnoRuntime.queryInterface(
+ xNumberFormatSupplier = UnoRuntime.queryInterface(
XNumberFormatsSupplier.class, xSheetdocument );
XNumberFormats xNumberFormats = null;
xNumberFormats = xNumberFormatSupplier.getNumberFormats();
@@ -154,14 +154,14 @@ public class EuroAdaption {
// you have to use the FormatSupplier interface to get the
// CellFormat enumeration
XCellFormatRangesSupplier xCellFormatSupplier =
- (XCellFormatRangesSupplier)UnoRuntime.queryInterface(
- XCellFormatRangesSupplier.class, xSheet );
+ UnoRuntime.queryInterface(
+ XCellFormatRangesSupplier.class, xSheet );
// getCellFormatRanges() has the interfaces for the enumeration
XEnumerationAccess xEnumerationAccess =
- (XEnumerationAccess)UnoRuntime.queryInterface(
- XEnumerationAccess.class,
- xCellFormatSupplier.getCellFormatRanges() );
+ UnoRuntime.queryInterface(
+ XEnumerationAccess.class,
+ xCellFormatSupplier.getCellFormatRanges() );
XEnumeration xRanges = xEnumerationAccess.createEnumeration();
@@ -170,11 +170,11 @@ public class EuroAdaption {
while( xRanges.hasMoreElements() ) {
// the enumeration returns a cellrange
- XCellRange xCellRange = (XCellRange) UnoRuntime.queryInterface(
+ XCellRange xCellRange = UnoRuntime.queryInterface(
XCellRange.class, xRanges.nextElement());
// the PropertySet the get and set the properties from the cellrange
- XPropertySet xCellProp = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet xCellProp = UnoRuntime.queryInterface(
XPropertySet.class, xCellRange );
// getPropertyValue returns an Object, you have to cast it to
@@ -183,8 +183,7 @@ public class EuroAdaption {
int iNumberFormat = aAnyConv.toInt(oNumberObject);
// get the properties from the cellrange numberformat
- XPropertySet xFormat = (XPropertySet)
- xNumberFormats.getByKey(iNumberFormat );
+ XPropertySet xFormat = xNumberFormats.getByKey(iNumberFormat );
short fType = aAnyConv.toShort(xFormat.getPropertyValue("Type"));
String sCurrencySymbol = aAnyConv.toString(
@@ -221,9 +220,8 @@ public class EuroAdaption {
// interate over all cells from the cellrange with an
// content and use the DM/EUR factor
- XCellRangesQuery xCellRangesQuery = (XCellRangesQuery)
- UnoRuntime.queryInterface(
- XCellRangesQuery.class, xCellRange );
+ XCellRangesQuery xCellRangesQuery = UnoRuntime.queryInterface(
+ XCellRangesQuery.class, xCellRange );
XSheetCellRanges xSheetCellRanges =
xCellRangesQuery.queryContentCells(
@@ -236,9 +234,9 @@ public class EuroAdaption {
xCellEnumerationAccess.createEnumeration();
while( xCellEnumeration.hasMoreElements() ) {
- XCell xCell = (XCell) UnoRuntime.queryInterface(
+ XCell xCell = UnoRuntime.queryInterface(
XCell.class, xCellEnumeration.nextElement());
- xCell.setValue( (double) xCell.getValue() / fFactor );
+ xCell.setValue( xCell.getValue() / fFactor );
}
}
}
@@ -299,7 +297,7 @@ public class EuroAdaption {
2, 1 + iCounter );
// get the ProperySet from the cell, to change the numberformat
- XPropertySet xCellProp = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet xCellProp = UnoRuntime.queryInterface(
XPropertySet.class, xCellRange );
xCellProp.setPropertyValue( "NumberFormat",
new Integer(iNumberFormatKey) );
@@ -327,7 +325,7 @@ public class EuroAdaption {
Object oDesktop = xMCF.createInstanceWithContext(
"com.sun.star.frame.Desktop", xContext);
- xDesktop = (XDesktop) UnoRuntime.queryInterface(
+ xDesktop = UnoRuntime.queryInterface(
XDesktop.class, oDesktop);
}
else
@@ -350,7 +348,7 @@ public class EuroAdaption {
XComponent xComponent = null;
xComponent = CreateNewDocument( xDesktop, "scalc" );
- aSheetDocument = (XSpreadsheetDocument) UnoRuntime.queryInterface(
+ aSheetDocument = UnoRuntime.queryInterface(
XSpreadsheetDocument.class, xComponent);
}
catch( Exception e) {
@@ -370,7 +368,7 @@ public class EuroAdaption {
PropertyValue xEmptyArgs[] = new PropertyValue[0];
try {
- xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface(
+ xComponentLoader = UnoRuntime.queryInterface(
XComponentLoader.class, xDesktop );
xComponent = xComponentLoader.loadComponentFromURL(
diff --git a/odk/examples/java/Spreadsheet/SCalc.java b/odk/examples/java/Spreadsheet/SCalc.java
index 66dc73fda7d3..dded8243fa7e 100644
--- a/odk/examples/java/Spreadsheet/SCalc.java
+++ b/odk/examples/java/Spreadsheet/SCalc.java
@@ -126,20 +126,17 @@ public class SCalc {
//***************************************************************************
try {
- XStyleFamiliesSupplier xSFS = (XStyleFamiliesSupplier)
- UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, myDoc);
- XNameAccess xSF = (XNameAccess) xSFS.getStyleFamilies();
- XNameAccess xCS = (XNameAccess) UnoRuntime.queryInterface(
+ XStyleFamiliesSupplier xSFS = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, myDoc);
+ XNameAccess xSF = xSFS.getStyleFamilies();
+ XNameAccess xCS = UnoRuntime.queryInterface(
XNameAccess.class, xSF.getByName("CellStyles"));
- XMultiServiceFactory oDocMSF = (XMultiServiceFactory)
- UnoRuntime.queryInterface(XMultiServiceFactory.class, myDoc );
- XNameContainer oStyleFamilyNameContainer = (XNameContainer)
- UnoRuntime.queryInterface(
- XNameContainer.class, xCS);
+ XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, myDoc );
+ XNameContainer oStyleFamilyNameContainer = UnoRuntime.queryInterface(
+ XNameContainer.class, xCS);
XInterface oInt1 = (XInterface) oDocMSF.createInstance(
"com.sun.star.style.CellStyle");
oStyleFamilyNameContainer.insertByName("My Style", oInt1);
- XPropertySet oCPS1 = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet oCPS1 = UnoRuntime.queryInterface(
XPropertySet.class, oInt1 );
oCPS1.setPropertyValue("IsCellBackgroundTransparent", new Boolean(false));
oCPS1.setPropertyValue("CellBackColor",new Integer(6710932));
@@ -147,7 +144,7 @@ public class SCalc {
XInterface oInt2 = (XInterface) oDocMSF.createInstance(
"com.sun.star.style.CellStyle");
oStyleFamilyNameContainer.insertByName("My Style2", oInt2);
- XPropertySet oCPS2 = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet oCPS2 = UnoRuntime.queryInterface(
XPropertySet.class, oInt2 );
oCPS2.setPropertyValue("IsCellBackgroundTransparent", new Boolean(false));
oCPS2.setPropertyValue("CellBackColor",new Integer(13421823));
@@ -171,9 +168,9 @@ public class SCalc {
try {
System.out.println("Getting spreadsheet") ;
XSpreadsheets xSheets = myDoc.getSheets() ;
- XIndexAccess oIndexSheets = (XIndexAccess) UnoRuntime.queryInterface(
+ XIndexAccess oIndexSheets = UnoRuntime.queryInterface(
XIndexAccess.class, xSheets);
- xSheet = (XSpreadsheet) UnoRuntime.queryInterface(
+ xSheet = UnoRuntime.queryInterface(
XSpreadsheet.class, oIndexSheets.getByIndex(0));
} catch (Exception e) {
@@ -280,16 +277,15 @@ public class SCalc {
oRect.Width = 25000;
oRect.Height = 11000;
- XCellRange oRange = (XCellRange)UnoRuntime.queryInterface(
+ XCellRange oRange = UnoRuntime.queryInterface(
XCellRange.class, xSheet);
XCellRange myRange = oRange.getCellRangeByName("A1:N4");
- XCellRangeAddressable oRangeAddr = (XCellRangeAddressable)
- UnoRuntime.queryInterface(XCellRangeAddressable.class, myRange);
+ XCellRangeAddressable oRangeAddr = UnoRuntime.queryInterface(XCellRangeAddressable.class, myRange);
CellRangeAddress myAddr = oRangeAddr.getRangeAddress();
CellRangeAddress[] oAddr = new CellRangeAddress[1];
oAddr[0] = myAddr;
- XTableChartsSupplier oSupp = (XTableChartsSupplier)UnoRuntime.queryInterface(
+ XTableChartsSupplier oSupp = UnoRuntime.queryInterface(
XTableChartsSupplier.class, xSheet);
XTableChart oChart = null;
@@ -302,22 +298,21 @@ public class SCalc {
// get the diagramm and Change some of the properties
try {
- oChart = (XTableChart) (UnoRuntime.queryInterface(
- XTableChart.class, ((XNameAccess)UnoRuntime.queryInterface(
- XNameAccess.class, oCharts)).getByName("Example")));
- XEmbeddedObjectSupplier oEOS = (XEmbeddedObjectSupplier)
- UnoRuntime.queryInterface(XEmbeddedObjectSupplier.class, oChart);
+ oChart = (UnoRuntime.queryInterface(
+ XTableChart.class, UnoRuntime.queryInterface(
+ XNameAccess.class, oCharts).getByName("Example")));
+ XEmbeddedObjectSupplier oEOS = UnoRuntime.queryInterface(XEmbeddedObjectSupplier.class, oChart);
XInterface oInt = oEOS.getEmbeddedObject();
- XChartDocument xChart = (XChartDocument) UnoRuntime.queryInterface(
+ XChartDocument xChart = UnoRuntime.queryInterface(
XChartDocument.class,oInt);
- XDiagram oDiag = (XDiagram) xChart.getDiagram();
+ XDiagram oDiag = xChart.getDiagram();
System.out.println("Change Diagramm to 3D");
- XPropertySet oCPS = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet oCPS = UnoRuntime.queryInterface(
XPropertySet.class, oDiag );
oCPS.setPropertyValue("Dim3D", new Boolean(true));
System.out.println("Change the title");
Thread.sleep(200);
- XPropertySet oTPS = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet oTPS = UnoRuntime.queryInterface(
XPropertySet.class, xChart.getTitle() );
oTPS.setPropertyValue("String","The new title");
//oDiag.Dim3D();
@@ -347,14 +342,14 @@ public class SCalc {
"com.sun.star.frame.Desktop", xContext );
// query the desktop object for the XComponentLoader
- xCLoader = ( XComponentLoader ) UnoRuntime.queryInterface(
+ xCLoader = UnoRuntime.queryInterface(
XComponentLoader.class, oDesktop );
PropertyValue [] szEmptyArgs = new PropertyValue [0];
String strDoc = "private:factory/scalc";
xComp = xCLoader.loadComponentFromURL(strDoc, "_blank", 0, szEmptyArgs );
- xSpreadSheetDoc = (XSpreadsheetDocument) UnoRuntime.queryInterface(
+ xSpreadSheetDoc = UnoRuntime.queryInterface(
XSpreadsheetDocument.class, xComp);
} catch(Exception e){
@@ -397,7 +392,7 @@ public class SCalc {
ex.printStackTrace(System.err);
}
- XPropertySet xCPS = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet xCPS = UnoRuntime.queryInterface(
XPropertySet.class, xCR );
try {
diff --git a/odk/examples/java/Storage/StorageFunctionality.java b/odk/examples/java/Storage/StorageFunctionality.java
index a030d63a280b..29efd663653d 100644
--- a/odk/examples/java/Storage/StorageFunctionality.java
+++ b/odk/examples/java/Storage/StorageFunctionality.java
@@ -57,7 +57,7 @@ public class StorageFunctionality {
try
{
Object oStorageFactory = xMSF.createInstance( "com.sun.star.embed.StorageFactory" );
- xStorageFactory = (XSingleServiceFactory)UnoRuntime.queryInterface( XSingleServiceFactory.class,
+ xStorageFactory = UnoRuntime.queryInterface( XSingleServiceFactory.class,
oStorageFactory );
if ( xStorageFactory == null )
@@ -76,15 +76,15 @@ public class StorageFunctionality {
final int nNumTests = 9;
StorageTest pTests[] = new StorageTest[nNumTests];
- pTests[0] = (StorageTest) new Test01( xMSF, xStorageFactory );
- pTests[1] = (StorageTest) new Test02( xMSF, xStorageFactory );
- pTests[2] = (StorageTest) new Test03( xMSF, xStorageFactory );
- pTests[3] = (StorageTest) new Test04( xMSF, xStorageFactory );
- pTests[4] = (StorageTest) new Test05( xMSF, xStorageFactory );
- pTests[5] = (StorageTest) new Test06( xMSF, xStorageFactory );
- pTests[6] = (StorageTest) new Test07( xMSF, xStorageFactory );
- pTests[7] = (StorageTest) new Test08( xMSF, xStorageFactory );
- pTests[8] = (StorageTest) new Test09( xMSF, xStorageFactory );
+ pTests[0] = new Test01( xMSF, xStorageFactory );
+ pTests[1] = new Test02( xMSF, xStorageFactory );
+ pTests[2] = new Test03( xMSF, xStorageFactory );
+ pTests[3] = new Test04( xMSF, xStorageFactory );
+ pTests[4] = new Test05( xMSF, xStorageFactory );
+ pTests[5] = new Test06( xMSF, xStorageFactory );
+ pTests[6] = new Test07( xMSF, xStorageFactory );
+ pTests[7] = new Test08( xMSF, xStorageFactory );
+ pTests[8] = new Test09( xMSF, xStorageFactory );
System.out.println( "\nstart testing\n" );
@@ -130,11 +130,11 @@ public class StorageFunctionality {
// create a connector, so that it can contact the office
Object oUrlResolver = xLocalServiceManager.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver", xComponentContext );
- XUnoUrlResolver xUrlResolver = (XUnoUrlResolver)UnoRuntime.queryInterface(
+ XUnoUrlResolver xUrlResolver = UnoRuntime.queryInterface(
XUnoUrlResolver.class, oUrlResolver );
Object oInitialObject = xUrlResolver.resolve( sConnectStr );
- XNamingService xName = (XNamingService)UnoRuntime.queryInterface(
+ XNamingService xName = UnoRuntime.queryInterface(
XNamingService.class, oInitialObject );
XMultiServiceFactory xMSF = null;
@@ -142,8 +142,7 @@ public class StorageFunctionality {
System.err.println( "got the remote naming service !" );
Object oMSF = xName.getRegisteredObject("StarOffice.ServiceManager" );
- xMSF = (XMultiServiceFactory)
- UnoRuntime.queryInterface( XMultiServiceFactory.class, oMSF );
+ xMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, oMSF );
}
else
System.out.println( "Error: Can't get XNamingService interface from url resolver!" );
diff --git a/odk/examples/java/Storage/Test01.java b/odk/examples/java/Storage/Test01.java
index 4fc4cc625ef8..4abe4b25b83c 100644
--- a/odk/examples/java/Storage/Test01.java
+++ b/odk/examples/java/Storage/Test01.java
@@ -49,7 +49,7 @@ public class Test01 implements StorageTest {
// create temporary storage based on arbitrary medium
// after such a storage is closed it is lost
Object oTempStorage = m_xStorageFactory.createInstance();
- XStorage xTempStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTempStorage );
+ XStorage xTempStorage = UnoRuntime.queryInterface( XStorage.class, oTempStorage );
if ( xTempStorage == null )
{
m_aTestHelper.Error( "Can't create temporary storage representation!" );
@@ -94,11 +94,11 @@ public class Test01 implements StorageTest {
// create temporary storage based on a previously created temporary file
Object pArgs[] = new Object[2];
- pArgs[0] = (Object) sTempFileURL;
+ pArgs[0] = sTempFileURL;
pArgs[1] = new Integer( ElementModes.WRITE );
Object oTempFileStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
- XStorage xTempFileStorage = (XStorage)UnoRuntime.queryInterface( XStorage.class, oTempFileStorage );
+ XStorage xTempFileStorage = UnoRuntime.queryInterface( XStorage.class, oTempFileStorage );
if ( xTempFileStorage == null )
{
m_aTestHelper.Error( "Can't create storage based on temporary file!" );
@@ -121,7 +121,7 @@ public class Test01 implements StorageTest {
// the temporary file must not be locked any more after storage disposing
pArgs[1] = new Integer( ElementModes.READWRITE );
Object oResultStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
- XStorage xResultStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oResultStorage );
+ XStorage xResultStorage = UnoRuntime.queryInterface( XStorage.class, oResultStorage );
if ( xResultStorage == null )
{
m_aTestHelper.Error( "Can't reopen storage based on temporary file!" );
diff --git a/odk/examples/java/Storage/Test02.java b/odk/examples/java/Storage/Test02.java
index 9989a6a76bec..c78260b95bc1 100644
--- a/odk/examples/java/Storage/Test02.java
+++ b/odk/examples/java/Storage/Test02.java
@@ -49,11 +49,11 @@ public class Test02 implements StorageTest {
// create storage based on the temporary stream
Object pArgs[] = new Object[2];
- pArgs[0] = (Object) xTempFileStream;
+ pArgs[0] = xTempFileStream;
pArgs[1] = new Integer( ElementModes.WRITE );
Object oTempStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
- XStorage xTempStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTempStorage );
+ XStorage xTempStorage = UnoRuntime.queryInterface( XStorage.class, oTempStorage );
if ( xTempStorage == null )
{
m_aTestHelper.Error( "Can't create temporary storage representation!" );
@@ -121,10 +121,10 @@ public class Test02 implements StorageTest {
// open input stream
// since no mode is provided the result storage must be opened readonly
Object pOneArg[] = new Object[1];
- pOneArg[0] = (Object) xTempInStream;
+ pOneArg[0] = xTempInStream;
Object oResultStorage = m_xStorageFactory.createInstanceWithArguments( pOneArg );
- XStorage xResultStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oResultStorage );
+ XStorage xResultStorage = UnoRuntime.queryInterface( XStorage.class, oResultStorage );
if ( xResultStorage == null )
{
m_aTestHelper.Error( "Can't open storage based on input stream!" );
diff --git a/odk/examples/java/Storage/Test03.java b/odk/examples/java/Storage/Test03.java
index 39e9c01ad7c1..fe9d8c05c499 100644
--- a/odk/examples/java/Storage/Test03.java
+++ b/odk/examples/java/Storage/Test03.java
@@ -43,7 +43,7 @@ public class Test03 implements StorageTest {
// create temporary storage based on arbitrary medium
// after such a storage is closed it is lost
Object oTempStorage = m_xStorageFactory.createInstance();
- XStorage xTempStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTempStorage );
+ XStorage xTempStorage = UnoRuntime.queryInterface( XStorage.class, oTempStorage );
if ( xTempStorage == null )
{
m_aTestHelper.Error( "Can't create temporary storage representation!" );
@@ -118,7 +118,7 @@ public class Test03 implements StorageTest {
return false;
}
- XNameAccess xRootNameAccess = (XNameAccess) UnoRuntime.queryInterface( XNameAccess.class, xTempStorage );
+ XNameAccess xRootNameAccess = UnoRuntime.queryInterface( XNameAccess.class, xTempStorage );
if ( xRootNameAccess == null )
{
m_aTestHelper.Error( "Root storage doesn't support XNameAccess!" );
@@ -170,7 +170,7 @@ public class Test03 implements StorageTest {
if ( !m_aTestHelper.checkStorageProperties( xResultSubStorage, "MediaType3", false, ElementModes.READ ) )
return false;
- XNameAccess xChildAccess = (XNameAccess) UnoRuntime.queryInterface( XNameAccess.class, xResultSubStorage );
+ XNameAccess xChildAccess = UnoRuntime.queryInterface( XNameAccess.class, xResultSubStorage );
if ( xChildAccess == null )
{
m_aTestHelper.Error( "Child storage doesn't support XNameAccess!" );
@@ -199,7 +199,7 @@ public class Test03 implements StorageTest {
try
{
Object oStorage = xAccess.getByName( sName );
- XStorage xResult = (XStorage) UnoRuntime.queryInterface( XStorage.class, oStorage );
+ XStorage xResult = UnoRuntime.queryInterface( XStorage.class, oStorage );
if ( xResult != null )
return xResult;
diff --git a/odk/examples/java/Storage/Test04.java b/odk/examples/java/Storage/Test04.java
index cf3a6ec36b4f..9196b3870c23 100644
--- a/odk/examples/java/Storage/Test04.java
+++ b/odk/examples/java/Storage/Test04.java
@@ -50,7 +50,7 @@ public class Test04 implements StorageTest {
// create temporary storage based on arbitrary medium
// after such a storage is closed it is lost
Object oTempStorage = m_xStorageFactory.createInstance();
- XStorage xTempStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTempStorage );
+ XStorage xTempStorage = UnoRuntime.queryInterface( XStorage.class, oTempStorage );
if ( xTempStorage == null )
{
m_aTestHelper.Error( "Can't create temporary storage representation!" );
@@ -114,11 +114,11 @@ public class Test04 implements StorageTest {
// create temporary storage based on a previously created temporary file
Object pArgs[] = new Object[2];
- pArgs[0] = (Object) sTempFileURL;
+ pArgs[0] = sTempFileURL;
pArgs[1] = new Integer( ElementModes.WRITE );
Object oTempFileStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
- XStorage xTempFileStorage = (XStorage)UnoRuntime.queryInterface( XStorage.class, oTempFileStorage );
+ XStorage xTempFileStorage = UnoRuntime.queryInterface( XStorage.class, oTempFileStorage );
if ( xTempFileStorage == null )
{
m_aTestHelper.Error( "Can't create storage based on temporary file!" );
@@ -178,7 +178,7 @@ public class Test04 implements StorageTest {
// the temporary file must not be locked any more after storage disposing
pArgs[1] = new Integer( ElementModes.READWRITE );
Object oResStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
- XStorage xResStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oResStorage );
+ XStorage xResStorage = UnoRuntime.queryInterface( XStorage.class, oResStorage );
if ( xResStorage == null )
{
m_aTestHelper.Error( "Can't reopen storage based on temporary file!" );
@@ -237,7 +237,7 @@ public class Test04 implements StorageTest {
try
{
- XNameAccess xResAccess = (XNameAccess) UnoRuntime.queryInterface( XNameAccess.class, xResStorage );
+ XNameAccess xResAccess = UnoRuntime.queryInterface( XNameAccess.class, xResStorage );
if ( xResAccess.hasByName( "SubStorage2" ) )
m_aTestHelper.Error( "SubStorage2 must be removed already!" );
}
diff --git a/odk/examples/java/Storage/Test05.java b/odk/examples/java/Storage/Test05.java
index d00ced1d3341..9a21b74e9482 100644
--- a/odk/examples/java/Storage/Test05.java
+++ b/odk/examples/java/Storage/Test05.java
@@ -50,11 +50,11 @@ public class Test05 implements StorageTest {
// create temporary storage based on a previously created temporary file
Object pArgs[] = new Object[2];
- pArgs[0] = (Object) sTempFileURL;
+ pArgs[0] = sTempFileURL;
pArgs[1] = new Integer( ElementModes.WRITE );
Object oTempFileStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
- XStorage xTempFileStorage = (XStorage)UnoRuntime.queryInterface( XStorage.class, oTempFileStorage );
+ XStorage xTempFileStorage = UnoRuntime.queryInterface( XStorage.class, oTempFileStorage );
if ( xTempFileStorage == null )
{
m_aTestHelper.Error( "Can't create storage based on temporary file!" );
@@ -218,7 +218,7 @@ public class Test05 implements StorageTest {
pArgs[1] = new Integer( ElementModes.READ );
Object oResultStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
- XStorage xResultStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oResultStorage );
+ XStorage xResultStorage = UnoRuntime.queryInterface( XStorage.class, oResultStorage );
if ( xResultStorage == null )
{
m_aTestHelper.Error( "Can't reopen storage based on temporary file!" );
diff --git a/odk/examples/java/Storage/Test06.java b/odk/examples/java/Storage/Test06.java
index 2b3d62820282..d3b1cb097fd6 100644
--- a/odk/examples/java/Storage/Test06.java
+++ b/odk/examples/java/Storage/Test06.java
@@ -42,7 +42,7 @@ public class Test06 implements StorageTest {
// create temporary storage based on arbitrary medium
// after such a storage is closed it is lost
Object oTempStorage = m_xStorageFactory.createInstance();
- XStorage xTempStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTempStorage );
+ XStorage xTempStorage = UnoRuntime.queryInterface( XStorage.class, oTempStorage );
if ( xTempStorage == null )
{
m_aTestHelper.Error( "Can't create temporary storage representation!" );
@@ -192,7 +192,7 @@ public class Test06 implements StorageTest {
// create new temporary storage based on arbitrary medium
Object oTargetStorage = m_xStorageFactory.createInstance();
- XStorage xTargetStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTargetStorage );
+ XStorage xTargetStorage = UnoRuntime.queryInterface( XStorage.class, oTargetStorage );
if ( xTargetStorage == null )
{
m_aTestHelper.Error( "Can't create temporary storage representation!" );
diff --git a/odk/examples/java/Storage/Test07.java b/odk/examples/java/Storage/Test07.java
index 753bac8256a3..2e24b3c126b5 100644
--- a/odk/examples/java/Storage/Test07.java
+++ b/odk/examples/java/Storage/Test07.java
@@ -49,7 +49,7 @@ public class Test07 implements StorageTest {
// create temporary storage based on arbitrary medium
// after such a storage is closed it is lost
Object oTempStorage = m_xStorageFactory.createInstance();
- XStorage xTempStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTempStorage );
+ XStorage xTempStorage = UnoRuntime.queryInterface( XStorage.class, oTempStorage );
if ( xTempStorage == null )
{
m_aTestHelper.Error( "Can't create temporary storage representation!" );
@@ -72,11 +72,11 @@ public class Test07 implements StorageTest {
// create temporary storage based on a previously created temporary file
Object pArgs[] = new Object[2];
- pArgs[0] = (Object) sTempFileURL;
+ pArgs[0] = sTempFileURL;
pArgs[1] = new Integer( ElementModes.WRITE );
Object oTempFileStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
- XStorage xTempFileStorage = (XStorage)UnoRuntime.queryInterface( XStorage.class, oTempFileStorage );
+ XStorage xTempFileStorage = UnoRuntime.queryInterface( XStorage.class, oTempFileStorage );
if ( xTempFileStorage == null )
{
m_aTestHelper.Error( "Can't create storage based on temporary file!" );
@@ -99,7 +99,7 @@ public class Test07 implements StorageTest {
// the temporary file must not be locked any more after storage disposing
pArgs[1] = new Integer( ElementModes.READWRITE );
Object oResultStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
- XStorage xResultStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oResultStorage );
+ XStorage xResultStorage = UnoRuntime.queryInterface( XStorage.class, oResultStorage );
if ( xResultStorage == null )
{
m_aTestHelper.Error( "Can't reopen storage based on temporary file!" );
@@ -107,7 +107,7 @@ public class Test07 implements StorageTest {
}
Object o2CopyStorage = m_xStorageFactory.createInstance();
- XStorage x2CopyStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, o2CopyStorage );
+ XStorage x2CopyStorage = UnoRuntime.queryInterface( XStorage.class, o2CopyStorage );
if ( x2CopyStorage == null )
{
m_aTestHelper.Error( "Can't create temporary storage representation!" );
diff --git a/odk/examples/java/Storage/Test08.java b/odk/examples/java/Storage/Test08.java
index 8b29d2cbe5aa..4aef187901cc 100644
--- a/odk/examples/java/Storage/Test08.java
+++ b/odk/examples/java/Storage/Test08.java
@@ -43,7 +43,7 @@ public class Test08 implements StorageTest {
// create temporary storage based on arbitrary medium
// after such a storage is closed it is lost
Object oTempStorage = m_xStorageFactory.createInstance();
- XStorage xTempStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTempStorage );
+ XStorage xTempStorage = UnoRuntime.queryInterface( XStorage.class, oTempStorage );
if ( xTempStorage == null )
{
m_aTestHelper.Error( "Can't create temporary storage representation!" );
@@ -52,7 +52,7 @@ public class Test08 implements StorageTest {
// set the global password for the root storage
XEncryptionProtectedSource xTempStorageEncryption =
- (XEncryptionProtectedSource) UnoRuntime.queryInterface( XEncryptionProtectedSource.class, xTempStorage );
+ UnoRuntime.queryInterface( XEncryptionProtectedSource.class, xTempStorage );
if ( xTempStorageEncryption == null )
{
@@ -127,11 +127,11 @@ public class Test08 implements StorageTest {
// create temporary storage based on a previously created temporary file
Object pArgs[] = new Object[2];
- pArgs[0] = (Object) sTempFileURL;
+ pArgs[0] = sTempFileURL;
pArgs[1] = new Integer( ElementModes.WRITE );
Object oTempFileStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
- XStorage xTempFileStorage = (XStorage)UnoRuntime.queryInterface( XStorage.class, oTempFileStorage );
+ XStorage xTempFileStorage = UnoRuntime.queryInterface( XStorage.class, oTempFileStorage );
if ( xTempFileStorage == null )
{
m_aTestHelper.Error( "Can't create storage based on temporary file!" );
@@ -154,7 +154,7 @@ public class Test08 implements StorageTest {
// the temporary file must not be locked any more after storage disposing
pArgs[1] = new Integer( ElementModes.READ );
Object oResultStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
- XStorage xResultStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oResultStorage );
+ XStorage xResultStorage = UnoRuntime.queryInterface( XStorage.class, oResultStorage );
if ( xResultStorage == null )
{
m_aTestHelper.Error( "Can't reopen storage based on temporary file!" );
@@ -179,7 +179,7 @@ public class Test08 implements StorageTest {
// set the global password for the root storage
XEncryptionProtectedSource xResultStorageEncryption =
- (XEncryptionProtectedSource) UnoRuntime.queryInterface( XEncryptionProtectedSource.class, xResultStorage );
+ UnoRuntime.queryInterface( XEncryptionProtectedSource.class, xResultStorage );
if ( xResultStorageEncryption == null )
{
diff --git a/odk/examples/java/Storage/Test09.java b/odk/examples/java/Storage/Test09.java
index 5e7bbe4f09ca..2c0fbac71950 100644
--- a/odk/examples/java/Storage/Test09.java
+++ b/odk/examples/java/Storage/Test09.java
@@ -43,7 +43,7 @@ public class Test09 implements StorageTest {
// create temporary storage based on arbitrary medium
// after such a storage is closed it is lost
Object oTempStorage = m_xStorageFactory.createInstance();
- XStorage xTempStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTempStorage );
+ XStorage xTempStorage = UnoRuntime.queryInterface( XStorage.class, oTempStorage );
if ( xTempStorage == null )
{
m_aTestHelper.Error( "Can't create temporary storage representation!" );
@@ -69,11 +69,11 @@ public class Test09 implements StorageTest {
// create temporary storage based on a previously created temporary file
Object pArgs[] = new Object[2];
- pArgs[0] = (Object) sTempFileURL;
+ pArgs[0] = sTempFileURL;
pArgs[1] = new Integer( ElementModes.WRITE );
Object oTempFileStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
- XStorage xTempFileStorage = (XStorage)UnoRuntime.queryInterface( XStorage.class, oTempFileStorage );
+ XStorage xTempFileStorage = UnoRuntime.queryInterface( XStorage.class, oTempFileStorage );
if ( xTempFileStorage == null )
{
m_aTestHelper.Error( "Can't create storage based on temporary file!" );
@@ -106,7 +106,7 @@ public class Test09 implements StorageTest {
// the temporary file must not be locked any more after storage disposing
pArgs[1] = new Integer( ElementModes.READ );
Object oResultStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
- XStorage xResultStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oResultStorage );
+ XStorage xResultStorage = UnoRuntime.queryInterface( XStorage.class, oResultStorage );
if ( xResultStorage == null )
{
m_aTestHelper.Error( "Can't reopen storage based on temporary file!" );
diff --git a/odk/examples/java/Storage/TestHelper.java b/odk/examples/java/Storage/TestHelper.java
index 935e0b4a9785..ac0c3b9c2d03 100644
--- a/odk/examples/java/Storage/TestHelper.java
+++ b/odk/examples/java/Storage/TestHelper.java
@@ -49,7 +49,7 @@ public class TestHelper {
}
// get XTrucate implementation from output stream
- XTruncate xTruncate = (XTruncate) UnoRuntime.queryInterface( XTruncate.class, xOutput );
+ XTruncate xTruncate = UnoRuntime.queryInterface( XTruncate.class, xOutput );
if ( xTruncate == null )
{
Error( "Can't get XTruncate implementation from substream '" + sStreamName + "'!" );
@@ -69,7 +69,7 @@ public class TestHelper {
}
// get access to the XPropertySet interface
- XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, xStream );
+ XPropertySet xPropSet = UnoRuntime.queryInterface( XPropertySet.class, xStream );
if ( xPropSet == null )
{
Error( "Can't get XPropertySet implementation from substream '" + sStreamName + "'!" );
@@ -105,7 +105,7 @@ public class TestHelper {
}
// free the stream resources, garbage collector may remove the object too late
- XComponent xComponent = (XComponent) UnoRuntime.queryInterface( XComponent.class, xStream );
+ XComponent xComponent = UnoRuntime.queryInterface( XComponent.class, xStream );
if ( xComponent == null )
{
Error( "Can't get XComponent implementation from substream '" + sStreamName + "'!" );
@@ -128,7 +128,7 @@ public class TestHelper {
try
{
Object oSubStream = xStorage.openStreamElement( sStreamName, ElementModes.WRITE );
- xSubStream = (XStream) UnoRuntime.queryInterface( XStream.class, oSubStream );
+ xSubStream = UnoRuntime.queryInterface( XStream.class, oSubStream );
if ( xSubStream == null )
{
Error( "Can't create substream '" + sStreamName + "'!" );
@@ -156,7 +156,7 @@ public class TestHelper {
try
{
Object oSubStream = xStorage.openEncryptedStreamElement( sStreamName, ElementModes.WRITE, new String(pPass) );
- xSubStream = (XStream) UnoRuntime.queryInterface( XStream.class, oSubStream );
+ xSubStream = UnoRuntime.queryInterface( XStream.class, oSubStream );
if ( xSubStream == null )
{
Error( "Can't create substream '" + sStreamName + "'!" );
@@ -184,7 +184,7 @@ public class TestHelper {
try
{
Object oSubStream = xStorage.openStreamElement( sStreamName, ElementModes.WRITE );
- xSubStream = (XStream) UnoRuntime.queryInterface( XStream.class, oSubStream );
+ xSubStream = UnoRuntime.queryInterface( XStream.class, oSubStream );
if ( xSubStream == null )
{
Error( "Can't create substream '" + sStreamName + "'!" );
@@ -198,7 +198,7 @@ public class TestHelper {
}
// get access to the XPropertySet interface
- XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, xSubStream );
+ XPropertySet xPropSet = UnoRuntime.queryInterface( XPropertySet.class, xSubStream );
if ( xPropSet == null )
{
Error( "Can't get XPropertySet implementation from substream '" + sStreamName + "'!" );
@@ -229,7 +229,7 @@ public class TestHelper {
try
{
Object oSubStream = xStorage.openEncryptedStreamElement( sStreamName, ElementModes.WRITE, new String(pOldPass) );
- xSubStream = (XStream) UnoRuntime.queryInterface( XStream.class, oSubStream );
+ xSubStream = UnoRuntime.queryInterface( XStream.class, oSubStream );
if ( xSubStream == null )
{
Error( "Can't open substream '" + sStreamName + "'!" );
@@ -245,7 +245,7 @@ public class TestHelper {
// change the password for the stream
XEncryptionProtectedSource xStreamEncryption =
- (XEncryptionProtectedSource) UnoRuntime.queryInterface( XEncryptionProtectedSource.class, xSubStream );
+ UnoRuntime.queryInterface( XEncryptionProtectedSource.class, xSubStream );
if ( xStreamEncryption == null )
{
@@ -263,7 +263,7 @@ public class TestHelper {
}
// free the stream resources, garbage collector may remove the object too late
- XComponent xComponent = (XComponent) UnoRuntime.queryInterface( XComponent.class, xSubStream );
+ XComponent xComponent = UnoRuntime.queryInterface( XComponent.class, xSubStream );
if ( xComponent == null )
{
Error( "Can't get XComponent implementation from substream '" + sStreamName + "'!" );
@@ -279,7 +279,7 @@ public class TestHelper {
boolean bOk = false;
// get access to the XPropertySet interface
- XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, xStorage );
+ XPropertySet xPropSet = UnoRuntime.queryInterface( XPropertySet.class, xStorage );
if ( xPropSet != null )
{
try
@@ -323,7 +323,7 @@ public class TestHelper {
boolean bOk = false;
// get access to the XPropertySet interface
- XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, xStorage );
+ XPropertySet xPropSet = UnoRuntime.queryInterface( XPropertySet.class, xStorage );
if ( xPropSet != null )
{
try
@@ -421,7 +421,7 @@ public class TestHelper {
boolean bOk = false;
// get access to the XPropertySet interface
- XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, xStream );
+ XPropertySet xPropSet = UnoRuntime.queryInterface( XPropertySet.class, xStream );
if ( xPropSet != null )
{
try
@@ -467,7 +467,7 @@ public class TestHelper {
try
{
Object oSubStream = xParentStorage.openStreamElement( sName, ElementModes.READ );
- xSubStream = (XStream) UnoRuntime.queryInterface( XStream.class, oSubStream );
+ xSubStream = UnoRuntime.queryInterface( XStream.class, oSubStream );
if ( xSubStream == null )
{
Error( "Can't open substream '" + sName + "'!" );
@@ -532,7 +532,7 @@ public class TestHelper {
try
{
Object oSubStream = xParentStorage.openEncryptedStreamElement( sName, ElementModes.READ, new String(pPass) );
- xSubStream = (XStream) UnoRuntime.queryInterface( XStream.class, oSubStream );
+ xSubStream = UnoRuntime.queryInterface( XStream.class, oSubStream );
if ( xSubStream == null )
{
Error( "Can't open encrypted substream '" + sName + "'!" );
@@ -567,7 +567,7 @@ public class TestHelper {
public boolean commitStorage( XStorage xStorage )
{
// XTransactedObject must be supported by storages
- XTransactedObject xTransact = (XTransactedObject) UnoRuntime.queryInterface( XTransactedObject.class, xStorage );
+ XTransactedObject xTransact = UnoRuntime.queryInterface( XTransactedObject.class, xStorage );
if ( xTransact == null )
{
Error( "Storage doesn't implement transacted access!" );
@@ -590,7 +590,7 @@ public class TestHelper {
public boolean disposeStorage( XStorage xStorage )
{
// dispose the storage
- XComponent xComponent = (XComponent) UnoRuntime.queryInterface( XComponent.class, xStorage );
+ XComponent xComponent = UnoRuntime.queryInterface( XComponent.class, xStorage );
if ( xComponent == null )
{
Error( "Can't retrieve XComponent implementation from storage!" );
@@ -664,7 +664,7 @@ public class TestHelper {
try
{
Object oSubStorage = xStorage.openStorageElement( sName, nMode );
- XStorage xSubStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oSubStorage );
+ XStorage xSubStorage = UnoRuntime.queryInterface( XStorage.class, oSubStorage );
return xSubStorage;
}
catch( Exception e )
@@ -682,7 +682,7 @@ public class TestHelper {
try
{
Object oTempFile = xMSF.createInstance( "com.sun.star.io.TempFile" );
- xTempFileStream = (XStream)UnoRuntime.queryInterface( XStream.class, oTempFile );
+ xTempFileStream = UnoRuntime.queryInterface( XStream.class, oTempFile );
}
catch( Exception e )
{}
@@ -702,7 +702,7 @@ public class TestHelper {
try
{
Object oTempFile = xMSF.createInstance( "com.sun.star.io.TempFile" );
- xTempFileProps = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, oTempFile );
+ xTempFileProps = UnoRuntime.queryInterface( XPropertySet.class, oTempFile );
}
catch( Exception e )
{}
@@ -727,7 +727,7 @@ public class TestHelper {
// close temporary file explicitly
try
{
- XStream xStream = (XStream)UnoRuntime.queryInterface( XStream.class, xTempFileProps );
+ XStream xStream = UnoRuntime.queryInterface( XStream.class, xTempFileProps );
if ( xStream != null )
{
XOutputStream xOut = xStream.getOutputStream();
@@ -822,7 +822,7 @@ public class TestHelper {
try
{
Object oSubStream = xStorage.openStreamElement( sStreamName, nMode );
- xSubStream = (XStream) UnoRuntime.queryInterface( XStream.class, oSubStream );
+ xSubStream = UnoRuntime.queryInterface( XStream.class, oSubStream );
if ( xSubStream == null )
Error( "Can't create substream '" + sStreamName + "'!" );
}
diff --git a/odk/examples/java/Text/BookmarkInsertion.java b/odk/examples/java/Text/BookmarkInsertion.java
index ced4ddb4984c..fee990dc653c 100644
--- a/odk/examples/java/Text/BookmarkInsertion.java
+++ b/odk/examples/java/Text/BookmarkInsertion.java
@@ -84,14 +84,13 @@ public class BookmarkInsertion {
try {
for( iCounter = 0; iCounter < mList.length; iCounter++ ) {
// the findfirst returns a XInterface
- xSearchInterface = (com.sun.star.uno.XInterface)FindFirst(
+ xSearchInterface = FindFirst(
xTextDocument, mList[ iCounter ] );
if( xSearchInterface != null ) {
// get the TextRange form the XInterface
- xSearchTextRange = (com.sun.star.text.XTextRange)
- UnoRuntime.queryInterface(
- com.sun.star.text.XTextRange.class, xSearchInterface);
+ xSearchTextRange = UnoRuntime.queryInterface(
+ com.sun.star.text.XTextRange.class, xSearchInterface);
InsertBookmark(xTextDocument, xSearchTextRange,
sPrefix + iCounter);
@@ -112,9 +111,8 @@ public class BookmarkInsertion {
try {
// get the MultiServiceFactory from the text document
com.sun.star.lang.XMultiServiceFactory xDocMSF;
- xDocMSF = (com.sun.star.lang.XMultiServiceFactory)
- UnoRuntime.queryInterface(
- com.sun.star.lang.XMultiServiceFactory.class, xTextDocument);
+ xDocMSF = UnoRuntime.queryInterface(
+ com.sun.star.lang.XMultiServiceFactory.class, xTextDocument);
// the bookmark service is a context dependend service, you need
// the MultiServiceFactory from the document
@@ -122,17 +120,15 @@ public class BookmarkInsertion {
// set the name from the bookmark
com.sun.star.container.XNamed xNameAccess = null;
- xNameAccess = (com.sun.star.container.XNamed)
- UnoRuntime.queryInterface(
- com.sun.star.container.XNamed.class, xObject);
+ xNameAccess = UnoRuntime.queryInterface(
+ com.sun.star.container.XNamed.class, xObject);
xNameAccess.setName(sBookName);
// create a XTextContent, for the method 'insertTextContent'
com.sun.star.text.XTextContent xTextContent = null;
- xTextContent = (com.sun.star.text.XTextContent)
- UnoRuntime.queryInterface(
- com.sun.star.text.XTextContent.class, xNameAccess);
+ xTextContent = UnoRuntime.queryInterface(
+ com.sun.star.text.XTextContent.class, xNameAccess);
// insertTextContent need a TextRange not a cursor to specify the
// position from the bookmark
@@ -153,18 +149,15 @@ public class BookmarkInsertion {
com.sun.star.uno.XInterface xSearchInterface = null;
try {
- xSearchable = (com.sun.star.util.XSearchable)
- UnoRuntime.queryInterface(
- com.sun.star.util.XSearchable.class, xTextDocument);
- xSearchDescriptor = (com.sun.star.util.XSearchDescriptor)
- xSearchable.createSearchDescriptor();
+ xSearchable = UnoRuntime.queryInterface(
+ com.sun.star.util.XSearchable.class, xTextDocument);
+ xSearchDescriptor = xSearchable.createSearchDescriptor();
xSearchDescriptor.setSearchString(sSearchString);
com.sun.star.beans.XPropertySet xPropertySet = null;
- xPropertySet = (com.sun.star.beans.XPropertySet)
- UnoRuntime.queryInterface(
- com.sun.star.beans.XPropertySet.class, xSearchDescriptor);
+ xPropertySet = UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xSearchDescriptor);
xPropertySet.setPropertyValue("SearchRegularExpression",
new Boolean( true ) );
@@ -185,8 +178,7 @@ public class BookmarkInsertion {
com.sun.star.text.XTextCursor xTextCursor = null;
try {
- xTextCursor = (com.sun.star.text.XTextCursor)
- xTextDocument.getText().createTextCursor();
+ xTextCursor = xTextDocument.getText().createTextCursor();
xTextCursor.setString( "He heard quiet steps behind him. That didn't bode well. Who could be following him this late at night and in this deadbeat part of town? And at this particular moment, just after he pulled off the big time and was making off with the greenbacks. Was there another crook who'd had the same idea, and was now watching him and waiting for a chance to grab the fruit of his labor?" );
xTextCursor.collapseToEnd();
@@ -219,7 +211,7 @@ public class BookmarkInsertion {
Object oDesktop = xMCF.createInstanceWithContext(
"com.sun.star.frame.Desktop", xContext);
- xDesktop = (com.sun.star.frame.XDesktop) UnoRuntime.queryInterface(
+ xDesktop = UnoRuntime.queryInterface(
com.sun.star.frame.XDesktop.class, oDesktop);
}
else
@@ -242,9 +234,8 @@ public class BookmarkInsertion {
try {
com.sun.star.lang.XComponent xComponent = CreateNewDocument(xDesktop,
"swriter");
- aTextDocument = (com.sun.star.text.XTextDocument)
- UnoRuntime.queryInterface(
- com.sun.star.text.XTextDocument.class, xComponent);
+ aTextDocument = UnoRuntime.queryInterface(
+ com.sun.star.text.XTextDocument.class, xComponent);
}
catch( Exception e) {
e.printStackTrace(System.err);
@@ -268,9 +259,8 @@ public class BookmarkInsertion {
new com.sun.star.beans.PropertyValue[0];
try {
- xComponentLoader = (com.sun.star.frame.XComponentLoader)
- UnoRuntime.queryInterface(
- com.sun.star.frame.XComponentLoader.class, xDesktop);
+ xComponentLoader = UnoRuntime.queryInterface(
+ com.sun.star.frame.XComponentLoader.class, xDesktop);
xComponent = xComponentLoader.loadComponentFromURL(
sURL, "_blank", 0, xEmptyArgs);
diff --git a/odk/examples/java/Text/GraphicsInserter.java b/odk/examples/java/Text/GraphicsInserter.java
index 866da1c0849f..d2078f76b9db 100644
--- a/odk/examples/java/Text/GraphicsInserter.java
+++ b/odk/examples/java/Text/GraphicsInserter.java
@@ -68,14 +68,13 @@ public class GraphicsInserter {
frames in which components can be loaded. Desktop is the
environment for components which can instanciate within
frames. */
- com.sun.star.frame.XDesktop xDesktop = (com.sun.star.frame.XDesktop)
- UnoRuntime.queryInterface(com.sun.star.frame.XDesktop.class,
- xMCF.createInstanceWithContext("com.sun.star.frame.Desktop",
- xContext ) );
+ com.sun.star.frame.XDesktop xDesktop = UnoRuntime.queryInterface(com.sun.star.frame.XDesktop.class,
+ xMCF.createInstanceWithContext("com.sun.star.frame.Desktop",
+ xContext ) );
com.sun.star.frame.XComponentLoader xCompLoader =
- (com.sun.star.frame.XComponentLoader)UnoRuntime.queryInterface(
- com.sun.star.frame.XComponentLoader.class, xDesktop);
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XComponentLoader.class, xDesktop);
// Load a Writer document, which will be automaticly displayed
com.sun.star.lang.XComponent xComp = xCompLoader.loadComponentFromURL(
@@ -84,13 +83,13 @@ public class GraphicsInserter {
// Querying for the interface XTextDocument on the xcomponent
com.sun.star.text.XTextDocument xTextDoc =
- (com.sun.star.text.XTextDocument)UnoRuntime.queryInterface(
- com.sun.star.text.XTextDocument.class, xComp);
+ UnoRuntime.queryInterface(
+ com.sun.star.text.XTextDocument.class, xComp);
// Querying for the interface XMultiServiceFactory on the xtextdocument
com.sun.star.lang.XMultiServiceFactory xMSFDoc =
- (com.sun.star.lang.XMultiServiceFactory)UnoRuntime.queryInterface(
- com.sun.star.lang.XMultiServiceFactory.class, xTextDoc);
+ UnoRuntime.queryInterface(
+ com.sun.star.lang.XMultiServiceFactory.class, xTextDoc);
// Providing a log file for output
PrintWriter printwriterLog = new PrintWriter(
@@ -115,8 +114,8 @@ public class GraphicsInserter {
// Querying for the interface XTextContent on the GraphicObject
com.sun.star.text.XTextContent xTextContent =
- (com.sun.star.text.XTextContent)UnoRuntime.queryInterface(
- com.sun.star.text.XTextContent.class, oGraphic );
+ UnoRuntime.queryInterface(
+ com.sun.star.text.XTextContent.class, oGraphic );
// Printing information to the log file
printwriterLog.println( "inserting graphic" );
@@ -133,8 +132,8 @@ public class GraphicsInserter {
// Querying for the interface XPropertySet on GraphicObject
com.sun.star.beans.XPropertySet xPropSet =
- (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface(
- com.sun.star.beans.XPropertySet.class, oGraphic);
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, oGraphic);
try {
// Creating a string for the graphic url
java.io.File sourceFile = new java.io.File(args[0]);
diff --git a/odk/examples/java/Text/HardFormatting.java b/odk/examples/java/Text/HardFormatting.java
index 9fff431acc52..b94f62064833 100644
--- a/odk/examples/java/Text/HardFormatting.java
+++ b/odk/examples/java/Text/HardFormatting.java
@@ -69,8 +69,7 @@ public class HardFormatting {
// you travel only at the model, not at the view. The cursor that you can
// see on the document doesn't change the position
com.sun.star.text.XTextCursor xTextCursor = null;
- xTextCursor = (com.sun.star.text.XTextCursor)
- xTextDocument.getText().createTextCursor();
+ xTextCursor = xTextDocument.getText().createTextCursor();
xText.insertString( xTextCursor, "Headline", false );
xText.insertControlCharacter(xTextCursor,
@@ -84,15 +83,13 @@ public class HardFormatting {
// BEGIN: 'Hard formating'
// the text range not the cursor contains the 'parastyle' property
xTextRange = xText.getEnd();
- xPropertySet = (com.sun.star.beans.XPropertySet)
- UnoRuntime.queryInterface(
- com.sun.star.beans.XPropertySet.class, xTextRange);
+ xPropertySet = UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xTextRange);
// create a paragraph cursor to travel throught the paragraphs
com.sun.star.text.XParagraphCursor xParagraphCursor = null;
- xParagraphCursor = (com.sun.star.text.XParagraphCursor)
- UnoRuntime.queryInterface(
- com.sun.star.text.XParagraphCursor.class, xTextRange);
+ xParagraphCursor = UnoRuntime.queryInterface(
+ com.sun.star.text.XParagraphCursor.class, xTextRange);
xParagraphCursor.gotoStart( false );
xParagraphCursor.gotoEndOfParagraph( true );
@@ -100,13 +97,12 @@ public class HardFormatting {
// create a WordCursor to travel into the paragraph
com.sun.star.text.XWordCursor xWordCursor = null;
- xWordCursor = (com.sun.star.text.XWordCursor) UnoRuntime.queryInterface(
+ xWordCursor = UnoRuntime.queryInterface(
com.sun.star.text.XWordCursor.class, xTextRange);
// the PropertySet from the cursor contains the text attributes
- xPropertySet = (com.sun.star.beans.XPropertySet)
- UnoRuntime.queryInterface(
- com.sun.star.beans.XPropertySet.class, xWordCursor);
+ xPropertySet = UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xWordCursor);
System.out.println(
"Parastyle : "
+xPropertySet.getPropertyValue("ParaStyleName").toString()
@@ -119,9 +115,8 @@ public class HardFormatting {
xWordCursor.gotoNextWord(false);
xWordCursor.gotoEndOfWord(true);
- xPropertySet = (com.sun.star.beans.XPropertySet)
- UnoRuntime.queryInterface(
- com.sun.star.beans.XPropertySet.class, xWordCursor);
+ xPropertySet = UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xWordCursor);
xPropertySet.setPropertyValue("CharWeight",
new Float(com.sun.star.awt.FontWeight.BOLD));
xPropertySet.setPropertyValue("CharColor", new Integer( 255 ) );
@@ -137,9 +132,8 @@ public class HardFormatting {
// the PropertyState contains information where the attribute is set,
// is a text part hard formated or not.
com.sun.star.beans.XPropertyState xPropertyState = null;
- xPropertyState = (com.sun.star.beans.XPropertyState)
- UnoRuntime.queryInterface(
- com.sun.star.beans.XPropertyState.class, xWordCursor);
+ xPropertyState = UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertyState.class, xWordCursor);
com.sun.star.beans.PropertyState xPropertyStateValue =
xPropertyState.getPropertyState("CharWeight");
@@ -221,7 +215,7 @@ public class HardFormatting {
Object oDesktop = xMCF.createInstanceWithContext(
"com.sun.star.frame.Desktop", xContext);
- xDesktop = (com.sun.star.frame.XDesktop) UnoRuntime.queryInterface(
+ xDesktop = UnoRuntime.queryInterface(
com.sun.star.frame.XDesktop.class, oDesktop);
}
else
@@ -244,9 +238,8 @@ public class HardFormatting {
try {
com.sun.star.lang.XComponent xComponent = CreateNewDocument(xDesktop,
"swriter");
- aTextDocument = (com.sun.star.text.XTextDocument)
- UnoRuntime.queryInterface(
- com.sun.star.text.XTextDocument.class, xComponent);
+ aTextDocument = UnoRuntime.queryInterface(
+ com.sun.star.text.XTextDocument.class, xComponent);
}
catch( Exception e) {
e.printStackTrace(System.err);
@@ -270,9 +263,8 @@ public class HardFormatting {
new com.sun.star.beans.PropertyValue[0];
try {
- xComponentLoader = (com.sun.star.frame.XComponentLoader)
- UnoRuntime.queryInterface(
- com.sun.star.frame.XComponentLoader.class, xDesktop);
+ xComponentLoader = UnoRuntime.queryInterface(
+ com.sun.star.frame.XComponentLoader.class, xDesktop);
xComponent = xComponentLoader.loadComponentFromURL(
sURL, "_blank", 0, xEmptyArgs);
diff --git a/odk/examples/java/Text/SWriter.java b/odk/examples/java/Text/SWriter.java
index 18ae35481189..7b79bc817997 100644
--- a/odk/examples/java/Text/SWriter.java
+++ b/odk/examples/java/Text/SWriter.java
@@ -116,16 +116,15 @@ public class SWriter {
//getting MSF of the document
com.sun.star.lang.XMultiServiceFactory xDocMSF =
- (com.sun.star.lang.XMultiServiceFactory) UnoRuntime.queryInterface(
- com.sun.star.lang.XMultiServiceFactory.class, myDoc);
+ UnoRuntime.queryInterface(
+ com.sun.star.lang.XMultiServiceFactory.class, myDoc);
//create instance of a text table
com.sun.star.text.XTextTable xTT = null;
try {
Object oInt = xDocMSF.createInstance("com.sun.star.text.TextTable");
- xTT = (com.sun.star.text.XTextTable)
- UnoRuntime.queryInterface(com.sun.star.text.XTextTable.class,oInt);
+ xTT = UnoRuntime.queryInterface(com.sun.star.text.XTextTable.class,oInt);
} catch (Exception e) {
System.err.println("Couldn't create instance "+ e);
e.printStackTrace(System.err);
@@ -141,7 +140,7 @@ public class SWriter {
xText.insertTextContent(xTCursor, xTT, false);
// get first Row
com.sun.star.container.XIndexAccess xTTRows = xTT.getRows();
- xTTRowPS = (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface(
+ xTTRowPS = UnoRuntime.queryInterface(
com.sun.star.beans.XPropertySet.class, xTTRows.getByIndex(0));
} catch (Exception e) {
@@ -152,8 +151,7 @@ public class SWriter {
// get the property set of the text table
- com.sun.star.beans.XPropertySet xTTPS = (com.sun.star.beans.XPropertySet)
- UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class, xTT);
+ com.sun.star.beans.XPropertySet xTTPS = UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class, xTT);
// Change the BackColor
try {
@@ -202,9 +200,8 @@ public class SWriter {
//*************************************************************************
// get the property set of the cursor
- com.sun.star.beans.XPropertySet xTCPS = (com.sun.star.beans.XPropertySet)
- UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class,
- xTCursor);
+ com.sun.star.beans.XPropertySet xTCPS = UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class,
+ xTCursor);
Object oldValue = null;
@@ -257,9 +254,9 @@ public class SWriter {
try {
Object oInt = xDocMSF.createInstance("com.sun.star.text.TextFrame");
- xTF = (com.sun.star.text.XTextFrame) UnoRuntime.queryInterface(
+ xTF = UnoRuntime.queryInterface(
com.sun.star.text.XTextFrame.class,oInt);
- xTFS = (com.sun.star.drawing.XShape) UnoRuntime.queryInterface(
+ xTFS = UnoRuntime.queryInterface(
com.sun.star.drawing.XShape.class,oInt);
com.sun.star.awt.Size aSize = new com.sun.star.awt.Size();
@@ -273,8 +270,7 @@ public class SWriter {
}
// get the property set of the text frame
- com.sun.star.beans.XPropertySet xTFPS = (com.sun.star.beans.XPropertySet)
- UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class, xTF);
+ com.sun.star.beans.XPropertySet xTFPS = UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class, xTF);
// Change the AnchorType
try {
@@ -352,16 +348,14 @@ public class SWriter {
Object oDesktop = xMCF.createInstanceWithContext(
"com.sun.star.frame.Desktop", xContext);
- xCLoader = (com.sun.star.frame.XComponentLoader)
- UnoRuntime.queryInterface(com.sun.star.frame.XComponentLoader.class,
- oDesktop);
+ xCLoader = UnoRuntime.queryInterface(com.sun.star.frame.XComponentLoader.class,
+ oDesktop);
com.sun.star.beans.PropertyValue [] szEmptyArgs =
new com.sun.star.beans.PropertyValue [0];
String strDoc = "private:factory/swriter";
xComp = xCLoader.loadComponentFromURL(strDoc, "_blank", 0, szEmptyArgs);
- xDoc = (com.sun.star.text.XTextDocument)
- UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class,
- xComp);
+ xDoc = UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class,
+ xComp);
} catch(Exception e){
System.err.println(" Exception " + e);
@@ -373,15 +367,13 @@ public class SWriter {
public static void insertIntoCell(String CellName, String theText,
com.sun.star.text.XTextTable xTTbl) {
- com.sun.star.text.XText xTableText = (com.sun.star.text.XText)
- UnoRuntime.queryInterface(com.sun.star.text.XText.class,
- xTTbl.getCellByName(CellName));
+ com.sun.star.text.XText xTableText = UnoRuntime.queryInterface(com.sun.star.text.XText.class,
+ xTTbl.getCellByName(CellName));
//create a cursor object
com.sun.star.text.XTextCursor xTC = xTableText.createTextCursor();
- com.sun.star.beans.XPropertySet xTPS = (com.sun.star.beans.XPropertySet)
- UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class, xTC);
+ com.sun.star.beans.XPropertySet xTPS = UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class, xTC);
try {
xTPS.setPropertyValue("CharColor",new Integer(16777215));
diff --git a/odk/examples/java/Text/StyleCreation.java b/odk/examples/java/Text/StyleCreation.java
index 91cfb3f7a8c6..f32b6672dfae 100644
--- a/odk/examples/java/Text/StyleCreation.java
+++ b/odk/examples/java/Text/StyleCreation.java
@@ -60,8 +60,8 @@ public class StyleCreation {
// the service '..ParagraphStyle' is context dependend, you need
// the multi service factory from the document to use the service
com.sun.star.lang.XMultiServiceFactory xDocMSF =
- (com.sun.star.lang.XMultiServiceFactory)UnoRuntime.queryInterface(
- com.sun.star.lang.XMultiServiceFactory.class, xTextDocument);
+ UnoRuntime.queryInterface(
+ com.sun.star.lang.XMultiServiceFactory.class, xTextDocument);
// use the service 'com.sun.star.style.ParagraphStyle'
com.sun.star.uno.XInterface xInterface = (com.sun.star.uno.XInterface)
@@ -69,8 +69,8 @@ public class StyleCreation {
// create a supplier to get the Style family collection
com.sun.star.style.XStyleFamiliesSupplier xSupplier =
- (com.sun.star.style.XStyleFamiliesSupplier)UnoRuntime.queryInterface(
- com.sun.star.style.XStyleFamiliesSupplier.class, xTextDocument );
+ UnoRuntime.queryInterface(
+ com.sun.star.style.XStyleFamiliesSupplier.class, xTextDocument );
// get the NameAccess interface from the Style family collection
com.sun.star.container.XNameAccess xNameAccess =
@@ -78,14 +78,14 @@ public class StyleCreation {
// select the Paragraph styles, you get the Paragraph style collection
com.sun.star.container.XNameContainer xParaStyleCollection =
- (com.sun.star.container.XNameContainer) UnoRuntime.queryInterface(
- com.sun.star.container.XNameContainer.class,
- xNameAccess.getByName("ParagraphStyles"));
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XNameContainer.class,
+ xNameAccess.getByName("ParagraphStyles"));
// create a PropertySet to set the properties for the new Paragraphstyle
com.sun.star.beans.XPropertySet xPropertySet =
- (com.sun.star.beans.XPropertySet) UnoRuntime.queryInterface(
- com.sun.star.beans.XPropertySet.class, xInterface );
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xInterface );
System.out.println( "create a PropertySet to set the properties for the new Paragraphstyle" );
// set some properties from the Paragraph style
@@ -122,8 +122,8 @@ public class StyleCreation {
// get the PropertySet from the current paragraph
com.sun.star.beans.XPropertySet xParagraphPropertySet =
- (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface(
- com.sun.star.beans.XPropertySet.class, xTextRange );
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xTextRange );
// change the value from the property 'ParaStyle' to apply the
// Paragraph style
// To run the sample with StarOffice 5.2 you'll have to change
@@ -160,7 +160,7 @@ public class StyleCreation {
Object oDesktop = xMCF.createInstanceWithContext(
"com.sun.star.frame.Desktop", xContext);
- xDesktop = (com.sun.star.frame.XDesktop) UnoRuntime.queryInterface(
+ xDesktop = UnoRuntime.queryInterface(
com.sun.star.frame.XDesktop.class, oDesktop);
}
else
@@ -183,9 +183,8 @@ public class StyleCreation {
try {
com.sun.star.lang.XComponent xComponent = CreateNewDocument(xDesktop,
"swriter");
- aTextDocument = (com.sun.star.text.XTextDocument)
- UnoRuntime.queryInterface(
- com.sun.star.text.XTextDocument.class, xComponent);
+ aTextDocument = UnoRuntime.queryInterface(
+ com.sun.star.text.XTextDocument.class, xComponent);
}
catch( Exception e) {
e.printStackTrace(System.err);
@@ -209,9 +208,8 @@ public class StyleCreation {
new com.sun.star.beans.PropertyValue[0];
try {
- xComponentLoader = (com.sun.star.frame.XComponentLoader)
- UnoRuntime.queryInterface(
- com.sun.star.frame.XComponentLoader.class, xDesktop);
+ xComponentLoader = UnoRuntime.queryInterface(
+ com.sun.star.frame.XComponentLoader.class, xDesktop);
xComponent = xComponentLoader.loadComponentFromURL(
sURL, "_blank", 0, xEmptyArgs);
diff --git a/odk/examples/java/Text/StyleInitialization.java b/odk/examples/java/Text/StyleInitialization.java
index c08243609499..e092a3634fb9 100644
--- a/odk/examples/java/Text/StyleInitialization.java
+++ b/odk/examples/java/Text/StyleInitialization.java
@@ -70,12 +70,10 @@ public class StyleInitialization {
// you travel only at the model, not at the view. The cursor that you can
// see on the document doesn't change the position
com.sun.star.text.XTextCursor xTextCursor = null;
- xTextCursor = (com.sun.star.text.XTextCursor)
- xTextDocument.getText().createTextCursor();
+ xTextCursor = xTextDocument.getText().createTextCursor();
- com.sun.star.beans.XPropertySet oCPS = (com.sun.star.beans.XPropertySet)
- UnoRuntime.queryInterface(
- com.sun.star.beans.XPropertySet.class, xTextCursor);
+ com.sun.star.beans.XPropertySet oCPS = UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xTextCursor);
try {
oCPS.setPropertyValue("CharFontName","Helvetica");
}
@@ -101,9 +99,8 @@ public class StyleInitialization {
// the text range not the cursor contains the 'parastyle' property
xTextRange = xText.getEnd();
- xPropertySet = (com.sun.star.beans.XPropertySet)
- UnoRuntime.queryInterface(
- com.sun.star.beans.XPropertySet.class, xTextRange );
+ xPropertySet = UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xTextRange );
// To run the sample with StarOffice 5.2 you'll have to change
// 'ParaStyleName' to 'ParaStyle' in the next line
@@ -118,18 +115,16 @@ public class StyleInitialization {
// The first way, with the paragraph cursor
com.sun.star.text.XParagraphCursor xParagraphCursor = null;
- xParagraphCursor = (com.sun.star.text.XParagraphCursor)
- UnoRuntime.queryInterface(
- com.sun.star.text.XParagraphCursor.class, xTextRange );
+ xParagraphCursor = UnoRuntime.queryInterface(
+ com.sun.star.text.XParagraphCursor.class, xTextRange );
xParagraphCursor.gotoStart( false );
xParagraphCursor.gotoEndOfParagraph( true );
// The second way, with the paragraph enumeration
com.sun.star.container.XEnumerationAccess xEnumerationAccess = null;
- xEnumerationAccess = (com.sun.star.container.XEnumerationAccess)
- UnoRuntime.queryInterface(
- com.sun.star.container.XEnumerationAccess.class, xText );
+ xEnumerationAccess = UnoRuntime.queryInterface(
+ com.sun.star.container.XEnumerationAccess.class, xText );
// the enumeration contains all paragraph form the document
com.sun.star.container.XEnumeration xParagraphEnumeration = null;
@@ -144,10 +139,9 @@ public class StyleInitialization {
// check if a paragraph is available
while ( xParagraphEnumeration.hasMoreElements() ) {
// get the next paragraph
- xParagraph = (com.sun.star.text.XTextContent)
- UnoRuntime.queryInterface(
- com.sun.star.text.XTextContent.class,
- xParagraphEnumeration.nextElement());
+ xParagraph = UnoRuntime.queryInterface(
+ com.sun.star.text.XTextContent.class,
+ xParagraphEnumeration.nextElement());
// you need the method getAnchor to a TextRange -> to manipulate
// the paragraph
@@ -163,14 +157,13 @@ public class StyleInitialization {
// The enumeration from the paragraphs contain parts from the
// paragraph with a different attributes.
- xParaEnumerationAccess = (com.sun.star.container.XEnumerationAccess)
- UnoRuntime.queryInterface(
- com.sun.star.container.XEnumerationAccess.class, xParagraph);
+ xParaEnumerationAccess = UnoRuntime.queryInterface(
+ com.sun.star.container.XEnumerationAccess.class, xParagraph);
xPortionEnumeration = xParaEnumerationAccess.createEnumeration();
while ( xPortionEnumeration.hasMoreElements() ) {
// output of all parts from the paragraph with different attributes
- xWord = (com.sun.star.text.XTextRange) UnoRuntime.queryInterface(
+ xWord = UnoRuntime.queryInterface(
com.sun.star.text.XTextRange.class,
xPortionEnumeration.nextElement());
String sWordString = xWord.getString();
@@ -182,7 +175,7 @@ public class StyleInitialization {
// craete a supplier to get the styles-collection
com.sun.star.style.XStyleFamiliesSupplier xSupplier = null;
- xSupplier = ( com.sun.star.style.XStyleFamiliesSupplier ) UnoRuntime.queryInterface(
+ xSupplier = UnoRuntime.queryInterface(
com.sun.star.style.XStyleFamiliesSupplier.class, xTextDocument );
// use the name access from the collection
@@ -190,7 +183,7 @@ public class StyleInitialization {
xNameAccess = xSupplier.getStyleFamilies();
com.sun.star.container.XNameContainer xParaStyleCollection = null;
- xParaStyleCollection = (com.sun.star.container.XNameContainer) UnoRuntime.queryInterface(
+ xParaStyleCollection = UnoRuntime.queryInterface(
com.sun.star.container.XNameContainer.class, xNameAccess.getByName( "ParagraphStyles" ));
// create a array from strings with the name of all paragraph styles from the text document
@@ -200,12 +193,12 @@ public class StyleInitialization {
for( int iCounter = 0; iCounter < iElementCount; iCounter++ ) {
// specify one paragraph style
com.sun.star.style.XStyle xStyle = null;
- xStyle = (com.sun.star.style.XStyle) UnoRuntime.queryInterface(
+ xStyle = UnoRuntime.queryInterface(
com.sun.star.style.XStyle.class,
xParaStyleCollection.getByName( sElementNames[iCounter] ));
// create a property set of all properties from the style
- xPropertySet = (com.sun.star.beans.XPropertySet) UnoRuntime.queryInterface(
+ xPropertySet = UnoRuntime.queryInterface(
com.sun.star.beans.XPropertySet.class, xStyle );
AnyConverter aAnyConv = new AnyConverter();
@@ -215,7 +208,7 @@ public class StyleInitialization {
// if the style use the font 'Albany', apply it to the current paragraph
if( sFontname.compareTo("albany") == 0 ) {
// create a property set from the current paragraph, to change the paragraph style
- xPropertySet = (com.sun.star.beans.XPropertySet) UnoRuntime.queryInterface(
+ xPropertySet = UnoRuntime.queryInterface(
com.sun.star.beans.XPropertySet.class, xTextRange );
// To run the sample with StarOffice 5.2 you'll have to change 'ParaStyleName'
@@ -255,7 +248,7 @@ public class StyleInitialization {
Object oDesktop = xMCF.createInstanceWithContext(
"com.sun.star.frame.Desktop", xContext);
- xDesktop = (com.sun.star.frame.XDesktop) UnoRuntime.queryInterface(
+ xDesktop = UnoRuntime.queryInterface(
com.sun.star.frame.XDesktop.class, oDesktop);
}
else
@@ -278,9 +271,8 @@ public class StyleInitialization {
try {
com.sun.star.lang.XComponent xComponent = CreateNewDocument(xDesktop,
"swriter");
- aTextDocument = (com.sun.star.text.XTextDocument)
- UnoRuntime.queryInterface(
- com.sun.star.text.XTextDocument.class, xComponent);
+ aTextDocument = UnoRuntime.queryInterface(
+ com.sun.star.text.XTextDocument.class, xComponent);
}
catch( Exception e) {
e.printStackTrace(System.err);
@@ -304,9 +296,8 @@ public class StyleInitialization {
new com.sun.star.beans.PropertyValue[0];
try {
- xComponentLoader = (com.sun.star.frame.XComponentLoader)
- UnoRuntime.queryInterface(
- com.sun.star.frame.XComponentLoader.class, xDesktop);
+ xComponentLoader = UnoRuntime.queryInterface(
+ com.sun.star.frame.XComponentLoader.class, xDesktop);
xComponent = xComponentLoader.loadComponentFromURL(
sURL, "_blank", 0, xEmptyArgs);
diff --git a/odk/examples/java/Text/TextDocumentStructure.java b/odk/examples/java/Text/TextDocumentStructure.java
index f60ce98c937d..74b2659ac9ee 100644
--- a/odk/examples/java/Text/TextDocumentStructure.java
+++ b/odk/examples/java/Text/TextDocumentStructure.java
@@ -62,9 +62,8 @@ public class TextDocumentStructure {
// get the component laoder from the desktop to create a new
// text document
com.sun.star.frame.XComponentLoader xCLoader =
- (com.sun.star.frame.XComponentLoader)
UnoRuntime.queryInterface(
- com.sun.star.frame.XComponentLoader.class,oDesktop);
+ com.sun.star.frame.XComponentLoader.class,oDesktop);
com.sun.star.beans.PropertyValue [] szEmptyArgs =
new com.sun.star.beans.PropertyValue [0];
String strDoc = "private:factory/swriter";
@@ -76,8 +75,8 @@ public class TextDocumentStructure {
// query the new document for the XTextDocument interface
com.sun.star.text.XTextDocument xTextDocument =
- (com.sun.star.text.XTextDocument)UnoRuntime.queryInterface(
- com.sun.star.text.XTextDocument.class, xComp);
+ UnoRuntime.queryInterface(
+ com.sun.star.text.XTextDocument.class, xComp);
// create some example data
com.sun.star.text.XText xText = xTextDocument.getText();
@@ -94,20 +93,18 @@ public class TextDocumentStructure {
System.out.println("create an enumeration of all paragraphs");
// create an enumeration access of all paragraphs of a document
com.sun.star.container.XEnumerationAccess xEnumerationAccess =
- (com.sun.star.container.XEnumerationAccess)
- UnoRuntime.queryInterface(
- com.sun.star.container.XEnumerationAccess.class, xText);
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XEnumerationAccess.class, xText);
xParagraphEnumeration = xEnumerationAccess.createEnumeration();
// Loop through all paragraphs of the document
while ( xParagraphEnumeration.hasMoreElements() ) {
- xTextElement = (com.sun.star.text.XTextContent)
- UnoRuntime.queryInterface(
- com.sun.star.text.XTextContent.class,
- xParagraphEnumeration.nextElement());
+ xTextElement = UnoRuntime.queryInterface(
+ com.sun.star.text.XTextContent.class,
+ xParagraphEnumeration.nextElement());
com.sun.star.lang.XServiceInfo xServiceInfo =
- (com.sun.star.lang.XServiceInfo)UnoRuntime.queryInterface(
- com.sun.star.lang.XServiceInfo.class, xTextElement);
+ UnoRuntime.queryInterface(
+ com.sun.star.lang.XServiceInfo.class, xTextElement);
// check ifs the current paragraph really a paragraph or an
// anchor of a frame or picture
@@ -119,34 +116,31 @@ public class TextDocumentStructure {
// create another enumeration to get all text portions of
// the paragraph
xParaEnumerationAccess =
- (com.sun.star.container.XEnumerationAccess)
- UnoRuntime.queryInterface(
- com.sun.star.container.XEnumerationAccess.class,
- xTextElement);
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XEnumerationAccess.class,
+ xTextElement);
xTextPortionEnum = xParaEnumerationAccess.createEnumeration();
while ( xTextPortionEnum.hasMoreElements() ) {
com.sun.star.text.XTextRange xTextPortion =
- (com.sun.star.text.XTextRange)UnoRuntime.queryInterface(
- com.sun.star.text.XTextRange.class,
- xTextPortionEnum.nextElement());
+ UnoRuntime.queryInterface(
+ com.sun.star.text.XTextRange.class,
+ xTextPortionEnum.nextElement());
System.out.println( "Text from the portion : "
+ xTextPortion.getString() );
com.sun.star.beans.XPropertySet xPropertySet =
- (com.sun.star.beans.XPropertySet)
- UnoRuntime.queryInterface(
- com.sun.star.beans.XPropertySet.class,
- xTextPortion);
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class,
+ xTextPortion);
System.out.println( "Name of the font : "
+ xPropertySet.getPropertyValue( "CharFontName" ) );
// PropertyState status of each text portion.
com.sun.star.beans.XPropertyState xPropertyState =
- (com.sun.star.beans.XPropertyState)
- UnoRuntime.queryInterface(
- com.sun.star.beans.XPropertyState.class,
- xTextPortion);
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertyState.class,
+ xTextPortion);
if( xPropertyState.getPropertyState("CharWeight").equals(
com.sun.star.beans.PropertyState.AMBIGUOUS_VALUE) )
@@ -181,16 +175,16 @@ public class TextDocumentStructure {
xText.setString( "This is an example sentence" );
com.sun.star.text.XWordCursor xWordCursor =
- (com.sun.star.text.XWordCursor)UnoRuntime.queryInterface(
- com.sun.star.text.XWordCursor.class, xText.getStart());
+ UnoRuntime.queryInterface(
+ com.sun.star.text.XWordCursor.class, xText.getStart());
xWordCursor.gotoNextWord(false);
xWordCursor.gotoNextWord(false);
xWordCursor.gotoEndOfWord(true);
com.sun.star.beans.XPropertySet xPropertySet =
- (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface(
- com.sun.star.beans.XPropertySet.class, xWordCursor );
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xWordCursor );
xPropertySet.setPropertyValue("CharWeight",
new Float( com.sun.star.awt.FontWeight.BOLD ));
diff --git a/odk/examples/java/Text/TextReplace.java b/odk/examples/java/Text/TextReplace.java
index 980b955e990f..86ce7a4d2e18 100644
--- a/odk/examples/java/Text/TextReplace.java
+++ b/odk/examples/java/Text/TextReplace.java
@@ -66,13 +66,11 @@ public class TextReplace {
com.sun.star.util.XSearchDescriptor xSearchDescriptor = null;
com.sun.star.util.XReplaceable xReplaceable = null;
- xReplaceable = (com.sun.star.util.XReplaceable)
- UnoRuntime.queryInterface(
- com.sun.star.util.XReplaceable.class, xTextDocument);
+ xReplaceable = UnoRuntime.queryInterface(
+ com.sun.star.util.XReplaceable.class, xTextDocument);
// You need a descriptor to set properies for Replace
- xReplaceDescr = (com.sun.star.util.XReplaceDescriptor)
- xReplaceable.createReplaceDescriptor();
+ xReplaceDescr = xReplaceable.createReplaceDescriptor();
System.out.println("Change all occurrences of ...");
for( int iArrayCounter = 0; iArrayCounter < mBritishWords.length;
@@ -106,18 +104,15 @@ public class TextReplace {
com.sun.star.text.XTextCursor xTextCursor = null;
try {
- xTextCursor = (com.sun.star.text.XTextCursor)
- xTextDocument.getText().createTextCursor();
- com.sun.star.text.XText xText = (com.sun.star.text.XText)
- xTextDocument.getText();
+ xTextCursor = xTextDocument.getText().createTextCursor();
+ com.sun.star.text.XText xText = xTextDocument.getText();
xText.insertString( xTextCursor,
"He nervously looked all around. Suddenly he saw his ", false );
xText.insertString( xTextCursor, "neighbour ", true );
- com.sun.star.beans.XPropertySet xCPS = (com.sun.star.beans.XPropertySet)
- UnoRuntime.queryInterface(
- com.sun.star.beans.XPropertySet.class, xTextCursor);
+ com.sun.star.beans.XPropertySet xCPS = UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xTextCursor);
// Set the word blue
xCPS.setPropertyValue( "CharColor", new Integer( 255 ) );
// Go to last character
@@ -127,7 +122,7 @@ public class TextReplace {
xText.insertString( xTextCursor, "in the alley. Like lightening he darted off to the left and disappeared between the two warehouses almost falling over the trash can lying in the ", false );
xText.insertString( xTextCursor, "centre ", true );
- xCPS = (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface(
+ xCPS = UnoRuntime.queryInterface(
com.sun.star.beans.XPropertySet.class, xTextCursor);
// Set the word blue
xCPS.setPropertyValue( "CharColor", new Integer( 255 ) );
@@ -166,7 +161,7 @@ public class TextReplace {
Object oDesktop = xMCF.createInstanceWithContext(
"com.sun.star.frame.Desktop", xContext);
- xDesktop = (com.sun.star.frame.XDesktop) UnoRuntime.queryInterface(
+ xDesktop = UnoRuntime.queryInterface(
com.sun.star.frame.XDesktop.class, oDesktop);
}
else
@@ -189,9 +184,8 @@ public class TextReplace {
try {
com.sun.star.lang.XComponent xComponent = CreateNewDocument(xDesktop,
"swriter");
- aTextDocument = (com.sun.star.text.XTextDocument)
- UnoRuntime.queryInterface(
- com.sun.star.text.XTextDocument.class, xComponent);
+ aTextDocument = UnoRuntime.queryInterface(
+ com.sun.star.text.XTextDocument.class, xComponent);
}
catch( Exception e) {
e.printStackTrace(System.err);
@@ -215,9 +209,8 @@ public class TextReplace {
new com.sun.star.beans.PropertyValue[0];
try {
- xComponentLoader = (com.sun.star.frame.XComponentLoader)
- UnoRuntime.queryInterface(
- com.sun.star.frame.XComponentLoader.class, xDesktop);
+ xComponentLoader = UnoRuntime.queryInterface(
+ com.sun.star.frame.XComponentLoader.class, xDesktop);
xComponent = xComponentLoader.loadComponentFromURL(
sURL, "_blank", 0, xEmptyArgs);
diff --git a/odk/examples/java/Text/WriterSelector.java b/odk/examples/java/Text/WriterSelector.java
index 6fd00189d657..1343293a968a 100644
--- a/odk/examples/java/Text/WriterSelector.java
+++ b/odk/examples/java/Text/WriterSelector.java
@@ -57,32 +57,30 @@ public class WriterSelector {
xContext.getServiceManager();
// get a new instance of the desktop
- com.sun.star.frame.XDesktop xDesktop = (com.sun.star.frame.XDesktop)
- UnoRuntime.queryInterface(com.sun.star.frame.XDesktop.class,
- xMCF.createInstanceWithContext("com.sun.star.frame.Desktop",
- xContext ) );
+ com.sun.star.frame.XDesktop xDesktop = UnoRuntime.queryInterface(com.sun.star.frame.XDesktop.class,
+ xMCF.createInstanceWithContext("com.sun.star.frame.Desktop",
+ xContext ) );
com.sun.star.frame.XComponentLoader xCompLoader =
- (com.sun.star.frame.XComponentLoader)UnoRuntime.queryInterface(
- com.sun.star.frame.XComponentLoader.class, xDesktop);
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XComponentLoader.class, xDesktop);
com.sun.star.lang.XComponent xComponent =
xCompLoader.loadComponentFromURL("private:factory/swriter",
"_blank", 0, new com.sun.star.beans.PropertyValue[0]);
{
- com.sun.star.text.XTextDocument xDoc =(com.sun.star.text.XTextDocument)
- UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class,
- xComponent);
+ com.sun.star.text.XTextDocument xDoc =UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class,
+ xComponent);
xDoc.getText().setString("Please select something in this text and press then \"return\" in the shell where you have started the example.\n");
// ensure that the document content is optimal visible
com.sun.star.frame.XModel xModel =
- (com.sun.star.frame.XModel)UnoRuntime.queryInterface(
- com.sun.star.frame.XModel.class, xDoc);
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XModel.class, xDoc);
com.sun.star.view.XViewSettingsSupplier xViewSettings =
- (com.sun.star.view.XViewSettingsSupplier)UnoRuntime.queryInterface(
- com.sun.star.view.XViewSettingsSupplier.class, xModel.getCurrentController());
+ UnoRuntime.queryInterface(
+ com.sun.star.view.XViewSettingsSupplier.class, xModel.getCurrentController());
xViewSettings.getViewSettings().setPropertyValue(
"ZoomType", new Short((short)0));
}
@@ -101,28 +99,27 @@ public class WriterSelector {
com.sun.star.frame.XController xController = xframe.getController();
com.sun.star.view.XSelectionSupplier xSelSupplier =
- (com.sun.star.view.XSelectionSupplier)UnoRuntime.queryInterface(
- com.sun.star.view.XSelectionSupplier.class, xController );
+ UnoRuntime.queryInterface(
+ com.sun.star.view.XSelectionSupplier.class, xController );
Object oSelection = xSelSupplier.getSelection();
com.sun.star.lang.XServiceInfo xServInfo =
- (com.sun.star.lang.XServiceInfo)UnoRuntime.queryInterface(
- com.sun.star.lang.XServiceInfo.class, oSelection );
+ UnoRuntime.queryInterface(
+ com.sun.star.lang.XServiceInfo.class, oSelection );
if ( xServInfo.supportsService("com.sun.star.text.TextRanges") )
{
com.sun.star.container.XIndexAccess xIndexAccess =
- (com.sun.star.container.XIndexAccess)UnoRuntime.queryInterface(
- com.sun.star.container.XIndexAccess.class, oSelection);
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XIndexAccess.class, oSelection);
int count = xIndexAccess.getCount();
com.sun.star.text.XTextRange xTextRange = null;
for ( int i = 0; i < count; i++ ) {
- xTextRange = (com.sun.star.text.XTextRange)
- UnoRuntime.queryInterface(
- com.sun.star.text.XTextRange.class,
- xIndexAccess.getByIndex(i));
+ xTextRange = UnoRuntime.queryInterface(
+ com.sun.star.text.XTextRange.class,
+ xIndexAccess.getByIndex(i));
System.out.println( "You have selected a text range: \""
+ xTextRange.getString() + "\"." );
@@ -141,9 +138,8 @@ public class WriterSelector {
// close test document
- com.sun.star.util.XCloseable xCloseable = (com.sun.star.util.XCloseable)
- UnoRuntime.queryInterface(com.sun.star.util.XCloseable.class,
- xComponent );
+ com.sun.star.util.XCloseable xCloseable = UnoRuntime.queryInterface(com.sun.star.util.XCloseable.class,
+ xComponent );
if (xCloseable != null ) {
xCloseable.close(false);