From b65017a2a7af290f6681da7b197a52efe83d5185 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 27 Jun 2012 15:40:17 +0200 Subject: Java5 update - usage generics where possible Change-Id: I12f8c448961919e153047e28fee2a0acf3af1002 --- qadevOOo/runner/util/AccessibilityTools.java | 6 +- qadevOOo/runner/util/BasicMacroTools.java | 13 ++--- qadevOOo/runner/util/CalcTools.java | 8 +-- qadevOOo/runner/util/DBTools.java | 32 +++++------ qadevOOo/runner/util/DesktopTools.java | 34 ++++++------ qadevOOo/runner/util/DrawTools.java | 5 +- qadevOOo/runner/util/DynamicClassLoader.java | 12 ++-- qadevOOo/runner/util/FormTools.java | 43 +++++++------- qadevOOo/runner/util/FrameDsc.java | 2 +- qadevOOo/runner/util/InstCreator.java | 29 ++++------ qadevOOo/runner/util/InstDescr.java | 4 +- qadevOOo/runner/util/RegistryTools.java | 2 +- qadevOOo/runner/util/SOfficeFactory.java | 46 +++++++-------- qadevOOo/runner/util/SysUtils.java | 8 +-- qadevOOo/runner/util/UITools.java | 61 ++++++++------------ qadevOOo/runner/util/ValueChanger.java | 8 +-- qadevOOo/runner/util/ValueComparer.java | 2 +- qadevOOo/runner/util/WaitUnreachable.java | 4 +- qadevOOo/runner/util/WriterTools.java | 10 ++-- qadevOOo/runner/util/XMLTools.java | 80 +++++++++++++-------------- qadevOOo/runner/util/db/DataSource.java | 4 +- qadevOOo/runner/util/db/DatabaseDocument.java | 8 +-- qadevOOo/runner/util/utils.java | 22 ++++---- 23 files changed, 204 insertions(+), 239 deletions(-) (limited to 'qadevOOo/runner/util') diff --git a/qadevOOo/runner/util/AccessibilityTools.java b/qadevOOo/runner/util/AccessibilityTools.java index 95f45cf8b286..e6f345b0493c 100644 --- a/qadevOOo/runner/util/AccessibilityTools.java +++ b/qadevOOo/runner/util/AccessibilityTools.java @@ -339,7 +339,7 @@ public class AccessibilityTools { ac.getAccessibleDescription() + "):" + utils.getImplName(ac)); - XAccessibleComponent aComp = (XAccessibleComponent) UnoRuntime.queryInterface( + XAccessibleComponent aComp = UnoRuntime.queryInterface( XAccessibleComponent.class, xacc); if (aComp != null) { @@ -389,7 +389,7 @@ public class AccessibilityTools { } public static String accessibleToString(Object AC) { - XAccessibleContext xAC = (XAccessibleContext) UnoRuntime.queryInterface( + XAccessibleContext xAC = UnoRuntime.queryInterface( XAccessibleContext.class, AC); if (xAC != null) { @@ -398,7 +398,7 @@ public class AccessibilityTools { xAC.getAccessibleDescription() + "):"; } - XAccessible xA = (XAccessible) UnoRuntime.queryInterface( + XAccessible xA = UnoRuntime.queryInterface( XAccessible.class, AC); if (xA == null) { diff --git a/qadevOOo/runner/util/BasicMacroTools.java b/qadevOOo/runner/util/BasicMacroTools.java index b5e55278c787..313ed1b0f565 100644 --- a/qadevOOo/runner/util/BasicMacroTools.java +++ b/qadevOOo/runner/util/BasicMacroTools.java @@ -66,7 +66,7 @@ public class BasicMacroTools { mLCxNA = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, DocLibCont); - mLCxLC = (XLibraryContainer) UnoRuntime.queryInterface( + mLCxLC = UnoRuntime.queryInterface( XLibraryContainer.class, DocLibCont); } catch (Exception e) { @@ -98,7 +98,7 @@ public class BasicMacroTools { mLCxNA = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, ASLC); - mLCxLC = (XLibraryContainer) UnoRuntime.queryInterface( + mLCxLC = UnoRuntime.queryInterface( XLibraryContainer.class, ASLC); } catch (Exception e) { @@ -117,14 +117,14 @@ public class BasicMacroTools { throw new Exception("Could not create DispatchProvider"); } - return (XDispatchProvider) UnoRuntime.queryInterface( + return UnoRuntime.queryInterface( XDispatchProvider.class, xFrame); } private static XURLTransformer makeParser(XMultiServiceFactory mMSF) throws java.lang.Exception { try { - return (com.sun.star.util.XURLTransformer) UnoRuntime.queryInterface( + return UnoRuntime.queryInterface( XURLTransformer.class, mMSF.createInstance( "com.sun.star.util.URLTransformer")); } catch (Exception e) { @@ -231,8 +231,7 @@ public class BasicMacroTools { Object oProvider = xMSF.createInstance("com.sun.star.configuration.ConfigurationProvider"); - XMultiServiceFactory oProviderMSF = (XMultiServiceFactory) - UnoRuntime.queryInterface(XMultiServiceFactory.class, oProvider); + XMultiServiceFactory oProviderMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, oProvider); Object oSecure = oProviderMSF.createInstanceWithArguments( "com.sun.star.configuration.ConfigurationUpdateAccess", @@ -246,7 +245,7 @@ public class BasicMacroTools { oScriptingSettings.setPropertyValue("SecureURL", new String[]{secureURL}); oScriptingSettings.setPropertyValue("OfficeBasic", new Integer(2)); - XChangesBatch oSecureChange = (XChangesBatch) UnoRuntime.queryInterface(XChangesBatch.class, oSecure); + XChangesBatch oSecureChange = UnoRuntime.queryInterface(XChangesBatch.class, oSecure); oSecureChange.commitChanges(); } } diff --git a/qadevOOo/runner/util/CalcTools.java b/qadevOOo/runner/util/CalcTools.java index 7f12b2462aba..22bd2258ca3c 100644 --- a/qadevOOo/runner/util/CalcTools.java +++ b/qadevOOo/runner/util/CalcTools.java @@ -95,7 +95,7 @@ public class CalcTools { "Couldn't get CellRange from sheett: " + e.toString()); } - XCellRangeData xRangeData = (XCellRangeData) UnoRuntime.queryInterface(XCellRangeData.class, xRange); + XCellRangeData xRangeData = UnoRuntime.queryInterface(XCellRangeData.class, xRange); xRangeData.setDataArray(newData); } catch (Exception e){ @@ -119,13 +119,11 @@ public class CalcTools { XSpreadsheet xSheet = null; try{ - XSpreadsheetDocument xSpreadsheetDoc = (XSpreadsheetDocument) - UnoRuntime.queryInterface(XSpreadsheetDocument.class, xSheetDoc); + XSpreadsheetDocument xSpreadsheetDoc = UnoRuntime.queryInterface(XSpreadsheetDocument.class, xSheetDoc); XSpreadsheets xSpreadsheets = xSpreadsheetDoc.getSheets(); - XIndexAccess xSheetsIndexArray = (XIndexAccess) - UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets); + XIndexAccess xSheetsIndexArray = UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets); try{ xSheet = (XSpreadsheet) AnyConverter.toObject( diff --git a/qadevOOo/runner/util/DBTools.java b/qadevOOo/runner/util/DBTools.java index 825c626403e6..30c1b230548f 100644 --- a/qadevOOo/runner/util/DBTools.java +++ b/qadevOOo/runner/util/DBTools.java @@ -274,7 +274,7 @@ public class DBTools { try { Object cont = xMSF.createInstance("com.sun.star.sdb.DatabaseContext") ; - dbContext = (XNamingService) UnoRuntime.queryInterface + dbContext = UnoRuntime.queryInterface (XNamingService.class, cont) ; } catch (com.sun.star.uno.Exception e) {} @@ -320,9 +320,8 @@ public class DBTools { revokeDB(name) ; } catch (com.sun.star.uno.Exception e) {} - XDocumentDataSource xDDS = (XDocumentDataSource) - UnoRuntime.queryInterface(XDocumentDataSource.class, dataSource); - XStorable store = (XStorable) UnoRuntime.queryInterface(XStorable.class, + XDocumentDataSource xDDS = UnoRuntime.queryInterface(XDocumentDataSource.class, dataSource); + XStorable store = UnoRuntime.queryInterface(XStorable.class, xDDS.getDatabaseDocument()); String aFile = utils.getOfficeTemp(xMSF) + name + ".odb"; store.storeAsURL(aFile, new PropertyValue[] { }); @@ -355,11 +354,9 @@ public class DBTools { dbContext.registerObject(contextName, newSource) ; Object handler = xMSF.createInstance("com.sun.star.sdb.InteractionHandler"); - XInteractionHandler xHandler = (XInteractionHandler) - UnoRuntime.queryInterface(XInteractionHandler.class, handler) ; + XInteractionHandler xHandler = UnoRuntime.queryInterface(XInteractionHandler.class, handler) ; - XCompletedConnection xSrcCon = (XCompletedConnection) - UnoRuntime.queryInterface(XCompletedConnection.class, newSource) ; + XCompletedConnection xSrcCon = UnoRuntime.queryInterface(XCompletedConnection.class, newSource) ; XConnection con = xSrcCon.connectWithCompletion(xHandler) ; @@ -416,11 +413,9 @@ public class DBTools { throws com.sun.star.uno.Exception { Object handler = xMSF.createInstance("com.sun.star.sdb.InteractionHandler"); - XInteractionHandler xHandler = (XInteractionHandler) - UnoRuntime.queryInterface(XInteractionHandler.class, handler) ; + XInteractionHandler xHandler = UnoRuntime.queryInterface(XInteractionHandler.class, handler) ; - XCompletedConnection xSrcCon = (XCompletedConnection) - UnoRuntime.queryInterface(XCompletedConnection.class, dbSource) ; + XCompletedConnection xSrcCon = UnoRuntime.queryInterface(XCompletedConnection.class, dbSource) ; return xSrcCon.connectWithCompletion(xHandler) ; } @@ -510,7 +505,7 @@ public class DBTools { XResultSet set = stat.executeQuery("SELECT * FROM " + table) ; - XResultSetUpdate updt = (XResultSetUpdate) UnoRuntime.queryInterface + XResultSetUpdate updt = UnoRuntime.queryInterface (XResultSetUpdate.class, set) ; int count = 0 ; @@ -524,7 +519,7 @@ public class DBTools { count ++ ; } - XCloseable xClose = (XCloseable) UnoRuntime.queryInterface + XCloseable xClose = UnoRuntime.queryInterface (XCloseable.class, set) ; xClose.close() ; @@ -556,10 +551,10 @@ public class DBTools { XResultSet set = stat.executeQuery("SELECT * FROM " + table) ; - XResultSetUpdate updt = (XResultSetUpdate) UnoRuntime.queryInterface + XResultSetUpdate updt = UnoRuntime.queryInterface (XResultSetUpdate.class, set) ; - XRowUpdate rowUpdt = (XRowUpdate) UnoRuntime.queryInterface + XRowUpdate rowUpdt = UnoRuntime.queryInterface (XRowUpdate.class, set) ; updt.moveToInsertRow() ; @@ -592,7 +587,7 @@ public class DBTools { updt.insertRow() ; - XCloseable xClose = (XCloseable) UnoRuntime.queryInterface + XCloseable xClose = UnoRuntime.queryInterface (XCloseable.class, set) ; xClose.close() ; } @@ -622,8 +617,7 @@ public class DBTools { * Prints full info about currently registered DataSource's. */ public void printRegisteredDatabasesInfo(PrintWriter out) { - XEnumerationAccess dbContEA = (XEnumerationAccess) - UnoRuntime.queryInterface(XEnumerationAccess.class, dbContext) ; + XEnumerationAccess dbContEA = UnoRuntime.queryInterface(XEnumerationAccess.class, dbContext) ; XEnumeration xEnum = dbContEA.createEnumeration() ; diff --git a/qadevOOo/runner/util/DesktopTools.java b/qadevOOo/runner/util/DesktopTools.java index 0c7e6b3913d4..e24037f6c622 100644 --- a/qadevOOo/runner/util/DesktopTools.java +++ b/qadevOOo/runner/util/DesktopTools.java @@ -59,10 +59,10 @@ public class DesktopTools */ public static XComponentLoader getCLoader(XMultiServiceFactory xMSF) { - XDesktop oDesktop = (XDesktop) UnoRuntime.queryInterface( + XDesktop oDesktop = UnoRuntime.queryInterface( XDesktop.class, createDesktop(xMSF)); - XComponentLoader oCLoader = (XComponentLoader) UnoRuntime.queryInterface( + XComponentLoader oCLoader = UnoRuntime.queryInterface( XComponentLoader.class, oDesktop); return oCLoader; @@ -97,7 +97,7 @@ public class DesktopTools */ public static XEnumeration getAllComponents(XMultiServiceFactory xMSF) { - XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface( + XDesktop xDesktop = UnoRuntime.queryInterface( XDesktop.class, createDesktop(xMSF)); return xDesktop.getComponents().createEnumeration(); } @@ -109,7 +109,7 @@ public class DesktopTools */ public static XComponent getCurrentComponent(XMultiServiceFactory xMSF) { - XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface( + XDesktop xDesktop = UnoRuntime.queryInterface( XDesktop.class, createDesktop(xMSF)); return xDesktop.getCurrentComponent(); } @@ -121,7 +121,7 @@ public class DesktopTools */ public static XFrame getCurrentFrame(XMultiServiceFactory xMSF) { - XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface( + XDesktop xDesktop = UnoRuntime.queryInterface( XDesktop.class, createDesktop(xMSF)); return xDesktop.getCurrentFrame(); } @@ -138,8 +138,8 @@ public class DesktopTools */ public static Object[] getAllOpenDocuments(XMultiServiceFactory xMSF) { - ArrayList components = new ArrayList(); - XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface( + ArrayList components = new ArrayList(); + XDesktop xDesktop = UnoRuntime.queryInterface( XDesktop.class, createDesktop(xMSF)); XEnumeration allComp = getAllComponents(xMSF); @@ -148,7 +148,7 @@ public class DesktopTools { try { - XComponent xComponent = (XComponent) UnoRuntime.queryInterface( + XComponent xComponent = UnoRuntime.queryInterface( XComponent.class, allComp.nextElement()); if (getDocumentType(xComponent) != null) @@ -293,8 +293,8 @@ public class DesktopTools System.out.println("The property 'KeepDocument' is set and so the document won't be disposed"); return; } - XModifiable modified = (XModifiable) UnoRuntime.queryInterface(XModifiable.class, DocumentToClose); - XCloseable closer = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, DocumentToClose); + XModifiable modified = UnoRuntime.queryInterface(XModifiable.class, DocumentToClose); + XCloseable closer = UnoRuntime.queryInterface(XCloseable.class, DocumentToClose); try { @@ -363,7 +363,7 @@ public class DesktopTools throw new StatusException("Couldn't get toolkit", e); } - XToolkit tk = (XToolkit) UnoRuntime.queryInterface( + XToolkit tk = UnoRuntime.queryInterface( XToolkit.class, oObj); WindowDescriptor descriptor = new com.sun.star.awt.WindowDescriptor(); @@ -408,9 +408,9 @@ public class DesktopTools { try { - XModel xMod = (XModel) UnoRuntime.queryInterface(XModel.class, xDoc); + XModel xMod = UnoRuntime.queryInterface(XModel.class, xDoc); XInterface oCont = xMod.getCurrentController(); - XViewSettingsSupplier oVSSupp = (XViewSettingsSupplier) UnoRuntime.queryInterface(XViewSettingsSupplier.class, oCont); + XViewSettingsSupplier oVSSupp = UnoRuntime.queryInterface(XViewSettingsSupplier.class, oCont); XInterface oViewSettings = oVSSupp.getViewSettings(); XPropertySet oViewProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oViewSettings); @@ -488,9 +488,9 @@ public class DesktopTools // System.out.println("DEBUG: bring to front xModel"); XTopWindow xTopWindow = - (XTopWindow) UnoRuntime.queryInterface( - XTopWindow.class, - xModel.getCurrentController().getFrame().getContainerWindow()); + UnoRuntime.queryInterface( + XTopWindow.class, + xModel.getCurrentController().getFrame().getContainerWindow()); xTopWindow.toFront(); } @@ -498,7 +498,7 @@ public class DesktopTools public static void bringWindowToFront(XComponent xComponent) { // System.out.println("DEBUG: bring to front xComponent"); - XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xComponent); + XModel xModel = UnoRuntime.queryInterface(XModel.class, xComponent); if (xModel != null) { bringWindowToFront(xModel); diff --git a/qadevOOo/runner/util/DrawTools.java b/qadevOOo/runner/util/DrawTools.java index 64270d8ca9f9..842f34affee5 100644 --- a/qadevOOo/runner/util/DrawTools.java +++ b/qadevOOo/runner/util/DrawTools.java @@ -68,8 +68,7 @@ public class DrawTools { public static XDrawPages getDrawPages ( XComponent aDoc ) { XDrawPages oDPn = null; try { - XDrawPagesSupplier oDPS = (XDrawPagesSupplier) - UnoRuntime.queryInterface(XDrawPagesSupplier.class,aDoc); + XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class,aDoc); oDPn = oDPS.getDrawPages(); } catch ( Exception e ) { @@ -105,7 +104,7 @@ public class DrawTools { */ public static XShapes getShapes ( XDrawPage oDP ) { - return (XShapes) UnoRuntime.queryInterface(XShapes.class,oDP); + return UnoRuntime.queryInterface(XShapes.class,oDP); } /** diff --git a/qadevOOo/runner/util/DynamicClassLoader.java b/qadevOOo/runner/util/DynamicClassLoader.java index 702264017176..dbb3dd7972c2 100644 --- a/qadevOOo/runner/util/DynamicClassLoader.java +++ b/qadevOOo/runner/util/DynamicClassLoader.java @@ -31,7 +31,7 @@ public class DynamicClassLoader { * @param className The name of the class to create. * @return The created class. */ - public static Class forName(String className) + public static Class forName(String className) throws ClassNotFoundException { return Class.forName(className) ; @@ -45,7 +45,7 @@ public class DynamicClassLoader { public Object getInstance(String className) throws IllegalArgumentException { try { - Class cls = DynamicClassLoader.forName(className); + Class cls = DynamicClassLoader.forName(className); return cls.newInstance(); } catch ( ClassNotFoundException e ) { throw new IllegalArgumentException("Couldn't find " + className @@ -68,7 +68,7 @@ public class DynamicClassLoader { */ public Object getInstance(String className, Object[] ctorArgs) throws IllegalArgumentException { - Class[] ctorType = new Class[ctorArgs.length]; + Class[] ctorType = new Class[ctorArgs.length]; for(int i=0; i[]ctorClassTypes, Object[] ctorArgs) throws IllegalArgumentException { try { - Class cls = DynamicClassLoader.forName(className); - Constructor ctor = cls.getConstructor(ctorClassTypes); + Class cls = DynamicClassLoader.forName(className); + Constructor ctor = cls.getConstructor(ctorClassTypes); System.out.println("ctor: " + ctor.getName() + " " + ctor.getModifiers()); return ctor.newInstance(ctorArgs); diff --git a/qadevOOo/runner/util/FormTools.java b/qadevOOo/runner/util/FormTools.java index 2dc2f3bc1906..7bafd75047df 100644 --- a/qadevOOo/runner/util/FormTools.java +++ b/qadevOOo/runner/util/FormTools.java @@ -65,8 +65,7 @@ public class FormTools { XControlModel aControl = null; //get MSF - XMultiServiceFactory oDocMSF = (XMultiServiceFactory) - UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc ); + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc ); try{ Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape"); @@ -74,8 +73,8 @@ public class FormTools { XPropertySet model_props = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,aCon); model_props.setPropertyValue("DefaultControl","com.sun.star.form.control."+kind); - aControl = (XControlModel) UnoRuntime.queryInterface( XControlModel.class, aCon ); - oCShape = (XControlShape) UnoRuntime.queryInterface( XControlShape.class, oInt ); + aControl = UnoRuntime.queryInterface( XControlModel.class, aCon ); + oCShape = UnoRuntime.queryInterface( XControlShape.class, oInt ); size.Height = height; size.Width = width; position.X = x; @@ -101,7 +100,7 @@ public class FormTools { XControlModel aControl = null; //get MSF - XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc ); + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc ); try{ Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape"); @@ -109,8 +108,8 @@ public class FormTools { XPropertySet model_props = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,aCon); model_props.setPropertyValue("DefaultControl","com.sun.star.awt."+defControl); - aControl = (XControlModel) UnoRuntime.queryInterface( XControlModel.class, aCon ); - oCShape = (XControlShape) UnoRuntime.queryInterface( XControlShape.class, oInt ); + aControl = UnoRuntime.queryInterface( XControlModel.class, aCon ); + oCShape = UnoRuntime.queryInterface( XControlShape.class, oInt ); size.Height = height; size.Width = width; position.X = x; @@ -138,14 +137,14 @@ public class FormTools { XControlModel aControl = null; //get MSF - XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc ); + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc ); try{ Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape"); Object aCon = oDocMSF.createInstance("com.sun.star.form.component."+kind); - aControl = (XControlModel) UnoRuntime.queryInterface( XControlModel.class, aCon ); - oCShape = (XControlShape) UnoRuntime.queryInterface( XControlShape.class, oInt ); + aControl = UnoRuntime.queryInterface( XControlModel.class, aCon ); + oCShape = UnoRuntime.queryInterface( XControlShape.class, oInt ); size.Height = height; size.Width = width; position.X = x; @@ -168,8 +167,7 @@ public class FormTools { XInterface oControl = null; - XMultiServiceFactory oDocMSF = (XMultiServiceFactory) - UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc ); + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc ); try{ oControl = (XInterface) oDocMSF.createInstance( @@ -183,16 +181,16 @@ public class FormTools { public static XNameContainer getForms ( XDrawPage oDP ) { - XFormsSupplier oFS = (XFormsSupplier) UnoRuntime.queryInterface( + XFormsSupplier oFS = UnoRuntime.queryInterface( XFormsSupplier.class,oDP); return oFS.getForms(); } //finish getForms public static XIndexContainer getIndexedForms ( XDrawPage oDP ) { - XFormsSupplier oFS = (XFormsSupplier) UnoRuntime.queryInterface( + XFormsSupplier oFS = UnoRuntime.queryInterface( XFormsSupplier.class,oDP); - return (XIndexContainer)UnoRuntime.queryInterface( XIndexContainer.class, + return UnoRuntime.queryInterface( XIndexContainer.class, oFS.getForms() ); } //finish getIndexedForms @@ -231,7 +229,7 @@ public class FormTools { formProps.setPropertyValue("DataSourceName","Bibliography"); formProps.setPropertyValue("Command","biblio"); formProps.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.TABLE)); - formLoader = (XLoadable) UnoRuntime.queryInterface(XLoadable.class, the_form); + formLoader = UnoRuntime.queryInterface(XLoadable.class, the_form); } catch (Exception ex) { System.out.println("Exception: "+ex); @@ -261,7 +259,7 @@ public class FormTools { formProps.setPropertyValue("Command",tableName); formProps.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.TABLE)); - return (XLoadable) UnoRuntime.queryInterface(XLoadable.class, the_form); + return UnoRuntime.queryInterface(XLoadable.class, the_form); } public static XLoadable bindForm( XTextDocument aDoc, String formName ) { @@ -273,7 +271,7 @@ public class FormTools { formProps.setPropertyValue("DataSourceName","Bibliography"); formProps.setPropertyValue("Command","biblio"); formProps.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.TABLE)); - formLoader = (XLoadable) UnoRuntime.queryInterface(XLoadable.class, the_form); + formLoader = UnoRuntime.queryInterface(XLoadable.class, the_form); } catch (Exception ex) { System.out.println("Exception: "+ex); @@ -304,22 +302,21 @@ public class FormTools { formProps.setPropertyValue("Command",tableName); formProps.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.TABLE)); - return (XLoadable) UnoRuntime.queryInterface(XLoadable.class, the_form); + return UnoRuntime.queryInterface(XLoadable.class, the_form); } public static void switchDesignOf(XMultiServiceFactory xMSF, XTextDocument aDoc) { try { com.sun.star.frame.XController aController = aDoc.getCurrentController(); com.sun.star.frame.XFrame aFrame = aController.getFrame(); - com.sun.star.frame.XDispatchProvider aDispProv = (com.sun.star.frame.XDispatchProvider) - UnoRuntime.queryInterface(com.sun.star.frame.XDispatchProvider.class,aFrame); + com.sun.star.frame.XDispatchProvider aDispProv = UnoRuntime.queryInterface(com.sun.star.frame.XDispatchProvider.class,aFrame); com.sun.star.util.URL aURL = new com.sun.star.util.URL(); aURL.Complete = ".uno:SwitchControlDesignMode"; Object instance = xMSF.createInstance("com.sun.star.util.URLTransformer"); com.sun.star.util.XURLTransformer atrans = - (com.sun.star.util.XURLTransformer)UnoRuntime.queryInterface( - com.sun.star.util.XURLTransformer.class,instance); + UnoRuntime.queryInterface( + com.sun.star.util.XURLTransformer.class,instance); com.sun.star.util.URL[] aURLA = new com.sun.star.util.URL[1]; aURLA[0] = aURL; atrans.parseStrict(aURLA); diff --git a/qadevOOo/runner/util/FrameDsc.java b/qadevOOo/runner/util/FrameDsc.java index 86a80465f0eb..e5448afa651c 100644 --- a/qadevOOo/runner/util/FrameDsc.java +++ b/qadevOOo/runner/util/FrameDsc.java @@ -85,7 +85,7 @@ public class FrameDsc extends InstDescr { } catch( com.sun.star.uno.Exception cssuE ){ } - XShape shape = (XShape)UnoRuntime.queryInterface( XShape.class, SrvObj ); + XShape shape = UnoRuntime.queryInterface( XShape.class, SrvObj ); try { shape.setSize(size); } diff --git a/qadevOOo/runner/util/InstCreator.java b/qadevOOo/runner/util/InstCreator.java index bfd894c0e296..684b93479dd8 100644 --- a/qadevOOo/runner/util/InstCreator.java +++ b/qadevOOo/runner/util/InstCreator.java @@ -43,7 +43,7 @@ public class InstCreator implements XInstCreator { this.xParent = xParent; this.iDsc = iDsc; - xMSF = (XMultiServiceFactory)UnoRuntime.queryInterface( + xMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, xParent ); xInstance = createInstance(); @@ -70,44 +70,39 @@ public class InstCreator implements XInstCreator { XNameAccess oNA = null; if ( iDsc instanceof TableDsc ) { - XTextTablesSupplier oTTS = (XTextTablesSupplier) - UnoRuntime.queryInterface( - XTextTablesSupplier.class, xParent ); + XTextTablesSupplier oTTS = UnoRuntime.queryInterface( + XTextTablesSupplier.class, xParent ); oNA = oTTS.getTextTables(); } if ( iDsc instanceof FrameDsc ) { - XTextFramesSupplier oTTS = (XTextFramesSupplier) - UnoRuntime.queryInterface( - XTextFramesSupplier.class, xParent ); + XTextFramesSupplier oTTS = UnoRuntime.queryInterface( + XTextFramesSupplier.class, xParent ); oNA = oTTS.getTextFrames(); } if ( iDsc instanceof BookmarkDsc ) { - XBookmarksSupplier oTTS = (XBookmarksSupplier) - UnoRuntime.queryInterface( - XBookmarksSupplier.class, xParent ); + XBookmarksSupplier oTTS = UnoRuntime.queryInterface( + XBookmarksSupplier.class, xParent ); oNA = oTTS.getBookmarks(); } if ( iDsc instanceof FootnoteDsc ) { - XFootnotesSupplier oTTS = (XFootnotesSupplier) - UnoRuntime.queryInterface( - XFootnotesSupplier.class, xParent ); + XFootnotesSupplier oTTS = UnoRuntime.queryInterface( + XFootnotesSupplier.class, xParent ); return( oTTS.getFootnotes() ); } if ( iDsc instanceof TextSectionDsc ) { - XTextSectionsSupplier oTSS = (XTextSectionsSupplier) - UnoRuntime.queryInterface( - XTextSectionsSupplier.class, xParent ); + XTextSectionsSupplier oTSS = UnoRuntime.queryInterface( + XTextSectionsSupplier.class, xParent ); oNA = oTSS.getTextSections(); } - return (XIndexAccess)UnoRuntime.queryInterface( + return UnoRuntime.queryInterface( XIndexAccess.class, oNA); } } \ No newline at end of file diff --git a/qadevOOo/runner/util/InstDescr.java b/qadevOOo/runner/util/InstDescr.java index 14a7bc89f0db..7b349b0f8427 100644 --- a/qadevOOo/runner/util/InstDescr.java +++ b/qadevOOo/runner/util/InstDescr.java @@ -25,7 +25,7 @@ import com.sun.star.uno.XInterface; */ abstract public class InstDescr { - protected Class ifcClass = null; + protected Class ifcClass = null; protected abstract String getIfcName(); protected abstract String getName(); @@ -33,7 +33,7 @@ abstract public class InstDescr { /** * the method getIfcClass */ - public Class getIfcClass() { + public Class getIfcClass() { return ifcClass; } /** diff --git a/qadevOOo/runner/util/RegistryTools.java b/qadevOOo/runner/util/RegistryTools.java index cff6783272c1..d8129087d4f9 100644 --- a/qadevOOo/runner/util/RegistryTools.java +++ b/qadevOOo/runner/util/RegistryTools.java @@ -43,7 +43,7 @@ public class RegistryTools { Object oInterface = xMSF.createInstance ("com.sun.star.registry.SimpleRegistry"); - return (XSimpleRegistry) UnoRuntime.queryInterface ( + return UnoRuntime.queryInterface ( XSimpleRegistry.class, oInterface) ; } diff --git a/qadevOOo/runner/util/SOfficeFactory.java b/qadevOOo/runner/util/SOfficeFactory.java index 27398b2f486e..327b271c946c 100644 --- a/qadevOOo/runner/util/SOfficeFactory.java +++ b/qadevOOo/runner/util/SOfficeFactory.java @@ -44,7 +44,7 @@ import com.sun.star.awt.*; public class SOfficeFactory { - private static HashMap lookup = new HashMap(10); + private static HashMap lookup = new HashMap(10); protected XComponentLoader oCLoader; private SOfficeFactory(XMultiServiceFactory xMSF) { @@ -58,16 +58,16 @@ public class SOfficeFactory { } // query the desktop interface and then it's componentloader - XDesktop oDesktop = (XDesktop) UnoRuntime.queryInterface( + XDesktop oDesktop = UnoRuntime.queryInterface( XDesktop.class, oInterface); - oCLoader = (XComponentLoader) UnoRuntime.queryInterface( + oCLoader = UnoRuntime.queryInterface( XComponentLoader.class, oDesktop); } public static SOfficeFactory getFactory(XMultiServiceFactory xMSF) { - SOfficeFactory soFactory = (SOfficeFactory) lookup.get(new Integer(xMSF.hashCode()).toString()); + SOfficeFactory soFactory = lookup.get(new Integer(xMSF.hashCode()).toString()); if (soFactory == null) { soFactory = new SOfficeFactory(xMSF); @@ -92,7 +92,7 @@ public class SOfficeFactory { if (oDoc != null) { DesktopTools.bringWindowToFront(oDoc); - return (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, oDoc); + return UnoRuntime.queryInterface(XTextDocument.class, oDoc); } else { return null; } @@ -111,7 +111,7 @@ public class SOfficeFactory { if (oDoc != null) { DesktopTools.bringWindowToFront(oDoc); - return (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, oDoc); + return UnoRuntime.queryInterface(XTextDocument.class, oDoc); } else { return null; } @@ -129,7 +129,7 @@ public class SOfficeFactory { if (oDoc != null) { DesktopTools.bringWindowToFront(oDoc); - return (XSpreadsheetDocument) UnoRuntime.queryInterface(XSpreadsheetDocument.class, oDoc); + return UnoRuntime.queryInterface(XSpreadsheetDocument.class, oDoc); } else { return null; } @@ -147,7 +147,7 @@ public class SOfficeFactory { if (oDoc != null) { DesktopTools.bringWindowToFront(oDoc); - return (XSpreadsheetDocument) UnoRuntime.queryInterface(XSpreadsheetDocument.class, oDoc); + return UnoRuntime.queryInterface(XSpreadsheetDocument.class, oDoc); } else { return null; } @@ -225,7 +225,7 @@ public class SOfficeFactory { if (oDoc != null) { DesktopTools.bringWindowToFront(oDoc); - return (XChartDocument) UnoRuntime.queryInterface(XChartDocument.class, oDoc); + return UnoRuntime.queryInterface(XChartDocument.class, oDoc); } else { return null; } @@ -290,7 +290,7 @@ public class SOfficeFactory { public static void insertString(XTextDocument xTextDoc, String cString) throws com.sun.star.uno.Exception { XText xText = xTextDoc.getText(); - XText oText = (XText) UnoRuntime.queryInterface( + XText oText = UnoRuntime.queryInterface( XText.class, xText); XTextCursor oCursor = oText.createTextCursor(); @@ -301,7 +301,7 @@ public class SOfficeFactory { XTextContent xCont) throws com.sun.star.lang.IllegalArgumentException { XText xText = xTextDoc.getText(); - XText oText = (XText) UnoRuntime.queryInterface( + XText oText = UnoRuntime.queryInterface( XText.class, xText); XTextCursor oCursor = oText.createTextCursor(); @@ -367,12 +367,12 @@ public class SOfficeFactory { public static XTextContent createIndex(XTextDocument xTextDoc, String kind) throws com.sun.star.uno.Exception { - XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); Object oInt = oDocMSF.createInstance(kind); - XTextContent xTC = (XTextContent) UnoRuntime.queryInterface(XDocumentIndex.class, oInt); + XTextContent xTC = UnoRuntime.queryInterface(XDocumentIndex.class, oInt); return xTC; @@ -381,7 +381,7 @@ public class SOfficeFactory { public static XSpreadsheet createSpreadsheet(XSpreadsheetDocument oDoc) throws com.sun.star.uno.Exception { - XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc); + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc); Object oInt = oDocMSF.createInstance( "com.sun.star.sheet.Spreadsheet"); @@ -393,10 +393,10 @@ public class SOfficeFactory { public static XIndexAccess getTableCollection(XTextDocument oDoc) { - XTextTablesSupplier oTTS = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, oDoc); + XTextTablesSupplier oTTS = UnoRuntime.queryInterface(XTextTablesSupplier.class, oDoc); XNameAccess oNA = oTTS.getTextTables(); - XIndexAccess oIA = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, oNA); + XIndexAccess oIA = UnoRuntime.queryInterface(XIndexAccess.class, oNA); return oIA; } @@ -433,11 +433,11 @@ public class SOfficeFactory { XDiagram oDiagram = null; //get LineDiagram - XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc); + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc); try { oInterface = (XInterface) oDocMSF.createInstance("com.sun.star.chart." + kind); - oDiagram = (XDiagram) UnoRuntime.queryInterface(XDiagram.class, oInterface); + oDiagram = UnoRuntime.queryInterface(XDiagram.class, oInterface); } catch (Exception e) { // Some exception occures.FAILED System.out.println("Couldn't create " + kind + "-Diagram " + e); @@ -452,7 +452,7 @@ public class SOfficeFactory { XInterface oControl = null; - XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc); + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc); try { oControl = (XInterface) oDocMSF.createInstance("com.sun.star.form.component." + kind); @@ -470,7 +470,7 @@ public class SOfficeFactory { Object oInstance = null; - XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc); + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc); try { oInstance = (Object) oDocMSF.createInstance(kind); @@ -489,13 +489,13 @@ public class SOfficeFactory { XControlModel aControl = null; //get MSF - XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc); + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc); try { Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape"); Object aCon = oDocMSF.createInstance("com.sun.star.form.component." + kind); - aControl = (XControlModel) UnoRuntime.queryInterface(XControlModel.class, aCon); - oCShape = (XControlShape) UnoRuntime.queryInterface(XControlShape.class, oInt); + aControl = UnoRuntime.queryInterface(XControlModel.class, aCon); + oCShape = UnoRuntime.queryInterface(XControlShape.class, oInt); size.Height = height; size.Width = width; position.X = x; diff --git a/qadevOOo/runner/util/SysUtils.java b/qadevOOo/runner/util/SysUtils.java index 6252a7eb930d..78abc9502883 100644 --- a/qadevOOo/runner/util/SysUtils.java +++ b/qadevOOo/runner/util/SysUtils.java @@ -41,7 +41,7 @@ public class SysUtils { return jh; } - static ArrayList files = new ArrayList(); + static ArrayList files = new ArrayList(); public static Object[] traverse( String afileDirectory ) { @@ -89,7 +89,7 @@ public class SysUtils { XComponent ac = null; try { Object desk = msf.createInstance("com.sun.star.frame.Desktop"); - XDesktop xDesk = (XDesktop) UnoRuntime.queryInterface(XDesktop.class,desk); + XDesktop xDesk = UnoRuntime.queryInterface(XDesktop.class,desk); ac = xDesk.getCurrentComponent(); } catch (com.sun.star.uno.Exception e) { System.out.println("Couldn't get active Component"); @@ -100,7 +100,7 @@ public class SysUtils { public static XFrame getActiveFrame(XMultiServiceFactory msf) { try { Object desk = msf.createInstance("com.sun.star.frame.Desktop"); - XDesktop xDesk = (XDesktop) UnoRuntime.queryInterface(XDesktop.class,desk); + XDesktop xDesk = UnoRuntime.queryInterface(XDesktop.class,desk); return xDesk.getCurrentFrame(); } catch (com.sun.star.uno.Exception e) { System.out.println("Couldn't get active Component"); @@ -122,7 +122,7 @@ public class SysUtils { public static String getSysClipboardText(XMultiServiceFactory msf) throws com.sun.star.uno.Exception { - XClipboard xCB = (XClipboard) UnoRuntime.queryInterface + XClipboard xCB = UnoRuntime.queryInterface (XClipboard.class, msf.createInstance ("com.sun.star.datatransfer.clipboard.SystemClipboard")); diff --git a/qadevOOo/runner/util/UITools.java b/qadevOOo/runner/util/UITools.java index a489498fd8b4..bb35f80fd87e 100644 --- a/qadevOOo/runner/util/UITools.java +++ b/qadevOOo/runner/util/UITools.java @@ -61,7 +61,7 @@ public class UITools { public UITools(XMultiServiceFactory msf, XTextDocument xTextDoc) { mMSF = msf; - XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xTextDoc); + XModel xModel = UnoRuntime.queryInterface(XModel.class, xTextDoc); mXRoot = makeRoot(mMSF, xModel); } @@ -80,23 +80,20 @@ public class UITools { private static String getString(XInterface xInt) { - XAccessibleText oText = (XAccessibleText) - UnoRuntime.queryInterface(XAccessibleText.class, xInt); + XAccessibleText oText = UnoRuntime.queryInterface(XAccessibleText.class, xInt); return oText.getText(); } private static void setString(XInterface xInt, String cText) { - XAccessibleEditableText oText = (XAccessibleEditableText) - UnoRuntime.queryInterface(XAccessibleEditableText.class, xInt); + XAccessibleEditableText oText = UnoRuntime.queryInterface(XAccessibleEditableText.class, xInt); oText.setText(cText); } private static Object getValue(XInterface xInt) { - XAccessibleValue oValue = (XAccessibleValue) - UnoRuntime.queryInterface(XAccessibleValue.class, xInt); + XAccessibleValue oValue = UnoRuntime.queryInterface(XAccessibleValue.class, xInt); return oValue.getCurrentValue(); } @@ -154,8 +151,7 @@ public class UITools { if (oButton == null){ throw new Exception("Could not get button '" + buttonName + "'"); } - XAccessibleAction oAction = (XAccessibleAction) - UnoRuntime.queryInterface(XAccessibleAction.class, oButton); + XAccessibleAction oAction = UnoRuntime.queryInterface(XAccessibleAction.class, oButton); // "click" the button try{ @@ -183,8 +179,7 @@ public class UITools { if (oButton != null){ boolean isChecked = oButton.getAccessibleStateSet().contains(com.sun.star.accessibility.AccessibleStateType.CHECKED); if((isChecked && !toBePressed) || (!isChecked && toBePressed)){ - XAccessibleAction oAction = (XAccessibleAction) - UnoRuntime.queryInterface(XAccessibleAction.class, oButton); + XAccessibleAction oAction = UnoRuntime.queryInterface(XAccessibleAction.class, oButton); try{ // "click" the button oAction.doAccessibleAction(0); @@ -269,8 +264,7 @@ public class UITools { XInterface xRB =mAT.getAccessibleObjectForRole(mXRoot, AccessibleRole.RADIO_BUTTON, buttonName); if(xRB == null) System.out.println("AccessibleObjectForRole couldn't be found for " + buttonName); - XAccessibleValue oValue = (XAccessibleValue) - UnoRuntime.queryInterface(XAccessibleValue.class, xRB); + XAccessibleValue oValue = UnoRuntime.queryInterface(XAccessibleValue.class, xRB); if(oValue == null) System.out.println("XAccessibleValue couldn't be queried for " + buttonName); oValue.setCurrentValue(new Integer(iValue)); @@ -301,15 +295,13 @@ public class UITools { xListBox =mAT.getAccessibleObjectForRole(mXRoot, AccessibleRole.PANEL, ListBoxName); } - XAccessible xListBoxAccess = (XAccessible) - UnoRuntime.queryInterface(XAccessible.class, xListBox); + XAccessible xListBoxAccess = UnoRuntime.queryInterface(XAccessible.class, xListBox); // if a List is not pulled to be open all entries are not visiblle, therefore the // boolean argument XAccessibleContext xList =mAT.getAccessibleObjectForRole( xListBoxAccess, AccessibleRole.LIST, true); - XAccessibleSelection xListSelect = (XAccessibleSelection) - UnoRuntime.queryInterface(XAccessibleSelection.class, xList); + XAccessibleSelection xListSelect = UnoRuntime.queryInterface(XAccessibleSelection.class, xList); xListSelect.selectAccessibleChild(nChildIndex); @@ -329,7 +321,7 @@ public class UITools { public Object[] getListBoxObjects(String ListBoxName) throws java.lang.Exception { - ArrayList Items = new ArrayList(); + ArrayList Items = new ArrayList(); try { XAccessibleContext xListBox = null; XAccessibleContext xList = null; @@ -349,8 +341,7 @@ public class UITools { // all other list boxes have a children of kind of LIST } else { - XAccessible xListBoxAccess = (XAccessible) - UnoRuntime.queryInterface(XAccessible.class, xListBox); + XAccessible xListBoxAccess = UnoRuntime.queryInterface(XAccessible.class, xListBox); // if a List is not pulled to be open all entries are not visiblle, therefore the // boolean argument xList =mAT.getAccessibleObjectForRole( @@ -393,7 +384,7 @@ public class UITools { public String[] getListBoxItems(String ListBoxName) throws java.lang.Exception { - ArrayList Items = new ArrayList(); + ArrayList Items = new ArrayList(); try { XAccessibleContext xListBox = null; XAccessibleContext xList = null; @@ -413,8 +404,7 @@ public class UITools { // all other list boxes have a children of kind of LIST } else { - XAccessible xListBoxAccess = (XAccessible) - UnoRuntime.queryInterface(XAccessible.class, xListBox); + XAccessible xListBoxAccess = UnoRuntime.queryInterface(XAccessible.class, xListBox); // if a List is not pulled to be open all entries are not visiblle, therefore the // boolean argument xList =mAT.getAccessibleObjectForRole( @@ -441,7 +431,7 @@ public class UITools { + ListBoxName + "' : " + e.toString()); } String[]ret = new String[Items.size()]; - return (String[])Items.toArray(ret); + return Items.toArray(ret); } /** * set to a named nureric filed a given value @@ -456,9 +446,8 @@ public class UITools { XInterface xNumericField =mAT.getAccessibleObjectForRole( mXRoot, AccessibleRole.TEXT, NumericFieldName); //util.dbg.printInterfaces(xNumericField); - XAccessibleEditableText oValue = (XAccessibleEditableText) - UnoRuntime.queryInterface( - XAccessibleEditableText.class, xNumericField); + XAccessibleEditableText oValue = UnoRuntime.queryInterface( + XAccessibleEditableText.class, xNumericField); setString(xNumericField, cValue); } catch (Exception e) { @@ -566,8 +555,7 @@ public class UITools { try{ XAccessibleContext xTextField =mAT.getAccessibleObjectForRole(mXRoot, AccessibleRole.SCROLL_PANE, TextFieldName); - XAccessible xTextFieldAccess = (XAccessible) - UnoRuntime.queryInterface(XAccessible.class, xTextField); + XAccessible xTextFieldAccess = UnoRuntime.queryInterface(XAccessible.class, xTextField); XAccessibleContext xFrame =mAT.getAccessibleObjectForRole( xTextFieldAccess, AccessibleRole.TEXT_FRAME); for (int i=0;i enumClass = oldValue.getClass() ; Field[] flds = enumClass.getFields() ; newValue = null ; @@ -861,7 +861,7 @@ public class ValueChanger { } else if (oldValue.getClass().isArray()) { // changer for arrays : changes all elements - Class arrType = oldValue.getClass().getComponentType() ; + Class arrType = oldValue.getClass().getComponentType() ; newValue = Array.newInstance(arrType, Array.getLength(oldValue)) ; for (int i = 0; i < Array.getLength(newValue); i++) { if (!arrType.isPrimitive()) { @@ -900,13 +900,13 @@ public class ValueChanger { } else if (isStructure(oldValue)) { // universal changer for structures - Class clazz = oldValue.getClass() ; + Class clazz = oldValue.getClass() ; try { newValue = clazz.newInstance() ; Field[] fields = clazz.getFields(); for (int i = 0; i < fields.length; i++) { if ((fields[i].getModifiers() & Modifier.PUBLIC) != 0) { - Class fType = fields[i].getType() ; + Class fType = fields[i].getType() ; Field field = fields[i] ; if (!fType.isPrimitive()) { field.set(newValue, changePValue(field.get(oldValue))); diff --git a/qadevOOo/runner/util/ValueComparer.java b/qadevOOo/runner/util/ValueComparer.java index 47dd0a9e7f5f..3ce1719156d5 100644 --- a/qadevOOo/runner/util/ValueComparer.java +++ b/qadevOOo/runner/util/ValueComparer.java @@ -73,7 +73,7 @@ public class ValueComparer { if ( pv1.length != pv2.length) { return false; } - HashMap hm1 = new HashMap(); + HashMap hm1 = new HashMap(); boolean result = true; int i = 0; diff --git a/qadevOOo/runner/util/WaitUnreachable.java b/qadevOOo/runner/util/WaitUnreachable.java index cfae04a08d16..33e383be95de 100644 --- a/qadevOOo/runner/util/WaitUnreachable.java +++ b/qadevOOo/runner/util/WaitUnreachable.java @@ -48,7 +48,7 @@ public final class WaitUnreachable { public WaitUnreachable(Object obj) { this.obj = obj; queue = new ReferenceQueue(); - ref = new PhantomReference(obj, queue); + ref = new PhantomReference(obj, queue); } /** @@ -114,5 +114,5 @@ public final class WaitUnreachable { private Object obj; private final ReferenceQueue queue; - private final PhantomReference ref; + private final PhantomReference ref; } diff --git a/qadevOOo/runner/util/WriterTools.java b/qadevOOo/runner/util/WriterTools.java index 82c7208a0229..7b6b0cc8d18b 100644 --- a/qadevOOo/runner/util/WriterTools.java +++ b/qadevOOo/runner/util/WriterTools.java @@ -40,7 +40,7 @@ public class WriterTools { public static XTextDocument createTextDoc(XMultiServiceFactory xMSF) { PropertyValue[] Args = new PropertyValue[0]; XComponent comp = DesktopTools.openNewDoc(xMSF, "swriter", Args); - XTextDocument WriterDoc = (XTextDocument) UnoRuntime.queryInterface( + XTextDocument WriterDoc = UnoRuntime.queryInterface( XTextDocument.class, comp); return WriterDoc; @@ -57,7 +57,7 @@ public class WriterTools { public static XTextDocument loadTextDoc(XMultiServiceFactory xMSF, String url, PropertyValue[] Args) { XComponent comp = DesktopTools.loadDoc(xMSF, url, Args); - XTextDocument WriterDoc = (XTextDocument) UnoRuntime.queryInterface( + XTextDocument WriterDoc = UnoRuntime.queryInterface( XTextDocument.class, comp); return WriterDoc; @@ -67,7 +67,7 @@ public class WriterTools { XDrawPage oDP = null; try { - XDrawPageSupplier oDPS = (XDrawPageSupplier) UnoRuntime.queryInterface( + XDrawPageSupplier oDPS = UnoRuntime.queryInterface( XDrawPageSupplier.class, aDoc); oDP = (XDrawPage) oDPS.getDrawPage(); } catch (Exception e) { @@ -87,7 +87,7 @@ public class WriterTools { XText the_text = aDoc.getText(); XTextCursor the_cursor = the_text.createTextCursor(); - XTextContent the_content = (XTextContent) UnoRuntime.queryInterface( + XTextContent the_content = UnoRuntime.queryInterface( XTextContent.class, oGObject); the_text.insertTextContent(the_cursor, the_content, true); @@ -101,7 +101,7 @@ public class WriterTools { oProps.setPropertyValue("Width", new Integer(width)); oProps.setPropertyValue("Height", new Integer(height)); - XNamed the_name = (XNamed) UnoRuntime.queryInterface(XNamed.class, + XNamed the_name = UnoRuntime.queryInterface(XNamed.class, oGObject); the_name.setName(name); } catch (Exception ex) { diff --git a/qadevOOo/runner/util/XMLTools.java b/qadevOOo/runner/util/XMLTools.java index c5acb225b048..bfaa6b53f405 100644 --- a/qadevOOo/runner/util/XMLTools.java +++ b/qadevOOo/runner/util/XMLTools.java @@ -58,8 +58,8 @@ public class XMLTools { public String Type ; public String Value ; } - private Hashtable attrByName = new Hashtable() ; - private ArrayList attributes = new ArrayList() ; + private Hashtable attrByName = new Hashtable() ; + private ArrayList attributes = new ArrayList() ; private PrintWriter log = null ; /** @@ -128,7 +128,7 @@ public class XMLTools { } public String getNameByIndex(short idx) { - String name = ((Attribute) attributes.get(idx)).Name ; + String name = attributes.get(idx).Name ; if (log != null) log.println("getNameByIndex(" + idx + ") called -> '" + name + "'") ; @@ -136,7 +136,7 @@ public class XMLTools { } public String getTypeByIndex(short idx) { - String type = ((Attribute) attributes.get(idx)).Type ; + String type = attributes.get(idx).Type ; if (log != null) log.println("getTypeByIndex(" + idx + ") called -> '" + type + "'") ; @@ -144,14 +144,14 @@ public class XMLTools { } public String getTypeByName(String name) { - String type = ((Attribute) attrByName.get(name)).Type ; + String type = attrByName.get(name).Type ; if (log != null) log.println("getTypeByName('" + name + "') called -> '" + type + "'") ; return type; } public String getValueByIndex(short idx) { - String value = ((Attribute) attributes.get(idx)).Value ; + String value = attributes.get(idx).Value ; if (log != null) log.println("getValueByIndex(" + idx + ") called -> '" + value + "'") ; @@ -159,7 +159,7 @@ public class XMLTools { } public String getValueByName(String name) { - String value = ((Attribute) attrByName.get(name)).Value ; + String value = attrByName.get(name).Value ; if (log != null) log.println("getValueByName('" + name + "') called -> '" + value + "'") ; @@ -255,7 +255,7 @@ public class XMLTools { public static class XMLWellFormChecker extends XMLWriter { protected boolean docStarted = false ; protected boolean docEnded = false ; - protected ArrayList tagStack = new ArrayList() ; + protected ArrayList tagStack = new ArrayList() ; protected boolean wellFormed = true ; protected boolean noOtherErrors = true ; protected PrintWriter log = null ; @@ -279,7 +279,7 @@ public class XMLTools { public void reset() { docStarted = false ; docEnded = false ; - tagStack = new ArrayList() ; + tagStack = new ArrayList() ; wellFormed = true ; noOtherErrors = true ; PrintWriter log = null ; @@ -320,7 +320,7 @@ public class XMLTools { wellFormed = false ; printError("No tags to close (bad closing tag )") ; } else { - String startTag = (String) tagStack.get(0) ; + String startTag = tagStack.get(0) ; tagStack.remove(0) ; if (!startTag.equals(name)) { wellFormed = false ; @@ -355,7 +355,7 @@ public class XMLTools { if (printXMLData) return ; log.println(" Tag trace :") ; for (int i = 0; i < tagStack.size(); i++) { - String tag = (String) tagStack.get(i) ; + String tag = tagStack.get(i) ; log.println(" <" + tag + ">") ; } } @@ -411,7 +411,7 @@ public class XMLTools { if (!outerTag.equals("")) { boolean isInTag = false ; for (int i = 0; i < tagStack.size(); i++) { - if (outerTag.equals((String) tagStack.get(i))) { + if (outerTag.equals(tagStack.get(i))) { isInTag = true ; break ; } @@ -434,7 +434,7 @@ public class XMLTools { if (!outerTag.equals("")) { boolean isInTag = false ; for (int i = 0; i < tagStack.size(); i++) { - if (outerTag.equals((String) tagStack.get(i))) { + if (outerTag.equals(tagStack.get(i))) { isInTag = true ; break ; } @@ -456,21 +456,21 @@ public class XMLTools { public boolean checkTags() { allOK &= isWellFormed() ; - Enumeration badTags = tags.keys() ; - Enumeration badChars = chars.keys() ; + Enumeration badTags = tags.keys() ; + Enumeration badChars = chars.keys() ; if (badTags.hasMoreElements()) { allOK = false ; log.println("Required tags were not found in export :") ; while(badTags.hasMoreElements()) { - log.println(" <" + ((String) badTags.nextElement()) + ">") ; + log.println(" <" + badTags.nextElement() + ">") ; } } if (badChars.hasMoreElements()) { allOK = false ; log.println("Required characters were not found in export :") ; while(badChars.hasMoreElements()) { - log.println(" <" + ((String) badChars.nextElement()) + ">") ; + log.println(" <" + badChars.nextElement() + ">") ; } } reset(); @@ -622,11 +622,11 @@ public class XMLTools { * character data exists inside any tag specified. */ public static class XMLChecker extends XMLWellFormChecker { - protected HashSet tagSet = new HashSet() ; - protected ArrayList tags = new ArrayList() ; - protected ArrayList chars = new ArrayList() ; - protected ArrayList tagStack = new ArrayList() ; - protected ArrayList attrStack = new ArrayList() ; + protected HashSet tagSet = new HashSet() ; + protected ArrayList tags = new ArrayList() ; + protected ArrayList chars = new ArrayList() ; + protected ArrayList tagStack = new ArrayList() ; + protected ArrayList attrStack = new ArrayList() ; public XMLChecker(PrintWriter log, boolean writeXML) { super(log, writeXML) ; @@ -656,15 +656,15 @@ public class XMLTools { if (tagSet.contains(name)) { for (int i = 0; i < tags.size(); i++) { - Tag[] tag = (Tag[]) tags.get(i); + Tag[] tag = tags.get(i); if (tag[0].isMatchTo(name, attr)) { if (tag[1] == null) { tags.remove(i--); } else { boolean isInStack = false ; for (int j = 0; j < tagStack.size(); j++) { - if (tag[1].isMatchTo((String) tagStack.get(j), - (XAttributeList) attrStack.get(j))) { + if (tag[1].isMatchTo(tagStack.get(j), + attrStack.get(j))) { isInStack = true ; break ; @@ -688,15 +688,15 @@ public class XMLTools { public void characters(String ch) { super.characters(ch) ; for (int i = 0; i < chars.size(); i++) { - Object[] chr = (Object[]) chars.get(i); + Object[] chr = chars.get(i); if (((String) chr[0]).equals(ch)) { if (chr[1] == null) { chars.remove(i--); } else { boolean isInStack = false ; for (int j = 0; j < tagStack.size(); j++) { - if (((Tag) chr[1]).isMatchTo((String) tagStack.get(j), - (XAttributeList) attrStack.get(j))) { + if (((Tag) chr[1]).isMatchTo(tagStack.get(j), + attrStack.get(j))) { isInStack = true ; break ; @@ -727,7 +727,7 @@ public class XMLTools { if (tags.size()> 0) { log.println("!!! Error: Some tags were not found :") ; for (int i = 0; i < tags.size(); i++) { - Tag[] tag = (Tag[]) tags.get(i) ; + Tag[] tag = tags.get(i) ; log.println(" Tag " + tag[0] + " was not found"); if (tag[1] != null) log.println(" inside tag " + tag[1]) ; @@ -736,7 +736,7 @@ public class XMLTools { if (chars.size() > 0) { log.println("!!! Error: Some character data blocks were not found :") ; for (int i = 0; i < chars.size(); i++) { - Object[] ch = (Object[]) chars.get(i) ; + Object[] ch = chars.get(i) ; log.println(" Character data \"" + ch[0] + "\" was not found ") ; if (ch[1] != null) log.println(" inside tag " + ch[1]) ; @@ -767,11 +767,10 @@ public class XMLTools { "com.sun.star.xml.sax.Writer"); XInterface oPipe = (XInterface) xMSF.createInstance ( "com.sun.star.io.Pipe" ); - XOutputStream xPipeOutput = (XOutputStream) UnoRuntime. + XOutputStream xPipeOutput = UnoRuntime. queryInterface(XOutputStream.class, oPipe) ; - XActiveDataSource xADS = (XActiveDataSource) - UnoRuntime.queryInterface(XActiveDataSource.class,Writer); + XActiveDataSource xADS = UnoRuntime.queryInterface(XActiveDataSource.class,Writer); xADS.setOutputStream(xPipeOutput); XDocumentHandler handler = (XDocumentHandler) UnoRuntime.queryInterface(XDocumentHandler.class,Writer); @@ -812,13 +811,12 @@ public class XMLTools { { XInterface oFacc = (XInterface)xMSF.createInstance( "com.sun.star.comp.ucb.SimpleFileAccess"); - XSimpleFileAccess xFacc = (XSimpleFileAccess)UnoRuntime.queryInterface + XSimpleFileAccess xFacc = UnoRuntime.queryInterface (XSimpleFileAccess.class, oFacc) ; XInterface oWriter = (XInterface)xMSF.createInstance( "com.sun.star.xml.sax.Writer"); - XActiveDataSource xWriterDS = (XActiveDataSource) - UnoRuntime.queryInterface(XActiveDataSource.class, oWriter); + XActiveDataSource xWriterDS = UnoRuntime.queryInterface(XActiveDataSource.class, oWriter); XDocumentHandler xDocHandWriter = (XDocumentHandler) UnoRuntime.queryInterface (XDocumentHandler.class, oWriter) ; @@ -842,13 +840,13 @@ public class XMLTools { { XInterface oFacc = (XInterface)xMSF.createInstance( "com.sun.star.comp.ucb.SimpleFileAccess"); - XSimpleFileAccess xFacc = (XSimpleFileAccess)UnoRuntime.queryInterface + XSimpleFileAccess xFacc = UnoRuntime.queryInterface (XSimpleFileAccess.class, oFacc) ; XInputStream oIn = xFacc.openFileRead(fileURL) ; XInterface oParser = (XInterface)xMSF.createInstance( "com.sun.star.xml.sax.Parser"); - XParser xParser = (XParser) UnoRuntime.queryInterface(XParser.class, oParser); + XParser xParser = UnoRuntime.queryInterface(XParser.class, oParser); xParser.setDocumentHandler(handler) ; InputSource inSrc = new InputSource() ; @@ -886,11 +884,11 @@ public class XMLTools { "com.sun.star.comp." + docType + ".XML" + exportType + "Exporter", new Object[] {arg}); - XExporter xExp = (XExporter) UnoRuntime.queryInterface + XExporter xExp = UnoRuntime.queryInterface (XExporter.class, oExp) ; xExp.setSourceDocument(xDoc) ; - XFilter filter = (XFilter) UnoRuntime.queryInterface(XFilter.class, oExp) ; + XFilter filter = UnoRuntime.queryInterface(XFilter.class, oExp) ; filter.filter(XMLTools.createMediaDescriptor( new String[] {"FilterName"}, new Object[] {"Custom filter"})) ; @@ -919,7 +917,7 @@ public class XMLTools { XInterface oImp = (XInterface)xMSF.createInstance( "com.sun.star.comp." + docType + ".XML" + importType + "Importer"); - XImporter xImp = (XImporter) UnoRuntime.queryInterface + XImporter xImp = UnoRuntime.queryInterface (XImporter.class, oImp) ; XDocumentHandler xDocHandImp = (XDocumentHandler) UnoRuntime.queryInterface (XDocumentHandler.class, oImp) ; diff --git a/qadevOOo/runner/util/db/DataSource.java b/qadevOOo/runner/util/db/DataSource.java index 2b861f156c37..4c612fb08969 100644 --- a/qadevOOo/runner/util/db/DataSource.java +++ b/qadevOOo/runner/util/db/DataSource.java @@ -45,7 +45,7 @@ public class DataSource m_orb = _orb; try { - m_dataSource = (XDataSource)UnoRuntime.queryInterface( XDataSource.class, + m_dataSource = UnoRuntime.queryInterface( XDataSource.class, m_orb.createInstance( "com.sun.star.sdb.DataSource" ) ); m_properties = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, m_dataSource ); @@ -90,7 +90,7 @@ public class DataSource try { dataSourceName = (String)m_properties.getPropertyValue( "Name" ); - XNamingService dbContext = (XNamingService)UnoRuntime.queryInterface( XNamingService.class, + XNamingService dbContext = UnoRuntime.queryInterface( XNamingService.class, m_orb.createInstance( "com.sun.star.sdb.DatabaseContext" ) ); dbContext.revokeObject( dataSourceName ); } diff --git a/qadevOOo/runner/util/db/DatabaseDocument.java b/qadevOOo/runner/util/db/DatabaseDocument.java index bc2683c63678..b045d50f0110 100644 --- a/qadevOOo/runner/util/db/DatabaseDocument.java +++ b/qadevOOo/runner/util/db/DatabaseDocument.java @@ -37,13 +37,13 @@ public class DatabaseDocument m_orb = _orb; m_dataSource = _dataSource; - XDocumentDataSource docDataSource = (XDocumentDataSource)UnoRuntime.queryInterface( + XDocumentDataSource docDataSource = UnoRuntime.queryInterface( XDocumentDataSource.class, m_dataSource.getDataSource() ); - m_databaseDocument = (XOfficeDatabaseDocument)UnoRuntime.queryInterface(XOfficeDatabaseDocument.class, + m_databaseDocument = UnoRuntime.queryInterface(XOfficeDatabaseDocument.class, docDataSource.getDatabaseDocument() ); - m_model = (XModel)UnoRuntime.queryInterface( XModel.class, m_databaseDocument ); - m_storeDoc = (XStorable)UnoRuntime.queryInterface( XStorable.class, m_databaseDocument ); + m_model = UnoRuntime.queryInterface( XModel.class, m_databaseDocument ); + m_storeDoc = UnoRuntime.queryInterface( XStorable.class, m_databaseDocument ); } public DataSource getDataSource() diff --git a/qadevOOo/runner/util/utils.java b/qadevOOo/runner/util/utils.java index 61ebf8480507..65c2f8da97cc 100644 --- a/qadevOOo/runner/util/utils.java +++ b/qadevOOo/runner/util/utils.java @@ -468,7 +468,7 @@ public class utils { try { Object fileacc = msf.createInstance("com.sun.star.comp.ucb.SimpleFileAccess"); - XSimpleFileAccess simpleAccess = (XSimpleFileAccess) UnoRuntime.queryInterface(XSimpleFileAccess.class, + XSimpleFileAccess simpleAccess = UnoRuntime.queryInterface(XSimpleFileAccess.class, fileacc); if (simpleAccess.exists(fileURL)) { exists = true; @@ -494,7 +494,7 @@ public class utils { try { Object fileacc = xMsf.createInstance("com.sun.star.comp.ucb.SimpleFileAccess"); - XSimpleFileAccess simpleAccess = (XSimpleFileAccess) UnoRuntime.queryInterface(XSimpleFileAccess.class, + XSimpleFileAccess simpleAccess = UnoRuntime.queryInterface(XSimpleFileAccess.class, fileacc); if (simpleAccess.exists(fileURL)) { simpleAccess.kill(fileURL); @@ -519,7 +519,7 @@ public class utils { boolean res = false; try { Object fileacc = xMsf.createInstance("com.sun.star.comp.ucb.SimpleFileAccess"); - XSimpleFileAccess simpleAccess = (XSimpleFileAccess) UnoRuntime.queryInterface(XSimpleFileAccess.class, + XSimpleFileAccess simpleAccess = UnoRuntime.queryInterface(XSimpleFileAccess.class, fileacc); if (!simpleAccess.exists(destinaion)) { simpleAccess.copy(source, destinaion); @@ -541,7 +541,7 @@ public class utils { try { Object fileacc = xMsf.createInstance("com.sun.star.comp.ucb.SimpleFileAccess"); - XSimpleFileAccess simpleAccess = (XSimpleFileAccess) UnoRuntime.queryInterface(XSimpleFileAccess.class, + XSimpleFileAccess simpleAccess = UnoRuntime.queryInterface(XSimpleFileAccess.class, fileacc); if (simpleAccess.exists(newF)) { simpleAccess.kill(newF); @@ -681,7 +681,7 @@ public class utils { XURLTransformer xTrans = null; try { Object inst = xMSF.createInstance("com.sun.star.util.URLTransformer"); - xTrans = (XURLTransformer) UnoRuntime.queryInterface(XURLTransformer.class, inst); + xTrans = UnoRuntime.queryInterface(XURLTransformer.class, inst); } catch (com.sun.star.uno.Exception e) { } @@ -734,7 +734,7 @@ public class utils { public static String[] getFilteredPropertyNames(XPropertySet props, short includePropertyAttribute, short excludePropertyAttribute) { Property[] the_props = props.getPropertySetInfo().getProperties(); - ArrayList l = new ArrayList(); + ArrayList l = new ArrayList(); for (int i = 0; i < the_props.length; i++) { boolean exclude = ((the_props[i].Attributes & excludePropertyAttribute) != 0); boolean include = (includePropertyAttribute == 0) || @@ -745,7 +745,7 @@ public class utils { } Collections.sort(l); String[] names = new String[l.size()]; - names = (String[]) l.toArray(names); + names = l.toArray(names); return names; } @@ -899,7 +899,7 @@ public class utils { XPropertySet xPS = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xMSF); XComponentContext xContext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, xPS.getPropertyValue("DefaultContext")); - XMacroExpander xME = (XMacroExpander) UnoRuntime.queryInterface(XMacroExpander.class, + XMacroExpander xME = UnoRuntime.queryInterface(XMacroExpander.class, xContext.getValueByName("/singletons/com.sun.star.util.theMacroExpander")); return xME.expandMacros(expand); } catch (Exception e) { @@ -948,7 +948,7 @@ public class utils { * @throws java.lang.Exception throws java.lang.Exception on any error */ public static void dispatchURL(XMultiServiceFactory xMSF, XComponent xDoc, String URL) throws java.lang.Exception { - XModel aModel = (XModel) UnoRuntime.queryInterface(XModel.class, xDoc); + XModel aModel = UnoRuntime.queryInterface(XModel.class, xDoc); XController xCont = aModel.getCurrentController(); @@ -966,9 +966,9 @@ public class utils { public static void dispatchURL(XMultiServiceFactory xMSF, XController xCont, String URL) throws java.lang.Exception { try { - XDispatchProvider xDispProv = (XDispatchProvider) UnoRuntime.queryInterface(XDispatchProvider.class, xCont); + XDispatchProvider xDispProv = UnoRuntime.queryInterface(XDispatchProvider.class, xCont); - XURLTransformer xParser = (com.sun.star.util.XURLTransformer) UnoRuntime.queryInterface( + XURLTransformer xParser = UnoRuntime.queryInterface( XURLTransformer.class, xMSF.createInstance("com.sun.star.util.URLTransformer")); -- cgit