diff options
author | Noel Grandin <noel@peralex.com> | 2013-04-23 09:01:41 +0200 |
---|---|---|
committer | Fridrich Strba <fridrich@documentfoundation.org> | 2013-04-23 10:29:36 +0000 |
commit | 68b9fb0aaeff4aef41dfd6989491b522578ca079 (patch) | |
tree | 91ce6c4395e11b17c7ca652a66bd8ce905afcd7b /odk/examples/DevelopersGuide/OfficeDev | |
parent | 4f6adb0585037013241bd59e5c869a261c1f20c1 (diff) |
Java cleanup - remove unnecessary casts in the ODK code
Change-Id: I1ab8ad5182444fc3eebd2349135a0240ebbe0fd4
Reviewed-on: https://gerrit.libreoffice.org/3566
Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org>
Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
Diffstat (limited to 'odk/examples/DevelopersGuide/OfficeDev')
6 files changed, 57 insertions, 60 deletions
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/DocumentView.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/DocumentView.java index c0e165edab7a..70748dfb7e64 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/DocumentView.java +++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/DocumentView.java @@ -232,7 +232,7 @@ public class DocumentView extends JFrame maCustomizeView.setFrame(mxFrame); // be listener for closing the remote target view frame - com.sun.star.lang.XComponent xBroadcaster = (com.sun.star.lang.XComponent)UnoRuntime.queryInterface( + com.sun.star.lang.XComponent xBroadcaster = UnoRuntime.queryInterface( com.sun.star.lang.XComponent.class, mxFrame); diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/FunctionHelper.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/FunctionHelper.java index 3fb237ffb20c..9076fcb8b101 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/FunctionHelper.java +++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/FunctionHelper.java @@ -92,10 +92,10 @@ public class FunctionHelper // Create special service for parsing of given URL. com.sun.star.util.XURLTransformer xParser = - (com.sun.star.util.XURLTransformer)UnoRuntime.queryInterface( - com.sun.star.util.XURLTransformer.class, - xOfficeCtx.getServiceManager().createInstanceWithContext( - "com.sun.star.util.URLTransformer", xOfficeCtx)); + UnoRuntime.queryInterface( + com.sun.star.util.XURLTransformer.class, + xOfficeCtx.getServiceManager().createInstanceWithContext( + "com.sun.star.util.URLTransformer", xOfficeCtx)); // Because it's an in/out parameter we must use an array of URL objects. com.sun.star.util.URL[] aParseURL = new com.sun.star.util.URL[1]; @@ -146,7 +146,7 @@ public class FunctionHelper com.sun.star.frame.XFrame xFrame = null; try{ - xFrame = (com.sun.star.frame.XFrame)UnoRuntime.queryInterface( + xFrame = UnoRuntime.queryInterface( com.sun.star.frame.XFrame.class, xCtx.getServiceManager().createInstanceWithContext( "com.sun.star.frame.Task", xCtx)); @@ -155,7 +155,7 @@ public class FunctionHelper if (xFrame==null) { try{ - xFrame = (com.sun.star.frame.XFrame)UnoRuntime.queryInterface( + xFrame = UnoRuntime.queryInterface( com.sun.star.frame.XFrame.class, xCtx.getServiceManager().createInstanceWithContext( "com.sun.star.frame.Frame", xCtx)); @@ -213,7 +213,7 @@ public class FunctionHelper // get access to toolkit of remote office to create the container window of // new target frame try{ - xToolkit = (com.sun.star.awt.XToolkit)UnoRuntime.queryInterface( + xToolkit = UnoRuntime.queryInterface( com.sun.star.awt.XToolkit.class, xCtx.getServiceManager().createInstanceWithContext( "com.sun.star.awt.Toolkit", xCtx)); @@ -257,8 +257,8 @@ public class FunctionHelper // the remote office. Means if this java client and the remote office // use the same display! com.sun.star.awt.XSystemChildFactory xChildFactory = - (com.sun.star.awt.XSystemChildFactory)UnoRuntime.queryInterface( - com.sun.star.awt.XSystemChildFactory.class, xToolkit); + UnoRuntime.queryInterface( + com.sun.star.awt.XSystemChildFactory.class, xToolkit); try { @@ -266,7 +266,7 @@ public class FunctionHelper short nSystem = (short)aParentView.getNativeWindowSystemType(); byte[] lProcID = new byte[0]; - xPeer = xChildFactory.createSystemChild((Object)nHandle, + xPeer = xChildFactory.createSystemChild(nHandle, lProcID, nSystem); if (xPeer==null) @@ -279,8 +279,8 @@ public class FunctionHelper JavaWindowPeerFake(aParentView); com.sun.star.awt.XWindowPeer xParentPeer = - (com.sun.star.awt.XWindowPeer)UnoRuntime.queryInterface( - com.sun.star.awt.XWindowPeer.class, aWrapper); + UnoRuntime.queryInterface( + com.sun.star.awt.XWindowPeer.class, aWrapper); com.sun.star.awt.WindowDescriptor aDescriptor = new com.sun.star.awt.WindowDescriptor(); @@ -316,7 +316,7 @@ public class FunctionHelper // It doesn't matter which way was used to get the window peer. // Cast it to the right return interface and return it. - xWindow = (com.sun.star.awt.XWindow)UnoRuntime.queryInterface( + xWindow = UnoRuntime.queryInterface( com.sun.star.awt.XWindow.class, xPeer); @@ -370,7 +370,7 @@ public class FunctionHelper // Insert the new frame in desktop hierarchy. // Use XFrames interface to do so. It provides access to the child frame container of that instance. - com.sun.star.frame.XFramesSupplier xTreeRoot = (com.sun.star.frame.XFramesSupplier)UnoRuntime.queryInterface( + com.sun.star.frame.XFramesSupplier xTreeRoot = UnoRuntime.queryInterface( com.sun.star.frame.XFramesSupplier.class, xCtx.getServiceManager().createInstanceWithContext( "com.sun.star.frame.Desktop", xCtx)); @@ -395,7 +395,7 @@ public class FunctionHelper // After the dispose() call forget all references to this frame and let him die. // If a new exception will occure ... no generell solution exist then. // Nobody can guarantee if next call will work or not. - com.sun.star.lang.XComponent xComponent = (com.sun.star.lang.XComponent)UnoRuntime.queryInterface( + com.sun.star.lang.XComponent xComponent = UnoRuntime.queryInterface( com.sun.star.lang.XComponent.class, xFrame); xComponent.dispose(); @@ -411,7 +411,7 @@ public class FunctionHelper // Without the desktop service that wasn't possible. So no further rollbacks must follow. if(xFrame!=null) { - com.sun.star.lang.XComponent xComponent = (com.sun.star.lang.XComponent)UnoRuntime.queryInterface( + com.sun.star.lang.XComponent xComponent = UnoRuntime.queryInterface( com.sun.star.lang.XComponent.class, xFrame); xComponent.dispose(); @@ -453,7 +453,7 @@ public class FunctionHelper try { // Query the frame for right interface which provides access to all available dispatch objects. - 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); @@ -511,7 +511,7 @@ public class FunctionHelper try { // Query the frame for right interface which provides access to all available dispatch objects. - 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); @@ -519,7 +519,7 @@ public class FunctionHelper // Force THIS frame as target for following dispatch. // Attention: The interface XNotifyingDispatch is an optional one! com.sun.star.frame.XDispatch xDispatcher = xProvider.queryDispatch(aURL,"",0); - com.sun.star.frame.XNotifyingDispatch xNotifyingDispatcher = (com.sun.star.frame.XNotifyingDispatch)UnoRuntime.queryInterface( + com.sun.star.frame.XNotifyingDispatch xNotifyingDispatcher = UnoRuntime.queryInterface( com.sun.star.frame.XNotifyingDispatch.class, xDispatcher); @@ -571,10 +571,10 @@ public class FunctionHelper // Get access to the global component loader of the office // for synchronous loading the document. com.sun.star.frame.XComponentLoader xLoader = - (com.sun.star.frame.XComponentLoader)UnoRuntime.queryInterface( - com.sun.star.frame.XComponentLoader.class, - xCtx.getServiceManager().createInstanceWithContext( - "com.sun.star.frame.Desktop", xCtx)); + UnoRuntime.queryInterface( + com.sun.star.frame.XComponentLoader.class, + xCtx.getServiceManager().createInstanceWithContext( + "com.sun.star.frame.Desktop", xCtx)); // Load the document into the target frame by using his name and // special search flags. @@ -642,18 +642,18 @@ public class FunctionHelper // Normaly the application documents (text, spreadsheet ...) do so // but some other ones (e.g. db components) doesn't do that. // They can't be save then. - com.sun.star.frame.XModel xModel = (com.sun.star.frame.XModel)UnoRuntime.queryInterface( + com.sun.star.frame.XModel xModel = UnoRuntime.queryInterface( com.sun.star.frame.XModel.class, xDocument); if(xModel!=null) { // Check for modifications => 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<nCount; ++i ) diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java index 12ea20173b3a..c9fe4f38c33f 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java +++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java @@ -237,7 +237,7 @@ public class Interceptor implements com.sun.star.frame.XFrameActionListener, Vector<Object> lOutParams = new Vector<Object>(); 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<Object> 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<Object> lOutParams = new Vector<Object>(); 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) |