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: AccessibleGraphicShape.java,v $
10 * $Revision: 1.7.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
.drawing
.XShape
;
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 AccessibleGraphicShape
extends TestCase
{
57 static XComponent xDrawDoc
;
60 protected void initialize( TestParameters tParam
, PrintWriter log
) {
62 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF() );
65 log
.println( "creating a drawdoc" );
66 xDrawDoc
= SOF
.createDrawDoc(null);
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
);
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;
90 // creation of testobject here
91 // first we write what we are intend to do to log file
92 log
.println( "creating a test environment" );
94 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF());
95 final XShape oShape
= SOF
.createShape(xDrawDoc
,
96 5000,5000,1500,1000,"GraphicObject");
99 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
);
101 AccessibilityTools at
= new AccessibilityTools();
103 XWindow xWindow
= at
.getCurrentWindow ((XMultiServiceFactory
)tParam
.getMSF(),aModel
);
104 XAccessible xRoot
= at
.getAccessibleObject(xWindow
);
107 // oObj = at.getAccessibleObjectForRole
108 // (xRoot, AccessibleRole.SHAPE, "GraphicObject");
109 oObj
= at
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.UNKNOWN
, "GraphicObject");
111 // create test environment here
112 TestEnvironment tEnv
= new TestEnvironment( oObj
);
114 tEnv
.addObjRelation("EventProducer",
115 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
116 public void fireEvent() {
118 Size size
= oShape
.getSize();
120 oShape
.setSize(size
);
121 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {}
126 log
.println("Implementation Name: " + utils
.getImplName(oObj
));
129 } // finish method getTestEnvironment