merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / document / _XEventBroadcaster.java
blob184f841a9797eba260f162237984b8ee95a7099e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XEventBroadcaster.java,v $
10 * $Revision: 1.5 $
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 ************************************************************************/
31 package ifc.document;
33 import lib.MultiMethodTest;
35 import com.sun.star.document.XEventBroadcaster;
36 import com.sun.star.document.XEventListener;
37 import com.sun.star.frame.XController;
38 import com.sun.star.frame.XModel;
39 import com.sun.star.uno.UnoRuntime;
41 public class _XEventBroadcaster extends MultiMethodTest {
43 public XEventBroadcaster oObj;
44 protected static boolean listenerCalled=false;
45 private static XEventListener listener=null;
47 public class MyEventListener implements XEventListener {
49 public void disposing(com.sun.star.lang.EventObject eventObject) {
52 public void notifyEvent(com.sun.star.document.EventObject eventObject) {
53 System.out.println("EventObject "+eventObject.EventName);
54 listenerCalled = true;
59 private void switchFocus() {
60 XModel docModel = (XModel) UnoRuntime.queryInterface(
61 XModel.class,tEnv.getTestObject());
62 docModel.getCurrentController().getFrame().getContainerWindow().setFocus();
63 util.utils.shortWait(1000);
64 XController xc = (XController) UnoRuntime.queryInterface(XController.class,tEnv.getObjRelation("CONT2"));
65 xc.getFrame().getContainerWindow().setFocus();
68 public void _addEventListener() {
69 listener = new MyEventListener();
70 listenerCalled = false;
71 oObj.addEventListener(listener);
72 switchFocus();
73 util.utils.shortWait(1000);
74 tRes.tested("addEventListener()",listenerCalled);
77 public void _removeEventListener() {
78 requiredMethod("addEventListener()");
79 listenerCalled = false;
80 oObj.removeEventListener(listener);
81 switchFocus();
82 util.utils.shortWait(1000);
83 tRes.tested("removeEventListener()",!listenerCalled);