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 "vbaframes.hxx"
20 #include "vbaframe.hxx"
21 #include <com/sun/star/frame/XModel.hpp>
22 #include <cppuhelper/implbase.hxx>
25 using namespace ::ooo::vba
;
26 using namespace ::com::sun::star
;
30 class FramesEnumeration
: public ::cppu::WeakImplHelper
< container::XEnumeration
>
33 uno::Reference
< XHelperInterface
> mxParent
;
34 uno::Reference
< uno::XComponentContext
> mxContext
;
35 uno::Reference
< container::XIndexAccess
> mxIndexAccess
;
36 uno::Reference
< frame::XModel
> mxModel
;
37 sal_Int32 mnCurrentPos
;
39 /// @throws uno::RuntimeException
40 FramesEnumeration( uno::Reference
< XHelperInterface
> xParent
, uno::Reference
< uno::XComponentContext
> xContext
, uno::Reference
< container::XIndexAccess
> xIndexAccess
, uno::Reference
< frame::XModel
> xModel
) : mxParent(std::move( xParent
)), mxContext(std::move( xContext
)), mxIndexAccess(std::move( xIndexAccess
)), mxModel(std::move( xModel
)), mnCurrentPos(0)
43 virtual sal_Bool SAL_CALL
hasMoreElements( ) override
45 return ( mnCurrentPos
< mxIndexAccess
->getCount() );
48 virtual uno::Any SAL_CALL
nextElement( ) override
50 if ( !hasMoreElements() )
51 throw container::NoSuchElementException();
52 uno::Reference
< text::XTextFrame
> xTextFrame( mxIndexAccess
->getByIndex( mnCurrentPos
++ ), uno::UNO_QUERY_THROW
);
53 return uno::Any( uno::Reference
< word::XFrame
> ( new SwVbaFrame( mxParent
, mxContext
, mxModel
, xTextFrame
) ) );
60 SwVbaFrames::SwVbaFrames( const uno::Reference
< XHelperInterface
>& xParent
, const uno::Reference
< uno::XComponentContext
> & xContext
, const uno::Reference
< container::XIndexAccess
>& xFrames
, uno::Reference
< frame::XModel
> xModel
): SwVbaFrames_BASE( xParent
, xContext
, xFrames
), mxModel(std::move( xModel
))
62 mxFramesSupplier
.set( mxModel
, uno::UNO_QUERY_THROW
);
66 SwVbaFrames::getElementType()
68 return cppu::UnoType
<word::XFrame
>::get();
71 uno::Reference
< container::XEnumeration
>
72 SwVbaFrames::createEnumeration()
74 return new FramesEnumeration( this, mxContext
,m_xIndexAccess
, mxModel
);
78 SwVbaFrames::createCollectionObject( const css::uno::Any
& aSource
)
80 uno::Reference
< text::XTextFrame
> xTextFrame( aSource
, uno::UNO_QUERY_THROW
);
81 return uno::Any( uno::Reference
< word::XFrame
> ( new SwVbaFrame( this, mxContext
, mxModel
, xTextFrame
) ) );
85 SwVbaFrames::getServiceImplName()
90 css::uno::Sequence
<OUString
>
91 SwVbaFrames::getServiceNames()
93 static uno::Sequence
< OUString
> const sNames
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */