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
;
22 import lib
.StatusException
;
24 import lib
.TestEnvironment
;
25 import lib
.TestParameters
;
26 import util
.AccessibilityTools
;
27 import util
.WriterTools
;
30 import com
.sun
.star
.accessibility
.AccessibleRole
;
31 import com
.sun
.star
.accessibility
.XAccessible
;
32 import com
.sun
.star
.awt
.XWindow
;
33 import com
.sun
.star
.beans
.XPropertySet
;
34 import com
.sun
.star
.container
.XNameAccess
;
35 import com
.sun
.star
.frame
.XController
;
36 import com
.sun
.star
.frame
.XModel
;
37 import com
.sun
.star
.style
.XStyle
;
38 import com
.sun
.star
.style
.XStyleFamiliesSupplier
;
39 import com
.sun
.star
.text
.XTextDocument
;
40 import com
.sun
.star
.uno
.AnyConverter
;
41 import com
.sun
.star
.uno
.Type
;
42 import com
.sun
.star
.uno
.UnoRuntime
;
43 import com
.sun
.star
.uno
.XInterface
;
44 import com
.sun
.star
.view
.XViewSettingsSupplier
;
47 * Test of accessible object for a footer of a text document.<p>
48 * Object implements the following interfaces :
50 * <li> <code>::com::sun::star::accessibility::XAccessible</code></li>
52 * @see com.sun.star.accessibility.XAccessible
54 public class SwAccessibleFooterView
extends TestCase
{
56 XTextDocument xTextDoc
= null;
59 * Called to create an instance of <code>TestEnvironment</code>
60 * with an object to test and related objects. Obtains style
61 * <code>Standard</code> from style family <code>PageStyles</code>.
62 * Changes values of property <code>FooterIsOn</code> by <code>true</code>.
63 * Changes zoom value to 10%(footer must be in visible area of the document).
64 * Obtains accessible component for the footer.
66 * @param Param test parameters
67 * @param log writer to log information while testing
69 * @see TestEnvironment
70 * @see #getTestEnvironment
73 protected TestEnvironment
createTestEnvironment(
74 TestParameters Param
, PrintWriter log
) throws Exception
{
76 XInterface oObj
= null;
77 XNameAccess PageStyles
= null;
78 XStyle StdStyle
= null;
80 XStyleFamiliesSupplier StyleFam
= UnoRuntime
.queryInterface(XStyleFamiliesSupplier
.class, xTextDoc
);
81 XNameAccess StyleFamNames
= StyleFam
.getStyleFamilies();
83 // obtains style 'Standard' from style family 'PageStyles'
84 PageStyles
= (XNameAccess
) AnyConverter
.toObject(
85 new Type(XNameAccess
.class),StyleFamNames
.getByName("PageStyles"));
86 StdStyle
= (XStyle
) AnyConverter
.toObject(
87 new Type(XStyle
.class),PageStyles
.getByName("Standard"));
89 final XPropertySet PropSet
= UnoRuntime
.queryInterface( XPropertySet
.class, StdStyle
);
91 // changing/getting some properties
92 log
.println( "Switching on footer" );
93 PropSet
.setPropertyValue("FooterIsOn", Boolean
.TRUE
);
95 //change zoom value to 10%
96 //footer should be in the visible area of the document
97 XController xController
= xTextDoc
.getCurrentController();
98 XViewSettingsSupplier xViewSetSup
= UnoRuntime
.queryInterface(XViewSettingsSupplier
.class,
100 XPropertySet xPropSet
= xViewSetSup
.getViewSettings();
101 xPropSet
.setPropertyValue("ZoomValue", Short
.valueOf("20"));
103 XModel aModel
= UnoRuntime
.queryInterface(XModel
.class, xTextDoc
);
105 XWindow xWindow
= AccessibilityTools
.getCurrentWindow(aModel
);
106 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
108 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.FOOTER
);
110 log
.println("ImplementationName " + utils
.getImplName(oObj
));
111 AccessibilityTools
.printAccessibleTree(log
, xRoot
, Param
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
113 TestEnvironment tEnv
= new TestEnvironment(oObj
);
115 tEnv
.addObjRelation("EventProducer",
116 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer(){
117 public void fireEvent() {
119 PropSet
.setPropertyValue("FooterLeftMargin",
120 Integer
.valueOf(1000));
121 } catch (com
.sun
.star
.uno
.Exception e
) {
123 throw new StatusException("Can't change footer.", e
);
133 * Called while disposing a <code>TestEnvironment</code>.
134 * Disposes text document.
135 * @param Param test parameters
136 * @param log writer to log information while testing
139 protected void cleanup( TestParameters Param
, PrintWriter log
) {
140 log
.println("dispose text document");
141 util
.DesktopTools
.closeDoc(xTextDoc
);
145 * Called while the <code>TestCase</code> initialization.
146 * Creates a text document.
148 * @param Param test parameters
149 * @param log writer to log information while testing
151 * @see #initializeTestCase
154 protected void initialize(TestParameters Param
, PrintWriter log
) throws Exception
{
155 log
.println( "creating a text document" );
156 xTextDoc
= WriterTools
.createTextDoc(Param
.getMSF());