1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <ChartDocumentWrapper.hxx>
21 #include <ChartView.hxx>
22 #include <ChartViewHelper.hxx>
23 #include <ChartTypeManager.hxx>
24 #include <ChartTypeTemplate.hxx>
25 #include <servicenames.hxx>
26 #include <PropertyHelper.hxx>
27 #include <TitleHelper.hxx>
29 #include <LegendHelper.hxx>
30 #include <ControllerLockGuard.hxx>
31 #include <DisposeHelper.hxx>
32 #include "DataSeriesPointWrapper.hxx"
33 #include <chartview/ExplicitValueProvider.hxx>
34 #include <chartview/DrawModelWrapper.hxx>
35 #include "Chart2ModelContact.hxx"
36 #include <BaseCoordinateSystem.hxx>
38 #include <ChartModel.hxx>
40 #include <DataSourceHelper.hxx>
41 #include <AxisHelper.hxx>
42 #include <ThreeDHelper.hxx>
44 #include "TitleWrapper.hxx"
45 #include "ChartDataWrapper.hxx"
46 #include "DiagramWrapper.hxx"
47 #include "LegendWrapper.hxx"
48 #include "AreaWrapper.hxx"
49 #include "WrappedAddInProperty.hxx"
50 #include <WrappedIgnoreProperty.hxx>
51 #include <cppuhelper/supportsservice.hxx>
52 #include <comphelper/processfactory.hxx>
53 #include <comphelper/sequence.hxx>
55 #include <vcl/settings.hxx>
57 #include <com/sun/star/drawing/ShapeCollection.hpp>
58 #include <com/sun/star/beans/PropertyAttribute.hpp>
59 #include <com/sun/star/lang/DisposedException.hpp>
60 #include <com/sun/star/lang/XInitialization.hpp>
61 #include <com/sun/star/util/XRefreshable.hpp>
62 #include <comphelper/diagnose_ex.hxx>
67 using namespace ::com::sun::star
;
68 using namespace ::com::sun::star::chart
;
70 using ::com::sun::star::uno::Any
;
71 using ::com::sun::star::uno::UNO_QUERY_THROW
;
72 using ::com::sun::star::uno::Reference
;
73 using ::com::sun::star::uno::Sequence
;
74 using ::com::sun::star::beans::Property
;
80 SERVICE_NAME_AREA_DIAGRAM
= 0,
81 SERVICE_NAME_BAR_DIAGRAM
,
82 SERVICE_NAME_DONUT_DIAGRAM
,
83 SERVICE_NAME_LINE_DIAGRAM
,
84 SERVICE_NAME_NET_DIAGRAM
,
85 SERVICE_NAME_FILLED_NET_DIAGRAM
,
86 SERVICE_NAME_PIE_DIAGRAM
,
87 SERVICE_NAME_STOCK_DIAGRAM
,
88 SERVICE_NAME_XY_DIAGRAM
,
89 SERVICE_NAME_BUBBLE_DIAGRAM
,
91 SERVICE_NAME_DASH_TABLE
,
92 SERVICE_NAME_GRADIENT_TABLE
,
93 SERVICE_NAME_HATCH_TABLE
,
94 SERVICE_NAME_BITMAP_TABLE
,
95 SERVICE_NAME_TRANSP_GRADIENT_TABLE
,
96 SERVICE_NAME_MARKER_TABLE
,
98 SERVICE_NAME_NAMESPACE_MAP
,
99 SERVICE_NAME_EXPORT_GRAPHIC_STORAGE_RESOLVER
,
100 SERVICE_NAME_IMPORT_GRAPHIC_STORAGE_RESOLVER
103 typedef std::map
< OUString
, enum eServiceType
> tServiceNameMap
;
105 tServiceNameMap
& lcl_getStaticServiceNameMap()
107 static tServiceNameMap aServiceNameMap
{
108 {"com.sun.star.chart.AreaDiagram", SERVICE_NAME_AREA_DIAGRAM
},
109 {"com.sun.star.chart.BarDiagram", SERVICE_NAME_BAR_DIAGRAM
},
110 {"com.sun.star.chart.DonutDiagram", SERVICE_NAME_DONUT_DIAGRAM
},
111 {"com.sun.star.chart.LineDiagram", SERVICE_NAME_LINE_DIAGRAM
},
112 {"com.sun.star.chart.NetDiagram", SERVICE_NAME_NET_DIAGRAM
},
113 {"com.sun.star.chart.FilledNetDiagram", SERVICE_NAME_FILLED_NET_DIAGRAM
},
114 {"com.sun.star.chart.PieDiagram", SERVICE_NAME_PIE_DIAGRAM
},
115 {"com.sun.star.chart.StockDiagram", SERVICE_NAME_STOCK_DIAGRAM
},
116 {"com.sun.star.chart.XYDiagram", SERVICE_NAME_XY_DIAGRAM
},
117 {"com.sun.star.chart.BubbleDiagram", SERVICE_NAME_BUBBLE_DIAGRAM
},
119 {"com.sun.star.drawing.DashTable", SERVICE_NAME_DASH_TABLE
},
120 {"com.sun.star.drawing.GradientTable", SERVICE_NAME_GRADIENT_TABLE
},
121 {"com.sun.star.drawing.HatchTable", SERVICE_NAME_HATCH_TABLE
},
122 {"com.sun.star.drawing.BitmapTable", SERVICE_NAME_BITMAP_TABLE
},
123 {"com.sun.star.drawing.TransparencyGradientTable", SERVICE_NAME_TRANSP_GRADIENT_TABLE
},
124 {"com.sun.star.drawing.MarkerTable", SERVICE_NAME_MARKER_TABLE
},
126 {"com.sun.star.xml.NamespaceMap", SERVICE_NAME_NAMESPACE_MAP
},
127 {"com.sun.star.document.ExportGraphicStorageHandler", SERVICE_NAME_EXPORT_GRAPHIC_STORAGE_RESOLVER
},
128 {"com.sun.star.document.ImportGraphicStorageHandler", SERVICE_NAME_IMPORT_GRAPHIC_STORAGE_RESOLVER
}
131 return aServiceNameMap
;
136 PROP_DOCUMENT_HAS_MAIN_TITLE
,
137 PROP_DOCUMENT_HAS_SUB_TITLE
,
138 PROP_DOCUMENT_HAS_LEGEND
,
139 PROP_DOCUMENT_LABELS_IN_FIRST_ROW
,
140 PROP_DOCUMENT_LABELS_IN_FIRST_COLUMN
,
142 PROP_DOCUMENT_BASEDIAGRAM
,
143 PROP_DOCUMENT_ADDITIONAL_SHAPES
,
144 PROP_DOCUMENT_UPDATE_ADDIN
,
145 PROP_DOCUMENT_NULL_DATE
,
146 PROP_DOCUMENT_ENABLE_COMPLEX_CHARTTYPES
,
147 PROP_DOCUMENT_ENABLE_DATATABLE_DIALOG
150 void lcl_AddPropertiesToVector(
151 std::vector
< Property
> & rOutProperties
)
153 rOutProperties
.emplace_back( "HasMainTitle",
154 PROP_DOCUMENT_HAS_MAIN_TITLE
,
155 cppu::UnoType
<bool>::get(),
156 //#i111967# no PropertyChangeEvent is fired on change so far
157 beans::PropertyAttribute::MAYBEDEFAULT
);
158 rOutProperties
.emplace_back( "HasSubTitle",
159 PROP_DOCUMENT_HAS_SUB_TITLE
,
160 cppu::UnoType
<bool>::get(),
161 //#i111967# no PropertyChangeEvent is fired on change so far
162 beans::PropertyAttribute::MAYBEDEFAULT
);
163 rOutProperties
.emplace_back( "HasLegend",
164 PROP_DOCUMENT_HAS_LEGEND
,
165 cppu::UnoType
<bool>::get(),
166 //#i111967# no PropertyChangeEvent is fired on change so far
167 beans::PropertyAttribute::MAYBEDEFAULT
);
170 rOutProperties
.emplace_back( "DataSourceLabelsInFirstRow",
171 PROP_DOCUMENT_LABELS_IN_FIRST_ROW
,
172 cppu::UnoType
<bool>::get(),
173 beans::PropertyAttribute::BOUND
174 | beans::PropertyAttribute::MAYBEDEFAULT
);
175 rOutProperties
.emplace_back( "DataSourceLabelsInFirstColumn",
176 PROP_DOCUMENT_LABELS_IN_FIRST_COLUMN
,
177 cppu::UnoType
<bool>::get(),
178 //#i111967# no PropertyChangeEvent is fired on change so far
179 beans::PropertyAttribute::MAYBEDEFAULT
);
182 rOutProperties
.emplace_back( "AddIn",
184 cppu::UnoType
<util::XRefreshable
>::get(),
185 beans::PropertyAttribute::BOUND
186 | beans::PropertyAttribute::MAYBEVOID
);
187 rOutProperties
.emplace_back( "BaseDiagram",
188 PROP_DOCUMENT_BASEDIAGRAM
,
189 cppu::UnoType
<OUString
>::get(),
190 beans::PropertyAttribute::BOUND
191 | beans::PropertyAttribute::MAYBEVOID
);
192 rOutProperties
.emplace_back( "AdditionalShapes",
193 PROP_DOCUMENT_ADDITIONAL_SHAPES
,
194 cppu::UnoType
<drawing::XShapes
>::get(),
195 beans::PropertyAttribute::BOUND
196 | beans::PropertyAttribute::MAYBEVOID
197 | beans::PropertyAttribute::READONLY
);
198 rOutProperties
.emplace_back( "RefreshAddInAllowed",
199 PROP_DOCUMENT_UPDATE_ADDIN
,
200 cppu::UnoType
<bool>::get(),
201 //#i111967# no PropertyChangeEvent is fired on change so far
202 beans::PropertyAttribute::TRANSIENT
);
204 // table:null-date // i99104
205 rOutProperties
.emplace_back( "NullDate",
206 PROP_DOCUMENT_NULL_DATE
,
207 ::cppu::UnoType
<css::util::DateTime
>::get(),
208 beans::PropertyAttribute::MAYBEVOID
);
210 rOutProperties
.emplace_back( "EnableComplexChartTypes",
211 PROP_DOCUMENT_ENABLE_COMPLEX_CHARTTYPES
,
212 cppu::UnoType
<bool>::get(),
213 //#i112666# no PropertyChangeEvent is fired on change so far
214 beans::PropertyAttribute::MAYBEDEFAULT
);
215 rOutProperties
.emplace_back( "EnableDataTableDialog",
216 PROP_DOCUMENT_ENABLE_DATATABLE_DIALOG
,
217 cppu::UnoType
<bool>::get(),
218 //#i112666# no PropertyChangeEvent is fired on change so far
219 beans::PropertyAttribute::MAYBEDEFAULT
);
222 const Sequence
< Property
> & StaticChartDocumentWrapperPropertyArray()
224 static Sequence
< Property
> aPropSeq
= []()
226 std::vector
< css::beans::Property
> aProperties
;
227 lcl_AddPropertiesToVector( aProperties
);
229 std::sort( aProperties
.begin(), aProperties
.end(),
230 ::chart::PropertyNameLess() );
232 return comphelper::containerToSequence( aProperties
);
237 } // anonymous namespace
239 namespace chart::wrapper
244 //PROP_DOCUMENT_LABELS_IN_FIRST_ROW
245 class WrappedDataSourceLabelsInFirstRowProperty
: public WrappedProperty
248 explicit WrappedDataSourceLabelsInFirstRowProperty(std::shared_ptr
<Chart2ModelContact
> spChart2ModelContact
);
250 virtual void setPropertyValue( const css::uno::Any
& rOuterValue
, const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
252 virtual css::uno::Any
getPropertyValue( const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
254 virtual css::uno::Any
getPropertyDefault( const css::uno::Reference
< css::beans::XPropertyState
>& xInnerPropertyState
) const override
;
257 std::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
258 mutable Any m_aOuterValue
;
263 WrappedDataSourceLabelsInFirstRowProperty::WrappedDataSourceLabelsInFirstRowProperty(std::shared_ptr
<Chart2ModelContact
> spChart2ModelContact
)
264 : WrappedProperty(u
"DataSourceLabelsInFirstRow"_ustr
,OUString())
265 , m_spChart2ModelContact(std::move( spChart2ModelContact
))
267 m_aOuterValue
= WrappedDataSourceLabelsInFirstRowProperty::getPropertyDefault( nullptr );
270 void WrappedDataSourceLabelsInFirstRowProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
272 bool bLabelsInFirstRow
= true;
273 if( ! (rOuterValue
>>= bLabelsInFirstRow
) )
274 throw lang::IllegalArgumentException(u
"Property DataSourceLabelsInFirstRow requires value of type boolean"_ustr
, nullptr, 0 );
276 m_aOuterValue
= rOuterValue
;
277 bool bNewValue
= bLabelsInFirstRow
;
279 OUString aRangeString
;
280 bool bUseColumns
= true;
281 bool bFirstCellAsLabel
= true;
282 bool bHasCategories
= true;
283 uno::Sequence
< sal_Int32
> aSequenceMapping
;
285 if( !DataSourceHelper::detectRangeSegmentation(
286 m_spChart2ModelContact
->getDocumentModel(), aRangeString
, aSequenceMapping
, bUseColumns
287 , bFirstCellAsLabel
, bHasCategories
) )
290 if( bUseColumns
&& bNewValue
!= bFirstCellAsLabel
)
292 DataSourceHelper::setRangeSegmentation(
293 m_spChart2ModelContact
->getDocumentModel(), aSequenceMapping
, bUseColumns
,bNewValue
, bHasCategories
);
295 else if( !bUseColumns
&& bNewValue
!= bHasCategories
)
297 DataSourceHelper::setRangeSegmentation(
298 m_spChart2ModelContact
->getDocumentModel(), aSequenceMapping
, bUseColumns
, bFirstCellAsLabel
, bNewValue
);
302 Any
WrappedDataSourceLabelsInFirstRowProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
304 OUString aRangeString
;
305 bool bUseColumns
= true;
306 bool bFirstCellAsLabel
= true;
307 bool bHasCategories
= true;
308 uno::Sequence
< sal_Int32
> aSequenceMapping
;
310 if( DataSourceHelper::detectRangeSegmentation(
311 m_spChart2ModelContact
->getDocumentModel(), aRangeString
, aSequenceMapping
, bUseColumns
312 , bFirstCellAsLabel
, bHasCategories
) )
314 bool bLabelsInFirstRow
= true;
316 bLabelsInFirstRow
= bFirstCellAsLabel
;
318 bLabelsInFirstRow
= bHasCategories
;
320 m_aOuterValue
<<= bLabelsInFirstRow
;
322 return m_aOuterValue
;
325 Any
WrappedDataSourceLabelsInFirstRowProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
334 //PROP_DOCUMENT_LABELS_IN_FIRST_COLUMN
335 class WrappedDataSourceLabelsInFirstColumnProperty
: public WrappedProperty
338 explicit WrappedDataSourceLabelsInFirstColumnProperty(std::shared_ptr
<Chart2ModelContact
> spChart2ModelContact
);
340 virtual void setPropertyValue( const css::uno::Any
& rOuterValue
, const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
342 virtual css::uno::Any
getPropertyValue( const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
344 virtual css::uno::Any
getPropertyDefault( const css::uno::Reference
< css::beans::XPropertyState
>& xInnerPropertyState
) const override
;
347 std::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
348 mutable Any m_aOuterValue
;
353 WrappedDataSourceLabelsInFirstColumnProperty::WrappedDataSourceLabelsInFirstColumnProperty(std::shared_ptr
<Chart2ModelContact
> spChart2ModelContact
)
354 : WrappedProperty(u
"DataSourceLabelsInFirstColumn"_ustr
,OUString())
355 , m_spChart2ModelContact(std::move( spChart2ModelContact
))
357 m_aOuterValue
= WrappedDataSourceLabelsInFirstColumnProperty::getPropertyDefault( nullptr );
360 void WrappedDataSourceLabelsInFirstColumnProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
362 bool bLabelsInFirstRow
= true;
363 if( ! (rOuterValue
>>= bLabelsInFirstRow
) )
364 throw lang::IllegalArgumentException(u
"Property DataSourceLabelsInFirstRow requires value of type boolean"_ustr
, nullptr, 0 );
366 m_aOuterValue
= rOuterValue
;
367 bool bNewValue
= bLabelsInFirstRow
;
369 OUString aRangeString
;
370 bool bUseColumns
= true;
371 bool bFirstCellAsLabel
= true;
372 bool bHasCategories
= true;
373 uno::Sequence
< sal_Int32
> aSequenceMapping
;
375 if( !DataSourceHelper::detectRangeSegmentation(
376 m_spChart2ModelContact
->getDocumentModel(), aRangeString
, aSequenceMapping
, bUseColumns
377 , bFirstCellAsLabel
, bHasCategories
) )
380 if( bUseColumns
&& bNewValue
!= bHasCategories
)
382 DataSourceHelper::setRangeSegmentation(
383 m_spChart2ModelContact
->getDocumentModel(), aSequenceMapping
, bUseColumns
, bFirstCellAsLabel
, bNewValue
);
385 else if( !bUseColumns
&& bNewValue
!= bFirstCellAsLabel
)
387 DataSourceHelper::setRangeSegmentation(
388 m_spChart2ModelContact
->getDocumentModel(), aSequenceMapping
, bUseColumns
, bNewValue
, bHasCategories
);
392 Any
WrappedDataSourceLabelsInFirstColumnProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
394 OUString aRangeString
;
395 bool bUseColumns
= true;
396 bool bFirstCellAsLabel
= true;
397 bool bHasCategories
= true;
398 uno::Sequence
< sal_Int32
> aSequenceMapping
;
400 if( DataSourceHelper::detectRangeSegmentation(
401 m_spChart2ModelContact
->getDocumentModel(), aRangeString
, aSequenceMapping
, bUseColumns
402 , bFirstCellAsLabel
, bHasCategories
) )
404 bool bLabelsInFirstColumn
= true;
406 bLabelsInFirstColumn
= bHasCategories
;
408 bLabelsInFirstColumn
= bFirstCellAsLabel
;
410 m_aOuterValue
<<= bLabelsInFirstColumn
;
412 return m_aOuterValue
;
415 Any
WrappedDataSourceLabelsInFirstColumnProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
424 //PROP_DOCUMENT_HAS_LEGEND
425 class WrappedHasLegendProperty
: public WrappedProperty
428 explicit WrappedHasLegendProperty(std::shared_ptr
<Chart2ModelContact
> spChart2ModelContact
);
430 virtual void setPropertyValue( const css::uno::Any
& rOuterValue
, const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
432 virtual css::uno::Any
getPropertyValue( const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
434 virtual css::uno::Any
getPropertyDefault( const css::uno::Reference
< css::beans::XPropertyState
>& xInnerPropertyState
) const override
;
437 std::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
442 WrappedHasLegendProperty::WrappedHasLegendProperty(std::shared_ptr
<Chart2ModelContact
> spChart2ModelContact
)
443 : WrappedProperty(u
"HasLegend"_ustr
,OUString())
444 , m_spChart2ModelContact(std::move( spChart2ModelContact
))
448 void WrappedHasLegendProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
450 bool bNewValue
= true;
451 if( ! (rOuterValue
>>= bNewValue
) )
452 throw lang::IllegalArgumentException(u
"Property HasLegend requires value of type boolean"_ustr
, nullptr, 0 );
456 rtl::Reference
< Legend
> xLegend
= LegendHelper::getLegend( *m_spChart2ModelContact
->getDocumentModel(), m_spChart2ModelContact
->m_xContext
,bNewValue
);
459 bool bOldValue
= true;
460 Any aAOld
= xLegend
->getPropertyValue(u
"Show"_ustr
);
462 if( bOldValue
!= bNewValue
)
463 xLegend
->setPropertyValue(u
"Show"_ustr
, uno::Any( bNewValue
));
466 catch (const uno::Exception
&)
468 DBG_UNHANDLED_EXCEPTION("chart2");
472 Any
WrappedHasLegendProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
477 rtl::Reference
< Legend
> xLegend
=
478 LegendHelper::getLegend( *m_spChart2ModelContact
->getDocumentModel() );
480 aRet
= xLegend
->getPropertyValue(u
"Show"_ustr
);
484 catch (const uno::Exception
&)
486 DBG_UNHANDLED_EXCEPTION("chart2");
491 Any
WrappedHasLegendProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
500 //PROP_DOCUMENT_HAS_MAIN_TITLE
501 class WrappedHasMainTitleProperty
: public WrappedProperty
504 explicit WrappedHasMainTitleProperty(std::shared_ptr
<Chart2ModelContact
> spChart2ModelContact
);
506 virtual void setPropertyValue( const css::uno::Any
& rOuterValue
, const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
508 virtual css::uno::Any
getPropertyValue( const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
510 virtual css::uno::Any
getPropertyDefault( const css::uno::Reference
< css::beans::XPropertyState
>& xInnerPropertyState
) const override
;
513 std::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
518 WrappedHasMainTitleProperty::WrappedHasMainTitleProperty(std::shared_ptr
<Chart2ModelContact
> spChart2ModelContact
)
519 : WrappedProperty(u
"HasMainTitle"_ustr
,OUString())
520 , m_spChart2ModelContact(std::move( spChart2ModelContact
))
524 void WrappedHasMainTitleProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
526 bool bNewValue
= true;
527 if( ! (rOuterValue
>>= bNewValue
) )
528 throw lang::IllegalArgumentException(u
"Property HasMainTitle requires value of type boolean"_ustr
, nullptr, 0 );
533 TitleHelper::createTitle( TitleHelper::MAIN_TITLE
, u
"main-title"_ustr
, m_spChart2ModelContact
->getDocumentModel(), m_spChart2ModelContact
->m_xContext
);
535 TitleHelper::removeTitle( TitleHelper::MAIN_TITLE
, m_spChart2ModelContact
->getDocumentModel() );
537 catch (const uno::Exception
&)
539 DBG_UNHANDLED_EXCEPTION("chart2");
543 Any
WrappedHasMainTitleProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
548 aRet
<<= TitleHelper::getTitle( TitleHelper::MAIN_TITLE
, m_spChart2ModelContact
->getDocumentModel() ).is();
550 catch (const uno::Exception
&)
552 DBG_UNHANDLED_EXCEPTION("chart2");
557 Any
WrappedHasMainTitleProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
566 //PROP_DOCUMENT_HAS_SUB_TITLE
567 class WrappedHasSubTitleProperty
: public WrappedProperty
570 explicit WrappedHasSubTitleProperty(std::shared_ptr
<Chart2ModelContact
> spChart2ModelContact
);
572 virtual void setPropertyValue( const css::uno::Any
& rOuterValue
, const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
574 virtual css::uno::Any
getPropertyValue( const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
576 virtual css::uno::Any
getPropertyDefault( const css::uno::Reference
< css::beans::XPropertyState
>& xInnerPropertyState
) const override
;
579 std::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
584 WrappedHasSubTitleProperty::WrappedHasSubTitleProperty(std::shared_ptr
<Chart2ModelContact
> spChart2ModelContact
)
585 : WrappedProperty(u
"HasSubTitle"_ustr
,OUString())
586 , m_spChart2ModelContact(std::move( spChart2ModelContact
))
590 void WrappedHasSubTitleProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
592 bool bNewValue
= true;
593 if( ! (rOuterValue
>>= bNewValue
) )
594 throw lang::IllegalArgumentException(u
"Property HasSubTitle requires value of type boolean"_ustr
, nullptr, 0 );
599 TitleHelper::createTitle( TitleHelper::SUB_TITLE
, u
""_ustr
, m_spChart2ModelContact
->getDocumentModel(), m_spChart2ModelContact
->m_xContext
);
601 TitleHelper::removeTitle( TitleHelper::SUB_TITLE
, m_spChart2ModelContact
->getDocumentModel() );
603 catch (const uno::Exception
&)
605 DBG_UNHANDLED_EXCEPTION("chart2");
609 Any
WrappedHasSubTitleProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
614 aRet
<<= TitleHelper::getTitle( TitleHelper::SUB_TITLE
, m_spChart2ModelContact
->getDocumentModel() ).is();
616 catch (const uno::Exception
&)
618 DBG_UNHANDLED_EXCEPTION("chart2");
623 Any
WrappedHasSubTitleProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
630 ChartDocumentWrapper::ChartDocumentWrapper(
631 const Reference
< uno::XComponentContext
> & xContext
) :
632 m_spChart2ModelContact( std::make_shared
<Chart2ModelContact
>( xContext
) ),
633 m_bUpdateAddIn( true ),
634 m_bIsDisposed( false )
638 ChartDocumentWrapper::~ChartDocumentWrapper()
640 stopAllComponentListening();
643 // ____ XInterface (for new interfaces) ____
644 // [-loplugin:unoaggregation]
645 uno::Any SAL_CALL
ChartDocumentWrapper::queryInterface( const uno::Type
& aType
)
647 if( m_xDelegator
.is())
648 // calls queryAggregation if the delegator doesn't know aType
649 return m_xDelegator
->queryInterface( aType
);
651 return queryAggregation( aType
);
654 // ____ chart::XChartDocument (old API wrapper) ____
655 Reference
< drawing::XShape
> SAL_CALL
ChartDocumentWrapper::getTitle()
659 ControllerLockGuardUNO
aCtrlLockGuard( m_spChart2ModelContact
->getDocumentModel() );
660 m_xTitle
= new TitleWrapper( TitleHelper::MAIN_TITLE
, m_spChart2ModelContact
);
665 Reference
< drawing::XShape
> SAL_CALL
ChartDocumentWrapper::getSubTitle()
667 if( !m_xSubTitle
.is() )
669 ControllerLockGuardUNO
aCtrlLockGuard( m_spChart2ModelContact
->getDocumentModel() );
670 m_xSubTitle
= new TitleWrapper( TitleHelper::SUB_TITLE
, m_spChart2ModelContact
);
675 Reference
< drawing::XShape
> SAL_CALL
ChartDocumentWrapper::getLegend()
677 if( ! m_xLegend
.is())
679 m_xLegend
= new LegendWrapper( m_spChart2ModelContact
);
685 Reference
< beans::XPropertySet
> SAL_CALL
ChartDocumentWrapper::getArea()
689 m_xArea
.set( new AreaWrapper( m_spChart2ModelContact
) );
695 Reference
< XDiagram
> SAL_CALL
ChartDocumentWrapper::getDiagram()
697 if( !m_xDiagram
.is() )
701 m_xDiagram
= new DiagramWrapper( m_spChart2ModelContact
);
703 catch (const uno::Exception
&)
705 DBG_UNHANDLED_EXCEPTION("chart2");
712 void SAL_CALL
ChartDocumentWrapper::setDiagram( const Reference
< XDiagram
>& _xDiagram
)
716 auto xDiagram
= dynamic_cast<DiagramWrapper
*>(_xDiagram
.get());
718 if( xDiagram
!= m_xDiagram
)
720 // set new wrapped diagram at new chart. This requires the old
721 // diagram given as parameter to implement the new interface. If
722 // this is not possible throw an exception
723 rtl::Reference
< ::chart::Diagram
> xNewDia( xDiagram
->getUnderlyingDiagram());
727 rtl::Reference
< ChartModel
> xChartDoc( m_spChart2ModelContact
->getDocumentModel() );
730 // set the new diagram
731 xChartDoc
->setFirstDiagram( xNewDia
);
732 m_xDiagram
= xDiagram
;
735 catch (const uno::Exception
&)
737 DBG_UNHANDLED_EXCEPTION("chart2");
742 Reference
< XChartData
> SAL_CALL
ChartDocumentWrapper::getData()
744 if( !m_xChartData
.is() )
746 m_xChartData
.set( new ChartDataWrapper( m_spChart2ModelContact
) );
748 //@todo: check hasInternalDataProvider also in else?
753 void SAL_CALL
ChartDocumentWrapper::attachData( const Reference
< XChartData
>& xNewData
)
758 ControllerLockGuardUNO
aCtrlLockGuard( m_spChart2ModelContact
->getDocumentModel() );
759 m_xChartData
.set( new ChartDataWrapper( m_spChart2ModelContact
, xNewData
) );
763 sal_Bool SAL_CALL
ChartDocumentWrapper::attachResource(
765 const Sequence
< beans::PropertyValue
>& Arguments
)
767 rtl::Reference
< ChartModel
> xModel( m_spChart2ModelContact
->getDocumentModel() );
769 return xModel
->attachResource( URL
, Arguments
);
773 OUString SAL_CALL
ChartDocumentWrapper::getURL()
775 rtl::Reference
< ChartModel
> xModel( m_spChart2ModelContact
->getDocumentModel() );
777 return xModel
->getURL();
781 Sequence
< beans::PropertyValue
> SAL_CALL
ChartDocumentWrapper::getArgs()
783 rtl::Reference
< ChartModel
> xModel( m_spChart2ModelContact
->getDocumentModel() );
785 return xModel
->getArgs();
786 return Sequence
< beans::PropertyValue
>();
789 void SAL_CALL
ChartDocumentWrapper::connectController( const Reference
< frame::XController
>& Controller
)
791 rtl::Reference
< ChartModel
> xModel( m_spChart2ModelContact
->getDocumentModel() );
793 xModel
->connectController( Controller
);
796 void SAL_CALL
ChartDocumentWrapper::disconnectController(
797 const Reference
< frame::XController
>& Controller
)
799 rtl::Reference
< ChartModel
> xModel( m_spChart2ModelContact
->getDocumentModel() );
801 xModel
->disconnectController( Controller
);
804 void SAL_CALL
ChartDocumentWrapper::lockControllers()
806 rtl::Reference
< ChartModel
> xModel( m_spChart2ModelContact
->getDocumentModel() );
808 xModel
->lockControllers();
811 void SAL_CALL
ChartDocumentWrapper::unlockControllers()
813 rtl::Reference
< ChartModel
> xModel( m_spChart2ModelContact
->getDocumentModel() );
815 xModel
->unlockControllers();
818 sal_Bool SAL_CALL
ChartDocumentWrapper::hasControllersLocked()
820 rtl::Reference
< ChartModel
> xModel( m_spChart2ModelContact
->getDocumentModel() );
822 return xModel
->hasControllersLocked();
826 Reference
< frame::XController
> SAL_CALL
ChartDocumentWrapper::getCurrentController()
828 rtl::Reference
< ChartModel
> xModel( m_spChart2ModelContact
->getDocumentModel() );
830 return xModel
->getCurrentController();
834 void SAL_CALL
ChartDocumentWrapper::setCurrentController(
835 const Reference
< frame::XController
>& Controller
)
837 rtl::Reference
< ChartModel
> xModel( m_spChart2ModelContact
->getDocumentModel() );
839 xModel
->setCurrentController( Controller
);
842 Reference
< uno::XInterface
> SAL_CALL
ChartDocumentWrapper::getCurrentSelection()
844 rtl::Reference
< ChartModel
> xModel( m_spChart2ModelContact
->getDocumentModel() );
846 return xModel
->getCurrentSelection();
850 // ____ XComponent ____
851 void SAL_CALL
ChartDocumentWrapper::dispose()
856 m_bIsDisposed
= true;
860 Reference
< lang::XComponent
> xFormerDelegator( m_xDelegator
, uno::UNO_QUERY
);
866 DisposeHelper::DisposeAndClear( m_xSubTitle
);
867 DisposeHelper::DisposeAndClear( m_xLegend
);
868 DisposeHelper::DisposeAndClear( m_xChartData
);
869 DisposeHelper::DisposeAndClear( m_xDiagram
);
870 DisposeHelper::DisposeAndClear( m_xArea
);
871 m_xChartView
.clear();
872 m_xShapeFactory
.clear();
873 m_xDelegator
.clear();
875 clearWrappedPropertySet();
876 m_spChart2ModelContact
->clear();
879 stopAllComponentListening();
883 if( xFormerDelegator
.is())
884 xFormerDelegator
->dispose();
886 catch (const lang::DisposedException
&)
888 // this is ok, don't panic
891 catch (const uno::Exception
&)
893 DBG_UNHANDLED_EXCEPTION("chart2");
897 void ChartDocumentWrapper::impl_resetAddIn()
899 Reference
< util::XRefreshable
> xAddIn( m_xAddIn
);
907 //make sure that the add-in does not hold a references to us anymore:
908 Reference
< lang::XComponent
> xComp( xAddIn
, uno::UNO_QUERY
);
913 uno::Reference
< lang::XInitialization
> xInit( xAddIn
, uno::UNO_QUERY
);
917 uno::Reference
< css::chart::XChartDocument
> xDoc
;
919 uno::Sequence
< uno::Any
> aSeq( &aParam
, 1 );
920 xInit
->initialize( aSeq
);
924 catch (const uno::RuntimeException
&)
926 DBG_UNHANDLED_EXCEPTION("chart2");
928 catch (const uno::Exception
&)
930 DBG_UNHANDLED_EXCEPTION("chart2");
934 void ChartDocumentWrapper::setBaseDiagram( const OUString
& rBaseDiagram
)
936 ControllerLockGuardUNO
aCtrlLockGuard( m_spChart2ModelContact
->getDocumentModel() );
937 m_aBaseDiagram
= rBaseDiagram
;
939 uno::Reference
< XDiagram
> xDiagram( ChartDocumentWrapper::createInstance( rBaseDiagram
), uno::UNO_QUERY
);
941 setDiagram( xDiagram
);
944 void ChartDocumentWrapper::setAddIn( const Reference
< util::XRefreshable
>& xAddIn
)
946 if( m_xAddIn
== xAddIn
)
949 ControllerLockGuardUNO
aCtrlLockGuard( m_spChart2ModelContact
->getDocumentModel() );
952 // initialize AddIn with this as chart document
953 uno::Reference
< lang::XInitialization
> xInit( m_xAddIn
, uno::UNO_QUERY
);
957 uno::Reference
< XChartDocument
> xDoc(this);
959 uno::Sequence
< uno::Any
> aSeq( &aParam
, 1 );
960 xInit
->initialize( aSeq
);
964 void ChartDocumentWrapper::setUpdateAddIn( bool bUpdateAddIn
)
966 m_bUpdateAddIn
= bUpdateAddIn
;
969 Reference
< drawing::XShapes
> ChartDocumentWrapper::getAdditionalShapes() const
971 // get additional non-chart shapes for XML export
972 uno::Reference
< drawing::XShapes
> xFoundShapes
;
973 rtl::Reference
<SvxDrawPage
> xDrawPage( impl_getDrawPage() );
975 if( !xDrawPage
.is() )
978 uno::Reference
<drawing::XShapes
> xChartRoot( DrawModelWrapper::getChartRootShape( xDrawPage
) );
980 // iterate 'flat' over all top-level objects
981 // and determine all that are no chart objects
982 std::vector
< uno::Reference
< drawing::XShape
> > aShapeVector
;
983 sal_Int32 nSubCount
= xDrawPage
->getCount();
984 uno::Reference
< drawing::XShape
> xShape
;
985 for( sal_Int32 nS
= 0; nS
< nSubCount
; nS
++ )
987 if( xDrawPage
->getByIndex( nS
) >>= xShape
)
989 if( xShape
.is() && xChartRoot
!=xShape
)
990 aShapeVector
.push_back( xShape
);
994 if( !aShapeVector
.empty() )
996 // create a shape collection
997 xFoundShapes
= drawing::ShapeCollection::create(
998 comphelper::getProcessComponentContext());
1000 OSL_ENSURE( xFoundShapes
.is(), "Couldn't create a shape collection!" );
1001 if( xFoundShapes
.is())
1003 for (auto const& shape
: aShapeVector
)
1004 xFoundShapes
->add(shape
);
1008 return xFoundShapes
;
1011 void SAL_CALL
ChartDocumentWrapper::addEventListener( const Reference
< lang::XEventListener
>& xListener
)
1013 rtl::Reference
< ChartModel
> xModel( m_spChart2ModelContact
->getDocumentModel() );
1015 xModel
->addEventListener( xListener
);
1018 void SAL_CALL
ChartDocumentWrapper::removeEventListener( const Reference
< lang::XEventListener
>& aListener
)
1020 rtl::Reference
< ChartModel
> xModel( m_spChart2ModelContact
->getDocumentModel() );
1022 xModel
->removeEventListener( aListener
);
1025 // ____ XDrawPageSupplier ____
1026 uno::Reference
< drawing::XDrawPage
> SAL_CALL
ChartDocumentWrapper::getDrawPage()
1028 return impl_getDrawPage();
1031 rtl::Reference
<SvxDrawPage
> ChartDocumentWrapper::impl_getDrawPage() const
1033 return m_spChart2ModelContact
->getDrawPage();
1038 uno::Reference
< lang::XMultiServiceFactory
> getShapeFactory(const rtl::Reference
<ChartView
>& xChartView
)
1041 return xChartView
->getDrawModelWrapper()->getShapeFactory();
1043 return uno::Reference
< lang::XMultiServiceFactory
>();
1048 // ____ XMultiServiceFactory ____
1049 uno::Reference
< uno::XInterface
> SAL_CALL
ChartDocumentWrapper::createInstance(
1050 const OUString
& aServiceSpecifier
)
1052 uno::Reference
< uno::XInterface
> xResult
;
1054 rtl::Reference
< ChartModel
> xChartDoc( m_spChart2ModelContact
->getDocumentModel() );
1055 if( !xChartDoc
.is() )
1058 bool bServiceFound
= false;
1059 tServiceNameMap
& rMap
= lcl_getStaticServiceNameMap();
1061 tServiceNameMap::const_iterator
aIt( rMap
.find( aServiceSpecifier
));
1062 if( aIt
!= rMap
.end())
1064 bool bCreateDiagram
= false;
1065 rtl::Reference
< ::chart::ChartTypeManager
> xChartTypeManager
=
1066 xChartDoc
->getTypeManager();
1067 rtl::Reference
< ::chart::ChartTypeTemplate
> xTemplate
;
1069 switch( (*aIt
).second
)
1071 case SERVICE_NAME_AREA_DIAGRAM
:
1072 if( xChartTypeManager
.is())
1075 xChartTypeManager
->createTemplate(u
"com.sun.star.chart2.template.Area"_ustr
);
1076 bCreateDiagram
= true;
1079 case SERVICE_NAME_BAR_DIAGRAM
:
1080 if( xChartTypeManager
.is())
1082 // this is for bar and column (the latter is the default if
1083 // no "Vertical=false" property was set)
1085 xChartTypeManager
->createTemplate(u
"com.sun.star.chart2.template.Column"_ustr
);
1086 bCreateDiagram
= true;
1089 case SERVICE_NAME_DONUT_DIAGRAM
:
1090 if( xChartTypeManager
.is())
1093 xChartTypeManager
->createTemplate(u
"com.sun.star.chart2.template.Donut"_ustr
);
1094 bCreateDiagram
= true;
1097 case SERVICE_NAME_LINE_DIAGRAM
:
1098 if( xChartTypeManager
.is())
1101 xChartTypeManager
->createTemplate(u
"com.sun.star.chart2.template.Line"_ustr
);
1102 bCreateDiagram
= true;
1105 case SERVICE_NAME_NET_DIAGRAM
:
1106 if( xChartTypeManager
.is())
1109 xChartTypeManager
->createTemplate(u
"com.sun.star.chart2.template.Net"_ustr
);
1110 bCreateDiagram
= true;
1113 case SERVICE_NAME_FILLED_NET_DIAGRAM
:
1114 if( xChartTypeManager
.is())
1117 xChartTypeManager
->createTemplate(u
"com.sun.star.chart2.template.FilledNet"_ustr
);
1118 bCreateDiagram
= true;
1121 case SERVICE_NAME_PIE_DIAGRAM
:
1122 if( xChartTypeManager
.is())
1125 xChartTypeManager
->createTemplate(u
"com.sun.star.chart2.template.Pie"_ustr
);
1126 bCreateDiagram
= true;
1129 case SERVICE_NAME_STOCK_DIAGRAM
:
1130 if( xChartTypeManager
.is())
1133 xChartTypeManager
->createTemplate(u
"com.sun.star.chart2.template.StockLowHighClose"_ustr
);
1134 bCreateDiagram
= true;
1137 case SERVICE_NAME_XY_DIAGRAM
:
1138 if( xChartTypeManager
.is())
1141 xChartTypeManager
->createTemplate(u
"com.sun.star.chart2.template.ScatterLineSymbol"_ustr
);
1142 bCreateDiagram
= true;
1146 case SERVICE_NAME_BUBBLE_DIAGRAM
:
1147 if( xChartTypeManager
.is())
1150 xChartTypeManager
->createTemplate(u
"com.sun.star.chart2.template.Bubble"_ustr
);
1151 bCreateDiagram
= true;
1155 case SERVICE_NAME_DASH_TABLE
:
1156 case SERVICE_NAME_GRADIENT_TABLE
:
1157 case SERVICE_NAME_HATCH_TABLE
:
1158 case SERVICE_NAME_BITMAP_TABLE
:
1159 case SERVICE_NAME_TRANSP_GRADIENT_TABLE
:
1160 case SERVICE_NAME_MARKER_TABLE
:
1161 xResult
.set( xChartDoc
->createInstance( aIt
->first
), uno::UNO_QUERY
);
1164 case SERVICE_NAME_NAMESPACE_MAP
:
1166 case SERVICE_NAME_EXPORT_GRAPHIC_STORAGE_RESOLVER
:
1168 case SERVICE_NAME_IMPORT_GRAPHIC_STORAGE_RESOLVER
:
1172 if( bCreateDiagram
&& xTemplate
.is() )
1176 uno::Reference
< chart2::XDiagram
> xDia( xChartDoc
->getFirstDiagram());
1179 // locked controllers
1180 ControllerLockGuardUNO
aCtrlLockGuard( xChartDoc
);
1181 rtl::Reference
< Diagram
> xDiagram
= xChartDoc
->getFirstChartDiagram();
1182 ThreeDLookScheme e3DScheme
= xDiagram
->detectScheme();
1183 rtl::Reference
< ::chart::ChartTypeManager
> xTemplateManager
= xChartDoc
->getTypeManager();
1184 Diagram::tTemplateWithServiceName
aTemplateWithService(
1185 xDiagram
->getTemplate( xTemplateManager
));
1186 if( aTemplateWithService
.xChartTypeTemplate
.is())
1187 aTemplateWithService
.xChartTypeTemplate
->resetStyles2( xDiagram
);//#i109371#
1188 xTemplate
->changeDiagram( xDiagram
);
1189 if( AllSettings::GetMathLayoutRTL() )
1190 AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram
, 0 ) );
1191 xDiagram
->setScheme( e3DScheme
);
1195 // locked controllers
1196 ControllerLockGuardUNO
aCtrlLockGuard( xChartDoc
);
1197 xDia
.set( xTemplate
->createDiagramByDataSource(
1198 uno::Reference
< chart2::data::XDataSource
>(),
1199 uno::Sequence
< beans::PropertyValue
>()));
1200 xChartDoc
->setFirstDiagram( xDia
);
1203 xResult
= static_cast< ::cppu::OWeakObject
* >( new DiagramWrapper( m_spChart2ModelContact
));
1205 catch (const uno::Exception
&)
1207 DBG_UNHANDLED_EXCEPTION("chart2");
1211 bServiceFound
= true;
1213 else if( aServiceSpecifier
== "com.sun.star.comp.chart2.DataSeriesWrapper" )
1215 Reference
< beans::XPropertySet
> xDataSeries( new DataSeriesPointWrapper( m_spChart2ModelContact
) );
1216 xResult
.set( xDataSeries
);
1217 bServiceFound
= true;
1219 else if( aServiceSpecifier
== CHART_VIEW_SERVICE_NAME
)
1221 if( !m_xChartView
.is() )
1223 rtl::Reference
<::chart::ChartModel
> pChartModel
= new ::chart::ChartModel(m_spChart2ModelContact
->m_xContext
);
1224 rtl::Reference
<ChartView
> xChartView
= new ::chart::ChartView(m_spChart2ModelContact
->m_xContext
, *pChartModel
);
1228 m_xChartView
= xChartView
;
1230 Sequence
< Any
> aArguments
{ Any(Reference
<frame::XModel
>(this)),
1231 Any(true) }; // bRefreshAddIn
1232 xChartView
->initialize(aArguments
);
1234 catch (const uno::Exception
&)
1236 DBG_UNHANDLED_EXCEPTION("chart2");
1239 xResult
.set( static_cast<cppu::OWeakObject
*>(m_xChartView
.get()) );
1240 bServiceFound
= true;
1244 // try to create a shape
1247 if( !m_xShapeFactory
.is() && m_xChartView
.is() )
1249 m_xShapeFactory
= getShapeFactory( m_xChartView
);
1253 rtl::Reference
<ChartModel
> pModel
= m_spChart2ModelContact
->getDocumentModel();
1256 m_xChartView
= pModel
->getChartView();
1257 m_xShapeFactory
= getShapeFactory( m_xChartView
);
1261 if( m_xShapeFactory
.is() )
1263 xResult
= m_xShapeFactory
->createInstance( aServiceSpecifier
);
1264 bServiceFound
= true;
1267 catch (const uno::Exception
&)
1269 // couldn't create shape
1273 // finally, try to create an addin
1274 if( !bServiceFound
)
1278 Reference
< lang::XMultiServiceFactory
> xFact(
1279 m_spChart2ModelContact
->m_xContext
->getServiceManager(), uno::UNO_QUERY_THROW
);
1280 uno::Reference
< util::XRefreshable
> xAddIn(
1281 xFact
->createInstance( aServiceSpecifier
), uno::UNO_QUERY
);
1287 catch (const uno::Exception
&)
1289 // couldn't create service
1296 uno::Reference
< uno::XInterface
> SAL_CALL
ChartDocumentWrapper::createInstanceWithArguments(
1297 const OUString
& ServiceSpecifier
,
1298 const uno::Sequence
< uno::Any
>& Arguments
)
1300 OSL_ENSURE( Arguments
.hasElements(), "createInstanceWithArguments: Warning: Arguments are ignored" );
1302 return createInstance( ServiceSpecifier
);
1305 uno::Sequence
< OUString
> SAL_CALL
ChartDocumentWrapper::getAvailableServiceNames()
1307 return comphelper::mapKeysToSequence( lcl_getStaticServiceNameMap() );
1310 // ____ XAggregation ____
1311 void SAL_CALL
ChartDocumentWrapper::setDelegator(
1312 const uno::Reference
< uno::XInterface
>& rDelegator
)
1316 if( rDelegator
.is() )
1317 throw lang::DisposedException(u
"ChartDocumentWrapper is disposed"_ustr
,
1318 static_cast< ::cppu::OWeakObject
* >( this ));
1322 if( rDelegator
.is())
1324 m_xDelegator
= rDelegator
;
1325 ChartModel
* pChartModel
= dynamic_cast<ChartModel
*>(rDelegator
.get());
1326 assert(pChartModel
);
1327 m_spChart2ModelContact
->setDocumentModel( pChartModel
);
1331 // this is a sort of dispose() from the new model,so release resources here
1336 catch (const uno::Exception
&)
1338 DBG_UNHANDLED_EXCEPTION("chart2");
1343 uno::Any SAL_CALL
ChartDocumentWrapper::queryAggregation( const uno::Type
& rType
)
1345 return ChartDocumentWrapper_Base::queryInterface( rType
);
1348 // ____ ::utl::OEventListenerAdapter ____
1349 void ChartDocumentWrapper::_disposing( const lang::EventObject
& rSource
)
1351 if( rSource
.Source
== cppu::getXWeak(m_xTitle
.get()) )
1353 else if( rSource
.Source
== cppu::getXWeak(m_xSubTitle
.get()) )
1354 m_xSubTitle
.clear();
1355 else if( rSource
.Source
== cppu::getXWeak(m_xLegend
.get()) )
1357 else if( rSource
.Source
== m_xChartData
)
1358 m_xChartData
.clear();
1359 else if( rSource
.Source
== cppu::getXWeak(m_xDiagram
.get()) )
1361 else if( rSource
.Source
== m_xArea
)
1363 else if( rSource
.Source
== m_xAddIn
)
1365 else if( rSource
.Source
== static_cast<cppu::OWeakObject
*>(m_xChartView
.get()) )
1366 m_xChartView
.clear();
1369 // ____ XPropertySet ____
1370 void SAL_CALL
ChartDocumentWrapper::setPropertyValue(const OUString
& rPropertyName
, const css::uno::Any
& rValue
)
1372 if (rPropertyName
== u
"ODFImport_UpdateView")
1374 // A hack used at load time to notify the view that it needs an update
1375 // See SchXMLImport::~SchXMLImport
1376 if (auto xChartModel
= rValue
.query
<css::chart2::XChartDocument
>())
1377 ChartViewHelper::setViewToDirtyState_UNO(xChartModel
);
1380 ChartDocumentWrapper_Base::setPropertyValue(rPropertyName
, rValue
);
1383 // WrappedPropertySet
1384 Reference
< beans::XPropertySet
> ChartDocumentWrapper::getInnerPropertySet()
1388 const Sequence
< beans::Property
>& ChartDocumentWrapper::getPropertySequence()
1390 return StaticChartDocumentWrapperPropertyArray();
1393 std::vector
< std::unique_ptr
<WrappedProperty
> > ChartDocumentWrapper::createWrappedProperties()
1395 std::vector
< std::unique_ptr
<WrappedProperty
> > aWrappedProperties
;
1396 aWrappedProperties
.emplace_back( new WrappedDataSourceLabelsInFirstRowProperty( m_spChart2ModelContact
) );
1397 aWrappedProperties
.emplace_back( new WrappedDataSourceLabelsInFirstColumnProperty( m_spChart2ModelContact
) );
1398 aWrappedProperties
.emplace_back( new WrappedHasLegendProperty( m_spChart2ModelContact
) );
1399 aWrappedProperties
.emplace_back( new WrappedHasMainTitleProperty( m_spChart2ModelContact
) );
1400 aWrappedProperties
.emplace_back( new WrappedHasSubTitleProperty( m_spChart2ModelContact
) );
1401 aWrappedProperties
.emplace_back( new WrappedAddInProperty( *this ) );
1402 aWrappedProperties
.emplace_back( new WrappedBaseDiagramProperty( *this ) );
1403 aWrappedProperties
.emplace_back( new WrappedAdditionalShapesProperty( *this ) );
1404 aWrappedProperties
.emplace_back( new WrappedRefreshAddInAllowedProperty( *this ) );
1405 aWrappedProperties
.emplace_back( new WrappedIgnoreProperty(u
"NullDate"_ustr
,Any() ) ); // i99104
1406 aWrappedProperties
.emplace_back( new WrappedIgnoreProperty(u
"EnableComplexChartTypes"_ustr
, uno::Any(true) ) );
1407 aWrappedProperties
.emplace_back( new WrappedIgnoreProperty(u
"EnableDataTableDialog"_ustr
, uno::Any(true) ) );
1409 return aWrappedProperties
;
1412 OUString SAL_CALL
ChartDocumentWrapper::getImplementationName()
1414 return CHART_CHARTAPIWRAPPER_IMPLEMENTATION_NAME
;
1417 sal_Bool SAL_CALL
ChartDocumentWrapper::supportsService( const OUString
& rServiceName
)
1419 return cppu::supportsService(this, rServiceName
);
1422 css::uno::Sequence
< OUString
> SAL_CALL
ChartDocumentWrapper::getSupportedServiceNames()
1425 u
"com.sun.star.chart.ChartDocument"_ustr
,
1426 CHART_CHARTAPIWRAPPER_SERVICE_NAME
,
1427 u
"com.sun.star.xml.UserDefinedAttributesSupplier"_ustr
,
1428 u
"com.sun.star.beans.PropertySet"_ustr
1432 } // namespace chart::wrapper
1434 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1435 com_sun_star_comp_chart2_ChartDocumentWrapper_get_implementation(css::uno::XComponentContext
*context
,
1436 css::uno::Sequence
<css::uno::Any
> const &)
1438 return cppu::acquire(new ::chart::wrapper::ChartDocumentWrapper(context
));
1441 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */