LibreOffice Module sw (master)  1
vbalistgalleries.cxx
Go to the documentation of this file.
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 
27 {
29  sal_Int32 nIndex;
30 public:
31  explicit ListGalleriesEnumWrapper( SwVbaListGalleries* pGalleries ) : pListGalleries( pGalleries ), nIndex( 1 ) {}
32  virtual sal_Bool SAL_CALL hasMoreElements( ) override
33  {
34  return ( nIndex <= pListGalleries->getCount() );
35  }
36 
37  virtual uno::Any SAL_CALL nextElement( ) override
38  {
39  if ( nIndex <= pListGalleries->getCount() )
40  return pListGalleries->Item( uno::makeAny( nIndex++ ), uno::Any() );
41  throw container::NoSuchElementException();
42  }
43 };
44 
45 SwVbaListGalleries::SwVbaListGalleries( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextDocument >& xTextDoc ) : SwVbaListGalleries_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >() ), mxTextDocument( xTextDoc )
46 {
47 }
48 
49 ::sal_Int32 SAL_CALL SwVbaListGalleries::getCount()
50 {
51  // 3 types of list( bullet, numbered and outline )
52  return 3;
53 }
54 
55 uno::Any SAL_CALL SwVbaListGalleries::Item( const uno::Any& Index1, const uno::Any& /*not processed in this base class*/ )
56 {
57  sal_Int32 nIndex = 0;
58  if( Index1 >>= nIndex )
59  {
60  if( nIndex == word::WdListGalleryType::wdBulletGallery
61  || nIndex == word::WdListGalleryType::wdNumberGallery
62  || nIndex == word::WdListGalleryType::wdOutlineNumberGallery )
63  return uno::makeAny( uno::Reference< word::XListGallery >( new SwVbaListGallery( this, mxContext, mxTextDocument, nIndex ) ) );
64  }
65  throw uno::RuntimeException("Index out of bounds" );
66 }
67 
68 // XEnumerationAccess
71 {
73 }
74 
75 uno::Reference< container::XEnumeration >
77 {
78  return new ListGalleriesEnumWrapper( this );
79 }
80 
82 SwVbaListGalleries::createCollectionObject( const css::uno::Any& aSource )
83 {
84  return aSource;
85 }
86 
87 OUString
89 {
90  return "SwVbaListGalleries";
91 }
92 
93 css::uno::Sequence<OUString>
95 {
96  static uno::Sequence< OUString > const sNames
97  {
98  "ooo.vba.word.ListGalleries"
99  };
100  return sNames;
101 }
102 
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Sequence< OUString > getServiceNames() override
Reference
virtual css::uno::Type SAL_CALL getElementType() override
::cppu::WeakImplHelper< css::container::XEnumeration > EnumerationHelper_BASE
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
virtual ::sal_Int32 SAL_CALL getCount() override
ListGalleriesEnumWrapper(SwVbaListGalleries *pGalleries)
unsigned char sal_Bool
SwVbaListGalleries(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::text::XTextDocument > &xTextDoc)
css::uno::Type const & get()
virtual css::uno::Any createCollectionObject(const css::uno::Any &aSource) override
SwVbaListGalleries * pListGalleries
virtual OUString getServiceImplName() override
css::uno::Reference< css::uno::XComponentContext > mxContext
virtual uno::Any SAL_CALL nextElement() override
virtual css::uno::Any SAL_CALL Item(const css::uno::Any &Index1, const css::uno::Any &) override
virtual sal_Bool SAL_CALL hasMoreElements() override
css::uno::Reference< css::text::XTextDocument > mxTextDocument