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  return;
60 
61  OUString aName( pTable->GetFrameFormat()->GetName() );
62  SwOLENode *pONd;
63  SwStartNode *pStNd;
65  while (nullptr != (pStNd = aIdx.GetNode().GetStartNode()))
66  {
67  ++aIdx;
68  pONd = aIdx.GetNode().GetOLENode();
69  if( pONd &&
70  aName == pONd->GetChartTableName() /* OLE node is chart? */ &&
71  nullptr != (pONd->getLayoutFrame( m_rDoc.getIDocumentLayoutAccess().GetCurrentLayout() )) /* chart frame is not hidden */ )
72  {
73  uno::Reference < embed::XEmbeddedObject > xIP = pONd->GetOLEObj().GetOleRef();
75  {
76  uno::Reference< chart2::XChartDocument > xChart( xIP->getComponent(), UNO_QUERY );
77  if (xChart.is())
78  xChart->createInternalDataProvider( true );
79 
80  // there may be more than one chart for each table thus we need to continue the loop...
81  }
82  }
83  aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
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:156
SwOLENode * GetOLENode()
Inline methods from Node.hxx.
Definition: ndole.hxx:161
const SwOLEObj & GetOLEObj() const
Definition: ndole.hxx:112
virtual const SwRootFrame * GetCurrentLayout() const =0
css::uno::Reference< css::embed::XEmbeddedObject > const & GetOleRef()
Definition: ndole.cxx:913
Definition: doc.hxx:184
SwChartLockController_Helper & GetChartControllerHelper() override
returns chart controller helper that is used to lock/unlock all charts when relevant parts of tables ...
SwNode & GetNode() const
Definition: ndindex.hxx:119
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
PDFDocument & m_rDoc
SwStartNode * GetStartNode()
Definition: node.hxx:591
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:405
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
OUString aName
SwNodes & GetNodes()
Definition: doc.hxx:403
static bool TryRunningState(const css::uno::Reference< css::embed::XEmbeddedObject > &)