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.Size; 44 import com.sun.star.awt.XWindow; 45 import com.sun.star.drawing.XShape; 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 AccessibleGraphicShape 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 87 // creation of testobject here 88 // first we write what we are intend to do to log file 89 log.println( "creating a test environment" ); 90 91 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF()); 92 final XShape oShape = SOF.createShape(xDrawDoc, 93 5000,5000,1500,1000,"GraphicObject"); 94 95 96 DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); 97 98 AccessibilityTools at = new AccessibilityTools(); 99 100 XWindow xWindow = at.getCurrentWindow ((XMultiServiceFactory)tParam.getMSF(),aModel); 101 XAccessible xRoot = at.getAccessibleObject(xWindow); 102 103 104 // oObj = at.getAccessibleObjectForRole 105 // (xRoot, AccessibleRole.SHAPE, "GraphicObject"); 106 oObj = at.getAccessibleObjectForRole(xRoot, AccessibleRole.UNKNOWN, "GraphicObject"); 107 108 // create test environment here 109 TestEnvironment tEnv = new TestEnvironment( oObj ); 110 111 tEnv.addObjRelation("EventProducer", 112 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { 113 public void fireEvent() { 114 try { 115 Size size = oShape.getSize(); 116 size.Width += 100; 117 oShape.setSize(size); 118 } catch(com.sun.star.beans.PropertyVetoException e) {} 119 } 120 }); 121 122 123 log.println("Implementation Name: " + utils.getImplName(oObj)); 124 125 return tEnv; 126 } // finish method getTestEnvironment 127 128 } 129 130