2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import lib
.MultiMethodTest
;
23 import com
.sun
.star
.drawing
.XDrawPage
;
24 import com
.sun
.star
.drawing
.XDrawPages
;
25 import com
.sun
.star
.drawing
.XMasterPageTarget
;
28 * Testing <code>com.sun.star.drawing.XMasterPageTarget</code>
31 * <li><code> getMasterPage()</code></li>
32 * <li><code> setMasterPage()</code></li>
34 * This test needs the following object relations :
36 * <li> <code>'MasterPageSupplier'</code>
37 * (of type <code>XDrawPages</code>):
38 * the relation is used to create a new draw page. </li>
40 * Test is <b> NOT </b> multithread compliant. <p>
41 * @see com.sun.star.drawing.XMasterPageTarget
43 public class _XMasterPageTarget
extends MultiMethodTest
{
45 public XMasterPageTarget oObj
= null;
46 public XDrawPage DrawPage
= null;
49 * Gets the master page and stores. <p>
50 * Has <b> OK </b> status if the value returned is not null. <p>
52 public void _getMasterPage(){
53 boolean result
= false;
54 log
.println("get the MasterPage");
56 DrawPage
= oObj
.getMasterPage();
57 result
= DrawPage
!= null ;
59 tRes
.tested("getMasterPage()",result
);
63 * Gets the pages supplier from relation. Then a new page is created,
64 * inserted and set as master page.<p>
65 * Has <b> OK </b> status if the master page get is equal to page
67 * The following method tests are to be completed successfully before :
69 * <li> <code> getMasterPage() </code> : to get old master page.</li>
72 public void _setMasterPage() {
73 requiredMethod("getMasterPage()") ;
75 boolean result
= true;
76 XDrawPage oNewPage
= null;
78 XDrawPages oPages
= (XDrawPages
) tEnv
.getObjRelation("MasterPageSupplier");
79 log
.println("inserting new MasterPage");
80 oNewPage
= oPages
.insertNewByIndex(oPages
.getCount());
82 // save the old MasterPage
83 XDrawPage oOldPage
= DrawPage
;
85 // set the new Page as MasterPage
86 log
.println("set the new MasterPage");
87 oObj
.setMasterPage(oNewPage
);
89 // get the new MasterPage
90 DrawPage
= oObj
.getMasterPage();
92 // test the different MasterPages
93 if (DrawPage
.equals(oOldPage
)) result
= false;
95 tRes
.tested("setMasterPage()",result
);
98 } // end of XMasterPageTarget