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 "vbalistgalleries.hxx"
29 : : #include "vbalistgallery.hxx"
30 : : #include <ooo/vba/word/WdListGalleryType.hpp>
31 : :
32 : : using namespace ::ooo::vba;
33 : : using namespace ::com::sun::star;
34 : :
35 [ # # ]: 0 : class ListGalleriesEnumWrapper : public EnumerationHelper_BASE
36 : : {
37 : : SwVbaListGalleries* pListGalleries;
38 : : sal_Int32 nIndex;
39 : : public:
40 : 0 : ListGalleriesEnumWrapper( SwVbaListGalleries* pGalleries ) : pListGalleries( pGalleries ), nIndex( 1 ) {}
41 : 0 : virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
42 : : {
43 : 0 : return ( nIndex <= pListGalleries->getCount() );
44 : : }
45 : :
46 : 0 : virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
47 : : {
48 [ # # ]: 0 : if ( nIndex <= pListGalleries->getCount() )
49 [ # # ][ # # ]: 0 : return pListGalleries->Item( uno::makeAny( nIndex++ ), uno::Any() );
50 [ # # ]: 0 : throw container::NoSuchElementException();
51 : : }
52 : : };
53 : :
54 [ # # ]: 0 : SwVbaListGalleries::SwVbaListGalleries( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextDocument >& xTextDoc ) throw (uno::RuntimeException) : SwVbaListGalleries_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >() ), mxTextDocument( xTextDoc )
55 : : {
56 : 0 : }
57 : :
58 : 0 : ::sal_Int32 SAL_CALL SwVbaListGalleries::getCount() throw (uno::RuntimeException)
59 : : {
60 : : // 3 types of list( bullet, numbered and outline )
61 : 0 : return 3;
62 : : }
63 : :
64 : 0 : uno::Any SAL_CALL SwVbaListGalleries::Item( const uno::Any& Index1, const uno::Any& /*not processed in this base class*/ ) throw (uno::RuntimeException)
65 : : {
66 : 0 : sal_Int32 nIndex = 0;
67 [ # # ]: 0 : if( ( Index1 >>= nIndex ) == sal_True )
68 : : {
69 [ # # ][ # # ]: 0 : if( nIndex == word::WdListGalleryType::wdBulletGallery
[ # # ]
70 : : || nIndex == word::WdListGalleryType::wdNumberGallery
71 : : || nIndex == word::WdListGalleryType::wdOutlineNumberGallery )
72 [ # # ][ # # ]: 0 : return uno::makeAny( uno::Reference< word::XListGallery >( new SwVbaListGallery( this, mxContext, mxTextDocument, nIndex ) ) );
[ # # ][ # # ]
[ # # ]
73 : : }
74 [ # # ][ # # ]: 0 : throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Index out of bounds") ), uno::Reference< uno::XInterface >() );
75 : : }
76 : :
77 : : // XEnumerationAccess
78 : : uno::Type
79 : 0 : SwVbaListGalleries::getElementType() throw (uno::RuntimeException)
80 : : {
81 : 0 : return word::XListGallery::static_type(0);
82 : : }
83 : :
84 : : uno::Reference< container::XEnumeration >
85 : 0 : SwVbaListGalleries::createEnumeration() throw (uno::RuntimeException)
86 : : {
87 [ # # ][ # # ]: 0 : return new ListGalleriesEnumWrapper( this );
88 : : }
89 : :
90 : : uno::Any
91 : 0 : SwVbaListGalleries::createCollectionObject( const css::uno::Any& aSource )
92 : : {
93 : 0 : return aSource;
94 : : }
95 : :
96 : : rtl::OUString
97 : 0 : SwVbaListGalleries::getServiceImplName()
98 : : {
99 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaListGalleries"));
100 : : }
101 : :
102 : : css::uno::Sequence<rtl::OUString>
103 : 0 : SwVbaListGalleries::getServiceNames()
104 : : {
105 [ # # ][ # # ]: 0 : static uno::Sequence< rtl::OUString > sNames;
[ # # ][ # # ]
106 [ # # ]: 0 : if ( sNames.getLength() == 0 )
107 : : {
108 : 0 : sNames.realloc( 1 );
109 [ # # ]: 0 : sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.ListGalleries") );
110 : : }
111 : 0 : return sNames;
112 : : }
113 : :
114 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|