12#include <com/sun/star/lang/EventObject.hpp>
13#include <com/sun/star/sheet/ActivationEvent.hpp>
14#include <com/sun/star/sheet/XActivationBroadcaster.hpp>
15#include <com/sun/star/sheet/XActivationEventListener.hpp>
16#include <com/sun/star/sheet/XSpreadsheetView.hpp>
17#include <com/sun/star/uno/Reference.hxx>
22#include <cppunit/TestAssert.h>
31class MockedActivationEventListener :
public ::cppu::WeakImplHelper<sheet::XActivationEventListener>
34 MockedActivationEventListener()
40 activeSpreadsheetChanged(
const sheet::ActivationEvent& )
override
44 virtual void SAL_CALL disposing(
const lang::EventObject& )
override {}
50 uno::Reference<sheet::XActivationBroadcaster> xAB(
init(), UNO_QUERY_THROW);
51 xAB->addActivationEventListener(
nullptr);
54 xAB->addActivationEventListener(uno::Reference<sheet::XActivationEventListener>(xListener));
56 uno::Reference<sheet::XSpreadsheetView> xView(xAB, UNO_QUERY_THROW);
57 uno::Reference<sheet::XSpreadsheet> xSheet1(xView->getActiveSheet(), UNO_SET_THROW);
58 uno::Reference<sheet::XSpreadsheet> xSheet2(
getXSpreadsheet(1), UNO_QUERY_THROW);
60 xView->setActiveSheet(xSheet2);
62 CPPUNIT_ASSERT_MESSAGE(
"Listener wasn't called", xListener->mbListenerCalled);
64 xAB->removeActivationEventListener(uno::Reference<sheet::XActivationEventListener>(xListener));
65 xView->setActiveSheet(xSheet1);
66 CPPUNIT_ASSERT_MESSAGE(
"Listener still called after removal", xListener->mbListenerCalled);
virtual css::uno::Reference< css::uno::XInterface > init()=0
virtual css::uno::Reference< css::uno::XInterface > getXSpreadsheet(const sal_Int16 nNumber=0)=0
void testAddRemoveActivationEventListener()