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