diff options
author | Noel Grandin <noel@peralex.com> | 2012-08-20 17:05:35 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-08-20 19:04:33 +0100 |
commit | 8bfe47960f60e1dc2e6bcf0f3c3f7e43dfd3fc0b (patch) | |
tree | 12399f5232ff90f000bb58e213629140e564f0ce /bean | |
parent | f906ac27761332580b769f5f90d1f6bbd7f93701 (diff) |
Java5 updates - convert to generics
Change-Id: I039e51958865a7ea000034e7bf765f64d49689cd
Diffstat (limited to 'bean')
-rw-r--r-- | bean/com/sun/star/beans/LocalOfficeConnection.java | 11 | ||||
-rw-r--r-- | bean/com/sun/star/beans/LocalOfficeWindow.java | 16 | ||||
-rw-r--r-- | bean/com/sun/star/comp/beans/Controller.java | 5 | ||||
-rw-r--r-- | bean/com/sun/star/comp/beans/Frame.java | 10 | ||||
-rw-r--r-- | bean/com/sun/star/comp/beans/LocalOfficeConnection.java | 15 | ||||
-rw-r--r-- | bean/com/sun/star/comp/beans/LocalOfficeWindow.java | 16 | ||||
-rw-r--r-- | bean/com/sun/star/comp/beans/OOoBean.java | 42 | ||||
-rw-r--r-- | bean/com/sun/star/comp/beans/OfficeDocument.java | 15 | ||||
-rw-r--r-- | bean/com/sun/star/comp/beans/Wrapper.java | 5 | ||||
-rw-r--r-- | bean/qa/complex/bean/OOoBeanTest.java | 2 | ||||
-rw-r--r-- | bean/qa/complex/bean/WriterFrame.java | 8 |
11 files changed, 66 insertions, 79 deletions
diff --git a/bean/com/sun/star/beans/LocalOfficeConnection.java b/bean/com/sun/star/beans/LocalOfficeConnection.java index 15f025ac6738..b742fb3a7027 100644 --- a/bean/com/sun/star/beans/LocalOfficeConnection.java +++ b/bean/com/sun/star/beans/LocalOfficeConnection.java @@ -110,8 +110,8 @@ public class LocalOfficeConnection UnoUrl aURL = UnoUrl.parseUnoUrl( url ); mProgramPath = null; mConnType = aURL.getConnection(); - mPipe = (String) aURL.getConnectionParameters().get( "pipe" ); - mPort = (String) aURL.getConnectionParameters().get( "port" ); + mPipe = aURL.getConnectionParameters().get( "pipe" ); + mPort = aURL.getConnectionParameters().get( "port" ); mProtocol = aURL.getProtocol(); mInitialObject = aURL.getRootOid(); } @@ -221,7 +221,7 @@ public class LocalOfficeConnection // query for the XUnoUrlResolver interface XUnoUrlResolver xUrlResolver = - (XUnoUrlResolver) UnoRuntime.queryInterface( XUnoUrlResolver.class, urlResolver ); + UnoRuntime.queryInterface( XUnoUrlResolver.class, urlResolver ); // try to connect to soffice Object aInitialObject = null; @@ -261,10 +261,9 @@ public class LocalOfficeConnection // XComponentContext if( null != aInitialObject ) { - XPropertySet xPropertySet = (XPropertySet) - UnoRuntime.queryInterface( XPropertySet.class, aInitialObject); + XPropertySet xPropertySet = UnoRuntime.queryInterface( XPropertySet.class, aInitialObject); Object xContext = xPropertySet.getPropertyValue("DefaultContext"); - XComponentContext xComponentContext = (XComponentContext) UnoRuntime.queryInterface( + XComponentContext xComponentContext = UnoRuntime.queryInterface( XComponentContext.class, xContext); return xComponentContext; } diff --git a/bean/com/sun/star/beans/LocalOfficeWindow.java b/bean/com/sun/star/beans/LocalOfficeWindow.java index 4f06c2ebe5c9..90ddbe8a8311 100644 --- a/bean/com/sun/star/beans/LocalOfficeWindow.java +++ b/bean/com/sun/star/beans/LocalOfficeWindow.java @@ -58,7 +58,7 @@ public class LocalOfficeWindow /* package */ LocalOfficeWindow(OfficeConnection connection) { mConnection = connection; - mConnection.addEventListener((XEventListener)this); + mConnection.addEventListener(this); } /** @@ -109,10 +109,10 @@ public class LocalOfficeWindow { compfactory = mConnection.getComponentContext().getServiceManager(); XMultiServiceFactory factory; - factory = (XMultiServiceFactory)UnoRuntime.queryInterface( + factory = UnoRuntime.queryInterface( XMultiServiceFactory.class, compfactory); Object object = factory.createInstance( "com.sun.star.awt.Toolkit"); - return (XToolkit)UnoRuntime.queryInterface(XToolkit.class, object); + return UnoRuntime.queryInterface(XToolkit.class, object); } else return null; @@ -124,13 +124,13 @@ public class LocalOfficeWindow if ( !bPeer ) { // set real parent - XVclWindowPeer xVclWindowPeer = (XVclWindowPeer)UnoRuntime.queryInterface( + XVclWindowPeer xVclWindowPeer = UnoRuntime.queryInterface( XVclWindowPeer.class, mWindow); xVclWindowPeer.setProperty( "PluginParent", new Long(getNativeWindow()) ); bPeer = true; // show document window - XWindow aWindow = (XWindow)UnoRuntime.queryInterface(XWindow.class, mWindow); + XWindow aWindow = UnoRuntime.queryInterface(XWindow.class, mWindow); aWindow.setVisible( true ); } } @@ -141,11 +141,11 @@ public class LocalOfficeWindow if ( bPeer ) { // hide document window - XWindow aWindow = (XWindow)UnoRuntime.queryInterface(XWindow.class, mWindow); + XWindow aWindow = UnoRuntime.queryInterface(XWindow.class, mWindow); aWindow.setVisible( false ); // set null parent - XVclWindowPeer xVclWindowPeer = (XVclWindowPeer)UnoRuntime.queryInterface( + XVclWindowPeer xVclWindowPeer = UnoRuntime.queryInterface( XVclWindowPeer.class, mWindow); xVclWindowPeer.setProperty( "PluginParent", new Long(0) ); bPeer = false; @@ -228,7 +228,7 @@ public class LocalOfficeWindow addComponentListener( new ComponentEventHandler() ); // set initial visibility - XWindow aWindow = (XWindow)UnoRuntime.queryInterface(XWindow.class, mWindow); + XWindow aWindow = UnoRuntime.queryInterface(XWindow.class, mWindow); aWindow.setVisible( bPeer ); } catch (com.sun.star.uno.Exception exp) { diff --git a/bean/com/sun/star/comp/beans/Controller.java b/bean/com/sun/star/comp/beans/Controller.java index ee29234802a5..9521af6bc2cd 100644 --- a/bean/com/sun/star/comp/beans/Controller.java +++ b/bean/com/sun/star/comp/beans/Controller.java @@ -36,9 +36,8 @@ public class Controller { super( xController ); this.xController = xController; - xDispatchProvider = (com.sun.star.frame.XDispatchProvider) - UnoRuntime.queryInterface( com.sun.star.frame.XDispatchProvider.class, - xController ); + xDispatchProvider = UnoRuntime.queryInterface( com.sun.star.frame.XDispatchProvider.class, + xController ); } //============================================================== diff --git a/bean/com/sun/star/comp/beans/Frame.java b/bean/com/sun/star/comp/beans/Frame.java index 03e2a37c593d..cd68bb789090 100644 --- a/bean/com/sun/star/comp/beans/Frame.java +++ b/bean/com/sun/star/comp/beans/Frame.java @@ -39,12 +39,10 @@ public class Frame { super( xFrame ); this.xFrame = xFrame; - xDispatchProvider = (com.sun.star.frame.XDispatchProvider) - UnoRuntime.queryInterface( com.sun.star.frame.XDispatchProvider.class, - xFrame ); - xDispatchProviderInterception = (com.sun.star.frame.XDispatchProviderInterception) - UnoRuntime.queryInterface( com.sun.star.frame.XDispatchProviderInterception.class, - xFrame ); + xDispatchProvider = UnoRuntime.queryInterface( com.sun.star.frame.XDispatchProvider.class, + xFrame ); + xDispatchProviderInterception = UnoRuntime.queryInterface( com.sun.star.frame.XDispatchProviderInterception.class, + xFrame ); } //============================================================== diff --git a/bean/com/sun/star/comp/beans/LocalOfficeConnection.java b/bean/com/sun/star/comp/beans/LocalOfficeConnection.java index a1d51f6ae18d..bf0e079075d8 100644 --- a/bean/com/sun/star/comp/beans/LocalOfficeConnection.java +++ b/bean/com/sun/star/comp/beans/LocalOfficeConnection.java @@ -176,8 +176,8 @@ public class LocalOfficeConnection { UnoUrl aURL = UnoUrl.parseUnoUrl( url ); mConnType = aURL.getConnection(); - mPipe = (String) aURL.getConnectionParameters().get( "pipe" ); - mPort = (String) aURL.getConnectionParameters().get( "port" ); + mPipe = aURL.getConnectionParameters().get( "pipe" ); + mPort = aURL.getConnectionParameters().get( "port" ); mProtocol = aURL.getProtocol(); mInitialObject = aURL.getRootOid(); } @@ -251,7 +251,7 @@ public class LocalOfficeConnection //to the office including the bridge needs to be terminated. if (mBridge != null) { - XComponent comp = (XComponent)UnoRuntime.queryInterface( + XComponent comp = UnoRuntime.queryInterface( XComponent.class, mBridge); if (comp != null) comp.dispose(); @@ -337,10 +337,9 @@ public class LocalOfficeConnection // XComponentContext if( null != aInitialObject ) { - XPropertySet xPropertySet = (XPropertySet) - UnoRuntime.queryInterface( XPropertySet.class, aInitialObject); + XPropertySet xPropertySet = UnoRuntime.queryInterface( XPropertySet.class, aInitialObject); Object xContext = xPropertySet.getPropertyValue("DefaultContext"); - XComponentContext xComponentContext = (XComponentContext) UnoRuntime.queryInterface( + XComponentContext xComponentContext = UnoRuntime.queryInterface( XComponentContext.class, xContext); return xComponentContext; } @@ -419,7 +418,7 @@ public class LocalOfficeConnection XMultiComponentFactory xLocalServiceManager = xLocalContext.getServiceManager(); try { - xBridgeFactory = (XBridgeFactory)UnoRuntime.queryInterface( + xBridgeFactory = UnoRuntime.queryInterface( XBridgeFactory.class, xLocalServiceManager.createInstanceWithContext( "com.sun.star.bridge.BridgeFactory", xLocalContext)); @@ -435,7 +434,7 @@ public class LocalOfficeConnection } catch (com.sun.star.uno.Exception e) { throw new com.sun.star.uno.RuntimeException(e.getMessage()); } - XConnector connector_xConnector = (XConnector)UnoRuntime.queryInterface(XConnector.class, connector); + XConnector connector_xConnector = UnoRuntime.queryInterface(XConnector.class, connector); // connect to the server XConnection xConnection = connector_xConnector.connect(conDcp); // create the bridge name. This should not be necessary if we pass an diff --git a/bean/com/sun/star/comp/beans/LocalOfficeWindow.java b/bean/com/sun/star/comp/beans/LocalOfficeWindow.java index 76f73d9d55ed..9e471b03ee86 100644 --- a/bean/com/sun/star/comp/beans/LocalOfficeWindow.java +++ b/bean/com/sun/star/comp/beans/LocalOfficeWindow.java @@ -62,7 +62,7 @@ public class LocalOfficeWindow protected LocalOfficeWindow(OfficeConnection connection) { mConnection = connection; - mConnection.addEventListener((XEventListener)this); + mConnection.addEventListener(this); } /** @@ -113,10 +113,10 @@ public class LocalOfficeWindow { compfactory = mConnection.getComponentContext().getServiceManager(); XMultiServiceFactory factory; - factory = (XMultiServiceFactory)UnoRuntime.queryInterface( + factory = UnoRuntime.queryInterface( XMultiServiceFactory.class, compfactory); Object object = factory.createInstance( "com.sun.star.awt.Toolkit"); - return (XToolkit)UnoRuntime.queryInterface(XToolkit.class, object); + return UnoRuntime.queryInterface(XToolkit.class, object); } else return null; @@ -128,13 +128,13 @@ public class LocalOfficeWindow if ( !bPeer ) { // set real parent - XVclWindowPeer xVclWindowPeer = (XVclWindowPeer)UnoRuntime.queryInterface( + XVclWindowPeer xVclWindowPeer = UnoRuntime.queryInterface( XVclWindowPeer.class, mWindow); xVclWindowPeer.setProperty( "PluginParent", getWrappedWindowHandle()); bPeer = true; // show document window - XWindow aWindow = (XWindow)UnoRuntime.queryInterface(XWindow.class, mWindow); + XWindow aWindow = UnoRuntime.queryInterface(XWindow.class, mWindow); aWindow.setVisible( true ); } } @@ -145,11 +145,11 @@ public class LocalOfficeWindow if ( bPeer ) { // hide document window - XWindow aWindow = (XWindow)UnoRuntime.queryInterface(XWindow.class, mWindow); + XWindow aWindow = UnoRuntime.queryInterface(XWindow.class, mWindow); aWindow.setVisible( false ); // set null parent - XVclWindowPeer xVclWindowPeer = (XVclWindowPeer)UnoRuntime.queryInterface( + XVclWindowPeer xVclWindowPeer = UnoRuntime.queryInterface( XVclWindowPeer.class, mWindow); xVclWindowPeer.setProperty( "PluginParent", new Long(0) ); bPeer = false; @@ -209,7 +209,7 @@ public class LocalOfficeWindow // set initial visibility - XWindow aWindow = (XWindow)UnoRuntime.queryInterface(XWindow.class, mWindow); + XWindow aWindow = UnoRuntime.queryInterface(XWindow.class, mWindow); aWindow.setVisible( bPeer ); } catch (com.sun.star.uno.Exception exp) { diff --git a/bean/com/sun/star/comp/beans/OOoBean.java b/bean/com/sun/star/comp/beans/OOoBean.java index 2c7a72005563..9c30201639b3 100644 --- a/bean/com/sun/star/comp/beans/OOoBean.java +++ b/bean/com/sun/star/comp/beans/OOoBean.java @@ -295,9 +295,8 @@ public class OOoBean { com.sun.star.lang.XMultiComponentFactory aFactory = iConn.getComponentContext().getServiceManager(); - xServiceFactory = (com.sun.star.lang.XMultiServiceFactory) - UnoRuntime.queryInterface( - com.sun.star.lang.XMultiServiceFactory.class, aFactory ); + xServiceFactory = UnoRuntime.queryInterface( + com.sun.star.lang.XMultiServiceFactory.class, aFactory ); } }; aConnectorThread.start(); @@ -324,7 +323,7 @@ public class OOoBean try { Object aObject = getMultiServiceFactory().createInstance( "com.sun.star.frame.Desktop"); - xDesktop = (com.sun.star.frame.XDesktop) UnoRuntime.queryInterface( + xDesktop = UnoRuntime.queryInterface( com.sun.star.frame.XDesktop.class, aObject ); } catch ( com.sun.star.uno.Exception aExc ) @@ -381,8 +380,7 @@ public class OOoBean new CallWatchThread( nOOoCallTimeOut, "clear" ); //By closing the frame we avoid that dialogs are displayed, for example when //the document is modified. - com.sun.star.util.XCloseable xCloseable = (com.sun.star.util.XCloseable) - UnoRuntime.queryInterface( com.sun.star.util.XCloseable.class, aFrame ); + com.sun.star.util.XCloseable xCloseable = UnoRuntime.queryInterface( com.sun.star.util.XCloseable.class, aFrame ); if ( xCloseable != null ) { try @@ -415,9 +413,8 @@ public class OOoBean { try { - com.sun.star.lang.XComponent xComp = (com.sun.star.lang.XComponent) - UnoRuntime.queryInterface( - com.sun.star.lang.XComponent.class, xURLTransformer ); + com.sun.star.lang.XComponent xComp = UnoRuntime.queryInterface( + com.sun.star.lang.XComponent.class, xURLTransformer ); if ( xComp != null ) xComp.dispose(); } @@ -573,23 +570,23 @@ public class OOoBean { // create the frame com.sun.star.awt.XWindow xWindow = - (com.sun.star.awt.XWindow) UnoRuntime.queryInterface( - com.sun.star.awt.XWindow.class, xFrameWindow.getUNOWindowPeer()); + UnoRuntime.queryInterface( + com.sun.star.awt.XWindow.class, xFrameWindow.getUNOWindowPeer()); Object xFrame = xServiceFactory.createInstance( "com.sun.star.frame.Frame"); - aFrame = new Frame( (com.sun.star.frame.XFrame)UnoRuntime.queryInterface( + aFrame = new Frame( UnoRuntime.queryInterface( com.sun.star.frame.XFrame.class, xFrame ) ); aFrame.initialize( xWindow ); aFrame.setName( aFrame.toString() ); // register the frame at the desktop com.sun.star.frame.XFrames xFrames = - ( (com.sun.star.frame.XFramesSupplier)UnoRuntime.queryInterface( - com.sun.star.frame.XFramesSupplier.class, getOOoDesktop() ) ).getFrames(); + UnoRuntime.queryInterface( + com.sun.star.frame.XFramesSupplier.class, getOOoDesktop() ).getFrames(); xFrames.append( aFrame ); } // Initializes the slot command execution environment. - xURLTransformer = (com.sun.star.util.XURLTransformer) UnoRuntime.queryInterface( + xURLTransformer = UnoRuntime.queryInterface( com.sun.star.util.XURLTransformer.class, xServiceFactory.createInstance( "com.sun.star.util.URLTransformer") ); @@ -603,8 +600,7 @@ public class OOoBean } // get XComponentLoader from frame - com.sun.star.frame.XComponentLoader xLoader = (com.sun.star.frame.XComponentLoader) - UnoRuntime.queryInterface( com.sun.star.frame.XComponentLoader.class, aFrame ); + com.sun.star.frame.XComponentLoader xLoader = UnoRuntime.queryInterface( com.sun.star.frame.XComponentLoader.class, aFrame ); if ( xLoader == null ) { throw new java.lang.RuntimeException( @@ -668,7 +664,7 @@ public class OOoBean // Get document's XModifiable interface if any. aDocument = new OfficeDocument( - (com.sun.star.frame.XModel) UnoRuntime.queryInterface( + UnoRuntime.queryInterface( com.sun.star.frame.XModel.class, xComponent ) ); bLoaded = true; } @@ -1088,12 +1084,12 @@ xLayoutManager.showElement("private:resource/menubar/menubar"); try { com.sun.star.beans.XPropertySet xPropSet = - (com.sun.star.beans.XPropertySet) UnoRuntime.queryInterface( - com.sun.star.beans.XPropertySet.class, aFrame ); + UnoRuntime.queryInterface( + com.sun.star.beans.XPropertySet.class, aFrame ); com.sun.star.frame.XLayoutManager xLayoutManager = - (com.sun.star.frame.XLayoutManager) UnoRuntime.queryInterface( - com.sun.star.frame.XLayoutManager.class, - xPropSet.getPropertyValue( "LayoutManager" ) ); + UnoRuntime.queryInterface( + com.sun.star.frame.XLayoutManager.class, + xPropSet.getPropertyValue( "LayoutManager" ) ); if ( bNewValue ) xLayoutManager.showElement( aResourceURL ); else diff --git a/bean/com/sun/star/comp/beans/OfficeDocument.java b/bean/com/sun/star/comp/beans/OfficeDocument.java index a7d01507cfc9..380bceac5c50 100644 --- a/bean/com/sun/star/comp/beans/OfficeDocument.java +++ b/bean/com/sun/star/comp/beans/OfficeDocument.java @@ -47,15 +47,12 @@ public class OfficeDocument extends Wrapper super( xModel ); this.xModel = xModel; - this.xModifiable = (com.sun.star.util.XModifiable) - UnoRuntime.queryInterface( - com.sun.star.util.XModifiable.class, xModel ); - this.xPrintable = (com.sun.star.view.XPrintable) - UnoRuntime.queryInterface( - com.sun.star.view.XPrintable.class, xModel ); - this.xStorable = (com.sun.star.frame.XStorable) - UnoRuntime.queryInterface( - com.sun.star.frame.XStorable.class, xModel ); + this.xModifiable = UnoRuntime.queryInterface( + com.sun.star.util.XModifiable.class, xModel ); + this.xPrintable = UnoRuntime.queryInterface( + com.sun.star.view.XPrintable.class, xModel ); + this.xStorable = UnoRuntime.queryInterface( + com.sun.star.frame.XStorable.class, xModel ); } //========================================================== diff --git a/bean/com/sun/star/comp/beans/Wrapper.java b/bean/com/sun/star/comp/beans/Wrapper.java index 4eefcf58cc64..9303c868105d 100644 --- a/bean/com/sun/star/comp/beans/Wrapper.java +++ b/bean/com/sun/star/comp/beans/Wrapper.java @@ -51,9 +51,8 @@ class Wrapper public Wrapper( com.sun.star.uno.XInterface xProxy ) { xQueryInterface = (com.sun.star.uno.IQueryInterface) xProxy; - xComponent = (com.sun.star.lang.XComponent) - UnoRuntime.queryInterface( - com.sun.star.lang.XComponent.class, xProxy ); + xComponent = UnoRuntime.queryInterface( + com.sun.star.lang.XComponent.class, xProxy ); } //============================================================== diff --git a/bean/qa/complex/bean/OOoBeanTest.java b/bean/qa/complex/bean/OOoBeanTest.java index a64499363877..8a394d2299d1 100644 --- a/bean/qa/complex/bean/OOoBeanTest.java +++ b/bean/qa/complex/bean/OOoBeanTest.java @@ -95,7 +95,7 @@ public class OOoBeanTest private String getText(OOoBean bean) throws Exception { - com.sun.star.frame.XModel model = (com.sun.star.frame.XModel)bean.getDocument(); + com.sun.star.frame.XModel model = bean.getDocument(); com.sun.star.text.XTextDocument myDoc = UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class, model); com.sun.star.text.XText xText = myDoc.getText(); diff --git a/bean/qa/complex/bean/WriterFrame.java b/bean/qa/complex/bean/WriterFrame.java index a12bf8fcb09c..525ddf78fc48 100644 --- a/bean/qa/complex/bean/WriterFrame.java +++ b/bean/qa/complex/bean/WriterFrame.java @@ -77,7 +77,7 @@ class WriterFrame extends java.awt.Frame public void setText(String s) throws Exception { - com.sun.star.frame.XModel model = (com.sun.star.frame.XModel)m_bean.getDocument(); + com.sun.star.frame.XModel model = m_bean.getDocument(); com.sun.star.text.XTextDocument myDoc = UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class, model); com.sun.star.text.XText xText = myDoc.getText(); @@ -88,7 +88,7 @@ class WriterFrame extends java.awt.Frame public String getText() throws Exception { - com.sun.star.frame.XModel model = (com.sun.star.frame.XModel)m_bean.getDocument(); + com.sun.star.frame.XModel model = m_bean.getDocument(); com.sun.star.text.XTextDocument myDoc = UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class, model); com.sun.star.text.XText xText = myDoc.getText(); @@ -112,7 +112,7 @@ class WriterFrame extends java.awt.Frame */ public void goToStart() throws Exception { - com.sun.star.frame.XModel xModel = (com.sun.star.frame.XModel)m_bean.getDocument(); + com.sun.star.frame.XModel xModel = m_bean.getDocument(); com.sun.star.frame.XController xController = xModel.getCurrentController(); com.sun.star.text.XTextViewCursorSupplier xVCSupplier = @@ -125,7 +125,7 @@ class WriterFrame extends java.awt.Frame public void pageDown() throws Exception { - com.sun.star.frame.XModel xModel = (com.sun.star.frame.XModel)m_bean.getDocument(); + com.sun.star.frame.XModel xModel = m_bean.getDocument(); com.sun.star.frame.XController xController = xModel.getCurrentController(); com.sun.star.text.XTextViewCursorSupplier xVCSupplier = |