1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AccessibleOLEShape.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 ************************************************************************/
33 import java
.io
.PrintWriter
;
35 import lib
.StatusException
;
37 import lib
.TestEnvironment
;
38 import lib
.TestParameters
;
39 import util
.AccessibilityTools
;
40 import util
.DrawTools
;
41 import util
.SOfficeFactory
;
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 AccessibleOLEShape
extends TestCase
{
58 static XComponent xDrawDoc
;
61 protected void initialize( TestParameters tParam
, PrintWriter log
) {
63 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF() );
66 log
.println( "creating a drawdoc" );
67 xDrawDoc
= SOF
.createDrawDoc(null);
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
);
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;
91 // creation of testobject here
92 // first we write what we are intend to do to log file
93 log
.println( "creating a test environment" );
95 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF());
96 final XShape oShape
= SOF
.createShape
97 (xDrawDoc
,5000,5000,1500,1000,"OLE2");
99 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
);
101 XPropertySet shape_props
= (XPropertySet
)
102 UnoRuntime
.queryInterface(XPropertySet
.class,oShape
);
104 log
.println("Inserting a Chart");
108 setPropertyValue("CLSID","12DCAE26-281F-416F-a234-c3086127382e");
109 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
110 e
.printStackTrace(log
);
111 throw new StatusException("Couldn't change property", e
);
112 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
113 e
.printStackTrace(log
);
114 throw new StatusException("Couldn't change property", e
);
115 } catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
116 e
.printStackTrace(log
);
117 throw new StatusException("Couldn't change property", e
);
118 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
119 e
.printStackTrace(log
);
120 throw new StatusException("Couldn't change property", e
);
123 AccessibilityTools at
= new AccessibilityTools();
125 XWindow xWindow
= at
.getCurrentWindow ((XMultiServiceFactory
)tParam
.getMSF(),aModel
);
126 XAccessible xRoot
= at
.getAccessibleObject(xWindow
);
128 at
.printAccessibleTree(log
, xRoot
, tParam
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
130 // oObj = at.getAccessibleObjectForRole
131 // (xRoot, AccessibleRole.SHAPE, "OLEShape");
132 oObj
= at
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.UNKNOWN
, "OLEShape");
134 // create test environment here
135 TestEnvironment tEnv
= new TestEnvironment( oObj
);
137 tEnv
.addObjRelation("EventProducer",
138 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
139 public void fireEvent() {
141 Size size
= oShape
.getSize();
143 oShape
.setSize(size
);
144 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {}
148 log
.println("Implementation Name: " + utils
.getImplName(oObj
));
151 } // finish method getTestEnvironment