Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "DrawModelBroadcaster.hxx"
30 : : #include <osl/diagnose.h>
31 : : #include <rtl/strbuf.hxx>
32 : : #include <svx/svdmodel.hxx>
33 : : #include <svx/unomod.hxx>
34 : :
35 : : using namespace ::com::sun::star;
36 : :
37 : 5 : ScDrawModelBroadcaster::ScDrawModelBroadcaster( SdrModel *pDrawModel ) :
38 : : maEventListeners( maListenerMutex ),
39 [ + - ][ + - ]: 5 : mpDrawModel( pDrawModel )
[ + - ]
40 : : {
41 [ + - ]: 5 : if (mpDrawModel)
42 [ + - ]: 5 : StartListening( *mpDrawModel );
43 : 5 : }
44 : :
45 [ + - ][ + - ]: 5 : ScDrawModelBroadcaster::~ScDrawModelBroadcaster()
[ + - ]
46 : : {
47 [ + - ]: 5 : if (mpDrawModel)
48 [ + - ]: 5 : EndListening( *mpDrawModel );
49 [ - + ]: 10 : }
50 : :
51 : 0 : void SAL_CALL ScDrawModelBroadcaster::addEventListener( const uno::Reference< document::XEventListener >& xListener )
52 : : throw (uno::RuntimeException)
53 : : {
54 : 0 : maEventListeners.addInterface( xListener );
55 : 0 : }
56 : :
57 : 0 : void SAL_CALL ScDrawModelBroadcaster::removeEventListener( const uno::Reference< document::XEventListener >& xListener )
58 : : throw (uno::RuntimeException)
59 : : {
60 : 0 : maEventListeners.removeInterface( xListener );
61 : 0 : }
62 : :
63 : 6 : void ScDrawModelBroadcaster::Notify( SfxBroadcaster&,
64 : : const SfxHint& rHint )
65 : : {
66 [ + - ][ + - ]: 6 : const SdrHint *pSdrHint = PTR_CAST( SdrHint, &rHint );
[ + - ][ + + ]
67 [ + + ]: 6 : if( !pSdrHint )
68 : : return;
69 : :
70 [ + - ]: 1 : document::EventObject aEvent;
71 [ + - ][ + - ]: 1 : if( !SvxUnoDrawMSFactory::createEvent( mpDrawModel, pSdrHint, aEvent ) )
72 : : return;
73 : :
74 [ # # ]: 0 : ::cppu::OInterfaceIteratorHelper aIter( maEventListeners );
75 [ # # ]: 0 : while( aIter.hasMoreElements() )
76 : : {
77 [ # # ][ # # ]: 0 : uno::Reference < document::XEventListener > xListener( aIter.next(), uno::UNO_QUERY );
78 : : try
79 : : {
80 [ # # ][ # # ]: 0 : xListener->notifyEvent( aEvent );
81 : : }
82 [ # # ]: 0 : catch( const uno::RuntimeException& r )
83 : : {
84 : : (void) r;
85 : : #if OSL_DEBUG_LEVEL > 1
86 : : rtl::OStringBuffer aError(RTL_CONSTASCII_STRINGPARAM(
87 : : "Runtime exception caught while notifying shape.:\n"));
88 : : aError.append(rtl::OUStringToOString(r.Message, RTL_TEXTENCODING_ASCII_US));
89 : : OSL_FAIL( aError.getStr() );
90 : : #endif
91 : : }
92 [ # # ][ + - ]: 6 : }
[ - + ][ # # ]
93 : : }
94 : :
95 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|