1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
29 import com
.sun
.star
.sheet
.SheetLinkMode
;
30 import com
.sun
.star
.sheet
.XSheetLinkable
;
31 import lib
.MultiMethodTest
;
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;
44 public void before() {
45 // get a document for linking.
46 linkUrl
= (String
)tEnv
.getObjRelation("XSheetLinkable.LinkSheet");
47 linkUrl
= utils
.getFullTestURL(linkUrl
);
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");
53 linkUrl
= utils
.getFullTestURL(linkUrl
);
55 // set a name for the sheet.
56 linkSheetName
= "Sheet1";
59 public void _getLinkMode() {
60 requiredMethod("link()");
61 slm
= oObj
.getLinkMode();
62 tRes
.tested("getLinkMode()", slm
== SheetLinkMode
.VALUE
);
65 public void _getLinkSheetName() {
66 requiredMethod("link()");
67 String lSheetName
= oObj
.getLinkSheetName();
68 tRes
.tested("getLinkSheetName()", linkSheetName
.equals(lSheetName
));
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
));
79 oObj
.link(linkUrl
, linkSheetName
, "", "", SheetLinkMode
.VALUE
);
80 tRes
.tested("link()", true);
83 public void _setLinkMode() {
84 requiredMethod("getLinkMode()");
85 oObj
.setLinkMode(SheetLinkMode
.NONE
);
86 slm
= oObj
.getLinkMode();
87 tRes
.tested("setLinkMode()", slm
== SheetLinkMode
.NONE
);
90 public void _setLinkSheetName() {
91 requiredMethod("getLinkSheetName()");
92 oObj
.setLinkSheetName("Sheet2");
93 linkSheetName
= oObj
.getLinkSheetName();
94 tRes
.tested("setLinkSheetName()", linkSheetName
.equals("Sheet2"));
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
);
106 oObj
.setLinkUrl(linkUrl2
);
107 linkUrl
= oObj
.getLinkUrl();
108 result
= linkUrl
.equals(linkUrl2
);
110 tRes
.tested("setLinkUrl()", result
);