1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
24 using namespace ::ooo::vba
;
25 using namespace ::com::sun::star
;
29 // I assume there is only one pane in Writer
30 class PanesIndexAccess
: public ::cppu::WeakImplHelper
<container::XIndexAccess
>
33 uno::Reference
< XHelperInterface
> mxParent
;
34 uno::Reference
< uno::XComponentContext
> mxContext
;
35 uno::Reference
< frame::XModel
> mxModel
;
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
)) {}
41 virtual sal_Int32 SAL_CALL
getCount( ) override
45 virtual uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
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
61 class PanesEnumWrapper
: public EnumerationHelper_BASE
63 uno::Reference
<container::XIndexAccess
> m_xIndexAccess
;
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
) )
87 SwVbaPanes::getElementType()
89 return cppu::UnoType
<word::XPane
>::get();
91 uno::Reference
< container::XEnumeration
>
92 SwVbaPanes::createEnumeration()
94 return new PanesEnumWrapper( m_xIndexAccess
);
98 SwVbaPanes::createCollectionObject( const css::uno::Any
& aSource
)
104 SwVbaPanes::getServiceImplName()
109 css::uno::Sequence
<OUString
>
110 SwVbaPanes::getServiceNames()
112 static uno::Sequence
< OUString
> const sNames
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */