diff options
Diffstat (limited to 'odk/examples/DevelopersGuide/FirstSteps/FirstLoadComponent.java')
-rw-r--r-- | odk/examples/DevelopersGuide/FirstSteps/FirstLoadComponent.java | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/odk/examples/DevelopersGuide/FirstSteps/FirstLoadComponent.java b/odk/examples/DevelopersGuide/FirstSteps/FirstLoadComponent.java index 56a5447853f1..0bc329cd26a7 100644 --- a/odk/examples/DevelopersGuide/FirstSteps/FirstLoadComponent.java +++ b/odk/examples/DevelopersGuide/FirstSteps/FirstLoadComponent.java @@ -73,15 +73,13 @@ public class FirstLoadComponent { Object desktop = xRemoteServiceManager.createInstanceWithContext( "com.sun.star.frame.Desktop", xRemoteContext); - XComponentLoader xComponentLoader = (XComponentLoader) - UnoRuntime.queryInterface(XComponentLoader.class, desktop); + XComponentLoader xComponentLoader = UnoRuntime.queryInterface(XComponentLoader.class, desktop); PropertyValue[] loadProps = new PropertyValue[0]; XComponent xSpreadsheetComponent = xComponentLoader.loadComponentFromURL("private:factory/scalc", "_blank", 0, loadProps); - XSpreadsheetDocument xSpreadsheetDocument = (XSpreadsheetDocument) - UnoRuntime.queryInterface(XSpreadsheetDocument.class, - xSpreadsheetComponent); + XSpreadsheetDocument xSpreadsheetDocument = UnoRuntime.queryInterface(XSpreadsheetDocument.class, + xSpreadsheetComponent); XSpreadsheets xSpreadsheets = xSpreadsheetDocument.getSheets(); xSpreadsheets.insertNewByName("MySheet", (short)0); @@ -89,7 +87,7 @@ public class FirstLoadComponent { System.out.println(elemType.getTypeName()); Object sheet = xSpreadsheets.getByName("MySheet"); - XSpreadsheet xSpreadsheet = (XSpreadsheet)UnoRuntime.queryInterface( + XSpreadsheet xSpreadsheet = UnoRuntime.queryInterface( XSpreadsheet.class, sheet); XCell xCell = xSpreadsheet.getCellByPosition(0, 0); @@ -99,16 +97,15 @@ public class FirstLoadComponent { xCell = xSpreadsheet.getCellByPosition(0, 2); xCell.setFormula("=sum(A1:A2)"); - XPropertySet xCellProps = (XPropertySet)UnoRuntime.queryInterface( + XPropertySet xCellProps = UnoRuntime.queryInterface( XPropertySet.class, xCell); xCellProps.setPropertyValue("CellStyle", "Result"); - XModel xSpreadsheetModel = (XModel)UnoRuntime.queryInterface( + XModel xSpreadsheetModel = UnoRuntime.queryInterface( XModel.class, xSpreadsheetComponent); XController xSpreadsheetController = xSpreadsheetModel.getCurrentController(); - XSpreadsheetView xSpreadsheetView = (XSpreadsheetView) - UnoRuntime.queryInterface(XSpreadsheetView.class, - xSpreadsheetController); + XSpreadsheetView xSpreadsheetView = UnoRuntime.queryInterface(XSpreadsheetView.class, + xSpreadsheetController); xSpreadsheetView.setActiveSheet(xSpreadsheet); // ********************************************************* @@ -138,8 +135,7 @@ public class FirstLoadComponent { // ********************************************************* // example for use of XEnumerationAccess - XCellRangesQuery xCellQuery = (XCellRangesQuery) - UnoRuntime.queryInterface(XCellRangesQuery.class, sheet); + XCellRangesQuery xCellQuery = UnoRuntime.queryInterface(XCellRangesQuery.class, sheet); XSheetCellRanges xFormulaCells = xCellQuery.queryContentCells( (short)com.sun.star.sheet.CellFlags.FORMULA); XEnumerationAccess xFormulas = xFormulaCells.getCells(); @@ -147,9 +143,8 @@ public class FirstLoadComponent { while (xFormulaEnum.hasMoreElements()) { Object formulaCell = xFormulaEnum.nextElement(); - xCell = (XCell)UnoRuntime.queryInterface(XCell.class, formulaCell); - XCellAddressable xCellAddress = (XCellAddressable) - UnoRuntime.queryInterface(XCellAddressable.class, xCell); + xCell = UnoRuntime.queryInterface(XCell.class, formulaCell); + XCellAddressable xCellAddress = UnoRuntime.queryInterface(XCellAddressable.class, xCell); System.out.println("Formula cell in column " + xCellAddress.getCellAddress().Column + ", row " + xCellAddress.getCellAddress().Row |