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
.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
.drawing
.XDrawPages
;
35 import com
.sun
.star
.drawing
.XDrawPagesSupplier
;
36 import com
.sun
.star
.frame
.XDispatch
;
37 import com
.sun
.star
.frame
.XDispatchProvider
;
38 import com
.sun
.star
.frame
.XModel
;
39 import com
.sun
.star
.lang
.XComponent
;
40 import com
.sun
.star
.uno
.UnoRuntime
;
41 import com
.sun
.star
.uno
.XInterface
;
42 import com
.sun
.star
.util
.URL
;
43 import com
.sun
.star
.util
.XURLTransformer
;
45 public class AccessibleOutlineView
extends TestCase
{
48 XComponent xImpressDoc
= null;
51 * Called to create an instance of <code>TestEnvironment</code> with an
52 * object to test and related objects. Subclasses should implement this
53 * method to provide the implementation and related objects. The method is
54 * called from <code>getTestEnvironment()</code>.
56 * @param Param test parameters
57 * @param log writer to log information while testing
59 * @see TestEnvironment
60 * @see #getTestEnvironment
63 protected TestEnvironment createTestEnvironment
64 (TestParameters Param
, PrintWriter log
) {
65 XInterface oObj
= null;
67 XWindow xWindow
= AccessibilityTools
.getCurrentWindow (
69 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
71 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.DOCUMENT
);
73 log
.println("ImplementationName "+utils
.getImplName(oObj
));
75 TestEnvironment tEnv
= new TestEnvironment(oObj
);
77 XDrawPagesSupplier oDPS
= UnoRuntime
.queryInterface(XDrawPagesSupplier
.class, aModel
);
78 final XDrawPages oDPn
= oDPS
.getDrawPages();
80 tEnv
.addObjRelation("EventMsg","Inserting a drawpage via API has no "+
81 "effect to the outline view #101050# \r\n"+
82 "Therefore the listener isn't called");
84 tEnv
.addObjRelation("EventProducer",
85 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
86 public void fireEvent() {
87 oDPn
.insertNewByIndex(1);
96 * Called while disposing a <code>TestEnvironment</code>.
97 * Disposes Impress documents.
98 * @param Param test parameters
99 * @param log writer to log information while testing
102 protected void cleanup( TestParameters Param
, PrintWriter log
) {
103 log
.println("disposing Impress document");
104 util
.DesktopTools
.closeDoc(xImpressDoc
);
108 * Called while the <code>TestCase</code> initialization. In the
109 * implementation does nothing. Subclasses can override to initialize
110 * objects shared among all <code>TestEnvironment</code>s.
112 * @param Param test parameters
113 * @param log writer to log information while testing
115 * @see #initializeTestCase
118 protected void initialize(TestParameters Param
, PrintWriter log
) {
119 // get a soffice factory object
120 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
124 log
.println( "creating a impress document" );
125 xImpressDoc
= SOF
.createImpressDoc(null);
126 util
.utils
.pause(2000);
127 } catch (com
.sun
.star
.uno
.Exception e
) {
128 e
.printStackTrace( log
);
129 throw new StatusException("Couldn't create document", e
);
132 aModel
= UnoRuntime
.queryInterface(XModel
.class, xImpressDoc
);
134 XInterface oObj
= aModel
.getCurrentController();
136 //Change to Outline view
138 String aSlotID
= "slot:27010";
139 XDispatchProvider xDispProv
= UnoRuntime
.queryInterface( XDispatchProvider
.class, oObj
);
140 XURLTransformer xParser
= UnoRuntime
.queryInterface(XURLTransformer
.class,
142 createInstance("com.sun.star.util.URLTransformer"));
143 // Because it's an in/out parameter we must use an array of URL objects.
144 URL
[] aParseURL
= new URL
[1];
145 aParseURL
[0] = new URL();
146 aParseURL
[0].Complete
= aSlotID
;
147 xParser
.parseStrict(aParseURL
);
148 URL aURL
= aParseURL
[0];
149 XDispatch xDispatcher
= xDispProv
.queryDispatch( aURL
,"",0);
150 if( xDispatcher
!= null )
151 xDispatcher
.dispatch( aURL
, null );
152 } catch (com
.sun
.star
.uno
.Exception e
) {
153 log
.println("Couldn't change mode");
155 util
.utils
.pause(2000);