diff options
author | Stephan Wunderlich <sw@openoffice.org> | 2003-02-04 12:26:12 +0000 |
---|---|---|
committer | Stephan Wunderlich <sw@openoffice.org> | 2003-02-04 12:26:12 +0000 |
commit | 61a89771d57e58d70e1d675047862846b94b1a88 (patch) | |
tree | 37d5a9c562920162ec83d6c9cbc47f6b1d676b7c /qadevOOo/tests/java/mod | |
parent | 840c50f599e3c1748e4b238d2599a4e20e2ec9f8 (diff) |
CHG: using AnyConverter instead of simple cast
Diffstat (limited to 'qadevOOo/tests/java/mod')
7 files changed, 81 insertions, 35 deletions
diff --git a/qadevOOo/tests/java/mod/_sc/ScDrawPageObj.java b/qadevOOo/tests/java/mod/_sc/ScDrawPageObj.java index c9a5497131b5..87d4b70e97b5 100644 --- a/qadevOOo/tests/java/mod/_sc/ScDrawPageObj.java +++ b/qadevOOo/tests/java/mod/_sc/ScDrawPageObj.java @@ -2,9 +2,9 @@ * * $RCSfile: ScDrawPageObj.java,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change:$Date: 2003-01-27 18:16:31 $ + * last change:$Date: 2003-02-04 13:05:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -79,6 +79,9 @@ import util.InstCreator; import util.SOfficeFactory; import util.ShapeDsc; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; + public class ScDrawPageObj extends TestCase { XSpreadsheetDocument xDoc = null; @@ -148,7 +151,8 @@ public class ScDrawPageObj extends TestCase { oDP = (XDrawPages) oDPS.getDrawPages(); oDP.insertNewByIndex(1); oDP.insertNewByIndex(2); - oObj = (XDrawPage) oDP.getByIndex(0); + oObj = (XDrawPage) AnyConverter.toObject( + new Type(XDrawPage.class),oDP.getByIndex(0)); SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); @@ -165,6 +169,10 @@ public class ScDrawPageObj extends TestCase { log.println("Couldn't create insance"); e.printStackTrace(log); throw new StatusException("Can't create enviroment", e) ; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("Couldn't create insance"); + e.printStackTrace(log); + throw new StatusException("Can't create enviroment", e) ; } // create test environment here diff --git a/qadevOOo/tests/java/mod/_sc/ScIndexEnumeration_SubTotalFieldsEnumeration.java b/qadevOOo/tests/java/mod/_sc/ScIndexEnumeration_SubTotalFieldsEnumeration.java index 390733f26412..5f139c543c9a 100644 --- a/qadevOOo/tests/java/mod/_sc/ScIndexEnumeration_SubTotalFieldsEnumeration.java +++ b/qadevOOo/tests/java/mod/_sc/ScIndexEnumeration_SubTotalFieldsEnumeration.java @@ -2,9 +2,9 @@ * * $RCSfile: ScIndexEnumeration_SubTotalFieldsEnumeration.java,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change:$Date: 2003-01-27 18:16:21 $ + * last change:$Date: 2003-02-04 13:08:52 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -81,6 +81,9 @@ import lib.TestEnvironment; import lib.TestParameters; import util.SOfficeFactory; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; + public class ScIndexEnumeration_SubTotalFieldsEnumeration extends TestCase { public XSpreadsheetDocument xSpreadsheetDoc; @@ -124,13 +127,17 @@ public class ScIndexEnumeration_SubTotalFieldsEnumeration extends TestCase { XIndexAccess oIndexAccess = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets); try { - oSheet = (XSpreadsheet)oIndexAccess.getByIndex(0); + oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),oIndexAccess.getByIndex(0)); } catch (com.sun.star.lang.WrappedTargetException e) { e.printStackTrace(log); throw new StatusException( "Couldn't get a spreadsheet", e); } catch (com.sun.star.lang.IndexOutOfBoundsException e) { e.printStackTrace(log); throw new StatusException( "Couldn't get a spreadsheet", e); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + throw new StatusException( "Couldn't get a spreadsheet", e); } XSubTotalCalculatable xSTC = (XSubTotalCalculatable) diff --git a/qadevOOo/tests/java/mod/_sc/ScIndexEnumeration_TextFieldEnumeration.java b/qadevOOo/tests/java/mod/_sc/ScIndexEnumeration_TextFieldEnumeration.java index 6714ac371547..c3138ca1a140 100644 --- a/qadevOOo/tests/java/mod/_sc/ScIndexEnumeration_TextFieldEnumeration.java +++ b/qadevOOo/tests/java/mod/_sc/ScIndexEnumeration_TextFieldEnumeration.java @@ -2,9 +2,9 @@ * * $RCSfile: ScIndexEnumeration_TextFieldEnumeration.java,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change:$Date: 2003-01-27 18:16:19 $ + * last change:$Date: 2003-02-04 13:11:43 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -80,6 +80,9 @@ import lib.TestEnvironment; import lib.TestParameters; import util.SOfficeFactory; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; + /** * Test for object that represents enumeration of a colection * of text fields in a cell of a spreadsheet. <p> @@ -155,7 +158,8 @@ public class ScIndexEnumeration_TextFieldEnumeration extends TestCase { XSpreadsheets oSheets = xSheetDoc.getSheets() ; XIndexAccess oIndexSheets = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, oSheets); - XSpreadsheet oSheet = (XSpreadsheet)oIndexSheets.getByIndex(0); + XSpreadsheet oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0)); XCell oCell = oSheet.getCellByPosition(2,3); oText = (XText)UnoRuntime.queryInterface(XText.class, oCell); diff --git a/qadevOOo/tests/java/mod/_sc/ScLabelRangeObj.java b/qadevOOo/tests/java/mod/_sc/ScLabelRangeObj.java index 0b8b93ea667b..1583c449458c 100644 --- a/qadevOOo/tests/java/mod/_sc/ScLabelRangeObj.java +++ b/qadevOOo/tests/java/mod/_sc/ScLabelRangeObj.java @@ -2,9 +2,9 @@ * * $RCSfile: ScLabelRangeObj.java,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change:$Date: 2003-01-27 18:16:19 $ + * last change:$Date: 2003-02-04 13:15:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -76,6 +76,9 @@ import lib.TestEnvironment; import lib.TestParameters; import util.SOfficeFactory; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; + /** * Test for object which is represented by service * <code>com.sun.star.sheet.LabelRange</code>. <p> @@ -129,8 +132,7 @@ public class ScLabelRangeObj extends TestCase { * @see com.sun.star.sheet.LabelRange * @see com.sun.star.sheet.XLabelRanges */ - public synchronized TestEnvironment createTestEnvironment( - TestParameters Param, PrintWriter log) throws StatusException { + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { XInterface oObj = null; @@ -151,7 +153,8 @@ public class ScLabelRangeObj extends TestCase { CellRangeAddress aRange1 = new CellRangeAddress((short)0, 0, 0, 0, 1); lRanges.addNew(aRange1, aRange2); - oObj = (XLabelRange) lRanges.getByIndex(0); + oObj = (XLabelRange) AnyConverter.toObject( + new Type(XLabelRange.class),lRanges.getByIndex(0)); } catch (com.sun.star.lang.WrappedTargetException e) { e.printStackTrace(log) ; throw new StatusException( @@ -164,6 +167,10 @@ public class ScLabelRangeObj extends TestCase { e.printStackTrace(log) ; throw new StatusException( "Error getting test object from spreadsheet document",e) ; + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log) ; + throw new StatusException( + "Error getting test object from spreadsheet document",e) ; } log.println("creating a new environment for object"); diff --git a/qadevOOo/tests/java/mod/_sc/ScModelObj.java b/qadevOOo/tests/java/mod/_sc/ScModelObj.java index 82755a730b5a..8e09b372745f 100644 --- a/qadevOOo/tests/java/mod/_sc/ScModelObj.java +++ b/qadevOOo/tests/java/mod/_sc/ScModelObj.java @@ -2,9 +2,9 @@ * * $RCSfile: ScModelObj.java,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change:$Date: 2003-01-27 18:16:18 $ + * last change:$Date: 2003-02-04 13:18:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -79,6 +79,9 @@ import lib.TestEnvironment; import lib.TestParameters; import util.SOfficeFactory; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; + /** * Test for object which is represented by service * <code>com.sun.star.sheet.SpreadsheetDocument</code>. <p> @@ -149,8 +152,7 @@ public class ScModelObj extends TestCase { * </ul> * @see */ - public synchronized TestEnvironment createTestEnvironment( - TestParameters Param, PrintWriter log) throws StatusException { + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { // creation of the testobject here // first we write what we are intend to do to log file @@ -202,7 +204,8 @@ public class ScModelObj extends TestCase { XSpreadsheets oSheets = xSpreadsheetDoc.getSheets() ; XIndexAccess oIndexSheets = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, oSheets); - XSpreadsheet oSheet = (XSpreadsheet) oIndexSheets.getByIndex(0); + XSpreadsheet oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0)); log.println("Getting a cell from sheet") ; toSel = oSheet.getCellByPosition(2, 3) ; @@ -214,6 +217,10 @@ public class ScModelObj extends TestCase { e.printStackTrace(log) ; throw new StatusException( "Error getting cell object from spreadsheet document", e); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log) ; + throw new StatusException( + "Error getting cell object from spreadsheet document", e); } log.println( "Adding SelectionSupplier and Shape to select for XModel"); @@ -227,5 +234,4 @@ public class ScModelObj extends TestCase { } -} // finish class ScModelObj - +} // finish class ScModelObj
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_sc/ScNamedRangeObj.java b/qadevOOo/tests/java/mod/_sc/ScNamedRangeObj.java index 5e0e24d4dad3..1669d4b819a2 100644 --- a/qadevOOo/tests/java/mod/_sc/ScNamedRangeObj.java +++ b/qadevOOo/tests/java/mod/_sc/ScNamedRangeObj.java @@ -2,9 +2,9 @@ * * $RCSfile: ScNamedRangeObj.java,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change:$Date: 2003-01-27 18:16:18 $ + * last change:$Date: 2003-02-04 13:22:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -79,6 +79,9 @@ import lib.TestEnvironment; import lib.TestParameters; import util.SOfficeFactory; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; + /** * Test for object which is represented by service * <code>com.sun.star.sheet.NamedRange</code>. <p> @@ -140,8 +143,7 @@ public class ScNamedRangeObj extends TestCase { * created range) </li> * </ul> */ - public synchronized TestEnvironment createTestEnvironment( - TestParameters Param, PrintWriter log) throws StatusException { + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { XInterface oInterface = null; XInterface oObj = null; @@ -156,13 +158,17 @@ public class ScNamedRangeObj extends TestCase { UnoRuntime.queryInterface(XIndexAccess.class, oSheets); XSpreadsheet oSheet = null; try { - oSheet = (XSpreadsheet) oIndexSheets.getByIndex(0); + oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0)); } catch (com.sun.star.lang.WrappedTargetException e) { e.printStackTrace(log); throw new StatusException( "Couldn't get a spreadsheet", e); } catch (com.sun.star.lang.IndexOutOfBoundsException e) { e.printStackTrace(log); throw new StatusException( "Couldn't get a spreadsheet", e); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + throw new StatusException( "Couldn't get a spreadsheet", e); } // Getting named ranges. @@ -198,13 +204,17 @@ public class ScNamedRangeObj extends TestCase { xNamedRanges.outputList(listOutputPosition); try { - oObj = (XInterface)xNamedRanges.getByName("ANamedRange"); + oObj = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),xNamedRanges.getByName("ANamedRange")); } catch(com.sun.star.lang.WrappedTargetException e){ e.printStackTrace(log); throw new StatusException("Couldn't get by name", e); } catch(com.sun.star.container.NoSuchElementException e){ e.printStackTrace(log); throw new StatusException("Couldn't get by name", e); + } catch(com.sun.star.lang.IllegalArgumentException e){ + e.printStackTrace(log); + throw new StatusException("Couldn't get by name", e); } TestEnvironment tEnv = new TestEnvironment( oObj ); diff --git a/qadevOOo/tests/java/mod/_sc/ScNamedRangesObj.java b/qadevOOo/tests/java/mod/_sc/ScNamedRangesObj.java index 6a51160adbdd..3e94520b6cc7 100644 --- a/qadevOOo/tests/java/mod/_sc/ScNamedRangesObj.java +++ b/qadevOOo/tests/java/mod/_sc/ScNamedRangesObj.java @@ -2,9 +2,9 @@ * * $RCSfile: ScNamedRangesObj.java,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change:$Date: 2003-01-27 18:16:17 $ + * last change:$Date: 2003-02-04 13:26:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -79,6 +79,9 @@ import lib.TestEnvironment; import lib.TestParameters; import util.SOfficeFactory; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; + /** * Test for object which is represented by service * <code>com.sun.star.sheet.NamedRanges</code>. <p> @@ -140,8 +143,7 @@ public class ScNamedRangesObj extends TestCase { * </ul> * @see com.sun.star.sheet.NamedRanges */ - public synchronized TestEnvironment createTestEnvironment( - TestParameters Param, PrintWriter log) throws StatusException { + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { XInterface oInterface = null; XInterface oObj = null; @@ -156,13 +158,17 @@ public class ScNamedRangesObj extends TestCase { XIndexAccess oIndexSheets = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, oSheets); try { - oSheet = (XSpreadsheet) oIndexSheets.getByIndex(0); + oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0)); } catch (com.sun.star.lang.WrappedTargetException e) { e.printStackTrace(log); throw new StatusException( "Couldn't get a spreadsheet", e); } catch (com.sun.star.lang.IndexOutOfBoundsException e) { e.printStackTrace(log); throw new StatusException( "Couldn't get a spreadsheet", e); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + throw new StatusException( "Couldn't get a spreadsheet", e); } // Getting named ranges. @@ -202,6 +208,4 @@ public class ScNamedRangesObj extends TestCase { return tEnv; } -} - - +}
\ No newline at end of file |