xref: /AOO41X/main/dbaccess/source/core/dataaccess/definitioncontainer.cxx (revision 96de54900b79e13b861fbc62cbf36018b54e21b7)
1*96de5490SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*96de5490SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*96de5490SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*96de5490SAndrew Rist  * distributed with this work for additional information
6*96de5490SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*96de5490SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*96de5490SAndrew Rist  * "License"); you may not use this file except in compliance
9*96de5490SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*96de5490SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*96de5490SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*96de5490SAndrew Rist  * software distributed under the License is distributed on an
15*96de5490SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*96de5490SAndrew Rist  * KIND, either express or implied.  See the License for the
17*96de5490SAndrew Rist  * specific language governing permissions and limitations
18*96de5490SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*96de5490SAndrew Rist  *************************************************************/
21*96de5490SAndrew Rist 
22*96de5490SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef _DBA_CORE_DEFINITIONCONTAINER_HXX_
28cdf0e10cSrcweir #include "definitioncontainer.hxx"
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
31cdf0e10cSrcweir #include "dbastrings.hrc"
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef _DBASHARED_APITOOLS_HXX_
34cdf0e10cSrcweir #include "apitools.hxx"
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #ifndef _DBA_CORE_RESOURCE_HXX_
37cdf0e10cSrcweir #include "core_resource.hxx"
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #ifndef _DBA_CORE_RESOURCE_HRC_
40cdf0e10cSrcweir #include "core_resource.hrc"
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX
44cdf0e10cSrcweir #include <tools/debug.hxx>
45cdf0e10cSrcweir #endif
46cdf0e10cSrcweir #ifndef TOOLS_DIAGNOSE_EX_H
47cdf0e10cSrcweir #include <tools/diagnose_ex.h>
48cdf0e10cSrcweir #endif
49cdf0e10cSrcweir #ifndef _COMPHELPER_SEQUENCE_HXX_
50cdf0e10cSrcweir #include <comphelper/sequence.hxx>
51cdf0e10cSrcweir #endif
52cdf0e10cSrcweir #ifndef _COMPHELPER_ENUMHELPER_HXX_
53cdf0e10cSrcweir #include <comphelper/enumhelper.hxx>
54cdf0e10cSrcweir #endif
55cdf0e10cSrcweir #ifndef _COMPHELPER_EXTRACT_HXX_
56cdf0e10cSrcweir #include <comphelper/extract.hxx>
57cdf0e10cSrcweir #endif
58cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
59cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
60cdf0e10cSrcweir #endif
61cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UCB_COMMANDINFO_HPP_
62cdf0e10cSrcweir #include <com/sun/star/ucb/CommandInfo.hpp>
63cdf0e10cSrcweir #endif
64cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
65cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
66cdf0e10cSrcweir #endif
67cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_ERRORCONDITION_HPP_
68cdf0e10cSrcweir #include <com/sun/star/sdb/ErrorCondition.hpp>
69cdf0e10cSrcweir #endif
70cdf0e10cSrcweir #ifndef _COMPHELPER_TYPES_HXX_
71cdf0e10cSrcweir #include <comphelper/types.hxx>
72cdf0e10cSrcweir #endif
73cdf0e10cSrcweir #ifndef _UCBHELPER_CONTENTIDENTIFIER_HXX
74cdf0e10cSrcweir #include <ucbhelper/contentidentifier.hxx>
75cdf0e10cSrcweir #endif
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 
78cdf0e10cSrcweir using namespace ::com::sun::star::uno;
79cdf0e10cSrcweir using namespace ::com::sun::star::lang;
80cdf0e10cSrcweir using namespace ::com::sun::star::util;
81cdf0e10cSrcweir using namespace ::com::sun::star::beans;
82cdf0e10cSrcweir using namespace ::com::sun::star::container;
83cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx;
84cdf0e10cSrcweir using namespace ::com::sun::star::sdb;
85cdf0e10cSrcweir using namespace ::osl;
86cdf0e10cSrcweir using namespace ::comphelper;
87cdf0e10cSrcweir using namespace ::cppu;
88cdf0e10cSrcweir using namespace ::com::sun::star::ucb;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir //........................................................................
91cdf0e10cSrcweir namespace dbaccess
92cdf0e10cSrcweir {
93cdf0e10cSrcweir //........................................................................
94cdf0e10cSrcweir 
95cdf0e10cSrcweir //==========================================================================
96cdf0e10cSrcweir //= ODefinitionContainer_Impl
97cdf0e10cSrcweir //==========================================================================
98cdf0e10cSrcweir //--------------------------------------------------------------------------
erase(TContentPtr _pDefinition)99cdf0e10cSrcweir void ODefinitionContainer_Impl::erase( TContentPtr _pDefinition )
100cdf0e10cSrcweir {
101cdf0e10cSrcweir     NamedDefinitions::iterator aPos = find( _pDefinition );
102cdf0e10cSrcweir 	if ( aPos != end() )
103cdf0e10cSrcweir 		m_aDefinitions.erase( aPos );
104cdf0e10cSrcweir }
105cdf0e10cSrcweir 
106cdf0e10cSrcweir //--------------------------------------------------------------------------
find(TContentPtr _pDefinition) const107cdf0e10cSrcweir ODefinitionContainer_Impl::const_iterator ODefinitionContainer_Impl::find( TContentPtr _pDefinition ) const
108cdf0e10cSrcweir {
109cdf0e10cSrcweir 	return ::std::find_if(
110cdf0e10cSrcweir         m_aDefinitions.begin(),
111cdf0e10cSrcweir         m_aDefinitions.end(),
112cdf0e10cSrcweir         ::std::compose1(
113cdf0e10cSrcweir 			::std::bind2nd( ::std::equal_to< TContentPtr >(), _pDefinition ),
114cdf0e10cSrcweir             ::std::select2nd< NamedDefinitions::value_type >()
115cdf0e10cSrcweir         )
116cdf0e10cSrcweir     );
117cdf0e10cSrcweir }
118cdf0e10cSrcweir 
119cdf0e10cSrcweir //--------------------------------------------------------------------------
find(TContentPtr _pDefinition)120cdf0e10cSrcweir ODefinitionContainer_Impl::iterator ODefinitionContainer_Impl::find( TContentPtr _pDefinition )
121cdf0e10cSrcweir {
122cdf0e10cSrcweir 	return ::std::find_if(
123cdf0e10cSrcweir         m_aDefinitions.begin(),
124cdf0e10cSrcweir         m_aDefinitions.end(),
125cdf0e10cSrcweir         ::std::compose1(
126cdf0e10cSrcweir 			::std::bind2nd( ::std::equal_to< TContentPtr >(), _pDefinition ),
127cdf0e10cSrcweir             ::std::select2nd< NamedDefinitions::value_type >()
128cdf0e10cSrcweir         )
129cdf0e10cSrcweir     );
130cdf0e10cSrcweir }
131cdf0e10cSrcweir 
132cdf0e10cSrcweir //==========================================================================
133cdf0e10cSrcweir //= ODefinitionContainer
134cdf0e10cSrcweir //==========================================================================
DBG_NAME(ODefinitionContainer)135cdf0e10cSrcweir DBG_NAME(ODefinitionContainer)
136cdf0e10cSrcweir //--------------------------------------------------------------------------
137cdf0e10cSrcweir ODefinitionContainer::ODefinitionContainer(   const Reference< XMultiServiceFactory >& _xORB
138cdf0e10cSrcweir 											, const Reference< XInterface >&	_xParentContainer
139cdf0e10cSrcweir 											, const TContentPtr& _pImpl
140cdf0e10cSrcweir                                             , bool _bCheckSlash
141cdf0e10cSrcweir 											)
142cdf0e10cSrcweir 	:OContentHelper(_xORB,_xParentContainer,_pImpl)
143cdf0e10cSrcweir     ,m_aApproveListeners(m_aMutex)
144cdf0e10cSrcweir 	,m_aContainerListeners(m_aMutex)
145cdf0e10cSrcweir 	,m_bInPropertyChange(sal_False)
146cdf0e10cSrcweir     ,m_bCheckSlash(_bCheckSlash)
147cdf0e10cSrcweir {
148cdf0e10cSrcweir 	m_pImpl->m_aProps.bIsDocument = sal_False;
149cdf0e10cSrcweir 	m_pImpl->m_aProps.bIsFolder = sal_True;
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 	const ODefinitionContainer_Impl& rDefinitions( getDefinitions() );
152cdf0e10cSrcweir 	ODefinitionContainer_Impl::const_iterator aEnd = rDefinitions.end();
153cdf0e10cSrcweir 	for	(	ODefinitionContainer_Impl::const_iterator aDefinition = rDefinitions.begin();
154cdf0e10cSrcweir 			aDefinition != aEnd;
155cdf0e10cSrcweir 			++aDefinition
156cdf0e10cSrcweir 		)
157cdf0e10cSrcweir 		m_aDocuments.push_back(
158cdf0e10cSrcweir             m_aDocumentMap.insert(
159cdf0e10cSrcweir                 Documents::value_type( aDefinition->first, Documents::mapped_type() ) ).first );
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 	DBG_CTOR(ODefinitionContainer, NULL);
162cdf0e10cSrcweir }
163cdf0e10cSrcweir 
164cdf0e10cSrcweir //--------------------------------------------------------------------------
disposing()165cdf0e10cSrcweir void SAL_CALL ODefinitionContainer::disposing()
166cdf0e10cSrcweir {
167cdf0e10cSrcweir 	OContentHelper::disposing();
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 	// say our listeners goobye
172cdf0e10cSrcweir 	EventObject aEvt(*this);
173cdf0e10cSrcweir 	m_aApproveListeners.disposeAndClear(aEvt);
174cdf0e10cSrcweir 	m_aContainerListeners.disposeAndClear(aEvt);
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 	// dispose our elements
177cdf0e10cSrcweir 	Documents::iterator aIter = m_aDocumentMap.begin();
178cdf0e10cSrcweir 	Documents::iterator aEnd = m_aDocumentMap.end();
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 	for	(; aIter != aEnd; ++aIter)
181cdf0e10cSrcweir 	{
182cdf0e10cSrcweir 		Reference<XContent> xProp = aIter->second;
183cdf0e10cSrcweir 		if ( xProp.is() )
184cdf0e10cSrcweir 		{
185cdf0e10cSrcweir 			removeObjectListener(xProp);
186cdf0e10cSrcweir 			::comphelper::disposeComponent(xProp);
187cdf0e10cSrcweir 		}
188cdf0e10cSrcweir 	}
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 	// remove our elements
191cdf0e10cSrcweir 	m_aDocuments.clear();
192cdf0e10cSrcweir 	//  !!! do this before clearing the map which the vector elements refer to !!!
193cdf0e10cSrcweir 	m_aDocumentMap.clear();
194cdf0e10cSrcweir }
195cdf0e10cSrcweir 
196cdf0e10cSrcweir //--------------------------------------------------------------------------
~ODefinitionContainer()197cdf0e10cSrcweir ODefinitionContainer::~ODefinitionContainer()
198cdf0e10cSrcweir {
199cdf0e10cSrcweir 	DBG_DTOR(ODefinitionContainer, NULL);
200cdf0e10cSrcweir }
201cdf0e10cSrcweir 
202cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( ODefinitionContainer,OContentHelper,ODefinitionContainer_Base)
203cdf0e10cSrcweir IMPLEMENT_TYPEPROVIDER2(ODefinitionContainer,OContentHelper,ODefinitionContainer_Base);
204cdf0e10cSrcweir // XServiceInfo
205cdf0e10cSrcweir //--------------------------------------------------------------------------
getImplementationName()206cdf0e10cSrcweir ::rtl::OUString SAL_CALL ODefinitionContainer::getImplementationName(  ) throw(RuntimeException)
207cdf0e10cSrcweir {
208cdf0e10cSrcweir 	return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.ODefinitionContainer"));
209cdf0e10cSrcweir }
210cdf0e10cSrcweir //--------------------------------------------------------------------------
getSupportedServiceNames()211cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL ODefinitionContainer::getSupportedServiceNames(  ) throw(RuntimeException)
212cdf0e10cSrcweir {
213cdf0e10cSrcweir 	Sequence< ::rtl::OUString > aReturn(2);
214cdf0e10cSrcweir 	aReturn.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DefinitionContainer"));
215cdf0e10cSrcweir 	aReturn.getArray()[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.Content"));
216cdf0e10cSrcweir 	return aReturn;
217cdf0e10cSrcweir }
218cdf0e10cSrcweir 
219cdf0e10cSrcweir // XNameContainer
220cdf0e10cSrcweir //--------------------------------------------------------------------------
insertByName(const::rtl::OUString & _rName,const Any & aElement)221cdf0e10cSrcweir void SAL_CALL ODefinitionContainer::insertByName( const ::rtl::OUString& _rName, const Any& aElement ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
222cdf0e10cSrcweir {
223cdf0e10cSrcweir 	ResettableMutexGuard aGuard(m_aMutex);
224cdf0e10cSrcweir 
225cdf0e10cSrcweir 	// approve the new object
226cdf0e10cSrcweir 	Reference< XContent > xNewElement(aElement,UNO_QUERY);
227cdf0e10cSrcweir 	approveNewObject( _rName, xNewElement );  // will throw if necessary
228cdf0e10cSrcweir 
229cdf0e10cSrcweir     notifyByName( aGuard, _rName, xNewElement, NULL, E_INSERTED, ApproveListeners );
230cdf0e10cSrcweir 	implAppend( _rName, xNewElement );
231cdf0e10cSrcweir 	notifyByName( aGuard, _rName, xNewElement, NULL, E_INSERTED, ContainerListemers );
232cdf0e10cSrcweir }
233cdf0e10cSrcweir 
234cdf0e10cSrcweir //--------------------------------------------------------------------------
removeByName(const::rtl::OUString & _rName)235cdf0e10cSrcweir void SAL_CALL ODefinitionContainer::removeByName( const ::rtl::OUString& _rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
236cdf0e10cSrcweir {
237cdf0e10cSrcweir 	ResettableMutexGuard aGuard(m_aMutex);
238cdf0e10cSrcweir 
239cdf0e10cSrcweir     // check the arguments
240cdf0e10cSrcweir 	if (!_rName.getLength())
241cdf0e10cSrcweir 		throw IllegalArgumentException();
242cdf0e10cSrcweir 
243cdf0e10cSrcweir 	if (!checkExistence(_rName))
244cdf0e10cSrcweir 		throw NoSuchElementException(_rName,*this);
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 	// the old element (for the notifications)
247cdf0e10cSrcweir 	Reference< XContent > xOldElement = implGetByName( _rName, impl_haveAnyListeners_nothrow() );
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 	// do the removal
250cdf0e10cSrcweir     notifyByName( aGuard, _rName, NULL, xOldElement, E_REMOVED, ApproveListeners );
251cdf0e10cSrcweir 	implRemove( _rName );
252cdf0e10cSrcweir     notifyByName( aGuard, _rName, NULL, xOldElement, E_REMOVED, ContainerListemers );
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 	removeObjectListener( xOldElement );
255cdf0e10cSrcweir     disposeComponent(xOldElement);
256cdf0e10cSrcweir }
257cdf0e10cSrcweir 
258cdf0e10cSrcweir // XNameReplace
259cdf0e10cSrcweir //--------------------------------------------------------------------------
replaceByName(const::rtl::OUString & _rName,const Any & aElement)260cdf0e10cSrcweir void SAL_CALL ODefinitionContainer::replaceByName( const ::rtl::OUString& _rName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
261cdf0e10cSrcweir {
262cdf0e10cSrcweir 	ResettableMutexGuard aGuard(m_aMutex);
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 	// let derived classes approve the new object
265cdf0e10cSrcweir 	Reference< XContent > xNewElement(aElement,UNO_QUERY);
266cdf0e10cSrcweir 	approveNewObject( _rName, xNewElement );    // will throw if necessary
267cdf0e10cSrcweir 
268cdf0e10cSrcweir 	// the old element (for the notifications)
269cdf0e10cSrcweir 	Reference< XContent > xOldElement = implGetByName( _rName, impl_haveAnyListeners_nothrow() );
270cdf0e10cSrcweir 
271cdf0e10cSrcweir 	notifyByName( aGuard, _rName, xNewElement, xOldElement, E_REPLACED, ApproveListeners );
272cdf0e10cSrcweir     implReplace( _rName, xNewElement );
273cdf0e10cSrcweir 	notifyByName( aGuard, _rName, xNewElement, xOldElement, E_REPLACED, ContainerListemers );
274cdf0e10cSrcweir 
275cdf0e10cSrcweir 	// and dispose it
276cdf0e10cSrcweir     disposeComponent(xOldElement);
277cdf0e10cSrcweir }
278cdf0e10cSrcweir 
279cdf0e10cSrcweir // -----------------------------------------------------------------------------
280cdf0e10cSrcweir namespace
281cdf0e10cSrcweir {
282cdf0e10cSrcweir     typedef Reference< XVeto > ( SAL_CALL XContainerApproveListener::*ContainerApprovalMethod )( const ContainerEvent& );
283cdf0e10cSrcweir 
284cdf0e10cSrcweir     struct RaiseExceptionFromVeto
285cdf0e10cSrcweir     {
286cdf0e10cSrcweir     private:
287cdf0e10cSrcweir         ContainerApprovalMethod m_pMethod;
288cdf0e10cSrcweir         const ContainerEvent&   m_rEvent;
289cdf0e10cSrcweir 
290cdf0e10cSrcweir     public:
RaiseExceptionFromVetodbaccess::__anon2f1e9e650111::RaiseExceptionFromVeto291cdf0e10cSrcweir         RaiseExceptionFromVeto( ContainerApprovalMethod _pMethod, const ContainerEvent& _rEvent )
292cdf0e10cSrcweir             :m_pMethod( _pMethod )
293cdf0e10cSrcweir             ,m_rEvent( _rEvent )
294cdf0e10cSrcweir         {
295cdf0e10cSrcweir         }
296cdf0e10cSrcweir 
operator ()dbaccess::__anon2f1e9e650111::RaiseExceptionFromVeto297cdf0e10cSrcweir         void operator()( const Reference< XContainerApproveListener >& _Listener ) const
298cdf0e10cSrcweir         {
299cdf0e10cSrcweir             Reference< XVeto > xVeto = (_Listener.get()->*m_pMethod)( m_rEvent );
300cdf0e10cSrcweir             if ( !xVeto.is() )
301cdf0e10cSrcweir                 return;
302cdf0e10cSrcweir 
303cdf0e10cSrcweir             Any eVetoDetails = xVeto->getDetails();
304cdf0e10cSrcweir 
305cdf0e10cSrcweir             IllegalArgumentException aIllegalArgumentError;
306cdf0e10cSrcweir             if ( eVetoDetails >>= aIllegalArgumentError )
307cdf0e10cSrcweir                 throw aIllegalArgumentError;
308cdf0e10cSrcweir 
309cdf0e10cSrcweir             WrappedTargetException aWrappedError;
310cdf0e10cSrcweir             if ( eVetoDetails >>= aWrappedError )
311cdf0e10cSrcweir                 throw aWrappedError;
312cdf0e10cSrcweir 
313cdf0e10cSrcweir             throw WrappedTargetException( xVeto->getReason(), _Listener.get(), eVetoDetails );
314cdf0e10cSrcweir         }
315cdf0e10cSrcweir     };
316cdf0e10cSrcweir }
317cdf0e10cSrcweir 
318cdf0e10cSrcweir // -----------------------------------------------------------------------------
notifyByName(ResettableMutexGuard & _rGuard,const::rtl::OUString & _rName,const Reference<XContent> & _xNewElement,const Reference<XContent> & _xOldElement,ContainerOperation _eOperation,ListenerType _eType)319cdf0e10cSrcweir void ODefinitionContainer::notifyByName( ResettableMutexGuard& _rGuard, const ::rtl::OUString& _rName,
320cdf0e10cSrcweir         const Reference< XContent >& _xNewElement, const Reference< XContent >& _xOldElement,
321cdf0e10cSrcweir         ContainerOperation _eOperation, ListenerType _eType )
322cdf0e10cSrcweir {
323cdf0e10cSrcweir     bool bApprove = ( _eType == ApproveListeners );
324cdf0e10cSrcweir 
325cdf0e10cSrcweir     ::cppu::OInterfaceContainerHelper& rContainer( bApprove ? m_aApproveListeners : m_aContainerListeners );
326cdf0e10cSrcweir 	if ( !rContainer.getLength() )
327cdf0e10cSrcweir         return;
328cdf0e10cSrcweir 
329cdf0e10cSrcweir     ContainerEvent aEvent( *this, makeAny( _rName ), makeAny( _xNewElement ), makeAny( _xOldElement ) );
330cdf0e10cSrcweir 
331cdf0e10cSrcweir     _rGuard.clear();
332cdf0e10cSrcweir 	switch ( _eOperation )
333cdf0e10cSrcweir 	{
334cdf0e10cSrcweir 		case E_INSERTED:
335cdf0e10cSrcweir             if ( bApprove )
336cdf0e10cSrcweir                 rContainer.forEach< XContainerApproveListener, RaiseExceptionFromVeto >(
337cdf0e10cSrcweir                     RaiseExceptionFromVeto( &XContainerApproveListener::approveInsertElement, aEvent ) );
338cdf0e10cSrcweir             else
339cdf0e10cSrcweir                 rContainer.notifyEach( &XContainerListener::elementInserted, aEvent );
340cdf0e10cSrcweir 			break;
341cdf0e10cSrcweir 		case E_REPLACED:
342cdf0e10cSrcweir             if ( bApprove )
343cdf0e10cSrcweir                 rContainer.forEach< XContainerApproveListener, RaiseExceptionFromVeto >(
344cdf0e10cSrcweir                     RaiseExceptionFromVeto( &XContainerApproveListener::approveReplaceElement, aEvent ) );
345cdf0e10cSrcweir             else
346cdf0e10cSrcweir                 rContainer.notifyEach( &XContainerListener::elementReplaced, aEvent );
347cdf0e10cSrcweir 			break;
348cdf0e10cSrcweir 		case E_REMOVED:
349cdf0e10cSrcweir             if ( bApprove )
350cdf0e10cSrcweir                 rContainer.forEach< XContainerApproveListener, RaiseExceptionFromVeto >(
351cdf0e10cSrcweir                     RaiseExceptionFromVeto( &XContainerApproveListener::approveRemoveElement, aEvent ) );
352cdf0e10cSrcweir             else
353cdf0e10cSrcweir                 rContainer.notifyEach( &XContainerListener::elementRemoved, aEvent );
354cdf0e10cSrcweir 			break;
355cdf0e10cSrcweir 	}
356cdf0e10cSrcweir 
357cdf0e10cSrcweir     if ( bApprove )
358cdf0e10cSrcweir         _rGuard.reset();
359cdf0e10cSrcweir }
360cdf0e10cSrcweir 
361cdf0e10cSrcweir //--------------------------------------------------------------------------
addContainerListener(const Reference<XContainerListener> & _rxListener)362cdf0e10cSrcweir void SAL_CALL ODefinitionContainer::addContainerListener( const Reference< XContainerListener >& _rxListener ) throw(RuntimeException)
363cdf0e10cSrcweir {
364cdf0e10cSrcweir 	if (_rxListener.is())
365cdf0e10cSrcweir 		m_aContainerListeners.addInterface(_rxListener);
366cdf0e10cSrcweir }
367cdf0e10cSrcweir 
368cdf0e10cSrcweir //--------------------------------------------------------------------------
removeContainerListener(const Reference<XContainerListener> & _rxListener)369cdf0e10cSrcweir void SAL_CALL ODefinitionContainer::removeContainerListener( const Reference< XContainerListener >& _rxListener ) throw(RuntimeException)
370cdf0e10cSrcweir {
371cdf0e10cSrcweir 	if (_rxListener.is())
372cdf0e10cSrcweir 		m_aContainerListeners.removeInterface(_rxListener);
373cdf0e10cSrcweir }
374cdf0e10cSrcweir 
375cdf0e10cSrcweir //--------------------------------------------------------------------------
addContainerApproveListener(const Reference<XContainerApproveListener> & _Listener)376cdf0e10cSrcweir void SAL_CALL ODefinitionContainer::addContainerApproveListener( const Reference< XContainerApproveListener >& _Listener ) throw (RuntimeException)
377cdf0e10cSrcweir {
378cdf0e10cSrcweir     if ( _Listener.is() )
379cdf0e10cSrcweir         m_aApproveListeners.addInterface( _Listener );
380cdf0e10cSrcweir }
381cdf0e10cSrcweir 
382cdf0e10cSrcweir //--------------------------------------------------------------------------
removeContainerApproveListener(const Reference<XContainerApproveListener> & _Listener)383cdf0e10cSrcweir void SAL_CALL ODefinitionContainer::removeContainerApproveListener( const Reference< XContainerApproveListener >& _Listener ) throw (RuntimeException)
384cdf0e10cSrcweir {
385cdf0e10cSrcweir     if ( _Listener.is() )
386cdf0e10cSrcweir         m_aApproveListeners.removeInterface( _Listener );
387cdf0e10cSrcweir }
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 
390cdf0e10cSrcweir // XElementAccess
391cdf0e10cSrcweir //--------------------------------------------------------------------------
getElementType()392cdf0e10cSrcweir Type SAL_CALL ODefinitionContainer::getElementType( ) throw (RuntimeException)
393cdf0e10cSrcweir {
394cdf0e10cSrcweir 	return ::getCppuType( static_cast< Reference< XContent >* >(NULL) );
395cdf0e10cSrcweir }
396cdf0e10cSrcweir 
397cdf0e10cSrcweir //--------------------------------------------------------------------------
hasElements()398cdf0e10cSrcweir sal_Bool SAL_CALL ODefinitionContainer::hasElements( ) throw (RuntimeException)
399cdf0e10cSrcweir {
400cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
401cdf0e10cSrcweir 	return !m_aDocuments.empty();
402cdf0e10cSrcweir }
403cdf0e10cSrcweir 
404cdf0e10cSrcweir // XEnumerationAccess
405cdf0e10cSrcweir //--------------------------------------------------------------------------
createEnumeration()406cdf0e10cSrcweir Reference< XEnumeration > SAL_CALL ODefinitionContainer::createEnumeration(  ) throw(RuntimeException)
407cdf0e10cSrcweir {
408cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
409cdf0e10cSrcweir 	return new ::comphelper::OEnumerationByIndex(static_cast<XIndexAccess*>(this));
410cdf0e10cSrcweir }
411cdf0e10cSrcweir 
412cdf0e10cSrcweir //--------------------------------------------------------------------------
413cdf0e10cSrcweir // XIndexAccess
getCount()414cdf0e10cSrcweir sal_Int32 SAL_CALL ODefinitionContainer::getCount(  ) throw(RuntimeException)
415cdf0e10cSrcweir {
416cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
417cdf0e10cSrcweir 	return m_aDocuments.size();
418cdf0e10cSrcweir }
419cdf0e10cSrcweir 
420cdf0e10cSrcweir //--------------------------------------------------------------------------
getByIndex(sal_Int32 _nIndex)421cdf0e10cSrcweir Any SAL_CALL ODefinitionContainer::getByIndex( sal_Int32 _nIndex ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
422cdf0e10cSrcweir {
423cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
424cdf0e10cSrcweir 
425cdf0e10cSrcweir 	if ((_nIndex < 0) || (_nIndex >= (sal_Int32)m_aDocuments.size()))
426cdf0e10cSrcweir 		throw IndexOutOfBoundsException();
427cdf0e10cSrcweir 
428cdf0e10cSrcweir 	Documents::iterator aPos = m_aDocuments[_nIndex];
429cdf0e10cSrcweir 	Reference<XContent> xProp = aPos->second;
430cdf0e10cSrcweir 	if (!xProp.is())
431cdf0e10cSrcweir 	{	// that's the first access to the object
432cdf0e10cSrcweir 		// -> create it
433cdf0e10cSrcweir 		xProp = createObject(aPos->first);
434cdf0e10cSrcweir 		aPos->second = Documents::mapped_type();
435cdf0e10cSrcweir 		// and update the name-access map
436cdf0e10cSrcweir 	}
437cdf0e10cSrcweir 
438cdf0e10cSrcweir 	return makeAny(xProp);
439cdf0e10cSrcweir }
440cdf0e10cSrcweir 
441cdf0e10cSrcweir //--------------------------------------------------------------------------
getByName(const::rtl::OUString & _rName)442cdf0e10cSrcweir Any SAL_CALL ODefinitionContainer::getByName( const ::rtl::OUString& _rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
443cdf0e10cSrcweir {
444cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
445cdf0e10cSrcweir 
446cdf0e10cSrcweir 	return makeAny( implGetByName( _rName, sal_True ) );
447cdf0e10cSrcweir }
448cdf0e10cSrcweir 
449cdf0e10cSrcweir //--------------------------------------------------------------------------
implGetByName(const::rtl::OUString & _rName,sal_Bool _bReadIfNeccessary)450cdf0e10cSrcweir Reference< XContent > ODefinitionContainer::implGetByName(const ::rtl::OUString& _rName, sal_Bool _bReadIfNeccessary) throw (NoSuchElementException)
451cdf0e10cSrcweir {
452cdf0e10cSrcweir 	Documents::iterator aMapPos = m_aDocumentMap.find(_rName);
453cdf0e10cSrcweir 	if (aMapPos == m_aDocumentMap.end())
454cdf0e10cSrcweir 		throw NoSuchElementException(_rName,*this);
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 	Reference< XContent > xProp = aMapPos->second;
457cdf0e10cSrcweir 
458cdf0e10cSrcweir 	if (_bReadIfNeccessary && !xProp.is())
459cdf0e10cSrcweir 	{	// the object has never been accessed before, so we have to read it now
460cdf0e10cSrcweir 		// (that's the expensive part)
461cdf0e10cSrcweir 
462cdf0e10cSrcweir 		// create the object and insert it into the map
463cdf0e10cSrcweir 		xProp = createObject(_rName);
464cdf0e10cSrcweir 		aMapPos->second = xProp;
465cdf0e10cSrcweir 		addObjectListener(xProp);
466cdf0e10cSrcweir 	}
467cdf0e10cSrcweir 
468cdf0e10cSrcweir 	return xProp;
469cdf0e10cSrcweir }
470cdf0e10cSrcweir 
471cdf0e10cSrcweir //--------------------------------------------------------------------------
getElementNames()472cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL ODefinitionContainer::getElementNames(  ) throw(RuntimeException)
473cdf0e10cSrcweir {
474cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
475cdf0e10cSrcweir 
476cdf0e10cSrcweir 	Sequence< ::rtl::OUString > aNames(m_aDocumentMap.size());
477cdf0e10cSrcweir 	::rtl::OUString* pNames = aNames.getArray();
478cdf0e10cSrcweir 	Documents::iterator aEnd = m_aDocumentMap.end();
479cdf0e10cSrcweir 	for	(	Documents::iterator aNameIter = m_aDocumentMap.begin();
480cdf0e10cSrcweir 			aNameIter != aEnd;
481cdf0e10cSrcweir 			++pNames, ++aNameIter
482cdf0e10cSrcweir 		)
483cdf0e10cSrcweir 	{
484cdf0e10cSrcweir 		*pNames = aNameIter->first;
485cdf0e10cSrcweir 	}
486cdf0e10cSrcweir 
487cdf0e10cSrcweir 	return aNames;
488cdf0e10cSrcweir }
489cdf0e10cSrcweir 
490cdf0e10cSrcweir //--------------------------------------------------------------------------
hasByName(const::rtl::OUString & _rName)491cdf0e10cSrcweir sal_Bool SAL_CALL ODefinitionContainer::hasByName( const ::rtl::OUString& _rName ) throw(RuntimeException)
492cdf0e10cSrcweir {
493cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
494cdf0e10cSrcweir 
495cdf0e10cSrcweir 	return checkExistence(_rName);
496cdf0e10cSrcweir }
497cdf0e10cSrcweir 
498cdf0e10cSrcweir //--------------------------------------------------------------------------
disposing(const EventObject & _rSource)499cdf0e10cSrcweir void SAL_CALL ODefinitionContainer::disposing( const EventObject& _rSource ) throw(RuntimeException)
500cdf0e10cSrcweir {
501cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
502cdf0e10cSrcweir 	Reference< XContent > xSource(_rSource.Source, UNO_QUERY);
503cdf0e10cSrcweir 	// it's one of our documents ....
504cdf0e10cSrcweir 	Documents::iterator aIter = m_aDocumentMap.begin();
505cdf0e10cSrcweir 	Documents::iterator aEnd = m_aDocumentMap.end();
506cdf0e10cSrcweir 	for	(;aIter != aEnd;++aIter )
507cdf0e10cSrcweir 	{
508cdf0e10cSrcweir 		if ( xSource == aIter->second.get() )
509cdf0e10cSrcweir 		{
510cdf0e10cSrcweir 			removeObjectListener(xSource);
511cdf0e10cSrcweir 			// and clear our document map/vector, so the object will be recreated on next access
512cdf0e10cSrcweir 			aIter->second = Documents::mapped_type();
513cdf0e10cSrcweir 		}
514cdf0e10cSrcweir 	}
515cdf0e10cSrcweir }
516cdf0e10cSrcweir 
517cdf0e10cSrcweir //--------------------------------------------------------------------------
implRemove(const::rtl::OUString & _rName)518cdf0e10cSrcweir void ODefinitionContainer::implRemove(const ::rtl::OUString& _rName)
519cdf0e10cSrcweir {
520cdf0e10cSrcweir 	// from the object maps
521cdf0e10cSrcweir 	Documents::iterator aFind = m_aDocumentMap.find(_rName);
522cdf0e10cSrcweir 	if ( aFind != m_aDocumentMap.end() )
523cdf0e10cSrcweir 	{
524cdf0e10cSrcweir 		m_aDocuments.erase( ::std::find(m_aDocuments.begin(),m_aDocuments.end(),aFind));
525cdf0e10cSrcweir 		m_aDocumentMap.erase(aFind);
526cdf0e10cSrcweir 
527cdf0e10cSrcweir 	    getDefinitions().erase( _rName );
528cdf0e10cSrcweir 
529cdf0e10cSrcweir 		notifyDataSourceModified();
530cdf0e10cSrcweir 	}
531cdf0e10cSrcweir }
532cdf0e10cSrcweir 
533cdf0e10cSrcweir //--------------------------------------------------------------------------
534cdf0e10cSrcweir namespace
535cdf0e10cSrcweir {
lcl_ensureName(const Reference<XContent> & _rxContent,const::rtl::OUString & _rName)536cdf0e10cSrcweir     bool    lcl_ensureName( const Reference< XContent >& _rxContent, const ::rtl::OUString& _rName )
537cdf0e10cSrcweir     {
538cdf0e10cSrcweir         if ( !_rxContent.is() )
539cdf0e10cSrcweir             return true;
540cdf0e10cSrcweir 
541cdf0e10cSrcweir         // ..........................................................
542cdf0e10cSrcweir         // obtain the current name. If it's the same as the new one,
543cdf0e10cSrcweir         // don't do anything
544cdf0e10cSrcweir         try
545cdf0e10cSrcweir         {
546cdf0e10cSrcweir             Reference< XPropertySet > xProps( _rxContent, UNO_QUERY );
547cdf0e10cSrcweir             if ( xProps.is() )
548cdf0e10cSrcweir             {
549cdf0e10cSrcweir                 ::rtl::OUString sCurrentName;
550cdf0e10cSrcweir                 OSL_VERIFY( xProps->getPropertyValue( PROPERTY_NAME ) >>= sCurrentName );
551cdf0e10cSrcweir                 if ( sCurrentName.equals( _rName ) )
552cdf0e10cSrcweir                     return true;
553cdf0e10cSrcweir             }
554cdf0e10cSrcweir         }
555cdf0e10cSrcweir         catch( const Exception& )
556cdf0e10cSrcweir         {
557cdf0e10cSrcweir         	OSL_ENSURE( sal_False, "lcl_ensureName: caught an exception while obtaining the current name!" );
558cdf0e10cSrcweir         }
559cdf0e10cSrcweir 
560cdf0e10cSrcweir         // ..........................................................
561cdf0e10cSrcweir         // set the new name
562cdf0e10cSrcweir         Reference< XRename > xRename( _rxContent, UNO_QUERY );
563cdf0e10cSrcweir         OSL_ENSURE( xRename.is(), "lcl_ensureName: invalid content (not renameable)!" );
564cdf0e10cSrcweir         if ( !xRename.is() )
565cdf0e10cSrcweir             return false;
566cdf0e10cSrcweir         try
567cdf0e10cSrcweir         {
568cdf0e10cSrcweir             xRename->rename( _rName );
569cdf0e10cSrcweir             return true;
570cdf0e10cSrcweir         }
571cdf0e10cSrcweir         catch( const Exception& )
572cdf0e10cSrcweir         {
573cdf0e10cSrcweir         	OSL_ENSURE( sal_False, "lcl_ensureName: caught an exception!" );
574cdf0e10cSrcweir         }
575cdf0e10cSrcweir         return false;
576cdf0e10cSrcweir     }
577cdf0e10cSrcweir }
578cdf0e10cSrcweir //--------------------------------------------------------------------------
implAppend(const::rtl::OUString & _rName,const Reference<XContent> & _rxNewObject)579cdf0e10cSrcweir void ODefinitionContainer::implAppend(const ::rtl::OUString& _rName, const Reference< XContent >& _rxNewObject)
580cdf0e10cSrcweir {
581cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
582cdf0e10cSrcweir 	try
583cdf0e10cSrcweir 	{
584cdf0e10cSrcweir 		Reference<XChild> xChild(_rxNewObject,UNO_QUERY);
585cdf0e10cSrcweir 		if ( xChild.is() )
586cdf0e10cSrcweir 			xChild->setParent(static_cast<OWeakObject*>(this));
587cdf0e10cSrcweir 
588cdf0e10cSrcweir 	    ODefinitionContainer_Impl& rDefinitions( getDefinitions() );
589cdf0e10cSrcweir 		ODefinitionContainer_Impl::const_iterator aFind = rDefinitions.find( _rName );
590cdf0e10cSrcweir 		if ( aFind == rDefinitions.end() )
591cdf0e10cSrcweir 		{
592cdf0e10cSrcweir             // ensure that the new object thas the proper name.
593cdf0e10cSrcweir             // Somebody could create an object with name "foo", and insert it as "bar"
594cdf0e10cSrcweir             // into a container. In this case, we need to ensure that the object name
595cdf0e10cSrcweir             // is also "bar"
596cdf0e10cSrcweir             // #i44786# / 2005-03-11 / frank.schoenheit@sun.com
597cdf0e10cSrcweir             lcl_ensureName( _rxNewObject, _rName );
598cdf0e10cSrcweir 
599cdf0e10cSrcweir 			::rtl::Reference< OContentHelper > pContent = OContentHelper::getImplementation( _rxNewObject );
600cdf0e10cSrcweir 			if ( pContent.is() )
601cdf0e10cSrcweir 			{
602cdf0e10cSrcweir 				TContentPtr pImpl = pContent->getImpl();
603cdf0e10cSrcweir                 rDefinitions.erase( pImpl );
604cdf0e10cSrcweir 				pImpl->m_aProps.aTitle = _rName;
605cdf0e10cSrcweir 				rDefinitions.insert( _rName, pImpl );
606cdf0e10cSrcweir 			}
607cdf0e10cSrcweir 		}
608cdf0e10cSrcweir 
609cdf0e10cSrcweir 
610cdf0e10cSrcweir 		m_aDocuments.push_back(m_aDocumentMap.insert(Documents::value_type(_rName,_rxNewObject)).first);
611cdf0e10cSrcweir 		notifyDataSourceModified();
612cdf0e10cSrcweir 		// now update our structures
613cdf0e10cSrcweir 		if ( _rxNewObject.is() )
614cdf0e10cSrcweir 			addObjectListener(_rxNewObject);
615cdf0e10cSrcweir 	}
616cdf0e10cSrcweir 	catch(Exception&)
617cdf0e10cSrcweir 	{
618cdf0e10cSrcweir 		DBG_ERROR("ODefinitionContainer::implAppend: caught something !");
619cdf0e10cSrcweir 	}
620cdf0e10cSrcweir }
621cdf0e10cSrcweir 
622cdf0e10cSrcweir //--------------------------------------------------------------------------
implReplace(const::rtl::OUString & _rName,const Reference<XContent> & _rxNewObject)623cdf0e10cSrcweir void ODefinitionContainer::implReplace(const ::rtl::OUString& _rName, const Reference< XContent >& _rxNewObject)
624cdf0e10cSrcweir {
625cdf0e10cSrcweir 	DBG_ASSERT(checkExistence(_rName), "ODefinitionContainer::implReplace : invalid name !");
626cdf0e10cSrcweir 
627cdf0e10cSrcweir 	Documents::iterator aFind = m_aDocumentMap.find(_rName);
628cdf0e10cSrcweir 	removeObjectListener(aFind->second);
629cdf0e10cSrcweir 	aFind->second = _rxNewObject;
630cdf0e10cSrcweir 	addObjectListener(aFind->second);
631cdf0e10cSrcweir }
632cdf0e10cSrcweir 
633cdf0e10cSrcweir // -----------------------------------------------------------------------------
approveNewObject(const::rtl::OUString & _sName,const Reference<XContent> & _rxObject) const634cdf0e10cSrcweir void ODefinitionContainer::approveNewObject(const ::rtl::OUString& _sName,const Reference< XContent >& _rxObject) const
635cdf0e10cSrcweir {
636cdf0e10cSrcweir 	// check the arguments
637cdf0e10cSrcweir 	if ( !_sName.getLength() )
638cdf0e10cSrcweir         throw IllegalArgumentException(
639cdf0e10cSrcweir             DBA_RES( RID_STR_NAME_MUST_NOT_BE_EMPTY ),
640cdf0e10cSrcweir             *this,
641cdf0e10cSrcweir             0 );
642cdf0e10cSrcweir 
643cdf0e10cSrcweir     if ( m_bCheckSlash && _sName.indexOf( '/' ) != -1 )
644cdf0e10cSrcweir         throw IllegalArgumentException(
645cdf0e10cSrcweir             m_aErrorHelper.getErrorMessage( ErrorCondition::DB_OBJECT_NAME_WITH_SLASHES ),
646cdf0e10cSrcweir             *this,
647cdf0e10cSrcweir             0 );
648cdf0e10cSrcweir 
649cdf0e10cSrcweir 	if ( !_rxObject.is() )
650cdf0e10cSrcweir         throw IllegalArgumentException(
651cdf0e10cSrcweir             DBA_RES( RID_STR_NO_NULL_OBJECTS_IN_CONTAINER ),
652cdf0e10cSrcweir             *this,
653cdf0e10cSrcweir             0 );
654cdf0e10cSrcweir 
655cdf0e10cSrcweir 	const ODefinitionContainer_Impl& rDefinitions( getDefinitions() );
656cdf0e10cSrcweir     if ( rDefinitions.find( _sName ) != rDefinitions.end() )
657cdf0e10cSrcweir         throw ElementExistException(
658cdf0e10cSrcweir             DBA_RES( RID_STR_NAME_ALREADY_USED ),
659cdf0e10cSrcweir             *this );
660cdf0e10cSrcweir 
661cdf0e10cSrcweir     ::rtl::Reference< OContentHelper > pContent( OContentHelper::getImplementation( _rxObject ) );
662cdf0e10cSrcweir     if ( !pContent.is() )
663cdf0e10cSrcweir         throw IllegalArgumentException(
664cdf0e10cSrcweir             DBA_RES( RID_STR_OBJECT_CONTAINER_MISMATCH ),
665cdf0e10cSrcweir             *this,
666cdf0e10cSrcweir             1 );
667cdf0e10cSrcweir 
668cdf0e10cSrcweir     if ( rDefinitions.find( pContent->getImpl() ) != rDefinitions.end() )
669cdf0e10cSrcweir         throw ElementExistException(
670cdf0e10cSrcweir             DBA_RES( RID_STR_OBJECT_ALREADY_CONTAINED ),
671cdf0e10cSrcweir             *this );
672cdf0e10cSrcweir }
673cdf0e10cSrcweir 
674cdf0e10cSrcweir // -----------------------------------------------------------------------------
675cdf0e10cSrcweir // XPropertyChangeListener
propertyChange(const PropertyChangeEvent & evt)676cdf0e10cSrcweir void SAL_CALL ODefinitionContainer::propertyChange( const PropertyChangeEvent& evt ) throw (RuntimeException)
677cdf0e10cSrcweir {
678cdf0e10cSrcweir 	ClearableMutexGuard aGuard(m_aMutex);
679cdf0e10cSrcweir     if(evt.PropertyName == (rtl::OUString) PROPERTY_NAME || evt.PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ))
680cdf0e10cSrcweir 	{
681cdf0e10cSrcweir 		m_bInPropertyChange = sal_True;
682cdf0e10cSrcweir 		try
683cdf0e10cSrcweir 		{
684cdf0e10cSrcweir 			::rtl::OUString sNewName,sOldName;
685cdf0e10cSrcweir 			evt.OldValue >>= sOldName;
686cdf0e10cSrcweir 			evt.NewValue >>= sNewName;
687cdf0e10cSrcweir 			Reference<XContent> xContent( evt.Source, UNO_QUERY );
688cdf0e10cSrcweir 			removeObjectListener( xContent );
689cdf0e10cSrcweir             implRemove( sOldName );
690cdf0e10cSrcweir 			implAppend( sNewName, xContent );
691cdf0e10cSrcweir 		}
692cdf0e10cSrcweir 		catch(const Exception&)
693cdf0e10cSrcweir 		{
694cdf0e10cSrcweir             DBG_UNHANDLED_EXCEPTION();
695cdf0e10cSrcweir 			throw RuntimeException();
696cdf0e10cSrcweir 		}
697cdf0e10cSrcweir 		m_bInPropertyChange = sal_False;
698cdf0e10cSrcweir 	}
699cdf0e10cSrcweir }
700cdf0e10cSrcweir // -----------------------------------------------------------------------------
701cdf0e10cSrcweir // XVetoableChangeListener
vetoableChange(const PropertyChangeEvent & aEvent)702cdf0e10cSrcweir void SAL_CALL ODefinitionContainer::vetoableChange( const PropertyChangeEvent& aEvent ) throw (PropertyVetoException, RuntimeException)
703cdf0e10cSrcweir {
704cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
705cdf0e10cSrcweir 
706cdf0e10cSrcweir     if(aEvent.PropertyName == (rtl::OUString) PROPERTY_NAME || aEvent.PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
707cdf0e10cSrcweir 	{
708cdf0e10cSrcweir 		::rtl::OUString sNewName;
709cdf0e10cSrcweir 		aEvent.NewValue >>= sNewName;
710cdf0e10cSrcweir 		if(hasByName(sNewName))
711cdf0e10cSrcweir 			throw PropertyVetoException();
712cdf0e10cSrcweir 	}
713cdf0e10cSrcweir }
714cdf0e10cSrcweir // -----------------------------------------------------------------------------
addObjectListener(const Reference<XContent> & _xNewObject)715cdf0e10cSrcweir void ODefinitionContainer::addObjectListener(const Reference< XContent >& _xNewObject)
716cdf0e10cSrcweir {
717cdf0e10cSrcweir 	OSL_ENSURE(_xNewObject.is(),"ODefinitionContainer::addObjectListener: Object is null!");
718cdf0e10cSrcweir 	Reference<XPropertySet> xProp(_xNewObject,UNO_QUERY);
719cdf0e10cSrcweir 	if ( xProp.is() )
720cdf0e10cSrcweir 	{
721cdf0e10cSrcweir 		xProp->addPropertyChangeListener(PROPERTY_NAME, this);
722cdf0e10cSrcweir 		xProp->addVetoableChangeListener(PROPERTY_NAME, this);
723cdf0e10cSrcweir 	}
724cdf0e10cSrcweir }
725cdf0e10cSrcweir // -----------------------------------------------------------------------------
removeObjectListener(const Reference<XContent> & _xNewObject)726cdf0e10cSrcweir void ODefinitionContainer::removeObjectListener(const Reference< XContent >& _xNewObject)
727cdf0e10cSrcweir {
728cdf0e10cSrcweir 	Reference<XPropertySet> xProp(_xNewObject,UNO_QUERY);
729cdf0e10cSrcweir 	if ( xProp.is() )
730cdf0e10cSrcweir 	{
731cdf0e10cSrcweir 		xProp->removePropertyChangeListener(PROPERTY_NAME, this);
732cdf0e10cSrcweir 		xProp->removeVetoableChangeListener(PROPERTY_NAME, this);
733cdf0e10cSrcweir 	}
734cdf0e10cSrcweir }
735cdf0e10cSrcweir // -----------------------------------------------------------------------------
checkExistence(const::rtl::OUString & _rName)736cdf0e10cSrcweir sal_Bool ODefinitionContainer::checkExistence(const ::rtl::OUString& _rName)
737cdf0e10cSrcweir {
738cdf0e10cSrcweir 	return m_aDocumentMap.find(_rName) != m_aDocumentMap.end();
739cdf0e10cSrcweir }
740cdf0e10cSrcweir 
741cdf0e10cSrcweir //........................................................................
742cdf0e10cSrcweir }
743cdf0e10cSrcweir // namespace dbaccess
744cdf0e10cSrcweir //........................................................................
745