/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
void OInterfaceContainerHelper::copyAndResetInUse()
{
OSL_ENSURE( bInUse, "OInterfaceContainerHelper not in use" ); if( bInUse )
{ // this should be the worst case. If an iterator is active // and a new Listener is added. if( bIsList )
aData.pAsVector= new std::vector< Reference< XInterface > >( *aData.pAsVector ); elseif( aData.pAsInterface )
aData.pAsInterface->acquire();
void OInterfaceContainerHelper::disposeAndClear( const EventObject & rEvt )
{
ClearableMutexGuard aGuard( rMutex );
OInterfaceIteratorHelper aIt( *this ); // Release container, in case new entries come while disposing
OSL_ENSURE( !bIsList || bInUse, "OInterfaceContainerHelper not in use" ); if( !bIsList && aData.pAsInterface )
aData.pAsInterface->release(); // set the member to null, use the iterator to delete the values
aData.pAsInterface = nullptr;
bIsList = false;
bInUse = false;
aGuard.clear(); while( aIt.hasMoreElements() )
{ try
{
Reference<XEventListener > xLst( aIt.next(), UNO_QUERY ); if( xLst.is() )
xLst->disposing( rEvt );
} catch ( RuntimeException & )
{ // be robust, if e.g. a remote bridge has disposed already. // there is no way to delegate the error to the caller :o(.
}
}
}
void OInterfaceContainerHelper::clear()
{
MutexGuard aGuard( rMutex ); // Release container, in case new entries come while disposing
OSL_ENSURE( !bIsList || bInUse, "OInterfaceContainerHelper not in use" ); if (bInUse)
copyAndResetInUse(); if (bIsList) delete aData.pAsVector; elseif (aData.pAsInterface)
aData.pAsInterface->release();
aData.pAsInterface = nullptr;
bIsList = false;
}
// specialized class for type
typedef std::vector< std::pair < Type , void* > > t_type2ptr;
sal_Int32 i = 0; for (constauto& rItem : *pMap)
{ // are interfaces added to this container? if( static_cast<OInterfaceContainerHelper*>(rItem.second)->getLength() ) // yes, put the type in the array
pArray[i++] = rItem.first;
} if( static_cast<t_type2ptr::size_type>(i) != nSize ) { // may be empty container, reduce the sequence to the right size
aInterfaceTypes = css::uno::Sequence< Type >( pArray, i );
} return aInterfaceTypes;
} return css::uno::Sequence< Type >();
}
t_type2ptr::size_type i = 0; for (constauto& rItem : *pMap)
{
ppListenerContainers[i++] = static_cast<OInterfaceContainerHelper*>(rItem.second);
}
}
}
// create a copy, because do not fire event in a guarded section for( t_type2ptr::size_type i = 0;
i < nSize; i++ )
{ if( ppListenerContainers[i] )
ppListenerContainers[i]->disposeAndClear( rEvt );
}
}
sal_Int32 i = 0; for (constauto& rItem : *pMap)
{ // are interfaces added to this container? if( static_cast<OInterfaceContainerHelper*>(rItem.second)->getLength() ) // yes, put the type in the array
pArray[i++] = rItem.first;
} if( static_cast<t_long2ptr::size_type>(i) != nSize ) { // may be empty container, reduce the sequence to the right size
aInterfaceTypes = css::uno::Sequence< sal_Int32 >( pArray, i );
} return aInterfaceTypes;
} return css::uno::Sequence< sal_Int32 >();
}
t_long2ptr::size_type i = 0; for (constauto& rItem : *pMap)
{
ppListenerContainers[i++] = static_cast<OInterfaceContainerHelper*>(rItem.second);
}
}
}
// create a copy, because do not fire event in a guarded section for( t_long2ptr::size_type i = 0;
i < nSize; i++ )
{ if( ppListenerContainers[i] )
ppListenerContainers[i]->disposeAndClear( rEvt );
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.