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>
22 #include <cppuhelper/implbase.hxx>
23 
24 using namespace ::ooo::vba;
25 using namespace ::com::sun::star;
26 
27 namespace {
28 
29 class FramesEnumeration : public ::cppu::WeakImplHelper< container::XEnumeration >
30 {
31 private:
32  uno::Reference< XHelperInterface > mxParent;
33  uno::Reference< uno::XComponentContext > mxContext;
34  uno::Reference< container::XIndexAccess> mxIndexAccess;
35  uno::Reference< frame::XModel > mxModel;
36  sal_Int32 nCurrentPos;
37 public:
39  FramesEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess, const uno::Reference< frame::XModel >& xModel ) : mxParent( xParent ), mxContext( xContext), mxIndexAccess( xIndexAccess ), mxModel( xModel ), nCurrentPos(0)
40  {
41  }
42  virtual sal_Bool SAL_CALL hasMoreElements( ) override
43  {
44  return ( nCurrentPos < mxIndexAccess->getCount() );
45  }
46 
47  virtual uno::Any SAL_CALL nextElement( ) override
48  {
49  if ( !hasMoreElements() )
50  throw container::NoSuchElementException();
51  uno::Reference< text::XTextFrame > xTextFrame( mxIndexAccess->getByIndex( nCurrentPos++ ), uno::UNO_QUERY_THROW );
52  return uno::makeAny( uno::Reference< word::XFrame > ( new SwVbaFrame( mxParent, mxContext, mxModel, xTextFrame ) ) );
53  }
54 
55 };
56 
57 }
58 
59 SwVbaFrames::SwVbaFrames( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< container::XIndexAccess >& xFrames, const uno::Reference< frame::XModel >& xModel ): SwVbaFrames_BASE( xParent, xContext, xFrames ), mxModel( xModel )
60 {
61  mxFramesSupplier.set( mxModel, uno::UNO_QUERY_THROW );
62 }
63 // XEnumerationAccess
66 {
68 }
69 
70 uno::Reference< container::XEnumeration >
72 {
73  return new FramesEnumeration( this, mxContext,m_xIndexAccess, mxModel );
74 }
75 
77 SwVbaFrames::createCollectionObject( const css::uno::Any& aSource )
78 {
79  uno::Reference< text::XTextFrame > xTextFrame( aSource, uno::UNO_QUERY_THROW );
80  return uno::makeAny( uno::Reference< word::XFrame > ( new SwVbaFrame( this, mxContext, mxModel, xTextFrame ) ) );
81 }
82 
83 OUString
85 {
86  return "SwVbaFrames";
87 }
88 
89 css::uno::Sequence<OUString>
91 {
92  static uno::Sequence< OUString > const sNames
93  {
94  "ooo.vba.word.Frames"
95  };
96  return sNames;
97 }
98 
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::container::XIndexAccess > m_xIndexAccess
uno::Reference< uno::XComponentContext > mxContext
WeakReference< XInterface > mxParent
virtual css::uno::Any createCollectionObject(const css::uno::Any &aSource) override
Definition: vbaframes.cxx:77
css::uno::Reference< css::frame::XModel2 > mxModel
css::uno::Reference< css::text::XTextFramesSupplier > mxFramesSupplier
Definition: vbaframes.hxx:32
SwVbaFrames(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::container::XIndexAccess > &xFrames, const css::uno::Reference< css::frame::XModel > &xModel)
Definition: vbaframes.cxx:59
virtual css::uno::Sequence< OUString > getServiceNames() override
Definition: vbaframes.cxx:90
unsigned char sal_Bool
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: vbaframes.cxx:71
css::uno::Type const & get()
virtual OUString getServiceImplName() override
Definition: vbaframes.cxx:84
virtual css::uno::Type SAL_CALL getElementType() override
Definition: vbaframes.cxx:65