xref: /AOO41X/main/qadevOOo/tests/java/ifc/sheet/_XSheetAnnotationAnchor.java (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
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 
32 import com.sun.star.sheet.XSheetAnnotation;
33 import com.sun.star.sheet.XSheetAnnotationAnchor;
34 import com.sun.star.table.CellAddress;
35 import com.sun.star.text.XSimpleText;
36 import com.sun.star.uno.UnoRuntime;
37 
38 /**
39 * Testing <code>com.sun.star.sheet.XSheetAnnotationAnchor</code>
40 * interface methods :
41 * <ul>
42 *  <li><code> getAnnotation()</code></li>
43 * </ul>
44 * @see com.sun.star.sheet.XSheetAnnotationAnchor
45 */
46 public class _XSheetAnnotationAnchor extends MultiMethodTest {
47 
48     public XSheetAnnotationAnchor oObj = null;
49     protected XSheetAnnotation anno = null;
50 
51     public void _getAnnotation() {
52         anno = oObj.getAnnotation();
53         tRes.tested("getAnnotation()",checkAnnotation());
54     }
55 
56     protected boolean checkAnnotation() {
57         boolean res = true;
58         res &= check_getAuthor();
59         res &= check_getDate();
60         res &= check_getIsVisible();
61         res &= check_getPosition();
62         res &= check_setIsVisible();
63         return res;
64     }
65 
66     /**
67     * Gets the author of annotation. <p>
68     * Returns <b>true</b> if not null value returned.
69     */
70     protected boolean check_getAuthor() {
71       String author = anno.getAuthor();
72       return (author != null);
73     }
74 
75     /**
76     * Gets the modification date of annotation. <p>
77     * Returns <b>true</b> if not null value returned.
78     */
79     protected boolean check_getDate() {
80       String date = anno.getDate();
81       return (date != null);
82     }
83 
84     /**
85     * Sets the string of annotation, then makes it visible and
86     * checks the value returned by <code>getIsVisible</code> method. <p>
87     * Returns <b>true</b> if the method returns <code>true</code>.
88     */
89     protected boolean check_getIsVisible() {
90       XSimpleText oText  = (XSimpleText)
91         UnoRuntime.queryInterface(XSimpleText.class, anno);
92       oText.setString("XSheetAnnotation");
93       anno.setIsVisible(true);
94       boolean bVis = anno.getIsVisible();
95       return bVis;
96     }
97 
98     /**
99     * Gets the position of annotated cell
100     * Returns <b>true</b> if this position is not null.
101     */
102     protected boolean check_getPosition() {
103       CellAddress oCAddr = anno.getPosition();
104       return  (oCAddr != null);
105     }
106 
107     /**
108     * Sets the string of annotation, makes it hidden and then
109     * visible. Visibility is checked in both cases. <p>
110     * Returns <b>true</b> if the <code>getIsVisible</code> method
111     * returns <code>false</code> in the first case and <code>true</code>
112     * in the second.
113     */
114     protected boolean check_setIsVisible() {
115       boolean bResult = true;
116       XSimpleText oText  = (XSimpleText)
117           UnoRuntime.queryInterface(XSimpleText.class, anno);
118       oText.setString("XSheetAnnotation");
119       anno.setIsVisible(false);
120       boolean bVis = anno.getIsVisible();
121       if (!bVis) {
122           anno.setIsVisible(true);
123           bVis = anno.getIsVisible();
124           if (bVis) {
125               bResult = true;
126           }
127       }
128 
129       return bResult;
130     }
131 
132 }