20#include <com/sun/star/drawing/XControlShape.hpp>
21#include <com/sun/star/container/XNamed.hpp>
22#include <ooo/vba/excel/XOLEObject.hpp>
38typedef std::vector< uno::Reference< drawing::XControlShape > > OLEObjects;
41 explicit IndexAccessWrapper(
const uno::Reference< container::XIndexAccess >& xIndexAccess )
43 sal_Int32 nLen = xIndexAccess->getCount();
46 uno::Reference< drawing::XControlShape > xControlShape( xIndexAccess->getByIndex(
index), uno::UNO_QUERY);
47 if ( xControlShape.is() )
48 vObjects.push_back( xControlShape );
52 virtual ::sal_Int32 SAL_CALL getCount()
override
54 return vObjects.size();
57 virtual uno::Any SAL_CALL getByIndex( ::sal_Int32
Index )
override
60 throw lang::IndexOutOfBoundsException();
65 virtual uno::Type SAL_CALL getElementType()
override
70 virtual sal_Bool SAL_CALL hasElements()
override
72 return ( getCount() > 0 );
80 uno::Reference<XHelperInterface > m_xParent;
81 uno::Reference<uno::XComponentContext >
m_xContext;
82 uno::Reference<container::XIndexAccess > m_xIndexAccess;
85 EnumWrapper( uno::Reference< XHelperInterface > xParent,
86 uno::Reference< uno::XComponentContext > xContext,
87 uno::Reference< container::XIndexAccess > xIndexAccess )
88 : m_xParent(std::move( xParent )),
m_xContext(std::move( xContext)), m_xIndexAccess(std::move( xIndexAccess )),
nIndex( 0 ) {}
90 virtual sal_Bool SAL_CALL hasMoreElements( )
override
92 return ( nIndex < m_xIndexAccess->getCount() );
95 virtual uno::Any SAL_CALL nextElement( )
override
97 if ( nIndex < m_xIndexAccess->getCount() )
99 uno::Reference< drawing::XControlShape > xControlShape ( m_xIndexAccess->getByIndex(
nIndex++ ), uno::UNO_QUERY_THROW );
102 throw container::NoSuchElementException();
106uno::Reference< container::XIndexAccess > oleObjectIndexWrapper(
const uno::Reference< container::XIndexAccess >& xIndexAccess )
108 return new IndexAccessWrapper( xIndexAccess );
114 const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess )
118uno::Reference< container::XEnumeration >
127 if( aSource.hasValue() )
129 uno::Reference< drawing::XControlShape > xControlShape( aSource, uno::UNO_QUERY_THROW );
143 catch (
const uno::RuntimeException&)
145 uno::Reference< container::XIndexAccess > xIndexAccess(
m_xIndexAccess, uno::UNO_SET_THROW );
146 sal_Int32
nCount = xIndexAccess->getCount();
150 uno::Reference< drawing::XControlShape > xControlShape( aUnoObj, uno::UNO_QUERY_THROW );
151 uno::Reference< awt::XControlModel > xControlModel( xControlShape->getControl() );
152 uno::Reference< container::XNamed > xNamed( xControlModel, uno::UNO_QUERY_THROW );
153 if( sIndex == xNamed->getName() )
172 return "ScVbaOLEObjects";
175uno::Sequence< OUString >
180 "ooo.vba.excel.OLEObjects"
Reference< XComponentContext > m_xContext
css::uno::Reference< css::uno::XComponentContext > mxContext
virtual css::uno::Reference< ov::XHelperInterface > SAL_CALL getParent() override
css::uno::Reference< css::container::XIndexAccess > m_xIndexAccess
virtual css::uno::Any getItemByStringIndex(const OUString &sIndex)
virtual css::uno::Type SAL_CALL getElementType() override
virtual css::uno::Sequence< OUString > getServiceNames() override
virtual css::uno::Any getItemByStringIndex(const OUString &sIndex) override
virtual OUString getServiceImplName() override
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
virtual css::uno::Any createCollectionObject(const css::uno::Any &aSource) override
ScVbaOLEObjects(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::container::XIndexAccess > &xIndexAccess)
css::uno::Type const & get()
Sequence< OUString > aServiceNames
::cppu::WeakImplHelper< css::container::XEnumeration > EnumerationHelper_BASE
::cppu::WeakImplHelper< container::XIndexAccess > XIndexAccess_BASE
::cppu::WeakImplHelper< container::XIndexAccess > XIndexAccess_BASE