1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XMasterPageTarget.java,v $
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 ************************************************************************/
33 import lib
.MultiMethodTest
;
35 import com
.sun
.star
.drawing
.XDrawPage
;
36 import com
.sun
.star
.drawing
.XDrawPages
;
37 import com
.sun
.star
.drawing
.XMasterPageTarget
;
40 * Testing <code>com.sun.star.drawing.XMasterPageTarget</code>
43 * <li><code> getMasterPage()</code></li>
44 * <li><code> setMasterPage()</code></li>
46 * This test needs the following object relations :
48 * <li> <code>'MasterPageSupplier'</code>
49 * (of type <code>XDrawPages</code>):
50 * the relation is used to create a new draw page. </li>
52 * Test is <b> NOT </b> multithread compilant. <p>
53 * @see com.sun.star.drawing.XMasterPageTarget
55 public class _XMasterPageTarget
extends MultiMethodTest
{
57 public XMasterPageTarget oObj
= null;
58 public XDrawPage DrawPage
= null;
61 * Gets the master page and stores. <p>
62 * Has <b> OK </b> status if the value returned is not null. <p>
64 public void _getMasterPage(){
65 boolean result
= false;
66 log
.println("get the MasterPage");
68 DrawPage
= oObj
.getMasterPage();
69 result
= DrawPage
!= null ;
71 tRes
.tested("getMasterPage()",result
);
75 * Gets the pages supplier from relation. Then a new page is created,
76 * inserted and set as master page.<p>
77 * Has <b> OK </b> status if the master page get is equal to page
79 * The following method tests are to be completed successfully before :
81 * <li> <code> getMasterPage() </code> : to get old master page.</li>
84 public void _setMasterPage() {
85 requiredMethod("getMasterPage()") ;
87 boolean result
= true;
88 XDrawPage oNewPage
= null;
90 XDrawPages oPages
= (XDrawPages
) tEnv
.getObjRelation("MasterPageSupplier");
91 log
.println("inserting new MasterPage");
92 oNewPage
= oPages
.insertNewByIndex(oPages
.getCount());
94 // save the old MasterPage
95 XDrawPage oOldPage
= DrawPage
;
97 // set the new Page as MasterPage
98 log
.println("set the new MasterPage");
99 oObj
.setMasterPage(oNewPage
);
101 // get the new MasterPage
102 DrawPage
= oObj
.getMasterPage();
104 // test the diffrent MasterPages
105 if (DrawPage
.equals(oOldPage
)) result
= false;
107 tRes
.tested("setMasterPage()",result
);
110 } // end of XMasterPageTarget