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.view;
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir import com.sun.star.container.NoSuchElementException;
31*cdf0e10cSrcweir import com.sun.star.container.XEnumeration;
32*cdf0e10cSrcweir import com.sun.star.lang.WrappedTargetException;
33*cdf0e10cSrcweir import com.sun.star.view.XMultiSelectionSupplier;
34*cdf0e10cSrcweir import java.util.Comparator;
35*cdf0e10cSrcweir import lib.MultiMethodTest;
36*cdf0e10cSrcweir import lib.Status;
37*cdf0e10cSrcweir import lib.StatusException;
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir /**
40*cdf0e10cSrcweir  * Testing <code>com.sun.star.view.XSelectionSupplier</code>
41*cdf0e10cSrcweir  * interface methods :
42*cdf0e10cSrcweir  * <ul>
43*cdf0e10cSrcweir  *  <li><code> addSelection()</code></li>
44*cdf0e10cSrcweir  *  <li><code> removeSelection()</code></li>
45*cdf0e10cSrcweir  *  <li><code> clearSelection()</code></li>
46*cdf0e10cSrcweir  *  <li><code> getSelectionCount()</code></li>
47*cdf0e10cSrcweir  *  <li><code> createSelectionEnumeration()</code></li>
48*cdf0e10cSrcweir  *  <li><code> createReverseSelectionEnumeration()</code></li>
49*cdf0e10cSrcweir  * </ul>
50*cdf0e10cSrcweir  * This test needs the following object relations :
51*cdf0e10cSrcweir  * <ul>
52*cdf0e10cSrcweir  *  <li> <code>'Selections'</code> of type <code>Object[]</code> :
53*cdf0e10cSrcweir  *   the array of the instances which can be selected.</li>
54*cdf0e10cSrcweir  *  <li> <code>'Comparer'</code> of type <code>Comparator</code> :
55*cdf0e10cSrcweir  *   the interface for comparing of selected instances</li>
56*cdf0e10cSrcweir  * <ul> <p>
57*cdf0e10cSrcweir  * Test is <b> NOT </b> multithread compilant. <p>
58*cdf0e10cSrcweir  * @see com.sun.star.view.XSelectionSupplier
59*cdf0e10cSrcweir  */
60*cdf0e10cSrcweir public class _XMultiSelectionSupplier extends MultiMethodTest {
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir     public XMultiSelectionSupplier oObj = null;
63*cdf0e10cSrcweir     public boolean selectionChanged = false;
64*cdf0e10cSrcweir     Object[] selections = null;
65*cdf0e10cSrcweir     Comparator ObjCompare = null;
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir     protected void before() {
68*cdf0e10cSrcweir         selections = (Object[])tEnv.getObjRelation("Selections");
69*cdf0e10cSrcweir         if (selections == null) {
70*cdf0e10cSrcweir             throw new StatusException(Status.failed(
71*cdf0e10cSrcweir                 "Couldn't get relation 'Selections'"));
72*cdf0e10cSrcweir         }
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir         ObjCompare = (Comparator)tEnv.getObjRelation("Comparer");
75*cdf0e10cSrcweir     }
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir     protected void after() {
78*cdf0e10cSrcweir         disposeEnvironment();
79*cdf0e10cSrcweir     }
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir     /**
82*cdf0e10cSrcweir      * Selects an instance from relation 'First'. <p>
83*cdf0e10cSrcweir      * Has <b> OK </b> status if no exceptions were thrown. <p>
84*cdf0e10cSrcweir      */
85*cdf0e10cSrcweir     public void _addSelection() {
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir         boolean bOK = true;
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir         log.println("clear selections");
90*cdf0e10cSrcweir         oObj.clearSelection();
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir         int count = oObj.getSelectionCount();
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir         bOK &= (count == 0);
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir         if ( ! bOK) log.println("ERROR: after clear selection I got a selection count of '" + count + "' => FAILED");
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir         for(int i = 0; i < selections.length; i++) {
99*cdf0e10cSrcweir             try {
100*cdf0e10cSrcweir                 log.println("select object from object relation 'selections["+i+"]'");
101*cdf0e10cSrcweir                 oObj.addSelection(selections[i]);
102*cdf0e10cSrcweir             } catch (com.sun.star.lang.IllegalArgumentException ex) {
103*cdf0e10cSrcweir                 log.println("ERROR: could not add selection from object relation 'selections[" + i + "]': " + ex.toString());
104*cdf0e10cSrcweir                 bOK = false;
105*cdf0e10cSrcweir             }
106*cdf0e10cSrcweir             count = oObj.getSelectionCount();
107*cdf0e10cSrcweir             if (count != (i+1)){
108*cdf0e10cSrcweir                 log.println("ERROR: add a selection but selection count ("+count+ ") " +
109*cdf0e10cSrcweir                     "is not as expected (" + (i+1) + ") => FAILED");
110*cdf0e10cSrcweir                 bOK = false;
111*cdf0e10cSrcweir             }
112*cdf0e10cSrcweir         }
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir         log.println("try to select object relation 'selections[0]' second time...");
115*cdf0e10cSrcweir         try {
116*cdf0e10cSrcweir             count = oObj.getSelectionCount();
117*cdf0e10cSrcweir             oObj.addSelection(selections[0]);
118*cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException ex) {
119*cdf0e10cSrcweir             log.println("ERROR: could not add selection from object relation 'selections[0] a second time': " + ex.toString());
120*cdf0e10cSrcweir         }
121*cdf0e10cSrcweir         if (count != oObj.getSelectionCount()){
122*cdf0e10cSrcweir             log.println("ERROR: the selected count ("+oObj.getSelectionCount() +") is not that before (" + count + ")");
123*cdf0e10cSrcweir             bOK = false;
124*cdf0e10cSrcweir         }
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir         log.println("try to select invalid object...");
127*cdf0e10cSrcweir         try {
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir             oObj.addSelection(oObj);
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir             log.println("ERORR: expected exception 'com.sun.star.lang.IllegalArgumentException' was not thrown => FAILED");
132*cdf0e10cSrcweir             bOK = false;
133*cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException ex) {
134*cdf0e10cSrcweir             log.println("expected exception 'com.sun.star.lang.IllegalArgumentException' => OK");
135*cdf0e10cSrcweir         }
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir         tRes.tested("addSelection()", bOK);
138*cdf0e10cSrcweir     }
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir     public void _removeSelection() {
141*cdf0e10cSrcweir         requiredMethod("addSelection()");
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir         boolean bOK = true;
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir         log.println("clear selections");
146*cdf0e10cSrcweir         oObj.clearSelection();
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir         int count = oObj.getSelectionCount();
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir         bOK &= (count == 0);
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir         if ( ! bOK) log.println("ERROR: after clear selection I got a selection count of '" + count + "' => FAILED");
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir         log.println("add some selections...");
155*cdf0e10cSrcweir         for(int i = 0; i < selections.length; i++) {
156*cdf0e10cSrcweir             try {
157*cdf0e10cSrcweir                 log.println("select object from object relation 'selections["+i+"]'");
158*cdf0e10cSrcweir                 oObj.addSelection(selections[i]);
159*cdf0e10cSrcweir             } catch (com.sun.star.lang.IllegalArgumentException ex) {
160*cdf0e10cSrcweir                 log.println("ERROR: could not add selection from object relation 'selections[" + i + "]': " + ex.toString());
161*cdf0e10cSrcweir                 bOK = false;
162*cdf0e10cSrcweir             }
163*cdf0e10cSrcweir             count = oObj.getSelectionCount();
164*cdf0e10cSrcweir             if (count != (i+1)){
165*cdf0e10cSrcweir                 log.println("ERROR: added a selection but selection count ("+count+ ") " +
166*cdf0e10cSrcweir                     "is not as expected (" + (i+1) + ") => FAILED");
167*cdf0e10cSrcweir                 bOK = false;
168*cdf0e10cSrcweir             }
169*cdf0e10cSrcweir         }
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir         log.println("try now to remove selections...");
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir         count = oObj.getSelectionCount();
174*cdf0e10cSrcweir         int oldCount = oObj.getSelectionCount();
175*cdf0e10cSrcweir         for(int i = 0; i < selections.length; i++) {
176*cdf0e10cSrcweir             try {
177*cdf0e10cSrcweir                 log.println("remove selection for object relation 'selections["+i+"]'");
178*cdf0e10cSrcweir                 oObj.removeSelection(selections[i]);
179*cdf0e10cSrcweir             } catch (com.sun.star.lang.IllegalArgumentException ex) {
180*cdf0e10cSrcweir                 log.println("ERROR: could not remove selection from object relation 'selections[" + i + "]': " + ex.toString());
181*cdf0e10cSrcweir                 bOK = false;
182*cdf0e10cSrcweir             }
183*cdf0e10cSrcweir             count = oObj.getSelectionCount();
184*cdf0e10cSrcweir             if (count !=  (oldCount - i - 1)){
185*cdf0e10cSrcweir                 log.println("ERROR: removed a selection but selection count ("+count+ ") " +
186*cdf0e10cSrcweir                     "is not as expected (" + (oldCount -i -1) + ") => FAILED");
187*cdf0e10cSrcweir                 bOK = false;
188*cdf0e10cSrcweir             }
189*cdf0e10cSrcweir         }
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir         log.println("try to remove a removed selection a second time...");
192*cdf0e10cSrcweir         count = oObj.getSelectionCount();
193*cdf0e10cSrcweir         try {
194*cdf0e10cSrcweir             oObj.removeSelection(selections[0]);
195*cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException ex) {
196*cdf0e10cSrcweir             log.println("ERROR: could not remove selection from object relation 'selections[0] a second time': " + ex.toString());
197*cdf0e10cSrcweir         }
198*cdf0e10cSrcweir         if (count != oObj.getSelectionCount()){
199*cdf0e10cSrcweir             log.println("ERROR: the selected count ("+oObj.getSelectionCount() +") is not that before (" + count + ")");
200*cdf0e10cSrcweir             bOK = false;
201*cdf0e10cSrcweir         }
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir         log.println("try to remove invalid object...");
204*cdf0e10cSrcweir         try {
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir             oObj.removeSelection(oObj);
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir             log.println("ERORR: expected exception 'com.sun.star.lang.IllegalArgumentException' was not thrown => FAILED");
209*cdf0e10cSrcweir             bOK = false;
210*cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException ex) {
211*cdf0e10cSrcweir             log.println("expected exception 'com.sun.star.lang.IllegalArgumentException' => OK");
212*cdf0e10cSrcweir         }
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir         tRes.tested("removeSelection()", bOK);
215*cdf0e10cSrcweir     }
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir     /**
219*cdf0e10cSrcweir      * First test changes selection of the object : if nothing is
220*cdf0e10cSrcweir      * currently selected or first instance ('First' relation) is
221*cdf0e10cSrcweir      * selected then selects second instance; if second instance
222*cdf0e10cSrcweir      * is currently selected then the first instance is selected. <p>
223*cdf0e10cSrcweir      * Then <code>getSelection</code> is called and values set and
224*cdf0e10cSrcweir      * get are compared. Comparison has some special cases. For
225*cdf0e10cSrcweir      * example if selection is a Cell, then the values contained
226*cdf0e10cSrcweir      * in cells are compared. <p>
227*cdf0e10cSrcweir      * Has <b>OK</b> status if selection changed properly.
228*cdf0e10cSrcweir      */
229*cdf0e10cSrcweir     public void _getSelectionCount() {
230*cdf0e10cSrcweir         requiredMethod("addSelection()");
231*cdf0e10cSrcweir         tRes.tested("getSelectionCount()", true);
232*cdf0e10cSrcweir     }
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir     public void _clearSelection() {
235*cdf0e10cSrcweir         requiredMethod("addSelection()");
236*cdf0e10cSrcweir         boolean bOK = true;
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir         log.println("clear selections");
239*cdf0e10cSrcweir         oObj.clearSelection();
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir         int count = oObj.getSelectionCount();
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir         bOK &= (count == 0);
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir         if ( ! bOK) log.println("ERROR: after clear selection I got a selection count of '" + count + "' => FAILED");
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir         log.println("add some selections...");
248*cdf0e10cSrcweir         for(int i = 0; i < selections.length; i++) {
249*cdf0e10cSrcweir             try {
250*cdf0e10cSrcweir                 log.println("select object from object relation 'selections["+i+"]'");
251*cdf0e10cSrcweir                 oObj.addSelection(selections[i]);
252*cdf0e10cSrcweir             } catch (com.sun.star.lang.IllegalArgumentException ex) {
253*cdf0e10cSrcweir                 log.println("ERROR: could not add selection from object relation 'selections[" + i + "]': " + ex.toString());
254*cdf0e10cSrcweir                 bOK = false;
255*cdf0e10cSrcweir             }
256*cdf0e10cSrcweir             count = oObj.getSelectionCount();
257*cdf0e10cSrcweir             if (count != (i+1)){
258*cdf0e10cSrcweir                 log.println("ERROR: added a selection but selection count ("+count+ ") " +
259*cdf0e10cSrcweir                     "is not as expected (" + (i+1) + ") => FAILED");
260*cdf0e10cSrcweir                 bOK = false;
261*cdf0e10cSrcweir             }
262*cdf0e10cSrcweir         }
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir         count = oObj.getSelectionCount();
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir         log.println("clear selections...");
267*cdf0e10cSrcweir         oObj.clearSelection();
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir         count = oObj.getSelectionCount();
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir         bOK &= (count == 0);
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir         if ( ! bOK) log.println("ERROR: after clear selection I got a selection count of '" + count + "' => FAILED");
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir         tRes.tested("clearSelection()", bOK);
276*cdf0e10cSrcweir     }
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir     public void _createSelectionEnumeration() {
279*cdf0e10cSrcweir         requiredMethod("addSelection()");
280*cdf0e10cSrcweir         boolean bOK = true;
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir         log.println("clear selections");
283*cdf0e10cSrcweir         oObj.clearSelection();
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir         int count = oObj.getSelectionCount();
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir         bOK &= (count == 0);
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir         if ( ! bOK) log.println("ERROR: after clear selection I got a selection count of '" + count + "' => FAILED");
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir         log.println("add some selections...");
292*cdf0e10cSrcweir         for(int i = 0; i < selections.length; i++) {
293*cdf0e10cSrcweir             try {
294*cdf0e10cSrcweir                 log.println("select object from object relation 'selections["+i+"]'");
295*cdf0e10cSrcweir                 oObj.addSelection(selections[i]);
296*cdf0e10cSrcweir             } catch (com.sun.star.lang.IllegalArgumentException ex) {
297*cdf0e10cSrcweir                 log.println("ERROR: could not add selection from object relation 'selections[" + i + "]': " + ex.toString());
298*cdf0e10cSrcweir                 bOK = false;
299*cdf0e10cSrcweir             }
300*cdf0e10cSrcweir             count = oObj.getSelectionCount();
301*cdf0e10cSrcweir             if (count != (i+1)){
302*cdf0e10cSrcweir                 log.println("ERROR: added a selection but selection count ("+count+ ") " +
303*cdf0e10cSrcweir                     "is not as expected (" + (i+1) + ") => FAILED");
304*cdf0e10cSrcweir                 bOK = false;
305*cdf0e10cSrcweir             }
306*cdf0e10cSrcweir         }
307*cdf0e10cSrcweir 
308*cdf0e10cSrcweir         log.println("create enumeration...");
309*cdf0e10cSrcweir         XEnumeration xEnum = oObj.createSelectionEnumeration();
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir         boolean compRes = true; //compare result
312*cdf0e10cSrcweir         int i = 0;
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir         while (xEnum.hasMoreElements()){
315*cdf0e10cSrcweir             log.println("try to get first element..");
316*cdf0e10cSrcweir             Object nextElement = null;
317*cdf0e10cSrcweir             try {
318*cdf0e10cSrcweir                 nextElement = xEnum.nextElement();
319*cdf0e10cSrcweir             } catch (WrappedTargetException ex) {
320*cdf0e10cSrcweir                 log.println("ERROR: could not get nextElement: " + ex.toString());
321*cdf0e10cSrcweir                 bOK = false;
322*cdf0e10cSrcweir             } catch (NoSuchElementException ex) {
323*cdf0e10cSrcweir                 log.println("ERROR: could not get nextElement: " + ex.toString());
324*cdf0e10cSrcweir                 bOK = false;
325*cdf0e10cSrcweir             }
326*cdf0e10cSrcweir             Object shouldElement = selections[i];
327*cdf0e10cSrcweir             i++;
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir             if (ObjCompare != null) {
330*cdf0e10cSrcweir                 ObjCompare.compare(shouldElement, nextElement);
331*cdf0e10cSrcweir             } else {
332*cdf0e10cSrcweir                 compRes = util.ValueComparer.equalValue(shouldElement, nextElement);
333*cdf0e10cSrcweir             }
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir             log.println("nextElement()-object and expected object 'selections["+i+"]' are equal: "+compRes);
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir             if (!compRes) {
338*cdf0e10cSrcweir                 if ((selections[i]) instanceof Object[]){
339*cdf0e10cSrcweir                     if (((Object[])selections[i])[0] instanceof Integer) {
340*cdf0e10cSrcweir                         log.println("Getting: "+((Integer) ((Object[])shouldElement)[0]).intValue());
341*cdf0e10cSrcweir                         log.println("Expected: "+((Integer) ((Object[])selections[i])[0]).intValue());
342*cdf0e10cSrcweir                     }
343*cdf0e10cSrcweir                 }
344*cdf0e10cSrcweir             }
345*cdf0e10cSrcweir             bOK &= compRes;
346*cdf0e10cSrcweir         }
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir         tRes.tested("createSelectionEnumeration()", bOK);
349*cdf0e10cSrcweir     }
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir     public void _createReverseSelectionEnumeration() {
352*cdf0e10cSrcweir         requiredMethod("addSelection()");
353*cdf0e10cSrcweir         boolean bOK = true;
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir         log.println("clear selections");
356*cdf0e10cSrcweir         oObj.clearSelection();
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir         int count = oObj.getSelectionCount();
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir         bOK &= (count == 0);
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir         if ( ! bOK) log.println("ERROR: after clear selection I got a selection count of '" + count + "' => FAILED");
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir         log.println("add some selections...");
365*cdf0e10cSrcweir         for(int i = 0; i < selections.length; i++) {
366*cdf0e10cSrcweir             try {
367*cdf0e10cSrcweir                 log.println("select object from object relation 'selections["+i+"]'");
368*cdf0e10cSrcweir                 oObj.addSelection(selections[i]);
369*cdf0e10cSrcweir             } catch (com.sun.star.lang.IllegalArgumentException ex) {
370*cdf0e10cSrcweir                 log.println("ERROR: could not add selection from object relation 'selections[" + i + "]': " + ex.toString());
371*cdf0e10cSrcweir                 bOK = false;
372*cdf0e10cSrcweir             }
373*cdf0e10cSrcweir             count = oObj.getSelectionCount();
374*cdf0e10cSrcweir             if (count != (i+1)){
375*cdf0e10cSrcweir                 log.println("ERROR: added a selection but selection count ("+count+ ") " +
376*cdf0e10cSrcweir                     "is not as expected (" + (i+1) + ") => FAILED");
377*cdf0e10cSrcweir                 bOK = false;
378*cdf0e10cSrcweir             }
379*cdf0e10cSrcweir         }
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir         log.println("create enumeration...");
382*cdf0e10cSrcweir         XEnumeration xEnum = oObj.createSelectionEnumeration();
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir         boolean compRes = true; //compare result
385*cdf0e10cSrcweir         int i = selections.length - 1;
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir         while (xEnum.hasMoreElements()){
388*cdf0e10cSrcweir             log.println("try to get first element..");
389*cdf0e10cSrcweir             Object nextElement = null;
390*cdf0e10cSrcweir             try {
391*cdf0e10cSrcweir                 nextElement = xEnum.nextElement();
392*cdf0e10cSrcweir             } catch (WrappedTargetException ex) {
393*cdf0e10cSrcweir                 log.println("ERROR: could not get nextElement: " + ex.toString());
394*cdf0e10cSrcweir                 bOK = false;
395*cdf0e10cSrcweir             } catch (NoSuchElementException ex) {
396*cdf0e10cSrcweir                 log.println("ERROR: could not get nextElement: " + ex.toString());
397*cdf0e10cSrcweir                 bOK = false;
398*cdf0e10cSrcweir             }
399*cdf0e10cSrcweir             Object shouldElement = selections[i];
400*cdf0e10cSrcweir             i--;
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir             if (ObjCompare != null) {
403*cdf0e10cSrcweir                 ObjCompare.compare(shouldElement, nextElement);
404*cdf0e10cSrcweir             } else {
405*cdf0e10cSrcweir                 compRes = util.ValueComparer.equalValue(shouldElement, nextElement);
406*cdf0e10cSrcweir             }
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir             log.println("nextElement()-object and expected object 'selections["+i+"]' are equal: "+compRes);
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir             if (!compRes) {
411*cdf0e10cSrcweir                 if ((selections[i]) instanceof Object[]){
412*cdf0e10cSrcweir                     if (((Object[])selections[i])[0] instanceof Integer) {
413*cdf0e10cSrcweir                         log.println("Getting: "+((Integer) ((Object[])shouldElement)[0]).intValue());
414*cdf0e10cSrcweir                         log.println("Expected: "+((Integer) ((Object[])selections[i])[0]).intValue());
415*cdf0e10cSrcweir                     }
416*cdf0e10cSrcweir                 }
417*cdf0e10cSrcweir             }
418*cdf0e10cSrcweir             bOK &= compRes;
419*cdf0e10cSrcweir         }
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir         tRes.tested("createReverseSelectionEnumeration()", bOK);
422*cdf0e10cSrcweir     }
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir }  // finish class _XMultiSelectionSupplier
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir 
428