LibreOffice Module sw (master)
1
sw
source
core
doc
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
20
#include <
DocumentChartDataProviderManager.hxx
>
21
22
#include <
doc.hxx
>
23
#include <
IDocumentLayoutAccess.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
{
39
40
}
41
42
SwChartDataProvider
*
DocumentChartDataProviderManager::GetChartDataProvider
(
bool
bCreate )
const
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
{
50
maChartDataProviderImplRef
=
new
SwChartDataProvider
(
m_rDoc
);
51
}
52
return
maChartDataProviderImplRef
.get();
53
}
54
55
void
DocumentChartDataProviderManager::CreateChartInternalDataProviders
(
const
SwTable
*pTable )
56
{
57
if
(!pTable)
58
return
;
59
60
OUString
aName
( pTable->
GetFrameFormat
()->
GetName
() );
61
SwOLENode
*pONd;
62
SwStartNode
*pStNd;
63
SwNodeIndex
aIdx( *
m_rDoc
.
GetNodes
().
GetEndOfAutotext
().
StartOfSectionNode
(), 1 );
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
();
73
if
(
svt::EmbeddedObjectRef::TryRunningState
( xIP ) )
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
SwChartLockController_Helper
&
DocumentChartDataProviderManager::GetChartControllerHelper
()
87
{
88
if
(!
mpChartControllerHelper
)
89
{
90
mpChartControllerHelper
.reset(
new
SwChartLockController_Helper
( &
m_rDoc
));
91
}
92
return
*
mpChartControllerHelper
;
93
}
94
95
DocumentChartDataProviderManager::~DocumentChartDataProviderManager
()
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.
101
maChartDataProviderImplRef
.clear();
102
}
103
104
}
105
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DocumentChartDataProviderManager.hxx
IDocumentLayoutAccess.hxx
IDocumentLayoutAccess::GetCurrentLayout
virtual const SwRootFrame * GetCurrentLayout() const =0
SolarMutexGuard
SwChartDataProvider
Definition:
unochart.hxx:105
SwChartLockController_Helper
Definition:
unochart.hxx:70
SwContentNode::getLayoutFrame
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition:
node.cxx:1223
SwDoc
Definition:
doc.hxx:197
SwDoc::GetNodes
SwNodes & GetNodes()
Definition:
doc.hxx:422
SwDoc::getIDocumentLayoutAccess
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition:
doc.cxx:419
SwFormat::GetName
const OUString & GetName() const
Definition:
format.hxx:131
SwNodeIndex
Marks a node in the document model.
Definition:
ndindex.hxx:31
SwNodeIndex::GetNode
SwNode & GetNode() const
Definition:
ndindex.hxx:123
SwNodeIndex::Assign
SwNodeIndex & Assign(SwNodes const &rNds, SwNodeOffset nIdx)
Definition:
ndindex.hxx:114
SwNode::GetStartNode
SwStartNode * GetStartNode()
Definition:
node.hxx:642
SwNode::StartOfSectionNode
const SwStartNode * StartOfSectionNode() const
Definition:
node.hxx:153
SwNode::GetOLENode
SwOLENode * GetOLENode()
Inline methods from Node.hxx.
Definition:
ndole.hxx:165
SwNode::EndOfSectionNode
const SwEndNode * EndOfSectionNode() const
Definition:
node.hxx:695
SwNodes::GetEndOfAutotext
SwNode & GetEndOfAutotext() const
Section for all Flys/Header/Footers.
Definition:
ndarr.hxx:158
SwOLENode
Definition:
ndole.hxx:90
SwOLENode::GetOLEObj
const SwOLEObj & GetOLEObj() const
Definition:
ndole.hxx:116
SwOLENode::GetChartTableName
const OUString & GetChartTableName() const
Definition:
ndole.hxx:156
SwOLEObj::GetOleRef
css::uno::Reference< css::embed::XEmbeddedObject > const & GetOleRef()
Definition:
ndole.cxx:1012
SwStartNode
Starts a section of nodes in the document model.
Definition:
node.hxx:348
SwTable
SwTable is one table in the document model, containing rows (which contain cells).
Definition:
swtable.hxx:113
SwTable::GetFrameFormat
SwTableFormat * GetFrameFormat()
Definition:
swtable.hxx:209
svt::EmbeddedObjectRef::TryRunningState
static bool TryRunningState(const css::uno::Reference< css::embed::XEmbeddedObject > &)
sw::DocumentChartDataProviderManager::DocumentChartDataProviderManager
DocumentChartDataProviderManager(SwDoc &i_rSwdoc)
Definition:
DocumentChartDataProviderManager.cxx:37
sw::DocumentChartDataProviderManager::GetChartControllerHelper
SwChartLockController_Helper & GetChartControllerHelper() override
returns chart controller helper that is used to lock/unlock all charts when relevant parts of tables ...
Definition:
DocumentChartDataProviderManager.cxx:86
sw::DocumentChartDataProviderManager::GetChartDataProvider
SwChartDataProvider * GetChartDataProvider(bool bCreate=false) const override
returns or creates the data-provider for chart
Definition:
DocumentChartDataProviderManager.cxx:42
sw::DocumentChartDataProviderManager::mpChartControllerHelper
std::unique_ptr< SwChartLockController_Helper > mpChartControllerHelper
Definition:
DocumentChartDataProviderManager.hxx:58
sw::DocumentChartDataProviderManager::maChartDataProviderImplRef
rtl::Reference< SwChartDataProvider > maChartDataProviderImplRef
Definition:
DocumentChartDataProviderManager.hxx:57
sw::DocumentChartDataProviderManager::m_rDoc
SwDoc & m_rDoc
Definition:
DocumentChartDataProviderManager.hxx:55
sw::DocumentChartDataProviderManager::~DocumentChartDataProviderManager
virtual ~DocumentChartDataProviderManager() override
Definition:
DocumentChartDataProviderManager.cxx:95
sw::DocumentChartDataProviderManager::CreateChartInternalDataProviders
void CreateChartInternalDataProviders(const SwTable *pTable) override
calls createInternalDataProvider for all charts using the specified table
Definition:
DocumentChartDataProviderManager.cxx:55
doc.hxx
m_rDoc
SwDoc & m_rDoc
Definition:
docbm.cxx:1228
aName
OUString aName
com::sun::star::uno
com::sun::star
sw
Dialog to specify the properties of date form field.
Definition:
AccessibilityCheck.cxx:48
ndole.hxx
svapp.hxx
swtable.hxx
unochart.hxx
Generated on Sun Jul 30 2023 04:28:20 for LibreOffice Module sw (master) by
1.9.3