bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sd / SdMasterPagesAccess.java
blobb906feca90bdf3686bc393fff3b5ffb2d9683704
1 /*
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 .
19 package mod._sd;
21 import java.io.PrintWriter;
23 import lib.StatusException;
24 import lib.TestCase;
25 import lib.TestEnvironment;
26 import lib.TestParameters;
27 import util.SOfficeFactory;
29 import com.sun.star.drawing.XDrawPages;
30 import com.sun.star.drawing.XMasterPagesSupplier;
31 import com.sun.star.lang.XComponent;
32 import com.sun.star.lang.XMultiServiceFactory;
33 import com.sun.star.uno.UnoRuntime;
34 import com.sun.star.uno.XInterface;
36 /**
37 * Test for object which is represented by service
38 * <code>com.sun.star.drawing.MasterPages</code>. <p>
39 * Object implements the following interfaces :
40 * <ul>
41 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
42 * <li> <code>com::sun::star::container::XElementAccess</code></li>
43 * <li> <code>com::sun::star::drawing::XDrawPages</code></li>
44 * </ul>
45 * @see com.sun.star.drawing.MasterPages
46 * @see com.sun.star.container.XIndexAccess
47 * @see com.sun.star.container.XElementAccess
48 * @see com.sun.star.drawing.XDrawPages
49 * @see ifc.container._XIndexAccess
50 * @see ifc.container._XElementAccess
51 * @see ifc.drawing._XDrawPages
53 public class SdMasterPagesAccess extends TestCase {
54 XComponent xDrawDoc;
56 /**
57 * Creates Drawing document.
59 protected void initialize(TestParameters Param, PrintWriter log) {
60 // get a soffice factory object
61 SOfficeFactory SOF = SOfficeFactory.getFactory(
62 (XMultiServiceFactory)Param.getMSF());
64 try {
65 log.println( "creating a draw document" );
66 xDrawDoc = SOF.createDrawDoc(null);
67 } catch (com.sun.star.uno.Exception e) {
68 // Some exception occurs.FAILED
69 e.printStackTrace( log );
70 throw new StatusException( "Couldn't create document", e );
74 /**
75 * Disposes Drawing document.
77 protected void cleanup( TestParameters Param, PrintWriter log) {
78 log.println("disposing xDrawDoc");
79 util.DesktopTools.closeDoc(xDrawDoc);
82 /**
83 * Creating a Testenvironment for the interfaces to be tested.
84 * Retrieves the collection of the master pages from the document using the
85 * interface <code>XMasterPagesSupplier</code>. Inserts two new draw pages.
86 * The retrieved collection is the instance of the service
87 * <code>com.sun.star.drawing.MasterPages</code>.
88 * @see com.sun.star.drawing.XMasterPagesSupplier
89 * @see com.sun.star.drawing.MasterPages
91 public synchronized TestEnvironment createTestEnvironment(
92 TestParameters Param, PrintWriter log) throws StatusException {
94 log.println( "creating a test environment" );
96 // get the MasterPages here
97 log.println( "getting MasterPages" );
98 XMasterPagesSupplier oMPS = UnoRuntime.queryInterface( XMasterPagesSupplier.class, xDrawDoc);
99 XDrawPages oMP = oMPS.getMasterPages();
100 log.println( "insert MasterPages" );
101 oMP.insertNewByIndex(1);
102 oMP.insertNewByIndex(2);
103 XInterface oObj = oMP;
105 log.println( "creating a new environment for MasterPagesAccess object" );
106 TestEnvironment tEnv = new TestEnvironment( oObj );
108 return tEnv;
109 } // finish method createTestEnvironment
111 } // finish class SdMasterPagesAccess