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: ChXDataRow.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
;
42 import com
.sun
.star
.beans
.XPropertySet
;
43 import com
.sun
.star
.chart
.XChartDocument
;
44 import com
.sun
.star
.chart
.XDiagram
;
45 import com
.sun
.star
.lang
.XComponent
;
46 import com
.sun
.star
.lang
.XMultiServiceFactory
;
47 import com
.sun
.star
.uno
.UnoRuntime
;
50 * Test for object which is represented by service
51 * <code>com.sun.star.chart.ChartDataRowProperties</code>. <p>
52 * Object implements the following interfaces :
54 * <li> <code>com::sun::star::drawing::FillProperties</code></li>
55 * <li> <code>com::sun::star::chart::ChartStatistics</code></li>
56 * <li> <code>com::sun::star::chart::ChartDataRowProperties</code></li>
57 * <li> <code>com::sun::star::drawing::LineProperties</code></li>
58 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
59 * <li> <code>com::sun::star::chart::ChartDataPointProperties</code></li>
60 * <li> <code>com::sun::star::chart::Chart3DBarProperties</code></li>
61 * <li> <code>com::sun::star::style::CharacterProperties</code></li>
63 * The following files used by this test :
65 * <li><b> TransparencyChart.sxs </b> : to load predefined chart
66 * document where two 'automatic' transparency styles exists :
67 * 'Transparency 1' and 'Transparency 2'.</li>
69 * @see com.sun.star.drawing.FillProperties
70 * @see com.sun.star.chart.ChartStatistics
71 * @see com.sun.star.chart.ChartDataRowProperties
72 * @see com.sun.star.drawing.LineProperties
73 * @see com.sun.star.beans.XPropertySet
74 * @see com.sun.star.chart.ChartDataPointProperties
75 * @see com.sun.star.chart.Chart3DBarProperties
76 * @see com.sun.star.style.CharacterProperties
77 * @see ifc.drawing._FillProperties
78 * @see ifc.chart._ChartStatistics
79 * @see ifc.chart._ChartDataRowProperties
80 * @see ifc.drawing._LineProperties
81 * @see ifc.beans._XPropertySet
82 * @see ifc.chart._ChartDataPointProperties
83 * @see ifc.chart._Chart3DBarProperties
84 * @see ifc.style._CharacterProperties
86 public class ChXDataRow
extends TestCase
{
87 XChartDocument xChartDoc
= null;
90 * Creates Chart document.
92 protected void initialize( TestParameters tParam
, PrintWriter log
) {
93 // get a soffice factory object
94 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF());
97 log
.println( "creating a chartdocument" );
98 XComponent xComp
= SOF
.loadDocument(
99 utils
.getFullTestURL("TransparencyChart.sxs"));
100 xChartDoc
= (XChartDocument
)
101 UnoRuntime
.queryInterface(XChartDocument
.class,xComp
);
102 } catch (com
.sun
.star
.uno
.Exception e
) {
103 // Some exception occures.FAILED
104 e
.printStackTrace( log
);
105 throw new StatusException( "Couldn't create document", e
);
110 * Disposes Chart document.
112 protected synchronized void cleanup( TestParameters tParam
, PrintWriter log
) {
113 log
.println( " closing xChartDoc " );
114 util
.DesktopTools
.closeDoc(xChartDoc
);
119 * Creating a Testenvironment for the interfaces to be tested.
120 * Retrieves the diagram of the chart document. Obtains the properties of
121 * the specified data row. The obtained properties is the instance of
122 * the service <code>com.sun.star.chart.ChartDataRowProperties</code>.
123 * Creates a XY-diagram and bar-diagram also.
124 * Object relations created :
126 * <li> <code>'LINE'</code> for
127 * {@link ifc.chart._ChartDataPointProperties}(the created XY-diagram)</li>
128 * <li> <code>'CHARTDOC'</code> for
129 * {@link ifc.chart._ChartDataPointProperties},
130 * {@link ifc.chart._Chart3DBarProperties}(the chart document)</li>
131 * <li> <code>'BAR'</code> for
132 * {@link ifc.chart._Chart3DBarProperties}(the created bar-diagram)</li>
135 protected TestEnvironment
createTestEnvironment(TestParameters Param
, PrintWriter log
) {
137 XPropertySet oObj
= null;
138 XDiagram oDiagram
= null;
139 // get the ChXDataRowPoint_Row
141 log
.println( "getting ChXDataRowPoint_Row" );
142 oDiagram
= (XDiagram
) xChartDoc
.getDiagram();
143 oObj
= (XPropertySet
) oDiagram
.getDataRowProperties(1);
144 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
145 // Some exception occures.FAILED
146 e
.printStackTrace( log
);
147 throw new StatusException( "Couldn't get ChXDataRowPoint_Row", e
);
150 log
.println( "creating a new environment for chartdocument object" );
151 TestEnvironment tEnv
= new TestEnvironment( oObj
);
153 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)Param
.getMSF());
155 Object line
= SOF
.createDiagram(xChartDoc
,"XYDiagram");
156 tEnv
.addObjRelation("LINE",line
);
158 Object bar
= SOF
.createDiagram(xChartDoc
,"BarDiagram");
159 tEnv
.addObjRelation("BAR",bar
);
161 log
.println( "adding ChartDocument as mod relation to environment" );
162 tEnv
.addObjRelation("CHARTDOC", xChartDoc
);
165 } // finish method getTestEnvironment
168 } // finish class ChXDataRow