LCOV - code coverage report
Current view: top level - chart2/source/controller/main - ControllerCommandDispatch.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 296 355 83.4 %
Date: 2014-11-03 Functions: 21 24 87.5 %
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        1603 : bool lcl_isStatusBarVisible( const Reference< frame::XController > & xController )
      54             : {
      55        1603 :     bool bIsStatusBarVisible = false;
      56             :     // Status-Bar visible, workaround: this should not be necessary. @todo:
      57             :     // remove when Issue #i68864# is fixed
      58        1603 :     if( xController.is())
      59             :     {
      60        1603 :         Reference< beans::XPropertySet > xPropSet( xController->getFrame(), uno::UNO_QUERY );
      61        1603 :         if( xPropSet.is() )
      62             :         {
      63        1603 :             uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
      64        1603 :             xPropSet->getPropertyValue( "LayoutManager" ) >>= xLayoutManager;
      65        1603 :             if ( xLayoutManager.is() )
      66        1603 :                 bIsStatusBarVisible = xLayoutManager->isElementVisible( "private:resource/statusbar/statusbar" );
      67        1603 :         }
      68             :     }
      69        1603 :     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          34 : 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          34 :         bMayFormatYErrorBars( false )
     165          34 : {}
     166             : 
     167        1637 : void ControllerState::update(
     168             :     const Reference< frame::XController > & xController,
     169             :     const Reference< frame::XModel > & xModel )
     170             : {
     171             :     Reference< view::XSelectionSupplier > xSelectionSupplier(
     172        1637 :         xController, uno::UNO_QUERY );
     173             : 
     174             :     // Update ControllerState variables.
     175        1637 :     if( xSelectionSupplier.is())
     176             :     {
     177        1637 :         uno::Any aSelObj( xSelectionSupplier->getSelection() );
     178        3274 :         ObjectIdentifier aSelOID( aSelObj );
     179        3274 :         OUString aSelObjCID( aSelOID.getObjectCID() );
     180             : 
     181        1637 :         bHasSelectedObject = aSelOID.isValid();
     182             : 
     183        1637 :         ObjectType aObjectType(ObjectIdentifier::getObjectType( aSelObjCID ));
     184             : 
     185        1637 :         bIsPositionableObject = (OBJECTTYPE_DATA_POINT != aObjectType) && aSelOID.isDragableObject();
     186        1637 :         bIsTextObject = OBJECTTYPE_TITLE == aObjectType;
     187             : 
     188        3274 :         uno::Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel ));
     189        1637 :         bIsFormateableObjectSelected = bHasSelectedObject && aSelOID.isAutoGeneratedObject();
     190        1637 :         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        3274 :                 aSelObjCID, xModel ) );
     196             : 
     197        1637 :         bIsDeleteableObjectSelected = ChartController::isObjectDeleteable( aSelObj );
     198             : 
     199        4911 :         bMayMoveSeriesForward = (OBJECTTYPE_DATA_POINT!=aObjectType) && DiagramHelper::isSeriesMoveable(
     200             :             ChartModelHelper::findDiagram( xModel ),
     201             :             xGivenDataSeries,
     202        4911 :             MOVE_SERIES_FORWARD );
     203             : 
     204        4911 :         bMayMoveSeriesBackward = (OBJECTTYPE_DATA_POINT!=aObjectType) && DiagramHelper::isSeriesMoveable(
     205             :             ChartModelHelper::findDiagram( xModel ),
     206             :             xGivenDataSeries,
     207        4911 :             MOVE_SERIES_BACKWARD );
     208             : 
     209        1637 :         bMayAddMenuTrendline = false;
     210        1637 :         bMayAddTrendline = false;
     211        1637 :         bMayAddTrendlineEquation = false;
     212        1637 :         bMayAddR2Value = false;
     213        1637 :         bMayAddMeanValue = false;
     214        1637 :         bMayAddXErrorBars = false;
     215        1637 :         bMayAddYErrorBars = false;
     216        1637 :         bMayDeleteTrendline = false;
     217        1637 :         bMayDeleteTrendlineEquation = false;
     218        1637 :         bMayDeleteR2Value = false;
     219        1637 :         bMayDeleteMeanValue = false;
     220        1637 :         bMayDeleteXErrorBars = false;
     221        1637 :         bMayDeleteYErrorBars = false;
     222        1637 :         bMayFormatTrendline = false;
     223        1637 :         bMayFormatTrendlineEquation = false;
     224        1637 :         bMayFormatMeanValue = false;
     225        1637 :         bMayFormatXErrorBars = false;
     226        1637 :         bMayFormatYErrorBars = false;
     227        1637 :         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        1637 :         }
     303        1637 :     }
     304        1637 : }
     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          34 : 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          34 :         bSupportsAxes( false )
     389             : 
     390          34 : {}
     391             : 
     392        1637 : void ModelState::update( const Reference< frame::XModel > & xModel )
     393             : {
     394        1637 :     Reference< chart2::XChartDocument > xChartDoc( xModel, uno::UNO_QUERY );
     395        3274 :     Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel ));
     396             : 
     397        1637 :     bIsReadOnly = true;
     398        3274 :     Reference< frame::XStorable > xStorable( xModel, uno::UNO_QUERY );
     399        1637 :     if( xStorable.is())
     400        1637 :         bIsReadOnly = xStorable->isReadonly();
     401             : 
     402        1637 :     sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
     403             : 
     404        3274 :     uno::Reference< chart2::XChartType > xFirstChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) );
     405        1637 :     bSupportsStatistics = ChartTypeHelper::isSupportingStatisticProperties( xFirstChartType, nDimensionCount );
     406        1637 :     bSupportsAxes = ChartTypeHelper::isSupportingMainAxis( xFirstChartType, nDimensionCount, 0 );
     407             : 
     408        1637 :     bIsThreeD = (nDimensionCount == 3);
     409        1637 :     bHasOwnData = (xChartDoc.is() && xChartDoc->hasInternalDataProvider());
     410             : 
     411        1637 :     bHasMainTitle =  TitleHelper::getTitle( TitleHelper::MAIN_TITLE, xModel ).is();
     412        1637 :     bHasSubTitle =   TitleHelper::getTitle( TitleHelper::SUB_TITLE, xModel ).is();
     413        1637 :     bHasXAxisTitle = TitleHelper::getTitle( TitleHelper::X_AXIS_TITLE, xModel ).is();
     414        1637 :     bHasYAxisTitle = TitleHelper::getTitle( TitleHelper::Y_AXIS_TITLE, xModel ).is();
     415        1637 :     bHasZAxisTitle = TitleHelper::getTitle( TitleHelper::Z_AXIS_TITLE, xModel ).is();
     416        1637 :     bHasSecondaryXAxisTitle = TitleHelper::getTitle( TitleHelper::SECONDARY_X_AXIS_TITLE, xModel ).is();
     417        1637 :     bHasSecondaryYAxisTitle = TitleHelper::getTitle( TitleHelper::SECONDARY_Y_AXIS_TITLE, xModel ).is();
     418             : 
     419        1637 :     bHasXAxis = bSupportsAxes && AxisHelper::getAxis( 0, true, xDiagram ).is();
     420        1637 :     bHasYAxis = bSupportsAxes && AxisHelper::getAxis( 1, true, xDiagram ).is();
     421        1637 :     bHasZAxis = bSupportsAxes && AxisHelper::getAxis( 2, true, xDiagram ).is();
     422        1637 :     bHasAAxis = bSupportsAxes && AxisHelper::getAxis( 0, false, xDiagram ).is();
     423        1637 :     bHasBAxis = bSupportsAxes && AxisHelper::getAxis( 1, false, xDiagram ).is();
     424             : 
     425        1637 :     bHasMainXGrid = bSupportsAxes && AxisHelper::isGridShown( 0, 0, true, xDiagram );
     426        1637 :     bHasMainYGrid = bSupportsAxes && AxisHelper::isGridShown( 1, 0, true, xDiagram );
     427        1637 :     bHasMainZGrid = bSupportsAxes && AxisHelper::isGridShown( 2, 0, true, xDiagram );
     428        1637 :     bHasHelpXGrid = bSupportsAxes && AxisHelper::isGridShown( 0, 0, false, xDiagram );
     429        1637 :     bHasHelpYGrid = bSupportsAxes && AxisHelper::isGridShown( 1, 0, false, xDiagram );
     430        1637 :     bHasHelpZGrid = bSupportsAxes && AxisHelper::isGridShown( 2, 0, false, xDiagram );
     431             : 
     432             :     bHasAutoScaledText =
     433        1637 :         (ReferenceSizeProvider::getAutoResizeState( xChartDoc ) ==
     434        1637 :          ReferenceSizeProvider::AUTO_RESIZE_YES);
     435             : 
     436        1637 :     bHasLegend = LegendHelper::hasLegend( xDiagram );
     437        1637 :     bHasWall = DiagramHelper::isSupportingFloorAndWall( xDiagram );
     438        3274 :     bHasFloor = bHasWall && bIsThreeD;
     439        1637 : }
     440             : 
     441        1637 : bool ModelState::HasAnyAxis() const
     442             : {
     443        1637 :     return bHasXAxis || bHasYAxis || bHasZAxis || bHasAAxis || bHasBAxis;
     444             : }
     445             : 
     446        1637 : bool ModelState::HasAnyGrid() const
     447             : {
     448        1499 :     return bHasMainXGrid || bHasMainYGrid || bHasMainZGrid ||
     449        2154 :         bHasHelpXGrid || bHasHelpYGrid || bHasHelpZGrid;
     450             : }
     451             : 
     452        1637 : bool ModelState::HasAnyTitle() const
     453             : {
     454        1637 :     return bHasMainTitle || bHasSubTitle || bHasXAxisTitle || bHasYAxisTitle || bHasZAxisTitle || bHasSecondaryXAxisTitle || bHasSecondaryYAxisTitle;
     455             : }
     456             : 
     457             : } // namespace impl
     458             : 
     459          34 : ControllerCommandDispatch::ControllerCommandDispatch(
     460             :     const Reference< uno::XComponentContext > & xContext,
     461             :     ChartController* pController, CommandDispatchContainer* pContainer ) :
     462             :         impl::ControllerCommandDispatch_Base( xContext ),
     463             :         m_pChartController( pController ),
     464          34 :         m_xController( Reference< frame::XController >( pController ) ),
     465          34 :         m_xSelectionSupplier( Reference< view::XSelectionSupplier >( pController ) ),
     466          34 :         m_xDispatch( Reference< frame::XDispatch >( pController ) ),
     467             :         m_apModelState( new impl::ModelState() ),
     468             :         m_apControllerState( new impl::ControllerState() ),
     469         136 :         m_pDispatchContainer( pContainer )
     470             : {
     471          34 : }
     472             : 
     473           4 : ControllerCommandDispatch::~ControllerCommandDispatch()
     474             : {
     475           4 : }
     476             : 
     477          34 : void ControllerCommandDispatch::initialize()
     478             : {
     479          34 :     if( m_xController.is())
     480             :     {
     481          34 :         Reference< frame::XModel > xModel( m_xController->getModel());
     482          68 :         Reference< util::XModifyBroadcaster > xModifyBroadcaster( xModel, uno::UNO_QUERY );
     483             :         OSL_ASSERT( xModifyBroadcaster.is());
     484          34 :         if( xModifyBroadcaster.is())
     485          34 :             xModifyBroadcaster->addModifyListener( this );
     486             : 
     487             :                 // Listen selection modifications (Arrangement feature - issue 63017).
     488          34 :                 if( m_xSelectionSupplier.is() )
     489          34 :                         m_xSelectionSupplier->addSelectionChangeListener( this );
     490             : 
     491          34 :         if( m_apModelState.get() && xModel.is())
     492          34 :             m_apModelState->update( xModel );
     493             : 
     494          34 :         if( m_apControllerState.get() && xModel.is())
     495          34 :             m_apControllerState->update( m_xController, xModel );
     496             : 
     497          68 :         updateCommandAvailability();
     498             :     }
     499          34 : }
     500             : 
     501      168612 : void ControllerCommandDispatch::fireStatusEventForURLImpl(
     502             :     const OUString & rURL,
     503             :     const Reference< frame::XStatusListener > & xSingleListener )
     504             : {
     505      168612 :     ::std::map< OUString, uno::Any >::const_iterator aArgIt( m_aCommandArguments.find( rURL ));
     506      168612 :     if( aArgIt != m_aCommandArguments.end())
     507        6520 :         fireStatusEventForURL( rURL, aArgIt->second, commandAvailable( rURL ), xSingleListener );
     508             :     else
     509      162092 :         fireStatusEventForURL( rURL, uno::Any(), commandAvailable( rURL ), xSingleListener );
     510      168612 : }
     511             : 
     512        1637 : void ControllerCommandDispatch::updateCommandAvailability()
     513             : {
     514        1637 :     bool bModelStateIsValid = ( m_apModelState.get() != 0 );
     515        1637 :     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        1637 :     bool bIsWritable = bModelStateIsValid && (! m_apModelState->bIsReadOnly);
     522             :     // paste is available
     523             :     // @todo: determine correctly
     524        1637 :     bool bHasSuitableClipboardContent = true;
     525             : 
     526        1637 :     bool bShapeContext = m_pChartController && m_pChartController->isShapeContext();
     527             : 
     528        1637 :     bool bEnableDataTableDialog = false;
     529        1637 :     if ( m_xController.is() )
     530             :     {
     531        1637 :         Reference< beans::XPropertySet > xProps( m_xController->getModel(), uno::UNO_QUERY );
     532        1637 :         if ( xProps.is() )
     533             :         {
     534             :             try
     535             :             {
     536        1637 :                 xProps->getPropertyValue("EnableDataTableDialog") >>= bEnableDataTableDialog;
     537             :             }
     538           0 :             catch( const uno::Exception& e )
     539             :             {
     540             :                 ASSERT_EXCEPTION( e );
     541             :             }
     542        1637 :         }
     543             :     }
     544             : 
     545             :     // edit commands
     546        1637 :     m_aCommandAvailability[ ".uno:Cut" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bIsDeleteableObjectSelected;
     547        1637 :     m_aCommandAvailability[ ".uno:Copy" ] = bControllerStateIsValid && m_apControllerState->bHasSelectedObject;
     548        1637 :     m_aCommandAvailability[ ".uno:Paste" ] = bIsWritable && bHasSuitableClipboardContent;
     549             : 
     550             :     // toolbar commands
     551        1637 :     m_aCommandAvailability[ ".uno:ToggleGridHorizontal" ] = bIsWritable;
     552        1637 :     m_aCommandArguments[ ".uno:ToggleGridHorizontal" ] = uno::makeAny( m_apModelState->bHasMainYGrid );
     553        1637 :     m_aCommandAvailability[ ".uno:ToggleGridVertical" ] = bIsWritable;
     554        1637 :     m_aCommandArguments[ ".uno:ToggleGridVertical" ] = uno::makeAny( m_apModelState->bHasMainXGrid );
     555             : 
     556        1637 :     m_aCommandAvailability[ ".uno:ToggleLegend" ] = bIsWritable;
     557        1637 :     m_aCommandArguments[ ".uno:ToggleLegend" ] = uno::makeAny( m_apModelState->bHasLegend );
     558             : 
     559        1637 :     m_aCommandAvailability[ ".uno:NewArrangement" ] = bIsWritable;
     560        1637 :     m_aCommandAvailability[ ".uno:Update" ] = bIsWritable;
     561        1637 :     m_aCommandAvailability[ ".uno:DefaultColors" ] = bIsWritable;
     562        1637 :     m_aCommandAvailability[ ".uno:BarWidth" ] = bIsWritable;
     563        1637 :     m_aCommandAvailability[ ".uno:NumberOfLines" ] = bIsWritable;
     564        3274 :     m_aCommandAvailability[ ".uno:ArrangeRow" ] =
     565        1637 :         bShapeContext || ( bIsWritable && bControllerStateIsValid && ( m_apControllerState->bMayMoveSeriesForward || m_apControllerState->bMayMoveSeriesBackward ) );
     566             : 
     567             :     // insert objects
     568        1637 :     m_aCommandAvailability[ ".uno:InsertTitles" ] = m_aCommandAvailability[ ".uno:InsertMenuTitles" ] = bIsWritable;
     569        1637 :     m_aCommandAvailability[ ".uno:InsertLegend" ] = m_aCommandAvailability[ ".uno:InsertMenuLegend" ] = bIsWritable;
     570        1637 :     m_aCommandAvailability[ ".uno:DeleteLegend" ] = bIsWritable;
     571        1637 :     m_aCommandAvailability[ ".uno:InsertMenuDataLabels" ] = bIsWritable;
     572        1637 :     m_aCommandAvailability[ ".uno:InsertRemoveAxes" ] = m_aCommandAvailability[ ".uno:InsertMenuAxes" ] = bIsWritable && m_apModelState->bSupportsAxes;
     573        1637 :     m_aCommandAvailability[ ".uno:InsertMenuGrids" ] = bIsWritable && m_apModelState->bSupportsAxes;
     574        1637 :     m_aCommandAvailability[ ".uno:InsertMenuTrendlines" ] = bIsWritable && m_apModelState->bSupportsStatistics && m_apControllerState->bMayAddMenuTrendline;
     575        1637 :     m_aCommandAvailability[ ".uno:InsertMenuMeanValues" ] = bIsWritable && m_apModelState->bSupportsStatistics;
     576        1637 :     m_aCommandAvailability[ ".uno:InsertMenuXErrorBars" ] = bIsWritable && m_apModelState->bSupportsStatistics;
     577        1637 :     m_aCommandAvailability[ ".uno:InsertMenuYErrorBars" ] = bIsWritable && m_apModelState->bSupportsStatistics;
     578        1637 :     m_aCommandAvailability[ ".uno:InsertSymbol" ] = bIsWritable && m_apControllerState->bIsTextObject;
     579             : 
     580             :     // format objects
     581        1637 :     bool bFormatObjectAvailable = bIsWritable && bControllerStateIsValid && m_apControllerState->bIsFormateableObjectSelected;
     582        1637 :     m_aCommandAvailability[ ".uno:FormatSelection" ] = bFormatObjectAvailable;
     583        1637 :     m_aCommandAvailability[ ".uno:FormatAxis" ] = bFormatObjectAvailable;
     584        1637 :     m_aCommandAvailability[ ".uno:FormatTitle" ] = bFormatObjectAvailable;
     585        1637 :     m_aCommandAvailability[ ".uno:FormatDataSeries" ] = bFormatObjectAvailable;
     586        1637 :     m_aCommandAvailability[ ".uno:FormatDataPoint" ] = bFormatObjectAvailable;
     587        1637 :     m_aCommandAvailability[ ".uno:FormatDataLabels" ] = bFormatObjectAvailable;
     588        1637 :     m_aCommandAvailability[ ".uno:FormatDataLabel" ] = bFormatObjectAvailable;
     589        1637 :     m_aCommandAvailability[ ".uno:FormatXErrorBars" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatXErrorBars;
     590        1637 :     m_aCommandAvailability[ ".uno:FormatYErrorBars" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatYErrorBars;
     591        1637 :     m_aCommandAvailability[ ".uno:FormatMeanValue" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatMeanValue;
     592        1637 :     m_aCommandAvailability[ ".uno:FormatTrendline" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatTrendline;
     593        1637 :     m_aCommandAvailability[ ".uno:FormatTrendlineEquation" ] = bFormatObjectAvailable && bControllerStateIsValid && m_apControllerState->bMayFormatTrendlineEquation;
     594        1637 :     m_aCommandAvailability[ ".uno:FormatStockLoss" ] = bFormatObjectAvailable;
     595        1637 :     m_aCommandAvailability[ ".uno:FormatStockGain" ] = bFormatObjectAvailable;
     596             : 
     597        1637 :     m_aCommandAvailability[ ".uno:DiagramType" ] = bIsWritable;
     598        1637 :     m_aCommandAvailability[ ".uno:Legend" ] = bIsWritable && m_apModelState->bHasLegend;
     599        1637 :     m_aCommandAvailability[ ".uno:DiagramWall" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasWall;
     600        1637 :     m_aCommandAvailability[ ".uno:DiagramArea" ] = bIsWritable;
     601             : 
     602        1637 :     m_aCommandAvailability[ ".uno:TransformDialog" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bHasSelectedObject && m_apControllerState->bIsPositionableObject;
     603             : 
     604             :     // 3d commands
     605        1637 :     m_aCommandAvailability[ ".uno:View3D" ] = bIsWritable && bModelStateIsValid && m_apModelState->bIsThreeD;
     606        1637 :     m_aCommandAvailability[ ".uno:DiagramFloor" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasFloor;
     607             : 
     608             :     //some mor format commands with different ui text
     609        1637 :     m_aCommandAvailability[ ".uno:FormatWall" ] = m_aCommandAvailability[ ".uno:DiagramWall" ];
     610        1637 :     m_aCommandAvailability[ ".uno:FormatFloor" ] = m_aCommandAvailability[ ".uno:DiagramFloor" ];
     611        1637 :     m_aCommandAvailability[ ".uno:FormatChartArea" ] = m_aCommandAvailability[ ".uno:DiagramArea" ];
     612        1637 :     m_aCommandAvailability[ ".uno:FormatLegend" ] = m_aCommandAvailability[ ".uno:Legend" ];
     613             : 
     614             :     // depending on own data
     615        1637 :     m_aCommandAvailability[ ".uno:DataRanges" ] = bIsWritable && bModelStateIsValid && (! m_apModelState->bHasOwnData);
     616        1637 :     m_aCommandAvailability[ ".uno:DiagramData" ] = bIsWritable && bModelStateIsValid &&  m_apModelState->bHasOwnData && bEnableDataTableDialog;
     617             : 
     618             :     // titles
     619        1637 :     m_aCommandAvailability[ ".uno:MainTitle" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasMainTitle;
     620        1637 :     m_aCommandAvailability[ ".uno:SubTitle" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasSubTitle;
     621        1637 :     m_aCommandAvailability[ ".uno:XTitle" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasXAxisTitle;
     622        1637 :     m_aCommandAvailability[ ".uno:YTitle" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasYAxisTitle;
     623        1637 :     m_aCommandAvailability[ ".uno:ZTitle" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasZAxisTitle;
     624        1637 :     m_aCommandAvailability[ ".uno:SecondaryXTitle" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasSecondaryXAxisTitle;
     625        1637 :     m_aCommandAvailability[ ".uno:SecondaryYTitle" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasSecondaryYAxisTitle;
     626        1637 :     m_aCommandAvailability[ ".uno:AllTitles" ] = bIsWritable && bModelStateIsValid && m_apModelState->HasAnyTitle();
     627             : 
     628             :     // text
     629        1637 :     m_aCommandAvailability[ ".uno:ScaleText" ] = bIsWritable && bModelStateIsValid ;
     630        1637 :     m_aCommandArguments[ ".uno:ScaleText" ] = uno::makeAny( m_apModelState->bHasAutoScaledText );
     631             : 
     632             :     // axes
     633        1637 :     m_aCommandAvailability[ ".uno:DiagramAxisX" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasXAxis;
     634        1637 :     m_aCommandAvailability[ ".uno:DiagramAxisY" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasYAxis;
     635        1637 :     m_aCommandAvailability[ ".uno:DiagramAxisZ" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasZAxis;
     636        1637 :     m_aCommandAvailability[ ".uno:DiagramAxisA" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasAAxis;
     637        1637 :     m_aCommandAvailability[ ".uno:DiagramAxisB" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasBAxis;
     638        1637 :     m_aCommandAvailability[ ".uno:DiagramAxisAll" ] = bIsWritable && bModelStateIsValid && m_apModelState->HasAnyAxis();
     639             : 
     640             :     // grids
     641             :     // note: x and y are swapped in the commands!
     642        1637 :     m_aCommandAvailability[ ".uno:DiagramGridYMain" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasMainXGrid;
     643        1637 :     m_aCommandAvailability[ ".uno:DiagramGridXMain" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasMainYGrid;
     644        1637 :     m_aCommandAvailability[ ".uno:DiagramGridZMain" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasMainZGrid;
     645        1637 :     m_aCommandAvailability[ ".uno:DiagramGridYHelp" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasHelpXGrid;
     646        1637 :     m_aCommandAvailability[ ".uno:DiagramGridXHelp" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasHelpYGrid;
     647        1637 :     m_aCommandAvailability[ ".uno:DiagramGridZHelp" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasHelpZGrid;
     648        1637 :     m_aCommandAvailability[ ".uno:DiagramGridAll" ] = bIsWritable && bModelStateIsValid && m_apModelState->HasAnyGrid();
     649             : 
     650             :     // series arrangement
     651        3274 :     m_aCommandAvailability[ ".uno:Forward" ] = ( bShapeContext ? isShapeControllerCommandAvailable( ".uno:Forward" ) :
     652        1637 :         ( bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesForward && bEnableDataTableDialog ) );
     653        3274 :     m_aCommandAvailability[ ".uno:Backward" ] = ( bShapeContext ? isShapeControllerCommandAvailable( ".uno:Backward" ) :
     654        1637 :         ( bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesBackward && bEnableDataTableDialog ) );
     655             : 
     656        1637 :     m_aCommandAvailability[ ".uno:InsertDataLabels" ] = bIsWritable;
     657        1637 :     m_aCommandAvailability[ ".uno:InsertDataLabel" ] = bIsWritable;
     658        1637 :     m_aCommandAvailability[ ".uno:InsertMeanValue" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddMeanValue;
     659        1637 :     m_aCommandAvailability[ ".uno:InsertTrendline" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddTrendline;
     660        1637 :     m_aCommandAvailability[ ".uno:InsertTrendlineEquation" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddTrendlineEquation;
     661        1637 :     m_aCommandAvailability[ ".uno:InsertTrendlineEquationAndR2" ] = m_aCommandAvailability[ ".uno:InsertTrendlineEquation" ];
     662        1637 :     m_aCommandAvailability[ ".uno:InsertR2Value" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddR2Value;
     663        1637 :     m_aCommandAvailability[ ".uno:DeleteR2Value" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteR2Value;
     664             : 
     665        1637 :     m_aCommandAvailability[ ".uno:InsertXErrorBars" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddXErrorBars;
     666        1637 :     m_aCommandAvailability[ ".uno:InsertYErrorBars" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddYErrorBars;
     667             : 
     668        1637 :     m_aCommandAvailability[ ".uno:DeleteDataLabels" ] = bIsWritable;
     669        1637 :     m_aCommandAvailability[ ".uno:DeleteDataLabel" ] = bIsWritable;
     670        1637 :     m_aCommandAvailability[ ".uno:DeleteTrendline" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteTrendline;
     671        1637 :     m_aCommandAvailability[ ".uno:DeleteTrendlineEquation" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteTrendlineEquation;
     672        1637 :     m_aCommandAvailability[ ".uno:DeleteMeanValue" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteMeanValue;
     673        1637 :     m_aCommandAvailability[ ".uno:DeleteXErrorBars" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteXErrorBars;
     674        1637 :     m_aCommandAvailability[ ".uno:DeleteYErrorBars" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteYErrorBars;
     675             : 
     676        1637 :     m_aCommandAvailability[ ".uno:ResetDataPoint" ] = bIsWritable;
     677        1637 :     m_aCommandAvailability[ ".uno:ResetAllDataPoints" ] = bIsWritable;
     678             : 
     679        1637 :     m_aCommandAvailability[ ".uno:InsertAxis" ] = bIsWritable;
     680        1637 :     m_aCommandAvailability[ ".uno:DeleteAxis" ] = bIsWritable;
     681        1637 :     m_aCommandAvailability[ ".uno:InsertAxisTitle" ] = bIsWritable;
     682        1637 :     m_aCommandAvailability[ ".uno:FormatMajorGrid" ] = bIsWritable;
     683        1637 :     m_aCommandAvailability[ ".uno:InsertMajorGrid" ] = bIsWritable;
     684        1637 :     m_aCommandAvailability[ ".uno:DeleteMajorGrid" ] = bIsWritable;
     685        1637 :     m_aCommandAvailability[ ".uno:FormatMinorGrid" ] = bIsWritable;
     686        1637 :     m_aCommandAvailability[ ".uno:InsertMinorGrid" ] = bIsWritable;
     687        1637 :     m_aCommandAvailability[ ".uno:DeleteMinorGrid" ] = bIsWritable;
     688        1637 : }
     689             : 
     690      168612 : bool ControllerCommandDispatch::commandAvailable( const OUString & rCommand )
     691             : {
     692      168612 :     ::std::map< OUString, bool >::const_iterator aIt( m_aCommandAvailability.find( rCommand ));
     693      168612 :     if( aIt != m_aCommandAvailability.end())
     694      168612 :         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        1927 : void ControllerCommandDispatch::fireStatusEvent(
     711             :     const OUString & rURL,
     712             :     const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ )
     713             : {
     714        1927 :     bool bIsChartSelectorURL = rURL == ".uno:ChartElementSelector";
     715        1927 :     if( rURL.isEmpty() || bIsChartSelectorURL )
     716             :     {
     717        1630 :         uno::Any aArg;
     718        1630 :         aArg <<= m_xController;
     719        1630 :         fireStatusEventForURL( ".uno:ChartElementSelector", aArg, true, xSingleListener );
     720             :     }
     721             : 
     722        1927 :     if( rURL.isEmpty() )
     723      509754 :         for( ::std::map< OUString, bool >::const_iterator aIt( m_aCommandAvailability.begin());
     724      339836 :              aIt != m_aCommandAvailability.end(); ++aIt )
     725      168315 :             fireStatusEventForURLImpl( aIt->first, xSingleListener );
     726         324 :     else if( !bIsChartSelectorURL )
     727         297 :         fireStatusEventForURLImpl( rURL, xSingleListener );
     728             : 
     729             :     // statusbar. Should be handled by base implementation
     730             :     // @todo: remove if Issue 68864 is fixed
     731        1927 :     if( rURL.isEmpty() || rURL == ".uno:StatusBarVisible" )
     732             :     {
     733        1603 :         bool bIsStatusBarVisible( lcl_isStatusBarVisible( m_xController ));
     734        1603 :         fireStatusEventForURL( ".uno:StatusBarVisible", uno::makeAny( bIsStatusBarVisible ), true, xSingleListener );
     735             :     }
     736        1927 : }
     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          34 : void SAL_CALL ControllerCommandDispatch::disposing()
     751             : {
     752          34 :     m_xController.clear();
     753          34 :     m_xDispatch.clear();
     754          34 :     m_xSelectionSupplier.clear();
     755          34 : }
     756             : 
     757             : // ____ XEventListener (base of XModifyListener) ____
     758          34 : void SAL_CALL ControllerCommandDispatch::disposing( const lang::EventObject& /* Source */ )
     759             :     throw (uno::RuntimeException, std::exception)
     760             : {
     761          34 :     m_xController.clear();
     762          34 :     m_xDispatch.clear();
     763          34 :     m_xSelectionSupplier.clear();
     764          34 : }
     765             : 
     766             : // ____ XModifyListener ____
     767        1603 : void SAL_CALL ControllerCommandDispatch::modified( const lang::EventObject& aEvent )
     768             :     throw (uno::RuntimeException, std::exception)
     769             : {
     770        1603 :     bool bUpdateCommandAvailability = false;
     771             : 
     772             :     // Update the "ModelState" Struct.
     773        1603 :     if( m_apModelState.get() && m_xController.is())
     774             :     {
     775        1603 :         m_apModelState->update( m_xController->getModel());
     776        1603 :         bUpdateCommandAvailability = true;
     777             :     }
     778             : 
     779             :     // Update the "ControllerState" Struct.
     780        1603 :     if( m_apControllerState.get() && m_xController.is())
     781             :     {
     782        1603 :         m_apControllerState->update( m_xController, m_xController->getModel());
     783        1603 :         bUpdateCommandAvailability = true;
     784             :     }
     785             : 
     786        1603 :     if( bUpdateCommandAvailability )
     787        1603 :         updateCommandAvailability();
     788             : 
     789        1603 :     CommandDispatch::modified( aEvent );
     790        1603 : }
     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         102 : } //  namespace chart
     807             : 
     808             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10