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

Generated by: LCOV version 1.10