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
;
22 import java
.util
.Comparator
;
24 import lib
.StatusException
;
26 import lib
.TestEnvironment
;
27 import lib
.TestParameters
;
28 import util
.SOfficeFactory
;
30 import com
.sun
.star
.chart
.XChartDocument
;
31 import com
.sun
.star
.drawing
.XShapeDescriptor
;
32 import com
.sun
.star
.frame
.XController
;
33 import com
.sun
.star
.frame
.XModel
;
34 import com
.sun
.star
.uno
.UnoRuntime
;
37 * Test for object which is represented by service
38 * <code>com.sun.star.view.OfficeDocumentView</code>. <p>
39 * Object implements the following interfaces :
41 * <li> <code>com::sun::star::view::XViewSettingsSupplier</code></li>
42 * <li> <code>com::sun::star::view::XControlAccess</code></li>
43 * <li> <code>com::sun::star::view::XSelectionSupplier</code></li>
45 * @see com.sun.star.view.OfficeDocumentView
46 * @see com.sun.star.view.XViewSettingsSupplier
47 * @see com.sun.star.view.XControlAccess
48 * @see com.sun.star.view.XSelectionSupplier
49 * @see ifc.view._XViewSettingsSupplier
50 * @see ifc.view._XControlAccess
51 * @see ifc.view._XSelectionSupplier
53 public class ChXChartView
extends TestCase
{
54 XChartDocument xChartDoc
= null;
57 * Creates Chart document.
60 protected void initialize( TestParameters tParam
, PrintWriter log
) {
61 // get a soffice factory object
62 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF());
65 log
.println( "creating a chartdocument" );
66 xChartDoc
= SOF
.createChartDoc();
67 } catch (com
.sun
.star
.uno
.Exception e
) {
68 // Some exception occurs.FAILED
69 e
.printStackTrace( log
);
70 throw new StatusException( "Couldn't create document", e
);
75 * Disposes Chart document.
78 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
79 if( xChartDoc
!=null ) {
80 log
.println( " closing xChartDoc" );
81 util
.DesktopTools
.closeDoc(xChartDoc
);
87 * Creating a Testenvironment for the interfaces to be tested.
88 * Retrieves the current controller of the chart document using
89 * the interface <code>XModel</code>.The retrieved controller is the instance
90 * of the service <code>com.sun.star.view.OfficeDocumentView</code>.
91 * Obtains the main title and the legend of the chart document.
92 * Object relations created :
96 * @see com.sun.star.frame.XModel
99 protected synchronized TestEnvironment
createTestEnvironment(TestParameters Param
, PrintWriter log
) {
101 XController oObj
= null;
102 XModel oModel
= null;
105 log
.println( "getting ChartView" );
106 oModel
= UnoRuntime
.queryInterface(XModel
.class, xChartDoc
);
107 oObj
= oModel
.getCurrentController();
109 log
.println( "creating a new environment for chartdocument object" );
110 TestEnvironment tEnv
= new TestEnvironment( oObj
);
112 tEnv
.addObjRelation("Selections", new Object
[]
113 {xChartDoc
.getArea(), xChartDoc
.getDiagram(), xChartDoc
.getTitle(),
114 xChartDoc
.getLegend()} );
116 tEnv
.addObjRelation("Comparer", new Comparator
<Object
>() {
117 public int compare(Object o1
, Object o2
) {
118 XShapeDescriptor descr1
= UnoRuntime
.queryInterface(XShapeDescriptor
.class, o1
);
119 XShapeDescriptor descr2
= UnoRuntime
.queryInterface(XShapeDescriptor
.class, o2
);
120 if (descr1
== null || descr2
== null) {
123 if (descr1
.getShapeType().equals(descr2
.getShapeType())) {
131 } // finish method getTestEnvironment
134 } // finish class ChXChartView