Branch data Line data Source code
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 "ChartDocumentWrapper.hxx"
21 : : #include "macros.hxx"
22 : : #include "servicenames.hxx"
23 : : #include "PropertyHelper.hxx"
24 : : #include "TitleHelper.hxx"
25 : : #include "LegendHelper.hxx"
26 : : #include "ControllerLockGuard.hxx"
27 : : #include "ModifyListenerHelper.hxx"
28 : : #include "DisposeHelper.hxx"
29 : : #include "DataSeriesPointWrapper.hxx"
30 : : #include "chartview/ExplicitValueProvider.hxx"
31 : : #include "chartview/DrawModelWrapper.hxx"
32 : : #include "Chart2ModelContact.hxx"
33 : :
34 : : #include "DiagramHelper.hxx"
35 : : #include "DataSourceHelper.hxx"
36 : : #include "ChartModelHelper.hxx"
37 : : #include "ContainerHelper.hxx"
38 : : #include "AxisHelper.hxx"
39 : : #include "ThreeDHelper.hxx"
40 : :
41 : : #include "TitleWrapper.hxx"
42 : : #include "ChartDataWrapper.hxx"
43 : : #include "DiagramWrapper.hxx"
44 : : #include "LegendWrapper.hxx"
45 : : #include "AreaWrapper.hxx"
46 : : #include "WrappedAddInProperty.hxx"
47 : : #include "WrappedIgnoreProperty.hxx"
48 : : #include "ChartRenderer.hxx"
49 : : #include <com/sun/star/chart2/XTitled.hpp>
50 : : #include <com/sun/star/chart2/data/XDataReceiver.hpp>
51 : : #include <com/sun/star/chart/ChartDataRowSource.hpp>
52 : : #include <comphelper/InlineContainer.hxx>
53 : : // header for function SvxShapeCollection_NewInstance
54 : : #include <svx/unoshcol.hxx>
55 : : #include <vcl/svapp.hxx>
56 : :
57 : : #include <com/sun/star/drawing/XDrawPagesSupplier.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/DateTime.hpp>
62 : :
63 : : #include <vector>
64 : : #include <algorithm>
65 : : #include <functional>
66 : : #include <o3tl/compat_functional.hxx>
67 : :
68 : : using namespace ::com::sun::star;
69 : : using namespace ::com::sun::star::chart;
70 : :
71 : : using ::com::sun::star::uno::Any;
72 : : using ::com::sun::star::uno::UNO_QUERY_THROW;
73 : : using ::com::sun::star::uno::Reference;
74 : : using ::com::sun::star::uno::Sequence;
75 : : using ::com::sun::star::beans::Property;
76 : : using ::osl::MutexGuard;
77 : : using ::rtl::OUString;
78 : :
79 : : namespace
80 : : {
81 : : enum eServiceType
82 : : {
83 : : SERVICE_NAME_AREA_DIAGRAM = 0,
84 : : SERVICE_NAME_BAR_DIAGRAM,
85 : : SERVICE_NAME_DONUT_DIAGRAM,
86 : : SERVICE_NAME_LINE_DIAGRAM,
87 : : SERVICE_NAME_NET_DIAGRAM,
88 : : SERVICE_NAME_FILLED_NET_DIAGRAM,
89 : : SERVICE_NAME_PIE_DIAGRAM,
90 : : SERVICE_NAME_STOCK_DIAGRAM,
91 : : SERVICE_NAME_XY_DIAGRAM,
92 : : SERVICE_NAME_BUBBLE_DIAGRAM,
93 : :
94 : : SERVICE_NAME_DASH_TABLE,
95 : : SERVICE_NAME_GARDIENT_TABLE,
96 : : SERVICE_NAME_HATCH_TABLE,
97 : : SERVICE_NAME_BITMAP_TABLE,
98 : : SERVICE_NAME_TRANSP_GRADIENT_TABLE,
99 : : SERVICE_NAME_MARKER_TABLE,
100 : :
101 : : SERVICE_NAME_NAMESPACE_MAP,
102 : : SERVICE_NAME_EXPORT_GRAPHIC_RESOLVER,
103 : : SERVICE_NAME_IMPORT_GRAPHIC_RESOLVER
104 : : };
105 : :
106 : : typedef ::std::map< ::rtl::OUString, enum eServiceType > tServiceNameMap;
107 : : typedef ::comphelper::MakeMap< ::rtl::OUString, enum eServiceType > tMakeServiceNameMap;
108 : :
109 : 4817 : tServiceNameMap & lcl_getStaticServiceNameMap()
110 : : {
111 : : static tServiceNameMap aServiceNameMap(
112 : : tMakeServiceNameMap
113 : : ( "com.sun.star.chart.AreaDiagram", SERVICE_NAME_AREA_DIAGRAM )
114 [ + - ][ + - ]: 28 : ( "com.sun.star.chart.BarDiagram", SERVICE_NAME_BAR_DIAGRAM )
115 [ + - ]: 42 : ( "com.sun.star.chart.DonutDiagram", SERVICE_NAME_DONUT_DIAGRAM )
116 [ + - ]: 42 : ( "com.sun.star.chart.LineDiagram", SERVICE_NAME_LINE_DIAGRAM )
117 [ + - ]: 42 : ( "com.sun.star.chart.NetDiagram", SERVICE_NAME_NET_DIAGRAM )
118 [ + - ]: 42 : ( "com.sun.star.chart.FilledNetDiagram", SERVICE_NAME_FILLED_NET_DIAGRAM )
119 [ + - ]: 42 : ( "com.sun.star.chart.PieDiagram", SERVICE_NAME_PIE_DIAGRAM )
120 [ + - ]: 42 : ( "com.sun.star.chart.StockDiagram", SERVICE_NAME_STOCK_DIAGRAM )
121 [ + - ]: 42 : ( "com.sun.star.chart.XYDiagram", SERVICE_NAME_XY_DIAGRAM )
122 [ + - ]: 42 : ( "com.sun.star.chart.BubbleDiagram", SERVICE_NAME_BUBBLE_DIAGRAM )
123 : :
124 [ + - ]: 42 : ( "com.sun.star.drawing.DashTable", SERVICE_NAME_DASH_TABLE )
125 [ + - ]: 42 : ( "com.sun.star.drawing.GradientTable", SERVICE_NAME_GARDIENT_TABLE )
126 [ + - ]: 42 : ( "com.sun.star.drawing.HatchTable", SERVICE_NAME_HATCH_TABLE )
127 [ + - ]: 42 : ( "com.sun.star.drawing.BitmapTable", SERVICE_NAME_BITMAP_TABLE )
128 [ + - ]: 42 : ( "com.sun.star.drawing.TransparencyGradientTable", SERVICE_NAME_TRANSP_GRADIENT_TABLE )
129 [ + - ]: 42 : ( "com.sun.star.drawing.MarkerTable", SERVICE_NAME_MARKER_TABLE )
130 : :
131 [ + - ]: 42 : ( "com.sun.star.xml.NamespaceMap", SERVICE_NAME_NAMESPACE_MAP )
132 [ + - ]: 42 : ( "com.sun.star.document.ExportGraphicObjectResolver", SERVICE_NAME_EXPORT_GRAPHIC_RESOLVER )
133 [ + - ]: 42 : ( "com.sun.star.document.ImportGraphicObjectResolver", SERVICE_NAME_IMPORT_GRAPHIC_RESOLVER )
134 [ + + ][ + - ]: 4831 : );
[ + - ][ # # ]
135 : :
136 : 4817 : return aServiceNameMap;
137 : : }
138 : :
139 : : enum
140 : : {
141 : : PROP_DOCUMENT_HAS_MAIN_TITLE,
142 : : PROP_DOCUMENT_HAS_SUB_TITLE,
143 : : PROP_DOCUMENT_HAS_LEGEND,
144 : : PROP_DOCUMENT_LABELS_IN_FIRST_ROW,
145 : : PROP_DOCUMENT_LABELS_IN_FIRST_COLUMN,
146 : : PROP_DOCUMENT_ADDIN,
147 : : PROP_DOCUMENT_BASEDIAGRAM,
148 : : PROP_DOCUMENT_ADDITIONAL_SHAPES,
149 : : PROP_DOCUMENT_UPDATE_ADDIN,
150 : : PROP_DOCUMENT_NULL_DATE,
151 : : PROP_DOCUMENT_DISABLE_COMPLEX_CHARTTYPES,
152 : : PROP_DOCUMENT_DISABLE_DATATABLE_DIALOG
153 : : };
154 : :
155 : 14 : void lcl_AddPropertiesToVector(
156 : : ::std::vector< Property > & rOutProperties )
157 : : {
158 : : rOutProperties.push_back(
159 : : Property( "HasMainTitle",
160 : : PROP_DOCUMENT_HAS_MAIN_TITLE,
161 : 14 : ::getBooleanCppuType(),
162 : : //#i111967# no PropertyChangeEvent is fired on change so far
163 [ + - ]: 14 : beans::PropertyAttribute::MAYBEDEFAULT ));
164 : : rOutProperties.push_back(
165 : : Property( "HasSubTitle",
166 : : PROP_DOCUMENT_HAS_SUB_TITLE,
167 : 14 : ::getBooleanCppuType(),
168 : : //#i111967# no PropertyChangeEvent is fired on change so far
169 [ + - ]: 14 : beans::PropertyAttribute::MAYBEDEFAULT ));
170 : : rOutProperties.push_back(
171 : : Property( "HasLegend",
172 : : PROP_DOCUMENT_HAS_LEGEND,
173 : 14 : ::getBooleanCppuType(),
174 : : //#i111967# no PropertyChangeEvent is fired on change so far
175 [ + - ]: 14 : beans::PropertyAttribute::MAYBEDEFAULT ));
176 : :
177 : : // really needed?
178 : : rOutProperties.push_back(
179 : : Property( "DataSourceLabelsInFirstRow",
180 : : PROP_DOCUMENT_LABELS_IN_FIRST_ROW,
181 [ + - ]: 14 : ::getBooleanCppuType(),
182 : : beans::PropertyAttribute::BOUND
183 [ + - ]: 14 : | beans::PropertyAttribute::MAYBEDEFAULT ));
184 : : rOutProperties.push_back(
185 : : Property( "DataSourceLabelsInFirstColumn",
186 : : PROP_DOCUMENT_LABELS_IN_FIRST_COLUMN,
187 : 14 : ::getBooleanCppuType(),
188 : : //#i111967# no PropertyChangeEvent is fired on change so far
189 [ + - ]: 14 : beans::PropertyAttribute::MAYBEDEFAULT ));
190 : :
191 : : //add-in
192 : : rOutProperties.push_back(
193 : : Property( "AddIn",
194 : : PROP_DOCUMENT_ADDIN,
195 [ + - ]: 14 : ::getCppuType( reinterpret_cast< Reference< util::XRefreshable > * >(0)),
196 : : beans::PropertyAttribute::BOUND
197 [ + - ]: 14 : | beans::PropertyAttribute::MAYBEVOID ));
198 : : rOutProperties.push_back(
199 : : Property( "BaseDiagram",
200 : : PROP_DOCUMENT_BASEDIAGRAM,
201 [ + - ]: 14 : ::getCppuType( reinterpret_cast< const ::rtl::OUString * >(0)),
202 : : beans::PropertyAttribute::BOUND
203 [ + - ]: 14 : | beans::PropertyAttribute::MAYBEVOID ));
204 : : rOutProperties.push_back(
205 : : Property( "AdditionalShapes",
206 : : PROP_DOCUMENT_ADDITIONAL_SHAPES,
207 [ + - ]: 14 : ::getCppuType( reinterpret_cast< Reference< drawing::XShapes > * >(0)),
208 : : beans::PropertyAttribute::BOUND
209 : : | beans::PropertyAttribute::MAYBEVOID
210 [ + - ]: 14 : | beans::PropertyAttribute::READONLY ));
211 : : rOutProperties.push_back(
212 : : Property( "RefreshAddInAllowed",
213 : : PROP_DOCUMENT_UPDATE_ADDIN,
214 : 14 : ::getBooleanCppuType(),
215 : : //#i111967# no PropertyChangeEvent is fired on change so far
216 [ + - ]: 14 : beans::PropertyAttribute::TRANSIENT ));
217 : :
218 : : // table:null-date // i99104
219 : : rOutProperties.push_back(
220 : : Property( "NullDate",
221 : : PROP_DOCUMENT_NULL_DATE,
222 : 14 : ::getCppuType( static_cast< const ::com::sun::star::util::DateTime * >(0)),
223 [ + - ]: 14 : beans::PropertyAttribute::MAYBEVOID ));
224 : :
225 : : rOutProperties.push_back(
226 : : Property( "DisableComplexChartTypes",
227 : : PROP_DOCUMENT_DISABLE_COMPLEX_CHARTTYPES,
228 : 14 : ::getBooleanCppuType(),
229 : : //#i112666# no PropertyChangeEvent is fired on change so far
230 [ + - ]: 14 : beans::PropertyAttribute::MAYBEDEFAULT ) );
231 : : rOutProperties.push_back(
232 : : Property( "DisableDataTableDialog",
233 : : PROP_DOCUMENT_DISABLE_DATATABLE_DIALOG,
234 : 14 : ::getBooleanCppuType(),
235 : : //#i112666# no PropertyChangeEvent is fired on change so far
236 [ + - ]: 14 : beans::PropertyAttribute::MAYBEDEFAULT ) );
237 : 14 : }
238 : :
239 : : struct StaticChartDocumentWrapperPropertyArray_Initializer
240 : : {
241 : 14 : Sequence< Property >* operator()()
242 : : {
243 [ + - ][ + - ]: 14 : static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
[ + - ][ # # ]
244 : 14 : return &aPropSeq;
245 : : }
246 : :
247 : : private:
248 : 14 : uno::Sequence< Property > lcl_GetPropertySequence()
249 : : {
250 [ + - ]: 14 : ::std::vector< ::com::sun::star::beans::Property > aProperties;
251 [ + - ]: 14 : lcl_AddPropertiesToVector( aProperties );
252 : :
253 : : ::std::sort( aProperties.begin(), aProperties.end(),
254 [ + - ]: 14 : ::chart::PropertyNameLess() );
255 : :
256 [ + - ]: 14 : return ::chart::ContainerHelper::ContainerToSequence( aProperties );
257 : : }
258 : : };
259 : :
260 : : struct StaticChartDocumentWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticChartDocumentWrapperPropertyArray_Initializer >
261 : : {
262 : : };
263 : :
264 : : } // anonymous namespace
265 : :
266 : : namespace chart
267 : : {
268 : : namespace wrapper
269 : : {
270 : : //-----------------------------------------------------------------------------------------------------------------
271 : :
272 : :
273 : : //PROP_DOCUMENT_LABELS_IN_FIRST_ROW
274 : : class WrappedDataSourceLabelsInFirstRowProperty : public WrappedProperty
275 : : {
276 : : public:
277 : : WrappedDataSourceLabelsInFirstRowProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact );
278 : : virtual ~WrappedDataSourceLabelsInFirstRowProperty();
279 : :
280 : : virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
281 : : throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
282 : :
283 : : virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
284 : : throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
285 : :
286 : : virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const
287 : : throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
288 : :
289 : : private: //member
290 : : ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
291 : : mutable Any m_aOuterValue;
292 : : };
293 : :
294 : 56 : WrappedDataSourceLabelsInFirstRowProperty::WrappedDataSourceLabelsInFirstRowProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
295 : : : WrappedProperty("DataSourceLabelsInFirstRow",OUString())
296 : : , m_spChart2ModelContact( spChart2ModelContact )
297 [ + - ][ + - ]: 56 : , m_aOuterValue()
298 : : {
299 [ + - ][ + - ]: 56 : m_aOuterValue = WrappedDataSourceLabelsInFirstRowProperty::getPropertyDefault( 0 );
300 : 56 : }
301 : :
302 [ + - ]: 56 : WrappedDataSourceLabelsInFirstRowProperty::~WrappedDataSourceLabelsInFirstRowProperty()
303 : : {
304 [ - + ]: 112 : }
305 : :
306 : 2 : void WrappedDataSourceLabelsInFirstRowProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
307 : : throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
308 : : {
309 : 2 : sal_Bool bLabelsInFirstRow = sal_True;
310 [ - + ]: 2 : if( ! (rOuterValue >>= bLabelsInFirstRow) )
311 [ # # ][ # # ]: 0 : throw lang::IllegalArgumentException("Property DataSourceLabelsInFirstRow requires value of type boolean", 0, 0 );
312 : :
313 : 2 : m_aOuterValue = rOuterValue;
314 : 2 : bool bNewValue = bLabelsInFirstRow;
315 : :
316 : 2 : ::rtl::OUString aRangeString;
317 : 2 : bool bUseColumns = true;
318 : 2 : bool bFirstCellAsLabel = true;
319 : 2 : bool bHasCategories = true;
320 [ + - ]: 2 : uno::Sequence< sal_Int32 > aSequenceMapping;
321 : :
322 [ + - + - ]: 4 : if( DataSourceHelper::detectRangeSegmentation(
323 : : m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns
324 [ + - ]: 4 : , bFirstCellAsLabel, bHasCategories ) )
325 : : {
326 [ + - ][ + - ]: 2 : if( bUseColumns && bNewValue != bFirstCellAsLabel )
327 : : {
328 : : DataSourceHelper::setRangeSegmentation(
329 [ + - ][ + - ]: 2 : m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns ,bNewValue, bHasCategories );
330 : : }
331 [ # # ][ # # ]: 0 : else if( !bUseColumns && bNewValue != bHasCategories )
332 : : {
333 : : DataSourceHelper::setRangeSegmentation(
334 [ # # ][ # # ]: 2 : m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns , bFirstCellAsLabel, bNewValue );
335 : : }
336 [ + - ]: 2 : }
337 : 2 : }
338 : :
339 : 13 : Any WrappedDataSourceLabelsInFirstRowProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
340 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
341 : : {
342 : 13 : ::rtl::OUString aRangeString;
343 : 13 : bool bUseColumns = true;
344 : 13 : bool bFirstCellAsLabel = true;
345 : 13 : bool bHasCategories = true;
346 [ + - ]: 13 : uno::Sequence< sal_Int32 > aSequenceMapping;
347 : :
348 [ + - + - ]: 26 : if( DataSourceHelper::detectRangeSegmentation(
349 : : m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns
350 [ + - ]: 26 : , bFirstCellAsLabel, bHasCategories ) )
351 : : {
352 : 13 : sal_Bool bLabelsInFirstRow = sal_True;
353 [ + - ]: 13 : if( bUseColumns )
354 : 13 : bLabelsInFirstRow = bFirstCellAsLabel;
355 : : else
356 : 0 : bLabelsInFirstRow = bHasCategories;
357 : :
358 [ + - ]: 13 : m_aOuterValue <<= bLabelsInFirstRow;
359 : : }
360 [ + - ]: 13 : return m_aOuterValue;
361 : : }
362 : :
363 : 56 : Any WrappedDataSourceLabelsInFirstRowProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
364 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
365 : : {
366 : 56 : Any aRet;
367 [ + - ]: 56 : aRet <<= sal_True;
368 : 56 : return aRet;
369 : : }
370 : :
371 : : //-----------------------------------------------------------------------------------------------------------------
372 : :
373 : :
374 : : //PROP_DOCUMENT_LABELS_IN_FIRST_COLUMN
375 : : class WrappedDataSourceLabelsInFirstColumnProperty : public WrappedProperty
376 : : {
377 : : public:
378 : : WrappedDataSourceLabelsInFirstColumnProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact );
379 : : virtual ~WrappedDataSourceLabelsInFirstColumnProperty();
380 : :
381 : : virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
382 : : throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
383 : :
384 : : virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
385 : : throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
386 : :
387 : : virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const
388 : : throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
389 : :
390 : : private: //member
391 : : ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
392 : : mutable Any m_aOuterValue;
393 : : };
394 : :
395 : 56 : WrappedDataSourceLabelsInFirstColumnProperty::WrappedDataSourceLabelsInFirstColumnProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
396 : : : WrappedProperty("DataSourceLabelsInFirstColumn",OUString())
397 : : , m_spChart2ModelContact( spChart2ModelContact )
398 [ + - ][ + - ]: 56 : , m_aOuterValue()
399 : : {
400 [ + - ][ + - ]: 56 : m_aOuterValue = WrappedDataSourceLabelsInFirstColumnProperty::getPropertyDefault( 0 );
401 : 56 : }
402 : :
403 [ + - ]: 56 : WrappedDataSourceLabelsInFirstColumnProperty::~WrappedDataSourceLabelsInFirstColumnProperty()
404 : : {
405 [ - + ]: 112 : }
406 : :
407 : 4 : void WrappedDataSourceLabelsInFirstColumnProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
408 : : throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
409 : : {
410 : 4 : sal_Bool bLabelsInFirstRow = sal_True;
411 [ - + ]: 4 : if( ! (rOuterValue >>= bLabelsInFirstRow) )
412 [ # # ][ # # ]: 0 : throw lang::IllegalArgumentException("Property DataSourceLabelsInFirstRow requires value of type boolean", 0, 0 );
413 : :
414 : 4 : m_aOuterValue = rOuterValue;
415 : 4 : bool bNewValue = bLabelsInFirstRow;
416 : :
417 : 4 : ::rtl::OUString aRangeString;
418 : 4 : bool bUseColumns = true;
419 : 4 : bool bFirstCellAsLabel = true;
420 : 4 : bool bHasCategories = true;
421 [ + - ]: 4 : uno::Sequence< sal_Int32 > aSequenceMapping;
422 : :
423 [ + - + - ]: 8 : if( DataSourceHelper::detectRangeSegmentation(
424 : : m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns
425 [ + - ]: 8 : , bFirstCellAsLabel, bHasCategories ) )
426 : : {
427 [ + - ][ + - ]: 4 : if( bUseColumns && bNewValue != bHasCategories )
428 : : {
429 : : DataSourceHelper::setRangeSegmentation(
430 [ + - ][ + - ]: 4 : m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns, bFirstCellAsLabel, bNewValue );
431 : : }
432 [ # # ][ # # ]: 0 : else if( !bUseColumns && bNewValue != bFirstCellAsLabel )
433 : : {
434 : : DataSourceHelper::setRangeSegmentation(
435 [ # # ][ # # ]: 4 : m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns , bNewValue, bHasCategories );
436 : : }
437 [ + - ]: 4 : }
438 : 4 : }
439 : :
440 : 19 : Any WrappedDataSourceLabelsInFirstColumnProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
441 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
442 : : {
443 : 19 : ::rtl::OUString aRangeString;
444 : 19 : bool bUseColumns = true;
445 : 19 : bool bFirstCellAsLabel = true;
446 : 19 : bool bHasCategories = true;
447 [ + - ]: 19 : uno::Sequence< sal_Int32 > aSequenceMapping;
448 : :
449 [ + - + - ]: 38 : if( DataSourceHelper::detectRangeSegmentation(
450 : : m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns
451 [ + - ]: 38 : , bFirstCellAsLabel, bHasCategories ) )
452 : : {
453 : 19 : sal_Bool bLabelsInFirstColumn = sal_True;
454 [ + - ]: 19 : if( bUseColumns )
455 : 19 : bLabelsInFirstColumn = bHasCategories;
456 : : else
457 : 0 : bLabelsInFirstColumn = bFirstCellAsLabel;
458 : :
459 [ + - ]: 19 : m_aOuterValue <<= bLabelsInFirstColumn;
460 : : }
461 [ + - ]: 19 : return m_aOuterValue;
462 : : }
463 : :
464 : 56 : Any WrappedDataSourceLabelsInFirstColumnProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
465 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
466 : : {
467 : 56 : Any aRet;
468 [ + - ]: 56 : aRet <<= sal_True;
469 : 56 : return aRet;
470 : : }
471 : :
472 : : //-----------------------------------------------------------------------------------------------------------------
473 : :
474 : :
475 : : //PROP_DOCUMENT_HAS_LEGEND
476 : : class WrappedHasLegendProperty : public WrappedProperty
477 : : {
478 : : public:
479 : : WrappedHasLegendProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact );
480 : : virtual ~WrappedHasLegendProperty();
481 : :
482 : : virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
483 : : throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
484 : :
485 : : virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
486 : : throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
487 : :
488 : : virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const
489 : : throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
490 : :
491 : : private: //member
492 : : ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
493 : : };
494 : :
495 : 56 : WrappedHasLegendProperty::WrappedHasLegendProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
496 : : : WrappedProperty("HasLegend",OUString())
497 [ + - ][ + - ]: 56 : , m_spChart2ModelContact( spChart2ModelContact )
498 : : {
499 : 56 : }
500 : :
501 [ + - ]: 56 : WrappedHasLegendProperty::~WrappedHasLegendProperty()
502 : : {
503 [ - + ]: 112 : }
504 : :
505 : 12 : void WrappedHasLegendProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
506 : : throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
507 : : {
508 : 12 : sal_Bool bNewValue = sal_True;
509 [ - + ]: 12 : if( ! (rOuterValue >>= bNewValue) )
510 [ # # ][ # # ]: 0 : throw lang::IllegalArgumentException("Property HasLegend requires value of type boolean", 0, 0 );
511 : :
512 : : try
513 : : {
514 [ + - ][ + - ]: 12 : Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext,bNewValue ));
515 [ + - ]: 12 : if(xLegend.is())
516 : : {
517 [ + - ]: 12 : Reference< beans::XPropertySet > xLegendProp( xLegend, uno::UNO_QUERY_THROW );
518 : 12 : sal_Bool bOldValue = sal_True;
519 [ + - ][ + - ]: 12 : Any aAOld = xLegendProp->getPropertyValue("Show");
520 : 12 : aAOld >>= bOldValue;
521 [ + + ]: 12 : if( bOldValue != bNewValue )
522 [ + - ][ + - ]: 12 : xLegendProp->setPropertyValue("Show", uno::makeAny( bNewValue ));
[ + - ]
523 [ # # ]: 12 : }
524 : : }
525 [ # # ]: 0 : catch (const uno::Exception& ex)
526 : : {
527 : : ASSERT_EXCEPTION( ex );
528 : : }
529 : 12 : }
530 : :
531 : 32 : Any WrappedHasLegendProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
532 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
533 : : {
534 : 32 : Any aRet;
535 : : try
536 : : {
537 : : Reference< beans::XPropertySet > xLegendProp(
538 [ + - ][ + - ]: 32 : LegendHelper::getLegend( m_spChart2ModelContact->getChartModel() ), uno::UNO_QUERY );
[ + - ][ + - ]
539 [ + - ]: 32 : if( xLegendProp.is())
540 [ + - ][ + - ]: 32 : aRet = xLegendProp->getPropertyValue("Show");
541 : : else
542 [ # # ][ # # ]: 32 : aRet <<= sal_False;
543 : : }
544 [ # # ]: 0 : catch (const uno::Exception& ex)
545 : : {
546 : : ASSERT_EXCEPTION( ex );
547 : : }
548 : 32 : return aRet;
549 : : }
550 : :
551 : 0 : Any WrappedHasLegendProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
552 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
553 : : {
554 : 0 : Any aRet;
555 [ # # ]: 0 : aRet <<= sal_False;
556 : 0 : return aRet;
557 : : }
558 : :
559 : : //-----------------------------------------------------------------------------------------------------------------
560 : :
561 : :
562 : : //PROP_DOCUMENT_HAS_MAIN_TITLE
563 : : class WrappedHasMainTitleProperty : public WrappedProperty
564 : : {
565 : : public:
566 : : WrappedHasMainTitleProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact );
567 : : virtual ~WrappedHasMainTitleProperty();
568 : :
569 : : virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
570 : : throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
571 : :
572 : : virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
573 : : throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
574 : :
575 : : virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const
576 : : throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
577 : :
578 : : private: //member
579 : : ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
580 : : };
581 : :
582 : 56 : WrappedHasMainTitleProperty::WrappedHasMainTitleProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
583 : : : WrappedProperty("HasMainTitle",OUString())
584 [ + - ][ + - ]: 56 : , m_spChart2ModelContact( spChart2ModelContact )
585 : : {
586 : 56 : }
587 : :
588 [ + - ]: 56 : WrappedHasMainTitleProperty::~WrappedHasMainTitleProperty()
589 : : {
590 [ - + ]: 112 : }
591 : :
592 : 12 : void WrappedHasMainTitleProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
593 : : throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
594 : : {
595 : 12 : sal_Bool bNewValue = sal_True;
596 [ - + ]: 12 : if( ! (rOuterValue >>= bNewValue) )
597 [ # # ][ # # ]: 0 : throw lang::IllegalArgumentException("Property HasMainTitle requires value of type boolean", 0, 0 );
598 : :
599 : : try
600 : : {
601 [ + + ]: 12 : if( bNewValue )
602 [ + - ][ + - ]: 8 : TitleHelper::createTitle( TitleHelper::MAIN_TITLE, "main-title", m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext );
603 : : else
604 [ + - ][ + - ]: 4 : TitleHelper::removeTitle( TitleHelper::MAIN_TITLE, m_spChart2ModelContact->getChartModel() );
[ # # ]
605 : : }
606 [ # # ]: 0 : catch (const uno::Exception& ex)
607 : : {
608 : : ASSERT_EXCEPTION( ex );
609 : : }
610 : 12 : }
611 : :
612 : 35 : Any WrappedHasMainTitleProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
613 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
614 : : {
615 : 35 : Any aRet;
616 : : try
617 : : {
618 [ + - ][ + - ]: 35 : aRet <<= sal_Bool( TitleHelper::getTitle( TitleHelper::MAIN_TITLE, m_spChart2ModelContact->getChartModel() ).is() );
[ # # ][ + - ]
619 : : }
620 [ # # ]: 0 : catch (const uno::Exception& ex)
621 : : {
622 : : ASSERT_EXCEPTION( ex );
623 : : }
624 : 35 : return aRet;
625 : : }
626 : :
627 : 0 : Any WrappedHasMainTitleProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
628 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
629 : : {
630 : 0 : Any aRet;
631 [ # # ]: 0 : aRet <<= sal_False;
632 : 0 : return aRet;
633 : : }
634 : :
635 : : //-----------------------------------------------------------------------------------------------------------------
636 : :
637 : :
638 : : //PROP_DOCUMENT_HAS_SUB_TITLE
639 : : class WrappedHasSubTitleProperty : public WrappedProperty
640 : : {
641 : : public:
642 : : WrappedHasSubTitleProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact );
643 : : virtual ~WrappedHasSubTitleProperty();
644 : :
645 : : virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
646 : : throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
647 : :
648 : : virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
649 : : throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
650 : :
651 : : virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const
652 : : throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
653 : :
654 : : private: //member
655 : : ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
656 : : };
657 : :
658 : 56 : WrappedHasSubTitleProperty::WrappedHasSubTitleProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
659 : : : WrappedProperty("HasSubTitle",OUString())
660 [ + - ][ + - ]: 56 : , m_spChart2ModelContact( spChart2ModelContact )
661 : : {
662 : 56 : }
663 : :
664 [ + - ]: 56 : WrappedHasSubTitleProperty::~WrappedHasSubTitleProperty()
665 : : {
666 [ - + ]: 112 : }
667 : :
668 : 12 : void WrappedHasSubTitleProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
669 : : throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
670 : : {
671 : 12 : sal_Bool bNewValue = sal_True;
672 [ - + ]: 12 : if( ! (rOuterValue >>= bNewValue) )
673 [ # # ][ # # ]: 0 : throw lang::IllegalArgumentException("Property HasSubTitle requires value of type boolean", 0, 0 );
674 : :
675 : :
676 : : try
677 : : {
678 [ + + ]: 12 : if( bNewValue )
679 [ + - ][ + - ]: 10 : TitleHelper::createTitle( TitleHelper::SUB_TITLE, "sub-title", m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext );
680 : : else
681 [ + - ][ + - ]: 2 : TitleHelper::removeTitle( TitleHelper::SUB_TITLE, m_spChart2ModelContact->getChartModel() );
[ # # ]
682 : : }
683 [ # # ]: 0 : catch (const uno::Exception& ex)
684 : : {
685 : : ASSERT_EXCEPTION( ex );
686 : : }
687 : 12 : }
688 : :
689 : 32 : Any WrappedHasSubTitleProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
690 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
691 : : {
692 : 32 : Any aRet;
693 : : try
694 : : {
695 [ + - ][ + - ]: 32 : aRet <<= sal_Bool( TitleHelper::getTitle( TitleHelper::SUB_TITLE, m_spChart2ModelContact->getChartModel() ).is() );
[ # # ][ + - ]
696 : : }
697 [ # # ]: 0 : catch (const uno::Exception& ex)
698 : : {
699 : : ASSERT_EXCEPTION( ex );
700 : : }
701 : 32 : return aRet;
702 : : }
703 : :
704 : 0 : Any WrappedHasSubTitleProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
705 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
706 : : {
707 : 0 : Any aRet;
708 [ # # ]: 0 : aRet <<= sal_False;
709 : 0 : return aRet;
710 : : }
711 : :
712 : : //-----------------------------------------------------------------------------------------------------------------
713 : :
714 : 56 : ChartDocumentWrapper::ChartDocumentWrapper(
715 : : const Reference< uno::XComponentContext > & xContext ) :
716 [ + - ]: 56 : m_spChart2ModelContact( new Chart2ModelContact( xContext ) ),
717 : : m_bUpdateAddIn( sal_True ),
718 [ + - ][ + - ]: 112 : m_bIsDisposed( false )
[ + - ]
719 : : {
720 : 56 : }
721 : :
722 [ + - ][ + - ]: 56 : ChartDocumentWrapper::~ChartDocumentWrapper()
723 : : {
724 [ + - ]: 56 : stopAllComponentListening();
725 [ - + ]: 112 : }
726 : :
727 : : // ____ XInterface (for new interfaces) ____
728 : 28966 : uno::Any SAL_CALL ChartDocumentWrapper::queryInterface( const uno::Type& aType )
729 : : throw (uno::RuntimeException)
730 : : {
731 [ + + ]: 28966 : if( m_xDelegator.is())
732 : : // calls queryAggregation if the delegator doesn't know aType
733 : 28906 : return m_xDelegator->queryInterface( aType );
734 : : else
735 : 28966 : return queryAggregation( aType );
736 : : }
737 : :
738 : : // ____ chart::XChartDocument (old API wrapper) ____
739 : 25 : Reference< drawing::XShape > SAL_CALL ChartDocumentWrapper::getTitle()
740 : : throw (uno::RuntimeException)
741 : : {
742 [ + + ]: 25 : if( !m_xTitle.is() )
743 : : {
744 [ + - ][ + - ]: 19 : ControllerLockGuard aCtrlLockGuard( Reference< frame::XModel >( m_spChart2ModelContact->getChart2Document(), uno::UNO_QUERY ));
[ + - ]
745 [ + - ][ + - ]: 19 : m_xTitle = new TitleWrapper( TitleHelper::MAIN_TITLE, m_spChart2ModelContact );
[ + - ][ + - ]
[ + - ][ + - ]
746 : : }
747 : 25 : return m_xTitle;
748 : : }
749 : :
750 : 12 : Reference< drawing::XShape > SAL_CALL ChartDocumentWrapper::getSubTitle()
751 : : throw (uno::RuntimeException)
752 : : {
753 [ + + ]: 12 : if( !m_xSubTitle.is() )
754 : : {
755 [ + - ][ + - ]: 6 : ControllerLockGuard aCtrlLockGuard( Reference< frame::XModel >( m_spChart2ModelContact->getChart2Document(), uno::UNO_QUERY ));
[ + - ]
756 [ + - ][ + - ]: 6 : m_xSubTitle = new TitleWrapper( TitleHelper::SUB_TITLE, m_spChart2ModelContact );
[ + - ][ + - ]
[ + - ][ + - ]
757 : : }
758 : 12 : return m_xSubTitle;
759 : : }
760 : :
761 : 37 : Reference< drawing::XShape > SAL_CALL ChartDocumentWrapper::getLegend()
762 : : throw (uno::RuntimeException)
763 : : {
764 [ + + ]: 37 : if( ! m_xLegend.is())
765 : : {
766 [ + - ][ + - ]: 15 : m_xLegend = new LegendWrapper( m_spChart2ModelContact );
[ + - ][ + - ]
[ + - ]
767 [ + - ]: 15 : Reference< lang::XComponent > xComp( m_xLegend, uno::UNO_QUERY );
768 : : }
769 : :
770 : 37 : return m_xLegend;
771 : : }
772 : :
773 : 28 : Reference< beans::XPropertySet > SAL_CALL ChartDocumentWrapper::getArea()
774 : : throw (uno::RuntimeException)
775 : : {
776 [ + + ]: 28 : if( ! m_xArea.is())
777 : : {
778 [ + - ][ + - ]: 15 : m_xArea.set( new AreaWrapper( m_spChart2ModelContact ) );
[ + - ][ + - ]
[ + - ]
779 [ + - ]: 15 : Reference< lang::XComponent > xComp( m_xArea, uno::UNO_QUERY );
780 : : }
781 : :
782 : 28 : return m_xArea;
783 : : }
784 : :
785 : 1110 : Reference< XDiagram > SAL_CALL ChartDocumentWrapper::getDiagram()
786 : : throw (uno::RuntimeException)
787 : : {
788 [ + + ]: 1110 : if( !m_xDiagram.is() )
789 : : {
790 : : try
791 : : {
792 [ + - ][ + - ]: 54 : m_xDiagram = new DiagramWrapper( m_spChart2ModelContact );
[ + - ][ + - ]
[ + - ][ # # ]
793 : : }
794 : 0 : catch (const uno::Exception& ex)
795 : : {
796 : : ASSERT_EXCEPTION( ex );
797 : : }
798 : : }
799 : :
800 : 1110 : return m_xDiagram;
801 : : }
802 : :
803 : 28 : void SAL_CALL ChartDocumentWrapper::setDiagram( const Reference< XDiagram >& xDiagram )
804 : : throw (uno::RuntimeException)
805 : : {
806 [ + - ]: 28 : uno::Reference< util::XRefreshable > xAddIn( xDiagram, uno::UNO_QUERY );
807 [ - + ]: 28 : if( xAddIn.is() )
808 : : {
809 [ # # ]: 0 : setAddIn( xAddIn );
810 : : }
811 [ + - ][ + - ]: 28 : else if( xDiagram.is() && xDiagram != m_xDiagram )
[ + - ][ + - ]
812 : : {
813 : : // set new wrapped diagram at new chart. This requires the old
814 : : // diagram given as parameter to implement the new interface. If
815 : : // this is not possible throw an exception
816 [ + - ]: 28 : Reference< chart2::XDiagramProvider > xNewDiaProvider( xDiagram, uno::UNO_QUERY_THROW );
817 [ + - ][ + - ]: 28 : Reference< chart2::XDiagram > xNewDia( xNewDiaProvider->getDiagram());
818 : :
819 : : try
820 : : {
821 [ + - ]: 28 : Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
822 [ + - ]: 28 : if( xChartDoc.is() )
823 : : {
824 : : // set the new diagram
825 [ + - ][ + - ]: 28 : xChartDoc->setFirstDiagram( xNewDia );
826 [ + - ]: 28 : m_xDiagram = xDiagram;
827 [ # # ]: 28 : }
828 : : }
829 [ # # ]: 0 : catch (const uno::Exception& ex)
830 : : {
831 : : ASSERT_EXCEPTION( ex );
832 : 28 : }
833 : 28 : }
834 : 28 : }
835 : :
836 : 23 : Reference< XChartData > SAL_CALL ChartDocumentWrapper::getData()
837 : : throw (uno::RuntimeException)
838 : : {
839 [ + + ]: 23 : if( !m_xChartData.is() )
840 : : {
841 [ + - ][ + - ]: 21 : m_xChartData.set( new ChartDataWrapper( m_spChart2ModelContact ) );
[ + - ]
842 : : }
843 : : //@todo: check hasInternalDataProvider also in else?
844 : :
845 : 23 : return m_xChartData;
846 : : }
847 : :
848 : 0 : void SAL_CALL ChartDocumentWrapper::attachData( const Reference< XChartData >& xNewData )
849 : : throw (uno::RuntimeException)
850 : : {
851 [ # # ]: 0 : if( !xNewData.is() )
852 : 0 : return;
853 : :
854 : : // /-- locked controllers
855 [ # # ][ # # ]: 0 : ControllerLockGuard aCtrlLockGuard( Reference< frame::XModel >( m_spChart2ModelContact->getChart2Document(), uno::UNO_QUERY ));
[ # # ]
856 [ # # ][ # # ]: 0 : m_xChartData.set( new ChartDataWrapper( m_spChart2ModelContact, xNewData ) );
[ # # ][ # # ]
[ # # ][ # # ]
857 : : // \-- locked controllers
858 : : }
859 : :
860 : : // ____ XModel ____
861 : 0 : sal_Bool SAL_CALL ChartDocumentWrapper::attachResource(
862 : : const ::rtl::OUString& URL,
863 : : const Sequence< beans::PropertyValue >& Arguments )
864 : : throw (uno::RuntimeException)
865 : : {
866 [ # # ]: 0 : Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
867 [ # # ]: 0 : if( xModel.is() )
868 [ # # ][ # # ]: 0 : return xModel->attachResource( URL, Arguments );
869 : 0 : return sal_False;
870 : : }
871 : :
872 : 0 : ::rtl::OUString SAL_CALL ChartDocumentWrapper::getURL()
873 : : throw (uno::RuntimeException)
874 : : {
875 [ # # ]: 0 : Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
876 [ # # ]: 0 : if( xModel.is() )
877 [ # # ][ # # ]: 0 : return xModel->getURL();
878 : 0 : return ::rtl::OUString();
879 : : }
880 : :
881 : 0 : Sequence< beans::PropertyValue > SAL_CALL ChartDocumentWrapper::getArgs()
882 : : throw (uno::RuntimeException)
883 : : {
884 [ # # ]: 0 : Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
885 [ # # ]: 0 : if( xModel.is() )
886 [ # # ][ # # ]: 0 : return xModel->getArgs();
887 [ # # ]: 0 : return Sequence< beans::PropertyValue >();
888 : : }
889 : :
890 : 0 : void SAL_CALL ChartDocumentWrapper::connectController( const Reference< frame::XController >& Controller )
891 : : throw (uno::RuntimeException)
892 : : {
893 [ # # ]: 0 : Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
894 [ # # ]: 0 : if( xModel.is() )
895 [ # # ][ # # ]: 0 : xModel->connectController( Controller );
896 : 0 : }
897 : :
898 : 0 : void SAL_CALL ChartDocumentWrapper::disconnectController(
899 : : const Reference< frame::XController >& Controller )
900 : : throw (uno::RuntimeException)
901 : : {
902 [ # # ]: 0 : Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
903 [ # # ]: 0 : if( xModel.is() )
904 [ # # ][ # # ]: 0 : xModel->disconnectController( Controller );
905 : 0 : }
906 : :
907 : 8 : void SAL_CALL ChartDocumentWrapper::lockControllers()
908 : : throw (uno::RuntimeException)
909 : : {
910 [ + - ]: 8 : Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
911 [ + - ]: 8 : if( xModel.is() )
912 [ + - ][ + - ]: 8 : xModel->lockControllers();
913 : 8 : }
914 : :
915 : 8 : void SAL_CALL ChartDocumentWrapper::unlockControllers()
916 : : throw (uno::RuntimeException)
917 : : {
918 [ + - ]: 8 : Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
919 [ + - ]: 8 : if( xModel.is() )
920 [ + - ][ + - ]: 8 : xModel->unlockControllers();
921 : 8 : }
922 : :
923 : 0 : sal_Bool SAL_CALL ChartDocumentWrapper::hasControllersLocked()
924 : : throw (uno::RuntimeException)
925 : : {
926 [ # # ]: 0 : Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
927 [ # # ]: 0 : if( xModel.is() )
928 [ # # ][ # # ]: 0 : return xModel->hasControllersLocked();
929 : 0 : return sal_False;
930 : : }
931 : :
932 : 8 : Reference< frame::XController > SAL_CALL ChartDocumentWrapper::getCurrentController()
933 : : throw (uno::RuntimeException)
934 : : {
935 [ + - ]: 8 : Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
936 [ + - ]: 8 : if( xModel.is() )
937 [ + - ][ + - ]: 8 : return xModel->getCurrentController();
938 [ # # ]: 8 : return 0;
939 : : }
940 : :
941 : 0 : void SAL_CALL ChartDocumentWrapper::setCurrentController(
942 : : const Reference< frame::XController >& Controller )
943 : : throw (container::NoSuchElementException,
944 : : uno::RuntimeException)
945 : : {
946 [ # # ]: 0 : Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
947 [ # # ]: 0 : if( xModel.is() )
948 [ # # ][ # # ]: 0 : xModel->setCurrentController( Controller );
949 : 0 : }
950 : :
951 : 0 : Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::getCurrentSelection()
952 : : throw (uno::RuntimeException)
953 : : {
954 [ # # ]: 0 : Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
955 [ # # ]: 0 : if( xModel.is() )
956 [ # # ][ # # ]: 0 : return xModel->getCurrentSelection();
957 [ # # ]: 0 : return 0;
958 : : }
959 : :
960 : :
961 : : // ____ XComponent ____
962 : 56 : void SAL_CALL ChartDocumentWrapper::dispose()
963 : : throw (uno::RuntimeException)
964 : : {
965 [ - + ]: 56 : if( m_bIsDisposed )
966 : : throw lang::DisposedException("ChartDocumentWrapper is disposed",
967 [ # # ][ # # ]: 0 : static_cast< ::cppu::OWeakObject* >( this ));
[ # # ]
968 : :
969 : 56 : m_bIsDisposed = true;
970 : :
971 : : try
972 : : {
973 [ + - ]: 56 : Reference< lang::XComponent > xFormerDelegator( m_xDelegator, uno::UNO_QUERY );
974 [ + - ]: 56 : DisposeHelper::DisposeAndClear( m_xTitle );
975 [ + - ]: 56 : DisposeHelper::DisposeAndClear( m_xSubTitle );
976 [ + - ]: 56 : DisposeHelper::DisposeAndClear( m_xLegend );
977 [ + - ]: 56 : DisposeHelper::DisposeAndClear( m_xChartData );
978 [ + - ]: 56 : DisposeHelper::DisposeAndClear( m_xDiagram );
979 [ + - ]: 56 : DisposeHelper::DisposeAndClear( m_xArea );
980 [ + - ]: 56 : m_xChartView.set( 0 );
981 [ + - ]: 56 : m_xShapeFactory.set( 0 );
982 [ + - ]: 56 : m_xDelegator.set( 0 );
983 : :
984 [ + - ]: 56 : clearWrappedPropertySet();
985 [ + - ]: 56 : m_spChart2ModelContact->clear();
986 [ + - ]: 56 : impl_resetAddIn();
987 : :
988 [ + - ]: 56 : stopAllComponentListening();
989 : :
990 : : try
991 : : {
992 [ + - ]: 56 : if( xFormerDelegator.is())
993 [ + - ][ + - ]: 56 : xFormerDelegator->dispose();
994 : : }
995 [ # # ]: 0 : catch (const lang::DisposedException&)
996 : : {
997 : : // this is ok, don't panic
998 [ # # ]: 56 : }
999 : : }
1000 : 0 : catch (const uno::Exception &ex)
1001 : : {
1002 : : ASSERT_EXCEPTION( ex );
1003 : : }
1004 : 56 : }
1005 : :
1006 : 56 : void ChartDocumentWrapper::impl_resetAddIn()
1007 : : {
1008 : 56 : Reference< util::XRefreshable > xAddIn( m_xAddIn );
1009 [ + - ]: 56 : m_xAddIn.set( 0 );
1010 : :
1011 [ - + ]: 56 : if( xAddIn.is() )
1012 : : {
1013 : : try
1014 : : {
1015 : : //make sure that the add-in does not hold a refernce to us anymore:
1016 [ # # ]: 0 : Reference< lang::XComponent > xComp( xAddIn, uno::UNO_QUERY );
1017 [ # # ]: 0 : if( xComp.is())
1018 [ # # ][ # # ]: 0 : xComp->dispose();
1019 : : else
1020 : : {
1021 [ # # ]: 0 : uno::Reference< lang::XInitialization > xInit( xAddIn, uno::UNO_QUERY );
1022 [ # # ]: 0 : if( xInit.is() )
1023 : : {
1024 : 0 : uno::Any aParam;
1025 [ # # ]: 0 : uno::Reference< com::sun::star::chart::XChartDocument > xDoc( 0 );
1026 [ # # ]: 0 : aParam <<= xDoc;
1027 [ # # ]: 0 : uno::Sequence< uno::Any > aSeq( &aParam, 1 );
1028 [ # # ][ # # ]: 0 : xInit->initialize( aSeq );
[ # # ]
1029 : 0 : }
1030 [ # # # ]: 0 : }
1031 : : }
1032 [ # # ]: 0 : catch (const uno::RuntimeException& ex)
1033 : : {
1034 : : ASSERT_EXCEPTION( ex );
1035 : : }
1036 [ # # ]: 0 : catch (const uno::Exception& ex)
1037 : : {
1038 : : ASSERT_EXCEPTION( ex );
1039 : : }
1040 : 56 : }
1041 : 56 : }
1042 : :
1043 : 0 : void ChartDocumentWrapper::setBaseDiagram( const rtl::OUString& rBaseDiagram )
1044 : : {
1045 [ # # ][ # # ]: 0 : ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() );
1046 : 0 : m_aBaseDiagram = rBaseDiagram;
1047 : :
1048 [ # # ][ # # ]: 0 : uno::Reference< XDiagram > xDiagram( ChartDocumentWrapper::createInstance( rBaseDiagram ), uno::UNO_QUERY );
1049 [ # # ]: 0 : if( xDiagram.is() )
1050 [ # # ][ # # ]: 0 : this->setDiagram( xDiagram );
1051 : 0 : }
1052 : :
1053 : 0 : rtl::OUString ChartDocumentWrapper::getBaseDiagram() const
1054 : : {
1055 : 0 : return m_aBaseDiagram;
1056 : : }
1057 : :
1058 : 878 : Reference< util::XRefreshable > ChartDocumentWrapper::getAddIn() const
1059 : : {
1060 : 878 : return m_xAddIn;
1061 : : }
1062 : :
1063 : 0 : void ChartDocumentWrapper::setAddIn( const Reference< util::XRefreshable >& xAddIn )
1064 : : {
1065 [ # # ][ # # ]: 0 : if( m_xAddIn == xAddIn )
1066 : 0 : return;
1067 : :
1068 [ # # ][ # # ]: 0 : ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() );
1069 [ # # ]: 0 : impl_resetAddIn();
1070 [ # # ]: 0 : m_xAddIn = xAddIn;
1071 : : // initialize AddIn with this as chart document
1072 [ # # ]: 0 : uno::Reference< lang::XInitialization > xInit( m_xAddIn, uno::UNO_QUERY );
1073 [ # # ]: 0 : if( xInit.is() )
1074 : : {
1075 : 0 : uno::Any aParam;
1076 [ # # ]: 0 : uno::Reference< XChartDocument > xDoc( (XChartDocument*)this, uno::UNO_QUERY );
1077 [ # # ]: 0 : aParam <<= xDoc;
1078 [ # # ]: 0 : uno::Sequence< uno::Any > aSeq( &aParam, 1 );
1079 [ # # ][ # # ]: 0 : xInit->initialize( aSeq );
[ # # ]
1080 [ # # ]: 0 : }
1081 : : }
1082 : :
1083 : 10 : void ChartDocumentWrapper::setUpdateAddIn( sal_Bool bUpdateAddIn )
1084 : : {
1085 : 10 : m_bUpdateAddIn = bUpdateAddIn;
1086 : 10 : }
1087 : 10 : sal_Bool ChartDocumentWrapper::getUpdateAddIn() const
1088 : : {
1089 : 10 : return m_bUpdateAddIn;
1090 : : }
1091 : :
1092 : 41 : Reference< drawing::XShapes > ChartDocumentWrapper::getAdditionalShapes() const
1093 : : {
1094 : : // get additional non-chart shapes for XML export
1095 : 41 : uno::Reference< drawing::XShapes > xFoundShapes;
1096 [ + - ]: 41 : uno::Reference< drawing::XDrawPage > xDrawPage( this->impl_getDrawPage() );
1097 : :
1098 [ + - ]: 41 : uno::Reference< drawing::XShapes > xDrawPageShapes( xDrawPage, uno::UNO_QUERY );
1099 [ + - ]: 41 : if( !xDrawPageShapes.is() )
1100 : : return xFoundShapes;
1101 : :
1102 [ + - ]: 41 : uno::Reference<drawing::XShapes> xChartRoot( DrawModelWrapper::getChartRootShape( xDrawPage ) );
1103 : :
1104 : : // iterate 'flat' over all top-level objects
1105 : : // and determine all that are no chart objects
1106 [ + - ]: 41 : ::std::vector< uno::Reference< drawing::XShape > > aShapeVector;
1107 [ + - ][ + - ]: 41 : sal_Int32 nSubCount = xDrawPageShapes->getCount();
1108 : 41 : uno::Reference< drawing::XShape > xShape;
1109 [ + + ]: 82 : for( sal_Int32 nS = 0; nS < nSubCount; nS++ )
1110 : : {
1111 [ + - ][ + - ]: 41 : if( xDrawPageShapes->getByIndex( nS ) >>= xShape )
[ + - ][ + - ]
1112 : : {
1113 [ + - ][ + - ]: 41 : if( xShape.is() && xChartRoot!=xShape )
[ - + ][ - + ]
1114 [ # # ]: 0 : aShapeVector.push_back( xShape );
1115 : : }
1116 : : }
1117 : :
1118 [ - + ]: 41 : if( !aShapeVector.empty() )
1119 : : {
1120 : : // create a shape collection
1121 [ # # ][ # # ]: 0 : xFoundShapes = uno::Reference< drawing::XShapes >( SvxShapeCollection_NewInstance(), uno::UNO_QUERY );
1122 : :
1123 : : OSL_ENSURE( xFoundShapes.is(), "Couldn't create a shape collection!" );
1124 [ # # ]: 0 : if( xFoundShapes.is())
1125 : : {
1126 : 0 : ::std::vector< uno::Reference< drawing::XShape > >::iterator aIter;
1127 [ # # ][ # # ]: 0 : for( aIter = aShapeVector.begin(); aIter != aShapeVector.end(); ++aIter )
1128 [ # # ][ # # ]: 0 : xFoundShapes->add( *aIter );
1129 : : }
1130 : : }
1131 : :
1132 : 41 : return xFoundShapes;
1133 : : }
1134 : :
1135 : 0 : void SAL_CALL ChartDocumentWrapper::addEventListener( const Reference< lang::XEventListener >& xListener )
1136 : : throw (uno::RuntimeException)
1137 : : {
1138 [ # # ]: 0 : Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
1139 [ # # ]: 0 : if( xModel.is() )
1140 [ # # ][ # # ]: 0 : xModel->addEventListener( xListener );
1141 : 0 : }
1142 : :
1143 : 0 : void SAL_CALL ChartDocumentWrapper::removeEventListener( const Reference< lang::XEventListener >& aListener )
1144 : : throw (uno::RuntimeException)
1145 : : {
1146 [ # # ]: 0 : Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
1147 [ # # ]: 0 : if( xModel.is() )
1148 [ # # ][ # # ]: 0 : xModel->removeEventListener( aListener );
1149 : 0 : }
1150 : :
1151 : : // ____ XDrawPageSupplier ____
1152 : 9 : uno::Reference< drawing::XDrawPage > SAL_CALL ChartDocumentWrapper::getDrawPage()
1153 : : throw (uno::RuntimeException)
1154 : : {
1155 : 9 : return this->impl_getDrawPage();
1156 : : }
1157 : :
1158 : 50 : uno::Reference< drawing::XDrawPage > ChartDocumentWrapper::impl_getDrawPage() const
1159 : : throw (uno::RuntimeException)
1160 : : {
1161 : 50 : return m_spChart2ModelContact->getDrawPage();
1162 : : }
1163 : :
1164 : : // ____ XMultiServiceFactory ____
1165 : 4808 : uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance(
1166 : : const ::rtl::OUString& aServiceSpecifier )
1167 : : throw (uno::Exception,
1168 : : uno::RuntimeException)
1169 : : {
1170 : 4808 : uno::Reference< uno::XInterface > xResult;
1171 : :
1172 [ + - ]: 4808 : Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
1173 [ + - ]: 4808 : if( !xChartDoc.is() )
1174 : : return xResult;
1175 : :
1176 : 4808 : bool bServiceFound = false;
1177 [ + - ]: 4808 : tServiceNameMap & rMap = lcl_getStaticServiceNameMap();
1178 : :
1179 [ + - ]: 4808 : tServiceNameMap::const_iterator aIt( rMap.find( aServiceSpecifier ));
1180 [ + + ]: 4808 : if( aIt != rMap.end())
1181 : : {
1182 : 32 : bool bCreateDiagram = false;
1183 : : uno::Reference< lang::XMultiServiceFactory > xManagerFact(
1184 [ + - ][ + - ]: 32 : xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
[ + - ]
1185 : 32 : uno::Reference< chart2::XChartTypeTemplate > xTemplate;
1186 : :
1187 [ - + - + : 32 : switch( (*aIt).second )
- - + + +
- - - - -
- ]
1188 : : {
1189 : : case SERVICE_NAME_AREA_DIAGRAM:
1190 [ # # ]: 0 : if( xManagerFact.is())
1191 : : {
1192 : : xTemplate.set(
1193 [ # # ]: 0 : xManagerFact->createInstance("com.sun.star.chart2.template.Area"),
1194 [ # # ][ # # ]: 0 : uno::UNO_QUERY );
1195 : 0 : bCreateDiagram = true;
1196 : : }
1197 : 0 : break;
1198 : : case SERVICE_NAME_BAR_DIAGRAM:
1199 [ + - ]: 12 : if( xManagerFact.is())
1200 : : {
1201 : : // this is for bar and column (the latter is the default if
1202 : : // no "Vertical=false" property was set)
1203 : : xTemplate.set(
1204 [ + - ]: 12 : xManagerFact->createInstance("com.sun.star.chart2.template.Column"),
1205 [ + - ][ + - ]: 12 : uno::UNO_QUERY );
1206 : 12 : bCreateDiagram = true;
1207 : : }
1208 : 12 : break;
1209 : : case SERVICE_NAME_DONUT_DIAGRAM:
1210 [ # # ]: 0 : if( xManagerFact.is())
1211 : : {
1212 : : xTemplate.set(
1213 [ # # ]: 0 : xManagerFact->createInstance("com.sun.star.chart2.template.Donut"),
1214 [ # # ][ # # ]: 0 : uno::UNO_QUERY );
1215 : 0 : bCreateDiagram = true;
1216 : : }
1217 : 0 : break;
1218 : : case SERVICE_NAME_LINE_DIAGRAM:
1219 [ + - ]: 6 : if( xManagerFact.is())
1220 : : {
1221 : : xTemplate.set(
1222 [ + - ]: 6 : xManagerFact->createInstance("com.sun.star.chart2.template.Line"),
1223 [ + - ][ + - ]: 6 : uno::UNO_QUERY );
1224 : 6 : bCreateDiagram = true;
1225 : : }
1226 : 6 : break;
1227 : : case SERVICE_NAME_NET_DIAGRAM:
1228 [ # # ]: 0 : if( xManagerFact.is())
1229 : : {
1230 : : xTemplate.set(
1231 [ # # ]: 0 : xManagerFact->createInstance("com.sun.star.chart2.template.Net"),
1232 [ # # ][ # # ]: 0 : uno::UNO_QUERY );
1233 : 0 : bCreateDiagram = true;
1234 : : }
1235 : 0 : break;
1236 : : case SERVICE_NAME_FILLED_NET_DIAGRAM:
1237 [ # # ]: 0 : if( xManagerFact.is())
1238 : : {
1239 : : xTemplate.set(
1240 [ # # ]: 0 : xManagerFact->createInstance("com.sun.star.chart2.template.FilledNet"),
1241 [ # # ][ # # ]: 0 : uno::UNO_QUERY );
1242 : 0 : bCreateDiagram = true;
1243 : : }
1244 : : case SERVICE_NAME_PIE_DIAGRAM:
1245 [ + - ]: 4 : if( xManagerFact.is())
1246 : : {
1247 : : xTemplate.set(
1248 [ + - ]: 4 : xManagerFact->createInstance("com.sun.star.chart2.template.Pie"),
1249 [ + - ][ + - ]: 4 : uno::UNO_QUERY );
1250 : 4 : bCreateDiagram = true;
1251 : : }
1252 : 4 : break;
1253 : : case SERVICE_NAME_STOCK_DIAGRAM:
1254 [ + - ]: 4 : if( xManagerFact.is())
1255 : : {
1256 : : xTemplate.set(
1257 [ + - ]: 4 : xManagerFact->createInstance("com.sun.star.chart2.template.StockLowHighClose"),
1258 [ + - ][ + - ]: 4 : uno::UNO_QUERY );
1259 : 4 : bCreateDiagram = true;
1260 : : }
1261 : 4 : break;
1262 : : case SERVICE_NAME_XY_DIAGRAM:
1263 [ + - ]: 6 : if( xManagerFact.is())
1264 : : {
1265 : : xTemplate.set(
1266 [ + - ]: 6 : xManagerFact->createInstance("com.sun.star.chart2.template.ScatterLineSymbol"),
1267 [ + - ][ + - ]: 6 : uno::UNO_QUERY );
1268 : 6 : bCreateDiagram = true;
1269 : : }
1270 : 6 : break;
1271 : :
1272 : : case SERVICE_NAME_BUBBLE_DIAGRAM:
1273 [ # # ]: 0 : if( xManagerFact.is())
1274 : : {
1275 : : xTemplate.set(
1276 [ # # ]: 0 : xManagerFact->createInstance("com.sun.star.chart2.template.Bubble"),
1277 [ # # ][ # # ]: 0 : uno::UNO_QUERY );
1278 : 0 : bCreateDiagram = true;
1279 : : }
1280 : 0 : break;
1281 : :
1282 : : case SERVICE_NAME_DASH_TABLE:
1283 : : case SERVICE_NAME_GARDIENT_TABLE:
1284 : : case SERVICE_NAME_HATCH_TABLE:
1285 : : case SERVICE_NAME_BITMAP_TABLE:
1286 : : case SERVICE_NAME_TRANSP_GRADIENT_TABLE:
1287 : : case SERVICE_NAME_MARKER_TABLE:
1288 : : {
1289 [ # # ]: 0 : uno::Reference< lang::XMultiServiceFactory > xTableFactory( xChartDoc, uno::UNO_QUERY );
1290 : : OSL_ENSURE( xTableFactory.get() != this, "new model is expected to implement service factory for gradient table etc" );
1291 [ # # ][ # # ]: 0 : if( xTableFactory.is() && xTableFactory.get() != this )
[ # # ][ # # ]
1292 [ # # ][ # # ]: 0 : xResult.set( xTableFactory->createInstance( aIt->first ), uno::UNO_QUERY );
[ # # ]
1293 : : }
1294 : 0 : break;
1295 : :
1296 : : case SERVICE_NAME_NAMESPACE_MAP:
1297 : 0 : break;
1298 : : case SERVICE_NAME_EXPORT_GRAPHIC_RESOLVER:
1299 : 0 : break;
1300 : : case SERVICE_NAME_IMPORT_GRAPHIC_RESOLVER:
1301 : 0 : break;
1302 : : }
1303 : :
1304 [ + - ][ + - ]: 32 : if( bCreateDiagram && xTemplate.is() )
[ + - ]
1305 : : {
1306 : : try
1307 : : {
1308 [ + - ][ + - ]: 32 : uno::Reference< chart2::XDiagram > xDia( xChartDoc->getFirstDiagram());
1309 [ + + ]: 32 : if( xDia.is())
1310 : : {
1311 : : // locked controllers
1312 [ + - ]: 26 : Reference< frame::XModel > xModel( xChartDoc, uno::UNO_QUERY );
1313 [ + - ]: 26 : ControllerLockGuard aCtrlLockGuard( xModel );
1314 [ + - ]: 26 : Reference< chart2::XDiagram > xDiagram = ChartModelHelper::findDiagram( xModel );
1315 [ + - ]: 26 : ThreeDLookScheme e3DScheme = ThreeDHelper::detectScheme( xDiagram );
1316 [ + - ][ + - ]: 26 : Reference< lang::XMultiServiceFactory > xTemplateManager( xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
[ + - ]
1317 : : DiagramHelper::tTemplateWithServiceName aTemplateWithService(
1318 [ + - ]: 26 : DiagramHelper::getTemplateForDiagram( xDiagram, xTemplateManager ));
1319 [ + - ]: 26 : if( aTemplateWithService.first.is())
1320 [ + - ][ + - ]: 26 : aTemplateWithService.first->resetStyles( xDiagram );//#i109371#
1321 [ + - ][ + - ]: 26 : xTemplate->changeDiagram( xDiagram );
1322 [ + - ][ + - ]: 26 : if( Application::GetSettings().GetLayoutRTL() )
[ - + ]
1323 [ # # ][ # # ]: 0 : AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) );
1324 [ + - ][ + - ]: 26 : ThreeDHelper::setScheme( xDiagram, e3DScheme );
[ + - ]
1325 : : }
1326 : : else
1327 : : {
1328 : : // locked controllers
1329 [ + - ][ + - ]: 6 : ControllerLockGuard aCtrlLockGuard( Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ));
1330 [ + - ]: 6 : xDia.set( xTemplate->createDiagramByDataSource(
1331 : : uno::Reference< chart2::data::XDataSource >(),
1332 [ + - ][ + - ]: 6 : uno::Sequence< beans::PropertyValue >()));
[ + - ][ + - ]
1333 [ + - ][ + - ]: 6 : xChartDoc->setFirstDiagram( xDia );
[ + - ]
1334 : : }
1335 : :
1336 [ + - ][ + - ]: 32 : xResult = static_cast< ::cppu::OWeakObject* >( new DiagramWrapper( m_spChart2ModelContact ));
[ + - ][ + - ]
[ + - ][ # # ]
1337 : : }
1338 [ # # ]: 0 : catch (const uno::Exception& ex)
1339 : : {
1340 : : ASSERT_EXCEPTION( ex );
1341 : : }
1342 : : }
1343 : :
1344 : 32 : bServiceFound = true;
1345 : : }
1346 [ + - ][ - + ]: 4776 : else if( aServiceSpecifier.equals( CHART_RENDERER_SERVICE_IMPLEMENTATION_NAME ) )
1347 : : {
1348 [ # # ][ # # ]: 0 : Reference< lang::XUnoTunnel > xChartRenderer( new ChartRenderer( m_spChart2ModelContact->getChartModel() ) );
[ # # ][ # # ]
1349 [ # # ]: 0 : xResult.set( xChartRenderer );
1350 : 0 : bServiceFound = true;
1351 : : }
1352 [ + + ]: 4776 : else if( aServiceSpecifier == "com.sun.star.comp.chart2.DataSeriesWrapper" )
1353 : : {
1354 [ + - ][ + - ]: 92 : Reference< beans::XPropertySet > xDataSeries( new DataSeriesPointWrapper( m_spChart2ModelContact ) );
[ + - ][ + - ]
[ + - ]
1355 [ + - ]: 92 : xResult.set( xDataSeries );
1356 : 92 : bServiceFound = true;
1357 : : }
1358 [ + - ][ + + ]: 4684 : else if( aServiceSpecifier.equals( CHART_VIEW_SERVICE_NAME ) )
1359 : : {
1360 [ + + ]: 4645 : if( !m_xChartView.is() )
1361 : : {
1362 : : Reference< lang::XMultiServiceFactory > xFact(
1363 [ + - ][ + - ]: 56 : m_spChart2ModelContact->m_xContext->getServiceManager(), uno::UNO_QUERY_THROW );
[ + - ]
1364 [ + - ]: 56 : if( xFact.is() )
1365 : : {
1366 [ + - ]: 56 : Reference< lang::XInitialization > xViewInit( xFact->createInstance(
1367 [ + - ][ + - ]: 56 : CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY );
[ + - ]
1368 [ + - ]: 56 : if(xViewInit.is())
1369 : : {
1370 : : try
1371 : : {
1372 [ + - ]: 56 : m_xChartView = xViewInit;
1373 : :
1374 [ + - ]: 56 : Sequence< Any > aArguments(2);
1375 [ + - ]: 56 : Reference<frame::XModel> xModel(this);
1376 [ + - ][ + - ]: 56 : aArguments[0]=uno::makeAny(xModel);
1377 : 56 : sal_Bool bRefreshAddIn = sal_True;
1378 [ + - ][ + - ]: 56 : aArguments[1]=uno::makeAny(bRefreshAddIn);
1379 [ + - ][ + - ]: 56 : xViewInit->initialize(aArguments);
[ # # ][ + - ]
1380 : : }
1381 [ # # ]: 0 : catch (const uno::Exception& ex)
1382 : : {
1383 : : ASSERT_EXCEPTION( ex );
1384 : : }
1385 : 56 : }
1386 : 56 : }
1387 : : }
1388 [ + - ]: 4645 : xResult.set( m_xChartView );
1389 : 4645 : bServiceFound = true;
1390 : : }
1391 : : else
1392 : : {
1393 : : // try to create a shape
1394 : : try
1395 : : {
1396 [ + + ][ + - ]: 39 : if( !m_xShapeFactory.is() && m_xChartView.is() )
[ + + ]
1397 : : {
1398 [ + - ]: 13 : Reference< lang::XUnoTunnel> xUnoTunnel(m_xChartView,uno::UNO_QUERY);
1399 [ + - ]: 13 : if(xUnoTunnel.is())
1400 : : {
1401 [ + - ]: 13 : ExplicitValueProvider* pProvider = reinterpret_cast<ExplicitValueProvider*>(xUnoTunnel->getSomething(
1402 [ + - ][ + - ]: 13 : ExplicitValueProvider::getUnoTunnelId() ));
1403 [ + - ]: 13 : if( pProvider )
1404 [ + - ][ + - ]: 13 : m_xShapeFactory.set( pProvider->getDrawModelWrapper()->getShapeFactory() );
[ + - ][ + - ]
1405 : 13 : }
1406 : : }
1407 [ + - ]: 39 : if( m_xShapeFactory.is() )
1408 : : {
1409 [ + - ][ - + ]: 39 : xResult = m_xShapeFactory->createInstance( aServiceSpecifier );
[ # # ][ - + ]
1410 : 0 : bServiceFound = true;
1411 : : }
1412 : : }
1413 [ + - ]: 39 : catch (const uno::Exception&)
1414 : : {
1415 : : // couldn't create shape
1416 : : }
1417 : : }
1418 : :
1419 : : // finally, try to create an addin
1420 [ + + ]: 4808 : if( !bServiceFound )
1421 : : {
1422 : : try
1423 : : {
1424 : : Reference< lang::XMultiServiceFactory > xFact(
1425 [ + - ][ + - ]: 39 : m_spChart2ModelContact->m_xContext->getServiceManager(), uno::UNO_QUERY_THROW );
[ + - ]
1426 [ + - ]: 39 : if( xFact.is() )
1427 : : {
1428 : : uno::Reference< util::XRefreshable > xAddIn(
1429 [ + - ][ + - ]: 39 : xFact->createInstance( aServiceSpecifier ), uno::UNO_QUERY );
[ + - ]
1430 [ - + ]: 39 : if( xAddIn.is() )
1431 : : {
1432 [ # # ]: 0 : xResult = xAddIn;
1433 : 0 : bServiceFound = true;
1434 : 39 : }
1435 [ # # ]: 39 : }
1436 : : }
1437 [ # # ]: 0 : catch (const uno::Exception&)
1438 : : {
1439 : : // couldn't create service
1440 : : }
1441 : : }
1442 : :
1443 : 4808 : return xResult;
1444 : : }
1445 : :
1446 : 0 : uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstanceWithArguments(
1447 : : const ::rtl::OUString& ServiceSpecifier,
1448 : : const uno::Sequence< uno::Any >& Arguments )
1449 : : throw (uno::Exception,
1450 : : uno::RuntimeException)
1451 : : {
1452 : : OSL_ENSURE( Arguments.getLength(), "createInstanceWithArguments: Warning: Arguments are ignored" );
1453 : : (void)(Arguments);
1454 : :
1455 : 0 : return createInstance( ServiceSpecifier );
1456 : : }
1457 : :
1458 : 9 : uno::Sequence< ::rtl::OUString > SAL_CALL ChartDocumentWrapper::getAvailableServiceNames()
1459 : : throw (uno::RuntimeException)
1460 : : {
1461 : 9 : tServiceNameMap & rMap = lcl_getStaticServiceNameMap();
1462 : 9 : uno::Sequence< ::rtl::OUString > aResult( rMap.size());
1463 : :
1464 : : ::std::transform( rMap.begin(), rMap.end(),
1465 : : aResult.getArray(),
1466 [ + - ][ + - ]: 9 : ::o3tl::select1st< tServiceNameMap::value_type >() );
1467 : :
1468 : 9 : return aResult;
1469 : :
1470 : : }
1471 : :
1472 : : // ____ XAggregation ____
1473 : 168 : void SAL_CALL ChartDocumentWrapper::setDelegator(
1474 : : const uno::Reference< uno::XInterface >& rDelegator )
1475 : : throw (uno::RuntimeException)
1476 : : {
1477 [ + + ]: 168 : if( m_bIsDisposed )
1478 : : {
1479 [ - + ]: 56 : if( rDelegator.is() )
1480 : : throw lang::DisposedException("ChartDocumentWrapper is disposed",
1481 [ # # ][ # # ]: 0 : static_cast< ::cppu::OWeakObject* >( this ));
1482 : : else
1483 : 168 : return;
1484 : : }
1485 : :
1486 [ + + ]: 112 : if( rDelegator.is())
1487 : : {
1488 : 56 : m_xDelegator = rDelegator;
1489 [ # # ][ + - ]: 56 : m_spChart2ModelContact->setModel( uno::Reference< frame::XModel >(m_xDelegator, uno::UNO_QUERY) );
1490 : : }
1491 : : else
1492 : : {
1493 : : // this is a sort of dispose() from the new model,so release resources here
1494 : : try
1495 : : {
1496 [ + - ]: 56 : this->dispose();
1497 : : }
1498 : 0 : catch (const uno::Exception& ex)
1499 : : {
1500 : : ASSERT_EXCEPTION( ex );
1501 : : }
1502 : : }
1503 : : }
1504 : :
1505 : 19737 : uno::Any SAL_CALL ChartDocumentWrapper::queryAggregation( const uno::Type& rType )
1506 : : throw (uno::RuntimeException)
1507 : : {
1508 : 19737 : return ChartDocumentWrapper_Base::queryInterface( rType );
1509 : : }
1510 : :
1511 : : // ____ ::utl::OEventListenerAdapter ____
1512 : 0 : void ChartDocumentWrapper::_disposing( const lang::EventObject& rSource )
1513 : : {
1514 [ # # ]: 0 : if( rSource.Source == m_xTitle )
1515 : 0 : m_xTitle.set( 0 );
1516 [ # # ]: 0 : else if( rSource.Source == m_xSubTitle )
1517 : 0 : m_xSubTitle.set( 0 );
1518 [ # # ]: 0 : else if( rSource.Source == m_xLegend )
1519 : 0 : m_xLegend.set( 0 );
1520 [ # # ]: 0 : else if( rSource.Source == m_xChartData )
1521 : 0 : m_xChartData.set( 0 );
1522 [ # # ]: 0 : else if( rSource.Source == m_xDiagram )
1523 : 0 : m_xDiagram.set( 0 );
1524 [ # # ]: 0 : else if( rSource.Source == m_xArea )
1525 : 0 : m_xArea.set( 0 );
1526 [ # # ]: 0 : else if( rSource.Source == m_xAddIn )
1527 : 0 : m_xAddIn.set( 0 );
1528 [ # # ]: 0 : else if( rSource.Source == m_xChartView )
1529 : 0 : m_xChartView.set( 0 );
1530 : 0 : }
1531 : :
1532 : : // ================================================================================
1533 : :
1534 : : // WrappedPropertySet
1535 : 12341 : Reference< beans::XPropertySet > ChartDocumentWrapper::getInnerPropertySet()
1536 : : {
1537 : 12341 : return 0;
1538 : : }
1539 : 56 : const Sequence< beans::Property >& ChartDocumentWrapper::getPropertySequence()
1540 : : {
1541 : 56 : return *StaticChartDocumentWrapperPropertyArray::get();
1542 : : }
1543 : :
1544 : 56 : const std::vector< WrappedProperty* > ChartDocumentWrapper::createWrappedProperties()
1545 : : {
1546 : 56 : ::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
1547 [ + - ][ + - ]: 56 : aWrappedProperties.push_back( new WrappedDataSourceLabelsInFirstRowProperty( m_spChart2ModelContact ) );
[ + - ][ + - ]
[ + - ]
1548 [ + - ][ + - ]: 56 : aWrappedProperties.push_back( new WrappedDataSourceLabelsInFirstColumnProperty( m_spChart2ModelContact ) );
[ + - ][ + - ]
[ + - ]
1549 [ + - ][ + - ]: 56 : aWrappedProperties.push_back( new WrappedHasLegendProperty( m_spChart2ModelContact ) );
[ + - ][ + - ]
[ + - ]
1550 [ + - ][ + - ]: 56 : aWrappedProperties.push_back( new WrappedHasMainTitleProperty( m_spChart2ModelContact ) );
[ + - ][ + - ]
[ + - ]
1551 [ + - ][ + - ]: 56 : aWrappedProperties.push_back( new WrappedHasSubTitleProperty( m_spChart2ModelContact ) );
[ + - ][ + - ]
[ + - ]
1552 [ + - ][ + - ]: 56 : aWrappedProperties.push_back( new WrappedAddInProperty( *this ) );
[ + - ]
1553 [ + - ][ + - ]: 56 : aWrappedProperties.push_back( new WrappedBaseDiagramProperty( *this ) );
[ + - ]
1554 [ + - ][ + - ]: 56 : aWrappedProperties.push_back( new WrappedAdditionalShapesProperty( *this ) );
[ + - ]
1555 [ + - ][ + - ]: 56 : aWrappedProperties.push_back( new WrappedRefreshAddInAllowedProperty( *this ) );
[ + - ]
1556 [ + - ][ + - ]: 56 : aWrappedProperties.push_back( new WrappedIgnoreProperty("NullDate",Any() ) ); // i99104
[ + - ]
1557 [ + - ][ + - ]: 56 : aWrappedProperties.push_back( new WrappedIgnoreProperty("DisableComplexChartTypes", uno::makeAny( sal_False ) ) );
[ + - ][ + - ]
1558 [ + - ][ + - ]: 56 : aWrappedProperties.push_back( new WrappedIgnoreProperty("DisableDataTableDialog", uno::makeAny( sal_False ) ) );
[ + - ][ + - ]
1559 : :
1560 : 56 : return aWrappedProperties;
1561 : : }
1562 : :
1563 : : // ================================================================================
1564 : :
1565 : 14 : uno::Sequence< ::rtl::OUString > ChartDocumentWrapper::getSupportedServiceNames_Static()
1566 : : {
1567 : 14 : uno::Sequence< ::rtl::OUString > aServices( 4 );
1568 [ + - ]: 14 : aServices[ 0 ] = "com.sun.star.chart.ChartDocument";
1569 [ + - ][ + - ]: 14 : aServices[ 1 ] = CHART_CHARTAPIWRAPPER_SERVICE_NAME;
1570 [ + - ]: 14 : aServices[ 2 ] = "com.sun.star.xml.UserDefinedAttributeSupplier";
1571 [ + - ]: 14 : aServices[ 3 ] = "com.sun.star.beans.PropertySet";
1572 : 14 : return aServices;
1573 : : }
1574 : :
1575 : : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
1576 [ # # ][ # # ]: 32 : APPHELPER_XSERVICEINFO_IMPL( ChartDocumentWrapper, CHART_CHARTAPIWRAPPER_IMPLEMENTATION_NAME );
[ # # ][ # # ]
[ # # ]
1577 : :
1578 : : } // namespace wrapper
1579 : : } // namespace chart
1580 : :
1581 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|