Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2008 by Sun Microsystems, Inc.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #include "vbaframes.hxx"
29 : : #include "vbaframe.hxx"
30 : : #include <com/sun/star/text/XTextDocument.hpp>
31 : : #include <com/sun/star/text/XTextViewCursor.hpp>
32 : : #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
33 : : #include "wordvbahelper.hxx"
34 : :
35 : : using namespace ::ooo::vba;
36 : : using namespace ::com::sun::star;
37 : :
38 : : typedef ::cppu::WeakImplHelper1< container::XEnumeration > FramesEnumeration_Base;
39 [ # # ]: 0 : class FramesEnumeration : public FramesEnumeration_Base
40 : : {
41 : : private:
42 : : uno::Reference< XHelperInterface > mxParent;
43 : : uno::Reference< uno::XComponentContext > mxContext;
44 : : uno::Reference< container::XIndexAccess> mxIndexAccess;
45 : : uno::Reference< frame::XModel > mxModel;
46 : : sal_Int32 nCurrentPos;
47 : : public:
48 : 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)
49 : : {
50 : 0 : }
51 : 0 : virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
52 : : {
53 : 0 : return ( nCurrentPos < mxIndexAccess->getCount() );
54 : : }
55 : :
56 : 0 : virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
57 : : {
58 [ # # ][ # # ]: 0 : if ( !hasMoreElements() )
59 [ # # ]: 0 : throw container::NoSuchElementException();
60 [ # # ][ # # ]: 0 : uno::Reference< text::XTextFrame > xTextFrame( mxIndexAccess->getByIndex( nCurrentPos++ ), uno::UNO_QUERY_THROW );
[ # # ]
61 [ # # ][ # # ]: 0 : return uno::makeAny( uno::Reference< word::XFrame > ( new SwVbaFrame( mxParent, mxContext, mxModel, xTextFrame ) ) );
[ # # ][ # # ]
62 : : }
63 : :
64 : : };
65 : :
66 : 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 )
67 : : {
68 [ # # ]: 0 : mxFramesSupplier.set( mxModel, uno::UNO_QUERY_THROW );
69 : 0 : }
70 : : // XEnumerationAccess
71 : : uno::Type
72 : 0 : SwVbaFrames::getElementType() throw (uno::RuntimeException)
73 : : {
74 : 0 : return word::XFrame::static_type(0);
75 : : }
76 : :
77 : : uno::Reference< container::XEnumeration >
78 : 0 : SwVbaFrames::createEnumeration() throw (uno::RuntimeException)
79 : : {
80 [ # # ][ # # ]: 0 : return new FramesEnumeration( this, mxContext,m_xIndexAccess, mxModel );
[ # # ]
81 : : }
82 : :
83 : : uno::Any
84 : 0 : SwVbaFrames::createCollectionObject( const css::uno::Any& aSource )
85 : : {
86 [ # # ]: 0 : uno::Reference< text::XTextFrame > xTextFrame( aSource, uno::UNO_QUERY_THROW );
87 [ # # ][ # # ]: 0 : return uno::makeAny( uno::Reference< word::XFrame > ( new SwVbaFrame( this, mxContext, mxModel, xTextFrame ) ) );
[ # # ][ # # ]
[ # # ]
88 : : }
89 : :
90 : : rtl::OUString
91 : 0 : SwVbaFrames::getServiceImplName()
92 : : {
93 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaFrames"));
94 : : }
95 : :
96 : : css::uno::Sequence<rtl::OUString>
97 : 0 : SwVbaFrames::getServiceNames()
98 : : {
99 [ # # ][ # # ]: 0 : static uno::Sequence< rtl::OUString > sNames;
[ # # ][ # # ]
100 [ # # ]: 0 : if ( sNames.getLength() == 0 )
101 : : {
102 : 0 : sNames.realloc( 1 );
103 [ # # ]: 0 : sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Frames") );
104 : : }
105 : 0 : return sNames;
106 : : }
107 : :
108 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|