1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include "vbalistgalleries.hxx"
20 #include "vbalistgallery.hxx"
21 #include <ooo/vba/word/WdListGalleryType.hpp>
24 using namespace ::ooo::vba
;
25 using namespace ::com::sun::star
;
29 class ListGalleriesEnumWrapper
: public EnumerationHelper_BASE
31 SwVbaListGalleries
* m_pListGalleries
;
34 explicit ListGalleriesEnumWrapper( SwVbaListGalleries
* pGalleries
) : m_pListGalleries( pGalleries
), m_nIndex( 1 ) {}
35 virtual sal_Bool SAL_CALL
hasMoreElements( ) override
37 return ( m_nIndex
<= m_pListGalleries
->getCount() );
40 virtual uno::Any SAL_CALL
nextElement( ) override
42 if ( m_nIndex
<= m_pListGalleries
->getCount() )
43 return m_pListGalleries
->Item( uno::Any( m_nIndex
++ ), uno::Any() );
44 throw container::NoSuchElementException();
50 SwVbaListGalleries::SwVbaListGalleries( const uno::Reference
< XHelperInterface
>& xParent
, const uno::Reference
< uno::XComponentContext
> & xContext
, uno::Reference
< text::XTextDocument
> xTextDoc
) : SwVbaListGalleries_BASE( xParent
, xContext
, uno::Reference
< container::XIndexAccess
>() ), mxTextDocument(std::move( xTextDoc
))
54 ::sal_Int32 SAL_CALL
SwVbaListGalleries::getCount()
56 // 3 types of list( bullet, numbered and outline )
60 uno::Any SAL_CALL
SwVbaListGalleries::Item( const uno::Any
& Index1
, const uno::Any
& /*not processed in this base class*/ )
63 if( Index1
>>= nIndex
)
65 if( nIndex
== word::WdListGalleryType::wdBulletGallery
66 || nIndex
== word::WdListGalleryType::wdNumberGallery
67 || nIndex
== word::WdListGalleryType::wdOutlineNumberGallery
)
68 return uno::Any( uno::Reference
< word::XListGallery
>( new SwVbaListGallery( this, mxContext
, mxTextDocument
, nIndex
) ) );
70 throw uno::RuntimeException("Index out of bounds" );
75 SwVbaListGalleries::getElementType()
77 return cppu::UnoType
<word::XListGallery
>::get();
80 uno::Reference
< container::XEnumeration
>
81 SwVbaListGalleries::createEnumeration()
83 return new ListGalleriesEnumWrapper( this );
87 SwVbaListGalleries::createCollectionObject( const css::uno::Any
& aSource
)
93 SwVbaListGalleries::getServiceImplName()
95 return "SwVbaListGalleries";
98 css::uno::Sequence
<OUString
>
99 SwVbaListGalleries::getServiceNames()
101 static uno::Sequence
< OUString
> const sNames
103 "ooo.vba.word.ListGalleries"
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */