xref: /AOO42X/main/qadevOOo/tests/java/ifc/table/_XTableColumns.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir package ifc.table;
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir import lib.MultiMethodTest;
31*cdf0e10cSrcweir import lib.Status;
32*cdf0e10cSrcweir import lib.StatusException;
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir import com.sun.star.table.XCell;
35*cdf0e10cSrcweir import com.sun.star.table.XCellRange;
36*cdf0e10cSrcweir import com.sun.star.table.XTableColumns;
37*cdf0e10cSrcweir import com.sun.star.text.XSimpleText;
38*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir /**
41*cdf0e10cSrcweir * Testing <code>com.sun.star.table.XTableColumns</code>
42*cdf0e10cSrcweir * interface methods :
43*cdf0e10cSrcweir * <ul>
44*cdf0e10cSrcweir *  <li><code> insertByIndex()</code></li>
45*cdf0e10cSrcweir *  <li><code> removeByIndex()</code></li>
46*cdf0e10cSrcweir * </ul> <p>
47*cdf0e10cSrcweir *
48*cdf0e10cSrcweir * This test needs the following object relations :
49*cdf0e10cSrcweir * <ul>
50*cdf0e10cSrcweir *  <li> <code>'XTableColumns.XCellRange'</code> : <code>
51*cdf0e10cSrcweir *    com.sun.star.table.XCellRange</code> the cell range of
52*cdf0e10cSrcweir *    columns.</li>
53*cdf0e10cSrcweir * <ul> <p>
54*cdf0e10cSrcweir *
55*cdf0e10cSrcweir * Test is multithread compilant. <p>
56*cdf0e10cSrcweir * @see com.sun.star.table.XTableColumns
57*cdf0e10cSrcweir */
58*cdf0e10cSrcweir public class _XTableColumns extends MultiMethodTest {
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir     public XTableColumns oObj = null;
61*cdf0e10cSrcweir     private XCellRange xCellRange = null;
62*cdf0e10cSrcweir     private int lastColumn = 0;
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir     public void before() {
65*cdf0e10cSrcweir         xCellRange = (XCellRange)
66*cdf0e10cSrcweir             tEnv.getObjRelation("XTableColumns.XCellRange") ;
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir         if (xCellRange == null) throw new
69*cdf0e10cSrcweir             StatusException(Status.failed("Relation missing"));
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir         lastColumn = oObj.getCount() - 1 ;
72*cdf0e10cSrcweir     }
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir     /**
75*cdf0e10cSrcweir      * First a number of cells in cell range are filled with data.
76*cdf0e10cSrcweir      *
77*cdf0e10cSrcweir      * Then columns inserted to valid positions : 1 column at 1,
78*cdf0e10cSrcweir      * 1 column at 0, 2 columns at 0. <p>
79*cdf0e10cSrcweir      *
80*cdf0e10cSrcweir      * Then columns inserted to invalid positions : position -1,
81*cdf0e10cSrcweir      * the column after last, and 0 columns inserted. <p>
82*cdf0e10cSrcweir      *
83*cdf0e10cSrcweir      * Has <b> OK </b> status if for valid cases :
84*cdf0e10cSrcweir      * <ul>
85*cdf0e10cSrcweir      *  <li> content of other cells are properly shifted </li>
86*cdf0e10cSrcweir      *  <li> inserted columns are empty </li>
87*cdf0e10cSrcweir      *  <li> number of columns increases (in case if it is not the whole
88*cdf0e10cSrcweir      *      spreadsheet) by proper number. </li>
89*cdf0e10cSrcweir      * </ul>
90*cdf0e10cSrcweir      * and for invalid cases exception is thrown.
91*cdf0e10cSrcweir      */
92*cdf0e10cSrcweir     public void _insertByIndex() {
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir         boolean result = true;
95*cdf0e10cSrcweir         int origCnt = oObj.getCount();
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir         try {
98*cdf0e10cSrcweir             log.println("Filling range ... ");
99*cdf0e10cSrcweir             fillRange(xCellRange);
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir             log.println("Inserting 1 column at position 1 ...");
102*cdf0e10cSrcweir             oObj.insertByIndex(1,1);
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir             result &= checkColumn(0, 0);
105*cdf0e10cSrcweir             result &= checkColumnEmpty(1);
106*cdf0e10cSrcweir             result &= checkColumn(2, 1);
107*cdf0e10cSrcweir             result &= checkColumn(3, 2);
108*cdf0e10cSrcweir             result &= checkColumnEmpty(4);
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir             if (lastColumn < 200) {
111*cdf0e10cSrcweir                 result &= checkColumn(lastColumn + 1, lastColumn);
112*cdf0e10cSrcweir                 result &= oObj.getCount() == origCnt + 1;
113*cdf0e10cSrcweir             } else {
114*cdf0e10cSrcweir                 result &= checkColumnEmpty(lastColumn);
115*cdf0e10cSrcweir             }
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir             log.println("Inserting 1 column at position 0 ...");
118*cdf0e10cSrcweir             oObj.insertByIndex(0,1);
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir             result &= checkColumnEmpty(0);
121*cdf0e10cSrcweir             result &= checkColumn(1, 0);
122*cdf0e10cSrcweir             result &= checkColumnEmpty(2);
123*cdf0e10cSrcweir             result &= checkColumn(3, 1);
124*cdf0e10cSrcweir             result &= checkColumn(4, 2);
125*cdf0e10cSrcweir             result &= checkColumnEmpty(5);
126*cdf0e10cSrcweir             if (lastColumn < 200) {
127*cdf0e10cSrcweir                 result &= checkColumn(lastColumn + 2, lastColumn);
128*cdf0e10cSrcweir                 result &= oObj.getCount() == origCnt + 2;
129*cdf0e10cSrcweir             }
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir             log.println("Inserting 2 columns at position 0 ...");
132*cdf0e10cSrcweir             oObj.insertByIndex(0,2);
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir             result &= checkColumnEmpty(0);
135*cdf0e10cSrcweir             result &= checkColumnEmpty(1);
136*cdf0e10cSrcweir             result &= checkColumnEmpty(2);
137*cdf0e10cSrcweir             result &= checkColumn(3, 0);
138*cdf0e10cSrcweir             result &= checkColumnEmpty(4);
139*cdf0e10cSrcweir             result &= checkColumn(5, 1);
140*cdf0e10cSrcweir             result &= checkColumn(6, 2);
141*cdf0e10cSrcweir             result &= checkColumnEmpty(7);
142*cdf0e10cSrcweir             if (lastColumn < 200) {
143*cdf0e10cSrcweir                 result &= checkColumn(lastColumn + 4, lastColumn);
144*cdf0e10cSrcweir             }
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
147*cdf0e10cSrcweir             e.printStackTrace(log);
148*cdf0e10cSrcweir             result = false;
149*cdf0e10cSrcweir         }
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir         // spreadsheet supports 256 columns and after inserting
153*cdf0e10cSrcweir         // or removing a column their number remains the same
154*cdf0e10cSrcweir         if (origCnt < 200) {
155*cdf0e10cSrcweir             log.println("Checking that number of column increased.");
156*cdf0e10cSrcweir             result &= oObj.getCount() == origCnt + 4;
157*cdf0e10cSrcweir             log.println("Before: " + origCnt + ", After: " + oObj.getCount());
158*cdf0e10cSrcweir         } else {
159*cdf0e10cSrcweir             log.println("Number of columns is " + origCnt + ",") ;
160*cdf0e10cSrcweir             log.println("supposing that this is the whole spreadsheet and ");
161*cdf0e10cSrcweir             log.println("number of columns should not change.");
162*cdf0e10cSrcweir         }
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir         try {
165*cdf0e10cSrcweir             oObj.insertByIndex(-1,1);
166*cdf0e10cSrcweir             log.println("No Exception occurred while inserting column at -1");
167*cdf0e10cSrcweir             result &= false;
168*cdf0e10cSrcweir         } catch (Exception e) {
169*cdf0e10cSrcweir             log.println("Inserting column at Index -1 ... OK");
170*cdf0e10cSrcweir             result &= true;
171*cdf0e10cSrcweir         }
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir         int cnt = oObj.getCount();
174*cdf0e10cSrcweir         try {
175*cdf0e10cSrcweir             oObj.insertByIndex(cnt, 1);
176*cdf0e10cSrcweir             log.println("No Exception occurred while inserting column at "
177*cdf0e10cSrcweir                 + cnt);
178*cdf0e10cSrcweir             result &= false;
179*cdf0e10cSrcweir         } catch (Exception e) {
180*cdf0e10cSrcweir             log.println("Inserting column at Index " + cnt + " ... OK");
181*cdf0e10cSrcweir             result &= true;
182*cdf0e10cSrcweir         }
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir         if (tEnv.getTestCase().getObjectName().equals("ScTableColumnsObj")) {
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir             try {
187*cdf0e10cSrcweir                 oObj.insertByIndex(0,0);
188*cdf0e10cSrcweir                 log.println("No Exception occurred while inserting 0 columns");
189*cdf0e10cSrcweir                 result &= false;
190*cdf0e10cSrcweir             } catch (Exception e) {
191*cdf0e10cSrcweir                 log.println("Inserting 0 columns ... OK");
192*cdf0e10cSrcweir                 result &= true;
193*cdf0e10cSrcweir             }
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir         }
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir         tRes.tested( "insertByIndex()", result );
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir     } // end insertByIndex()
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir     /**
202*cdf0e10cSrcweir      * Columns removed from valid positions : 1 column at 1,
203*cdf0e10cSrcweir      * 1 column at 0, 2 columns at 0. <p>
204*cdf0e10cSrcweir      *
205*cdf0e10cSrcweir      * Then columns removed from invalid positions : position -1,
206*cdf0e10cSrcweir      * the column after last, and 0 columns removed. <p>
207*cdf0e10cSrcweir      *
208*cdf0e10cSrcweir      * Has <b> OK </b> status if for valid cases :
209*cdf0e10cSrcweir      * <ul>
210*cdf0e10cSrcweir      *  <li> content of other cells are properly shifted </li>
211*cdf0e10cSrcweir      *  <li> columns which are shifted left are empty </li>
212*cdf0e10cSrcweir      *  <li> number of columns decreases (in case if it is not the whole
213*cdf0e10cSrcweir      *      spreadsheet) by proper number. </li>
214*cdf0e10cSrcweir      * </ul>
215*cdf0e10cSrcweir      * and for invalid cases exception is thrown.
216*cdf0e10cSrcweir      */
217*cdf0e10cSrcweir     public void _removeByIndex() {
218*cdf0e10cSrcweir         executeMethod("insertByIndex()");
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir         boolean result = true;
221*cdf0e10cSrcweir         int origCnt = oObj.getCount();
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir         try {
224*cdf0e10cSrcweir             log.println("Filling range ... ");
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir             log.println("Removing 2 columns at position 0 ...");
227*cdf0e10cSrcweir             oObj.removeByIndex(0,2);
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir             result &= checkColumnEmpty(0);
230*cdf0e10cSrcweir             result &= checkColumn(1, 0);
231*cdf0e10cSrcweir             result &= checkColumnEmpty(2);
232*cdf0e10cSrcweir             result &= checkColumn(3, 1);
233*cdf0e10cSrcweir             result &= checkColumn(4, 2);
234*cdf0e10cSrcweir             result &= checkColumnEmpty(5);
235*cdf0e10cSrcweir             if (lastColumn < 200) {
236*cdf0e10cSrcweir                 result &= checkColumn(lastColumn + 2, lastColumn);
237*cdf0e10cSrcweir                 result &= oObj.getCount() == origCnt - 2;
238*cdf0e10cSrcweir             }
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir             log.println("Removing 1 column at position 0 ...");
241*cdf0e10cSrcweir             oObj.removeByIndex(0,1);
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir             result &= checkColumn(0, 0);
244*cdf0e10cSrcweir             result &= checkColumnEmpty(1);
245*cdf0e10cSrcweir             result &= checkColumn(2, 1);
246*cdf0e10cSrcweir             result &= checkColumn(3, 2);
247*cdf0e10cSrcweir             result &= checkColumnEmpty(4);
248*cdf0e10cSrcweir             if (lastColumn < 200) {
249*cdf0e10cSrcweir                 result &= checkColumn(lastColumn + 1, lastColumn);
250*cdf0e10cSrcweir                 result &= oObj.getCount() == origCnt - 3;
251*cdf0e10cSrcweir             }
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir             log.println("Removing 1 column at position 1 ...");
254*cdf0e10cSrcweir             oObj.removeByIndex(1,1);
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir             result &= checkColumn(0, 0);
257*cdf0e10cSrcweir             result &= checkColumn(1, 1);
258*cdf0e10cSrcweir             result &= checkColumn(2, 2);
259*cdf0e10cSrcweir             result &= checkColumnEmpty(3);
260*cdf0e10cSrcweir             if (lastColumn < 200) {
261*cdf0e10cSrcweir                 result &= checkColumn(lastColumn, lastColumn);
262*cdf0e10cSrcweir             }
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
265*cdf0e10cSrcweir             e.printStackTrace(log);
266*cdf0e10cSrcweir             result = false;
267*cdf0e10cSrcweir         }
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir         // spreadsheet supports 256 columns and after inserting
271*cdf0e10cSrcweir         // or removing a column their number remains the same
272*cdf0e10cSrcweir         if (origCnt < 200) {
273*cdf0e10cSrcweir             log.println("Checking that number of column increased.");
274*cdf0e10cSrcweir             result &= oObj.getCount() == origCnt - 4;
275*cdf0e10cSrcweir             log.println("Before: " + origCnt + ", After: " + oObj.getCount());
276*cdf0e10cSrcweir         } else {
277*cdf0e10cSrcweir             log.println("Number of columns is " + origCnt + ",") ;
278*cdf0e10cSrcweir             log.println("supposing that this is the whole spreadsheet and ");
279*cdf0e10cSrcweir             log.println("number of columns should not change.");
280*cdf0e10cSrcweir         }
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir         try {
283*cdf0e10cSrcweir             oObj.removeByIndex(-1,1);
284*cdf0e10cSrcweir             log.println("No Exception occurred while removing column at -1");
285*cdf0e10cSrcweir             result &= false;
286*cdf0e10cSrcweir         } catch (Exception e) {
287*cdf0e10cSrcweir             log.println("removing column at Index -1 ... OK");
288*cdf0e10cSrcweir             result &= true;
289*cdf0e10cSrcweir         }
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir         int cnt = oObj.getCount();
292*cdf0e10cSrcweir         try {
293*cdf0e10cSrcweir             oObj.removeByIndex(cnt, 1);
294*cdf0e10cSrcweir             log.println("No Exception occurred while removing column at "
295*cdf0e10cSrcweir                 + cnt);
296*cdf0e10cSrcweir             result &= false;
297*cdf0e10cSrcweir         } catch (Exception e) {
298*cdf0e10cSrcweir             log.println("Removing column at Index " + cnt + " ... OK");
299*cdf0e10cSrcweir             result &= true;
300*cdf0e10cSrcweir         }
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir         if (tEnv.getTestCase().getObjectName().equals("ScTableColumnsObj")) {
303*cdf0e10cSrcweir             try {
304*cdf0e10cSrcweir                 oObj.removeByIndex(0,0);
305*cdf0e10cSrcweir                 log.println("No Exception occurred while removing 0 columns");
306*cdf0e10cSrcweir                 result &= false;
307*cdf0e10cSrcweir             } catch (Exception e) {
308*cdf0e10cSrcweir                 log.println("removing 0 columns ... OK");
309*cdf0e10cSrcweir                 result &= true;
310*cdf0e10cSrcweir             }
311*cdf0e10cSrcweir         }
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir         tRes.tested( "removeByIndex()", result );
314*cdf0e10cSrcweir     } // end removeByIndex()
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir     private void setCellText(XCell cell, String text) {
317*cdf0e10cSrcweir         XSimpleText xText = (XSimpleText) UnoRuntime.queryInterface
318*cdf0e10cSrcweir             (XSimpleText.class, cell) ;
319*cdf0e10cSrcweir         xText.setString(text);
320*cdf0e10cSrcweir     }
321*cdf0e10cSrcweir     private String getCellText(XCell cell) {
322*cdf0e10cSrcweir         XSimpleText xText = (XSimpleText) UnoRuntime.queryInterface
323*cdf0e10cSrcweir             (XSimpleText.class, cell) ;
324*cdf0e10cSrcweir         return xText.getString();
325*cdf0e10cSrcweir     }
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir     /**
328*cdf0e10cSrcweir      * Fills the range with some data : two rows and 3 columns, and
329*cdf0e10cSrcweir      * some columns are cleared.
330*cdf0e10cSrcweir      *
331*cdf0e10cSrcweir      * @param xRange Range to fill
332*cdf0e10cSrcweir      * @throws IndexOutOfBoundsException if any errors occur during filling.
333*cdf0e10cSrcweir      */
334*cdf0e10cSrcweir     private void fillRange(XCellRange xRange)
335*cdf0e10cSrcweir             throws com.sun.star.lang.IndexOutOfBoundsException {
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir         for (int i = 0; i <= lastColumn && i < 3; i++) {
338*cdf0e10cSrcweir             setCellText(xRange.getCellByPosition(i, 0), "" + i + "a");
339*cdf0e10cSrcweir             setCellText(xRange.getCellByPosition(i, 1), "" + i + "b");
340*cdf0e10cSrcweir         }
341*cdf0e10cSrcweir 
342*cdf0e10cSrcweir         for (int i = 3; i <= lastColumn && i < 10; i++) {
343*cdf0e10cSrcweir             setCellText(xRange.getCellByPosition(i, 0), "");
344*cdf0e10cSrcweir             setCellText(xRange.getCellByPosition(i, 1), "");
345*cdf0e10cSrcweir         }
346*cdf0e10cSrcweir     }
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir     /**
349*cdf0e10cSrcweir      * Check the column (first two rows) if it has values with
350*cdf0e10cSrcweir      * index specified.
351*cdf0e10cSrcweir      *
352*cdf0e10cSrcweir      * @param col Column to check
353*cdf0e10cSrcweir      * @param idx What indexes must be in cells
354*cdf0e10cSrcweir      * @return <code>true</code> if expected indexes are found,
355*cdf0e10cSrcweir      *  <code>false</code> otherwise.
356*cdf0e10cSrcweir      * @throws IndexOutOfBoundsException
357*cdf0e10cSrcweir      */
358*cdf0e10cSrcweir     private boolean checkColumn(int col, int idx)
359*cdf0e10cSrcweir             throws com.sun.star.lang.IndexOutOfBoundsException {
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir         if (col >= oObj.getCount()) return true;
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir         String c1 = getCellText(xCellRange.getCellByPosition(col, 0));
364*cdf0e10cSrcweir         String c2 = getCellText(xCellRange.getCellByPosition(col, 1));
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir         if (!((""+ idx + "a").equals(c1) && (""+ idx + "b").equals(c2))) {
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir             log.println("FAILED for column " + col + " and index " + idx + "("
369*cdf0e10cSrcweir                 + c1 + "," + c2 + ")");
370*cdf0e10cSrcweir             return false ;
371*cdf0e10cSrcweir         }
372*cdf0e10cSrcweir         return true;
373*cdf0e10cSrcweir     }
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir     /**
376*cdf0e10cSrcweir      * Checks if the column (first two rows) has no data in its cells.
377*cdf0e10cSrcweir      *
378*cdf0e10cSrcweir      * @param col Column to check
379*cdf0e10cSrcweir      * @return <code>true</code> if the column is empty, <code>false</code>
380*cdf0e10cSrcweir      *   if first two cells contains some strings.
381*cdf0e10cSrcweir      * @throws IndexOutOfBoundsException
382*cdf0e10cSrcweir      */
383*cdf0e10cSrcweir     private boolean checkColumnEmpty(int col)
384*cdf0e10cSrcweir             throws com.sun.star.lang.IndexOutOfBoundsException {
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir         if (col >= oObj.getCount()) return true;
387*cdf0e10cSrcweir 
388*cdf0e10cSrcweir         String c1 = getCellText(xCellRange.getCellByPosition(col, 0));
389*cdf0e10cSrcweir         String c2 = getCellText(xCellRange.getCellByPosition(col, 1));
390*cdf0e10cSrcweir         if (!("".equals(c1) && "".equals(c2))) {
391*cdf0e10cSrcweir             log.println("FAILED for column " + col + " is not empty ("
392*cdf0e10cSrcweir                 + c1 + "," + c2 + ")");
393*cdf0e10cSrcweir             return false ;
394*cdf0e10cSrcweir         }
395*cdf0e10cSrcweir         return true;
396*cdf0e10cSrcweir     }
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir     } //finish class _XTableColumns
399*cdf0e10cSrcweir 
400