1*34dd1e25SAndrew Rist /**************************************************************
2*34dd1e25SAndrew Rist  *
3*34dd1e25SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*34dd1e25SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*34dd1e25SAndrew Rist  * distributed with this work for additional information
6*34dd1e25SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*34dd1e25SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*34dd1e25SAndrew Rist  * "License"); you may not use this file except in compliance
9*34dd1e25SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*34dd1e25SAndrew Rist  *
11*34dd1e25SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*34dd1e25SAndrew Rist  *
13*34dd1e25SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*34dd1e25SAndrew Rist  * software distributed under the License is distributed on an
15*34dd1e25SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*34dd1e25SAndrew Rist  * KIND, either express or implied.  See the License for the
17*34dd1e25SAndrew Rist  * specific language governing permissions and limitations
18*34dd1e25SAndrew Rist  * under the License.
19*34dd1e25SAndrew Rist  *
20*34dd1e25SAndrew Rist  *************************************************************/
21*34dd1e25SAndrew Rist 
22*34dd1e25SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // __________ Imports __________
25cdf0e10cSrcweir 
26cdf0e10cSrcweir // base classes
27cdf0e10cSrcweir import com.sun.star.uno.XInterface;
28cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
29cdf0e10cSrcweir import com.sun.star.lang.*;
30cdf0e10cSrcweir 
31cdf0e10cSrcweir // property access
32cdf0e10cSrcweir import com.sun.star.beans.*;
33cdf0e10cSrcweir 
34cdf0e10cSrcweir // application specific classes
35cdf0e10cSrcweir import com.sun.star.chart.*;
36cdf0e10cSrcweir import com.sun.star.drawing.*;
37cdf0e10cSrcweir 
38cdf0e10cSrcweir import com.sun.star.table.CellRangeAddress;
39cdf0e10cSrcweir import com.sun.star.table.XCellRange;
40cdf0e10cSrcweir import com.sun.star.sheet.XCellRangeAddressable;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir import com.sun.star.frame.XModel;
43cdf0e10cSrcweir import com.sun.star.frame.XController;
44cdf0e10cSrcweir 
45cdf0e10cSrcweir import com.sun.star.util.XNumberFormatsSupplier;
46cdf0e10cSrcweir import com.sun.star.util.XNumberFormats;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir // base graphics things
49cdf0e10cSrcweir import com.sun.star.awt.Point;
50cdf0e10cSrcweir import com.sun.star.awt.Size;
51cdf0e10cSrcweir import com.sun.star.awt.Rectangle;
52cdf0e10cSrcweir import com.sun.star.awt.FontWeight;
53cdf0e10cSrcweir import com.sun.star.awt.FontRelief;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir // Exceptions
56cdf0e10cSrcweir import com.sun.star.uno.Exception;
57cdf0e10cSrcweir import com.sun.star.uno.RuntimeException;
58cdf0e10cSrcweir import com.sun.star.beans.UnknownPropertyException;
59cdf0e10cSrcweir import com.sun.star.lang.IndexOutOfBoundsException;
60cdf0e10cSrcweir import com.sun.star.util.MalformedNumberFormatException;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 
63cdf0e10cSrcweir // __________ Implementation __________
64cdf0e10cSrcweir 
65cdf0e10cSrcweir /** Create a spreadsheet add some data and add a chart
66cdf0e10cSrcweir     @author Björn Milcke
67cdf0e10cSrcweir  */
68cdf0e10cSrcweir public class ChartInCalc
69cdf0e10cSrcweir {
70cdf0e10cSrcweir     // ____________________
71cdf0e10cSrcweir 
main( String args[] )72cdf0e10cSrcweir     public static void main( String args[] )
73cdf0e10cSrcweir     {
74cdf0e10cSrcweir         Helper aHelper = new Helper( args );
75cdf0e10cSrcweir 
76cdf0e10cSrcweir         CalcHelper aCalcHelper = new CalcHelper( aHelper.createSpreadsheetDocument() );
77cdf0e10cSrcweir 
78cdf0e10cSrcweir         // insert a cell range with 4 columns and 24 rows filled with random numbers
79cdf0e10cSrcweir         XCellRange aRange = aCalcHelper.insertRandomRange( 4, 24 );
80cdf0e10cSrcweir         CellRangeAddress aRangeAddress = ((XCellRangeAddressable) UnoRuntime.queryInterface(
81cdf0e10cSrcweir             XCellRangeAddressable.class, aRange)).getRangeAddress();
82cdf0e10cSrcweir 
83cdf0e10cSrcweir         // change view to sheet containing the chart
84cdf0e10cSrcweir         aCalcHelper.raiseChartSheet();
85cdf0e10cSrcweir 
86cdf0e10cSrcweir         // the unit for measures is 1/100th of a millimeter
87cdf0e10cSrcweir         // position at (1cm, 1cm)
88cdf0e10cSrcweir         Point aPos    = new Point( 1000, 1000 );
89cdf0e10cSrcweir 
90cdf0e10cSrcweir         // size of the chart is 15cm x 9.271cm
91cdf0e10cSrcweir         Size  aExtent = new Size( 15000, 9271 );
92cdf0e10cSrcweir 
93cdf0e10cSrcweir         // insert a new chart into the "Chart" sheet of the
94cdf0e10cSrcweir         // spreadsheet document
95cdf0e10cSrcweir         XChartDocument aChartDoc = aCalcHelper.insertChart(
96cdf0e10cSrcweir             "ScatterChart",
97cdf0e10cSrcweir             aRangeAddress,
98cdf0e10cSrcweir             aPos,
99cdf0e10cSrcweir             aExtent,
100cdf0e10cSrcweir             "com.sun.star.chart.XYDiagram" );
101cdf0e10cSrcweir 
102cdf0e10cSrcweir         // instantiate test class with newly created chart
103cdf0e10cSrcweir         ChartInCalc aTest   = new ChartInCalc( aChartDoc );
104cdf0e10cSrcweir 
105cdf0e10cSrcweir         try
106cdf0e10cSrcweir         {
107cdf0e10cSrcweir             aTest.lockControllers();
108cdf0e10cSrcweir 
109cdf0e10cSrcweir             aTest.testDiagram();
110cdf0e10cSrcweir             aTest.testArea();
111cdf0e10cSrcweir             aTest.testWall();
112cdf0e10cSrcweir             aTest.testTitle();
113cdf0e10cSrcweir             aTest.testAxis();
114cdf0e10cSrcweir             aTest.testGrid();
115cdf0e10cSrcweir 
116cdf0e10cSrcweir             // show an intermediate state, ...
117cdf0e10cSrcweir             aTest.unlockControllers();
118cdf0e10cSrcweir             aTest.lockControllers();
119cdf0e10cSrcweir 
120cdf0e10cSrcweir             // ..., because the following takes a while:
121cdf0e10cSrcweir             // an internet URL has to be resolved
122cdf0e10cSrcweir             aTest.testDataRowProperties();
123cdf0e10cSrcweir             aTest.testDataPointProperties();
124cdf0e10cSrcweir 
125cdf0e10cSrcweir             aTest.unlockControllers();
126cdf0e10cSrcweir         }
127cdf0e10cSrcweir         catch( Exception ex )
128cdf0e10cSrcweir         {
129cdf0e10cSrcweir             System.out.println( "UNO Exception caught: " + ex );
130cdf0e10cSrcweir             System.out.println( "Message: " + ex.getMessage() );
131cdf0e10cSrcweir         }
132cdf0e10cSrcweir 
133cdf0e10cSrcweir         System.exit( 0 );
134cdf0e10cSrcweir     }
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     // ________________________________________
138cdf0e10cSrcweir 
ChartInCalc( XChartDocument aChartDoc )139cdf0e10cSrcweir     public ChartInCalc( XChartDocument aChartDoc )
140cdf0e10cSrcweir     {
141cdf0e10cSrcweir         maChartDocument = aChartDoc;
142cdf0e10cSrcweir         maDiagram       = maChartDocument.getDiagram();
143cdf0e10cSrcweir     }
144cdf0e10cSrcweir 
145cdf0e10cSrcweir     // ____________________
146cdf0e10cSrcweir 
lockControllers()147cdf0e10cSrcweir     public void lockControllers()
148cdf0e10cSrcweir         throws RuntimeException
149cdf0e10cSrcweir     {
150cdf0e10cSrcweir         ((XModel) UnoRuntime.queryInterface( XModel.class, maChartDocument )).lockControllers();
151cdf0e10cSrcweir     }
152cdf0e10cSrcweir 
153cdf0e10cSrcweir     // ____________________
154cdf0e10cSrcweir 
unlockControllers()155cdf0e10cSrcweir     public void unlockControllers()
156cdf0e10cSrcweir         throws RuntimeException
157cdf0e10cSrcweir     {
158cdf0e10cSrcweir         ((XModel) UnoRuntime.queryInterface( XModel.class, maChartDocument )).unlockControllers();
159cdf0e10cSrcweir     }
160cdf0e10cSrcweir 
161cdf0e10cSrcweir     // ____________________
162cdf0e10cSrcweir 
testDiagram()163cdf0e10cSrcweir     public void testDiagram()
164cdf0e10cSrcweir         throws RuntimeException, UnknownPropertyException, PropertyVetoException,
165cdf0e10cSrcweir                com.sun.star.lang.IllegalArgumentException, WrappedTargetException
166cdf0e10cSrcweir     {
167cdf0e10cSrcweir         XPropertySet aDiaProp = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, maDiagram );
168cdf0e10cSrcweir 
169cdf0e10cSrcweir         if( aDiaProp != null )
170cdf0e10cSrcweir         {
171cdf0e10cSrcweir             // change chart type
172cdf0e10cSrcweir             aDiaProp.setPropertyValue( "Lines", new Boolean( true ));
173cdf0e10cSrcweir 
174cdf0e10cSrcweir             // change attributes for all series
175cdf0e10cSrcweir             // set line width to 0.5mm
176cdf0e10cSrcweir             aDiaProp.setPropertyValue( "LineWidth",  new Integer( 50 ));
177cdf0e10cSrcweir         }
178cdf0e10cSrcweir     }
179cdf0e10cSrcweir 
180cdf0e10cSrcweir     // ____________________
181cdf0e10cSrcweir 
testDataRowProperties()182cdf0e10cSrcweir     public void testDataRowProperties()
183cdf0e10cSrcweir         throws RuntimeException, UnknownPropertyException, PropertyVetoException,
184cdf0e10cSrcweir                com.sun.star.lang.IllegalArgumentException, WrappedTargetException
185cdf0e10cSrcweir     {
186cdf0e10cSrcweir         // change properties of the data series
187cdf0e10cSrcweir         try
188cdf0e10cSrcweir         {
189cdf0e10cSrcweir             XPropertySet aSeriesProp;
190cdf0e10cSrcweir             for( int i = 1; i <= 3; i++ )
191cdf0e10cSrcweir             {
192cdf0e10cSrcweir                 aSeriesProp = maDiagram.getDataRowProperties( i );
193cdf0e10cSrcweir                 aSeriesProp.setPropertyValue( "LineColor", new Integer(
194cdf0e10cSrcweir                                                   0x400000 * i +
195cdf0e10cSrcweir                                                   0x005000 * i +
196cdf0e10cSrcweir                                                   0x0000ff - 0x40 * i ));
197cdf0e10cSrcweir                 if( 1 == i )
198cdf0e10cSrcweir                 {
199cdf0e10cSrcweir                     StringBuffer sUrl = new StringBuffer("file:///");
200cdf0e10cSrcweir                     try {
201cdf0e10cSrcweir                         /* for use without net it's easier to load a local graphic */
202cdf0e10cSrcweir                         java.io.File sourceFile = new java.io.File("bullet.gif");
203cdf0e10cSrcweir                         sUrl.append(sourceFile.getCanonicalPath().replace('\\', '/'));
204cdf0e10cSrcweir                     } catch (java.io.IOException e) {
205cdf0e10cSrcweir                         sUrl = new StringBuffer("http://graphics.openoffice.org/chart/bullet1.gif");
206cdf0e10cSrcweir                     }
207cdf0e10cSrcweir 
208cdf0e10cSrcweir                     // set a bitmap via URL as symbol for the first series
209cdf0e10cSrcweir                     aSeriesProp.setPropertyValue( "SymbolType", new Integer( ChartSymbolType.BITMAPURL ));
210cdf0e10cSrcweir                     aSeriesProp.setPropertyValue( "SymbolBitmapURL", sUrl.toString() );
211cdf0e10cSrcweir                 }
212cdf0e10cSrcweir                 else
213cdf0e10cSrcweir                 {
214cdf0e10cSrcweir                     aSeriesProp.setPropertyValue( "SymbolType", new Integer( ChartSymbolType.SYMBOL1 ));
215cdf0e10cSrcweir                     aSeriesProp.setPropertyValue( "SymbolSize", new Size( 250, 250 ));
216cdf0e10cSrcweir                 }
217cdf0e10cSrcweir             }
218cdf0e10cSrcweir         }
219cdf0e10cSrcweir         catch( IndexOutOfBoundsException ex )
220cdf0e10cSrcweir         {
221cdf0e10cSrcweir             System.out.println( "Oops, there not enough series for setting properties: " + ex );
222cdf0e10cSrcweir         }
223cdf0e10cSrcweir     }
224cdf0e10cSrcweir 
225cdf0e10cSrcweir     // ____________________
226cdf0e10cSrcweir 
testDataPointProperties()227cdf0e10cSrcweir     public void testDataPointProperties()
228cdf0e10cSrcweir         throws RuntimeException, UnknownPropertyException, PropertyVetoException,
229cdf0e10cSrcweir                com.sun.star.lang.IllegalArgumentException, WrappedTargetException
230cdf0e10cSrcweir     {
231cdf0e10cSrcweir         // set properties for a single data point
232cdf0e10cSrcweir         try
233cdf0e10cSrcweir         {
234cdf0e10cSrcweir             // determine the maximum value of the first series
235cdf0e10cSrcweir             int nMaxIndex = 0;
236cdf0e10cSrcweir 
237cdf0e10cSrcweir             XChartDataArray aDataArray = (XChartDataArray) UnoRuntime.queryInterface(
238cdf0e10cSrcweir                 XChartDataArray.class, maChartDocument.getData());
239cdf0e10cSrcweir             double aData[][] = aDataArray.getData();
240cdf0e10cSrcweir 
241cdf0e10cSrcweir             int i;
242cdf0e10cSrcweir             double fMax = aData[ 0 ][ 1 ];
243cdf0e10cSrcweir             for( i = 1; i < aData.length; i++ )
244cdf0e10cSrcweir             {
245cdf0e10cSrcweir                 if( aData[ i ][ 1 ] > fMax )
246cdf0e10cSrcweir                 {
247cdf0e10cSrcweir                     fMax = aData[ i ][ 1 ];
248cdf0e10cSrcweir                     nMaxIndex = i;
249cdf0e10cSrcweir                 }
250cdf0e10cSrcweir             }
251cdf0e10cSrcweir 
252cdf0e10cSrcweir             // first parameter is the index of the point, the second one is the series
253cdf0e10cSrcweir             XPropertySet aPointProp = maDiagram.getDataPointProperties( 0, 1 );
254cdf0e10cSrcweir 
255cdf0e10cSrcweir             // set a different, larger symbol
256cdf0e10cSrcweir             aPointProp.setPropertyValue( "SymbolType", new Integer( ChartSymbolType.SYMBOL6 ));
257cdf0e10cSrcweir             aPointProp.setPropertyValue( "SymbolSize", new Size( 600, 600 ));
258cdf0e10cSrcweir 
259cdf0e10cSrcweir             // add a label text with bold font, bordeaux red 14pt
260cdf0e10cSrcweir             aPointProp.setPropertyValue( "DataCaption", new Integer( ChartDataCaption.VALUE ));
261cdf0e10cSrcweir             aPointProp.setPropertyValue( "CharHeight",  new Float( 14.0 ));
262cdf0e10cSrcweir             aPointProp.setPropertyValue( "CharColor",   new Integer( 0x993366 ));
263cdf0e10cSrcweir             aPointProp.setPropertyValue( "CharWeight",  new Float( FontWeight.BOLD ));
264cdf0e10cSrcweir         }
265cdf0e10cSrcweir         catch( IndexOutOfBoundsException ex )
266cdf0e10cSrcweir         {
267cdf0e10cSrcweir             System.out.println( "Oops, there not enough data points or series for setting properties: " + ex );
268cdf0e10cSrcweir         }
269cdf0e10cSrcweir     }
270cdf0e10cSrcweir 
271cdf0e10cSrcweir     // ____________________
272cdf0e10cSrcweir 
testArea()273cdf0e10cSrcweir     public void testArea()
274cdf0e10cSrcweir         throws RuntimeException, UnknownPropertyException, PropertyVetoException,
275cdf0e10cSrcweir                com.sun.star.lang.IllegalArgumentException, WrappedTargetException
276cdf0e10cSrcweir     {
277cdf0e10cSrcweir         XPropertySet   aArea = maChartDocument.getArea();
278cdf0e10cSrcweir 
279cdf0e10cSrcweir         if( aArea != null )
280cdf0e10cSrcweir         {
281cdf0e10cSrcweir             // change background color of entire chart
282cdf0e10cSrcweir             aArea.setPropertyValue( "FillStyle", FillStyle.SOLID );
283cdf0e10cSrcweir             aArea.setPropertyValue( "FillColor", new Integer( 0xeeeeee ));
284cdf0e10cSrcweir         }
285cdf0e10cSrcweir     }
286cdf0e10cSrcweir 
287cdf0e10cSrcweir     // ____________________
288cdf0e10cSrcweir 
testWall()289cdf0e10cSrcweir     public void testWall()
290cdf0e10cSrcweir         throws RuntimeException, UnknownPropertyException, PropertyVetoException,
291cdf0e10cSrcweir                com.sun.star.lang.IllegalArgumentException, WrappedTargetException
292cdf0e10cSrcweir     {
293cdf0e10cSrcweir         XPropertySet aWall = ((X3DDisplay) UnoRuntime.queryInterface(
294cdf0e10cSrcweir                                   X3DDisplay.class, maDiagram )).getWall();
295cdf0e10cSrcweir 
296cdf0e10cSrcweir         // change background color of area
297cdf0e10cSrcweir         aWall.setPropertyValue( "FillStyle", FillStyle.SOLID );
298cdf0e10cSrcweir         aWall.setPropertyValue( "FillColor", new Integer( 0xcccccc ));
299cdf0e10cSrcweir     }
300cdf0e10cSrcweir 
301cdf0e10cSrcweir     // ____________________
302cdf0e10cSrcweir 
testTitle()303cdf0e10cSrcweir     public void testTitle()
304cdf0e10cSrcweir         throws RuntimeException, UnknownPropertyException, PropertyVetoException,
305cdf0e10cSrcweir                com.sun.star.lang.IllegalArgumentException, WrappedTargetException
306cdf0e10cSrcweir     {
307cdf0e10cSrcweir         // change main title
308cdf0e10cSrcweir         XPropertySet aDocProp = (XPropertySet) UnoRuntime.queryInterface(
309cdf0e10cSrcweir             XPropertySet.class, maChartDocument );
310cdf0e10cSrcweir         aDocProp.setPropertyValue( "HasMainTitle", new Boolean( true ));
311cdf0e10cSrcweir 
312cdf0e10cSrcweir         XShape aTitle = maChartDocument.getTitle();
313cdf0e10cSrcweir         XPropertySet aTitleProp = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, aTitle );
314cdf0e10cSrcweir 
315cdf0e10cSrcweir         // set new text
316cdf0e10cSrcweir         if( aTitleProp != null )
317cdf0e10cSrcweir         {
318cdf0e10cSrcweir             aTitleProp.setPropertyValue( "String", "Random Scatter Chart" );
319cdf0e10cSrcweir             aTitleProp.setPropertyValue( "CharHeight", new Float(14.0) );
320cdf0e10cSrcweir         }
321cdf0e10cSrcweir 
322cdf0e10cSrcweir         // align title with y axis
323cdf0e10cSrcweir         XShape aAxis = (XShape) UnoRuntime.queryInterface(
324cdf0e10cSrcweir             XShape.class, ((XAxisYSupplier) UnoRuntime.queryInterface(
325cdf0e10cSrcweir                 XAxisYSupplier.class, maDiagram )).getYAxis() );
326cdf0e10cSrcweir 
327cdf0e10cSrcweir         if( aAxis != null &&
328cdf0e10cSrcweir             aTitle != null )
329cdf0e10cSrcweir         {
330cdf0e10cSrcweir             Point aPos = aTitle.getPosition();
331cdf0e10cSrcweir             aPos.X = ( aAxis.getPosition() ).X;
332cdf0e10cSrcweir             aTitle.setPosition( aPos );
333cdf0e10cSrcweir         }
334cdf0e10cSrcweir     }
335cdf0e10cSrcweir 
336cdf0e10cSrcweir     // ____________________
337cdf0e10cSrcweir 
testAxis()338cdf0e10cSrcweir     public void testAxis()
339cdf0e10cSrcweir         throws RuntimeException, UnknownPropertyException, PropertyVetoException,
340cdf0e10cSrcweir                com.sun.star.lang.IllegalArgumentException, WrappedTargetException,
341cdf0e10cSrcweir                MalformedNumberFormatException
342cdf0e10cSrcweir     {
343cdf0e10cSrcweir         // x axis
344cdf0e10cSrcweir         XPropertySet aAxisProp = ((XAxisXSupplier) UnoRuntime.queryInterface(
345cdf0e10cSrcweir                                       XAxisXSupplier.class, maDiagram )).getXAxis();
346cdf0e10cSrcweir         if( aAxisProp != null )
347cdf0e10cSrcweir         {
348cdf0e10cSrcweir             aAxisProp.setPropertyValue( "Max",      new Integer( 24 ));
349cdf0e10cSrcweir             aAxisProp.setPropertyValue( "StepMain", new Integer( 3 ));
350cdf0e10cSrcweir         }
351cdf0e10cSrcweir 
352cdf0e10cSrcweir         // change number format for y axis
353cdf0e10cSrcweir         aAxisProp = ((XAxisYSupplier) UnoRuntime.queryInterface(
354cdf0e10cSrcweir                          XAxisYSupplier.class, maDiagram )).getYAxis();
355cdf0e10cSrcweir 
356cdf0e10cSrcweir         // add a new custom number format and get the new key
357cdf0e10cSrcweir         int nNewNumberFormat = 0;
358cdf0e10cSrcweir         XNumberFormatsSupplier aNumFmtSupp = (XNumberFormatsSupplier) UnoRuntime.queryInterface(
359cdf0e10cSrcweir             XNumberFormatsSupplier.class, maChartDocument );
360cdf0e10cSrcweir 
361cdf0e10cSrcweir         if( aNumFmtSupp != null )
362cdf0e10cSrcweir         {
363cdf0e10cSrcweir             XNumberFormats aFormats = aNumFmtSupp.getNumberFormats();
364cdf0e10cSrcweir             Locale aLocale = new Locale( "de", "DE", "de" );
365cdf0e10cSrcweir 
366cdf0e10cSrcweir             String aFormatStr = aFormats.generateFormat( nNewNumberFormat, aLocale, true, true, (short)3, (short)1 );
367cdf0e10cSrcweir             nNewNumberFormat = aFormats.addNew( aFormatStr, aLocale );
368cdf0e10cSrcweir         }
369cdf0e10cSrcweir 
370cdf0e10cSrcweir         if( aAxisProp != null )
371cdf0e10cSrcweir         {
372cdf0e10cSrcweir             aAxisProp.setPropertyValue( "NumberFormat", new Integer( nNewNumberFormat ));
373cdf0e10cSrcweir         }
374cdf0e10cSrcweir     }
375cdf0e10cSrcweir 
376cdf0e10cSrcweir     // ____________________
377cdf0e10cSrcweir 
testGrid()378cdf0e10cSrcweir     public void testGrid()
379cdf0e10cSrcweir         throws RuntimeException, UnknownPropertyException, PropertyVetoException,
380cdf0e10cSrcweir                com.sun.star.lang.IllegalArgumentException, WrappedTargetException
381cdf0e10cSrcweir     {
382cdf0e10cSrcweir         // y major grid
383cdf0e10cSrcweir         XPropertySet aGridProp = (XPropertySet) UnoRuntime.queryInterface(
384cdf0e10cSrcweir             XPropertySet.class,
385cdf0e10cSrcweir             ( (XAxisYSupplier) UnoRuntime.queryInterface(
386cdf0e10cSrcweir                 XAxisYSupplier.class, maDiagram )).getYMainGrid());
387cdf0e10cSrcweir 
388cdf0e10cSrcweir         if( aGridProp != null )
389cdf0e10cSrcweir         {
390cdf0e10cSrcweir             LineDash aDash = new LineDash();
391cdf0e10cSrcweir             aDash.Style    = DashStyle.ROUND;
392cdf0e10cSrcweir             aDash.Dots     = 2;
393cdf0e10cSrcweir             aDash.DotLen   = 10;
394cdf0e10cSrcweir             aDash.Dashes   = 1;
395cdf0e10cSrcweir             aDash.DashLen  = 200;
396cdf0e10cSrcweir             aDash.Distance = 100;
397cdf0e10cSrcweir 
398cdf0e10cSrcweir             aGridProp.setPropertyValue( "LineColor", new Integer( 0x999999 ));
399cdf0e10cSrcweir             aGridProp.setPropertyValue( "LineStyle", LineStyle.DASH );
400cdf0e10cSrcweir             aGridProp.setPropertyValue( "LineDash", aDash );
401cdf0e10cSrcweir             aGridProp.setPropertyValue( "LineWidth", new Integer( 30 ));
402cdf0e10cSrcweir         }
403cdf0e10cSrcweir     }
404cdf0e10cSrcweir 
405cdf0e10cSrcweir 
406cdf0e10cSrcweir     // ______________________________
407cdf0e10cSrcweir     //
408cdf0e10cSrcweir     // private members
409cdf0e10cSrcweir     // ______________________________
410cdf0e10cSrcweir 
411cdf0e10cSrcweir     private XChartDocument maChartDocument;
412cdf0e10cSrcweir     private XDiagram       maDiagram;
413cdf0e10cSrcweir }
414