1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ControllerCommandDispatch.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
34 #include "ControllerCommandDispatch.hxx"
35 #include "ChartModelHelper.hxx"
36 #include "DiagramHelper.hxx"
37 #include "AxisHelper.hxx"
38 #include "TitleHelper.hxx"
39 #include "LegendHelper.hxx"
40 #include "ObjectIdentifier.hxx"
42 #include "ChartTypeHelper.hxx"
43 #include "DiagramHelper.hxx"
44 #include "ChartController.hxx"
45 #include "RegressionCurveHelper.hxx"
46 #include "DataSeriesHelper.hxx"
47 #include "StatisticsHelper.hxx"
49 #include <com/sun/star/util/XModifyBroadcaster.hpp>
50 #include <com/sun/star/frame/XStorable.hpp>
51 #include <com/sun/star/chart2/XChartDocument.hpp>
52 #include <com/sun/star/chart2/XChartType.hpp>
53 #include <com/sun/star/chart2/XDataSeries.hpp>
54 #include <com/sun/star/chart2/XRegressionCurve.hpp>
55 #include <com/sun/star/chart2/data/XDatabaseDataProvider.hpp>
57 // only needed until #i68864# is fixed
58 #include <com/sun/star/frame/XLayoutManager.hpp>
60 using namespace ::com::sun::star
;
62 using ::com::sun::star::uno::Reference
;
63 using ::com::sun::star::uno::Sequence
;
64 using ::rtl::OUString
;
68 bool lcl_isStatusBarVisible( const Reference
< frame::XController
> & xController
)
70 bool bIsStatusBarVisible
= false;
71 // Status-Bar visible, workaround: this should not be necessary. @todo:
72 // remove when Issue #i68864# is fixed
75 Reference
< beans::XPropertySet
> xPropSet( xController
->getFrame(), uno::UNO_QUERY
);
78 uno::Reference
< ::com::sun::star::frame::XLayoutManager
> xLayoutManager
;
79 xPropSet
->getPropertyValue( C2U( "LayoutManager" ) ) >>= xLayoutManager
;
80 if ( xLayoutManager
.is() )
81 bIsStatusBarVisible
= xLayoutManager
->isElementVisible( C2U("private:resource/statusbar/statusbar"));
84 return bIsStatusBarVisible
;
87 } // anonymous namespace
92 // ----------------------------------------
97 /// Constants for moving the series.
99 MOVE_SERIES_FORWARD
= true,
100 MOVE_SERIES_BACKWARD
= false
103 /** Represents the current state of the controller (needed for issue 63017).
105 You can set the state by calling update(). After this call the state is
106 preserved in this class until the next call to update().
108 This is useful, not to say necessary, for enabling and disabling of menu
109 entries (e.g. format>arrangement). As the status requests are sent very
110 frequently it would be impossible, from a performance point of view, to
111 query the current status every time directly at the model. So this class
112 serves as a cache for the state.
114 struct ControllerState
118 void update( const Reference
< frame::XController
> & xController
,
119 const Reference
< frame::XModel
> & xModel
);
121 // -- State variables -------
122 bool bHasSelectedObject
;
123 bool bIsDraggableObject
;
125 bool bIsDeleteableObjectSelected
;
126 bool bIsFormateableObjectSelected
;
128 // May the selected series be moved forward or backward (cf
129 // format>arrangement).
130 bool bMayMoveSeriesForward
;
131 bool bMayMoveSeriesBackward
;
134 bool bMayAddTrendline
;
135 bool bMayAddTrendlineEquation
;
136 bool bMayAddMeanValue
;
137 bool bMayAddYErrorBars
;
139 bool bMayDeleteTrendline
;
140 bool bMayDeleteMeanValue
;
141 bool bMayDeleteYErrorBars
;
145 ControllerState::ControllerState() :
146 bHasSelectedObject( false ),
147 bIsDraggableObject( false ),
148 bIsTextObject(false),
149 bIsDeleteableObjectSelected(false),
150 bIsFormateableObjectSelected(false),
151 bMayMoveSeriesForward( false ),
152 bMayMoveSeriesBackward( false ),
153 bMayAddTrendline( false ),
154 bMayAddTrendlineEquation( false ),
155 bMayAddMeanValue( false ),
156 bMayAddYErrorBars( false ),
157 bMayDeleteTrendline( false ),
158 bMayDeleteMeanValue( false ),
159 bMayDeleteYErrorBars( false )
162 void ControllerState::update(
163 const Reference
< frame::XController
> & xController
,
164 const Reference
< frame::XModel
> & xModel
)
166 Reference
< view::XSelectionSupplier
> xSelectionSupplier(
167 xController
, uno::UNO_QUERY
);
171 // Update ControllerState variables.
172 if( xSelectionSupplier
.is())
174 uno::Any
aSelObj( xSelectionSupplier
->getSelection() );
176 bHasSelectedObject
= ((aSelObj
>>= aSelObjCID
) && aSelObjCID
.getLength() > 0);
178 bIsDraggableObject
= ObjectIdentifier::isDragableObject( aSelObjCID
);
180 ObjectType
aObjectType(ObjectIdentifier::getObjectType( aSelObjCID
));
181 bIsTextObject
= OBJECTTYPE_TITLE
== aObjectType
;
183 uno::Reference
< chart2::XDiagram
> xDiagram( ChartModelHelper::findDiagram( xModel
));
184 bIsFormateableObjectSelected
= bHasSelectedObject
;
185 if( OBJECTTYPE_DIAGRAM
==aObjectType
|| OBJECTTYPE_DIAGRAM_WALL
==aObjectType
|| OBJECTTYPE_DIAGRAM_FLOOR
==aObjectType
)
186 bIsFormateableObjectSelected
= DiagramHelper::isSupportingFloorAndWall( xDiagram
);
188 uno::Reference
< chart2::XDataSeries
> xGivenDataSeries(
189 ObjectIdentifier::getDataSeriesForCID(
190 aSelObjCID
, xModel
) );
192 bIsDeleteableObjectSelected
= ChartController::isObjectDeleteable( aSelObj
);
194 bMayMoveSeriesForward
= DiagramHelper::isSeriesMoveable(
195 ChartModelHelper::findDiagram( xModel
),
197 MOVE_SERIES_FORWARD
);
199 bMayMoveSeriesBackward
= DiagramHelper::isSeriesMoveable(
200 ChartModelHelper::findDiagram( xModel
),
202 MOVE_SERIES_BACKWARD
);
204 bMayAddTrendline
= false;
205 bMayAddTrendlineEquation
= false;
206 bMayAddMeanValue
= false;
207 bMayAddYErrorBars
= false;
208 bMayDeleteTrendline
= false;
209 bMayDeleteMeanValue
= false;
210 bMayDeleteYErrorBars
= false;
211 if( bHasSelectedObject
)
213 if( xGivenDataSeries
.is())
215 sal_Int32 nDimensionCount
= DiagramHelper::getDimension( xDiagram
);
216 uno::Reference
< chart2::XChartType
> xFirstChartType(
217 DataSeriesHelper::getChartTypeOfSeries( xGivenDataSeries
, xDiagram
));
219 // trend lines/mean value line
220 if( ChartTypeHelper::isSupportingRegressionProperties(
221 xFirstChartType
, nDimensionCount
))
223 uno::Reference
< chart2::XRegressionCurveContainer
> xRegCurveCnt(
224 xGivenDataSeries
, uno::UNO_QUERY
);
225 if( xRegCurveCnt
.is())
227 bMayDeleteTrendline
= RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt
).is();
228 bMayDeleteMeanValue
= RegressionCurveHelper::hasMeanValueLine( xRegCurveCnt
);
229 bMayAddTrendline
= ! bMayDeleteTrendline
;
230 bMayAddMeanValue
= ! bMayDeleteMeanValue
;
235 if( ChartTypeHelper::isSupportingStatisticProperties(
236 xFirstChartType
, nDimensionCount
))
238 bMayDeleteYErrorBars
= StatisticsHelper::hasErrorBars( xGivenDataSeries
);
239 bMayAddYErrorBars
= ! bMayDeleteYErrorBars
;
243 if( aObjectType
== OBJECTTYPE_DATA_CURVE
)
245 uno::Reference
< chart2::XRegressionCurve
> xRegCurve(
246 ObjectIdentifier::getObjectPropertySet( aSelObjCID
, xModel
), uno::UNO_QUERY
);
249 uno::Reference
< beans::XPropertySet
> xEqProp( xRegCurve
->getEquationProperties());
250 bool bShowEq
= false;
251 bool bShowCorr
= false;
254 xEqProp
->getPropertyValue( C2U("ShowEquation")) >>= bShowEq
;
255 xEqProp
->getPropertyValue( C2U("ShowCorrelationCoefficient")) >>= bShowCorr
;
257 bMayAddTrendlineEquation
= ! (bShowEq
|| bShowCorr
);
266 /** Represents the current state of the model.
268 You can set the state by calling update(). After this call the state is
269 preserved in this class until the next call to update().
271 This is useful, not to say necessary, for enabling and disabling of menu
272 entries and toolbar icons. As the status requests are sent very frequently
273 it would be impossible, from a performance point of view, to query the
274 current status every time directly at the model. So this class serves as a
281 void update( const Reference
< frame::XModel
> & xModel
);
283 bool HasAnyAxis() const;
284 bool HasAnyGrid() const;
285 bool HasAnyTitle() const;
296 bool bHasSecondaryXAxisTitle
;
297 bool bHasSecondaryYAxisTitle
;
312 bool bHasAutoScaledText
;
317 bool bSupportsStatistics
;
321 ModelState::ModelState() :
324 bHasOwnData( false ),
325 bHasMainTitle( false ),
326 bHasSubTitle( false ),
327 bHasXAxisTitle( false ),
328 bHasYAxisTitle( false ),
329 bHasZAxisTitle( false ),
330 bHasSecondaryXAxisTitle( false ),
331 bHasSecondaryYAxisTitle( false ),
337 bHasMainXGrid( false ),
338 bHasMainYGrid( false ),
339 bHasMainZGrid( false ),
340 bHasHelpXGrid( false ),
341 bHasHelpYGrid( false ),
342 bHasHelpZGrid( false ),
343 bHasAutoScaledText( false ),
347 bSupportsStatistics( false ),
348 bSupportsAxes( false )
352 void ModelState::update( const Reference
< frame::XModel
> & xModel
)
354 Reference
< chart2::XChartDocument
> xChartDoc( xModel
, uno::UNO_QUERY
);
355 Reference
< chart2::XDiagram
> xDiagram( ChartModelHelper::findDiagram( xModel
));
358 Reference
< frame::XStorable
> xStorable( xModel
, uno::UNO_QUERY
);
360 bIsReadOnly
= xStorable
->isReadonly();
362 sal_Int32 nDimensionCount
= DiagramHelper::getDimension( xDiagram
);
364 uno::Reference
< chart2::XChartType
> xFirstChartType( DiagramHelper::getChartTypeByIndex( xDiagram
, 0 ) );
365 bSupportsStatistics
= ChartTypeHelper::isSupportingStatisticProperties( xFirstChartType
, nDimensionCount
);
366 bSupportsAxes
= ChartTypeHelper::isSupportingMainAxis( xFirstChartType
, nDimensionCount
, 0 );
368 bIsThreeD
= (nDimensionCount
== 3);
369 bHasOwnData
= (xChartDoc
.is() && xChartDoc
->hasInternalDataProvider());
371 bHasMainTitle
= TitleHelper::getTitle( TitleHelper::MAIN_TITLE
, xModel
).is();
372 bHasSubTitle
= TitleHelper::getTitle( TitleHelper::SUB_TITLE
, xModel
).is();
373 bHasXAxisTitle
= TitleHelper::getTitle( TitleHelper::X_AXIS_TITLE
, xModel
).is();
374 bHasYAxisTitle
= TitleHelper::getTitle( TitleHelper::Y_AXIS_TITLE
, xModel
).is();
375 bHasZAxisTitle
= TitleHelper::getTitle( TitleHelper::Z_AXIS_TITLE
, xModel
).is();
376 bHasSecondaryXAxisTitle
= TitleHelper::getTitle( TitleHelper::SECONDARY_X_AXIS_TITLE
, xModel
).is();
377 bHasSecondaryYAxisTitle
= TitleHelper::getTitle( TitleHelper::SECONDARY_Y_AXIS_TITLE
, xModel
).is();
379 bHasXAxis
= bSupportsAxes
&& AxisHelper::getAxis( 0, true, xDiagram
).is();
380 bHasYAxis
= bSupportsAxes
&& AxisHelper::getAxis( 1, true, xDiagram
).is();
381 bHasZAxis
= bSupportsAxes
&& AxisHelper::getAxis( 2, true, xDiagram
).is();
382 bHasAAxis
= bSupportsAxes
&& AxisHelper::getAxis( 0, false, xDiagram
).is();
383 bHasBAxis
= bSupportsAxes
&& AxisHelper::getAxis( 1, false, xDiagram
).is();
385 bHasMainXGrid
= bSupportsAxes
&& AxisHelper::isGridShown( 0, 0, true, xDiagram
);
386 bHasMainYGrid
= bSupportsAxes
&& AxisHelper::isGridShown( 1, 0, true, xDiagram
);
387 bHasMainZGrid
= bSupportsAxes
&& AxisHelper::isGridShown( 2, 0, true, xDiagram
);
388 bHasHelpXGrid
= bSupportsAxes
&& AxisHelper::isGridShown( 0, 0, false, xDiagram
);
389 bHasHelpYGrid
= bSupportsAxes
&& AxisHelper::isGridShown( 1, 0, false, xDiagram
);
390 bHasHelpZGrid
= bSupportsAxes
&& AxisHelper::isGridShown( 2, 0, false, xDiagram
);
393 (ReferenceSizeProvider::getAutoResizeState( xChartDoc
) ==
394 ReferenceSizeProvider::AUTO_RESIZE_YES
);
396 bHasLegend
= LegendHelper::hasLegend( xDiagram
);
397 bHasWall
= DiagramHelper::isSupportingFloorAndWall( xDiagram
);
398 bHasFloor
= bHasWall
&& bIsThreeD
;
401 bool ModelState::HasAnyAxis() const
403 return bHasXAxis
|| bHasYAxis
|| bHasZAxis
|| bHasAAxis
|| bHasBAxis
;
406 bool ModelState::HasAnyGrid() const
408 return bHasMainXGrid
|| bHasMainYGrid
|| bHasMainZGrid
||
409 bHasHelpXGrid
|| bHasHelpYGrid
|| bHasHelpZGrid
;
412 bool ModelState::HasAnyTitle() const
414 return bHasMainTitle
|| bHasSubTitle
|| bHasXAxisTitle
|| bHasYAxisTitle
|| bHasZAxisTitle
|| bHasSecondaryXAxisTitle
|| bHasSecondaryYAxisTitle
;
419 // ----------------------------------------
420 DBG_NAME(ControllerCommandDispatch
)
422 ControllerCommandDispatch::ControllerCommandDispatch(
423 const Reference
< uno::XComponentContext
> & xContext
,
424 const Reference
< frame::XController
> & xController
) :
425 impl::ControllerCommandDispatch_Base( xContext
),
426 m_xController( xController
),
427 m_xSelectionSupplier( xController
, uno::UNO_QUERY
),
428 m_xDispatch( xController
, uno::UNO_QUERY
),
429 m_apModelState( new impl::ModelState() ),
430 m_apControllerState( new impl::ControllerState() )
432 DBG_CTOR(ControllerCommandDispatch
,NULL
);
435 ControllerCommandDispatch::~ControllerCommandDispatch()
438 DBG_DTOR(ControllerCommandDispatch
,NULL
);
441 void ControllerCommandDispatch::initialize()
443 if( m_xController
.is())
445 Reference
< frame::XModel
> xModel( m_xController
->getModel());
446 Reference
< util::XModifyBroadcaster
> xModifyBroadcaster( xModel
, uno::UNO_QUERY
);
447 OSL_ASSERT( xModifyBroadcaster
.is());
448 if( xModifyBroadcaster
.is())
449 xModifyBroadcaster
->addModifyListener( this );
451 // Listen selection modifications (Arrangement feature - issue 63017).
452 if( m_xSelectionSupplier
.is() )
453 m_xSelectionSupplier
->addSelectionChangeListener( this );
455 if( m_apModelState
.get() && xModel
.is())
456 m_apModelState
->update( xModel
);
458 if( m_apControllerState
.get() && xModel
.is())
459 m_apControllerState
->update( m_xController
, xModel
);
461 updateCommandAvailability();
465 void ControllerCommandDispatch::fireStatusEventForURLImpl(
466 const OUString
& rURL
,
467 const Reference
< frame::XStatusListener
> & xSingleListener
)
469 ::std::map
< OUString
, uno::Any
>::const_iterator
aArgIt( m_aCommandArguments
.find( rURL
));
470 if( aArgIt
!= m_aCommandArguments
.end())
471 fireStatusEventForURL( rURL
, aArgIt
->second
, commandAvailable( rURL
), xSingleListener
);
473 fireStatusEventForURL( rURL
, uno::Any(), commandAvailable( rURL
), xSingleListener
);
476 void ControllerCommandDispatch::updateCommandAvailability()
478 bool bModelStateIsValid
= ( m_apModelState
.get() != 0 );
479 bool bControllerStateIsValid
= ( m_apControllerState
.get() != 0 );
480 // Model and controller states exist.
481 OSL_ASSERT( bModelStateIsValid
);
482 OSL_ASSERT( bControllerStateIsValid
);
485 bool bIsWritable
= bModelStateIsValid
&& (! m_apModelState
->bIsReadOnly
);
486 // paste is available
487 // @todo: determine correctly
488 bool bHasSuitableClipboardContent
= true;
491 m_aCommandAvailability
[ C2U(".uno:Cut")] = bIsWritable
&& bControllerStateIsValid
&& m_apControllerState
->bIsDeleteableObjectSelected
;
492 m_aCommandAvailability
[ C2U(".uno:Copy")] = bControllerStateIsValid
&& m_apControllerState
->bHasSelectedObject
;
493 m_aCommandAvailability
[ C2U(".uno:Paste")] = bIsWritable
&& bHasSuitableClipboardContent
;
496 m_aCommandAvailability
[ C2U(".uno:ToggleGridHorizontal")] = bIsWritable
;
497 m_aCommandArguments
[ C2U(".uno:ToggleGridHorizontal")] = uno::makeAny( m_apModelState
->bHasMainYGrid
);
499 m_aCommandAvailability
[ C2U(".uno:ToggleLegend")] = bIsWritable
;
500 m_aCommandArguments
[ C2U(".uno:ToggleLegend")] = uno::makeAny( m_apModelState
->bHasLegend
);
502 m_aCommandAvailability
[ C2U(".uno:NewArrangement")] = bIsWritable
;
503 m_aCommandAvailability
[ C2U(".uno:Update")] = bIsWritable
;
504 m_aCommandAvailability
[ C2U(".uno:DefaultColors")] = bIsWritable
;
505 m_aCommandAvailability
[ C2U(".uno:BarWidth")] = bIsWritable
;
506 m_aCommandAvailability
[ C2U(".uno:NumberOfLines")] = bIsWritable
;
507 m_aCommandAvailability
[ C2U(".uno:ArrangeRow")] = bIsWritable
;
510 m_aCommandAvailability
[ C2U(".uno:InsertTitle")] = bIsWritable
;
511 m_aCommandAvailability
[ C2U(".uno:InsertLegend")] = bIsWritable
;
512 m_aCommandAvailability
[ C2U(".uno:InsertDescription")] = bIsWritable
;
513 m_aCommandAvailability
[ C2U(".uno:InsertAxis")] = bIsWritable
&& m_apModelState
->bSupportsAxes
;
514 m_aCommandAvailability
[ C2U(".uno:InsertGrids")] = bIsWritable
&& m_apModelState
->bSupportsAxes
;
515 // m_aCommandAvailability[ C2U(".uno:InsertStatistics")] = bIsWritable && m_apModelState->bSupportsStatistics;
516 m_aCommandAvailability
[ C2U(".uno:InsertTrendlines")] = bIsWritable
&& m_apModelState
->bSupportsStatistics
;
517 m_aCommandAvailability
[ C2U(".uno:InsertMeanValues")] = bIsWritable
&& m_apModelState
->bSupportsStatistics
;
518 m_aCommandAvailability
[ C2U(".uno:InsertYErrorbars")] = bIsWritable
&& m_apModelState
->bSupportsStatistics
;
519 m_aCommandAvailability
[ C2U(".uno:InsertSymbol")] = bIsWritable
&& m_apControllerState
->bIsTextObject
;
522 m_aCommandAvailability
[ C2U(".uno:DiagramObjects")] = bIsWritable
&& bControllerStateIsValid
&& m_apControllerState
->bIsFormateableObjectSelected
;
523 m_aCommandAvailability
[ C2U(".uno:DiagramType")] = bIsWritable
;
524 m_aCommandAvailability
[ C2U(".uno:Legend")] = bIsWritable
&& m_apModelState
->bHasLegend
;
525 m_aCommandAvailability
[ C2U(".uno:DiagramWall")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->bHasWall
;
526 m_aCommandAvailability
[ C2U(".uno:DiagramArea")] = bIsWritable
;
527 m_aCommandAvailability
[ C2U(".uno:TransformDialog")] = bIsWritable
&& bControllerStateIsValid
&& m_apControllerState
->bHasSelectedObject
&& m_apControllerState
->bIsDraggableObject
;
530 m_aCommandAvailability
[ C2U(".uno:View3D")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->bIsThreeD
;
531 m_aCommandAvailability
[ C2U(".uno:DiagramFloor")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->bHasFloor
;
533 // depending on own data
534 m_aCommandAvailability
[ C2U(".uno:DataRanges")] = bIsWritable
&& bModelStateIsValid
&& (! m_apModelState
->bHasOwnData
);
535 m_aCommandAvailability
[ C2U(".uno:DiagramData")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->bHasOwnData
;
538 m_aCommandAvailability
[ C2U(".uno:MainTitle")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->bHasMainTitle
;
539 m_aCommandAvailability
[ C2U(".uno:SubTitle")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->bHasSubTitle
;
540 m_aCommandAvailability
[ C2U(".uno:XTitle")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->bHasXAxisTitle
;
541 m_aCommandAvailability
[ C2U(".uno:YTitle")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->bHasYAxisTitle
;
542 m_aCommandAvailability
[ C2U(".uno:ZTitle")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->bHasZAxisTitle
;
543 m_aCommandAvailability
[ C2U(".uno:SecondaryXTitle")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->bHasSecondaryXAxisTitle
;
544 m_aCommandAvailability
[ C2U(".uno:SecondaryYTitle")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->bHasSecondaryYAxisTitle
;
545 m_aCommandAvailability
[ C2U(".uno:AllTitles")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->HasAnyTitle();
548 m_aCommandAvailability
[ C2U(".uno:ScaleText")] = bIsWritable
&& bModelStateIsValid
;
549 m_aCommandArguments
[ C2U(".uno:ScaleText")] = uno::makeAny( m_apModelState
->bHasAutoScaledText
);
552 m_aCommandAvailability
[ C2U(".uno:DiagramAxisX")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->bHasXAxis
;
553 m_aCommandAvailability
[ C2U(".uno:DiagramAxisY")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->bHasYAxis
;
554 m_aCommandAvailability
[ C2U(".uno:DiagramAxisZ")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->bHasZAxis
;
555 m_aCommandAvailability
[ C2U(".uno:DiagramAxisA")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->bHasAAxis
;
556 m_aCommandAvailability
[ C2U(".uno:DiagramAxisB")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->bHasBAxis
;
557 m_aCommandAvailability
[ C2U(".uno:DiagramAxisAll")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->HasAnyAxis();
560 // note: x and y are swapped in the commands!
561 m_aCommandAvailability
[ C2U(".uno:DiagramGridYMain")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->bHasMainXGrid
;
562 m_aCommandAvailability
[ C2U(".uno:DiagramGridXMain")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->bHasMainYGrid
;
563 m_aCommandAvailability
[ C2U(".uno:DiagramGridZMain")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->bHasMainZGrid
;
564 m_aCommandAvailability
[ C2U(".uno:DiagramGridYHelp")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->bHasHelpXGrid
;
565 m_aCommandAvailability
[ C2U(".uno:DiagramGridXHelp")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->bHasHelpYGrid
;
566 m_aCommandAvailability
[ C2U(".uno:DiagramGridZHelp")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->bHasHelpZGrid
;
567 m_aCommandAvailability
[ C2U(".uno:DiagramGridAll")] = bIsWritable
&& bModelStateIsValid
&& m_apModelState
->HasAnyGrid();
569 // series arrangement
570 m_aCommandAvailability
[ C2U(".uno:Forward")] = bIsWritable
&& bControllerStateIsValid
&& m_apControllerState
->bMayMoveSeriesForward
;
571 m_aCommandAvailability
[ C2U(".uno:Backward")] = bIsWritable
&& bControllerStateIsValid
&& m_apControllerState
->bMayMoveSeriesBackward
;
573 m_aCommandAvailability
[ C2U(".uno:InsertMeanValue")] = bIsWritable
&& bControllerStateIsValid
&& m_apControllerState
->bMayAddMeanValue
;
574 m_aCommandAvailability
[ C2U(".uno:InsertTrendline")] = bIsWritable
&& bControllerStateIsValid
&& m_apControllerState
->bMayAddTrendline
;
575 m_aCommandAvailability
[ C2U(".uno:InsertTrendlineEquation")] = bIsWritable
&& bControllerStateIsValid
&& m_apControllerState
->bMayAddTrendlineEquation
;
576 m_aCommandAvailability
[ C2U(".uno:InsertYErrorbar")] = bIsWritable
&& bControllerStateIsValid
&& m_apControllerState
->bMayAddYErrorBars
;
578 m_aCommandAvailability
[ C2U(".uno:DeleteTrendline")] = bIsWritable
&& bControllerStateIsValid
&& m_apControllerState
->bMayDeleteTrendline
;
579 m_aCommandAvailability
[ C2U(".uno:DeleteMeanValue")] = bIsWritable
&& bControllerStateIsValid
&& m_apControllerState
->bMayDeleteMeanValue
;
580 m_aCommandAvailability
[ C2U(".uno:DeleteYErrorbar")] = bIsWritable
&& bControllerStateIsValid
&& m_apControllerState
->bMayDeleteYErrorBars
;
583 bool ControllerCommandDispatch::commandAvailable( const OUString
& rCommand
)
585 ::std::map
< OUString
, bool >::const_iterator
aIt( m_aCommandAvailability
.find( rCommand
));
586 if( aIt
!= m_aCommandAvailability
.end())
588 OSL_ENSURE( false, "commandAvailable: command not in availability map" );
592 void ControllerCommandDispatch::fireStatusEvent(
593 const OUString
& rURL
,
594 const Reference
< frame::XStatusListener
> & xSingleListener
/* = 0 */ )
596 if( rURL
.getLength() == 0 )
597 for( ::std::map
< OUString
, bool >::const_iterator
aIt( m_aCommandAvailability
.begin());
598 aIt
!= m_aCommandAvailability
.end(); ++aIt
)
599 fireStatusEventForURLImpl( aIt
->first
, xSingleListener
);
601 fireStatusEventForURLImpl( rURL
, xSingleListener
);
603 // statusbar. Should be handled by base implementation
604 // @todo: remove if Issue 68864 is fixed
605 if( rURL
.getLength() == 0 ||
606 rURL
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:StatusBarVisible")))
608 bool bIsStatusBarVisible( lcl_isStatusBarVisible( m_xController
));
609 fireStatusEventForURL( C2U(".uno:StatusBarVisible"), uno::makeAny( bIsStatusBarVisible
), true, xSingleListener
);
613 // ____ XDispatch ____
614 void SAL_CALL
ControllerCommandDispatch::dispatch(
615 const util::URL
& URL
,
616 const Sequence
< beans::PropertyValue
>& Arguments
)
617 throw (uno::RuntimeException
)
619 if( commandAvailable( URL
.Complete
))
620 m_xDispatch
->dispatch( URL
, Arguments
);
623 // ____ WeakComponentImplHelperBase ____
624 /// is called when this is disposed
625 void SAL_CALL
ControllerCommandDispatch::disposing()
627 m_xController
.clear();
629 m_xSelectionSupplier
.clear();
632 // ____ XEventListener (base of XModifyListener) ____
633 void SAL_CALL
ControllerCommandDispatch::disposing( const lang::EventObject
& /* Source */ )
634 throw (uno::RuntimeException
)
636 m_xController
.clear();
638 m_xSelectionSupplier
.clear();
641 // ____ XModifyListener ____
642 void SAL_CALL
ControllerCommandDispatch::modified( const lang::EventObject
& aEvent
)
643 throw (uno::RuntimeException
)
645 bool bUpdateCommandAvailability
= false;
647 // Update the "ModelState" Struct.
648 if( m_apModelState
.get() && m_xController
.is())
650 m_apModelState
->update( m_xController
->getModel());
651 bUpdateCommandAvailability
= true;
654 // Update the "ControllerState" Struct.
655 if( m_apControllerState
.get() && m_xController
.is())
657 m_apControllerState
->update( m_xController
, m_xController
->getModel());
658 bUpdateCommandAvailability
= true;
661 if( bUpdateCommandAvailability
)
662 updateCommandAvailability();
664 CommandDispatch::modified( aEvent
);
668 // ____ XSelectionChangeListener ____
669 void SAL_CALL
ControllerCommandDispatch::selectionChanged( const lang::EventObject
& aEvent
)
670 throw (uno::RuntimeException
)
672 // Update the "ControllerState" Struct.
673 if( m_apControllerState
.get() && m_xController
.is())
675 m_apControllerState
->update( m_xController
, m_xController
->getModel());
676 updateCommandAvailability();
679 CommandDispatch::modified( aEvent
);