update dev300-m58
[ooovba.git] / vbahelper / source / msforms / vbamultipage.cxx
blob118e0051d041adfde2abeecf0bb6e63e187c67eb
1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile$
7 * $Revision$
9 * last change: $Author$ $Date$
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 * MA 02111-1307 USA
34 ************************************************************************/
35 #include "vbamultipage.hxx"
36 #include <ooo/vba/XCollection.hpp>
37 #include "vbapages.hxx"
38 #include <vector>
40 using namespace com::sun::star;
41 using namespace ooo::vba;
43 // uno servicename com.sun.star.awt.UnoControlProgressBarMode
44 const rtl::OUString SVALUE( RTL_CONSTASCII_USTRINGPARAM("ProgressValue") );
45 const rtl::OUString SVALUEMAX( RTL_CONSTASCII_USTRINGPARAM("ProgressValueMax") );
46 const rtl::OUString SSTEP( RTL_CONSTASCII_USTRINGPARAM("Step") );
48 typedef cppu::WeakImplHelper1< container::XIndexAccess > PagesImpl_Base;
49 class PagesImpl : public PagesImpl_Base
51 sal_Int32 mnPages;
52 public:
53 PagesImpl( sal_Int32 nPages ) : mnPages( nPages ) {}
54 virtual ::sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException) { return mnPages; }
55 virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, ::uno::RuntimeException)
57 if ( Index < 0 || Index > mnPages )
58 throw lang::IndexOutOfBoundsException();
59 return uno::makeAny( uno::Reference< uno::XInterface >() );
61 // XElementAccess
62 virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException)
64 // no Pages object yet #FIXME
65 //return msforms::XPage::static_type(0);
66 return uno::XInterface::static_type(0);
68 virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException)
70 return ( mnPages > 0 );
73 uno::Reference< container::XIndexAccess >
74 ScVbaMultiPage::getPages( sal_Int32 nPages )
76 return new PagesImpl( nPages );
79 ScVbaMultiPage::ScVbaMultiPage( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper, const uno::Reference< uno::XInterface >& xDialog ) : MultiPageImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
81 mxDialogProps.set( xDialog, uno::UNO_QUERY_THROW );
82 // set dialog step to value of multipage pseudo model
83 setValue(getValue());
86 // Attributes
87 sal_Int32 SAL_CALL
88 ScVbaMultiPage::getValue() throw (css::uno::RuntimeException)
90 sal_Int32 nValue = 0;
91 m_xProps->getPropertyValue( SVALUE ) >>= nValue;
92 return nValue;
95 void SAL_CALL
96 ScVbaMultiPage::setValue( const sal_Int32 _value ) throw (::com::sun::star::uno::RuntimeException)
98 // track change in dialog ( dialog value is 1 based, 0 is a special value )
99 m_xProps->setPropertyValue( SVALUE, uno::makeAny( _value ) );
100 mxDialogProps->setPropertyValue( SSTEP, uno::makeAny( _value + 1) );
104 rtl::OUString&
105 ScVbaMultiPage::getServiceImplName()
107 static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaMultiPage") );
108 return sImplName;
111 uno::Any SAL_CALL
112 ScVbaMultiPage::Pages( const uno::Any& index ) throw (uno::RuntimeException)
114 sal_Int32 nValue = 0;
115 m_xProps->getPropertyValue( SVALUEMAX ) >>= nValue;
116 uno::Reference< XCollection > xColl( new ScVbaPages( this, mxContext, getPages( nValue ) ) );
117 if ( !index.hasValue() )
118 return uno::makeAny( xColl );
119 return xColl->Item( uno::makeAny( index ), uno::Any() );
122 uno::Sequence< rtl::OUString >
123 ScVbaMultiPage::getServiceNames()
125 static uno::Sequence< rtl::OUString > aServiceNames;
126 if ( aServiceNames.getLength() == 0 )
128 aServiceNames.realloc( 1 );
129 aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.MultiPage" ) );
131 return aServiceNames;