Line data Source code
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 :
26 : using namespace ::ooo::vba;
27 : using namespace ::com::sun::star;
28 :
29 : typedef ::cppu::WeakImplHelper1< container::XEnumeration > FramesEnumeration_Base;
30 0 : class FramesEnumeration : public FramesEnumeration_Base
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:
39 0 : FramesEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) : mxParent( xParent ), mxContext( xContext), mxIndexAccess( xIndexAccess ), mxModel( xModel ), nCurrentPos(0)
40 : {
41 0 : }
42 0 : virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
43 : {
44 0 : return ( nCurrentPos < mxIndexAccess->getCount() );
45 : }
46 :
47 0 : virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
48 : {
49 0 : if ( !hasMoreElements() )
50 0 : throw container::NoSuchElementException();
51 0 : uno::Reference< text::XTextFrame > xTextFrame( mxIndexAccess->getByIndex( nCurrentPos++ ), uno::UNO_QUERY_THROW );
52 0 : return uno::makeAny( uno::Reference< word::XFrame > ( new SwVbaFrame( mxParent, mxContext, mxModel, xTextFrame ) ) );
53 : }
54 :
55 : };
56 :
57 0 : 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 )
58 : {
59 0 : mxFramesSupplier.set( mxModel, uno::UNO_QUERY_THROW );
60 0 : }
61 : // XEnumerationAccess
62 : uno::Type
63 0 : SwVbaFrames::getElementType() throw (uno::RuntimeException)
64 : {
65 0 : return word::XFrame::static_type(0);
66 : }
67 :
68 : uno::Reference< container::XEnumeration >
69 0 : SwVbaFrames::createEnumeration() throw (uno::RuntimeException)
70 : {
71 0 : return new FramesEnumeration( this, mxContext,m_xIndexAccess, mxModel );
72 : }
73 :
74 : uno::Any
75 0 : SwVbaFrames::createCollectionObject( const css::uno::Any& aSource )
76 : {
77 0 : uno::Reference< text::XTextFrame > xTextFrame( aSource, uno::UNO_QUERY_THROW );
78 0 : return uno::makeAny( uno::Reference< word::XFrame > ( new SwVbaFrame( this, mxContext, mxModel, xTextFrame ) ) );
79 : }
80 :
81 : rtl::OUString
82 0 : SwVbaFrames::getServiceImplName()
83 : {
84 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaFrames"));
85 : }
86 :
87 : css::uno::Sequence<rtl::OUString>
88 0 : SwVbaFrames::getServiceNames()
89 : {
90 0 : static uno::Sequence< rtl::OUString > sNames;
91 0 : if ( sNames.getLength() == 0 )
92 : {
93 0 : sNames.realloc( 1 );
94 0 : sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Frames") );
95 : }
96 0 : return sNames;
97 : }
98 :
99 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|