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