Kaydet (Commit) e5a50239 authored tarafından Michael Stahl's avatar Michael Stahl

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
üst 0bb8bcf1
...@@ -57,17 +57,17 @@ public class FormTools { ...@@ -57,17 +57,17 @@ public class FormTools {
* @return the created XControlShape * @return the created XControlShape
*/ */
public static XControlShape createControlShape( XComponent oDoc, int height, 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(); Size size = new Size();
Point position = new Point(); Point position = new Point();
XControlShape oCShape = null; XControlShape oCShape = null;
XControlModel aControl = null; XControlModel aControl = null;
//get MSF
XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc ); XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc );
try{
Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape"); Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape");
Object aCon = oDocMSF.createInstance("com.sun.star.form.component."+kind); Object aCon = oDocMSF.createInstance("com.sun.star.form.component."+kind);
XPropertySet model_props = UnoRuntime.queryInterface(XPropertySet.class,aCon); XPropertySet model_props = UnoRuntime.queryInterface(XPropertySet.class,aCon);
...@@ -80,10 +80,6 @@ public class FormTools { ...@@ -80,10 +80,6 @@ public class FormTools {
position.Y = y; position.Y = y;
oCShape.setSize(size); oCShape.setSize(size);
oCShape.setPosition(position); oCShape.setPosition(position);
} catch ( com.sun.star.uno.Exception e ) {
// Some exception occurs.FAILED
System.out.println( "Couldn't create instance "+ e );
}
oCShape.setControl(aControl); oCShape.setControl(aControl);
...@@ -91,17 +87,17 @@ public class FormTools { ...@@ -91,17 +87,17 @@ public class FormTools {
} // finish createControlShape } // finish createControlShape
public static XControlShape createUnoControlShape( XComponent oDoc, int height, 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(); Size size = new Size();
Point position = new Point(); Point position = new Point();
XControlShape oCShape = null; XControlShape oCShape = null;
XControlModel aControl = null; XControlModel aControl = null;
//get MSF
XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc ); XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc );
try{
Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape"); Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape");
Object aCon = oDocMSF.createInstance("com.sun.star.form.component."+kind); Object aCon = oDocMSF.createInstance("com.sun.star.form.component."+kind);
XPropertySet model_props = UnoRuntime.queryInterface(XPropertySet.class,aCon); XPropertySet model_props = UnoRuntime.queryInterface(XPropertySet.class,aCon);
...@@ -115,29 +111,23 @@ public class FormTools { ...@@ -115,29 +111,23 @@ public class FormTools {
oCShape.setSize(size); oCShape.setSize(size);
oCShape.setPosition(position); oCShape.setPosition(position);
} catch ( com.sun.star.uno.Exception e ) {
// Some exception occurs.FAILED
System.out.println( "Couldn't create instance "+ e );
}
oCShape.setControl(aControl); oCShape.setControl(aControl);
return oCShape; return oCShape;
} // finish createControlShape } // finish createControlShape
public static XControlShape createControlShapeWithDefaultControl( XComponent oDoc, int height, 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(); Size size = new Size();
Point position = new Point(); Point position = new Point();
XControlShape oCShape = null; XControlShape oCShape = null;
XControlModel aControl = null; XControlModel aControl = null;
//get MSF
XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc ); XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc );
try{
Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape"); Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape");
Object aCon = oDocMSF.createInstance("com.sun.star.form.component."+kind); Object aCon = oDocMSF.createInstance("com.sun.star.form.component."+kind);
...@@ -150,30 +140,20 @@ public class FormTools { ...@@ -150,30 +140,20 @@ public class FormTools {
oCShape.setSize(size); oCShape.setSize(size);
oCShape.setPosition(position); oCShape.setPosition(position);
} catch ( com.sun.star.uno.Exception e ) {
// Some exception occurs.FAILED
System.out.println( "Couldn't create instance "+ e );
}
oCShape.setControl(aControl); oCShape.setControl(aControl);
return oCShape; return oCShape;
} // finish createControlShape } // 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; 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); "com.sun.star.form.component."+kind);
} catch ( Exception e ) {
// Some exception occurs.FAILED
System.out.println( "Couldn't create instance "+ kind + ": "+ e );
}
return oControl; return oControl;
} // finish createControl } // finish createControl
...@@ -193,46 +173,37 @@ public class FormTools { ...@@ -193,46 +173,37 @@ public class FormTools {
} //finish getIndexedForms } //finish getIndexedForms
public static void insertForm ( XComponent aDoc, XNameContainer Forms, public static void insertForm ( XComponent aDoc, XNameContainer Forms,
String aName ) { String aName )
try { throws com.sun.star.uno.Exception
{
XInterface oControl = createControl(aDoc, "Form"); XInterface oControl = createControl(aDoc, "Form");
XForm oForm = UnoRuntime.queryInterface(XForm.class, oControl); XForm oForm = UnoRuntime.queryInterface(XForm.class, oControl);
Forms.insertByName(aName,oForm); Forms.insertByName(aName,oForm);
} catch ( Exception e ) {
throw new IllegalArgumentException( "Couldn't insert Form", e );
}
} }
public static XControlShape insertControlShape( XComponent oDoc, int height, 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); XControlShape aShape = createControlShape(oDoc,height,width,x,y,kind);
XDrawPage oDP = DrawTools.getDrawPage(oDoc,0); XDrawPage oDP = DrawTools.getDrawPage(oDoc,0);
DrawTools.getShapes(oDP).add(aShape); DrawTools.getShapes(oDP).add(aShape);
return aShape; return aShape;
} }
public static XLoadable bindForm( XTextDocument aDoc ) { public static XLoadable bindForm( XTextDocument aDoc )
throws com.sun.star.uno.Exception
{
XLoadable formLoader = null; XLoadable formLoader = null;
try {
Object aForm = FormTools.getIndexedForms(WriterTools.getDrawPage(aDoc)).getByIndex(0); Object aForm = FormTools.getIndexedForms(WriterTools.getDrawPage(aDoc)).getByIndex(0);
XForm the_form = null; XForm the_form = null;
try {
the_form = (XForm) AnyConverter.toObject(new Type(XForm.class), aForm); 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); XPropertySet formProps = UnoRuntime.queryInterface(XPropertySet.class, the_form);
formProps.setPropertyValue("DataSourceName","Bibliography"); formProps.setPropertyValue("DataSourceName","Bibliography");
formProps.setPropertyValue("Command","biblio"); formProps.setPropertyValue("Command","biblio");
formProps.setPropertyValue("CommandType",Integer.valueOf(com.sun.star.sdb.CommandType.TABLE)); formProps.setPropertyValue("CommandType",Integer.valueOf(com.sun.star.sdb.CommandType.TABLE));
formLoader = UnoRuntime.queryInterface(XLoadable.class, the_form); formLoader = UnoRuntime.queryInterface(XLoadable.class, the_form);
}
catch (Exception ex) {
System.out.println("Exception: "+ex);
ex.printStackTrace(System.err);
}
return formLoader; return formLoader;
} }
...@@ -286,8 +257,9 @@ public class FormTools { ...@@ -286,8 +257,9 @@ public class FormTools {
return UnoRuntime.queryInterface(XLoadable.class, the_form); return UnoRuntime.queryInterface(XLoadable.class, the_form);
} }
public static void switchDesignOf(XMultiServiceFactory xMSF, XTextDocument aDoc) { public static void switchDesignOf(XMultiServiceFactory xMSF, XTextDocument aDoc)
try { throws com.sun.star.uno.Exception
{
com.sun.star.frame.XController aController = aDoc.getCurrentController(); com.sun.star.frame.XController aController = aDoc.getCurrentController();
com.sun.star.frame.XFrame aFrame = aController.getFrame(); com.sun.star.frame.XFrame aFrame = aController.getFrame();
com.sun.star.frame.XDispatchProvider aDispProv = UnoRuntime.queryInterface(com.sun.star.frame.XDispatchProvider.class,aFrame); com.sun.star.frame.XDispatchProvider aDispProv = UnoRuntime.queryInterface(com.sun.star.frame.XDispatchProvider.class,aFrame);
...@@ -310,10 +282,6 @@ public class FormTools { ...@@ -310,10 +282,6 @@ public class FormTools {
com.sun.star.beans.PropertyValue[] noArgs = new com.sun.star.beans.PropertyValue[0]; com.sun.star.beans.PropertyValue[] noArgs = new com.sun.star.beans.PropertyValue[0];
aDisp.dispatch(aURL, noArgs); aDisp.dispatch(aURL, noArgs);
util.utils.waitForEventIdle(xMSF); // async dispatch util.utils.waitForEventIdle(xMSF); // async dispatch
} catch (Exception e) {
System.out.println("******* Mist");
e.printStackTrace();
}
} }
} }
...@@ -68,7 +68,9 @@ public class _XControlShape extends MultiMethodTest { ...@@ -68,7 +68,9 @@ public class _XControlShape extends MultiMethodTest {
* <li> <code> getControl() </code> </li> * <li> <code> getControl() </code> </li>
* </ul> * </ul>
*/ */
public void _setControl() { public void _setControl()
throws com.sun.star.uno.Exception
{
requiredMethod("getControl()") ; requiredMethod("getControl()") ;
XInterface oNewControl = FormTools.createControl XInterface oNewControl = FormTools.createControl
......
...@@ -64,7 +64,9 @@ public class _XControlAccess extends MultiMethodTest { ...@@ -64,7 +64,9 @@ public class _XControlAccess extends MultiMethodTest {
* is returned. <p> * is returned. <p>
* @throws StatusException If the relation was not found. * @throws StatusException If the relation was not found.
*/ */
public void _getControl(){ public void _getControl()
throws com.sun.star.uno.Exception
{
boolean bResult = true; boolean bResult = true;
try { try {
XComponent oDoc = (XComponent)tEnv.getObjRelation("DOCUMENT"); XComponent oDoc = (XComponent)tEnv.getObjRelation("DOCUMENT");
......
...@@ -117,7 +117,9 @@ public class OFormsCollection extends TestCase { ...@@ -117,7 +117,9 @@ public class OFormsCollection extends TestCase {
*/ */
@Override @Override
protected TestEnvironment createTestEnvironment(TestParameters Param, protected TestEnvironment createTestEnvironment(TestParameters Param,
PrintWriter log) { PrintWriter log)
throws com.sun.star.uno.Exception
{
XInterface oObj = null; XInterface oObj = null;
XDrawPage oDP = null; XDrawPage oDP = null;
......
...@@ -64,7 +64,9 @@ public class OScrollBarModel extends TestCase { ...@@ -64,7 +64,9 @@ public class OScrollBarModel extends TestCase {
} }
@Override @Override
protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log)
throws com.sun.star.uno.Exception
{
XInterface oObj = null; XInterface oObj = null;
......
...@@ -69,8 +69,9 @@ public class OSpinButtonModel extends TestCase { ...@@ -69,8 +69,9 @@ public class OSpinButtonModel extends TestCase {
* Adds spin button into text and retrieves it's control model. * Adds spin button into text and retrieves it's control model.
*/ */
@Override @Override
protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log)
throws com.sun.star.uno.Exception
{
XInterface oObj = null; XInterface oObj = null;
XControlShape aShape = FormTools.createControlShape( XControlShape aShape = FormTools.createControlShape(
......
...@@ -62,7 +62,9 @@ public class AccessibleControlShape extends TestCase { ...@@ -62,7 +62,9 @@ public class AccessibleControlShape extends TestCase {
@Override @Override
protected TestEnvironment createTestEnvironment protected TestEnvironment createTestEnvironment
(TestParameters tParam, PrintWriter log) { (TestParameters tParam, PrintWriter log)
throws com.sun.star.uno.Exception
{
XInterface oObj = null; XInterface oObj = null;
......
...@@ -116,7 +116,9 @@ public class SwXTextView extends TestCase { ...@@ -116,7 +116,9 @@ public class SwXTextView extends TestCase {
*/ */
@Override @Override
public TestEnvironment createTestEnvironment( TestParameters tParam, public TestEnvironment createTestEnvironment( TestParameters tParam,
PrintWriter log )throws StatusException { PrintWriter log )
throws com.sun.star.uno.Exception
{
// creation of testobject here // creation of testobject here
......
...@@ -59,7 +59,9 @@ public class TabController extends TestCase { ...@@ -59,7 +59,9 @@ public class TabController extends TestCase {
@Override @Override
public TestEnvironment createTestEnvironment(TestParameters param, public TestEnvironment createTestEnvironment(TestParameters param,
PrintWriter log) { PrintWriter log)
throws com.sun.star.uno.Exception
{
XInterface oObj = null; XInterface oObj = null;
XControl xCtrl1 = null; XControl xCtrl1 = null;
XTabControllerModel tabCtrlModel = null; XTabControllerModel tabCtrlModel = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment