merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _svx / AccessiblePresentationShape.java
blob1df3986fa0a53769b40efd3b9addc040cbc06469
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: AccessiblePresentationShape.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 AccessiblePresentationShape 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
101 ("com.sun.star.presentation.HandoutShape"));
102 } catch (com.sun.star.uno.Exception e) {
103 throw new StatusException("couldn't create component", e);
107 DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape);
109 XPropertySet shapeProps = (XPropertySet)
110 UnoRuntime.queryInterface(XPropertySet.class, oShape);
112 try {
113 shapeProps.setPropertyValue(
114 "IsEmptyPresentationObject", new Boolean(false));
115 } catch (Exception e) {}
117 AccessibilityTools at = new AccessibilityTools();
119 XWindow xWindow = at.getCurrentWindow ((XMultiServiceFactory)tParam.getMSF(),aModel);
120 XAccessible xRoot = at.getAccessibleObject(xWindow);
122 at.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
123 // oObj = at.getAccessibleObjectForRole
124 // (xRoot, AccessibleRole.SHAPE, "ImpressHandout");
125 oObj = at.getAccessibleObjectForRole(xRoot, AccessibleRole.UNKNOWN, "ImpressHandout");
127 log.println("Implementation Name: "+utils.getImplName(oObj));
129 // create test environment here
130 TestEnvironment tEnv = new TestEnvironment( oObj );
132 final XShape fShape = oShape ;
133 tEnv.addObjRelation("EventProducer",
134 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
135 public void fireEvent() {
136 try {
137 Size size = fShape.getSize();
138 size.Width += 100;
139 fShape.setSize(size);
140 } catch(com.sun.star.beans.PropertyVetoException e) {}
144 log.println("Implementation Name: " + utils.getImplName(oObj));
146 return tEnv;
147 } // finish method getTestEnvironment