1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package ifc.sheet;
25 
26 import lib.MultiMethodTest;
27 
28 import com.sun.star.sheet.XSheetAnnotation;
29 import com.sun.star.sheet.XSheetAnnotationAnchor;
30 import com.sun.star.table.CellAddress;
31 import com.sun.star.text.XSimpleText;
32 import com.sun.star.uno.UnoRuntime;
33 
34 /**
35 * Testing <code>com.sun.star.sheet.XSheetAnnotationAnchor</code>
36 * interface methods :
37 * <ul>
38 *  <li><code> getAnnotation()</code></li>
39 * </ul>
40 * @see com.sun.star.sheet.XSheetAnnotationAnchor
41 */
42 public class _XSheetAnnotationAnchor extends MultiMethodTest {
43 
44     public XSheetAnnotationAnchor oObj = null;
45     protected XSheetAnnotation anno = null;
46 
_getAnnotation()47     public void _getAnnotation() {
48         anno = oObj.getAnnotation();
49         tRes.tested("getAnnotation()",checkAnnotation());
50     }
51 
checkAnnotation()52     protected boolean checkAnnotation() {
53         boolean res = true;
54         res &= check_getAuthor();
55         res &= check_getDate();
56         res &= check_getIsVisible();
57         res &= check_getPosition();
58         res &= check_setIsVisible();
59         return res;
60     }
61 
62     /**
63     * Gets the author of annotation. <p>
64     * Returns <b>true</b> if not null value returned.
65     */
check_getAuthor()66     protected boolean check_getAuthor() {
67       String author = anno.getAuthor();
68       return (author != null);
69     }
70 
71     /**
72     * Gets the modification date of annotation. <p>
73     * Returns <b>true</b> if not null value returned.
74     */
check_getDate()75     protected boolean check_getDate() {
76       String date = anno.getDate();
77       return (date != null);
78     }
79 
80     /**
81     * Sets the string of annotation, then makes it visible and
82     * checks the value returned by <code>getIsVisible</code> method. <p>
83     * Returns <b>true</b> if the method returns <code>true</code>.
84     */
check_getIsVisible()85     protected boolean check_getIsVisible() {
86       XSimpleText oText  = (XSimpleText)
87         UnoRuntime.queryInterface(XSimpleText.class, anno);
88       oText.setString("XSheetAnnotation");
89       anno.setIsVisible(true);
90       boolean bVis = anno.getIsVisible();
91       return bVis;
92     }
93 
94     /**
95     * Gets the position of annotated cell
96     * Returns <b>true</b> if this position is not null.
97     */
check_getPosition()98     protected boolean check_getPosition() {
99       CellAddress oCAddr = anno.getPosition();
100       return  (oCAddr != null);
101     }
102 
103     /**
104     * Sets the string of annotation, makes it hidden and then
105     * visible. Visibility is checked in both cases. <p>
106     * Returns <b>true</b> if the <code>getIsVisible</code> method
107     * returns <code>false</code> in the first case and <code>true</code>
108     * in the second.
109     */
check_setIsVisible()110     protected boolean check_setIsVisible() {
111       boolean bResult = true;
112       XSimpleText oText  = (XSimpleText)
113           UnoRuntime.queryInterface(XSimpleText.class, anno);
114       oText.setString("XSheetAnnotation");
115       anno.setIsVisible(false);
116       boolean bVis = anno.getIsVisible();
117       if (!bVis) {
118           anno.setIsVisible(true);
119           bVis = anno.getIsVisible();
120           if (bVis) {
121               bResult = true;
122           }
123       }
124 
125       return bResult;
126     }
127 
128 }