37#include <com/sun/star/container/ElementExistException.hpp>
38#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
52using com::sun::star::uno::Any;
53using com::sun::star::uno::Type;
54using com::sun::star::uno::XInterface;
57using com::sun::star::uno::RuntimeException;
59using com::sun::star::container::NoSuchElementException;
60using com::sun::star::container::XEnumeration;
61using com::sun::star::container::XContainerListener;
62using com::sun::star::container::ContainerEvent;
63using com::sun::star::lang::IndexOutOfBoundsException;
64using com::sun::star::lang::XEventListener;
72class ReplacedBroadcaster :
public EventBroadcastHelper
78 const OUString &
name,
79 const Any & newElement,
80 const OUString & oldElement ) :
84 virtual void fire( XEventListener * listener )
const override
94class InsertedBroadcaster :
public EventBroadcastHelper
100 const OUString &
name,
101 const Any & newElement ) :
105 virtual void fire( XEventListener * listener )
const override
116class RemovedBroadcaster :
public EventBroadcastHelper
122 const OUString &
name) :
126 virtual void fire( XEventListener * listener )
const override
140 const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
141 css::uno::Reference< css::sdbc::XConnection > origin,
145 m_xMutex( refMutex ),
146 m_pSettings( pSettings ),
147 m_origin(
std::move( origin )),
157 throw NoSuchElementException(
158 "Element " +
aName +
" unknown in " +
m_type +
"-Container",
168 auto retRange = asNonConstRange(ret);
172 retRange[rIndex] = rName;
196 throw IndexOutOfBoundsException(
197 "Index " + OUString::number(
Index )
198 +
" out of range for " +
m_type +
"-Container, expected 0 <= x <= "
199 + OUString::number(
m_values.size() -1),
212class ContainerEnumeration :
public ::cppu::WeakImplHelper< XEnumeration >
217 explicit ContainerEnumeration( std::vector< css::uno::Any >&& vec )
224 virtual sal_Bool SAL_CALL hasMoreElements( )
override;
225 virtual css::uno::Any SAL_CALL nextElement( )
override;
231sal_Bool ContainerEnumeration::hasMoreElements()
236css::uno::Any ContainerEnumeration::nextElement()
238 if( ! hasMoreElements() )
240 throw NoSuchElementException(
241 "NoSuchElementException during enumeration", *
this );
249 return new ContainerEnumeration( std::vector(
m_values) );
253 const css::uno::Reference< css::util::XRefreshListener >& l )
255 rBHelper.addListener(
cppu::UnoType<
decltype(l)>::get() , l );
259 const css::uno::Reference< css::util::XRefreshListener >& l )
261 rBHelper.removeListener(
cppu::UnoType<
decltype(l)>::get() , l );
273 osl::MutexGuard guard (
m_xMutex->GetMutex() );
274 String2IntMap::iterator ii =
m_name2index.find( oldName );
277 sal_Int32
nIndex = ii->second;
283 fire( ReplacedBroadcaster( *
this,
newName, newValue, oldName ) );
289 osl::MutexGuard guard(
m_xMutex->GetMutex() );
290 String2IntMap::const_iterator ii =
m_name2index.find( elementName );
293 throw css::container::NoSuchElementException(
294 "Column " + elementName +
" is unknown in "
295 +
m_type +
" container, so it can't be dropped",
303 osl::MutexGuard guard(
m_xMutex->GetMutex() );
306 throw css::lang::IndexOutOfBoundsException(
307 "Index out of range (allowed 0 to "
308 + OUString::number(
m_values.size() -1)
309 +
", got " + OUString::number(
index )
316 [&
index](
const String2IntMap::value_type& rEntry) { return rEntry.second == index; });
329 [&
i](
const String2IntMap::value_type& rEntry) { return rEntry.second == i; });
337 fire( RemovedBroadcaster( *
this,
name ) );
341 const OUString &
name,
342 const css::uno::Reference< css::beans::XPropertySet >& descriptor )
345 osl::MutexGuard guard(
m_xMutex->GetMutex() );
349 throw css::container::ElementExistException(
350 "a " +
m_type +
" with name " +
name +
" already exists in this container",
358 fire( InsertedBroadcaster( *
this,
name,
Any( descriptor ) ) );
362 const css::uno::Reference< css::beans::XPropertySet >& descriptor)
369 const css::uno::Reference< css::container::XContainerListener >& l )
371 rBHelper.addListener(
cppu::UnoType<
decltype(l)>::get() , l );
375 const css::uno::Reference< css::container::XContainerListener >& l )
377 rBHelper.removeListener(
cppu::UnoType<
decltype(l)>::get() , l );
392 helper.fire(
static_cast<XEventListener *
>(iterator.
next()) );
394 catch ( css::uno::RuntimeException & )
400 catch( css::uno::Exception & )
css::uno::XInterface *SAL_CALL next()
bool SAL_CALL hasMoreElements() const
css::uno::Type const & get()
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
void append(const OUString &str, const css::uno::Reference< css::beans::XPropertySet > &descriptor)
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Container(const ::rtl::Reference< comphelper::RefCountedMutex > &refMutex, css::uno::Reference< css::sdbc::XConnection > origin, ConnectionSettings *pSettings, OUString type)
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
virtual void SAL_CALL addRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &l) override
void fire(const EventBroadcastHelper &helper)
void rename(const OUString &oldName, const OUString &newName)
virtual sal_Bool SAL_CALL hasElements() override
virtual sal_Int32 SAL_CALL getCount() override
virtual void SAL_CALL dropByName(const OUString &elementName) override
css::uno::Reference< css::sdbc::XConnection > m_origin
virtual css::uno::Type SAL_CALL getElementType() override
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
virtual void SAL_CALL disposing() override
virtual void SAL_CALL addContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
virtual void SAL_CALL removeRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &l) override
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
::rtl::Reference< comphelper::RefCountedMutex > m_xMutex
virtual void SAL_CALL appendByDescriptor(const css::uno::Reference< css::beans::XPropertySet > &descriptor) override
String2IntMap m_name2index
virtual void SAL_CALL removeContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
virtual void SAL_CALL dropByIndex(sal_Int32 index) override
std::vector< css::uno::Any > m_values
#define TOOLS_WARN_EXCEPTION(area, stream)
void SAL_CALL elementReplaced(const css::container::ContainerEvent &Event) override
void SAL_CALL elementRemoved(const css::container::ContainerEvent &Event) override
DECL_LISTENERMULTIPLEXER_END void SAL_CALL elementInserted(const css::container::ContainerEvent &Event) override
class SAL_NO_VTABLE XPropertySet
OUString newName(std::u16string_view aNewPrefix, std::u16string_view aOldPrefix, std::u16string_view old_Name)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
::cppu::WeakComponentImplHelper< css::container::XNameAccess, css::container::XIndexAccess, css::container::XEnumerationAccess, css::sdbcx::XAppend, css::sdbcx::XDrop, css::util::XRefreshable, css::sdbcx::XDataDescriptorFactory, css::container::XContainer > ContainerBase
OUString extractStringProperty(const Reference< XPropertySet > &descriptor, const OUString &name)
bool getType(BSTR name, Type &type)
std::vector< css::uno::Any > m_vec