1*b1cdbd2cSJim Jagielski /**************************************************************
2*b1cdbd2cSJim Jagielski *
3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file
5*b1cdbd2cSJim Jagielski * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file
7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski *
11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski *
13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the
17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski * under the License.
19*b1cdbd2cSJim Jagielski *
20*b1cdbd2cSJim Jagielski *************************************************************/
21*b1cdbd2cSJim Jagielski
22*b1cdbd2cSJim Jagielski
23*b1cdbd2cSJim Jagielski #include "vbapanes.hxx"
24*b1cdbd2cSJim Jagielski #include "vbapane.hxx"
25*b1cdbd2cSJim Jagielski
26*b1cdbd2cSJim Jagielski using namespace ::ooo::vba;
27*b1cdbd2cSJim Jagielski using namespace ::com::sun::star;
28*b1cdbd2cSJim Jagielski
29*b1cdbd2cSJim Jagielski // I assume there is only one pane in Writer
30*b1cdbd2cSJim Jagielski typedef ::cppu::WeakImplHelper1<container::XIndexAccess > PanesIndexAccess_Base;
31*b1cdbd2cSJim Jagielski class PanesIndexAccess : public PanesIndexAccess_Base
32*b1cdbd2cSJim Jagielski {
33*b1cdbd2cSJim Jagielski private:
34*b1cdbd2cSJim Jagielski uno::Reference< XHelperInterface > mxParent;
35*b1cdbd2cSJim Jagielski uno::Reference< uno::XComponentContext > mxContext;
36*b1cdbd2cSJim Jagielski uno::Reference< frame::XModel > mxModel;
37*b1cdbd2cSJim Jagielski
38*b1cdbd2cSJim Jagielski public:
PanesIndexAccess(const uno::Reference<XHelperInterface> & xParent,const uno::Reference<uno::XComponentContext> & xContext,const uno::Reference<frame::XModel> & xModel)39*b1cdbd2cSJim Jagielski PanesIndexAccess( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : mxParent( xParent ), mxContext( xContext ), mxModel( xModel ) {}
~PanesIndexAccess()40*b1cdbd2cSJim Jagielski ~PanesIndexAccess(){}
41*b1cdbd2cSJim Jagielski
42*b1cdbd2cSJim Jagielski // XIndexAccess
getCount()43*b1cdbd2cSJim Jagielski virtual sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException)
44*b1cdbd2cSJim Jagielski {
45*b1cdbd2cSJim Jagielski return 1;
46*b1cdbd2cSJim Jagielski }
getByIndex(sal_Int32 Index)47*b1cdbd2cSJim Jagielski virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
48*b1cdbd2cSJim Jagielski {
49*b1cdbd2cSJim Jagielski if( Index != 1 )
50*b1cdbd2cSJim Jagielski throw container::NoSuchElementException();
51*b1cdbd2cSJim Jagielski return uno::makeAny( uno::Reference< word::XPane >( new SwVbaPane( mxParent, mxContext, mxModel ) ) );
52*b1cdbd2cSJim Jagielski }
getElementType()53*b1cdbd2cSJim Jagielski virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException)
54*b1cdbd2cSJim Jagielski {
55*b1cdbd2cSJim Jagielski return word::XPane::static_type(0);
56*b1cdbd2cSJim Jagielski }
hasElements()57*b1cdbd2cSJim Jagielski virtual sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException)
58*b1cdbd2cSJim Jagielski {
59*b1cdbd2cSJim Jagielski return sal_True;
60*b1cdbd2cSJim Jagielski }
61*b1cdbd2cSJim Jagielski };
62*b1cdbd2cSJim Jagielski
63*b1cdbd2cSJim Jagielski class PanesEnumWrapper : public EnumerationHelper_BASE
64*b1cdbd2cSJim Jagielski {
65*b1cdbd2cSJim Jagielski uno::Reference<container::XIndexAccess > m_xIndexAccess;
66*b1cdbd2cSJim Jagielski sal_Int32 nIndex;
67*b1cdbd2cSJim Jagielski public:
PanesEnumWrapper(const uno::Reference<container::XIndexAccess> & xIndexAccess)68*b1cdbd2cSJim Jagielski PanesEnumWrapper( const uno::Reference< container::XIndexAccess >& xIndexAccess ) : m_xIndexAccess( xIndexAccess ), nIndex( 0 ) {}
hasMoreElements()69*b1cdbd2cSJim Jagielski virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
70*b1cdbd2cSJim Jagielski {
71*b1cdbd2cSJim Jagielski return ( nIndex < m_xIndexAccess->getCount() );
72*b1cdbd2cSJim Jagielski }
73*b1cdbd2cSJim Jagielski
nextElement()74*b1cdbd2cSJim Jagielski virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
75*b1cdbd2cSJim Jagielski {
76*b1cdbd2cSJim Jagielski if ( nIndex < m_xIndexAccess->getCount() )
77*b1cdbd2cSJim Jagielski return m_xIndexAccess->getByIndex( nIndex++ );
78*b1cdbd2cSJim Jagielski throw container::NoSuchElementException();
79*b1cdbd2cSJim Jagielski }
80*b1cdbd2cSJim Jagielski };
81*b1cdbd2cSJim Jagielski
SwVbaPanes(const uno::Reference<XHelperInterface> & xParent,const uno::Reference<uno::XComponentContext> & xContext,const uno::Reference<frame::XModel> & xModel)82*b1cdbd2cSJim Jagielski 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 )
83*b1cdbd2cSJim Jagielski {
84*b1cdbd2cSJim Jagielski }
85*b1cdbd2cSJim Jagielski // XEnumerationAccess
86*b1cdbd2cSJim Jagielski uno::Type
getElementType()87*b1cdbd2cSJim Jagielski SwVbaPanes::getElementType() throw (uno::RuntimeException)
88*b1cdbd2cSJim Jagielski {
89*b1cdbd2cSJim Jagielski return word::XPane::static_type(0);
90*b1cdbd2cSJim Jagielski }
91*b1cdbd2cSJim Jagielski uno::Reference< container::XEnumeration >
createEnumeration()92*b1cdbd2cSJim Jagielski SwVbaPanes::createEnumeration() throw (uno::RuntimeException)
93*b1cdbd2cSJim Jagielski {
94*b1cdbd2cSJim Jagielski return new PanesEnumWrapper( m_xIndexAccess );
95*b1cdbd2cSJim Jagielski }
96*b1cdbd2cSJim Jagielski
97*b1cdbd2cSJim Jagielski uno::Any
createCollectionObject(const css::uno::Any & aSource)98*b1cdbd2cSJim Jagielski SwVbaPanes::createCollectionObject( const css::uno::Any& aSource )
99*b1cdbd2cSJim Jagielski {
100*b1cdbd2cSJim Jagielski return aSource;
101*b1cdbd2cSJim Jagielski }
102*b1cdbd2cSJim Jagielski
103*b1cdbd2cSJim Jagielski rtl::OUString&
getServiceImplName()104*b1cdbd2cSJim Jagielski SwVbaPanes::getServiceImplName()
105*b1cdbd2cSJim Jagielski {
106*b1cdbd2cSJim Jagielski static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaPanes") );
107*b1cdbd2cSJim Jagielski return sImplName;
108*b1cdbd2cSJim Jagielski }
109*b1cdbd2cSJim Jagielski
110*b1cdbd2cSJim Jagielski css::uno::Sequence<rtl::OUString>
getServiceNames()111*b1cdbd2cSJim Jagielski SwVbaPanes::getServiceNames()
112*b1cdbd2cSJim Jagielski {
113*b1cdbd2cSJim Jagielski static uno::Sequence< rtl::OUString > sNames;
114*b1cdbd2cSJim Jagielski if ( sNames.getLength() == 0 )
115*b1cdbd2cSJim Jagielski {
116*b1cdbd2cSJim Jagielski sNames.realloc( 1 );
117*b1cdbd2cSJim Jagielski sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Panes") );
118*b1cdbd2cSJim Jagielski }
119*b1cdbd2cSJim Jagielski return sNames;
120*b1cdbd2cSJim Jagielski }
121