1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ContentHelper.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
33 #ifndef DBA_CONTENTHELPER_HXX
34 #include "ContentHelper.hxx"
36 #ifndef _UCBHELPER_CANCELCOMMANDEXECUTION_HXX_
37 #include <ucbhelper/cancelcommandexecution.hxx>
39 #ifndef _COMPHELPER_PROPERTY_HXX_
40 #include <comphelper/property.hxx>
42 #ifndef _COM_SUN_STAR_UCB_UNSUPPORTEDCOMMANDEXCEPTION_HPP_
43 #include <com/sun/star/ucb/UnsupportedCommandException.hpp>
45 #ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_
46 #include <com/sun/star/lang/IllegalArgumentException.hpp>
48 #ifndef _COM_SUN_STAR_LANG_ILLEGALACCESSEXCEPTION_HPP_
49 #include <com/sun/star/lang/IllegalAccessException.hpp>
51 #ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_
52 #include <com/sun/star/io/XOutputStream.hpp>
54 #ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HPP_
55 #include <com/sun/star/io/XActiveDataSink.hpp>
57 #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
58 #include <com/sun/star/beans/PropertyAttribute.hpp>
60 #ifndef _UCBHELPER_PROPERTYVALUESET_HXX
61 #include <ucbhelper/propertyvalueset.hxx>
63 #ifndef _UCBHELPER_CONTENTIDENTIFIER_HXX
64 #include <ucbhelper/contentidentifier.hxx>
66 #ifndef DBA_UCPRESULTSET_HXX
67 #include "myucp_resultset.hxx"
69 #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
70 #include <com/sun/star/container/XNameContainer.hpp>
72 #ifndef DBACORE_SDBCORETOOLS_HXX
73 #include "sdbcoretools.hxx"
75 #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
76 #include "dbastrings.hrc"
78 #ifndef _TOOLS_DEBUG_HXX
79 #include <tools/debug.hxx>
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
)
118 ,m_aErrorHelper( m_aContext
)
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 // -----------------------------------------------------------------------------
139 Reference
< XContentIdentifier
> SAL_CALL
OContentHelper::getIdentifier( ) throw (RuntimeException
)
141 ::osl::MutexGuard
aGuard(m_aMutex
);
142 ::rtl::OUStringBuffer aIdentifier
;
143 aIdentifier
.appendAscii( "private:" );
144 aIdentifier
.append( impl_getHierarchicalName( true ) );
145 return new ::ucbhelper::ContentIdentifier( m_aContext
.getLegacyServiceFactory(), aIdentifier
.makeStringAndClear() );
147 // -----------------------------------------------------------------------------
148 ::rtl::OUString
OContentHelper::impl_getHierarchicalName( bool _includingRootContainer
) const
150 ::rtl::OUStringBuffer
aHierarchicalName( m_pImpl
->m_aProps
.aTitle
);
151 Reference
< XInterface
> xParent
= m_xParentContainer
;
152 while( xParent
.is() )
154 Reference
<XPropertySet
> xProp( xParent
, UNO_QUERY
);
155 Reference
< XChild
> xChild( xParent
, UNO_QUERY
);
156 xParent
.set( xChild
.is() ? xChild
->getParent() : Reference
< XInterface
>(), UNO_QUERY
);
157 if ( xProp
.is() && xParent
.is() )
159 ::rtl::OUString sName
;
160 xProp
->getPropertyValue( PROPERTY_NAME
) >>= sName
;
162 ::rtl::OUString sPrevious
= aHierarchicalName
.makeStringAndClear();
163 aHierarchicalName
.append( sName
);
164 aHierarchicalName
.append( sal_Unicode( '/' ) );
165 aHierarchicalName
.append( sPrevious
);
168 ::rtl::OUString
sHierarchicalName( aHierarchicalName
.makeStringAndClear() );
169 if ( !_includingRootContainer
)
170 sHierarchicalName
= sHierarchicalName
.copy( sHierarchicalName
.indexOf( '/' ) + 1 );
171 return sHierarchicalName
;
174 // -----------------------------------------------------------------------------
175 ::rtl::OUString SAL_CALL
OContentHelper::getContentType() throw (RuntimeException
)
177 ::osl::MutexGuard
aGuard(m_aMutex
);
179 if ( !m_pImpl
->m_aProps
.aContentType
)
180 { // content type not yet retrieved
181 m_pImpl
->m_aProps
.aContentType
.reset( determineContentType() );
184 return *m_pImpl
->m_aProps
.aContentType
;
186 // -----------------------------------------------------------------------------
187 void SAL_CALL
OContentHelper::addContentEventListener( const Reference
< XContentEventListener
>& _rxListener
) throw (RuntimeException
)
189 ::osl::MutexGuard
aGuard(m_aMutex
);
190 if ( _rxListener
.is() )
191 m_aContentListeners
.addInterface(_rxListener
);
193 // -----------------------------------------------------------------------------
194 void SAL_CALL
OContentHelper::removeContentEventListener( const Reference
< XContentEventListener
>& _rxListener
) throw (RuntimeException
)
196 ::osl::MutexGuard
aGuard(m_aMutex
);
197 if (_rxListener
.is())
198 m_aContentListeners
.removeInterface(_rxListener
);
200 // -----------------------------------------------------------------------------
203 sal_Int32 SAL_CALL
OContentHelper::createCommandIdentifier( ) throw (RuntimeException
)
205 ::osl::MutexGuard
aGuard(m_aMutex
);
206 // Just increase counter on every call to generate an identifier.
207 return ++m_nCommandId
;
209 // -----------------------------------------------------------------------------
210 Any SAL_CALL
OContentHelper::execute( const Command
& aCommand
, sal_Int32
/*CommandId*/, const Reference
< XCommandEnvironment
>& Environment
) throw (Exception
, CommandAbortedException
, RuntimeException
)
213 if ( aCommand
.Name
.compareToAscii( "getPropertyValues" ) == 0 )
215 //////////////////////////////////////////////////////////////////
217 //////////////////////////////////////////////////////////////////
219 Sequence
< Property
> Properties
;
220 if ( !( aCommand
.Argument
>>= Properties
) )
222 OSL_ENSURE( sal_False
, "Wrong argument type!" );
223 ucbhelper::cancelCommandExecution(
224 makeAny( IllegalArgumentException(
226 static_cast< cppu::OWeakObject
* >( this ),
231 aRet
<<= getPropertyValues( Properties
);
233 else if ( aCommand
.Name
.compareToAscii( "setPropertyValues" ) == 0 )
235 //////////////////////////////////////////////////////////////////
237 //////////////////////////////////////////////////////////////////
239 Sequence
< PropertyValue
> aProperties
;
240 if ( !( aCommand
.Argument
>>= aProperties
) )
242 OSL_ENSURE( sal_False
, "Wrong argument type!" );
243 ucbhelper::cancelCommandExecution(
244 makeAny( IllegalArgumentException(
246 static_cast< cppu::OWeakObject
* >( this ),
252 if ( !aProperties
.getLength() )
254 OSL_ENSURE( sal_False
, "No properties!" );
255 ucbhelper::cancelCommandExecution(
256 makeAny( IllegalArgumentException(
258 static_cast< cppu::OWeakObject
* >( this ),
264 aRet
<<= setPropertyValues( aProperties
, Environment
);
266 else if ( aCommand
.Name
.compareToAscii( "getPropertySetInfo" ) == 0 )
268 //////////////////////////////////////////////////////////////////
269 // getPropertySetInfo
270 //////////////////////////////////////////////////////////////////
272 Reference
<XPropertySet
> xProp(*this,UNO_QUERY
);
274 aRet
<<= xProp
->getPropertySetInfo();
275 // aRet <<= getPropertySetInfo(); // TODO
279 //////////////////////////////////////////////////////////////////
280 // Unsupported command
281 //////////////////////////////////////////////////////////////////
283 OSL_ENSURE( sal_False
, "Content::execute - unsupported command!" );
285 ucbhelper::cancelCommandExecution(
286 makeAny( UnsupportedCommandException(
288 static_cast< cppu::OWeakObject
* >( this ) ) ),
295 // -----------------------------------------------------------------------------
296 void SAL_CALL
OContentHelper::abort( sal_Int32
/*CommandId*/ ) throw (RuntimeException
)
299 // -----------------------------------------------------------------------------
301 // XPropertiesChangeNotifier
302 void SAL_CALL
OContentHelper::addPropertiesChangeListener( const Sequence
< ::rtl::OUString
>& PropertyNames
, const Reference
< XPropertiesChangeListener
>& Listener
) throw (RuntimeException
)
304 ::osl::MutexGuard
aGuard(m_aMutex
);
305 sal_Int32 nCount
= PropertyNames
.getLength();
308 // Note: An empty sequence means a listener for "all" properties.
309 m_aPropertyChangeListeners
.addInterface(::rtl::OUString(), Listener
);
313 const ::rtl::OUString
* pSeq
= PropertyNames
.getConstArray();
315 for ( sal_Int32 n
= 0; n
< nCount
; ++n
)
317 const ::rtl::OUString
& rName
= pSeq
[ n
];
318 if ( rName
.getLength() )
319 m_aPropertyChangeListeners
.addInterface(rName
, Listener
);
323 // -----------------------------------------------------------------------------
324 void SAL_CALL
OContentHelper::removePropertiesChangeListener( const Sequence
< ::rtl::OUString
>& PropertyNames
, const Reference
< XPropertiesChangeListener
>& Listener
) throw (RuntimeException
)
326 ::osl::MutexGuard
aGuard(m_aMutex
);
327 sal_Int32 nCount
= PropertyNames
.getLength();
330 // Note: An empty sequence means a listener for "all" properties.
331 m_aPropertyChangeListeners
.removeInterface( ::rtl::OUString(), Listener
);
335 const ::rtl::OUString
* pSeq
= PropertyNames
.getConstArray();
337 for ( sal_Int32 n
= 0; n
< nCount
; ++n
)
339 const ::rtl::OUString
& rName
= pSeq
[ n
];
340 if ( rName
.getLength() )
341 m_aPropertyChangeListeners
.removeInterface( rName
, Listener
);
345 // -----------------------------------------------------------------------------
347 // XPropertyContainer
348 void SAL_CALL
OContentHelper::addProperty( const ::rtl::OUString
& /*Name*/, sal_Int16
/*Attributes*/, const Any
& /*DefaultValue*/ ) throw (PropertyExistException
, IllegalTypeException
, IllegalArgumentException
, RuntimeException
)
350 DBG_ERROR( "OContentHelper::addProperty: not implemented!" );
352 // -----------------------------------------------------------------------------
353 void SAL_CALL
OContentHelper::removeProperty( const ::rtl::OUString
& /*Name*/ ) throw (UnknownPropertyException
, NotRemoveableException
, RuntimeException
)
355 DBG_ERROR( "OContentHelper::removeProperty: not implemented!" );
357 // -----------------------------------------------------------------------------
359 void SAL_CALL
OContentHelper::initialize( const Sequence
< Any
>& _aArguments
) throw(Exception
, RuntimeException
)
361 const Any
* pBegin
= _aArguments
.getConstArray();
362 const Any
* pEnd
= pBegin
+ _aArguments
.getLength();
363 PropertyValue aValue
;;
364 for(;pBegin
!= pEnd
;++pBegin
)
367 if ( aValue
.Name
.equalsAscii("Parent") )
369 m_xParentContainer
.set(aValue
.Value
,UNO_QUERY
);
371 else if ( aValue
.Name
.equalsAscii(PROPERTY_NAME
) )
373 aValue
.Value
>>= m_pImpl
->m_aProps
.aTitle
;
375 else if ( aValue
.Name
.equalsAscii(PROPERTY_PERSISTENT_NAME
) )
377 aValue
.Value
>>= m_pImpl
->m_aProps
.sPersistentName
;
381 // -----------------------------------------------------------------------------
382 Sequence
< Any
> OContentHelper::setPropertyValues(const Sequence
< PropertyValue
>& rValues
,const Reference
< XCommandEnvironment
>& /*xEnv*/ )
384 osl::ClearableGuard
< osl::Mutex
> aGuard( m_aMutex
);
386 Sequence
< Any
> aRet( rValues
.getLength() );
387 Sequence
< PropertyChangeEvent
> aChanges( rValues
.getLength() );
388 sal_Int32 nChanged
= 0;
390 PropertyChangeEvent aEvent
;
391 aEvent
.Source
= static_cast< cppu::OWeakObject
* >( this );
392 aEvent
.Further
= sal_False
;
393 aEvent
.PropertyHandle
= -1;
395 const PropertyValue
* pValues
= rValues
.getConstArray();
396 sal_Int32 nCount
= rValues
.getLength();
398 for ( sal_Int32 n
= 0; n
< nCount
; ++n
)
400 const PropertyValue
& rValue
= pValues
[ n
];
402 if ( rValue
.Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) )
404 // Read-only property!
405 aRet
[ n
] <<= IllegalAccessException(
406 rtl::OUString::createFromAscii(
407 "Property is read-only!" ),
408 static_cast< cppu::OWeakObject
* >( this ) );
410 else if ( rValue
.Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) )
412 // Read-only property!
413 aRet
[ n
] <<= IllegalAccessException(
414 rtl::OUString::createFromAscii(
415 "Property is read-only!" ),
416 static_cast< cppu::OWeakObject
* >( this ) );
418 else if ( rValue
.Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) )
420 // Read-only property!
421 aRet
[ n
] <<= IllegalAccessException(
422 rtl::OUString::createFromAscii(
423 "Property is read-only!" ),
424 static_cast< cppu::OWeakObject
* >( this ) );
426 else if ( rValue
.Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
428 rtl::OUString aNewValue
;
429 if ( rValue
.Value
>>= aNewValue
)
431 if ( aNewValue
!= m_pImpl
->m_aProps
.aTitle
)
433 aEvent
.PropertyName
= rValue
.Name
;
434 aEvent
.OldValue
= makeAny( m_pImpl
->m_aProps
.aTitle
);
438 impl_rename_throw( aNewValue
,false);
439 OSL_ENSURE( m_pImpl
->m_aProps
.aTitle
== aNewValue
, "OContentHelper::setPropertyValues('Title'): rename did not work!" );
441 aEvent
.NewValue
= makeAny( aNewValue
);
442 aChanges
.getArray()[ nChanged
] = aEvent
;
445 catch( const Exception
& )
447 OSL_ENSURE( sal_False
, "OContentHelper::setPropertyValues('Title'): caught an exception while renaming!" );
452 // Old value equals new value. No error!
457 aRet
[ n
] <<= IllegalTypeException(
458 rtl::OUString::createFromAscii(
459 "Property value has wrong type!" ),
460 static_cast< cppu::OWeakObject
* >( this ) );
464 // @@@ Process other properties supported directly.
466 else if ( rValue
.Name
.equalsAsciiL(
467 RTL_CONSTASCII_STRINGPARAM( "xxxxxx" ) ) )
473 aRet
[ n
] <<= Exception(
474 rtl::OUString::createFromAscii(
475 "No property set for storing the value!" ),
476 static_cast< cppu::OWeakObject
* >( this ) );
485 notifyDataSourceModified();
487 aChanges
.realloc( nChanged
);
488 notifyPropertiesChange( aChanges
);
493 // -----------------------------------------------------------------------------
494 //=========================================================================
496 Reference
< XRow
> OContentHelper::getPropertyValues( const Sequence
< Property
>& rProperties
)
498 // Note: Empty sequence means "get values of all supported properties".
500 rtl::Reference
< ::ucbhelper::PropertyValueSet
> xRow
= new ::ucbhelper::PropertyValueSet( m_aContext
.getLegacyServiceFactory() );
502 sal_Int32 nCount
= rProperties
.getLength();
505 const Property
* pProps
= rProperties
.getConstArray();
506 for ( sal_Int32 n
= 0; n
< nCount
; ++n
)
508 const Property
& rProp
= pProps
[ n
];
510 // Process Core properties.
512 if ( rProp
.Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) )
514 xRow
->appendString ( rProp
, getContentType() );
516 else if ( rProp
.Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
518 xRow
->appendString ( rProp
, m_pImpl
->m_aProps
.aTitle
);
520 else if ( rProp
.Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) )
522 xRow
->appendBoolean( rProp
, m_pImpl
->m_aProps
.bIsDocument
);
524 else if ( rProp
.Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) )
526 xRow
->appendBoolean( rProp
, m_pImpl
->m_aProps
.bIsFolder
);
529 xRow
->appendVoid(rProp
);
531 // @@@ Process other properties supported directly.
533 else if ( rProp
.Name
.equalsAsciiL(
534 RTL_CONSTASCII_STRINGPARAM( "xxxxxx" ) ) )
542 // Append all Core Properties.
544 Property( rtl::OUString::createFromAscii( "ContentType" ),
546 getCppuType( static_cast< const rtl::OUString
* >( 0 ) ),
547 PropertyAttribute::BOUND
548 | PropertyAttribute::READONLY
),
551 Property( rtl::OUString::createFromAscii( "Title" ),
553 getCppuType( static_cast< const rtl::OUString
* >( 0 ) ),
554 PropertyAttribute::BOUND
),
555 m_pImpl
->m_aProps
.aTitle
);
557 Property( rtl::OUString::createFromAscii( "IsDocument" ),
559 getCppuBooleanType(),
560 PropertyAttribute::BOUND
561 | PropertyAttribute::READONLY
),
562 m_pImpl
->m_aProps
.bIsDocument
);
564 Property( rtl::OUString::createFromAscii( "IsFolder" ),
566 getCppuBooleanType(),
567 PropertyAttribute::BOUND
568 | PropertyAttribute::READONLY
),
569 m_pImpl
->m_aProps
.bIsFolder
);
571 // @@@ Append other properties supported directly.
574 return Reference
< XRow
>( xRow
.get() );
576 // -----------------------------------------------------------------------------
577 // -----------------------------------------------------------------------------
578 void OContentHelper::notifyPropertiesChange( const Sequence
< PropertyChangeEvent
>& evt
) const
581 sal_Int32 nCount
= evt
.getLength();
584 // First, notify listeners interested in changes of every property.
585 OInterfaceContainerHelper
* pAllPropsContainer
= m_aPropertyChangeListeners
.getContainer( ::rtl::OUString() );
586 if ( pAllPropsContainer
)
588 OInterfaceIteratorHelper
aIter( *pAllPropsContainer
);
589 while ( aIter
.hasMoreElements() )
592 Reference
< XPropertiesChangeListener
> xListener( aIter
.next(), UNO_QUERY
);
593 if ( xListener
.is() )
594 xListener
->propertiesChange( evt
);
598 typedef Sequence
< PropertyChangeEvent
> PropertyEventSequence
;
599 typedef ::std::map
< XPropertiesChangeListener
*, PropertyEventSequence
* > PropertiesEventListenerMap
;
600 PropertiesEventListenerMap aListeners
;
603 const PropertyChangeEvent
* propertyChangeEvent
= evt
.getConstArray();
605 for ( sal_Int32 n
= 0; n
< nCount
; ++n
, ++propertyChangeEvent
)
607 const PropertyChangeEvent
& rEvent
= *propertyChangeEvent
;
608 const ::rtl::OUString
& rName
= rEvent
.PropertyName
;
610 OInterfaceContainerHelper
* pPropsContainer
= m_aPropertyChangeListeners
.getContainer( rName
);
611 if ( pPropsContainer
)
613 OInterfaceIteratorHelper
aIter( *pPropsContainer
);
614 while ( aIter
.hasMoreElements() )
616 PropertyEventSequence
* propertyEvents
= NULL
;
618 XPropertiesChangeListener
* pListener
= static_cast< XPropertiesChangeListener
* >( aIter
.next() );
619 PropertiesEventListenerMap::iterator it
= aListeners
.find( pListener
);
620 if ( it
== aListeners
.end() )
622 // Not in map - create and insert new entry.
623 propertyEvents
= new PropertyEventSequence( nCount
);
624 aListeners
[ pListener
] = propertyEvents
;
627 propertyEvents
= (*it
).second
;
629 if ( propertyEvents
)
630 (*propertyEvents
)[n
] = rEvent
;
636 PropertiesEventListenerMap::iterator it
= aListeners
.begin();
637 while ( !aListeners
.empty() )
639 XPropertiesChangeListener
* pListener
=
640 static_cast< XPropertiesChangeListener
* >( (*it
).first
);
641 PropertyEventSequence
* pSeq
= (*it
).second
;
643 // Remove current element.
644 aListeners
.erase( it
);
647 pListener
->propertiesChange( *pSeq
);
651 it
= aListeners
.begin();
655 // -----------------------------------------------------------------------------
656 // com::sun::star::lang::XUnoTunnel
657 //------------------------------------------------------------------
658 sal_Int64
OContentHelper::getSomething( const Sequence
< sal_Int8
> & rId
) throw (RuntimeException
)
660 if (rId
.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId
.getConstArray(), 16 ) )
661 return reinterpret_cast<sal_Int64
>(this);
666 // -----------------------------------------------------------------------------
667 OContentHelper
* OContentHelper::getImplementation( const Reference
< XInterface
>& _rxComponent
)
669 OContentHelper
* pContent( NULL
);
671 Reference
< XUnoTunnel
> xUnoTunnel( _rxComponent
, UNO_QUERY
);
672 if ( xUnoTunnel
.is() )
673 pContent
= reinterpret_cast< OContentHelper
* >( xUnoTunnel
->getSomething( getUnoTunnelImplementationId() ) );
678 // -----------------------------------------------------------------------------
679 Reference
< XInterface
> SAL_CALL
OContentHelper::getParent( ) throw (RuntimeException
)
681 ::osl::MutexGuard
aGuard(m_aMutex
);
682 return m_xParentContainer
;
684 // -----------------------------------------------------------------------------
685 void SAL_CALL
OContentHelper::setParent( const Reference
< XInterface
>& _xParent
) throw (NoSupportException
, RuntimeException
)
687 ::osl::MutexGuard
aGuard(m_aMutex
);
688 m_xParentContainer
= _xParent
;
691 // -----------------------------------------------------------------------------
692 void OContentHelper::impl_rename_throw(const ::rtl::OUString
& _sNewName
,bool _bNotify
)
694 osl::ClearableGuard
< osl::Mutex
> aGuard(m_aMutex
);
695 if ( _sNewName
.equals( m_pImpl
->m_aProps
.aTitle
) )
699 Sequence
< PropertyChangeEvent
> aChanges( 1 );
701 aChanges
[0].Source
= static_cast< cppu::OWeakObject
* >( this );
702 aChanges
[0].Further
= sal_False
;
703 aChanges
[0].PropertyName
= PROPERTY_NAME
;
704 aChanges
[0].PropertyHandle
= PROPERTY_ID_NAME
;
705 aChanges
[0].OldValue
<<= m_pImpl
->m_aProps
.aTitle
;
706 aChanges
[0].NewValue
<<= _sNewName
;
710 m_pImpl
->m_aProps
.aTitle
= _sNewName
;
712 notifyPropertiesChange( aChanges
);
713 notifyDataSourceModified();
715 catch(const PropertyVetoException
&)
717 throw ElementExistException(_sNewName
,*this);
720 // -----------------------------------------------------------------------------
721 void SAL_CALL
OContentHelper::rename( const ::rtl::OUString
& newName
) throw (SQLException
, ElementExistException
, RuntimeException
)
724 impl_rename_throw(newName
);
725 //Reference<XNameContainer> xNameCont(m_xParentContainer,UNO_QUERY);
726 //if ( xNameCont.is() )
728 // if ( xNameCont->hasByName(newName) )
729 // throw ElementExistException(newName,*this);
733 // if ( xNameCont->hasByName(m_pImpl->m_aProps.aTitle) )
734 // xNameCont->removeByName(m_pImpl->m_aProps.aTitle);
736 // m_pImpl->m_aProps.aTitle = newName;
737 // xNameCont->insertByName(m_pImpl->m_aProps.aTitle,makeAny(Reference<XContent>(*this,UNO_QUERY)));
738 // notifyDataSourceModified();
740 // catch(IllegalArgumentException)
742 // throw SQLException();
744 // catch(NoSuchElementException)
746 // throw SQLException();
748 // catch(WrappedTargetException)
750 // throw SQLException();
754 // m_pImpl->m_aProps.aTitle = newName;
757 // -----------------------------------------------------------------------------
758 void OContentHelper::notifyDataSourceModified()
760 ::dbaccess::notifyDataSourceModified(m_xParentContainer
,sal_True
);
762 //........................................................................
763 } // namespace dbaccess
764 //........................................................................