LibreOffice Module sw (master) 1
DocumentChartDataProviderManager.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
21
22#include <doc.hxx>
24#include <vcl/svapp.hxx>
25#include <swtable.hxx>
26#include <unochart.hxx>
27#include <ndole.hxx>
28#include <com/sun/star/chart2/XChartDocument.hpp>
29#include <com/sun/star/embed/XEmbeddedObject.hpp>
30
31
32using namespace com::sun::star;
33using namespace com::sun::star::uno;
34
35namespace sw {
36
38{
39
40}
41
43{
44 // since there must be only one instance of this object per document
45 // we need a mutex here
46 SolarMutexGuard aGuard;
47
48 if (bCreate && !maChartDataProviderImplRef.is())
49 {
51 }
52 return maChartDataProviderImplRef.get();
53}
54
56{
57 if (!pTable)
58 return;
59
60 OUString aName( pTable->GetFrameFormat()->GetName() );
61 SwOLENode *pONd;
62 SwStartNode *pStNd;
64 while (nullptr != (pStNd = aIdx.GetNode().GetStartNode()))
65 {
66 ++aIdx;
67 pONd = aIdx.GetNode().GetOLENode();
68 if( pONd &&
69 aName == pONd->GetChartTableName() /* OLE node is chart? */ &&
70 nullptr != (pONd->getLayoutFrame( m_rDoc.getIDocumentLayoutAccess().GetCurrentLayout() )) /* chart frame is not hidden */ )
71 {
72 uno::Reference < embed::XEmbeddedObject > xIP = pONd->GetOLEObj().GetOleRef();
74 {
75 uno::Reference< chart2::XChartDocument > xChart( xIP->getComponent(), UNO_QUERY );
76 if (xChart.is())
77 xChart->createInternalDataProvider( true );
78
79 // there may be more than one chart for each table thus we need to continue the loop...
80 }
81 }
82 aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
83 }
84}
85
87{
89 {
91 }
93}
94
96{
97 // clean up chart related structures...
98 // Note: the chart data provider gets already disposed in ~SwDocShell
99 // since all UNO API related functionality requires an existing SwDocShell
100 // this assures that dispose gets called if there is need for it.
102}
103
104}
105/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual const SwRootFrame * GetCurrentLayout() const =0
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1223
Definition: doc.hxx:197
SwNodes & GetNodes()
Definition: doc.hxx:422
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:419
const OUString & GetName() const
Definition: format.hxx:131
Marks a node in the document model.
Definition: ndindex.hxx:31
SwNode & GetNode() const
Definition: ndindex.hxx:123
SwNodeIndex & Assign(SwNodes const &rNds, SwNodeOffset nIdx)
Definition: ndindex.hxx:114
SwStartNode * GetStartNode()
Definition: node.hxx:642
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:153
SwOLENode * GetOLENode()
Inline methods from Node.hxx.
Definition: ndole.hxx:165
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:695
SwNode & GetEndOfAutotext() const
Section for all Flys/Header/Footers.
Definition: ndarr.hxx:158
const SwOLEObj & GetOLEObj() const
Definition: ndole.hxx:116
const OUString & GetChartTableName() const
Definition: ndole.hxx:156
css::uno::Reference< css::embed::XEmbeddedObject > const & GetOleRef()
Definition: ndole.cxx:1012
Starts a section of nodes in the document model.
Definition: node.hxx:348
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:113
SwTableFormat * GetFrameFormat()
Definition: swtable.hxx:209
static bool TryRunningState(const css::uno::Reference< css::embed::XEmbeddedObject > &)
SwChartLockController_Helper & GetChartControllerHelper() override
returns chart controller helper that is used to lock/unlock all charts when relevant parts of tables ...
SwChartDataProvider * GetChartDataProvider(bool bCreate=false) const override
returns or creates the data-provider for chart
std::unique_ptr< SwChartLockController_Helper > mpChartControllerHelper
rtl::Reference< SwChartDataProvider > maChartDataProviderImplRef
void CreateChartInternalDataProviders(const SwTable *pTable) override
calls createInternalDataProvider for all charts using the specified table
SwDoc & m_rDoc
Definition: docbm.cxx:1228
OUString aName
Dialog to specify the properties of date form field.