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