diff options
Diffstat (limited to 'odk/examples/DevelopersGuide/Charts')
-rw-r--r-- | odk/examples/DevelopersGuide/Charts/AddInChart.ods | bin | 18045 -> 0 bytes | |||
-rw-r--r-- | odk/examples/DevelopersGuide/Charts/CalcHelper.java | 412 | ||||
-rw-r--r-- | odk/examples/DevelopersGuide/Charts/ChartHelper.java | 261 | ||||
-rw-r--r-- | odk/examples/DevelopersGuide/Charts/ChartInCalc.java | 424 | ||||
-rw-r--r-- | odk/examples/DevelopersGuide/Charts/ChartInDraw.java | 308 | ||||
-rw-r--r-- | odk/examples/DevelopersGuide/Charts/ChartInWriter.java | 178 | ||||
-rw-r--r-- | odk/examples/DevelopersGuide/Charts/Helper.java | 170 | ||||
-rw-r--r-- | odk/examples/DevelopersGuide/Charts/JavaSampleChartAddIn.components | 10 | ||||
-rw-r--r-- | odk/examples/DevelopersGuide/Charts/JavaSampleChartAddIn.java | 480 | ||||
-rw-r--r-- | odk/examples/DevelopersGuide/Charts/ListenAtCalcRangeInDraw.java | 211 | ||||
-rw-r--r-- | odk/examples/DevelopersGuide/Charts/Makefile | 200 | ||||
-rw-r--r-- | odk/examples/DevelopersGuide/Charts/SelectionChangeListener.java | 219 | ||||
-rw-r--r-- | odk/examples/DevelopersGuide/Charts/bullet.gif | bin | 335 -> 0 bytes | |||
-rw-r--r-- | odk/examples/DevelopersGuide/Charts/makefile.mk | 75 |
14 files changed, 0 insertions, 2948 deletions
diff --git a/odk/examples/DevelopersGuide/Charts/AddInChart.ods b/odk/examples/DevelopersGuide/Charts/AddInChart.ods Binary files differdeleted file mode 100644 index 01708ed7..00000000 --- a/odk/examples/DevelopersGuide/Charts/AddInChart.ods +++ /dev/null diff --git a/odk/examples/DevelopersGuide/Charts/CalcHelper.java b/odk/examples/DevelopersGuide/Charts/CalcHelper.java deleted file mode 100644 index c9bac593..00000000 --- a/odk/examples/DevelopersGuide/Charts/CalcHelper.java +++ /dev/null @@ -1,412 +0,0 @@ -/************************************************************************* - * - * 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. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * 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. - * - *************************************************************************/ - -// __________ Imports __________ - -import java.util.Random; - -// base classes -import com.sun.star.uno.XInterface; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.lang.*; - -// factory for creating components -import com.sun.star.comp.servicemanager.ServiceManager; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.bridge.XUnoUrlResolver; -import com.sun.star.uno.XNamingService; -import com.sun.star.frame.XDesktop; -import com.sun.star.frame.XComponentLoader; - -// property access -import com.sun.star.beans.*; - -// container access -import com.sun.star.container.*; - -// application specific classes -import com.sun.star.sheet.*; -import com.sun.star.table.*; -import com.sun.star.chart.*; -import com.sun.star.text.XText; - -import com.sun.star.document.XEmbeddedObjectSupplier; -import com.sun.star.frame.XModel; -import com.sun.star.frame.XController; - -// base graphics things -import com.sun.star.awt.Point; -import com.sun.star.awt.Size; -import com.sun.star.awt.Rectangle; - -// Exceptions -import com.sun.star.uno.RuntimeException; -import com.sun.star.container.NoSuchElementException; -import com.sun.star.beans.UnknownPropertyException; -import com.sun.star.lang.IndexOutOfBoundsException; - -// __________ Implementation __________ - -/** Helper for accessing a calc document - @author Björn Milcke - */ -public class CalcHelper -{ - public CalcHelper( XSpreadsheetDocument aDoc ) - { - maSpreadSheetDoc = aDoc; - initSpreadSheet(); - } - - // ____________________ - - public XSpreadsheet getChartSheet() throws RuntimeException - { - XNameAccess aSheetsNA = (XNameAccess) UnoRuntime.queryInterface( - XNameAccess.class, maSpreadSheetDoc.getSheets() ); - - XSpreadsheet aSheet = null; - try - { - aSheet = (XSpreadsheet) UnoRuntime.queryInterface( - XSpreadsheet.class, aSheetsNA.getByName( msChartSheetName ) ); - } - catch( NoSuchElementException ex ) - { - System.out.println( "Couldn't find sheet with name " + msChartSheetName + ": " + ex ); - } - catch( Exception ex ) - {} - - return aSheet; - } - - // ____________________ - - public XSpreadsheet getDataSheet() throws RuntimeException - { - XNameAccess aSheetsNA = (XNameAccess) UnoRuntime.queryInterface( - XNameAccess.class, maSpreadSheetDoc.getSheets() ); - - XSpreadsheet aSheet = null; - if( aSheetsNA != null ) - { - try - { - aSheet = (XSpreadsheet) UnoRuntime.queryInterface( - XSpreadsheet.class, aSheetsNA.getByName( msDataSheetName ) ); - } - catch( NoSuchElementException ex ) - { - System.out.println( "Couldn't find sheet with name " + msDataSheetName + ": " + ex ); - } - catch( Exception ex ) - {} - } - - return aSheet; - } - - // ____________________ - - /** Insert a chart using the given name as name of the OLE object and the range as correspoding - range of data to be used for rendering. The chart is placed in the sheet for charts at - position aUpperLeft extending as large as given in aExtent. - - The service name must be the name of a diagram service that can be instantiated via the - factory of the chart document - */ - public XChartDocument insertChart( - String sChartName, - CellRangeAddress aRange, - Point aUpperLeft, - Size aExtent, - String sChartServiceName ) - { - XChartDocument aResult = null; - XTableChartsSupplier aSheet; - - // get the sheet to insert the chart - try - { - aSheet = (XTableChartsSupplier) UnoRuntime.queryInterface( - XTableChartsSupplier.class, getChartSheet() ); - } - catch( Exception ex ) - { - System.out.println( "Sheet not found" + ex ); - return aResult; - } - - XTableCharts aChartCollection = aSheet.getCharts(); - XNameAccess aChartCollectionNA = (XNameAccess) UnoRuntime.queryInterface( - XNameAccess.class, aChartCollection ); - - if( aChartCollectionNA != null && - ! aChartCollectionNA.hasByName( sChartName ) ) - { - Rectangle aRect = new Rectangle( aUpperLeft.X, aUpperLeft.Y, aExtent.Width, aExtent.Height ); - - CellRangeAddress[] aAddresses = new CellRangeAddress[ 1 ]; - aAddresses[ 0 ] = aRange; - - // first bool: ColumnHeaders - // second bool: RowHeaders - aChartCollection.addNewByName( sChartName, aRect, aAddresses, true, false ); - - try - { - XTableChart aTableChart = (XTableChart) UnoRuntime.queryInterface( - XTableChart.class, aChartCollectionNA.getByName( sChartName )); - - // the table chart is an embedded object which contains the chart document - aResult = (XChartDocument) UnoRuntime.queryInterface( - XChartDocument.class, - ((XEmbeddedObjectSupplier) UnoRuntime.queryInterface( - XEmbeddedObjectSupplier.class, - aTableChart )).getEmbeddedObject()); - - // create a diagram via the factory and set this as new diagram - aResult.setDiagram( - (XDiagram) UnoRuntime.queryInterface( - XDiagram.class, - ((XMultiServiceFactory) UnoRuntime.queryInterface( - XMultiServiceFactory.class, - aResult )).createInstance( sChartServiceName ))); - } - catch( NoSuchElementException ex ) - { - System.out.println( "Couldn't find chart with name " + sChartName + ": " + ex ); - } - catch( Exception ex ) - {} - } - - return aResult; - } - - // ____________________ - - /** Fill a rectangular range with random numbers. - The first column has increasing values - */ - public XCellRange insertRandomRange( int nColumnCount, int nRowCount ) - { - XCellRange aRange = null; - - // get the sheet to insert the chart - try - { - XSpreadsheet aSheet = getDataSheet(); - XCellRange aSheetRange = (XCellRange) UnoRuntime.queryInterface( XCellRange.class, aSheet ); - - aRange = aSheetRange.getCellRangeByPosition( - 0, 0, - nColumnCount - 1, nRowCount - 1 ); - - int nCol, nRow; - double fBase = 0.0; - double fRange = 10.0; - double fValue; - Random aGenerator = new Random(); - - - for( nCol = 0; nCol < nColumnCount; nCol++ ) - { - if( 0 == nCol ) - { - (aSheet.getCellByPosition( nCol, 0 )).setFormula( "X" ); - } - else - { - (aSheet.getCellByPosition( nCol, 0 )).setFormula( "Random " + nCol ); - } - - for( nRow = 1; nRow < nRowCount; nRow++ ) - { - if( 0 == nCol ) - { - // x values: ascending numbers - fValue = (double)nRow + aGenerator.nextDouble(); - } - else - { - fValue = fBase + ( aGenerator.nextGaussian() * fRange ); - } - - // put value into cell - - // note: getCellByPosition is a method at ...table.XCellRange which - // the XSpreadsheet inherits via ...sheet.XSheetCellRange - (aSheet.getCellByPosition( nCol, nRow )).setValue( fValue ); - } - } - - } - catch( Exception ex ) - { - System.out.println( "Sheet not found" + ex ); - } - - return aRange; - } - - // ____________________ - - public XCellRange insertFormulaRange( int nColumnCount, int nRowCount ) - { - XCellRange aRange = null; - - // get the sheet to insert the chart - try - { - XSpreadsheet aSheet = getDataSheet(); - XCellRange aSheetRange = (XCellRange) UnoRuntime.queryInterface( XCellRange.class, aSheet ); - - aRange = aSheetRange.getCellRangeByPosition( - 0, 0, - nColumnCount - 1, nRowCount - 1 ); - - int nCol, nRow; - double fValue; - double fFactor = 2.0 * java.lang.Math.PI / (double)(nRowCount - 1); - String aFormula; - - // set variable factor for cos formula - int nFactorCol = nColumnCount + 2; - (aSheet.getCellByPosition( nFactorCol - 1, 0 )).setValue( 0.2 ); - - XText xCellText = (XText) UnoRuntime.queryInterface( XText.class, aSheet.getCellByPosition( nFactorCol - 1, 1 ) ); - xCellText.setString( "Change the factor above and\nwatch the changes in the chart" ); - - for( nCol = 0; nCol < nColumnCount; nCol++ ) - { - for( nRow = 0; nRow < nRowCount; nRow++ ) - { - if( 0 == nCol ) - { - // x values: ascending numbers - fValue = (double)nRow * fFactor; - (aSheet.getCellByPosition( nCol, nRow )).setValue( fValue ); - } - else - { - aFormula = new String( "=" ); - if( nCol % 2 == 0 ) - aFormula += "SIN"; - else - aFormula += "COS"; - aFormula += "(INDIRECT(ADDRESS(" + (nRow + 1) + ";1)))+RAND()*INDIRECT(ADDRESS(1;" + nFactorCol + "))"; - (aSheet.getCellByPosition( nCol, nRow )).setFormula( aFormula ); - } - } - } - - } - catch( Exception ex ) - { - System.out.println( "Sheet not found" + ex ); - } - - return aRange; - } - - // ____________________ - - /** Bring the sheet containing charts visually to the foreground - */ - public void raiseChartSheet() - { - ((XSpreadsheetView) UnoRuntime.queryInterface( - XSpreadsheetView.class, - ((XModel) UnoRuntime.queryInterface( - XModel.class, - maSpreadSheetDoc )).getCurrentController()) ).setActiveSheet( getChartSheet() ); - } - - - // __________ private members and methods __________ - - private final String msDataSheetName = "Data"; - private final String msChartSheetName = "Chart"; - - private XSpreadsheetDocument maSpreadSheetDoc; - - - // ____________________ - - /** create two sheets, one for data and one for charts in the document - */ - private void initSpreadSheet() - { - if( maSpreadSheetDoc != null ) - { - XSpreadsheets aSheets = maSpreadSheetDoc.getSheets(); - XNameContainer aSheetsNC = (XNameContainer) UnoRuntime.queryInterface( - XNameContainer.class, aSheets ); - XIndexAccess aSheetsIA = (XIndexAccess) UnoRuntime.queryInterface( - XIndexAccess.class, aSheets ); - - if( aSheets != null && - aSheetsNC != null && - aSheetsIA != null ) - { - try - { - // remove all sheets except one - for( int i = aSheetsIA.getCount() - 1; i > 0; i-- ) - { - aSheetsNC.removeByName( - ( (XNamed) UnoRuntime.queryInterface( - XNamed.class, aSheetsIA.getByIndex( i ) )).getName() ); - } - - XNamed aFirstSheet = (XNamed) UnoRuntime.queryInterface( - XNamed.class, - aSheetsIA.getByIndex( 0 )); - - // first sheet becomes data sheet - aFirstSheet.setName( msDataSheetName ); - - // second sheet becomes chart sheet - aSheets.insertNewByName( msChartSheetName, (short)1 ); - } - catch( Exception ex ) - { - System.out.println( "Couldn't initialize Spreadsheet Document: " + ex ); - } - } - } - } -} diff --git a/odk/examples/DevelopersGuide/Charts/ChartHelper.java b/odk/examples/DevelopersGuide/Charts/ChartHelper.java deleted file mode 100644 index 5d44dc03..00000000 --- a/odk/examples/DevelopersGuide/Charts/ChartHelper.java +++ /dev/null @@ -1,261 +0,0 @@ -/************************************************************************* - * - * 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. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * 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. - * - *************************************************************************/ - -// __________ Imports __________ - - -// base classes -import com.sun.star.uno.XInterface; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.Any; - -// factory for creating components -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.lang.XComponent; -import com.sun.star.beans.XPropertySet; - -// application specific classes -import com.sun.star.chart.XChartDocument; -import com.sun.star.chart.XDiagram; -import com.sun.star.drawing.*; -import com.sun.star.frame.XModel; -import com.sun.star.text.XTextDocument; -import com.sun.star.text.XTextContent; -import com.sun.star.text.XTextCursor; -import com.sun.star.text.XText; -//import com.sun.star.text.VertOrientation; -//import com.sun.star.text.HoriOrientation; -import com.sun.star.document.XEmbeddedObjectSupplier; - -// base graphics things -import com.sun.star.awt.Point; -import com.sun.star.awt.Size; - -// Exceptions -import com.sun.star.uno.RuntimeException; -import com.sun.star.container.NoSuchElementException; -import com.sun.star.beans.UnknownPropertyException; -import com.sun.star.lang.IndexOutOfBoundsException; - -// __________ Implementation __________ - -/** Helper for creating an OLE chart - @author Björn Milcke - */ -public class ChartHelper -{ - public ChartHelper( XModel aContainerDoc ) - { - maContainerDocument = aContainerDoc; - } - - public XChartDocument insertOLEChartInWriter( - String sChartName, - Point aUpperLeft, - Size aExtent, - String sChartServiceName ) - { - XChartDocument aResult = null; - - XMultiServiceFactory aFact = (XMultiServiceFactory) - UnoRuntime.queryInterface(XMultiServiceFactory.class, - maContainerDocument ); - - if( aFact != null ) - { - try - { - XTextContent xTextContent = (XTextContent)UnoRuntime.queryInterface( - XTextContent.class, - aFact.createInstance("com.sun.star.text.TextEmbeddedObject")); - - if ( xTextContent != null ) - { - XPropertySet xPropSet = (XPropertySet)UnoRuntime.queryInterface( - XPropertySet.class, xTextContent); - - Any aAny = new Any(String.class, msChartClassID); - xPropSet.setPropertyValue("CLSID", aAny ); - - XTextDocument xTextDoc = (XTextDocument) - UnoRuntime.queryInterface(XTextDocument.class, - maContainerDocument); - XText xText = xTextDoc.getText(); - XTextCursor xCursor = xText.createTextCursor(); - - //insert embedded object in text -> object will be created - xText.insertTextContent( xCursor, xTextContent, true ); - - // set size and position - XShape xShape = (XShape)UnoRuntime.queryInterface( - XShape.class, xTextContent); - xShape.setSize( aExtent ); - - aAny = new Any(Short.class, - new Short(com.sun.star.text.VertOrientation.NONE)); - xPropSet.setPropertyValue("VertOrient", aAny ); - aAny = new Any(Short.class, - new Short(com.sun.star.text.HoriOrientation.NONE)); - xPropSet.setPropertyValue("HoriOrient", aAny ); - aAny = new Any(Integer.class, new Integer(aUpperLeft.Y)); - xPropSet.setPropertyValue("VertOrientPosition", aAny ); - aAny = new Any(Integer.class, new Integer(aUpperLeft.X)); - xPropSet.setPropertyValue("HoriOrientPosition", aAny ); - - // retrieve the chart document as model of the OLE shape - aResult = (XChartDocument) UnoRuntime.queryInterface( - XChartDocument.class, - xPropSet.getPropertyValue( "Model" )); - - // create a diagram via the factory and set this as - // new diagram - aResult.setDiagram( - (XDiagram) UnoRuntime.queryInterface( - XDiagram.class, - ((XMultiServiceFactory) UnoRuntime.queryInterface( - XMultiServiceFactory.class, - aResult )).createInstance(sChartServiceName ))); - } - } catch( Exception ex) - { - System.out.println( "caught exception: " + ex ); - } - } - - return aResult; - } - - public XChartDocument insertOLEChartInDraw( - String sChartName, - Point aUpperLeft, - Size aExtent, - String sChartServiceName ) - { - XChartDocument aResult = null; - - XShapes aPage = null; - - // try interface for multiple pages in a document - XDrawPagesSupplier aSupplier = (XDrawPagesSupplier) - UnoRuntime.queryInterface(XDrawPagesSupplier.class, - maContainerDocument ); - - if( aSupplier != null ) - { - try - { - // get first page - aPage = (XShapes) UnoRuntime.queryInterface( - XShapes.class, aSupplier.getDrawPages().getByIndex( 0 ) ); - } - catch( Exception ex ) - { - System.out.println( "First page not found in shape collection: " + - ex ); - } - } - else - { - // try interface for single draw page (e.g. spreadsheet) - XDrawPageSupplier aOnePageSupplier = (XDrawPageSupplier) - UnoRuntime.queryInterface(XDrawPageSupplier.class, - maContainerDocument ); - - if( aOnePageSupplier != null ) - { - aPage = (XShapes) UnoRuntime.queryInterface( - XShapes.class, aOnePageSupplier.getDrawPage()); - } - } - - if( aPage != null ) - { - XMultiServiceFactory aFact = (XMultiServiceFactory) - UnoRuntime.queryInterface(XMultiServiceFactory.class, - maContainerDocument ); - - if( aFact != null ) - { - try - { - // create an OLE shape - XShape aShape = (XShape) UnoRuntime.queryInterface( - XShape.class, - aFact.createInstance( "com.sun.star.drawing.OLE2Shape" )); - - // insert the shape into the page - aPage.add( aShape ); - aShape.setPosition( aUpperLeft ); - aShape.setSize( aExtent ); - - // make the OLE shape a chart - XPropertySet aShapeProp = (XPropertySet) - UnoRuntime.queryInterface(XPropertySet.class, aShape ); - if( aShapeProp != null ) - { - // set the class id for charts - aShapeProp.setPropertyValue( "CLSID", msChartClassID ); - - // retrieve the chart document as model of the OLE shape - aResult = (XChartDocument) UnoRuntime.queryInterface( - XChartDocument.class, - aShapeProp.getPropertyValue( "Model" )); - - // create a diagram via the factory and set this as - // new diagram - aResult.setDiagram( - (XDiagram) UnoRuntime.queryInterface( - XDiagram.class, - ((XMultiServiceFactory) UnoRuntime.queryInterface( - XMultiServiceFactory.class, - aResult )).createInstance(sChartServiceName ))); - } - } - catch( Exception ex ) - { - System.out.println( "Couldn't change the OLE shape into a chart: " + ex ); - } - } - } - - return aResult; - } - - - // __________ private members and methods __________ - - private final String msChartClassID = "12dcae26-281f-416f-a234-c3086127382e"; - - private XModel maContainerDocument; -} diff --git a/odk/examples/DevelopersGuide/Charts/ChartInCalc.java b/odk/examples/DevelopersGuide/Charts/ChartInCalc.java deleted file mode 100644 index 44ae4603..00000000 --- a/odk/examples/DevelopersGuide/Charts/ChartInCalc.java +++ /dev/null @@ -1,424 +0,0 @@ -/************************************************************************* - * - * 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. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * 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. - * - *************************************************************************/ - -// __________ Imports __________ - -// base classes -import com.sun.star.uno.XInterface; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.lang.*; - -// property access -import com.sun.star.beans.*; - -// application specific classes -import com.sun.star.chart.*; -import com.sun.star.drawing.*; - -import com.sun.star.table.CellRangeAddress; -import com.sun.star.table.XCellRange; -import com.sun.star.sheet.XCellRangeAddressable; - -import com.sun.star.frame.XModel; -import com.sun.star.frame.XController; - -import com.sun.star.util.XNumberFormatsSupplier; -import com.sun.star.util.XNumberFormats; - -// base graphics things -import com.sun.star.awt.Point; -import com.sun.star.awt.Size; -import com.sun.star.awt.Rectangle; -import com.sun.star.awt.FontWeight; -import com.sun.star.awt.FontRelief; - -// Exceptions -import com.sun.star.uno.Exception; -import com.sun.star.uno.RuntimeException; -import com.sun.star.beans.UnknownPropertyException; -import com.sun.star.lang.IndexOutOfBoundsException; -import com.sun.star.util.MalformedNumberFormatException; - - -// __________ Implementation __________ - -/** Create a spreadsheet add some data and add a chart - @author Björn Milcke - */ -public class ChartInCalc -{ - // ____________________ - - public static void main( String args[] ) - { - Helper aHelper = new Helper( args ); - - CalcHelper aCalcHelper = new CalcHelper( aHelper.createSpreadsheetDocument() ); - - // insert a cell range with 4 columns and 24 rows filled with random numbers - XCellRange aRange = aCalcHelper.insertRandomRange( 4, 24 ); - CellRangeAddress aRangeAddress = ((XCellRangeAddressable) UnoRuntime.queryInterface( - XCellRangeAddressable.class, aRange)).getRangeAddress(); - - // change view to sheet containing the chart - aCalcHelper.raiseChartSheet(); - - // the unit for measures is 1/100th of a millimeter - // position at (1cm, 1cm) - Point aPos = new Point( 1000, 1000 ); - - // size of the chart is 15cm x 9.271cm - Size aExtent = new Size( 15000, 9271 ); - - // insert a new chart into the "Chart" sheet of the - // spreadsheet document - XChartDocument aChartDoc = aCalcHelper.insertChart( - "ScatterChart", - aRangeAddress, - aPos, - aExtent, - "com.sun.star.chart.XYDiagram" ); - - // instantiate test class with newly created chart - ChartInCalc aTest = new ChartInCalc( aChartDoc ); - - try - { - aTest.lockControllers(); - - aTest.testDiagram(); - aTest.testArea(); - aTest.testWall(); - aTest.testTitle(); - aTest.testAxis(); - aTest.testGrid(); - - // show an intermediate state, ... - aTest.unlockControllers(); - aTest.lockControllers(); - - // ..., because the following takes a while: - // an internet URL has to be resolved - aTest.testDataRowProperties(); - aTest.testDataPointProperties(); - - aTest.unlockControllers(); - } - catch( Exception ex ) - { - System.out.println( "UNO Exception caught: " + ex ); - System.out.println( "Message: " + ex.getMessage() ); - } - - System.exit( 0 ); - } - - - // ________________________________________ - - public ChartInCalc( XChartDocument aChartDoc ) - { - maChartDocument = aChartDoc; - maDiagram = maChartDocument.getDiagram(); - } - - // ____________________ - - public void lockControllers() - throws RuntimeException - { - ((XModel) UnoRuntime.queryInterface( XModel.class, maChartDocument )).lockControllers(); - } - - // ____________________ - - public void unlockControllers() - throws RuntimeException - { - ((XModel) UnoRuntime.queryInterface( XModel.class, maChartDocument )).unlockControllers(); - } - - // ____________________ - - public void testDiagram() - throws RuntimeException, UnknownPropertyException, PropertyVetoException, - com.sun.star.lang.IllegalArgumentException, WrappedTargetException - { - XPropertySet aDiaProp = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, maDiagram ); - - if( aDiaProp != null ) - { - // change chart type - aDiaProp.setPropertyValue( "Lines", new Boolean( true )); - - // change attributes for all series - // set line width to 0.5mm - aDiaProp.setPropertyValue( "LineWidth", new Integer( 50 )); - } - } - - // ____________________ - - public void testDataRowProperties() - throws RuntimeException, UnknownPropertyException, PropertyVetoException, - com.sun.star.lang.IllegalArgumentException, WrappedTargetException - { - // change properties of the data series - try - { - XPropertySet aSeriesProp; - for( int i = 1; i <= 3; i++ ) - { - aSeriesProp = maDiagram.getDataRowProperties( i ); - aSeriesProp.setPropertyValue( "LineColor", new Integer( - 0x400000 * i + - 0x005000 * i + - 0x0000ff - 0x40 * i )); - if( 1 == i ) - { - StringBuffer sUrl = new StringBuffer("file:///"); - try { - /* for use without net it's easier to load a local graphic */ - java.io.File sourceFile = new java.io.File("bullet.gif"); - sUrl.append(sourceFile.getCanonicalPath().replace('\\', '/')); - } catch (java.io.IOException e) { - sUrl = new StringBuffer("http://graphics.openoffice.org/chart/bullet1.gif"); - } - - // set a bitmap via URL as symbol for the first series - aSeriesProp.setPropertyValue( "SymbolType", new Integer( ChartSymbolType.BITMAPURL )); - aSeriesProp.setPropertyValue( "SymbolBitmapURL", sUrl.toString() ); - } - else - { - aSeriesProp.setPropertyValue( "SymbolType", new Integer( ChartSymbolType.SYMBOL1 )); - aSeriesProp.setPropertyValue( "SymbolSize", new Size( 250, 250 )); - } - } - } - catch( IndexOutOfBoundsException ex ) - { - System.out.println( "Oops, there not enough series for setting properties: " + ex ); - } - } - - // ____________________ - - public void testDataPointProperties() - throws RuntimeException, UnknownPropertyException, PropertyVetoException, - com.sun.star.lang.IllegalArgumentException, WrappedTargetException - { - // set properties for a single data point - try - { - // determine the maximum value of the first series - int nMaxIndex = 0; - - XChartDataArray aDataArray = (XChartDataArray) UnoRuntime.queryInterface( - XChartDataArray.class, maChartDocument.getData()); - double aData[][] = aDataArray.getData(); - - int i; - double fMax = aData[ 0 ][ 1 ]; - for( i = 1; i < aData.length; i++ ) - { - if( aData[ i ][ 1 ] > fMax ) - { - fMax = aData[ i ][ 1 ]; - nMaxIndex = i; - } - } - - // first parameter is the index of the point, the second one is the series - XPropertySet aPointProp = maDiagram.getDataPointProperties( 0, 1 ); - - // set a different, larger symbol - aPointProp.setPropertyValue( "SymbolType", new Integer( ChartSymbolType.SYMBOL6 )); - aPointProp.setPropertyValue( "SymbolSize", new Size( 600, 600 )); - - // add a label text with bold font, bordeaux red 14pt - aPointProp.setPropertyValue( "DataCaption", new Integer( ChartDataCaption.VALUE )); - aPointProp.setPropertyValue( "CharHeight", new Float( 14.0 )); - aPointProp.setPropertyValue( "CharColor", new Integer( 0x993366 )); - aPointProp.setPropertyValue( "CharWeight", new Float( FontWeight.BOLD )); - } - catch( IndexOutOfBoundsException ex ) - { - System.out.println( "Oops, there not enough data points or series for setting properties: " + ex ); - } - } - - // ____________________ - - public void testArea() - throws RuntimeException, UnknownPropertyException, PropertyVetoException, - com.sun.star.lang.IllegalArgumentException, WrappedTargetException - { - XPropertySet aArea = maChartDocument.getArea(); - - if( aArea != null ) - { - // change background color of entire chart - aArea.setPropertyValue( "FillStyle", FillStyle.SOLID ); - aArea.setPropertyValue( "FillColor", new Integer( 0xeeeeee )); - } - } - - // ____________________ - - public void testWall() - throws RuntimeException, UnknownPropertyException, PropertyVetoException, - com.sun.star.lang.IllegalArgumentException, WrappedTargetException - { - XPropertySet aWall = ((X3DDisplay) UnoRuntime.queryInterface( - X3DDisplay.class, maDiagram )).getWall(); - - // change background color of area - aWall.setPropertyValue( "FillStyle", FillStyle.SOLID ); - aWall.setPropertyValue( "FillColor", new Integer( 0xcccccc )); - } - - // ____________________ - - public void testTitle() - throws RuntimeException, UnknownPropertyException, PropertyVetoException, - com.sun.star.lang.IllegalArgumentException, WrappedTargetException - { - // change main title - XPropertySet aDocProp = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, maChartDocument ); - aDocProp.setPropertyValue( "HasMainTitle", new Boolean( true )); - - XShape aTitle = maChartDocument.getTitle(); - XPropertySet aTitleProp = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, aTitle ); - - // set new text - if( aTitleProp != null ) - { - aTitleProp.setPropertyValue( "String", "Random Scatter Chart" ); - aTitleProp.setPropertyValue( "CharHeight", new Float(14.0) ); - } - - // align title with y axis - XShape aAxis = (XShape) UnoRuntime.queryInterface( - XShape.class, ((XAxisYSupplier) UnoRuntime.queryInterface( - XAxisYSupplier.class, maDiagram )).getYAxis() ); - - if( aAxis != null && - aTitle != null ) - { - Point aPos = aTitle.getPosition(); - aPos.X = ( aAxis.getPosition() ).X; - aTitle.setPosition( aPos ); - } - } - - // ____________________ - - public void testAxis() - throws RuntimeException, UnknownPropertyException, PropertyVetoException, - com.sun.star.lang.IllegalArgumentException, WrappedTargetException, - MalformedNumberFormatException - { - // x axis - XPropertySet aAxisProp = ((XAxisXSupplier) UnoRuntime.queryInterface( - XAxisXSupplier.class, maDiagram )).getXAxis(); - if( aAxisProp != null ) - { - aAxisProp.setPropertyValue( "Max", new Integer( 24 )); - aAxisProp.setPropertyValue( "StepMain", new Integer( 3 )); - } - - // change number format for y axis - aAxisProp = ((XAxisYSupplier) UnoRuntime.queryInterface( - XAxisYSupplier.class, maDiagram )).getYAxis(); - - // add a new custom number format and get the new key - int nNewNumberFormat = 0; - XNumberFormatsSupplier aNumFmtSupp = (XNumberFormatsSupplier) UnoRuntime.queryInterface( - XNumberFormatsSupplier.class, maChartDocument ); - - if( aNumFmtSupp != null ) - { - XNumberFormats aFormats = aNumFmtSupp.getNumberFormats(); - Locale aLocale = new Locale( "de", "DE", "de" ); - - String aFormatStr = aFormats.generateFormat( nNewNumberFormat, aLocale, true, true, (short)3, (short)1 ); - nNewNumberFormat = aFormats.addNew( aFormatStr, aLocale ); - } - - if( aAxisProp != null ) - { - aAxisProp.setPropertyValue( "NumberFormat", new Integer( nNewNumberFormat )); - } - } - - // ____________________ - - public void testGrid() - throws RuntimeException, UnknownPropertyException, PropertyVetoException, - com.sun.star.lang.IllegalArgumentException, WrappedTargetException - { - // y major grid - XPropertySet aGridProp = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, - ( (XAxisYSupplier) UnoRuntime.queryInterface( - XAxisYSupplier.class, maDiagram )).getYMainGrid()); - - if( aGridProp != null ) - { - LineDash aDash = new LineDash(); - aDash.Style = DashStyle.ROUND; - aDash.Dots = 2; - aDash.DotLen = 10; - aDash.Dashes = 1; - aDash.DashLen = 200; - aDash.Distance = 100; - - aGridProp.setPropertyValue( "LineColor", new Integer( 0x999999 )); - aGridProp.setPropertyValue( "LineStyle", LineStyle.DASH ); - aGridProp.setPropertyValue( "LineDash", aDash ); - aGridProp.setPropertyValue( "LineWidth", new Integer( 30 )); - } - } - - - // ______________________________ - // - // private members - // ______________________________ - - private XChartDocument maChartDocument; - private XDiagram maDiagram; -} diff --git a/odk/examples/DevelopersGuide/Charts/ChartInDraw.java b/odk/examples/DevelopersGuide/Charts/ChartInDraw.java deleted file mode 100644 index ed21c900..00000000 --- a/odk/examples/DevelopersGuide/Charts/ChartInDraw.java +++ /dev/null @@ -1,308 +0,0 @@ -/************************************************************************* - * - * 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. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * 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. - * - *************************************************************************/ - -// __________ Imports __________ - -// base classes -import com.sun.star.uno.XInterface; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.lang.*; - -// property access -import com.sun.star.beans.*; - -// application specific classes -import com.sun.star.chart.*; -import com.sun.star.drawing.*; - -import com.sun.star.table.CellRangeAddress; -import com.sun.star.frame.XModel; -import com.sun.star.frame.XController; - -import com.sun.star.util.XNumberFormatsSupplier; -import com.sun.star.util.XNumberFormats; - -// base graphics things -import com.sun.star.awt.Point; -import com.sun.star.awt.Size; -import com.sun.star.awt.Rectangle; -import com.sun.star.awt.FontWeight; -import com.sun.star.awt.FontRelief; - -// Exceptions -import com.sun.star.uno.Exception; -import com.sun.star.uno.RuntimeException; -import com.sun.star.beans.UnknownPropertyException; -import com.sun.star.lang.IndexOutOfBoundsException; -import com.sun.star.util.MalformedNumberFormatException; - - -// __________ Implementation __________ - -/** Create a spreadsheet add some data and add a chart - @author Björn Milcke - */ -public class ChartInDraw -{ - // ____________________ - - public static void main( String args[] ) - { - Helper aHelper = new Helper( args ); - - ChartHelper aChartHelper = new ChartHelper( aHelper.createDrawingDocument()); - - // the unit for measures is 1/100th of a millimeter - // position at (1cm, 1cm) - Point aPos = new Point( 1000, 1000 ); - - // size of the chart is 15cm x 12cm - Size aExtent = new Size( 15000, 13000 ); - - // insert a new chart into the "Chart" sheet of the - // spreadsheet document - XChartDocument aChartDoc = aChartHelper.insertOLEChartInDraw( - "BarChart", - aPos, - aExtent, - "com.sun.star.chart.BarDiagram" ); - - // instantiate test class with newly created chart - ChartInDraw aTest = new ChartInDraw( aChartDoc ); - - try - { - aTest.lockControllers(); - - aTest.testArea(); - aTest.testWall(); - aTest.testTitle(); - aTest.testLegend(); - aTest.testThreeD(); - - aTest.unlockControllers(); - } - catch( Exception ex ) - { - System.out.println( "UNO Exception caught: " + ex ); - System.out.println( "Message: " + ex.getMessage() ); - } - - System.exit( 0 ); - } - - - // ________________________________________ - - public ChartInDraw( XChartDocument aChartDoc ) - { - maChartDocument = aChartDoc; - maDiagram = maChartDocument.getDiagram(); - } - - // ____________________ - - public void lockControllers() - throws RuntimeException - { - ((XModel) UnoRuntime.queryInterface( XModel.class, maChartDocument )).lockControllers(); - } - - // ____________________ - - public void unlockControllers() - throws RuntimeException - { - ((XModel) UnoRuntime.queryInterface( XModel.class, maChartDocument )).unlockControllers(); - } - - // ____________________ - - public void testArea() - throws RuntimeException, UnknownPropertyException, PropertyVetoException, - com.sun.star.lang.IllegalArgumentException, WrappedTargetException - { - XPropertySet aArea = maChartDocument.getArea(); - - if( aArea != null ) - { - // change background color of entire chart - aArea.setPropertyValue( "FillStyle", FillStyle.SOLID ); - aArea.setPropertyValue( "FillColor", new Integer( 0xeeeeee )); - } - } - - // ____________________ - - public void testWall() - throws RuntimeException, UnknownPropertyException, PropertyVetoException, - com.sun.star.lang.IllegalArgumentException, WrappedTargetException - { - XPropertySet aWall = ((X3DDisplay) UnoRuntime.queryInterface( - X3DDisplay.class, maDiagram )).getWall(); - - // change background color of area - aWall.setPropertyValue( "FillColor", new Integer( 0xcccccc )); - aWall.setPropertyValue( "FillStyle", FillStyle.SOLID ); - } - - // ____________________ - - public void testTitle() - throws RuntimeException, UnknownPropertyException, PropertyVetoException, - com.sun.star.lang.IllegalArgumentException, WrappedTargetException - { - // change main title - XPropertySet aDocProp = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, maChartDocument ); - aDocProp.setPropertyValue( "HasMainTitle", new Boolean( true )); - - XShape aTitle = maChartDocument.getTitle(); - XPropertySet aTitleProp = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, aTitle ); - - // set new text - if( aTitleProp != null ) - { - aTitleProp.setPropertyValue( "String", "Bar Chart in a Draw Document" ); - } - } - - // ____________________ - - public void testLegend() - throws RuntimeException, UnknownPropertyException, PropertyVetoException, - com.sun.star.lang.IllegalArgumentException, WrappedTargetException - { - XShape aLegend = maChartDocument.getLegend(); - XPropertySet aLegendProp = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, aLegend ); - - aLegendProp.setPropertyValue( "Alignment", ChartLegendPosition.LEFT ); - aLegendProp.setPropertyValue( "FillStyle", FillStyle.SOLID ); - aLegendProp.setPropertyValue( "FillColor", new Integer( 0xeeddee )); - } - - // ____________________ - - public void testThreeD() - throws RuntimeException, UnknownPropertyException, PropertyVetoException, - com.sun.star.lang.IllegalArgumentException, WrappedTargetException, - com.sun.star.lang.IndexOutOfBoundsException - { - XPropertySet aDiaProp = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, maDiagram ); - Boolean aTrue = new Boolean( true ); - - aDiaProp.setPropertyValue( "Dim3D", aTrue ); - aDiaProp.setPropertyValue( "Deep", aTrue ); - // from Chart3DBarProperties: - aDiaProp.setPropertyValue( "SolidType", new Integer( ChartSolidType.CYLINDER )); - - // change floor color to Magenta6 - XPropertySet aFloor = ((X3DDisplay) UnoRuntime.queryInterface( - X3DDisplay.class, maDiagram )).getFloor(); - aFloor.setPropertyValue( "FillColor", new Integer( 0x6b2394 )); - - // apply changes to get a 3d scene - unlockControllers(); - lockControllers(); - - - // rotate scene to a different angle - HomogenMatrix aMatrix = new HomogenMatrix(); - HomogenMatrixLine aLines[] = new HomogenMatrixLine[] - { - new HomogenMatrixLine( 1.0, 0.0, 0.0, 0.0 ), - new HomogenMatrixLine( 0.0, 1.0, 0.0, 0.0 ), - new HomogenMatrixLine( 0.0, 0.0, 1.0, 0.0 ), - new HomogenMatrixLine( 0.0, 0.0, 0.0, 1.0 ) - }; - - aMatrix.Line1 = aLines[ 0 ]; - aMatrix.Line2 = aLines[ 1 ]; - aMatrix.Line3 = aLines[ 2 ]; - aMatrix.Line4 = aLines[ 3 ]; - - // rotate 10 degrees along the x axis - double fAngle = 10.0; - double fCosX = java.lang.Math.cos( java.lang.Math.PI / 180.0 * fAngle ); - double fSinX = java.lang.Math.sin( java.lang.Math.PI / 180.0 * fAngle ); - - // rotate -20 degrees along the y axis - fAngle = -20.0; - double fCosY = java.lang.Math.cos( java.lang.Math.PI / 180.0 * fAngle ); - double fSinY = java.lang.Math.sin( java.lang.Math.PI / 180.0 * fAngle ); - - // rotate -5 degrees along the z axis - fAngle = -5.0; - double fCosZ = java.lang.Math.cos( java.lang.Math.PI / 180.0 * fAngle ); - double fSinZ = java.lang.Math.sin( java.lang.Math.PI / 180.0 * fAngle ); - - aMatrix.Line1.Column1 = fCosY * fCosZ; - aMatrix.Line1.Column2 = fCosY * -fSinZ; - aMatrix.Line1.Column3 = fSinY; - - aMatrix.Line2.Column1 = fSinX * fSinY * fCosZ + fCosX * fSinZ; - aMatrix.Line2.Column2 = -fSinX * fSinY * fSinZ + fCosX * fCosZ; - aMatrix.Line2.Column3 = -fSinX * fCosY; - - aMatrix.Line3.Column1 = -fCosX * fSinY * fCosZ + fSinX * fSinZ; - aMatrix.Line3.Column2 = fCosX * fSinY * fSinZ + fSinX * fCosZ; - aMatrix.Line3.Column3 = fCosX * fCosY; - - aDiaProp.setPropertyValue( "D3DTransformMatrix", aMatrix ); - - // add a red light source - - // in a chart by default only the second (non-specular) light source is switched on - // light source 1 is a specular light source - aDiaProp.setPropertyValue( "D3DSceneLightColor1", new Integer( 0xff3333 )); - - // set direction - com.sun.star.drawing.Direction3D aDirection = new com.sun.star.drawing.Direction3D(); - - aDirection.DirectionX = -0.75; - aDirection.DirectionY = 0.5; - aDirection.DirectionZ = 0.5; - - aDiaProp.setPropertyValue( "D3DSceneLightDirection1", aDirection ); - aDiaProp.setPropertyValue( "D3DSceneLightOn1", new Boolean( true )); - } - - // ______________________________ - // - // private members - // ______________________________ - - private XChartDocument maChartDocument; - private XDiagram maDiagram; -} diff --git a/odk/examples/DevelopersGuide/Charts/ChartInWriter.java b/odk/examples/DevelopersGuide/Charts/ChartInWriter.java deleted file mode 100644 index 22108393..00000000 --- a/odk/examples/DevelopersGuide/Charts/ChartInWriter.java +++ /dev/null @@ -1,178 +0,0 @@ -/************************************************************************* - * - * 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. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * 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. - * - *************************************************************************/ - -// __________ Imports __________ - -// base classes -import com.sun.star.uno.XInterface; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.lang.*; - -// property access -import com.sun.star.beans.*; - -// application specific classes -import com.sun.star.chart.*; -import com.sun.star.drawing.*; -import com.sun.star.text.XTextDocument; - -import com.sun.star.table.CellRangeAddress; -import com.sun.star.frame.XModel; -import com.sun.star.frame.XController; - -import com.sun.star.util.XNumberFormatsSupplier; -import com.sun.star.util.XNumberFormats; - -// base graphics things -import com.sun.star.awt.Point; -import com.sun.star.awt.Size; -import com.sun.star.awt.Rectangle; -import com.sun.star.awt.FontWeight; -import com.sun.star.awt.FontRelief; - -// Exceptions -import com.sun.star.uno.Exception; -import com.sun.star.uno.RuntimeException; -import com.sun.star.beans.UnknownPropertyException; -import com.sun.star.lang.IndexOutOfBoundsException; -import com.sun.star.util.MalformedNumberFormatException; - - -// __________ Implementation __________ - -/** Test to create a writer document and insert an OLE Chart. - - Be careful! This does not really work. The Writer currently has no - interface for dealing with OLE objects. You can add an OLE shape to the - Writer's drawing layer, but it is not treated correctly as OLE object. - Thus, you can not activate the chart by double-clicking. The office may - also crash when the document is closed! - - @author Björn Milcke - */ -public class ChartInWriter -{ - // ____________________ - - public static void main( String args[] ) - { - Helper aHelper = new Helper( args ); - - ChartHelper aChartHelper = new ChartHelper( - (XModel) UnoRuntime.queryInterface( XModel.class, - aHelper.createTextDocument())); - - // the unit for measures is 1/100th of a millimeter - // position at (1cm, 1cm) - Point aPos = new Point( 1000, 1000 ); - - // size of the chart is 15cm x 12cm - Size aExtent = new Size( 15000, 13000 ); - - // insert a new chart into the "Chart" sheet of the - // spreadsheet document - XChartDocument aChartDoc = aChartHelper.insertOLEChartInWriter( - "BarChart", - aPos, - aExtent, - "com.sun.star.chart.AreaDiagram" ); - - // instantiate test class with newly created chart - ChartInWriter aTest = new ChartInWriter( aChartDoc ); - - try - { - aTest.lockControllers(); - - // do tests here - aTest.testWall(); - - aTest.unlockControllers(); - } - catch( Exception ex ) - { - System.out.println( "UNO Exception caught: " + ex ); - System.out.println( "Message: " + ex.getMessage() ); - } - - System.exit( 0 ); - } - - - // ________________________________________ - - public ChartInWriter( XChartDocument aChartDoc ) - { - maChartDocument = aChartDoc; - maDiagram = maChartDocument.getDiagram(); - } - - // ____________________ - - public void lockControllers() - throws RuntimeException - { - ((XModel) UnoRuntime.queryInterface( XModel.class, maChartDocument )).lockControllers(); - } - - // ____________________ - - public void unlockControllers() - throws RuntimeException - { - ((XModel) UnoRuntime.queryInterface( XModel.class, maChartDocument )).unlockControllers(); - } - - // ____________________ - - public void testWall() - throws RuntimeException, UnknownPropertyException, PropertyVetoException, - com.sun.star.lang.IllegalArgumentException, WrappedTargetException - { - XPropertySet aWall = ((X3DDisplay) UnoRuntime.queryInterface( - X3DDisplay.class, maDiagram )).getWall(); - - // change background color of area - aWall.setPropertyValue( "FillColor", new Integer( 0xeecc99 )); - aWall.setPropertyValue( "FillStyle", FillStyle.SOLID ); - } - - // ______________________________ - // - // private members - // ______________________________ - - private XChartDocument maChartDocument; - private XDiagram maDiagram; -} diff --git a/odk/examples/DevelopersGuide/Charts/Helper.java b/odk/examples/DevelopersGuide/Charts/Helper.java deleted file mode 100644 index cae86ca2..00000000 --- a/odk/examples/DevelopersGuide/Charts/Helper.java +++ /dev/null @@ -1,170 +0,0 @@ -/************************************************************************* - * - * 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. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * 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. - * - *************************************************************************/ - -// __________ Imports __________ - -import java.util.Random; - -// base classes -import com.sun.star.uno.XInterface; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XComponentContext; -import com.sun.star.lang.*; - -// factory for creating components -import com.sun.star.comp.servicemanager.ServiceManager; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.bridge.XUnoUrlResolver; -import com.sun.star.uno.XNamingService; -import com.sun.star.frame.XDesktop; -import com.sun.star.frame.XComponentLoader; - -// property access -import com.sun.star.beans.*; - -// container access -import com.sun.star.container.*; - -// application specific classes -import com.sun.star.sheet.XSpreadsheetDocument; -import com.sun.star.text.XTextDocument; - -import com.sun.star.document.XEmbeddedObjectSupplier; -import com.sun.star.frame.XModel; -import com.sun.star.frame.XController; - -// Exceptions -import com.sun.star.uno.RuntimeException; -import com.sun.star.container.NoSuchElementException; -import com.sun.star.beans.UnknownPropertyException; -import com.sun.star.lang.IndexOutOfBoundsException; - -// __________ Implementation __________ - -/** Helper for creating a calc document adding cell values and charts - @author Björn Milcke - */ -public class Helper -{ - public Helper( String[] args ) - { - // connect to a running office and get the ServiceManager - try { - // get the remote office component context - maContext = com.sun.star.comp.helper.Bootstrap.bootstrap(); - System.out.println("Connected to a running office ..."); - - // get the remote office service manager - maMCFactory = maContext.getServiceManager(); - } - catch( Exception e) { - System.out.println( "Couldn't get ServiceManager: " + e ); - e.printStackTrace(); - System.exit(1); - } - } - - // ____________________ - - public XSpreadsheetDocument createSpreadsheetDocument() - { - return (XSpreadsheetDocument) UnoRuntime.queryInterface( - XSpreadsheetDocument.class, createDocument( "scalc" )); - } - - // ____________________ - - public XModel createPresentationDocument() - { - return createDocument( "simpress" ); - } - - // ____________________ - - public XModel createDrawingDocument() - { - return createDocument( "sdraw" ); - } - - // ____________________ - - public XModel createTextDocument() - { - return createDocument( "swriter" ); - } - - // ____________________ - - public XModel createDocument( String sDocType ) - { - XModel aResult = null; - try - { - XComponentLoader aLoader = (XComponentLoader) - UnoRuntime.queryInterface(XComponentLoader.class, - maMCFactory.createInstanceWithContext("com.sun.star.frame.Desktop", - maContext) ); - - aResult = (XModel) UnoRuntime.queryInterface( - XModel.class, - aLoader.loadComponentFromURL( "private:factory/" + sDocType, - "_blank", - 0, - new PropertyValue[ 0 ] ) ); - } - catch( Exception e ) - { - System.err.println("Couldn't create Document of type "+ sDocType +": "+e); - e.printStackTrace(); - System.exit( 0 ); - } - - return aResult; - } - - public XComponentContext getComponentContext(){ - return maContext; - - } - - // __________ private members and methods __________ - - private final String msDataSheetName = "Data"; - private final String msChartSheetName = "Chart"; - private final String msChartName = "SampleChart"; - - private XComponentContext maContext; - private XMultiComponentFactory maMCFactory; - private XSpreadsheetDocument maSpreadSheetDoc; -} diff --git a/odk/examples/DevelopersGuide/Charts/JavaSampleChartAddIn.components b/odk/examples/DevelopersGuide/Charts/JavaSampleChartAddIn.components deleted file mode 100644 index e9a7baa4..00000000 --- a/odk/examples/DevelopersGuide/Charts/JavaSampleChartAddIn.components +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<components xmlns="http://openoffice.org/2010/uno-components"> - <component loader="com.sun.star.loader.Java2" uri="JavaSampleChartAddIn.uno.jar"> - <implementation name="JavaSampleChartAddIn"> - <service name="com.sun.star.comp.Chart.JavaSampleChartAddIn"/> - <service name="com.sun.star.chart.Diagram"/> - <service name="com.sun.star.chart.ChartAxisYSupplier"/> - </implementation> - </component> -</components> diff --git a/odk/examples/DevelopersGuide/Charts/JavaSampleChartAddIn.java b/odk/examples/DevelopersGuide/Charts/JavaSampleChartAddIn.java deleted file mode 100644 index fe599c13..00000000 --- a/odk/examples/DevelopersGuide/Charts/JavaSampleChartAddIn.java +++ /dev/null @@ -1,480 +0,0 @@ -/************************************************************************* - * - * 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. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * 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. - * - *************************************************************************/ - -// base classes -import com.sun.star.uno.XInterface; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.Type; -import com.sun.star.container.XIndexAccess; -import com.sun.star.lib.uno.helper.WeakBase; - -// factories -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.lang.XSingleServiceFactory; - -// graphics stuff -import com.sun.star.drawing.*; -import com.sun.star.awt.Point; -import com.sun.star.awt.Rectangle; -import com.sun.star.awt.Size; - -// chart stuff -import com.sun.star.chart.*; - -// property access -import com.sun.star.beans.*; - -// Add-In stuff -import com.sun.star.lang.XInitialization; -import com.sun.star.util.XRefreshable; -import com.sun.star.lang.XServiceName; -import com.sun.star.lang.XServiceInfo; -import com.sun.star.lang.XTypeProvider; - -// Exceptions -import com.sun.star.uno.Exception; -import com.sun.star.uno.RuntimeException; - -import javax.swing.JOptionPane; - -public class JavaSampleChartAddIn extends WeakBase implements - XInitialization, - XRefreshable, - XDiagram, - XServiceName, - XServiceInfo -{ - public JavaSampleChartAddIn() - {} - - // __________ interface methods __________ - - // XInitialization - public void initialize( Object[] aArguments ) - throws Exception, RuntimeException - { - if( aArguments.length > 0 ) - { - maChartDocument = (XChartDocument) UnoRuntime.queryInterface( - XChartDocument.class, aArguments[ 0 ]); - - XPropertySet aDocProp = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, maChartDocument ); - if( aDocProp != null ) - { - // set base diagram which will be extended in refresh() - aDocProp.setPropertyValue( "BaseDiagram", "com.sun.star.chart.XYDiagram" ); - } - - // get the draw page - XDrawPageSupplier aPageSupp = (XDrawPageSupplier) UnoRuntime.queryInterface( - XDrawPageSupplier.class, maChartDocument ); - if( aPageSupp != null ) - maDrawPage = (XDrawPage) UnoRuntime.queryInterface( - XDrawPage.class, aPageSupp.getDrawPage() ); - - // get a factory for creating shapes - maShapeFactory = (XMultiServiceFactory) UnoRuntime.queryInterface( - XMultiServiceFactory.class, maChartDocument ); - } - } - - // XRefreshable - public void refresh() throws RuntimeException - { - // recycle shapes in first call, if document was loaded - if( maBottomLine == null || - maTopLine == null ) - { - // try to recycle loaded shapes - XPropertySet aDocProp = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, maChartDocument ); - if( aDocProp != null ) - { - try - { - XIndexAccess aShapesIA = (XIndexAccess) UnoRuntime.queryInterface( - XIndexAccess.class, aDocProp.getPropertyValue( "AdditionalShapes" )); - if( aShapesIA != null && - aShapesIA.getCount() > 0 ) - { - XShape aShape; - String aName; - for( int i = aShapesIA.getCount() - 1; i >= 0; --i ) - { - aShape = (XShape) UnoRuntime.queryInterface( - XShape.class, aShapesIA.getByIndex( i )); - if( aShape != null ) - { - XPropertySet aProp = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, aShape ); - aName = (String) aProp.getPropertyValue( "Name" ); - - if( aName.equals( "top" )) - { - maTopLine = aShape; - } - else if( aName.equals( "bottom" )) - { - maBottomLine = aShape; - } - } - } - } - } - catch( Exception ex ) - { - JOptionPane.showMessageDialog( null, ex, "Exception caught", JOptionPane.WARNING_MESSAGE ); - } - } - } - - // create top line if it does not yet exist - try - { - if( maTopLine == null ) - { - maTopLine = (XShape) UnoRuntime.queryInterface( - XShape.class, maShapeFactory.createInstance( "com.sun.star.drawing.LineShape" )); - maDrawPage.add( maTopLine ); - - // make line red and thicker - XPropertySet aShapeProp = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, maTopLine ); - - aShapeProp.setPropertyValue( "LineColor", new Integer( 0xe01010 )); - aShapeProp.setPropertyValue( "LineWidth", new Integer( 50 )); - aShapeProp.setPropertyValue( "Name", "top" ); - } - } - catch( Exception ex ) - { - JOptionPane.showMessageDialog( null, ex, "Exception caught", JOptionPane.WARNING_MESSAGE ); - } - - // create bottom line if it does not yet exist - try - { - if( maBottomLine == null ) - { - maBottomLine = (XShape) UnoRuntime.queryInterface( - XShape.class, maShapeFactory.createInstance( "com.sun.star.drawing.LineShape" )); - maDrawPage.add( maBottomLine ); - - // make line green and thicker - XPropertySet aShapeProp = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, maBottomLine ); - - aShapeProp.setPropertyValue( "LineColor", new Integer( 0x10e010 )); - aShapeProp.setPropertyValue( "LineWidth", new Integer( 50 )); - aShapeProp.setPropertyValue( "Name", "bottom" ); - } - } - catch( Exception ex ) - { - JOptionPane.showMessageDialog( null, ex, "Exception caught", JOptionPane.WARNING_MESSAGE ); - } - - if( maTopLine == null || - maBottomLine == null ) - { - JOptionPane.showMessageDialog( null, "One of the lines is still null", "Assertion", JOptionPane.WARNING_MESSAGE ); - return; - } - - // position lines - // -------------- - - // get data - XChartDataArray aDataArray = (XChartDataArray) UnoRuntime.queryInterface( - XChartDataArray.class, maChartDocument.getData()); - double aData[][] = aDataArray.getData(); - - // get axes - XDiagram aDiagram = maChartDocument.getDiagram(); - XShape aXAxis = (XShape) UnoRuntime.queryInterface( - XShape.class, ((XAxisXSupplier) UnoRuntime.queryInterface( - XAxisXSupplier.class, aDiagram )).getXAxis() ); - XShape aYAxis = (XShape) UnoRuntime.queryInterface( - XShape.class, ((XAxisYSupplier) UnoRuntime.queryInterface( - XAxisYSupplier.class, aDiagram )).getYAxis() ); - - // calculate points for hull - final int nLength = aData.length; - int i, j; - double fMax, fMin; - - Point aMaxPtSeq[][] = new Point[ 1 ][]; - aMaxPtSeq[ 0 ] = new Point[ nLength ]; - Point aMinPtSeq[][] = new Point[ 1 ][]; - aMinPtSeq[ 0 ] = new Point[ nLength ]; - - for( i = 0; i < nLength; i++ ) - { - fMin = fMax = aData[ i ][ 1 ]; - for( j = 1; j < aData[ i ].length; j++ ) - { - if( aData[ i ][ j ] > fMax ) - fMax = aData[ i ][ j ]; - else if( aData[ i ][ j ] < fMin ) - fMin = aData[ i ][ j ]; - } - aMaxPtSeq[ 0 ][ i ] = new Point( getAxisPosition( aXAxis, aData[ i ][ 0 ], false ), - getAxisPosition( aYAxis, fMax, true )); - aMinPtSeq[ 0 ][ i ] = new Point( getAxisPosition( aXAxis, aData[ i ][ 0 ], false ), - getAxisPosition( aYAxis, fMin, true )); - } - - // apply point sequences to lines - try - { - XPropertySet aShapeProp = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, maTopLine ); - aShapeProp.setPropertyValue( "PolyPolygon", aMaxPtSeq ); - - aShapeProp = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, maBottomLine ); - aShapeProp.setPropertyValue( "PolyPolygon", aMinPtSeq ); - } - catch( Exception ex ) - { - JOptionPane.showMessageDialog( null, ex, "Exception caught", JOptionPane.WARNING_MESSAGE ); - } - } - - public void addRefreshListener( com.sun.star.util.XRefreshListener aListener ) - throws RuntimeException - { - // we don't want this but we have to implement the interface - } - - public void removeRefreshListener( com.sun.star.util.XRefreshListener aListener ) - throws RuntimeException - { - // we don't want this but we have to implement the interface - } - - - // XServiceName - public String getServiceName() throws RuntimeException - { - return new String( smServiceName ); - } - - // XServiceInfo - public boolean supportsService( String aServiceName ) - { - String[] aServices = getSupportedServiceNames_Static(); - int i, nLength = aServices.length; - boolean bResult = false; - - for( i = 0; !bResult && i < nLength; ++i ) - bResult = aServiceName.equals( aServices[ i ] ); - - return bResult; - } - - public String getImplementationName() - { - return( JavaSampleChartAddIn.class.getName() ); - } - - public String[] getSupportedServiceNames() - { - return getSupportedServiceNames_Static(); - } - - // XDiagram - public String getDiagramType() throws RuntimeException - { - return new String( smServiceName ); - } - - public XPropertySet getDataRowProperties( int nRow ) - throws com.sun.star.lang.IndexOutOfBoundsException, RuntimeException - { - return maChartDocument.getDiagram().getDataRowProperties( nRow ); - } - - public XPropertySet getDataPointProperties( int nCol, int nRow ) - throws com.sun.star.lang.IndexOutOfBoundsException, RuntimeException - { - return maChartDocument.getDiagram().getDataPointProperties( nCol, nRow ); - } - - // XShape : XDiagram - public Size getSize() throws RuntimeException - { - return ((XShape) UnoRuntime.queryInterface( XShape.class, maChartDocument.getDiagram())).getSize(); - } - public void setSize( Size aSize ) throws RuntimeException, PropertyVetoException - { - ((XShape) UnoRuntime.queryInterface( XShape.class, maChartDocument.getDiagram())).setSize( aSize ); - } - - public Point getPosition() throws RuntimeException - { - return ((XShape) UnoRuntime.queryInterface( XShape.class, maChartDocument.getDiagram())).getPosition(); - } - public void setPosition( Point aPos ) throws RuntimeException - { - ((XShape) UnoRuntime.queryInterface( XShape.class, maChartDocument.getDiagram())).setPosition( aPos ); - } - - // XShapeDescriptor : XShape : XDiagram - public String getShapeType() throws RuntimeException - { - return new String( "com.sun.star.comp.Chart.JavaSampleDiagramShape" ); - } - - - // __________ private members __________ - private com.sun.star.chart.XChartDocument maChartDocument; - private com.sun.star.drawing.XDrawPage maDrawPage; - private com.sun.star.lang.XMultiServiceFactory maShapeFactory; - - // shapes added by add-in - private com.sun.star.drawing.XShape maTopLine; - private com.sun.star.drawing.XShape maBottomLine; - - // __________ private methods __________ - - private int getAxisPosition( XShape aAxis, double fValue, boolean bVertical ) - { - int nResult = 0; - - if( aAxis != null ) - { - XPropertySet aAxisProp = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, aAxis ); - - try - { - double fMin, fMax; - fMin = ((Double) aAxisProp.getPropertyValue( "Min" )).doubleValue(); - fMax = ((Double) aAxisProp.getPropertyValue( "Max" )).doubleValue(); - double fRange = fMax - fMin; - - if( fMin <= fValue && fValue <= fMax && - fRange != 0 ) - { - if( bVertical ) - { - nResult = aAxis.getPosition().Y + - (int)((double)(aAxis.getSize().Height) * - (1.0 - (( fValue - fMin ) / fRange ))); - } - else - { - nResult = aAxis.getPosition().X + - (int)((double)(aAxis.getSize().Width) * - (( fValue - fMin ) / fRange )); - } - } - } - catch( Exception ex ) - { - JOptionPane.showMessageDialog( null, ex, "Exception caught", JOptionPane.WARNING_MESSAGE ); - } - } - return nResult; - } - - // __________ static things __________ - - private static final String smServiceName = "com.sun.star.comp.Chart.JavaSampleChartAddIn"; - - public static String[] getSupportedServiceNames_Static() - { - String[] aResult = { smServiceName, - "com.sun.star.chart.Diagram", - "com.sun.star.chart.ChartAxisYSupplier" }; - return aResult; - } - - - /** - * Returns a factory for creating the service. - * This method is called by the <code>JavaLoader</code> - * <p> - * @return returns a <code>XSingleServiceFactory</code> for creating the component - * @param implName the name of the implementation for which a service is desired - * @param multiFactory the service manager to be used if needed - * @param regKey the registryKey - * @see com.sun.star.comp.loader.JavaLoader - */ - public static XSingleServiceFactory __getServiceFactory( - String implName, - XMultiServiceFactory multiFactory, - com.sun.star.registry.XRegistryKey regKey ) - { - XSingleServiceFactory xSingleServiceFactory = null; - - if( implName.equals( JavaSampleChartAddIn.class.getName()) ) - { - xSingleServiceFactory = com.sun.star.comp.loader.FactoryHelper.getServiceFactory( - JavaSampleChartAddIn.class, smServiceName, - multiFactory, regKey ); - } - - return xSingleServiceFactory; - } - - /** - * Writes the service information into the given registry key. - * This method is called by the <code>JavaLoader</code> - * <p> - * @return returns true if the operation succeeded - * @param regKey the registryKey - * @see com.sun.star.comp.loader.JavaLoader - */ - // This method not longer necessary since OOo 3.4 where the component registration - // was changed to passive component registration. For more details see - // http://wiki.services.openoffice.org/wiki/Passive_Component_Registration - -// public static boolean __writeRegistryServiceInfo( com.sun.star.registry.XRegistryKey regKey ) -// { -// boolean bResult = true; - -// String[] aServices = getSupportedServiceNames_Static(); -// int i, nLength = aServices.length; - -// for( i = 0; i < nLength; ++i ) -// { -// bResult = bResult && com.sun.star.comp.loader.FactoryHelper.writeRegistryServiceInfo( -// JavaSampleChartAddIn.class.getName(), aServices[ i ], regKey ); -// } -// return bResult; -// } -} diff --git a/odk/examples/DevelopersGuide/Charts/ListenAtCalcRangeInDraw.java b/odk/examples/DevelopersGuide/Charts/ListenAtCalcRangeInDraw.java deleted file mode 100644 index 41ee1afb..00000000 --- a/odk/examples/DevelopersGuide/Charts/ListenAtCalcRangeInDraw.java +++ /dev/null @@ -1,211 +0,0 @@ -/************************************************************************* - * - * 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. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * 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. - * - *************************************************************************/ - -// __________ Imports __________ - -// base classes -import com.sun.star.uno.XInterface; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.lang.*; - -// property access -import com.sun.star.beans.*; - -// application specific classes -import com.sun.star.chart.*; -import com.sun.star.drawing.*; - -import com.sun.star.table.CellRangeAddress; -import com.sun.star.table.XCellRange; -import com.sun.star.sheet.XSpreadsheetDocument; - -import com.sun.star.frame.XModel; -import com.sun.star.frame.XController; - -import com.sun.star.util.XNumberFormatsSupplier; -import com.sun.star.util.XNumberFormats; - -// base graphics things -import com.sun.star.awt.Point; -import com.sun.star.awt.Size; -import com.sun.star.awt.Rectangle; -import com.sun.star.awt.FontWeight; -import com.sun.star.awt.FontRelief; - -// Exceptions -import com.sun.star.uno.Exception; -import com.sun.star.uno.RuntimeException; -import com.sun.star.beans.UnknownPropertyException; -import com.sun.star.lang.IndexOutOfBoundsException; -import com.sun.star.util.MalformedNumberFormatException; - - -// __________ Implementation __________ - -/** Create a spreadsheet add some data. - Create a presentation and add a chart. - Connect the chart to a calc range via a listener - @author Björn Milcke - */ -public class ListenAtCalcRangeInDraw implements XChartDataChangeEventListener -{ - public static void main( String args[] ) - { - ListenAtCalcRangeInDraw aMySelf = new ListenAtCalcRangeInDraw( args ); - - aMySelf.run(); - } - - public ListenAtCalcRangeInDraw( String args[] ) - { - Helper aHelper = new Helper( args ); - - maSheetDoc = aHelper.createSpreadsheetDocument(); - maDrawDoc = aHelper.createDrawingDocument(); - CalcHelper aCalcHelper = new CalcHelper( maSheetDoc ); - ChartHelper aChartHelper = new ChartHelper( maDrawDoc ); - - XCellRange aRange = aCalcHelper.insertFormulaRange( 3, 30 ); - - // the unit for measures is 1/100th of a millimeter - // position at (1cm, 1cm) - Point aPos = new Point( 1000, 1000 ); - - // size of the chart is 15cm x 9.271cm - Size aExtent = new Size( 15000, 9271 ); - - // insert a new chart into the "Chart" sheet of the - // spreadsheet document - maChartDocument = aChartHelper.insertOLEChartInDraw( - "ChartWithCalcData", - aPos, - aExtent, - "com.sun.star.chart.XYDiagram" ); - - // attach the data coming from the cell range to the chart - maChartData = (XChartData) UnoRuntime.queryInterface( XChartData.class, aRange ); - maChartDocument.attachData( maChartData ); - } - - // ____________________ - - public void run() - { - try - { - ((XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, maChartDocument )).setPropertyValue( - "HasSubTitle", new Boolean( true )); - - // start listening for death of spreadsheet - ((XComponent) UnoRuntime.queryInterface( - XComponent.class, maSheetDoc )).addEventListener( this ); - - // start listening for death of chart - ((XComponent) UnoRuntime.queryInterface( - XComponent.class, maChartDocument )).addEventListener( this ); - - //start listening for change of data - maChartData.addChartDataChangeEventListener( this ); - } - catch( Exception ex ) - { - System.out.println( "Oops: " + ex ); - } - - // call listener - ChartDataChangeEvent aEvent = new ChartDataChangeEvent(); - aEvent.Type = ChartDataChangeType.ALL; - chartDataChanged( aEvent ); - } - - // ____________________ - - // XEventListener (base of XChartDataChangeEventListener) - public void disposing( EventObject aSourceObj ) - { - if( UnoRuntime.queryInterface( XChartDocument.class, aSourceObj.Source ) != null ) - System.out.println( "Disconnecting Listener because Chart was shut down" ); - - if( UnoRuntime.queryInterface( XSpreadsheetDocument.class, aSourceObj.Source ) != null ) - System.out.println( "Disconnecting Listener because Spreadsheet was shut down" ); - - // remove data change listener - maChartData.removeChartDataChangeEventListener( this ); - - // remove dispose listeners - ((XComponent) UnoRuntime.queryInterface( - XComponent.class, maSheetDoc )).removeEventListener( this ); - ((XComponent) UnoRuntime.queryInterface( - XComponent.class, maChartDocument )).removeEventListener( this ); - - System.exit( 0 ); - } - - // ____________________ - - // XChartDataChangeEventListener - public void chartDataChanged( ChartDataChangeEvent aEvent ) - { - // update subtitle - String aTitle = new String( "Last Update: " + new java.util.Date( System.currentTimeMillis() )); - - try - { - XPropertySet aDocProp = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, maChartDocument ); - aDocProp.setPropertyValue( "HasMainTitle", new Boolean( true )); - - ((XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, maChartDocument.getSubTitle())).setPropertyValue( - "String", aTitle ); - - maChartDocument.attachData( maChartData ); - } - catch( Exception ex ) - { - System.out.println( "Oops: " + ex ); - } - - System.out.println( "Data has changed" ); - } - - - // __________ private __________ - - private XSpreadsheetDocument maSheetDoc; - private XModel maDrawDoc; - private XChartDocument maChartDocument; - private XChartData maChartData; -} diff --git a/odk/examples/DevelopersGuide/Charts/Makefile b/odk/examples/DevelopersGuide/Charts/Makefile deleted file mode 100644 index d6727662..00000000 --- a/odk/examples/DevelopersGuide/Charts/Makefile +++ /dev/null @@ -1,200 +0,0 @@ -#************************************************************************* -# -# 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. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. Neither the name of Sun Microsystems, Inc. nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# 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. -# -#************************************************************************** - -# Builds the Charts examples of the Developers Guide. - -PRJ=../../.. -SETTINGS=$(PRJ)/settings - -include $(SETTINGS)/settings.mk -include $(SETTINGS)/std.mk -include $(SETTINGS)/dk.mk - -# Define non-platform/compiler specific settings -SAMPLE_NAME=DevGuideChartExample -SAMPLE_CLASS_OUT = $(OUT_CLASS)/$(SAMPLE_NAME) -SAMPLE_GEN_OUT = $(OUT_MISC)/$(SAMPLE_NAME) - -APP1_NAME=ChartInCalc -APP1_JAR=$(SAMPLE_CLASS_OUT)/$(APP1_NAME).jar -APP2_NAME=ChartInDraw -APP2_JAR=$(SAMPLE_CLASS_OUT)/$(APP2_NAME).jar -APP3_NAME=ChartInWriter -APP3_JAR=$(SAMPLE_CLASS_OUT)/$(APP3_NAME).jar -APP4_NAME=ListenAtCalcRangeInDraw -APP4_JAR=$(SAMPLE_CLASS_OUT)/$(APP4_NAME).jar -APP5_NAME=SelectionChangeListener -APP5_JAR=$(SAMPLE_CLASS_OUT)/$(APP5_NAME).jar - -COMP_NAME=JavaSampleChartAddIn -COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT) -COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)") -COMP_JAR_NAME = $(COMP_NAME).uno.jar -COMP_JAR = $(SAMPLE_CLASS_OUT)/$(COMP_JAR_NAME) -COMP_MANIFESTFILE = $(SAMPLE_CLASS_OUT)/$(COMP_NAME).uno.Manifest -COMP_UNOPKG_MANIFEST = $(SAMPLE_CLASS_OUT)/$(COMP_NAME)/META-INF/manifest.xml -COMP_REGISTERFLAG = $(SAMPLE_GEN_OUT)/devguide_$(COMP_NAME)_register_component.flag -COMP_COMPONENTS=$(COMP_NAME).components - -COMPJAVAFILES = \ - JavaSampleChartAddIn.java - -APP_JAVAFILES = \ - Helper.java \ - CalcHelper.java \ - ChartHelper.java - -COMPCLASSFILES= $(patsubst %.java,$(SAMPLE_CLASS_OUT)/%.class,$(COMPJAVAFILES)) - -APP_CLASSFILES= $(patsubst %.java,$(SAMPLE_CLASS_OUT)/%.class,$(APP_JAVAFILES)) -APP_CLASSNAMES= $(patsubst %.java,%.class,$(APP_JAVAFILES)) - -$(COMP_NAME)_CLASSFILES = $(COMP_NAME).class - -SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\ - $(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT)) - - -# Targets -.PHONY: ALL -ALL : $(SAMPLE_NAME) - -include $(SETTINGS)/stdtarget.mk - -$(SAMPLE_CLASS_OUT)/%.Manifest : - -$(MKDIR) $(subst /,$(PS),$(@D)) - @echo RegistrationClassName: $(basename $(basename $(@F)))> $@ - -# rule for client/example application class files, explicit dependencies to common -# java files which are used in all examples. -$(SAMPLE_CLASS_OUT)/%.class : %.java $(APP_JAVAFILES) - -$(MKDIR) $(subst /,$(PS),$(@D)) - $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(SAMPLE_CLASS_OUT) $< $(APP_JAVAFILES) - -$(COMPCLASSFILES) : $(JAVAFILES) - -$(MKDIR) $(subst /,$(PS),$(@D)) - $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(SAMPLE_CLASS_OUT) $(COMPJAVAFILES) - -# rule for client/example application manifest file -$(SAMPLE_CLASS_OUT)/%.mf : - -$(MKDIR) $(subst /,$(PS),$(@D)) - @echo Main-Class: com.sun.star.lib.loader.Loader> $@ - $(ECHOLINE)>> $@ - @echo Name: com/sun/star/lib/loader/Loader.class>> $@ - @echo Application-Class: $*>> $@ - -# rule for client/example application jar file -$(SAMPLE_CLASS_OUT)/%.jar : $(SAMPLE_CLASS_OUT)/%.mf $(SAMPLE_CLASS_OUT)/%.class - -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) - -$(MKDIR) $(subst /,$(PS),$(@D)) - +cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) cvfm $(@F) $*.mf $**.class $(APP_CLASSNAMES) - - +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES) - -# rule for component jar file -$(COMP_JAR) : $(COMP_MANIFESTFILE) $(COMPCLASSFILES) - -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) - -$(MKDIR) $(subst /,$(PS),$(@D)) - cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES) - -# rule for component package manifest -$(SAMPLE_CLASS_OUT)/%/manifest.xml : - -$(MKDIR) $(subst /,$(PS),$(@D)) - @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@ - @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@ - @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@ - @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@ - @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_COMPONENTS)$(QM)"/$(CSEP)>> $@ - @echo $(OSEP)/manifest:manifest$(CSEP) >> $@ - -# rule for component pacakge file -$(COMP_PACKAGE) : $(COMP_JAR) $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS) - -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) - -$(MKDIR) $(subst /,$(PS),$(@D)) - $(SDK_ZIP) $@ $(COMP_COMPONENTS) - cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_ZIP) ../../bin/$(@F) -u $(<F) - cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) ../../../bin/$(@F) -u META-INF/manifest.xml - -$(COMP_REGISTERFLAG) : $(COMP_PACKAGE) -ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES" - -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) - -$(MKDIR) $(subst /,$(PS),$(@D)) - $(DEPLOYTOOL) $(COMP_PACKAGE_URL) - @echo flagged > $(subst /,$(PS),$@) -else - @echo -------------------------------------------------------------------------------- - @echo If you want to install your component automatically, please set the environment - @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only - @echo possible if no office instance is running. - @echo -------------------------------------------------------------------------------- -endif - -$(APP1_JAR) : $(SAMPLE_CLASS_OUT)/$(APP1_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP1_NAME).class -$(APP2_JAR) : $(SAMPLE_CLASS_OUT)/$(APP2_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP2_NAME).class -$(APP3_JAR) : $(SAMPLE_CLASS_OUT)/$(APP3_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP3_NAME).class -$(APP4_JAR) : $(SAMPLE_CLASS_OUT)/$(APP4_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP4_NAME).class -$(APP5_JAR) : $(SAMPLE_CLASS_OUT)/$(APP5_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP5_NAME).class - -$(SAMPLE_NAME) : $(COMP_REGISTERFLAG) $(APP1_JAR) $(APP2_JAR) $(APP3_JAR) $(APP4_JAR) $(APP5_JAR) - @echo -------------------------------------------------------------------------------- - @echo When you run the "$(QM)$(APP5_NAME)$(QM)" example please select the - @echo legend or the title to add a $(APP5_NAME). The example terminates - @echo when the document is closed. - @echo - - @echo Please use the following commands to execute the examples! - @echo - - @echo $(MAKE) $(APP1_NAME).run - @echo $(MAKE) $(APP2_NAME).run - @echo $(MAKE) $(APP3_NAME).run - @echo $(MAKE) $(APP4_NAME).run - @echo $(MAKE) $(APP5_NAME).run - @echo -------- - @echo The Chart add-in component was installed if SDK_AUTO_DEPLOYMENT = YES. - @echo Load the "$(QM)AddInChart.ods$(QM)" document in your office to see the new chart type, - @echo and see the example description. - @echo - - @echo $(MAKE) AddInChart.ods.load - @echo -------------------------------------------------------------------------------- - -%.run: $(SAMPLE_CLASS_OUT)/%.jar - $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< - -AddInChart.ods.load : $(REGISTERFLAG) - "$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@) - -.PHONY: clean -clean : - -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) - -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT)) - -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL))) diff --git a/odk/examples/DevelopersGuide/Charts/SelectionChangeListener.java b/odk/examples/DevelopersGuide/Charts/SelectionChangeListener.java deleted file mode 100644 index d895be7d..00000000 --- a/odk/examples/DevelopersGuide/Charts/SelectionChangeListener.java +++ /dev/null @@ -1,219 +0,0 @@ -/************************************************************************* - * - * 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. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * 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.XMessageBox; -import com.sun.star.awt.XWindowPeer; -import com.sun.star.frame.XDesktop; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.lang.*; -import com.sun.star.frame.XModel; -import com.sun.star.frame.XController; - -// application specific classes -import com.sun.star.chart.*; -import com.sun.star.uno.XComponentContext; -import com.sun.star.uno.XInterface; - -import com.sun.star.view.XSelectionChangeListener; -import com.sun.star.view.XSelectionSupplier; - -import com.sun.star.table.CellRangeAddress; -import com.sun.star.table.XCellRange; -import com.sun.star.sheet.XCellRangeAddressable; - -import com.sun.star.awt.Point; -import com.sun.star.awt.Rectangle; -import com.sun.star.awt.Size; -import com.sun.star.awt.XMessageBoxFactory; -import com.sun.star.awt.XWindow; - -// __________ Implementation __________ - -/** Create a spreadsheet add some data. - * Create a presentation and add a chart. - * Connect the chart to a calc range via a listener - * - * Note: This example does not work in StarOffice 6.0. It will be available - * in the StarOffice Accessibility release. - * - * @author Björn Milcke - */ -public class SelectionChangeListener implements XSelectionChangeListener { - public static void main( String args[] ) { - SelectionChangeListener aMySelf = new SelectionChangeListener( args ); - - aMySelf.run(); - } - - public SelectionChangeListener( String args[] ) { - Helper aHelper = new Helper( args ); - - maContext = aHelper.getComponentContext(); - - CalcHelper aCalcHelper = new CalcHelper( aHelper.createSpreadsheetDocument() ); - - // insert a cell range with 4 columns and 12 rows filled with random numbers - XCellRange aRange = aCalcHelper.insertRandomRange( 4, 12 ); - CellRangeAddress aRangeAddress = ((XCellRangeAddressable) UnoRuntime.queryInterface( - XCellRangeAddressable.class, aRange)).getRangeAddress(); - - // change view to sheet containing the chart - aCalcHelper.raiseChartSheet(); - - // the unit for measures is 1/100th of a millimeter - // position at (1cm, 1cm) - Point aPos = new Point( 1000, 1000 ); - - // size of the chart is 15cm x 9.271cm - Size aExtent = new Size( 15000, 9271 ); - - // insert a new chart into the "Chart" sheet of the - // spreadsheet document - maChartDocument = aCalcHelper.insertChart( - "SampleChart", - aRangeAddress, - aPos, - aExtent, - "com.sun.star.chart.XYDiagram" ); - } - - // ____________________ - - public void run() { - boolean bTrying = true; - - while( bTrying ) { - // start listening for selection changes - XSelectionSupplier aSelSupp = (XSelectionSupplier) UnoRuntime.queryInterface( - XSelectionSupplier.class, - (((XModel) UnoRuntime.queryInterface( - XModel.class, maChartDocument )).getCurrentController()) ); - if( aSelSupp != null ) { - aSelSupp.addSelectionChangeListener( this ); - System.out.println( "Successfully attached as selection change listener" ); - bTrying = false; - } - - // start listening for death of Controller - XComponent aComp = (XComponent) UnoRuntime.queryInterface( XComponent.class, aSelSupp ); - if( aComp != null ) { - aComp.addEventListener( this ); - System.out.println( "Successfully attached as dispose listener" ); - } - - try { - Thread.currentThread().sleep( 500 ); - } catch( InterruptedException ex ) { - } - } - } - - // ____________________ - - // XEventListener (base of XSelectionChangeListener) - public void disposing( EventObject aSourceObj ) { - System.out.println( "disposing called. detaching as listener" ); - - // stop listening for selection changes - XSelectionSupplier aCtrl = (XSelectionSupplier) UnoRuntime.queryInterface( - XSelectionSupplier.class, aSourceObj ); - if( aCtrl != null ) - aCtrl.removeSelectionChangeListener( this ); - - // remove as dispose listener - XComponent aComp = (XComponent) UnoRuntime.queryInterface( XComponent.class, aSourceObj ); - if( aComp != null ) - aComp.removeEventListener( this ); - - // bail out - System.exit( 0 ); - } - - // ____________________ - - // XSelectionChangeListener - public void selectionChanged( EventObject aEvent ) { - XController aCtrl = (XController) UnoRuntime.queryInterface( XController.class, aEvent.Source ); - if( aCtrl != null ) { - XMultiComponentFactory mMCF = maContext.getServiceManager(); - - MyMessageBox aMsgBox = new MyMessageBox(mMCF); - - aMsgBox.start(); - - System.out.println("Listener finished"); - } - } - - // __________ private __________ - - private class MyMessageBox extends Thread{ - private XMultiComponentFactory mMCF; - - public MyMessageBox(XMultiComponentFactory xMCF){ - mMCF = xMCF; - } - - public void run() { - XDesktop aDesktop = null; - XInterface aToolKit = null; - try { - Thread.sleep(1000); - } catch (InterruptedException ex) { - ex.printStackTrace(); - } - try { - Object oDesktop = mMCF.createInstanceWithContext("com.sun.star.frame.Desktop", maContext); - Object oToolKit = mMCF.createInstanceWithContext("com.sun.star.awt.Toolkit", maContext); - - aDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, oDesktop); - aToolKit = (XInterface) UnoRuntime.queryInterface(XInterface.class, oToolKit); - } catch (Exception ex) { - ex.printStackTrace(); - } - - XWindow xWin = aDesktop.getCurrentFrame().getContainerWindow(); - XWindowPeer aWinPeer = (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, xWin); - - Rectangle aRect = new Rectangle(); - int button = com.sun.star.awt.MessageBoxButtons.BUTTONS_OK; - XMessageBoxFactory aMBF = (XMessageBoxFactory) UnoRuntime.queryInterface(XMessageBoxFactory.class, aToolKit); - XMessageBox xMB = aMBF.createMessageBox(aWinPeer, aRect, "infobox" , button, "Event-Notify", "Listener was called, selcetion has changed"); - xMB.execute(); - } - } - - private XChartDocument maChartDocument; - private XComponentContext maContext; -} diff --git a/odk/examples/DevelopersGuide/Charts/bullet.gif b/odk/examples/DevelopersGuide/Charts/bullet.gif Binary files differdeleted file mode 100644 index 0f8efd14..00000000 --- a/odk/examples/DevelopersGuide/Charts/bullet.gif +++ /dev/null diff --git a/odk/examples/DevelopersGuide/Charts/makefile.mk b/odk/examples/DevelopersGuide/Charts/makefile.mk deleted file mode 100644 index 225d8d7e..00000000 --- a/odk/examples/DevelopersGuide/Charts/makefile.mk +++ /dev/null @@ -1,75 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/..$/.. -PRJNAME=odk -TARGET=copying - -#---------------------------------------------------------------- -.INCLUDE: settings.mk -.INCLUDE: $(PRJ)$/util$/makefile.pmk -#---------------------------------------------------------------- - -#---------------------------------------------------- -# this makefile is only used for copying the example -# files into the SDK -#---------------------------------------------------- - -CHARTS_FILES=\ - $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/AddInChart.ods \ - $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/CalcHelper.java \ - $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/ChartHelper.java \ - $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/ChartInCalc.java \ - $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/ChartInDraw.java \ - $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/ChartInWriter.java \ - $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/Helper.java \ - $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/JavaSampleChartAddIn.java \ - $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/ListenAtCalcRangeInDraw.java \ - $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/SelectionChangeListener.java \ - $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/bullet.gif \ - $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/Makefile - -DIR_FILE_LIST= \ - $(CHARTS_FILES) - -DIR_DIRECTORY_LIST=$(uniq $(DIR_FILE_LIST:d)) -DIR_CREATE_FLAG=$(MISC)$/devguide_charts_dirs_created.txt -DIR_FILE_FLAG=$(MISC)$/devguide_charts.txt - -#-------------------------------------------------- -# TARGETS -#-------------------------------------------------- -all : \ - $(DIR_FILE_LIST) \ - $(DIR_FILE_FLAG) - -#-------------------------------------------------- -# use global rules -#-------------------------------------------------- -.INCLUDE: $(PRJ)$/util$/odk_rules.pmk - - |