tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwXShape.java
blobe3309db612cf1697164109a5b384a8db4c13f72a
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._sw;
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.XDrawPage;
30 import com.sun.star.drawing.XDrawPageSupplier;
31 import com.sun.star.drawing.XShape;
32 import com.sun.star.drawing.XShapes;
33 import com.sun.star.text.XTextDocument;
34 import com.sun.star.uno.UnoRuntime;
35 import com.sun.star.uno.XInterface;
37 /**
38 * Test for object which is represented by service
39 * <code>com.sun.star.drawing.Shape</code>. <p>
40 * Object implements the following interfaces :
41 * <ul>
42 * <li> <code>com::sun::star::lang::XComponent</code></li>
43 * <li> <code>com::sun::star::drawing::XShape</code></li>
44 * <li> <code>com::sun::star::drawing::XShapeDescriptor</code></li>
45 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
46 * <li> <code>com::sun::star::drawing::Shape</code></li>
47 * </ul> <p>
48 * This object test <b> is NOT </b> designed to be run in several
49 * threads concurrently.
50 * @see com.sun.star.lang.XComponent
51 * @see com.sun.star.drawing.XShape
52 * @see com.sun.star.drawing.XShapeDescriptor
53 * @see com.sun.star.beans.XPropertySet
54 * @see com.sun.star.drawing.Shape
55 * @see ifc.lang._XComponent
56 * @see ifc.drawing._XShape
57 * @see ifc.drawing._XShapeDescriptor
58 * @see ifc.beans._XPropertySet
59 * @see ifc.drawing._Shape
61 public class SwXShape extends TestCase {
62 XTextDocument xTextDoc;
63 SOfficeFactory SOF;
65 /**
66 * Creates text document.
68 @Override
69 protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
70 SOF = SOfficeFactory.getFactory( tParam.getMSF() );
71 log.println( "creating a textdocument" );
72 xTextDoc = SOF.createTextDoc( null );
75 /**
76 * Disposes text document.
78 @Override
79 protected void cleanup( TestParameters tParam, PrintWriter log ) {
80 log.println( " disposing xTextDoc " );
81 util.DesktopTools.closeDoc(xTextDoc);
84 /**
85 * Creating a TestEnvironment for the interfaces to be tested. At first,
86 * DrawPage is gotten from text document using <code>XDrawPageSupplier</code>
87 * interface. Then shape (rectangle) is created and added to DrawPage
88 * obtained before, then returned as a test component.
90 @Override
91 public TestEnvironment createTestEnvironment(
92 TestParameters tParam, PrintWriter log ) throws StatusException {
93 XInterface oObj = null;
94 XDrawPage oDP = null;
95 XShapes oShapes = null;
97 log.println( "creating a test environment" );
98 log.println( "getting Drawpage" );
99 XDrawPageSupplier oDPS = UnoRuntime.queryInterface(XDrawPageSupplier.class, xTextDoc);
100 oDP = oDPS.getDrawPage();
102 log.println( "getting Shape" );
103 oShapes = UnoRuntime.queryInterface(XShapes.class, oDP);
104 oObj = SOF.createShape(xTextDoc,5000,3500,7500,5000,"Rectangle");
105 oShapes.add((XShape) oObj);
107 for ( int i = 0; i < 9; i++){
108 XInterface oShape = SOF.createShape(xTextDoc,
109 5000 + 100*i,3500,7500,5000,"Rectangle");
110 oShapes.add((XShape) oShape);
113 log.println( "creating a new environment for XShape object" );
114 TestEnvironment tEnv = new TestEnvironment( oObj );
116 return tEnv;
117 } // finish method getTestEnvironment
119 } // finish class SwXShape