LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - ChartDocumentWrapper.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 653 0.0 %
Date: 2014-04-14 Functions: 0 84 0.0 %
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           0 : tServiceNameMap & lcl_getStaticServiceNameMap()
     112             : {
     113             :     static tServiceNameMap aServiceNameMap(
     114             :         tMakeServiceNameMap
     115             :         ( "com.sun.star.chart.AreaDiagram",                    SERVICE_NAME_AREA_DIAGRAM )
     116           0 :         ( "com.sun.star.chart.BarDiagram",                     SERVICE_NAME_BAR_DIAGRAM )
     117           0 :         ( "com.sun.star.chart.DonutDiagram",                   SERVICE_NAME_DONUT_DIAGRAM )
     118           0 :         ( "com.sun.star.chart.LineDiagram",                    SERVICE_NAME_LINE_DIAGRAM )
     119           0 :         ( "com.sun.star.chart.NetDiagram",                     SERVICE_NAME_NET_DIAGRAM )
     120           0 :         ( "com.sun.star.chart.FilledNetDiagram",               SERVICE_NAME_FILLED_NET_DIAGRAM )
     121           0 :         ( "com.sun.star.chart.PieDiagram",                     SERVICE_NAME_PIE_DIAGRAM )
     122           0 :         ( "com.sun.star.chart.StockDiagram",                   SERVICE_NAME_STOCK_DIAGRAM )
     123           0 :         ( "com.sun.star.chart.XYDiagram",                      SERVICE_NAME_XY_DIAGRAM )
     124           0 :         ( "com.sun.star.chart.BubbleDiagram",                  SERVICE_NAME_BUBBLE_DIAGRAM )
     125           0 :         ( "com.sun.star.chart.GL3DBarDiagram",                 SERVICE_NAME_GL3DBAR_DIAGRAM )
     126             : 
     127           0 :         ( "com.sun.star.drawing.DashTable",                    SERVICE_NAME_DASH_TABLE )
     128           0 :         ( "com.sun.star.drawing.GradientTable",                SERVICE_NAME_GARDIENT_TABLE )
     129           0 :         ( "com.sun.star.drawing.HatchTable",                   SERVICE_NAME_HATCH_TABLE )
     130           0 :         ( "com.sun.star.drawing.BitmapTable",                  SERVICE_NAME_BITMAP_TABLE )
     131           0 :         ( "com.sun.star.drawing.TransparencyGradientTable",    SERVICE_NAME_TRANSP_GRADIENT_TABLE )
     132           0 :         ( "com.sun.star.drawing.MarkerTable",                  SERVICE_NAME_MARKER_TABLE )
     133             : 
     134           0 :         ( "com.sun.star.xml.NamespaceMap",                     SERVICE_NAME_NAMESPACE_MAP )
     135           0 :         ( "com.sun.star.document.ExportGraphicObjectResolver", SERVICE_NAME_EXPORT_GRAPHIC_RESOLVER )
     136           0 :         ( "com.sun.star.document.ImportGraphicObjectResolver", SERVICE_NAME_IMPORT_GRAPHIC_RESOLVER )
     137           0 :         );
     138             : 
     139           0 :     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           0 : void lcl_AddPropertiesToVector(
     159             :     ::std::vector< Property > & rOutProperties )
     160             : {
     161             :     rOutProperties.push_back(
     162             :         Property( "HasMainTitle",
     163             :                   PROP_DOCUMENT_HAS_MAIN_TITLE,
     164           0 :                   ::getBooleanCppuType(),
     165             :                   //#i111967# no PropertyChangeEvent is fired on change so far
     166           0 :                   beans::PropertyAttribute::MAYBEDEFAULT ));
     167             :     rOutProperties.push_back(
     168             :         Property( "HasSubTitle",
     169             :                   PROP_DOCUMENT_HAS_SUB_TITLE,
     170           0 :                   ::getBooleanCppuType(),
     171             :                   //#i111967# no PropertyChangeEvent is fired on change so far
     172           0 :                   beans::PropertyAttribute::MAYBEDEFAULT ));
     173             :     rOutProperties.push_back(
     174             :         Property( "HasLegend",
     175             :                   PROP_DOCUMENT_HAS_LEGEND,
     176           0 :                   ::getBooleanCppuType(),
     177             :                   //#i111967# no PropertyChangeEvent is fired on change so far
     178           0 :                   beans::PropertyAttribute::MAYBEDEFAULT ));
     179             : 
     180             :     // really needed?
     181             :     rOutProperties.push_back(
     182             :         Property( "DataSourceLabelsInFirstRow",
     183             :                   PROP_DOCUMENT_LABELS_IN_FIRST_ROW,
     184           0 :                   ::getBooleanCppuType(),
     185             :                   beans::PropertyAttribute::BOUND
     186           0 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     187             :     rOutProperties.push_back(
     188             :         Property( "DataSourceLabelsInFirstColumn",
     189             :                   PROP_DOCUMENT_LABELS_IN_FIRST_COLUMN,
     190           0 :                   ::getBooleanCppuType(),
     191             :                   //#i111967# no PropertyChangeEvent is fired on change so far
     192           0 :                   beans::PropertyAttribute::MAYBEDEFAULT ));
     193             : 
     194             :     //add-in
     195             :     rOutProperties.push_back(
     196             :         Property( "AddIn",
     197             :                   PROP_DOCUMENT_ADDIN,
     198           0 :                   ::getCppuType( reinterpret_cast< Reference< util::XRefreshable > * >(0)),
     199             :                   beans::PropertyAttribute::BOUND
     200           0 :                   | beans::PropertyAttribute::MAYBEVOID ));
     201             :     rOutProperties.push_back(
     202             :         Property( "BaseDiagram",
     203             :                   PROP_DOCUMENT_BASEDIAGRAM,
     204           0 :                   ::getCppuType( reinterpret_cast< const OUString * >(0)),
     205             :                   beans::PropertyAttribute::BOUND
     206           0 :                   | beans::PropertyAttribute::MAYBEVOID ));
     207             :     rOutProperties.push_back(
     208             :         Property( "AdditionalShapes",
     209             :                   PROP_DOCUMENT_ADDITIONAL_SHAPES,
     210           0 :                   ::getCppuType( reinterpret_cast< Reference< drawing::XShapes > * >(0)),
     211             :                   beans::PropertyAttribute::BOUND
     212             :                   | beans::PropertyAttribute::MAYBEVOID
     213           0 :                   | beans::PropertyAttribute::READONLY ));
     214             :     rOutProperties.push_back(
     215             :         Property( "RefreshAddInAllowed",
     216             :                   PROP_DOCUMENT_UPDATE_ADDIN,
     217           0 :                   ::getBooleanCppuType(),
     218             :                   //#i111967# no PropertyChangeEvent is fired on change so far
     219           0 :                   beans::PropertyAttribute::TRANSIENT ));
     220             : 
     221             :     // table:null-date // i99104
     222             :     rOutProperties.push_back(
     223             :         Property( "NullDate",
     224             :                   PROP_DOCUMENT_NULL_DATE,
     225           0 :                   ::getCppuType( static_cast< const ::com::sun::star::util::DateTime * >(0)),
     226           0 :                   beans::PropertyAttribute::MAYBEVOID ));
     227             : 
     228             :     rOutProperties.push_back(
     229             :         Property( "EnableComplexChartTypes",
     230             :                   PROP_DOCUMENT_ENABLE_COMPLEX_CHARTTYPES,
     231           0 :                   ::getBooleanCppuType(),
     232             :                   //#i112666# no PropertyChangeEvent is fired on change so far
     233           0 :                   beans::PropertyAttribute::MAYBEDEFAULT ) );
     234             :     rOutProperties.push_back(
     235             :         Property( "EnableDataTableDialog",
     236             :                   PROP_DOCUMENT_ENABLE_DATATABLE_DIALOG,
     237           0 :                   ::getBooleanCppuType(),
     238             :                   //#i112666# no PropertyChangeEvent is fired on change so far
     239           0 :                   beans::PropertyAttribute::MAYBEDEFAULT ) );
     240           0 : }
     241             : 
     242             : struct StaticChartDocumentWrapperPropertyArray_Initializer
     243             : {
     244           0 :     Sequence< Property >* operator()()
     245             :     {
     246           0 :         static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
     247           0 :         return &aPropSeq;
     248             :     }
     249             : 
     250             : private:
     251           0 :     uno::Sequence< Property > lcl_GetPropertySequence()
     252             :     {
     253           0 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
     254           0 :         lcl_AddPropertiesToVector( aProperties );
     255             : 
     256             :         ::std::sort( aProperties.begin(), aProperties.end(),
     257           0 :                      ::chart::PropertyNameLess() );
     258             : 
     259           0 :         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           0 : WrappedDataSourceLabelsInFirstRowProperty::WrappedDataSourceLabelsInFirstRowProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
     296             :             : WrappedProperty("DataSourceLabelsInFirstRow",OUString())
     297             :             , m_spChart2ModelContact( spChart2ModelContact )
     298           0 :             , m_aOuterValue()
     299             : {
     300           0 :     m_aOuterValue = WrappedDataSourceLabelsInFirstRowProperty::getPropertyDefault( 0 );
     301           0 : }
     302             : 
     303           0 : WrappedDataSourceLabelsInFirstRowProperty::~WrappedDataSourceLabelsInFirstRowProperty()
     304             : {
     305           0 : }
     306             : 
     307           0 : 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           0 :     sal_Bool bLabelsInFirstRow = sal_True;
     311           0 :     if( ! (rOuterValue >>= bLabelsInFirstRow) )
     312           0 :         throw lang::IllegalArgumentException("Property DataSourceLabelsInFirstRow requires value of type boolean", 0, 0 );
     313             : 
     314           0 :     m_aOuterValue = rOuterValue;
     315           0 :     bool bNewValue = bLabelsInFirstRow;
     316             : 
     317           0 :     OUString aRangeString;
     318           0 :     bool bUseColumns = true;
     319           0 :     bool bFirstCellAsLabel = true;
     320           0 :     bool bHasCategories = true;
     321           0 :     uno::Sequence< sal_Int32 > aSequenceMapping;
     322             : 
     323           0 :     if( DataSourceHelper::detectRangeSegmentation(
     324             :             m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns
     325           0 :             , bFirstCellAsLabel, bHasCategories ) )
     326             :     {
     327           0 :         if( bUseColumns && bNewValue != bFirstCellAsLabel )
     328             :         {
     329             :             DataSourceHelper::setRangeSegmentation(
     330           0 :                 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           0 :     }
     338           0 : }
     339             : 
     340           0 : Any WrappedDataSourceLabelsInFirstRowProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
     341             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     342             : {
     343           0 :     OUString aRangeString;
     344           0 :     bool bUseColumns = true;
     345           0 :     bool bFirstCellAsLabel = true;
     346           0 :     bool bHasCategories = true;
     347           0 :     uno::Sequence< sal_Int32 > aSequenceMapping;
     348             : 
     349           0 :     if( DataSourceHelper::detectRangeSegmentation(
     350             :             m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns
     351           0 :             , bFirstCellAsLabel, bHasCategories ) )
     352             :     {
     353           0 :         sal_Bool bLabelsInFirstRow = sal_True;
     354           0 :         if( bUseColumns )
     355           0 :             bLabelsInFirstRow = bFirstCellAsLabel;
     356             :         else
     357           0 :             bLabelsInFirstRow = bHasCategories;
     358             : 
     359           0 :         m_aOuterValue <<= bLabelsInFirstRow;
     360             :     }
     361           0 :     return m_aOuterValue;
     362             : }
     363             : 
     364           0 : Any WrappedDataSourceLabelsInFirstRowProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
     365             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     366             : {
     367           0 :     Any aRet;
     368           0 :     aRet <<= sal_True;
     369           0 :     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           0 : WrappedDataSourceLabelsInFirstColumnProperty::WrappedDataSourceLabelsInFirstColumnProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
     394             :             : WrappedProperty("DataSourceLabelsInFirstColumn",OUString())
     395             :             , m_spChart2ModelContact( spChart2ModelContact )
     396           0 :             , m_aOuterValue()
     397             : {
     398           0 :     m_aOuterValue = WrappedDataSourceLabelsInFirstColumnProperty::getPropertyDefault( 0 );
     399           0 : }
     400             : 
     401           0 : WrappedDataSourceLabelsInFirstColumnProperty::~WrappedDataSourceLabelsInFirstColumnProperty()
     402             : {
     403           0 : }
     404             : 
     405           0 : 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           0 :     sal_Bool bLabelsInFirstRow = sal_True;
     409           0 :     if( ! (rOuterValue >>= bLabelsInFirstRow) )
     410           0 :         throw lang::IllegalArgumentException("Property DataSourceLabelsInFirstRow requires value of type boolean", 0, 0 );
     411             : 
     412           0 :     m_aOuterValue = rOuterValue;
     413           0 :     bool bNewValue = bLabelsInFirstRow;
     414             : 
     415           0 :     OUString aRangeString;
     416           0 :     bool bUseColumns = true;
     417           0 :     bool bFirstCellAsLabel = true;
     418           0 :     bool bHasCategories = true;
     419           0 :     uno::Sequence< sal_Int32 > aSequenceMapping;
     420             : 
     421           0 :     if( DataSourceHelper::detectRangeSegmentation(
     422             :             m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns
     423           0 :             , bFirstCellAsLabel, bHasCategories ) )
     424             :     {
     425           0 :         if( bUseColumns && bNewValue != bHasCategories )
     426             :         {
     427             :             DataSourceHelper::setRangeSegmentation(
     428           0 :                 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           0 :     }
     436           0 : }
     437             : 
     438           0 : Any WrappedDataSourceLabelsInFirstColumnProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
     439             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     440             : {
     441           0 :     OUString aRangeString;
     442           0 :     bool bUseColumns = true;
     443           0 :     bool bFirstCellAsLabel = true;
     444           0 :     bool bHasCategories = true;
     445           0 :     uno::Sequence< sal_Int32 > aSequenceMapping;
     446             : 
     447           0 :     if( DataSourceHelper::detectRangeSegmentation(
     448             :             m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns
     449           0 :             , bFirstCellAsLabel, bHasCategories ) )
     450             :     {
     451           0 :         sal_Bool bLabelsInFirstColumn = sal_True;
     452           0 :         if( bUseColumns )
     453           0 :             bLabelsInFirstColumn = bHasCategories;
     454             :         else
     455           0 :             bLabelsInFirstColumn = bFirstCellAsLabel;
     456             : 
     457           0 :         m_aOuterValue <<= bLabelsInFirstColumn;
     458             :     }
     459           0 :     return m_aOuterValue;
     460             : }
     461             : 
     462           0 : Any WrappedDataSourceLabelsInFirstColumnProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
     463             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     464             : {
     465           0 :     Any aRet;
     466           0 :     aRet <<= sal_True;
     467           0 :     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           0 : WrappedHasLegendProperty::WrappedHasLegendProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
     491             :             : WrappedProperty("HasLegend",OUString())
     492           0 :             , m_spChart2ModelContact( spChart2ModelContact )
     493             : {
     494           0 : }
     495             : 
     496           0 : WrappedHasLegendProperty::~WrappedHasLegendProperty()
     497             : {
     498           0 : }
     499             : 
     500           0 : 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           0 :     sal_Bool bNewValue = sal_True;
     504           0 :     if( ! (rOuterValue >>= bNewValue) )
     505           0 :         throw lang::IllegalArgumentException("Property HasLegend requires value of type boolean", 0, 0 );
     506             : 
     507             :     try
     508             :     {
     509           0 :         Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( *m_spChart2ModelContact->getModel(), m_spChart2ModelContact->m_xContext,bNewValue ));
     510           0 :         if(xLegend.is())
     511             :         {
     512           0 :             Reference< beans::XPropertySet > xLegendProp( xLegend, uno::UNO_QUERY_THROW );
     513           0 :             sal_Bool bOldValue = sal_True;
     514           0 :             Any aAOld = xLegendProp->getPropertyValue("Show");
     515           0 :             aAOld >>= bOldValue;
     516           0 :             if( bOldValue != bNewValue )
     517           0 :                 xLegendProp->setPropertyValue("Show", uno::makeAny( bNewValue ));
     518           0 :         }
     519             :     }
     520           0 :     catch (const uno::Exception& ex)
     521             :     {
     522             :         ASSERT_EXCEPTION( ex );
     523             :     }
     524           0 : }
     525             : 
     526           0 : Any WrappedHasLegendProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
     527             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     528             : {
     529           0 :     Any aRet;
     530             :     try
     531             :     {
     532             :         Reference< beans::XPropertySet > xLegendProp(
     533           0 :             LegendHelper::getLegend( *m_spChart2ModelContact->getModel() ), uno::UNO_QUERY );
     534           0 :         if( xLegendProp.is())
     535           0 :             aRet = xLegendProp->getPropertyValue("Show");
     536             :         else
     537           0 :             aRet <<= sal_False;
     538             :     }
     539           0 :     catch (const uno::Exception& ex)
     540             :     {
     541             :         ASSERT_EXCEPTION( ex );
     542             :     }
     543           0 :     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           0 : WrappedHasMainTitleProperty::WrappedHasMainTitleProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
     575             :             : WrappedProperty("HasMainTitle",OUString())
     576           0 :             , m_spChart2ModelContact( spChart2ModelContact )
     577             : {
     578           0 : }
     579             : 
     580           0 : WrappedHasMainTitleProperty::~WrappedHasMainTitleProperty()
     581             : {
     582           0 : }
     583             : 
     584           0 : 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           0 :     sal_Bool bNewValue = sal_True;
     588           0 :     if( ! (rOuterValue >>= bNewValue) )
     589           0 :         throw lang::IllegalArgumentException("Property HasMainTitle requires value of type boolean", 0, 0 );
     590             : 
     591             :     try
     592             :     {
     593           0 :         if( bNewValue )
     594           0 :             TitleHelper::createTitle( TitleHelper::MAIN_TITLE, "main-title", m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext );
     595             :         else
     596           0 :             TitleHelper::removeTitle( TitleHelper::MAIN_TITLE, m_spChart2ModelContact->getChartModel() );
     597             :     }
     598           0 :     catch (const uno::Exception& ex)
     599             :     {
     600             :         ASSERT_EXCEPTION( ex );
     601             :     }
     602           0 : }
     603             : 
     604           0 : Any WrappedHasMainTitleProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
     605             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     606             : {
     607           0 :     Any aRet;
     608             :     try
     609             :     {
     610           0 :         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           0 :     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           0 : WrappedHasSubTitleProperty::WrappedHasSubTitleProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
     648             :             : WrappedProperty("HasSubTitle",OUString())
     649           0 :             , m_spChart2ModelContact( spChart2ModelContact )
     650             : {
     651           0 : }
     652             : 
     653           0 : WrappedHasSubTitleProperty::~WrappedHasSubTitleProperty()
     654             : {
     655           0 : }
     656             : 
     657           0 : 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           0 :     sal_Bool bNewValue = sal_True;
     661           0 :     if( ! (rOuterValue >>= bNewValue) )
     662           0 :         throw lang::IllegalArgumentException("Property HasSubTitle requires value of type boolean", 0, 0 );
     663             : 
     664             :     try
     665             :     {
     666           0 :         if( bNewValue )
     667           0 :             TitleHelper::createTitle( TitleHelper::SUB_TITLE, "sub-title", m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext );
     668             :         else
     669           0 :             TitleHelper::removeTitle( TitleHelper::SUB_TITLE, m_spChart2ModelContact->getChartModel() );
     670             :     }
     671           0 :     catch (const uno::Exception& ex)
     672             :     {
     673             :         ASSERT_EXCEPTION( ex );
     674             :     }
     675           0 : }
     676             : 
     677           0 : Any WrappedHasSubTitleProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
     678             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     679             : {
     680           0 :     Any aRet;
     681             :     try
     682             :     {
     683           0 :         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           0 :     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           0 : ChartDocumentWrapper::ChartDocumentWrapper(
     701             :     const Reference< uno::XComponentContext > & xContext ) :
     702           0 :         m_spChart2ModelContact( new Chart2ModelContact( xContext ) ),
     703             :         m_bUpdateAddIn( sal_True ),
     704           0 :         m_bIsDisposed( false )
     705             : {
     706           0 : }
     707             : 
     708           0 : ChartDocumentWrapper::~ChartDocumentWrapper()
     709             : {
     710           0 :     stopAllComponentListening();
     711           0 : }
     712             : 
     713             : // ____ XInterface (for new interfaces) ____
     714           0 : uno::Any SAL_CALL ChartDocumentWrapper::queryInterface( const uno::Type& aType )
     715             :     throw (uno::RuntimeException, std::exception)
     716             : {
     717           0 :     if( m_xDelegator.is())
     718             :         // calls queryAggregation if the delegator doesn't know aType
     719           0 :         return m_xDelegator->queryInterface( aType );
     720             :     else
     721           0 :         return queryAggregation( aType );
     722             : }
     723             : 
     724             : // ____ chart::XChartDocument (old API wrapper) ____
     725           0 : Reference< drawing::XShape > SAL_CALL ChartDocumentWrapper::getTitle()
     726             :     throw (uno::RuntimeException, std::exception)
     727             : {
     728           0 :     if( !m_xTitle.is()  )
     729             :     {
     730           0 :         ControllerLockGuardUNO aCtrlLockGuard( Reference< frame::XModel >( m_spChart2ModelContact->getChart2Document(), uno::UNO_QUERY ));
     731           0 :         m_xTitle = new TitleWrapper( TitleHelper::MAIN_TITLE, m_spChart2ModelContact );
     732             :     }
     733           0 :     return m_xTitle;
     734             : }
     735             : 
     736           0 : Reference< drawing::XShape > SAL_CALL ChartDocumentWrapper::getSubTitle()
     737             :     throw (uno::RuntimeException, std::exception)
     738             : {
     739           0 :     if( !m_xSubTitle.is() )
     740             :     {
     741           0 :         ControllerLockGuardUNO aCtrlLockGuard( Reference< frame::XModel >( m_spChart2ModelContact->getChart2Document(), uno::UNO_QUERY ));
     742           0 :         m_xSubTitle = new TitleWrapper( TitleHelper::SUB_TITLE, m_spChart2ModelContact );
     743             :     }
     744           0 :     return m_xSubTitle;
     745             : }
     746             : 
     747           0 : Reference< drawing::XShape > SAL_CALL ChartDocumentWrapper::getLegend()
     748             :     throw (uno::RuntimeException, std::exception)
     749             : {
     750           0 :     if( ! m_xLegend.is())
     751             :     {
     752           0 :         m_xLegend = new LegendWrapper( m_spChart2ModelContact );
     753           0 :         Reference< lang::XComponent > xComp( m_xLegend, uno::UNO_QUERY );
     754             :     }
     755             : 
     756           0 :     return m_xLegend;
     757             : }
     758             : 
     759           0 : Reference< beans::XPropertySet > SAL_CALL ChartDocumentWrapper::getArea()
     760             :     throw (uno::RuntimeException, std::exception)
     761             : {
     762           0 :     if( ! m_xArea.is())
     763             :     {
     764           0 :         m_xArea.set( new AreaWrapper( m_spChart2ModelContact ) );
     765           0 :         Reference< lang::XComponent > xComp( m_xArea, uno::UNO_QUERY );
     766             :     }
     767             : 
     768           0 :     return m_xArea;
     769             : }
     770             : 
     771           0 : Reference< XDiagram > SAL_CALL ChartDocumentWrapper::getDiagram()
     772             :     throw (uno::RuntimeException, std::exception)
     773             : {
     774           0 :     if( !m_xDiagram.is()  )
     775             :     {
     776             :         try
     777             :         {
     778           0 :             m_xDiagram = new DiagramWrapper( m_spChart2ModelContact );
     779             :         }
     780           0 :         catch (const uno::Exception& ex)
     781             :         {
     782             :             ASSERT_EXCEPTION( ex );
     783             :         }
     784             :     }
     785             : 
     786           0 :     return m_xDiagram;
     787             : }
     788             : 
     789           0 : void SAL_CALL ChartDocumentWrapper::setDiagram( const Reference< XDiagram >& xDiagram )
     790             :     throw (uno::RuntimeException, std::exception)
     791             : {
     792           0 :     uno::Reference< util::XRefreshable > xAddIn( xDiagram, uno::UNO_QUERY );
     793           0 :     if( xAddIn.is() )
     794             :     {
     795           0 :         setAddIn( xAddIn );
     796             :     }
     797           0 :     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           0 :         Reference< chart2::XDiagramProvider > xNewDiaProvider( xDiagram, uno::UNO_QUERY_THROW );
     803           0 :         Reference< chart2::XDiagram > xNewDia( xNewDiaProvider->getDiagram());
     804             : 
     805             :         try
     806             :         {
     807           0 :             Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
     808           0 :             if( xChartDoc.is() )
     809             :             {
     810             :                 // set the new diagram
     811           0 :                 xChartDoc->setFirstDiagram( xNewDia );
     812           0 :                 m_xDiagram = xDiagram;
     813           0 :             }
     814             :         }
     815           0 :         catch (const uno::Exception& ex)
     816             :         {
     817             :             ASSERT_EXCEPTION( ex );
     818           0 :         }
     819           0 :     }
     820           0 : }
     821             : 
     822           0 : Reference< XChartData > SAL_CALL ChartDocumentWrapper::getData()
     823             :     throw (uno::RuntimeException, std::exception)
     824             : {
     825           0 :     if( !m_xChartData.is() )
     826             :     {
     827           0 :         m_xChartData.set( new ChartDataWrapper( m_spChart2ModelContact ) );
     828             :     }
     829             :     //@todo: check hasInternalDataProvider also in else?
     830             : 
     831           0 :     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           0 : Reference< frame::XController > SAL_CALL ChartDocumentWrapper::getCurrentController()
     919             :     throw (uno::RuntimeException, std::exception)
     920             : {
     921           0 :     Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
     922           0 :     if( xModel.is() )
     923           0 :         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           0 : void SAL_CALL ChartDocumentWrapper::dispose()
     948             :     throw (uno::RuntimeException, std::exception)
     949             : {
     950           0 :     if( m_bIsDisposed )
     951             :         throw lang::DisposedException("ChartDocumentWrapper is disposed",
     952           0 :             static_cast< ::cppu::OWeakObject* >( this ));
     953             : 
     954           0 :     m_bIsDisposed = true;
     955             : 
     956             :     try
     957             :     {
     958           0 :         Reference< lang::XComponent > xFormerDelegator( m_xDelegator, uno::UNO_QUERY );
     959           0 :         DisposeHelper::DisposeAndClear( m_xTitle );
     960           0 :         DisposeHelper::DisposeAndClear( m_xSubTitle );
     961           0 :         DisposeHelper::DisposeAndClear( m_xLegend );
     962           0 :         DisposeHelper::DisposeAndClear( m_xChartData );
     963           0 :         DisposeHelper::DisposeAndClear( m_xDiagram );
     964           0 :         DisposeHelper::DisposeAndClear( m_xArea );
     965           0 :         m_xChartView.set( 0 );
     966           0 :         m_xShapeFactory.set( 0 );
     967           0 :         m_xDelegator.set( 0 );
     968             : 
     969           0 :         clearWrappedPropertySet();
     970           0 :         m_spChart2ModelContact->clear();
     971           0 :         impl_resetAddIn();
     972             : 
     973           0 :         stopAllComponentListening();
     974             : 
     975             :         try
     976             :         {
     977           0 :             if( xFormerDelegator.is())
     978           0 :                 xFormerDelegator->dispose();
     979             :         }
     980           0 :         catch (const lang::DisposedException&)
     981             :         {
     982             :             // this is ok, don't panic
     983           0 :         }
     984             :     }
     985           0 :     catch (const uno::Exception &ex)
     986             :     {
     987             :         ASSERT_EXCEPTION( ex );
     988             :     }
     989           0 : }
     990             : 
     991           0 : void ChartDocumentWrapper::impl_resetAddIn()
     992             : {
     993           0 :     Reference< util::XRefreshable > xAddIn( m_xAddIn );
     994           0 :     m_xAddIn.set( 0 );
     995             : 
     996           0 :     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           0 :     }
    1026           0 : }
    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           0 : Reference< util::XRefreshable > ChartDocumentWrapper::getAddIn() const
    1044             : {
    1045           0 :     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           0 : void ChartDocumentWrapper::setUpdateAddIn( sal_Bool bUpdateAddIn )
    1069             : {
    1070           0 :     m_bUpdateAddIn = bUpdateAddIn;
    1071           0 : }
    1072           0 : sal_Bool ChartDocumentWrapper::getUpdateAddIn() const
    1073             : {
    1074           0 :     return m_bUpdateAddIn;
    1075             : }
    1076             : 
    1077           0 : Reference< drawing::XShapes > ChartDocumentWrapper::getAdditionalShapes() const
    1078             : {
    1079             :     // get additional non-chart shapes for XML export
    1080           0 :     uno::Reference< drawing::XShapes > xFoundShapes;
    1081           0 :     uno::Reference< drawing::XDrawPage > xDrawPage( this->impl_getDrawPage() );
    1082             : 
    1083           0 :     uno::Reference< drawing::XShapes > xDrawPageShapes( xDrawPage, uno::UNO_QUERY );
    1084           0 :     if( !xDrawPageShapes.is() )
    1085           0 :         return xFoundShapes;
    1086             : 
    1087           0 :     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           0 :     ::std::vector< uno::Reference< drawing::XShape > > aShapeVector;
    1092           0 :     sal_Int32 nSubCount = xDrawPageShapes->getCount();
    1093           0 :     uno::Reference< drawing::XShape > xShape;
    1094           0 :     for( sal_Int32 nS = 0; nS < nSubCount; nS++ )
    1095             :     {
    1096           0 :         if( xDrawPageShapes->getByIndex( nS ) >>= xShape )
    1097             :         {
    1098           0 :             if( xShape.is() && xChartRoot!=xShape )
    1099           0 :                 aShapeVector.push_back( xShape );
    1100             :         }
    1101             :     }
    1102             : 
    1103           0 :     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           0 :     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           0 : uno::Reference< drawing::XDrawPage > SAL_CALL ChartDocumentWrapper::getDrawPage()
    1139             :     throw (uno::RuntimeException, std::exception)
    1140             : {
    1141           0 :     return this->impl_getDrawPage();
    1142             : }
    1143             : 
    1144           0 : uno::Reference< drawing::XDrawPage > ChartDocumentWrapper::impl_getDrawPage() const
    1145             :     throw (uno::RuntimeException)
    1146             : {
    1147           0 :     return m_spChart2ModelContact->getDrawPage();
    1148             : }
    1149             : 
    1150             : // ____ XMultiServiceFactory ____
    1151           0 : uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance(
    1152             :     const OUString& aServiceSpecifier )
    1153             :     throw (uno::Exception,
    1154             :            uno::RuntimeException, std::exception)
    1155             : {
    1156           0 :     uno::Reference< uno::XInterface > xResult;
    1157             : 
    1158           0 :     Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
    1159           0 :     if( !xChartDoc.is() )
    1160           0 :         return xResult;
    1161             : 
    1162           0 :     bool bServiceFound = false;
    1163           0 :     tServiceNameMap & rMap = lcl_getStaticServiceNameMap();
    1164             : 
    1165           0 :     tServiceNameMap::const_iterator aIt( rMap.find( aServiceSpecifier ));
    1166           0 :     if( aIt != rMap.end())
    1167             :     {
    1168           0 :         bool bCreateDiagram = false;
    1169             :         uno::Reference< lang::XMultiServiceFactory > xManagerFact(
    1170           0 :             xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
    1171           0 :         uno::Reference< chart2::XChartTypeTemplate > xTemplate;
    1172             : 
    1173           0 :         switch( (*aIt).second )
    1174             :         {
    1175             :             case SERVICE_NAME_AREA_DIAGRAM:
    1176           0 :                 if( xManagerFact.is())
    1177             :                 {
    1178             :                     xTemplate.set(
    1179           0 :                         xManagerFact->createInstance("com.sun.star.chart2.template.Area"),
    1180           0 :                                 uno::UNO_QUERY );
    1181           0 :                     bCreateDiagram = true;
    1182             :                 }
    1183           0 :                 break;
    1184             :             case SERVICE_NAME_BAR_DIAGRAM:
    1185           0 :                 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           0 :                         xManagerFact->createInstance("com.sun.star.chart2.template.Column"),
    1191           0 :                                 uno::UNO_QUERY );
    1192           0 :                     bCreateDiagram = true;
    1193             :                 }
    1194           0 :                 break;
    1195             :             case SERVICE_NAME_DONUT_DIAGRAM:
    1196           0 :                 if( xManagerFact.is())
    1197             :                 {
    1198             :                     xTemplate.set(
    1199           0 :                         xManagerFact->createInstance("com.sun.star.chart2.template.Donut"),
    1200           0 :                                 uno::UNO_QUERY );
    1201           0 :                     bCreateDiagram = true;
    1202             :                 }
    1203           0 :                 break;
    1204             :             case SERVICE_NAME_LINE_DIAGRAM:
    1205           0 :                 if( xManagerFact.is())
    1206             :                 {
    1207             :                     xTemplate.set(
    1208           0 :                         xManagerFact->createInstance("com.sun.star.chart2.template.Line"),
    1209           0 :                                 uno::UNO_QUERY );
    1210           0 :                     bCreateDiagram = true;
    1211             :                 }
    1212           0 :                 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           0 :                 if( xManagerFact.is())
    1233             :                 {
    1234             :                     xTemplate.set(
    1235           0 :                         xManagerFact->createInstance("com.sun.star.chart2.template.Pie"),
    1236           0 :                                 uno::UNO_QUERY );
    1237           0 :                     bCreateDiagram = true;
    1238             :                 }
    1239           0 :                 break;
    1240             :             case SERVICE_NAME_STOCK_DIAGRAM:
    1241           0 :                 if( xManagerFact.is())
    1242             :                 {
    1243             :                     xTemplate.set(
    1244           0 :                         xManagerFact->createInstance("com.sun.star.chart2.template.StockLowHighClose"),
    1245           0 :                                 uno::UNO_QUERY );
    1246           0 :                     bCreateDiagram = true;
    1247             :                 }
    1248           0 :                 break;
    1249             :             case SERVICE_NAME_XY_DIAGRAM:
    1250           0 :                 if( xManagerFact.is())
    1251             :                 {
    1252             :                     xTemplate.set(
    1253           0 :                         xManagerFact->createInstance("com.sun.star.chart2.template.ScatterLineSymbol"),
    1254           0 :                                 uno::UNO_QUERY );
    1255           0 :                     bCreateDiagram = true;
    1256             :                 }
    1257           0 :                 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           0 :                 break;
    1298             :         }
    1299             : 
    1300           0 :         if( bCreateDiagram && xTemplate.is() )
    1301             :         {
    1302             :             try
    1303             :             {
    1304           0 :                 uno::Reference< chart2::XDiagram > xDia( xChartDoc->getFirstDiagram());
    1305           0 :                 if( xDia.is())
    1306             :                 {
    1307             :                     // locked controllers
    1308           0 :                     Reference< frame::XModel > xModel( xChartDoc, uno::UNO_QUERY );
    1309           0 :                     ControllerLockGuardUNO aCtrlLockGuard( xModel );
    1310           0 :                     Reference< chart2::XDiagram > xDiagram = ChartModelHelper::findDiagram( xModel );
    1311           0 :                     ThreeDLookScheme e3DScheme = ThreeDHelper::detectScheme( xDiagram );
    1312           0 :                     Reference< lang::XMultiServiceFactory > xTemplateManager( xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
    1313             :                     DiagramHelper::tTemplateWithServiceName aTemplateWithService(
    1314           0 :                         DiagramHelper::getTemplateForDiagram( xDiagram, xTemplateManager ));
    1315           0 :                     if( aTemplateWithService.first.is())
    1316           0 :                         aTemplateWithService.first->resetStyles( xDiagram );//#i109371#
    1317           0 :                     xTemplate->changeDiagram( xDiagram );
    1318           0 :                     if( Application::GetSettings().GetMathLayoutRTL() )
    1319           0 :                         AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) );
    1320           0 :                     ThreeDHelper::setScheme( xDiagram, e3DScheme );
    1321             :                 }
    1322             :                 else
    1323             :                 {
    1324             :                     // locked controllers
    1325           0 :                     ControllerLockGuardUNO aCtrlLockGuard( Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ));
    1326           0 :                     xDia.set( xTemplate->createDiagramByDataSource(
    1327             :                                   uno::Reference< chart2::data::XDataSource >(),
    1328           0 :                                   uno::Sequence< beans::PropertyValue >()));
    1329           0 :                     xChartDoc->setFirstDiagram( xDia );
    1330             :                 }
    1331             : 
    1332           0 :                 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           0 :         bServiceFound = true;
    1341             :     }
    1342           0 :     else if( aServiceSpecifier == "com.sun.star.comp.chart2.DataSeriesWrapper" )
    1343             :     {
    1344           0 :         Reference< beans::XPropertySet > xDataSeries( new DataSeriesPointWrapper( m_spChart2ModelContact ) );
    1345           0 :         xResult.set( xDataSeries );
    1346           0 :         bServiceFound = true;
    1347             :     }
    1348           0 :     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           0 :             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           0 :             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           0 :     if( !bServiceFound )
    1411             :     {
    1412             :         try
    1413             :         {
    1414             :             Reference< lang::XMultiServiceFactory > xFact(
    1415           0 :                 m_spChart2ModelContact->m_xContext->getServiceManager(), uno::UNO_QUERY_THROW );
    1416           0 :             if( xFact.is() )
    1417             :             {
    1418             :                 uno::Reference< util::XRefreshable > xAddIn(
    1419           0 :                     xFact->createInstance( aServiceSpecifier ), uno::UNO_QUERY );
    1420           0 :                 if( xAddIn.is() )
    1421             :                 {
    1422           0 :                     xResult = xAddIn;
    1423           0 :                     bServiceFound = true;
    1424           0 :                 }
    1425           0 :             }
    1426             :         }
    1427           0 :         catch (const uno::Exception&)
    1428             :         {
    1429             :             // couldn't create service
    1430             :         }
    1431             :     }
    1432             : 
    1433           0 :     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           0 : uno::Sequence< OUString > SAL_CALL ChartDocumentWrapper::getAvailableServiceNames()
    1449             :     throw (uno::RuntimeException, std::exception)
    1450             : {
    1451           0 :     tServiceNameMap & rMap = lcl_getStaticServiceNameMap();
    1452           0 :     uno::Sequence< OUString > aResult( rMap.size());
    1453             : 
    1454             :     ::std::transform( rMap.begin(), rMap.end(),
    1455             :                       aResult.getArray(),
    1456           0 :                       ::o3tl::select1st< tServiceNameMap::value_type >() );
    1457             : 
    1458           0 :     return aResult;
    1459             : 
    1460             : }
    1461             : 
    1462             : // ____ XAggregation ____
    1463           0 : void SAL_CALL ChartDocumentWrapper::setDelegator(
    1464             :     const uno::Reference< uno::XInterface >& rDelegator )
    1465             :     throw (uno::RuntimeException, std::exception)
    1466             : {
    1467           0 :     if( m_bIsDisposed )
    1468             :     {
    1469           0 :         if( rDelegator.is() )
    1470             :             throw lang::DisposedException("ChartDocumentWrapper is disposed",
    1471           0 :                 static_cast< ::cppu::OWeakObject* >( this ));
    1472             :         else
    1473           0 :             return;
    1474             :     }
    1475             : 
    1476           0 :     if( rDelegator.is())
    1477             :     {
    1478           0 :         m_xDelegator = rDelegator;
    1479           0 :         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           0 :             this->dispose();
    1487             :         }
    1488           0 :         catch (const uno::Exception& ex)
    1489             :         {
    1490             :             ASSERT_EXCEPTION( ex );
    1491             :         }
    1492             :     }
    1493             : }
    1494             : 
    1495           0 : uno::Any SAL_CALL ChartDocumentWrapper::queryAggregation( const uno::Type& rType )
    1496             :     throw (uno::RuntimeException, std::exception)
    1497             : {
    1498           0 :     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           0 : Reference< beans::XPropertySet > ChartDocumentWrapper::getInnerPropertySet()
    1524             : {
    1525           0 :     return 0;
    1526             : }
    1527           0 : const Sequence< beans::Property >& ChartDocumentWrapper::getPropertySequence()
    1528             : {
    1529           0 :     return *StaticChartDocumentWrapperPropertyArray::get();
    1530             : }
    1531             : 
    1532           0 : const std::vector< WrappedProperty* > ChartDocumentWrapper::createWrappedProperties()
    1533             : {
    1534           0 :     ::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
    1535           0 :     aWrappedProperties.push_back( new WrappedDataSourceLabelsInFirstRowProperty( m_spChart2ModelContact ) );
    1536           0 :     aWrappedProperties.push_back( new WrappedDataSourceLabelsInFirstColumnProperty( m_spChart2ModelContact ) );
    1537           0 :     aWrappedProperties.push_back( new WrappedHasLegendProperty( m_spChart2ModelContact ) );
    1538           0 :     aWrappedProperties.push_back( new WrappedHasMainTitleProperty( m_spChart2ModelContact ) );
    1539           0 :     aWrappedProperties.push_back( new WrappedHasSubTitleProperty( m_spChart2ModelContact ) );
    1540           0 :     aWrappedProperties.push_back( new WrappedAddInProperty( *this ) );
    1541           0 :     aWrappedProperties.push_back( new WrappedBaseDiagramProperty( *this ) );
    1542           0 :     aWrappedProperties.push_back( new WrappedAdditionalShapesProperty( *this ) );
    1543           0 :     aWrappedProperties.push_back( new WrappedRefreshAddInAllowedProperty( *this ) );
    1544           0 :     aWrappedProperties.push_back( new WrappedIgnoreProperty("NullDate",Any() ) ); // i99104
    1545           0 :     aWrappedProperties.push_back( new WrappedIgnoreProperty("EnableComplexChartTypes", uno::makeAny(sal_True) ) );
    1546           0 :     aWrappedProperties.push_back( new WrappedIgnoreProperty("EnableDataTableDialog", uno::makeAny(sal_True) ) );
    1547             : 
    1548           0 :     return aWrappedProperties;
    1549             : }
    1550             : 
    1551           0 : uno::Sequence< OUString > ChartDocumentWrapper::getSupportedServiceNames_Static()
    1552             : {
    1553           0 :     uno::Sequence< OUString > aServices( 4 );
    1554           0 :     aServices[ 0 ] = "com.sun.star.chart.ChartDocument";
    1555           0 :     aServices[ 1 ] = CHART_CHARTAPIWRAPPER_SERVICE_NAME;
    1556           0 :     aServices[ 2 ] = "com.sun.star.xml.UserDefinedAttributesSupplier";
    1557           0 :     aServices[ 3 ] = "com.sun.star.beans.PropertySet";
    1558           0 :     return aServices;
    1559             : }
    1560             : 
    1561             : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
    1562           0 : 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