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: ChartController_Properties.cxx,v $
10 * $Revision: 1.33.44.2 $
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"
33 #include "ChartController.hxx"
34 #include "ChartWindow.hxx"
35 #include "chartview/DrawModelWrapper.hxx"
36 #include "ObjectIdentifier.hxx"
37 #include "chartview/ExplicitValueProvider.hxx"
39 #include "dlg_ObjectProperties.hxx"
40 #include "dlg_View3D.hxx"
41 #include "dlg_InsertErrorBars.hxx"
42 #include "ViewElementListProvider.hxx"
43 #include "DataPointItemConverter.hxx"
44 #include "AxisItemConverter.hxx"
45 #include "MultipleChartConverters.hxx"
46 #include "TitleItemConverter.hxx"
47 #include "LegendItemConverter.hxx"
48 #include "RegressionCurveItemConverter.hxx"
49 #include "RegressionEquationItemConverter.hxx"
50 #include "ErrorBarItemConverter.hxx"
51 #include "ChartModelHelper.hxx"
52 #include "AxisHelper.hxx"
53 #include "TitleHelper.hxx"
54 #include "LegendHelper.hxx"
55 #include "ChartTypeHelper.hxx"
56 #include "ColorPerPointHelper.hxx"
57 #include "DiagramHelper.hxx"
58 #include "servicenames_charttypes.hxx"
59 #include "ControllerLockGuard.hxx"
60 #include "UndoGuard.hxx"
61 #include "ObjectNameProvider.hxx"
63 #include "Strings.hrc"
64 #include "ReferenceSizeProvider.hxx"
65 #include "RegressionCurveHelper.hxx"
66 #include <com/sun/star/chart2/XChartDocument.hpp>
71 // header for define RET_OK
72 #include <vcl/msgbox.hxx>
74 #include <vcl/svapp.hxx>
75 #include <vos/mutex.hxx>
76 #include <svx/ActionDescriptionProvider.hxx>
78 //.............................................................................
81 //.............................................................................
82 using namespace ::com::sun::star
;
83 using namespace ::com::sun::star::chart2
;
84 using ::com::sun::star::uno::Reference
;
85 using ::rtl::OUString
;
90 ::comphelper::ItemConverter
* createItemConverter(
91 const ::rtl::OUString
& aObjectCID
92 , const uno::Reference
< frame::XModel
> & xChartModel
93 , const uno::Reference
< uno::XComponentContext
> & xContext
94 , SdrModel
& rDrawModel
95 , NumberFormatterWrapper
* pNumberFormatterWrapper
= NULL
96 , ExplicitValueProvider
* pExplicitValueProvider
= NULL
97 , ::std::auto_ptr
< ReferenceSizeProvider
> pRefSizeProvider
=
98 ::std::auto_ptr
< ReferenceSizeProvider
>()
101 ::comphelper::ItemConverter
* pItemConverter
=NULL
;
103 //-------------------------------------------------------------
104 //get type of selected object
105 ObjectType eObjectType
= ObjectIdentifier::getObjectType( aObjectCID
);
106 if( OBJECTTYPE_UNKNOWN
==eObjectType
)
108 DBG_ERROR("unknown ObjectType");
112 rtl::OUString aParticleID
= ObjectIdentifier::getParticleID( aObjectCID
);
113 bool bAffectsMultipleObjects
= aParticleID
.equals(C2U("ALLELEMENTS"));
114 //-------------------------------------------------------------
115 if( !bAffectsMultipleObjects
)
117 uno::Reference
< beans::XPropertySet
> xObjectProperties
=
118 ObjectIdentifier::getObjectPropertySet( aObjectCID
, xChartModel
);
119 if(!xObjectProperties
.is())
121 //create itemconverter for a single object
124 case OBJECTTYPE_PAGE
:
125 pItemConverter
= new wrapper::GraphicPropertyItemConverter(
126 xObjectProperties
, rDrawModel
.GetItemPool(),
127 rDrawModel
, uno::Reference
< lang::XMultiServiceFactory
>( xChartModel
, uno::UNO_QUERY
),
128 wrapper::GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES
);
130 case OBJECTTYPE_TITLE
:
132 ::std::auto_ptr
< awt::Size
> pRefSize
;
133 if( pRefSizeProvider
.get() )
134 pRefSize
.reset( new awt::Size( pRefSizeProvider
->getPageSize()));
136 pItemConverter
= new wrapper::TitleItemConverter( xObjectProperties
,
137 rDrawModel
.GetItemPool(), rDrawModel
,
138 uno::Reference
< lang::XMultiServiceFactory
>( xChartModel
, uno::UNO_QUERY
),
142 case OBJECTTYPE_LEGEND
:
144 ::std::auto_ptr
< awt::Size
> pRefSize
;
145 if( pRefSizeProvider
.get() )
146 pRefSize
.reset( new awt::Size( pRefSizeProvider
->getPageSize()));
148 pItemConverter
= new wrapper::LegendItemConverter( xObjectProperties
,
149 rDrawModel
.GetItemPool(), rDrawModel
,
150 uno::Reference
< lang::XMultiServiceFactory
>( xChartModel
, uno::UNO_QUERY
),
154 case OBJECTTYPE_LEGEND_ENTRY
:
156 case OBJECTTYPE_DIAGRAM
:
158 case OBJECTTYPE_DIAGRAM_WALL
:
159 case OBJECTTYPE_DIAGRAM_FLOOR
:
160 pItemConverter
= new wrapper::GraphicPropertyItemConverter(
161 xObjectProperties
, rDrawModel
.GetItemPool(),
162 rDrawModel
, uno::Reference
< lang::XMultiServiceFactory
>( xChartModel
, uno::UNO_QUERY
),
163 wrapper::GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES
);
165 case OBJECTTYPE_AXIS
:
167 ::std::auto_ptr
< awt::Size
> pRefSize
;
168 if( pRefSizeProvider
.get() )
169 pRefSize
.reset( new awt::Size( pRefSizeProvider
->getPageSize()));
171 uno::Reference
< beans::XPropertySet
> xDiaProp
;
172 xDiaProp
.set( ChartModelHelper::findDiagram( xChartModel
), uno::UNO_QUERY
);
174 // the second property set contains the property CoordinateOrigin
175 // nOriginIndex is the index of the corresponding index of the
176 // origin (x=0, y=1, z=2)
178 ExplicitScaleData aExplicitScale
;
179 ExplicitIncrementData aExplicitIncrement
;
180 if( pExplicitValueProvider
)
181 pExplicitValueProvider
->getExplicitValuesForAxis(
182 uno::Reference
< XAxis
>( xObjectProperties
, uno::UNO_QUERY
),
183 aExplicitScale
, aExplicitIncrement
);
185 pItemConverter
= new wrapper::AxisItemConverter(
186 xObjectProperties
, rDrawModel
.GetItemPool(),
188 uno::Reference
< chart2::XChartDocument
>( xChartModel
, uno::UNO_QUERY
),
189 &aExplicitScale
, &aExplicitIncrement
,
193 case OBJECTTYPE_AXIS_UNITLABEL
:
195 case OBJECTTYPE_DATA_LABELS
:
196 case OBJECTTYPE_DATA_SERIES
:
197 case OBJECTTYPE_DATA_LABEL
:
198 case OBJECTTYPE_DATA_POINT
:
200 ::std::auto_ptr
< awt::Size
> pRefSize
;
201 if( pRefSizeProvider
.get() )
202 pRefSize
.reset( new awt::Size( pRefSizeProvider
->getPageSize()));
204 wrapper::GraphicPropertyItemConverter::eGraphicObjectType eMapTo
=
205 wrapper::GraphicPropertyItemConverter::FILLED_DATA_POINT
;
207 uno::Reference
< XDataSeries
> xSeries
= ObjectIdentifier::getDataSeriesForCID( aObjectCID
, xChartModel
);
208 uno::Reference
< XChartType
> xChartType
= ChartModelHelper::getChartTypeOfSeries( xChartModel
, xSeries
);
210 uno::Reference
< XDiagram
> xDiagram( ChartModelHelper::findDiagram( xChartModel
) );
211 sal_Int32 nDimensionCount
= DiagramHelper::getDimension( xDiagram
);
212 if( !ChartTypeHelper::isSupportingAreaProperties( xChartType
, nDimensionCount
) )
213 eMapTo
= wrapper::GraphicPropertyItemConverter::LINE_DATA_POINT
;
219 LINE_AND_FILL_PROPERTIES
221 bool bDataSeries
= ( eObjectType
== OBJECTTYPE_DATA_SERIES
|| eObjectType
== OBJECTTYPE_DATA_LABELS
);
223 //special color for pie chart:
224 bool bUseSpecialFillColor
= false;
225 sal_Int32 nSpecialFillColor
=0;
226 sal_Int32 nPointIndex
= -1; /*-1 for whole series*/
229 nPointIndex
= aParticleID
.toInt32();
230 uno::Reference
< beans::XPropertySet
> xSeriesProp( xSeries
, uno::UNO_QUERY
);
231 bool bVaryColorsByPoint
= false;
232 if( xSeriesProp
.is() &&
233 (xSeriesProp
->getPropertyValue(C2U("VaryColorsByPoint")) >>= bVaryColorsByPoint
) &&
236 if( !ColorPerPointHelper::hasPointOwnColor( xSeriesProp
, nPointIndex
, xObjectProperties
) )
238 bUseSpecialFillColor
= true;
239 OSL_ASSERT( xDiagram
.is());
240 uno::Reference
< XColorScheme
> xColorScheme( xDiagram
->getDefaultColorScheme() );
241 if( xColorScheme
.is())
242 nSpecialFillColor
= xColorScheme
->getColorByIndex( nPointIndex
);
246 sal_Int32 nNumberFormat
=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties
, xSeries
, nPointIndex
, xDiagram
);
247 sal_Int32 nPercentNumberFormat
=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel(
248 xObjectProperties
,uno::Reference
< util::XNumberFormatsSupplier
>(xChartModel
, uno::UNO_QUERY
));
250 pItemConverter
= new wrapper::DataPointItemConverter( xChartModel
, xContext
,
251 xObjectProperties
, xSeries
, rDrawModel
.GetItemPool(), rDrawModel
,
252 pNumberFormatterWrapper
,
253 uno::Reference
< lang::XMultiServiceFactory
>( xChartModel
, uno::UNO_QUERY
),
254 eMapTo
, pRefSize
, bDataSeries
, bUseSpecialFillColor
, nSpecialFillColor
, false,
255 nNumberFormat
, nPercentNumberFormat
);
258 case OBJECTTYPE_GRID
:
259 case OBJECTTYPE_SUBGRID
:
260 case OBJECTTYPE_DATA_AVERAGE_LINE
:
261 pItemConverter
= new wrapper::GraphicPropertyItemConverter(
262 xObjectProperties
, rDrawModel
.GetItemPool(),
263 rDrawModel
, uno::Reference
< lang::XMultiServiceFactory
>( xChartModel
, uno::UNO_QUERY
),
264 wrapper::GraphicPropertyItemConverter::LINE_PROPERTIES
);
267 case OBJECTTYPE_DATA_ERRORS
:
268 pItemConverter
= new wrapper::ErrorBarItemConverter(
269 xChartModel
, xObjectProperties
, rDrawModel
.GetItemPool(),
270 rDrawModel
, uno::Reference
< lang::XMultiServiceFactory
>( xChartModel
, uno::UNO_QUERY
));
273 case OBJECTTYPE_DATA_CURVE
:
274 pItemConverter
= new wrapper::RegressionCurveItemConverter(
275 xObjectProperties
, uno::Reference
< chart2::XRegressionCurveContainer
>(
276 ObjectIdentifier::getDataSeriesForCID( aObjectCID
, xChartModel
), uno::UNO_QUERY
),
277 rDrawModel
.GetItemPool(), rDrawModel
,
278 uno::Reference
< lang::XMultiServiceFactory
>( xChartModel
, uno::UNO_QUERY
));
280 case OBJECTTYPE_DATA_CURVE_EQUATION
:
282 ::std::auto_ptr
< awt::Size
> pRefSize
;
283 if( pRefSizeProvider
.get() )
284 pRefSize
.reset( new awt::Size( pRefSizeProvider
->getPageSize()));
286 pItemConverter
= new wrapper::RegressionEquationItemConverter(
287 xObjectProperties
, rDrawModel
.GetItemPool(), rDrawModel
,
288 uno::Reference
< lang::XMultiServiceFactory
>( xChartModel
, uno::UNO_QUERY
),
292 case OBJECTTYPE_DATA_ERRORS_X
:
294 case OBJECTTYPE_DATA_ERRORS_Y
:
296 case OBJECTTYPE_DATA_ERRORS_Z
:
298 case OBJECTTYPE_DATA_STOCK_RANGE
:
300 case OBJECTTYPE_DATA_STOCK_LOSS
:
301 case OBJECTTYPE_DATA_STOCK_GAIN
:
302 pItemConverter
= new wrapper::GraphicPropertyItemConverter(
303 xObjectProperties
, rDrawModel
.GetItemPool(),
304 rDrawModel
, uno::Reference
< lang::XMultiServiceFactory
>( xChartModel
, uno::UNO_QUERY
),
305 wrapper::GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES
);
307 default: //OBJECTTYPE_UNKNOWN
313 //create itemconverter for a all objects of given type
316 case OBJECTTYPE_TITLE
:
317 pItemConverter
= new wrapper::AllTitleItemConverter( xChartModel
, rDrawModel
.GetItemPool(),
318 rDrawModel
, uno::Reference
< lang::XMultiServiceFactory
>( xChartModel
, uno::UNO_QUERY
));
320 case OBJECTTYPE_AXIS
:
322 ::std::auto_ptr
< awt::Size
> pRefSize
;
323 if( pRefSizeProvider
.get() )
324 pRefSize
.reset( new awt::Size( pRefSizeProvider
->getPageSize()));
326 pItemConverter
= new wrapper::AllAxisItemConverter( xChartModel
, rDrawModel
.GetItemPool(),
327 rDrawModel
, uno::Reference
< lang::XMultiServiceFactory
>( xChartModel
, uno::UNO_QUERY
), pRefSize
);
330 case OBJECTTYPE_GRID
:
331 case OBJECTTYPE_SUBGRID
:
332 pItemConverter
= new wrapper::AllGridItemConverter( xChartModel
, rDrawModel
.GetItemPool(),
333 rDrawModel
, uno::Reference
< lang::XMultiServiceFactory
>( xChartModel
, uno::UNO_QUERY
));
335 default: //for this type it is not supported to change all elements at once
340 return pItemConverter
;
343 rtl::OUString
lcl_getTitleCIDForCommand( const ::rtl::OString
& rDispatchCommand
, const uno::Reference
< frame::XModel
> & xChartModel
)
345 if( rDispatchCommand
.equals("AllTitles"))
346 return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_TITLE
, C2U("ALLELEMENTS") );
348 TitleHelper::eTitleType
nTitleType( TitleHelper::MAIN_TITLE
);
349 if( rDispatchCommand
.equals("SubTitle") )
350 nTitleType
= TitleHelper::SUB_TITLE
;
351 else if( rDispatchCommand
.equals("XTitle") )
352 nTitleType
= TitleHelper::X_AXIS_TITLE
;
353 else if( rDispatchCommand
.equals("YTitle") )
354 nTitleType
= TitleHelper::Y_AXIS_TITLE
;
355 else if( rDispatchCommand
.equals("ZTitle") )
356 nTitleType
= TitleHelper::Z_AXIS_TITLE
;
357 else if( rDispatchCommand
.equals("SecondaryXTitle") )
358 nTitleType
= TitleHelper::SECONDARY_X_AXIS_TITLE
;
359 else if( rDispatchCommand
.equals("SecondaryYTitle") )
360 nTitleType
= TitleHelper::SECONDARY_Y_AXIS_TITLE
;
362 uno::Reference
< XTitle
> xTitle( TitleHelper::getTitle( nTitleType
, xChartModel
) );
363 return ObjectIdentifier::createClassifiedIdentifierForObject( xTitle
, xChartModel
);
366 rtl::OUString
lcl_getAxisCIDForCommand( const ::rtl::OString
& rDispatchCommand
, const uno::Reference
< frame::XModel
>& xChartModel
)
368 if( rDispatchCommand
.equals("DiagramAxisAll"))
369 return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_AXIS
, C2U("ALLELEMENTS") );
371 sal_Int32 nDimensionIndex
=0;
373 if( rDispatchCommand
.equals("DiagramAxisX"))
375 nDimensionIndex
=0; bMainAxis
=true;
377 else if( rDispatchCommand
.equals("DiagramAxisY"))
379 nDimensionIndex
=1; bMainAxis
=true;
381 else if( rDispatchCommand
.equals("DiagramAxisZ"))
383 nDimensionIndex
=2; bMainAxis
=true;
385 else if( rDispatchCommand
.equals("DiagramAxisA"))
387 nDimensionIndex
=0; bMainAxis
=false;
389 else if( rDispatchCommand
.equals("DiagramAxisB"))
391 nDimensionIndex
=1; bMainAxis
=false;
394 uno::Reference
< XDiagram
> xDiagram( ChartModelHelper::findDiagram( xChartModel
) );
395 uno::Reference
< XAxis
> xAxis( AxisHelper::getAxis( nDimensionIndex
, bMainAxis
, xDiagram
) );
396 return ObjectIdentifier::createClassifiedIdentifierForObject( xAxis
, xChartModel
);
399 rtl::OUString
lcl_getGridCIDForCommand( const ::rtl::OString
& rDispatchCommand
, const uno::Reference
< frame::XModel
>& xChartModel
)
401 uno::Reference
< XDiagram
> xDiagram( ChartModelHelper::findDiagram( xChartModel
) );
403 if( rDispatchCommand
.equals("DiagramGridAll"))
404 return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_GRID
, C2U("ALLELEMENTS") );
406 sal_Int32 nDimensionIndex
=0;
409 //x and y is swapped in the commands
411 if( rDispatchCommand
.equals("DiagramGridYMain"))
413 nDimensionIndex
=0; bMainGrid
=true;
415 else if( rDispatchCommand
.equals("DiagramGridXMain"))
417 nDimensionIndex
=1; bMainGrid
=true;
419 else if( rDispatchCommand
.equals("DiagramGridZMain"))
421 nDimensionIndex
=2; bMainGrid
=true;
423 else if( rDispatchCommand
.equals("DiagramGridYHelp"))
425 nDimensionIndex
=0; bMainGrid
=false;
427 else if( rDispatchCommand
.equals("DiagramGridXHelp"))
429 nDimensionIndex
=1; bMainGrid
=false;
431 else if( rDispatchCommand
.equals("DiagramGridZHelp"))
433 nDimensionIndex
=2; bMainGrid
=false;
436 bool bMainAxis
= true;
437 uno::Reference
< XAxis
> xAxis( AxisHelper::getAxis( nDimensionIndex
, bMainAxis
, xDiagram
) );
439 sal_Int32 nSubGridIndex
= bMainGrid
? (-1) : 0;
440 rtl::OUString
aCID( ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis
, xChartModel
, nSubGridIndex
) );
443 rtl::OUString
lcl_getObjectCIDForCommand( const ::rtl::OString
& rDispatchCommand
, const uno::Reference
< XChartDocument
> & xChartDocument
, const rtl::OUString
& rSelectedCID
)
445 ObjectType eObjectType
= OBJECTTYPE_UNKNOWN
;
446 rtl::OUString aParticleID
;
448 uno::Reference
< frame::XModel
> xChartModel( xChartDocument
, uno::UNO_QUERY
);
449 const ObjectType eSelectedType
= ObjectIdentifier::getObjectType( rSelectedCID
);
450 uno::Reference
< XDataSeries
> xSeries
= ObjectIdentifier::getDataSeriesForCID( rSelectedCID
, xChartModel
);
451 uno::Reference
< chart2::XRegressionCurveContainer
> xRegCurveCnt( xSeries
, uno::UNO_QUERY
);
453 //-------------------------------------------------------------------------
455 if( rDispatchCommand
.equals("Legend") || rDispatchCommand
.equals("FormatLegend") )
457 eObjectType
= OBJECTTYPE_LEGEND
;
458 //@todo set particular aParticleID if we have more than one legend
460 //-------------------------------------------------------------------------
462 else if( rDispatchCommand
.equals("DiagramWall") || rDispatchCommand
.equals("FormatWall") )
464 //OBJECTTYPE_DIAGRAM;
465 eObjectType
= OBJECTTYPE_DIAGRAM_WALL
;
466 //@todo set particular aParticleID if we have more than one diagram
468 else if( rDispatchCommand
.equals("DiagramFloor") || rDispatchCommand
.equals("FormatFloor") )
470 eObjectType
= OBJECTTYPE_DIAGRAM_FLOOR
;
471 //@todo set particular aParticleID if we have more than one diagram
473 else if( rDispatchCommand
.equals("DiagramArea") || rDispatchCommand
.equals("FormatChartArea") )
475 eObjectType
= OBJECTTYPE_PAGE
;
477 //-------------------------------------------------------------------------
479 else if( rDispatchCommand
.equals("MainTitle")
480 || rDispatchCommand
.equals("SubTitle")
481 || rDispatchCommand
.equals("XTitle")
482 || rDispatchCommand
.equals("YTitle")
483 || rDispatchCommand
.equals("ZTitle")
484 || rDispatchCommand
.equals("SecondaryXTitle")
485 || rDispatchCommand
.equals("SecondaryYTitle")
486 || rDispatchCommand
.equals("AllTitles")
489 return lcl_getTitleCIDForCommand( rDispatchCommand
, xChartModel
);
491 //-------------------------------------------------------------------------
493 else if( rDispatchCommand
.equals("DiagramAxisX")
494 || rDispatchCommand
.equals("DiagramAxisY")
495 || rDispatchCommand
.equals("DiagramAxisZ")
496 || rDispatchCommand
.equals("DiagramAxisA")
497 || rDispatchCommand
.equals("DiagramAxisB")
498 || rDispatchCommand
.equals("DiagramAxisAll")
501 return lcl_getAxisCIDForCommand( rDispatchCommand
, xChartModel
);
503 //-------------------------------------------------------------------------
505 else if( rDispatchCommand
.equals("DiagramGridYMain")
506 || rDispatchCommand
.equals("DiagramGridXMain")
507 || rDispatchCommand
.equals("DiagramGridZMain")
508 || rDispatchCommand
.equals("DiagramGridYHelp")
509 || rDispatchCommand
.equals("DiagramGridXHelp")
510 || rDispatchCommand
.equals("DiagramGridZHelp")
511 || rDispatchCommand
.equals("DiagramGridAll")
514 return lcl_getGridCIDForCommand( rDispatchCommand
, xChartModel
);
516 //-------------------------------------------------------------------------
518 else if( rDispatchCommand
.equals("FormatDataSeries") )
520 if( eSelectedType
== OBJECTTYPE_DATA_SERIES
)
523 return ObjectIdentifier::createClassifiedIdentifier(
524 OBJECTTYPE_DATA_SERIES
, ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID
) );
526 //-------------------------------------------------------------------------
528 else if( rDispatchCommand
.equals("FormatDataPoint") )
532 //-------------------------------------------------------------------------
534 else if( rDispatchCommand
.equals("FormatDataLabels") )
536 if( eSelectedType
== OBJECTTYPE_DATA_LABELS
)
539 return ObjectIdentifier::createClassifiedIdentifierWithParent(
540 OBJECTTYPE_DATA_LABELS
, ::rtl::OUString(), rSelectedCID
);
542 //-------------------------------------------------------------------------
544 else if( rDispatchCommand
.equals("FormatDataLabel") )
546 if( eSelectedType
== OBJECTTYPE_DATA_LABEL
)
550 sal_Int32 nPointIndex
= ObjectIdentifier::getParticleID( rSelectedCID
).toInt32();
553 OUString aSeriesParticle
= ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID
);
554 OUString
aChildParticle( ObjectIdentifier::getStringForType( OBJECTTYPE_DATA_LABELS
) );
555 aChildParticle
+=(C2U("="));
556 OUString aLabelsCID
= ObjectIdentifier::createClassifiedIdentifierForParticles( aSeriesParticle
, aChildParticle
);
557 OUString aLabelCID_Stub
= ObjectIdentifier::createClassifiedIdentifierWithParent(
558 OBJECTTYPE_DATA_LABEL
, ::rtl::OUString(), aLabelsCID
);
560 return ObjectIdentifier::createPointCID( aLabelCID_Stub
, nPointIndex
);
564 //-------------------------------------------------------------------------
566 else if( rDispatchCommand
.equals("FormatMeanValue") )
568 if( eSelectedType
== OBJECTTYPE_DATA_AVERAGE_LINE
)
571 return ObjectIdentifier::createDataCurveCID(
572 ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID
),
573 RegressionCurveHelper::getRegressionCurveIndex( xRegCurveCnt
,
574 RegressionCurveHelper::getMeanValueLine( xRegCurveCnt
) ), true );
576 //-------------------------------------------------------------------------
578 else if( rDispatchCommand
.equals("FormatTrendline") )
580 if( eSelectedType
== OBJECTTYPE_DATA_CURVE
)
583 return ObjectIdentifier::createDataCurveCID(
584 ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID
),
585 RegressionCurveHelper::getRegressionCurveIndex( xRegCurveCnt
,
586 RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt
) ), false );
588 //-------------------------------------------------------------------------
589 //trend line equation
590 else if( rDispatchCommand
.equals("FormatTrendlineEquation") )
592 if( eSelectedType
== OBJECTTYPE_DATA_CURVE_EQUATION
)
595 return ObjectIdentifier::createDataCurveEquationCID(
596 ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID
),
597 RegressionCurveHelper::getRegressionCurveIndex( xRegCurveCnt
,
598 RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt
) ) );
600 //-------------------------------------------------------------------------
602 else if( rDispatchCommand
.equals("FormatYErrorBars") )
604 if( eSelectedType
== OBJECTTYPE_DATA_ERRORS
)
607 return ObjectIdentifier::createClassifiedIdentifierWithParent(
608 OBJECTTYPE_DATA_ERRORS
, ::rtl::OUString(), rSelectedCID
);
610 //-------------------------------------------------------------------------
612 else if( rDispatchCommand
.equals("FormatAxis") )
614 if( eSelectedType
== OBJECTTYPE_AXIS
)
618 Reference
< XAxis
> xAxis
= ObjectIdentifier::getAxisForCID( rSelectedCID
, xChartModel
);
619 return ObjectIdentifier::createClassifiedIdentifierForObject( xAxis
, xChartModel
);
622 //-------------------------------------------------------------------------
624 else if( rDispatchCommand
.equals("FormatMajorGrid") )
626 if( eSelectedType
== OBJECTTYPE_GRID
)
630 Reference
< XAxis
> xAxis
= ObjectIdentifier::getAxisForCID( rSelectedCID
, xChartModel
);
631 return ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis
, xChartModel
);
635 //-------------------------------------------------------------------------
637 else if( rDispatchCommand
.equals("FormatMinorGrid") )
639 if( eSelectedType
== OBJECTTYPE_SUBGRID
)
643 Reference
< XAxis
> xAxis
= ObjectIdentifier::getAxisForCID( rSelectedCID
, xChartModel
);
644 return ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis
, xChartModel
, 0 /*sub grid index*/ );
647 //-------------------------------------------------------------------------
649 else if( rDispatchCommand
.equals("FormatTitle") )
651 if( eSelectedType
== OBJECTTYPE_TITLE
)
654 //-------------------------------------------------------------------------
656 else if( rDispatchCommand
.equals("FormatStockLoss") )
658 if( eSelectedType
== OBJECTTYPE_DATA_STOCK_LOSS
)
661 return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DATA_STOCK_LOSS
, rtl::OUString());
663 //-------------------------------------------------------------------------
665 else if( rDispatchCommand
.equals("FormatStockGain") )
667 if( eSelectedType
== OBJECTTYPE_DATA_STOCK_GAIN
)
670 return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DATA_STOCK_GAIN
, rtl::OUString() );
673 return ObjectIdentifier::createClassifiedIdentifier(
674 eObjectType
, aParticleID
);
678 // anonymous namespace
680 void SAL_CALL
ChartController::executeDispatch_FormatObject(const ::rtl::OUString
& rDispatchCommand
)
682 uno::Reference
< XChartDocument
> xChartDocument( m_aModel
->getModel(), uno::UNO_QUERY
);
683 rtl::OString
aCommand( rtl::OUStringToOString( rDispatchCommand
, RTL_TEXTENCODING_ASCII_US
) );
684 rtl::OUString rObjectCID
= lcl_getObjectCIDForCommand( aCommand
, xChartDocument
, m_aSelection
.getSelectedCID() );
685 executeDlg_ObjectProperties( rObjectCID
);
688 void SAL_CALL
ChartController::executeDispatch_ObjectProperties()
690 executeDlg_ObjectProperties( m_aSelection
.getSelectedCID() );
696 rtl::OUString
lcl_getFormatCIDforSelectedCID( const ::rtl::OUString
& rSelectedCID
)
698 ::rtl::OUString
aFormatCID(rSelectedCID
);
700 //get type of selected object
701 ObjectType eObjectType
= ObjectIdentifier::getObjectType( aFormatCID
);
703 // some legend entries are handled as if they were data series
704 if( OBJECTTYPE_LEGEND_ENTRY
==eObjectType
)
706 rtl::OUString
aParentParticle( ObjectIdentifier::getFullParentParticle( rSelectedCID
) );
707 aFormatCID
= ObjectIdentifier::createClassifiedIdentifierForParticle( aParentParticle
);
710 // treat diagram as wall
711 if( OBJECTTYPE_DIAGRAM
==eObjectType
)
712 aFormatCID
= ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL
, rtl::OUString() );
717 }//end anonymous namespace
719 void SAL_CALL
ChartController::executeDlg_ObjectProperties( const ::rtl::OUString
& rSelectedObjectCID
)
721 rtl::OUString aObjectCID
= lcl_getFormatCIDforSelectedCID( rSelectedObjectCID
);
723 UndoGuard
aUndoGuard( ActionDescriptionProvider::createDescription(
724 ActionDescriptionProvider::FORMAT
,
725 ObjectNameProvider::getName( ObjectIdentifier::getObjectType( aObjectCID
))),
726 m_xUndoManager
, m_aModel
->getModel() );
728 bool bSuccess
= ChartController::executeDlg_ObjectProperties_withoutUndoGuard( aObjectCID
, false );
730 aUndoGuard
.commitAction();
733 bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( const ::rtl::OUString
& rObjectCID
, bool bOkClickOnUnchangedDialogSouldBeRatedAsSuccessAlso
)
735 //return true if the properties were changed successfully
737 if( !rObjectCID
.getLength() )
739 //DBG_ERROR("empty ObjectID");
744 NumberFormatterWrapper
aNumberFormatterWrapper( uno::Reference
< util::XNumberFormatsSupplier
>(m_aModel
->getModel(), uno::UNO_QUERY
) );
746 //-------------------------------------------------------------
748 ObjectType eObjectType
= ObjectIdentifier::getObjectType( rObjectCID
);
749 if( OBJECTTYPE_UNKNOWN
==eObjectType
)
751 //DBG_ERROR("unknown ObjectType");
754 if( OBJECTTYPE_DIAGRAM_WALL
==eObjectType
|| OBJECTTYPE_DIAGRAM_FLOOR
==eObjectType
)
756 if( !DiagramHelper::isSupportingFloorAndWall( ChartModelHelper::findDiagram( m_aModel
->getModel() ) ) )
760 //-------------------------------------------------------------
761 //convert properties to ItemSet
763 awt::Size
aPageSize( ChartModelHelper::getPageSize(m_aModel
->getModel()) );
765 ::std::auto_ptr
< ReferenceSizeProvider
> pRefSizeProv(
766 impl_createReferenceSizeProvider());
767 ::std::auto_ptr
< ::comphelper::ItemConverter
> apItemConverter(
768 createItemConverter( rObjectCID
, m_aModel
->getModel(), m_xCC
,
769 m_pDrawModelWrapper
->getSdrModel(),
770 &aNumberFormatterWrapper
,
771 ExplicitValueProvider::getExplicitValueProvider(m_xChartView
),
773 if(!apItemConverter
.get())
776 SfxItemSet aItemSet
= apItemConverter
->CreateEmptyItemSet();
777 apItemConverter
->FillItemSet( aItemSet
);
779 //-------------------------------------------------------------
781 ObjectPropertiesDialogParameter aDialogParameter
= ObjectPropertiesDialogParameter( rObjectCID
);
782 aDialogParameter
.init( m_aModel
->getModel() );
783 ViewElementListProvider
aViewElementListProvider( m_pDrawModelWrapper
.get() );
785 ::vos::OGuard
aGuard( Application::GetSolarMutex());
786 SchAttribTabDlg
aDlg( m_pChartWindow
, &aItemSet
, &aDialogParameter
, &aViewElementListProvider
787 , uno::Reference
< util::XNumberFormatsSupplier
>( m_aModel
->getModel(), uno::UNO_QUERY
) );
789 if(aDialogParameter
.HasSymbolProperties())
791 SfxItemSet
* pSymbolShapeProperties
=NULL
;
792 uno::Reference
< beans::XPropertySet
> xObjectProperties
=
793 ObjectIdentifier::getObjectPropertySet( rObjectCID
, m_aModel
->getModel() );
794 wrapper::DataPointItemConverter
aSymbolItemConverter( m_aModel
->getModel(), m_xCC
795 , xObjectProperties
, ObjectIdentifier::getDataSeriesForCID( rObjectCID
, m_aModel
->getModel() )
796 , m_pDrawModelWrapper
->getSdrModel().GetItemPool()
797 , m_pDrawModelWrapper
->getSdrModel()
798 , &aNumberFormatterWrapper
799 , uno::Reference
< lang::XMultiServiceFactory
>( m_aModel
->getModel(), uno::UNO_QUERY
)
800 , wrapper::GraphicPropertyItemConverter::FILLED_DATA_POINT
);
802 pSymbolShapeProperties
= new SfxItemSet( aSymbolItemConverter
.CreateEmptyItemSet() );
803 aSymbolItemConverter
.FillItemSet( *pSymbolShapeProperties
);
805 sal_Int32 nStandardSymbol
=0;//@todo get from somewhere
806 Graphic
* pAutoSymbolGraphic
= new Graphic( aViewElementListProvider
.GetSymbolGraphic( nStandardSymbol
, pSymbolShapeProperties
) );
807 // note: the dialog takes the ownership of pSymbolShapeProperties and pAutoSymbolGraphic
808 aDlg
.setSymbolInformation( pSymbolShapeProperties
, pAutoSymbolGraphic
);
810 if( aDialogParameter
.HasStatisticProperties() )
812 aDlg
.SetAxisMinorStepWidthForErrorBarDecimals(
813 InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( m_aModel
->getModel(), m_xChartView
, rObjectCID
) );
816 //-------------------------------------------------------------
818 if( aDlg
.Execute() == RET_OK
|| (bOkClickOnUnchangedDialogSouldBeRatedAsSuccessAlso
&& aDlg
.DialogWasClosedWithOK()) )
820 const SfxItemSet
* pOutItemSet
= aDlg
.GetOutputItemSet();
823 ControllerLockGuard
aCLGuard( m_aModel
->getModel());
824 apItemConverter
->ApplyItemSet( *pOutItemSet
);//model should be changed now
829 catch( util::CloseVetoException
& )
832 catch( uno::RuntimeException
& )
838 void SAL_CALL
ChartController::executeDispatch_View3D()
842 // using assignment for broken gcc 3.3
843 UndoLiveUpdateGuard aUndoGuard
= UndoLiveUpdateGuard(
844 ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_3D_VIEW
))),
845 m_xUndoManager
, m_aModel
->getModel());
849 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex());
850 View3DDialog
aDlg( m_pChartWindow
, m_aModel
->getModel(), m_pDrawModelWrapper
->GetColorTable() );
851 if( aDlg
.Execute() == RET_OK
)
852 aUndoGuard
.commitAction();
855 catch( uno::RuntimeException
& e
)
857 ASSERT_EXCEPTION( e
);
861 //.............................................................................
863 //.............................................................................