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