tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sd / SdXShape.java
blob049adedf0962c63c416737d622c43f06c68f9973
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.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
26 import util.SOfficeFactory;
28 import com.sun.star.beans.XPropertySet;
29 import com.sun.star.container.XIndexAccess;
30 import com.sun.star.drawing.XDrawPage;
31 import com.sun.star.drawing.XDrawPages;
32 import com.sun.star.drawing.XDrawPagesSupplier;
33 import com.sun.star.drawing.XShape;
34 import com.sun.star.drawing.XShapes;
35 import com.sun.star.lang.XComponent;
36 import com.sun.star.style.XStyle;
37 import com.sun.star.uno.AnyConverter;
38 import com.sun.star.uno.Type;
39 import com.sun.star.uno.UnoRuntime;
40 import com.sun.star.uno.XInterface;
42 /**
43 * Test for object which is represented by service
44 * <code>com.sun.star.drawing.Shape</code>. <p>
45 * Object implements the following interfaces :
46 * <ul>
47 * <li> <code>com::sun::star::lang::XComponent</code></li>
48 * <li> <code>com::sun::star::drawing::XShape</code></li>
49 * <li> <code>com::sun::star::drawing::XShapeDescriptor</code></li>
50 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
51 * <li> <code>com::sun::star::drawing::Shape</code></li>
52 * </ul>
53 * @see com.sun.star.lang.XComponent
54 * @see com.sun.star.drawing.XShape
55 * @see com.sun.star.drawing.XShapeDescriptor
56 * @see com.sun.star.beans.XPropertySet
57 * @see com.sun.star.drawing.Shape
58 * @see ifc.lang._XComponent
59 * @see ifc.drawing._XShape
60 * @see ifc.drawing._XShapeDescriptor
61 * @see ifc.beans._XPropertySet
62 * @see ifc.drawing._Shape
64 public class SdXShape extends TestCase {
65 XComponent xDrawDoc;
67 /**
68 * Creates Drawing document.
70 @Override
71 protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
72 // get a soffice factory object
73 SOfficeFactory SOF = SOfficeFactory.getFactory(
74 Param.getMSF());
76 log.println( "creating a draw document" );
77 xDrawDoc = SOF.createDrawDoc(null);
80 /**
81 * Disposes Drawing document.
83 @Override
84 protected void cleanup( TestParameters Param, PrintWriter log) {
85 log.println("disposing xDrawDoc");
86 util.DesktopTools.closeDoc(xDrawDoc);
89 /**
90 * Creating a TestEnvironment for the interfaces to be tested.
91 * Retrieves the collection of the draw pages from the drawing document using
92 * the interface <code>XDrawPagesSupplier</code>. Creates a rectangle shape
93 * that is the instance of the service <code>com.sun.star.drawing.Shape</code>.
94 * Creates and adds several new rectangle shapes and one ellipse shape to
95 * the retrieved draw page. Sets and gets some properties of the created
96 * rectangle shape.
97 * Object relations created :
98 * <ul>
99 * <li> <code>'Style1'</code> for
100 * {@link ifc.drawing._XShapeDescriptor}, {@link ifc.drawing._XShape}
101 * (the value of the property 'Style' that was retrieved from the created
102 * rectangle shape) </li>
103 * <li> <code>'Style2'</code> for
104 * {@link ifc.drawing._XShapeDescriptor}, {@link ifc.drawing._XShape}
105 * (the value of the property 'Style' that was retrieved from the created
106 * ellipse shape) </li>
107 * </ul>
108 * @see com.sun.star.drawing.XDrawPagesSupplier
109 * @see com.sun.star.drawing.Shape
111 @Override
112 protected TestEnvironment createTestEnvironment(
113 TestParameters Param, PrintWriter log) throws Exception {
115 log.println( "creating a test environment" );
117 // get a soffice factory object
118 SOfficeFactory SOF = SOfficeFactory.getFactory(
119 Param.getMSF());
121 // get the drawpage of drawing here
122 log.println( "getting Drawpage" );
123 XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xDrawDoc);
124 XDrawPages oDPn = oDPS.getDrawPages();
125 XIndexAccess oDPi = UnoRuntime.queryInterface(XIndexAccess.class, oDPn);
126 XDrawPage oDP = (XDrawPage) AnyConverter.toObject(
127 new Type(XDrawPage.class),oDPi.getByIndex(0));
129 //get a Shape
130 log.println( "getting Shape" );
131 XShapes oShapes = UnoRuntime.queryInterface
132 (XShapes.class, oDP);
133 XInterface oObj = SOF.createShape
134 (xDrawDoc, 5000, 3500, 7500, 5000, "Rectangle");
135 for (int i=0; i < 10; i++) {
136 oShapes.add(
137 SOF.createShape(xDrawDoc,
138 5000, 3500, 7510 + 10 * i, 5010 + 10 * i, "Rectangle"));
140 XShape oShape = SOF.createShape
141 (xDrawDoc, 3000, 4500, 15000, 1000, "Ellipse");
142 oShapes.add((XShape) oObj);
143 oShapes.add(oShape);
145 log.println( "creating a new environment for XShape object" );
146 TestEnvironment tEnv = new TestEnvironment( oObj );
148 log.println( "adding two style as ObjRelation for ShapeDescriptor" );
149 XPropertySet oShapeProps = UnoRuntime.queryInterface(XPropertySet.class, oObj);
150 XStyle aStyle = null;
151 aStyle = (XStyle) AnyConverter.toObject(
152 new Type(XStyle.class),oShapeProps.getPropertyValue("Style"));
153 oShapeProps.setPropertyValue("ZOrder", Integer.valueOf(1));
155 tEnv.addObjRelation("Style1", aStyle);
156 oShapeProps = UnoRuntime.queryInterface(XPropertySet.class, oShape);
157 aStyle = (XStyle) AnyConverter.toObject(
158 new Type(XStyle.class),oShapeProps.getPropertyValue("Style"));
160 tEnv.addObjRelation("Style2", aStyle);
162 return tEnv;
163 } // finish method createTestEnvironment
165 } // finish class SdXShape