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: _XSheetAnnotationAnchor.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 com
.sun
.star
.sheet
.XSheetAnnotation
;
36 import com
.sun
.star
.sheet
.XSheetAnnotationAnchor
;
37 import com
.sun
.star
.table
.CellAddress
;
38 import com
.sun
.star
.text
.XSimpleText
;
39 import com
.sun
.star
.uno
.UnoRuntime
;
42 * Testing <code>com.sun.star.sheet.XSheetAnnotationAnchor</code>
45 * <li><code> getAnnotation()</code></li>
47 * @see com.sun.star.sheet.XSheetAnnotationAnchor
49 public class _XSheetAnnotationAnchor
extends MultiMethodTest
{
51 public XSheetAnnotationAnchor oObj
= null;
52 protected XSheetAnnotation anno
= null;
54 public void _getAnnotation() {
55 anno
= oObj
.getAnnotation();
56 tRes
.tested("getAnnotation()",checkAnnotation());
59 protected boolean checkAnnotation() {
61 res
&= check_getAuthor();
62 res
&= check_getDate();
63 res
&= check_getIsVisible();
64 res
&= check_getPosition();
65 res
&= check_setIsVisible();
70 * Gets the author of annotation. <p>
71 * Returns <b>true</b> if not null value returned.
73 protected boolean check_getAuthor() {
74 String author
= anno
.getAuthor();
75 return (author
!= null);
79 * Gets the modification date of annotation. <p>
80 * Returns <b>true</b> if not null value returned.
82 protected boolean check_getDate() {
83 String date
= anno
.getDate();
84 return (date
!= null);
88 * Sets the string of annotation, then makes it visible and
89 * checks the value returned by <code>getIsVisible</code> method. <p>
90 * Returns <b>true</b> if the method returns <code>true</code>.
92 protected boolean check_getIsVisible() {
93 XSimpleText oText
= (XSimpleText
)
94 UnoRuntime
.queryInterface(XSimpleText
.class, anno
);
95 oText
.setString("XSheetAnnotation");
96 anno
.setIsVisible(true);
97 boolean bVis
= anno
.getIsVisible();
102 * Gets the position of annotated cell
103 * Returns <b>true</b> if this position is not null.
105 protected boolean check_getPosition() {
106 CellAddress oCAddr
= anno
.getPosition();
107 return (oCAddr
!= null);
111 * Sets the string of annotation, makes it hidden and then
112 * visible. Visibility is checked in both cases. <p>
113 * Returns <b>true</b> if the <code>getIsVisible</code> method
114 * returns <code>false</code> in the first case and <code>true</code>
117 protected boolean check_setIsVisible() {
118 boolean bResult
= true;
119 XSimpleText oText
= (XSimpleText
)
120 UnoRuntime
.queryInterface(XSimpleText
.class, anno
);
121 oText
.setString("XSheetAnnotation");
122 anno
.setIsVisible(false);
123 boolean bVis
= anno
.getIsVisible();
125 anno
.setIsVisible(true);
126 bVis
= anno
.getIsVisible();