LCOV - code coverage report
Current view: top level - chart2/source/controller/main - ChartController_Properties.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 1 348 0.3 %
Date: 2014-04-11 Functions: 2 14 14.3 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10