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 2000, 2010 Oracle and/or its affiliates.
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 "vbapanes.hxx"
29 : : #include "vbapane.hxx"
30 : :
31 : : using namespace ::ooo::vba;
32 : : using namespace ::com::sun::star;
33 : :
34 : : // I assume there is only one pane in Writer
35 : : typedef ::cppu::WeakImplHelper1<container::XIndexAccess > PanesIndexAccess_Base;
36 : : class PanesIndexAccess : public PanesIndexAccess_Base
37 : : {
38 : : private:
39 : : uno::Reference< XHelperInterface > mxParent;
40 : : uno::Reference< uno::XComponentContext > mxContext;
41 : : uno::Reference< frame::XModel > mxModel;
42 : :
43 : : public:
44 : 0 : PanesIndexAccess( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : mxParent( xParent ), mxContext( xContext ), mxModel( xModel ) {}
45 [ # # ]: 0 : ~PanesIndexAccess(){}
46 : :
47 : : // XIndexAccess
48 : 0 : virtual sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException)
49 : : {
50 : 0 : return 1;
51 : : }
52 : 0 : virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
53 : : {
54 [ # # ]: 0 : if( Index != 1 )
55 [ # # ]: 0 : throw container::NoSuchElementException();
56 [ # # ][ # # ]: 0 : return uno::makeAny( uno::Reference< word::XPane >( new SwVbaPane( mxParent, mxContext, mxModel ) ) );
[ # # ]
57 : : }
58 : 0 : virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException)
59 : : {
60 : 0 : return word::XPane::static_type(0);
61 : : }
62 : 0 : virtual sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException)
63 : : {
64 : 0 : return sal_True;
65 : : }
66 : : };
67 : :
68 [ # # ]: 0 : class PanesEnumWrapper : public EnumerationHelper_BASE
69 : : {
70 : : uno::Reference<container::XIndexAccess > m_xIndexAccess;
71 : : sal_Int32 nIndex;
72 : : public:
73 : 0 : PanesEnumWrapper( const uno::Reference< container::XIndexAccess >& xIndexAccess ) : m_xIndexAccess( xIndexAccess ), nIndex( 0 ) {}
74 : 0 : virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
75 : : {
76 : 0 : return ( nIndex < m_xIndexAccess->getCount() );
77 : : }
78 : :
79 : 0 : virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
80 : : {
81 [ # # ]: 0 : if ( nIndex < m_xIndexAccess->getCount() )
82 : 0 : return m_xIndexAccess->getByIndex( nIndex++ );
83 [ # # ]: 0 : throw container::NoSuchElementException();
84 : : }
85 : : };
86 : :
87 [ # # ][ # # ]: 0 : SwVbaPanes::SwVbaPanes( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel ): SwVbaPanes_BASE( xParent, xContext, new PanesIndexAccess( xParent, xContext, xModel ) ), mxModel( xModel )
[ # # ]
88 : : {
89 : 0 : }
90 : : // XEnumerationAccess
91 : : uno::Type
92 : 0 : SwVbaPanes::getElementType() throw (uno::RuntimeException)
93 : : {
94 : 0 : return word::XPane::static_type(0);
95 : : }
96 : : uno::Reference< container::XEnumeration >
97 : 0 : SwVbaPanes::createEnumeration() throw (uno::RuntimeException)
98 : : {
99 [ # # ][ # # ]: 0 : return new PanesEnumWrapper( m_xIndexAccess );
100 : : }
101 : :
102 : : uno::Any
103 : 0 : SwVbaPanes::createCollectionObject( const css::uno::Any& aSource )
104 : : {
105 : 0 : return aSource;
106 : : }
107 : :
108 : : rtl::OUString
109 : 0 : SwVbaPanes::getServiceImplName()
110 : : {
111 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaPanes"));
112 : : }
113 : :
114 : : css::uno::Sequence<rtl::OUString>
115 : 0 : SwVbaPanes::getServiceNames()
116 : : {
117 [ # # ][ # # ]: 0 : static uno::Sequence< rtl::OUString > sNames;
[ # # ][ # # ]
118 [ # # ]: 0 : if ( sNames.getLength() == 0 )
119 : : {
120 : 0 : sNames.realloc( 1 );
121 [ # # ]: 0 : sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Panes") );
122 : : }
123 : 0 : return sNames;
124 : : }
125 : :
126 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|