From 68b9fb0aaeff4aef41dfd6989491b522578ca079 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 23 Apr 2013 09:01:41 +0200 Subject: [PATCH] Java cleanup - remove unnecessary casts in the ODK code Change-Id: I1ab8ad5182444fc3eebd2349135a0240ebbe0fd4 Reviewed-on: https://gerrit.libreoffice.org/3566 Reviewed-by: Fridrich Strba Tested-by: Fridrich Strba --- .../DevelopersGuide/Forms/ControlLock.java | 4 +- .../DevelopersGuide/Forms/DataAwareness.java | 14 +-- .../Forms/DocumentBasedExample.java | 5 +- .../DevelopersGuide/Forms/DocumentHelper.java | 38 +++---- .../Forms/DocumentViewHelper.java | 14 +-- .../DevelopersGuide/Forms/FLTools.java | 14 +-- .../DevelopersGuide/Forms/FormLayer.java | 12 +- .../Forms/GridFieldValidator.java | 4 +- .../DevelopersGuide/Forms/HsqlDatabase.java | 18 +-- .../DevelopersGuide/Forms/KeyGenerator.java | 22 ++-- .../DevelopersGuide/Forms/RowSet.java | 10 +- .../DevelopersGuide/Forms/SalesFilter.java | 2 +- .../Forms/SingleControlValidation.java | 6 +- .../Forms/SpreadsheetDocument.java | 10 +- .../Forms/SpreadsheetValueBinding.java | 6 +- .../Forms/SpreadsheetView.java | 8 +- odk/examples/DevelopersGuide/Forms/UNO.java | 16 +-- .../DevelopersGuide/Forms/ValueBinding.java | 6 +- .../DesktopEnvironment/DocumentView.java | 2 +- .../DesktopEnvironment/FunctionHelper.java | 103 +++++++++--------- .../DesktopEnvironment/Interceptor.java | 4 +- .../JavaWindowPeerFake.java | 2 +- .../DesktopEnvironment/StatusListener.java | 4 +- .../DesktopEnvironment/ViewContainer.java | 2 +- .../UCB/ChildrenRetriever.java | 2 +- odk/examples/DevelopersGuide/UCB/Helper.java | 14 +-- .../DevelopersGuide/UCB/ResourceCreator.java | 2 +- .../java/Inspector/HideableTreeModel.java | 6 +- .../java/Inspector/InspectorAddon.java | 8 +- .../java/Inspector/InspectorPane.java | 4 +- .../java/Inspector/ProtocolHandlerAddon.java | 8 +- .../java/Inspector/SourceCodeGenerator.java | 4 +- .../java/Inspector/SwingDialogProvider.java | 2 +- .../Inspector/SwingTreeControlProvider.java | 2 +- odk/examples/java/Inspector/TDocSupplier.java | 10 +- .../java/Inspector/TestInspector.java | 4 +- odk/examples/java/Inspector/UnoNode.java | 10 +- .../java/Inspector/UnoPropertyNode.java | 2 +- 38 files changed, 200 insertions(+), 204 deletions(-) diff --git a/odk/examples/DevelopersGuide/Forms/ControlLock.java b/odk/examples/DevelopersGuide/Forms/ControlLock.java index a24a28203119..efce0c990462 100644 --- a/odk/examples/DevelopersGuide/Forms/ControlLock.java +++ b/odk/examples/DevelopersGuide/Forms/ControlLock.java @@ -65,7 +65,7 @@ class LockControlModels extends ComponentTreeTraversal if ( !super.shouldStepInto( xContainer ) ) return false; // don't try to be more clever than our base class - XForm xForm = (XForm)UnoRuntime.queryInterface( XForm.class, xContainer ); + XForm xForm = UnoRuntime.queryInterface( XForm.class, xContainer ); if ( ( null != xForm ) && ( m_nLevel > 1 ) ) // don't step into sub forms - we only handle the form we were originally // applied to @@ -169,7 +169,7 @@ class ControlLock implements XRowSetListener m_bLockingEnabled = bLock; // add or remove ourself as listener to get notified of cursor moves - XRowSet xRowSet = (XRowSet)UnoRuntime.queryInterface( + XRowSet xRowSet = UnoRuntime.queryInterface( XRowSet.class, m_xForm ); if ( m_bLockingEnabled ) { diff --git a/odk/examples/DevelopersGuide/Forms/DataAwareness.java b/odk/examples/DevelopersGuide/Forms/DataAwareness.java index a5aa106fb9d2..70323e25a373 100644 --- a/odk/examples/DevelopersGuide/Forms/DataAwareness.java +++ b/odk/examples/DevelopersGuide/Forms/DataAwareness.java @@ -76,7 +76,7 @@ class PrintComponentTree extends ComponentTreeTraversal public void handle( Object aFormComponent ) throws com.sun.star.uno.Exception { // the name of the child - XNamed xName = (XNamed)UnoRuntime.queryInterface( XNamed.class, aFormComponent ); + XNamed xName = UnoRuntime.queryInterface( XNamed.class, aFormComponent ); // if it's a form control model, check it's type XPropertySet xProps = UNO.queryPropertySet( aFormComponent ); @@ -183,7 +183,7 @@ public class DataAwareness extends DocumentBasedExample implements XPropertyChan { String sObjectName; - XNamed xNameAcc = (XNamed)UnoRuntime.queryInterface( XNamed.class, xContainer ); + XNamed xNameAcc = UnoRuntime.queryInterface( XNamed.class, xContainer ); if ( null == xNameAcc ) sObjectName = new String( "" ); else @@ -244,12 +244,12 @@ public class DataAwareness extends DocumentBasedExample implements XPropertyChan // get the columns of our master form - XColumnsSupplier xSuppCols = (XColumnsSupplier)UnoRuntime.queryInterface( + XColumnsSupplier xSuppCols = UnoRuntime.queryInterface( XColumnsSupplier.class, xFormProps ); XNameAccess xCols = xSuppCols.getColumns(); // and update the date column with a NULL value - XColumnUpdate xDateColumn = (XColumnUpdate)UnoRuntime.queryInterface( + XColumnUpdate xDateColumn = UnoRuntime.queryInterface( XColumnUpdate.class, xCols.getByName( "SALEDATE" ) ); xDateColumn.updateNull(); @@ -644,11 +644,11 @@ public class DataAwareness extends DocumentBasedExample implements XPropertyChan // the container to insert columns into XIndexContainer xColumnContainer = UNO.queryIndexContainer( aGridModel ); // the factory for creating column models - XGridColumnFactory xColumnFactory = (XGridColumnFactory)UnoRuntime.queryInterface( + XGridColumnFactory xColumnFactory = UnoRuntime.queryInterface( XGridColumnFactory.class, aGridModel ); // (let) create the new col - XInterface xNewCol = (XInterface)xColumnFactory.createColumn( sColumnService ); + XInterface xNewCol = xColumnFactory.createColumn( sColumnService ); XPropertySet xColProps = UNO.queryPropertySet( xNewCol ); // some props @@ -913,7 +913,7 @@ public class DataAwareness extends DocumentBasedExample implements XPropertyChan m_aSalesNameValidator.enableColumnWatch( false ); // remove our own reset listener from the form - XNameAccess xMasterAsNames = (XNameAccess)UnoRuntime.queryInterface( + XNameAccess xMasterAsNames = UnoRuntime.queryInterface( XNameAccess.class, m_xMasterForm ); XReset xFormReset = UNO.queryReset( xMasterAsNames.getByName( "Sales" ) ); xFormReset.removeResetListener( this ); diff --git a/odk/examples/DevelopersGuide/Forms/DocumentBasedExample.java b/odk/examples/DevelopersGuide/Forms/DocumentBasedExample.java index 2b10138471e3..456e4125c9d2 100644 --- a/odk/examples/DevelopersGuide/Forms/DocumentBasedExample.java +++ b/odk/examples/DevelopersGuide/Forms/DocumentBasedExample.java @@ -159,9 +159,8 @@ public abstract class DocumentBasedExample implements com.sun.star.lang.XEventLi // close our document if ( m_document != null ) { - XCloseable closeDoc = (XCloseable) - UnoRuntime.queryInterface( XCloseable.class, - m_document.getDocument() ); + XCloseable closeDoc = UnoRuntime.queryInterface( XCloseable.class, + m_document.getDocument() ); if (closeDoc != null) closeDoc.close( true ); else diff --git a/odk/examples/DevelopersGuide/Forms/DocumentHelper.java b/odk/examples/DevelopersGuide/Forms/DocumentHelper.java index 9132a9c27f0a..b10f52d27440 100644 --- a/odk/examples/DevelopersGuide/Forms/DocumentHelper.java +++ b/odk/examples/DevelopersGuide/Forms/DocumentHelper.java @@ -58,7 +58,7 @@ public class DocumentHelper public DocumentHelper( XComponentContext xContext, XComponent document ) { m_remoteContext = xContext; - m_orb = (XMultiServiceFactory)UnoRuntime.queryInterface( + m_orb = UnoRuntime.queryInterface( XMultiServiceFactory.class, m_remoteContext.getServiceManager()); m_documentComponent = document; } @@ -66,7 +66,7 @@ public class DocumentHelper /* ------------------------------------------------------------------ */ protected static XComponent implCreateBlankDocument( XComponentContext xCtx, String factoryURL ) throws com.sun.star.uno.Exception { - XComponentLoader aLoader = (XComponentLoader)UnoRuntime.queryInterface( + XComponentLoader aLoader = UnoRuntime.queryInterface( XComponentLoader.class, xCtx.getServiceManager().createInstanceWithContext( "com.sun.star.frame.Desktop", xCtx )); @@ -100,7 +100,7 @@ public class DocumentHelper public DocumentViewHelper getCurrentView( ) { // get the model interface for the document - XModel xDocModel = (XModel)UnoRuntime.queryInterface(XModel.class, m_documentComponent ); + XModel xDocModel = UnoRuntime.queryInterface(XModel.class, m_documentComponent ); // get the current controller for the document - as a controller is tied to a view, // this gives us the currently active view for the document. XController xController = xDocModel.getCurrentController(); @@ -137,7 +137,7 @@ public class DocumentHelper } // outta here - return (XIndexContainer)UnoRuntime.queryInterface( XIndexContainer.class, xNewForm ); + return UnoRuntime.queryInterface( XIndexContainer.class, xNewForm ); } /* ------------------------------------------------------------------ */ @@ -152,7 +152,7 @@ public class DocumentHelper public XIndexContainer createSubForm( Object aParentContainer, String sInitialName ) throws com.sun.star.uno.Exception { - XIndexContainer xParentContainer = (XIndexContainer)UnoRuntime.queryInterface( + XIndexContainer xParentContainer = UnoRuntime.queryInterface( XIndexContainer.class, aParentContainer ); return createSubForm( xParentContainer, sInitialName ); } @@ -169,8 +169,8 @@ public class DocumentHelper public XIndexContainer createSiblingForm( Object aForm, String sInitialName ) throws com.sun.star.uno.Exception { // get the parent - XChild xAsChild = (XChild)UnoRuntime.queryInterface( XChild.class, aForm ); - XIndexContainer xContainer = (XIndexContainer)UnoRuntime.queryInterface( + XChild xAsChild = UnoRuntime.queryInterface( XChild.class, aForm ); + XIndexContainer xContainer = UnoRuntime.queryInterface( XIndexContainer.class, xAsChild.getParent() );; // append a new form to this parent container return createSubForm( xContainer, sInitialName ); @@ -181,13 +181,13 @@ public class DocumentHelper */ static public DocumentHelper getDocumentForComponent( Object aFormComponent, XComponentContext xCtx ) { - XChild xChild = (XChild)UnoRuntime.queryInterface( XChild.class, aFormComponent ); + XChild xChild = UnoRuntime.queryInterface( XChild.class, aFormComponent ); XModel xModel = null; while ( ( null != xChild ) && ( null == xModel ) ) { XInterface xParent = (XInterface)xChild.getParent(); - xModel = (XModel)UnoRuntime.queryInterface( XModel.class, xParent ); - xChild = (XChild)UnoRuntime.queryInterface( XChild.class, xParent ); + xModel = UnoRuntime.queryInterface( XModel.class, xParent ); + xChild = UnoRuntime.queryInterface( XChild.class, xParent ); } return new DocumentHelper( xCtx, xModel ); @@ -212,7 +212,7 @@ public class DocumentHelper */ public DocumentType classify( ) { - XServiceInfo xSI = (XServiceInfo)UnoRuntime.queryInterface( + XServiceInfo xSI = UnoRuntime.queryInterface( XServiceInfo.class, m_documentComponent ); if ( xSI.supportsService( "com.sun.star.text.TextDocument" ) ) @@ -234,11 +234,11 @@ public class DocumentHelper */ protected XDrawPage getDrawPage( int index ) throws com.sun.star.lang.IndexOutOfBoundsException, com.sun.star.lang.WrappedTargetException { - XDrawPagesSupplier xSuppPages = (XDrawPagesSupplier)UnoRuntime.queryInterface( + XDrawPagesSupplier xSuppPages = UnoRuntime.queryInterface( XDrawPagesSupplier.class, getDocument() ); XDrawPages xPages = xSuppPages.getDrawPages(); - return (XDrawPage)UnoRuntime.queryInterface( XDrawPage.class, xPages.getByIndex( index ) ); + return UnoRuntime.queryInterface( XDrawPage.class, xPages.getByIndex( index ) ); } /* ------------------------------------------------------------------ */ @@ -249,18 +249,18 @@ public class DocumentHelper XDrawPage xReturn; // in case of a Writer document, this is rather easy: simply ask the XDrawPageSupplier - XDrawPageSupplier xSuppPage = (XDrawPageSupplier)UnoRuntime.queryInterface( + XDrawPageSupplier xSuppPage = UnoRuntime.queryInterface( XDrawPageSupplier.class, getDocument() ); if ( null != xSuppPage ) xReturn = xSuppPage.getDrawPage(); else { // the model itself is no draw page supplier - okay, it may be a Writer or Calc document // (or any other multi-page document) - XDrawPagesSupplier xSuppPages = (XDrawPagesSupplier)UnoRuntime.queryInterface( + XDrawPagesSupplier xSuppPages = UnoRuntime.queryInterface( XDrawPagesSupplier.class, getDocument() ); XDrawPages xPages = xSuppPages.getDrawPages(); - xReturn = (XDrawPage)UnoRuntime.queryInterface( XDrawPage.class, xPages.getByIndex( 0 ) ); + xReturn = UnoRuntime.queryInterface( XDrawPage.class, xPages.getByIndex( 0 ) ); // Note that this is no really error-proof code: If the document model does not support the // XDrawPagesSupplier interface, or if the pages collection returned is empty, this will break. @@ -274,7 +274,7 @@ public class DocumentHelper */ protected XNameContainer getFormComponentTreeRoot( ) throws com.sun.star.uno.Exception { - XFormsSupplier xSuppForms = (XFormsSupplier)UnoRuntime.queryInterface( + XFormsSupplier xSuppForms = UnoRuntime.queryInterface( XFormsSupplier.class, getMainDrawPage( ) ); XNameContainer xFormsCollection = null; @@ -290,7 +290,7 @@ public class DocumentHelper */ public XInterface createInstance( String serviceSpecifier ) throws com.sun.star.uno.Exception { - XMultiServiceFactory xORB = (XMultiServiceFactory)UnoRuntime.queryInterface( XMultiServiceFactory.class, + XMultiServiceFactory xORB = UnoRuntime.queryInterface( XMultiServiceFactory.class, m_documentComponent ); return (XInterface)xORB.createInstance( serviceSpecifier ); } @@ -300,7 +300,7 @@ public class DocumentHelper */ public XInterface createInstanceWithArguments( String serviceSpecifier, Object[] arguments ) throws com.sun.star.uno.Exception { - XMultiServiceFactory xORB = (XMultiServiceFactory)UnoRuntime.queryInterface( XMultiServiceFactory.class, + XMultiServiceFactory xORB = UnoRuntime.queryInterface( XMultiServiceFactory.class, m_documentComponent ); return (XInterface) xORB.createInstanceWithArguments( serviceSpecifier, arguments ); } diff --git a/odk/examples/DevelopersGuide/Forms/DocumentViewHelper.java b/odk/examples/DevelopersGuide/Forms/DocumentViewHelper.java index 7b160831b83c..25308ea29cf1 100644 --- a/odk/examples/DevelopersGuide/Forms/DocumentViewHelper.java +++ b/odk/examples/DevelopersGuide/Forms/DocumentViewHelper.java @@ -90,12 +90,12 @@ class DocumentViewHelper // go get the current view XController xController = (XController)get( XController.class ); // go get the dispatch provider of it's frame - XDispatchProvider xProvider = (XDispatchProvider)UnoRuntime.queryInterface( + XDispatchProvider xProvider = UnoRuntime.queryInterface( XDispatchProvider.class, xController.getFrame() ); if ( null != xProvider ) { // need an URLTransformer - XURLTransformer xTransformer = (XURLTransformer)UnoRuntime.queryInterface( + XURLTransformer xTransformer = UnoRuntime.queryInterface( XURLTransformer.class, m_orb.createInstance( "com.sun.star.util.URLTransformer" ) ); xTransformer.parseStrict( aURL ); @@ -120,7 +120,7 @@ class DocumentViewHelper public XFormController getFormController( Object _form ) { XFormLayerAccess formLayer = (XFormLayerAccess)get( XFormLayerAccess.class ); - return formLayer.getFormController( (XForm)UnoRuntime.queryInterface( XForm.class, _form ) ); + return formLayer.getFormController( UnoRuntime.queryInterface( XForm.class, _form ) ); } /* ------------------------------------------------------------------ */ @@ -141,14 +141,14 @@ class DocumentViewHelper /* ------------------------------------------------------------------ */ public XControl getFormControl( Object aModel ) throws com.sun.star.uno.Exception { - XControlModel xModel = (XControlModel)UnoRuntime.queryInterface( XControlModel.class, aModel ); + XControlModel xModel = UnoRuntime.queryInterface( XControlModel.class, aModel ); return getFormControl( xModel ); } /* ------------------------------------------------------------------ */ public Object getFormControl( Object aModel, Class aInterfaceClass ) throws com.sun.star.uno.Exception { - XControlModel xModel = (XControlModel)UnoRuntime.queryInterface( XControlModel.class, aModel ); + XControlModel xModel = UnoRuntime.queryInterface( XControlModel.class, aModel ); return UnoRuntime.queryInterface( aInterfaceClass, getFormControl( xModel ) ); } @@ -179,7 +179,7 @@ class DocumentViewHelper XControl xControl = getFormControl( xModel ); // the focus can be set to an XWindow only - XWindow xControlWindow = (XWindow)UnoRuntime.queryInterface( XWindow.class, + XWindow xControlWindow = UnoRuntime.queryInterface( XWindow.class, xControl ); // grab the focus @@ -202,7 +202,7 @@ class DocumentViewHelper XPropertySet xControlProps = UNO.queryPropertySet( xForm.getByIndex( i ) ); if ( FormComponentType.FIXEDTEXT != ((Short)xControlProps.getPropertyValue( "ClassId" )).shortValue() ) { - XControlModel xControlModel = (XControlModel)UnoRuntime.queryInterface( + XControlModel xControlModel = UnoRuntime.queryInterface( XControlModel.class, xControlProps ); // set the focus to this control grabControlFocus( xControlModel ); diff --git a/odk/examples/DevelopersGuide/Forms/FLTools.java b/odk/examples/DevelopersGuide/Forms/FLTools.java index 3f87e77e1bd6..143816625e44 100644 --- a/odk/examples/DevelopersGuide/Forms/FLTools.java +++ b/odk/examples/DevelopersGuide/Forms/FLTools.java @@ -64,7 +64,7 @@ public class FLTools URL[] aURL = new URL[] { new URL() }; aURL[0].Complete = sURL; // need an URLTransformer - XURLTransformer xTransformer = (XURLTransformer)UnoRuntime.queryInterface( + XURLTransformer xTransformer = UnoRuntime.queryInterface( XURLTransformer.class, xCtx.getServiceManager().createInstanceWithContext( "com.sun.star.util.URLTransformer", xCtx ) ); @@ -78,7 +78,7 @@ public class FLTools */ public static String getName( Object aFormComponent ) throws com.sun.star.uno.Exception { - XNamed xNamed = (XNamed)UnoRuntime.queryInterface( XNamed.class, + XNamed xNamed = UnoRuntime.queryInterface( XNamed.class, aFormComponent ); String sName = ""; if ( null != xNamed ) @@ -130,7 +130,7 @@ public class FLTools int nIndex = -1; // norm the element - XInterface xElement = (XInterface)UnoRuntime.queryInterface( + XInterface xElement = UnoRuntime.queryInterface( XInterface.class, aElement ); // get the container @@ -142,7 +142,7 @@ public class FLTools for ( int i = 0; i < nCount; ++i ) { // compare with the element - XInterface xCurrent = (XInterface)UnoRuntime.queryInterface( + XInterface xCurrent = UnoRuntime.queryInterface( XInterface.class, xIndexCont.getByIndex( 0 ) ); if ( xCurrent.equals( xElement ) ) { // found @@ -161,7 +161,7 @@ public class FLTools */ static Object getParent( Object aComponent, Class aInterfaceClass ) { - XChild xAsChild = (XChild)UnoRuntime.queryInterface( XChild.class, aComponent ); + XChild xAsChild = UnoRuntime.queryInterface( XChild.class, aComponent ); return UnoRuntime.queryInterface( aInterfaceClass, xAsChild.getParent() ); } @@ -179,7 +179,7 @@ public class FLTools */ static public void disposeComponent( Object xComp ) throws java.lang.RuntimeException { - XComponent xComponent = (XComponent)UnoRuntime.queryInterface( XComponent.class, + XComponent xComponent = UnoRuntime.queryInterface( XComponent.class, xComp ); if ( null != xComponent ) xComponent.dispose(); @@ -190,7 +190,7 @@ public class FLTools */ static public Object getModel( Object aControl, Class aInterfaceClass ) { - XControl xControl = (XControl)UnoRuntime.queryInterface( + XControl xControl = UnoRuntime.queryInterface( XControl.class, aControl ); XControlModel xModel = null; if ( null != xControl ) diff --git a/odk/examples/DevelopersGuide/Forms/FormLayer.java b/odk/examples/DevelopersGuide/Forms/FormLayer.java index 1436591292a3..e7eb0699347b 100644 --- a/odk/examples/DevelopersGuide/Forms/FormLayer.java +++ b/odk/examples/DevelopersGuide/Forms/FormLayer.java @@ -87,9 +87,9 @@ public class FormLayer int nYPos, int nWidth, int nHeight, XIndexContainer xParentForm ) throws java.lang.Exception { // let the document create a shape - XMultiServiceFactory xDocAsFactory = (XMultiServiceFactory)UnoRuntime.queryInterface( + XMultiServiceFactory xDocAsFactory = UnoRuntime.queryInterface( XMultiServiceFactory.class, m_document.getDocument() ); - XControlShape xShape = (XControlShape)UnoRuntime.queryInterface( XControlShape.class, + XControlShape xShape = UnoRuntime.queryInterface( XControlShape.class, xDocAsFactory.createInstance( "com.sun.star.drawing.ControlShape" ) ); // position and size of the shape @@ -103,7 +103,7 @@ public class FormLayer // create the form component (the model of a form control) String sQualifiedComponentName = "com.sun.star.form.component." + sFormComponentService; - XControlModel xModel = (XControlModel)UnoRuntime.queryInterface( XControlModel.class, + XControlModel xModel = UnoRuntime.queryInterface( XControlModel.class, m_document.getOrb().createInstance( sQualifiedComponentName ) ); // insert the model into the form component hierarchy, if the caller gave us a location @@ -118,7 +118,7 @@ public class FormLayer // add the shape to the shapes collection of the document XDrawPage pageWhereToInsert = ( m_insertPage != -1 ) ? m_document.getDrawPage( m_insertPage ) : m_document.getMainDrawPage(); - XShapes xDocShapes = (XShapes)UnoRuntime.queryInterface( XShapes.class, pageWhereToInsert ); + XShapes xDocShapes = UnoRuntime.queryInterface( XShapes.class, pageWhereToInsert ); xDocShapes.add( xShape ); // some initializations which are the same for all controls @@ -240,7 +240,7 @@ public class FormLayer */ public XPropertySet getRadioModelByRefValue( XPropertySet form, String name, String refValue ) throws com.sun.star.uno.Exception, java.lang.Exception { - XIndexAccess indexAccess = (XIndexAccess)UnoRuntime.queryInterface( XIndexAccess.class, + XIndexAccess indexAccess = UnoRuntime.queryInterface( XIndexAccess.class, form ); for ( int i=0; i break save process if there is nothing to do. - com.sun.star.util.XModifiable xModified = (com.sun.star.util.XModifiable)UnoRuntime.queryInterface( + com.sun.star.util.XModifiable xModified = UnoRuntime.queryInterface( com.sun.star.util.XModifiable.class, xModel); if(xModified.isModified()==true) { - com.sun.star.frame.XStorable xStore = (com.sun.star.frame.XStorable)UnoRuntime.queryInterface( + com.sun.star.frame.XStorable xStore = UnoRuntime.queryInterface( com.sun.star.frame.XStorable.class, xModel); @@ -703,9 +703,8 @@ public class FunctionHelper // Well known filter names are used directly. They must exist in current // office installation. Otherwise this code will fail. But to prevent // this code against missing filters it check for existing state of it. - com.sun.star.lang.XServiceInfo xInfo = (com.sun.star.lang.XServiceInfo) - UnoRuntime.queryInterface(com.sun.star.lang.XServiceInfo.class, - xDocument); + com.sun.star.lang.XServiceInfo xInfo = UnoRuntime.queryInterface(com.sun.star.lang.XServiceInfo.class, + xDocument); if(xInfo!=null) { @@ -727,11 +726,10 @@ public class FunctionHelper OfficeConnect.getOfficeContext(); com.sun.star.container.XNameAccess xFilterContainer = - (com.sun.star.container.XNameAccess) UnoRuntime.queryInterface( - com.sun.star.container.XNameAccess.class, - xCtx.getServiceManager().createInstanceWithContext( - "com.sun.star.document.FilterFactory", xCtx)); + com.sun.star.container.XNameAccess.class, + xCtx.getServiceManager().createInstanceWithContext( + "com.sun.star.document.FilterFactory", xCtx)); if(xFilterContainer.hasByName(sFilter)==false) sFilter=null; @@ -755,8 +753,8 @@ public class FunctionHelper lProperties[1].Value = Boolean.TRUE; com.sun.star.frame.XStorable xStore = - (com.sun.star.frame.XStorable)UnoRuntime.queryInterface( - com.sun.star.frame.XStorable.class, xDocument); + UnoRuntime.queryInterface( + com.sun.star.frame.XStorable.class, xDocument); xStore.storeAsURL(sURL,lProperties); } @@ -797,8 +795,8 @@ public class FunctionHelper { // Check supported functionality of the document (model or controller). com.sun.star.frame.XModel xModel = - (com.sun.star.frame.XModel)UnoRuntime.queryInterface( - com.sun.star.frame.XModel.class, xDocument); + UnoRuntime.queryInterface( + com.sun.star.frame.XModel.class, xDocument); if(xModel!=null) { @@ -806,8 +804,8 @@ public class FunctionHelper // Reset the modify state of it and close it. // Note: Model can disgree by throwing a veto exception. com.sun.star.util.XModifiable xModify = - (com.sun.star.util.XModifiable)UnoRuntime.queryInterface( - com.sun.star.util.XModifiable.class, xModel); + UnoRuntime.queryInterface( + com.sun.star.util.XModifiable.class, xModel); xModify.setModified(false); xDocument.dispose(); @@ -818,8 +816,8 @@ public class FunctionHelper // window only. If it's at least a controller - we can try to // suspend him. But - he can disagree with that! com.sun.star.frame.XController xController = - (com.sun.star.frame.XController)UnoRuntime.queryInterface( - com.sun.star.frame.XController.class, xDocument); + UnoRuntime.queryInterface( + com.sun.star.frame.XController.class, xDocument); if(xController!=null) { @@ -879,8 +877,8 @@ public class FunctionHelper // It replace the deprecated XTask::close() and should be preferred ... // if it can be queried. com.sun.star.util.XCloseable xCloseable = - (com.sun.star.util.XCloseable)UnoRuntime.queryInterface( - com.sun.star.util.XCloseable.class, xFrame); + UnoRuntime.queryInterface( + com.sun.star.util.XCloseable.class, xFrame); if (xCloseable!=null) { // We deliver the owner ship of this frame not to the (possible) @@ -899,9 +897,8 @@ public class FunctionHelper else { // OK: the new way isn't possible. Try the old one. - com.sun.star.frame.XTask xTask = (com.sun.star.frame.XTask) - UnoRuntime.queryInterface(com.sun.star.frame.XTask.class, - xFrame); + com.sun.star.frame.XTask xTask = UnoRuntime.queryInterface(com.sun.star.frame.XTask.class, + xFrame); if (xTask!=null) { // return value doesn't interest here. Because @@ -946,15 +943,15 @@ public class FunctionHelper try { com.sun.star.frame.XFramesSupplier xSupplier = - (com.sun.star.frame.XFramesSupplier)UnoRuntime.queryInterface( - com.sun.star.frame.XFramesSupplier.class, - xCtx.getServiceManager().createInstanceWithContext( - "com.sun.star.frame.Desktop", xCtx)); + UnoRuntime.queryInterface( + com.sun.star.frame.XFramesSupplier.class, + xCtx.getServiceManager().createInstanceWithContext( + "com.sun.star.frame.Desktop", xCtx)); com.sun.star.container.XIndexAccess xContainer = - (com.sun.star.container.XIndexAccess)UnoRuntime.queryInterface( - com.sun.star.container.XIndexAccess.class, - xSupplier.getFrames()); + UnoRuntime.queryInterface( + com.sun.star.container.XIndexAccess.class, + xSupplier.getFrames()); int nCount = xContainer.getCount(); for (int i=0; i lOutParams = new Vector(); lOutParams.add(aEvent); - OnewayExecutor aExecutor = new OnewayExecutor( (IOnewayLink)this , + OnewayExecutor aExecutor = new OnewayExecutor( this , OnewayExecutor.REQUEST_FRAMEACTION , lOutParams ); aExecutor.start(); @@ -275,7 +275,7 @@ public class Interceptor implements com.sun.star.frame.XFrameActionListener, Vector lOutParams = OnewayExecutor.encodeDispatch( lInURL , lInArguments ); - OnewayExecutor aExecutor = new OnewayExecutor( (IOnewayLink)this , + OnewayExecutor aExecutor = new OnewayExecutor( this , OnewayExecutor.REQUEST_DISPATCH , lOutParams ); aExecutor.start(); diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/JavaWindowPeerFake.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/JavaWindowPeerFake.java index 9100f57f8a11..3bc089543687 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/JavaWindowPeerFake.java +++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/JavaWindowPeerFake.java @@ -57,7 +57,7 @@ class JavaWindowPeerFake implements com.sun.star.awt.XSystemDependentWindowPeer, { Object aReturn = null; if(aSystem==maView.maSystem) - aReturn = (Object)maView.maHandle; + aReturn = maView.maHandle; return aReturn; } diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java index da7f8b7e1973..fd79205cfaa3 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java +++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java @@ -216,7 +216,7 @@ class StatusListener implements com.sun.star.frame.XStatusListener, Vector lOutParams = new Vector(); lOutParams.add(aEvent); - OnewayExecutor aExecutor = new OnewayExecutor( (IOnewayLink)this , + OnewayExecutor aExecutor = new OnewayExecutor( this , OnewayExecutor.REQUEST_FRAMEACTION , lOutParams ); aExecutor.start(); @@ -357,7 +357,7 @@ class StatusListener implements com.sun.star.frame.XStatusListener, if (! bRegister) return; - com.sun.star.frame.XDispatchProvider xProvider = (com.sun.star.frame.XDispatchProvider)UnoRuntime.queryInterface( + com.sun.star.frame.XDispatchProvider xProvider = UnoRuntime.queryInterface( com.sun.star.frame.XDispatchProvider.class, xFrame); diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/ViewContainer.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/ViewContainer.java index f1c47bcd38c8..c2fbff2cde91 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/ViewContainer.java +++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/ViewContainer.java @@ -205,7 +205,7 @@ public class ViewContainer extends Thread synchronized(mlListener) { try{ - aListener = (IShutdownListener)mlListener.firstElement(); + aListener = mlListener.firstElement(); } catch(java.util.NoSuchElementException exEmpty) {} } if (aListener==null) diff --git a/odk/examples/DevelopersGuide/UCB/ChildrenRetriever.java b/odk/examples/DevelopersGuide/UCB/ChildrenRetriever.java index f33e71d4cfd5..00591ec4bc58 100644 --- a/odk/examples/DevelopersGuide/UCB/ChildrenRetriever.java +++ b/odk/examples/DevelopersGuide/UCB/ChildrenRetriever.java @@ -138,7 +138,7 @@ public class ChildrenRetriever { // Execute command "open". set = UnoRuntime.queryInterface( XDynamicResultSet.class, m_helper.executeCommand( m_content, "open", arg )); - XResultSet resultSet = ( XResultSet )set.getStaticResultSet(); + XResultSet resultSet = set.getStaticResultSet(); result = new Vector>(); diff --git a/odk/examples/DevelopersGuide/UCB/Helper.java b/odk/examples/DevelopersGuide/UCB/Helper.java index c203904749bc..7bde0ce47e6e 100644 --- a/odk/examples/DevelopersGuide/UCB/Helper.java +++ b/odk/examples/DevelopersGuide/UCB/Helper.java @@ -76,7 +76,7 @@ public class Helper { System.out.println("Connected to a running office ..."); } - m_ucb = (XInterface)UnoRuntime.queryInterface( + m_ucb = UnoRuntime.queryInterface( XInterface.class, UniversalContentBroker.create(m_xContext)); } @@ -103,11 +103,11 @@ public class Helper { // Obtain required UCB interfaces... XContentIdentifierFactory idFactory - = ( XContentIdentifierFactory )UnoRuntime.queryInterface( - XContentIdentifierFactory.class, m_ucb ); + = UnoRuntime.queryInterface( + XContentIdentifierFactory.class, m_ucb ); XContentProvider provider - = ( XContentProvider )UnoRuntime.queryInterface( - XContentProvider.class, m_ucb ); + = UnoRuntime.queryInterface( + XContentProvider.class, m_ucb ); // Create identifier object for given URL. XContentIdentifier id = idFactory.createContentIdentifier( connectURL ); @@ -152,8 +152,8 @@ public class Helper { ///////////////////////////////////////////////////////////////////// XCommandProcessor cmdProcessor - = (XCommandProcessor)UnoRuntime.queryInterface( - XCommandProcessor.class, ifc ); + = UnoRuntime.queryInterface( + XCommandProcessor.class, ifc ); ///////////////////////////////////////////////////////////////////// // Assemble command to execute. diff --git a/odk/examples/DevelopersGuide/UCB/ResourceCreator.java b/odk/examples/DevelopersGuide/UCB/ResourceCreator.java index 4dc1946c752e..c78710881698 100644 --- a/odk/examples/DevelopersGuide/UCB/ResourceCreator.java +++ b/odk/examples/DevelopersGuide/UCB/ResourceCreator.java @@ -154,7 +154,7 @@ public class ResourceCreator { info.Attributes = 0; // Create new, empty content (execute command "createNewContent"). - XContent newContent = ( XContent )UnoRuntime.queryInterface( + XContent newContent = UnoRuntime.queryInterface( XContent.class, m_helper.executeCommand( m_content, "createNewContent", info ) ); diff --git a/odk/examples/java/Inspector/HideableTreeModel.java b/odk/examples/java/Inspector/HideableTreeModel.java index 21732e6776fe..44c208c8be3a 100644 --- a/odk/examples/java/Inspector/HideableTreeModel.java +++ b/odk/examples/java/Inspector/HideableTreeModel.java @@ -261,7 +261,7 @@ public class HideableTreeModel implements TreeModel { if(parent instanceof TreeNode) { TreeNode p = (TreeNode) parent; for(int i = 0, j = -1; i < p.getChildCount(); i++) { - TreeNode pc = (TreeNode)p.getChildAt(i); + TreeNode pc = p.getChildAt(i); if(isNodeVisible(pc)) { j++; } @@ -279,7 +279,7 @@ public class HideableTreeModel implements TreeModel { if(parent instanceof TreeNode) { TreeNode p = (TreeNode) parent; for(int i = 0; i < p.getChildCount(); i++) { - TreeNode pc = (TreeNode)p.getChildAt(i); + TreeNode pc = p.getChildAt(i); if(isNodeVisible(pc)) { count++; } @@ -297,7 +297,7 @@ public class HideableTreeModel implements TreeModel { if(isNodeVisible(c)) { index = 0; for(int i = 0; i < p.getChildCount(); i++) { - TreeNode pc = (TreeNode)p.getChildAt(i); + TreeNode pc = p.getChildAt(i); if(pc.equals(c)) { return index; } diff --git a/odk/examples/java/Inspector/InspectorAddon.java b/odk/examples/java/Inspector/InspectorAddon.java index f7605fd87c6d..d5ec16811fc7 100644 --- a/odk/examples/java/Inspector/InspectorAddon.java +++ b/odk/examples/java/Inspector/InspectorAddon.java @@ -93,7 +93,7 @@ public class InspectorAddon { public void initialize( Object[] object ) throws com.sun.star.uno.Exception { if ( object.length > 0 ){ - m_xFrame = ( XFrame ) UnoRuntime.queryInterface(XFrame.class, object[ 0 ] ); + m_xFrame = UnoRuntime.queryInterface(XFrame.class, object[ 0 ] ); } } @@ -120,14 +120,14 @@ public class InspectorAddon { com.sun.star.lang.XMultiComponentFactory xMCF = m_xContext.getServiceManager(); if (xInstInspector == null){ Object obj= xMCF.createInstanceWithContext("org.openoffice.InstanceInspector", m_xContext); - xInstInspector = (org.openoffice.XInstanceInspector)UnoRuntime.queryInterface(org.openoffice.XInstanceInspector.class, obj); + xInstInspector = UnoRuntime.queryInterface(org.openoffice.XInstanceInspector.class, obj); } if ((m_xFrame == null) || (xModel == null)){ Object oDesktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", m_xContext); - m_xFrame = (XFrame) UnoRuntime.queryInterface(XFrame.class, oDesktop); + m_xFrame = UnoRuntime.queryInterface(XFrame.class, oDesktop); oUnoInspectObject = m_xFrame; } - XPropertySet xFramePropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, m_xFrame); + XPropertySet xFramePropertySet = UnoRuntime.queryInterface(XPropertySet.class, m_xFrame); String sTitle = (String) xFramePropertySet.getPropertyValue("Title"); String[] sTitleList = sTitle.split(" - "); if (sTitleList.length > 0){ diff --git a/odk/examples/java/Inspector/InspectorPane.java b/odk/examples/java/Inspector/InspectorPane.java index 49339402fefd..11640ce874e0 100644 --- a/odk/examples/java/Inspector/InspectorPane.java +++ b/odk/examples/java/Inspector/InspectorPane.java @@ -294,7 +294,7 @@ import org.openoffice.XInstanceInspector; // add all services for the given object to the tree under the node parent private void addServicesToTreeNode(XUnoNode _oGrandParentNode, Object _oUnoObject) { try{ - XServiceInfo xServiceInfo = ( XServiceInfo ) UnoRuntime.queryInterface( XServiceInfo.class, _oUnoObject ); + XServiceInfo xServiceInfo = UnoRuntime.queryInterface( XServiceInfo.class, _oUnoObject ); if ( xServiceInfo != null ){ String[] sSupportedServiceNames = xServiceInfo.getSupportedServiceNames(); for ( int m = 0; m < sSupportedServiceNames.length; m++ ) { @@ -325,7 +325,7 @@ import org.openoffice.XInstanceInspector; for ( int n = 0; n < _aProperties.length; n++ ){ Property aProperty = _aProperties[n]; XIntrospectionAccess xIntrospectionAccess = m_oIntrospector.getXIntrospectionAccess(_oUnoParentObject); - XPropertySet xPropertySet = ( XPropertySet ) UnoRuntime.queryInterface( XPropertySet.class, xIntrospectionAccess.queryAdapter(new Type( XPropertySet.class))); + XPropertySet xPropertySet = UnoRuntime.queryInterface( XPropertySet.class, xIntrospectionAccess.queryAdapter(new Type( XPropertySet.class))); if (xPropertySet != null) { if (xPropertySet.getPropertySetInfo().hasPropertyByName(aProperty.Name)){ Object objectElement = xPropertySet.getPropertyValue(aProperty.Name); diff --git a/odk/examples/java/Inspector/ProtocolHandlerAddon.java b/odk/examples/java/Inspector/ProtocolHandlerAddon.java index e20d3a2b1bcf..00bc253cb703 100644 --- a/odk/examples/java/Inspector/ProtocolHandlerAddon.java +++ b/odk/examples/java/Inspector/ProtocolHandlerAddon.java @@ -101,12 +101,12 @@ public class ProtocolHandlerAddon { if ( object.length > 0 ) { - m_xFrame = ( XFrame ) UnoRuntime.queryInterface( + m_xFrame = UnoRuntime.queryInterface( XFrame.class, object[ 0 ] ); } // Create the toolkit to have access to it later - m_xToolkit = (XToolkit) UnoRuntime.queryInterface( + m_xToolkit = UnoRuntime.queryInterface( XToolkit.class, m_xCmpCtx.getServiceManager().createInstanceWithContext("com.sun.star.awt.Toolkit", m_xCmpCtx)); @@ -211,7 +211,7 @@ public class ProtocolHandlerAddon { aDescriptor.Type = WindowClass.MODALTOP; aDescriptor.WindowServiceName = new String( "infobox" ); aDescriptor.ParentIndex = -1; - aDescriptor.Parent = (XWindowPeer)UnoRuntime.queryInterface( + aDescriptor.Parent = UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow()); aDescriptor.Bounds = new Rectangle(0,0,300,200); aDescriptor.WindowAttributes = WindowAttribute.BORDER | @@ -220,7 +220,7 @@ public class ProtocolHandlerAddon { XWindowPeer xPeer = m_xToolkit.createWindow( aDescriptor ); if ( null != xPeer ) { - XMessageBox xMsgBox = (XMessageBox)UnoRuntime.queryInterface( + XMessageBox xMsgBox = UnoRuntime.queryInterface( XMessageBox.class, xPeer); if ( null != xMsgBox ) { diff --git a/odk/examples/java/Inspector/SourceCodeGenerator.java b/odk/examples/java/Inspector/SourceCodeGenerator.java index f8de8c2fbab3..5855ed4e2c65 100644 --- a/odk/examples/java/Inspector/SourceCodeGenerator.java +++ b/odk/examples/java/Inspector/SourceCodeGenerator.java @@ -364,9 +364,9 @@ public class SourceCodeGenerator { private class HeaderStatements extends Vector { public boolean contains(String _oElement){ - String sCompName = (String) _oElement; + String sCompName = _oElement; for (int i = 0; i < this.size(); i++){ - String sElement = (String) this.get(i); + String sElement = this.get(i); if (sElement.equals(sCompName)){ return true; } diff --git a/odk/examples/java/Inspector/SwingDialogProvider.java b/odk/examples/java/Inspector/SwingDialogProvider.java index 51c56fb63e5d..5f5a31b8818d 100644 --- a/odk/examples/java/Inspector/SwingDialogProvider.java +++ b/odk/examples/java/Inspector/SwingDialogProvider.java @@ -132,7 +132,7 @@ public class SwingDialogProvider implements XDialogProvider{ if (_nIndex > -1){ JPanel jPnlContainerInspectorPanel = (JPanel) m_jTabbedPane1.getComponentAt(_nIndex); String sInspectorPanelTitle = m_jTabbedPane1.getTitleAt(_nIndex); - oInspectorPane = (InspectorPane) m_oInspector.getInspectorPages().get(sInspectorPanelTitle); + oInspectorPane = m_oInspector.getInspectorPages().get(sInspectorPanelTitle); } return oInspectorPane; } diff --git a/odk/examples/java/Inspector/SwingTreeControlProvider.java b/odk/examples/java/Inspector/SwingTreeControlProvider.java index 8ef3b158f11a..f4eb91945cc3 100644 --- a/odk/examples/java/Inspector/SwingTreeControlProvider.java +++ b/odk/examples/java/Inspector/SwingTreeControlProvider.java @@ -397,7 +397,7 @@ public class SwingTreeControlProvider implements XTreeControlProvider{ public XUnoPropertyNode addUnoPropertyNodeWithAttributesDescription(Property _aProperty){ SwingUnoPropertyNode oUnoPropertyNode = new SwingUnoPropertyNode(_aProperty); XConstantTypeDescription[] xPropertyAttributesTypeDescriptions = Introspector.getIntrospector().getFieldsOfConstantGroup("com.sun.star.beans.PropertyAttribute"); - String sDisplay = Introspector.getIntrospector().getConstantDisplayString((int) _aProperty.Attributes, xPropertyAttributesTypeDescriptions, "Attributes: "); + String sDisplay = Introspector.getIntrospector().getConstantDisplayString(_aProperty.Attributes, xPropertyAttributesTypeDescriptions, "Attributes: "); oUnoPropertyNode.setLabel(sDisplay); return oUnoPropertyNode; } diff --git a/odk/examples/java/Inspector/TDocSupplier.java b/odk/examples/java/Inspector/TDocSupplier.java index c0afd57170a1..7f34d13de96d 100644 --- a/odk/examples/java/Inspector/TDocSupplier.java +++ b/odk/examples/java/Inspector/TDocSupplier.java @@ -78,7 +78,7 @@ public class TDocSupplier { XRow xRow = getXRowOfTDocUrl(_sTDocUrl, "DocumentModel"); if (xRow != null){ Object oModel = xRow.getObject(1, null); - XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, oModel); + XModel xModel = UnoRuntime.queryInterface(XModel.class, oModel); return xModel; } }catch(Exception exception){ @@ -108,7 +108,7 @@ public class TDocSupplier { XUniversalContentBroker xUCB = UniversalContentBroker.create( getXComponentContext() ); XContentIdentifier xId = xUCB.createContentIdentifier(_sTDocUrl); XContent xContent = xUCB.queryContent(xId); - XCommandProcessor xCmdProcessor = (XCommandProcessor) UnoRuntime.queryInterface(XCommandProcessor.class, xContent); + XCommandProcessor xCmdProcessor = UnoRuntime.queryInterface(XCommandProcessor.class, xContent); Property aProperty = new Property(); aProperty.Name = _sPropertyName; // "DocumentModel"; //DocumentModel Command aCommand = new Command(); @@ -116,7 +116,7 @@ public class TDocSupplier { aCommand.Handle = -1; // not available aCommand.Argument = new Property[]{aProperty}; Object oAny = xCmdProcessor.execute(aCommand, 0, null); - XRow xRow = (XRow) UnoRuntime.queryInterface(XRow.class, oAny); + XRow xRow = UnoRuntime.queryInterface(XRow.class, oAny); return xRow; }catch(Exception exception){ exception.printStackTrace(System.err); @@ -136,7 +136,7 @@ public class TDocSupplier { protected String[] getTDocUrls(){ try{ Object oSimpleFileAccess = getXMultiComponentFactory().createInstanceWithContext("com.sun.star.ucb.SimpleFileAccess", getXComponentContext()); - XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) UnoRuntime.queryInterface(XSimpleFileAccess.class, oSimpleFileAccess); + XSimpleFileAccess xSimpleFileAccess = UnoRuntime.queryInterface(XSimpleFileAccess.class, oSimpleFileAccess); String[] sContent = xSimpleFileAccess.getFolderContents("vnd.sun.star.tdoc:/", false); return sContent; } catch( Exception e ) { @@ -152,7 +152,7 @@ public class TDocSupplier { aPropertyValues[0].Name = "Hidden"; aPropertyValues[0].Value = Boolean.TRUE; Object oDesktop = getXMultiComponentFactory().createInstanceWithContext("com.sun.star.frame.Desktop", getXComponentContext()); - XComponentLoader xCL = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, oDesktop); + XComponentLoader xCL = UnoRuntime.queryInterface(XComponentLoader.class, oDesktop); return xCL.loadComponentFromURL(_sUrl, "_default", 0, aPropertyValues); } catch( Exception exception ) { diff --git a/odk/examples/java/Inspector/TestInspector.java b/odk/examples/java/Inspector/TestInspector.java index 6b8758b0728c..bd7a38ed7401 100644 --- a/odk/examples/java/Inspector/TestInspector.java +++ b/odk/examples/java/Inspector/TestInspector.java @@ -61,14 +61,14 @@ public class TestInspector { } org.openoffice.XInstanceInspector xInstInspector = null; if (obj != null) { - xInstInspector = (org.openoffice.XInstanceInspector)UnoRuntime.queryInterface(org.openoffice.XInstanceInspector.class, obj); + xInstInspector = UnoRuntime.queryInterface(org.openoffice.XInstanceInspector.class, obj); } /* 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. */ - com.sun.star.frame.XComponentLoader xCmpLoader = (com.sun.star.frame.XComponentLoader)UnoRuntime.queryInterface( com.sun.star.frame.XComponentLoader.class, + com.sun.star.frame.XComponentLoader xCmpLoader = UnoRuntime.queryInterface( com.sun.star.frame.XComponentLoader.class, xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext)); // Load a new spreadsheet document, which will be automaticly diff --git a/odk/examples/java/Inspector/UnoNode.java b/odk/examples/java/Inspector/UnoNode.java index 9ba110c06c3a..92fef1885aec 100644 --- a/odk/examples/java/Inspector/UnoNode.java +++ b/odk/examples/java/Inspector/UnoNode.java @@ -170,7 +170,7 @@ public class UnoNode{ private com.sun.star.util.URL getDispatchURL(String _sURL){ try { Object oTransformer = getXMultiComponentFactory().createInstanceWithContext("com.sun.star.util.URLTransformer", getXComponentContext()); - XURLTransformer xTransformer = (XURLTransformer) UnoRuntime.queryInterface(XURLTransformer.class, oTransformer); + XURLTransformer xTransformer = UnoRuntime.queryInterface(XURLTransformer.class, oTransformer); com.sun.star.util.URL[] oURL = new com.sun.star.util.URL[1]; oURL[0] = new com.sun.star.util.URL(); oURL[0].Complete = _sURL; @@ -186,7 +186,7 @@ public class UnoNode{ private XFrame getCurrentFrame(){ try{ Object oDesktop = getXMultiComponentFactory().createInstanceWithContext("com.sun.star.frame.Desktop", getXComponentContext()); - XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, oDesktop); + XDesktop xDesktop = UnoRuntime.queryInterface(XDesktop.class, oDesktop); return xDesktop.getCurrentFrame(); } catch (Exception e) { e.printStackTrace(System.err); @@ -198,7 +198,7 @@ public class UnoNode{ try { com.sun.star.util.URL[] oURLArray = new com.sun.star.util.URL[1]; oURLArray[0] = oURL; - XDispatchProvider xDispatchProvider = (XDispatchProvider) UnoRuntime.queryInterface(XDispatchProvider.class, getCurrentFrame()); + XDispatchProvider xDispatchProvider = UnoRuntime.queryInterface(XDispatchProvider.class, getCurrentFrame()); XDispatch xDispatch = xDispatchProvider.queryDispatch(oURLArray[0], "_top", FrameSearchFlag.ALL); // "_self" return xDispatch; } catch (Exception e) { @@ -250,7 +250,7 @@ public class UnoNode{ while (xTDEnumeration.hasMoreElements()) { XTypeDescription xTD = xTDEnumeration.nextTypeDescription(); if (xTD.getName().equals(_sServiceName)){ - XServiceTypeDescription xServiceTypeDescription = (XServiceTypeDescription) UnoRuntime.queryInterface(XServiceTypeDescription.class, xTD); + XServiceTypeDescription xServiceTypeDescription = UnoRuntime.queryInterface(XServiceTypeDescription.class, xTD); XServiceTypeDescription[] xMandatoryServiceTypeDescriptions = xServiceTypeDescription.getMandatoryServices(); int nlength = xMandatoryServiceTypeDescriptions.length; sMandatoryServiceNames = new String[nlength]; @@ -414,7 +414,7 @@ public class UnoNode{ public static String getNodeDescription(Object _oUnoObject){ - XServiceInfo xServiceInfo = ( XServiceInfo ) UnoRuntime.queryInterface( XServiceInfo.class, _oUnoObject ); + XServiceInfo xServiceInfo = UnoRuntime.queryInterface( XServiceInfo.class, _oUnoObject ); if ( xServiceInfo != null ) { return xServiceInfo.getImplementationName(); } diff --git a/odk/examples/java/Inspector/UnoPropertyNode.java b/odk/examples/java/Inspector/UnoPropertyNode.java index 24f7573bbeaf..920300e15546 100644 --- a/odk/examples/java/Inspector/UnoPropertyNode.java +++ b/odk/examples/java/Inspector/UnoPropertyNode.java @@ -97,7 +97,7 @@ public class UnoPropertyNode extends UnoNode{ public String getClassName(){ String sClassName = ""; if (m_oUnoObject != null){ - XServiceInfo xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, m_oUnoObject); + XServiceInfo xServiceInfo = UnoRuntime.queryInterface(XServiceInfo.class, m_oUnoObject); if (xServiceInfo != null){ String[] sServiceNames = xServiceInfo.getSupportedServiceNames(); for (int i = 0; i < sServiceNames.length; i++){