1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ChartLine.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import java
.io
.PrintWriter
;
35 import lib
.StatusException
;
37 import lib
.TestEnvironment
;
38 import lib
.TestParameters
;
39 import util
.SOfficeFactory
;
41 import com
.sun
.star
.beans
.XPropertySet
;
42 import com
.sun
.star
.chart
.XChartDocument
;
43 import com
.sun
.star
.chart
.XDiagram
;
44 import com
.sun
.star
.lang
.XMultiServiceFactory
;
45 import com
.sun
.star
.uno
.AnyConverter
;
46 import com
.sun
.star
.uno
.Type
;
49 * Test for object which is represented by service
50 * <code>com.sun.star.chart.ChartLine</code>. <p>
51 * Object implements the following interfaces :
53 * <li> <code>com::sun::star::drawing::LineProperties</code></li>
54 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
56 * @see com.sun.star.drawing.LineProperties
57 * @see com.sun.star.beans.XPropertySet
58 * @see ifc.drawing._LineProperties
59 * @see ifc.beans._XPropertySet
61 public class ChartLine
extends TestCase
{
62 XChartDocument xChartDoc
= null;
65 * Creates Chart document.
67 protected void initialize( TestParameters tParam
, PrintWriter log
) {
68 // get a soffice factory object
69 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF());
72 log
.println( "creating a chartdocument" );
73 xChartDoc
= SOF
.createChartDoc(null);;
74 } catch (com
.sun
.star
.uno
.Exception e
) {
75 // Some exception occures.FAILED
76 e
.printStackTrace( log
);
77 throw new StatusException( "Couldn't create document", e
);
82 * Disposes Chart document.
84 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
85 log
.println( " closing xChartDoc " );
86 util
.DesktopTools
.closeDoc(xChartDoc
);
90 * Creating a Testenvironment for the interfaces to be tested.
91 * Creates a bar diagram and sets the created diagram for the chart document.
92 * Retrieves the property <code>'DataMeanValueProperties'</code> of
93 * the specified data row. The retrieved property is the instance of
94 * the service <code>com.sun.star.chart.ChartLine</code>.
95 * @see com.sun.star.chart.ChartLine
97 protected synchronized TestEnvironment
createTestEnvironment(TestParameters Param
, PrintWriter log
) {
99 XPropertySet oObj
= null;
100 XDiagram oDiagram
= null;
101 SOfficeFactory SOF
= null;
104 SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)Param
.getMSF());
105 oDiagram
= SOF
.createDiagram(xChartDoc
, "LineDiagram");
107 log
.println( "getting Line-Diagram" );
108 xChartDoc
.setDiagram(oDiagram
);
112 log
.println( "getting Line" );
113 XPropertySet RowProps
= oDiagram
.getDataRowProperties(1);
114 RowProps
.setPropertyValue("MeanValue", new Boolean( true ));
115 oObj
= (XPropertySet
) AnyConverter
.toObject(
116 new Type(XPropertySet
.class),
117 RowProps
.getPropertyValue("DataMeanValueProperties"));
118 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
119 // Some exception occures.FAILED
120 e
.printStackTrace( log
);
121 throw new StatusException( "Couldn't get Line", e
);
122 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
123 // Some exception occures.FAILED
124 e
.printStackTrace( log
);
125 throw new StatusException( "Couldn't get Line", e
);
126 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
127 // Some exception occures.FAILED
128 e
.printStackTrace( log
);
129 throw new StatusException( "Couldn't get Line", e
);
130 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
131 // Some exception occures.FAILED
132 e
.printStackTrace( log
);
133 throw new StatusException( "Couldn't get Line", e
);
135 catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
136 // Some exception occures.FAILED
137 e
.printStackTrace( log
);
138 throw new StatusException( "Couldn't get Line", e
);
141 log
.println( "creating a new environment for chartdocument object" );
142 TestEnvironment tEnv
= new TestEnvironment( oObj
);
146 } // finish method getTestEnvironment
149 } // finish class ChartLine