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: _XSheetAnnotation.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 lib
.MultiMethodTest
;
35 import lib
.StatusException
;
36 import util
.ValueComparer
;
38 import com
.sun
.star
.sheet
.XSheetAnnotation
;
39 import com
.sun
.star
.table
.CellAddress
;
40 import com
.sun
.star
.text
.XSimpleText
;
41 import com
.sun
.star
.uno
.UnoRuntime
;
44 * Testing <code>com.sun.star.sheet.XSheetAnnotation</code>
47 * <li><code> getPosition()</code></li>
48 * <li><code> getAuthor()</code></li>
49 * <li><code> getDate()</code></li>
50 * <li><code> getIsVisible()</code></li>
51 * <li><code> setIsVisible()</code></li>
53 * This test needs the following object relations :
55 * <li> <code>'CELLPOS'</code> (of type
56 * <code>com.sun.star.table.CellAddress</code>):
57 * The position of cell with annotation. </li>
59 * Test is <b> NOT </b> multithread compilant. <p>
60 * @see com.sun.star.sheet.XSheetAnnotation
62 public class _XSheetAnnotation
extends MultiMethodTest
{
64 public XSheetAnnotation oObj
= null;
67 * Gets the author of annotation. <p>
68 * Has <b>OK</b> status if not null value returned.
70 public void _getAuthor() {
71 String author
= oObj
.getAuthor();
72 tRes
.tested("getAuthor()", author
!= null);
76 * Gets the modification date of annotation. <p>
77 * Has <b>OK</b> status if not null value returned.
79 public void _getDate() {
80 String date
= oObj
.getDate();
81 tRes
.tested("getDate()", date
!= null);
85 * Sets the string of annotation, then makes it visible and
86 * checks the value returned by <code>getIsVisible</code> method. <p>
87 * Has <b>OK</b> status if the method returns <code>true</code>.
89 public void _getIsVisible() {
90 XSimpleText oText
= (XSimpleText
)
91 UnoRuntime
.queryInterface(XSimpleText
.class, oObj
);
92 oText
.setString("XSheetAnnotation");
93 oObj
.setIsVisible(true);
94 boolean bVis
= oObj
.getIsVisible();
95 tRes
.tested("getIsVisible()", bVis
);
99 * Gets the position of annotated cell and compares it to
100 * the position passed as relation. <p>
101 * Has <b>OK</b> status if these positions are equal and not
104 public void _getPosition() {
105 boolean bResult
= false;
106 CellAddress sCAddr
= (CellAddress
) tEnv
.getObjRelation("CELLPOS") ;
107 if (sCAddr
== null) throw new StatusException(Status
.failed
108 ("Relation 'CELLPOS' not found"));
110 CellAddress oCAddr
= oObj
.getPosition();
112 bResult
= (oCAddr
!= null) && (sCAddr
!= null) &&
113 ValueComparer
.equalValue(oCAddr
, sCAddr
) ;
115 tRes
.tested("getPosition()", bResult
);
119 * Sets the string of annotation, makes it hidden and then
120 * visible. Visibility is checked in both cases. <p>
121 * Has <b>OK</b> status if the <code>getIsVisible</code> method
122 * returns <code>flase</code> in the first case and <code>true</code>
125 public void _setIsVisible() {
126 boolean bResult
= true;
127 XSimpleText oText
= (XSimpleText
)
128 UnoRuntime
.queryInterface(XSimpleText
.class, oObj
);
129 oText
.setString("XSheetAnnotation");
130 oObj
.setIsVisible(false);
131 boolean bVis
= oObj
.getIsVisible();
133 oObj
.setIsVisible(true);
134 bVis
= oObj
.getIsVisible();
140 tRes
.tested("setIsVisible()", bResult
);
143 } // EOC _XSheetAnnotation