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
;
24 import lib
.TestEnvironment
;
25 import lib
.TestParameters
;
26 import util
.AccessibilityTools
;
27 import util
.DrawTools
;
28 import util
.SOfficeFactory
;
31 import com
.sun
.star
.accessibility
.AccessibleRole
;
32 import com
.sun
.star
.accessibility
.XAccessible
;
33 import com
.sun
.star
.awt
.XWindow
;
34 import com
.sun
.star
.container
.XIndexAccess
;
35 import com
.sun
.star
.drawing
.XDrawPage
;
36 import com
.sun
.star
.drawing
.XDrawPages
;
37 import com
.sun
.star
.drawing
.XDrawPagesSupplier
;
38 import com
.sun
.star
.drawing
.XDrawView
;
39 import com
.sun
.star
.drawing
.XShape
;
40 import com
.sun
.star
.frame
.XModel
;
41 import com
.sun
.star
.lang
.XComponent
;
42 import com
.sun
.star
.uno
.AnyConverter
;
43 import com
.sun
.star
.uno
.Type
;
44 import com
.sun
.star
.uno
.UnoRuntime
;
45 import com
.sun
.star
.uno
.XInterface
;
47 public class AccessibleDrawDocumentView
extends TestCase
{
52 * Called to create an instance of <code>TestEnvironment</code> with an
53 * object to test and related objects. Subclasses should implement this
54 * method to provide the implementation and related objects. The method is
55 * called from <code>getTestEnvironment()</code>.
57 * @param Param test parameters
58 * @param log writer to log information while testing
60 * @see TestEnvironment
61 * @see #getTestEnvironment
64 protected TestEnvironment createTestEnvironment
65 (TestParameters Param
, PrintWriter log
) throws Exception
{
66 XInterface oObj
= null;
68 // get a soffice factory object
69 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
72 // get the drawpage of drawing here
73 log
.println( "getting Drawpage" );
74 XDrawPagesSupplier oDPS
= UnoRuntime
.queryInterface(XDrawPagesSupplier
.class, xDrawDoc
);
75 XDrawPages oDPn
= oDPS
.getDrawPages();
76 final XDrawPage fDP2
= oDPn
.insertNewByIndex(1);
77 XIndexAccess oDPi
= UnoRuntime
.queryInterface(XIndexAccess
.class, oDPn
);
78 XDrawPage oDP
= (XDrawPage
) AnyConverter
.toObject(
79 new Type(XDrawPage
.class),oDPi
.getByIndex(0));
82 log
.println( "inserting a Shape" );
83 XShape oShape
= SOF
.createShape(xDrawDoc
, 5000, 3500, 7500, 5000, "Rectangle");
84 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
);
86 XModel aModel
= UnoRuntime
.queryInterface(XModel
.class, xDrawDoc
);
88 XWindow xWindow
= AccessibilityTools
.getCurrentWindow (
90 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
92 //com.sun.star.accessibility.AccessibleRole
93 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.DOCUMENT
);
95 log
.println("ImplementationName "+utils
.getImplName(oObj
));
97 AccessibilityTools
.printAccessibleTree(log
, xRoot
, Param
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
99 TestEnvironment tEnv
= new TestEnvironment(oObj
);
101 final XDrawView xView
= UnoRuntime
.queryInterface
102 (XDrawView
.class, aModel
.getCurrentController()) ;
103 final XDrawPage fDP1
= oDP
;
105 tEnv
.addObjRelation("EventProducer",
106 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
107 public void fireEvent() {
108 xView
.setCurrentPage(fDP2
);
109 xView
.setCurrentPage(fDP1
);
118 * Called while disposing a <code>TestEnvironment</code>.
119 * Disposes Impress documents.
120 * @param Param test parameters
121 * @param log writer to log information while testing
124 protected void cleanup( TestParameters Param
, PrintWriter log
) {
125 log
.println("disposing Draw document");
126 util
.DesktopTools
.closeDoc(xDrawDoc
);
130 * Called while the <code>TestCase</code> initialization. In the
131 * implementation does nothing. Subclasses can override to initialize
132 * objects shared among all <code>TestEnvironment</code>s.
134 * @param Param test parameters
135 * @param log writer to log information while testing
137 * @see #initializeTestCase
140 protected void initialize(TestParameters Param
, PrintWriter log
) throws Exception
{
141 // get a soffice factory object
142 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
145 log
.println( "creating a draw document" );
146 xDrawDoc
= SOF
.createDrawDoc(null);