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 .
20 import java
.io
.PrintWriter
;
23 import lib
.TestEnvironment
;
24 import lib
.TestParameters
;
25 import util
.AccessibilityTools
;
26 import util
.WriterTools
;
29 import com
.sun
.star
.accessibility
.AccessibleRole
;
30 import com
.sun
.star
.accessibility
.XAccessible
;
31 import com
.sun
.star
.awt
.XWindow
;
32 import com
.sun
.star
.beans
.XPropertySet
;
33 import com
.sun
.star
.frame
.XController
;
34 import com
.sun
.star
.frame
.XModel
;
35 import com
.sun
.star
.lang
.XMultiServiceFactory
;
36 import com
.sun
.star
.text
.XText
;
37 import com
.sun
.star
.text
.XTextContent
;
38 import com
.sun
.star
.text
.XTextCursor
;
39 import com
.sun
.star
.text
.XTextDocument
;
40 import com
.sun
.star
.uno
.UnoRuntime
;
41 import com
.sun
.star
.uno
.XInterface
;
42 import com
.sun
.star
.view
.XViewSettingsSupplier
;
44 public class SwAccessibleEndnoteView
extends TestCase
{
46 XTextDocument xTextDoc
= null;
49 * Called to create an instance of <code>TestEnvironment</code>
50 * with an object to test and related objects.
51 * Inserts the created endnote to the document.
52 * Changes zoom value to 10%(endnote must be in visible area of the document).
53 * Obtains accessible object for the inserted endnote.
55 * @param Param test parameters
56 * @param log writer to log information while testing
58 * @see TestEnvironment
59 * @see #getTestEnvironment
62 protected TestEnvironment
createTestEnvironment(
63 TestParameters Param
, PrintWriter log
) throws Exception
{
65 XInterface oObj
= null;
66 XInterface oEndnote
= null;
68 log
.println( "Creating a test environment" );
69 XMultiServiceFactory msf
= UnoRuntime
.queryInterface(XMultiServiceFactory
.class, xTextDoc
);
70 log
.println("creating an endnote");
71 oEndnote
= UnoRuntime
.queryInterface(XInterface
.class,
72 msf
.createInstance("com.sun.star.text.Endnote"));
74 XText oText
= xTextDoc
.getText();
75 XTextCursor oCursor
= oText
.createTextCursor();
77 log
.println("inserting the footnote into text document");
78 XTextContent xTC
= UnoRuntime
.queryInterface(XTextContent
.class, oEndnote
);
79 oText
.insertTextContent(oCursor
, xTC
, false);
81 XController xController
= xTextDoc
.getCurrentController();
82 XViewSettingsSupplier xViewSetSup
= UnoRuntime
.queryInterface(XViewSettingsSupplier
.class,
84 XPropertySet xPropSet
= xViewSetSup
.getViewSettings();
86 //change zoom value to 20%
87 //footer should be in the visible area of the document
88 xPropSet
.setPropertyValue("ZoomValue", Short
.valueOf("20"));
90 XModel aModel
= UnoRuntime
.queryInterface(XModel
.class, xTextDoc
);
92 XWindow xWindow
= AccessibilityTools
.getCurrentWindow(aModel
);
93 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
95 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.END_NOTE
);
97 log
.println("ImplementationName " + utils
.getImplName(oObj
));
98 AccessibilityTools
.printAccessibleTree(log
, xRoot
, Param
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
100 TestEnvironment tEnv
= new TestEnvironment(oObj
);
102 final XPropertySet PropSet
= xViewSetSup
.getViewSettings();
104 tEnv
.addObjRelation("EventProducer",
105 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
106 public void fireEvent() {
108 //change zoom value to 21%
109 PropSet
.setPropertyValue("ZoomValue", Short
.valueOf("21"));
111 PropSet
.setPropertyValue("ZoomValue", Short
.valueOf("20"));
112 } catch ( com
.sun
.star
.lang
.WrappedTargetException e
) {
114 } catch ( com
.sun
.star
.lang
.IllegalArgumentException e
) {
116 } catch ( com
.sun
.star
.beans
.PropertyVetoException e
) {
118 } catch ( com
.sun
.star
.beans
.UnknownPropertyException e
) {
129 * Called while disposing a <code>TestEnvironment</code>.
130 * Disposes text document.
131 * @param Param test parameters
132 * @param log writer to log information while testing
135 protected void cleanup( TestParameters Param
, PrintWriter log
) {
136 log
.println("dispose text document");
137 util
.DesktopTools
.closeDoc(xTextDoc
);
141 * Called while the <code>TestCase</code> initialization. In the
142 * implementation does nothing. Subclasses can override to initialize
143 * objects shared among all <code>TestEnvironment</code>s.
145 * @param Param test parameters
146 * @param log writer to log information while testing
148 * @see #initializeTestCase
151 protected void initialize(TestParameters Param
, PrintWriter log
) throws Exception
{
152 log
.println( "creating a text document" );
153 xTextDoc
= WriterTools
.createTextDoc(Param
.getMSF());