LibreOffice Module sw (master) 1
vbaframes.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 "vbaframes.hxx"
20#include "vbaframe.hxx"
21#include <com/sun/star/frame/XModel.hpp>
23#include <utility>
24
25using namespace ::ooo::vba;
26using namespace ::com::sun::star;
27
28namespace {
29
30class FramesEnumeration : public ::cppu::WeakImplHelper< container::XEnumeration >
31{
32private:
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;
38public:
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)
41 {
42 }
43 virtual sal_Bool SAL_CALL hasMoreElements( ) override
44 {
45 return ( mnCurrentPos < mxIndexAccess->getCount() );
46 }
47
48 virtual uno::Any SAL_CALL nextElement( ) override
49 {
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 ) ) );
54 }
55
56};
57
58}
59
60SwVbaFrames::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 ))
61{
62 mxFramesSupplier.set( mxModel, uno::UNO_QUERY_THROW );
63}
64// XEnumerationAccess
67{
69}
70
71uno::Reference< container::XEnumeration >
73{
74 return new FramesEnumeration( this, mxContext,m_xIndexAccess, mxModel );
75}
76
78SwVbaFrames::createCollectionObject( const css::uno::Any& aSource )
79{
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 ) ) );
82}
83
84OUString
86{
87 return "SwVbaFrames";
88}
89
90css::uno::Sequence<OUString>
92{
93 static uno::Sequence< OUString > const sNames
94 {
95 "ooo.vba.word.Frames"
96 };
97 return sNames;
98}
99
100/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::frame::XModel2 > mxModel
unotools::WeakReference< AnimationNode > mxParent
css::uno::Reference< css::uno::XComponentContext > mxContext
css::uno::Reference< css::container::XIndexAccess > m_xIndexAccess
virtual OUString getServiceImplName() override
Definition: vbaframes.cxx:85
virtual css::uno::Type SAL_CALL getElementType() override
Definition: vbaframes.cxx:66
css::uno::Reference< css::frame::XModel > mxModel
Definition: vbaframes.hxx:31
virtual css::uno::Any createCollectionObject(const css::uno::Any &aSource) override
Definition: vbaframes.cxx:78
SwVbaFrames(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::container::XIndexAccess > &xFrames, css::uno::Reference< css::frame::XModel > xModel)
Definition: vbaframes.cxx:60
virtual css::uno::Sequence< OUString > getServiceNames() override
Definition: vbaframes.cxx:91
css::uno::Reference< css::text::XTextFramesSupplier > mxFramesSupplier
Definition: vbaframes.hxx:32
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: vbaframes.cxx:72
css::uno::Type const & get()
uno::Reference< uno::XComponentContext > mxContext
Reference< XModel > xModel
unsigned char sal_Bool