odk/examples/DevelopersGuide/Forms/ButtonOperator.java | 2 - odk/examples/DevelopersGuide/Forms/DocumentViewHelper.java | 10 ++++---- odk/examples/DevelopersGuide/Forms/FLTools.java | 6 ++--- odk/examples/DevelopersGuide/Forms/SalesFilter.java | 2 - odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OfficeConnect.java | 12 +++++----- 5 files changed, 16 insertions(+), 16 deletions(-)
New commits: commit bc8b419b0dc8bffb70accce443f4f46aa48cbd58 Author: Noel Grandin <n...@peralex.com> Date: Tue Apr 23 09:18:08 2013 +0200 Java cleanup - use generics to reduce casting More queryInterface related cleanup. Change-Id: I97d064c425389e687c6f0fbc3a962080f46dd511 Reviewed-on: https://gerrit.libreoffice.org/3568 Reviewed-by: Fridrich Strba <fridr...@documentfoundation.org> Tested-by: Fridrich Strba <fridr...@documentfoundation.org> diff --git a/odk/examples/DevelopersGuide/Forms/ButtonOperator.java b/odk/examples/DevelopersGuide/Forms/ButtonOperator.java index 113b704..a447381 100644 --- a/odk/examples/DevelopersGuide/Forms/ButtonOperator.java +++ b/odk/examples/DevelopersGuide/Forms/ButtonOperator.java @@ -148,7 +148,7 @@ public class ButtonOperator implements XActionListener, XFeatureInvalidation public void actionPerformed( ActionEvent aEvent ) throws com.sun.star.uno.RuntimeException { // get the model's name - XPropertySet buttonModel = (XPropertySet)FLTools.getModel( aEvent.Source, XPropertySet.class ); + XPropertySet buttonModel = FLTools.getModel( aEvent.Source, XPropertySet.class ); try { short formFeature = getAssociatedFormFeature( buttonModel ); diff --git a/odk/examples/DevelopersGuide/Forms/DocumentViewHelper.java b/odk/examples/DevelopersGuide/Forms/DocumentViewHelper.java index 25308ea..09befbe 100644 --- a/odk/examples/DevelopersGuide/Forms/DocumentViewHelper.java +++ b/odk/examples/DevelopersGuide/Forms/DocumentViewHelper.java @@ -69,7 +69,7 @@ class DocumentViewHelper @param aInterfaceClass the class of the interface which shall be returned */ - public Object get( Class aInterfaceClass ) + public <T> T get( Class<T> aInterfaceClass ) { return UnoRuntime.queryInterface( aInterfaceClass, m_controller ); } @@ -88,7 +88,7 @@ class DocumentViewHelper XDispatch xReturn = null; // go get the current view - XController xController = (XController)get( XController.class ); + XController xController = get( XController.class ); // go get the dispatch provider of it's frame XDispatchProvider xProvider = UnoRuntime.queryInterface( XDispatchProvider.class, xController.getFrame() ); @@ -119,7 +119,7 @@ class DocumentViewHelper */ public XFormController getFormController( Object _form ) { - XFormLayerAccess formLayer = (XFormLayerAccess)get( XFormLayerAccess.class ); + XFormLayerAccess formLayer = get( XFormLayerAccess.class ); return formLayer.getFormController( UnoRuntime.queryInterface( XForm.class, _form ) ); } @@ -133,7 +133,7 @@ class DocumentViewHelper public XControl getFormControl( XControlModel xModel ) throws com.sun.star.uno.Exception { // the current view of the document - XControlAccess xCtrlAcc = (XControlAccess)get( XControlAccess.class ); + XControlAccess xCtrlAcc = get( XControlAccess.class ); // delegate the task of looking for the control return xCtrlAcc.getControl( xModel ); } @@ -146,7 +146,7 @@ class DocumentViewHelper } /* ------------------------------------------------------------------ */ - public Object getFormControl( Object aModel, Class aInterfaceClass ) throws com.sun.star.uno.Exception + public <T> T getFormControl( Object aModel, Class<T> aInterfaceClass ) throws com.sun.star.uno.Exception { XControlModel xModel = UnoRuntime.queryInterface( XControlModel.class, aModel ); return UnoRuntime.queryInterface( aInterfaceClass, getFormControl( xModel ) ); diff --git a/odk/examples/DevelopersGuide/Forms/FLTools.java b/odk/examples/DevelopersGuide/Forms/FLTools.java index 1438166..36d4fb3 100644 --- a/odk/examples/DevelopersGuide/Forms/FLTools.java +++ b/odk/examples/DevelopersGuide/Forms/FLTools.java @@ -159,7 +159,7 @@ public class FLTools /* ------------------------------------------------------------------ */ /** retrieves the parent of the given object */ - static Object getParent( Object aComponent, Class aInterfaceClass ) + static <T> T getParent( Object aComponent, Class<T> aInterfaceClass ) { XChild xAsChild = UnoRuntime.queryInterface( XChild.class, aComponent ); @@ -171,7 +171,7 @@ public class FLTools */ static XPropertySet getParent( Object aComponent ) { - return (XPropertySet)getParent( aComponent, XPropertySet.class ); + return getParent( aComponent, XPropertySet.class ); } /* ------------------------------------------------------------------ */ @@ -188,7 +188,7 @@ public class FLTools /* ------------------------------------------------------------------ */ /** get's the XControlModel for a control */ - static public Object getModel( Object aControl, Class aInterfaceClass ) + static public <T> T getModel( Object aControl, Class<T> aInterfaceClass ) { XControl xControl = UnoRuntime.queryInterface( XControl.class, aControl ); diff --git a/odk/examples/DevelopersGuide/Forms/SalesFilter.java b/odk/examples/DevelopersGuide/Forms/SalesFilter.java index df7e96a..e4c5161 100644 --- a/odk/examples/DevelopersGuide/Forms/SalesFilter.java +++ b/odk/examples/DevelopersGuide/Forms/SalesFilter.java @@ -107,7 +107,7 @@ class SalesFilter implements XActionListener, XPropertyChangeListener, XResetLis // for the button, we can add to the control only, not to the model // - clicking a button is something which happens on the _control_. DocumentViewHelper aView = m_aDocument.getCurrentView(); - XButton xButton = (XButton)aView.getFormControl( m_xApplyFilter, XButton.class ); + XButton xButton = aView.getFormControl( m_xApplyFilter, XButton.class ); xButton.addActionListener( this ); } catch ( com.sun.star.uno.Exception e ) diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OfficeConnect.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OfficeConnect.java index 4af8213..f7cf1d3 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OfficeConnect.java +++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OfficeConnect.java @@ -126,10 +126,10 @@ public class OfficeConnect * @param sServiceSpecifier name of service which should be created * @return the new created service object */ - public static synchronized Object createRemoteInstance( - Class aType, String sServiceSpecifier) + public static synchronized <T> T createRemoteInstance( + Class<T> aType, String sServiceSpecifier) { - Object aResult = null; + T aResult = null; try { aResult = UnoRuntime.queryInterface(aType, @@ -157,10 +157,10 @@ public class OfficeConnect * @param sServiceSpecifier Description of Parameter * @return the new create service object */ - public static synchronized Object createRemoteInstanceWithArguments( - Class aType, String sServiceSpecifier, Any[] lArguments) + public static synchronized <T> T createRemoteInstanceWithArguments( + Class<T> aType, String sServiceSpecifier, Any[] lArguments) { - Object aResult = null; + T aResult = null; try { aResult = UnoRuntime.queryInterface(aType, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits