xref: /AOO41X/main/dbaccess/source/core/dataaccess/ContentHelper.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 #ifndef DBA_CONTENTHELPER_HXX
27cdf0e10cSrcweir #include "ContentHelper.hxx"
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #ifndef _UCBHELPER_CANCELCOMMANDEXECUTION_HXX_
30cdf0e10cSrcweir #include <ucbhelper/cancelcommandexecution.hxx>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #ifndef _COMPHELPER_PROPERTY_HXX_
33cdf0e10cSrcweir #include <comphelper/property.hxx>
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UCB_UNSUPPORTEDCOMMANDEXCEPTION_HPP_
36cdf0e10cSrcweir #include <com/sun/star/ucb/UnsupportedCommandException.hpp>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_
39cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp>
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_ILLEGALACCESSEXCEPTION_HPP_
42cdf0e10cSrcweir #include <com/sun/star/lang/IllegalAccessException.hpp>
43cdf0e10cSrcweir #endif
44cdf0e10cSrcweir #ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_
45cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp>
46cdf0e10cSrcweir #endif
47cdf0e10cSrcweir #ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HPP_
48cdf0e10cSrcweir #include <com/sun/star/io/XActiveDataSink.hpp>
49cdf0e10cSrcweir #endif
50cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
51cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir #ifndef _UCBHELPER_PROPERTYVALUESET_HXX
54cdf0e10cSrcweir #include <ucbhelper/propertyvalueset.hxx>
55cdf0e10cSrcweir #endif
56cdf0e10cSrcweir #ifndef _UCBHELPER_CONTENTIDENTIFIER_HXX
57cdf0e10cSrcweir #include <ucbhelper/contentidentifier.hxx>
58cdf0e10cSrcweir #endif
59cdf0e10cSrcweir #ifndef DBA_UCPRESULTSET_HXX
60cdf0e10cSrcweir #include "myucp_resultset.hxx"
61cdf0e10cSrcweir #endif
62cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
63cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
64cdf0e10cSrcweir #endif
65cdf0e10cSrcweir #ifndef DBACORE_SDBCORETOOLS_HXX
66cdf0e10cSrcweir #include "sdbcoretools.hxx"
67cdf0e10cSrcweir #endif
68cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
69cdf0e10cSrcweir #include "dbastrings.hrc"
70cdf0e10cSrcweir #endif
71cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX
72cdf0e10cSrcweir #include <tools/debug.hxx>
73cdf0e10cSrcweir #endif
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 
76cdf0e10cSrcweir namespace dbaccess
77cdf0e10cSrcweir {
78cdf0e10cSrcweir using namespace ::com::sun::star::uno;
79cdf0e10cSrcweir using namespace ::com::sun::star::ucb;
80cdf0e10cSrcweir using namespace ::com::sun::star::beans;
81cdf0e10cSrcweir using namespace ::com::sun::star::lang;
82cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
83cdf0e10cSrcweir using namespace ::com::sun::star::io;
84cdf0e10cSrcweir using namespace ::com::sun::star::util;
85cdf0e10cSrcweir using namespace ::com::sun::star::embed;
86cdf0e10cSrcweir using namespace ::com::sun::star::container;
87cdf0e10cSrcweir using namespace ::comphelper;
88cdf0e10cSrcweir using namespace ::cppu;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir // -----------------------------------------------------------------------------
DBG_NAME(OContentHelper_Impl)91cdf0e10cSrcweir DBG_NAME(OContentHelper_Impl)
92cdf0e10cSrcweir OContentHelper_Impl::OContentHelper_Impl()
93cdf0e10cSrcweir {
94cdf0e10cSrcweir 	DBG_CTOR(OContentHelper_Impl,NULL);
95cdf0e10cSrcweir }
96cdf0e10cSrcweir // -----------------------------------------------------------------------------
~OContentHelper_Impl()97cdf0e10cSrcweir OContentHelper_Impl::~OContentHelper_Impl()
98cdf0e10cSrcweir {
99cdf0e10cSrcweir 	DBG_DTOR(OContentHelper_Impl,NULL);
100cdf0e10cSrcweir }
101cdf0e10cSrcweir // -----------------------------------------------------------------------------
102cdf0e10cSrcweir 
OContentHelper(const Reference<XMultiServiceFactory> & _xORB,const Reference<XInterface> & _xParentContainer,const TContentPtr & _pImpl)103cdf0e10cSrcweir OContentHelper::OContentHelper(const Reference< XMultiServiceFactory >& _xORB
104cdf0e10cSrcweir 							   ,const Reference< XInterface >&	_xParentContainer
105cdf0e10cSrcweir 							   ,const TContentPtr& _pImpl)
106cdf0e10cSrcweir 	: OContentHelper_COMPBASE(m_aMutex)
107cdf0e10cSrcweir 	,m_aContentListeners(m_aMutex)
108cdf0e10cSrcweir 	,m_aPropertyChangeListeners(m_aMutex)
109cdf0e10cSrcweir 	,m_xParentContainer(_xParentContainer)
110cdf0e10cSrcweir 	,m_aContext( _xORB )
111cdf0e10cSrcweir     ,m_aErrorHelper( m_aContext )
112cdf0e10cSrcweir 	,m_pImpl(_pImpl)
113cdf0e10cSrcweir 	,m_nCommandId(0)
114cdf0e10cSrcweir {
115cdf0e10cSrcweir }
116cdf0e10cSrcweir //--------------------------------------------------------------------------
disposing()117cdf0e10cSrcweir void SAL_CALL OContentHelper::disposing()
118cdf0e10cSrcweir {
119cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 	// say our listeners goobye
122cdf0e10cSrcweir 	EventObject aEvt(*this);
123cdf0e10cSrcweir 	m_aContentListeners.disposeAndClear(aEvt);
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 	m_xParentContainer = NULL;
126cdf0e10cSrcweir }
127cdf0e10cSrcweir // -----------------------------------------------------------------------------
128cdf0e10cSrcweir IMPLEMENT_SERVICE_INFO1(OContentHelper,"com.sun.star.comp.sdb.Content","com.sun.star.ucb.Content");
IMPLEMENT_IMPLEMENTATION_ID(OContentHelper)129cdf0e10cSrcweir IMPLEMENT_IMPLEMENTATION_ID(OContentHelper)
130cdf0e10cSrcweir // -----------------------------------------------------------------------------
131cdf0e10cSrcweir // XContent
132cdf0e10cSrcweir Reference< XContentIdentifier > SAL_CALL OContentHelper::getIdentifier(  ) throw (RuntimeException)
133cdf0e10cSrcweir {
134cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
135cdf0e10cSrcweir     ::rtl::OUStringBuffer aIdentifier;
136cdf0e10cSrcweir     aIdentifier.appendAscii( "private:" );
137cdf0e10cSrcweir     aIdentifier.append( impl_getHierarchicalName( true ) );
138cdf0e10cSrcweir     return new ::ucbhelper::ContentIdentifier( m_aContext.getLegacyServiceFactory(), aIdentifier.makeStringAndClear() );
139cdf0e10cSrcweir }
140cdf0e10cSrcweir // -----------------------------------------------------------------------------
impl_getHierarchicalName(bool _includingRootContainer) const141cdf0e10cSrcweir ::rtl::OUString OContentHelper::impl_getHierarchicalName( bool _includingRootContainer ) const
142cdf0e10cSrcweir {
143cdf0e10cSrcweir     ::rtl::OUStringBuffer aHierarchicalName( m_pImpl->m_aProps.aTitle );
144cdf0e10cSrcweir 	Reference< XInterface > xParent = m_xParentContainer;
145cdf0e10cSrcweir 	while( xParent.is() )
146cdf0e10cSrcweir 	{
147cdf0e10cSrcweir 		Reference<XPropertySet> xProp( xParent, UNO_QUERY );
148cdf0e10cSrcweir 		Reference< XChild > xChild( xParent, UNO_QUERY );
149cdf0e10cSrcweir 		xParent.set( xChild.is() ? xChild->getParent() : Reference< XInterface >(), UNO_QUERY );
150cdf0e10cSrcweir 		if ( xProp.is() && xParent.is() )
151cdf0e10cSrcweir 		{
152cdf0e10cSrcweir 			::rtl::OUString sName;
153cdf0e10cSrcweir 			xProp->getPropertyValue( PROPERTY_NAME ) >>= sName;
154cdf0e10cSrcweir 
155cdf0e10cSrcweir             ::rtl::OUString sPrevious = aHierarchicalName.makeStringAndClear();
156cdf0e10cSrcweir             aHierarchicalName.append( sName );
157cdf0e10cSrcweir             aHierarchicalName.append( sal_Unicode( '/' ) );
158cdf0e10cSrcweir             aHierarchicalName.append( sPrevious );
159cdf0e10cSrcweir 		}
160cdf0e10cSrcweir 	}
161cdf0e10cSrcweir     ::rtl::OUString sHierarchicalName( aHierarchicalName.makeStringAndClear() );
162cdf0e10cSrcweir     if ( !_includingRootContainer )
163cdf0e10cSrcweir         sHierarchicalName = sHierarchicalName.copy( sHierarchicalName.indexOf( '/' ) + 1 );
164cdf0e10cSrcweir     return sHierarchicalName;
165cdf0e10cSrcweir }
166cdf0e10cSrcweir 
167cdf0e10cSrcweir // -----------------------------------------------------------------------------
getContentType()168cdf0e10cSrcweir ::rtl::OUString SAL_CALL OContentHelper::getContentType() throw (RuntimeException)
169cdf0e10cSrcweir {
170cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
171cdf0e10cSrcweir 
172cdf0e10cSrcweir     if ( !m_pImpl->m_aProps.aContentType )
173cdf0e10cSrcweir     {   // content type not yet retrieved
174cdf0e10cSrcweir         m_pImpl->m_aProps.aContentType.reset( determineContentType() );
175cdf0e10cSrcweir     }
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 	return *m_pImpl->m_aProps.aContentType;
178cdf0e10cSrcweir }
179cdf0e10cSrcweir // -----------------------------------------------------------------------------
addContentEventListener(const Reference<XContentEventListener> & _rxListener)180cdf0e10cSrcweir void SAL_CALL OContentHelper::addContentEventListener( const Reference< XContentEventListener >& _rxListener ) throw (RuntimeException)
181cdf0e10cSrcweir {
182cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
183cdf0e10cSrcweir 	if ( _rxListener.is() )
184cdf0e10cSrcweir 		m_aContentListeners.addInterface(_rxListener);
185cdf0e10cSrcweir }
186cdf0e10cSrcweir // -----------------------------------------------------------------------------
removeContentEventListener(const Reference<XContentEventListener> & _rxListener)187cdf0e10cSrcweir void SAL_CALL OContentHelper::removeContentEventListener( const Reference< XContentEventListener >& _rxListener ) throw (RuntimeException)
188cdf0e10cSrcweir {
189cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
190cdf0e10cSrcweir 	if (_rxListener.is())
191cdf0e10cSrcweir 		m_aContentListeners.removeInterface(_rxListener);
192cdf0e10cSrcweir }
193cdf0e10cSrcweir // -----------------------------------------------------------------------------
194cdf0e10cSrcweir 
195cdf0e10cSrcweir // XCommandProcessor
createCommandIdentifier()196cdf0e10cSrcweir sal_Int32 SAL_CALL OContentHelper::createCommandIdentifier(  ) throw (RuntimeException)
197cdf0e10cSrcweir {
198cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
199cdf0e10cSrcweir 	// Just increase counter on every call to generate an identifier.
200cdf0e10cSrcweir 	return ++m_nCommandId;
201cdf0e10cSrcweir }
202cdf0e10cSrcweir // -----------------------------------------------------------------------------
execute(const Command & aCommand,sal_Int32,const Reference<XCommandEnvironment> & Environment)203cdf0e10cSrcweir Any SAL_CALL OContentHelper::execute( const Command& aCommand, sal_Int32 /*CommandId*/, const Reference< XCommandEnvironment >& Environment ) throw (Exception, CommandAbortedException, RuntimeException)
204cdf0e10cSrcweir {
205cdf0e10cSrcweir 	Any aRet;
206cdf0e10cSrcweir 	if ( aCommand.Name.compareToAscii( "getPropertyValues" ) == 0 )
207cdf0e10cSrcweir 	{
208cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
209cdf0e10cSrcweir 		// getPropertyValues
210cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
211cdf0e10cSrcweir 
212cdf0e10cSrcweir 		Sequence< Property > Properties;
213cdf0e10cSrcweir 		if ( !( aCommand.Argument >>= Properties ) )
214cdf0e10cSrcweir 		{
215cdf0e10cSrcweir 			OSL_ENSURE( sal_False, "Wrong argument type!" );
216cdf0e10cSrcweir             ucbhelper::cancelCommandExecution(
217cdf0e10cSrcweir                 makeAny( IllegalArgumentException(
218cdf0e10cSrcweir                                     rtl::OUString(),
219cdf0e10cSrcweir                                     static_cast< cppu::OWeakObject * >( this ),
220cdf0e10cSrcweir                                     -1 ) ),
221cdf0e10cSrcweir                 Environment );
222cdf0e10cSrcweir             // Unreachable
223cdf0e10cSrcweir 		}
224cdf0e10cSrcweir 		aRet <<= getPropertyValues( Properties);
225cdf0e10cSrcweir 	}
226cdf0e10cSrcweir 	else if ( aCommand.Name.compareToAscii( "setPropertyValues" ) == 0 )
227cdf0e10cSrcweir 	{
228cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
229cdf0e10cSrcweir 		// setPropertyValues
230cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
231cdf0e10cSrcweir 
232cdf0e10cSrcweir 		Sequence< PropertyValue > aProperties;
233cdf0e10cSrcweir 		if ( !( aCommand.Argument >>= aProperties ) )
234cdf0e10cSrcweir 		{
235cdf0e10cSrcweir             OSL_ENSURE( sal_False, "Wrong argument type!" );
236cdf0e10cSrcweir             ucbhelper::cancelCommandExecution(
237cdf0e10cSrcweir                 makeAny( IllegalArgumentException(
238cdf0e10cSrcweir                                     rtl::OUString(),
239cdf0e10cSrcweir                                     static_cast< cppu::OWeakObject * >( this ),
240cdf0e10cSrcweir                                     -1 ) ),
241cdf0e10cSrcweir                 Environment );
242cdf0e10cSrcweir             // Unreachable
243cdf0e10cSrcweir         }
244cdf0e10cSrcweir 
245cdf0e10cSrcweir 		if ( !aProperties.getLength() )
246cdf0e10cSrcweir 		{
247cdf0e10cSrcweir             OSL_ENSURE( sal_False, "No properties!" );
248cdf0e10cSrcweir             ucbhelper::cancelCommandExecution(
249cdf0e10cSrcweir                 makeAny( IllegalArgumentException(
250cdf0e10cSrcweir                                     rtl::OUString(),
251cdf0e10cSrcweir                                     static_cast< cppu::OWeakObject * >( this ),
252cdf0e10cSrcweir                                     -1 ) ),
253cdf0e10cSrcweir                 Environment );
254cdf0e10cSrcweir             // Unreachable
255cdf0e10cSrcweir         }
256cdf0e10cSrcweir 
257cdf0e10cSrcweir         aRet <<= setPropertyValues( aProperties, Environment );
258cdf0e10cSrcweir 	}
259cdf0e10cSrcweir 	else if ( aCommand.Name.compareToAscii( "getPropertySetInfo" ) == 0 )
260cdf0e10cSrcweir 	{
261cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
262cdf0e10cSrcweir 		// getPropertySetInfo
263cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
264cdf0e10cSrcweir 
265cdf0e10cSrcweir 		Reference<XPropertySet> xProp(*this,UNO_QUERY);
266cdf0e10cSrcweir 		if ( xProp.is() )
267cdf0e10cSrcweir 			aRet <<= xProp->getPropertySetInfo();
268cdf0e10cSrcweir 		//	aRet <<= getPropertySetInfo(); // TODO
269cdf0e10cSrcweir 	}
270cdf0e10cSrcweir 	else
271cdf0e10cSrcweir 	{
272cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
273cdf0e10cSrcweir 		// Unsupported command
274cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
275cdf0e10cSrcweir 
276cdf0e10cSrcweir         OSL_ENSURE( sal_False, "Content::execute - unsupported command!" );
277cdf0e10cSrcweir 
278cdf0e10cSrcweir         ucbhelper::cancelCommandExecution(
279cdf0e10cSrcweir             makeAny( UnsupportedCommandException(
280cdf0e10cSrcweir                             rtl::OUString(),
281cdf0e10cSrcweir                             static_cast< cppu::OWeakObject * >( this ) ) ),
282cdf0e10cSrcweir             Environment );
283cdf0e10cSrcweir         // Unreachable
284cdf0e10cSrcweir     }
285cdf0e10cSrcweir 
286cdf0e10cSrcweir 	return aRet;
287cdf0e10cSrcweir }
288cdf0e10cSrcweir // -----------------------------------------------------------------------------
abort(sal_Int32)289cdf0e10cSrcweir void SAL_CALL OContentHelper::abort( sal_Int32 /*CommandId*/ ) throw (RuntimeException)
290cdf0e10cSrcweir {
291cdf0e10cSrcweir }
292cdf0e10cSrcweir // -----------------------------------------------------------------------------
293cdf0e10cSrcweir 
294cdf0e10cSrcweir // XPropertiesChangeNotifier
addPropertiesChangeListener(const Sequence<::rtl::OUString> & PropertyNames,const Reference<XPropertiesChangeListener> & Listener)295cdf0e10cSrcweir void SAL_CALL OContentHelper::addPropertiesChangeListener( const Sequence< ::rtl::OUString >& PropertyNames, const Reference< XPropertiesChangeListener >& Listener ) throw (RuntimeException)
296cdf0e10cSrcweir {
297cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
298cdf0e10cSrcweir 	sal_Int32 nCount = PropertyNames.getLength();
299cdf0e10cSrcweir 	if ( !nCount )
300cdf0e10cSrcweir 	{
301cdf0e10cSrcweir 		// Note: An empty sequence means a listener for "all" properties.
302cdf0e10cSrcweir 		m_aPropertyChangeListeners.addInterface(::rtl::OUString(), Listener );
303cdf0e10cSrcweir 	}
304cdf0e10cSrcweir 	else
305cdf0e10cSrcweir 	{
306cdf0e10cSrcweir 		const ::rtl::OUString* pSeq = PropertyNames.getConstArray();
307cdf0e10cSrcweir 
308cdf0e10cSrcweir 		for ( sal_Int32 n = 0; n < nCount; ++n )
309cdf0e10cSrcweir 		{
310cdf0e10cSrcweir 			const ::rtl::OUString& rName = pSeq[ n ];
311cdf0e10cSrcweir 			if ( rName.getLength() )
312cdf0e10cSrcweir 				m_aPropertyChangeListeners.addInterface(rName, Listener );
313cdf0e10cSrcweir 		}
314cdf0e10cSrcweir 	}
315cdf0e10cSrcweir }
316cdf0e10cSrcweir // -----------------------------------------------------------------------------
removePropertiesChangeListener(const Sequence<::rtl::OUString> & PropertyNames,const Reference<XPropertiesChangeListener> & Listener)317cdf0e10cSrcweir void SAL_CALL OContentHelper::removePropertiesChangeListener( const Sequence< ::rtl::OUString >& PropertyNames, const Reference< XPropertiesChangeListener >& Listener ) throw (RuntimeException)
318cdf0e10cSrcweir {
319cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
320cdf0e10cSrcweir 	sal_Int32 nCount = PropertyNames.getLength();
321cdf0e10cSrcweir 	if ( !nCount )
322cdf0e10cSrcweir 	{
323cdf0e10cSrcweir 		// Note: An empty sequence means a listener for "all" properties.
324cdf0e10cSrcweir 		m_aPropertyChangeListeners.removeInterface( ::rtl::OUString(), Listener );
325cdf0e10cSrcweir 	}
326cdf0e10cSrcweir 	else
327cdf0e10cSrcweir 	{
328cdf0e10cSrcweir 		const ::rtl::OUString* pSeq = PropertyNames.getConstArray();
329cdf0e10cSrcweir 
330cdf0e10cSrcweir 		for ( sal_Int32 n = 0; n < nCount; ++n )
331cdf0e10cSrcweir 		{
332cdf0e10cSrcweir 			const ::rtl::OUString& rName = pSeq[ n ];
333cdf0e10cSrcweir 			if ( rName.getLength() )
334cdf0e10cSrcweir 				m_aPropertyChangeListeners.removeInterface( rName, Listener );
335cdf0e10cSrcweir 		}
336cdf0e10cSrcweir 	}
337cdf0e10cSrcweir }
338cdf0e10cSrcweir // -----------------------------------------------------------------------------
339cdf0e10cSrcweir 
340cdf0e10cSrcweir // XPropertyContainer
addProperty(const::rtl::OUString &,sal_Int16,const Any &)341cdf0e10cSrcweir void SAL_CALL OContentHelper::addProperty( const ::rtl::OUString& /*Name*/, sal_Int16 /*Attributes*/, const Any& /*DefaultValue*/ ) throw (PropertyExistException, IllegalTypeException, IllegalArgumentException, RuntimeException)
342cdf0e10cSrcweir {
343cdf0e10cSrcweir     DBG_ERROR( "OContentHelper::addProperty: not implemented!" );
344cdf0e10cSrcweir }
345cdf0e10cSrcweir // -----------------------------------------------------------------------------
removeProperty(const::rtl::OUString &)346cdf0e10cSrcweir void SAL_CALL OContentHelper::removeProperty( const ::rtl::OUString& /*Name*/ ) throw (UnknownPropertyException, NotRemoveableException, RuntimeException)
347cdf0e10cSrcweir {
348cdf0e10cSrcweir     DBG_ERROR( "OContentHelper::removeProperty: not implemented!" );
349cdf0e10cSrcweir }
350cdf0e10cSrcweir // -----------------------------------------------------------------------------
351cdf0e10cSrcweir // XInitialization
initialize(const Sequence<Any> & _aArguments)352cdf0e10cSrcweir void SAL_CALL OContentHelper::initialize( const Sequence< Any >& _aArguments ) throw(Exception, RuntimeException)
353cdf0e10cSrcweir {
354cdf0e10cSrcweir 	const Any* pBegin = _aArguments.getConstArray();
355cdf0e10cSrcweir 	const Any* pEnd = pBegin + _aArguments.getLength();
356cdf0e10cSrcweir 	PropertyValue aValue;;
357cdf0e10cSrcweir 	for(;pBegin != pEnd;++pBegin)
358cdf0e10cSrcweir 	{
359cdf0e10cSrcweir 		*pBegin >>= aValue;
360cdf0e10cSrcweir 		if ( aValue.Name.equalsAscii("Parent") )
361cdf0e10cSrcweir 		{
362cdf0e10cSrcweir 			m_xParentContainer.set(aValue.Value,UNO_QUERY);
363cdf0e10cSrcweir 		}
364cdf0e10cSrcweir 		else if ( aValue.Name.equalsAscii(PROPERTY_NAME) )
365cdf0e10cSrcweir 		{
366cdf0e10cSrcweir 			aValue.Value >>= m_pImpl->m_aProps.aTitle;
367cdf0e10cSrcweir 		}
368cdf0e10cSrcweir 		else if ( aValue.Name.equalsAscii(PROPERTY_PERSISTENT_NAME) )
369cdf0e10cSrcweir 		{
370cdf0e10cSrcweir 			aValue.Value >>= m_pImpl->m_aProps.sPersistentName;
371cdf0e10cSrcweir 		}
372cdf0e10cSrcweir 	}
373cdf0e10cSrcweir }
374cdf0e10cSrcweir // -----------------------------------------------------------------------------
setPropertyValues(const Sequence<PropertyValue> & rValues,const Reference<XCommandEnvironment> &)375cdf0e10cSrcweir Sequence< Any > OContentHelper::setPropertyValues(const Sequence< PropertyValue >& rValues,const Reference< XCommandEnvironment >& /*xEnv*/ )
376cdf0e10cSrcweir {
377cdf0e10cSrcweir 	osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex );
378cdf0e10cSrcweir 
379cdf0e10cSrcweir     Sequence< Any > aRet( rValues.getLength() );
380cdf0e10cSrcweir     Sequence< PropertyChangeEvent > aChanges( rValues.getLength() );
381cdf0e10cSrcweir 	sal_Int32 nChanged = 0;
382cdf0e10cSrcweir 
383cdf0e10cSrcweir     PropertyChangeEvent aEvent;
384cdf0e10cSrcweir     aEvent.Source         = static_cast< cppu::OWeakObject * >( this );
385cdf0e10cSrcweir 	aEvent.Further 		  = sal_False;
386cdf0e10cSrcweir 	aEvent.PropertyHandle = -1;
387cdf0e10cSrcweir 
388cdf0e10cSrcweir     const PropertyValue* pValues = rValues.getConstArray();
389cdf0e10cSrcweir 	sal_Int32 nCount = rValues.getLength();
390cdf0e10cSrcweir 
391cdf0e10cSrcweir 	for ( sal_Int32 n = 0; n < nCount; ++n )
392cdf0e10cSrcweir 	{
393cdf0e10cSrcweir         const PropertyValue& rValue = pValues[ n ];
394cdf0e10cSrcweir 
395cdf0e10cSrcweir         if ( rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) )
396cdf0e10cSrcweir         {
397cdf0e10cSrcweir 			// Read-only property!
398cdf0e10cSrcweir             aRet[ n ] <<= IllegalAccessException(
399cdf0e10cSrcweir                             rtl::OUString::createFromAscii(
400cdf0e10cSrcweir                                 "Property is read-only!" ),
401cdf0e10cSrcweir                             static_cast< cppu::OWeakObject * >( this ) );
402cdf0e10cSrcweir 		}
403cdf0e10cSrcweir         else if ( rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) )
404cdf0e10cSrcweir 		{
405cdf0e10cSrcweir 			// Read-only property!
406cdf0e10cSrcweir             aRet[ n ] <<= IllegalAccessException(
407cdf0e10cSrcweir                             rtl::OUString::createFromAscii(
408cdf0e10cSrcweir                                 "Property is read-only!" ),
409cdf0e10cSrcweir                             static_cast< cppu::OWeakObject * >( this ) );
410cdf0e10cSrcweir 		}
411cdf0e10cSrcweir         else if ( rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) )
412cdf0e10cSrcweir 		{
413cdf0e10cSrcweir 			// Read-only property!
414cdf0e10cSrcweir             aRet[ n ] <<= IllegalAccessException(
415cdf0e10cSrcweir                             rtl::OUString::createFromAscii(
416cdf0e10cSrcweir                                 "Property is read-only!" ),
417cdf0e10cSrcweir                             static_cast< cppu::OWeakObject * >( this ) );
418cdf0e10cSrcweir 		}
419cdf0e10cSrcweir         else if ( rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
420cdf0e10cSrcweir 		{
421cdf0e10cSrcweir             rtl::OUString aNewValue;
422cdf0e10cSrcweir 			if ( rValue.Value >>= aNewValue )
423cdf0e10cSrcweir 			{
424cdf0e10cSrcweir 				if ( aNewValue != m_pImpl->m_aProps.aTitle )
425cdf0e10cSrcweir 				{
426cdf0e10cSrcweir 					aEvent.PropertyName = rValue.Name;
427cdf0e10cSrcweir                     aEvent.OldValue     = makeAny( m_pImpl->m_aProps.aTitle );
428cdf0e10cSrcweir 
429cdf0e10cSrcweir                     try
430cdf0e10cSrcweir                     {
431cdf0e10cSrcweir                         impl_rename_throw( aNewValue ,false);
432cdf0e10cSrcweir                         OSL_ENSURE( m_pImpl->m_aProps.aTitle == aNewValue, "OContentHelper::setPropertyValues('Title'): rename did not work!" );
433cdf0e10cSrcweir 
434cdf0e10cSrcweir                         aEvent.NewValue     = makeAny( aNewValue );
435cdf0e10cSrcweir 					    aChanges.getArray()[ nChanged ] = aEvent;
436cdf0e10cSrcweir 					    nChanged++;
437cdf0e10cSrcweir                     }
438cdf0e10cSrcweir                     catch( const Exception& )
439cdf0e10cSrcweir                     {
440cdf0e10cSrcweir                     	OSL_ENSURE( sal_False, "OContentHelper::setPropertyValues('Title'): caught an exception while renaming!" );
441cdf0e10cSrcweir                     }
442cdf0e10cSrcweir 				}
443cdf0e10cSrcweir                 else
444cdf0e10cSrcweir                 {
445cdf0e10cSrcweir                     // Old value equals new value. No error!
446cdf0e10cSrcweir                 }
447cdf0e10cSrcweir 			}
448cdf0e10cSrcweir             else
449cdf0e10cSrcweir             {
450cdf0e10cSrcweir                 aRet[ n ] <<= IllegalTypeException(
451cdf0e10cSrcweir                                 rtl::OUString::createFromAscii(
452cdf0e10cSrcweir                                     "Property value has wrong type!" ),
453cdf0e10cSrcweir                                 static_cast< cppu::OWeakObject * >( this ) );
454cdf0e10cSrcweir             }
455cdf0e10cSrcweir 		}
456cdf0e10cSrcweir 
457cdf0e10cSrcweir 		// @@@ Process other properties supported directly.
458cdf0e10cSrcweir #if 0
459cdf0e10cSrcweir         else if ( rValue.Name.equalsAsciiL(
460cdf0e10cSrcweir                         RTL_CONSTASCII_STRINGPARAM( "xxxxxx" ) ) )
461cdf0e10cSrcweir 		{
462cdf0e10cSrcweir 		}
463cdf0e10cSrcweir #endif
464cdf0e10cSrcweir 		else
465cdf0e10cSrcweir 		{
466cdf0e10cSrcweir             aRet[ n ] <<= Exception(
467cdf0e10cSrcweir                             rtl::OUString::createFromAscii(
468cdf0e10cSrcweir                                 "No property set for storing the value!" ),
469cdf0e10cSrcweir                             static_cast< cppu::OWeakObject * >( this ) );
470cdf0e10cSrcweir 		}
471cdf0e10cSrcweir 	}
472cdf0e10cSrcweir 
473cdf0e10cSrcweir 	if ( nChanged > 0 )
474cdf0e10cSrcweir 	{
475cdf0e10cSrcweir 		// @@@ Save changes.
476cdf0e10cSrcweir //		storeData();
477cdf0e10cSrcweir 
478cdf0e10cSrcweir 		notifyDataSourceModified();
479cdf0e10cSrcweir 		aGuard.clear();
480cdf0e10cSrcweir 		aChanges.realloc( nChanged );
481cdf0e10cSrcweir 		notifyPropertiesChange( aChanges );
482cdf0e10cSrcweir 	}
483cdf0e10cSrcweir 
484cdf0e10cSrcweir     return aRet;
485cdf0e10cSrcweir }
486cdf0e10cSrcweir // -----------------------------------------------------------------------------
487cdf0e10cSrcweir //=========================================================================
488cdf0e10cSrcweir // static
getPropertyValues(const Sequence<Property> & rProperties)489cdf0e10cSrcweir Reference< XRow > OContentHelper::getPropertyValues( const Sequence< Property >& rProperties)
490cdf0e10cSrcweir {
491cdf0e10cSrcweir 	// Note: Empty sequence means "get values of all supported properties".
492cdf0e10cSrcweir 
493cdf0e10cSrcweir     rtl::Reference< ::ucbhelper::PropertyValueSet > xRow = new ::ucbhelper::PropertyValueSet( m_aContext.getLegacyServiceFactory() );
494cdf0e10cSrcweir 
495cdf0e10cSrcweir 	sal_Int32 nCount = rProperties.getLength();
496cdf0e10cSrcweir 	if ( nCount )
497cdf0e10cSrcweir 	{
498cdf0e10cSrcweir         const Property* pProps = rProperties.getConstArray();
499cdf0e10cSrcweir 		for ( sal_Int32 n = 0; n < nCount; ++n )
500cdf0e10cSrcweir 		{
501cdf0e10cSrcweir             const Property& rProp = pProps[ n ];
502cdf0e10cSrcweir 
503cdf0e10cSrcweir 			// Process Core properties.
504cdf0e10cSrcweir 
505cdf0e10cSrcweir             if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) )
506cdf0e10cSrcweir             {
507cdf0e10cSrcweir 				xRow->appendString ( rProp, getContentType() );
508cdf0e10cSrcweir 			}
509cdf0e10cSrcweir             else if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
510cdf0e10cSrcweir 			{
511cdf0e10cSrcweir 				xRow->appendString ( rProp, m_pImpl->m_aProps.aTitle );
512cdf0e10cSrcweir 			}
513cdf0e10cSrcweir             else if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) )
514cdf0e10cSrcweir 			{
515cdf0e10cSrcweir 				xRow->appendBoolean( rProp, m_pImpl->m_aProps.bIsDocument );
516cdf0e10cSrcweir 			}
517cdf0e10cSrcweir             else if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) )
518cdf0e10cSrcweir 			{
519cdf0e10cSrcweir 				xRow->appendBoolean( rProp, m_pImpl->m_aProps.bIsFolder );
520cdf0e10cSrcweir 			}
521cdf0e10cSrcweir 			else
522cdf0e10cSrcweir 				xRow->appendVoid(rProp);
523cdf0e10cSrcweir 
524cdf0e10cSrcweir 			// @@@ Process other properties supported directly.
525cdf0e10cSrcweir #if 0
526cdf0e10cSrcweir             else if ( rProp.Name.equalsAsciiL(
527cdf0e10cSrcweir                     RTL_CONSTASCII_STRINGPARAM( "xxxxxx" ) ) )
528cdf0e10cSrcweir 			{
529cdf0e10cSrcweir 			}
530cdf0e10cSrcweir #endif
531cdf0e10cSrcweir 		}
532cdf0e10cSrcweir 	}
533cdf0e10cSrcweir 	else
534cdf0e10cSrcweir 	{
535cdf0e10cSrcweir 		// Append all Core Properties.
536cdf0e10cSrcweir 		xRow->appendString (
537cdf0e10cSrcweir             Property( rtl::OUString::createFromAscii( "ContentType" ),
538cdf0e10cSrcweir 					  -1,
539cdf0e10cSrcweir                       getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
540cdf0e10cSrcweir                       PropertyAttribute::BOUND
541cdf0e10cSrcweir                         | PropertyAttribute::READONLY ),
542cdf0e10cSrcweir 			getContentType() );
543cdf0e10cSrcweir 		xRow->appendString (
544cdf0e10cSrcweir             Property( rtl::OUString::createFromAscii( "Title" ),
545cdf0e10cSrcweir 					  -1,
546cdf0e10cSrcweir                       getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
547cdf0e10cSrcweir                       PropertyAttribute::BOUND ),
548cdf0e10cSrcweir 			m_pImpl->m_aProps.aTitle );
549cdf0e10cSrcweir 		xRow->appendBoolean(
550cdf0e10cSrcweir             Property( rtl::OUString::createFromAscii( "IsDocument" ),
551cdf0e10cSrcweir 					  -1,
552cdf0e10cSrcweir 					  getCppuBooleanType(),
553cdf0e10cSrcweir                       PropertyAttribute::BOUND
554cdf0e10cSrcweir                         | PropertyAttribute::READONLY ),
555cdf0e10cSrcweir 			m_pImpl->m_aProps.bIsDocument );
556cdf0e10cSrcweir 		xRow->appendBoolean(
557cdf0e10cSrcweir             Property( rtl::OUString::createFromAscii( "IsFolder" ),
558cdf0e10cSrcweir 					  -1,
559cdf0e10cSrcweir 					  getCppuBooleanType(),
560cdf0e10cSrcweir                       PropertyAttribute::BOUND
561cdf0e10cSrcweir                         | PropertyAttribute::READONLY ),
562cdf0e10cSrcweir 			m_pImpl->m_aProps.bIsFolder );
563cdf0e10cSrcweir 
564cdf0e10cSrcweir 		// @@@ Append other properties supported directly.
565cdf0e10cSrcweir 	}
566cdf0e10cSrcweir 
567cdf0e10cSrcweir     return Reference< XRow >( xRow.get() );
568cdf0e10cSrcweir }
569cdf0e10cSrcweir // -----------------------------------------------------------------------------
570cdf0e10cSrcweir // -----------------------------------------------------------------------------
notifyPropertiesChange(const Sequence<PropertyChangeEvent> & evt) const571cdf0e10cSrcweir void OContentHelper::notifyPropertiesChange( const Sequence< PropertyChangeEvent >& evt ) const
572cdf0e10cSrcweir {
573cdf0e10cSrcweir 
574cdf0e10cSrcweir 	sal_Int32 nCount = evt.getLength();
575cdf0e10cSrcweir 	if ( nCount )
576cdf0e10cSrcweir 	{
577cdf0e10cSrcweir 		// First, notify listeners interested in changes of every property.
578cdf0e10cSrcweir 		OInterfaceContainerHelper* pAllPropsContainer = m_aPropertyChangeListeners.getContainer( ::rtl::OUString() );
579cdf0e10cSrcweir 		if ( pAllPropsContainer )
580cdf0e10cSrcweir 		{
581cdf0e10cSrcweir 			OInterfaceIteratorHelper aIter( *pAllPropsContainer );
582cdf0e10cSrcweir 			while ( aIter.hasMoreElements() )
583cdf0e10cSrcweir 			{
584cdf0e10cSrcweir 				// Propagate event.
585cdf0e10cSrcweir 				Reference< XPropertiesChangeListener > xListener( aIter.next(), UNO_QUERY );
586cdf0e10cSrcweir 				if ( xListener.is() )
587cdf0e10cSrcweir 					xListener->propertiesChange( evt );
588cdf0e10cSrcweir 			}
589cdf0e10cSrcweir 		}
590cdf0e10cSrcweir 
591cdf0e10cSrcweir 		typedef Sequence< PropertyChangeEvent > PropertyEventSequence;
592cdf0e10cSrcweir 		typedef ::std::map< XPropertiesChangeListener*, PropertyEventSequence* > PropertiesEventListenerMap;
593cdf0e10cSrcweir 		PropertiesEventListenerMap aListeners;
594cdf0e10cSrcweir 
595cdf0e10cSrcweir 
596cdf0e10cSrcweir 		const PropertyChangeEvent* propertyChangeEvent = evt.getConstArray();
597cdf0e10cSrcweir 
598cdf0e10cSrcweir 		for ( sal_Int32 n = 0; n < nCount; ++n, ++propertyChangeEvent )
599cdf0e10cSrcweir 		{
600cdf0e10cSrcweir 			const PropertyChangeEvent& rEvent = *propertyChangeEvent;
601cdf0e10cSrcweir 			const ::rtl::OUString& rName = rEvent.PropertyName;
602cdf0e10cSrcweir 
603cdf0e10cSrcweir 			OInterfaceContainerHelper* pPropsContainer = m_aPropertyChangeListeners.getContainer( rName );
604cdf0e10cSrcweir 			if ( pPropsContainer )
605cdf0e10cSrcweir 			{
606cdf0e10cSrcweir 				OInterfaceIteratorHelper aIter( *pPropsContainer );
607cdf0e10cSrcweir 				while ( aIter.hasMoreElements() )
608cdf0e10cSrcweir 				{
609cdf0e10cSrcweir 					PropertyEventSequence* propertyEvents = NULL;
610cdf0e10cSrcweir 
611cdf0e10cSrcweir 					XPropertiesChangeListener* pListener = static_cast< XPropertiesChangeListener * >( aIter.next() );
612cdf0e10cSrcweir 					PropertiesEventListenerMap::iterator it = aListeners.find( pListener );
613cdf0e10cSrcweir 					if ( it == aListeners.end() )
614cdf0e10cSrcweir 					{
615cdf0e10cSrcweir 						// Not in map - create and insert new entry.
616cdf0e10cSrcweir 						propertyEvents = new PropertyEventSequence( nCount );
617cdf0e10cSrcweir 						aListeners[ pListener ] = propertyEvents;
618cdf0e10cSrcweir 					}
619cdf0e10cSrcweir 					else
620cdf0e10cSrcweir 						propertyEvents = (*it).second;
621cdf0e10cSrcweir 
622cdf0e10cSrcweir 					if ( propertyEvents )
623cdf0e10cSrcweir 						(*propertyEvents)[n] = rEvent;
624cdf0e10cSrcweir 				}
625cdf0e10cSrcweir 			}
626cdf0e10cSrcweir 		}
627cdf0e10cSrcweir 
628cdf0e10cSrcweir 		// Notify listeners.
629cdf0e10cSrcweir 		PropertiesEventListenerMap::iterator it = aListeners.begin();
630cdf0e10cSrcweir 		while ( !aListeners.empty() )
631cdf0e10cSrcweir 		{
632cdf0e10cSrcweir 			XPropertiesChangeListener* pListener =
633cdf0e10cSrcweir 					static_cast< XPropertiesChangeListener * >( (*it).first );
634cdf0e10cSrcweir 			PropertyEventSequence* pSeq = (*it).second;
635cdf0e10cSrcweir 
636cdf0e10cSrcweir 			// Remove current element.
637cdf0e10cSrcweir 			aListeners.erase( it );
638cdf0e10cSrcweir 
639cdf0e10cSrcweir 			// Propagate event.
640cdf0e10cSrcweir 			pListener->propertiesChange( *pSeq );
641cdf0e10cSrcweir 
642cdf0e10cSrcweir 			delete pSeq;
643cdf0e10cSrcweir 
644cdf0e10cSrcweir 			it = aListeners.begin();
645cdf0e10cSrcweir 		}
646cdf0e10cSrcweir 	}
647cdf0e10cSrcweir }
648cdf0e10cSrcweir // -----------------------------------------------------------------------------
649cdf0e10cSrcweir // com::sun::star::lang::XUnoTunnel
650cdf0e10cSrcweir //------------------------------------------------------------------
getSomething(const Sequence<sal_Int8> & rId)651cdf0e10cSrcweir sal_Int64 OContentHelper::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
652cdf0e10cSrcweir {
653cdf0e10cSrcweir 	if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(),  rId.getConstArray(), 16 ) )
654cdf0e10cSrcweir 		return reinterpret_cast<sal_Int64>(this);
655cdf0e10cSrcweir 
656cdf0e10cSrcweir 	return 0;
657cdf0e10cSrcweir }
658cdf0e10cSrcweir 
659cdf0e10cSrcweir // -----------------------------------------------------------------------------
getImplementation(const Reference<XInterface> & _rxComponent)660cdf0e10cSrcweir OContentHelper* OContentHelper::getImplementation( const Reference< XInterface >& _rxComponent )
661cdf0e10cSrcweir {
662cdf0e10cSrcweir 	OContentHelper* pContent( NULL );
663cdf0e10cSrcweir 
664cdf0e10cSrcweir     Reference< XUnoTunnel > xUnoTunnel( _rxComponent, UNO_QUERY );
665cdf0e10cSrcweir 	if ( xUnoTunnel.is() )
666cdf0e10cSrcweir 		pContent = reinterpret_cast< OContentHelper* >( xUnoTunnel->getSomething( getUnoTunnelImplementationId() ) );
667cdf0e10cSrcweir 
668cdf0e10cSrcweir     return pContent;
669cdf0e10cSrcweir }
670cdf0e10cSrcweir 
671cdf0e10cSrcweir // -----------------------------------------------------------------------------
getParent()672cdf0e10cSrcweir Reference< XInterface > SAL_CALL OContentHelper::getParent(  ) throw (RuntimeException)
673cdf0e10cSrcweir {
674cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
675cdf0e10cSrcweir 	return m_xParentContainer;
676cdf0e10cSrcweir }
677cdf0e10cSrcweir // -----------------------------------------------------------------------------
setParent(const Reference<XInterface> & _xParent)678cdf0e10cSrcweir void SAL_CALL OContentHelper::setParent( const Reference< XInterface >& _xParent ) throw (NoSupportException, RuntimeException)
679cdf0e10cSrcweir {
680cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
681cdf0e10cSrcweir 	m_xParentContainer = _xParent;
682cdf0e10cSrcweir }
683cdf0e10cSrcweir 
684cdf0e10cSrcweir // -----------------------------------------------------------------------------
impl_rename_throw(const::rtl::OUString & _sNewName,bool _bNotify)685cdf0e10cSrcweir void OContentHelper::impl_rename_throw(const ::rtl::OUString& _sNewName,bool _bNotify )
686cdf0e10cSrcweir {
687cdf0e10cSrcweir 	osl::ClearableGuard< osl::Mutex > aGuard(m_aMutex);
688cdf0e10cSrcweir     if ( _sNewName.equals( m_pImpl->m_aProps.aTitle ) )
689cdf0e10cSrcweir         return;
690cdf0e10cSrcweir     try
691cdf0e10cSrcweir 	{
692cdf0e10cSrcweir         Sequence< PropertyChangeEvent > aChanges( 1 );
693cdf0e10cSrcweir 
694cdf0e10cSrcweir         aChanges[0].Source          = static_cast< cppu::OWeakObject * >( this );
695cdf0e10cSrcweir 	    aChanges[0].Further 	    = sal_False;
696cdf0e10cSrcweir         aChanges[0].PropertyName    = PROPERTY_NAME;
697cdf0e10cSrcweir 	    aChanges[0].PropertyHandle  = PROPERTY_ID_NAME;
698cdf0e10cSrcweir         aChanges[0].OldValue        <<= m_pImpl->m_aProps.aTitle;
699cdf0e10cSrcweir         aChanges[0].NewValue        <<= _sNewName;
700cdf0e10cSrcweir 
701cdf0e10cSrcweir 		aGuard.clear();
702cdf0e10cSrcweir 
703cdf0e10cSrcweir 		m_pImpl->m_aProps.aTitle = _sNewName;
704cdf0e10cSrcweir         if ( _bNotify )
705cdf0e10cSrcweir             notifyPropertiesChange( aChanges );
706cdf0e10cSrcweir         notifyDataSourceModified();
707cdf0e10cSrcweir 	}
708cdf0e10cSrcweir 	catch(const PropertyVetoException&)
709cdf0e10cSrcweir 	{
710cdf0e10cSrcweir 		throw ElementExistException(_sNewName,*this);
711cdf0e10cSrcweir 	}
712cdf0e10cSrcweir }
713cdf0e10cSrcweir // -----------------------------------------------------------------------------
rename(const::rtl::OUString & newName)714cdf0e10cSrcweir void SAL_CALL OContentHelper::rename( const ::rtl::OUString& newName ) throw (SQLException, ElementExistException, RuntimeException)
715cdf0e10cSrcweir {
716cdf0e10cSrcweir 
717cdf0e10cSrcweir     impl_rename_throw(newName);
718cdf0e10cSrcweir 	//Reference<XNameContainer> xNameCont(m_xParentContainer,UNO_QUERY);
719cdf0e10cSrcweir 	//if ( xNameCont.is() )
720cdf0e10cSrcweir 	//{
721cdf0e10cSrcweir 	//	if ( xNameCont->hasByName(newName) )
722cdf0e10cSrcweir 	//		throw ElementExistException(newName,*this);
723cdf0e10cSrcweir 
724cdf0e10cSrcweir 	//	try
725cdf0e10cSrcweir 	//	{
726cdf0e10cSrcweir 	//		if ( xNameCont->hasByName(m_pImpl->m_aProps.aTitle) )
727cdf0e10cSrcweir 	//			xNameCont->removeByName(m_pImpl->m_aProps.aTitle);
728cdf0e10cSrcweir 
729cdf0e10cSrcweir 	//		m_pImpl->m_aProps.aTitle = newName;
730cdf0e10cSrcweir 	//		xNameCont->insertByName(m_pImpl->m_aProps.aTitle,makeAny(Reference<XContent>(*this,UNO_QUERY)));
731cdf0e10cSrcweir 	//		notifyDataSourceModified();
732cdf0e10cSrcweir 	//	}
733cdf0e10cSrcweir 	//	catch(IllegalArgumentException)
734cdf0e10cSrcweir 	//	{
735cdf0e10cSrcweir 	//		throw SQLException();
736cdf0e10cSrcweir 	//	}
737cdf0e10cSrcweir 	//	catch(NoSuchElementException)
738cdf0e10cSrcweir 	//	{
739cdf0e10cSrcweir 	//		throw SQLException();
740cdf0e10cSrcweir 	//	}
741cdf0e10cSrcweir 	//	catch(WrappedTargetException)
742cdf0e10cSrcweir 	//	{
743cdf0e10cSrcweir 	//		throw SQLException();
744cdf0e10cSrcweir 	//	}
745cdf0e10cSrcweir 	//}
746cdf0e10cSrcweir 	//else
747cdf0e10cSrcweir 	//	m_pImpl->m_aProps.aTitle = newName;
748cdf0e10cSrcweir 
749cdf0e10cSrcweir }
750cdf0e10cSrcweir // -----------------------------------------------------------------------------
notifyDataSourceModified()751cdf0e10cSrcweir void OContentHelper::notifyDataSourceModified()
752cdf0e10cSrcweir {
753cdf0e10cSrcweir 	::dbaccess::notifyDataSourceModified(m_xParentContainer,sal_True);
754cdf0e10cSrcweir }
755cdf0e10cSrcweir //........................................................................
756cdf0e10cSrcweir }	// namespace dbaccess
757cdf0e10cSrcweir //........................................................................
758cdf0e10cSrcweir 
759