1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
30 import lib
.MultiMethodTest
;
32 import com
.sun
.star
.drawing
.XDrawPage
;
33 import com
.sun
.star
.drawing
.XDrawPageDuplicator
;
34 import com
.sun
.star
.drawing
.XDrawPages
;
35 import com
.sun
.star
.drawing
.XDrawPagesSupplier
;
36 import com
.sun
.star
.uno
.AnyConverter
;
37 import com
.sun
.star
.uno
.Type
;
38 import com
.sun
.star
.uno
.UnoRuntime
;
39 import com
.sun
.star
.uno
.XInterface
;
43 * Testing <code>com.sun.star.drawing.XDrawPageDuplicator</code>
46 * <li><code> duplicate()</code></li>
48 * The object tested <b> must implement </b>
49 * <code>XDrawPagesSupplier</code> interface to have access to draw
50 * pages collection. <p>
51 * Test is <b> NOT </b> multithread compilant. <p>
52 * After test completion object environment has to be recreated.
53 * @see com.sun.star.drawing.XDrawPageDuplicator
55 public class _XDrawPageDuplicator
extends MultiMethodTest
{
56 public XDrawPageDuplicator oObj
= null;
59 * First queries object tested for <code>XDrawPagesSupplier</code>
60 * interface and obtains one draw page from document. Then it
61 * tries to duplicate it.<p>
62 * Has <b> OK </b> status if the method returns not null value and
63 * this value is not equal to the page which was duplicated. <p>
65 public void _duplicate(){
66 boolean result
= false;
67 XInterface testobj
= tEnv
.getTestObject();
68 XDrawPagesSupplier PS
= (XDrawPagesSupplier
)
69 UnoRuntime
.queryInterface(XDrawPagesSupplier
.class, testobj
);
70 XDrawPages DPs
= PS
.getDrawPages();
73 DP
= (XDrawPage
) AnyConverter
.toObject(
74 new Type(XDrawPage
.class),DPs
.getByIndex(0));
75 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
76 log
.println("Exception occurred while testing: " + e
);
77 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
78 log
.println("Exception occurred while testing: " + e
);
79 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
80 log
.println("Exception occurred while testing: " + e
);
84 XDrawPage newPage
= oObj
.duplicate(DP
);
85 result
= (newPage
!= null) && !(newPage
.equals(DP
));
87 tRes
.tested("duplicate()", result
);