2003-01-27 17:20:08 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 18:00:49 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2008-04-10 18:00:49 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2008-04-10 18:00:49 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2008-04-10 18:00:49 +00:00
|
|
|
* $RCSfile: AccessibleControlShape.java,v $
|
|
|
|
* $Revision: 1.9 $
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2008-04-10 18:00:49 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2008-04-10 18:00:49 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2008-04-10 18:00:49 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2008-04-10 18:00:49 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
package mod._svx;
|
|
|
|
|
|
|
|
import java.io.PrintWriter;
|
2003-09-08 11:35:02 +00:00
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
import lib.StatusException;
|
|
|
|
import lib.TestCase;
|
|
|
|
import lib.TestEnvironment;
|
|
|
|
import lib.TestParameters;
|
|
|
|
import util.AccessibilityTools;
|
|
|
|
import util.FormTools;
|
|
|
|
import util.SOfficeFactory;
|
|
|
|
import util.utils;
|
|
|
|
|
2003-09-08 11:35:02 +00:00
|
|
|
import com.sun.star.accessibility.AccessibleRole;
|
|
|
|
import com.sun.star.accessibility.XAccessible;
|
|
|
|
import com.sun.star.awt.Size;
|
|
|
|
import com.sun.star.awt.XWindow;
|
|
|
|
import com.sun.star.drawing.XShape;
|
|
|
|
import com.sun.star.frame.XModel;
|
|
|
|
import com.sun.star.lang.XComponent;
|
|
|
|
import com.sun.star.lang.XMultiServiceFactory;
|
|
|
|
import com.sun.star.uno.UnoRuntime;
|
|
|
|
import com.sun.star.uno.XInterface;
|
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
public class AccessibleControlShape extends TestCase {
|
|
|
|
|
|
|
|
XComponent xDrawDoc;
|
|
|
|
XModel aModel;
|
|
|
|
|
|
|
|
protected void initialize( TestParameters tParam, PrintWriter log ) {
|
|
|
|
|
2003-05-27 12:34:18 +00:00
|
|
|
SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
log.println( "creating a drawdoc" );
|
|
|
|
xDrawDoc = SOF.createDrawDoc(null);
|
|
|
|
aModel = (XModel)
|
|
|
|
UnoRuntime.queryInterface(XModel.class, xDrawDoc);
|
|
|
|
|
|
|
|
} catch ( com.sun.star.uno.Exception e ) {
|
|
|
|
// Some exception occures.FAILED
|
|
|
|
e.printStackTrace( log );
|
|
|
|
throw new StatusException( "Couldn't create document", e );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Disposes the Draw document loaded before.
|
|
|
|
*/
|
|
|
|
protected void cleanup( TestParameters tParam, PrintWriter log ) {
|
|
|
|
log.println( " disposing xDrawDoc " );
|
2004-01-05 18:41:33 +00:00
|
|
|
util.DesktopTools.closeDoc(xDrawDoc);
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected TestEnvironment createTestEnvironment
|
|
|
|
(TestParameters tParam, PrintWriter log) {
|
|
|
|
|
|
|
|
XInterface oObj = null;
|
|
|
|
|
|
|
|
log.println( "creating a test environment" );
|
|
|
|
|
|
|
|
final XShape oShape = FormTools.insertControlShape
|
|
|
|
(xDrawDoc,3000,4500,15000,1000,"CommandButton");
|
|
|
|
|
|
|
|
AccessibilityTools at = new AccessibilityTools();
|
|
|
|
|
2003-05-27 12:34:18 +00:00
|
|
|
XWindow xWindow = at.getCurrentWindow ((XMultiServiceFactory)tParam.getMSF(),aModel);
|
2003-01-27 17:20:08 +00:00
|
|
|
XAccessible xRoot = at.getAccessibleObject(xWindow);
|
|
|
|
|
|
|
|
at.getAccessibleObjectForRole(xRoot, AccessibleRole.SHAPE);
|
|
|
|
|
2004-11-02 11:07:26 +00:00
|
|
|
at.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
|
2003-04-28 11:31:17 +00:00
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
oObj = at.getAccessibleObjectForRole(xRoot, AccessibleRole.SHAPE,
|
2003-02-28 13:31:09 +00:00
|
|
|
"Button");
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
// create test environment here
|
|
|
|
TestEnvironment tEnv = new TestEnvironment( oObj );
|
|
|
|
|
|
|
|
tEnv.addObjRelation("EventProducer",
|
|
|
|
new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
|
|
|
|
public void fireEvent() {
|
|
|
|
try {
|
|
|
|
Size size = oShape.getSize();
|
|
|
|
size.Width += 100;
|
|
|
|
oShape.setSize(size);
|
|
|
|
} catch(com.sun.star.beans.PropertyVetoException e) {}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
log.println("Implementation Name: " + utils.getImplName(oObj));
|
|
|
|
|
|
|
|
return tEnv;
|
|
|
|
} // finish method getTestEnvironment
|
|
|
|
|
|
|
|
}
|
|
|
|
|