1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ChartDocumentWrapper.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
33 #include "ChartDocumentWrapper.hxx"
35 #include "servicenames.hxx"
36 #include "PropertyHelper.hxx"
37 #include "TitleHelper.hxx"
38 #include "LegendHelper.hxx"
39 #include "ControllerLockGuard.hxx"
40 #include "ModifyListenerHelper.hxx"
41 #include "DisposeHelper.hxx"
42 #include "DataSeriesPointWrapper.hxx"
43 #include "chartview/ExplicitValueProvider.hxx"
44 #include "chartview/DrawModelWrapper.hxx"
45 #include "Chart2ModelContact.hxx"
47 #include "DiagramHelper.hxx"
48 #include "DataSourceHelper.hxx"
49 #include "ChartModelHelper.hxx"
50 #include "ContainerHelper.hxx"
52 #include "TitleWrapper.hxx"
53 #include "ChartDataWrapper.hxx"
54 #include "DiagramWrapper.hxx"
55 #include "LegendWrapper.hxx"
56 #include "AreaWrapper.hxx"
57 #include "WrappedAddInProperty.hxx"
58 #include "WrappedIgnoreProperty.hxx"
59 #include "ChartRenderer.hxx"
60 #include <com/sun/star/chart2/XTitled.hpp>
61 #include <com/sun/star/chart2/data/XDataReceiver.hpp>
62 #include <com/sun/star/chart/ChartDataRowSource.hpp>
63 #include <com/sun/star/chart/XChartDataArray.hpp>
64 #include <comphelper/InlineContainer.hxx>
65 // header for function SvxShapeCollection_NewInstance
66 #include <svx/unoshcol.hxx>
67 // header for define DBG_ASSERT
68 #include <tools/debug.hxx>
69 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
70 #include <com/sun/star/beans/PropertyAttribute.hpp>
71 #include <com/sun/star/lang/DisposedException.hpp>
72 #include <com/sun/star/lang/XInitialization.hpp>
73 #include <com/sun/star/util/DateTime.hpp>
79 using namespace ::com::sun::star
;
80 using namespace ::com::sun::star::chart
;
82 using ::com::sun::star::uno::Any
;
83 using ::com::sun::star::uno::Reference
;
84 using ::com::sun::star::uno::Sequence
;
85 using ::com::sun::star::beans::Property
;
86 using ::osl::MutexGuard
;
87 using ::rtl::OUString
;
93 SERVICE_NAME_AREA_DIAGRAM
= 0,
94 SERVICE_NAME_BAR_DIAGRAM
,
95 SERVICE_NAME_DONUT_DIAGRAM
,
96 SERVICE_NAME_LINE_DIAGRAM
,
97 SERVICE_NAME_NET_DIAGRAM
,
98 SERVICE_NAME_FILLED_NET_DIAGRAM
,
99 SERVICE_NAME_PIE_DIAGRAM
,
100 SERVICE_NAME_STOCK_DIAGRAM
,
101 SERVICE_NAME_XY_DIAGRAM
,
102 SERVICE_NAME_BUBBLE_DIAGRAM
,
104 SERVICE_NAME_DASH_TABLE
,
105 SERVICE_NAME_GARDIENT_TABLE
,
106 SERVICE_NAME_HATCH_TABLE
,
107 SERVICE_NAME_BITMAP_TABLE
,
108 SERVICE_NAME_TRANSP_GRADIENT_TABLE
,
109 SERVICE_NAME_MARKER_TABLE
,
111 SERVICE_NAME_NAMESPACE_MAP
,
112 SERVICE_NAME_EXPORT_GRAPHIC_RESOLVER
,
113 SERVICE_NAME_IMPORT_GRAPHIC_RESOLVER
116 typedef ::std::map
< ::rtl::OUString
, enum eServiceType
> tServiceNameMap
;
117 typedef ::comphelper::MakeMap
< ::rtl::OUString
, enum eServiceType
> tMakeServiceNameMap
;
119 tServiceNameMap
& lcl_getStaticServiceNameMap()
121 static tServiceNameMap
aServiceNameMap(
123 ( C2U( "com.sun.star.chart.AreaDiagram" ), SERVICE_NAME_AREA_DIAGRAM
)
124 ( C2U( "com.sun.star.chart.BarDiagram" ), SERVICE_NAME_BAR_DIAGRAM
)
125 ( C2U( "com.sun.star.chart.DonutDiagram" ), SERVICE_NAME_DONUT_DIAGRAM
)
126 ( C2U( "com.sun.star.chart.LineDiagram" ), SERVICE_NAME_LINE_DIAGRAM
)
127 ( C2U( "com.sun.star.chart.NetDiagram" ), SERVICE_NAME_NET_DIAGRAM
)
128 ( C2U( "com.sun.star.chart.FilledNetDiagram" ), SERVICE_NAME_FILLED_NET_DIAGRAM
)
129 ( C2U( "com.sun.star.chart.PieDiagram" ), SERVICE_NAME_PIE_DIAGRAM
)
130 ( C2U( "com.sun.star.chart.StockDiagram" ), SERVICE_NAME_STOCK_DIAGRAM
)
131 ( C2U( "com.sun.star.chart.XYDiagram" ), SERVICE_NAME_XY_DIAGRAM
)
132 ( C2U( "com.sun.star.chart.BubbleDiagram" ), SERVICE_NAME_BUBBLE_DIAGRAM
)
134 ( C2U( "com.sun.star.drawing.DashTable" ), SERVICE_NAME_DASH_TABLE
)
135 ( C2U( "com.sun.star.drawing.GradientTable" ), SERVICE_NAME_GARDIENT_TABLE
)
136 ( C2U( "com.sun.star.drawing.HatchTable" ), SERVICE_NAME_HATCH_TABLE
)
137 ( C2U( "com.sun.star.drawing.BitmapTable" ), SERVICE_NAME_BITMAP_TABLE
)
138 ( C2U( "com.sun.star.drawing.TransparencyGradientTable" ), SERVICE_NAME_TRANSP_GRADIENT_TABLE
)
139 ( C2U( "com.sun.star.drawing.MarkerTable" ), SERVICE_NAME_MARKER_TABLE
)
141 ( C2U( "com.sun.star.xml.NamespaceMap" ), SERVICE_NAME_NAMESPACE_MAP
)
142 ( C2U( "com.sun.star.document.ExportGraphicObjectResolver" ), SERVICE_NAME_EXPORT_GRAPHIC_RESOLVER
)
143 ( C2U( "com.sun.star.document.ImportGraphicObjectResolver" ), SERVICE_NAME_IMPORT_GRAPHIC_RESOLVER
)
146 return aServiceNameMap
;
151 PROP_DOCUMENT_HAS_MAIN_TITLE
,
152 PROP_DOCUMENT_HAS_SUB_TITLE
,
153 PROP_DOCUMENT_HAS_LEGEND
,
154 PROP_DOCUMENT_LABELS_IN_FIRST_ROW
,
155 PROP_DOCUMENT_LABELS_IN_FIRST_COLUMN
,
157 PROP_DOCUMENT_BASEDIAGRAM
,
158 PROP_DOCUMENT_ADDITIONAL_SHAPES
,
159 PROP_DOCUMENT_UPDATE_ADDIN
,
160 PROP_DOCUMENT_NULL_DATE
163 void lcl_AddPropertiesToVector(
164 ::std::vector
< Property
> & rOutProperties
)
166 rOutProperties
.push_back(
167 Property( C2U( "HasMainTitle" ),
168 PROP_DOCUMENT_HAS_MAIN_TITLE
,
169 ::getBooleanCppuType(),
170 beans::PropertyAttribute::BOUND
171 | beans::PropertyAttribute::MAYBEDEFAULT
));
172 rOutProperties
.push_back(
173 Property( C2U( "HasSubTitle" ),
174 PROP_DOCUMENT_HAS_SUB_TITLE
,
175 ::getBooleanCppuType(),
176 beans::PropertyAttribute::BOUND
177 | beans::PropertyAttribute::MAYBEDEFAULT
));
178 rOutProperties
.push_back(
179 Property( C2U( "HasLegend" ),
180 PROP_DOCUMENT_HAS_LEGEND
,
181 ::getBooleanCppuType(),
182 beans::PropertyAttribute::BOUND
183 | beans::PropertyAttribute::MAYBEDEFAULT
));
186 rOutProperties
.push_back(
187 Property( C2U( "DataSourceLabelsInFirstRow" ),
188 PROP_DOCUMENT_LABELS_IN_FIRST_ROW
,
189 ::getBooleanCppuType(),
190 beans::PropertyAttribute::BOUND
191 | beans::PropertyAttribute::MAYBEDEFAULT
));
192 rOutProperties
.push_back(
193 Property( C2U( "DataSourceLabelsInFirstColumn" ),
194 PROP_DOCUMENT_LABELS_IN_FIRST_COLUMN
,
195 ::getBooleanCppuType(),
196 beans::PropertyAttribute::BOUND
197 | beans::PropertyAttribute::MAYBEDEFAULT
));
200 rOutProperties
.push_back(
201 Property( C2U( "AddIn" ),
203 ::getCppuType( reinterpret_cast< Reference
< util::XRefreshable
> * >(0)),
204 beans::PropertyAttribute::BOUND
205 | beans::PropertyAttribute::MAYBEVOID
));
206 rOutProperties
.push_back(
207 Property( C2U( "BaseDiagram" ),
208 PROP_DOCUMENT_BASEDIAGRAM
,
209 ::getCppuType( reinterpret_cast< const ::rtl::OUString
* >(0)),
210 beans::PropertyAttribute::BOUND
211 | beans::PropertyAttribute::MAYBEVOID
));
212 rOutProperties
.push_back(
213 Property( C2U( "AdditionalShapes" ),
214 PROP_DOCUMENT_ADDITIONAL_SHAPES
,
215 ::getCppuType( reinterpret_cast< Reference
< drawing::XShapes
> * >(0)),
216 beans::PropertyAttribute::BOUND
217 | beans::PropertyAttribute::MAYBEVOID
218 | beans::PropertyAttribute::READONLY
));
219 rOutProperties
.push_back(
220 Property( C2U( "RefreshAddInAllowed" ),
221 PROP_DOCUMENT_UPDATE_ADDIN
,
222 ::getBooleanCppuType(),
223 beans::PropertyAttribute::BOUND
));
225 // table:null-date // i99104
226 rOutProperties
.push_back(
227 Property( C2U( "NullDate" ),
228 PROP_DOCUMENT_NULL_DATE
,
229 ::getCppuType( static_cast< const ::com::sun::star::util::DateTime
* >(0)),
230 beans::PropertyAttribute::MAYBEVOID
));
233 const uno::Sequence
< Property
> & lcl_GetPropertySequence()
235 static uno::Sequence
< Property
> aPropSeq
;
238 MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
239 if( 0 == aPropSeq
.getLength() )
242 ::std::vector
< ::com::sun::star::beans::Property
> aProperties
;
243 lcl_AddPropertiesToVector( aProperties
);
245 // and sort them for access via bsearch
246 ::std::sort( aProperties
.begin(), aProperties
.end(),
247 ::chart::PropertyNameLess() );
249 // transfer result to static Sequence
250 aPropSeq
= ::chart::ContainerHelper::ContainerToSequence( aProperties
);
256 } // anonymous namespace
262 //-----------------------------------------------------------------------------------------------------------------
263 //-----------------------------------------------------------------------------------------------------------------
264 //-----------------------------------------------------------------------------------------------------------------
266 //PROP_DOCUMENT_LABELS_IN_FIRST_ROW
267 class WrappedDataSourceLabelsInFirstRowProperty
: public WrappedProperty
270 WrappedDataSourceLabelsInFirstRowProperty( ::boost::shared_ptr
< Chart2ModelContact
> spChart2ModelContact
);
271 virtual ~WrappedDataSourceLabelsInFirstRowProperty();
273 virtual void setPropertyValue( const ::com::sun::star::uno::Any
& rOuterValue
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xInnerPropertySet
) const
274 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
);
276 virtual ::com::sun::star::uno::Any
getPropertyValue( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xInnerPropertySet
) const
277 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
279 virtual ::com::sun::star::uno::Any
getPropertyDefault( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyState
>& xInnerPropertyState
) const
280 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
283 ::boost::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
284 mutable Any m_aOuterValue
;
287 WrappedDataSourceLabelsInFirstRowProperty::WrappedDataSourceLabelsInFirstRowProperty( ::boost::shared_ptr
< Chart2ModelContact
> spChart2ModelContact
)
288 : WrappedProperty(C2U("DataSourceLabelsInFirstRow"),OUString())
289 , m_spChart2ModelContact( spChart2ModelContact
)
292 m_aOuterValue
= WrappedDataSourceLabelsInFirstRowProperty::getPropertyDefault( 0 );
295 WrappedDataSourceLabelsInFirstRowProperty::~WrappedDataSourceLabelsInFirstRowProperty()
299 void WrappedDataSourceLabelsInFirstRowProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
300 throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
302 sal_Bool bLabelsInFirstRow
= sal_True
;
303 if( ! (rOuterValue
>>= bLabelsInFirstRow
) )
304 throw lang::IllegalArgumentException( C2U("Property DataSourceLabelsInFirstRow requires value of type boolean"), 0, 0 );
306 m_aOuterValue
= rOuterValue
;
307 bool bNewValue
= bLabelsInFirstRow
;
309 ::rtl::OUString aRangeString
;
310 bool bUseColumns
= true;
311 bool bFirstCellAsLabel
= true;
312 bool bHasCategories
= true;
313 uno::Sequence
< sal_Int32
> aSequenceMapping
;
315 if( DataSourceHelper::detectRangeSegmentation(
316 m_spChart2ModelContact
->getChartModel(), aRangeString
, aSequenceMapping
, bUseColumns
317 , bFirstCellAsLabel
, bHasCategories
) )
319 if( bUseColumns
&& bNewValue
!= bFirstCellAsLabel
)
321 DataSourceHelper::setRangeSegmentation(
322 m_spChart2ModelContact
->getChartModel(), aSequenceMapping
, bUseColumns
,bNewValue
, bHasCategories
);
324 else if( !bUseColumns
&& bNewValue
!= bHasCategories
)
326 DataSourceHelper::setRangeSegmentation(
327 m_spChart2ModelContact
->getChartModel(), aSequenceMapping
, bUseColumns
, bFirstCellAsLabel
, bNewValue
);
332 Any
WrappedDataSourceLabelsInFirstRowProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
333 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
335 ::rtl::OUString aRangeString
;
336 bool bUseColumns
= true;
337 bool bFirstCellAsLabel
= true;
338 bool bHasCategories
= true;
339 uno::Sequence
< sal_Int32
> aSequenceMapping
;
341 if( DataSourceHelper::detectRangeSegmentation(
342 m_spChart2ModelContact
->getChartModel(), aRangeString
, aSequenceMapping
, bUseColumns
343 , bFirstCellAsLabel
, bHasCategories
) )
345 sal_Bool bLabelsInFirstRow
= sal_True
;
347 bLabelsInFirstRow
= bFirstCellAsLabel
;
349 bLabelsInFirstRow
= bHasCategories
;
351 m_aOuterValue
<<= bLabelsInFirstRow
;
353 return m_aOuterValue
;
356 Any
WrappedDataSourceLabelsInFirstRowProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
357 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
364 //-----------------------------------------------------------------------------------------------------------------
365 //-----------------------------------------------------------------------------------------------------------------
366 //-----------------------------------------------------------------------------------------------------------------
368 //PROP_DOCUMENT_LABELS_IN_FIRST_COLUMN
369 class WrappedDataSourceLabelsInFirstColumnProperty
: public WrappedProperty
372 WrappedDataSourceLabelsInFirstColumnProperty( ::boost::shared_ptr
< Chart2ModelContact
> spChart2ModelContact
);
373 virtual ~WrappedDataSourceLabelsInFirstColumnProperty();
375 virtual void setPropertyValue( const ::com::sun::star::uno::Any
& rOuterValue
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xInnerPropertySet
) const
376 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
);
378 virtual ::com::sun::star::uno::Any
getPropertyValue( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xInnerPropertySet
) const
379 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
381 virtual ::com::sun::star::uno::Any
getPropertyDefault( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyState
>& xInnerPropertyState
) const
382 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
385 ::boost::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
386 mutable Any m_aOuterValue
;
389 WrappedDataSourceLabelsInFirstColumnProperty::WrappedDataSourceLabelsInFirstColumnProperty( ::boost::shared_ptr
< Chart2ModelContact
> spChart2ModelContact
)
390 : WrappedProperty(C2U("DataSourceLabelsInFirstColumn"),OUString())
391 , m_spChart2ModelContact( spChart2ModelContact
)
394 m_aOuterValue
= WrappedDataSourceLabelsInFirstColumnProperty::getPropertyDefault( 0 );
397 WrappedDataSourceLabelsInFirstColumnProperty::~WrappedDataSourceLabelsInFirstColumnProperty()
401 void WrappedDataSourceLabelsInFirstColumnProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
402 throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
404 sal_Bool bLabelsInFirstRow
= sal_True
;
405 if( ! (rOuterValue
>>= bLabelsInFirstRow
) )
406 throw lang::IllegalArgumentException( C2U("Property DataSourceLabelsInFirstRow requires value of type boolean"), 0, 0 );
408 m_aOuterValue
= rOuterValue
;
409 bool bNewValue
= bLabelsInFirstRow
;
411 ::rtl::OUString aRangeString
;
412 bool bUseColumns
= true;
413 bool bFirstCellAsLabel
= true;
414 bool bHasCategories
= true;
415 uno::Sequence
< sal_Int32
> aSequenceMapping
;
417 if( DataSourceHelper::detectRangeSegmentation(
418 m_spChart2ModelContact
->getChartModel(), aRangeString
, aSequenceMapping
, bUseColumns
419 , bFirstCellAsLabel
, bHasCategories
) )
421 if( bUseColumns
&& bNewValue
!= bHasCategories
)
423 DataSourceHelper::setRangeSegmentation(
424 m_spChart2ModelContact
->getChartModel(), aSequenceMapping
, bUseColumns
, bFirstCellAsLabel
, bNewValue
);
426 else if( !bUseColumns
&& bNewValue
!= bFirstCellAsLabel
)
428 DataSourceHelper::setRangeSegmentation(
429 m_spChart2ModelContact
->getChartModel(), aSequenceMapping
, bUseColumns
, bNewValue
, bHasCategories
);
434 Any
WrappedDataSourceLabelsInFirstColumnProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
435 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
437 ::rtl::OUString aRangeString
;
438 bool bUseColumns
= true;
439 bool bFirstCellAsLabel
= true;
440 bool bHasCategories
= true;
441 uno::Sequence
< sal_Int32
> aSequenceMapping
;
443 if( DataSourceHelper::detectRangeSegmentation(
444 m_spChart2ModelContact
->getChartModel(), aRangeString
, aSequenceMapping
, bUseColumns
445 , bFirstCellAsLabel
, bHasCategories
) )
447 sal_Bool bLabelsInFirstColumn
= sal_True
;
449 bLabelsInFirstColumn
= bHasCategories
;
451 bLabelsInFirstColumn
= bFirstCellAsLabel
;
453 m_aOuterValue
<<= bLabelsInFirstColumn
;
455 return m_aOuterValue
;
458 Any
WrappedDataSourceLabelsInFirstColumnProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
459 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
466 //-----------------------------------------------------------------------------------------------------------------
467 //-----------------------------------------------------------------------------------------------------------------
468 //-----------------------------------------------------------------------------------------------------------------
470 //PROP_DOCUMENT_HAS_LEGEND
471 class WrappedHasLegendProperty
: public WrappedProperty
474 WrappedHasLegendProperty( ::boost::shared_ptr
< Chart2ModelContact
> spChart2ModelContact
);
475 virtual ~WrappedHasLegendProperty();
477 virtual void setPropertyValue( const ::com::sun::star::uno::Any
& rOuterValue
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xInnerPropertySet
) const
478 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
);
480 virtual ::com::sun::star::uno::Any
getPropertyValue( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xInnerPropertySet
) const
481 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
483 virtual ::com::sun::star::uno::Any
getPropertyDefault( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyState
>& xInnerPropertyState
) const
484 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
487 ::boost::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
490 WrappedHasLegendProperty::WrappedHasLegendProperty( ::boost::shared_ptr
< Chart2ModelContact
> spChart2ModelContact
)
491 : WrappedProperty(C2U("HasLegend"),OUString())
492 , m_spChart2ModelContact( spChart2ModelContact
)
496 WrappedHasLegendProperty::~WrappedHasLegendProperty()
500 void WrappedHasLegendProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
501 throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
503 sal_Bool bNewValue
= sal_True
;
504 if( ! (rOuterValue
>>= bNewValue
) )
505 throw lang::IllegalArgumentException( C2U("Property HasLegend requires value of type boolean"), 0, 0 );
509 Reference
< chart2::XLegend
> xLegend( LegendHelper::getLegend( m_spChart2ModelContact
->getChartModel(), m_spChart2ModelContact
->m_xContext
,bNewValue
));
512 Reference
< beans::XPropertySet
> xLegendProp( xLegend
, uno::UNO_QUERY_THROW
);
513 sal_Bool bOldValue
= sal_True
;
514 Any aAOld
= xLegendProp
->getPropertyValue( C2U("Show") );
516 if( bOldValue
!= bNewValue
)
517 xLegendProp
->setPropertyValue( C2U("Show"), uno::makeAny( bNewValue
));
520 catch( uno::Exception
& ex
)
522 ASSERT_EXCEPTION( ex
);
526 Any
WrappedHasLegendProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
527 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
532 Reference
< beans::XPropertySet
> xLegendProp(
533 LegendHelper::getLegend( m_spChart2ModelContact
->getChartModel() ), uno::UNO_QUERY
);
534 if( xLegendProp
.is())
535 aRet
= xLegendProp
->getPropertyValue( C2U("Show"));
539 catch( uno::Exception
& ex
)
541 ASSERT_EXCEPTION( ex
);
546 Any
WrappedHasLegendProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
547 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
554 //-----------------------------------------------------------------------------------------------------------------
555 //-----------------------------------------------------------------------------------------------------------------
556 //-----------------------------------------------------------------------------------------------------------------
558 //PROP_DOCUMENT_HAS_MAIN_TITLE
559 class WrappedHasMainTitleProperty
: public WrappedProperty
562 WrappedHasMainTitleProperty( ::boost::shared_ptr
< Chart2ModelContact
> spChart2ModelContact
);
563 virtual ~WrappedHasMainTitleProperty();
565 virtual void setPropertyValue( const ::com::sun::star::uno::Any
& rOuterValue
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xInnerPropertySet
) const
566 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
);
568 virtual ::com::sun::star::uno::Any
getPropertyValue( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xInnerPropertySet
) const
569 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
571 virtual ::com::sun::star::uno::Any
getPropertyDefault( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyState
>& xInnerPropertyState
) const
572 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
575 ::boost::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
578 WrappedHasMainTitleProperty::WrappedHasMainTitleProperty( ::boost::shared_ptr
< Chart2ModelContact
> spChart2ModelContact
)
579 : WrappedProperty(C2U("HasMainTitle"),OUString())
580 , m_spChart2ModelContact( spChart2ModelContact
)
584 WrappedHasMainTitleProperty::~WrappedHasMainTitleProperty()
588 void WrappedHasMainTitleProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
589 throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
591 sal_Bool bNewValue
= sal_True
;
592 if( ! (rOuterValue
>>= bNewValue
) )
593 throw lang::IllegalArgumentException( C2U("Property HasMainTitle requires value of type boolean"), 0, 0 );
598 TitleHelper::createTitle( TitleHelper::MAIN_TITLE
, C2U("main-title"), m_spChart2ModelContact
->getChartModel(), m_spChart2ModelContact
->m_xContext
);
600 TitleHelper::removeTitle( TitleHelper::MAIN_TITLE
, m_spChart2ModelContact
->getChartModel() );
602 catch( uno::Exception
& ex
)
604 ASSERT_EXCEPTION( ex
);
608 Any
WrappedHasMainTitleProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
609 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
614 aRet
<<= sal_Bool( TitleHelper::getTitle( TitleHelper::MAIN_TITLE
, m_spChart2ModelContact
->getChartModel() ).is() );
616 catch( uno::Exception
& ex
)
618 ASSERT_EXCEPTION( ex
);
623 Any
WrappedHasMainTitleProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
624 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
631 //-----------------------------------------------------------------------------------------------------------------
632 //-----------------------------------------------------------------------------------------------------------------
633 //-----------------------------------------------------------------------------------------------------------------
635 //PROP_DOCUMENT_HAS_SUB_TITLE
636 class WrappedHasSubTitleProperty
: public WrappedProperty
639 WrappedHasSubTitleProperty( ::boost::shared_ptr
< Chart2ModelContact
> spChart2ModelContact
);
640 virtual ~WrappedHasSubTitleProperty();
642 virtual void setPropertyValue( const ::com::sun::star::uno::Any
& rOuterValue
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xInnerPropertySet
) const
643 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
);
645 virtual ::com::sun::star::uno::Any
getPropertyValue( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xInnerPropertySet
) const
646 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
648 virtual ::com::sun::star::uno::Any
getPropertyDefault( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyState
>& xInnerPropertyState
) const
649 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
652 ::boost::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
655 WrappedHasSubTitleProperty::WrappedHasSubTitleProperty( ::boost::shared_ptr
< Chart2ModelContact
> spChart2ModelContact
)
656 : WrappedProperty(C2U("HasSubTitle"),OUString())
657 , m_spChart2ModelContact( spChart2ModelContact
)
661 WrappedHasSubTitleProperty::~WrappedHasSubTitleProperty()
665 void WrappedHasSubTitleProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
666 throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
668 sal_Bool bNewValue
= sal_True
;
669 if( ! (rOuterValue
>>= bNewValue
) )
670 throw lang::IllegalArgumentException( C2U("Property HasSubTitle requires value of type boolean"), 0, 0 );
676 TitleHelper::createTitle( TitleHelper::SUB_TITLE
, C2U("sub-title"), m_spChart2ModelContact
->getChartModel(), m_spChart2ModelContact
->m_xContext
);
678 TitleHelper::removeTitle( TitleHelper::SUB_TITLE
, m_spChart2ModelContact
->getChartModel() );
680 catch( uno::Exception
& ex
)
682 ASSERT_EXCEPTION( ex
);
686 Any
WrappedHasSubTitleProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
687 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
692 aRet
<<= sal_Bool( TitleHelper::getTitle( TitleHelper::SUB_TITLE
, m_spChart2ModelContact
->getChartModel() ).is() );
694 catch( uno::Exception
& ex
)
696 ASSERT_EXCEPTION( ex
);
701 Any
WrappedHasSubTitleProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
702 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
709 //-----------------------------------------------------------------------------------------------------------------
710 //-----------------------------------------------------------------------------------------------------------------
711 //-----------------------------------------------------------------------------------------------------------------
712 ChartDocumentWrapper::ChartDocumentWrapper(
713 const Reference
< uno::XComponentContext
> & xContext
) :
714 m_spChart2ModelContact( new Chart2ModelContact( xContext
) ),
715 m_bUpdateAddIn( sal_True
),
716 m_bIsDisposed( false )
720 ChartDocumentWrapper::~ChartDocumentWrapper()
722 stopAllComponentListening();
725 // ____ XInterface (for new interfaces) ____
726 uno::Any SAL_CALL
ChartDocumentWrapper::queryInterface( const uno::Type
& aType
)
727 throw (uno::RuntimeException
)
729 if( m_xDelegator
.is())
730 // calls queryAggregation if the delegator doesn't know aType
731 return m_xDelegator
->queryInterface( aType
);
733 return queryAggregation( aType
);
736 // ____ chart::XChartDocument (old API wrapper) ____
737 Reference
< drawing::XShape
> SAL_CALL
ChartDocumentWrapper::getTitle()
738 throw (uno::RuntimeException
)
742 m_xTitle
= new TitleWrapper( TitleHelper::MAIN_TITLE
, m_spChart2ModelContact
);
747 Reference
< drawing::XShape
> SAL_CALL
ChartDocumentWrapper::getSubTitle()
748 throw (uno::RuntimeException
)
750 if( !m_xSubTitle
.is() )
752 m_xSubTitle
= new TitleWrapper( TitleHelper::SUB_TITLE
, m_spChart2ModelContact
);
757 Reference
< drawing::XShape
> SAL_CALL
ChartDocumentWrapper::getLegend()
758 throw (uno::RuntimeException
)
760 if( ! m_xLegend
.is())
762 m_xLegend
= new LegendWrapper( m_spChart2ModelContact
);
763 Reference
< lang::XComponent
> xComp( m_xLegend
, uno::UNO_QUERY
);
769 Reference
< beans::XPropertySet
> SAL_CALL
ChartDocumentWrapper::getArea()
770 throw (uno::RuntimeException
)
774 m_xArea
.set( new AreaWrapper( m_spChart2ModelContact
) );
775 Reference
< lang::XComponent
> xComp( m_xArea
, uno::UNO_QUERY
);
781 Reference
< XDiagram
> SAL_CALL
ChartDocumentWrapper::getDiagram()
782 throw (uno::RuntimeException
)
784 if( !m_xDiagram
.is() )
788 m_xDiagram
= new DiagramWrapper( m_spChart2ModelContact
);
790 catch( uno::Exception
& ex
)
792 ASSERT_EXCEPTION( ex
);
799 void SAL_CALL
ChartDocumentWrapper::setDiagram( const Reference
< XDiagram
>& xDiagram
)
800 throw (uno::RuntimeException
)
802 uno::Reference
< util::XRefreshable
> xAddIn( xDiagram
, uno::UNO_QUERY
);
807 else if( xDiagram
.is() && xDiagram
!= m_xDiagram
)
809 // set new wrapped diagram at new chart. This requires the old
810 // diagram given as parameter to implement the new interface. If
811 // this is not possible throw an exception
812 Reference
< chart2::XDiagramProvider
> xNewDiaProvider( xDiagram
, uno::UNO_QUERY_THROW
);
813 Reference
< chart2::XDiagram
> xNewDia( xNewDiaProvider
->getDiagram());
817 Reference
< chart2::XChartDocument
> xChartDoc( m_spChart2ModelContact
->getChart2Document() );
820 // set the new diagram
821 xChartDoc
->setFirstDiagram( xNewDia
);
822 m_xDiagram
= xDiagram
;
825 catch( uno::Exception
& ex
)
827 ASSERT_EXCEPTION( ex
);
832 Reference
< XChartData
> SAL_CALL
ChartDocumentWrapper::getData()
833 throw (uno::RuntimeException
)
835 if( ! m_xChartData
.is())
837 m_xChartData
.set( new ChartDataWrapper( m_spChart2ModelContact
) );
839 //@todo: check hasInternalDataProvider also in else?
844 void SAL_CALL
ChartDocumentWrapper::attachData( const Reference
< XChartData
>& xData
)
845 throw (uno::RuntimeException
)
850 Reference
< chart2::XChartDocument
> xChartDoc( m_spChart2ModelContact
->getChart2Document() );
851 if( !xChartDoc
.is() )
854 uno::Reference
< chart2::data::XDataProvider
> xDataProvider( xChartDoc
->getDataProvider());
855 uno::Reference
< XChartDataArray
> xDocDataArray( xDataProvider
, uno::UNO_QUERY
);
856 uno::Reference
< XChartDataArray
> xDataArray( xData
, uno::UNO_QUERY
);
857 OSL_ASSERT( xDataArray
.is());
858 if( ! xDataArray
.is() ||
859 xDocDataArray
== xDataArray
)
862 // remember some diagram properties to reset later
863 ChartDataRowSource eSeriesSource
= ChartDataRowSource_ROWS
;
864 sal_Bool bStacked
= sal_False
;
865 sal_Bool bPercent
= sal_False
;
866 sal_Bool bDeep
= sal_False
;
867 Reference
< beans::XPropertySet
> xDiaProp( getDiagram(), uno::UNO_QUERY
);
870 xDiaProp
->getPropertyValue( C2U("DataRowSource")) >>= eSeriesSource
;
871 xDiaProp
->getPropertyValue( C2U("Stacked")) >>= bStacked
;
872 xDiaProp
->getPropertyValue( C2U("Percent")) >>= bPercent
;
873 xDiaProp
->getPropertyValue( C2U("Deep")) >>= bDeep
;
876 // create and attach new data source
877 uno::Reference
< chart2::data::XDataSource
> xSource
;
878 Sequence
< beans::PropertyValue
> aArguments( 4 );
879 aArguments
[0] = beans::PropertyValue(
880 C2U("CellRangeRepresentation"), -1, uno::makeAny( C2U("all") ),
881 beans::PropertyState_DIRECT_VALUE
);
882 aArguments
[1] = beans::PropertyValue(
883 C2U("DataRowSource"), -1, uno::makeAny( eSeriesSource
),
884 beans::PropertyState_DIRECT_VALUE
);
885 aArguments
[2] = beans::PropertyValue(
886 C2U("FirstCellAsLabel"), -1, uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE
);
887 aArguments
[3] = beans::PropertyValue(
888 C2U("HasCategories"), -1, uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE
);
890 // /-- locked controllers
891 ControllerLockGuard
aCtrlLockGuard( Reference
< frame::XModel
>( xChartDoc
, uno::UNO_QUERY
));
892 if( xDocDataArray
.is())
894 // we have an internal data provider that supports the XChartDataArray
896 xDocDataArray
->setData( xDataArray
->getData());
897 xDocDataArray
->setRowDescriptions( xDataArray
->getRowDescriptions());
898 xDocDataArray
->setColumnDescriptions( xDataArray
->getColumnDescriptions());
900 xSource
.set( xDataProvider
->createDataSource( aArguments
));
904 uno::Reference
< chart2::data::XDataReceiver
> xReceiver( xChartDoc
, uno::UNO_QUERY
);
905 OSL_ASSERT( xChartDoc
.is());
906 OSL_ASSERT( xReceiver
.is());
907 OSL_ASSERT( xDataArray
.is());
908 if( ! (xChartDoc
.is() &&
912 // create a data provider containing the new data
913 Reference
< chart2::data::XDataProvider
> xTempDataProvider(
914 ChartModelHelper::createInternalDataProvider( xDataArray
));
916 if( ! xTempDataProvider
.is())
917 throw uno::RuntimeException( C2U("Couldn't create temporary data provider"),
918 static_cast< ::cppu::OWeakObject
* >( this ));
920 // removes existing data provider and attaches the new one
921 xReceiver
->attachDataProvider( xTempDataProvider
);
922 xSource
.set( xTempDataProvider
->createDataSource( aArguments
));
925 // determine a template
926 Reference
< lang::XMultiServiceFactory
> xFact( xChartDoc
->getChartTypeManager(), uno::UNO_QUERY
);
927 Reference
< chart2::XDiagram
> xDia( xChartDoc
->getFirstDiagram());
928 DiagramHelper::tTemplateWithServiceName aTemplateAndService
=
929 DiagramHelper::getTemplateForDiagram( xDia
, xFact
);
930 OUString
aServiceName( aTemplateAndService
.second
);
931 Reference
< chart2::XChartTypeTemplate
> xTemplate
= aTemplateAndService
.first
;
934 if( ! xTemplate
.is())
936 if( aServiceName
.getLength() == 0 )
937 aServiceName
= C2U("com.sun.star.chart2.template.Column");
938 xTemplate
.set( xFact
->createInstance( aServiceName
), uno::UNO_QUERY
);
940 OSL_ASSERT( xTemplate
.is());
942 if( xTemplate
.is() && xSource
.is())
944 // argument detection works with internal knowledge of the
946 OSL_ASSERT( xDia
.is());
947 xTemplate
->changeDiagramData(
948 xDia
, xSource
, aArguments
);
951 // should do nothing if we already have an internal data provider
952 xChartDoc
->createInternalDataProvider( sal_True
/* bCloneExistingData */ );
954 //correct stacking mode
955 if( bStacked
|| bPercent
|| bDeep
)
957 StackMode eStackMode
= StackMode_Y_STACKED
;
959 eStackMode
= StackMode_Z_STACKED
;
961 eStackMode
= StackMode_Y_STACKED_PERCENT
;
962 DiagramHelper::setStackMode( xDia
, eStackMode
);
965 m_xChartData
= xData
;
966 // \-- locked controllers
970 sal_Bool SAL_CALL
ChartDocumentWrapper::attachResource(
971 const ::rtl::OUString
& URL
,
972 const Sequence
< beans::PropertyValue
>& Arguments
)
973 throw (uno::RuntimeException
)
975 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
977 return xModel
->attachResource( URL
, Arguments
);
981 ::rtl::OUString SAL_CALL
ChartDocumentWrapper::getURL()
982 throw (uno::RuntimeException
)
984 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
986 return xModel
->getURL();
987 return ::rtl::OUString();
990 Sequence
< beans::PropertyValue
> SAL_CALL
ChartDocumentWrapper::getArgs()
991 throw (uno::RuntimeException
)
993 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
995 return xModel
->getArgs();
996 return Sequence
< beans::PropertyValue
>();
999 void SAL_CALL
ChartDocumentWrapper::connectController( const Reference
< frame::XController
>& Controller
)
1000 throw (uno::RuntimeException
)
1002 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
1004 xModel
->connectController( Controller
);
1007 void SAL_CALL
ChartDocumentWrapper::disconnectController(
1008 const Reference
< frame::XController
>& Controller
)
1009 throw (uno::RuntimeException
)
1011 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
1013 xModel
->disconnectController( Controller
);
1016 void SAL_CALL
ChartDocumentWrapper::lockControllers()
1017 throw (uno::RuntimeException
)
1019 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
1021 xModel
->lockControllers();
1024 void SAL_CALL
ChartDocumentWrapper::unlockControllers()
1025 throw (uno::RuntimeException
)
1027 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
1029 xModel
->unlockControllers();
1032 sal_Bool SAL_CALL
ChartDocumentWrapper::hasControllersLocked()
1033 throw (uno::RuntimeException
)
1035 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
1037 return xModel
->hasControllersLocked();
1041 Reference
< frame::XController
> SAL_CALL
ChartDocumentWrapper::getCurrentController()
1042 throw (uno::RuntimeException
)
1044 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
1046 return xModel
->getCurrentController();
1050 void SAL_CALL
ChartDocumentWrapper::setCurrentController(
1051 const Reference
< frame::XController
>& Controller
)
1052 throw (container::NoSuchElementException
,
1053 uno::RuntimeException
)
1055 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
1057 xModel
->setCurrentController( Controller
);
1060 Reference
< uno::XInterface
> SAL_CALL
ChartDocumentWrapper::getCurrentSelection()
1061 throw (uno::RuntimeException
)
1063 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
1065 return xModel
->getCurrentSelection();
1070 // ____ XComponent ____
1071 void SAL_CALL
ChartDocumentWrapper::dispose()
1072 throw (uno::RuntimeException
)
1075 throw lang::DisposedException(
1076 C2U("ChartDocumentWrapper is disposed" ),
1077 static_cast< ::cppu::OWeakObject
* >( this ));
1079 m_bIsDisposed
= true;
1083 Reference
< lang::XComponent
> xFormerDelegator( m_xDelegator
, uno::UNO_QUERY
);
1084 DisposeHelper::DisposeAndClear( m_xTitle
);
1085 DisposeHelper::DisposeAndClear( m_xSubTitle
);
1086 DisposeHelper::DisposeAndClear( m_xLegend
);
1087 DisposeHelper::DisposeAndClear( m_xChartData
);
1088 DisposeHelper::DisposeAndClear( m_xDiagram
);
1089 DisposeHelper::DisposeAndClear( m_xArea
);
1090 m_xChartView
.set( 0 );
1091 m_xShapeFactory
.set( 0 );
1092 m_xDelegator
.set( 0 );
1094 clearWrappedPropertySet();
1095 m_spChart2ModelContact
->clear();
1098 stopAllComponentListening();
1102 if( xFormerDelegator
.is())
1103 xFormerDelegator
->dispose();
1105 catch( lang::DisposedException
)
1107 // this is ok, don't panic
1110 catch( uno::Exception
&ex
)
1112 ASSERT_EXCEPTION( ex
);
1116 void ChartDocumentWrapper::impl_resetAddIn()
1118 Reference
< util::XRefreshable
> xAddIn( m_xAddIn
);
1125 //make sure that the add-in does not hold a refernce to us anymore:
1126 Reference
< lang::XComponent
> xComp( xAddIn
, uno::UNO_QUERY
);
1131 uno::Reference
< lang::XInitialization
> xInit( xAddIn
, uno::UNO_QUERY
);
1135 uno::Reference
< com::sun::star::chart::XChartDocument
> xDoc( 0 );
1137 uno::Sequence
< uno::Any
> aSeq( &aParam
, 1 );
1138 xInit
->initialize( aSeq
);
1142 catch( const uno::RuntimeException
& ex
)
1144 ASSERT_EXCEPTION( ex
);
1146 catch( const uno::Exception
& ex
)
1148 ASSERT_EXCEPTION( ex
);
1153 void ChartDocumentWrapper::setBaseDiagram( const rtl::OUString
& rBaseDiagram
)
1155 ControllerLockGuard
aCtrlLockGuard( m_spChart2ModelContact
->getChartModel() );
1156 m_aBaseDiagram
= rBaseDiagram
;
1158 uno::Reference
< XDiagram
> xDiagram( ChartDocumentWrapper::createInstance( rBaseDiagram
), uno::UNO_QUERY
);
1160 this->setDiagram( xDiagram
);
1163 rtl::OUString
ChartDocumentWrapper::getBaseDiagram() const
1165 return m_aBaseDiagram
;
1168 Reference
< util::XRefreshable
> ChartDocumentWrapper::getAddIn() const
1173 void ChartDocumentWrapper::setAddIn( const Reference
< util::XRefreshable
>& xAddIn
)
1175 if( m_xAddIn
== xAddIn
)
1178 ControllerLockGuard
aCtrlLockGuard( m_spChart2ModelContact
->getChartModel() );
1181 // initialize AddIn with this as chart document
1182 uno::Reference
< lang::XInitialization
> xInit( m_xAddIn
, uno::UNO_QUERY
);
1186 uno::Reference
< XChartDocument
> xDoc( (XChartDocument
*)this, uno::UNO_QUERY
);
1188 uno::Sequence
< uno::Any
> aSeq( &aParam
, 1 );
1189 xInit
->initialize( aSeq
);
1193 void ChartDocumentWrapper::setUpdateAddIn( sal_Bool bUpdateAddIn
)
1195 m_bUpdateAddIn
= bUpdateAddIn
;
1197 sal_Bool
ChartDocumentWrapper::getUpdateAddIn() const
1199 return m_bUpdateAddIn
;
1202 Reference
< drawing::XShapes
> ChartDocumentWrapper::getAdditionalShapes() const
1204 // get additional non-chart shapes for XML export
1205 uno::Reference
< drawing::XShapes
> xFoundShapes
;
1206 uno::Reference
< drawing::XDrawPage
> xDrawPage( this->impl_getDrawPage() );
1208 uno::Reference
< drawing::XShapes
> xDrawPageShapes( xDrawPage
, uno::UNO_QUERY
);
1209 if( !xDrawPageShapes
.is() )
1210 return xFoundShapes
;
1212 uno::Reference
<drawing::XShapes
> xChartRoot( DrawModelWrapper::getChartRootShape( xDrawPage
) );
1214 // iterate 'flat' over all top-level objects
1215 // and determine all that are no chart objects
1216 ::std::vector
< uno::Reference
< drawing::XShape
> > aShapeVector
;
1217 sal_Int32 nSubCount
= xDrawPageShapes
->getCount();
1218 uno::Reference
< drawing::XShape
> xShape
;
1219 for( sal_Int32 nS
= 0; nS
< nSubCount
; nS
++ )
1221 if( xDrawPageShapes
->getByIndex( nS
) >>= xShape
)
1223 if( xShape
.is() && xChartRoot
!=xShape
)
1224 aShapeVector
.push_back( xShape
);
1228 if( !aShapeVector
.empty() )
1230 // create a shape collection
1231 xFoundShapes
= uno::Reference
< drawing::XShapes
>( SvxShapeCollection_NewInstance(), uno::UNO_QUERY
);
1233 DBG_ASSERT( xFoundShapes
.is(), "Couldn't create a shape collection!" );
1234 if( xFoundShapes
.is())
1236 ::std::vector
< uno::Reference
< drawing::XShape
> >::iterator aIter
;
1237 for( aIter
= aShapeVector
.begin(); aIter
!= aShapeVector
.end(); ++aIter
)
1238 xFoundShapes
->add( *aIter
);
1242 return xFoundShapes
;
1245 void SAL_CALL
ChartDocumentWrapper::addEventListener( const Reference
< lang::XEventListener
>& xListener
)
1246 throw (uno::RuntimeException
)
1248 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
1250 xModel
->addEventListener( xListener
);
1253 void SAL_CALL
ChartDocumentWrapper::removeEventListener( const Reference
< lang::XEventListener
>& aListener
)
1254 throw (uno::RuntimeException
)
1256 Reference
< frame::XModel
> xModel( m_spChart2ModelContact
->getChartModel() );
1258 xModel
->removeEventListener( aListener
);
1261 // ____ XDrawPageSupplier ____
1262 uno::Reference
< drawing::XDrawPage
> SAL_CALL
ChartDocumentWrapper::getDrawPage()
1263 throw (uno::RuntimeException
)
1265 return this->impl_getDrawPage();
1268 uno::Reference
< drawing::XDrawPage
> ChartDocumentWrapper::impl_getDrawPage() const
1269 throw (uno::RuntimeException
)
1271 return m_spChart2ModelContact
->getDrawPage();
1274 // ____ XMultiServiceFactory ____
1275 uno::Reference
< uno::XInterface
> SAL_CALL
ChartDocumentWrapper::createInstance(
1276 const ::rtl::OUString
& aServiceSpecifier
)
1277 throw (uno::Exception
,
1278 uno::RuntimeException
)
1280 uno::Reference
< uno::XInterface
> xResult
;
1282 Reference
< chart2::XChartDocument
> xChartDoc( m_spChart2ModelContact
->getChart2Document() );
1283 if( !xChartDoc
.is() )
1286 bool bServiceFound
= false;
1287 tServiceNameMap
& rMap
= lcl_getStaticServiceNameMap();
1289 tServiceNameMap::const_iterator
aIt( rMap
.find( aServiceSpecifier
));
1290 if( aIt
!= rMap
.end())
1292 bool bCreateDiagram
= false;
1293 uno::Reference
< lang::XMultiServiceFactory
> xManagerFact(
1294 xChartDoc
->getChartTypeManager(), uno::UNO_QUERY
);
1295 uno::Reference
< chart2::XChartTypeTemplate
> xTemplate
;
1297 switch( (*aIt
).second
)
1299 case SERVICE_NAME_AREA_DIAGRAM
:
1300 if( xManagerFact
.is())
1303 xManagerFact
->createInstance(
1304 C2U( "com.sun.star.chart2.template.Area" )), uno::UNO_QUERY
);
1305 bCreateDiagram
= true;
1308 case SERVICE_NAME_BAR_DIAGRAM
:
1309 if( xManagerFact
.is())
1311 // this is for bar and column (the latter is the default if
1312 // no "Vertical=false" property was set)
1314 xManagerFact
->createInstance(
1315 C2U( "com.sun.star.chart2.template.Column" )), uno::UNO_QUERY
);
1316 bCreateDiagram
= true;
1319 case SERVICE_NAME_DONUT_DIAGRAM
:
1320 if( xManagerFact
.is())
1323 xManagerFact
->createInstance(
1324 C2U( "com.sun.star.chart2.template.Donut" )), uno::UNO_QUERY
);
1325 bCreateDiagram
= true;
1328 case SERVICE_NAME_LINE_DIAGRAM
:
1329 if( xManagerFact
.is())
1332 xManagerFact
->createInstance(
1333 C2U( "com.sun.star.chart2.template.Line" )), uno::UNO_QUERY
);
1334 bCreateDiagram
= true;
1337 case SERVICE_NAME_NET_DIAGRAM
:
1338 if( xManagerFact
.is())
1341 xManagerFact
->createInstance(
1342 C2U( "com.sun.star.chart2.template.Net" )), uno::UNO_QUERY
);
1343 bCreateDiagram
= true;
1346 case SERVICE_NAME_FILLED_NET_DIAGRAM
:
1347 if( xManagerFact
.is())
1350 xManagerFact
->createInstance(
1351 C2U( "com.sun.star.chart2.template.FilledNet" )), uno::UNO_QUERY
);
1352 bCreateDiagram
= true;
1354 case SERVICE_NAME_PIE_DIAGRAM
:
1355 if( xManagerFact
.is())
1358 xManagerFact
->createInstance(
1359 C2U( "com.sun.star.chart2.template.Pie" )), uno::UNO_QUERY
);
1360 bCreateDiagram
= true;
1363 case SERVICE_NAME_STOCK_DIAGRAM
:
1364 if( xManagerFact
.is())
1367 xManagerFact
->createInstance(
1368 C2U( "com.sun.star.chart2.template.StockLowHighClose" )), uno::UNO_QUERY
);
1369 bCreateDiagram
= true;
1372 case SERVICE_NAME_XY_DIAGRAM
:
1373 if( xManagerFact
.is())
1376 xManagerFact
->createInstance(
1377 C2U( "com.sun.star.chart2.template.ScatterLineSymbol" )), uno::UNO_QUERY
);
1378 bCreateDiagram
= true;
1382 case SERVICE_NAME_BUBBLE_DIAGRAM
:
1383 if( xManagerFact
.is())
1386 xManagerFact
->createInstance(
1387 C2U( "com.sun.star.chart2.template.Bubble" )), uno::UNO_QUERY
);
1388 bCreateDiagram
= true;
1392 case SERVICE_NAME_DASH_TABLE
:
1393 case SERVICE_NAME_GARDIENT_TABLE
:
1394 case SERVICE_NAME_HATCH_TABLE
:
1395 case SERVICE_NAME_BITMAP_TABLE
:
1396 case SERVICE_NAME_TRANSP_GRADIENT_TABLE
:
1397 case SERVICE_NAME_MARKER_TABLE
:
1399 uno::Reference
< lang::XMultiServiceFactory
> xTableFactory( xChartDoc
, uno::UNO_QUERY
);
1400 DBG_ASSERT( xTableFactory
.get() != this, "new model is expected to implement service factory for gradient table etc" );
1401 if( xTableFactory
.is() && xTableFactory
.get() != this )
1402 xResult
.set( xTableFactory
->createInstance( aIt
->first
), uno::UNO_QUERY
);
1406 case SERVICE_NAME_NAMESPACE_MAP
:
1407 // xResult = svx::NamespaceMap_createInstance( aWhichIds, &m_pModel->GetPool() );
1409 case SERVICE_NAME_EXPORT_GRAPHIC_RESOLVER
:
1410 // xResult = static_cast< ::cppu::OWeakObject * >( new SvXMLGraphicHelper( GRAPHICHELPER_MODE_WRITE ));
1412 case SERVICE_NAME_IMPORT_GRAPHIC_RESOLVER
:
1413 // xResult = static_cast< ::cppu::OWeakObject * >( new SvXMLGraphicHelper( GRAPHICHELPER_MODE_READ ));
1417 if( bCreateDiagram
&& xTemplate
.is() )
1421 uno::Reference
< chart2::XDiagram
> xDia( xChartDoc
->getFirstDiagram());
1424 // /-- locked controllers
1425 ControllerLockGuard
aCtrlLockGuard( Reference
< frame::XModel
>( xChartDoc
, uno::UNO_QUERY
));
1426 xTemplate
->changeDiagram( xDia
);
1427 // \-- locked controllers
1431 // /-- locked controllers
1432 ControllerLockGuard
aCtrlLockGuard( Reference
< frame::XModel
>( xChartDoc
, uno::UNO_QUERY
));
1433 xDia
.set( xTemplate
->createDiagramByDataSource(
1434 uno::Reference
< chart2::data::XDataSource
>(),
1435 uno::Sequence
< beans::PropertyValue
>()));
1436 xChartDoc
->setFirstDiagram( xDia
);
1437 // \-- locked controllers
1440 xResult
= static_cast< ::cppu::OWeakObject
* >( new DiagramWrapper( m_spChart2ModelContact
));
1442 catch( uno::Exception
& ex
)
1444 ASSERT_EXCEPTION( ex
);
1448 bServiceFound
= true;
1450 else if( aServiceSpecifier
.equals( CHART_RENDERER_SERVICE_IMPLEMENTATION_NAME
) )
1452 Reference
< lang::XUnoTunnel
> xChartRenderer( new ChartRenderer( m_spChart2ModelContact
->getChartModel() ) );
1453 xResult
.set( xChartRenderer
);
1454 bServiceFound
= true;
1456 else if( aServiceSpecifier
.equals( C2U("com.sun.star.comp.chart2.DataSeriesWrapper") ) )
1458 Reference
< beans::XPropertySet
> xDataSeries( new DataSeriesPointWrapper( m_spChart2ModelContact
) );
1459 xResult
.set( xDataSeries
);
1460 bServiceFound
= true;
1462 else if( aServiceSpecifier
.equals( CHART_VIEW_SERVICE_NAME
) )
1464 if( !m_xChartView
.is() )
1466 Reference
< lang::XMultiServiceFactory
> xFact(
1467 m_spChart2ModelContact
->m_xContext
->getServiceManager(), uno::UNO_QUERY_THROW
);
1470 Reference
< lang::XInitialization
> xViewInit( xFact
->createInstance(
1471 CHART_VIEW_SERVICE_NAME
), uno::UNO_QUERY
);
1476 m_xChartView
= xViewInit
;
1478 Sequence
< Any
> aArguments(2);
1479 Reference
<frame::XModel
> xModel(this);
1480 aArguments
[0]=uno::makeAny(xModel
);
1481 sal_Bool bRefreshAddIn
= sal_True
;
1482 aArguments
[1]=uno::makeAny(bRefreshAddIn
);
1483 xViewInit
->initialize(aArguments
);
1485 catch( uno::Exception
& ex
)
1487 ASSERT_EXCEPTION( ex
);
1492 xResult
.set( m_xChartView
);
1493 bServiceFound
= true;
1497 // try to create a shape
1500 if( !m_xShapeFactory
.is() && m_xChartView
.is() )
1502 Reference
< lang::XUnoTunnel
> xUnoTunnel(m_xChartView
,uno::UNO_QUERY
);
1505 ExplicitValueProvider
* pProvider
= reinterpret_cast<ExplicitValueProvider
*>(xUnoTunnel
->getSomething(
1506 ExplicitValueProvider::getUnoTunnelId() ));
1508 m_xShapeFactory
.set( pProvider
->getDrawModelWrapper()->getShapeFactory() );
1511 if( m_xShapeFactory
.is() )
1513 xResult
= m_xShapeFactory
->createInstance( aServiceSpecifier
);
1514 bServiceFound
= true;
1517 catch( const uno::Exception
)
1519 // couldn't create shape
1523 // finally, try to create an addin
1524 if( !bServiceFound
)
1528 Reference
< lang::XMultiServiceFactory
> xFact(
1529 m_spChart2ModelContact
->m_xContext
->getServiceManager(), uno::UNO_QUERY_THROW
);
1532 uno::Reference
< util::XRefreshable
> xAddIn(
1533 xFact
->createInstance( aServiceSpecifier
), uno::UNO_QUERY
);
1537 bServiceFound
= true;
1541 catch( const uno::Exception
& ex
)
1544 // couldn't create service
1551 uno::Reference
< uno::XInterface
> SAL_CALL
ChartDocumentWrapper::createInstanceWithArguments(
1552 const ::rtl::OUString
& ServiceSpecifier
,
1553 const uno::Sequence
< uno::Any
>& Arguments
)
1554 throw (uno::Exception
,
1555 uno::RuntimeException
)
1557 OSL_ENSURE( Arguments
.getLength(), "createInstanceWithArguments: Warning: Arguments are ignored" );
1560 return createInstance( ServiceSpecifier
);
1563 uno::Sequence
< ::rtl::OUString
> SAL_CALL
ChartDocumentWrapper::getAvailableServiceNames()
1564 throw (uno::RuntimeException
)
1566 tServiceNameMap
& rMap
= lcl_getStaticServiceNameMap();
1567 uno::Sequence
< ::rtl::OUString
> aResult( rMap
.size());
1569 ::std::transform( rMap
.begin(), rMap
.end(),
1571 ::std::select1st
< tServiceNameMap::value_type
>() );
1576 // // uno::Sequence< OUString > aDrawServices( SvxUnoDrawMSFactory::getAvailableServiceNames() );
1577 // // const OUString * pArr = aDrawServices.getConstArray();
1578 // // aServices.insert( aServices.end(), pArr, pArr + aDrawServices.getLength() );
1583 // uno::Sequence< OUString > aAddIns( GetAddInCollection().GetAddInNames() );
1584 // pArr = aAddIns.getConstArray();
1585 // aServices.insert( aServices.end(), pArr, pArr + aAddIns.getLength() );
1587 // return ContainerToSequence( aServices );
1590 // ____ XAggregation ____
1591 void SAL_CALL
ChartDocumentWrapper::setDelegator(
1592 const uno::Reference
< uno::XInterface
>& rDelegator
)
1593 throw (uno::RuntimeException
)
1595 if( rDelegator
.is())
1597 m_xDelegator
= rDelegator
;
1598 m_spChart2ModelContact
->setModel( uno::Reference
< frame::XModel
>(m_xDelegator
, uno::UNO_QUERY
) );
1602 // this is a sort of dispose() from the new model,so release ressources here
1607 catch( uno::Exception
&ex
)
1609 ASSERT_EXCEPTION( ex
);
1614 uno::Any SAL_CALL
ChartDocumentWrapper::queryAggregation( const uno::Type
& rType
)
1615 throw (uno::RuntimeException
)
1617 return ChartDocumentWrapper_Base::queryInterface( rType
);
1620 // ____ ::utl::OEventListenerAdapter ____
1621 void ChartDocumentWrapper::_disposing( const lang::EventObject
& rSource
)
1623 if( rSource
.Source
== m_xTitle
)
1625 else if( rSource
.Source
== m_xSubTitle
)
1626 m_xSubTitle
.set( 0 );
1627 else if( rSource
.Source
== m_xLegend
)
1629 else if( rSource
.Source
== m_xChartData
)
1630 m_xChartData
.set( 0 );
1631 else if( rSource
.Source
== m_xDiagram
)
1632 m_xDiagram
.set( 0 );
1633 else if( rSource
.Source
== m_xArea
)
1635 else if( rSource
.Source
== m_xAddIn
)
1637 else if( rSource
.Source
== m_xChartView
)
1638 m_xChartView
.set( 0 );
1641 // ================================================================================
1643 // WrappedPropertySet
1644 Reference
< beans::XPropertySet
> ChartDocumentWrapper::getInnerPropertySet()
1648 const Sequence
< beans::Property
>& ChartDocumentWrapper::getPropertySequence()
1650 return lcl_GetPropertySequence();
1653 const std::vector
< WrappedProperty
* > ChartDocumentWrapper::createWrappedProperties()
1655 ::std::vector
< ::chart::WrappedProperty
* > aWrappedProperties
;
1656 aWrappedProperties
.push_back( new WrappedDataSourceLabelsInFirstRowProperty( m_spChart2ModelContact
) );
1657 aWrappedProperties
.push_back( new WrappedDataSourceLabelsInFirstColumnProperty( m_spChart2ModelContact
) );
1658 aWrappedProperties
.push_back( new WrappedHasLegendProperty( m_spChart2ModelContact
) );
1659 aWrappedProperties
.push_back( new WrappedHasMainTitleProperty( m_spChart2ModelContact
) );
1660 aWrappedProperties
.push_back( new WrappedHasSubTitleProperty( m_spChart2ModelContact
) );
1661 aWrappedProperties
.push_back( new WrappedAddInProperty( *this ) );
1662 aWrappedProperties
.push_back( new WrappedBaseDiagramProperty( *this ) );
1663 aWrappedProperties
.push_back( new WrappedAdditionalShapesProperty( *this ) );
1664 aWrappedProperties
.push_back( new WrappedRefreshAddInAllowedProperty( *this ) );
1665 aWrappedProperties
.push_back( new WrappedIgnoreProperty( C2U("NullDate"),Any() ) ); // i99104
1667 return aWrappedProperties
;
1670 // ================================================================================
1672 uno::Sequence
< ::rtl::OUString
> ChartDocumentWrapper::getSupportedServiceNames_Static()
1674 uno::Sequence
< ::rtl::OUString
> aServices( 4 );
1675 aServices
[ 0 ] = C2U( "com.sun.star.chart.ChartDocument" );
1676 aServices
[ 1 ] = CHART_CHARTAPIWRAPPER_SERVICE_NAME
;
1677 aServices
[ 2 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" );
1678 aServices
[ 3 ] = C2U( "com.sun.star.beans.PropertySet" );
1682 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
1683 APPHELPER_XSERVICEINFO_IMPL( ChartDocumentWrapper
, CHART_CHARTAPIWRAPPER_IMPLEMENTATION_NAME
);
1685 } // namespace wrapper
1686 } // namespace chart