bump product version to 5.0.4.1
[LibreOffice.git] / ucb / source / ucp / file / filnot.cxx
blob2f84445aae84882bbfe38c640ce4b90ceda1b910
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <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"
30 using namespace fileaccess;
31 using namespace com::sun::star;
32 using namespace com::sun::star::ucb;
35 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 m_sListeners( sListeners )
47 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 m_sListeners( sListeners )
62 void ContentEventNotifier::notifyChildInserted( const OUString& aChildName )
64 FileContentIdentifier* p = new FileContentIdentifier( aChildName );
65 uno::Reference< XContentIdentifier > xChildId( p );
67 uno::Reference< XContent > xChildContent = m_pMyShell->m_pProvider->queryContent( xChildId );
69 ContentEvent aEvt( m_xCreatorContent,
70 ContentAction::INSERTED,
71 xChildContent,
72 m_xCreatorId );
74 for( sal_Int32 i = 0; i < m_sListeners.getLength(); ++i )
76 uno::Reference< XContentEventListener > ref( m_sListeners[i],uno::UNO_QUERY );
77 if( ref.is() )
78 ref->contentEvent( aEvt );
82 void ContentEventNotifier::notifyDeleted()
85 ContentEvent aEvt( m_xCreatorContent,
86 ContentAction::DELETED,
87 m_xCreatorContent,
88 m_xCreatorId );
91 for( sal_Int32 i = 0; i < m_sListeners.getLength(); ++i )
93 uno::Reference< XContentEventListener > ref( m_sListeners[i],uno::UNO_QUERY );
94 if( ref.is() )
95 ref->contentEvent( aEvt );
101 void ContentEventNotifier::notifyRemoved( const OUString& aChildName )
103 FileContentIdentifier* p = new FileContentIdentifier( aChildName );
104 uno::Reference< XContentIdentifier > xChildId( p );
106 BaseContent* pp = new BaseContent( m_pMyShell,xChildId,aChildName );
108 osl::MutexGuard aGuard( pp->m_aMutex );
109 pp->m_nState |= BaseContent::Deleted;
112 uno::Reference< XContent > xDeletedContent( pp );
115 ContentEvent aEvt( m_xCreatorContent,
116 ContentAction::REMOVED,
117 xDeletedContent,
118 m_xCreatorId );
120 for( sal_Int32 i = 0; i < m_sListeners.getLength(); ++i )
122 uno::Reference< XContentEventListener > ref( m_sListeners[i],uno::UNO_QUERY );
123 if( ref.is() )
124 ref->contentEvent( aEvt );
128 void ContentEventNotifier::notifyExchanged()
130 ContentEvent aEvt( m_xCreatorContent,
131 ContentAction::EXCHANGED,
132 m_xCreatorContent,
133 m_xOldId );
135 for( sal_Int32 i = 0; i < m_sListeners.getLength(); ++i )
137 uno::Reference< XContentEventListener > ref( m_sListeners[i],uno::UNO_QUERY );
138 if( ref.is() )
139 ref->contentEvent( aEvt );
143 /*********************************************************************************/
144 /* */
145 /* PropertySetInfoChangeNotifier */
146 /* */
147 /*********************************************************************************/
150 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 m_sListeners( sListeners )
162 void SAL_CALL
163 PropertySetInfoChangeNotifier::notifyPropertyAdded( const OUString & aPropertyName )
165 beans::PropertySetInfoChangeEvent aEvt( m_xCreatorContent,
166 aPropertyName,
168 beans::PropertySetInfoChange::PROPERTY_INSERTED );
170 for( sal_Int32 i = 0; i < m_sListeners.getLength(); ++i )
172 uno::Reference< beans::XPropertySetInfoChangeListener > ref( m_sListeners[i],uno::UNO_QUERY );
173 if( ref.is() )
174 ref->propertySetInfoChange( aEvt );
179 void SAL_CALL
180 PropertySetInfoChangeNotifier::notifyPropertyRemoved( const OUString & aPropertyName )
182 beans::PropertySetInfoChangeEvent aEvt( m_xCreatorContent,
183 aPropertyName,
185 beans::PropertySetInfoChange::PROPERTY_REMOVED );
187 for( sal_Int32 i = 0; i < m_sListeners.getLength(); ++i )
189 uno::Reference< beans::XPropertySetInfoChangeListener > ref( m_sListeners[i],uno::UNO_QUERY );
190 if( ref.is() )
191 ref->propertySetInfoChange( aEvt );
196 /*********************************************************************************/
197 /* */
198 /* PropertySetInfoChangeNotifier */
199 /* */
200 /*********************************************************************************/
203 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 m_pListeners( pListeners )
214 PropertyChangeNotifier::~PropertyChangeNotifier()
216 delete m_pListeners;
220 void PropertyChangeNotifier::notifyPropertyChanged(
221 const uno::Sequence< beans::PropertyChangeEvent >& _Changes )
223 sal_Int32 j;
224 uno::Sequence< beans::PropertyChangeEvent > Changes = _Changes;
226 for( j = 0; j < Changes.getLength(); ++j )
227 Changes[j].Source = m_xCreatorContent;
229 // notify listeners for all Events
231 uno::Sequence< uno::Reference< uno::XInterface > > seqList = (*m_pListeners)[ OUString() ];
232 for( j = 0; j < seqList.getLength(); ++j )
234 uno::Reference< beans::XPropertiesChangeListener > aListener( seqList[j],uno::UNO_QUERY );
235 if( aListener.is() )
237 aListener->propertiesChange( Changes );
241 uno::Sequence< beans::PropertyChangeEvent > seq(1);
242 for( j = 0; j < Changes.getLength(); ++j )
244 seq[0] = Changes[j];
245 seqList = (*m_pListeners)[ seq[0].PropertyName ];
247 for( sal_Int32 i = 0; i < seqList.getLength(); ++i )
249 uno::Reference< beans::XPropertiesChangeListener > aListener( seqList[j],uno::UNO_QUERY );
250 if( aListener.is() )
252 aListener->propertiesChange( seq );
258 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */