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: AccessiblePageShape.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
.XWindow
;
47 import com
.sun
.star
.beans
.XPropertySet
;
48 import com
.sun
.star
.drawing
.XDrawPage
;
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 AccessiblePageShape
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;
89 //XShape oShape = null;
90 XDrawPage oPage
= null;
92 // creation of testobject here
93 // first we write what we are intend to do to log file
94 log
.println( "creating a test environment" );
96 AccessibilityTools at
= new AccessibilityTools();
98 XWindow xWindow
= at
.getCurrentWindow ((XMultiServiceFactory
)tParam
.getMSF(),aModel
);
99 XAccessible xRoot
= at
.getAccessibleObject(xWindow
);
101 at
.printAccessibleTree(log
, xRoot
, tParam
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
103 // oObj = at.getAccessibleObjectForRole(xRoot, AccessibleRole.SHAPE,
105 oObj
= at
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.UNKNOWN
, "PageShape");
107 // create test environment here
108 TestEnvironment tEnv
= new TestEnvironment( oObj
);
110 //at.getAccessibleObjectForRole(xRoot, AccessibleRole.SCROLLBAR);
111 //final XAccessibleValue xAccVal = (XAccessibleValue)
112 // UnoRuntime.queryInterface
113 // (XAccessibleValue.class, at.SearchedContext) ;
114 oPage
= DrawTools
.getDrawPage(xDrawDoc
,0);
115 final XPropertySet PageProps
= (XPropertySet
)
116 UnoRuntime
.queryInterface(XPropertySet
.class, oPage
);
118 tEnv
.addObjRelation("EventProducer",
119 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
120 public void fireEvent() {
122 PageProps
.setPropertyValue("Height",new Integer(5000));
123 } catch (com
.sun
.star
.beans
.UnknownPropertyException upe
) {
124 System
.out
.println("Don't no the Property Height");
125 } catch (com
.sun
.star
.beans
.PropertyVetoException pve
) {
127 "PropertyVetoException Exception while changing Height");
128 } catch (com
.sun
.star
.lang
.IllegalArgumentException iae
) {
130 "IllegalArgumentException Exception while changing Height");
131 } catch (com
.sun
.star
.lang
.WrappedTargetException wte
) {
133 "WrappedTargetException Exception while changing Height");
138 log
.println("Implementation Name: " + utils
.getImplName(oObj
));
141 } // finish method getTestEnvironment