diff options
author | Michael Stahl <mstahl@redhat.com> | 2017-01-16 15:24:56 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2017-01-16 15:37:45 +0100 |
commit | e5a502392431a49fe8c60eccf75fc150178f6c07 (patch) | |
tree | 908c9e7549c22ca09a92910ba44b20d255d75080 /qadevOOo/runner | |
parent | 0bb8bcf1f8ea7b0e54eb52dc53b986d0485fa07c (diff) |
qadevOOo: remove silly exception catching from util.FormTools
What's the point of catching an exception and then continuing onwards in
a unit test?
Change-Id: I100dfcaa9a4fdd5398cf4ac38426ec4397451b8e
Diffstat (limited to 'qadevOOo/runner')
-rw-r--r-- | qadevOOo/runner/util/FormTools.java | 180 |
1 files changed, 74 insertions, 106 deletions
diff --git a/qadevOOo/runner/util/FormTools.java b/qadevOOo/runner/util/FormTools.java index dd68221cdf2e..2189612cd171 100644 --- a/qadevOOo/runner/util/FormTools.java +++ b/qadevOOo/runner/util/FormTools.java @@ -57,33 +57,29 @@ public class FormTools { * @return the created XControlShape */ public static XControlShape createControlShape( XComponent oDoc, int height, - int width, int x, int y, String kind ) { + int width, int x, int y, String kind ) + throws com.sun.star.uno.Exception + { Size size = new Size(); Point position = new Point(); XControlShape oCShape = null; XControlModel aControl = null; - //get MSF XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc ); - try{ - Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape"); - Object aCon = oDocMSF.createInstance("com.sun.star.form.component."+kind); - XPropertySet model_props = UnoRuntime.queryInterface(XPropertySet.class,aCon); - model_props.setPropertyValue("DefaultControl","com.sun.star.form.control."+kind); - aControl = UnoRuntime.queryInterface( XControlModel.class, aCon ); - oCShape = UnoRuntime.queryInterface( XControlShape.class, oInt ); - size.Height = height; - size.Width = width; - position.X = x; - position.Y = y; - oCShape.setSize(size); - oCShape.setPosition(position); - } catch ( com.sun.star.uno.Exception e ) { - // Some exception occurs.FAILED - System.out.println( "Couldn't create instance "+ e ); - } + Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape"); + Object aCon = oDocMSF.createInstance("com.sun.star.form.component."+kind); + XPropertySet model_props = UnoRuntime.queryInterface(XPropertySet.class,aCon); + model_props.setPropertyValue("DefaultControl","com.sun.star.form.control."+kind); + aControl = UnoRuntime.queryInterface( XControlModel.class, aCon ); + oCShape = UnoRuntime.queryInterface( XControlShape.class, oInt ); + size.Height = height; + size.Width = width; + position.X = x; + position.Y = y; + oCShape.setSize(size); + oCShape.setPosition(position); oCShape.setControl(aControl); @@ -91,35 +87,29 @@ public class FormTools { } // finish createControlShape public static XControlShape createUnoControlShape( XComponent oDoc, int height, - int width, int x, int y, String kind, String defControl ) { + int width, int x, int y, String kind, String defControl ) + throws com.sun.star.uno.Exception + { Size size = new Size(); Point position = new Point(); XControlShape oCShape = null; XControlModel aControl = null; - //get MSF - XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc ); - - try{ - Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape"); - Object aCon = oDocMSF.createInstance("com.sun.star.form.component."+kind); - XPropertySet model_props = UnoRuntime.queryInterface(XPropertySet.class,aCon); - model_props.setPropertyValue("DefaultControl","com.sun.star.awt."+defControl); - aControl = UnoRuntime.queryInterface( XControlModel.class, aCon ); - oCShape = UnoRuntime.queryInterface( XControlShape.class, oInt ); - size.Height = height; - size.Width = width; - position.X = x; - position.Y = y; - oCShape.setSize(size); - oCShape.setPosition(position); - - - } catch ( com.sun.star.uno.Exception e ) { - // Some exception occurs.FAILED - System.out.println( "Couldn't create instance "+ e ); - } + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc ); + + Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape"); + Object aCon = oDocMSF.createInstance("com.sun.star.form.component."+kind); + XPropertySet model_props = UnoRuntime.queryInterface(XPropertySet.class,aCon); + model_props.setPropertyValue("DefaultControl","com.sun.star.awt."+defControl); + aControl = UnoRuntime.queryInterface( XControlModel.class, aCon ); + oCShape = UnoRuntime.queryInterface( XControlShape.class, oInt ); + size.Height = height; + size.Width = width; + position.X = x; + position.Y = y; + oCShape.setSize(size); + oCShape.setPosition(position); oCShape.setControl(aControl); @@ -127,53 +117,43 @@ public class FormTools { } // finish createControlShape public static XControlShape createControlShapeWithDefaultControl( XComponent oDoc, int height, - int width, int x, int y, String kind ) { + int width, int x, int y, String kind ) + throws com.sun.star.uno.Exception + { Size size = new Size(); Point position = new Point(); XControlShape oCShape = null; XControlModel aControl = null; - //get MSF - XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc ); - - try{ - Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape"); - Object aCon = oDocMSF.createInstance("com.sun.star.form.component."+kind); - - aControl = UnoRuntime.queryInterface( XControlModel.class, aCon ); - oCShape = UnoRuntime.queryInterface( XControlShape.class, oInt ); - size.Height = height; - size.Width = width; - position.X = x; - position.Y = y; - oCShape.setSize(size); - oCShape.setPosition(position); + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc ); + Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape"); + Object aCon = oDocMSF.createInstance("com.sun.star.form.component."+kind); - } catch ( com.sun.star.uno.Exception e ) { - // Some exception occurs.FAILED - System.out.println( "Couldn't create instance "+ e ); - } + aControl = UnoRuntime.queryInterface( XControlModel.class, aCon ); + oCShape = UnoRuntime.queryInterface( XControlShape.class, oInt ); + size.Height = height; + size.Width = width; + position.X = x; + position.Y = y; + oCShape.setSize(size); + oCShape.setPosition(position); oCShape.setControl(aControl); return oCShape; } // finish createControlShape - public static XInterface createControl( XComponent oDoc, String kind ) { - + public static XInterface createControl( XComponent oDoc, String kind ) + throws com.sun.star.uno.Exception + { XInterface oControl = null; - XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc ); + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc ); - try{ - oControl = (XInterface) oDocMSF.createInstance( + oControl = (XInterface) oDocMSF.createInstance( "com.sun.star.form.component."+kind); - } catch ( Exception e ) { - // Some exception occurs.FAILED - System.out.println( "Couldn't create instance "+ kind + ": "+ e ); - } return oControl; } // finish createControl @@ -193,46 +173,37 @@ public class FormTools { } //finish getIndexedForms public static void insertForm ( XComponent aDoc, XNameContainer Forms, - String aName ) { - try { - XInterface oControl = createControl(aDoc, "Form"); - XForm oForm = UnoRuntime.queryInterface(XForm.class, oControl); - Forms.insertByName(aName,oForm); - } catch ( Exception e ) { - throw new IllegalArgumentException( "Couldn't insert Form", e ); - } + String aName ) + throws com.sun.star.uno.Exception + { + XInterface oControl = createControl(aDoc, "Form"); + XForm oForm = UnoRuntime.queryInterface(XForm.class, oControl); + Forms.insertByName(aName,oForm); } public static XControlShape insertControlShape( XComponent oDoc, int height, - int width, int x, int y, String kind ) { - + int width, int x, int y, String kind ) + throws com.sun.star.uno.Exception + { XControlShape aShape = createControlShape(oDoc,height,width,x,y,kind); XDrawPage oDP = DrawTools.getDrawPage(oDoc,0); DrawTools.getShapes(oDP).add(aShape); return aShape; } - public static XLoadable bindForm( XTextDocument aDoc ) { + public static XLoadable bindForm( XTextDocument aDoc ) + throws com.sun.star.uno.Exception + { XLoadable formLoader = null; - try { - Object aForm = FormTools.getIndexedForms(WriterTools.getDrawPage(aDoc)).getByIndex(0); - XForm the_form = null; - try { - the_form = (XForm) AnyConverter.toObject(new Type(XForm.class), aForm); - } catch (com.sun.star.lang.IllegalArgumentException iae) { - System.out.println("### Couldn't convert Any"); - } - XPropertySet formProps = UnoRuntime.queryInterface(XPropertySet.class, the_form); - formProps.setPropertyValue("DataSourceName","Bibliography"); - formProps.setPropertyValue("Command","biblio"); - formProps.setPropertyValue("CommandType",Integer.valueOf(com.sun.star.sdb.CommandType.TABLE)); - formLoader = UnoRuntime.queryInterface(XLoadable.class, the_form); - } - catch (Exception ex) { - System.out.println("Exception: "+ex); - ex.printStackTrace(System.err); - } + Object aForm = FormTools.getIndexedForms(WriterTools.getDrawPage(aDoc)).getByIndex(0); + XForm the_form = null; + the_form = (XForm) AnyConverter.toObject(new Type(XForm.class), aForm); + XPropertySet formProps = UnoRuntime.queryInterface(XPropertySet.class, the_form); + formProps.setPropertyValue("DataSourceName","Bibliography"); + formProps.setPropertyValue("Command","biblio"); + formProps.setPropertyValue("CommandType",Integer.valueOf(com.sun.star.sdb.CommandType.TABLE)); + formLoader = UnoRuntime.queryInterface(XLoadable.class, the_form); return formLoader; } @@ -286,8 +257,9 @@ public class FormTools { return UnoRuntime.queryInterface(XLoadable.class, the_form); } - public static void switchDesignOf(XMultiServiceFactory xMSF, XTextDocument aDoc) { - try { + public static void switchDesignOf(XMultiServiceFactory xMSF, XTextDocument aDoc) + throws com.sun.star.uno.Exception + { com.sun.star.frame.XController aController = aDoc.getCurrentController(); com.sun.star.frame.XFrame aFrame = aController.getFrame(); com.sun.star.frame.XDispatchProvider aDispProv = UnoRuntime.queryInterface(com.sun.star.frame.XDispatchProvider.class,aFrame); @@ -310,10 +282,6 @@ public class FormTools { com.sun.star.beans.PropertyValue[] noArgs = new com.sun.star.beans.PropertyValue[0]; aDisp.dispatch(aURL, noArgs); util.utils.waitForEventIdle(xMSF); // async dispatch - } catch (Exception e) { - System.out.println("******* Mist"); - e.printStackTrace(); - } } } |