1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 package ifc.sheet; 24 25 import com.sun.star.sheet.SheetLinkMode; 26 import com.sun.star.sheet.XSheetLinkable; 27 import lib.MultiMethodTest; 28 import util.utils; 29 30 /** 31 * 32 */ 33 public class _XSheetLinkable extends MultiMethodTest { 34 public XSheetLinkable oObj = null; 35 SheetLinkMode slm = null; 36 String linkSheetName = null; 37 String linkUrl = null; 38 String linkUrl2 = null; 39 before()40 public void before() { 41 // get a document for linking. 42 linkUrl = (String)tEnv.getObjRelation("XSheetLinkable.LinkSheet"); 43 linkUrl = utils.getFullTestURL(linkUrl); 44 45 // get a second sheet for changing the link url: if it's not set, 46 // this part of the test is omitted. 47 linkUrl2 = (String)tEnv.getObjRelation("XSheetLinkable.LinkSheet2"); 48 if (linkUrl2 != null) 49 linkUrl = utils.getFullTestURL(linkUrl); 50 51 // set a name for the sheet. 52 linkSheetName = "Sheet1"; 53 } 54 _getLinkMode()55 public void _getLinkMode() { 56 requiredMethod("link()"); 57 slm = oObj.getLinkMode(); 58 tRes.tested("getLinkMode()", slm == SheetLinkMode.VALUE); 59 } 60 _getLinkSheetName()61 public void _getLinkSheetName() { 62 requiredMethod("link()"); 63 String lSheetName = oObj.getLinkSheetName(); 64 tRes.tested("getLinkSheetName()", linkSheetName.equals(lSheetName)); 65 } 66 _getLinkUrl()67 public void _getLinkUrl() { 68 requiredMethod("link()"); 69 String lUrl = oObj.getLinkUrl(); 70 System.out.println("URL: " + lUrl); 71 tRes.tested("getLinkUrl()", lUrl.equals(linkUrl)); 72 } 73 _link()74 public void _link() { 75 oObj.link(linkUrl, linkSheetName, "", "", SheetLinkMode.VALUE); 76 tRes.tested("link()", true); 77 } 78 _setLinkMode()79 public void _setLinkMode() { 80 requiredMethod("getLinkMode()"); 81 oObj.setLinkMode(SheetLinkMode.NONE); 82 slm = oObj.getLinkMode(); 83 tRes.tested("setLinkMode()", slm == SheetLinkMode.NONE); 84 } 85 _setLinkSheetName()86 public void _setLinkSheetName() { 87 requiredMethod("getLinkSheetName()"); 88 oObj.setLinkSheetName("Sheet2"); 89 linkSheetName = oObj.getLinkSheetName(); 90 tRes.tested("setLinkSheetName()", linkSheetName.equals("Sheet2")); 91 } 92 _setLinkUrl()93 public void _setLinkUrl() { 94 requiredMethod("getLinkUrl()"); 95 boolean result = false; 96 if (linkUrl2 == null) { 97 // set back to the original value 98 oObj.setLinkUrl(linkUrl); 99 result = true; 100 } 101 else { 102 oObj.setLinkUrl(linkUrl2); 103 linkUrl = oObj.getLinkUrl(); 104 result = linkUrl.equals(linkUrl2); 105 } 106 tRes.tested("setLinkUrl()", result); 107 } 108 } 109