xref: /AOO41X/main/sc/source/ui/vba/vbapivottables.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #include "vbapivottables.hxx"
28*cdf0e10cSrcweir #include "vbapivottable.hxx"
29*cdf0e10cSrcweir #include <com/sun/star/sheet/XDataPilotTable.hpp>
30*cdf0e10cSrcweir #include <ooo/vba/excel/XPivotTable.hpp>
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir using namespace ::com::sun::star;
34*cdf0e10cSrcweir using namespace ::ooo::vba;
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir uno::Any DataPilotToPivotTable( const uno::Any& aSource, uno::Reference< uno::XComponentContext > & xContext )
37*cdf0e10cSrcweir {
38*cdf0e10cSrcweir 	uno::Reference< sheet::XDataPilotTable > xTable( aSource, uno::UNO_QUERY_THROW );
39*cdf0e10cSrcweir 	return uno::makeAny( uno::Reference< excel::XPivotTable > ( new ScVbaPivotTable( xContext, xTable ) ) );
40*cdf0e10cSrcweir }
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir class PivotTableEnumeration : public EnumerationHelperImpl
43*cdf0e10cSrcweir {
44*cdf0e10cSrcweir public:
45*cdf0e10cSrcweir     PivotTableEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ) {}
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir 	virtual uno::Any SAL_CALL nextElement(  ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
48*cdf0e10cSrcweir 	{
49*cdf0e10cSrcweir 		return DataPilotToPivotTable( m_xEnumeration->nextElement(),  m_xContext );
50*cdf0e10cSrcweir 	}
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir };
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir ScVbaPivotTables::ScVbaPivotTables( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess  ):  ScVbaPivotTables_BASE( xParent, xContext, xIndexAccess )
55*cdf0e10cSrcweir {
56*cdf0e10cSrcweir }
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir uno::Reference< container::XEnumeration >
59*cdf0e10cSrcweir ScVbaPivotTables::createEnumeration() throw (uno::RuntimeException)
60*cdf0e10cSrcweir {
61*cdf0e10cSrcweir 	uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
62*cdf0e10cSrcweir     return new PivotTableEnumeration( mxParent, mxContext, xEnumAccess->createEnumeration() );
63*cdf0e10cSrcweir }
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir uno::Any
66*cdf0e10cSrcweir ScVbaPivotTables::createCollectionObject( const css::uno::Any& aSource )
67*cdf0e10cSrcweir {
68*cdf0e10cSrcweir 	return DataPilotToPivotTable( aSource,  mxContext );
69*cdf0e10cSrcweir }
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir uno::Type
72*cdf0e10cSrcweir ScVbaPivotTables::getElementType() throw (uno::RuntimeException)
73*cdf0e10cSrcweir {
74*cdf0e10cSrcweir 	return excel::XPivotTable::static_type(0);
75*cdf0e10cSrcweir }
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir rtl::OUString&
78*cdf0e10cSrcweir ScVbaPivotTables::getServiceImplName()
79*cdf0e10cSrcweir {
80*cdf0e10cSrcweir 	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaPivotTables") );
81*cdf0e10cSrcweir 	return sImplName;
82*cdf0e10cSrcweir }
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir css::uno::Sequence<rtl::OUString>
85*cdf0e10cSrcweir ScVbaPivotTables::getServiceNames()
86*cdf0e10cSrcweir {
87*cdf0e10cSrcweir 	static uno::Sequence< rtl::OUString > sNames;
88*cdf0e10cSrcweir 	if ( sNames.getLength() == 0 )
89*cdf0e10cSrcweir 	{
90*cdf0e10cSrcweir 		sNames.realloc( 1 );
91*cdf0e10cSrcweir 		sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.PivotTables") );
92*cdf0e10cSrcweir 	}
93*cdf0e10cSrcweir 	return sNames;
94*cdf0e10cSrcweir }
95