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
;
25 import lib
.TestEnvironment
;
26 import lib
.TestParameters
;
27 import util
.SOfficeFactory
;
29 import com
.sun
.star
.chart
.XChartDocument
;
30 import com
.sun
.star
.drawing
.XShapeDescriptor
;
31 import com
.sun
.star
.frame
.XController
;
32 import com
.sun
.star
.frame
.XModel
;
33 import com
.sun
.star
.uno
.UnoRuntime
;
36 * Test for object which is represented by service
37 * <code>com.sun.star.view.OfficeDocumentView</code>. <p>
38 * Object implements the following interfaces :
40 * <li> <code>com::sun::star::view::XViewSettingsSupplier</code></li>
41 * <li> <code>com::sun::star::view::XControlAccess</code></li>
42 * <li> <code>com::sun::star::view::XSelectionSupplier</code></li>
44 * @see com.sun.star.view.OfficeDocumentView
45 * @see com.sun.star.view.XViewSettingsSupplier
46 * @see com.sun.star.view.XControlAccess
47 * @see com.sun.star.view.XSelectionSupplier
48 * @see ifc.view._XViewSettingsSupplier
49 * @see ifc.view._XControlAccess
50 * @see ifc.view._XSelectionSupplier
52 public class ChXChartView
extends TestCase
{
53 XChartDocument xChartDoc
= null;
56 * Creates Chart document.
59 protected void initialize( TestParameters tParam
, PrintWriter log
) throws Exception
{
60 // get a soffice factory object
61 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF());
62 log
.println( "creating a chartdocument" );
63 xChartDoc
= SOF
.createChartDoc();
67 * Disposes Chart document.
70 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
71 if( xChartDoc
!=null ) {
72 log
.println( " closing xChartDoc" );
73 util
.DesktopTools
.closeDoc(xChartDoc
);
79 * Creating a TestEnvironment for the interfaces to be tested.
80 * Retrieves the current controller of the chart document using
81 * the interface <code>XModel</code>.The retrieved controller is the instance
82 * of the service <code>com.sun.star.view.OfficeDocumentView</code>.
83 * Obtains the main title and the legend of the chart document.
84 * Object relations created :
88 * @see com.sun.star.frame.XModel
91 protected TestEnvironment
createTestEnvironment(TestParameters Param
, PrintWriter log
) {
93 XController oObj
= null;
97 log
.println( "getting ChartView" );
98 oModel
= UnoRuntime
.queryInterface(XModel
.class, xChartDoc
);
99 oObj
= oModel
.getCurrentController();
101 log
.println( "creating a new environment for chartdocument object" );
102 TestEnvironment tEnv
= new TestEnvironment( oObj
);
104 tEnv
.addObjRelation("Selections", new Object
[]
105 {xChartDoc
.getArea(), xChartDoc
.getDiagram(), xChartDoc
.getTitle(),
106 xChartDoc
.getLegend()} );
108 tEnv
.addObjRelation("Comparer", new Comparator
<Object
>() {
109 public int compare(Object o1
, Object o2
) {
110 XShapeDescriptor descr1
= UnoRuntime
.queryInterface(XShapeDescriptor
.class, o1
);
111 XShapeDescriptor descr2
= UnoRuntime
.queryInterface(XShapeDescriptor
.class, o2
);
112 if (descr1
== null || descr2
== null) {
115 if (descr1
.getShapeType().equals(descr2
.getShapeType())) {
123 } // finish method getTestEnvironment
126 } // finish class ChXChartView