1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 package ifc.sheet;
29 
30 import lib.MultiMethodTest;
31 import lib.Status;
32 import lib.StatusException;
33 
34 import com.sun.star.sheet.XSpreadsheet;
35 import com.sun.star.sheet.XSpreadsheetView;
36 
37 /**
38 * Testing <code>com.sun.star.sheet.XSpreadsheetView</code>
39 * interface methods :
40 * <ul>
41 *  <li><code> getActiveSheet()</code></li>
42 *  <li><code> setActiveSheet()</code></li>
43 * </ul> <p>
44 * This test needs the following object relations :
45 * <ul>
46 *  <li> <code>'Sheet'</code> (of type <code>XSpreadsheet</code>):
47 *   to set new active spreadsheet </li>
48 * <ul> <p>
49 * @see com.sun.star.sheet.XSpreadsheetView
50 */
51 public class _XSpreadsheetView extends MultiMethodTest {
52 
53     public XSpreadsheetView oObj = null;
54     public XSpreadsheet oSheet = null;
55 
56     /**
57     * Test calls the method, stores and checks returned value. <p>
58     * Has <b> OK </b> status if returned value isn't null. <p>
59     */
60     public void _getActiveSheet() {
61         oSheet = oObj.getActiveSheet();
62         tRes.tested("getActiveSheet()", oSheet != null);
63     }
64 
65     /**
66     * Test sets new active sheet that was obtained by relation
67     * <code>'Sheet'</code>, gets the current active sheet and compares
68     * returned value with value that was stored by method
69     * <code>getFilterFields()</code>. <p>
70     * Has <b> OK </b> status if values aren't equal. <p>
71     * The following method tests are to be completed successfully before :
72     * <ul>
73     *  <li> <code> getActiveSheet() </code> : to have the current
74     *  active sheet </li>
75     * </ul>
76     */
77     public void _setActiveSheet() {
78         requiredMethod("getActiveSheet()");
79 
80         XSpreadsheet new_Sheet = (XSpreadsheet)tEnv.getObjRelation("Sheet");
81         if (new_Sheet == null) throw new StatusException(Status.failed
82             ("Relation 'Sheet' not found"));
83 
84         oObj.setActiveSheet(new_Sheet);
85         new_Sheet = oObj.getActiveSheet();
86         tRes.tested("setActiveSheet()", !oSheet.equals(new_Sheet));
87     }
88 
89 
90 }  // finish class _XSpreadsheetView
91 
92 
93