Line data Source code
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 "vbalistlevels.hxx"
20 : #include "vbalistlevel.hxx"
21 : #include <ooo/vba/word/WdListGalleryType.hpp>
22 :
23 : using namespace ::ooo::vba;
24 : using namespace ::com::sun::star;
25 :
26 0 : class ListLevelsEnumWrapper : public EnumerationHelper_BASE
27 : {
28 : SwVbaListLevels* pListLevels;
29 : sal_Int32 nIndex;
30 : public:
31 0 : ListLevelsEnumWrapper( SwVbaListLevels* pLevels ) : pListLevels( pLevels ), nIndex( 1 ) {}
32 0 : virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
33 : {
34 0 : return ( nIndex <= pListLevels->getCount() );
35 : }
36 :
37 0 : virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
38 : {
39 0 : if ( nIndex <= pListLevels->getCount() )
40 0 : return pListLevels->Item( uno::makeAny( nIndex++ ), uno::Any() );
41 0 : throw container::NoSuchElementException();
42 : }
43 : };
44 :
45 0 : SwVbaListLevels::SwVbaListLevels( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, SwVbaListHelperRef pHelper ) throw (uno::RuntimeException) : SwVbaListLevels_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >() ), pListHelper( pHelper )
46 : {
47 0 : }
48 :
49 0 : ::sal_Int32 SAL_CALL SwVbaListLevels::getCount() throw (uno::RuntimeException)
50 : {
51 0 : sal_Int32 nGalleryType = pListHelper->getGalleryType();
52 0 : if( nGalleryType == word::WdListGalleryType::wdBulletGallery
53 : || nGalleryType == word::WdListGalleryType::wdNumberGallery )
54 0 : return 1;
55 0 : else if( nGalleryType == word::WdListGalleryType::wdOutlineNumberGallery )
56 0 : return 9;
57 0 : return 0;
58 : }
59 :
60 0 : uno::Any SAL_CALL SwVbaListLevels::Item( const uno::Any& Index1, const uno::Any& /*not processed in this base class*/ ) throw (uno::RuntimeException)
61 : {
62 0 : sal_Int32 nIndex = 0;
63 0 : if( ( Index1 >>= nIndex ) == sal_False )
64 0 : throw uno::RuntimeException();
65 0 : if( nIndex <=0 || nIndex > getCount() )
66 0 : throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Index out of bounds") ), uno::Reference< uno::XInterface >() );
67 :
68 0 : return uno::makeAny( uno::Reference< word::XListLevel >( new SwVbaListLevel( this, mxContext, pListHelper, nIndex - 1 ) ) );
69 : }
70 :
71 : // XEnumerationAccess
72 : uno::Type
73 0 : SwVbaListLevels::getElementType() throw (uno::RuntimeException)
74 : {
75 0 : return word::XListLevel::static_type(0);
76 : }
77 :
78 : uno::Reference< container::XEnumeration >
79 0 : SwVbaListLevels::createEnumeration() throw (uno::RuntimeException)
80 : {
81 0 : return new ListLevelsEnumWrapper( this );
82 : }
83 :
84 : uno::Any
85 0 : SwVbaListLevels::createCollectionObject( const css::uno::Any& aSource )
86 : {
87 0 : return aSource;
88 : }
89 :
90 : rtl::OUString
91 0 : SwVbaListLevels::getServiceImplName()
92 : {
93 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaListLevels"));
94 : }
95 :
96 : css::uno::Sequence<rtl::OUString>
97 0 : SwVbaListLevels::getServiceNames()
98 : {
99 0 : static uno::Sequence< rtl::OUString > sNames;
100 0 : if ( sNames.getLength() == 0 )
101 : {
102 0 : sNames.realloc( 1 );
103 0 : sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.ListLevels") );
104 : }
105 0 : return sNames;
106 : }
107 :
108 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|