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