1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: filnot.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_ucb.hxx"
33 #include <com/sun/star/ucb/XContent.hpp>
34 #include <com/sun/star/ucb/ContentAction.hpp>
35 #include <com/sun/star/beans/PropertySetInfoChange.hpp>
43 using namespace fileaccess
;
44 using namespace com::sun::star
;
45 using namespace com::sun::star::ucb
;
48 ContentEventNotifier::ContentEventNotifier( shell
* pMyShell
,
49 const uno::Reference
< XContent
>& xCreatorContent
,
50 const uno::Reference
< XContentIdentifier
>& xCreatorId
,
51 const uno::Sequence
< uno::Reference
< uno::XInterface
> >& sListeners
)
52 : m_pMyShell( pMyShell
),
53 m_xCreatorContent( xCreatorContent
),
54 m_xCreatorId( xCreatorId
),
55 m_sListeners( sListeners
)
60 ContentEventNotifier::ContentEventNotifier( shell
* pMyShell
,
61 const uno::Reference
< XContent
>& xCreatorContent
,
62 const uno::Reference
< XContentIdentifier
>& xCreatorId
,
63 const uno::Reference
< XContentIdentifier
>& xOldId
,
64 const uno::Sequence
< uno::Reference
< uno::XInterface
> >& sListeners
)
65 : m_pMyShell( pMyShell
),
66 m_xCreatorContent( xCreatorContent
),
67 m_xCreatorId( xCreatorId
),
69 m_sListeners( sListeners
)
75 void ContentEventNotifier::notifyChildInserted( const rtl::OUString
& aChildName
)
77 FileContentIdentifier
* p
= new FileContentIdentifier( m_pMyShell
,aChildName
);
78 uno::Reference
< XContentIdentifier
> xChildId( p
);
80 uno::Reference
< XContent
> xChildContent
= m_pMyShell
->m_pProvider
->queryContent( xChildId
);
82 ContentEvent
aEvt( m_xCreatorContent
,
83 ContentAction::INSERTED
,
87 for( sal_Int32 i
= 0; i
< m_sListeners
.getLength(); ++i
)
89 uno::Reference
< XContentEventListener
> ref( m_sListeners
[i
],uno::UNO_QUERY
);
91 ref
->contentEvent( aEvt
);
95 void ContentEventNotifier::notifyDeleted( void )
98 ContentEvent
aEvt( m_xCreatorContent
,
99 ContentAction::DELETED
,
104 for( sal_Int32 i
= 0; i
< m_sListeners
.getLength(); ++i
)
106 uno::Reference
< XContentEventListener
> ref( m_sListeners
[i
],uno::UNO_QUERY
);
108 ref
->contentEvent( aEvt
);
114 void ContentEventNotifier::notifyRemoved( const rtl::OUString
& aChildName
)
116 FileContentIdentifier
* p
= new FileContentIdentifier( m_pMyShell
,aChildName
);
117 uno::Reference
< XContentIdentifier
> xChildId( p
);
119 BaseContent
* pp
= new BaseContent( m_pMyShell
,xChildId
,aChildName
);
121 osl::MutexGuard
aGuard( pp
->m_aMutex
);
122 pp
->m_nState
|= BaseContent::Deleted
;
125 uno::Reference
< XContent
> xDeletedContent( pp
);
128 ContentEvent
aEvt( m_xCreatorContent
,
129 ContentAction::REMOVED
,
133 for( sal_Int32 i
= 0; i
< m_sListeners
.getLength(); ++i
)
135 uno::Reference
< XContentEventListener
> ref( m_sListeners
[i
],uno::UNO_QUERY
);
137 ref
->contentEvent( aEvt
);
141 void ContentEventNotifier::notifyExchanged()
143 ContentEvent
aEvt( m_xCreatorContent
,
144 ContentAction::EXCHANGED
,
148 for( sal_Int32 i
= 0; i
< m_sListeners
.getLength(); ++i
)
150 uno::Reference
< XContentEventListener
> ref( m_sListeners
[i
],uno::UNO_QUERY
);
152 ref
->contentEvent( aEvt
);
156 /*********************************************************************************/
158 /* PropertySetInfoChangeNotifier */
160 /*********************************************************************************/
163 PropertySetInfoChangeNotifier::PropertySetInfoChangeNotifier(
165 const uno::Reference
< XContent
>& xCreatorContent
,
166 const uno::Reference
< XContentIdentifier
>& xCreatorId
,
167 const uno::Sequence
< uno::Reference
< uno::XInterface
> >& sListeners
)
168 : m_pMyShell( pMyShell
),
169 m_xCreatorContent( xCreatorContent
),
170 m_xCreatorId( xCreatorId
),
171 m_sListeners( sListeners
)
178 PropertySetInfoChangeNotifier::notifyPropertyAdded( const rtl::OUString
& aPropertyName
)
180 beans::PropertySetInfoChangeEvent
aEvt( m_xCreatorContent
,
183 beans::PropertySetInfoChange::PROPERTY_INSERTED
);
185 for( sal_Int32 i
= 0; i
< m_sListeners
.getLength(); ++i
)
187 uno::Reference
< beans::XPropertySetInfoChangeListener
> ref( m_sListeners
[i
],uno::UNO_QUERY
);
189 ref
->propertySetInfoChange( aEvt
);
195 PropertySetInfoChangeNotifier::notifyPropertyRemoved( const rtl::OUString
& aPropertyName
)
197 beans::PropertySetInfoChangeEvent
aEvt( m_xCreatorContent
,
200 beans::PropertySetInfoChange::PROPERTY_REMOVED
);
202 for( sal_Int32 i
= 0; i
< m_sListeners
.getLength(); ++i
)
204 uno::Reference
< beans::XPropertySetInfoChangeListener
> ref( m_sListeners
[i
],uno::UNO_QUERY
);
206 ref
->propertySetInfoChange( aEvt
);
211 /*********************************************************************************/
213 /* PropertySetInfoChangeNotifier */
215 /*********************************************************************************/
218 PropertyChangeNotifier::PropertyChangeNotifier(
220 const com::sun::star::uno::Reference
< XContent
>& xCreatorContent
,
221 const com::sun::star::uno::Reference
< com::sun::star::ucb::XContentIdentifier
>& xCreatorId
,
222 ListenerMap
* pListeners
)
223 : m_pMyShell( pMyShell
),
224 m_xCreatorContent( xCreatorContent
),
225 m_xCreatorId( xCreatorId
),
226 m_pListeners( pListeners
)
231 PropertyChangeNotifier::~PropertyChangeNotifier()
237 void PropertyChangeNotifier::notifyPropertyChanged(
238 uno::Sequence
< beans::PropertyChangeEvent
> Changes
)
242 for( j
= 0; j
< Changes
.getLength(); ++j
)
243 Changes
[j
].Source
= m_xCreatorContent
;
245 // notify listeners for all Events
247 uno::Sequence
< uno::Reference
< uno::XInterface
> > seqList
= (*m_pListeners
)[ rtl::OUString() ];
248 for( j
= 0; j
< seqList
.getLength(); ++j
)
250 uno::Reference
< beans::XPropertiesChangeListener
> aListener( seqList
[j
],uno::UNO_QUERY
);
253 aListener
->propertiesChange( Changes
);
257 uno::Sequence
< beans::PropertyChangeEvent
> seq(1);
258 for( j
= 0; j
< Changes
.getLength(); ++j
)
261 seqList
= (*m_pListeners
)[ seq
[0].PropertyName
];
263 for( sal_Int32 i
= 0; i
< seqList
.getLength(); ++i
)
265 uno::Reference
< beans::XPropertiesChangeListener
> aListener( seqList
[j
],uno::UNO_QUERY
);
268 aListener
->propertiesChange( seq
);