LCOV - code coverage report
Current view: top level - chart2/source/controller/main - ControllerCommandDispatch.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 295 354 83.3 %
Date: 2014-04-11 Functions: 19 22 86.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "ControllerCommandDispatch.hxx"
      21             : #include "ChartModelHelper.hxx"
      22             : #include "DiagramHelper.hxx"
      23             : #include "AxisHelper.hxx"
      24             : #include "TitleHelper.hxx"
      25             : #include "LegendHelper.hxx"
      26             : #include "ObjectIdentifier.hxx"
      27             : #include "macros.hxx"
      28             : #include "ChartTypeHelper.hxx"
      29             : #include "ChartController.hxx"
      30             : #include "RegressionCurveHelper.hxx"
      31             : #include "DataSeriesHelper.hxx"
      32             : #include "StatisticsHelper.hxx"
      33             : #include "ShapeController.hxx"
      34             : 
      35             : #include <com/sun/star/util/XModifyBroadcaster.hpp>
      36             : #include <com/sun/star/frame/XStorable.hpp>
      37             : #include <com/sun/star/chart2/XChartDocument.hpp>
      38             : #include <com/sun/star/chart2/XChartType.hpp>
      39             : #include <com/sun/star/chart2/XDataSeries.hpp>
      40             : #include <com/sun/star/chart2/XRegressionCurve.hpp>
      41             : #include <com/sun/star/chart2/data/XDatabaseDataProvider.hpp>
      42             : 
      43             : // only needed until #i68864# is fixed
      44             : #include <com/sun/star/frame/XLayoutManager.hpp>
      45             : 
      46             : using namespace ::com::sun::star;
      47             : 
      48             : using ::com::sun::star::uno::Reference;
      49             : using ::com::sun::star::uno::Sequence;
      50             : 
      51             : namespace
      52             : {
      53         773 : bool lcl_isStatusBarVisible( const Reference< frame::XController > & xController )
      54             : {
      55         773 :     bool bIsStatusBarVisible = false;
      56             :     // Status-Bar visible, workaround: this should not be necessary. @todo:
      57             :     // remove when Issue #i68864# is fixed
      58         773 :     if( xController.is())
      59             :     {
      60         773 :         Reference< beans::XPropertySet > xPropSet( xController->getFrame(), uno::UNO_QUERY );
      61         773 :         if( xPropSet.is() )
      62             :         {
      63         773 :             uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
      64         773 :             xPropSet->getPropertyValue( "LayoutManager" ) >>= xLayoutManager;
      65         773 :             if ( xLayoutManager.is() )
      66         773 :                 bIsStatusBarVisible = xLayoutManager->isElementVisible( "private:resource/statusbar/statusbar" );
      67         773 :         }
      68             :     }
      69         773 :     return bIsStatusBarVisible;
      70             : }
      71             : 
      72             : } // anonymous namespace
      73             : 
      74             : namespace chart
      75             : {
      76             : 
      77             : namespace impl
      78             : {
      79             : 
      80             : /// Constants for moving the series.
      81             : namespace {
      82             :     static bool const MOVE_SERIES_FORWARD = true;
      83             :     static bool const MOVE_SERIES_BACKWARD = false;
      84             : }
      85             : 
      86             : /** Represents the current state of the controller (needed for issue 63017).
      87             : 
      88             :     You can set the state by calling update().  After this call the state is
      89             :     preserved in this class until the next call to update().
      90             : 
      91             :     This is useful, not to say necessary, for enabling and disabling of menu
      92             :     entries (e.g. format>arrangement). As the status requests are sent very
      93             :     frequently it would be impossible, from a performance point of view, to
      94             :     query the current status every time directly at the model.  So this class
      95             :     serves as a cache for the state.
      96             : */
      97             : struct ControllerState
      98             : {
      99             :     ControllerState();
     100             : 
     101             :     void update( const Reference< frame::XController > & xController,
     102             :                  const Reference< frame::XModel > & xModel );
     103             : 
     104             :     // -- State variables -------
     105             :     bool bHasSelectedObject;
     106             :     bool bIsPositionableObject;
     107             :     bool bIsTextObject;
     108             :     bool bIsDeleteableObjectSelected;
     109             :     bool bIsFormateableObjectSelected;
     110             : 
     111             :     // May the selected series be moved forward or backward (cf
     112             :     // format>arrangement).
     113             :     bool bMayMoveSeriesForward;
     114             :     bool bMayMoveSeriesBackward;
     115             : 
     116             :     // trendlines
     117             :     bool bMayAddMenuTrendline;
     118             :     bool bMayAddTrendline;
     119             :     bool bMayAddTrendlineEquation;
     120             :     bool bMayAddR2Value;
     121             :     bool bMayAddMeanValue;
     122             :     bool bMayAddXErrorBars;
     123             :     bool bMayAddYErrorBars;
     124             : 
     125             :     bool bMayDeleteTrendline;
     126             :     bool bMayDeleteTrendlineEquation;
     127             :     bool bMayDeleteR2Value;
     128             :     bool bMayDeleteMeanValue;
     129             :     bool bMayDeleteXErrorBars;
     130             :     bool bMayDeleteYErrorBars;
     131             : 
     132             :     bool bMayFormatTrendline;
     133             :     bool bMayFormatTrendlineEquation;
     134             :     bool bMayFormatMeanValue;
     135             :     bool bMayFormatXErrorBars;
     136             :     bool bMayFormatYErrorBars;
     137             : };
     138             : 
     139          17 : ControllerState::ControllerState() :
     140             :         bHasSelectedObject( false ),
     141             :         bIsPositionableObject( false ),
     142             :         bIsTextObject(false),
     143             :         bIsDeleteableObjectSelected(false),
     144             :         bIsFormateableObjectSelected(false),
     145             :         bMayMoveSeriesForward( false ),
     146             :         bMayMoveSeriesBackward( false ),
     147             :         bMayAddMenuTrendline( false ),
     148             :         bMayAddTrendline( false ),
     149             :         bMayAddTrendlineEquation( false ),
     150             :         bMayAddR2Value( false ),
     151             :         bMayAddMeanValue( false ),
     152             :         bMayAddXErrorBars( false ),
     153             :         bMayAddYErrorBars( false ),
     154             :         bMayDeleteTrendline( false ),
     155             :         bMayDeleteTrendlineEquation( false ),
     156             :         bMayDeleteR2Value( false ),
     157             :         bMayDeleteMeanValue( false ),
     158             :         bMayDeleteXErrorBars( false ),
     159             :         bMayDeleteYErrorBars( false ),
     160             :         bMayFormatTrendline( false ),
     161             :         bMayFormatTrendlineEquation( false ),
     162             :         bMayFormatMeanValue( false ),
     163             :         bMayFormatXErrorBars( false ),
     164          17 :         bMayFormatYErrorBars( false )
     165          17 : {}
     166             : 
     167         790 : void ControllerState::update(
     168             :     const Reference< frame::XController > & xController,
     169             :     const Reference< frame::XModel > & xModel )
     170             : {
     171             :     Reference< view::XSelectionSupplier > xSelectionSupplier(
     172         790 :         xController, uno::UNO_QUERY );
     173             : 
     174             :     // Update ControllerState variables.
     175         790 :     if( xSelectionSupplier.is())
     176             :     {
     177         790 :         uno::Any aSelObj( xSelectionSupplier->getSelection() );
     178        1580 :         ObjectIdentifier aSelOID( aSelObj );
     179        1580 :         OUString aSelObjCID( aSelOID.getObjectCID() );
     180             : 
     181         790 :         bHasSelectedObject = aSelOID.isValid();
     182             : 
     183         790 :         ObjectType aObjectType(ObjectIdentifier::getObjectType( aSelObjCID ));
     184             : 
     185         790 :         bIsPositionableObject = (OBJECTTYPE_DATA_POINT != aObjectType) && aSelOID.isDragableObject();
     186         790 :         bIsTextObject = OBJECTTYPE_TITLE == aObjectType;
     187             : 
     188        1580 :         uno::Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel ));
     189         790 :         bIsFormateableObjectSelected = bHasSelectedObject && aSelOID.isAutoGeneratedObject();
     190         790 :         if( OBJECTTYPE_DIAGRAM==aObjectType || OBJECTTYPE_DIAGRAM_WALL==aObjectType || OBJECTTYPE_DIAGRAM_FLOOR==aObjectType )
     191           0 :             bIsFormateableObjectSelected = DiagramHelper::isSupportingFloorAndWall( xDiagram );
     192             : 
     193             :         uno::Reference< chart2::XDataSeries > xGivenDataSeries(
     194             :             ObjectIdentifier::getDataSeriesForCID(
     195        1580 :                 aSelObjCID, xModel ) );
     196             : 
     197         790 :         bIsDeleteableObjectSelected = ChartController::isObjectDeleteable( aSelObj );
     198             : 
     199        2370 :         bMayMoveSeriesForward = (OBJECTTYPE_DATA_POINT!=aObjectType) && DiagramHelper::isSeriesMoveable(
     200             :             ChartModelHelper::findDiagram( xModel ),
     201             :             xGivenDataSeries,
     202        2370 :             MOVE_SERIES_FORWARD );
     203             : 
     204        2370 :         bMayMoveSeriesBackward = (OBJECTTYPE_DATA_POINT!=aObjectType) && DiagramHelper::isSeriesMoveable(
     205             :             ChartModelHelper::findDiagram( xModel ),
     206             :             xGivenDataSeries,
     207        2370 :             MOVE_SERIES_BACKWARD );
     208             : 
     209         790 :         bMayAddMenuTrendline = false;
     210         790 :         bMayAddTrendline = false;
     211         790 :         bMayAddTrendlineEquation = false;
     212         790 :         bMayAddR2Value = false;
     213         790 :         bMayAddMeanValue = false;
     214         790 :         bMayAddXErrorBars = false;
     215         790 :         bMayAddYErrorBars = false;
     216         790 :         bMayDeleteTrendline = false;
     217         790 :         bMayDeleteTrendlineEquation = false;
     218         790 :         bMayDeleteR2Value = false;
     219         790 :         bMayDeleteMeanValue = false;
     220         790 :         bMayDeleteXErrorBars = false;
     221         790 :         bMayDeleteYErrorBars = false;
     222         790 :         bMayFormatTrendline = false;
     223         790 :         bMayFormatTrendlineEquation = false;
     224         790 :         bMayFormatMeanValue = false;
     225         790 :         bMayFormatXErrorBars = false;
     226         790 :         bMayFormatYErrorBars = false;
     227         790 :         if( bHasSelectedObject )
     228             :         {
     229           0 :             if( xGivenDataSeries.is())
     230             :             {
     231           0 :                 bMayAddMenuTrendline = true;
     232           0 :                 sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
     233             :                 uno::Reference< chart2::XChartType > xFirstChartType(
     234           0 :                     DataSeriesHelper::getChartTypeOfSeries( xGivenDataSeries, xDiagram ));
     235             : 
     236             :                 // trend lines/mean value line
     237           0 :                 if( (OBJECTTYPE_DATA_SERIES == aObjectType || OBJECTTYPE_DATA_POINT == aObjectType)
     238           0 :                     && ChartTypeHelper::isSupportingRegressionProperties( xFirstChartType, nDimensionCount ))
     239             :                 {
     240           0 :                     uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( xGivenDataSeries, uno::UNO_QUERY );
     241           0 :                     if( xRegCurveCnt.is())
     242             :                     {
     243             :                         // Trendline
     244           0 :                         bMayAddTrendline = true;
     245             : 
     246             :                         // Mean Value
     247           0 :                         bMayFormatMeanValue = bMayDeleteMeanValue = RegressionCurveHelper::hasMeanValueLine( xRegCurveCnt );
     248           0 :                         bMayAddMeanValue = ! bMayDeleteMeanValue;
     249           0 :                     }
     250             :                 }
     251             : 
     252             :                 // error bars
     253           0 :                 if( (OBJECTTYPE_DATA_SERIES == aObjectType || OBJECTTYPE_DATA_POINT == aObjectType)
     254           0 :                     && ChartTypeHelper::isSupportingStatisticProperties( xFirstChartType, nDimensionCount ))
     255             :                 {
     256           0 :                     bMayFormatXErrorBars = bMayDeleteXErrorBars = StatisticsHelper::hasErrorBars( xGivenDataSeries, false );
     257           0 :                     bMayAddXErrorBars = ! bMayDeleteXErrorBars;
     258             : 
     259           0 :                     bMayFormatYErrorBars = bMayDeleteYErrorBars = StatisticsHelper::hasErrorBars( xGivenDataSeries, true );
     260           0 :                     bMayAddYErrorBars = ! bMayDeleteYErrorBars;
     261           0 :                 }
     262             :             }
     263             : 
     264           0 :             if( aObjectType == OBJECTTYPE_DATA_AVERAGE_LINE )
     265           0 :                 bMayFormatMeanValue = true;
     266             : 
     267           0 :             if( aObjectType == OBJECTTYPE_DATA_ERRORS_X)
     268           0 :                 bMayFormatXErrorBars = true;
     269             : 
     270           0 :             if( aObjectType == OBJECTTYPE_DATA_ERRORS_Y )
     271           0 :                 bMayFormatYErrorBars = true;
     272             : 
     273           0 :             if( aObjectType == OBJECTTYPE_DATA_CURVE )
     274             :             {
     275           0 :                 bMayFormatTrendline = true;
     276           0 :                 bMayDeleteTrendline = true;
     277             :                 uno::Reference< chart2::XRegressionCurve > xRegCurve(
     278           0 :                     ObjectIdentifier::getObjectPropertySet( aSelObjCID, xModel ), uno::UNO_QUERY );
     279             : 
     280             :                 // Trendline Equation
     281           0 :                 bMayFormatTrendlineEquation = bMayDeleteTrendlineEquation = RegressionCurveHelper::hasEquation( xRegCurve );
     282           0 :                 bMayAddTrendlineEquation = !bMayDeleteTrendlineEquation;
     283             :             }
     284           0 :             else if( aObjectType == OBJECTTYPE_DATA_CURVE_EQUATION )
     285             :             {
     286           0 :                 bMayFormatTrendlineEquation = true;
     287           0 :                 bool bHasR2Value = false;
     288             :                 try
     289             :                 {
     290             :                     uno::Reference< beans::XPropertySet > xEquationProperties(
     291           0 :                         ObjectIdentifier::getObjectPropertySet( aSelObjCID, xModel ), uno::UNO_QUERY );
     292           0 :                     if( xEquationProperties.is() )
     293           0 :                         xEquationProperties->getPropertyValue( "ShowCorrelationCoefficient" ) >>= bHasR2Value;
     294             :                 }
     295           0 :                 catch(const uno::RuntimeException& e)
     296             :                 {
     297             :                     ASSERT_EXCEPTION( e );
     298             :                 }
     299           0 :                 bMayAddR2Value = !bHasR2Value;
     300           0 :                 bMayDeleteR2Value = bHasR2Value;
     301             :             }
     302         790 :         }
     303         790 :     }
     304         790 : }
     305             : 
     306             : /** Represents the current state of the model.
     307             : 
     308             :     You can set the state by calling update().  After this call the state is
     309             :     preserved in this class until the next call to update().
     310             : 
     311             :     This is useful, not to say necessary, for enabling and disabling of menu
     312             :     entries and toolbar icons.  As the status requests are sent very frequently
     313             :     it would be impossible, from a performance point of view, to query the
     314             :     current status every time directly at the model.  So this class serves as a
     315             :     cache for the state.
     316             :  */
     317             : struct ModelState
     318             : {
     319             :     ModelState();
     320             : 
     321             :     void update( const Reference< frame::XModel > & xModel );
     322             : 
     323             :     bool HasAnyAxis() const;
     324             :     bool HasAnyGrid() const;
     325             :     bool HasAnyTitle() const;
     326             : 
     327             :     bool bIsReadOnly;
     328             :     bool bIsThreeD;
     329             :     bool bHasOwnData;
     330             : 
     331             :     bool bHasMainTitle;
     332             :     bool bHasSubTitle;
     333             :     bool bHasXAxisTitle;
     334             :     bool bHasYAxisTitle;
     335             :     bool bHasZAxisTitle;
     336             :     bool bHasSecondaryXAxisTitle;
     337             :     bool bHasSecondaryYAxisTitle;
     338             : 
     339             :     bool bHasXAxis;
     340             :     bool bHasYAxis;
     341             :     bool bHasZAxis;
     342             :     bool bHasAAxis;
     343             :     bool bHasBAxis;
     344             : 
     345             :     bool bHasMainXGrid;
     346             :     bool bHasMainYGrid;
     347             :     bool bHasMainZGrid;
     348             :     bool bHasHelpXGrid;
     349             :     bool bHasHelpYGrid;
     350             :     bool bHasHelpZGrid;
     351             : 
     352             :     bool bHasAutoScaledText;
     353             :     bool bHasLegend;
     354             :     bool bHasWall;
     355             :     bool bHasFloor;
     356             : 
     357             :     bool bSupportsStatistics;
     358             :     bool bSupportsAxes;
     359             : };
     360             : 
     361          17 : ModelState::ModelState() :
     362             :         bIsReadOnly( true ),
     363             :         bIsThreeD( false ),
     364             :         bHasOwnData( false ),
     365             :         bHasMainTitle( false ),
     366             :         bHasSubTitle( false ),
     367             :         bHasXAxisTitle( false ),
     368             :         bHasYAxisTitle( false ),
     369             :         bHasZAxisTitle( false ),
     370             :         bHasSecondaryXAxisTitle( false ),
     371             :         bHasSecondaryYAxisTitle( false ),
     372             :         bHasXAxis( false ),
     373             :         bHasYAxis( false ),
     374             :         bHasZAxis( false ),
     375             :         bHasAAxis( false ),
     376             :         bHasBAxis( false ),
     377             :         bHasMainXGrid( false ),
     378             :         bHasMainYGrid( false ),
     379             :         bHasMainZGrid( false ),
     380             :         bHasHelpXGrid( false ),
     381             :         bHasHelpYGrid( false ),
     382             :         bHasHelpZGrid( false ),
     383             :         bHasAutoScaledText( false ),
     384             :         bHasLegend( false ),
     385             :         bHasWall( false ),
     386             :         bHasFloor( false ),
     387             :         bSupportsStatistics( false ),
     388          17 :         bSupportsAxes( false )
     389             : 
     390          17 : {}
     391             : 
     392         790 : void ModelState::update( const Reference< frame::XModel > & xModel )
     393             : {
     394         790 :     Reference< chart2::XChartDocument > xChartDoc( xModel, uno::UNO_QUERY );
     395        1580 :     Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel ));
     396             : 
     397         790 :     bIsReadOnly = true;
     398        1580 :     Reference< frame::XStorable > xStorable( xModel, uno::UNO_QUERY );
     399         790 :     if( xStorable.is())
     400         790 :         bIsReadOnly = xStorable->isReadonly();
     401             : 
     402         790 :     sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
     403             : 
     404        1580 :     uno::Reference< chart2::XChartType > xFirstChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) );
     405         790 :     bSupportsStatistics = ChartTypeHelper::isSupportingStatisticProperties( xFirstChartType, nDimensionCount );
     406         790 :     bSupportsAxes = ChartTypeHelper::isSupportingMainAxis( xFirstChartType, nDimensionCount, 0 );
     407             : 
     408         790 :     bIsThreeD = (nDimensionCount == 3);
     409         790 :     bHasOwnData = (xChartDoc.is() && xChartDoc->hasInternalDataProvider());
     410             : 
     411         790 :     bHasMainTitle =  TitleHelper::getTitle( TitleHelper::MAIN_TITLE, xModel ).is();
     412         790 :     bHasSubTitle =   TitleHelper::getTitle( TitleHelper::SUB_TITLE, xModel ).is();
     413         790 :     bHasXAxisTitle = TitleHelper::getTitle( TitleHelper::X_AXIS_TITLE, xModel ).is();
     414         790 :     bHasYAxisTitle = TitleHelper::getTitle( TitleHelper::Y_AXIS_TITLE, xModel ).is();
     415         790 :     bHasZAxisTitle = TitleHelper::getTitle( TitleHelper::Z_AXIS_TITLE, xModel ).is();
     416         790 :     bHasSecondaryXAxisTitle = TitleHelper::getTitle( TitleHelper::SECONDARY_X_AXIS_TITLE, xModel ).is();
     417         790 :     bHasSecondaryYAxisTitle = TitleHelper::getTitle( TitleHelper::SECONDARY_Y_AXIS_TITLE, xModel ).is();
     418             : 
     419         790 :     bHasXAxis = bSupportsAxes && AxisHelper::getAxis( 0, true, xDiagram ).is();
     420         790 :     bHasYAxis = bSupportsAxes && AxisHelper::getAxis( 1, true, xDiagram ).is();
     421         790 :     bHasZAxis = bSupportsAxes && AxisHelper::getAxis( 2, true, xDiagram ).is();
     422         790 :     bHasAAxis = bSupportsAxes && AxisHelper::getAxis( 0, false, xDiagram ).is();
     423         790 :     bHasBAxis = bSupportsAxes && AxisHelper::getAxis( 1, false, xDiagram ).is();
     424             : 
     425         790 :     bHasMainXGrid = bSupportsAxes && AxisHelper::isGridShown( 0, 0, true, xDiagram );
     426         790 :     bHasMainYGrid = bSupportsAxes && AxisHelper::isGridShown( 1, 0, true, xDiagram );
     427         790 :     bHasMainZGrid = bSupportsAxes && AxisHelper::isGridShown( 2, 0, true, xDiagram );
     428         790 :     bHasHelpXGrid = bSupportsAxes && AxisHelper::isGridShown( 0, 0, false, xDiagram );
     429         790 :     bHasHelpYGrid = bSupportsAxes && AxisHelper::isGridShown( 1, 0, false, xDiagram );
     430         790 :     bHasHelpZGrid = bSupportsAxes && AxisHelper::isGridShown( 2, 0, false, xDiagram );
     431             : 
     432             :     bHasAutoScaledText =
     433         790 :         (ReferenceSizeProvider::getAutoResizeState( xChartDoc ) ==
     434         790 :          ReferenceSizeProvider::AUTO_RESIZE_YES);
     435             : 
     436         790 :     bHasLegend = LegendHelper::hasLegend( xDiagram );
     437         790 :     bHasWall = DiagramHelper::isSupportingFloorAndWall( xDiagram );
     438        1580 :     bHasFloor = bHasWall && bIsThreeD;
     439         790 : }
     440             : 
     441         790 : bool ModelState::HasAnyAxis() const
     442             : {
     443         790 :     return bHasXAxis || bHasYAxis || bHasZAxis || bHasAAxis || bHasBAxis;
     444             : }
     445             : 
     446         790 : bool ModelState::HasAnyGrid() const
     447             : {
     448         723 :     return bHasMainXGrid || bHasMainYGrid || bHasMainZGrid ||
     449        1035 :         bHasHelpXGrid || bHasHelpYGrid || bHasHelpZGrid;
     450             : }
     451             : 
     452         790 : bool ModelState::HasAnyTitle() const
     453             : {
     454         790 :     return bHasMainTitle || bHasSubTitle || bHasXAxisTitle || bHasYAxisTitle || bHasZAxisTitle || bHasSecondaryXAxisTitle || bHasSecondaryYAxisTitle;
     455             : }
     456             : 
     457             : } // namespace impl
     458             : 
     459          17 : ControllerCommandDispatch::ControllerCommandDispatch(
     460             :     const Reference< uno::XComponentContext > & xContext,
     461             :     ChartController* pController, CommandDispatchContainer* pContainer ) :
     462             :         impl::ControllerCommandDispatch_Base( xContext ),
     463             :         m_pChartController( pController ),
     464          17 :         m_xController( Reference< frame::XController >( pController ) ),
     465          17 :         m_xSelectionSupplier( Reference< view::XSelectionSupplier >( pController ) ),
     466          17 :         m_xDispatch( Reference< frame::XDispatch >( pController ) ),
     467             :         m_apModelState( new impl::ModelState() ),
     468             :         m_apControllerState( new impl::ControllerState() ),
     469          68 :         m_pDispatchContainer( pContainer )
     470             : {
     471          17 : }
     472             : 
     473          34 : ControllerCommandDispatch::~ControllerCommandDispatch()
     474             : {
     475          34 : }
     476             : 
     477          17 : void ControllerCommandDispatch::initialize()
     478             : {
     479          17 :     if( m_xController.is())
     480             :     {
     481          17 :         Reference< frame::XModel > xModel( m_xController->getModel());
     482          34 :         Reference< util::XModifyBroadcaster > xModifyBroadcaster( xModel, uno::UNO_QUERY );
     483             :         OSL_ASSERT( xModifyBroadcaster.is());
     484          17 :         if( xModifyBroadcaster.is())
     485          17 :             xModifyBroadcaster->addModifyListener( this );
     486             : 
     487             :                 // Listen selection modifications (Arrangement feature - issue 63017).
     488          17 :                 if( m_xSelectionSupplier.is() )
     489          17 :                         m_xSelectionSupplier->addSelectionChangeListener( this );
     490             : 
     491          17 :         if( m_apModelState.get() && xModel.is())
     492          17 :             m_apModelState->update( xModel );
     493             : 
     494          17 :         if( m_apControllerState.get() && xModel.is())
     495          17 :             m_apControllerState->update( m_xController, xModel );
     496             : 
     497          34 :         updateCommandAvailability();
     498             :     }
     499          17 : }
     500             : 
     501       81352 : void ControllerCommandDispatch::fireStatusEventForURLImpl(
     502             :     const OUString & rURL,
     503             :     const Reference< frame::XStatusListener > & xSingleListener )
     504             : {
     505       81352 :     ::std::map< OUString, uno::Any >::const_iterator aArgIt( m_aCommandArguments.find( rURL ));
     506       81352 :     if( aArgIt != m_aCommandArguments.end())
     507        3160 :         fireStatusEventForURL( rURL, aArgIt->second, commandAvailable( rURL ), xSingleListener );
     508             :     else
     509       78192 :         fireStatusEventForURL( rURL, uno::Any(), commandAvailable( rURL ), xSingleListener );
     510       81352 : }
     511             : 
     512         790 : void ControllerCommandDispatch::updateCommandAvailability()
     513             : {
     514         790 :     bool bModelStateIsValid = ( m_apModelState.get() != 0 );
     515         790 :     bool bControllerStateIsValid = ( m_apControllerState.get() != 0 );
     516             :     // Model and controller states exist.
     517             :     OSL_ASSERT( bModelStateIsValid );
     518             :     OSL_ASSERT( bControllerStateIsValid );
     519             : 
     520             :     // read-only
     521         790 :     bool bIsWritable = bModelStateIsValid && (! m_apModelState->bIsReadOnly);
     522             :     // paste is available
     523             :     // @todo: determine correctly
     524         790 :     bool bHasSuitableClipboardContent = true;
     525             : 
     526         790 :     bool bShapeContext = ( m_pChartController ? m_pChartController->isShapeContext() : false );
     527             : 
     528         790 :     bool bDisableDataTableDialog = false;
     529         790 :     if ( m_xController.is() )
     530             :     {
     531         790 :         Reference< beans::XPropertySet > xProps( m_xController->getModel(), uno::UNO_QUERY );
     532         790 :         if ( xProps.is() )
     533             :         {
     534             :             try
     535             :             {
     536         790 :                 xProps->getPropertyValue(  "EnableDataTableDialog" ) >>= bDisableDataTableDialog;
     537             :             }
     538           0 :             catch( const uno::Exception& e )
     539             :             {
     540             :                 ASSERT_EXCEPTION( e );
     541             :             }
     542         790 :         }
     543             :     }
     544             : 
     545             :     // edit commands
     546         790 :     m_aCommandAvailability[ ".uno:Cut" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bIsDeleteableObjectSelected;
     547         790 :     m_aCommandAvailability[ ".uno:Copy" ] = bControllerStateIsValid && m_apControllerState->bHasSelectedObject;
     548         790 :     m_aCommandAvailability[ ".uno:Paste" ] = bIsWritable && bHasSuitableClipboardContent;
     549             : 
     550             :     // toolbar commands
     551         790 :     m_aCommandAvailability[ ".uno:ToggleGridHorizontal" ] = bIsWritable;
     552         790 :     m_aCommandArguments[ ".uno:ToggleGridHorizontal" ] = uno::makeAny( m_apModelState->bHasMainYGrid );
     553         790 :     m_aCommandAvailability[ ".uno:ToggleGridVertical" ] = bIsWritable;
     554         790 :     m_aCommandArguments[ ".uno:ToggleGridVertical" ] = uno::makeAny( m_apModelState->bHasMainXGrid );
     555             : 
     556         790 :     m_aCommandAvailability[ ".uno:ToggleLegend" ] = bIsWritable;
     557         790 :     m_aCommandArguments[ ".uno:ToggleLegend" ] = uno::makeAny( m_apModelState->bHasLegend );
     558             : 
     559         790 :     m_aCommandAvailability[ ".uno:NewArrangement" ] = bIsWritable;
     560         790 :     m_aCommandAvailability[ ".uno:Update" ] = bIsWritable;
     561         790 :     m_aCommandAvailability[ ".uno:DefaultColors" ] = bIsWritable;
     562         790 :     m_aCommandAvailability[ ".uno:BarWidth" ] = bIsWritable;
     563         790 :     m_aCommandAvailability[ ".uno:NumberOfLines" ] = bIsWritable;
     564        1580 :     m_aCommandAvailability[ ".uno:ArrangeRow" ] =
     565         790 :         bShapeContext || ( bIsWritable && bControllerStateIsValid && ( m_apControllerState->bMayMoveSeriesForward || m_apControllerState->bMayMoveSeriesBackward ) );
     566             : 
     567             :     // insert objects
     568         790 :     m_aCommandAvailability[ ".uno:InsertTitles" ] = m_aCommandAvailability[ ".uno:InsertMenuTitles" ] = bIsWritable;
     569         790 :     m_aCommandAvailability[ ".uno:InsertLegend" ] = m_aCommandAvailability[ ".uno:InsertMenuLegend" ] = bIsWritable;
     570         790 :     m_aCommandAvailability[ ".uno:DeleteLegend" ] = bIsWritable;
     571         790 :     m_aCommandAvailability[ ".uno:InsertMenuDataLabels" ] = bIsWritable;
     572         790 :     m_aCommandAvailability[ ".uno:InsertRemoveAxes" ] = m_aCommandAvailability[ ".uno:InsertMenuAxes" ] = bIsWritable && m_apModelState->bSupportsAxes;
     573         790 :     m_aCommandAvailability[ ".uno:InsertMenuGrids" ] = bIsWritable && m_apModelState->bSupportsAxes;
     574         790 :     m_aCommandAvailability[ ".uno:InsertMenuTrendlines" ] = bIsWritable && m_apModelState->bSupportsStatistics && m_apControllerState->bMayAddMenuTrendline;
     575         790 :     m_aCommandAvailability[ ".uno:InsertMenuMeanValues" ] = bIsWritable && m_apModelState->bSupportsStatistics;
     576         790 :     m_aCommandAvailability[ ".uno:InsertMenuXErrorBars" ] = bIsWritable && m_apModelState->bSupportsStatistics;
     577         790 :     m_aCommandAvailability[ ".uno:InsertMenuYErrorBars" ] = bIsWritable && m_apModelState->bSupportsStatistics;
     578         790 :     m_aCommandAvailability[ ".uno:InsertSymbol" ] = bIsWritable && m_apControllerState->bIsTextObject;
     579             : 
     580             :     // format objects
     581         790 :     bool bFormatObjectAvailable = bIsWritable && bControllerStateIsValid && m_apControllerState->bIsFormateableObjectSelected;
     582         790 :     m_aCommandAvailability[ ".uno:FormatSelection" ] = bFormatObjectAvailable;
     583         790 :     m_aCommandAvailability[ ".uno:FormatAxis" ] = bFormatObjectAvailable;
     584         790 :     m_aCommandAvailability[ ".uno:FormatTitle" ] = bFormatObjectAvailable;
     585         790 :     m_aCommandAvailability[ ".uno:FormatDataSeries" ] = bFormatObjectAvailable;
     586         790 :     m_aCommandAvailability[ ".uno:FormatDataPoint" ] = bFormatObjectAvailable;
     587         790 :     m_aCommandAvailability[ ".uno:FormatDataLabels" ] = bFormatObjectAvailable;
     588         790 :     m_aCommandAvailability[ ".uno:FormatDataLabel" ] = bFormatObjectAvailable;
     589         790 :     m_aCommandAvailability[ ".uno:FormatXErrorBars" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatXErrorBars;
     590         790 :     m_aCommandAvailability[ ".uno:FormatYErrorBars" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatYErrorBars;
     591         790 :     m_aCommandAvailability[ ".uno:FormatMeanValue" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatMeanValue;
     592         790 :     m_aCommandAvailability[ ".uno:FormatTrendline" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatTrendline;
     593         790 :     m_aCommandAvailability[ ".uno:FormatTrendlineEquation" ] = bFormatObjectAvailable && bControllerStateIsValid && m_apControllerState->bMayFormatTrendlineEquation;
     594         790 :     m_aCommandAvailability[ ".uno:FormatStockLoss" ] = bFormatObjectAvailable;
     595         790 :     m_aCommandAvailability[ ".uno:FormatStockGain" ] = bFormatObjectAvailable;
     596             : 
     597         790 :     m_aCommandAvailability[ ".uno:DiagramType" ] = bIsWritable;
     598         790 :     m_aCommandAvailability[ ".uno:Legend" ] = bIsWritable && m_apModelState->bHasLegend;
     599         790 :     m_aCommandAvailability[ ".uno:DiagramWall" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasWall;
     600         790 :     m_aCommandAvailability[ ".uno:DiagramArea" ] = bIsWritable;
     601             : 
     602         790 :     m_aCommandAvailability[ ".uno:TransformDialog" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bHasSelectedObject && m_apControllerState->bIsPositionableObject;
     603             : 
     604             :     // 3d commands
     605         790 :     m_aCommandAvailability[ ".uno:View3D" ] = bIsWritable && bModelStateIsValid && m_apModelState->bIsThreeD;
     606         790 :     m_aCommandAvailability[ ".uno:DiagramFloor" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasFloor;
     607             : 
     608             :     //some mor format commands with different ui text
     609         790 :     m_aCommandAvailability[ ".uno:FormatWall" ] = m_aCommandAvailability[ ".uno:DiagramWall" ];
     610         790 :     m_aCommandAvailability[ ".uno:FormatFloor" ] = m_aCommandAvailability[ ".uno:DiagramFloor" ];
     611         790 :     m_aCommandAvailability[ ".uno:FormatChartArea" ] = m_aCommandAvailability[ ".uno:DiagramArea" ];
     612         790 :     m_aCommandAvailability[ ".uno:FormatLegend" ] = m_aCommandAvailability[ ".uno:Legend" ];
     613             : 
     614             :     // depending on own data
     615         790 :     m_aCommandAvailability[ ".uno:DataRanges" ] = bIsWritable && bModelStateIsValid && (! m_apModelState->bHasOwnData);
     616         790 :     m_aCommandAvailability[ ".uno:DiagramData" ] = bIsWritable && bModelStateIsValid &&  m_apModelState->bHasOwnData && !bDisableDataTableDialog;
     617             : 
     618             :     // titles
     619         790 :     m_aCommandAvailability[ ".uno:MainTitle" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasMainTitle;
     620         790 :     m_aCommandAvailability[ ".uno:SubTitle" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasSubTitle;
     621         790 :     m_aCommandAvailability[ ".uno:XTitle" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasXAxisTitle;
     622         790 :     m_aCommandAvailability[ ".uno:YTitle" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasYAxisTitle;
     623         790 :     m_aCommandAvailability[ ".uno:ZTitle" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasZAxisTitle;
     624         790 :     m_aCommandAvailability[ ".uno:SecondaryXTitle" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasSecondaryXAxisTitle;
     625         790 :     m_aCommandAvailability[ ".uno:SecondaryYTitle" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasSecondaryYAxisTitle;
     626         790 :     m_aCommandAvailability[ ".uno:AllTitles" ] = bIsWritable && bModelStateIsValid && m_apModelState->HasAnyTitle();
     627             : 
     628             :     // text
     629         790 :     m_aCommandAvailability[ ".uno:ScaleText" ] = bIsWritable && bModelStateIsValid ;
     630         790 :     m_aCommandArguments[ ".uno:ScaleText" ] = uno::makeAny( m_apModelState->bHasAutoScaledText );
     631             : 
     632             :     // axes
     633         790 :     m_aCommandAvailability[ ".uno:DiagramAxisX" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasXAxis;
     634         790 :     m_aCommandAvailability[ ".uno:DiagramAxisY" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasYAxis;
     635         790 :     m_aCommandAvailability[ ".uno:DiagramAxisZ" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasZAxis;
     636         790 :     m_aCommandAvailability[ ".uno:DiagramAxisA" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasAAxis;
     637         790 :     m_aCommandAvailability[ ".uno:DiagramAxisB" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasBAxis;
     638         790 :     m_aCommandAvailability[ ".uno:DiagramAxisAll" ] = bIsWritable && bModelStateIsValid && m_apModelState->HasAnyAxis();
     639             : 
     640             :     // grids
     641             :     // note: x and y are swapped in the commands!
     642         790 :     m_aCommandAvailability[ ".uno:DiagramGridYMain" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasMainXGrid;
     643         790 :     m_aCommandAvailability[ ".uno:DiagramGridXMain" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasMainYGrid;
     644         790 :     m_aCommandAvailability[ ".uno:DiagramGridZMain" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasMainZGrid;
     645         790 :     m_aCommandAvailability[ ".uno:DiagramGridYHelp" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasHelpXGrid;
     646         790 :     m_aCommandAvailability[ ".uno:DiagramGridXHelp" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasHelpYGrid;
     647         790 :     m_aCommandAvailability[ ".uno:DiagramGridZHelp" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasHelpZGrid;
     648         790 :     m_aCommandAvailability[ ".uno:DiagramGridAll" ] = bIsWritable && bModelStateIsValid && m_apModelState->HasAnyGrid();
     649             : 
     650             :     // series arrangement
     651        1580 :     m_aCommandAvailability[ ".uno:Forward" ] = ( bShapeContext ? isShapeControllerCommandAvailable( ".uno:Forward" ) :
     652         790 :         ( bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesForward && !bDisableDataTableDialog ) );
     653        1580 :     m_aCommandAvailability[ ".uno:Backward" ] = ( bShapeContext ? isShapeControllerCommandAvailable( ".uno:Backward" ) :
     654         790 :         ( bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesBackward && !bDisableDataTableDialog ) );
     655             : 
     656         790 :     m_aCommandAvailability[ ".uno:InsertDataLabels" ] = bIsWritable;
     657         790 :     m_aCommandAvailability[ ".uno:InsertDataLabel" ] = bIsWritable;
     658         790 :     m_aCommandAvailability[ ".uno:InsertMeanValue" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddMeanValue;
     659         790 :     m_aCommandAvailability[ ".uno:InsertTrendline" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddTrendline;
     660         790 :     m_aCommandAvailability[ ".uno:InsertTrendlineEquation" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddTrendlineEquation;
     661         790 :     m_aCommandAvailability[ ".uno:InsertTrendlineEquationAndR2" ] = m_aCommandAvailability[ ".uno:InsertTrendlineEquation" ];
     662         790 :     m_aCommandAvailability[ ".uno:InsertR2Value" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddR2Value;
     663         790 :     m_aCommandAvailability[ ".uno:DeleteR2Value" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteR2Value;
     664             : 
     665         790 :     m_aCommandAvailability[ ".uno:InsertXErrorBars" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddXErrorBars;
     666         790 :     m_aCommandAvailability[ ".uno:InsertYErrorBars" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddYErrorBars;
     667             : 
     668         790 :     m_aCommandAvailability[ ".uno:DeleteDataLabels" ] = bIsWritable;
     669         790 :     m_aCommandAvailability[ ".uno:DeleteDataLabel" ] = bIsWritable;
     670         790 :     m_aCommandAvailability[ ".uno:DeleteTrendline" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteTrendline;
     671         790 :     m_aCommandAvailability[ ".uno:DeleteTrendlineEquation" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteTrendlineEquation;
     672         790 :     m_aCommandAvailability[ ".uno:DeleteMeanValue" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteMeanValue;
     673         790 :     m_aCommandAvailability[ ".uno:DeleteXErrorBars" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteXErrorBars;
     674         790 :     m_aCommandAvailability[ ".uno:DeleteYErrorBars" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteYErrorBars;
     675             : 
     676         790 :     m_aCommandAvailability[ ".uno:ResetDataPoint" ] = bIsWritable;
     677         790 :     m_aCommandAvailability[ ".uno:ResetAllDataPoints" ] = bIsWritable;
     678             : 
     679         790 :     m_aCommandAvailability[ ".uno:InsertAxis" ] = bIsWritable;
     680         790 :     m_aCommandAvailability[ ".uno:DeleteAxis" ] = bIsWritable;
     681         790 :     m_aCommandAvailability[ ".uno:InsertAxisTitle" ] = bIsWritable;
     682         790 :     m_aCommandAvailability[ ".uno:FormatMajorGrid" ] = bIsWritable;
     683         790 :     m_aCommandAvailability[ ".uno:InsertMajorGrid" ] = bIsWritable;
     684         790 :     m_aCommandAvailability[ ".uno:DeleteMajorGrid" ] = bIsWritable;
     685         790 :     m_aCommandAvailability[ ".uno:FormatMinorGrid" ] = bIsWritable;
     686         790 :     m_aCommandAvailability[ ".uno:InsertMinorGrid" ] = bIsWritable;
     687         790 :     m_aCommandAvailability[ ".uno:DeleteMinorGrid" ] = bIsWritable;
     688         790 : }
     689             : 
     690       81352 : bool ControllerCommandDispatch::commandAvailable( const OUString & rCommand )
     691             : {
     692       81352 :     ::std::map< OUString, bool >::const_iterator aIt( m_aCommandAvailability.find( rCommand ));
     693       81352 :     if( aIt != m_aCommandAvailability.end())
     694       81352 :         return aIt->second;
     695             :     OSL_FAIL( "commandAvailable: command not in availability map" );
     696           0 :     return false;
     697             : }
     698             : 
     699           0 : bool ControllerCommandDispatch::isShapeControllerCommandAvailable( const OUString& rCommand )
     700             : {
     701           0 :     ShapeController* pShapeController = ( m_pDispatchContainer ? m_pDispatchContainer->getShapeController() : NULL );
     702           0 :     if ( pShapeController )
     703             :     {
     704           0 :         FeatureState aState( pShapeController->getState( rCommand ) );
     705           0 :         return aState.bEnabled;
     706             :     }
     707           0 :     return false;
     708             : }
     709             : 
     710         977 : void ControllerCommandDispatch::fireStatusEvent(
     711             :     const OUString & rURL,
     712             :     const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ )
     713             : {
     714         977 :     bool bIsChartSelectorURL = rURL == ".uno:ChartElementSelector";
     715         977 :     if( rURL.isEmpty() || bIsChartSelectorURL )
     716             :     {
     717         790 :         uno::Any aArg;
     718         790 :         aArg <<= m_xController;
     719         790 :         fireStatusEventForURL( ".uno:ChartElementSelector", aArg, true, xSingleListener );
     720             :     }
     721             : 
     722         977 :     if( rURL.isEmpty() )
     723      245814 :         for( ::std::map< OUString, bool >::const_iterator aIt( m_aCommandAvailability.begin());
     724      163876 :              aIt != m_aCommandAvailability.end(); ++aIt )
     725       81165 :             fireStatusEventForURLImpl( aIt->first, xSingleListener );
     726         204 :     else if( !bIsChartSelectorURL )
     727         187 :         fireStatusEventForURLImpl( rURL, xSingleListener );
     728             : 
     729             :     // statusbar. Should be handled by base implementation
     730             :     // @todo: remove if Issue 68864 is fixed
     731         977 :     if( rURL.isEmpty() || rURL == ".uno:StatusBarVisible" )
     732             :     {
     733         773 :         bool bIsStatusBarVisible( lcl_isStatusBarVisible( m_xController ));
     734         773 :         fireStatusEventForURL( ".uno:StatusBarVisible", uno::makeAny( bIsStatusBarVisible ), true, xSingleListener );
     735             :     }
     736         977 : }
     737             : 
     738             : // ____ XDispatch ____
     739           0 : void SAL_CALL ControllerCommandDispatch::dispatch(
     740             :     const util::URL& URL,
     741             :     const Sequence< beans::PropertyValue >& Arguments )
     742             :     throw (uno::RuntimeException, std::exception)
     743             : {
     744           0 :     if( commandAvailable( URL.Complete ))
     745           0 :         m_xDispatch->dispatch( URL, Arguments );
     746           0 : }
     747             : 
     748             : // ____ WeakComponentImplHelperBase ____
     749             : /// is called when this is disposed
     750          17 : void SAL_CALL ControllerCommandDispatch::disposing()
     751             : {
     752          17 :     m_xController.clear();
     753          17 :     m_xDispatch.clear();
     754          17 :     m_xSelectionSupplier.clear();
     755          17 : }
     756             : 
     757             : // ____ XEventListener (base of XModifyListener) ____
     758          17 : void SAL_CALL ControllerCommandDispatch::disposing( const lang::EventObject& /* Source */ )
     759             :     throw (uno::RuntimeException, std::exception)
     760             : {
     761          17 :     m_xController.clear();
     762          17 :     m_xDispatch.clear();
     763          17 :     m_xSelectionSupplier.clear();
     764          17 : }
     765             : 
     766             : // ____ XModifyListener ____
     767         773 : void SAL_CALL ControllerCommandDispatch::modified( const lang::EventObject& aEvent )
     768             :     throw (uno::RuntimeException, std::exception)
     769             : {
     770         773 :     bool bUpdateCommandAvailability = false;
     771             : 
     772             :     // Update the "ModelState" Struct.
     773         773 :     if( m_apModelState.get() && m_xController.is())
     774             :     {
     775         773 :         m_apModelState->update( m_xController->getModel());
     776         773 :         bUpdateCommandAvailability = true;
     777             :     }
     778             : 
     779             :     // Update the "ControllerState" Struct.
     780         773 :     if( m_apControllerState.get() && m_xController.is())
     781             :     {
     782         773 :         m_apControllerState->update( m_xController, m_xController->getModel());
     783         773 :         bUpdateCommandAvailability = true;
     784             :     }
     785             : 
     786         773 :     if( bUpdateCommandAvailability )
     787         773 :         updateCommandAvailability();
     788             : 
     789         773 :     CommandDispatch::modified( aEvent );
     790         773 : }
     791             : 
     792             : // ____ XSelectionChangeListener ____
     793           0 : void SAL_CALL ControllerCommandDispatch::selectionChanged( const lang::EventObject& aEvent )
     794             :     throw (uno::RuntimeException, std::exception)
     795             : {
     796             :     // Update the "ControllerState" Struct.
     797           0 :     if( m_apControllerState.get() && m_xController.is())
     798             :     {
     799           0 :         m_apControllerState->update( m_xController, m_xController->getModel());
     800           0 :         updateCommandAvailability();
     801             :     }
     802             : 
     803           0 :     CommandDispatch::modified( aEvent );
     804           0 : }
     805             : 
     806             : } //  namespace chart
     807             : 
     808             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10