tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _svx / SvxDrawPage.java
bloba0d07d0c9f1a50444681af18a8667dc38611a4e6
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 .
18 package mod._svx;
20 import com.sun.star.drawing.XDrawPage;
21 import com.sun.star.drawing.XDrawPages;
22 import com.sun.star.drawing.XDrawPagesSupplier;
23 import com.sun.star.drawing.XShape;
24 import com.sun.star.lang.XComponent;
25 import com.sun.star.sheet.XSpreadsheetDocument;
26 import com.sun.star.uno.AnyConverter;
27 import com.sun.star.uno.Type;
28 import com.sun.star.uno.UnoRuntime;
29 import com.sun.star.uno.XInterface;
31 import java.io.PrintWriter;
33 import lib.TestCase;
34 import lib.TestEnvironment;
35 import lib.TestParameters;
36 import util.DrawTools;
37 import util.FormTools;
38 import util.InstCreator;
39 import util.SOfficeFactory;
40 import util.ShapeDsc;
43 /**
44 * Test for object which is represented by service
45 * <code>com.sun.star.drawing.DrawPage</code>. <p>
47 * Object implements the following interfaces :
48 * <ul>
49 * <li> <code>com::sun::star::drawing::GenericDrawPage</code></li>
50 * <li> <code>com::sun::star::drawing::XShapeBinder</code></li>
51 * <li> <code>com::sun::star::drawing::XShapeGrouper</code></li>
52 * <li> <code>com::sun::star::drawing::XShapes</code></li>
53 * <li> <code>com::sun::star::lang::XServiceInfo</code></li>
54 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
55 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
56 * <li> <code>com::sun::star::container::XElementAccess</code></li>
57 * <li> <code>com::sun::star::drawing::XMasterPageTarget</code></li>
58 * <li> <code>com::sun::star::container::XNamed</code></li>
59 * <li> <code>com::sun::star::drawing::XShapeCombiner</code></li>
60 * </ul> <p>
62 * This object test <b> is NOT </b> designed to be run in several
63 * threads concurrently.
65 * @see com.sun.star.drawing.GenericDrawPage
66 * @see com.sun.star.drawing.XShapeBinder
67 * @see com.sun.star.drawing.XShapeGrouper
68 * @see com.sun.star.drawing.XShapes
69 * @see com.sun.star.lang.XServiceInfo
70 * @see com.sun.star.beans.XPropertySet
71 * @see com.sun.star.container.XIndexAccess
72 * @see com.sun.star.container.XElementAccess
73 * @see com.sun.star.drawing.XMasterPageTarget
74 * @see com.sun.star.container.XNamed
75 * @see com.sun.star.drawing.XShapeCombiner
76 * @see ifc.drawing._GenericDrawPage
77 * @see ifc.drawing._XShapeBinder
78 * @see ifc.drawing._XShapeGrouper
79 * @see ifc.drawing._XShapes
80 * @see ifc.lang._XServiceInfo
81 * @see ifc.beans._XPropertySet
82 * @see ifc.container._XIndexAccess
83 * @see ifc.container._XElementAccess
84 * @see ifc.drawing._XMasterPageTarget
85 * @see ifc.container._XNamed
86 * @see ifc.drawing._XShapeCombiner
88 public class SvxDrawPage extends TestCase {
89 static XSpreadsheetDocument xDoc = null;
91 /**
92 * Creates a new Draw document.
94 @Override
95 protected void initialize(TestParameters tParam, PrintWriter log) throws Exception {
96 // get a soffice factory object
97 SOfficeFactory SOF = SOfficeFactory.getFactory(
98 tParam.getMSF());
100 log.println("creating a sheetdocument");
101 xDoc = SOF.createCalcDoc(null);
105 * Disposes the Draw document created before
107 @Override
108 protected void cleanup(TestParameters tParam, PrintWriter log) {
109 log.println(" disposing xSheetDoc ");
110 util.DesktopTools.closeDoc(xDoc);
114 * Creating a TestEnvironment for the interfaces to be tested.
115 * From the Draw document created a collection of its draw
116 * pages is obtained. Two new pages are inserted. And one
117 * page is obtained as a testing component. A shape is added
118 * to this page. <p>
120 * Object relations created :
121 * <ul>
122 * <li> <code>'DrawPage'</code> for
123 * {@link ifc.drawing._XShapeGrouper} :
124 * the draw page tested. </li>
125 * <li> <code>'Shape'</code> for
126 * {@link ifc.drawing._XShapes} :
127 * the creator which can create instances of
128 * <code>com.sun.star.drawing.Line</code> service </li>
129 * </ul>
131 @Override
132 protected TestEnvironment createTestEnvironment(TestParameters tParam,
133 PrintWriter log) throws Exception {
134 XInterface oObj = null;
135 XShape oShape = null;
136 XDrawPages oDP = null;
138 XComponent xComp = UnoRuntime.queryInterface(
139 XComponent.class, xDoc);
142 // creation of testobject here
143 // first we write what we are intend to do to log file
144 log.println("creating a test environment");
146 log.println("getting Drawpages");
148 XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(
149 XDrawPagesSupplier.class, xDoc);
150 oDP = oDPS.getDrawPages();
151 oDP.insertNewByIndex(1);
152 oDP.insertNewByIndex(2);
153 oObj = (XDrawPage) AnyConverter.toObject(new Type(XDrawPage.class),
154 oDP.getByIndex(0));
156 SOfficeFactory SOF = SOfficeFactory.getFactory(
157 tParam.getMSF());
159 oShape = SOF.createShape(xComp, 5000, 3500, 7500, 5000,
160 "Rectangle");
161 DrawTools.getShapes((XDrawPage) oObj).add(oShape);
163 XShape oShape1 = SOF.createShape(xComp, 5000, 5500, 5000, 5000,
164 "Rectangle");
165 DrawTools.getShapes((XDrawPage) oObj).add(oShape1);
167 // create test environment here
168 TestEnvironment tEnv = new TestEnvironment(oObj);
171 //adding a controlButton to have a Form
172 FormTools.insertControlShape(
173 UnoRuntime.queryInterface(XComponent.class, xDoc),
174 3000, 4500, 15000, 1000, "CommandButton");
176 // relation for XShapes interface
177 ShapeDsc sDsc = new ShapeDsc(5000, 3500, 7500, 10000, "Line");
178 tEnv.addObjRelation("Shape", new InstCreator(xDoc, sDsc));
180 log.println("ImplementationName: " + util.utils.getImplName(oObj));
183 // adding relation for XShapeGrouper
184 tEnv.addObjRelation("DrawPage", oObj);
186 // adding relation for XMasterPageTarget
188 return tEnv;
189 } // finish method getTestEnvironment
190 } // finish class SvxDrawPage