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 
32 using namespace com::sun::star;
33 using namespace com::sun::star::uno;
34 
35 namespace sw {
36 
37 DocumentChartDataProviderManager::DocumentChartDataProviderManager( SwDoc& i_rSwdoc ) : m_rDoc( i_rSwdoc ),
38  maChartDataProviderImplRef()
39 {
40 
41 }
42 
44 {
45  // since there must be only one instance of this object per document
46  // we need a mutex here
47  SolarMutexGuard aGuard;
48 
49  if (bCreate && !maChartDataProviderImplRef.is())
50  {
52  }
53  return maChartDataProviderImplRef.get();
54 }
55 
57 {
58  if (pTable)
59  {
60  OUString aName( pTable->GetFrameFormat()->GetName() );
61  SwOLENode *pONd;
62  SwStartNode *pStNd;
64  while (nullptr != (pStNd = aIdx.GetNode().GetStartNode()))
65  {
66  ++aIdx;
67  if( nullptr != ( pONd = aIdx.GetNode().GetOLENode() ) &&
68  aName == pONd->GetChartTableName() /* OLE node is chart? */ &&
69  nullptr != (pONd->getLayoutFrame( m_rDoc.getIDocumentLayoutAccess().GetCurrentLayout() )) /* chart frame is not hidden */ )
70  {
71  uno::Reference < embed::XEmbeddedObject > xIP = pONd->GetOLEObj().GetOleRef();
73  {
74  uno::Reference< chart2::XChartDocument > xChart( xIP->getComponent(), UNO_QUERY );
75  if (xChart.is())
76  xChart->createInternalDataProvider( true );
77 
78  // there may be more than one chart for each table thus we need to continue the loop...
79  }
80  }
81  aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
82  }
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: */
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.
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:404
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:272