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 {
* @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);
......@@ -80,10 +80,6 @@ public class FormTools {
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 );
}
oCShape.setControl(aControl);
......@@ -91,17 +87,17 @@ 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);
......@@ -115,29 +111,23 @@ public class FormTools {
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 );
}
oCShape.setControl(aControl);
return oCShape;
} // 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);
......@@ -150,30 +140,20 @@ public class FormTools {
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 );
}
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 );
try{
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 {
String aName )
throws com.sun.star.uno.Exception
{
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 );
}
}
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);
}
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();
}
}
}
......@@ -68,7 +68,9 @@ public class _XControlShape extends MultiMethodTest {
* <li> <code> getControl() </code> </li>
* </ul>
*/
public void _setControl() {
public void _setControl()
throws com.sun.star.uno.Exception
{
requiredMethod("getControl()") ;
XInterface oNewControl = FormTools.createControl
......
......@@ -64,7 +64,9 @@ public class _XControlAccess extends MultiMethodTest {
* is returned. <p>
* @throws StatusException If the relation was not found.
*/
public void _getControl(){
public void _getControl()
throws com.sun.star.uno.Exception
{
boolean bResult = true;
try {
XComponent oDoc = (XComponent)tEnv.getObjRelation("DOCUMENT");
......
......@@ -117,7 +117,9 @@ public class OFormsCollection extends TestCase {
*/
@Override
protected TestEnvironment createTestEnvironment(TestParameters Param,
PrintWriter log) {
PrintWriter log)
throws com.sun.star.uno.Exception
{
XInterface oObj = null;
XDrawPage oDP = null;
......
......@@ -64,7 +64,9 @@ public class OScrollBarModel extends TestCase {
}
@Override
protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log)
throws com.sun.star.uno.Exception
{
XInterface oObj = null;
......
......@@ -69,8 +69,9 @@ public class OSpinButtonModel extends TestCase {
* Adds spin button into text and retrieves it's control model.
*/
@Override
protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log)
throws com.sun.star.uno.Exception
{
XInterface oObj = null;
XControlShape aShape = FormTools.createControlShape(
......
......@@ -62,7 +62,9 @@ public class AccessibleControlShape extends TestCase {
@Override
protected TestEnvironment createTestEnvironment
(TestParameters tParam, PrintWriter log) {
(TestParameters tParam, PrintWriter log)
throws com.sun.star.uno.Exception
{
XInterface oObj = null;
......
......@@ -116,7 +116,9 @@ public class SwXTextView extends TestCase {
*/
@Override
public TestEnvironment createTestEnvironment( TestParameters tParam,
PrintWriter log )throws StatusException {
PrintWriter log )
throws com.sun.star.uno.Exception
{
// creation of testobject here
......
......@@ -59,7 +59,9 @@ public class TabController extends TestCase {
@Override
public TestEnvironment createTestEnvironment(TestParameters param,
PrintWriter log) {
PrintWriter log)
throws com.sun.star.uno.Exception
{
XInterface oObj = null;
XControl xCtrl1 = 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