2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import java
.io
.PrintWriter
;
23 import lib
.StatusException
;
25 import lib
.TestEnvironment
;
26 import lib
.TestParameters
;
27 import util
.SOfficeFactory
;
29 import com
.sun
.star
.beans
.XPropertySet
;
30 import com
.sun
.star
.chart
.XChartDocument
;
31 import com
.sun
.star
.chart
.XDiagram
;
32 import com
.sun
.star
.uno
.AnyConverter
;
33 import com
.sun
.star
.uno
.Type
;
36 * Test for object which is represented by service
37 * <code>com.sun.star.chart.ChartLine</code>. <p>
38 * Object implements the following interfaces :
40 * <li> <code>com::sun::star::drawing::LineProperties</code></li>
41 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
43 * @see com.sun.star.drawing.LineProperties
44 * @see com.sun.star.beans.XPropertySet
45 * @see ifc.drawing._LineProperties
46 * @see ifc.beans._XPropertySet
48 public class ChartLine
extends TestCase
{
49 XChartDocument xChartDoc
= null;
52 * Creates Chart document.
55 protected void initialize( TestParameters tParam
, PrintWriter log
) {
56 // get a soffice factory object
57 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF());
60 log
.println( "creating a chartdocument" );
61 xChartDoc
= SOF
.createChartDoc();
62 } catch (com
.sun
.star
.uno
.Exception e
) {
63 // Some exception occurs.FAILED
64 e
.printStackTrace( log
);
65 throw new StatusException( "Couldn't create document", e
);
70 * Disposes Chart document.
73 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
74 if( xChartDoc
!=null ) {
75 log
.println( " closing xChartDoc" );
76 util
.DesktopTools
.closeDoc(xChartDoc
);
82 * Creating a Testenvironment for the interfaces to be tested.
83 * Creates a bar diagram and sets the created diagram for the chart document.
84 * Retrieves the property <code>'DataMeanValueProperties'</code> of
85 * the specified data row. The retrieved property is the instance of
86 * the service <code>com.sun.star.chart.ChartLine</code>.
87 * @see com.sun.star.chart.ChartLine
90 protected synchronized TestEnvironment
createTestEnvironment(TestParameters Param
, PrintWriter log
) {
92 XPropertySet oObj
= null;
93 XDiagram oDiagram
= null;
94 SOfficeFactory SOF
= null;
97 SOF
= SOfficeFactory
.getFactory( Param
.getMSF());
98 oDiagram
= SOF
.createDiagram(xChartDoc
, "LineDiagram");
100 log
.println( "getting Line-Diagram" );
101 xChartDoc
.setDiagram(oDiagram
);
105 log
.println( "getting Line" );
106 XPropertySet RowProps
= oDiagram
.getDataRowProperties(1);
107 RowProps
.setPropertyValue("MeanValue", Boolean
.TRUE
);
108 oObj
= (XPropertySet
) AnyConverter
.toObject(
109 new Type(XPropertySet
.class),
110 RowProps
.getPropertyValue("DataMeanValueProperties"));
111 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
112 // Some exception occurs.FAILED
113 e
.printStackTrace( log
);
114 throw new StatusException( "Couldn't get Line", e
);
115 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
116 // Some exception occurs.FAILED
117 e
.printStackTrace( log
);
118 throw new StatusException( "Couldn't get Line", e
);
119 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
120 // Some exception occurs.FAILED
121 e
.printStackTrace( log
);
122 throw new StatusException( "Couldn't get Line", e
);
123 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
124 // Some exception occurs.FAILED
125 e
.printStackTrace( log
);
126 throw new StatusException( "Couldn't get Line", e
);
128 catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
129 // Some exception occurs.FAILED
130 e
.printStackTrace( log
);
131 throw new StatusException( "Couldn't get Line", e
);
134 log
.println( "creating a new environment for chartdocument object" );
135 TestEnvironment tEnv
= new TestEnvironment( oObj
);
139 } // finish method getTestEnvironment
142 } // finish class ChartLine