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
.Size
;
34 import com
.sun
.star
.awt
.XWindow
;
35 import com
.sun
.star
.beans
.XPropertySet
;
36 import com
.sun
.star
.drawing
.XShape
;
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 AccessiblePresentationGraphicShape
extends TestCase
{
45 static XComponent xDoc
;
49 protected void initialize( TestParameters tParam
, PrintWriter log
) throws Exception
{
50 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF() );
51 log
.println( "creating a drawdoc" );
52 xDoc
= SOF
.createImpressDoc(null);
53 aModel
= UnoRuntime
.queryInterface(XModel
.class, xDoc
);
57 * Disposes the Draw document loaded before.
60 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
61 log
.println( " disposing xDrawDoc " );
62 util
.DesktopTools
.closeDoc(xDoc
);
66 protected TestEnvironment createTestEnvironment
67 (TestParameters tParam
, PrintWriter log
) throws Exception
{
69 XInterface oObj
= null;
72 // creation of testobject here
73 // first we write what we are intend to do to log file
74 log
.println( "creating a test environment" );
76 XMultiServiceFactory docMSF
= UnoRuntime
.queryInterface(XMultiServiceFactory
.class, xDoc
);
77 oShape
= UnoRuntime
.queryInterface(XShape
.class,
79 ("com.sun.star.presentation.GraphicObjectShape"));
81 DrawTools
.getShapes(DrawTools
.getDrawPage(xDoc
,0)).add(oShape
);
83 XPropertySet oShapeProps
= UnoRuntime
.queryInterface(XPropertySet
.class,oShape
);
85 oShapeProps
.setPropertyValue(
86 "GraphicURL",util
.utils
.getFullTestURL("space-metal.jpg"));
87 oShapeProps
.setPropertyValue("IsEmptyPresentationObject", Boolean
.FALSE
);
88 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
89 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
90 } catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
91 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
94 XWindow xWindow
= AccessibilityTools
.getCurrentWindow (aModel
);
95 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
97 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.UNKNOWN
, "GraphicObject");
99 // create test environment here
100 TestEnvironment tEnv
= new TestEnvironment( oObj
);
102 final XShape fShape
= oShape
;
103 tEnv
.addObjRelation("EventProducer",
104 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
105 public void fireEvent() {
107 Size size
= fShape
.getSize();
109 fShape
.setSize(size
);
110 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
111 System
.out
.println("caught exception: " + e
);
116 log
.println("Implementation Name: " + utils
.getImplName(oObj
));
119 } // finish method getTestEnvironment