22#include <com/sun/star/beans/XPropertySet.hpp>
23#include <com/sun/star/lang/XMultiServiceFactory.hpp>
24#include <com/sun/star/text/XDocumentIndexesSupplier.hpp>
35 uno::Reference< container::XIndexAccess > mxIndexAccess;
39 explicit TablesOfContentsEnumWrapper( uno::Reference< container::XIndexAccess > xIndexAccess ) : mxIndexAccess(
std::move( xIndexAccess )), m_nIndex( 0 )
42 virtual sal_Bool SAL_CALL hasMoreElements( )
override
44 return ( m_nIndex < mxIndexAccess->getCount() );
47 virtual uno::Any SAL_CALL nextElement( )
override
49 if( m_nIndex < mxIndexAccess->getCount() )
51 return mxIndexAccess->getByIndex( m_nIndex++ );
53 throw container::NoSuchElementException();
57class TableOfContentsCollectionHelper :
public ::cppu::WeakImplHelper< container::XIndexAccess,
58 container::XEnumerationAccess >
61 uno::Reference< XHelperInterface >
mxParent;
62 uno::Reference< uno::XComponentContext >
mxContext;
63 uno::Reference< text::XTextDocument > mxTextDocument;
64 std::vector< uno::Reference< text::XDocumentIndex > > maToc;
68 TableOfContentsCollectionHelper( uno::Reference< ov::XHelperInterface > xParent, uno::Reference< uno::XComponentContext > xContext, uno::Reference< text::XTextDocument > xDoc ):
mxParent(
std::move( xParent )),
mxContext(
std::move( xContext )), mxTextDocument(
std::move( xDoc ))
70 uno::Reference< text::XDocumentIndexesSupplier > xDocIndexSupp( mxTextDocument, uno::UNO_QUERY_THROW );
71 uno::Reference< container::XIndexAccess > xDocIndexes = xDocIndexSupp->getDocumentIndexes();
72 sal_Int32
nCount = xDocIndexes->getCount();
73 for( sal_Int32 i = 0;
i <
nCount;
i++ )
75 uno::Reference< text::XDocumentIndex > xToc( xDocIndexes->getByIndex(i), uno::UNO_QUERY_THROW );
76 if( xToc->getServiceName() ==
"com.sun.star.text.ContentIndex" )
78 maToc.push_back( xToc );
83 virtual sal_Int32 SAL_CALL getCount( )
override
87 virtual uno::Any SAL_CALL getByIndex( sal_Int32
Index )
override
90 throw lang::IndexOutOfBoundsException();
92 uno::Reference< text::XDocumentIndex > xToc( maToc[
Index], uno::UNO_SET_THROW );
95 virtual uno::Type SAL_CALL getElementType( )
override
99 virtual sal_Bool SAL_CALL hasElements( )
override
104 virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( )
override
106 return new TablesOfContentsEnumWrapper(
this );
116uno::Reference< word::XTableOfContents > SAL_CALL
117SwVbaTablesOfContents::Add(
const uno::Reference< word::XRange >&
Range,
const uno::Any& ,
const uno::Any& ,
const uno::Any& LowerHeadingLevel,
const uno::Any& UseFields,
const uno::Any& ,
const uno::Any& ,
const uno::Any& ,
const uno::Any& ,
const uno::Any& ,
const uno::Any& ,
const uno::Any& )
119 uno::Reference< lang::XMultiServiceFactory > xDocMSF(
mxTextDocument, uno::UNO_QUERY_THROW );
120 uno::Reference< text::XDocumentIndex > xDocumentIndex( xDocMSF->createInstance(
"com.sun.star.text.ContentIndex"), uno::UNO_QUERY_THROW );
122 uno::Reference< beans::XPropertySet > xTocProps( xDocumentIndex, uno::UNO_QUERY_THROW );
123 xTocProps->setPropertyValue(
"IsProtected",
uno::Any(
false ) );
127 sal_Int32 nLowerHeadingLevel = 9;
129 LowerHeadingLevel >>= nLowerHeadingLevel;
130 xToc->setLowerHeadingLevel( nLowerHeadingLevel );
132 bool bUseFields =
false;
134 UseFields >>= bUseFields;
135 xToc->setUseFields( bUseFields );
137 xToc->setUseOutlineLevels(
true );
141 throw uno::RuntimeException();
143 uno::Reference< text::XTextRange > xTextRange = pVbaRange->
getXTextRange();
144 uno::Reference< text::XText > xText = pVbaRange->
getXText();
145 uno::Reference< text::XTextContent > xTextContent( xDocumentIndex, uno::UNO_QUERY_THROW );
146 xText->insertTextContent( xTextRange, xTextContent,
false );
158uno::Reference< container::XEnumeration >
173 return "SwVbaTablesOfContents";
176uno::Sequence<OUString>
179 static uno::Sequence< OUString >
const sNames
181 "ooo.vba.word.TablesOfContents"
unotools::WeakReference< AnimationNode > mxParent
css::uno::Reference< css::uno::XComponentContext > mxContext
css::uno::Reference< css::container::XIndexAccess > m_xIndexAccess
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getXTextRange() override
const css::uno::Reference< css::text::XText > & getXText() const
SwVbaTablesOfContents(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::text::XTextDocument > &xDoc)
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
virtual css::uno::Any createCollectionObject(const css::uno::Any &aSource) override
virtual css::uno::Sequence< OUString > getServiceNames() override
css::uno::Reference< css::text::XTextDocument > mxTextDocument
virtual OUString getServiceImplName() override
virtual css::uno::Reference< ::ooo::vba::word::XTableOfContents > SAL_CALL Add(const css::uno::Reference< ::ooo::vba::word::XRange > &Range, const css::uno::Any &UseHeadingStyles, const css::uno::Any &UpperHeadingLevel, const css::uno::Any &LowerHeadingLevel, const css::uno::Any &UseFields, const css::uno::Any &TableID, const css::uno::Any &RightAlignPageNumbers, const css::uno::Any &IncludePageNumbers, const css::uno::Any &AddedStyles, const css::uno::Any &UseHyperlinks, const css::uno::Any &HidePageNumbersInWeb, const css::uno::Any &UseOutlineLevels) override
virtual css::uno::Type SAL_CALL getElementType() override
css::uno::Type const & get()
::cppu::WeakImplHelper< css::container::XEnumeration > EnumerationHelper_BASE