Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : :
20 : : #include <com/sun/star/ucb/XContent.hpp>
21 : : #include <com/sun/star/ucb/ContentAction.hpp>
22 : : #include <com/sun/star/beans/PropertySetInfoChange.hpp>
23 : : #include "filnot.hxx"
24 : : #include "filid.hxx"
25 : : #include "bc.hxx"
26 : : #include "prov.hxx"
27 : :
28 : :
29 : :
30 : : using namespace fileaccess;
31 : : using namespace com::sun::star;
32 : : using namespace com::sun::star::ucb;
33 : :
34 : :
35 : 4380 : ContentEventNotifier::ContentEventNotifier( shell* pMyShell,
36 : : const uno::Reference< XContent >& xCreatorContent,
37 : : const uno::Reference< XContentIdentifier >& xCreatorId,
38 : : const uno::Sequence< uno::Reference< uno::XInterface > >& sListeners )
39 : : : m_pMyShell( pMyShell ),
40 : : m_xCreatorContent( xCreatorContent ),
41 : : m_xCreatorId( xCreatorId ),
42 [ + - ]: 4380 : m_sListeners( sListeners )
43 : : {
44 : 4380 : }
45 : :
46 : :
47 : 0 : ContentEventNotifier::ContentEventNotifier( shell* pMyShell,
48 : : const uno::Reference< XContent >& xCreatorContent,
49 : : const uno::Reference< XContentIdentifier >& xCreatorId,
50 : : const uno::Reference< XContentIdentifier >& xOldId,
51 : : const uno::Sequence< uno::Reference< uno::XInterface > >& sListeners )
52 : : : m_pMyShell( pMyShell ),
53 : : m_xCreatorContent( xCreatorContent ),
54 : : m_xCreatorId( xCreatorId ),
55 : : m_xOldId( xOldId ),
56 [ # # ]: 0 : m_sListeners( sListeners )
57 : : {
58 : 0 : }
59 : :
60 : :
61 : :
62 : 3744 : void ContentEventNotifier::notifyChildInserted( const rtl::OUString& aChildName )
63 : : {
64 [ + - ]: 3744 : FileContentIdentifier* p = new FileContentIdentifier( m_pMyShell,aChildName );
65 [ + - ][ + - ]: 3744 : uno::Reference< XContentIdentifier > xChildId( p );
66 : :
67 [ + - ]: 3744 : uno::Reference< XContent > xChildContent = m_pMyShell->m_pProvider->queryContent( xChildId );
68 : :
69 : : ContentEvent aEvt( m_xCreatorContent,
70 : : ContentAction::INSERTED,
71 : : xChildContent,
72 [ + - ]: 3744 : m_xCreatorId );
73 : :
74 [ + + ]: 7488 : for( sal_Int32 i = 0; i < m_sListeners.getLength(); ++i )
75 : : {
76 [ + - ][ + - ]: 3744 : uno::Reference< XContentEventListener > ref( m_sListeners[i],uno::UNO_QUERY );
77 [ + - ]: 3744 : if( ref.is() )
78 [ + - ][ + - ]: 3744 : ref->contentEvent( aEvt );
79 [ + - ]: 7488 : }
80 : 3744 : }
81 : :
82 : 636 : void ContentEventNotifier::notifyDeleted( void )
83 : : {
84 : :
85 : : ContentEvent aEvt( m_xCreatorContent,
86 : : ContentAction::DELETED,
87 : : m_xCreatorContent,
88 [ + - ]: 636 : m_xCreatorId );
89 : :
90 : :
91 [ + + ]: 1272 : for( sal_Int32 i = 0; i < m_sListeners.getLength(); ++i )
92 : : {
93 [ + - ][ + - ]: 636 : uno::Reference< XContentEventListener > ref( m_sListeners[i],uno::UNO_QUERY );
94 [ + - ]: 636 : if( ref.is() )
95 [ + - ][ + - ]: 636 : ref->contentEvent( aEvt );
96 [ + - ]: 1272 : }
97 : 636 : }
98 : :
99 : :
100 : :
101 : 0 : void ContentEventNotifier::notifyRemoved( const rtl::OUString& aChildName )
102 : : {
103 [ # # ]: 0 : FileContentIdentifier* p = new FileContentIdentifier( m_pMyShell,aChildName );
104 [ # # ][ # # ]: 0 : uno::Reference< XContentIdentifier > xChildId( p );
105 : :
106 [ # # ]: 0 : BaseContent* pp = new BaseContent( m_pMyShell,xChildId,aChildName );
107 : : {
108 [ # # ]: 0 : osl::MutexGuard aGuard( pp->m_aMutex );
109 [ # # ]: 0 : pp->m_nState |= BaseContent::Deleted;
110 : : }
111 : :
112 [ # # ][ # # ]: 0 : uno::Reference< XContent > xDeletedContent( pp );
113 : :
114 : :
115 : : ContentEvent aEvt( m_xCreatorContent,
116 : : ContentAction::REMOVED,
117 : : xDeletedContent,
118 [ # # ]: 0 : m_xCreatorId );
119 : :
120 [ # # ]: 0 : for( sal_Int32 i = 0; i < m_sListeners.getLength(); ++i )
121 : : {
122 [ # # ][ # # ]: 0 : uno::Reference< XContentEventListener > ref( m_sListeners[i],uno::UNO_QUERY );
123 [ # # ]: 0 : if( ref.is() )
124 [ # # ][ # # ]: 0 : ref->contentEvent( aEvt );
125 [ # # ]: 0 : }
126 : 0 : }
127 : :
128 : 0 : void ContentEventNotifier::notifyExchanged()
129 : : {
130 : : ContentEvent aEvt( m_xCreatorContent,
131 : : ContentAction::EXCHANGED,
132 : : m_xCreatorContent,
133 [ # # ]: 0 : m_xOldId );
134 : :
135 [ # # ]: 0 : for( sal_Int32 i = 0; i < m_sListeners.getLength(); ++i )
136 : : {
137 [ # # ][ # # ]: 0 : uno::Reference< XContentEventListener > ref( m_sListeners[i],uno::UNO_QUERY );
138 [ # # ]: 0 : if( ref.is() )
139 [ # # ][ # # ]: 0 : ref->contentEvent( aEvt );
140 [ # # ]: 0 : }
141 : 0 : }
142 : :
143 : : /*********************************************************************************/
144 : : /* */
145 : : /* PropertySetInfoChangeNotifier */
146 : : /* */
147 : : /*********************************************************************************/
148 : :
149 : :
150 : 0 : PropertySetInfoChangeNotifier::PropertySetInfoChangeNotifier(
151 : : const uno::Reference< XContent >& xCreatorContent,
152 : : const uno::Reference< XContentIdentifier >& xCreatorId,
153 : : const uno::Sequence< uno::Reference< uno::XInterface > >& sListeners )
154 : : : m_xCreatorContent( xCreatorContent ),
155 : : m_xCreatorId( xCreatorId ),
156 [ # # ]: 0 : m_sListeners( sListeners )
157 : : {
158 : :
159 : 0 : }
160 : :
161 : :
162 : : void SAL_CALL
163 : 0 : PropertySetInfoChangeNotifier::notifyPropertyAdded( const rtl::OUString & aPropertyName )
164 : : {
165 : : beans::PropertySetInfoChangeEvent aEvt( m_xCreatorContent,
166 : : aPropertyName,
167 : : -1,
168 [ # # ]: 0 : beans::PropertySetInfoChange::PROPERTY_INSERTED );
169 : :
170 [ # # ]: 0 : for( sal_Int32 i = 0; i < m_sListeners.getLength(); ++i )
171 : : {
172 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySetInfoChangeListener > ref( m_sListeners[i],uno::UNO_QUERY );
173 [ # # ]: 0 : if( ref.is() )
174 [ # # ][ # # ]: 0 : ref->propertySetInfoChange( aEvt );
175 [ # # ]: 0 : }
176 : 0 : }
177 : :
178 : :
179 : : void SAL_CALL
180 : 0 : PropertySetInfoChangeNotifier::notifyPropertyRemoved( const rtl::OUString & aPropertyName )
181 : : {
182 : : beans::PropertySetInfoChangeEvent aEvt( m_xCreatorContent,
183 : : aPropertyName,
184 : : -1,
185 [ # # ]: 0 : beans::PropertySetInfoChange::PROPERTY_REMOVED );
186 : :
187 [ # # ]: 0 : for( sal_Int32 i = 0; i < m_sListeners.getLength(); ++i )
188 : : {
189 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySetInfoChangeListener > ref( m_sListeners[i],uno::UNO_QUERY );
190 [ # # ]: 0 : if( ref.is() )
191 [ # # ][ # # ]: 0 : ref->propertySetInfoChange( aEvt );
192 [ # # ]: 0 : }
193 : 0 : }
194 : :
195 : :
196 : : /*********************************************************************************/
197 : : /* */
198 : : /* PropertySetInfoChangeNotifier */
199 : : /* */
200 : : /*********************************************************************************/
201 : :
202 : :
203 : 0 : PropertyChangeNotifier::PropertyChangeNotifier(
204 : : const com::sun::star::uno::Reference< XContent >& xCreatorContent,
205 : : const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& xCreatorId,
206 : : ListenerMap* pListeners )
207 : : : m_xCreatorContent( xCreatorContent ),
208 : : m_xCreatorId( xCreatorId ),
209 : 0 : m_pListeners( pListeners )
210 : : {
211 : 0 : }
212 : :
213 : :
214 : 0 : PropertyChangeNotifier::~PropertyChangeNotifier()
215 : : {
216 [ # # ][ # # ]: 0 : delete m_pListeners;
217 : 0 : }
218 : :
219 : :
220 : 0 : void PropertyChangeNotifier::notifyPropertyChanged(
221 : : uno::Sequence< beans::PropertyChangeEvent > Changes )
222 : : {
223 : : sal_Int32 j;
224 : :
225 [ # # ]: 0 : for( j = 0; j < Changes.getLength(); ++j )
226 [ # # ][ # # ]: 0 : Changes[j].Source = m_xCreatorContent;
227 : :
228 : : // notify listeners for all Events
229 : :
230 [ # # ][ # # ]: 0 : uno::Sequence< uno::Reference< uno::XInterface > > seqList = (*m_pListeners)[ rtl::OUString() ];
231 [ # # ]: 0 : for( j = 0; j < seqList.getLength(); ++j )
232 : : {
233 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertiesChangeListener > aListener( seqList[j],uno::UNO_QUERY );
234 [ # # ]: 0 : if( aListener.is() )
235 : : {
236 [ # # ][ # # ]: 0 : aListener->propertiesChange( Changes );
237 : : }
238 : 0 : }
239 : :
240 [ # # ]: 0 : uno::Sequence< beans::PropertyChangeEvent > seq(1);
241 [ # # ]: 0 : for( j = 0; j < Changes.getLength(); ++j )
242 : : {
243 [ # # ][ # # ]: 0 : seq[0] = Changes[j];
[ # # ]
244 [ # # ][ # # ]: 0 : seqList = (*m_pListeners)[ seq[0].PropertyName ];
[ # # ]
245 : :
246 [ # # ]: 0 : for( sal_Int32 i = 0; i < seqList.getLength(); ++i )
247 : : {
248 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertiesChangeListener > aListener( seqList[j],uno::UNO_QUERY );
249 [ # # ]: 0 : if( aListener.is() )
250 : : {
251 [ # # ][ # # ]: 0 : aListener->propertiesChange( seq );
252 : : }
253 : 0 : }
254 [ # # ][ # # ]: 0 : }
255 : 0 : }
256 : :
257 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|