1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "DrawModelBroadcaster.hxx"
21 #include <osl/diagnose.h>
22 #include <rtl/strbuf.hxx>
23 #include <svx/svdmodel.hxx>
24 #include <svx/unomod.hxx>
26 using namespace ::com::sun::star
;
28 ScDrawModelBroadcaster::ScDrawModelBroadcaster( SdrModel
*pDrawModel
) :
29 maEventListeners( maListenerMutex
),
30 mpDrawModel( pDrawModel
)
33 StartListening( *mpDrawModel
);
36 ScDrawModelBroadcaster::~ScDrawModelBroadcaster()
39 EndListening( *mpDrawModel
);
42 void SAL_CALL
ScDrawModelBroadcaster::addEventListener( const uno::Reference
< document::XEventListener
>& xListener
)
43 throw (uno::RuntimeException
, std::exception
)
45 maEventListeners
.addInterface( xListener
);
48 void SAL_CALL
ScDrawModelBroadcaster::removeEventListener( const uno::Reference
< document::XEventListener
>& xListener
)
49 throw (uno::RuntimeException
, std::exception
)
51 maEventListeners
.removeInterface( xListener
);
54 void ScDrawModelBroadcaster::Notify( SfxBroadcaster
&,
55 const SfxHint
& rHint
)
57 const SdrHint
* pSdrHint
= dynamic_cast<const SdrHint
*>(&rHint
);
61 document::EventObject aEvent
;
62 if( !SvxUnoDrawMSFactory::createEvent( mpDrawModel
, pSdrHint
, aEvent
) )
65 ::cppu::OInterfaceIteratorHelper
aIter( maEventListeners
);
66 while( aIter
.hasMoreElements() )
68 uno::Reference
< document::XEventListener
> xListener( aIter
.next(), uno::UNO_QUERY
);
71 xListener
->notifyEvent( aEvent
);
73 catch( const uno::RuntimeException
& r
)
76 #if OSL_DEBUG_LEVEL > 1
77 OStringBuffer
aError("Runtime exception caught while notifying shape.:\n");
78 aError
.append(OUStringToOString(r
.Message
, RTL_TEXTENCODING_ASCII_US
));
79 OSL_FAIL( aError
.getStr() );
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */