diff options
Diffstat (limited to 'dbaccess/source/core/dataaccess/ContentHelper.cxx')
-rw-r--r-- | dbaccess/source/core/dataaccess/ContentHelper.cxx | 97 |
1 files changed, 44 insertions, 53 deletions
diff --git a/dbaccess/source/core/dataaccess/ContentHelper.cxx b/dbaccess/source/core/dataaccess/ContentHelper.cxx index 6e0e17b360ef..7dd40092fe52 100644 --- a/dbaccess/source/core/dataaccess/ContentHelper.cxx +++ b/dbaccess/source/core/dataaccess/ContentHelper.cxx @@ -31,15 +31,14 @@ #include <com/sun/star/container/ElementExistException.hpp> #include <ucbhelper/propertyvalueset.hxx> #include <ucbhelper/contentidentifier.hxx> -#include <cppuhelper/interfacecontainer.hxx> #include <comphelper/servicehelper.hxx> -#include <cppuhelper/typeprovider.hxx> -#include <tools/diagnose_ex.h> -#include <apitools.hxx> +#include <comphelper/diagnose_ex.hxx> #include <sdbcoretools.hxx> #include <stringconstants.hxx> +#include <strings.hxx> #include <map> +#include <utility> namespace dbaccess { @@ -49,8 +48,6 @@ using namespace ::com::sun::star::beans; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::io; -using namespace ::com::sun::star::util; -using namespace ::com::sun::star::embed; using namespace ::com::sun::star::container; using namespace ::cppu; @@ -65,13 +62,13 @@ OContentHelper_Impl::~OContentHelper_Impl() OContentHelper::OContentHelper(const Reference< XComponentContext >& _xORB ,const Reference< XInterface >& _xParentContainer - ,const TContentPtr& _pImpl) + ,TContentPtr _pImpl) : OContentHelper_COMPBASE(m_aMutex) ,m_aContentListeners(m_aMutex) ,m_aPropertyChangeListeners(m_aMutex) ,m_xParentContainer( _xParentContainer ) ,m_aContext( _xORB ) - ,m_pImpl(_pImpl) + ,m_pImpl(std::move(_pImpl)) ,m_nCommandId(0) { } @@ -87,14 +84,25 @@ void SAL_CALL OContentHelper::disposing() m_xParentContainer = nullptr; } -IMPLEMENT_SERVICE_INFO1(OContentHelper,"com.sun.star.comp.sdb.Content","com.sun.star.ucb.Content"); +OUString SAL_CALL OContentHelper::getImplementationName() + { + return "com.sun.star.comp.sdb.Content"; + } +sal_Bool SAL_CALL OContentHelper::supportsService(const OUString& _rServiceName) + { + const css::uno::Sequence< OUString > aSupported(getSupportedServiceNames()); + for (const OUString& s : aSupported) + if (s == _rServiceName) + return true; -css::uno::Sequence<sal_Int8> OContentHelper::getUnoTunnelId() + return false; + } +css::uno::Sequence< OUString > SAL_CALL OContentHelper::getSupportedServiceNames() { - static cppu::OImplementationId aId; - return aId.getImplementationId(); + return { "com.sun.star.ucb.Content" }; } + css::uno::Sequence<sal_Int8> OContentHelper::getImplementationId() { return css::uno::Sequence<sal_Int8>(); @@ -123,7 +131,7 @@ OUString OContentHelper::impl_getHierarchicalName( bool _includingRootContainer xProp->getPropertyValue( PROPERTY_NAME ) >>= sName; OUString sPrevious = aHierarchicalName.makeStringAndClear(); - aHierarchicalName.append( sName ).append( "/" ).append( sPrevious ); + aHierarchicalName.append( sName + "/" + sPrevious ); } } OUString sHierarchicalName( aHierarchicalName.makeStringAndClear() ); @@ -178,7 +186,7 @@ Any SAL_CALL OContentHelper::execute( const Command& aCommand, sal_Int32 /*Comma { OSL_FAIL( "Wrong argument type!" ); ucbhelper::cancelCommandExecution( - makeAny( IllegalArgumentException( + Any( IllegalArgumentException( OUString(), static_cast< cppu::OWeakObject * >( this ), -1 ) ), @@ -196,7 +204,7 @@ Any SAL_CALL OContentHelper::execute( const Command& aCommand, sal_Int32 /*Comma { OSL_FAIL( "Wrong argument type!" ); ucbhelper::cancelCommandExecution( - makeAny( IllegalArgumentException( + Any( IllegalArgumentException( OUString(), static_cast< cppu::OWeakObject * >( this ), -1 ) ), @@ -208,7 +216,7 @@ Any SAL_CALL OContentHelper::execute( const Command& aCommand, sal_Int32 /*Comma { OSL_FAIL( "No properties!" ); ucbhelper::cancelCommandExecution( - makeAny( IllegalArgumentException( + Any( IllegalArgumentException( OUString(), static_cast< cppu::OWeakObject * >( this ), -1 ) ), @@ -234,7 +242,7 @@ Any SAL_CALL OContentHelper::execute( const Command& aCommand, sal_Int32 /*Comma OSL_FAIL( "Content::execute - unsupported command!" ); ucbhelper::cancelCommandExecution( - makeAny( UnsupportedCommandException( + Any( UnsupportedCommandException( OUString(), static_cast< cppu::OWeakObject * >( this ) ) ), Environment ); @@ -333,6 +341,7 @@ Sequence< Any > OContentHelper::setPropertyValues(const Sequence< PropertyValue osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); Sequence< Any > aRet( rValues.getLength() ); + auto aRetRange = asNonConstRange(aRet); Sequence< PropertyChangeEvent > aChanges( rValues.getLength() ); sal_Int32 nChanged = 0; @@ -351,7 +360,7 @@ Sequence< Any > OContentHelper::setPropertyValues(const Sequence< PropertyValue if ( rValue.Name == "ContentType" || rValue.Name == "IsDocument" || rValue.Name == "IsFolder" ) { // Read-only property! - aRet[ n ] <<= IllegalAccessException("Property is read-only!", + aRetRange[ n ] <<= IllegalAccessException("Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } else if ( rValue.Name == "Title" ) @@ -385,14 +394,14 @@ Sequence< Any > OContentHelper::setPropertyValues(const Sequence< PropertyValue } else { - aRet[ n ] <<= IllegalTypeException("Property value has wrong type!", + aRetRange[ n ] <<= IllegalTypeException("Property value has wrong type!", static_cast< cppu::OWeakObject * >( this ) ); } } else { - aRet[ n ] <<= Exception("No property set for storing the value!", + aRetRange[ n ] <<= Exception("No property set for storing the value!", static_cast< cppu::OWeakObject * >( this ) ); } } @@ -475,7 +484,7 @@ Reference< XRow > OContentHelper::getPropertyValues( const Sequence< Property >& // @@@ Append other properties supported directly. } - return Reference< XRow >( xRow.get() ); + return xRow; } void OContentHelper::notifyPropertiesChange( const Sequence< PropertyChangeEvent >& evt ) const @@ -486,18 +495,9 @@ void OContentHelper::notifyPropertiesChange( const Sequence< PropertyChangeEvent return; // First, notify listeners interested in changes of every property. - OInterfaceContainerHelper* pAllPropsContainer = m_aPropertyChangeListeners.getContainer( OUString() ); + comphelper::OInterfaceContainerHelper3<XPropertiesChangeListener>* pAllPropsContainer = m_aPropertyChangeListeners.getContainer( OUString() ); if ( pAllPropsContainer ) - { - OInterfaceIteratorHelper aIter( *pAllPropsContainer ); - while ( aIter.hasMoreElements() ) - { - // Propagate event. - Reference< XPropertiesChangeListener > xListener( aIter.next(), UNO_QUERY ); - if ( xListener.is() ) - xListener->propertiesChange( evt ); - } - } + pAllPropsContainer->notifyEach( &XPropertiesChangeListener::propertiesChange, evt ); typedef std::map< XPropertiesChangeListener*, Sequence< PropertyChangeEvent > > PropertiesEventListenerMap; PropertiesEventListenerMap aListeners; @@ -509,15 +509,15 @@ void OContentHelper::notifyPropertiesChange( const Sequence< PropertyChangeEvent const PropertyChangeEvent& rEvent = *propertyChangeEvent; const OUString& rName = rEvent.PropertyName; - OInterfaceContainerHelper* pPropsContainer = m_aPropertyChangeListeners.getContainer( rName ); + comphelper::OInterfaceContainerHelper3<XPropertiesChangeListener>* pPropsContainer = m_aPropertyChangeListeners.getContainer( rName ); if ( pPropsContainer ) { - OInterfaceIteratorHelper aIter( *pPropsContainer ); + comphelper::OInterfaceIteratorHelper3 aIter( *pPropsContainer ); while ( aIter.hasMoreElements() ) { Sequence< PropertyChangeEvent >* propertyEvents; - XPropertiesChangeListener* pListener = static_cast< XPropertiesChangeListener * >( aIter.next() ); + XPropertiesChangeListener* pListener = aIter.next().get(); PropertiesEventListenerMap::iterator it = aListeners.find( pListener ); if ( it == aListeners.end() ) { @@ -528,7 +528,7 @@ void OContentHelper::notifyPropertiesChange( const Sequence< PropertyChangeEvent else propertyEvents = &(*it).second; - (*propertyEvents)[n] = rEvent; + propertyEvents->getArray()[n] = rEvent; } } } @@ -544,15 +544,6 @@ void OContentHelper::notifyPropertiesChange( const Sequence< PropertyChangeEvent } } -// css::lang::XUnoTunnel -sal_Int64 OContentHelper::getSomething( const Sequence< sal_Int8 > & rId ) -{ - if (isUnoTunnelId<OContentHelper>(rId)) - return reinterpret_cast<sal_Int64>(this); - - return 0; -} - Reference< XInterface > SAL_CALL OContentHelper::getParent( ) { ::osl::MutexGuard aGuard(m_aMutex); @@ -572,14 +563,14 @@ void OContentHelper::impl_rename_throw(const OUString& _sNewName,bool _bNotify ) return; try { - Sequence< PropertyChangeEvent > aChanges( 1 ); - - aChanges[0].Source = static_cast< cppu::OWeakObject * >( this ); - aChanges[0].Further = false; - aChanges[0].PropertyName = PROPERTY_NAME; - aChanges[0].PropertyHandle = PROPERTY_ID_NAME; - aChanges[0].OldValue <<= m_pImpl->m_aProps.aTitle; - aChanges[0].NewValue <<= _sNewName; + Sequence<PropertyChangeEvent> aChanges{ + { /* Source */ static_cast<cppu::OWeakObject*>(this), + /* PropertyName */ PROPERTY_NAME, + /* Further */ false, + /* PropertyHandle */ PROPERTY_ID_NAME, + /* OldValue */ Any(m_pImpl->m_aProps.aTitle), + /* NewValue */ Any(_sNewName) } + }; aGuard.clear(); |