21#include <com/sun/star/lang/XServiceInfo.hpp>
28SwVbaParagraph::SwVbaParagraph(
const uno::Reference< ooo::vba::XHelperInterface >& rParent,
const uno::Reference< uno::XComponentContext >& rContext, uno::Reference< text::XTextDocument > xDocument, uno::Reference< text::XTextRange > xTextRange ) :
37uno::Reference< word::XRange > SAL_CALL
46 uno::Reference< word::XRange > xRange =
getRange();
47 return xRange->getStyle();
53 uno::Reference< word::XRange > xRange =
getRange();
54 xRange->setStyle( style );
60 return "SwVbaParagraph";
63uno::Sequence< OUString >
68 "ooo.vba.word.Paragraph"
75class ParagraphCollectionHelper :
public ::cppu::WeakImplHelper< container::XIndexAccess,
76 container::XEnumerationAccess >
79 uno::Reference< text::XTextDocument > mxTextDocument;
82 uno::Reference< container::XEnumeration > getEnumeration()
84 uno::Reference< container::XEnumerationAccess > xParEnumAccess( mxTextDocument->getText(), uno::UNO_QUERY_THROW );
85 return xParEnumAccess->createEnumeration();
90 explicit ParagraphCollectionHelper( uno::Reference< text::XTextDocument > xDocument ): mxTextDocument(
std::move( xDocument ))
95 virtual sal_Bool SAL_CALL hasElements( )
override {
return true; }
97 virtual ::sal_Int32 SAL_CALL getCount( )
override
100 uno::Reference< container::XEnumeration > xParEnum = getEnumeration();
101 while( xParEnum->hasMoreElements() )
103 uno::Reference< lang::XServiceInfo > xServiceInfo( xParEnum->nextElement(), uno::UNO_QUERY_THROW );
104 if( xServiceInfo->supportsService(
"com.sun.star.text.Paragraph") )
111 virtual uno::Any SAL_CALL getByIndex( ::sal_Int32
Index )
override
113 if(
Index < getCount() )
116 uno::Reference< container::XEnumeration > xParEnum = getEnumeration();
117 while( xParEnum->hasMoreElements() )
119 uno::Reference< lang::XServiceInfo > xServiceInfo( xParEnum->nextElement(), uno::UNO_QUERY_THROW );
120 if( xServiceInfo->supportsService(
"com.sun.star.text.Paragraph") )
122 if(
Index == nCount )
128 throw lang::IndexOutOfBoundsException();
131 virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( )
override
133 return getEnumeration();
139SwVbaParagraphs::SwVbaParagraphs(
const uno::Reference< XHelperInterface >& xParent,
const uno::Reference< css::uno::XComponentContext > & xContext,
const uno::Reference< text::XTextDocument >& xDocument ) :
SwVbaParagraphs_BASE( xParent, xContext, new ParagraphCollectionHelper( xDocument ) ), mxTextDocument( xDocument )
149uno::Reference< container::XEnumeration >
152 uno::Reference< container::XEnumerationAccess > xEnumerationAccess(
m_xIndexAccess, uno::UNO_QUERY_THROW );
153 return xEnumerationAccess->createEnumeration();
159 uno::Reference< text::XTextRange > xTextRange( aSource, uno::UNO_QUERY_THROW );
166 return "SwVbaParagraphs";
169css::uno::Sequence<OUString>
172 static uno::Sequence< OUString >
const sNames
174 "ooo.vba.word.Paragraphs"
css::uno::Reference< css::uno::XComponentContext > mxContext
css::uno::Reference< css::container::XIndexAccess > m_xIndexAccess
virtual ~SwVbaParagraph() override
virtual css::uno::Reference< ooo::vba::word::XRange > SAL_CALL getRange() override
css::uno::Reference< css::text::XTextDocument > mxTextDocument
SwVbaParagraph(const css::uno::Reference< ooo::vba::XHelperInterface > &rParent, const css::uno::Reference< css::uno::XComponentContext > &rContext, css::uno::Reference< css::text::XTextDocument > xDocument, css::uno::Reference< css::text::XTextRange > xTextRange)
virtual void SAL_CALL setStyle(const css::uno::Any &style) override
css::uno::Reference< css::text::XTextRange > mxTextRange
virtual OUString getServiceImplName() override
virtual css::uno::Any SAL_CALL getStyle() override
virtual css::uno::Sequence< OUString > getServiceNames() override
css::uno::Reference< css::text::XTextDocument > mxTextDocument
virtual css::uno::Sequence< OUString > getServiceNames() override
virtual css::uno::Any createCollectionObject(const css::uno::Any &aSource) override
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
SwVbaParagraphs(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::text::XTextDocument > &xDocument)
virtual css::uno::Type SAL_CALL getElementType() override
virtual OUString getServiceImplName() override
css::uno::Type const & get()
Sequence< OUString > aServiceNames