Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2008 by Sun Microsystems, Inc.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #include "vbalistlevels.hxx"
29 : : #include "vbalistlevel.hxx"
30 : : #include <ooo/vba/word/WdListGalleryType.hpp>
31 : :
32 : : using namespace ::ooo::vba;
33 : : using namespace ::com::sun::star;
34 : :
35 [ # # ]: 0 : class ListLevelsEnumWrapper : public EnumerationHelper_BASE
36 : : {
37 : : SwVbaListLevels* pListLevels;
38 : : sal_Int32 nIndex;
39 : : public:
40 : 0 : ListLevelsEnumWrapper( SwVbaListLevels* pLevels ) : pListLevels( pLevels ), nIndex( 1 ) {}
41 : 0 : virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
42 : : {
43 : 0 : return ( nIndex <= pListLevels->getCount() );
44 : : }
45 : :
46 : 0 : virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
47 : : {
48 [ # # ]: 0 : if ( nIndex <= pListLevels->getCount() )
49 [ # # ][ # # ]: 0 : return pListLevels->Item( uno::makeAny( nIndex++ ), uno::Any() );
50 [ # # ]: 0 : throw container::NoSuchElementException();
51 : : }
52 : : };
53 : :
54 [ # # ][ # # ]: 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 )
55 : : {
56 : 0 : }
57 : :
58 : 0 : ::sal_Int32 SAL_CALL SwVbaListLevels::getCount() throw (uno::RuntimeException)
59 : : {
60 : 0 : sal_Int32 nGalleryType = pListHelper->getGalleryType();
61 [ # # ][ # # ]: 0 : if( nGalleryType == word::WdListGalleryType::wdBulletGallery
62 : : || nGalleryType == word::WdListGalleryType::wdNumberGallery )
63 : 0 : return 1;
64 [ # # ]: 0 : else if( nGalleryType == word::WdListGalleryType::wdOutlineNumberGallery )
65 : 0 : return 9;
66 : 0 : return 0;
67 : : }
68 : :
69 : 0 : uno::Any SAL_CALL SwVbaListLevels::Item( const uno::Any& Index1, const uno::Any& /*not processed in this base class*/ ) throw (uno::RuntimeException)
70 : : {
71 : 0 : sal_Int32 nIndex = 0;
72 [ # # ]: 0 : if( ( Index1 >>= nIndex ) == sal_False )
73 [ # # ]: 0 : throw uno::RuntimeException();
74 [ # # ][ # # ]: 0 : if( nIndex <=0 || nIndex > getCount() )
[ # # ][ # # ]
75 [ # # ][ # # ]: 0 : throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Index out of bounds") ), uno::Reference< uno::XInterface >() );
76 : :
77 [ # # ][ # # ]: 0 : return uno::makeAny( uno::Reference< word::XListLevel >( new SwVbaListLevel( this, mxContext, pListHelper, nIndex - 1 ) ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
78 : : }
79 : :
80 : : // XEnumerationAccess
81 : : uno::Type
82 : 0 : SwVbaListLevels::getElementType() throw (uno::RuntimeException)
83 : : {
84 : 0 : return word::XListLevel::static_type(0);
85 : : }
86 : :
87 : : uno::Reference< container::XEnumeration >
88 : 0 : SwVbaListLevels::createEnumeration() throw (uno::RuntimeException)
89 : : {
90 [ # # ][ # # ]: 0 : return new ListLevelsEnumWrapper( this );
91 : : }
92 : :
93 : : uno::Any
94 : 0 : SwVbaListLevels::createCollectionObject( const css::uno::Any& aSource )
95 : : {
96 : 0 : return aSource;
97 : : }
98 : :
99 : : rtl::OUString
100 : 0 : SwVbaListLevels::getServiceImplName()
101 : : {
102 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaListLevels"));
103 : : }
104 : :
105 : : css::uno::Sequence<rtl::OUString>
106 : 0 : SwVbaListLevels::getServiceNames()
107 : : {
108 [ # # ][ # # ]: 0 : static uno::Sequence< rtl::OUString > sNames;
[ # # ][ # # ]
109 [ # # ]: 0 : if ( sNames.getLength() == 0 )
110 : : {
111 : 0 : sNames.realloc( 1 );
112 [ # # ]: 0 : sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.ListLevels") );
113 : : }
114 : 0 : return sNames;
115 : : }
116 : :
117 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|