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 import lib.Status; 32 import lib.StatusException; 33 import util.ValueComparer; 34 35 import com.sun.star.sheet.XSheetAnnotation; 36 import com.sun.star.table.CellAddress; 37 import com.sun.star.text.XSimpleText; 38 import com.sun.star.uno.UnoRuntime; 39 40 /** 41 * Testing <code>com.sun.star.sheet.XSheetAnnotation</code> 42 * interface methods : 43 * <ul> 44 * <li><code> getPosition()</code></li> 45 * <li><code> getAuthor()</code></li> 46 * <li><code> getDate()</code></li> 47 * <li><code> getIsVisible()</code></li> 48 * <li><code> setIsVisible()</code></li> 49 * </ul> <p> 50 * This test needs the following object relations : 51 * <ul> 52 * <li> <code>'CELLPOS'</code> (of type 53 * <code>com.sun.star.table.CellAddress</code>): 54 * The position of cell with annotation. </li> 55 * <ul> <p> 56 * Test is <b> NOT </b> multithread compilant. <p> 57 * @see com.sun.star.sheet.XSheetAnnotation 58 */ 59 public class _XSheetAnnotation extends MultiMethodTest { 60 61 public XSheetAnnotation oObj = null; 62 63 /** 64 * Gets the author of annotation. <p> 65 * Has <b>OK</b> status if not null value returned. 66 */ 67 public void _getAuthor() { 68 String author = oObj.getAuthor(); 69 tRes.tested("getAuthor()", author != null); 70 } 71 72 /** 73 * Gets the modification date of annotation. <p> 74 * Has <b>OK</b> status if not null value returned. 75 */ 76 public void _getDate() { 77 String date = oObj.getDate(); 78 tRes.tested("getDate()", date != null); 79 } 80 81 /** 82 * Sets the string of annotation, then makes it visible and 83 * checks the value returned by <code>getIsVisible</code> method. <p> 84 * Has <b>OK</b> status if the method returns <code>true</code>. 85 */ 86 public void _getIsVisible() { 87 XSimpleText oText = (XSimpleText) 88 UnoRuntime.queryInterface(XSimpleText.class, oObj); 89 oText.setString("XSheetAnnotation"); 90 oObj.setIsVisible(true); 91 boolean bVis = oObj.getIsVisible(); 92 tRes.tested("getIsVisible()", bVis); 93 } 94 95 /** 96 * Gets the position of annotated cell and compares it to 97 * the position passed as relation. <p> 98 * Has <b>OK</b> status if these positions are equal and not 99 * null. 100 */ 101 public void _getPosition() { 102 boolean bResult = false; 103 CellAddress sCAddr = (CellAddress) tEnv.getObjRelation("CELLPOS") ; 104 if (sCAddr == null) throw new StatusException(Status.failed 105 ("Relation 'CELLPOS' not found")); 106 107 CellAddress oCAddr = oObj.getPosition(); 108 109 bResult = (oCAddr != null) && (sCAddr != null) && 110 ValueComparer.equalValue(oCAddr, sCAddr) ; 111 112 tRes.tested("getPosition()", bResult); 113 } 114 115 /** 116 * Sets the string of annotation, makes it hidden and then 117 * visible. Visibility is checked in both cases. <p> 118 * Has <b>OK</b> status if the <code>getIsVisible</code> method 119 * returns <code>flase</code> in the first case and <code>true</code> 120 * in the second. 121 */ 122 public void _setIsVisible() { 123 boolean bResult = true; 124 XSimpleText oText = (XSimpleText) 125 UnoRuntime.queryInterface(XSimpleText.class, oObj); 126 oText.setString("XSheetAnnotation"); 127 oObj.setIsVisible(false); 128 boolean bVis = oObj.getIsVisible(); 129 if (!bVis) { 130 oObj.setIsVisible(true); 131 bVis = oObj.getIsVisible(); 132 if (bVis) { 133 bResult = true; 134 } 135 } 136 137 tRes.tested("setIsVisible()", bResult); 138 } 139 140 } // EOC _XSheetAnnotation 141 142