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 package ifc.sheet; 28 29 import com.sun.star.sheet.SheetLinkMode; 30 import com.sun.star.sheet.XSheetLinkable; 31 import lib.MultiMethodTest; 32 import util.utils; 33 34 /** 35 * 36 */ 37 public class _XSheetLinkable extends MultiMethodTest { 38 public XSheetLinkable oObj = null; 39 SheetLinkMode slm = null; 40 String linkSheetName = null; 41 String linkUrl = null; 42 String linkUrl2 = null; 43 44 public void before() { 45 // get a document for linking. 46 linkUrl = (String)tEnv.getObjRelation("XSheetLinkable.LinkSheet"); 47 linkUrl = utils.getFullTestURL(linkUrl); 48 49 // get a second sheet for changing the link url: if it's not set, 50 // this part of the test is omitted. 51 linkUrl2 = (String)tEnv.getObjRelation("XSheetLinkable.LinkSheet2"); 52 if (linkUrl2 != null) 53 linkUrl = utils.getFullTestURL(linkUrl); 54 55 // set a name for the sheet. 56 linkSheetName = "Sheet1"; 57 } 58 59 public void _getLinkMode() { 60 requiredMethod("link()"); 61 slm = oObj.getLinkMode(); 62 tRes.tested("getLinkMode()", slm == SheetLinkMode.VALUE); 63 } 64 65 public void _getLinkSheetName() { 66 requiredMethod("link()"); 67 String lSheetName = oObj.getLinkSheetName(); 68 tRes.tested("getLinkSheetName()", linkSheetName.equals(lSheetName)); 69 } 70 71 public void _getLinkUrl() { 72 requiredMethod("link()"); 73 String lUrl = oObj.getLinkUrl(); 74 System.out.println("URL: " + lUrl); 75 tRes.tested("getLinkUrl()", lUrl.equals(linkUrl)); 76 } 77 78 public void _link() { 79 oObj.link(linkUrl, linkSheetName, "", "", SheetLinkMode.VALUE); 80 tRes.tested("link()", true); 81 } 82 83 public void _setLinkMode() { 84 requiredMethod("getLinkMode()"); 85 oObj.setLinkMode(SheetLinkMode.NONE); 86 slm = oObj.getLinkMode(); 87 tRes.tested("setLinkMode()", slm == SheetLinkMode.NONE); 88 } 89 90 public void _setLinkSheetName() { 91 requiredMethod("getLinkSheetName()"); 92 oObj.setLinkSheetName("Sheet2"); 93 linkSheetName = oObj.getLinkSheetName(); 94 tRes.tested("setLinkSheetName()", linkSheetName.equals("Sheet2")); 95 } 96 97 public void _setLinkUrl() { 98 requiredMethod("getLinkUrl()"); 99 boolean result = false; 100 if (linkUrl2 == null) { 101 // set back to the original value 102 oObj.setLinkUrl(linkUrl); 103 result = true; 104 } 105 else { 106 oObj.setLinkUrl(linkUrl2); 107 linkUrl = oObj.getLinkUrl(); 108 result = linkUrl.equals(linkUrl2); 109 } 110 tRes.tested("setLinkUrl()", result); 111 } 112 } 113