1*b3f79822SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*b3f79822SAndrew Rist * distributed with this work for additional information 6*b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*b3f79822SAndrew Rist * "License"); you may not use this file except in compliance 9*b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*b3f79822SAndrew Rist * software distributed under the License is distributed on an 15*b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b3f79822SAndrew Rist * KIND, either express or implied. See the License for the 17*b3f79822SAndrew Rist * specific language governing permissions and limitations 18*b3f79822SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*b3f79822SAndrew Rist *************************************************************/ 21*b3f79822SAndrew Rist 22*b3f79822SAndrew Rist 23cdf0e10cSrcweir #include "vbapivottables.hxx" 24cdf0e10cSrcweir #include "vbapivottable.hxx" 25cdf0e10cSrcweir #include <com/sun/star/sheet/XDataPilotTable.hpp> 26cdf0e10cSrcweir #include <ooo/vba/excel/XPivotTable.hpp> 27cdf0e10cSrcweir 28cdf0e10cSrcweir 29cdf0e10cSrcweir using namespace ::com::sun::star; 30cdf0e10cSrcweir using namespace ::ooo::vba; 31cdf0e10cSrcweir 32cdf0e10cSrcweir uno::Any DataPilotToPivotTable( const uno::Any& aSource, uno::Reference< uno::XComponentContext > & xContext ) 33cdf0e10cSrcweir { 34cdf0e10cSrcweir uno::Reference< sheet::XDataPilotTable > xTable( aSource, uno::UNO_QUERY_THROW ); 35cdf0e10cSrcweir return uno::makeAny( uno::Reference< excel::XPivotTable > ( new ScVbaPivotTable( xContext, xTable ) ) ); 36cdf0e10cSrcweir } 37cdf0e10cSrcweir 38cdf0e10cSrcweir class PivotTableEnumeration : public EnumerationHelperImpl 39cdf0e10cSrcweir { 40cdf0e10cSrcweir public: 41cdf0e10cSrcweir 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 ) {} 42cdf0e10cSrcweir 43cdf0e10cSrcweir virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) 44cdf0e10cSrcweir { 45cdf0e10cSrcweir return DataPilotToPivotTable( m_xEnumeration->nextElement(), m_xContext ); 46cdf0e10cSrcweir } 47cdf0e10cSrcweir 48cdf0e10cSrcweir }; 49cdf0e10cSrcweir 50cdf0e10cSrcweir ScVbaPivotTables::ScVbaPivotTables( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess ): ScVbaPivotTables_BASE( xParent, xContext, xIndexAccess ) 51cdf0e10cSrcweir { 52cdf0e10cSrcweir } 53cdf0e10cSrcweir 54cdf0e10cSrcweir uno::Reference< container::XEnumeration > 55cdf0e10cSrcweir ScVbaPivotTables::createEnumeration() throw (uno::RuntimeException) 56cdf0e10cSrcweir { 57cdf0e10cSrcweir uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); 58cdf0e10cSrcweir return new PivotTableEnumeration( mxParent, mxContext, xEnumAccess->createEnumeration() ); 59cdf0e10cSrcweir } 60cdf0e10cSrcweir 61cdf0e10cSrcweir uno::Any 62cdf0e10cSrcweir ScVbaPivotTables::createCollectionObject( const css::uno::Any& aSource ) 63cdf0e10cSrcweir { 64cdf0e10cSrcweir return DataPilotToPivotTable( aSource, mxContext ); 65cdf0e10cSrcweir } 66cdf0e10cSrcweir 67cdf0e10cSrcweir uno::Type 68cdf0e10cSrcweir ScVbaPivotTables::getElementType() throw (uno::RuntimeException) 69cdf0e10cSrcweir { 70cdf0e10cSrcweir return excel::XPivotTable::static_type(0); 71cdf0e10cSrcweir } 72cdf0e10cSrcweir 73cdf0e10cSrcweir rtl::OUString& 74cdf0e10cSrcweir ScVbaPivotTables::getServiceImplName() 75cdf0e10cSrcweir { 76cdf0e10cSrcweir static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaPivotTables") ); 77cdf0e10cSrcweir return sImplName; 78cdf0e10cSrcweir } 79cdf0e10cSrcweir 80cdf0e10cSrcweir css::uno::Sequence<rtl::OUString> 81cdf0e10cSrcweir ScVbaPivotTables::getServiceNames() 82cdf0e10cSrcweir { 83cdf0e10cSrcweir static uno::Sequence< rtl::OUString > sNames; 84cdf0e10cSrcweir if ( sNames.getLength() == 0 ) 85cdf0e10cSrcweir { 86cdf0e10cSrcweir sNames.realloc( 1 ); 87cdf0e10cSrcweir sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.PivotTables") ); 88cdf0e10cSrcweir } 89cdf0e10cSrcweir return sNames; 90cdf0e10cSrcweir } 91