LCOV - code coverage report
Current view: top level - dbaccess/source/core/dataaccess - ContentHelper.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 47 270 17.4 %
Date: 2014-11-03 Functions: 13 33 39.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <string.h>
      21             : #include "ContentHelper.hxx"
      22             : #include <rtl/ustrbuf.hxx>
      23             : #include <ucbhelper/cancelcommandexecution.hxx>
      24             : #include <comphelper/property.hxx>
      25             : #include <com/sun/star/ucb/UnsupportedCommandException.hpp>
      26             : #include <com/sun/star/lang/IllegalArgumentException.hpp>
      27             : #include <com/sun/star/lang/IllegalAccessException.hpp>
      28             : #include <com/sun/star/io/XOutputStream.hpp>
      29             : #include <com/sun/star/io/XActiveDataSink.hpp>
      30             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      31             : #include <ucbhelper/propertyvalueset.hxx>
      32             : #include <ucbhelper/contentidentifier.hxx>
      33             : #include "myucp_resultset.hxx"
      34             : #include <com/sun/star/container/XNameContainer.hpp>
      35             : #include "sdbcoretools.hxx"
      36             : #include "dbastrings.hrc"
      37             : #include <tools/debug.hxx>
      38             : 
      39             : namespace dbaccess
      40             : {
      41             : using namespace ::com::sun::star::uno;
      42             : using namespace ::com::sun::star::ucb;
      43             : using namespace ::com::sun::star::beans;
      44             : using namespace ::com::sun::star::lang;
      45             : using namespace ::com::sun::star::sdbc;
      46             : using namespace ::com::sun::star::io;
      47             : using namespace ::com::sun::star::util;
      48             : using namespace ::com::sun::star::embed;
      49             : using namespace ::com::sun::star::container;
      50             : using namespace ::comphelper;
      51             : using namespace ::cppu;
      52             : 
      53         988 : OContentHelper_Impl::OContentHelper_Impl()
      54         988 :     : m_pDataSource(0)
      55             : {
      56         988 : }
      57             : 
      58         988 : OContentHelper_Impl::~OContentHelper_Impl()
      59             : {
      60         988 : }
      61             : 
      62        1666 : OContentHelper::OContentHelper(const Reference< XComponentContext >& _xORB
      63             :                                ,const Reference< XInterface >&  _xParentContainer
      64             :                                ,const TContentPtr& _pImpl)
      65             :     : OContentHelper_COMPBASE(m_aMutex)
      66             :     ,m_aContentListeners(m_aMutex)
      67             :     ,m_aPropertyChangeListeners(m_aMutex)
      68             :     ,m_xParentContainer( _xParentContainer )
      69             :     ,m_aContext( _xORB )
      70             :     ,m_aErrorHelper( m_aContext )
      71             :     ,m_pImpl(_pImpl)
      72        1666 :     ,m_nCommandId(0)
      73             : {
      74        1666 : }
      75             : 
      76        1658 : void SAL_CALL OContentHelper::disposing()
      77             : {
      78        1658 :     ::osl::MutexGuard aGuard(m_aMutex);
      79             : 
      80             :     // say goodbye to our listeners
      81        3316 :     EventObject aEvt(*this);
      82        1658 :     m_aContentListeners.disposeAndClear(aEvt);
      83             : 
      84        3316 :     m_xParentContainer = NULL;
      85        1658 : }
      86             : 
      87           2 : IMPLEMENT_SERVICE_INFO1(OContentHelper,"com.sun.star.comp.sdb.Content","com.sun.star.ucb.Content");
      88         320 : IMPLEMENT_IMPLEMENTATION_ID(OContentHelper)
      89             : 
      90             : // XContent
      91           0 : Reference< XContentIdentifier > SAL_CALL OContentHelper::getIdentifier(  ) throw (RuntimeException, std::exception)
      92             : {
      93           0 :     ::osl::MutexGuard aGuard(m_aMutex);
      94           0 :     OUString aIdentifier( "private:" + impl_getHierarchicalName( true ) );
      95           0 :     return new ::ucbhelper::ContentIdentifier( aIdentifier );
      96             : }
      97             : 
      98           0 : OUString OContentHelper::impl_getHierarchicalName( bool _includingRootContainer ) const
      99             : {
     100           0 :     OUStringBuffer aHierarchicalName( m_pImpl->m_aProps.aTitle );
     101           0 :     Reference< XInterface > xParent = m_xParentContainer;
     102           0 :     while( xParent.is() )
     103             :     {
     104           0 :         Reference<XPropertySet> xProp( xParent, UNO_QUERY );
     105           0 :         Reference< XChild > xChild( xParent, UNO_QUERY );
     106           0 :         xParent.set( xChild.is() ? xChild->getParent() : Reference< XInterface >(), UNO_QUERY );
     107           0 :         if ( xProp.is() && xParent.is() )
     108             :         {
     109           0 :             OUString sName;
     110           0 :             xProp->getPropertyValue( PROPERTY_NAME ) >>= sName;
     111             : 
     112           0 :             OUString sPrevious = aHierarchicalName.makeStringAndClear();
     113           0 :             aHierarchicalName.append( sName + "/" + sPrevious );
     114             :         }
     115           0 :     }
     116           0 :     OUString sHierarchicalName( aHierarchicalName.makeStringAndClear() );
     117           0 :     if ( !_includingRootContainer )
     118           0 :         sHierarchicalName = sHierarchicalName.copy( sHierarchicalName.indexOf( '/' ) + 1 );
     119           0 :     return sHierarchicalName;
     120             : }
     121             : 
     122           0 : OUString SAL_CALL OContentHelper::getContentType() throw (RuntimeException, std::exception)
     123             : {
     124           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     125             : 
     126           0 :     if ( !m_pImpl->m_aProps.aContentType )
     127             :     {   // content type not yet retrieved
     128           0 :         m_pImpl->m_aProps.aContentType.reset( determineContentType() );
     129             :     }
     130             : 
     131           0 :     return *m_pImpl->m_aProps.aContentType;
     132             : }
     133             : 
     134           0 : void SAL_CALL OContentHelper::addContentEventListener( const Reference< XContentEventListener >& _rxListener ) throw (RuntimeException, std::exception)
     135             : {
     136           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     137           0 :     if ( _rxListener.is() )
     138           0 :         m_aContentListeners.addInterface(_rxListener);
     139           0 : }
     140             : 
     141           0 : void SAL_CALL OContentHelper::removeContentEventListener( const Reference< XContentEventListener >& _rxListener ) throw (RuntimeException, std::exception)
     142             : {
     143           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     144           0 :     if (_rxListener.is())
     145           0 :         m_aContentListeners.removeInterface(_rxListener);
     146           0 : }
     147             : 
     148             : // XCommandProcessor
     149           0 : sal_Int32 SAL_CALL OContentHelper::createCommandIdentifier(  ) throw (RuntimeException, std::exception)
     150             : {
     151           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     152             :     // Just increase counter on every call to generate an identifier.
     153           0 :     return ++m_nCommandId;
     154             : }
     155             : 
     156           0 : Any SAL_CALL OContentHelper::execute( const Command& aCommand, sal_Int32 /*CommandId*/, const Reference< XCommandEnvironment >& Environment ) throw (Exception, CommandAbortedException, RuntimeException, std::exception)
     157             : {
     158           0 :     Any aRet;
     159           0 :     if ( aCommand.Name.equalsAscii( "getPropertyValues" ) )
     160             :     {
     161             :         // getPropertyValues
     162             : 
     163           0 :         Sequence< Property > Properties;
     164           0 :         if ( !( aCommand.Argument >>= Properties ) )
     165             :         {
     166             :             OSL_FAIL( "Wrong argument type!" );
     167             :             ucbhelper::cancelCommandExecution(
     168             :                 makeAny( IllegalArgumentException(
     169             :                                     OUString(),
     170             :                                     static_cast< cppu::OWeakObject * >( this ),
     171             :                                     -1 ) ),
     172           0 :                 Environment );
     173             :             // Unreachable
     174             :         }
     175           0 :         aRet <<= getPropertyValues( Properties);
     176             :     }
     177           0 :     else if ( aCommand.Name.equalsAscii( "setPropertyValues" ) )
     178             :     {
     179             :         // setPropertyValues
     180             : 
     181           0 :         Sequence< PropertyValue > aProperties;
     182           0 :         if ( !( aCommand.Argument >>= aProperties ) )
     183             :         {
     184             :             OSL_FAIL( "Wrong argument type!" );
     185             :             ucbhelper::cancelCommandExecution(
     186             :                 makeAny( IllegalArgumentException(
     187             :                                     OUString(),
     188             :                                     static_cast< cppu::OWeakObject * >( this ),
     189             :                                     -1 ) ),
     190           0 :                 Environment );
     191             :             // Unreachable
     192             :         }
     193             : 
     194           0 :         if ( !aProperties.getLength() )
     195             :         {
     196             :             OSL_FAIL( "No properties!" );
     197             :             ucbhelper::cancelCommandExecution(
     198             :                 makeAny( IllegalArgumentException(
     199             :                                     OUString(),
     200             :                                     static_cast< cppu::OWeakObject * >( this ),
     201             :                                     -1 ) ),
     202           0 :                 Environment );
     203             :             // Unreachable
     204             :         }
     205             : 
     206           0 :         aRet <<= setPropertyValues( aProperties, Environment );
     207             :     }
     208           0 :     else if ( aCommand.Name.equalsAscii( "getPropertySetInfo" ) )
     209             :     {
     210             :         // getPropertySetInfo
     211             : 
     212           0 :         Reference<XPropertySet> xProp(*this,UNO_QUERY);
     213           0 :         if ( xProp.is() )
     214           0 :             aRet <<= xProp->getPropertySetInfo();
     215             :         //  aRet <<= getPropertySetInfo(); // TODO
     216             :     }
     217             :     else
     218             :     {
     219             :         // Unsupported command
     220             : 
     221             :         OSL_FAIL( "Content::execute - unsupported command!" );
     222             : 
     223             :         ucbhelper::cancelCommandExecution(
     224             :             makeAny( UnsupportedCommandException(
     225             :                             OUString(),
     226             :                             static_cast< cppu::OWeakObject * >( this ) ) ),
     227           0 :             Environment );
     228             :         // Unreachable
     229             :     }
     230             : 
     231           0 :     return aRet;
     232             : }
     233             : 
     234           0 : void SAL_CALL OContentHelper::abort( sal_Int32 /*CommandId*/ ) throw (RuntimeException, std::exception)
     235             : {
     236           0 : }
     237             : 
     238             : // XPropertiesChangeNotifier
     239           0 : void SAL_CALL OContentHelper::addPropertiesChangeListener( const Sequence< OUString >& PropertyNames, const Reference< XPropertiesChangeListener >& Listener ) throw (RuntimeException, std::exception)
     240             : {
     241           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     242           0 :     sal_Int32 nCount = PropertyNames.getLength();
     243           0 :     if ( !nCount )
     244             :     {
     245             :         // Note: An empty sequence means a listener for "all" properties.
     246           0 :         m_aPropertyChangeListeners.addInterface(OUString(), Listener );
     247             :     }
     248             :     else
     249             :     {
     250           0 :         const OUString* pSeq = PropertyNames.getConstArray();
     251             : 
     252           0 :         for ( sal_Int32 n = 0; n < nCount; ++n )
     253             :         {
     254           0 :             const OUString& rName = pSeq[ n ];
     255           0 :             if ( !rName.isEmpty() )
     256           0 :                 m_aPropertyChangeListeners.addInterface(rName, Listener );
     257             :         }
     258           0 :     }
     259           0 : }
     260             : 
     261           0 : void SAL_CALL OContentHelper::removePropertiesChangeListener( const Sequence< OUString >& PropertyNames, const Reference< XPropertiesChangeListener >& Listener ) throw (RuntimeException, std::exception)
     262             : {
     263           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     264           0 :     sal_Int32 nCount = PropertyNames.getLength();
     265           0 :     if ( !nCount )
     266             :     {
     267             :         // Note: An empty sequence means a listener for "all" properties.
     268           0 :         m_aPropertyChangeListeners.removeInterface( OUString(), Listener );
     269             :     }
     270             :     else
     271             :     {
     272           0 :         const OUString* pSeq = PropertyNames.getConstArray();
     273             : 
     274           0 :         for ( sal_Int32 n = 0; n < nCount; ++n )
     275             :         {
     276           0 :             const OUString& rName = pSeq[ n ];
     277           0 :             if ( !rName.isEmpty() )
     278           0 :                 m_aPropertyChangeListeners.removeInterface( rName, Listener );
     279             :         }
     280           0 :     }
     281           0 : }
     282             : 
     283             : // XPropertyContainer
     284           0 : void SAL_CALL OContentHelper::addProperty( const OUString& /*Name*/, sal_Int16 /*Attributes*/, const Any& /*DefaultValue*/ ) throw (PropertyExistException, IllegalTypeException, IllegalArgumentException, RuntimeException, std::exception)
     285             : {
     286             :     OSL_FAIL( "OContentHelper::addProperty: not implemented!" );
     287           0 : }
     288             : 
     289           0 : void SAL_CALL OContentHelper::removeProperty( const OUString& /*Name*/ ) throw (UnknownPropertyException, NotRemoveableException, RuntimeException, std::exception)
     290             : {
     291             :     OSL_FAIL( "OContentHelper::removeProperty: not implemented!" );
     292           0 : }
     293             : 
     294             : // XInitialization
     295          70 : void SAL_CALL OContentHelper::initialize( const Sequence< Any >& _aArguments ) throw(Exception, RuntimeException, std::exception)
     296             : {
     297          70 :     const Any* pBegin = _aArguments.getConstArray();
     298          70 :     const Any* pEnd = pBegin + _aArguments.getLength();
     299          70 :     PropertyValue aValue;
     300         186 :     for(;pBegin != pEnd;++pBegin)
     301             :     {
     302         116 :         *pBegin >>= aValue;
     303         116 :         if ( aValue.Name == "Parent" )
     304             :         {
     305          48 :             m_xParentContainer.set(aValue.Value,UNO_QUERY);
     306             :         }
     307          68 :         else if ( aValue.Name == PROPERTY_NAME )
     308             :         {
     309          68 :             aValue.Value >>= m_pImpl->m_aProps.aTitle;
     310             :         }
     311           0 :         else if ( aValue.Name == PROPERTY_PERSISTENT_NAME )
     312             :         {
     313           0 :             aValue.Value >>= m_pImpl->m_aProps.sPersistentName;
     314             :         }
     315          70 :     }
     316          70 : }
     317             : 
     318           0 : Sequence< Any > OContentHelper::setPropertyValues(const Sequence< PropertyValue >& rValues,const Reference< XCommandEnvironment >& /*xEnv*/ )
     319             : {
     320           0 :     osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex );
     321             : 
     322           0 :     Sequence< Any > aRet( rValues.getLength() );
     323           0 :     Sequence< PropertyChangeEvent > aChanges( rValues.getLength() );
     324           0 :     sal_Int32 nChanged = 0;
     325             : 
     326           0 :     PropertyChangeEvent aEvent;
     327           0 :     aEvent.Source         = static_cast< cppu::OWeakObject * >( this );
     328           0 :     aEvent.Further        = sal_False;
     329           0 :     aEvent.PropertyHandle = -1;
     330             : 
     331           0 :     const PropertyValue* pValues = rValues.getConstArray();
     332           0 :     sal_Int32 nCount = rValues.getLength();
     333             : 
     334           0 :     for ( sal_Int32 n = 0; n < nCount; ++n )
     335             :     {
     336           0 :         const PropertyValue& rValue = pValues[ n ];
     337             : 
     338           0 :         if ( rValue.Name == "ContentType" )
     339             :         {
     340             :             // Read-only property!
     341           0 :             aRet[ n ] <<= IllegalAccessException("Property is read-only!",
     342           0 :                             static_cast< cppu::OWeakObject * >( this ) );
     343             :         }
     344           0 :         else if ( rValue.Name == "IsDocument" )
     345             :         {
     346             :             // Read-only property!
     347           0 :             aRet[ n ] <<= IllegalAccessException("Property is read-only!",
     348           0 :                             static_cast< cppu::OWeakObject * >( this ) );
     349             :         }
     350           0 :         else if ( rValue.Name == "IsFolder" )
     351             :         {
     352             :             // Read-only property!
     353           0 :             aRet[ n ] <<= IllegalAccessException("Property is read-only!",
     354           0 :                             static_cast< cppu::OWeakObject * >( this ) );
     355             :         }
     356           0 :         else if ( rValue.Name == "Title" )
     357             :         {
     358           0 :             OUString aNewValue;
     359           0 :             if ( rValue.Value >>= aNewValue )
     360             :             {
     361           0 :                 if ( aNewValue != m_pImpl->m_aProps.aTitle )
     362             :                 {
     363           0 :                     aEvent.PropertyName = rValue.Name;
     364           0 :                     aEvent.OldValue     = makeAny( m_pImpl->m_aProps.aTitle );
     365             : 
     366             :                     try
     367             :                     {
     368           0 :                         impl_rename_throw( aNewValue ,false);
     369             :                         OSL_ENSURE( m_pImpl->m_aProps.aTitle == aNewValue, "OContentHelper::setPropertyValues('Title'): rename did not work!" );
     370             : 
     371           0 :                         aEvent.NewValue     = makeAny( aNewValue );
     372           0 :                         aChanges.getArray()[ nChanged ] = aEvent;
     373           0 :                         nChanged++;
     374             :                     }
     375           0 :                     catch( const Exception& )
     376             :                     {
     377             :                         OSL_FAIL( "OContentHelper::setPropertyValues('Title'): caught an exception while renaming!" );
     378             :                     }
     379             :                 }
     380             :                 else
     381             :                 {
     382             :                     // Old value equals new value. No error!
     383             :                 }
     384             :             }
     385             :             else
     386             :             {
     387           0 :                 aRet[ n ] <<= IllegalTypeException("Property value has wrong type!",
     388           0 :                                 static_cast< cppu::OWeakObject * >( this ) );
     389           0 :             }
     390             :         }
     391             : 
     392             :         else
     393             :         {
     394           0 :             aRet[ n ] <<= Exception("No property set for storing the value!",
     395           0 :                             static_cast< cppu::OWeakObject * >( this ) );
     396             :         }
     397             :     }
     398             : 
     399           0 :     if ( nChanged > 0 )
     400             :     {
     401           0 :         notifyDataSourceModified();
     402           0 :         aGuard.clear();
     403           0 :         aChanges.realloc( nChanged );
     404           0 :         notifyPropertiesChange( aChanges );
     405             :     }
     406             : 
     407           0 :     return aRet;
     408             : }
     409             : 
     410             : // static
     411           0 : Reference< XRow > OContentHelper::getPropertyValues( const Sequence< Property >& rProperties)
     412             : {
     413             :     // Note: Empty sequence means "get values of all supported properties".
     414             : 
     415           0 :     rtl::Reference< ::ucbhelper::PropertyValueSet > xRow = new ::ucbhelper::PropertyValueSet( m_aContext );
     416             : 
     417           0 :     sal_Int32 nCount = rProperties.getLength();
     418           0 :     if ( nCount )
     419             :     {
     420           0 :         const Property* pProps = rProperties.getConstArray();
     421           0 :         for ( sal_Int32 n = 0; n < nCount; ++n )
     422             :         {
     423           0 :             const Property& rProp = pProps[ n ];
     424             : 
     425             :             // Process Core properties.
     426             : 
     427           0 :             if ( rProp.Name == "ContentType" )
     428             :             {
     429           0 :                 xRow->appendString ( rProp, getContentType() );
     430             :             }
     431           0 :             else if ( rProp.Name == "Title" )
     432             :             {
     433           0 :                 xRow->appendString ( rProp, m_pImpl->m_aProps.aTitle );
     434             :             }
     435           0 :             else if ( rProp.Name == "IsDocument" )
     436             :             {
     437           0 :                 xRow->appendBoolean( rProp, m_pImpl->m_aProps.bIsDocument );
     438             :             }
     439           0 :             else if ( rProp.Name == "IsFolder" )
     440             :             {
     441           0 :                 xRow->appendBoolean( rProp, m_pImpl->m_aProps.bIsFolder );
     442             :             }
     443             :             else
     444           0 :                 xRow->appendVoid(rProp);
     445             :         }
     446             :     }
     447             :     else
     448             :     {
     449             :         // Append all Core Properties.
     450             :         xRow->appendString (
     451             :             Property( "ContentType", -1,
     452           0 :                       cppu::UnoType<OUString>::get(),
     453             :                       PropertyAttribute::BOUND
     454             :                         | PropertyAttribute::READONLY ),
     455           0 :             getContentType() );
     456             :         xRow->appendString (
     457             :             Property( "Title", -1,
     458           0 :                       cppu::UnoType<OUString>::get(),
     459             :                       PropertyAttribute::BOUND ),
     460           0 :             m_pImpl->m_aProps.aTitle );
     461             :         xRow->appendBoolean(
     462             :             Property( "IsDocument", -1,
     463           0 :                       getCppuBooleanType(),
     464             :                       PropertyAttribute::BOUND
     465             :                         | PropertyAttribute::READONLY ),
     466           0 :             m_pImpl->m_aProps.bIsDocument );
     467             :         xRow->appendBoolean(
     468             :             Property( "IsFolder", -1,
     469           0 :                       getCppuBooleanType(),
     470             :                       PropertyAttribute::BOUND
     471             :                         | PropertyAttribute::READONLY ),
     472           0 :             m_pImpl->m_aProps.bIsFolder );
     473             : 
     474             :         // @@@ Append other properties supported directly.
     475             :     }
     476             : 
     477           0 :     return Reference< XRow >( xRow.get() );
     478             : }
     479             : 
     480           0 : void OContentHelper::notifyPropertiesChange( const Sequence< PropertyChangeEvent >& evt ) const
     481             : {
     482             : 
     483           0 :     sal_Int32 nCount = evt.getLength();
     484           0 :     if ( nCount )
     485             :     {
     486             :         // First, notify listeners interested in changes of every property.
     487           0 :         OInterfaceContainerHelper* pAllPropsContainer = m_aPropertyChangeListeners.getContainer( OUString() );
     488           0 :         if ( pAllPropsContainer )
     489             :         {
     490           0 :             OInterfaceIteratorHelper aIter( *pAllPropsContainer );
     491           0 :             while ( aIter.hasMoreElements() )
     492             :             {
     493             :                 // Propagate event.
     494           0 :                 Reference< XPropertiesChangeListener > xListener( aIter.next(), UNO_QUERY );
     495           0 :                 if ( xListener.is() )
     496           0 :                     xListener->propertiesChange( evt );
     497           0 :             }
     498             :         }
     499             : 
     500             :         typedef Sequence< PropertyChangeEvent > PropertyEventSequence;
     501             :         typedef ::std::map< XPropertiesChangeListener*, PropertyEventSequence* > PropertiesEventListenerMap;
     502           0 :         PropertiesEventListenerMap aListeners;
     503             : 
     504           0 :         const PropertyChangeEvent* propertyChangeEvent = evt.getConstArray();
     505             : 
     506           0 :         for ( sal_Int32 n = 0; n < nCount; ++n, ++propertyChangeEvent )
     507             :         {
     508           0 :             const PropertyChangeEvent& rEvent = *propertyChangeEvent;
     509           0 :             const OUString& rName = rEvent.PropertyName;
     510             : 
     511           0 :             OInterfaceContainerHelper* pPropsContainer = m_aPropertyChangeListeners.getContainer( rName );
     512           0 :             if ( pPropsContainer )
     513             :             {
     514           0 :                 OInterfaceIteratorHelper aIter( *pPropsContainer );
     515           0 :                 while ( aIter.hasMoreElements() )
     516             :                 {
     517           0 :                     PropertyEventSequence* propertyEvents = NULL;
     518             : 
     519           0 :                     XPropertiesChangeListener* pListener = static_cast< XPropertiesChangeListener * >( aIter.next() );
     520           0 :                     PropertiesEventListenerMap::iterator it = aListeners.find( pListener );
     521           0 :                     if ( it == aListeners.end() )
     522             :                     {
     523             :                         // Not in map - create and insert new entry.
     524           0 :                         propertyEvents = new PropertyEventSequence( nCount );
     525           0 :                         aListeners[ pListener ] = propertyEvents;
     526             :                     }
     527             :                     else
     528           0 :                         propertyEvents = (*it).second;
     529             : 
     530           0 :                     if ( propertyEvents )
     531           0 :                         (*propertyEvents)[n] = rEvent;
     532           0 :                 }
     533             :             }
     534             :         }
     535             : 
     536             :         // Notify listeners.
     537           0 :         PropertiesEventListenerMap::iterator it = aListeners.begin();
     538           0 :         while ( !aListeners.empty() )
     539             :         {
     540             :             XPropertiesChangeListener* pListener =
     541           0 :                     static_cast< XPropertiesChangeListener * >( (*it).first );
     542           0 :             PropertyEventSequence* pSeq = (*it).second;
     543             : 
     544             :             // Remove current element.
     545           0 :             aListeners.erase( it );
     546             : 
     547             :             // Propagate event.
     548           0 :             pListener->propertiesChange( *pSeq );
     549             : 
     550           0 :             delete pSeq;
     551             : 
     552           0 :             it = aListeners.begin();
     553           0 :         }
     554             :     }
     555           0 : }
     556             : 
     557             : // com::sun::star::lang::XUnoTunnel
     558         160 : sal_Int64 OContentHelper::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException, std::exception)
     559             : {
     560         160 :     if (rId.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(),  rId.getConstArray(), 16 ) )
     561         160 :         return reinterpret_cast<sal_Int64>(this);
     562             : 
     563           0 :     return 0;
     564             : }
     565             : 
     566         160 : OContentHelper* OContentHelper::getImplementation( const Reference< XInterface >& _rxComponent )
     567             : {
     568         160 :     OContentHelper* pContent( NULL );
     569             : 
     570         160 :     Reference< XUnoTunnel > xUnoTunnel( _rxComponent, UNO_QUERY );
     571         160 :     if ( xUnoTunnel.is() )
     572         160 :         pContent = reinterpret_cast< OContentHelper* >( xUnoTunnel->getSomething( getUnoTunnelImplementationId() ) );
     573             : 
     574         160 :     return pContent;
     575             : }
     576             : 
     577        4166 : Reference< XInterface > SAL_CALL OContentHelper::getParent(  ) throw (RuntimeException, std::exception)
     578             : {
     579        4166 :     ::osl::MutexGuard aGuard(m_aMutex);
     580        4166 :     return m_xParentContainer;
     581             : }
     582             : 
     583         474 : void SAL_CALL OContentHelper::setParent( const Reference< XInterface >& _xParent ) throw (NoSupportException, RuntimeException, std::exception)
     584             : {
     585         474 :     ::osl::MutexGuard aGuard(m_aMutex);
     586         474 :     m_xParentContainer = _xParent;
     587         474 : }
     588             : 
     589           0 : void OContentHelper::impl_rename_throw(const OUString& _sNewName,bool _bNotify )
     590             : {
     591           0 :     osl::ClearableGuard< osl::Mutex > aGuard(m_aMutex);
     592           0 :     if ( _sNewName.equals( m_pImpl->m_aProps.aTitle ) )
     593           0 :         return;
     594             :     try
     595             :     {
     596           0 :         Sequence< PropertyChangeEvent > aChanges( 1 );
     597             : 
     598           0 :         aChanges[0].Source          = static_cast< cppu::OWeakObject * >( this );
     599           0 :         aChanges[0].Further         = sal_False;
     600           0 :         aChanges[0].PropertyName    = PROPERTY_NAME;
     601           0 :         aChanges[0].PropertyHandle  = PROPERTY_ID_NAME;
     602           0 :         aChanges[0].OldValue        <<= m_pImpl->m_aProps.aTitle;
     603           0 :         aChanges[0].NewValue        <<= _sNewName;
     604             : 
     605           0 :         aGuard.clear();
     606             : 
     607           0 :         m_pImpl->m_aProps.aTitle = _sNewName;
     608           0 :         if ( _bNotify )
     609           0 :             notifyPropertiesChange( aChanges );
     610           0 :         notifyDataSourceModified();
     611             :     }
     612           0 :     catch(const PropertyVetoException&)
     613             :     {
     614           0 :         throw ElementExistException(_sNewName,*this);
     615           0 :     }
     616             : }
     617             : 
     618           0 : void SAL_CALL OContentHelper::rename( const OUString& newName ) throw (SQLException, ElementExistException, RuntimeException, std::exception)
     619             : {
     620             : 
     621           0 :     impl_rename_throw(newName);
     622             : 
     623           0 : }
     624             : 
     625        1280 : void OContentHelper::notifyDataSourceModified()
     626             : {
     627        1280 :     ::dbaccess::notifyDataSourceModified(m_xParentContainer,true);
     628        1280 : }
     629             : 
     630             : }   // namespace dbaccess
     631             : 
     632             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10