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 <frmfmt.hxx>
28 #include <ndole.hxx>
29 #include <com/sun/star/chart2/XChartDocument.hpp>
30 #include <com/sun/star/embed/XEmbeddedObject.hpp>
31 
32 
33 using namespace com::sun::star;
34 using namespace com::sun::star::uno;
35 
36 namespace sw {
37 
38 DocumentChartDataProviderManager::DocumentChartDataProviderManager( SwDoc& i_rSwdoc ) : m_rDoc( i_rSwdoc ),
39  maChartDataProviderImplRef()
40 {
41 
42 }
43 
45 {
46  // since there must be only one instance of this object per document
47  // we need a mutex here
48  SolarMutexGuard aGuard;
49 
50  if (bCreate && !maChartDataProviderImplRef.is())
51  {
53  }
54  return maChartDataProviderImplRef.get();
55 }
56 
58 {
59  if (pTable)
60  {
61  OUString aName( pTable->GetFrameFormat()->GetName() );
62  SwOLENode *pONd;
63  SwStartNode *pStNd;
65  while (nullptr != (pStNd = aIdx.GetNode().GetStartNode()))
66  {
67  ++aIdx;
68  if( nullptr != ( pONd = aIdx.GetNode().GetOLENode() ) &&
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 }
86 
88 {
90  {
92  }
94 }
95 
97 {
98  // clean up chart related structures...
99  // Note: the chart data provider gets already disposed in ~SwDocShell
100  // since all UNO API related functionality requires an existing SwDocShell
101  // this assures that dispose gets called if there is need for it.
103 }
104 
105 }
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:682
Starts a section of nodes in the document model.
Definition: node.hxx:303
SwNode & GetEndOfAutotext() const
Section for all Flys/Header/Footers.
Definition: ndarr.hxx:157
virtual const SwRootFrame * GetCurrentLayout() const =0
Definition: doc.hxx:185
SwChartLockController_Helper & GetChartControllerHelper() override
returns chart controller helper that is used to lock/unlock all charts when relevant parts of tables ...
Dialog to specify the properties of date form field.
Definition: accfrmobj.cxx:38
SwTableFormat * GetFrameFormat()
Definition: swtable.hxx:201
SwChartDataProvider * GetChartDataProvider(bool bCreate=false) const override
returns or creates the data-provider for chart
rtl::Reference< SwChartDataProvider > maChartDataProviderImplRef
const OUString & GetName() const
Definition: format.hxx:111
void CreateChartInternalDataProviders(const SwTable *pTable) override
calls createInternalDataProvider for all charts using the specified table
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:131
Marks a node in the document model.
Definition: ndindex.hxx:31
SwStartNode * GetStartNode()
Definition: node.hxx:591
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:437
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:110
std::unique_ptr< SwChartLockController_Helper, o3tl::default_delete< SwChartLockController_Helper > > mpChartControllerHelper
SwNodes & GetNodes()
Definition: doc.hxx:402
OString const aName
static bool TryRunningState(const css::uno::Reference< css::embed::XEmbeddedObject > &)
SwNodeIndex & Assign(SwNodes const &rNds, sal_uLong)
Definition: ndindex.hxx:271