1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package mod._svx; 29 30 import java.io.PrintWriter; 31 32 import lib.StatusException; 33 import lib.TestCase; 34 import lib.TestEnvironment; 35 import lib.TestParameters; 36 import util.AccessibilityTools; 37 import util.DrawTools; 38 import util.SOfficeFactory; 39 import util.utils; 40 41 import com.sun.star.accessibility.AccessibleRole; 42 import com.sun.star.accessibility.XAccessible; 43 import com.sun.star.awt.XWindow; 44 import com.sun.star.beans.XPropertySet; 45 import com.sun.star.drawing.XDrawPage; 46 import com.sun.star.frame.XModel; 47 import com.sun.star.lang.XComponent; 48 import com.sun.star.lang.XMultiServiceFactory; 49 import com.sun.star.uno.UnoRuntime; 50 import com.sun.star.uno.XInterface; 51 52 public class AccessiblePageShape extends TestCase { 53 54 static XComponent xDrawDoc; 55 static XModel aModel; 56 57 protected void initialize( TestParameters tParam, PrintWriter log ) { 58 59 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); 60 61 try { 62 log.println( "creating a drawdoc" ); 63 xDrawDoc = SOF.createDrawDoc(null); 64 aModel = (XModel) 65 UnoRuntime.queryInterface(XModel.class, xDrawDoc); 66 67 } catch ( com.sun.star.uno.Exception e ) { 68 // Some exception occures.FAILED 69 e.printStackTrace( log ); 70 throw new StatusException( "Couldn't create document", e ); 71 } 72 } 73 74 /** 75 * Disposes the Draw document loaded before. 76 */ 77 protected void cleanup( TestParameters tParam, PrintWriter log ) { 78 log.println( " disposing xDrawDoc " ); 79 util.DesktopTools.closeDoc(xDrawDoc); 80 } 81 82 protected TestEnvironment createTestEnvironment 83 (TestParameters tParam, PrintWriter log) { 84 85 XInterface oObj = null; 86 //XShape oShape = null; 87 XDrawPage oPage = null; 88 89 // creation of testobject here 90 // first we write what we are intend to do to log file 91 log.println( "creating a test environment" ); 92 93 AccessibilityTools at = new AccessibilityTools(); 94 95 XWindow xWindow = at.getCurrentWindow ((XMultiServiceFactory)tParam.getMSF(),aModel); 96 XAccessible xRoot = at.getAccessibleObject(xWindow); 97 98 at.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); 99 100 // oObj = at.getAccessibleObjectForRole(xRoot, AccessibleRole.SHAPE, 101 // "PageShape"); 102 oObj = at.getAccessibleObjectForRole(xRoot, AccessibleRole.UNKNOWN, "PageShape"); 103 104 // create test environment here 105 TestEnvironment tEnv = new TestEnvironment( oObj ); 106 107 //at.getAccessibleObjectForRole(xRoot, AccessibleRole.SCROLLBAR); 108 //final XAccessibleValue xAccVal = (XAccessibleValue) 109 // UnoRuntime.queryInterface 110 // (XAccessibleValue.class, at.SearchedContext) ; 111 oPage = DrawTools.getDrawPage(xDrawDoc,0); 112 final XPropertySet PageProps = (XPropertySet) 113 UnoRuntime.queryInterface(XPropertySet.class, oPage); 114 115 tEnv.addObjRelation("EventProducer", 116 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { 117 public void fireEvent() { 118 try { 119 PageProps.setPropertyValue("Height",new Integer(5000)); 120 } catch (com.sun.star.beans.UnknownPropertyException upe) { 121 System.out.println("Don't no the Property Height"); 122 } catch (com.sun.star.beans.PropertyVetoException pve) { 123 System.out.println( 124 "PropertyVetoException Exception while changing Height"); 125 } catch (com.sun.star.lang.IllegalArgumentException iae) { 126 System.out.println( 127 "IllegalArgumentException Exception while changing Height"); 128 } catch (com.sun.star.lang.WrappedTargetException wte) { 129 System.out.println( 130 "WrappedTargetException Exception while changing Height"); 131 } 132 } 133 }); 134 135 log.println("Implementation Name: " + utils.getImplName(oObj)); 136 137 return tEnv; 138 } // finish method getTestEnvironment 139 140 } 141 142