/************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * * This file is part of OpenOffice.org. * * 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. * * 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). * * You should have received a copy of the GNU Lesser General Public License * version 3 along with OpenOffice.org. If not, see * * for a copy of the LGPLv3 License. * ************************************************************************/ package mod._sch; import java.io.PrintWriter; import lib.StatusException; import lib.TestCase; import lib.TestEnvironment; import lib.TestParameters; import util.AccessibilityTools; import util.SOfficeFactory; import util.utils; import com.sun.star.accessibility.AccessibleRole; import com.sun.star.accessibility.XAccessible; import com.sun.star.awt.PosSize; import com.sun.star.awt.Rectangle; import com.sun.star.awt.XWindow; import com.sun.star.chart.XChartDocument; import com.sun.star.frame.XModel; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XInterface; public class AccessibleDocumentView extends TestCase { XChartDocument xChartDoc = null; protected TestEnvironment createTestEnvironment( TestParameters Param, PrintWriter log) { XInterface oObj = null; XModel aModel = (XModel) UnoRuntime.queryInterface(XModel.class, xChartDoc); AccessibilityTools at = new AccessibilityTools(); XWindow xWindow = at.getCurrentWindow((XMultiServiceFactory)Param.getMSF(), aModel); XAccessible xRoot = at.getAccessibleObject(xWindow); at.getAccessibleObjectForRole(xRoot, AccessibleRole.DOCUMENT); oObj = AccessibilityTools.SearchedContext; if (oObj == null) { log.println("DocumentView hasn't the role 'Document'"); log.println("trying the role 'Shape'"); at.getAccessibleObjectForRole(xRoot, AccessibleRole.SHAPE); oObj = AccessibilityTools.SearchedContext; } log.println("ImplementationName " + utils.getImplName(oObj)); TestEnvironment tEnv = new TestEnvironment(oObj); final XWindow xDocWin = xWindow; tEnv.addObjRelation("EventProducer", new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { public void fireEvent() { Rectangle rect = xDocWin.getPosSize(); xDocWin.setPosSize(100,100,100,100,PosSize.POSSIZE); xDocWin.setPosSize(rect.X,rect.Y,rect.Width,rect.Height, PosSize.POSSIZE); } }); return tEnv; } /** * Called while disposing a TestEnvironment. * Disposes text document. * @param tParam test parameters * @param tEnv the environment to cleanup * @param log writer to log information while testing */ protected void cleanup( TestParameters Param, PrintWriter log) { if( xChartDoc!=null ) { log.println( " closing xChartDoc" ); util.DesktopTools.closeDoc(xChartDoc); xChartDoc = null; } } /** * Called while the TestCase initialization. * Creates a chart document. * * @param tParam test parameters * @param log writer to log information while testing * * @see #initializeTestCase() */ protected void initialize(TestParameters Param, PrintWriter log) { log.println( "creating a text document" ); SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF()); try { log.println( "creating a chartdocument" ); xChartDoc = SOF.createChartDoc(null); } catch (com.sun.star.uno.Exception e) { // Some exception occures.FAILED e.printStackTrace( log ); throw new StatusException( "Couldn't create document", e ); } } }