merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / drawing / _XDrawPageDuplicator.java
blob883b600ecfe6c5d2620fc32a09100b408eca0379
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XDrawPageDuplicator.java,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.drawing;
33 import lib.MultiMethodTest;
35 import com.sun.star.drawing.XDrawPage;
36 import com.sun.star.drawing.XDrawPageDuplicator;
37 import com.sun.star.drawing.XDrawPages;
38 import com.sun.star.drawing.XDrawPagesSupplier;
39 import com.sun.star.uno.AnyConverter;
40 import com.sun.star.uno.Type;
41 import com.sun.star.uno.UnoRuntime;
42 import com.sun.star.uno.XInterface;
45 /**
46 * Testing <code>com.sun.star.drawing.XDrawPageDuplicator</code>
47 * interface methods :
48 * <ul>
49 * <li><code> duplicate()</code></li>
50 * </ul> <p>
51 * The object tested <b> must implement </b>
52 * <code>XDrawPagesSupplier</code> interface to have access to draw
53 * pages collection. <p>
54 * Test is <b> NOT </b> multithread compilant. <p>
55 * After test completion object environment has to be recreated.
56 * @see com.sun.star.drawing.XDrawPageDuplicator
58 public class _XDrawPageDuplicator extends MultiMethodTest {
59 public XDrawPageDuplicator oObj = null;
61 /**
62 * First queries object tested for <code>XDrawPagesSupplier</code>
63 * interface and obtains one draw page from document. Then it
64 * tries to duplicate it.<p>
65 * Has <b> OK </b> status if the method returns not null value and
66 * this value is not equal to the page which was duplicated. <p>
68 public void _duplicate(){
69 boolean result = false;
70 XInterface testobj = tEnv.getTestObject();
71 XDrawPagesSupplier PS = (XDrawPagesSupplier)
72 UnoRuntime.queryInterface(XDrawPagesSupplier.class, testobj);
73 XDrawPages DPs = PS.getDrawPages();
74 XDrawPage DP = null;
75 try {
76 DP = (XDrawPage) AnyConverter.toObject(
77 new Type(XDrawPage.class),DPs.getByIndex(0));
78 } catch (com.sun.star.lang.WrappedTargetException e) {
79 log.println("Exception occured while testing: " + e);
80 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
81 log.println("Exception occured while testing: " + e);
82 } catch (com.sun.star.lang.IllegalArgumentException e) {
83 log.println("Exception occured while testing: " + e);
86 if (DP != null) {
87 XDrawPage newPage = oObj.duplicate(DP);
88 result = (newPage != null) && !(newPage.equals(DP));
90 tRes.tested("duplicate()", result);