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 
24 package ifc.drawing;
25 
26 import lib.MultiMethodTest;
27 
28 import com.sun.star.drawing.XDrawPage;
29 import com.sun.star.drawing.XDrawPageDuplicator;
30 import com.sun.star.drawing.XDrawPages;
31 import com.sun.star.drawing.XDrawPagesSupplier;
32 import com.sun.star.uno.AnyConverter;
33 import com.sun.star.uno.Type;
34 import com.sun.star.uno.UnoRuntime;
35 import com.sun.star.uno.XInterface;
36 
37 
38 /**
39 * Testing <code>com.sun.star.drawing.XDrawPageDuplicator</code>
40 * interface methods :
41 * <ul>
42 *  <li><code> duplicate()</code></li>
43 * </ul> <p>
44 * The object tested <b> must implement </b>
45 * <code>XDrawPagesSupplier</code> interface to have access to draw
46 * pages collection. <p>
47 * Test is <b> NOT </b> multithread compilant. <p>
48 * After test completion object environment has to be recreated.
49 * @see com.sun.star.drawing.XDrawPageDuplicator
50 */
51 public class _XDrawPageDuplicator extends MultiMethodTest {
52     public XDrawPageDuplicator oObj = null;
53 
54     /**
55     * First queries object tested for <code>XDrawPagesSupplier</code>
56     * interface and obtains one draw page from document. Then it
57     * tries to duplicate it.<p>
58     * Has <b> OK </b> status if the method returns not null value and
59     * this value is not equal to the page which was duplicated. <p>
60     */
_duplicate()61     public void _duplicate(){
62         boolean result = false;
63         XInterface testobj = tEnv.getTestObject();
64         XDrawPagesSupplier PS = (XDrawPagesSupplier)
65             UnoRuntime.queryInterface(XDrawPagesSupplier.class, testobj);
66         XDrawPages DPs = PS.getDrawPages();
67         XDrawPage DP = null;
68         try {
69             DP = (XDrawPage) AnyConverter.toObject(
70                     new Type(XDrawPage.class),DPs.getByIndex(0));
71         } catch (com.sun.star.lang.WrappedTargetException e) {
72             log.println("Exception occured while testing: " + e);
73         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
74             log.println("Exception occured while testing: " + e);
75         } catch (com.sun.star.lang.IllegalArgumentException e) {
76             log.println("Exception occured while testing: " + e);
77         }
78 
79         if (DP != null) {
80             XDrawPage newPage = oObj.duplicate(DP);
81             result = (newPage != null) && !(newPage.equals(DP));
82         }
83         tRes.tested("duplicate()", result);
84     }
85 
86 }
87 
88