2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import java
.io
.PrintWriter
;
23 import lib
.StatusException
;
25 import lib
.TestEnvironment
;
26 import lib
.TestParameters
;
27 import util
.AccessibilityTools
;
28 import util
.DrawTools
;
29 import util
.SOfficeFactory
;
32 import com
.sun
.star
.accessibility
.AccessibleRole
;
33 import com
.sun
.star
.accessibility
.XAccessible
;
34 import com
.sun
.star
.awt
.XWindow
;
35 import com
.sun
.star
.beans
.XPropertySet
;
36 import com
.sun
.star
.drawing
.XDrawPage
;
37 import com
.sun
.star
.frame
.XModel
;
38 import com
.sun
.star
.lang
.XComponent
;
39 import com
.sun
.star
.lang
.XMultiServiceFactory
;
40 import com
.sun
.star
.uno
.UnoRuntime
;
41 import com
.sun
.star
.uno
.XInterface
;
43 public class AccessiblePageShape
extends TestCase
{
45 static XComponent xDrawDoc
;
48 protected void initialize( TestParameters tParam
, PrintWriter log
) {
50 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF() );
53 log
.println( "creating a drawdoc" );
54 xDrawDoc
= SOF
.createDrawDoc(null);
55 aModel
= UnoRuntime
.queryInterface(XModel
.class, xDrawDoc
);
57 } catch ( com
.sun
.star
.uno
.Exception e
) {
58 // Some exception occurs.FAILED
59 e
.printStackTrace( log
);
60 throw new StatusException( "Couldn't create document", e
);
65 * Disposes the Draw document loaded before.
67 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
68 log
.println( " disposing xDrawDoc " );
69 util
.DesktopTools
.closeDoc(xDrawDoc
);
72 protected TestEnvironment createTestEnvironment
73 (TestParameters tParam
, PrintWriter log
) {
75 XInterface oObj
= null;
76 //XShape oShape = null;
77 XDrawPage oPage
= null;
79 // creation of testobject here
80 // first we write what we are intend to do to log file
81 log
.println( "creating a test environment" );
83 AccessibilityTools at
= new AccessibilityTools();
85 XWindow xWindow
= AccessibilityTools
.getCurrentWindow ((XMultiServiceFactory
)tParam
.getMSF(),aModel
);
86 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
88 AccessibilityTools
.printAccessibleTree(log
, xRoot
, tParam
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
90 // oObj = at.getAccessibleObjectForRole(xRoot, AccessibleRole.SHAPE,
92 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.UNKNOWN
, "PageShape");
94 // create test environment here
95 TestEnvironment tEnv
= new TestEnvironment( oObj
);
97 //at.getAccessibleObjectForRole(xRoot, AccessibleRole.SCROLLBAR);
98 //final XAccessibleValue xAccVal = (XAccessibleValue)
99 // UnoRuntime.queryInterface
100 // (XAccessibleValue.class, at.SearchedContext) ;
101 oPage
= DrawTools
.getDrawPage(xDrawDoc
,0);
102 final XPropertySet PageProps
= UnoRuntime
.queryInterface(XPropertySet
.class, oPage
);
104 tEnv
.addObjRelation("EventProducer",
105 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
106 public void fireEvent() {
108 PageProps
.setPropertyValue("Height",new Integer(5000));
109 } catch (com
.sun
.star
.beans
.UnknownPropertyException upe
) {
110 System
.out
.println("Don't no the Property Height");
111 } catch (com
.sun
.star
.beans
.PropertyVetoException pve
) {
113 "PropertyVetoException Exception while changing Height");
114 } catch (com
.sun
.star
.lang
.IllegalArgumentException iae
) {
116 "IllegalArgumentException Exception while changing Height");
117 } catch (com
.sun
.star
.lang
.WrappedTargetException wte
) {
119 "WrappedTargetException Exception while changing Height");
124 log
.println("Implementation Name: " + utils
.getImplName(oObj
));
127 } // finish method getTestEnvironment