1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AccessiblePresentationGraphicShape.java,v $
10 * $Revision: 1.7.8.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import java
.io
.PrintWriter
;
35 import lib
.StatusException
;
37 import lib
.TestEnvironment
;
38 import lib
.TestParameters
;
39 import util
.AccessibilityTools
;
40 import util
.DrawTools
;
41 import util
.SOfficeFactory
;
44 import com
.sun
.star
.accessibility
.AccessibleRole
;
45 import com
.sun
.star
.accessibility
.XAccessible
;
46 import com
.sun
.star
.awt
.Size
;
47 import com
.sun
.star
.awt
.XWindow
;
48 import com
.sun
.star
.beans
.XPropertySet
;
49 import com
.sun
.star
.drawing
.XShape
;
50 import com
.sun
.star
.frame
.XModel
;
51 import com
.sun
.star
.lang
.XComponent
;
52 import com
.sun
.star
.lang
.XMultiServiceFactory
;
53 import com
.sun
.star
.uno
.UnoRuntime
;
54 import com
.sun
.star
.uno
.XInterface
;
56 public class AccessiblePresentationGraphicShape
extends TestCase
{
58 static XComponent xDoc
;
61 protected void initialize( TestParameters tParam
, PrintWriter log
) {
63 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF() );
66 log
.println( "creating a drawdoc" );
67 xDoc
= SOF
.createImpressDoc(null);
69 UnoRuntime
.queryInterface(XModel
.class, xDoc
);
71 } catch ( com
.sun
.star
.uno
.Exception e
) {
72 // Some exception occures.FAILED
73 e
.printStackTrace( log
);
74 throw new StatusException( "Couldn't create document", e
);
79 * Disposes the Draw document loaded before.
81 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
82 log
.println( " disposing xDrawDoc " );
83 util
.DesktopTools
.closeDoc(xDoc
);
86 protected TestEnvironment createTestEnvironment
87 (TestParameters tParam
, PrintWriter log
) {
89 XInterface oObj
= null;
92 // creation of testobject here
93 // first we write what we are intend to do to log file
94 log
.println( "creating a test environment" );
96 XMultiServiceFactory docMSF
= (XMultiServiceFactory
)
97 UnoRuntime
.queryInterface(XMultiServiceFactory
.class, xDoc
);
99 oShape
= (XShape
) UnoRuntime
.queryInterface(XShape
.class,
100 docMSF
.createInstance
101 ("com.sun.star.presentation.GraphicObjectShape"));
102 } catch (com
.sun
.star
.uno
.Exception e
) {
103 throw new StatusException("couldn't create component", e
);
106 DrawTools
.getShapes(DrawTools
.getDrawPage(xDoc
,0)).add(oShape
);
108 XPropertySet oShapeProps
= (XPropertySet
)
109 UnoRuntime
.queryInterface(XPropertySet
.class,oShape
);
111 oShapeProps
.setPropertyValue(
112 "GraphicURL",util
.utils
.getFullTestURL("space-metal.jpg"));
113 oShapeProps
.setPropertyValue("IsEmptyPresentationObject", new Boolean(false));
114 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
115 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
116 } catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
117 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
120 //DrawTools.getShapes(DrawTools.getDrawPage(xDoc,0)).add(oShape);
122 AccessibilityTools at
= new AccessibilityTools();
124 XWindow xWindow
= at
.getCurrentWindow ((XMultiServiceFactory
)tParam
.getMSF(),aModel
);
125 XAccessible xRoot
= at
.getAccessibleObject(xWindow
);
127 // oObj = at.getAccessibleObjectForRole
128 // (xRoot, AccessibleRole.SHAPE, "GraphicObject");
129 oObj
= at
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.UNKNOWN
, "GraphicObject");
131 // create test environment here
132 TestEnvironment tEnv
= new TestEnvironment( oObj
);
134 final XShape fShape
= oShape
;
135 tEnv
.addObjRelation("EventProducer",
136 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
137 public void fireEvent() {
139 Size size
= fShape
.getSize();
141 fShape
.setSize(size
);
142 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {}
146 log
.println("Implementation Name: " + utils
.getImplName(oObj
));
149 } // finish method getTestEnvironment