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
This commit is contained in:
parent
0bb8bcf1f8
commit
e5a5023924
9 changed files with 98 additions and 115 deletions
|
@ -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 );
|
||||
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 );
|
||||
}
|
||||
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 );
|
||||
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);
|
||||
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);
|
||||
|
||||
|
||||
} 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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -121,4 +123,4 @@ public class TabController extends TestCase {
|
|||
|
||||
return tEnv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue