merge the formfield patch from ooo-build
[ooovba.git] / sc / source / ui / vba / vbapivottables.cxx
blob9e3dccbd2ac1f6bd4c468d8f7fa6b312c7288839
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: vbapivottables.cxx,v $
10 * $Revision: 1.4 $
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 "vbapivottables.hxx"
31 #include "vbapivottable.hxx"
32 #include <com/sun/star/sheet/XDataPilotTable.hpp>
33 #include <ooo/vba/excel/XPivotTable.hpp>
36 using namespace ::com::sun::star;
37 using namespace ::ooo::vba;
39 uno::Any DataPilotToPivotTable( const uno::Any& aSource, uno::Reference< uno::XComponentContext > & xContext )
41 uno::Reference< sheet::XDataPilotTable > xTable( aSource, uno::UNO_QUERY_THROW );
42 return uno::makeAny( uno::Reference< excel::XPivotTable > ( new ScVbaPivotTable( xContext, xTable ) ) );
45 class PivotTableEnumeration : public EnumerationHelperImpl
47 public:
48 PivotTableEnumeration( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xContext, xEnumeration ) {}
50 virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
52 return DataPilotToPivotTable( m_xEnumeration->nextElement(), m_xContext );
57 ScVbaPivotTables::ScVbaPivotTables( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess ): ScVbaPivotTables_BASE( xParent, xContext, xIndexAccess )
61 uno::Reference< container::XEnumeration >
62 ScVbaPivotTables::createEnumeration() throw (uno::RuntimeException)
64 uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
65 return new PivotTableEnumeration( mxContext, xEnumAccess->createEnumeration() );
68 uno::Any
69 ScVbaPivotTables::createCollectionObject( const css::uno::Any& aSource )
71 return DataPilotToPivotTable( aSource, mxContext );
74 uno::Type
75 ScVbaPivotTables::getElementType() throw (uno::RuntimeException)
77 return excel::XPivotTable::static_type(0);
80 rtl::OUString&
81 ScVbaPivotTables::getServiceImplName()
83 static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaPivotTables") );
84 return sImplName;
87 css::uno::Sequence<rtl::OUString>
88 ScVbaPivotTables::getServiceNames()
90 static uno::Sequence< rtl::OUString > sNames;
91 if ( sNames.getLength() == 0 )
93 sNames.realloc( 1 );
94 sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.PivotTables") );
96 return sNames;