1 /*************************************************************************
2 *
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
6 *
7 * OpenOffice.org - a multi-platform office productivity suite
8 *
9 * This file is part of OpenOffice.org.
10 *
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
14 *
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
20 *
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org.  If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
25 *
26 ************************************************************************/
27 
28 #ifndef INCLUDED_CONFIGMGR_SOURCE_BROADCASTER_HXX
29 #define INCLUDED_CONFIGMGR_SOURCE_BROADCASTER_HXX
30 
31 #include "sal/config.h"
32 
33 #include <vector>
34 
35 #include "boost/noncopyable.hpp"
36 #include "com/sun/star/beans/PropertyChangeEvent.hpp"
37 #include "com/sun/star/container/ContainerEvent.hpp"
38 #include "com/sun/star/lang/EventObject.hpp"
39 #include "com/sun/star/uno/Reference.hxx"
40 #include "com/sun/star/uno/Sequence.hxx"
41 #include "com/sun/star/util/ChangesEvent.hpp"
42 
43 namespace com { namespace sun { namespace star {
44     namespace beans {
45         class XPropertiesChangeListener;
46         class XPropertyChangeListener;
47     }
48     namespace container { class XContainerListener; }
49     namespace lang { class XEventListener; }
50     namespace util { class XChangesListener; }
51 } } }
52 
53 namespace configmgr {
54 
55 class Access;
56 
57 class Broadcaster: private boost::noncopyable {
58 public:
59     void addDisposeNotification(
60         com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >
61             const & listener,
62         com::sun::star::lang::EventObject const & event);
63 
64     void addContainerElementInsertedNotification(
65         com::sun::star::uno::Reference<
66             com::sun::star::container::XContainerListener > const & listener,
67         com::sun::star::container::ContainerEvent const & event);
68 
69     void addContainerElementRemovedNotification(
70         com::sun::star::uno::Reference<
71             com::sun::star::container::XContainerListener > const & listener,
72         com::sun::star::container::ContainerEvent const & event);
73 
74     void addContainerElementReplacedNotification(
75         com::sun::star::uno::Reference<
76             com::sun::star::container::XContainerListener > const & listener,
77         com::sun::star::container::ContainerEvent const & event);
78 
79     void addPropertyChangeNotification(
80         com::sun::star::uno::Reference<
81             com::sun::star::beans::XPropertyChangeListener > const & listener,
82         com::sun::star::beans::PropertyChangeEvent const & event);
83 
84     void addPropertiesChangeNotification(
85         com::sun::star::uno::Reference<
86             com::sun::star::beans::XPropertiesChangeListener > const & listener,
87         com::sun::star::uno::Sequence<
88             com::sun::star::beans::PropertyChangeEvent > const & event);
89 
90     void addChangesNotification(
91         com::sun::star::uno::Reference< com::sun::star::util::XChangesListener >
92             const & listener,
93         com::sun::star::util::ChangesEvent const & event);
94 
95     void send();
96 
97 private:
98     struct DisposeNotification {
99         com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >
100             listener;
101         com::sun::star::lang::EventObject event;
102 
103         DisposeNotification(
104             com::sun::star::uno::Reference<
105                 com::sun::star::lang::XEventListener > const & theListener,
106             com::sun::star::lang::EventObject const & theEvent);
107     };
108 
109     struct ContainerNotification {
110         com::sun::star::uno::Reference<
111             com::sun::star::container::XContainerListener > listener;
112         com::sun::star::container::ContainerEvent event;
113 
114         ContainerNotification(
115             com::sun::star::uno::Reference<
116                 com::sun::star::container::XContainerListener > const &
117                     theListener,
118             com::sun::star::container::ContainerEvent const & theEvent);
119     };
120 
121     struct PropertyChangeNotification {
122         com::sun::star::uno::Reference<
123             com::sun::star::beans::XPropertyChangeListener > listener;
124         com::sun::star::beans::PropertyChangeEvent event;
125 
126         PropertyChangeNotification(
127             com::sun::star::uno::Reference<
128                 com::sun::star::beans::XPropertyChangeListener > const &
129                 theListener,
130             com::sun::star::beans::PropertyChangeEvent const & theEvent);
131     };
132 
133     struct PropertiesChangeNotification {
134         com::sun::star::uno::Reference<
135             com::sun::star::beans::XPropertiesChangeListener > listener;
136         com::sun::star::uno::Sequence<
137             com::sun::star::beans::PropertyChangeEvent > event;
138 
139         PropertiesChangeNotification(
140             com::sun::star::uno::Reference<
141                 com::sun::star::beans::XPropertiesChangeListener > const &
142                 theListener,
143             com::sun::star::uno::Sequence<
144                 com::sun::star::beans::PropertyChangeEvent > const & theEvent);
145     };
146 
147     struct ChangesNotification {
148         com::sun::star::uno::Reference< com::sun::star::util::XChangesListener >
149             listener;
150         com::sun::star::util::ChangesEvent event;
151 
152         ChangesNotification(
153             com::sun::star::uno::Reference<
154                 com::sun::star::util::XChangesListener > const & theListener,
155             com::sun::star::util::ChangesEvent const & theEvent);
156     };
157 
158     typedef std::vector< DisposeNotification > DisposeNotifications;
159 
160     typedef std::vector< ContainerNotification > ContainerNotifications;
161 
162     typedef std::vector< PropertyChangeNotification >
163         PropertyChangeNotifications;
164 
165     typedef std::vector< PropertiesChangeNotification >
166         PropertiesChangeNotifications;
167 
168     typedef std::vector< ChangesNotification > ChangesNotifications;
169 
170     DisposeNotifications disposeNotifications_;
171     ContainerNotifications containerElementInsertedNotifications_;
172     ContainerNotifications containerElementRemovedNotifications_;
173     ContainerNotifications containerElementReplacedNotifications_;
174     PropertyChangeNotifications propertyChangeNotifications_;
175     PropertiesChangeNotifications propertiesChangeNotifications_;
176     ChangesNotifications changesNotifications_;
177 };
178 
179 }
180 
181 #endif
182