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