Bump for 3.6-28
[LibreOffice.git] / ucb / source / ucp / file / filnot.cxx
blob74c2668a6f8ceca788f2cf3deccb5a22fca9a0eb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
29 #include <com/sun/star/ucb/XContent.hpp>
30 #include <com/sun/star/ucb/ContentAction.hpp>
31 #include <com/sun/star/beans/PropertySetInfoChange.hpp>
32 #include "filnot.hxx"
33 #include "filid.hxx"
34 #include "bc.hxx"
35 #include "prov.hxx"
39 using namespace fileaccess;
40 using namespace com::sun::star;
41 using namespace com::sun::star::ucb;
44 ContentEventNotifier::ContentEventNotifier( shell* pMyShell,
45 const uno::Reference< XContent >& xCreatorContent,
46 const uno::Reference< XContentIdentifier >& xCreatorId,
47 const uno::Sequence< uno::Reference< uno::XInterface > >& sListeners )
48 : m_pMyShell( pMyShell ),
49 m_xCreatorContent( xCreatorContent ),
50 m_xCreatorId( xCreatorId ),
51 m_sListeners( sListeners )
56 ContentEventNotifier::ContentEventNotifier( shell* pMyShell,
57 const uno::Reference< XContent >& xCreatorContent,
58 const uno::Reference< XContentIdentifier >& xCreatorId,
59 const uno::Reference< XContentIdentifier >& xOldId,
60 const uno::Sequence< uno::Reference< uno::XInterface > >& sListeners )
61 : m_pMyShell( pMyShell ),
62 m_xCreatorContent( xCreatorContent ),
63 m_xCreatorId( xCreatorId ),
64 m_xOldId( xOldId ),
65 m_sListeners( sListeners )
71 void ContentEventNotifier::notifyChildInserted( const rtl::OUString& aChildName )
73 FileContentIdentifier* p = new FileContentIdentifier( m_pMyShell,aChildName );
74 uno::Reference< XContentIdentifier > xChildId( p );
76 uno::Reference< XContent > xChildContent = m_pMyShell->m_pProvider->queryContent( xChildId );
78 ContentEvent aEvt( m_xCreatorContent,
79 ContentAction::INSERTED,
80 xChildContent,
81 m_xCreatorId );
83 for( sal_Int32 i = 0; i < m_sListeners.getLength(); ++i )
85 uno::Reference< XContentEventListener > ref( m_sListeners[i],uno::UNO_QUERY );
86 if( ref.is() )
87 ref->contentEvent( aEvt );
91 void ContentEventNotifier::notifyDeleted( void )
94 ContentEvent aEvt( m_xCreatorContent,
95 ContentAction::DELETED,
96 m_xCreatorContent,
97 m_xCreatorId );
100 for( sal_Int32 i = 0; i < m_sListeners.getLength(); ++i )
102 uno::Reference< XContentEventListener > ref( m_sListeners[i],uno::UNO_QUERY );
103 if( ref.is() )
104 ref->contentEvent( aEvt );
110 void ContentEventNotifier::notifyRemoved( const rtl::OUString& aChildName )
112 FileContentIdentifier* p = new FileContentIdentifier( m_pMyShell,aChildName );
113 uno::Reference< XContentIdentifier > xChildId( p );
115 BaseContent* pp = new BaseContent( m_pMyShell,xChildId,aChildName );
117 osl::MutexGuard aGuard( pp->m_aMutex );
118 pp->m_nState |= BaseContent::Deleted;
121 uno::Reference< XContent > xDeletedContent( pp );
124 ContentEvent aEvt( m_xCreatorContent,
125 ContentAction::REMOVED,
126 xDeletedContent,
127 m_xCreatorId );
129 for( sal_Int32 i = 0; i < m_sListeners.getLength(); ++i )
131 uno::Reference< XContentEventListener > ref( m_sListeners[i],uno::UNO_QUERY );
132 if( ref.is() )
133 ref->contentEvent( aEvt );
137 void ContentEventNotifier::notifyExchanged()
139 ContentEvent aEvt( m_xCreatorContent,
140 ContentAction::EXCHANGED,
141 m_xCreatorContent,
142 m_xOldId );
144 for( sal_Int32 i = 0; i < m_sListeners.getLength(); ++i )
146 uno::Reference< XContentEventListener > ref( m_sListeners[i],uno::UNO_QUERY );
147 if( ref.is() )
148 ref->contentEvent( aEvt );
152 /*********************************************************************************/
153 /* */
154 /* PropertySetInfoChangeNotifier */
155 /* */
156 /*********************************************************************************/
159 PropertySetInfoChangeNotifier::PropertySetInfoChangeNotifier(
160 shell* pMyShell,
161 const uno::Reference< XContent >& xCreatorContent,
162 const uno::Reference< XContentIdentifier >& xCreatorId,
163 const uno::Sequence< uno::Reference< uno::XInterface > >& sListeners )
164 : m_pMyShell( pMyShell ),
165 m_xCreatorContent( xCreatorContent ),
166 m_xCreatorId( xCreatorId ),
167 m_sListeners( sListeners )
173 void SAL_CALL
174 PropertySetInfoChangeNotifier::notifyPropertyAdded( const rtl::OUString & aPropertyName )
176 beans::PropertySetInfoChangeEvent aEvt( m_xCreatorContent,
177 aPropertyName,
179 beans::PropertySetInfoChange::PROPERTY_INSERTED );
181 for( sal_Int32 i = 0; i < m_sListeners.getLength(); ++i )
183 uno::Reference< beans::XPropertySetInfoChangeListener > ref( m_sListeners[i],uno::UNO_QUERY );
184 if( ref.is() )
185 ref->propertySetInfoChange( aEvt );
190 void SAL_CALL
191 PropertySetInfoChangeNotifier::notifyPropertyRemoved( const rtl::OUString & aPropertyName )
193 beans::PropertySetInfoChangeEvent aEvt( m_xCreatorContent,
194 aPropertyName,
196 beans::PropertySetInfoChange::PROPERTY_REMOVED );
198 for( sal_Int32 i = 0; i < m_sListeners.getLength(); ++i )
200 uno::Reference< beans::XPropertySetInfoChangeListener > ref( m_sListeners[i],uno::UNO_QUERY );
201 if( ref.is() )
202 ref->propertySetInfoChange( aEvt );
207 /*********************************************************************************/
208 /* */
209 /* PropertySetInfoChangeNotifier */
210 /* */
211 /*********************************************************************************/
214 PropertyChangeNotifier::PropertyChangeNotifier(
215 shell* pMyShell,
216 const com::sun::star::uno::Reference< XContent >& xCreatorContent,
217 const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& xCreatorId,
218 ListenerMap* pListeners )
219 : m_pMyShell( pMyShell ),
220 m_xCreatorContent( xCreatorContent ),
221 m_xCreatorId( xCreatorId ),
222 m_pListeners( pListeners )
227 PropertyChangeNotifier::~PropertyChangeNotifier()
229 delete m_pListeners;
233 void PropertyChangeNotifier::notifyPropertyChanged(
234 uno::Sequence< beans::PropertyChangeEvent > Changes )
236 sal_Int32 j;
238 for( j = 0; j < Changes.getLength(); ++j )
239 Changes[j].Source = m_xCreatorContent;
241 // notify listeners for all Events
243 uno::Sequence< uno::Reference< uno::XInterface > > seqList = (*m_pListeners)[ rtl::OUString() ];
244 for( j = 0; j < seqList.getLength(); ++j )
246 uno::Reference< beans::XPropertiesChangeListener > aListener( seqList[j],uno::UNO_QUERY );
247 if( aListener.is() )
249 aListener->propertiesChange( Changes );
253 uno::Sequence< beans::PropertyChangeEvent > seq(1);
254 for( j = 0; j < Changes.getLength(); ++j )
256 seq[0] = Changes[j];
257 seqList = (*m_pListeners)[ seq[0].PropertyName ];
259 for( sal_Int32 i = 0; i < seqList.getLength(); ++i )
261 uno::Reference< beans::XPropertiesChangeListener > aListener( seqList[j],uno::UNO_QUERY );
262 if( aListener.is() )
264 aListener->propertiesChange( seq );
270 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */