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 <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
This commit is contained in:
committed by
Fridrich Strba
parent
ada0298167
commit
bc8b419b0d
@@ -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 );
|
||||
|
@@ -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 ) );
|
||||
|
@@ -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 );
|
||||
|
@@ -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 )
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user