LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - ChartDocumentWrapper.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 434 656 66.2 %
Date: 2014-11-03 Functions: 60 85 70.6 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10