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