1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 28 package ifc.drawing; 29 30 import lib.MultiMethodTest; 31 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; 40 41 42 /** 43 * Testing <code>com.sun.star.drawing.XDrawPageDuplicator</code> 44 * interface methods : 45 * <ul> 46 * <li><code> duplicate()</code></li> 47 * </ul> <p> 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 54 */ 55 public class _XDrawPageDuplicator extends MultiMethodTest { 56 public XDrawPageDuplicator oObj = null; 57 58 /** 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> 64 */ 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(); 71 XDrawPage DP = null; 72 try { 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 occured while testing: " + e); 77 } catch (com.sun.star.lang.IndexOutOfBoundsException e) { 78 log.println("Exception occured while testing: " + e); 79 } catch (com.sun.star.lang.IllegalArgumentException e) { 80 log.println("Exception occured while testing: " + e); 81 } 82 83 if (DP != null) { 84 XDrawPage newPage = oObj.duplicate(DP); 85 result = (newPage != null) && !(newPage.equals(DP)); 86 } 87 tRes.tested("duplicate()", result); 88 } 89 90 } 91 92