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: ChXChartView.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
;
34 import java
.util
.Comparator
;
36 import lib
.StatusException
;
38 import lib
.TestEnvironment
;
39 import lib
.TestParameters
;
40 import util
.SOfficeFactory
;
42 import com
.sun
.star
.chart
.XChartDocument
;
43 import com
.sun
.star
.drawing
.XShapeDescriptor
;
44 import com
.sun
.star
.frame
.XController
;
45 import com
.sun
.star
.frame
.XModel
;
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.view.OfficeDocumentView</code>. <p>
52 * Object implements the following interfaces :
54 * <li> <code>com::sun::star::view::XViewSettingsSupplier</code></li>
55 * <li> <code>com::sun::star::view::XControlAccess</code></li>
56 * <li> <code>com::sun::star::view::XSelectionSupplier</code></li>
58 * @see com.sun.star.view.OfficeDocumentView
59 * @see com.sun.star.view.XViewSettingsSupplier
60 * @see com.sun.star.view.XControlAccess
61 * @see com.sun.star.view.XSelectionSupplier
62 * @see ifc.view._XViewSettingsSupplier
63 * @see ifc.view._XControlAccess
64 * @see ifc.view._XSelectionSupplier
66 public class ChXChartView
extends TestCase
{
67 XChartDocument xChartDoc
= null;
70 * Creates Chart document.
72 protected void initialize( TestParameters tParam
, PrintWriter log
) {
73 // get a soffice factory object
74 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF());
77 log
.println( "creating a chartdocument" );
78 xChartDoc
= SOF
.createChartDoc(null);;
79 } catch (com
.sun
.star
.uno
.Exception e
) {
80 // Some exception occures.FAILED
81 e
.printStackTrace( log
);
82 throw new StatusException( "Couldn't create document", e
);
87 * Disposes Chart document.
89 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
90 log
.println( " closing xChartDoc " );
91 util
.DesktopTools
.closeDoc(xChartDoc
);
95 * Creating a Testenvironment for the interfaces to be tested.
96 * Retrieves the current controller of the chart document using
97 * the interface <code>XModel</code>.The retrieved controller is the instance
98 * of the service <code>com.sun.star.view.OfficeDocumentView</code>.
99 * Obtains the main title and the legend of the chart document.
100 * Object relations created :
104 * @see com.sun.star.frame.XModel
106 protected synchronized TestEnvironment
createTestEnvironment(TestParameters Param
, PrintWriter log
) {
108 XController oObj
= null;
109 XModel oModel
= null;
112 log
.println( "getting ChartView" );
113 oModel
= (XModel
)UnoRuntime
.queryInterface(XModel
.class, xChartDoc
);
114 oObj
= (XController
)oModel
.getCurrentController();
116 log
.println( "creating a new environment for chartdocument object" );
117 TestEnvironment tEnv
= new TestEnvironment( oObj
);
119 tEnv
.addObjRelation("Selections", new Object
[]
120 {xChartDoc
.getArea(), xChartDoc
.getDiagram(), xChartDoc
.getTitle(),
121 xChartDoc
.getLegend()} );
123 tEnv
.addObjRelation("Comparer", new Comparator() {
124 public int compare(Object o1
, Object o2
) {
125 XShapeDescriptor descr1
= (XShapeDescriptor
)
126 UnoRuntime
.queryInterface(XShapeDescriptor
.class, o1
);
127 XShapeDescriptor descr2
= (XShapeDescriptor
)
128 UnoRuntime
.queryInterface(XShapeDescriptor
.class, o2
);
129 if (descr1
== null || descr2
== null) {
132 if (descr1
.getShapeType().equals(descr2
.getShapeType())) {
137 public boolean equals(Object obj
) {
138 return compare(this, obj
) == 0;
143 } // finish method getTestEnvironment
146 } // finish class ChXChartView