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