android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / ui / vba / vbapanes.cxx
blob05b288e29074d3a729a193b7d01140d2bf59def6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #include "vbapanes.hxx"
20 #include "vbapane.hxx"
21 #include <cppuhelper/implbase.hxx>
22 #include <utility>
24 using namespace ::ooo::vba;
25 using namespace ::com::sun::star;
27 namespace {
29 // I assume there is only one pane in Writer
30 class PanesIndexAccess : public ::cppu::WeakImplHelper<container::XIndexAccess >
32 private:
33 uno::Reference< XHelperInterface > mxParent;
34 uno::Reference< uno::XComponentContext > mxContext;
35 uno::Reference< frame::XModel > mxModel;
37 public:
38 PanesIndexAccess( uno::Reference< XHelperInterface > xParent, uno::Reference< uno::XComponentContext > xContext, uno::Reference< frame::XModel > xModel ) : mxParent(std::move( xParent )), mxContext(std::move( xContext )), mxModel(std::move( xModel )) {}
40 // XIndexAccess
41 virtual sal_Int32 SAL_CALL getCount( ) override
43 return 1;
45 virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override
47 if( Index != 0 )
48 throw lang::IndexOutOfBoundsException();
49 return uno::Any( uno::Reference< word::XPane >( new SwVbaPane( mxParent, mxContext, mxModel ) ) );
51 virtual uno::Type SAL_CALL getElementType( ) override
53 return cppu::UnoType<word::XPane>::get();
55 virtual sal_Bool SAL_CALL hasElements( ) override
57 return true;
61 class PanesEnumWrapper : public EnumerationHelper_BASE
63 uno::Reference<container::XIndexAccess > m_xIndexAccess;
64 sal_Int32 m_nIndex;
65 public:
66 explicit PanesEnumWrapper( uno::Reference< container::XIndexAccess > xIndexAccess ) : m_xIndexAccess(std::move( xIndexAccess )), m_nIndex( 0 ) {}
67 virtual sal_Bool SAL_CALL hasMoreElements( ) override
69 return ( m_nIndex < m_xIndexAccess->getCount() );
72 virtual uno::Any SAL_CALL nextElement( ) override
74 if ( m_nIndex < m_xIndexAccess->getCount() )
75 return m_xIndexAccess->getByIndex( m_nIndex++ );
76 throw container::NoSuchElementException();
82 SwVbaPanes::SwVbaPanes( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel ): SwVbaPanes_BASE( xParent, xContext, new PanesIndexAccess( xParent, xContext, xModel ) )
85 // XEnumerationAccess
86 uno::Type
87 SwVbaPanes::getElementType()
89 return cppu::UnoType<word::XPane>::get();
91 uno::Reference< container::XEnumeration >
92 SwVbaPanes::createEnumeration()
94 return new PanesEnumWrapper( m_xIndexAccess );
97 uno::Any
98 SwVbaPanes::createCollectionObject( const css::uno::Any& aSource )
100 return aSource;
103 OUString
104 SwVbaPanes::getServiceImplName()
106 return "SwVbaPanes";
109 css::uno::Sequence<OUString>
110 SwVbaPanes::getServiceNames()
112 static uno::Sequence< OUString > const sNames
114 "ooo.vba.word.Panes"
116 return sNames;
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */