android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / ui / vba / vbalistlevels.cxx
blob3f0d83e47896edd2e173136857d3eaf64138e075
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "vbalistlevels.hxx"
20 #include "vbalistlevel.hxx"
21 #include <ooo/vba/word/WdListGalleryType.hpp>
22 #include <utility>
24 using namespace ::ooo::vba;
25 using namespace ::com::sun::star;
27 namespace {
29 class ListLevelsEnumWrapper : public EnumerationHelper_BASE
31 SwVbaListLevels* m_pListLevels;
32 sal_Int32 m_nIndex;
33 public:
34 explicit ListLevelsEnumWrapper( SwVbaListLevels* pLevels ) : m_pListLevels( pLevels ), m_nIndex( 1 ) {}
35 virtual sal_Bool SAL_CALL hasMoreElements( ) override
37 return ( m_nIndex <= m_pListLevels->getCount() );
40 virtual uno::Any SAL_CALL nextElement( ) override
42 if ( m_nIndex <= m_pListLevels->getCount() )
43 return m_pListLevels->Item( uno::Any( m_nIndex++ ), uno::Any() );
44 throw container::NoSuchElementException();
50 SwVbaListLevels::SwVbaListLevels( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, SwVbaListHelperRef pHelper ) : SwVbaListLevels_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >() ), m_pListHelper(std::move( pHelper ))
54 ::sal_Int32 SAL_CALL SwVbaListLevels::getCount()
56 sal_Int32 nGalleryType = m_pListHelper->getGalleryType();
57 if( nGalleryType == word::WdListGalleryType::wdBulletGallery
58 || nGalleryType == word::WdListGalleryType::wdNumberGallery )
59 return 1;
60 else if( nGalleryType == word::WdListGalleryType::wdOutlineNumberGallery )
61 return 9;
62 return 0;
65 uno::Any SAL_CALL SwVbaListLevels::Item( const uno::Any& Index1, const uno::Any& /*not processed in this base class*/ )
67 sal_Int32 nIndex = 0;
68 if( !( Index1 >>= nIndex ) )
69 throw uno::RuntimeException();
70 if( nIndex <=0 || nIndex > getCount() )
71 throw uno::RuntimeException("Index out of bounds" );
73 return uno::Any( uno::Reference< word::XListLevel >( new SwVbaListLevel( this, mxContext, m_pListHelper, nIndex - 1 ) ) );
76 // XEnumerationAccess
77 uno::Type
78 SwVbaListLevels::getElementType()
80 return cppu::UnoType<word::XListLevel>::get();
83 uno::Reference< container::XEnumeration >
84 SwVbaListLevels::createEnumeration()
86 return new ListLevelsEnumWrapper( this );
89 uno::Any
90 SwVbaListLevels::createCollectionObject( const css::uno::Any& aSource )
92 return aSource;
95 OUString
96 SwVbaListLevels::getServiceImplName()
98 return "SwVbaListLevels";
101 css::uno::Sequence<OUString>
102 SwVbaListLevels::getServiceNames()
104 static uno::Sequence< OUString > const sNames
106 "ooo.vba.word.ListLevels"
108 return sNames;
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */