summaryrefslogtreecommitdiff
path: root/odk/examples/java/Spreadsheet/ChartTypeChange.java
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2011-08-23 15:19:52 +0200
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2011-08-23 15:19:52 +0200
commita9bf268a68f9ed4ecb3b6130e098fc42bb259d23 (patch)
tree2012c7ad41c5058904ba05848e17d1e248f7559d /odk/examples/java/Spreadsheet/ChartTypeChange.java
parentcbb79e541cd2aa1f56cf7fbefcf8d0ce9c8db664 (diff)
recreated tag libreoffice-3.3.1.1 which had these commits:
commit f0c071b771bcb5ad8766beae20d0843034970038 (tag: refs/tags/libreoffice-3.3.1.1) Author: Petr Mladek <pmladek@suse.cz> Date: Tue Feb 8 18:07:45 2011 +0100 Version 3.3.1.1, tag libreoffice-3.3.1.1 (3.3.1-rc1) commit a095957324cb35016d2378c89e12188eb0e382e1 Author: Jan Holesovsky <kendy@suse.cz> Date: Mon Feb 7 21:23:29 2011 +0100 Branch libreoffice-3-3-1 This is 'libreoffice-3-3-1' - the stable branch for the 3.3.1 release. Only very safe changes, reviewed by three people are allowed. If you want to commit more complicated fix for the next 3.3.x release, please use the 'libreoffice-3-3' branch. If you want to build something cool, unstable, and risky, use master. commit a80b910ddedf4bb3b6fe53a5aa5fee5d48760368 Author: Petr Mladek <pmladek@suse.cz> Date: Tue Jan 11 23:05:58 2011 +0100 Please, ignore the previous message; it was for the libreoffice-3-3-0 branch This is 'libreoffice-3-3' - the stable branch for the 3.3.x releases. Only safe changes, reviewed by anoter person are allowed. If you want to build something cool, unstable, and risky, use master. commit 22b639a114400e7bce19595fcd1aafa9b8985132 Author: Petr Mladek <pmladek@suse.cz> Date: Tue Jan 11 22:39:09 2011 +0100 Branch libreoffice-3-3-0 This is 'libreoffice-3-3-0' - the stable branch for the 3.3.0 release. Only very safe changes, reviewed by three people are allowed. If you want to commit more complicated fix for the next 3.3.x release, please use the 'libreoffice-3-3' branch. If you want to build something cool, unstable, and risky, use master.
Notes
split repo tag: sdk_libreoffice-3.3.1.1
Diffstat (limited to 'odk/examples/java/Spreadsheet/ChartTypeChange.java')
-rw-r--r--odk/examples/java/Spreadsheet/ChartTypeChange.java98
1 files changed, 49 insertions, 49 deletions
diff --git a/odk/examples/java/Spreadsheet/ChartTypeChange.java b/odk/examples/java/Spreadsheet/ChartTypeChange.java
index 1a86ee3d0b97..ab4e44bfdc4c 100644
--- a/odk/examples/java/Spreadsheet/ChartTypeChange.java
+++ b/odk/examples/java/Spreadsheet/ChartTypeChange.java
@@ -2,7 +2,7 @@
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
* All rights reserved.
*
@@ -29,7 +29,7 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
*************************************************************************/
import com.sun.star.awt.Rectangle;
@@ -73,36 +73,36 @@ import com.sun.star.uno.XComponentContext;
* @author Bertram Nolte
*/
public class ChartTypeChange {
-
+
/** Table chart, which type will be changed.
*/
private XTableChart xtablechart = null;
-
+
/** Service factory
*/
private XMultiComponentFactory xMCF = null;
-
+
/** Component context
*/
private XComponentContext xCompContext = null;
-
+
/** Beginning of the program.
* @param args No arguments will be passed to the class.
*/
public static void main(String args[]) {
try {
ChartTypeChange charttypechange = new ChartTypeChange();
-
+
// Double array holding all values the chart should be based on.
String[][] stringValues = {
{ "", "Jan", "Feb", "Mar", "Apr", "Mai" },
{ "Profit", "12.3", "43.2", "5.1", "76", "56.8" },
{ "Rival in business", "12.2", "12.6", "17.7", "20.4", "100" },
};
-
+
// Create the chart with
charttypechange.getChart( stringValues );
-
+
String[] stringChartType = {
"com.sun.star.chart.LineDiagram",
"com.sun.star.chart.BarDiagram",
@@ -112,39 +112,39 @@ public class ChartTypeChange {
"com.sun.star.chart.StockDiagram",
"com.sun.star.chart.AreaDiagram"
};
-
+
for ( int intCounter = 0; intCounter < stringChartType.length;
intCounter++ ) {
charttypechange.changeChartType( stringChartType[ intCounter ],
false );
Thread.sleep( 3000 );
}
-
+
System.exit(0);
}
catch( Exception exception ) {
System.err.println( exception );
}
}
-
+
/** The constructor connects to the OpenOffice.org.
* @param args Parameters for this constructor (connection string).
* @throws Exception All exceptions are thrown from this method.
*/
public ChartTypeChange()
throws Exception {
-
+
/* Bootstraps a component context. Component context to be granted
to a component for running. Arbitrary values can be retrieved
from the context. */
xCompContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
-
+
/* Gets the service manager instance to be used (or null). This method has
been added for convenience, because the service manager is a often used
object. */
- xMCF = xCompContext.getServiceManager();
+ xMCF = xCompContext.getServiceManager();
}
-
+
/** This method will change the type of a specified chart.
* @param stringType The chart will be converted to this type.
* @param booleanIs3D If the chart should be displayed in 3D this parameter should be set to true.
@@ -155,7 +155,7 @@ public class ChartTypeChange {
XEmbeddedObjectSupplier xEmbeddedObjSupplier = (XEmbeddedObjectSupplier)
UnoRuntime.queryInterface(XEmbeddedObjectSupplier.class, xtablechart);
XInterface xInterface = xEmbeddedObjSupplier.getEmbeddedObject();
-
+
XChartDocument xChartDoc = (XChartDocument)UnoRuntime.queryInterface(
XChartDocument.class, xInterface);
XDiagram xDiagram = (XDiagram) xChartDoc.getDiagram();
@@ -163,14 +163,14 @@ public class ChartTypeChange {
UnoRuntime.queryInterface( XMultiServiceFactory.class, xChartDoc );
Object object = xMSF.createInstance( stringType );
xDiagram = (XDiagram) UnoRuntime.queryInterface(XDiagram.class, object);
-
+
XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, xDiagram );
xPropSet.setPropertyValue( "Dim3D", new Boolean( booleanIs3D ) );
-
+
xChartDoc.setDiagram(xDiagram);
}
-
+
/** Loading an OpenOffice.org Calc document and getting a chart by name.
* @param stringFileName Name of the OpenOffice.org Calc document which should
* be loaded.
@@ -186,30 +186,30 @@ public class ChartTypeChange {
UnoRuntime.queryInterface( XComponentLoader.class,
xMCF.createInstanceWithContext("com.sun.star.frame.Desktop",
xCompContext ) );
-
+
// Load a Writer document, which will be automaticly displayed
XComponent xComponent = xComponentloader.loadComponentFromURL(
"file:///" + stringFileName, "_blank", 0,
new PropertyValue[0] );
-
+
// Query for the interface XSpreadsheetDocument
XSpreadsheetDocument xSpreadSheetDocument = ( XSpreadsheetDocument )
UnoRuntime.queryInterface( XSpreadsheetDocument.class, xComponent );
-
+
XSpreadsheets xSpreadsheets = xSpreadSheetDocument.getSheets() ;
-
+
XIndexAccess xIndexAccess = (XIndexAccess)
UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets );
-
+
XSpreadsheet xSpreadsheet = (XSpreadsheet) UnoRuntime.queryInterface(
XSpreadsheet.class, xIndexAccess.getByIndex(0));
-
+
XTableChartsSupplier xTableChartsSupplier = ( XTableChartsSupplier )
UnoRuntime.queryInterface( XTableChartsSupplier.class, xSpreadsheet );
-
+
xIndexAccess = (XIndexAccess) UnoRuntime.queryInterface(
XIndexAccess.class, xTableChartsSupplier.getCharts() );
-
+
this.xtablechart = (XTableChart) UnoRuntime.queryInterface(
XTableChart.class, xIndexAccess.getByIndex( 0 ) );
}
@@ -217,7 +217,7 @@ public class ChartTypeChange {
System.err.println( exception );
}
}
-
+
/** Creating an empty OpenOffice.org Calc document, inserting data, and getting a
* chart by name.
* @param stringValues Double array with the values for the chart.
@@ -233,27 +233,27 @@ public class ChartTypeChange {
xMCF.createInstanceWithContext(
"com.sun.star.frame.Desktop",
xCompContext ) );
-
+
// Create an empty calc document, which will be automaticly displayed
XComponent xComponent = xcomponentloader.loadComponentFromURL(
"private:factory/scalc", "_blank", 0,
new PropertyValue[0] );
-
+
// Query for the interface XSpreadsheetDocument
XSpreadsheetDocument xspreadsheetdocument = ( XSpreadsheetDocument )
UnoRuntime.queryInterface( XSpreadsheetDocument.class, xComponent );
-
+
// Get all sheets of the spreadsheet document.
XSpreadsheets xspreadsheets = xspreadsheetdocument.getSheets() ;
-
+
// Get the index of the spreadsheet document.
XIndexAccess xindexaccess = (XIndexAccess) UnoRuntime.queryInterface(
XIndexAccess.class, xspreadsheets );
-
+
// Get the first spreadsheet.
XSpreadsheet xspreadsheet = (XSpreadsheet) UnoRuntime.queryInterface(
XSpreadsheet.class, xindexaccess.getByIndex(0));
-
+
// The double array will written to the spreadsheet
for ( int intY = 0; intY < stringValues.length; intY++ ) {
for ( int intX = 0; intX < stringValues[ intY ].length;
@@ -263,21 +263,21 @@ public class ChartTypeChange {
stringValues[ intY ][ intX ], xspreadsheet, "" );
}
}
-
+
// Create a rectangle, which holds the size of the chart.
Rectangle rectangle = new Rectangle();
rectangle.X = 500;
rectangle.Y = 3000;
rectangle.Width = 25000;
rectangle.Height = 11000;
-
+
// Get the cell range of the spreadsheet.
XCellRange xcellrange = ( XCellRange ) UnoRuntime.queryInterface(
XCellRange.class, xspreadsheet );
-
+
// Create the Unicode of the character for the column name.
char charRectangle = ( char ) ( 65 + stringValues.length - 1 );
-
+
// Get maximum length all rows in the double array.
int intMaximumWidthRow = 0;
for ( int intRow = 0; intRow < stringValues.length; intRow++ ) {
@@ -285,35 +285,35 @@ public class ChartTypeChange {
intMaximumWidthRow = stringValues[ intRow ].length;
}
}
-
+
// Get the cell range of the written values.
XCellRange xcellrangeChart = xcellrange.getCellRangeByName( "A1:" +
charRectangle + intMaximumWidthRow );
-
+
// Get the addressable cell range.
XCellRangeAddressable xcellrangeaddressable =
( XCellRangeAddressable ) UnoRuntime.queryInterface(
XCellRangeAddressable.class, xcellrangeChart );
-
+
// Get the cell range address.
CellRangeAddress cellrangeaddress = xcellrangeaddressable.getRangeAddress();
-
+
// Create the cell range address for the chart.
CellRangeAddress[] cellrangeaddressChart =
new CellRangeAddress[ 1 ];
cellrangeaddressChart[ 0 ] = cellrangeaddress;
-
+
// Get the table charts supplier of the spreadsheet.
XTableChartsSupplier xtablechartssupplier = ( XTableChartsSupplier )
UnoRuntime.queryInterface( XTableChartsSupplier.class, xspreadsheet );
-
+
// Get all table charts of the spreadsheet.
XTableCharts xtablecharts = xtablechartssupplier.getCharts();
-
+
// Create a table chart with all written values.
xtablecharts.addNewByName( "Example", rectangle,
cellrangeaddressChart, true, true );
-
+
// Get the created table chart.
this.xtablechart = ( XTableChart ) UnoRuntime.queryInterface(
XTableChart.class, (( XNameAccess ) UnoRuntime.queryInterface(
@@ -323,7 +323,7 @@ public class ChartTypeChange {
System.err.println( exception );
}
}
-
+
/** Inserting a given value to a cell, that is specified by the parameters intX
* and intY.
* @param intX Column on the spreadsheet.
@@ -338,7 +338,7 @@ public class ChartTypeChange {
XSpreadsheet xspreadsheet, String stringFlag )
{
XCell xcell = null;
-
+
try {
xcell = xspreadsheet.getCellByPosition( intX, intY );
}