20#include <com/sun/star/document/EventObject.hpp>
21#include <com/sun/star/drawing/XShapes.hpp>
22#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
23#include <com/sun/star/lang/XComponent.hpp>
24#include <com/sun/star/lang/XServiceInfo.hpp>
25#include <com/sun/star/uno/XComponentContext.hpp>
32#include <osl/mutex.hxx>
40class SvxShapeCollection :
50 SvxShapeCollection() noexcept;
53 virtual
void SAL_CALL release() noexcept override;
56 virtual
void SAL_CALL dispose() override;
57 virtual
void SAL_CALL addEventListener( const css::
uno::Reference< css::lang::XEventListener >& aListener ) override;
58 virtual
void SAL_CALL removeEventListener( const css::
uno::Reference< css::lang::XEventListener >& aListener ) override;
61 virtual sal_Int32 SAL_CALL getCount() override ;
62 virtual css::
uno::Any SAL_CALL getByIndex( sal_Int32
Index ) override;
65 virtual css::
uno::
Type SAL_CALL getElementType() override;
66 virtual
sal_Bool SAL_CALL hasElements() override;
69 virtual
void SAL_CALL add( const css::
uno::Reference< css::
drawing::XShape >& xShape ) override;
70 virtual
void SAL_CALL remove( const css::
uno::Reference< css::
drawing::XShape >& xShape ) override;
73 virtual OUString SAL_CALL getImplementationName() override;
74 virtual
sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
75 virtual css::
uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
78SvxShapeCollection::SvxShapeCollection() noexcept
79: maShapeContainer( m_aMutex ), mrBHelper( m_aMutex )
84void SvxShapeCollection::release() noexcept
86 uno::Reference< uno::XInterface >
x( xDelegator );
89 if (osl_atomic_decrement( &m_refCount ) == 0)
93 uno::Reference< uno::XInterface > xHoldAlive(
static_cast<uno::XWeak*
>(
this) );
99 catch(css::uno::Exception&)
105 OSL_ASSERT( m_refCount == 1 );
111 osl_atomic_increment( &m_refCount );
117void SvxShapeCollection::dispose()
122 uno::Reference< lang::XComponent > xSelf(
this );
126 bool bDoDispose =
false;
128 osl::MutexGuard aGuard( mrBHelper.
rMutex );
143 uno::Reference< uno::XInterface > xSource( uno::Reference< uno::XInterface >::query(
static_cast<lang::XComponent *
>(
this) ) );
144 document::EventObject aEvt;
145 aEvt.Source = xSource;
148 mrBHelper.
aLC.disposeAndClear( aEvt );
149 maShapeContainer.
clear();
151 catch(
const css::uno::Exception&)
170 SAL_INFO(
"svx",
"dispose called twice" );
175void SAL_CALL SvxShapeCollection::addEventListener(
const css::uno::Reference< css::lang::XEventListener >& aListener )
181void SAL_CALL SvxShapeCollection::removeEventListener(
const css::uno::Reference< css::lang::XEventListener >& aListener )
188void SAL_CALL SvxShapeCollection::add(
const Reference< drawing::XShape >& xShape )
194void SAL_CALL SvxShapeCollection::remove(
const uno::Reference< drawing::XShape >& xShape )
200sal_Int32 SAL_CALL SvxShapeCollection::getCount()
206uno::Any SAL_CALL SvxShapeCollection::getByIndex( sal_Int32
Index )
209 throw lang::IndexOutOfBoundsException();
216uno::Type SAL_CALL SvxShapeCollection::getElementType()
221sal_Bool SAL_CALL SvxShapeCollection::hasElements()
223 return getCount() != 0;
227OUString SAL_CALL SvxShapeCollection::getImplementationName()
229 return "com.sun.star.drawing.SvxShapeCollection";
232sal_Bool SAL_CALL SvxShapeCollection::supportsService(
const OUString& ServiceName )
237uno::Sequence< OUString > SAL_CALL SvxShapeCollection::getSupportedServiceNames()
239 return {
"com.sun.star.drawing.Shapes",
"com.sun.star.drawing.ShapeCollection" };
244extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
246 css::uno::XComponentContext *,
247 css::uno::Sequence<css::uno::Any>
const &)
249 return cppu::acquire(
new SvxShapeCollection);
sal_Int32 addInterface(const css::uno::Reference< ListenerT > &rxIFace)
const css::uno::Reference< ListenerT > & getInterface(sal_Int32 nIndex) const
sal_Int32 getLength() const
sal_Int32 removeInterface(const css::uno::Reference< ListenerT > &rxIFace)
virtual void SAL_CALL release() SAL_NOEXCEPT SAL_OVERRIDE
css::uno::Type const & get()
#define SAL_INFO(area, stream)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
void addListener(const keyType &key, const css::uno::Reference< css::uno::XInterface > &r)
void removeListener(const keyType &key, const css::uno::Reference< css::uno::XInterface > &r)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_drawing_SvxShapeCollection_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)