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 java
.io
.PrintWriter
;
24 import lib
.TestEnvironment
;
25 import lib
.TestParameters
;
26 import util
.InstCreator
;
27 import util
.SOfficeFactory
;
30 import com
.sun
.star
.container
.XIndexAccess
;
31 import com
.sun
.star
.drawing
.XDrawPage
;
32 import com
.sun
.star
.drawing
.XDrawPages
;
33 import com
.sun
.star
.drawing
.XMasterPagesSupplier
;
34 import com
.sun
.star
.drawing
.XShapes
;
35 import com
.sun
.star
.lang
.XComponent
;
36 import com
.sun
.star
.uno
.AnyConverter
;
37 import com
.sun
.star
.uno
.Type
;
38 import com
.sun
.star
.uno
.UnoRuntime
;
39 import com
.sun
.star
.uno
.XInterface
;
42 * Test for object which is represented by service
43 * <code>com.sun.star.drawing.MasterPage</code>. <p>
44 * Object implements the following interfaces :
46 * <li> <code>com::sun::star::drawing::GenericDrawPage</code></li>
47 * <li> <code>com::sun::star::drawing::XShapeBinder</code></li>
48 * <li> <code>com::sun::star::drawing::XShapeGrouper</code></li>
49 * <li> <code>com::sun::star::drawing::XShapes</code></li>
50 * <li> <code>com::sun::star::lang::XServiceInfo</code></li>
51 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
52 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
53 * <li> <code>com::sun::star::container::XElementAccess</code></li>
54 * <li> <code>com::sun::star::drawing::XShapeCombiner</code></li>
55 * <li> <code>com::sun::star::container::XNamed</code></li>
57 * @see com.sun.star.drawing.MasterPage
58 * @see com.sun.star.drawing.GenericDrawPage
59 * @see com.sun.star.drawing.XShapeBinder
60 * @see com.sun.star.drawing.XShapeGrouper
61 * @see com.sun.star.drawing.XShapes
62 * @see com.sun.star.lang.XServiceInfo
63 * @see com.sun.star.beans.XPropertySet
64 * @see com.sun.star.container.XIndexAccess
65 * @see com.sun.star.container.XElementAccess
66 * @see com.sun.star.drawing.XShapeCombiner
67 * @see com.sun.star.container.XNamed
68 * @see ifc.drawing._GenericDrawPage
69 * @see ifc.drawing._XShapeBinder
70 * @see ifc.drawing._XShapeGrouper
71 * @see ifc.drawing._XShapes
72 * @see ifc.lang._XServiceInfo
73 * @see ifc.beans._XPropertySet
74 * @see ifc.container._XIndexAccess
75 * @see ifc.container._XElementAccess
76 * @see ifc.drawing._XShapeCombiner
77 * @see ifc.container._XNamed
79 public class SdMasterPage
extends TestCase
{
83 * Creates Drawing document.
86 protected void initialize(TestParameters Param
, PrintWriter log
) throws Exception
{
87 // get a soffice factory object
88 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
91 log
.println( "creating a draw document" );
92 xDrawDoc
= SOF
.createDrawDoc(null);
96 * Disposes Drawing document.
99 protected void cleanup( TestParameters Param
, PrintWriter log
) {
100 log
.println("disposing xDrawDoc");
101 util
.DesktopTools
.closeDoc(xDrawDoc
);
105 * Creating a TestEnvironment for the interfaces to be tested.
106 * Retrieves the collection of the master pages from the document using the
107 * interface <code>XMasterPagesSupplier</code> and takes
108 * one of them. Inserts some shapes into the document. Creates a rectangle
109 * shape. The retrieved master page is the instance of the service
110 * <code>com.sun.star.drawing.MasterPage</code>.
111 * Object relations created :
113 * <li> <code>'DrawPage'</code> for
114 * {@link ifc.drawing._XShapeBinder}, {@link ifc.drawing._XShapeGrouper},
115 * {@link ifc.drawing._XShapeCombiner}( the draw page of the retrieved
117 * <li> <code>'Shape'</code> for
118 * {@link ifc.drawing._XShapes}(the created rectangle shape)</li>
120 * @see com.sun.star.drawing.XMasterPagesSupplier
123 protected TestEnvironment
createTestEnvironment(
124 TestParameters Param
, PrintWriter log
) throws Exception
{
126 log
.println( "creating a test environment" );
128 // get the MasterPages here
129 log
.println( "getting MasterPages" );
130 XMasterPagesSupplier oMPS
= UnoRuntime
.queryInterface(XMasterPagesSupplier
.class, xDrawDoc
);
131 XDrawPages oMPn
= oMPS
.getMasterPages();
132 XIndexAccess oMPi
= UnoRuntime
.queryInterface(XIndexAccess
.class, oMPn
);
134 log
.println( "getting MasterPage" );
135 XInterface oObj
= (XDrawPage
) AnyConverter
.toObject(
136 new Type(XDrawPage
.class),oMPi
.getByIndex(0));
138 // get a soffice factory object
139 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
142 //put something on the masterpage
143 log
.println( "inserting some Shapes" );
144 XShapes oShapes
= UnoRuntime
.queryInterface(XShapes
.class, oObj
);
145 oShapes
.add(SOF
.createShape(xDrawDoc
, 2000, 1500, 1000, 1000, "Line"));
146 oShapes
.add(SOF
.createShape
147 (xDrawDoc
, 3000, 4500, 15000, 1000, "Ellipse"));
148 oShapes
.add(SOF
.createShape
149 (xDrawDoc
, 5000, 3500, 7500, 5000, "Rectangle"));
151 log
.println( "creating a new environment for MasterPage object" );
152 TestEnvironment tEnv
= new TestEnvironment( oObj
);
154 log
.println( "adding DrawPage as mod relation to environment" );
155 tEnv
.addObjRelation("DrawPage", oObj
);
157 ShapeDsc sDsc
= new ShapeDsc(5000, 3500, 7500, 10000, "Rectangle");
158 log
.println( "adding Shape as mod relation to environment" );
159 tEnv
.addObjRelation("Shape", new InstCreator( xDrawDoc
, sDsc
));
162 } // finish method createTestEnvironment
164 } // finish class SdMasterPage