LibreOffice Module sc (master) 1
TablePivotChart.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
10#include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp>
11#include <com/sun/star/chart2/XChartDocument.hpp>
12#include <com/sun/star/embed/XEmbeddedObject.hpp>
13#include <svx/svdoole2.hxx>
14#include <svtools/embedhlp.hxx>
15#include <utility>
16#include <vcl/svapp.hxx>
17
18#include <miscuno.hxx>
19#include <docsh.hxx>
20
21#include <TablePivotChart.hxx>
22#include <ChartTools.hxx>
23
24using namespace css;
25
26namespace sc
27{
28
29SC_SIMPLE_SERVICE_INFO(TablePivotChart, "TablePivotChart", "com.sun.star.table.TablePivotChart")
30
31TablePivotChart::TablePivotChart(ScDocShell* pDocShell, SCTAB nTab, OUString aName)
32 : m_pDocShell(pDocShell)
33 , m_nTab(nTab)
34 , m_aChartName(std::move(aName))
35{
36 if (m_pDocShell)
37 m_pDocShell->GetDocument().AddUnoObject(*this);
38}
39
41{
42 SolarMutexGuard aGuard;
43
44 if (m_pDocShell)
46}
47
49{
50 if (rHint.GetId() == SfxHintId::Dying)
51 m_pDocShell = nullptr;
52}
53
54// XEmbeddedObjectSupplier
55
56uno::Reference<lang::XComponent> SAL_CALL TablePivotChart::getEmbeddedObject()
57{
58 SolarMutexGuard aGuard;
61 return uno::Reference<lang::XComponent>(pObject->GetObjRef()->getComponent(), uno::UNO_QUERY);
62 return nullptr;
63}
64
65// XNamed
66
67OUString SAL_CALL TablePivotChart::getName()
68{
69 return m_aChartName;
70}
71
72void SAL_CALL TablePivotChart::setName(OUString const & /* aName */)
73{
74 throw uno::RuntimeException(); // name cannot be changed
75}
76
77// XTablePivotChart
78
80{
81 SolarMutexGuard aGuard;
82
84 if (!pObject)
85 return OUString();
86
87 uno::Reference<embed::XEmbeddedObject> xObject = pObject->GetObjRef();
88 if (!xObject.is())
89 return OUString();
90
91 uno::Reference<chart2::XChartDocument> xChartDoc(xObject->getComponent(), uno::UNO_QUERY);
92 if (!xChartDoc.is())
93 return OUString();
94
95 uno::Reference<chart2::data::XPivotTableDataProvider> xPivotTableDataProvider(xChartDoc->getDataProvider(), uno::UNO_QUERY);
96 if (!xPivotTableDataProvider.is())
97 return OUString();
98
99 return xPivotTableDataProvider->getPivotTableName();
100}
101
102} // end sc namespace
103
104/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const ScDocument & GetDocument() const
Definition: docsh.hxx:219
void RemoveUnoObject(SfxListener &rObject)
Definition: documen3.cxx:909
SfxHintId GetId() const
ScDocShell * m_pDocShell
virtual void SAL_CALL setName(OUString const &aName) override
virtual OUString SAL_CALL getPivotTableName() override
virtual css::uno::Reference< css::lang::XComponent > SAL_CALL getEmbeddedObject() override
virtual OUString SAL_CALL getName() override
virtual ~TablePivotChart() override
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
static bool TryRunningState(const css::uno::Reference< css::embed::XEmbeddedObject > &)
EmbeddedObjectRef * pObject
#define SC_SIMPLE_SERVICE_INFO(ClassName, ClassNameAscii, ServiceAscii)
Definition: miscuno.hxx:63
SdrOle2Obj * findChartsByName(ScDocShell *pDocShell, SCTAB nTab, std::u16string_view rName, ChartSourceType eChartSourceType)
Definition: ChartTools.cxx:98
CAUTION! The following defines must be in the same namespace as the respective type.
Definition: broadcast.cxx:15
sal_Int16 SCTAB
Definition: types.hxx:22