diff options
Diffstat (limited to 'odk/examples/DevelopersGuide/Spreadsheet/GeneralTableSample.java')
-rw-r--r-- | odk/examples/DevelopersGuide/Spreadsheet/GeneralTableSample.java | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/GeneralTableSample.java b/odk/examples/DevelopersGuide/Spreadsheet/GeneralTableSample.java index 30bd5c143aa1..4b1682af2c7e 100644 --- a/odk/examples/DevelopersGuide/Spreadsheet/GeneralTableSample.java +++ b/odk/examples/DevelopersGuide/Spreadsheet/GeneralTableSample.java @@ -99,15 +99,13 @@ public class GeneralTableSample extends SpreadsheetDocHelper // *** Insert a TEXT CELL using the XText interface *** xCell = xSheet.getCellByPosition( 0, 3 ); - com.sun.star.text.XText xCellText = (com.sun.star.text.XText) - UnoRuntime.queryInterface( com.sun.star.text.XText.class, xCell ); + com.sun.star.text.XText xCellText = UnoRuntime.queryInterface( com.sun.star.text.XText.class, xCell ); com.sun.star.text.XTextCursor xTextCursor = xCellText.createTextCursor(); xCellText.insertString( xTextCursor, aText, false ); // *** Change cell properties *** int nValue = bValid ? 0x00FF00 : 0xFF4040; - xPropSet = (com.sun.star.beans.XPropertySet) - UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCell ); + xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCell ); xPropSet.setPropertyValue( "CellBackColor", new Integer( nValue ) ); @@ -118,16 +116,14 @@ public class GeneralTableSample extends SpreadsheetDocHelper xCellRange = xSheet.getCellRangeByPosition( 2, 0, 3, 1 ); // Change properties of the range. - xPropSet = (com.sun.star.beans.XPropertySet) - UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCellRange ); + xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCellRange ); xPropSet.setPropertyValue( "CellBackColor", new Integer( 0x8080FF ) ); // Accessing a cell range over its name. xCellRange = xSheet.getCellRangeByName( "C4:D5" ); // Change properties of the range. - xPropSet = (com.sun.star.beans.XPropertySet) - UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCellRange ); + xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCellRange ); xPropSet.setPropertyValue( "CellBackColor", new Integer( 0xFFFF80 ) ); @@ -136,13 +132,11 @@ public class GeneralTableSample extends SpreadsheetDocHelper // Create a cursor using the XSpreadsheet method createCursorByRange() xCellRange = xSheet.getCellRangeByName( "A1" ); - com.sun.star.sheet.XSheetCellRange xSheetCellRange = (com.sun.star.sheet.XSheetCellRange) - UnoRuntime.queryInterface( com.sun.star.sheet.XSheetCellRange.class, xCellRange ); + com.sun.star.sheet.XSheetCellRange xSheetCellRange = UnoRuntime.queryInterface( com.sun.star.sheet.XSheetCellRange.class, xCellRange ); com.sun.star.sheet.XSheetCellCursor xSheetCellCursor = xSheet.createCursorByRange( xSheetCellRange ); - com.sun.star.table.XCellCursor xCursor = (com.sun.star.table.XCellCursor) - UnoRuntime.queryInterface( com.sun.star.table.XCellCursor.class, xSheetCellCursor ); + com.sun.star.table.XCellCursor xCursor = UnoRuntime.queryInterface( com.sun.star.table.XCellCursor.class, xSheetCellCursor ); // Move to the last filled cell. xCursor.gotoEnd(); @@ -154,36 +148,30 @@ public class GeneralTableSample extends SpreadsheetDocHelper // *** Modifying COLUMNS and ROWS *** System.out.println( "*** Sample for services table.TableRows and table.TableColumns ***" ); - com.sun.star.table.XColumnRowRange xCRRange = (com.sun.star.table.XColumnRowRange) - UnoRuntime.queryInterface( com.sun.star.table.XColumnRowRange.class, xSheet ); + com.sun.star.table.XColumnRowRange xCRRange = UnoRuntime.queryInterface( com.sun.star.table.XColumnRowRange.class, xSheet ); com.sun.star.table.XTableColumns xColumns = xCRRange.getColumns(); com.sun.star.table.XTableRows xRows = xCRRange.getRows(); // Get column C by index (interface XIndexAccess). Object aColumnObj = xColumns.getByIndex( 2 ); - xPropSet = (com.sun.star.beans.XPropertySet) - UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aColumnObj ); + xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aColumnObj ); xPropSet.setPropertyValue( "Width", new Integer( 5000 ) ); // Get the name of the column. - com.sun.star.container.XNamed xNamed = (com.sun.star.container.XNamed) - UnoRuntime.queryInterface( com.sun.star.container.XNamed.class, aColumnObj ); + com.sun.star.container.XNamed xNamed = UnoRuntime.queryInterface( com.sun.star.container.XNamed.class, aColumnObj ); aText = "The name of this column is " + xNamed.getName() + "."; xSheet.getCellByPosition( 2, 2 ).setFormula( aText ); // Get column D by name (interface XNameAccess). - com.sun.star.container.XNameAccess xColumnsName = (com.sun.star.container.XNameAccess) - UnoRuntime.queryInterface( com.sun.star.container.XNameAccess.class, xColumns ); + com.sun.star.container.XNameAccess xColumnsName = UnoRuntime.queryInterface( com.sun.star.container.XNameAccess.class, xColumns ); aColumnObj = xColumnsName.getByName( "D" ); - xPropSet = (com.sun.star.beans.XPropertySet) - UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aColumnObj ); + xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aColumnObj ); xPropSet.setPropertyValue( "IsVisible", new Boolean( false ) ); // Get row 7 by index (interface XIndexAccess) Object aRowObj = xRows.getByIndex( 6 ); - xPropSet = (com.sun.star.beans.XPropertySet) - UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aRowObj ); + xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aRowObj ); xPropSet.setPropertyValue( "Height", new Integer( 5000 ) ); xSheet.getCellByPosition( 2, 6 ).setFormula( "What a big cell." ); @@ -200,8 +188,8 @@ public class GeneralTableSample extends SpreadsheetDocHelper System.out.println( "*** Sample for service table.TableCharts ***" ); com.sun.star.table.XTableChartsSupplier xChartsSupp = - (com.sun.star.table.XTableChartsSupplier) UnoRuntime.queryInterface( - com.sun.star.table.XTableChartsSupplier.class, xSheet ); + UnoRuntime.queryInterface( + com.sun.star.table.XTableChartsSupplier.class, xSheet ); com.sun.star.table.XTableCharts xCharts = xChartsSupp.getCharts(); // The chart will base on the last cell series, initializing all values. @@ -218,8 +206,7 @@ public class GeneralTableSample extends SpreadsheetDocHelper // Get the chart by name. Object aChartObj = xCharts.getByName( aName ); - com.sun.star.table.XTableChart xChart = (com.sun.star.table.XTableChart) - UnoRuntime.queryInterface( com.sun.star.table.XTableChart.class, aChartObj ); + com.sun.star.table.XTableChart xChart = UnoRuntime.queryInterface( com.sun.star.table.XTableChart.class, aChartObj ); // Query the state of row and column headers. aText = "Chart has column headers: "; |