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

Generated by: LCOV version 1.10