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
.DrawTools
;
29 import util
.SOfficeFactory
;
32 import com
.sun
.star
.accessibility
.AccessibleRole
;
33 import com
.sun
.star
.accessibility
.XAccessible
;
34 import com
.sun
.star
.awt
.Size
;
35 import com
.sun
.star
.awt
.XWindow
;
36 import com
.sun
.star
.beans
.XPropertySet
;
37 import com
.sun
.star
.drawing
.XShape
;
38 import com
.sun
.star
.frame
.XModel
;
39 import com
.sun
.star
.lang
.XComponent
;
40 import com
.sun
.star
.lang
.XMultiServiceFactory
;
41 import com
.sun
.star
.uno
.UnoRuntime
;
42 import com
.sun
.star
.uno
.XInterface
;
44 public class AccessiblePresentationGraphicShape
extends TestCase
{
46 static XComponent xDoc
;
49 protected void initialize( TestParameters tParam
, PrintWriter log
) {
51 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF() );
54 log
.println( "creating a drawdoc" );
55 xDoc
= SOF
.createImpressDoc(null);
56 aModel
= UnoRuntime
.queryInterface(XModel
.class, xDoc
);
58 } catch ( com
.sun
.star
.uno
.Exception e
) {
59 // Some exception occurs.FAILED
60 e
.printStackTrace( log
);
61 throw new StatusException( "Couldn't create document", e
);
66 * Disposes the Draw document loaded before.
68 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
69 log
.println( " disposing xDrawDoc " );
70 util
.DesktopTools
.closeDoc(xDoc
);
73 protected TestEnvironment createTestEnvironment
74 (TestParameters tParam
, PrintWriter log
) {
76 XInterface oObj
= null;
79 // creation of testobject here
80 // first we write what we are intend to do to log file
81 log
.println( "creating a test environment" );
83 XMultiServiceFactory docMSF
= UnoRuntime
.queryInterface(XMultiServiceFactory
.class, xDoc
);
85 oShape
= UnoRuntime
.queryInterface(XShape
.class,
87 ("com.sun.star.presentation.GraphicObjectShape"));
88 } catch (com
.sun
.star
.uno
.Exception e
) {
89 throw new StatusException("couldn't create component", e
);
92 DrawTools
.getShapes(DrawTools
.getDrawPage(xDoc
,0)).add(oShape
);
94 XPropertySet oShapeProps
= UnoRuntime
.queryInterface(XPropertySet
.class,oShape
);
96 oShapeProps
.setPropertyValue(
97 "GraphicURL",util
.utils
.getFullTestURL("space-metal.jpg"));
98 oShapeProps
.setPropertyValue("IsEmptyPresentationObject", new Boolean(false));
99 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
100 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
101 } catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
102 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
105 //DrawTools.getShapes(DrawTools.getDrawPage(xDoc,0)).add(oShape);
107 AccessibilityTools at
= new AccessibilityTools();
109 XWindow xWindow
= AccessibilityTools
.getCurrentWindow ((XMultiServiceFactory
)tParam
.getMSF(),aModel
);
110 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
112 // oObj = at.getAccessibleObjectForRole
113 // (xRoot, AccessibleRole.SHAPE, "GraphicObject");
114 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.UNKNOWN
, "GraphicObject");
116 // create test environment here
117 TestEnvironment tEnv
= new TestEnvironment( oObj
);
119 final XShape fShape
= oShape
;
120 tEnv
.addObjRelation("EventProducer",
121 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
122 public void fireEvent() {
124 Size size
= fShape
.getSize();
126 fShape
.setSize(size
);
127 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {}
131 log
.println("Implementation Name: " + utils
.getImplName(oObj
));
134 } // finish method getTestEnvironment