2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import lib
.MultiMethodTest
;
23 import lib
.StatusException
;
24 import util
.ValueComparer
;
26 import com
.sun
.star
.sheet
.XSheetAnnotation
;
27 import com
.sun
.star
.table
.CellAddress
;
28 import com
.sun
.star
.text
.XSimpleText
;
29 import com
.sun
.star
.uno
.UnoRuntime
;
32 * Testing <code>com.sun.star.sheet.XSheetAnnotation</code>
35 * <li><code> getPosition()</code></li>
36 * <li><code> getAuthor()</code></li>
37 * <li><code> getDate()</code></li>
38 * <li><code> getIsVisible()</code></li>
39 * <li><code> setIsVisible()</code></li>
41 * This test needs the following object relations :
43 * <li> <code>'CELLPOS'</code> (of type
44 * <code>com.sun.star.table.CellAddress</code>):
45 * The position of cell with annotation. </li>
47 * Test is <b> NOT </b> multithread compliant. <p>
48 * @see com.sun.star.sheet.XSheetAnnotation
50 public class _XSheetAnnotation
extends MultiMethodTest
{
52 public XSheetAnnotation oObj
= null;
55 * Gets the author of annotation. <p>
56 * Has <b>OK</b> status if not null value returned.
58 public void _getAuthor() {
59 String author
= oObj
.getAuthor();
60 tRes
.tested("getAuthor()", author
!= null);
64 * Gets the modification date of annotation. <p>
65 * Has <b>OK</b> status if not null value returned.
67 public void _getDate() {
68 String date
= oObj
.getDate();
69 tRes
.tested("getDate()", date
!= null);
73 * Sets the string of annotation, then makes it visible and
74 * checks the value returned by <code>getIsVisible</code> method. <p>
75 * Has <b>OK</b> status if the method returns <code>true</code>.
77 public void _getIsVisible() {
78 XSimpleText oText
= UnoRuntime
.queryInterface(XSimpleText
.class, oObj
);
79 oText
.setString("XSheetAnnotation");
80 oObj
.setIsVisible(true);
81 boolean bVis
= oObj
.getIsVisible();
82 tRes
.tested("getIsVisible()", bVis
);
86 * Gets the position of annotated cell and compares it to
87 * the position passed as relation. <p>
88 * Has <b>OK</b> status if these positions are equal and not
91 public void _getPosition() {
92 boolean bResult
= false;
93 CellAddress sCAddr
= (CellAddress
) tEnv
.getObjRelation("CELLPOS") ;
94 if (sCAddr
== null) throw new StatusException(Status
.failed
95 ("Relation 'CELLPOS' not found"));
97 CellAddress oCAddr
= oObj
.getPosition();
99 bResult
= (oCAddr
!= null) &&
100 ValueComparer
.equalValue(oCAddr
, sCAddr
) ;
102 tRes
.tested("getPosition()", bResult
);
106 * Sets the string of annotation, makes it hidden and then
107 * visible. Visibility is checked in both cases. <p>
108 * Has <b>OK</b> status if the <code>getIsVisible</code> method
109 * returns <code>flase</code> in the first case and <code>true</code>
112 public void _setIsVisible() {
113 boolean bResult
= true;
114 XSimpleText oText
= UnoRuntime
.queryInterface(XSimpleText
.class, oObj
);
115 oText
.setString("XSheetAnnotation");
116 oObj
.setIsVisible(false);
117 boolean bVis
= oObj
.getIsVisible();
119 oObj
.setIsVisible(true);
120 bVis
= oObj
.getIsVisible();
126 tRes
.tested("setIsVisible()", bResult
);
129 } // EOC _XSheetAnnotation