update dev300-m58
[ooovba.git] / dbaccess / source / core / dataaccess / ContentHelper.cxx
blobfe3e7c9b9315abbdd9ed3174e0ba3091114d8831
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ContentHelper.cxx,v $
10 * $Revision: 1.12 $
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_dbaccess.hxx"
33 #ifndef DBA_CONTENTHELPER_HXX
34 #include "ContentHelper.hxx"
35 #endif
36 #ifndef _UCBHELPER_CANCELCOMMANDEXECUTION_HXX_
37 #include <ucbhelper/cancelcommandexecution.hxx>
38 #endif
39 #ifndef _COMPHELPER_PROPERTY_HXX_
40 #include <comphelper/property.hxx>
41 #endif
42 #ifndef _COM_SUN_STAR_UCB_UNSUPPORTEDCOMMANDEXCEPTION_HPP_
43 #include <com/sun/star/ucb/UnsupportedCommandException.hpp>
44 #endif
45 #ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_
46 #include <com/sun/star/lang/IllegalArgumentException.hpp>
47 #endif
48 #ifndef _COM_SUN_STAR_LANG_ILLEGALACCESSEXCEPTION_HPP_
49 #include <com/sun/star/lang/IllegalAccessException.hpp>
50 #endif
51 #ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_
52 #include <com/sun/star/io/XOutputStream.hpp>
53 #endif
54 #ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HPP_
55 #include <com/sun/star/io/XActiveDataSink.hpp>
56 #endif
57 #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
58 #include <com/sun/star/beans/PropertyAttribute.hpp>
59 #endif
60 #ifndef _UCBHELPER_PROPERTYVALUESET_HXX
61 #include <ucbhelper/propertyvalueset.hxx>
62 #endif
63 #ifndef _UCBHELPER_CONTENTIDENTIFIER_HXX
64 #include <ucbhelper/contentidentifier.hxx>
65 #endif
66 #ifndef DBA_UCPRESULTSET_HXX
67 #include "myucp_resultset.hxx"
68 #endif
69 #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
70 #include <com/sun/star/container/XNameContainer.hpp>
71 #endif
72 #ifndef DBACORE_SDBCORETOOLS_HXX
73 #include "sdbcoretools.hxx"
74 #endif
75 #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
76 #include "dbastrings.hrc"
77 #endif
78 #ifndef _TOOLS_DEBUG_HXX
79 #include <tools/debug.hxx>
80 #endif
83 namespace dbaccess
85 using namespace ::com::sun::star::uno;
86 using namespace ::com::sun::star::ucb;
87 using namespace ::com::sun::star::beans;
88 using namespace ::com::sun::star::lang;
89 using namespace ::com::sun::star::sdbc;
90 using namespace ::com::sun::star::io;
91 using namespace ::com::sun::star::util;
92 using namespace ::com::sun::star::embed;
93 using namespace ::com::sun::star::container;
94 using namespace ::comphelper;
95 using namespace ::cppu;
97 // -----------------------------------------------------------------------------
98 DBG_NAME(OContentHelper_Impl)
99 OContentHelper_Impl::OContentHelper_Impl()
101 DBG_CTOR(OContentHelper_Impl,NULL);
103 // -----------------------------------------------------------------------------
104 OContentHelper_Impl::~OContentHelper_Impl()
106 DBG_DTOR(OContentHelper_Impl,NULL);
108 // -----------------------------------------------------------------------------
110 OContentHelper::OContentHelper(const Reference< XMultiServiceFactory >& _xORB
111 ,const Reference< XInterface >& _xParentContainer
112 ,const TContentPtr& _pImpl)
113 : OContentHelper_COMPBASE(m_aMutex)
114 ,m_aContentListeners(m_aMutex)
115 ,m_aPropertyChangeListeners(m_aMutex)
116 ,m_xParentContainer(_xParentContainer)
117 ,m_aContext( _xORB )
118 ,m_aErrorHelper( m_aContext )
119 ,m_pImpl(_pImpl)
120 ,m_nCommandId(0)
123 //--------------------------------------------------------------------------
124 void SAL_CALL OContentHelper::disposing()
126 ::osl::MutexGuard aGuard(m_aMutex);
128 // say our listeners goobye
129 EventObject aEvt(*this);
130 m_aContentListeners.disposeAndClear(aEvt);
132 m_xParentContainer = NULL;
134 // -----------------------------------------------------------------------------
135 IMPLEMENT_SERVICE_INFO1(OContentHelper,"com.sun.star.comp.sdb.Content","com.sun.star.ucb.Content");
136 IMPLEMENT_IMPLEMENTATION_ID(OContentHelper)
137 // -----------------------------------------------------------------------------
138 // XContent
139 Reference< XContentIdentifier > SAL_CALL OContentHelper::getIdentifier( ) throw (RuntimeException)
141 ::osl::MutexGuard aGuard(m_aMutex);
142 ::rtl::OUString sContentId = m_pImpl->m_aProps.aTitle;
143 Reference< XInterface > xParent = m_xParentContainer;
144 while( xParent.is() )
146 Reference<XPropertySet> xProp(xParent,UNO_QUERY);
147 Reference<XChild> xChild(xParent,UNO_QUERY);
148 xParent.set(xChild.is() ? xChild->getParent() : Reference< XInterface >(),UNO_QUERY);
149 if ( xProp.is() && xParent.is() )
151 ::rtl::OUString sName;
152 xProp->getPropertyValue(PROPERTY_NAME) >>= sName;
153 sContentId = sName + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sContentId;
157 sContentId = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:")) + sContentId;
158 return new ::ucbhelper::ContentIdentifier( m_aContext.getLegacyServiceFactory(), sContentId );
159 // return Reference< XContentIdentifier >();
161 // -----------------------------------------------------------------------------
162 ::rtl::OUString SAL_CALL OContentHelper::getContentType() throw (RuntimeException)
164 ::osl::MutexGuard aGuard(m_aMutex);
166 if ( !m_pImpl->m_aProps.aContentType )
167 { // content type not yet retrieved
168 m_pImpl->m_aProps.aContentType.reset( determineContentType() );
171 return *m_pImpl->m_aProps.aContentType;
173 // -----------------------------------------------------------------------------
174 void SAL_CALL OContentHelper::addContentEventListener( const Reference< XContentEventListener >& _rxListener ) throw (RuntimeException)
176 ::osl::MutexGuard aGuard(m_aMutex);
177 if ( _rxListener.is() )
178 m_aContentListeners.addInterface(_rxListener);
180 // -----------------------------------------------------------------------------
181 void SAL_CALL OContentHelper::removeContentEventListener( const Reference< XContentEventListener >& _rxListener ) throw (RuntimeException)
183 ::osl::MutexGuard aGuard(m_aMutex);
184 if (_rxListener.is())
185 m_aContentListeners.removeInterface(_rxListener);
187 // -----------------------------------------------------------------------------
189 // XCommandProcessor
190 sal_Int32 SAL_CALL OContentHelper::createCommandIdentifier( ) throw (RuntimeException)
192 ::osl::MutexGuard aGuard(m_aMutex);
193 // Just increase counter on every call to generate an identifier.
194 return ++m_nCommandId;
196 // -----------------------------------------------------------------------------
197 Any SAL_CALL OContentHelper::execute( const Command& aCommand, sal_Int32 /*CommandId*/, const Reference< XCommandEnvironment >& Environment ) throw (Exception, CommandAbortedException, RuntimeException)
199 Any aRet;
200 if ( aCommand.Name.compareToAscii( "getPropertyValues" ) == 0 )
202 //////////////////////////////////////////////////////////////////
203 // getPropertyValues
204 //////////////////////////////////////////////////////////////////
206 Sequence< Property > Properties;
207 if ( !( aCommand.Argument >>= Properties ) )
209 OSL_ENSURE( sal_False, "Wrong argument type!" );
210 ucbhelper::cancelCommandExecution(
211 makeAny( IllegalArgumentException(
212 rtl::OUString(),
213 static_cast< cppu::OWeakObject * >( this ),
214 -1 ) ),
215 Environment );
216 // Unreachable
218 aRet <<= getPropertyValues( Properties);
220 else if ( aCommand.Name.compareToAscii( "setPropertyValues" ) == 0 )
222 //////////////////////////////////////////////////////////////////
223 // setPropertyValues
224 //////////////////////////////////////////////////////////////////
226 Sequence< PropertyValue > aProperties;
227 if ( !( aCommand.Argument >>= aProperties ) )
229 OSL_ENSURE( sal_False, "Wrong argument type!" );
230 ucbhelper::cancelCommandExecution(
231 makeAny( IllegalArgumentException(
232 rtl::OUString(),
233 static_cast< cppu::OWeakObject * >( this ),
234 -1 ) ),
235 Environment );
236 // Unreachable
239 if ( !aProperties.getLength() )
241 OSL_ENSURE( sal_False, "No properties!" );
242 ucbhelper::cancelCommandExecution(
243 makeAny( IllegalArgumentException(
244 rtl::OUString(),
245 static_cast< cppu::OWeakObject * >( this ),
246 -1 ) ),
247 Environment );
248 // Unreachable
251 aRet <<= setPropertyValues( aProperties, Environment );
253 else if ( aCommand.Name.compareToAscii( "getPropertySetInfo" ) == 0 )
255 //////////////////////////////////////////////////////////////////
256 // getPropertySetInfo
257 //////////////////////////////////////////////////////////////////
259 Reference<XPropertySet> xProp(*this,UNO_QUERY);
260 if ( xProp.is() )
261 aRet <<= xProp->getPropertySetInfo();
262 // aRet <<= getPropertySetInfo(); // TODO
264 else
266 //////////////////////////////////////////////////////////////////
267 // Unsupported command
268 //////////////////////////////////////////////////////////////////
270 OSL_ENSURE( sal_False, "Content::execute - unsupported command!" );
272 ucbhelper::cancelCommandExecution(
273 makeAny( UnsupportedCommandException(
274 rtl::OUString(),
275 static_cast< cppu::OWeakObject * >( this ) ) ),
276 Environment );
277 // Unreachable
280 return aRet;
282 // -----------------------------------------------------------------------------
283 void SAL_CALL OContentHelper::abort( sal_Int32 /*CommandId*/ ) throw (RuntimeException)
286 // -----------------------------------------------------------------------------
288 // XPropertiesChangeNotifier
289 void SAL_CALL OContentHelper::addPropertiesChangeListener( const Sequence< ::rtl::OUString >& PropertyNames, const Reference< XPropertiesChangeListener >& Listener ) throw (RuntimeException)
291 ::osl::MutexGuard aGuard(m_aMutex);
292 sal_Int32 nCount = PropertyNames.getLength();
293 if ( !nCount )
295 // Note: An empty sequence means a listener for "all" properties.
296 m_aPropertyChangeListeners.addInterface(::rtl::OUString(), Listener );
298 else
300 const ::rtl::OUString* pSeq = PropertyNames.getConstArray();
302 for ( sal_Int32 n = 0; n < nCount; ++n )
304 const ::rtl::OUString& rName = pSeq[ n ];
305 if ( rName.getLength() )
306 m_aPropertyChangeListeners.addInterface(rName, Listener );
310 // -----------------------------------------------------------------------------
311 void SAL_CALL OContentHelper::removePropertiesChangeListener( const Sequence< ::rtl::OUString >& PropertyNames, const Reference< XPropertiesChangeListener >& Listener ) throw (RuntimeException)
313 ::osl::MutexGuard aGuard(m_aMutex);
314 sal_Int32 nCount = PropertyNames.getLength();
315 if ( !nCount )
317 // Note: An empty sequence means a listener for "all" properties.
318 m_aPropertyChangeListeners.removeInterface( ::rtl::OUString(), Listener );
320 else
322 const ::rtl::OUString* pSeq = PropertyNames.getConstArray();
324 for ( sal_Int32 n = 0; n < nCount; ++n )
326 const ::rtl::OUString& rName = pSeq[ n ];
327 if ( rName.getLength() )
328 m_aPropertyChangeListeners.removeInterface( rName, Listener );
332 // -----------------------------------------------------------------------------
334 // XPropertyContainer
335 void SAL_CALL OContentHelper::addProperty( const ::rtl::OUString& /*Name*/, sal_Int16 /*Attributes*/, const Any& /*DefaultValue*/ ) throw (PropertyExistException, IllegalTypeException, IllegalArgumentException, RuntimeException)
337 DBG_ERROR( "OContentHelper::addProperty: not implemented!" );
339 // -----------------------------------------------------------------------------
340 void SAL_CALL OContentHelper::removeProperty( const ::rtl::OUString& /*Name*/ ) throw (UnknownPropertyException, NotRemoveableException, RuntimeException)
342 DBG_ERROR( "OContentHelper::removeProperty: not implemented!" );
344 // -----------------------------------------------------------------------------
345 // XInitialization
346 void SAL_CALL OContentHelper::initialize( const Sequence< Any >& _aArguments ) throw(Exception, RuntimeException)
348 const Any* pBegin = _aArguments.getConstArray();
349 const Any* pEnd = pBegin + _aArguments.getLength();
350 PropertyValue aValue;;
351 for(;pBegin != pEnd;++pBegin)
353 *pBegin >>= aValue;
354 if ( aValue.Name.equalsAscii("Parent") )
356 m_xParentContainer.set(aValue.Value,UNO_QUERY);
358 else if ( aValue.Name.equalsAscii(PROPERTY_NAME) )
360 aValue.Value >>= m_pImpl->m_aProps.aTitle;
362 else if ( aValue.Name.equalsAscii(PROPERTY_PERSISTENT_NAME) )
364 aValue.Value >>= m_pImpl->m_aProps.sPersistentName;
368 // -----------------------------------------------------------------------------
369 Sequence< Any > OContentHelper::setPropertyValues(const Sequence< PropertyValue >& rValues,const Reference< XCommandEnvironment >& /*xEnv*/ )
371 osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex );
373 Sequence< Any > aRet( rValues.getLength() );
374 Sequence< PropertyChangeEvent > aChanges( rValues.getLength() );
375 sal_Int32 nChanged = 0;
377 PropertyChangeEvent aEvent;
378 aEvent.Source = static_cast< cppu::OWeakObject * >( this );
379 aEvent.Further = sal_False;
380 aEvent.PropertyHandle = -1;
382 const PropertyValue* pValues = rValues.getConstArray();
383 sal_Int32 nCount = rValues.getLength();
385 for ( sal_Int32 n = 0; n < nCount; ++n )
387 const PropertyValue& rValue = pValues[ n ];
389 if ( rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) )
391 // Read-only property!
392 aRet[ n ] <<= IllegalAccessException(
393 rtl::OUString::createFromAscii(
394 "Property is read-only!" ),
395 static_cast< cppu::OWeakObject * >( this ) );
397 else if ( rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) )
399 // Read-only property!
400 aRet[ n ] <<= IllegalAccessException(
401 rtl::OUString::createFromAscii(
402 "Property is read-only!" ),
403 static_cast< cppu::OWeakObject * >( this ) );
405 else if ( rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) )
407 // Read-only property!
408 aRet[ n ] <<= IllegalAccessException(
409 rtl::OUString::createFromAscii(
410 "Property is read-only!" ),
411 static_cast< cppu::OWeakObject * >( this ) );
413 else if ( rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
415 rtl::OUString aNewValue;
416 if ( rValue.Value >>= aNewValue )
418 if ( aNewValue != m_pImpl->m_aProps.aTitle )
420 aEvent.PropertyName = rValue.Name;
421 aEvent.OldValue = makeAny( m_pImpl->m_aProps.aTitle );
425 impl_rename_throw( aNewValue ,false);
426 OSL_ENSURE( m_pImpl->m_aProps.aTitle == aNewValue, "OContentHelper::setPropertyValues('Title'): rename did not work!" );
428 aEvent.NewValue = makeAny( aNewValue );
429 aChanges.getArray()[ nChanged ] = aEvent;
430 nChanged++;
432 catch( const Exception& )
434 OSL_ENSURE( sal_False, "OContentHelper::setPropertyValues('Title'): caught an exception while renaming!" );
437 else
439 // Old value equals new value. No error!
442 else
444 aRet[ n ] <<= IllegalTypeException(
445 rtl::OUString::createFromAscii(
446 "Property value has wrong type!" ),
447 static_cast< cppu::OWeakObject * >( this ) );
451 // @@@ Process other properties supported directly.
452 #if 0
453 else if ( rValue.Name.equalsAsciiL(
454 RTL_CONSTASCII_STRINGPARAM( "xxxxxx" ) ) )
457 #endif
458 else
460 aRet[ n ] <<= Exception(
461 rtl::OUString::createFromAscii(
462 "No property set for storing the value!" ),
463 static_cast< cppu::OWeakObject * >( this ) );
467 if ( nChanged > 0 )
469 // @@@ Save changes.
470 // storeData();
472 notifyDataSourceModified();
473 aGuard.clear();
474 aChanges.realloc( nChanged );
475 notifyPropertiesChange( aChanges );
478 return aRet;
480 // -----------------------------------------------------------------------------
481 //=========================================================================
482 // static
483 Reference< XRow > OContentHelper::getPropertyValues( const Sequence< Property >& rProperties)
485 // Note: Empty sequence means "get values of all supported properties".
487 rtl::Reference< ::ucbhelper::PropertyValueSet > xRow = new ::ucbhelper::PropertyValueSet( m_aContext.getLegacyServiceFactory() );
489 sal_Int32 nCount = rProperties.getLength();
490 if ( nCount )
492 const Property* pProps = rProperties.getConstArray();
493 for ( sal_Int32 n = 0; n < nCount; ++n )
495 const Property& rProp = pProps[ n ];
497 // Process Core properties.
499 if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) )
501 xRow->appendString ( rProp, getContentType() );
503 else if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
505 xRow->appendString ( rProp, m_pImpl->m_aProps.aTitle );
507 else if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) )
509 xRow->appendBoolean( rProp, m_pImpl->m_aProps.bIsDocument );
511 else if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) )
513 xRow->appendBoolean( rProp, m_pImpl->m_aProps.bIsFolder );
515 else
516 xRow->appendVoid(rProp);
518 // @@@ Process other properties supported directly.
519 #if 0
520 else if ( rProp.Name.equalsAsciiL(
521 RTL_CONSTASCII_STRINGPARAM( "xxxxxx" ) ) )
524 #endif
527 else
529 // Append all Core Properties.
530 xRow->appendString (
531 Property( rtl::OUString::createFromAscii( "ContentType" ),
533 getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
534 PropertyAttribute::BOUND
535 | PropertyAttribute::READONLY ),
536 getContentType() );
537 xRow->appendString (
538 Property( rtl::OUString::createFromAscii( "Title" ),
540 getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
541 PropertyAttribute::BOUND ),
542 m_pImpl->m_aProps.aTitle );
543 xRow->appendBoolean(
544 Property( rtl::OUString::createFromAscii( "IsDocument" ),
546 getCppuBooleanType(),
547 PropertyAttribute::BOUND
548 | PropertyAttribute::READONLY ),
549 m_pImpl->m_aProps.bIsDocument );
550 xRow->appendBoolean(
551 Property( rtl::OUString::createFromAscii( "IsFolder" ),
553 getCppuBooleanType(),
554 PropertyAttribute::BOUND
555 | PropertyAttribute::READONLY ),
556 m_pImpl->m_aProps.bIsFolder );
558 // @@@ Append other properties supported directly.
561 return Reference< XRow >( xRow.get() );
563 // -----------------------------------------------------------------------------
564 // -----------------------------------------------------------------------------
565 void OContentHelper::notifyPropertiesChange( const Sequence< PropertyChangeEvent >& evt ) const
568 sal_Int32 nCount = evt.getLength();
569 if ( nCount )
571 // First, notify listeners interested in changes of every property.
572 OInterfaceContainerHelper* pAllPropsContainer = m_aPropertyChangeListeners.getContainer( ::rtl::OUString() );
573 if ( pAllPropsContainer )
575 OInterfaceIteratorHelper aIter( *pAllPropsContainer );
576 while ( aIter.hasMoreElements() )
578 // Propagate event.
579 Reference< XPropertiesChangeListener > xListener( aIter.next(), UNO_QUERY );
580 if ( xListener.is() )
581 xListener->propertiesChange( evt );
585 typedef Sequence< PropertyChangeEvent > PropertyEventSequence;
586 typedef ::std::map< XPropertiesChangeListener*, PropertyEventSequence* > PropertiesEventListenerMap;
587 PropertiesEventListenerMap aListeners;
590 const PropertyChangeEvent* propertyChangeEvent = evt.getConstArray();
592 for ( sal_Int32 n = 0; n < nCount; ++n, ++propertyChangeEvent )
594 const PropertyChangeEvent& rEvent = *propertyChangeEvent;
595 const ::rtl::OUString& rName = rEvent.PropertyName;
597 OInterfaceContainerHelper* pPropsContainer = m_aPropertyChangeListeners.getContainer( rName );
598 if ( pPropsContainer )
600 OInterfaceIteratorHelper aIter( *pPropsContainer );
601 while ( aIter.hasMoreElements() )
603 PropertyEventSequence* propertyEvents = NULL;
605 XPropertiesChangeListener* pListener = static_cast< XPropertiesChangeListener * >( aIter.next() );
606 PropertiesEventListenerMap::iterator it = aListeners.find( pListener );
607 if ( it == aListeners.end() )
609 // Not in map - create and insert new entry.
610 propertyEvents = new PropertyEventSequence( nCount );
611 aListeners[ pListener ] = propertyEvents;
613 else
614 propertyEvents = (*it).second;
616 if ( propertyEvents )
617 (*propertyEvents)[n] = rEvent;
622 // Notify listeners.
623 PropertiesEventListenerMap::iterator it = aListeners.begin();
624 while ( !aListeners.empty() )
626 XPropertiesChangeListener* pListener =
627 static_cast< XPropertiesChangeListener * >( (*it).first );
628 PropertyEventSequence* pSeq = (*it).second;
630 // Remove current element.
631 aListeners.erase( it );
633 // Propagate event.
634 pListener->propertiesChange( *pSeq );
636 delete pSeq;
638 it = aListeners.begin();
642 // -----------------------------------------------------------------------------
643 // com::sun::star::lang::XUnoTunnel
644 //------------------------------------------------------------------
645 sal_Int64 OContentHelper::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
647 if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
648 return reinterpret_cast<sal_Int64>(this);
650 return 0;
653 // -----------------------------------------------------------------------------
654 OContentHelper* OContentHelper::getImplementation( const Reference< XInterface >& _rxComponent )
656 OContentHelper* pContent( NULL );
658 Reference< XUnoTunnel > xUnoTunnel( _rxComponent, UNO_QUERY );
659 if ( xUnoTunnel.is() )
660 pContent = reinterpret_cast< OContentHelper* >( xUnoTunnel->getSomething( getUnoTunnelImplementationId() ) );
662 return pContent;
665 // -----------------------------------------------------------------------------
666 Reference< XInterface > SAL_CALL OContentHelper::getParent( ) throw (RuntimeException)
668 ::osl::MutexGuard aGuard(m_aMutex);
669 return m_xParentContainer;
671 // -----------------------------------------------------------------------------
672 void SAL_CALL OContentHelper::setParent( const Reference< XInterface >& _xParent ) throw (NoSupportException, RuntimeException)
674 ::osl::MutexGuard aGuard(m_aMutex);
675 m_xParentContainer = _xParent;
678 // -----------------------------------------------------------------------------
679 void OContentHelper::impl_rename_throw(const ::rtl::OUString& _sNewName,bool _bNotify )
681 osl::ClearableGuard< osl::Mutex > aGuard(m_aMutex);
682 if ( _sNewName.equals( m_pImpl->m_aProps.aTitle ) )
683 return;
686 Sequence< PropertyChangeEvent > aChanges( 1 );
688 aChanges[0].Source = static_cast< cppu::OWeakObject * >( this );
689 aChanges[0].Further = sal_False;
690 aChanges[0].PropertyName = PROPERTY_NAME;
691 aChanges[0].PropertyHandle = PROPERTY_ID_NAME;
692 aChanges[0].OldValue <<= m_pImpl->m_aProps.aTitle;
693 aChanges[0].NewValue <<= _sNewName;
695 aGuard.clear();
697 m_pImpl->m_aProps.aTitle = _sNewName;
698 if ( _bNotify )
699 notifyPropertiesChange( aChanges );
700 notifyDataSourceModified();
702 catch(const PropertyVetoException&)
704 throw ElementExistException(_sNewName,*this);
707 // -----------------------------------------------------------------------------
708 void SAL_CALL OContentHelper::rename( const ::rtl::OUString& newName ) throw (SQLException, ElementExistException, RuntimeException)
711 impl_rename_throw(newName);
712 //Reference<XNameContainer> xNameCont(m_xParentContainer,UNO_QUERY);
713 //if ( xNameCont.is() )
715 // if ( xNameCont->hasByName(newName) )
716 // throw ElementExistException(newName,*this);
718 // try
719 // {
720 // if ( xNameCont->hasByName(m_pImpl->m_aProps.aTitle) )
721 // xNameCont->removeByName(m_pImpl->m_aProps.aTitle);
723 // m_pImpl->m_aProps.aTitle = newName;
724 // xNameCont->insertByName(m_pImpl->m_aProps.aTitle,makeAny(Reference<XContent>(*this,UNO_QUERY)));
725 // notifyDataSourceModified();
726 // }
727 // catch(IllegalArgumentException)
728 // {
729 // throw SQLException();
730 // }
731 // catch(NoSuchElementException)
732 // {
733 // throw SQLException();
734 // }
735 // catch(WrappedTargetException)
736 // {
737 // throw SQLException();
738 // }
740 //else
741 // m_pImpl->m_aProps.aTitle = newName;
744 // -----------------------------------------------------------------------------
745 void OContentHelper::notifyDataSourceModified()
747 ::dbaccess::notifyDataSourceModified(m_xParentContainer,sal_True);
749 //........................................................................
750 } // namespace dbaccess
751 //........................................................................