summaryrefslogtreecommitdiff
path: root/odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetDocHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetDocHelper.java')
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetDocHelper.java64
1 files changed, 26 insertions, 38 deletions
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetDocHelper.java b/odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetDocHelper.java
index d130ccfaf66c..58dbf4873d64 100644
--- a/odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetDocHelper.java
+++ b/odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetDocHelper.java
@@ -112,9 +112,9 @@ public class SpreadsheetDocHelper
try
{
com.sun.star.container.XIndexAccess xSheetsIA =
- (com.sun.star.container.XIndexAccess)UnoRuntime.queryInterface(
- com.sun.star.container.XIndexAccess.class, xSheets );
- xSheet = (com.sun.star.sheet.XSpreadsheet) UnoRuntime.queryInterface(
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XIndexAccess.class, xSheets );
+ xSheet = UnoRuntime.queryInterface(
com.sun.star.sheet.XSpreadsheet.class, xSheetsIA.getByIndex(nIndex));
}
catch (Exception ex)
@@ -139,9 +139,8 @@ public class SpreadsheetDocHelper
try
{
xSheets.insertNewByName( aName, nIndex );
- xSheet = (com.sun.star.sheet.XSpreadsheet)
- UnoRuntime.queryInterface(com.sun.star.sheet.XSpreadsheet.class,
- xSheets.getByName( aName ));
+ xSheet = UnoRuntime.queryInterface(com.sun.star.sheet.XSpreadsheet.class,
+ xSheets.getByName( aName ));
}
catch (Exception ex)
{
@@ -197,16 +196,15 @@ public class SpreadsheetDocHelper
// Set standard date format.
com.sun.star.util.XNumberFormatsSupplier xFormatsSupplier =
- (com.sun.star.util.XNumberFormatsSupplier) UnoRuntime.queryInterface(
- com.sun.star.util.XNumberFormatsSupplier.class, getDocument() );
+ UnoRuntime.queryInterface(
+ com.sun.star.util.XNumberFormatsSupplier.class, getDocument() );
com.sun.star.util.XNumberFormatTypes xFormatTypes =
- (com.sun.star.util.XNumberFormatTypes) UnoRuntime.queryInterface(
- com.sun.star.util.XNumberFormatTypes.class, xFormatsSupplier.getNumberFormats() );
+ UnoRuntime.queryInterface(
+ com.sun.star.util.XNumberFormatTypes.class, xFormatsSupplier.getNumberFormats() );
int nFormat = xFormatTypes.getStandardFormat(
com.sun.star.util.NumberFormat.DATE, new com.sun.star.lang.Locale() );
- com.sun.star.beans.XPropertySet xPropSet = (com.sun.star.beans.XPropertySet)
- UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCell );
+ com.sun.star.beans.XPropertySet xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCell );
xPropSet.setPropertyValue( "NumberFormat", new Integer( nFormat ) );
}
@@ -224,8 +222,7 @@ public class SpreadsheetDocHelper
// draw border
xCellRange = xSheet.getCellRangeByName( aRange );
- 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 );
com.sun.star.table.BorderLine aLine = new com.sun.star.table.BorderLine();
aLine.Color = 0x99CCFF;
aLine.InnerLineWidth = aLine.LineDistance = 0;
@@ -237,20 +234,17 @@ public class SpreadsheetDocHelper
xPropSet.setPropertyValue( "TableBorder", aBorder );
// draw headline
- com.sun.star.sheet.XCellRangeAddressable xAddr = (com.sun.star.sheet.XCellRangeAddressable)
- UnoRuntime.queryInterface( com.sun.star.sheet.XCellRangeAddressable.class, xCellRange );
+ com.sun.star.sheet.XCellRangeAddressable xAddr = UnoRuntime.queryInterface( com.sun.star.sheet.XCellRangeAddressable.class, xCellRange );
com.sun.star.table.CellRangeAddress aAddr = xAddr.getRangeAddress();
xCellRange = xSheet.getCellRangeByPosition(
aAddr.StartColumn, aAddr.StartRow, aAddr.EndColumn, aAddr.StartRow );
- 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( 0x99CCFF ) );
// write headline
com.sun.star.table.XCell xCell = xCellRange.getCellByPosition( 0, 0 );
xCell.setFormula( aHeadline );
- 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( "CharColor", new Integer( 0x003399 ) );
xPropSet.setPropertyValue( "CharWeight", new Float( com.sun.star.awt.FontWeight.BOLD ) );
}
@@ -266,9 +260,8 @@ public class SpreadsheetDocHelper
com.sun.star.sheet.XSpreadsheet xSheet,
String aCell ) throws RuntimeException, Exception
{
- com.sun.star.sheet.XCellAddressable xAddr = (com.sun.star.sheet.XCellAddressable)
- UnoRuntime.queryInterface( com.sun.star.sheet.XCellAddressable.class,
- xSheet.getCellRangeByName( aCell ).getCellByPosition( 0, 0 ) );
+ com.sun.star.sheet.XCellAddressable xAddr = UnoRuntime.queryInterface( com.sun.star.sheet.XCellAddressable.class,
+ xSheet.getCellRangeByName( aCell ).getCellByPosition( 0, 0 ) );
return xAddr.getCellAddress();
}
@@ -279,9 +272,8 @@ public class SpreadsheetDocHelper
public com.sun.star.table.CellRangeAddress createCellRangeAddress(
com.sun.star.sheet.XSpreadsheet xSheet, String aRange )
{
- com.sun.star.sheet.XCellRangeAddressable xAddr = (com.sun.star.sheet.XCellRangeAddressable)
- UnoRuntime.queryInterface( com.sun.star.sheet.XCellRangeAddressable.class,
- xSheet.getCellRangeByName( aRange ) );
+ com.sun.star.sheet.XCellRangeAddressable xAddr = UnoRuntime.queryInterface( com.sun.star.sheet.XCellRangeAddressable.class,
+ xSheet.getCellRangeByName( aRange ) );
return xAddr.getRangeAddress();
}
@@ -326,12 +318,10 @@ public class SpreadsheetDocHelper
if (bWithSheet)
{
com.sun.star.sheet.XSpreadsheet xSheet = xCellRange.getSpreadsheet();
- com.sun.star.container.XNamed xNamed = (com.sun.star.container.XNamed)
- UnoRuntime.queryInterface( com.sun.star.container.XNamed.class, xSheet );
+ com.sun.star.container.XNamed xNamed = UnoRuntime.queryInterface( com.sun.star.container.XNamed.class, xSheet );
aStr += xNamed.getName() + ".";
}
- com.sun.star.sheet.XCellRangeAddressable xAddr = (com.sun.star.sheet.XCellRangeAddressable)
- UnoRuntime.queryInterface( com.sun.star.sheet.XCellRangeAddressable.class, xCellRange );
+ com.sun.star.sheet.XCellRangeAddressable xAddr = UnoRuntime.queryInterface( com.sun.star.sheet.XCellRangeAddressable.class, xCellRange );
aStr += getCellRangeAddressString( xAddr.getRangeAddress() );
return aStr;
}
@@ -349,8 +339,7 @@ public class SpreadsheetDocHelper
if (nIndex > 0)
aStr += " ";
Object aRangeObj = xRangesIA.getByIndex( nIndex );
- com.sun.star.sheet.XSheetCellRange xCellRange = (com.sun.star.sheet.XSheetCellRange)
- UnoRuntime.queryInterface( com.sun.star.sheet.XSheetCellRange.class, aRangeObj );
+ com.sun.star.sheet.XSheetCellRange xCellRange = UnoRuntime.queryInterface( com.sun.star.sheet.XSheetCellRange.class, aRangeObj );
aStr += getCellRangeAddressString( xCellRange, false );
}
return aStr;
@@ -382,17 +371,16 @@ public class SpreadsheetDocHelper
private com.sun.star.sheet.XSpreadsheetDocument initDocument()
throws RuntimeException, Exception
{
- XComponentLoader aLoader = (XComponentLoader)
- UnoRuntime.queryInterface(
- XComponentLoader.class,
- mxRemoteServiceManager.createInstanceWithContext(
- "com.sun.star.frame.Desktop", mxRemoteContext));
+ XComponentLoader aLoader = UnoRuntime.queryInterface(
+ XComponentLoader.class,
+ mxRemoteServiceManager.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", mxRemoteContext));
XComponent xComponent = aLoader.loadComponentFromURL(
"private:factory/scalc", "_blank", 0,
new com.sun.star.beans.PropertyValue[0] );
- return (com.sun.star.sheet.XSpreadsheetDocument)UnoRuntime.queryInterface(
+ return UnoRuntime.queryInterface(
com.sun.star.sheet.XSpreadsheetDocument.class, xComponent );
}