1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include "vbapanes.hxx"
31 #include "vbapane.hxx"
33 using namespace ::ooo::vba
;
34 using namespace ::com::sun::star
;
36 // I assume there is only one pane in Writer
37 typedef ::cppu::WeakImplHelper1
<container::XIndexAccess
> PanesIndexAccess_Base
;
38 class PanesIndexAccess
: public PanesIndexAccess_Base
41 uno::Reference
< XHelperInterface
> mxParent
;
42 uno::Reference
< uno::XComponentContext
> mxContext
;
43 uno::Reference
< frame::XModel
> mxModel
;
46 PanesIndexAccess( const uno::Reference
< XHelperInterface
>& xParent
, const uno::Reference
< uno::XComponentContext
>& xContext
, const uno::Reference
< frame::XModel
>& xModel
) : mxParent( xParent
), mxContext( xContext
), mxModel( xModel
) {}
50 virtual sal_Int32 SAL_CALL
getCount( ) throw (uno::RuntimeException
)
54 virtual uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) throw (lang::IndexOutOfBoundsException
, lang::WrappedTargetException
, uno::RuntimeException
)
57 throw container::NoSuchElementException();
58 return uno::makeAny( uno::Reference
< word::XPane
>( new SwVbaPane( mxParent
, mxContext
, mxModel
) ) );
60 virtual uno::Type SAL_CALL
getElementType( ) throw (uno::RuntimeException
)
62 return word::XPane::static_type(0);
64 virtual sal_Bool SAL_CALL
hasElements( ) throw (uno::RuntimeException
)
70 class PanesEnumWrapper
: public EnumerationHelper_BASE
72 uno::Reference
<container::XIndexAccess
> m_xIndexAccess
;
75 PanesEnumWrapper( const uno::Reference
< container::XIndexAccess
>& xIndexAccess
) : m_xIndexAccess( xIndexAccess
), nIndex( 0 ) {}
76 virtual ::sal_Bool SAL_CALL
hasMoreElements( ) throw (uno::RuntimeException
)
78 return ( nIndex
< m_xIndexAccess
->getCount() );
81 virtual uno::Any SAL_CALL
nextElement( ) throw (container::NoSuchElementException
, lang::WrappedTargetException
, uno::RuntimeException
)
83 if ( nIndex
< m_xIndexAccess
->getCount() )
84 return m_xIndexAccess
->getByIndex( nIndex
++ );
85 throw container::NoSuchElementException();
89 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
)
94 SwVbaPanes::getElementType() throw (uno::RuntimeException
)
96 return word::XPane::static_type(0);
98 uno::Reference
< container::XEnumeration
>
99 SwVbaPanes::createEnumeration() throw (uno::RuntimeException
)
101 return new PanesEnumWrapper( m_xIndexAccess
);
105 SwVbaPanes::createCollectionObject( const css::uno::Any
& aSource
)
111 SwVbaPanes::getServiceImplName()
113 static rtl::OUString
sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaPanes") );
117 css::uno::Sequence
<rtl::OUString
>
118 SwVbaPanes::getServiceNames()
120 static uno::Sequence
< rtl::OUString
> sNames
;
121 if ( sNames
.getLength() == 0 )
124 sNames
[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Panes") );