1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package ifc.drawing;
25 
26 import lib.MultiMethodTest;
27 
28 import com.sun.star.drawing.XDrawPage;
29 import com.sun.star.drawing.XDrawPages;
30 import com.sun.star.drawing.XMasterPageTarget;
31 
32 /**
33 * Testing <code>com.sun.star.drawing.XMasterPageTarget</code>
34 * interface methods :
35 * <ul>
36 *  <li><code> getMasterPage()</code></li>
37 *  <li><code> setMasterPage()</code></li>
38 * </ul> <p>
39 * This test needs the following object relations :
40 * <ul>
41 *  <li> <code>'MasterPageSupplier'</code>
42 *   (of type <code>XDrawPages</code>):
43 *    the relation is used to create a new draw page. </li>
44 * <ul> <p>
45 * Test is <b> NOT </b> multithread compilant. <p>
46 * @see com.sun.star.drawing.XMasterPageTarget
47 */
48 public class _XMasterPageTarget extends MultiMethodTest{
49 
50     public XMasterPageTarget oObj = null;
51     public XDrawPage DrawPage = null;
52 
53     /**
54     * Gets the master page and stores. <p>
55     * Has <b> OK </b> status if the value returned is not null. <p>
56     */
_getMasterPage()57     public void _getMasterPage(){
58         boolean result = false;
59         log.println("get the MasterPage");
60 
61         DrawPage = oObj.getMasterPage();
62         result = DrawPage != null ;
63 
64         tRes.tested("getMasterPage()",result);
65     }
66 
67     /**
68     * Gets the pages supplier from relation. Then a new page is created,
69     * inserted and set as master page.<p>
70     * Has <b> OK </b> status if the master page get is equal to page
71     * which was set. <p>
72     * The following method tests are to be completed successfully before :
73     * <ul>
74     *  <li> <code> getMasterPage() </code> : to get old master page.</li>
75     * </ul>
76     */
_setMasterPage()77     public void _setMasterPage() {
78         requiredMethod("getMasterPage()") ;
79 
80         boolean result = true;
81         XDrawPage oNewPage = null;
82 
83         XDrawPages oPages = (XDrawPages) tEnv.getObjRelation("MasterPageSupplier");
84         log.println("inserting new MasterPage");
85         oNewPage = oPages.insertNewByIndex(oPages.getCount());
86 
87         // save the old MasterPage
88         XDrawPage oOldPage = DrawPage;
89 
90         // set the new Page as MasterPage
91         log.println("set the new MasterPage");
92         oObj.setMasterPage(oNewPage);
93 
94         // get the new MasterPage
95         DrawPage = oObj.getMasterPage();
96 
97         // test the diffrent MasterPages
98         if (DrawPage.equals(oOldPage)) result = false;
99 
100         tRes.tested("setMasterPage()",result);
101     }
102 
103 } // end of XMasterPageTarget
104 
105