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.beans.XPropertySet; 46 import com.sun.star.drawing.XShape; 47 import com.sun.star.frame.XModel; 48 import com.sun.star.lang.XComponent; 49 import com.sun.star.lang.XMultiServiceFactory; 50 import com.sun.star.uno.UnoRuntime; 51 import com.sun.star.uno.XInterface; 52 53 public class AccessiblePresentationOLEShape extends TestCase { 54 55 static XComponent xDrawDoc; 56 static XModel aModel; 57 58 protected void initialize( TestParameters tParam, PrintWriter log ) { 59 60 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); 61 62 try { 63 log.println( "creating a drawdoc" ); 64 xDrawDoc = SOF.createImpressDoc(null); 65 aModel = (XModel) 66 UnoRuntime.queryInterface(XModel.class, xDrawDoc); 67 68 } catch ( com.sun.star.uno.Exception e ) { 69 // Some exception occures.FAILED 70 e.printStackTrace( log ); 71 throw new StatusException( "Couldn't create document", e ); 72 } 73 } 74 75 /** 76 * Disposes the Draw document loaded before. 77 */ 78 protected void cleanup( TestParameters tParam, PrintWriter log ) { 79 log.println( " disposing xDrawDoc " ); 80 util.DesktopTools.closeDoc(xDrawDoc); 81 } 82 83 protected TestEnvironment createTestEnvironment 84 (TestParameters tParam, PrintWriter log) { 85 86 XInterface oObj = null; 87 XShape oShape = 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 XMultiServiceFactory docMSF = (XMultiServiceFactory) 94 UnoRuntime.queryInterface(XMultiServiceFactory.class, xDrawDoc); 95 try { 96 oShape = (XShape) UnoRuntime.queryInterface(XShape.class, 97 docMSF.createInstance("com.sun.star.presentation.OLE2Shape")); 98 } catch (com.sun.star.uno.Exception e) { 99 throw new StatusException("couldn't create component", e); 100 } 101 102 103 //DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); 104 105 XPropertySet oShapeProps = (XPropertySet) 106 UnoRuntime.queryInterface(XPropertySet.class,oShape); 107 try { 108 oShapeProps.setPropertyValue("IsEmptyPresentationObject", new Boolean(false)); 109 } catch (com.sun.star.lang.WrappedTargetException e) { 110 } catch (com.sun.star.lang.IllegalArgumentException e) { 111 } catch (com.sun.star.beans.PropertyVetoException e) { 112 } catch (com.sun.star.beans.UnknownPropertyException e) { 113 } 114 115 DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); 116 117 try { 118 oShapeProps.setPropertyValue( 119 "CLSID","12DCAE26-281F-416F-a234-c3086127382e"); 120 oShapeProps.setPropertyValue("IsEmptyPresentationObject", new Boolean(false)); 121 } catch (com.sun.star.lang.WrappedTargetException e) { 122 } catch (com.sun.star.lang.IllegalArgumentException e) { 123 } catch (com.sun.star.beans.PropertyVetoException e) { 124 } catch (com.sun.star.beans.UnknownPropertyException e) { 125 } 126 127 AccessibilityTools at = new AccessibilityTools(); 128 129 XWindow xWindow = at.getCurrentWindow ((XMultiServiceFactory)tParam.getMSF(),aModel); 130 XAccessible xRoot = at.getAccessibleObject(xWindow); 131 at.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); 132 133 // oObj = at.getAccessibleObjectForRole 134 // (xRoot, AccessibleRole.SHAPE, "ImpressOLE"); 135 oObj = at.getAccessibleObjectForRole(xRoot, AccessibleRole.UNKNOWN, "ImpressOLE"); 136 137 // create test environment here 138 TestEnvironment tEnv = new TestEnvironment( oObj ); 139 140 final XShape fShape = oShape ; 141 tEnv.addObjRelation("EventProducer", 142 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { 143 public void fireEvent() { 144 try { 145 Size size = fShape.getSize(); 146 size.Width += 100; 147 fShape.setSize(size); 148 } catch(com.sun.star.beans.PropertyVetoException e) {} 149 } 150 }); 151 152 log.println("Implementation Name: " + utils.getImplName(oObj)); 153 154 return tEnv; 155 } // finish method getTestEnvironment 156 157 } 158 159