From ff0ad0493ee1729c726587f667761b04101d774c Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 12 Aug 2014 15:09:06 +0200 Subject: java: use 'Integer.valueOf' instead of 'new Integer' Change-Id: Ia8befb8d69914ce971174fc5f2ffc0e2f506a940 --- .../Spreadsheet/ExampleDataPilotSource.java | 16 ++++++++-------- .../Spreadsheet/GeneralTableSample.java | 10 +++++----- .../Spreadsheet/SpreadsheetDocHelper.java | 6 +++--- .../Spreadsheet/SpreadsheetSample.java | 20 ++++++++++---------- .../DevelopersGuide/Spreadsheet/ViewSample.java | 4 ++-- 5 files changed, 28 insertions(+), 28 deletions(-) (limited to 'odk/examples/DevelopersGuide/Spreadsheet') diff --git a/odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.java b/odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.java index e72861db0233..593e8e572f48 100644 --- a/odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.java +++ b/odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.java @@ -269,12 +269,12 @@ class ExampleLevel implements public com.sun.star.sheet.MemberResult[] getResults() { int nDimensions = 0; - int nPosition = aSettings.aColDimensions.indexOf( new Integer(nDimension)); + int nPosition = aSettings.aColDimensions.indexOf( Integer.valueOf(nDimension)); if ( nPosition >= 0 ) nDimensions = aSettings.aColDimensions.size(); else { - nPosition = aSettings.aRowDimensions.indexOf( new Integer(nDimension)); + nPosition = aSettings.aRowDimensions.indexOf( Integer.valueOf(nDimension)); if ( nPosition >= 0 ) nDimensions = aSettings.aRowDimensions.size(); } @@ -604,7 +604,7 @@ class ExampleDimension implements eNewOrient != com.sun.star.sheet.DataPilotFieldOrientation.DATA ) { // remove from list for old orientation and add for new one - Integer aDimInt = new Integer(nDimension); + Integer aDimInt = Integer.valueOf(nDimension); if ( eOrientation == com.sun.star.sheet.DataPilotFieldOrientation.COLUMN ) aSettings.aColDimensions.remove( aDimInt ); else if ( eOrientation == com.sun.star.sheet.DataPilotFieldOrientation.ROW ) @@ -621,7 +621,7 @@ class ExampleDimension implements else if ( aPropertyName.equals( "Position" ) ) { int nNewPos = ((Integer) aValue).intValue(); - Integer aDimInt = new Integer(nDimension); + Integer aDimInt = Integer.valueOf(nDimension); if ( eOrientation == com.sun.star.sheet.DataPilotFieldOrientation.COLUMN ) { aSettings.aColDimensions.remove( aDimInt ); @@ -655,17 +655,17 @@ class ExampleDimension implements { int nPosition; if ( eOrientation == com.sun.star.sheet.DataPilotFieldOrientation.COLUMN ) - nPosition = aSettings.aColDimensions.indexOf( new Integer(nDimension) ); + nPosition = aSettings.aColDimensions.indexOf( Integer.valueOf(nDimension) ); else if ( eOrientation == com.sun.star.sheet.DataPilotFieldOrientation.ROW ) - nPosition = aSettings.aRowDimensions.indexOf( new Integer(nDimension) ); + nPosition = aSettings.aRowDimensions.indexOf( Integer.valueOf(nDimension) ); else nPosition = nDimension; - return new Integer( nPosition ); + return Integer.valueOf( nPosition ); } else if ( aPropertyName.equals( "Function" ) ) return com.sun.star.sheet.GeneralFunction.SUM; else if ( aPropertyName.equals( "UsedHierarchy" ) ) - return new Integer(0); + return Integer.valueOf(0); else if ( aPropertyName.equals( "Filter" ) ) return new com.sun.star.sheet.TableFilterField[0]; else diff --git a/odk/examples/DevelopersGuide/Spreadsheet/GeneralTableSample.java b/odk/examples/DevelopersGuide/Spreadsheet/GeneralTableSample.java index f25a9cfded8f..a40722f5e625 100644 --- a/odk/examples/DevelopersGuide/Spreadsheet/GeneralTableSample.java +++ b/odk/examples/DevelopersGuide/Spreadsheet/GeneralTableSample.java @@ -106,7 +106,7 @@ public class GeneralTableSample extends SpreadsheetDocHelper // *** Change cell properties *** int nValue = bValid ? 0x00FF00 : 0xFF4040; xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCell ); - xPropSet.setPropertyValue( "CellBackColor", new Integer( nValue ) ); + xPropSet.setPropertyValue( "CellBackColor", Integer.valueOf( nValue ) ); // *** Accessing a CELL RANGE *** @@ -117,14 +117,14 @@ public class GeneralTableSample extends SpreadsheetDocHelper // Change properties of the range. xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCellRange ); - xPropSet.setPropertyValue( "CellBackColor", new Integer( 0x8080FF ) ); + xPropSet.setPropertyValue( "CellBackColor", Integer.valueOf( 0x8080FF ) ); // Accessing a cell range over its name. xCellRange = xSheet.getCellRangeByName( "C4:D5" ); // Change properties of the range. xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCellRange ); - xPropSet.setPropertyValue( "CellBackColor", new Integer( 0xFFFF80 ) ); + xPropSet.setPropertyValue( "CellBackColor", Integer.valueOf( 0xFFFF80 ) ); // *** Using the CELL CURSOR to add some data below of the filled area *** @@ -155,7 +155,7 @@ public class GeneralTableSample extends SpreadsheetDocHelper // Get column C by index (interface XIndexAccess). Object aColumnObj = xColumns.getByIndex( 2 ); xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aColumnObj ); - xPropSet.setPropertyValue( "Width", new Integer( 5000 ) ); + xPropSet.setPropertyValue( "Width", Integer.valueOf( 5000 ) ); // Get the name of the column. com.sun.star.container.XNamed xNamed = UnoRuntime.queryInterface( com.sun.star.container.XNamed.class, aColumnObj ); @@ -172,7 +172,7 @@ public class GeneralTableSample extends SpreadsheetDocHelper // Get row 7 by index (interface XIndexAccess) Object aRowObj = xRows.getByIndex( 6 ); xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aRowObj ); - xPropSet.setPropertyValue( "Height", new Integer( 5000 ) ); + xPropSet.setPropertyValue( "Height", Integer.valueOf( 5000 ) ); xSheet.getCellByPosition( 2, 6 ).setFormula( "What a big cell." ); diff --git a/odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetDocHelper.java b/odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetDocHelper.java index dbdbc8004df2..4416440b10b4 100644 --- a/odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetDocHelper.java +++ b/odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetDocHelper.java @@ -202,7 +202,7 @@ public class SpreadsheetDocHelper com.sun.star.util.NumberFormat.DATE, new com.sun.star.lang.Locale() ); com.sun.star.beans.XPropertySet xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCell ); - xPropSet.setPropertyValue( "NumberFormat", new Integer( nFormat ) ); + xPropSet.setPropertyValue( "NumberFormat", Integer.valueOf( nFormat ) ); } /** Draws a colored border around the range and writes the headline in the @@ -237,12 +237,12 @@ public class SpreadsheetDocHelper xCellRange = xSheet.getCellRangeByPosition( aAddr.StartColumn, aAddr.StartRow, aAddr.EndColumn, aAddr.StartRow ); xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCellRange ); - xPropSet.setPropertyValue( "CellBackColor", new Integer( 0x99CCFF ) ); + xPropSet.setPropertyValue( "CellBackColor", Integer.valueOf( 0x99CCFF ) ); // write headline com.sun.star.table.XCell xCell = xCellRange.getCellByPosition( 0, 0 ); xCell.setFormula( aHeadline ); xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCell ); - xPropSet.setPropertyValue( "CharColor", new Integer( 0x003399 ) ); + xPropSet.setPropertyValue( "CharColor", Integer.valueOf( 0x003399 ) ); xPropSet.setPropertyValue( "CharWeight", new Float( com.sun.star.awt.FontWeight.BOLD ) ); } diff --git a/odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetSample.java b/odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetSample.java index 4438f880440e..467f3b5e91be 100644 --- a/odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetSample.java +++ b/odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetSample.java @@ -261,13 +261,13 @@ public class SpreadsheetSample extends SpreadsheetDocHelper // --- Change cell properties. --- xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCell ); // from styles.CharacterProperties - xPropSet.setPropertyValue( "CharColor", new Integer( 0x003399 ) ); + xPropSet.setPropertyValue( "CharColor", Integer.valueOf( 0x003399 ) ); xPropSet.setPropertyValue( "CharHeight", new Float( 20.0 ) ); // from styles.ParagraphProperties - xPropSet.setPropertyValue( "ParaLeftMargin", new Integer( 500 ) ); + xPropSet.setPropertyValue( "ParaLeftMargin", Integer.valueOf( 500 ) ); // from table.CellProperties xPropSet.setPropertyValue( "IsCellBackgroundTransparent", Boolean.FALSE ); - xPropSet.setPropertyValue( "CellBackColor", new Integer( 0x99CCFF ) ); + xPropSet.setPropertyValue( "CellBackColor", Integer.valueOf( 0x99CCFF ) ); // --- Get cell address. --- @@ -312,13 +312,13 @@ public class SpreadsheetSample extends SpreadsheetDocHelper // --- Change cell range properties. --- xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCellRange ); // from com.sun.star.styles.CharacterProperties - xPropSet.setPropertyValue( "CharColor", new Integer( 0x003399 ) ); + xPropSet.setPropertyValue( "CharColor", Integer.valueOf( 0x003399 ) ); xPropSet.setPropertyValue( "CharHeight", new Float( 20.0 ) ); // from com.sun.star.styles.ParagraphProperties - xPropSet.setPropertyValue( "ParaLeftMargin", new Integer( 500 ) ); + xPropSet.setPropertyValue( "ParaLeftMargin", Integer.valueOf( 500 ) ); // from com.sun.star.table.CellProperties xPropSet.setPropertyValue( "IsCellBackgroundTransparent", Boolean.FALSE ); - xPropSet.setPropertyValue( "CellBackColor", new Integer( 0x99CCFF ) ); + xPropSet.setPropertyValue( "CellBackColor", Integer.valueOf( 0x99CCFF ) ); // --- Replace text in all cells. --- @@ -366,7 +366,7 @@ public class SpreadsheetSample extends SpreadsheetDocHelper Object aColumnObj = xColumns.getByIndex( 0 ); xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aColumnObj ); - xPropSet.setPropertyValue( "Width", new Integer( 6000 ) ); + xPropSet.setPropertyValue( "Width", Integer.valueOf( 6000 ) ); com.sun.star.container.XNamed xNamed = UnoRuntime.queryInterface( com.sun.star.container.XNamed.class, aColumnObj ); System.out.println( "The name of the wide column is " + xNamed.getName() + "." ); @@ -647,7 +647,7 @@ public class SpreadsheetSample extends SpreadsheetDocHelper // modify properties of the new style xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aCellStyle ); - xPropSet.setPropertyValue( "CellBackColor", new Integer( 0x888888 ) ); + xPropSet.setPropertyValue( "CellBackColor", Integer.valueOf( 0x888888 ) ); xPropSet.setPropertyValue( "IsCellBackgroundTransparent", Boolean.FALSE ); @@ -741,7 +741,7 @@ public class SpreadsheetSample extends SpreadsheetDocHelper Object aFieldObj = xAutoFormatIA.getByIndex( 4 * nRow + nColumn ); xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aFieldObj ); - xPropSet.setPropertyValue( "CellBackColor", new Integer( nColor ) ); + xPropSet.setPropertyValue( "CellBackColor", Integer.valueOf( nColor ) ); } } @@ -1208,7 +1208,7 @@ public class SpreadsheetSample extends SpreadsheetDocHelper com.sun.star.table.XCellRange xResultRange = xRef.getReferredCells(); com.sun.star.beans.XPropertySet xResultProp = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xResultRange ); xResultProp.setPropertyValue( "IsCellBackgroundTransparent", Boolean.FALSE ); - xResultProp.setPropertyValue( "CellBackColor", new Integer( 0xFFFFCC ) ); + xResultProp.setPropertyValue( "CellBackColor", Integer.valueOf( 0xFFFFCC ) ); } } } diff --git a/odk/examples/DevelopersGuide/Spreadsheet/ViewSample.java b/odk/examples/DevelopersGuide/Spreadsheet/ViewSample.java index c313fa193d18..71b39d20a672 100644 --- a/odk/examples/DevelopersGuide/Spreadsheet/ViewSample.java +++ b/odk/examples/DevelopersGuide/Spreadsheet/ViewSample.java @@ -90,13 +90,13 @@ public class ViewSample extends SpreadsheetDocHelper com.sun.star.table.XCellRange xRange = xRefer.getReferredCells(); com.sun.star.beans.XPropertySet xRangeProp = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xRange ); xRangeProp.setPropertyValue( "IsCellBackgroundTransparent", Boolean.FALSE ); - xRangeProp.setPropertyValue( "CellBackColor", new Integer( 0xFFFFCC ) ); + xRangeProp.setPropertyValue( "CellBackColor", Integer.valueOf( 0xFFFFCC ) ); // --- View settings --- // change the view to display green grid lines com.sun.star.beans.XPropertySet xProp = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xController ); xProp.setPropertyValue( "ShowGrid", Boolean.TRUE ); - xProp.setPropertyValue( "GridColor", new Integer(0x00CC00) ); + xProp.setPropertyValue( "GridColor", Integer.valueOf(0x00CC00) ); // --- Range selection --- // let the user select a range and use it as the view's selection -- cgit