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.XDrawPages; 34 import com.sun.star.drawing.XMasterPageTarget; 35 36 /** 37 * Testing <code>com.sun.star.drawing.XMasterPageTarget</code> 38 * interface methods : 39 * <ul> 40 * <li><code> getMasterPage()</code></li> 41 * <li><code> setMasterPage()</code></li> 42 * </ul> <p> 43 * This test needs the following object relations : 44 * <ul> 45 * <li> <code>'MasterPageSupplier'</code> 46 * (of type <code>XDrawPages</code>): 47 * the relation is used to create a new draw page. </li> 48 * <ul> <p> 49 * Test is <b> NOT </b> multithread compilant. <p> 50 * @see com.sun.star.drawing.XMasterPageTarget 51 */ 52 public class _XMasterPageTarget extends MultiMethodTest{ 53 54 public XMasterPageTarget oObj = null; 55 public XDrawPage DrawPage = null; 56 57 /** 58 * Gets the master page and stores. <p> 59 * Has <b> OK </b> status if the value returned is not null. <p> 60 */ 61 public void _getMasterPage(){ 62 boolean result = false; 63 log.println("get the MasterPage"); 64 65 DrawPage = oObj.getMasterPage(); 66 result = DrawPage != null ; 67 68 tRes.tested("getMasterPage()",result); 69 } 70 71 /** 72 * Gets the pages supplier from relation. Then a new page is created, 73 * inserted and set as master page.<p> 74 * Has <b> OK </b> status if the master page get is equal to page 75 * which was set. <p> 76 * The following method tests are to be completed successfully before : 77 * <ul> 78 * <li> <code> getMasterPage() </code> : to get old master page.</li> 79 * </ul> 80 */ 81 public void _setMasterPage() { 82 requiredMethod("getMasterPage()") ; 83 84 boolean result = true; 85 XDrawPage oNewPage = null; 86 87 XDrawPages oPages = (XDrawPages) tEnv.getObjRelation("MasterPageSupplier"); 88 log.println("inserting new MasterPage"); 89 oNewPage = oPages.insertNewByIndex(oPages.getCount()); 90 91 // save the old MasterPage 92 XDrawPage oOldPage = DrawPage; 93 94 // set the new Page as MasterPage 95 log.println("set the new MasterPage"); 96 oObj.setMasterPage(oNewPage); 97 98 // get the new MasterPage 99 DrawPage = oObj.getMasterPage(); 100 101 // test the diffrent MasterPages 102 if (DrawPage.equals(oOldPage)) result = false; 103 104 tRes.tested("setMasterPage()",result); 105 } 106 107 } // end of XMasterPageTarget 108 109