LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - ChartDocumentWrapper.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 447 663 67.4 %
Date: 2015-06-13 12:38:46 Functions: 64 85 75.3 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11