1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_chart2.hxx" 26 #include "ChartController.hxx" 27 #include "ChartWindow.hxx" 28 #include "chartview/DrawModelWrapper.hxx" 29 #include "ObjectIdentifier.hxx" 30 #include "chartview/ExplicitValueProvider.hxx" 31 #include "macros.hxx" 32 #include "dlg_ObjectProperties.hxx" 33 #include "dlg_View3D.hxx" 34 #include "dlg_InsertErrorBars.hxx" 35 #include "ViewElementListProvider.hxx" 36 #include "DataPointItemConverter.hxx" 37 #include "AxisItemConverter.hxx" 38 #include "MultipleChartConverters.hxx" 39 #include "TitleItemConverter.hxx" 40 #include "LegendItemConverter.hxx" 41 #include "RegressionCurveItemConverter.hxx" 42 #include "RegressionEquationItemConverter.hxx" 43 #include "ErrorBarItemConverter.hxx" 44 #include "ChartModelHelper.hxx" 45 #include "AxisHelper.hxx" 46 #include "TitleHelper.hxx" 47 #include "LegendHelper.hxx" 48 #include "ChartTypeHelper.hxx" 49 #include "ColorPerPointHelper.hxx" 50 #include "DiagramHelper.hxx" 51 #include "servicenames_charttypes.hxx" 52 #include "ControllerLockGuard.hxx" 53 #include "UndoGuard.hxx" 54 #include "ObjectNameProvider.hxx" 55 #include "ResId.hxx" 56 #include "Strings.hrc" 57 #include "ReferenceSizeProvider.hxx" 58 #include "RegressionCurveHelper.hxx" 59 #include <com/sun/star/chart2/XChartDocument.hpp> 60 61 //for auto_ptr 62 #include <memory> 63 64 // header for define RET_OK 65 #include <vcl/msgbox.hxx> 66 // for SolarMutex 67 #include <vcl/svapp.hxx> 68 #include <vos/mutex.hxx> 69 #include <svx/ActionDescriptionProvider.hxx> 70 71 //............................................................................. 72 namespace chart 73 { 74 //............................................................................. 75 using namespace ::com::sun::star; 76 using namespace ::com::sun::star::chart2; 77 using ::com::sun::star::uno::Reference; 78 using ::rtl::OUString; 79 80 namespace 81 { 82 83 ::comphelper::ItemConverter* createItemConverter( 84 const ::rtl::OUString & aObjectCID 85 , const uno::Reference< frame::XModel > & xChartModel 86 , const uno::Reference< uno::XComponentContext > & xContext 87 , SdrModel & rDrawModel 88 , NumberFormatterWrapper * pNumberFormatterWrapper = NULL 89 , ExplicitValueProvider * pExplicitValueProvider = NULL 90 , ::std::auto_ptr< ReferenceSizeProvider > pRefSizeProvider = 91 ::std::auto_ptr< ReferenceSizeProvider >() 92 ) 93 { 94 ::comphelper::ItemConverter* pItemConverter=NULL; 95 96 //------------------------------------------------------------- 97 //get type of selected object 98 ObjectType eObjectType = ObjectIdentifier::getObjectType( aObjectCID ); 99 if( OBJECTTYPE_UNKNOWN==eObjectType ) 100 { 101 DBG_ERROR("unknown ObjectType"); 102 return NULL; 103 } 104 //-- 105 rtl::OUString aParticleID = ObjectIdentifier::getParticleID( aObjectCID ); 106 bool bAffectsMultipleObjects = aParticleID.equals(C2U("ALLELEMENTS")); 107 //------------------------------------------------------------- 108 if( !bAffectsMultipleObjects ) 109 { 110 uno::Reference< beans::XPropertySet > xObjectProperties = 111 ObjectIdentifier::getObjectPropertySet( aObjectCID, xChartModel ); 112 if(!xObjectProperties.is()) 113 return NULL; 114 //create itemconverter for a single object 115 switch(eObjectType) 116 { 117 case OBJECTTYPE_PAGE: 118 pItemConverter = new wrapper::GraphicPropertyItemConverter( 119 xObjectProperties, rDrawModel.GetItemPool(), 120 rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), 121 wrapper::GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES ); 122 break; 123 case OBJECTTYPE_TITLE: 124 { 125 ::std::auto_ptr< awt::Size > pRefSize; 126 if( pRefSizeProvider.get() ) 127 pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize())); 128 129 pItemConverter = new wrapper::TitleItemConverter( xObjectProperties, 130 rDrawModel.GetItemPool(), rDrawModel, 131 uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), 132 pRefSize ); 133 } 134 break; 135 case OBJECTTYPE_LEGEND: 136 { 137 ::std::auto_ptr< awt::Size > pRefSize; 138 if( pRefSizeProvider.get() ) 139 pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize())); 140 141 pItemConverter = new wrapper::LegendItemConverter( xObjectProperties, 142 rDrawModel.GetItemPool(), rDrawModel, 143 uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), 144 pRefSize ); 145 } 146 break; 147 case OBJECTTYPE_LEGEND_ENTRY: 148 break; 149 case OBJECTTYPE_DIAGRAM: 150 break; 151 case OBJECTTYPE_DIAGRAM_WALL: 152 case OBJECTTYPE_DIAGRAM_FLOOR: 153 pItemConverter = new wrapper::GraphicPropertyItemConverter( 154 xObjectProperties, rDrawModel.GetItemPool(), 155 rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), 156 wrapper::GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES ); 157 break; 158 case OBJECTTYPE_AXIS: 159 { 160 ::std::auto_ptr< awt::Size > pRefSize; 161 if( pRefSizeProvider.get() ) 162 pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize())); 163 164 uno::Reference< beans::XPropertySet > xDiaProp; 165 xDiaProp.set( ChartModelHelper::findDiagram( xChartModel ), uno::UNO_QUERY ); 166 167 // the second property set contains the property CoordinateOrigin 168 // nOriginIndex is the index of the corresponding index of the 169 // origin (x=0, y=1, z=2) 170 171 ExplicitScaleData aExplicitScale; 172 ExplicitIncrementData aExplicitIncrement; 173 if( pExplicitValueProvider ) 174 pExplicitValueProvider->getExplicitValuesForAxis( 175 uno::Reference< XAxis >( xObjectProperties, uno::UNO_QUERY ), 176 aExplicitScale, aExplicitIncrement ); 177 178 pItemConverter = new wrapper::AxisItemConverter( 179 xObjectProperties, rDrawModel.GetItemPool(), 180 rDrawModel, 181 uno::Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY ), 182 &aExplicitScale, &aExplicitIncrement, 183 pRefSize ); 184 } 185 break; 186 case OBJECTTYPE_AXIS_UNITLABEL: 187 break; 188 case OBJECTTYPE_DATA_LABELS: 189 case OBJECTTYPE_DATA_SERIES: 190 case OBJECTTYPE_DATA_LABEL: 191 case OBJECTTYPE_DATA_POINT: 192 { 193 ::std::auto_ptr< awt::Size > pRefSize; 194 if( pRefSizeProvider.get() ) 195 pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize())); 196 197 wrapper::GraphicPropertyItemConverter::eGraphicObjectType eMapTo = 198 wrapper::GraphicPropertyItemConverter::FILLED_DATA_POINT; 199 200 uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( aObjectCID, xChartModel ); 201 uno::Reference< XChartType > xChartType = ChartModelHelper::getChartTypeOfSeries( xChartModel, xSeries ); 202 203 uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); 204 sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); 205 if( !ChartTypeHelper::isSupportingAreaProperties( xChartType, nDimensionCount ) ) 206 eMapTo = wrapper::GraphicPropertyItemConverter::LINE_DATA_POINT; 207 /* 208 FILLED_DATA_POINT, 209 LINE_DATA_POINT, 210 LINE_PROPERTIES, 211 FILL_PROPERTIES, 212 LINE_AND_FILL_PROPERTIES 213 */ 214 bool bDataSeries = ( eObjectType == OBJECTTYPE_DATA_SERIES || eObjectType == OBJECTTYPE_DATA_LABELS ); 215 216 //special color for pie chart: 217 bool bUseSpecialFillColor = false; 218 sal_Int32 nSpecialFillColor =0; 219 sal_Int32 nPointIndex = -1; /*-1 for whole series*/ 220 if(!bDataSeries) 221 { 222 nPointIndex = aParticleID.toInt32(); 223 uno::Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY ); 224 bool bVaryColorsByPoint = false; 225 if( xSeriesProp.is() && 226 (xSeriesProp->getPropertyValue(C2U("VaryColorsByPoint")) >>= bVaryColorsByPoint) && 227 bVaryColorsByPoint ) 228 { 229 if( !ColorPerPointHelper::hasPointOwnColor( xSeriesProp, nPointIndex, xObjectProperties ) ) 230 { 231 bUseSpecialFillColor = true; 232 OSL_ASSERT( xDiagram.is()); 233 uno::Reference< XColorScheme > xColorScheme( xDiagram->getDefaultColorScheme() ); 234 if( xColorScheme.is()) 235 nSpecialFillColor = xColorScheme->getColorByIndex( nPointIndex ); 236 } 237 } 238 } 239 sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties, xSeries, nPointIndex, xDiagram ); 240 sal_Int32 nPercentNumberFormat=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel( 241 xObjectProperties,uno::Reference< util::XNumberFormatsSupplier >(xChartModel, uno::UNO_QUERY)); 242 243 pItemConverter = new wrapper::DataPointItemConverter( xChartModel, xContext, 244 xObjectProperties, xSeries, rDrawModel.GetItemPool(), rDrawModel, 245 pNumberFormatterWrapper, 246 uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), 247 eMapTo, pRefSize, bDataSeries, bUseSpecialFillColor, nSpecialFillColor, false, 248 nNumberFormat, nPercentNumberFormat ); 249 break; 250 } 251 case OBJECTTYPE_GRID: 252 case OBJECTTYPE_SUBGRID: 253 case OBJECTTYPE_DATA_AVERAGE_LINE: 254 pItemConverter = new wrapper::GraphicPropertyItemConverter( 255 xObjectProperties, rDrawModel.GetItemPool(), 256 rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), 257 wrapper::GraphicPropertyItemConverter::LINE_PROPERTIES ); 258 break; 259 260 case OBJECTTYPE_DATA_ERRORS: 261 pItemConverter = new wrapper::ErrorBarItemConverter( 262 xChartModel, xObjectProperties, rDrawModel.GetItemPool(), 263 rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY )); 264 break; 265 266 case OBJECTTYPE_DATA_CURVE: 267 pItemConverter = new wrapper::RegressionCurveItemConverter( 268 xObjectProperties, uno::Reference< chart2::XRegressionCurveContainer >( 269 ObjectIdentifier::getDataSeriesForCID( aObjectCID, xChartModel ), uno::UNO_QUERY ), 270 rDrawModel.GetItemPool(), rDrawModel, 271 uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY )); 272 break; 273 case OBJECTTYPE_DATA_CURVE_EQUATION: 274 { 275 ::std::auto_ptr< awt::Size > pRefSize; 276 if( pRefSizeProvider.get() ) 277 pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize())); 278 279 pItemConverter = new wrapper::RegressionEquationItemConverter( 280 xObjectProperties, rDrawModel.GetItemPool(), rDrawModel, 281 uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), 282 pRefSize ); 283 break; 284 } 285 case OBJECTTYPE_DATA_ERRORS_X: 286 break; 287 case OBJECTTYPE_DATA_ERRORS_Y: 288 break; 289 case OBJECTTYPE_DATA_ERRORS_Z: 290 break; 291 case OBJECTTYPE_DATA_STOCK_RANGE: 292 break; 293 case OBJECTTYPE_DATA_STOCK_LOSS: 294 case OBJECTTYPE_DATA_STOCK_GAIN: 295 pItemConverter = new wrapper::GraphicPropertyItemConverter( 296 xObjectProperties, rDrawModel.GetItemPool(), 297 rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), 298 wrapper::GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES ); 299 break; 300 default: //OBJECTTYPE_UNKNOWN 301 break; 302 } 303 } 304 else 305 { 306 //create itemconverter for a all objects of given type 307 switch(eObjectType) 308 { 309 case OBJECTTYPE_TITLE: 310 pItemConverter = new wrapper::AllTitleItemConverter( xChartModel, rDrawModel.GetItemPool(), 311 rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY )); 312 break; 313 case OBJECTTYPE_AXIS: 314 { 315 ::std::auto_ptr< awt::Size > pRefSize; 316 if( pRefSizeProvider.get() ) 317 pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize())); 318 319 pItemConverter = new wrapper::AllAxisItemConverter( xChartModel, rDrawModel.GetItemPool(), 320 rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), pRefSize ); 321 } 322 break; 323 case OBJECTTYPE_GRID: 324 case OBJECTTYPE_SUBGRID: 325 pItemConverter = new wrapper::AllGridItemConverter( xChartModel, rDrawModel.GetItemPool(), 326 rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY )); 327 break; 328 default: //for this type it is not supported to change all elements at once 329 break; 330 } 331 332 } 333 return pItemConverter; 334 } 335 336 rtl::OUString lcl_getTitleCIDForCommand( const ::rtl::OString& rDispatchCommand, const uno::Reference< frame::XModel > & xChartModel ) 337 { 338 if( rDispatchCommand.equals("AllTitles")) 339 return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_TITLE, C2U("ALLELEMENTS") ); 340 341 TitleHelper::eTitleType nTitleType( TitleHelper::MAIN_TITLE ); 342 if( rDispatchCommand.equals("SubTitle") ) 343 nTitleType = TitleHelper::SUB_TITLE; 344 else if( rDispatchCommand.equals("XTitle") ) 345 nTitleType = TitleHelper::X_AXIS_TITLE; 346 else if( rDispatchCommand.equals("YTitle") ) 347 nTitleType = TitleHelper::Y_AXIS_TITLE; 348 else if( rDispatchCommand.equals("ZTitle") ) 349 nTitleType = TitleHelper::Z_AXIS_TITLE; 350 else if( rDispatchCommand.equals("SecondaryXTitle") ) 351 nTitleType = TitleHelper::SECONDARY_X_AXIS_TITLE; 352 else if( rDispatchCommand.equals("SecondaryYTitle") ) 353 nTitleType = TitleHelper::SECONDARY_Y_AXIS_TITLE; 354 355 uno::Reference< XTitle > xTitle( TitleHelper::getTitle( nTitleType, xChartModel ) ); 356 return ObjectIdentifier::createClassifiedIdentifierForObject( xTitle, xChartModel ); 357 } 358 359 rtl::OUString lcl_getAxisCIDForCommand( const ::rtl::OString& rDispatchCommand, const uno::Reference< frame::XModel >& xChartModel ) 360 { 361 if( rDispatchCommand.equals("DiagramAxisAll")) 362 return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_AXIS, C2U("ALLELEMENTS") ); 363 364 sal_Int32 nDimensionIndex=0; 365 bool bMainAxis=true; 366 if( rDispatchCommand.equals("DiagramAxisX")) 367 { 368 nDimensionIndex=0; bMainAxis=true; 369 } 370 else if( rDispatchCommand.equals("DiagramAxisY")) 371 { 372 nDimensionIndex=1; bMainAxis=true; 373 } 374 else if( rDispatchCommand.equals("DiagramAxisZ")) 375 { 376 nDimensionIndex=2; bMainAxis=true; 377 } 378 else if( rDispatchCommand.equals("DiagramAxisA")) 379 { 380 nDimensionIndex=0; bMainAxis=false; 381 } 382 else if( rDispatchCommand.equals("DiagramAxisB")) 383 { 384 nDimensionIndex=1; bMainAxis=false; 385 } 386 387 uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); 388 uno::Reference< XAxis > xAxis( AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram ) ); 389 return ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, xChartModel ); 390 } 391 392 rtl::OUString lcl_getGridCIDForCommand( const ::rtl::OString& rDispatchCommand, const uno::Reference< frame::XModel >& xChartModel ) 393 { 394 uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); 395 396 if( rDispatchCommand.equals("DiagramGridAll")) 397 return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_GRID, C2U("ALLELEMENTS") ); 398 399 sal_Int32 nDimensionIndex=0; 400 bool bMainGrid=true; 401 402 //x and y is swapped in the commands 403 404 if( rDispatchCommand.equals("DiagramGridYMain")) 405 { 406 nDimensionIndex=0; bMainGrid=true; 407 } 408 else if( rDispatchCommand.equals("DiagramGridXMain")) 409 { 410 nDimensionIndex=1; bMainGrid=true; 411 } 412 else if( rDispatchCommand.equals("DiagramGridZMain")) 413 { 414 nDimensionIndex=2; bMainGrid=true; 415 } 416 else if( rDispatchCommand.equals("DiagramGridYHelp")) 417 { 418 nDimensionIndex=0; bMainGrid=false; 419 } 420 else if( rDispatchCommand.equals("DiagramGridXHelp")) 421 { 422 nDimensionIndex=1; bMainGrid=false; 423 } 424 else if( rDispatchCommand.equals("DiagramGridZHelp")) 425 { 426 nDimensionIndex=2; bMainGrid=false; 427 } 428 429 bool bMainAxis = true; 430 uno::Reference< XAxis > xAxis( AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram ) ); 431 432 sal_Int32 nSubGridIndex= bMainGrid ? (-1) : 0; 433 rtl::OUString aCID( ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel, nSubGridIndex ) ); 434 return aCID; 435 } 436 rtl::OUString lcl_getObjectCIDForCommand( const ::rtl::OString& rDispatchCommand, const uno::Reference< XChartDocument > & xChartDocument, const rtl::OUString& rSelectedCID ) 437 { 438 ObjectType eObjectType = OBJECTTYPE_UNKNOWN; 439 rtl::OUString aParticleID; 440 441 uno::Reference< frame::XModel > xChartModel( xChartDocument, uno::UNO_QUERY ); 442 const ObjectType eSelectedType = ObjectIdentifier::getObjectType( rSelectedCID ); 443 uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rSelectedCID, xChartModel ); 444 uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( xSeries, uno::UNO_QUERY ); 445 446 //------------------------------------------------------------------------- 447 //legend 448 if( rDispatchCommand.equals("Legend") || rDispatchCommand.equals("FormatLegend") ) 449 { 450 eObjectType = OBJECTTYPE_LEGEND; 451 //@todo set particular aParticleID if we have more than one legend 452 } 453 //------------------------------------------------------------------------- 454 //wall floor area 455 else if( rDispatchCommand.equals("DiagramWall") || rDispatchCommand.equals("FormatWall") ) 456 { 457 //OBJECTTYPE_DIAGRAM; 458 eObjectType = OBJECTTYPE_DIAGRAM_WALL; 459 //@todo set particular aParticleID if we have more than one diagram 460 } 461 else if( rDispatchCommand.equals("DiagramFloor") || rDispatchCommand.equals("FormatFloor") ) 462 { 463 eObjectType = OBJECTTYPE_DIAGRAM_FLOOR; 464 //@todo set particular aParticleID if we have more than one diagram 465 } 466 else if( rDispatchCommand.equals("DiagramArea") || rDispatchCommand.equals("FormatChartArea") ) 467 { 468 eObjectType = OBJECTTYPE_PAGE; 469 } 470 //------------------------------------------------------------------------- 471 //title 472 else if( rDispatchCommand.equals("MainTitle") 473 || rDispatchCommand.equals("SubTitle") 474 || rDispatchCommand.equals("XTitle") 475 || rDispatchCommand.equals("YTitle") 476 || rDispatchCommand.equals("ZTitle") 477 || rDispatchCommand.equals("SecondaryXTitle") 478 || rDispatchCommand.equals("SecondaryYTitle") 479 || rDispatchCommand.equals("AllTitles") 480 ) 481 { 482 return lcl_getTitleCIDForCommand( rDispatchCommand, xChartModel ); 483 } 484 //------------------------------------------------------------------------- 485 //axis 486 else if( rDispatchCommand.equals("DiagramAxisX") 487 || rDispatchCommand.equals("DiagramAxisY") 488 || rDispatchCommand.equals("DiagramAxisZ") 489 || rDispatchCommand.equals("DiagramAxisA") 490 || rDispatchCommand.equals("DiagramAxisB") 491 || rDispatchCommand.equals("DiagramAxisAll") 492 ) 493 { 494 return lcl_getAxisCIDForCommand( rDispatchCommand, xChartModel ); 495 } 496 //------------------------------------------------------------------------- 497 //grid 498 else if( rDispatchCommand.equals("DiagramGridYMain") 499 || rDispatchCommand.equals("DiagramGridXMain") 500 || rDispatchCommand.equals("DiagramGridZMain") 501 || rDispatchCommand.equals("DiagramGridYHelp") 502 || rDispatchCommand.equals("DiagramGridXHelp") 503 || rDispatchCommand.equals("DiagramGridZHelp") 504 || rDispatchCommand.equals("DiagramGridAll") 505 ) 506 { 507 return lcl_getGridCIDForCommand( rDispatchCommand, xChartModel ); 508 } 509 //------------------------------------------------------------------------- 510 //data series 511 else if( rDispatchCommand.equals("FormatDataSeries") ) 512 { 513 if( eSelectedType == OBJECTTYPE_DATA_SERIES ) 514 return rSelectedCID; 515 else 516 return ObjectIdentifier::createClassifiedIdentifier( 517 OBJECTTYPE_DATA_SERIES, ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ) ); 518 } 519 //------------------------------------------------------------------------- 520 //data point 521 else if( rDispatchCommand.equals("FormatDataPoint") ) 522 { 523 return rSelectedCID; 524 } 525 //------------------------------------------------------------------------- 526 //data labels 527 else if( rDispatchCommand.equals("FormatDataLabels") ) 528 { 529 if( eSelectedType == OBJECTTYPE_DATA_LABELS ) 530 return rSelectedCID; 531 else 532 return ObjectIdentifier::createClassifiedIdentifierWithParent( 533 OBJECTTYPE_DATA_LABELS, ::rtl::OUString(), rSelectedCID ); 534 } 535 //------------------------------------------------------------------------- 536 //data labels 537 else if( rDispatchCommand.equals("FormatDataLabel") ) 538 { 539 if( eSelectedType == OBJECTTYPE_DATA_LABEL ) 540 return rSelectedCID; 541 else 542 { 543 sal_Int32 nPointIndex = ObjectIdentifier::getParticleID( rSelectedCID ).toInt32(); 544 if( nPointIndex>=0 ) 545 { 546 OUString aSeriesParticle = ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ); 547 OUString aChildParticle( ObjectIdentifier::getStringForType( OBJECTTYPE_DATA_LABELS ) ); 548 aChildParticle+=(C2U("=")); 549 OUString aLabelsCID = ObjectIdentifier::createClassifiedIdentifierForParticles( aSeriesParticle, aChildParticle ); 550 OUString aLabelCID_Stub = ObjectIdentifier::createClassifiedIdentifierWithParent( 551 OBJECTTYPE_DATA_LABEL, ::rtl::OUString(), aLabelsCID ); 552 553 return ObjectIdentifier::createPointCID( aLabelCID_Stub, nPointIndex ); 554 } 555 } 556 } 557 //------------------------------------------------------------------------- 558 //mean value line 559 else if( rDispatchCommand.equals("FormatMeanValue") ) 560 { 561 if( eSelectedType == OBJECTTYPE_DATA_AVERAGE_LINE ) 562 return rSelectedCID; 563 else 564 return ObjectIdentifier::createDataCurveCID( 565 ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ), 566 RegressionCurveHelper::getRegressionCurveIndex( xRegCurveCnt, 567 RegressionCurveHelper::getMeanValueLine( xRegCurveCnt ) ), true ); 568 } 569 //------------------------------------------------------------------------- 570 //trend line 571 else if( rDispatchCommand.equals("FormatTrendline") ) 572 { 573 if( eSelectedType == OBJECTTYPE_DATA_CURVE ) 574 return rSelectedCID; 575 else 576 return ObjectIdentifier::createDataCurveCID( 577 ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ), 578 RegressionCurveHelper::getRegressionCurveIndex( xRegCurveCnt, 579 RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ) ), false ); 580 } 581 //------------------------------------------------------------------------- 582 //trend line equation 583 else if( rDispatchCommand.equals("FormatTrendlineEquation") ) 584 { 585 if( eSelectedType == OBJECTTYPE_DATA_CURVE_EQUATION ) 586 return rSelectedCID; 587 else 588 return ObjectIdentifier::createDataCurveEquationCID( 589 ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ), 590 RegressionCurveHelper::getRegressionCurveIndex( xRegCurveCnt, 591 RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ) ) ); 592 } 593 //------------------------------------------------------------------------- 594 // y error bars 595 else if( rDispatchCommand.equals("FormatYErrorBars") ) 596 { 597 if( eSelectedType == OBJECTTYPE_DATA_ERRORS ) 598 return rSelectedCID; 599 else 600 return ObjectIdentifier::createClassifiedIdentifierWithParent( 601 OBJECTTYPE_DATA_ERRORS, ::rtl::OUString(), rSelectedCID ); 602 } 603 //------------------------------------------------------------------------- 604 // axis 605 else if( rDispatchCommand.equals("FormatAxis") ) 606 { 607 if( eSelectedType == OBJECTTYPE_AXIS ) 608 return rSelectedCID; 609 else 610 { 611 Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartModel ); 612 return ObjectIdentifier::createClassifiedIdentifierForObject( xAxis , xChartModel ); 613 } 614 } 615 //------------------------------------------------------------------------- 616 // major grid 617 else if( rDispatchCommand.equals("FormatMajorGrid") ) 618 { 619 if( eSelectedType == OBJECTTYPE_GRID ) 620 return rSelectedCID; 621 else 622 { 623 Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartModel ); 624 return ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel ); 625 } 626 627 } 628 //------------------------------------------------------------------------- 629 // minor grid 630 else if( rDispatchCommand.equals("FormatMinorGrid") ) 631 { 632 if( eSelectedType == OBJECTTYPE_SUBGRID ) 633 return rSelectedCID; 634 else 635 { 636 Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartModel ); 637 return ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel, 0 /*sub grid index*/ ); 638 } 639 } 640 //------------------------------------------------------------------------- 641 // title 642 else if( rDispatchCommand.equals("FormatTitle") ) 643 { 644 if( eSelectedType == OBJECTTYPE_TITLE ) 645 return rSelectedCID; 646 } 647 //------------------------------------------------------------------------- 648 // stock loss 649 else if( rDispatchCommand.equals("FormatStockLoss") ) 650 { 651 if( eSelectedType == OBJECTTYPE_DATA_STOCK_LOSS ) 652 return rSelectedCID; 653 else 654 return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DATA_STOCK_LOSS, rtl::OUString()); 655 } 656 //------------------------------------------------------------------------- 657 // stock gain 658 else if( rDispatchCommand.equals("FormatStockGain") ) 659 { 660 if( eSelectedType == OBJECTTYPE_DATA_STOCK_GAIN ) 661 return rSelectedCID; 662 else 663 return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DATA_STOCK_GAIN, rtl::OUString() ); 664 } 665 666 return ObjectIdentifier::createClassifiedIdentifier( 667 eObjectType, aParticleID ); 668 } 669 670 } 671 // anonymous namespace 672 673 void SAL_CALL ChartController::executeDispatch_FormatObject(const ::rtl::OUString& rDispatchCommand) 674 { 675 uno::Reference< XChartDocument > xChartDocument( getModel(), uno::UNO_QUERY ); 676 rtl::OString aCommand( rtl::OUStringToOString( rDispatchCommand, RTL_TEXTENCODING_ASCII_US ) ); 677 rtl::OUString rObjectCID = lcl_getObjectCIDForCommand( aCommand, xChartDocument, m_aSelection.getSelectedCID() ); 678 executeDlg_ObjectProperties( rObjectCID ); 679 } 680 681 void SAL_CALL ChartController::executeDispatch_ObjectProperties() 682 { 683 executeDlg_ObjectProperties( m_aSelection.getSelectedCID() ); 684 } 685 686 namespace 687 { 688 689 rtl::OUString lcl_getFormatCIDforSelectedCID( const ::rtl::OUString& rSelectedCID ) 690 { 691 ::rtl::OUString aFormatCID(rSelectedCID); 692 693 //get type of selected object 694 ObjectType eObjectType = ObjectIdentifier::getObjectType( aFormatCID ); 695 696 // some legend entries are handled as if they were data series 697 if( OBJECTTYPE_LEGEND_ENTRY==eObjectType ) 698 { 699 rtl::OUString aParentParticle( ObjectIdentifier::getFullParentParticle( rSelectedCID ) ); 700 aFormatCID = ObjectIdentifier::createClassifiedIdentifierForParticle( aParentParticle ); 701 } 702 703 // treat diagram as wall 704 if( OBJECTTYPE_DIAGRAM==eObjectType ) 705 aFormatCID = ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, rtl::OUString() ); 706 707 return aFormatCID; 708 } 709 710 }//end anonymous namespace 711 712 void SAL_CALL ChartController::executeDlg_ObjectProperties( const ::rtl::OUString& rSelectedObjectCID ) 713 { 714 rtl::OUString aObjectCID = lcl_getFormatCIDforSelectedCID( rSelectedObjectCID ); 715 716 UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( 717 ActionDescriptionProvider::FORMAT, 718 ObjectNameProvider::getName( ObjectIdentifier::getObjectType( aObjectCID ))), 719 m_xUndoManager ); 720 721 bool bSuccess = ChartController::executeDlg_ObjectProperties_withoutUndoGuard( aObjectCID, false ); 722 if( bSuccess ) 723 aUndoGuard.commit(); 724 } 725 726 bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( const ::rtl::OUString& rObjectCID, bool bOkClickOnUnchangedDialogSouldBeRatedAsSuccessAlso ) 727 { 728 //return true if the properties were changed successfully 729 bool bRet = false; 730 if( !rObjectCID.getLength() ) 731 { 732 //DBG_ERROR("empty ObjectID"); 733 return bRet; 734 } 735 try 736 { 737 NumberFormatterWrapper aNumberFormatterWrapper( uno::Reference< util::XNumberFormatsSupplier >(getModel(), uno::UNO_QUERY) ); 738 739 //------------------------------------------------------------- 740 //get type of object 741 ObjectType eObjectType = ObjectIdentifier::getObjectType( rObjectCID ); 742 if( OBJECTTYPE_UNKNOWN==eObjectType ) 743 { 744 //DBG_ERROR("unknown ObjectType"); 745 return bRet; 746 } 747 if( OBJECTTYPE_DIAGRAM_WALL==eObjectType || OBJECTTYPE_DIAGRAM_FLOOR==eObjectType ) 748 { 749 if( !DiagramHelper::isSupportingFloorAndWall( ChartModelHelper::findDiagram( getModel() ) ) ) 750 return bRet; 751 } 752 753 //------------------------------------------------------------- 754 //convert properties to ItemSet 755 756 awt::Size aPageSize( ChartModelHelper::getPageSize(getModel()) ); 757 758 ::std::auto_ptr< ReferenceSizeProvider > pRefSizeProv( 759 impl_createReferenceSizeProvider()); 760 ::std::auto_ptr< ::comphelper::ItemConverter > apItemConverter( 761 createItemConverter( rObjectCID, getModel(), m_xCC, 762 m_pDrawModelWrapper->getSdrModel(), 763 &aNumberFormatterWrapper, 764 ExplicitValueProvider::getExplicitValueProvider(m_xChartView), 765 pRefSizeProv )); 766 if(!apItemConverter.get()) 767 return bRet; 768 769 SfxItemSet aItemSet = apItemConverter->CreateEmptyItemSet(); 770 apItemConverter->FillItemSet( aItemSet ); 771 772 //------------------------------------------------------------- 773 //prepare dialog 774 ObjectPropertiesDialogParameter aDialogParameter = ObjectPropertiesDialogParameter( rObjectCID ); 775 aDialogParameter.init( getModel() ); 776 ViewElementListProvider aViewElementListProvider( m_pDrawModelWrapper.get() ); 777 778 ::vos::OGuard aGuard( Application::GetSolarMutex()); 779 SchAttribTabDlg aDlg( m_pChartWindow, &aItemSet, &aDialogParameter, &aViewElementListProvider 780 , uno::Reference< util::XNumberFormatsSupplier >( getModel(), uno::UNO_QUERY ) ); 781 782 if(aDialogParameter.HasSymbolProperties()) 783 { 784 SfxItemSet* pSymbolShapeProperties=NULL; 785 uno::Reference< beans::XPropertySet > xObjectProperties = 786 ObjectIdentifier::getObjectPropertySet( rObjectCID, getModel() ); 787 wrapper::DataPointItemConverter aSymbolItemConverter( getModel(), m_xCC 788 , xObjectProperties, ObjectIdentifier::getDataSeriesForCID( rObjectCID, getModel() ) 789 , m_pDrawModelWrapper->getSdrModel().GetItemPool() 790 , m_pDrawModelWrapper->getSdrModel() 791 , &aNumberFormatterWrapper 792 , uno::Reference< lang::XMultiServiceFactory >( getModel(), uno::UNO_QUERY ) 793 , wrapper::GraphicPropertyItemConverter::FILLED_DATA_POINT ); 794 795 pSymbolShapeProperties = new SfxItemSet( aSymbolItemConverter.CreateEmptyItemSet() ); 796 aSymbolItemConverter.FillItemSet( *pSymbolShapeProperties ); 797 798 sal_Int32 nStandardSymbol=0;//@todo get from somewhere 799 Graphic* pAutoSymbolGraphic = new Graphic( aViewElementListProvider.GetSymbolGraphic( nStandardSymbol, pSymbolShapeProperties ) ); 800 // note: the dialog takes the ownership of pSymbolShapeProperties and pAutoSymbolGraphic 801 aDlg.setSymbolInformation( pSymbolShapeProperties, pAutoSymbolGraphic ); 802 } 803 if( aDialogParameter.HasStatisticProperties() ) 804 { 805 aDlg.SetAxisMinorStepWidthForErrorBarDecimals( 806 InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( getModel(), m_xChartView, rObjectCID ) ); 807 } 808 809 //------------------------------------------------------------- 810 //open the dialog 811 if( aDlg.Execute() == RET_OK || (bOkClickOnUnchangedDialogSouldBeRatedAsSuccessAlso && aDlg.DialogWasClosedWithOK()) ) 812 { 813 const SfxItemSet* pOutItemSet = aDlg.GetOutputItemSet(); 814 if(pOutItemSet) 815 { 816 ControllerLockGuard aCLGuard( getModel()); 817 apItemConverter->ApplyItemSet( *pOutItemSet );//model should be changed now 818 bRet = true; 819 } 820 } 821 } 822 catch( util::CloseVetoException& ) 823 { 824 } 825 catch( uno::RuntimeException& ) 826 { 827 } 828 return bRet; 829 } 830 831 void SAL_CALL ChartController::executeDispatch_View3D() 832 { 833 try 834 { 835 // using assignment for broken gcc 3.3 836 UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard( 837 String( SchResId( STR_ACTION_EDIT_3D_VIEW )), 838 m_xUndoManager ); 839 840 // /-- 841 //open dialog 842 ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); 843 View3DDialog aDlg( m_pChartWindow, getModel(), m_pDrawModelWrapper->GetColorTableFromSdrModel() ); 844 if( aDlg.Execute() == RET_OK ) 845 aUndoGuard.commit(); 846 // \-- 847 } 848 catch( uno::RuntimeException& e) 849 { 850 ASSERT_EXCEPTION( e ); 851 } 852 } 853 854 //............................................................................. 855 } //namespace chart 856 //............................................................................. 857