merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _svx / AccessiblePageShape.java
blob109f1e1b220fc6cd13773f829f4f459ff6e3f0ca
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: AccessiblePageShape.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.XWindow;
47 import com.sun.star.beans.XPropertySet;
48 import com.sun.star.drawing.XDrawPage;
49 import com.sun.star.frame.XModel;
50 import com.sun.star.lang.XComponent;
51 import com.sun.star.lang.XMultiServiceFactory;
52 import com.sun.star.uno.UnoRuntime;
53 import com.sun.star.uno.XInterface;
55 public class AccessiblePageShape extends TestCase {
57 static XComponent xDrawDoc;
58 static XModel aModel;
60 protected void initialize( TestParameters tParam, PrintWriter log ) {
62 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
64 try {
65 log.println( "creating a drawdoc" );
66 xDrawDoc = SOF.createDrawDoc(null);
67 aModel = (XModel)
68 UnoRuntime.queryInterface(XModel.class, xDrawDoc);
70 } catch ( com.sun.star.uno.Exception e ) {
71 // Some exception occures.FAILED
72 e.printStackTrace( log );
73 throw new StatusException( "Couldn't create document", e );
77 /**
78 * Disposes the Draw document loaded before.
80 protected void cleanup( TestParameters tParam, PrintWriter log ) {
81 log.println( " disposing xDrawDoc " );
82 util.DesktopTools.closeDoc(xDrawDoc);
85 protected TestEnvironment createTestEnvironment
86 (TestParameters tParam, PrintWriter log) {
88 XInterface oObj = null;
89 //XShape oShape = null;
90 XDrawPage oPage = 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 AccessibilityTools at = new AccessibilityTools();
98 XWindow xWindow = at.getCurrentWindow ((XMultiServiceFactory)tParam.getMSF(),aModel);
99 XAccessible xRoot = at.getAccessibleObject(xWindow);
101 at.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
103 // oObj = at.getAccessibleObjectForRole(xRoot, AccessibleRole.SHAPE,
104 // "PageShape");
105 oObj = at.getAccessibleObjectForRole(xRoot, AccessibleRole.UNKNOWN, "PageShape");
107 // create test environment here
108 TestEnvironment tEnv = new TestEnvironment( oObj );
110 //at.getAccessibleObjectForRole(xRoot, AccessibleRole.SCROLLBAR);
111 //final XAccessibleValue xAccVal = (XAccessibleValue)
112 // UnoRuntime.queryInterface
113 // (XAccessibleValue.class, at.SearchedContext) ;
114 oPage = DrawTools.getDrawPage(xDrawDoc,0);
115 final XPropertySet PageProps = (XPropertySet)
116 UnoRuntime.queryInterface(XPropertySet.class, oPage);
118 tEnv.addObjRelation("EventProducer",
119 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
120 public void fireEvent() {
121 try {
122 PageProps.setPropertyValue("Height",new Integer(5000));
123 } catch (com.sun.star.beans.UnknownPropertyException upe) {
124 System.out.println("Don't no the Property Height");
125 } catch (com.sun.star.beans.PropertyVetoException pve) {
126 System.out.println(
127 "PropertyVetoException Exception while changing Height");
128 } catch (com.sun.star.lang.IllegalArgumentException iae) {
129 System.out.println(
130 "IllegalArgumentException Exception while changing Height");
131 } catch (com.sun.star.lang.WrappedTargetException wte) {
132 System.out.println(
133 "WrappedTargetException Exception while changing Height");
138 log.println("Implementation Name: " + utils.getImplName(oObj));
140 return tEnv;
141 } // finish method getTestEnvironment