LibreOffice Module sc (master) 1
vbapivottables.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#include "vbapivottables.hxx"
20#include "vbapivottable.hxx"
21#include <com/sun/star/sheet/XDataPilotTable.hpp>
22#include <ooo/vba/excel/XPivotTable.hpp>
23
24using namespace ::com::sun::star;
25using namespace ::ooo::vba;
26
27static uno::Any DataPilotToPivotTable( const uno::Any& aSource, const uno::Reference< uno::XComponentContext > & xContext )
28{
29 uno::Reference< sheet::XDataPilotTable > xTable( aSource, uno::UNO_QUERY_THROW );
30 return uno::Any( uno::Reference< excel::XPivotTable > ( new ScVbaPivotTable( xContext, xTable ) ) );
31}
32
33namespace {
34
35class PivotTableEnumeration : public EnumerationHelperImpl
36{
37public:
39 PivotTableEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ) {}
40
41 virtual uno::Any SAL_CALL nextElement( ) override
42 {
43 return DataPilotToPivotTable( m_xEnumeration->nextElement(), m_xContext );
44 }
45
46};
47
48}
49
50ScVbaPivotTables::ScVbaPivotTables( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess ): ScVbaPivotTables_BASE( xParent, xContext, xIndexAccess )
51{
52}
53
54uno::Reference< container::XEnumeration >
56{
57 uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
58 return new PivotTableEnumeration( mxParent, mxContext, xEnumAccess->createEnumeration() );
59}
60
62ScVbaPivotTables::createCollectionObject( const css::uno::Any& aSource )
63{
64 return DataPilotToPivotTable( aSource, mxContext );
65}
66
69{
71}
72
73OUString
75{
76 return "ScVbaPivotTables";
77}
78
79css::uno::Sequence<OUString>
81{
82 static uno::Sequence< OUString > const sNames
83 {
84 "ooo.vba.excel.PivotTables"
85 };
86 return sNames;
87}
88
89/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::uno::XComponentContext > mxContext
css::uno::WeakReference< ov::XHelperInterface > mxParent
css::uno::Reference< css::container::XIndexAccess > m_xIndexAccess
virtual OUString getServiceImplName() override
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
virtual css::uno::Sequence< OUString > getServiceNames() override
ScVbaPivotTables(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::container::XIndexAccess > &xIndexAccess)
virtual css::uno::Any createCollectionObject(const css::uno::Any &aSource) override
virtual css::uno::Type SAL_CALL getElementType() override
css::uno::Type const & get()
static uno::Any DataPilotToPivotTable(const uno::Any &aSource, const uno::Reference< uno::XComponentContext > &xContext)