LibreOffice Module sw (master) 1
vbalistgalleries.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#include "vbalistgalleries.hxx"
20#include "vbalistgallery.hxx"
21#include <ooo/vba/word/WdListGalleryType.hpp>
22#include <utility>
23
24using namespace ::ooo::vba;
25using namespace ::com::sun::star;
26
27namespace {
28
29class ListGalleriesEnumWrapper : public EnumerationHelper_BASE
30{
31 SwVbaListGalleries* m_pListGalleries;
32 sal_Int32 m_nIndex;
33public:
34 explicit ListGalleriesEnumWrapper( SwVbaListGalleries* pGalleries ) : m_pListGalleries( pGalleries ), m_nIndex( 1 ) {}
35 virtual sal_Bool SAL_CALL hasMoreElements( ) override
36 {
37 return ( m_nIndex <= m_pListGalleries->getCount() );
38 }
39
40 virtual uno::Any SAL_CALL nextElement( ) override
41 {
42 if ( m_nIndex <= m_pListGalleries->getCount() )
43 return m_pListGalleries->Item( uno::Any( m_nIndex++ ), uno::Any() );
44 throw container::NoSuchElementException();
45 }
46};
47
48}
49
50SwVbaListGalleries::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 ))
51{
52}
53
54::sal_Int32 SAL_CALL SwVbaListGalleries::getCount()
55{
56 // 3 types of list( bullet, numbered and outline )
57 return 3;
58}
59
60uno::Any SAL_CALL SwVbaListGalleries::Item( const uno::Any& Index1, const uno::Any& /*not processed in this base class*/ )
61{
62 sal_Int32 nIndex = 0;
63 if( Index1 >>= nIndex )
64 {
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 ) ) );
69 }
70 throw uno::RuntimeException("Index out of bounds" );
71}
72
73// XEnumerationAccess
76{
78}
79
80uno::Reference< container::XEnumeration >
82{
83 return new ListGalleriesEnumWrapper( this );
84}
85
87SwVbaListGalleries::createCollectionObject( const css::uno::Any& aSource )
88{
89 return aSource;
90}
91
92OUString
94{
95 return "SwVbaListGalleries";
96}
97
98css::uno::Sequence<OUString>
100{
101 static uno::Sequence< OUString > const sNames
102 {
103 "ooo.vba.word.ListGalleries"
104 };
105 return sNames;
106}
107
108/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::uno::XComponentContext > mxContext
virtual OUString getServiceImplName() override
virtual ::sal_Int32 SAL_CALL getCount() override
SwVbaListGalleries(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, css::uno::Reference< css::text::XTextDocument > xTextDoc)
virtual css::uno::Any SAL_CALL Item(const css::uno::Any &Index1, const css::uno::Any &) override
css::uno::Reference< css::text::XTextDocument > mxTextDocument
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
virtual css::uno::Type SAL_CALL getElementType() override
css::uno::Type const & get()
sal_Int32 nIndex
Reference
unsigned char sal_Bool
::cppu::WeakImplHelper< css::container::XEnumeration > EnumerationHelper_BASE