bump product version to 6.3.0.0.beta1
[LibreOffice.git] / vbahelper / source / msforms / vbamultipage.cxx
blob0608c1d64bda6ac846e09ca907ab25012c89ad63
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include "vbamultipage.hxx"
20 #include <ooo/vba/XCollection.hpp>
21 #include "vbapages.hxx"
22 #include <com/sun/star/container/XNameContainer.hpp>
23 #include <cppuhelper/implbase.hxx>
25 using namespace com::sun::star;
26 using namespace ooo::vba;
28 const OUString SVALUE( "MultiPageValue" );
30 class PagesImpl : public cppu::WeakImplHelper< container::XIndexAccess >
32 sal_Int32 const mnPages;
33 public:
34 explicit PagesImpl( sal_Int32 nPages ) : mnPages( nPages ) {}
35 virtual ::sal_Int32 SAL_CALL getCount() override { return mnPages; }
36 virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) override
38 if ( Index < 0 || Index > mnPages )
39 throw lang::IndexOutOfBoundsException();
40 return uno::makeAny( uno::Reference< uno::XInterface >() );
42 // XElementAccess
43 virtual uno::Type SAL_CALL getElementType() override
45 // no Pages object yet #FIXME
46 //return cppu::UnoType<msforms::XPage>::get();
47 return cppu::UnoType<uno::XInterface>::get();
49 virtual sal_Bool SAL_CALL hasElements( ) override
51 return ( mnPages > 0 );
55 ScVbaMultiPage::ScVbaMultiPage(
56 const uno::Reference< ov::XHelperInterface >& xParent,
57 const uno::Reference< uno::XComponentContext >& xContext,
58 const uno::Reference< uno::XInterface >& xControl,
59 const uno::Reference< frame::XModel >& xModel,
60 std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper) :
61 MultiPageImpl_BASE( xParent, xContext, xControl, xModel, std::move(pGeomHelper) )
65 // Attributes
66 sal_Int32 SAL_CALL
67 ScVbaMultiPage::getValue()
69 sal_Int32 nValue = 0;
70 m_xProps->getPropertyValue( SVALUE ) >>= nValue;
71 // VBA 0 based tab index
72 return nValue - 1;
75 void SAL_CALL
76 ScVbaMultiPage::setValue( const sal_Int32 _value )
78 // Openoffice 1 based tab index
79 sal_Int32 nVal = _value + 1;
80 sal_Int32 nOldVal = getValue();
81 m_xProps->setPropertyValue( SVALUE, uno::makeAny( nVal ) );
82 if ( nVal != nOldVal )
83 fireChangeEvent();
86 OUString
87 ScVbaMultiPage::getServiceImplName()
89 return OUString( "ScVbaMultiPage" );
92 uno::Any SAL_CALL
93 ScVbaMultiPage::Pages( const uno::Any& index )
95 // get the container model
96 uno::Reference< container::XNameContainer > xContainer( m_xProps, uno::UNO_QUERY_THROW );
97 uno::Reference< XCollection > xColl( new ScVbaPages( this, mxContext, new PagesImpl( xContainer->getElementNames().getLength() ) ) );
98 if ( !index.hasValue() )
99 return uno::makeAny( xColl );
100 return xColl->Item( index, uno::Any() );
103 uno::Sequence< OUString >
104 ScVbaMultiPage::getServiceNames()
106 static uno::Sequence< OUString > const aServiceNames
108 "ooo.vba.msforms.MultiPage"
110 return aServiceNames;
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */