merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _svx / AccessiblePresentationOLEShape.java
blobdc39badbe3a09daf12d501e1ace9192929fee3ae
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AccessiblePresentationOLEShape.java,v $
10 * $Revision: 1.8.8.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package mod._svx;
33 import java.io.PrintWriter;
35 import lib.StatusException;
36 import lib.TestCase;
37 import lib.TestEnvironment;
38 import lib.TestParameters;
39 import util.AccessibilityTools;
40 import util.DrawTools;
41 import util.SOfficeFactory;
42 import util.utils;
44 import com.sun.star.accessibility.AccessibleRole;
45 import com.sun.star.accessibility.XAccessible;
46 import com.sun.star.awt.Size;
47 import com.sun.star.awt.XWindow;
48 import com.sun.star.beans.XPropertySet;
49 import com.sun.star.drawing.XShape;
50 import com.sun.star.frame.XModel;
51 import com.sun.star.lang.XComponent;
52 import com.sun.star.lang.XMultiServiceFactory;
53 import com.sun.star.uno.UnoRuntime;
54 import com.sun.star.uno.XInterface;
56 public class AccessiblePresentationOLEShape extends TestCase {
58 static XComponent xDrawDoc;
59 static XModel aModel;
61 protected void initialize( TestParameters tParam, PrintWriter log ) {
63 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
65 try {
66 log.println( "creating a drawdoc" );
67 xDrawDoc = SOF.createImpressDoc(null);
68 aModel = (XModel)
69 UnoRuntime.queryInterface(XModel.class, xDrawDoc);
71 } catch ( com.sun.star.uno.Exception e ) {
72 // Some exception occures.FAILED
73 e.printStackTrace( log );
74 throw new StatusException( "Couldn't create document", e );
78 /**
79 * Disposes the Draw document loaded before.
81 protected void cleanup( TestParameters tParam, PrintWriter log ) {
82 log.println( " disposing xDrawDoc " );
83 util.DesktopTools.closeDoc(xDrawDoc);
86 protected TestEnvironment createTestEnvironment
87 (TestParameters tParam, PrintWriter log) {
89 XInterface oObj = null;
90 XShape oShape = null;
92 // creation of testobject here
93 // first we write what we are intend to do to log file
94 log.println( "creating a test environment" );
96 XMultiServiceFactory docMSF = (XMultiServiceFactory)
97 UnoRuntime.queryInterface(XMultiServiceFactory.class, xDrawDoc);
98 try {
99 oShape = (XShape) UnoRuntime.queryInterface(XShape.class,
100 docMSF.createInstance("com.sun.star.presentation.OLE2Shape"));
101 } catch (com.sun.star.uno.Exception e) {
102 throw new StatusException("couldn't create component", e);
106 //DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape);
108 XPropertySet oShapeProps = (XPropertySet)
109 UnoRuntime.queryInterface(XPropertySet.class,oShape);
110 try {
111 oShapeProps.setPropertyValue("IsEmptyPresentationObject", new Boolean(false));
112 } catch (com.sun.star.lang.WrappedTargetException e) {
113 } catch (com.sun.star.lang.IllegalArgumentException e) {
114 } catch (com.sun.star.beans.PropertyVetoException e) {
115 } catch (com.sun.star.beans.UnknownPropertyException e) {
118 DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape);
120 try {
121 oShapeProps.setPropertyValue(
122 "CLSID","12DCAE26-281F-416F-a234-c3086127382e");
123 oShapeProps.setPropertyValue("IsEmptyPresentationObject", new Boolean(false));
124 } catch (com.sun.star.lang.WrappedTargetException e) {
125 } catch (com.sun.star.lang.IllegalArgumentException e) {
126 } catch (com.sun.star.beans.PropertyVetoException e) {
127 } catch (com.sun.star.beans.UnknownPropertyException e) {
130 AccessibilityTools at = new AccessibilityTools();
132 XWindow xWindow = at.getCurrentWindow ((XMultiServiceFactory)tParam.getMSF(),aModel);
133 XAccessible xRoot = at.getAccessibleObject(xWindow);
134 at.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
136 // oObj = at.getAccessibleObjectForRole
137 // (xRoot, AccessibleRole.SHAPE, "ImpressOLE");
138 oObj = at.getAccessibleObjectForRole(xRoot, AccessibleRole.UNKNOWN, "ImpressOLE");
140 // create test environment here
141 TestEnvironment tEnv = new TestEnvironment( oObj );
143 final XShape fShape = oShape ;
144 tEnv.addObjRelation("EventProducer",
145 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
146 public void fireEvent() {
147 try {
148 Size size = fShape.getSize();
149 size.Width += 100;
150 fShape.setSize(size);
151 } catch(com.sun.star.beans.PropertyVetoException e) {}
155 log.println("Implementation Name: " + utils.getImplName(oObj));
157 return tEnv;
158 } // finish method getTestEnvironment