Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3568

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/68/3568/1

Java cleanup - use generics to reduce casting

More queryInterface related cleanup.

Change-Id: I97d064c425389e687c6f0fbc3a962080f46dd511
---
M odk/examples/DevelopersGuide/Forms/ButtonOperator.java
M odk/examples/DevelopersGuide/Forms/DocumentViewHelper.java
M odk/examples/DevelopersGuide/Forms/FLTools.java
M odk/examples/DevelopersGuide/Forms/SalesFilter.java
M odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OfficeConnect.java
5 files changed, 16 insertions(+), 16 deletions(-)



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 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 @@
         @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 @@
         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 @@
      */
     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 @@
     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 @@
     }
 
     /* ------------------------------------------------------------------ */
-    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 @@
     /* ------------------------------------------------------------------ */
     /** 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 @@
     */
     static XPropertySet getParent( Object aComponent )
     {
-        return (XPropertySet)getParent( aComponent, XPropertySet.class );
+        return getParent( aComponent, XPropertySet.class );
     }
 
     /* ------------------------------------------------------------------ */
@@ -188,7 +188,7 @@
     /* ------------------------------------------------------------------ */
     /** 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 @@
             // 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 @@
      * @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 @@
      * @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,

-- 
To view, visit https://gerrit.libreoffice.org/3568
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I97d064c425389e687c6f0fbc3a962080f46dd511
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Noel Grandin <noelgrandin@gmail.com>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.