Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / sheet / _XActivationBroadcaster.java
blobdd3e9aff61b5891fe1153bf172867cbaa89ca2c7
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: _XActivationBroadcaster.java,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
30 package ifc.sheet;
32 import com.sun.star.sheet.XActivationBroadcaster;
33 import com.sun.star.sheet.XActivationEventListener;
34 import com.sun.star.sheet.XSpreadsheet;
35 import com.sun.star.sheet.XSpreadsheetView;
36 import com.sun.star.uno.UnoRuntime;
38 import lib.MultiMethodTest;
39 import lib.Status;
40 import lib.StatusException;
43 public class _XActivationBroadcaster extends MultiMethodTest {
44 public XActivationBroadcaster oObj;
45 protected boolean listenerCalled = false;
46 protected XSpreadsheetView xSpreadsheetView = null;
47 protected XActivationEventListener listener = null;
48 protected XSpreadsheet two = null;
50 public void _addActivationEventListener() {
52 log.println("trying to add an invalid listener");
53 oObj.addActivationEventListener(listener);
54 log.println(".... OK");
56 log.println("adding a valid listener");
57 listener = new MyListener();
58 oObj.addActivationEventListener(listener);
60 XSpreadsheet org = xSpreadsheetView.getActiveSheet();
61 xSpreadsheetView.setActiveSheet(two);
63 if (!listenerCalled) {
64 log.println("Listener wasn't called");
67 xSpreadsheetView.setActiveSheet(org);
68 tRes.tested("addActivationEventListener()", listenerCalled);
71 public void _removeActivationEventListener() {
72 requiredMethod("addActivationEventListener()");
73 listenerCalled = false;
74 oObj.removeActivationEventListener(listener);
76 XSpreadsheet org = xSpreadsheetView.getActiveSheet();
77 xSpreadsheetView.setActiveSheet(two);
79 if (listenerCalled) {
80 log.println("Listener was called eventhough it is removed");
83 xSpreadsheetView.setActiveSheet(org);
84 tRes.tested("removeActivationEventListener()", !listenerCalled);
87 public void before() {
88 xSpreadsheetView = (XSpreadsheetView) UnoRuntime.queryInterface(
89 XSpreadsheetView.class,
90 tEnv.getTestObject());
92 two = (XSpreadsheet) tEnv.getObjRelation("Sheet");
94 if ((xSpreadsheetView == null) || (two == null)) {
95 throw new StatusException(Status.failed(
96 "precondition for test is missing"));
100 protected class MyListener implements XActivationEventListener {
101 public void activeSpreadsheetChanged(com.sun.star.sheet.ActivationEvent activationEvent) {
102 listenerCalled = true;
105 public void disposing(com.sun.star.lang.EventObject eventObject) {