Files
libreoffice/connectivity/source/drivers/postgresql/pq_xcontainer.cxx

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

409 lines
12 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2011-08-02 16:10:00 +02:00
/*************************************************************************
*
* Effective License of whole file:
2011-08-02 16:10:00 +02:00
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
2011-08-02 16:10:00 +02:00
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
2011-08-02 16:10:00 +02:00
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
2011-08-02 16:10:00 +02:00
*
* Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
2011-08-02 16:10:00 +02:00
*
* The Contents of this file are made available subject to the terms of
* the GNU Lesser General Public License Version 2.1
2011-08-02 16:10:00 +02:00
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* Contributor(s): Joerg Budischewski
*
* All parts contributed on or after August 2011:
*
* 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/.
2011-08-02 16:10:00 +02:00
*
************************************************************************/
#include <com/sun/star/container/ElementExistException.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <cppuhelper/implbase.hxx>
2011-08-02 16:10:00 +02:00
#include "pq_xcontainer.hxx"
#include "pq_statics.hxx"
#include "pq_tools.hxx"
using osl::MutexGuard;
using com::sun::star::beans::XPropertySet;
using com::sun::star::uno::Any;
using com::sun::star::uno::makeAny;
using com::sun::star::uno::Type;
using com::sun::star::uno::XInterface;
using com::sun::star::uno::Reference;
using com::sun::star::uno::Sequence;
using com::sun::star::uno::RuntimeException;
using com::sun::star::container::NoSuchElementException;
using com::sun::star::container::XEnumeration;
using com::sun::star::container::XContainerListener;
using com::sun::star::container::ContainerEvent;
using com::sun::star::lang::IndexOutOfBoundsException;
using com::sun::star::lang::XEventListener;
namespace pq_sdbc_driver
{
Extend loplugin:external to warn about classes ...following up on 314f15bff08b76bf96acf99141776ef64d2f1355 "Extend loplugin:external to warn about enums". Cases where free functions were moved into an unnamed namespace along with a class, to not break ADL, are in: filter/source/svg/svgexport.cxx sc/source/filter/excel/xelink.cxx sc/source/filter/excel/xilink.cxx svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx All other free functions mentioning moved classes appear to be harmless and not give rise to (silent, even) ADL breakage. (One remaining TODO in compilerplugins/clang/external.cxx is that derived classes are not covered by computeAffectedTypes, even though they could also be affected by ADL-breakage--- but don't seem to be in any acutal case across the code base.) For friend declarations using elaborate type specifiers, like class C1 {}; class C2 { friend class C1; }; * If C2 (but not C1) is moved into an unnamed namespace, the friend declaration must be changed to not use an elaborate type specifier (i.e., "friend C1;"; see C++17 [namespace.memdef]/3: "If the name in a friend declaration is neither qualified nor a template-id and the declaration is a function or an elaborated-type-specifier, the lookup to determine whether the entity has been previously declared shall not consider any scopes outside the innermost enclosing namespace.") * If C1 (but not C2) is moved into an unnamed namespace, the friend declaration must be changed too, see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71882> "elaborated-type-specifier friend not looked up in unnamed namespace". Apart from that, to keep changes simple and mostly mechanical (which should help avoid regressions), out-of-line definitions of class members have been left in the enclosing (named) namespace. But explicit specializations of class templates had to be moved into the unnamed namespace to appease <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92598> "explicit specialization of template from unnamed namespace using unqualified-id in enclosing namespace". Also, accompanying declarations (of e.g. typedefs or static variables) that could arguably be moved into the unnamed namespace too have been left alone. And in some cases, mention of affected types in blacklists in other loplugins needed to be adapted. And sc/qa/unit/mark_test.cxx uses a hack of including other .cxx, one of which is sc/source/core/data/segmenttree.cxx where e.g. ScFlatUInt16SegmentsImpl is not moved into an unnamed namespace (because it is declared in sc/inc/segmenttree.hxx), but its base ScFlatSegmentsImpl is. GCC warns about such combinations with enabled-by-default -Wsubobject-linkage, but "The compiler doesn’t give this warning for types defined in the main .C file, as those are unlikely to have multiple definitions." (<https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Warning-Options.html>) The warned-about classes also don't have multiple definitions in the given test, so disable the warning when including the .cxx. Change-Id: Ib694094c0d8168be68f8fe90dfd0acbb66a3f1e4 Reviewed-on: https://gerrit.libreoffice.org/83239 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-11-19 16:32:49 +01:00
namespace {
2011-08-02 16:10:00 +02:00
class ReplacedBroadcaster : public EventBroadcastHelper
{
ContainerEvent m_event;
public:
ReplacedBroadcaster(
const Reference< XInterface > & source,
const OUString & name,
2011-08-02 16:10:00 +02:00
const Any & newElement,
const OUString & oldElement ) :
2011-08-02 16:10:00 +02:00
m_event( source, makeAny( name ), newElement, makeAny(oldElement) )
{}
virtual void fire( XEventListener * listener ) const override
2011-08-02 16:10:00 +02:00
{
static_cast<XContainerListener*>(listener)->elementReplaced( m_event );
2011-08-02 16:10:00 +02:00
}
virtual Type getType() const override
2011-08-02 16:10:00 +02:00
{
return cppu::UnoType<XContainerListener>::get();
2011-08-02 16:10:00 +02:00
}
};
class InsertedBroadcaster : public EventBroadcastHelper
{
public:
ContainerEvent m_event;
InsertedBroadcaster(
const Reference< XInterface > & source,
const OUString & name,
2011-08-02 16:10:00 +02:00
const Any & newElement ) :
m_event( source, makeAny( name ), newElement, Any() )
{}
virtual void fire( XEventListener * listener ) const override
2011-08-02 16:10:00 +02:00
{
static_cast<XContainerListener*>(listener)->elementInserted( m_event );
2011-08-02 16:10:00 +02:00
}
virtual Type getType() const override
2011-08-02 16:10:00 +02:00
{
return cppu::UnoType<XContainerListener>::get();
2011-08-02 16:10:00 +02:00
}
};
class RemovedBroadcaster : public EventBroadcastHelper
{
public:
ContainerEvent m_event;
RemovedBroadcaster(
const Reference< XInterface > & source,
const OUString & name) :
2011-08-02 16:10:00 +02:00
m_event( source, makeAny( name ), Any(), Any() )
{}
virtual void fire( XEventListener * listener ) const override
2011-08-02 16:10:00 +02:00
{
static_cast<XContainerListener*>(listener)->elementRemoved( m_event );
2011-08-02 16:10:00 +02:00
}
virtual Type getType() const override
2011-08-02 16:10:00 +02:00
{
return cppu::UnoType<XContainerListener>::get();
2011-08-02 16:10:00 +02:00
}
};
Extend loplugin:external to warn about classes ...following up on 314f15bff08b76bf96acf99141776ef64d2f1355 "Extend loplugin:external to warn about enums". Cases where free functions were moved into an unnamed namespace along with a class, to not break ADL, are in: filter/source/svg/svgexport.cxx sc/source/filter/excel/xelink.cxx sc/source/filter/excel/xilink.cxx svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx All other free functions mentioning moved classes appear to be harmless and not give rise to (silent, even) ADL breakage. (One remaining TODO in compilerplugins/clang/external.cxx is that derived classes are not covered by computeAffectedTypes, even though they could also be affected by ADL-breakage--- but don't seem to be in any acutal case across the code base.) For friend declarations using elaborate type specifiers, like class C1 {}; class C2 { friend class C1; }; * If C2 (but not C1) is moved into an unnamed namespace, the friend declaration must be changed to not use an elaborate type specifier (i.e., "friend C1;"; see C++17 [namespace.memdef]/3: "If the name in a friend declaration is neither qualified nor a template-id and the declaration is a function or an elaborated-type-specifier, the lookup to determine whether the entity has been previously declared shall not consider any scopes outside the innermost enclosing namespace.") * If C1 (but not C2) is moved into an unnamed namespace, the friend declaration must be changed too, see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71882> "elaborated-type-specifier friend not looked up in unnamed namespace". Apart from that, to keep changes simple and mostly mechanical (which should help avoid regressions), out-of-line definitions of class members have been left in the enclosing (named) namespace. But explicit specializations of class templates had to be moved into the unnamed namespace to appease <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92598> "explicit specialization of template from unnamed namespace using unqualified-id in enclosing namespace". Also, accompanying declarations (of e.g. typedefs or static variables) that could arguably be moved into the unnamed namespace too have been left alone. And in some cases, mention of affected types in blacklists in other loplugins needed to be adapted. And sc/qa/unit/mark_test.cxx uses a hack of including other .cxx, one of which is sc/source/core/data/segmenttree.cxx where e.g. ScFlatUInt16SegmentsImpl is not moved into an unnamed namespace (because it is declared in sc/inc/segmenttree.hxx), but its base ScFlatSegmentsImpl is. GCC warns about such combinations with enabled-by-default -Wsubobject-linkage, but "The compiler doesn’t give this warning for types defined in the main .C file, as those are unlikely to have multiple definitions." (<https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Warning-Options.html>) The warned-about classes also don't have multiple definitions in the given test, so disable the warning when including the .cxx. Change-Id: Ib694094c0d8168be68f8fe90dfd0acbb66a3f1e4 Reviewed-on: https://gerrit.libreoffice.org/83239 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-11-19 16:32:49 +01:00
}
2011-08-02 16:10:00 +02:00
Container::Container(
const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
const css::uno::Reference< css::sdbc::XConnection > & origin,
2011-08-02 16:10:00 +02:00
ConnectionSettings *pSettings,
const OUString &type)
: ContainerBase( refMutex->GetMutex() ),
m_xMutex( refMutex ),
2011-08-02 16:10:00 +02:00
m_pSettings( pSettings ),
m_origin( origin ),
m_type( type )
{
}
Any Container::getByName( const OUString& aName )
2011-08-02 16:10:00 +02:00
{
String2IntMap::const_iterator ii = m_name2index.find( aName );
if( ii == m_name2index.end() )
{
throw NoSuchElementException(
"Element " + aName + " unknown in " + m_type + "-Container",
*this );
2011-08-02 16:10:00 +02:00
}
OSL_ASSERT( ii->second >= 0 && ii->second < static_cast<int>(m_values.size()) );
2011-08-02 16:10:00 +02:00
return m_values[ ii->second ];
}
Sequence< OUString > Container::getElementNames( )
{
Sequence< OUString > ret( m_values.size() );
for( const auto& [rName, rIndex] : m_name2index )
2011-08-02 16:10:00 +02:00
{
// give element names in index order !
ret[rIndex] = rName;
2011-08-02 16:10:00 +02:00
}
return ret;
}
sal_Bool Container::hasByName( const OUString& aName )
2011-08-02 16:10:00 +02:00
{
return m_name2index.find( aName ) != m_name2index.end();
}
// Methods
Type Container::getElementType( )
{
return Type();
}
sal_Bool Container::hasElements( )
{
return ! m_name2index.empty();
}
Any Container::getByIndex( sal_Int32 Index )
{
if( Index < 0 || Index >= static_cast<sal_Int32>(m_values.size()) )
2011-08-02 16:10:00 +02:00
{
throw IndexOutOfBoundsException(
"Index " + OUString::number( Index )
+ " out of range for " + m_type + "-Container, expected 0 <= x <= "
+ OUString::number(m_values.size() -1),
*this );
2011-08-02 16:10:00 +02:00
}
return m_values[Index];
}
sal_Int32 Container::getCount()
{
return m_values.size();
2011-08-02 16:10:00 +02:00
}
Extend loplugin:external to warn about classes ...following up on 314f15bff08b76bf96acf99141776ef64d2f1355 "Extend loplugin:external to warn about enums". Cases where free functions were moved into an unnamed namespace along with a class, to not break ADL, are in: filter/source/svg/svgexport.cxx sc/source/filter/excel/xelink.cxx sc/source/filter/excel/xilink.cxx svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx All other free functions mentioning moved classes appear to be harmless and not give rise to (silent, even) ADL breakage. (One remaining TODO in compilerplugins/clang/external.cxx is that derived classes are not covered by computeAffectedTypes, even though they could also be affected by ADL-breakage--- but don't seem to be in any acutal case across the code base.) For friend declarations using elaborate type specifiers, like class C1 {}; class C2 { friend class C1; }; * If C2 (but not C1) is moved into an unnamed namespace, the friend declaration must be changed to not use an elaborate type specifier (i.e., "friend C1;"; see C++17 [namespace.memdef]/3: "If the name in a friend declaration is neither qualified nor a template-id and the declaration is a function or an elaborated-type-specifier, the lookup to determine whether the entity has been previously declared shall not consider any scopes outside the innermost enclosing namespace.") * If C1 (but not C2) is moved into an unnamed namespace, the friend declaration must be changed too, see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71882> "elaborated-type-specifier friend not looked up in unnamed namespace". Apart from that, to keep changes simple and mostly mechanical (which should help avoid regressions), out-of-line definitions of class members have been left in the enclosing (named) namespace. But explicit specializations of class templates had to be moved into the unnamed namespace to appease <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92598> "explicit specialization of template from unnamed namespace using unqualified-id in enclosing namespace". Also, accompanying declarations (of e.g. typedefs or static variables) that could arguably be moved into the unnamed namespace too have been left alone. And in some cases, mention of affected types in blacklists in other loplugins needed to be adapted. And sc/qa/unit/mark_test.cxx uses a hack of including other .cxx, one of which is sc/source/core/data/segmenttree.cxx where e.g. ScFlatUInt16SegmentsImpl is not moved into an unnamed namespace (because it is declared in sc/inc/segmenttree.hxx), but its base ScFlatSegmentsImpl is. GCC warns about such combinations with enabled-by-default -Wsubobject-linkage, but "The compiler doesn’t give this warning for types defined in the main .C file, as those are unlikely to have multiple definitions." (<https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Warning-Options.html>) The warned-about classes also don't have multiple definitions in the given test, so disable the warning when including the .cxx. Change-Id: Ib694094c0d8168be68f8fe90dfd0acbb66a3f1e4 Reviewed-on: https://gerrit.libreoffice.org/83239 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-11-19 16:32:49 +01:00
namespace {
2011-08-02 16:10:00 +02:00
class ContainerEnumeration : public ::cppu::WeakImplHelper< XEnumeration >
2011-08-02 16:10:00 +02:00
{
std::vector< css::uno::Any > m_vec;
2011-08-02 16:10:00 +02:00
sal_Int32 m_index;
public:
explicit ContainerEnumeration( const std::vector< css::uno::Any > &vec )
2011-08-02 16:10:00 +02:00
: m_vec( vec ),
m_index( -1 )
{}
public:
// XEnumeration
virtual sal_Bool SAL_CALL hasMoreElements( ) override;
virtual css::uno::Any SAL_CALL nextElement( ) override;
2011-08-02 16:10:00 +02:00
};
Extend loplugin:external to warn about classes ...following up on 314f15bff08b76bf96acf99141776ef64d2f1355 "Extend loplugin:external to warn about enums". Cases where free functions were moved into an unnamed namespace along with a class, to not break ADL, are in: filter/source/svg/svgexport.cxx sc/source/filter/excel/xelink.cxx sc/source/filter/excel/xilink.cxx svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx All other free functions mentioning moved classes appear to be harmless and not give rise to (silent, even) ADL breakage. (One remaining TODO in compilerplugins/clang/external.cxx is that derived classes are not covered by computeAffectedTypes, even though they could also be affected by ADL-breakage--- but don't seem to be in any acutal case across the code base.) For friend declarations using elaborate type specifiers, like class C1 {}; class C2 { friend class C1; }; * If C2 (but not C1) is moved into an unnamed namespace, the friend declaration must be changed to not use an elaborate type specifier (i.e., "friend C1;"; see C++17 [namespace.memdef]/3: "If the name in a friend declaration is neither qualified nor a template-id and the declaration is a function or an elaborated-type-specifier, the lookup to determine whether the entity has been previously declared shall not consider any scopes outside the innermost enclosing namespace.") * If C1 (but not C2) is moved into an unnamed namespace, the friend declaration must be changed too, see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71882> "elaborated-type-specifier friend not looked up in unnamed namespace". Apart from that, to keep changes simple and mostly mechanical (which should help avoid regressions), out-of-line definitions of class members have been left in the enclosing (named) namespace. But explicit specializations of class templates had to be moved into the unnamed namespace to appease <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92598> "explicit specialization of template from unnamed namespace using unqualified-id in enclosing namespace". Also, accompanying declarations (of e.g. typedefs or static variables) that could arguably be moved into the unnamed namespace too have been left alone. And in some cases, mention of affected types in blacklists in other loplugins needed to be adapted. And sc/qa/unit/mark_test.cxx uses a hack of including other .cxx, one of which is sc/source/core/data/segmenttree.cxx where e.g. ScFlatUInt16SegmentsImpl is not moved into an unnamed namespace (because it is declared in sc/inc/segmenttree.hxx), but its base ScFlatSegmentsImpl is. GCC warns about such combinations with enabled-by-default -Wsubobject-linkage, but "The compiler doesn’t give this warning for types defined in the main .C file, as those are unlikely to have multiple definitions." (<https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Warning-Options.html>) The warned-about classes also don't have multiple definitions in the given test, so disable the warning when including the .cxx. Change-Id: Ib694094c0d8168be68f8fe90dfd0acbb66a3f1e4 Reviewed-on: https://gerrit.libreoffice.org/83239 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-11-19 16:32:49 +01:00
}
2011-08-02 16:10:00 +02:00
sal_Bool ContainerEnumeration::hasMoreElements()
{
return static_cast<int>(m_vec.size()) > m_index +1;
2011-08-02 16:10:00 +02:00
}
css::uno::Any ContainerEnumeration::nextElement()
2011-08-02 16:10:00 +02:00
{
if( ! hasMoreElements() )
{
throw NoSuchElementException(
"NoSuchElementException during enumeration", *this );
2011-08-02 16:10:00 +02:00
}
m_index ++;
return m_vec[m_index];
}
Reference< XEnumeration > Container::createEnumeration( )
{
return new ContainerEnumeration( m_values );
}
void Container::addRefreshListener(
const css::uno::Reference< css::util::XRefreshListener >& l )
2011-08-02 16:10:00 +02:00
{
rBHelper.addListener( cppu::UnoType<decltype(l)>::get() , l );
2011-08-02 16:10:00 +02:00
}
void Container::removeRefreshListener(
const css::uno::Reference< css::util::XRefreshListener >& l )
2011-08-02 16:10:00 +02:00
{
rBHelper.removeListener( cppu::UnoType<decltype(l)>::get() , l );
2011-08-02 16:10:00 +02:00
}
void Container::disposing()
{
m_origin.clear();
}
void Container::rename( const OUString &oldName, const OUString &newName )
2011-08-02 16:10:00 +02:00
{
Any newValue;
{
osl::MutexGuard guard ( m_xMutex->GetMutex() );
2011-08-02 16:10:00 +02:00
String2IntMap::iterator ii = m_name2index.find( oldName );
if( ii != m_name2index.end() )
{
sal_Int32 nIndex = ii->second;
newValue = m_values[nIndex];
m_name2index.erase( ii );
m_name2index[ newName ] = nIndex;
}
}
fire( ReplacedBroadcaster( *this, newName, newValue, oldName ) );
fire( RefreshedBroadcaster( *this ) );
}
void Container::dropByName( const OUString& elementName )
2011-08-02 16:10:00 +02:00
{
osl::MutexGuard guard( m_xMutex->GetMutex() );
2011-08-02 16:10:00 +02:00
String2IntMap::const_iterator ii = m_name2index.find( elementName );
if( ii == m_name2index.end() )
{
throw css::container::NoSuchElementException(
"Column " + elementName + " is unknown in "
+ m_type + " container, so it can't be dropped",
*this );
2011-08-02 16:10:00 +02:00
}
dropByIndex( ii->second );
}
void Container::dropByIndex( sal_Int32 index )
{
osl::MutexGuard guard( m_xMutex->GetMutex() );
if( index < 0 || index >=static_cast<sal_Int32>(m_values.size()) )
2011-08-02 16:10:00 +02:00
{
throw css::lang::IndexOutOfBoundsException(
"Index out of range (allowed 0 to "
+ OUString::number(m_values.size() -1)
+ ", got " + OUString::number( index )
+ ") in " + m_type,
*this );
2011-08-02 16:10:00 +02:00
}
OUString name;
String2IntMap::iterator ii = std::find_if(m_name2index.begin(), m_name2index.end(),
[&index](const String2IntMap::value_type& rEntry) { return rEntry.second == index; });
if (ii != m_name2index.end())
2011-08-02 16:10:00 +02:00
{
name = ii->first;
m_name2index.erase( ii );
2011-08-02 16:10:00 +02:00
}
for( int i = index +1 ; i < static_cast<int>(m_values.size()) ; i ++ )
2011-08-02 16:10:00 +02:00
{
m_values[i-1] = m_values[i];
// I know, this is expensive, but don't want to maintain another map ...
ii = std::find_if(m_name2index.begin(), m_name2index.end(),
[&i](const String2IntMap::value_type& rEntry) { return rEntry.second == i; });
if (ii != m_name2index.end())
2011-08-02 16:10:00 +02:00
{
ii->second = i-1;
2011-08-02 16:10:00 +02:00
}
}
m_values.resize( m_values.size() - 1 );
2011-08-02 16:10:00 +02:00
fire( RemovedBroadcaster( *this, name ) );
}
void Container::append(
const OUString & name,
const css::uno::Reference< css::beans::XPropertySet >& descriptor )
2011-08-02 16:10:00 +02:00
{
osl::MutexGuard guard( m_xMutex->GetMutex() );
2011-08-02 16:10:00 +02:00
if( hasByName( name ) )
{
throw css::container::ElementExistException(
"a " + m_type + " with name " + name + " already exists in this container",
*this );
2011-08-02 16:10:00 +02:00
}
int index = m_values.size();
m_values.push_back( makeAny( descriptor ) );
2011-08-02 16:10:00 +02:00
m_name2index[name] = index;
fire( InsertedBroadcaster( *this, name, makeAny( descriptor ) ) );
}
void Container::appendByDescriptor(
const css::uno::Reference< css::beans::XPropertySet >& descriptor)
2011-08-02 16:10:00 +02:00
{
append( extractStringProperty( descriptor, getStatics().NAME ), descriptor );
}
void Container::addContainerListener(
const css::uno::Reference< css::container::XContainerListener >& l )
2011-08-02 16:10:00 +02:00
{
rBHelper.addListener( cppu::UnoType<decltype(l)>::get() , l );
2011-08-02 16:10:00 +02:00
}
void Container::removeContainerListener(
const css::uno::Reference< css::container::XContainerListener >& l )
2011-08-02 16:10:00 +02:00
{
rBHelper.removeListener( cppu::UnoType<decltype(l)>::get() , l );
2011-08-02 16:10:00 +02:00
}
void Container::fire( const EventBroadcastHelper &helper )
{
cppu::OInterfaceContainerHelper *container = rBHelper.getContainer( helper.getType() );
if( container )
{
cppu::OInterfaceIteratorHelper iterator( * container );
while( iterator.hasMoreElements() )
{
try
{
helper.fire( static_cast<XEventListener *>(iterator.next()) );
2011-08-02 16:10:00 +02:00
}
catch ( css::uno::RuntimeException & )
2011-08-02 16:10:00 +02:00
{
OSL_ENSURE( false, "exception caught" );
2011-08-02 16:10:00 +02:00
// loose coupling, a runtime exception shall not break anything
// TODO: log away as warning !
}
catch( css::uno::Exception & )
2011-08-02 16:10:00 +02:00
{
OSL_ENSURE( false, "exception from listener flying through" );
2011-08-02 16:10:00 +02:00
throw;
}
}
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */