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 <servicenames.hxx>
22 #include <PropertyHelper.hxx>
23 #include <TitleHelper.hxx>
24 #include <LegendHelper.hxx>
25 #include <ControllerLockGuard.hxx>
26 #include <DisposeHelper.hxx>
27 #include "DataSeriesPointWrapper.hxx"
28 #include <chartview/ExplicitValueProvider.hxx>
29 #include <chartview/DrawModelWrapper.hxx>
30 #include "Chart2ModelContact.hxx"
32 #include <ChartModel.hxx>
34 #include <DiagramHelper.hxx>
35 #include <DataSourceHelper.hxx>
36 #include <ChartModelHelper.hxx>
37 #include <AxisHelper.hxx>
38 #include <ThreeDHelper.hxx>
40 #include "TitleWrapper.hxx"
41 #include "ChartDataWrapper.hxx"
42 #include "DiagramWrapper.hxx"
43 #include "LegendWrapper.hxx"
44 #include "AreaWrapper.hxx"
45 #include "WrappedAddInProperty.hxx"
46 #include <WrappedIgnoreProperty.hxx>
47 #include <cppuhelper/supportsservice.hxx>
48 #include <comphelper/processfactory.hxx>
49 #include <comphelper/sequence.hxx>
50 #include <comphelper/servicehelper.hxx>
51 #include <vcl/settings.hxx>
53 #include <com/sun/star/drawing/ShapeCollection.hpp>
54 #include <com/sun/star/beans/PropertyAttribute.hpp>
55 #include <com/sun/star/lang/DisposedException.hpp>
56 #include <com/sun/star/lang/XInitialization.hpp>
57 #include <com/sun/star/util/XRefreshable.hpp>
58 #include <tools/diagnose_ex.h>
64 using namespace ::com::sun::star
;
65 using namespace ::com::sun::star::chart
;
67 using ::com::sun::star::uno::Any
;
68 using ::com::sun::star::uno::UNO_QUERY_THROW
;
69 using ::com::sun::star::uno::Reference
;
70 using ::com::sun::star::uno::Sequence
;
71 using ::com::sun::star::beans::Property
;
77 SERVICE_NAME_AREA_DIAGRAM
= 0,
78 SERVICE_NAME_BAR_DIAGRAM
,
79 SERVICE_NAME_DONUT_DIAGRAM
,
80 SERVICE_NAME_LINE_DIAGRAM
,
81 SERVICE_NAME_NET_DIAGRAM
,
82 SERVICE_NAME_FILLED_NET_DIAGRAM
,
83 SERVICE_NAME_PIE_DIAGRAM
,
84 SERVICE_NAME_STOCK_DIAGRAM
,
85 SERVICE_NAME_XY_DIAGRAM
,
86 SERVICE_NAME_BUBBLE_DIAGRAM
,
88 SERVICE_NAME_DASH_TABLE
,
89 SERVICE_NAME_GARDIENT_TABLE
,
90 SERVICE_NAME_HATCH_TABLE
,
91 SERVICE_NAME_BITMAP_TABLE
,
92 SERVICE_NAME_TRANSP_GRADIENT_TABLE
,
93 SERVICE_NAME_MARKER_TABLE
,
95 SERVICE_NAME_NAMESPACE_MAP
,
96 SERVICE_NAME_EXPORT_GRAPHIC_STORAGE_RESOLVER
,
97 SERVICE_NAME_IMPORT_GRAPHIC_STORAGE_RESOLVER
100 typedef std::map
< OUString
, enum eServiceType
> tServiceNameMap
;
102 tServiceNameMap
& lcl_getStaticServiceNameMap()
104 static tServiceNameMap aServiceNameMap
{
105 {"com.sun.star.chart.AreaDiagram", SERVICE_NAME_AREA_DIAGRAM
},
106 {"com.sun.star.chart.BarDiagram", SERVICE_NAME_BAR_DIAGRAM
},
107 {"com.sun.star.chart.DonutDiagram", SERVICE_NAME_DONUT_DIAGRAM
},
108 {"com.sun.star.chart.LineDiagram", SERVICE_NAME_LINE_DIAGRAM
},
109 {"com.sun.star.chart.NetDiagram", SERVICE_NAME_NET_DIAGRAM
},
110 {"com.sun.star.chart.FilledNetDiagram", SERVICE_NAME_FILLED_NET_DIAGRAM
},
111 {"com.sun.star.chart.PieDiagram", SERVICE_NAME_PIE_DIAGRAM
},
112 {"com.sun.star.chart.StockDiagram", SERVICE_NAME_STOCK_DIAGRAM
},
113 {"com.sun.star.chart.XYDiagram", SERVICE_NAME_XY_DIAGRAM
},
114 {"com.sun.star.chart.BubbleDiagram", SERVICE_NAME_BUBBLE_DIAGRAM
},
116 {"com.sun.star.drawing.DashTable", SERVICE_NAME_DASH_TABLE
},
117 {"com.sun.star.drawing.GradientTable", SERVICE_NAME_GARDIENT_TABLE
},
118 {"com.sun.star.drawing.HatchTable", SERVICE_NAME_HATCH_TABLE
},
119 {"com.sun.star.drawing.BitmapTable", SERVICE_NAME_BITMAP_TABLE
},
120 {"com.sun.star.drawing.TransparencyGradientTable", SERVICE_NAME_TRANSP_GRADIENT_TABLE
},
121 {"com.sun.star.drawing.MarkerTable", SERVICE_NAME_MARKER_TABLE
},
123 {"com.sun.star.xml.NamespaceMap", SERVICE_NAME_NAMESPACE_MAP
},
124 {"com.sun.star.document.ExportGraphicStoreageHandler", SERVICE_NAME_EXPORT_GRAPHIC_STORAGE_RESOLVER
},
125 {"com.sun.star.document.ImportGraphicStoreageHandler", SERVICE_NAME_IMPORT_GRAPHIC_STORAGE_RESOLVER
}
128 return aServiceNameMap
;
133 PROP_DOCUMENT_HAS_MAIN_TITLE
,
134 PROP_DOCUMENT_HAS_SUB_TITLE
,
135 PROP_DOCUMENT_HAS_LEGEND
,
136 PROP_DOCUMENT_LABELS_IN_FIRST_ROW
,
137 PROP_DOCUMENT_LABELS_IN_FIRST_COLUMN
,
139 PROP_DOCUMENT_BASEDIAGRAM
,
140 PROP_DOCUMENT_ADDITIONAL_SHAPES
,
141 PROP_DOCUMENT_UPDATE_ADDIN
,
142 PROP_DOCUMENT_NULL_DATE
,
143 PROP_DOCUMENT_ENABLE_COMPLEX_CHARTTYPES
,
144 PROP_DOCUMENT_ENABLE_DATATABLE_DIALOG
147 void lcl_AddPropertiesToVector(
148 std::vector
< Property
> & rOutProperties
)
150 rOutProperties
.emplace_back( "HasMainTitle",
151 PROP_DOCUMENT_HAS_MAIN_TITLE
,
152 cppu::UnoType
<bool>::get(),
153 //#i111967# no PropertyChangeEvent is fired on change so far
154 beans::PropertyAttribute::MAYBEDEFAULT
);
155 rOutProperties
.emplace_back( "HasSubTitle",
156 PROP_DOCUMENT_HAS_SUB_TITLE
,
157 cppu::UnoType
<bool>::get(),
158 //#i111967# no PropertyChangeEvent is fired on change so far
159 beans::PropertyAttribute::MAYBEDEFAULT
);
160 rOutProperties
.emplace_back( "HasLegend",
161 PROP_DOCUMENT_HAS_LEGEND
,
162 cppu::UnoType
<bool>::get(),
163 //#i111967# no PropertyChangeEvent is fired on change so far
164 beans::PropertyAttribute::MAYBEDEFAULT
);
167 rOutProperties
.emplace_back( "DataSourceLabelsInFirstRow",
168 PROP_DOCUMENT_LABELS_IN_FIRST_ROW
,
169 cppu::UnoType
<bool>::get(),
170 beans::PropertyAttribute::BOUND
171 | beans::PropertyAttribute::MAYBEDEFAULT
);
172 rOutProperties
.emplace_back( "DataSourceLabelsInFirstColumn",
173 PROP_DOCUMENT_LABELS_IN_FIRST_COLUMN
,
174 cppu::UnoType
<bool>::get(),
175 //#i111967# no PropertyChangeEvent is fired on change so far
176 beans::PropertyAttribute::MAYBEDEFAULT
);
179 rOutProperties
.emplace_back( "AddIn",
181 cppu::UnoType
<util::XRefreshable
>::get(),
182 beans::PropertyAttribute::BOUND
183 | beans::PropertyAttribute::MAYBEVOID
);
184 rOutProperties
.emplace_back( "BaseDiagram",
185 PROP_DOCUMENT_BASEDIAGRAM
,
186 cppu::UnoType
<OUString
>::get(),
187 beans::PropertyAttribute::BOUND
188 | beans::PropertyAttribute::MAYBEVOID
);
189 rOutProperties
.emplace_back( "AdditionalShapes",
190 PROP_DOCUMENT_ADDITIONAL_SHAPES
,
191 cppu::UnoType
<drawing::XShapes
>::get(),
192 beans::PropertyAttribute::BOUND
193 | beans::PropertyAttribute::MAYBEVOID
194 | beans::PropertyAttribute::READONLY
);
195 rOutProperties
.emplace_back( "RefreshAddInAllowed",
196 PROP_DOCUMENT_UPDATE_ADDIN
,
197 cppu::UnoType
<bool>::get(),
198 //#i111967# no PropertyChangeEvent is fired on change so far
199 beans::PropertyAttribute::TRANSIENT
);
201 // table:null-date // i99104
202 rOutProperties
.emplace_back( "NullDate",
203 PROP_DOCUMENT_NULL_DATE
,
204 ::cppu::UnoType
<css::util::DateTime
>::get(),
205 beans::PropertyAttribute::MAYBEVOID
);
207 rOutProperties
.emplace_back( "EnableComplexChartTypes",
208 PROP_DOCUMENT_ENABLE_COMPLEX_CHARTTYPES
,
209 cppu::UnoType
<bool>::get(),
210 //#i112666# no PropertyChangeEvent is fired on change so far
211 beans::PropertyAttribute::MAYBEDEFAULT
);
212 rOutProperties
.emplace_back( "EnableDataTableDialog",
213 PROP_DOCUMENT_ENABLE_DATATABLE_DIALOG
,
214 cppu::UnoType
<bool>::get(),
215 //#i112666# no PropertyChangeEvent is fired on change so far
216 beans::PropertyAttribute::MAYBEDEFAULT
);
219 struct StaticChartDocumentWrapperPropertyArray_Initializer
221 Sequence
< Property
>* operator()()
223 static Sequence
< Property
> aPropSeq( lcl_GetPropertySequence() );
228 static uno::Sequence
< Property
> lcl_GetPropertySequence()
230 std::vector
< css::beans::Property
> aProperties
;
231 lcl_AddPropertiesToVector( aProperties
);
233 std::sort( aProperties
.begin(), aProperties
.end(),
234 ::chart::PropertyNameLess() );
236 return comphelper::containerToSequence( aProperties
);
240 struct StaticChartDocumentWrapperPropertyArray
: public rtl::StaticAggregate
< Sequence
< Property
>, StaticChartDocumentWrapperPropertyArray_Initializer
>
244 } // anonymous namespace
251 //PROP_DOCUMENT_LABELS_IN_FIRST_ROW
252 class WrappedDataSourceLabelsInFirstRowProperty
: public WrappedProperty
255 explicit WrappedDataSourceLabelsInFirstRowProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
);
257 virtual void setPropertyValue( const css::uno::Any
& rOuterValue
, const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
259 virtual css::uno::Any
getPropertyValue( const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
261 virtual css::uno::Any
getPropertyDefault( const css::uno::Reference
< css::beans::XPropertyState
>& xInnerPropertyState
) const override
;
264 std::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
265 mutable Any m_aOuterValue
;
268 WrappedDataSourceLabelsInFirstRowProperty::WrappedDataSourceLabelsInFirstRowProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
)
269 : WrappedProperty("DataSourceLabelsInFirstRow",OUString())
270 , m_spChart2ModelContact( spChart2ModelContact
)
273 m_aOuterValue
= WrappedDataSourceLabelsInFirstRowProperty::getPropertyDefault( nullptr );
276 void WrappedDataSourceLabelsInFirstRowProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
278 bool bLabelsInFirstRow
= true;
279 if( ! (rOuterValue
>>= bLabelsInFirstRow
) )
280 throw lang::IllegalArgumentException("Property DataSourceLabelsInFirstRow requires value of type boolean", nullptr, 0 );
282 m_aOuterValue
= rOuterValue
;
283 bool bNewValue
= bLabelsInFirstRow
;
285 OUString aRangeString
;
286 bool bUseColumns
= true;
287 bool bFirstCellAsLabel
= true;
288 bool bHasCategories
= true;
289 uno::Sequence
< sal_Int32
> aSequenceMapping
;
291 if( DataSourceHelper::detectRangeSegmentation(
292 m_spChart2ModelContact
->getChartModel(), aRangeString
, aSequenceMapping
, bUseColumns
293 , bFirstCellAsLabel
, bHasCategories
) )
295 if( bUseColumns
&& bNewValue
!= bFirstCellAsLabel
)
297 DataSourceHelper::setRangeSegmentation(
298 m_spChart2ModelContact
->getChartModel(), aSequenceMapping
, bUseColumns
,bNewValue
, bHasCategories
);
300 else if( !bUseColumns
&& bNewValue
!= bHasCategories
)
302 DataSourceHelper::setRangeSegmentation(
303 m_spChart2ModelContact
->getChartModel(), aSequenceMapping
, bUseColumns
, bFirstCellAsLabel
, bNewValue
);
308 Any
WrappedDataSourceLabelsInFirstRowProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
310 OUString aRangeString
;
311 bool bUseColumns
= true;
312 bool bFirstCellAsLabel
= true;
313 bool bHasCategories
= true;
314 uno::Sequence
< sal_Int32
> aSequenceMapping
;
316 if( DataSourceHelper::detectRangeSegmentation(
317 m_spChart2ModelContact
->getChartModel(), aRangeString
, aSequenceMapping
, bUseColumns
318 , bFirstCellAsLabel
, bHasCategories
) )
320 bool bLabelsInFirstRow
= true;
322 bLabelsInFirstRow
= bFirstCellAsLabel
;
324 bLabelsInFirstRow
= bHasCategories
;
326 m_aOuterValue
<<= bLabelsInFirstRow
;
328 return m_aOuterValue
;
331 Any
WrappedDataSourceLabelsInFirstRowProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
338 //PROP_DOCUMENT_LABELS_IN_FIRST_COLUMN
339 class WrappedDataSourceLabelsInFirstColumnProperty
: public WrappedProperty
342 explicit WrappedDataSourceLabelsInFirstColumnProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
);
344 virtual void setPropertyValue( const css::uno::Any
& rOuterValue
, const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
346 virtual css::uno::Any
getPropertyValue( const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
348 virtual css::uno::Any
getPropertyDefault( const css::uno::Reference
< css::beans::XPropertyState
>& xInnerPropertyState
) const override
;
351 std::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
352 mutable Any m_aOuterValue
;
355 WrappedDataSourceLabelsInFirstColumnProperty::WrappedDataSourceLabelsInFirstColumnProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
)
356 : WrappedProperty("DataSourceLabelsInFirstColumn",OUString())
357 , m_spChart2ModelContact( spChart2ModelContact
)
360 m_aOuterValue
= WrappedDataSourceLabelsInFirstColumnProperty::getPropertyDefault( nullptr );
363 void WrappedDataSourceLabelsInFirstColumnProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
365 bool bLabelsInFirstRow
= true;
366 if( ! (rOuterValue
>>= bLabelsInFirstRow
) )
367 throw lang::IllegalArgumentException("Property DataSourceLabelsInFirstRow requires value of type boolean", nullptr, 0 );
369 m_aOuterValue
= rOuterValue
;
370 bool bNewValue
= bLabelsInFirstRow
;
372 OUString aRangeString
;
373 bool bUseColumns
= true;
374 bool bFirstCellAsLabel
= true;
375 bool bHasCategories
= true;
376 uno::Sequence
< sal_Int32
> aSequenceMapping
;
378 if( DataSourceHelper::detectRangeSegmentation(
379 m_spChart2ModelContact
->getChartModel(), aRangeString
, aSequenceMapping
, bUseColumns
380 , bFirstCellAsLabel
, bHasCategories
) )
382 if( bUseColumns
&& bNewValue
!= bHasCategories
)
384 DataSourceHelper::setRangeSegmentation(
385 m_spChart2ModelContact
->getChartModel(), aSequenceMapping
, bUseColumns
, bFirstCellAsLabel
, bNewValue
);
387 else if( !bUseColumns
&& bNewValue
!= bFirstCellAsLabel
)
389 DataSourceHelper::setRangeSegmentation(
390 m_spChart2ModelContact
->getChartModel(), aSequenceMapping
, bUseColumns
, bNewValue
, bHasCategories
);
395 Any
WrappedDataSourceLabelsInFirstColumnProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
397 OUString aRangeString
;
398 bool bUseColumns
= true;
399 bool bFirstCellAsLabel
= true;
400 bool bHasCategories
= true;
401 uno::Sequence
< sal_Int32
> aSequenceMapping
;
403 if( DataSourceHelper::detectRangeSegmentation(
404 m_spChart2ModelContact
->getChartModel(), aRangeString
, aSequenceMapping
, bUseColumns
405 , bFirstCellAsLabel
, bHasCategories
) )
407 bool bLabelsInFirstColumn
= true;
409 bLabelsInFirstColumn
= bHasCategories
;
411 bLabelsInFirstColumn
= bFirstCellAsLabel
;
413 m_aOuterValue
<<= bLabelsInFirstColumn
;
415 return m_aOuterValue
;
418 Any
WrappedDataSourceLabelsInFirstColumnProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
425 //PROP_DOCUMENT_HAS_LEGEND
426 class WrappedHasLegendProperty
: public WrappedProperty
429 explicit WrappedHasLegendProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
);
431 virtual void setPropertyValue( const css::uno::Any
& rOuterValue
, const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
433 virtual css::uno::Any
getPropertyValue( const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
435 virtual css::uno::Any
getPropertyDefault( const css::uno::Reference
< css::beans::XPropertyState
>& xInnerPropertyState
) const override
;
438 std::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
441 WrappedHasLegendProperty::WrappedHasLegendProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
)
442 : WrappedProperty("HasLegend",OUString())
443 , m_spChart2ModelContact( spChart2ModelContact
)
447 void WrappedHasLegendProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
449 bool bNewValue
= true;
450 if( ! (rOuterValue
>>= bNewValue
) )
451 throw lang::IllegalArgumentException("Property HasLegend requires value of type boolean", nullptr, 0 );
455 Reference
< chart2::XLegend
> xLegend( LegendHelper::getLegend( *m_spChart2ModelContact
->getModel(), m_spChart2ModelContact
->m_xContext
,bNewValue
));
458 Reference
< beans::XPropertySet
> xLegendProp( xLegend
, uno::UNO_QUERY_THROW
);
459 bool bOldValue
= true;
460 Any aAOld
= xLegendProp
->getPropertyValue("Show");
462 if( bOldValue
!= bNewValue
)
463 xLegendProp
->setPropertyValue("Show", uno::Any( bNewValue
));
466 catch (const uno::Exception
&)
468 DBG_UNHANDLED_EXCEPTION("chart2");
472 Any
WrappedHasLegendProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
477 Reference
< beans::XPropertySet
> xLegendProp(
478 LegendHelper::getLegend( *m_spChart2ModelContact
->getModel() ), uno::UNO_QUERY
);
479 if( xLegendProp
.is())
480 aRet
= xLegendProp
->getPropertyValue("Show");
484 catch (const uno::Exception
&)
486 DBG_UNHANDLED_EXCEPTION("chart2");
491 Any
WrappedHasLegendProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
498 //PROP_DOCUMENT_HAS_MAIN_TITLE
499 class WrappedHasMainTitleProperty
: public WrappedProperty
502 explicit WrappedHasMainTitleProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
);
504 virtual void setPropertyValue( const css::uno::Any
& rOuterValue
, const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
506 virtual css::uno::Any
getPropertyValue( const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
508 virtual css::uno::Any
getPropertyDefault( const css::uno::Reference
< css::beans::XPropertyState
>& xInnerPropertyState
) const override
;
511 std::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
514 WrappedHasMainTitleProperty::WrappedHasMainTitleProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
)
515 : WrappedProperty("HasMainTitle",OUString())
516 , m_spChart2ModelContact( spChart2ModelContact
)
520 void WrappedHasMainTitleProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
522 bool bNewValue
= true;
523 if( ! (rOuterValue
>>= bNewValue
) )
524 throw lang::IllegalArgumentException("Property HasMainTitle requires value of type boolean", nullptr, 0 );
529 TitleHelper::createTitle( TitleHelper::MAIN_TITLE
, "main-title", m_spChart2ModelContact
->getChartModel(), m_spChart2ModelContact
->m_xContext
);
531 TitleHelper::removeTitle( TitleHelper::MAIN_TITLE
, m_spChart2ModelContact
->getChartModel() );
533 catch (const uno::Exception
&)
535 DBG_UNHANDLED_EXCEPTION("chart2");
539 Any
WrappedHasMainTitleProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
544 aRet
<<= TitleHelper::getTitle( TitleHelper::MAIN_TITLE
, m_spChart2ModelContact
->getChartModel() ).is();
546 catch (const uno::Exception
&)
548 DBG_UNHANDLED_EXCEPTION("chart2");
553 Any
WrappedHasMainTitleProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
560 //PROP_DOCUMENT_HAS_SUB_TITLE
561 class WrappedHasSubTitleProperty
: public WrappedProperty
564 explicit WrappedHasSubTitleProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
);
566 virtual void setPropertyValue( const css::uno::Any
& rOuterValue
, const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
568 virtual css::uno::Any
getPropertyValue( const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
570 virtual css::uno::Any
getPropertyDefault( const css::uno::Reference
< css::beans::XPropertyState
>& xInnerPropertyState
) const override
;
573 std::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
576 WrappedHasSubTitleProperty::WrappedHasSubTitleProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
)
577 : WrappedProperty("HasSubTitle",OUString())
578 , m_spChart2ModelContact( spChart2ModelContact
)
582 void WrappedHasSubTitleProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
584 bool bNewValue
= true;
585 if( ! (rOuterValue
>>= bNewValue
) )
586 throw lang::IllegalArgumentException("Property HasSubTitle requires value of type boolean", nullptr, 0 );
591 TitleHelper::createTitle( TitleHelper::SUB_TITLE
, "", m_spChart2ModelContact
->getChartModel(), m_spChart2ModelContact
->m_xContext
);
593 TitleHelper::removeTitle( TitleHelper::SUB_TITLE
, m_spChart2ModelContact
->getChartModel() );
595 catch (const uno::Exception
&)
597 DBG_UNHANDLED_EXCEPTION("chart2");
601 Any
WrappedHasSubTitleProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
606 aRet
<<= TitleHelper::getTitle( TitleHelper::SUB_TITLE
, m_spChart2ModelContact
->getChartModel() ).is();
608 catch (const uno::Exception
&)
610 DBG_UNHANDLED_EXCEPTION("chart2");
615 Any
WrappedHasSubTitleProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
622 ChartDocumentWrapper::ChartDocumentWrapper(
623 const Reference
< uno::XComponentContext
> & xContext
) :
624 m_spChart2ModelContact( new Chart2ModelContact( xContext
) ),
625 m_bUpdateAddIn( true ),
626 m_bIsDisposed( false )
630 ChartDocumentWrapper::~ChartDocumentWrapper()
632 stopAllComponentListening();
635 // ____ XInterface (for new interfaces) ____
636 uno::Any SAL_CALL
ChartDocumentWrapper::queryInterface( const uno::Type
& aType
)
638 if( m_xDelegator
.is())
639 // calls queryAggregation if the delegator doesn't know aType
640 return m_xDelegator
->queryInterface( aType
);
642 return queryAggregation( aType
);
645 // ____ chart::XChartDocument (old API wrapper) ____
646 Reference
< drawing::XShape
> SAL_CALL
ChartDocumentWrapper::getTitle()
650 ControllerLockGuardUNO
aCtrlLockGuard( m_spChart2ModelContact
->getChart2Document() );
651 m_xTitle
= new TitleWrapper( TitleHelper::MAIN_TITLE
, m_spChart2ModelContact
);
656 Reference
< drawing::XShape
> SAL_CALL
ChartDocumentWrapper::getSubTitle()
658 if( !m_xSubTitle
.is() )
660 ControllerLockGuardUNO
aCtrlLockGuard( m_spChart2ModelContact
->getChart2Document() );
661 m_xSubTitle
= new TitleWrapper( TitleHelper::SUB_TITLE
, m_spChart2ModelContact
);
666 Reference
< drawing::XShape
> SAL_CALL
ChartDocumentWrapper::getLegend()
668 if( ! m_xLegend
.is())
670 m_xLegend
= new LegendWrapper( m_spChart2ModelContact
);
676 Reference
< beans::XPropertySet
> SAL_CALL
ChartDocumentWrapper::getArea()
680 m_xArea
.set( new AreaWrapper( m_spChart2ModelContact
) );
686 Reference
< XDiagram
> SAL_CALL
ChartDocumentWrapper::getDiagram()
688 if( !m_xDiagram
.is() )
692 m_xDiagram
= new DiagramWrapper( m_spChart2ModelContact
);
694 catch (const uno::Exception
&)
696 DBG_UNHANDLED_EXCEPTION("chart2");
703 void SAL_CALL
ChartDocumentWrapper::setDiagram( const Reference
< XDiagram
>& xDiagram
)
705 uno::Reference
< util::XRefreshable
> xAddIn( xDiagram
, uno::UNO_QUERY
);
710 else if( xDiagram
.is() && xDiagram
!= m_xDiagram
)
712 // set new wrapped diagram at new chart. This requires the old
713 // diagram given as parameter to implement the new interface. If
714 // this is not possible throw an exception
715 Reference
< chart2::XDiagramProvider
> xNewDiaProvider( xDiagram
, uno::UNO_QUERY_THROW
);
716 Reference
< chart2::XDiagram
> xNewDia( xNewDiaProvider
->getDiagram());
720 Reference
< chart2::XChartDocument
> xChartDoc( m_spChart2ModelContact
->getChart2Document() );
723 // set the new diagram
724 xChartDoc
->setFirstDiagram( xNewDia
);
725 m_xDiagram
= xDiagram
;
728 catch (const uno::Exception
&)
730 DBG_UNHANDLED_EXCEPTION("chart2");
735 Reference
< XChartData
> SAL_CALL
ChartDocumentWrapper::getData()
737 if( !m_xChartData
.is() )
739 m_xChartData
.set( new ChartDataWrapper( m_spChart2ModelContact
) );
741 //@todo: check hasInternalDataProvider also in else?
746 void SAL_CALL
ChartDocumentWrapper::attachData( const Reference
< XChartData
>& xNewData
)
751 ControllerLockGuardUNO
aCtrlLockGuard( m_spChart2ModelContact
->getChart2Document() );
752 m_xChartData
.set( new ChartDataWrapper( m_spChart2ModelContact
, xNewData
) );
756 sal_Bool SAL_CALL
ChartDocumentWrapper::attachResource(
758 const Sequence
< beans::PropertyValue
>& Arguments
)
760 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
762 return xModel
->attachResource( URL
, Arguments
);
766 OUString SAL_CALL
ChartDocumentWrapper::getURL()
768 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
770 return xModel
->getURL();
774 Sequence
< beans::PropertyValue
> SAL_CALL
ChartDocumentWrapper::getArgs()
776 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
778 return xModel
->getArgs();
779 return Sequence
< beans::PropertyValue
>();
782 void SAL_CALL
ChartDocumentWrapper::connectController( const Reference
< frame::XController
>& Controller
)
784 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
786 xModel
->connectController( Controller
);
789 void SAL_CALL
ChartDocumentWrapper::disconnectController(
790 const Reference
< frame::XController
>& Controller
)
792 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
794 xModel
->disconnectController( Controller
);
797 void SAL_CALL
ChartDocumentWrapper::lockControllers()
799 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
801 xModel
->lockControllers();
804 void SAL_CALL
ChartDocumentWrapper::unlockControllers()
806 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
808 xModel
->unlockControllers();
811 sal_Bool SAL_CALL
ChartDocumentWrapper::hasControllersLocked()
813 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
815 return xModel
->hasControllersLocked();
819 Reference
< frame::XController
> SAL_CALL
ChartDocumentWrapper::getCurrentController()
821 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
823 return xModel
->getCurrentController();
827 void SAL_CALL
ChartDocumentWrapper::setCurrentController(
828 const Reference
< frame::XController
>& Controller
)
830 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
832 xModel
->setCurrentController( Controller
);
835 Reference
< uno::XInterface
> SAL_CALL
ChartDocumentWrapper::getCurrentSelection()
837 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
839 return xModel
->getCurrentSelection();
843 // ____ XComponent ____
844 void SAL_CALL
ChartDocumentWrapper::dispose()
847 throw lang::DisposedException("ChartDocumentWrapper is disposed",
848 static_cast< ::cppu::OWeakObject
* >( this ));
850 m_bIsDisposed
= true;
854 Reference
< lang::XComponent
> xFormerDelegator( m_xDelegator
, uno::UNO_QUERY
);
855 DisposeHelper::DisposeAndClear( m_xTitle
);
856 DisposeHelper::DisposeAndClear( m_xSubTitle
);
857 DisposeHelper::DisposeAndClear( m_xLegend
);
858 DisposeHelper::DisposeAndClear( m_xChartData
);
859 DisposeHelper::DisposeAndClear( m_xDiagram
);
860 DisposeHelper::DisposeAndClear( m_xArea
);
861 m_xChartView
.set( nullptr );
862 m_xShapeFactory
.set( nullptr );
863 m_xDelegator
.set( nullptr );
865 clearWrappedPropertySet();
866 m_spChart2ModelContact
->clear();
869 stopAllComponentListening();
873 if( xFormerDelegator
.is())
874 xFormerDelegator
->dispose();
876 catch (const lang::DisposedException
&)
878 // this is ok, don't panic
881 catch (const uno::Exception
&)
883 DBG_UNHANDLED_EXCEPTION("chart2");
887 void ChartDocumentWrapper::impl_resetAddIn()
889 Reference
< util::XRefreshable
> xAddIn( m_xAddIn
);
890 m_xAddIn
.set( nullptr );
896 //make sure that the add-in does not hold a references to us anymore:
897 Reference
< lang::XComponent
> xComp( xAddIn
, uno::UNO_QUERY
);
902 uno::Reference
< lang::XInitialization
> xInit( xAddIn
, uno::UNO_QUERY
);
906 uno::Reference
< css::chart::XChartDocument
> xDoc
;
908 uno::Sequence
< uno::Any
> aSeq( &aParam
, 1 );
909 xInit
->initialize( aSeq
);
913 catch (const uno::RuntimeException
&)
915 DBG_UNHANDLED_EXCEPTION("chart2");
917 catch (const uno::Exception
&)
919 DBG_UNHANDLED_EXCEPTION("chart2");
924 void ChartDocumentWrapper::setBaseDiagram( const OUString
& rBaseDiagram
)
926 ControllerLockGuardUNO
aCtrlLockGuard( m_spChart2ModelContact
->getChartModel() );
927 m_aBaseDiagram
= rBaseDiagram
;
929 uno::Reference
< XDiagram
> xDiagram( ChartDocumentWrapper::createInstance( rBaseDiagram
), uno::UNO_QUERY
);
931 setDiagram( xDiagram
);
934 void ChartDocumentWrapper::setAddIn( const Reference
< util::XRefreshable
>& xAddIn
)
936 if( m_xAddIn
== xAddIn
)
939 ControllerLockGuardUNO
aCtrlLockGuard( m_spChart2ModelContact
->getChartModel() );
942 // initialize AddIn with this as chart document
943 uno::Reference
< lang::XInitialization
> xInit( m_xAddIn
, uno::UNO_QUERY
);
947 uno::Reference
< XChartDocument
> xDoc( static_cast<XChartDocument
*>(this), uno::UNO_QUERY
);
949 uno::Sequence
< uno::Any
> aSeq( &aParam
, 1 );
950 xInit
->initialize( aSeq
);
954 void ChartDocumentWrapper::setUpdateAddIn( bool bUpdateAddIn
)
956 m_bUpdateAddIn
= bUpdateAddIn
;
959 Reference
< drawing::XShapes
> ChartDocumentWrapper::getAdditionalShapes() const
961 // get additional non-chart shapes for XML export
962 uno::Reference
< drawing::XShapes
> xFoundShapes
;
963 uno::Reference
< drawing::XDrawPage
> xDrawPage( impl_getDrawPage() );
965 if( !xDrawPage
.is() )
968 uno::Reference
<drawing::XShapes
> xChartRoot( DrawModelWrapper::getChartRootShape( xDrawPage
) );
970 // iterate 'flat' over all top-level objects
971 // and determine all that are no chart objects
972 std::vector
< uno::Reference
< drawing::XShape
> > aShapeVector
;
973 sal_Int32 nSubCount
= xDrawPage
->getCount();
974 uno::Reference
< drawing::XShape
> xShape
;
975 for( sal_Int32 nS
= 0; nS
< nSubCount
; nS
++ )
977 if( xDrawPage
->getByIndex( nS
) >>= xShape
)
979 if( xShape
.is() && xChartRoot
!=xShape
)
980 aShapeVector
.push_back( xShape
);
984 if( !aShapeVector
.empty() )
986 // create a shape collection
987 xFoundShapes
= drawing::ShapeCollection::create(
988 comphelper::getProcessComponentContext());
990 OSL_ENSURE( xFoundShapes
.is(), "Couldn't create a shape collection!" );
991 if( xFoundShapes
.is())
993 for (auto const& shape
: aShapeVector
)
994 xFoundShapes
->add(shape
);
1001 void SAL_CALL
ChartDocumentWrapper::addEventListener( const Reference
< lang::XEventListener
>& xListener
)
1003 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
1005 xModel
->addEventListener( xListener
);
1008 void SAL_CALL
ChartDocumentWrapper::removeEventListener( const Reference
< lang::XEventListener
>& aListener
)
1010 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
1012 xModel
->removeEventListener( aListener
);
1015 // ____ XDrawPageSupplier ____
1016 uno::Reference
< drawing::XDrawPage
> SAL_CALL
ChartDocumentWrapper::getDrawPage()
1018 return impl_getDrawPage();
1021 uno::Reference
< drawing::XDrawPage
> ChartDocumentWrapper::impl_getDrawPage() const
1023 return m_spChart2ModelContact
->getDrawPage();
1028 uno::Reference
< lang::XMultiServiceFactory
> getShapeFactory(const uno::Reference
<uno::XInterface
>& xChartView
)
1030 auto pProvider
= comphelper::getUnoTunnelImplementation
<ExplicitValueProvider
>(xChartView
);
1032 return pProvider
->getDrawModelWrapper()->getShapeFactory();
1034 return uno::Reference
< lang::XMultiServiceFactory
>();
1039 // ____ XMultiServiceFactory ____
1040 uno::Reference
< uno::XInterface
> SAL_CALL
ChartDocumentWrapper::createInstance(
1041 const OUString
& aServiceSpecifier
)
1043 uno::Reference
< uno::XInterface
> xResult
;
1045 Reference
< chart2::XChartDocument
> xChartDoc( m_spChart2ModelContact
->getChart2Document() );
1046 if( !xChartDoc
.is() )
1049 bool bServiceFound
= false;
1050 tServiceNameMap
& rMap
= lcl_getStaticServiceNameMap();
1052 tServiceNameMap::const_iterator
aIt( rMap
.find( aServiceSpecifier
));
1053 if( aIt
!= rMap
.end())
1055 bool bCreateDiagram
= false;
1056 uno::Reference
< lang::XMultiServiceFactory
> xManagerFact(
1057 xChartDoc
->getChartTypeManager(), uno::UNO_QUERY
);
1058 uno::Reference
< chart2::XChartTypeTemplate
> xTemplate
;
1060 switch( (*aIt
).second
)
1062 case SERVICE_NAME_AREA_DIAGRAM
:
1063 if( xManagerFact
.is())
1066 xManagerFact
->createInstance("com.sun.star.chart2.template.Area"),
1068 bCreateDiagram
= true;
1071 case SERVICE_NAME_BAR_DIAGRAM
:
1072 if( xManagerFact
.is())
1074 // this is for bar and column (the latter is the default if
1075 // no "Vertical=false" property was set)
1077 xManagerFact
->createInstance("com.sun.star.chart2.template.Column"),
1079 bCreateDiagram
= true;
1082 case SERVICE_NAME_DONUT_DIAGRAM
:
1083 if( xManagerFact
.is())
1086 xManagerFact
->createInstance("com.sun.star.chart2.template.Donut"),
1088 bCreateDiagram
= true;
1091 case SERVICE_NAME_LINE_DIAGRAM
:
1092 if( xManagerFact
.is())
1095 xManagerFact
->createInstance("com.sun.star.chart2.template.Line"),
1097 bCreateDiagram
= true;
1100 case SERVICE_NAME_NET_DIAGRAM
:
1101 if( xManagerFact
.is())
1104 xManagerFact
->createInstance("com.sun.star.chart2.template.Net"),
1106 bCreateDiagram
= true;
1109 case SERVICE_NAME_FILLED_NET_DIAGRAM
:
1110 if( xManagerFact
.is())
1113 xManagerFact
->createInstance("com.sun.star.chart2.template.FilledNet"),
1115 bCreateDiagram
= true;
1118 case SERVICE_NAME_PIE_DIAGRAM
:
1119 if( xManagerFact
.is())
1122 xManagerFact
->createInstance("com.sun.star.chart2.template.Pie"),
1124 bCreateDiagram
= true;
1127 case SERVICE_NAME_STOCK_DIAGRAM
:
1128 if( xManagerFact
.is())
1131 xManagerFact
->createInstance("com.sun.star.chart2.template.StockLowHighClose"),
1133 bCreateDiagram
= true;
1136 case SERVICE_NAME_XY_DIAGRAM
:
1137 if( xManagerFact
.is())
1140 xManagerFact
->createInstance("com.sun.star.chart2.template.ScatterLineSymbol"),
1142 bCreateDiagram
= true;
1146 case SERVICE_NAME_BUBBLE_DIAGRAM
:
1147 if( xManagerFact
.is())
1150 xManagerFact
->createInstance("com.sun.star.chart2.template.Bubble"),
1152 bCreateDiagram
= true;
1156 case SERVICE_NAME_DASH_TABLE
:
1157 case SERVICE_NAME_GARDIENT_TABLE
:
1158 case SERVICE_NAME_HATCH_TABLE
:
1159 case SERVICE_NAME_BITMAP_TABLE
:
1160 case SERVICE_NAME_TRANSP_GRADIENT_TABLE
:
1161 case SERVICE_NAME_MARKER_TABLE
:
1163 uno::Reference
< lang::XMultiServiceFactory
> xTableFactory( xChartDoc
, uno::UNO_QUERY
);
1164 OSL_ENSURE( xTableFactory
.get() != this, "new model is expected to implement service factory for gradient table etc" );
1165 if( xTableFactory
.is() && xTableFactory
.get() != this )
1166 xResult
.set( xTableFactory
->createInstance( aIt
->first
), uno::UNO_QUERY
);
1170 case SERVICE_NAME_NAMESPACE_MAP
:
1172 case SERVICE_NAME_EXPORT_GRAPHIC_STORAGE_RESOLVER
:
1174 case SERVICE_NAME_IMPORT_GRAPHIC_STORAGE_RESOLVER
:
1178 if( bCreateDiagram
&& xTemplate
.is() )
1182 uno::Reference
< chart2::XDiagram
> xDia( xChartDoc
->getFirstDiagram());
1185 // locked controllers
1186 ControllerLockGuardUNO
aCtrlLockGuard( xChartDoc
);
1187 Reference
< chart2::XDiagram
> xDiagram
= ChartModelHelper::findDiagram( xChartDoc
);
1188 ThreeDLookScheme e3DScheme
= ThreeDHelper::detectScheme( xDiagram
);
1189 Reference
< lang::XMultiServiceFactory
> xTemplateManager( xChartDoc
->getChartTypeManager(), uno::UNO_QUERY
);
1190 DiagramHelper::tTemplateWithServiceName
aTemplateWithService(
1191 DiagramHelper::getTemplateForDiagram( xDiagram
, xTemplateManager
));
1192 if( aTemplateWithService
.first
.is())
1193 aTemplateWithService
.first
->resetStyles( xDiagram
);//#i109371#
1194 xTemplate
->changeDiagram( xDiagram
);
1195 if( AllSettings::GetMathLayoutRTL() )
1196 AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram
, 0 ) );
1197 ThreeDHelper::setScheme( xDiagram
, e3DScheme
);
1201 // locked controllers
1202 ControllerLockGuardUNO
aCtrlLockGuard( xChartDoc
);
1203 xDia
.set( xTemplate
->createDiagramByDataSource(
1204 uno::Reference
< chart2::data::XDataSource
>(),
1205 uno::Sequence
< beans::PropertyValue
>()));
1206 xChartDoc
->setFirstDiagram( xDia
);
1209 xResult
= static_cast< ::cppu::OWeakObject
* >( new DiagramWrapper( m_spChart2ModelContact
));
1211 catch (const uno::Exception
&)
1213 DBG_UNHANDLED_EXCEPTION("chart2");
1217 bServiceFound
= true;
1219 else if( aServiceSpecifier
== "com.sun.star.comp.chart2.DataSeriesWrapper" )
1221 Reference
< beans::XPropertySet
> xDataSeries( new DataSeriesPointWrapper( m_spChart2ModelContact
) );
1222 xResult
.set( xDataSeries
);
1223 bServiceFound
= true;
1225 else if( aServiceSpecifier
== CHART_VIEW_SERVICE_NAME
)
1227 if( !m_xChartView
.is() )
1229 Reference
< lang::XMultiServiceFactory
> xFact(
1230 m_spChart2ModelContact
->m_xContext
->getServiceManager(), uno::UNO_QUERY_THROW
);
1231 Reference
< lang::XInitialization
> xViewInit( xFact
->createInstance(
1232 CHART_VIEW_SERVICE_NAME
), uno::UNO_QUERY
);
1237 m_xChartView
= xViewInit
;
1239 Sequence
< Any
> aArguments(2);
1240 aArguments
[0] <<= Reference
<frame::XModel
>(this);
1241 aArguments
[1] <<= true; // bRefreshAddIn
1242 xViewInit
->initialize(aArguments
);
1244 catch (const uno::Exception
&)
1246 DBG_UNHANDLED_EXCEPTION("chart2");
1250 xResult
.set( m_xChartView
);
1251 bServiceFound
= true;
1255 // try to create a shape
1258 if( !m_xShapeFactory
.is() && m_xChartView
.is() )
1260 m_xShapeFactory
= getShapeFactory( m_xChartView
);
1264 ChartModel
* pModel
= m_spChart2ModelContact
->getModel();
1267 m_xChartView
= pModel
->getChartView();
1268 m_xShapeFactory
= getShapeFactory( m_xChartView
);
1272 if( m_xShapeFactory
.is() )
1274 xResult
= m_xShapeFactory
->createInstance( aServiceSpecifier
);
1275 bServiceFound
= true;
1278 catch (const uno::Exception
&)
1280 // couldn't create shape
1284 // finally, try to create an addin
1285 if( !bServiceFound
)
1289 Reference
< lang::XMultiServiceFactory
> xFact(
1290 m_spChart2ModelContact
->m_xContext
->getServiceManager(), uno::UNO_QUERY_THROW
);
1291 uno::Reference
< util::XRefreshable
> xAddIn(
1292 xFact
->createInstance( aServiceSpecifier
), uno::UNO_QUERY
);
1298 catch (const uno::Exception
&)
1300 // couldn't create service
1307 uno::Reference
< uno::XInterface
> SAL_CALL
ChartDocumentWrapper::createInstanceWithArguments(
1308 const OUString
& ServiceSpecifier
,
1309 const uno::Sequence
< uno::Any
>& Arguments
)
1311 OSL_ENSURE( Arguments
.hasElements(), "createInstanceWithArguments: Warning: Arguments are ignored" );
1313 return createInstance( ServiceSpecifier
);
1316 uno::Sequence
< OUString
> SAL_CALL
ChartDocumentWrapper::getAvailableServiceNames()
1318 return comphelper::mapKeysToSequence( lcl_getStaticServiceNameMap() );
1321 // ____ XAggregation ____
1322 void SAL_CALL
ChartDocumentWrapper::setDelegator(
1323 const uno::Reference
< uno::XInterface
>& rDelegator
)
1327 if( rDelegator
.is() )
1328 throw lang::DisposedException("ChartDocumentWrapper is disposed",
1329 static_cast< ::cppu::OWeakObject
* >( this ));
1333 if( rDelegator
.is())
1335 m_xDelegator
= rDelegator
;
1336 m_spChart2ModelContact
->setModel( uno::Reference
< frame::XModel
>(m_xDelegator
, uno::UNO_QUERY
) );
1340 // this is a sort of dispose() from the new model,so release resources here
1345 catch (const uno::Exception
&)
1347 DBG_UNHANDLED_EXCEPTION("chart2");
1352 uno::Any SAL_CALL
ChartDocumentWrapper::queryAggregation( const uno::Type
& rType
)
1354 return ChartDocumentWrapper_Base::queryInterface( rType
);
1357 // ____ ::utl::OEventListenerAdapter ____
1358 void ChartDocumentWrapper::_disposing( const lang::EventObject
& rSource
)
1360 if( rSource
.Source
== m_xTitle
)
1361 m_xTitle
.set( nullptr );
1362 else if( rSource
.Source
== m_xSubTitle
)
1363 m_xSubTitle
.set( nullptr );
1364 else if( rSource
.Source
== m_xLegend
)
1365 m_xLegend
.set( nullptr );
1366 else if( rSource
.Source
== m_xChartData
)
1367 m_xChartData
.set( nullptr );
1368 else if( rSource
.Source
== m_xDiagram
)
1369 m_xDiagram
.set( nullptr );
1370 else if( rSource
.Source
== m_xArea
)
1371 m_xArea
.set( nullptr );
1372 else if( rSource
.Source
== m_xAddIn
)
1373 m_xAddIn
.set( nullptr );
1374 else if( rSource
.Source
== m_xChartView
)
1375 m_xChartView
.set( nullptr );
1378 // WrappedPropertySet
1379 Reference
< beans::XPropertySet
> ChartDocumentWrapper::getInnerPropertySet()
1383 const Sequence
< beans::Property
>& ChartDocumentWrapper::getPropertySequence()
1385 return *StaticChartDocumentWrapperPropertyArray::get();
1388 std::vector
< std::unique_ptr
<WrappedProperty
> > ChartDocumentWrapper::createWrappedProperties()
1390 std::vector
< std::unique_ptr
<WrappedProperty
> > aWrappedProperties
;
1391 aWrappedProperties
.emplace_back( new WrappedDataSourceLabelsInFirstRowProperty( m_spChart2ModelContact
) );
1392 aWrappedProperties
.emplace_back( new WrappedDataSourceLabelsInFirstColumnProperty( m_spChart2ModelContact
) );
1393 aWrappedProperties
.emplace_back( new WrappedHasLegendProperty( m_spChart2ModelContact
) );
1394 aWrappedProperties
.emplace_back( new WrappedHasMainTitleProperty( m_spChart2ModelContact
) );
1395 aWrappedProperties
.emplace_back( new WrappedHasSubTitleProperty( m_spChart2ModelContact
) );
1396 aWrappedProperties
.emplace_back( new WrappedAddInProperty( *this ) );
1397 aWrappedProperties
.emplace_back( new WrappedBaseDiagramProperty( *this ) );
1398 aWrappedProperties
.emplace_back( new WrappedAdditionalShapesProperty( *this ) );
1399 aWrappedProperties
.emplace_back( new WrappedRefreshAddInAllowedProperty( *this ) );
1400 aWrappedProperties
.emplace_back( new WrappedIgnoreProperty("NullDate",Any() ) ); // i99104
1401 aWrappedProperties
.emplace_back( new WrappedIgnoreProperty("EnableComplexChartTypes", uno::Any(true) ) );
1402 aWrappedProperties
.emplace_back( new WrappedIgnoreProperty("EnableDataTableDialog", uno::Any(true) ) );
1404 return aWrappedProperties
;
1407 OUString SAL_CALL
ChartDocumentWrapper::getImplementationName()
1409 return CHART_CHARTAPIWRAPPER_IMPLEMENTATION_NAME
;
1412 sal_Bool SAL_CALL
ChartDocumentWrapper::supportsService( const OUString
& rServiceName
)
1414 return cppu::supportsService(this, rServiceName
);
1417 css::uno::Sequence
< OUString
> SAL_CALL
ChartDocumentWrapper::getSupportedServiceNames()
1420 "com.sun.star.chart.ChartDocument",
1421 CHART_CHARTAPIWRAPPER_SERVICE_NAME
,
1422 "com.sun.star.xml.UserDefinedAttributesSupplier",
1423 "com.sun.star.beans.PropertySet"
1427 } // namespace wrapper
1428 } // namespace chart
1430 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1431 com_sun_star_comp_chart2_ChartDocumentWrapper_get_implementation(css::uno::XComponentContext
*context
,
1432 css::uno::Sequence
<css::uno::Any
> const &)
1434 return cppu::acquire(new ::chart::wrapper::ChartDocumentWrapper(context
));
1437 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */