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 com.sun.star.sheet.XAreaLinks;
27cdf0e10cSrcweir import com.sun.star.table.CellAddress;
28cdf0e10cSrcweir import lib.MultiMethodTest;
29cdf0e10cSrcweir 
30cdf0e10cSrcweir /**
31cdf0e10cSrcweir * Testing <code>com.sun.star.sheet.XAreaLinks</code>
32cdf0e10cSrcweir * interface methods :
33cdf0e10cSrcweir * <ul>
34cdf0e10cSrcweir *  <li><code> insertAtPosition()</code></li>
35cdf0e10cSrcweir *  <li><code> removeByIndex()</code></li>
36cdf0e10cSrcweir * </ul> <p>
37cdf0e10cSrcweir * Test is <b> NOT </b> multithread compilant. <p>
38cdf0e10cSrcweir * @see com.sun.star.sheet.XAreaLinks
39cdf0e10cSrcweir */
40cdf0e10cSrcweir public class _XAreaLinks extends MultiMethodTest {
41cdf0e10cSrcweir 
42cdf0e10cSrcweir     public XAreaLinks oObj = null;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir     /**
45cdf0e10cSrcweir     * Inserts a new link into collection. Checks number of links
46cdf0e10cSrcweir     * before and after method call. <p>
47cdf0e10cSrcweir     * Has <b>OK</b> status if after method call number of
48cdf0e10cSrcweir     * links increased by 1.
49cdf0e10cSrcweir     */
_insertAtPosition()50cdf0e10cSrcweir     public void _insertAtPosition(){
51cdf0e10cSrcweir         boolean bResult = true ;
52cdf0e10cSrcweir         int cnt = 0;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir           cnt = oObj.getCount() ;
55cdf0e10cSrcweir           CellAddress addr = new CellAddress ((short) 1,2,3) ;
56cdf0e10cSrcweir           String aSourceArea = util.utils.getFullTestURL("calcshapes.sxc");
57cdf0e10cSrcweir           oObj.insertAtPosition (addr, aSourceArea, "a2:b5", "", "") ;
58cdf0e10cSrcweir 
59cdf0e10cSrcweir           if (bResult) {
60cdf0e10cSrcweir             int new_cnt = oObj.getCount() ;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir             if (cnt + 1 != new_cnt) {
63cdf0e10cSrcweir               bResult = false ;
64cdf0e10cSrcweir               log.println("Number of links before insertAtPosition() call was " + cnt +
65cdf0e10cSrcweir                     ", after call is " + new_cnt) ;
66cdf0e10cSrcweir             }
67cdf0e10cSrcweir         }
68cdf0e10cSrcweir 
69cdf0e10cSrcweir         tRes.tested("insertAtPosition()", bResult) ;
70cdf0e10cSrcweir    }
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 
73cdf0e10cSrcweir     /**
74cdf0e10cSrcweir     * Removes a link from collection. Checks number of links
75cdf0e10cSrcweir     * before and after method call. <p>
76cdf0e10cSrcweir     * Has <b>OK</b> status if after method call number of
77cdf0e10cSrcweir     * links decreases by 1. <p>
78cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
79cdf0e10cSrcweir     * <ul>
80cdf0e10cSrcweir     *  <li> <code> insertAtPosition </code> : to have at least one link. </li>
81cdf0e10cSrcweir     * </ul>
82cdf0e10cSrcweir     */
_removeByIndex()83cdf0e10cSrcweir     public void _removeByIndex(){
84cdf0e10cSrcweir          requiredMethod("insertAtPosition()") ;
85cdf0e10cSrcweir 
86cdf0e10cSrcweir          boolean bResult = true ;
87cdf0e10cSrcweir       int lcnt = 0;
88cdf0e10cSrcweir 
89cdf0e10cSrcweir       lcnt = oObj.getCount() ;
90cdf0e10cSrcweir       oObj.removeByIndex(0) ;
91cdf0e10cSrcweir 
92cdf0e10cSrcweir       int new_lcnt = oObj.getCount() ;
93cdf0e10cSrcweir       if (lcnt - 1 != new_lcnt) {
94cdf0e10cSrcweir           bResult = false ;
95cdf0e10cSrcweir           log.println(" # Number of links before removeByIndex() call was " +
96cdf0e10cSrcweir                 lcnt + ", after call is " + new_lcnt) ;
97cdf0e10cSrcweir       }
98cdf0e10cSrcweir       tRes.tested("removeByIndex()", bResult) ;
99cdf0e10cSrcweir     }
100cdf0e10cSrcweir 
101cdf0e10cSrcweir } //EOC _XAreaLinks
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 
104