diff options
author | Kurt Zenker <kz@openoffice.org> | 2009-09-11 16:06:18 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2009-09-11 16:06:18 +0000 |
commit | 921ff4b99a018c4d45c6d8d810fc96130c1b3a70 (patch) | |
tree | 21ae48e21f773e75d8152a1b0a0fcfdef4e74f1c /chart2/source/controller/main | |
parent | c24ab8def12f8a7a305e35d39c91976e345dd3b0 (diff) |
CWS-TOOLING: integrate CWS chartuseability01
2009-09-07 17:26:44 +0200 iha r275906 : CWS-TOOLING: rebase CWS chartuseability01 to trunk@275801 (milestone: DEV300:m57)
2009-08-27 13:48:16 +0200 iha r275481 : #7049# listbox to select chart elements
2009-08-27 11:54:53 +0200 iha r275464 : #i58163# #i69422# #i102820# enhance chart context menu
2009-08-26 16:49:58 +0200 iha r275435 : #i102820# added missing case 'floor'
2009-08-26 15:33:51 +0200 iha r275427 : #i102820# make 'insert legend' work properly
2009-08-25 16:35:00 +0200 ufi r275369 : i104087
2009-08-25 15:12:17 +0200 iha r275360 : #i104087# 'Object Properties' -> 'Format Selection'
2009-08-25 15:11:31 +0200 iha r275359 : #i104087# 'Object Properties' -> 'Format Selection'
2009-08-25 15:11:15 +0200 iha r275358 : #i104087# 'Object Properties' -> 'Format Selection'
2009-08-25 11:57:43 +0200 iha r275344 : #i104087# changed behavior of insert menu
2009-08-18 12:53:54 +0200 oc r275093 : #i104082,104086,104089# multiple changes because of changed chartUI
2009-08-10 16:46:17 +0200 ufi r274824 : i104083 i104087 i104090
2009-08-07 14:04:34 +0200 iha r274763 : #7049# listbox to select chart elements
2009-08-07 13:06:05 +0200 iha r274760 : #7049# listbox to select chart elements
2009-08-07 13:05:06 +0200 iha r274759 : #7049# listbox to select chart elements
2009-08-07 12:32:31 +0200 iha r274756 : #i58163# #i69422# #i102820# enhance chart context menu
2009-08-07 12:31:54 +0200 iha r274755 : #i58163# #i69422# #i102820# enhance chart context menu
2009-08-06 19:00:48 +0200 iha r274742 : #i103593# make insert menu behavior selection dependent
2009-08-06 19:00:14 +0200 iha r274741 : #i103593# make insert menu behavior selection dependent
2009-08-06 15:34:01 +0200 iha r274731 : #i58163# #i69422# #i102820# enhance chart context menu
2009-08-06 14:39:20 +0200 iha r274728 : #i86146# ease adding R-squared value with an equation
2009-08-06 14:37:02 +0200 iha r274727 : #i86146# ease adding R-squared value with an equation
2009-08-06 13:37:54 +0200 iha r274724 : #i86146# ease adding R-squared value with an equation
2009-08-06 13:37:15 +0200 iha r274723 : #i86146# ease adding R-squared value with an equation
2009-08-06 13:04:27 +0200 iha r274722 : #i103593# make insert menu behavior selection dependent
2009-08-06 13:03:35 +0200 iha r274721 : #i103593# make insert menu behavior selection dependent
2009-08-05 18:26:31 +0200 iha r274693 : #i104033# inconsistent wording 'error indicator' <-> 'error bar'
2009-08-05 16:51:45 +0200 iha r274688 : #i104028# rename font tabpage 'Characters'->'Font'
2009-08-05 16:30:21 +0200 iha r274685 : #i58163# #i69422# #i102820# enhance chart context menu
2009-08-05 15:34:11 +0200 iha r274680 : #i58163# #i69422# #i102820# enhance chart context menu
2009-08-05 15:32:43 +0200 iha r274679 : #i58163# #i69422# #i102820# enhance chart context menu
2009-08-05 15:31:26 +0200 iha r274678 : #i58163# #i69422# #i102820# enhance chart context menu
2009-08-05 15:17:51 +0200 iha r274676 : #i58163# #i69422# #i102820# enhance chart context menu
2009-08-05 15:16:22 +0200 iha r274675 : #i58163# #i69422# #i102820# enhance chart context menu
2009-08-05 14:58:59 +0200 iha r274674 : #7049# listbox to select chart elements
2009-08-05 14:33:54 +0200 iha r274669 : #7049# listbox to select chart elements
2009-08-05 14:22:17 +0200 iha r274665 : #7049# listbox to select chart elements
2009-08-05 13:21:05 +0200 iha r274656 : #i102820# offer insertion of several elements in context menu also if nothing is selected
2009-08-05 11:56:06 +0200 iha r274647 : #7049# listbox to select chart elements
2009-08-05 11:43:40 +0200 iha r274645 : #7049# listbox to select chart elements
2009-07-24 19:46:50 +0200 iha r274318 : #i58163# #i69422# #i102820# enhance chart context menu
2009-07-24 16:23:13 +0200 iha r274313 : #i58163# #i69422# #i102820# enhance chart context menu
2009-07-24 16:13:22 +0200 iha r274311 : #i58163# #i69422# #i102820# enhance chart context menu
Diffstat (limited to 'chart2/source/controller/main')
-rw-r--r-- | chart2/source/controller/main/ChartController.cxx | 148 | ||||
-rw-r--r-- | chart2/source/controller/main/ChartController.hxx | 58 | ||||
-rw-r--r-- | chart2/source/controller/main/ChartController_Insert.cxx | 422 | ||||
-rw-r--r-- | chart2/source/controller/main/ChartController_Properties.cxx | 279 | ||||
-rw-r--r-- | chart2/source/controller/main/ChartController_Tools.cxx | 2 | ||||
-rw-r--r-- | chart2/source/controller/main/ChartController_Window.cxx | 362 | ||||
-rw-r--r-- | chart2/source/controller/main/ControllerCommandDispatch.cxx | 173 | ||||
-rw-r--r-- | chart2/source/controller/main/ElementSelector.cxx | 328 | ||||
-rw-r--r-- | chart2/source/controller/main/ElementSelector.hxx | 125 | ||||
-rw-r--r-- | chart2/source/controller/main/ObjectHierarchy.cxx | 272 | ||||
-rw-r--r-- | chart2/source/controller/main/_serviceregistration_controller.cxx | 9 | ||||
-rw-r--r-- | chart2/source/controller/main/makefile.mk | 1 |
12 files changed, 1892 insertions, 287 deletions
diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index 7728104afc0f..bda0108c8ce8 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -576,6 +576,9 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent xMBroadcaster->addModifyListener( this ); #endif + //select chart area per default: + select( uno::makeAny( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, rtl::OUString() ) ) ); + uno::Reference< lang::XMultiServiceFactory > xFact( m_aModel->getModel(), uno::UNO_QUERY ); if( xFact.is()) { @@ -974,7 +977,7 @@ namespace { bool lcl_isFormatObjectCommand( const rtl::OString& aCommand ) { - if( aCommand.equals("MainTitle") + if( aCommand.equals("MainTitle") || aCommand.equals("SubTitle") || aCommand.equals("XTitle") || aCommand.equals("YTitle") @@ -982,7 +985,6 @@ bool lcl_isFormatObjectCommand( const rtl::OString& aCommand ) || aCommand.equals("SecondaryXTitle") || aCommand.equals("SecondaryYTitle") || aCommand.equals("AllTitles") - || aCommand.equals("Legend") || aCommand.equals("DiagramAxisX") || aCommand.equals("DiagramAxisY") || aCommand.equals("DiagramAxisZ") @@ -996,9 +998,31 @@ bool lcl_isFormatObjectCommand( const rtl::OString& aCommand ) || aCommand.equals("DiagramGridYHelp") || aCommand.equals("DiagramGridZHelp") || aCommand.equals("DiagramGridAll") + || aCommand.equals("DiagramWall") || aCommand.equals("DiagramFloor") || aCommand.equals("DiagramArea") + || aCommand.equals("Legend") + + || aCommand.equals("FormatWall") + || aCommand.equals("FormatFloor") + || aCommand.equals("FormatChartArea") + || aCommand.equals("FormatLegend") + + || aCommand.equals("FormatTitle") + || aCommand.equals("FormatAxis") + || aCommand.equals("FormatDataSeries") + || aCommand.equals("FormatDataPoint") + || aCommand.equals("FormatDataLabels") + || aCommand.equals("FormatDataLabel") + || aCommand.equals("FormatYErrorBars") + || aCommand.equals("FormatMeanValue") + || aCommand.equals("FormatTrendline") + || aCommand.equals("FormatTrendlineEquation") + || aCommand.equals("FormatStockLoss") + || aCommand.equals("FormatStockGain") + || aCommand.equals("FormatMajorGrid") + || aCommand.equals("FormatMinorGrid") ) return true; @@ -1064,24 +1088,28 @@ bool lcl_isFormatObjectCommand( const rtl::OString& aCommand ) else if(aCommand.equals("DiagramData")) this->executeDispatch_EditData(); //insert objects - else if( aCommand.equals("InsertTitle")) - this->executeDispatch_InsertTitle(); - else if( aCommand.equals("InsertLegend")) + else if( aCommand.equals("InsertTitles") + || aCommand.equals("InsertMenuTitles") ) + this->executeDispatch_InsertTitles(); + else if( aCommand.equals("InsertMenuLegend") ) + this->executeDispatch_OpenLegendDialog(); + else if( aCommand.equals("InsertLegend") ) this->executeDispatch_InsertLegend(); - else if( aCommand.equals("InsertDescription")) - this->executeDispatch_InsertDataLabel(); - else if( aCommand.equals("InsertAxis")) - this->executeDispatch_InsertAxis(); - else if( aCommand.equals("InsertGrids")) + else if( aCommand.equals("DeleteLegend") ) + this->executeDispatch_DeleteLegend(); + else if( aCommand.equals("InsertMenuDataLabels")) + this->executeDispatch_InsertMenu_DataLabels(); + else if( aCommand.equals("InsertMenuAxes") + || aCommand.equals("InsertRemoveAxes") ) + this->executeDispatch_InsertAxes(); + else if( aCommand.equals("InsertMenuGrids")) this->executeDispatch_InsertGrid(); -// else if( aCommand.equals("InsertStatistics")) -// this->executeDispatch_InsertStatistic(); - else if( aCommand.equals("InsertTrendlines")) - this->executeDispatch_InsertTrendlines(); - else if( aCommand.equals("InsertMeanValues")) - this->executeDispatch_InsertMeanValues(); - else if( aCommand.equals("InsertYErrorbars")) - this->executeDispatch_InsertYErrorbars(); + else if( aCommand.equals("InsertMenuTrendlines")) + this->executeDispatch_InsertMenu_Trendlines(); + else if( aCommand.equals("InsertMenuMeanValues")) + this->executeDispatch_InsertMenu_MeanValues(); + else if( aCommand.equals("InsertMenuYErrorBars")) + this->executeDispatch_InsertMenu_YErrorBars(); else if( aCommand.equals("InsertSymbol")) this->executeDispatch_InsertSpecialCharacter(); else if( aCommand.equals("InsertTrendline")) @@ -1092,14 +1120,48 @@ bool lcl_isFormatObjectCommand( const rtl::OString& aCommand ) this->executeDispatch_InsertMeanValue(); else if( aCommand.equals("DeleteMeanValue")) this->executeDispatch_DeleteMeanValue(); - else if( aCommand.equals("InsertYErrorbar")) - this->executeDispatch_InsertYErrorbar(); - else if( aCommand.equals("DeleteYErrorbar")) - this->executeDispatch_DeleteYErrorbar(); + else if( aCommand.equals("InsertYErrorBars")) + this->executeDispatch_InsertYErrorBars(); + else if( aCommand.equals("DeleteYErrorBars")) + this->executeDispatch_DeleteYErrorBars(); else if( aCommand.equals("InsertTrendlineEquation")) this->executeDispatch_InsertTrendlineEquation(); + else if( aCommand.equals("DeleteTrendlineEquation")) + this->executeDispatch_DeleteTrendlineEquation(); + else if( aCommand.equals("InsertTrendlineEquationAndR2")) + this->executeDispatch_InsertTrendlineEquation( true ); + else if( aCommand.equals("InsertR2Value")) + this->executeDispatch_InsertR2Value(); + else if( aCommand.equals("DeleteR2Value")) + this->executeDispatch_DeleteR2Value(); + else if( aCommand.equals("InsertDataLabels") ) + this->executeDispatch_InsertDataLabels(); + else if( aCommand.equals("InsertDataLabel") ) + this->executeDispatch_InsertDataLabel(); + else if( aCommand.equals("DeleteDataLabels") ) + this->executeDispatch_DeleteDataLabels(); + else if( aCommand.equals("DeleteDataLabel") ) + this->executeDispatch_DeleteDataLabel(); + else if( aCommand.equals("ResetAllDataPoints") ) + this->executeDispatch_ResetAllDataPoints(); + else if( aCommand.equals("ResetDataPoint") ) + this->executeDispatch_ResetDataPoint(); + else if( aCommand.equals("InsertAxis") ) + this->executeDispatch_InsertAxis(); + else if( aCommand.equals("InsertMajorGrid") ) + this->executeDispatch_InsertMajorGrid(); + else if( aCommand.equals("InsertMinorGrid") ) + this->executeDispatch_InsertMinorGrid(); + else if( aCommand.equals("InsertAxisTitle") ) + this->executeDispatch_InsertAxisTitle(); + else if( aCommand.equals("DeleteAxis") ) + this->executeDispatch_DeleteAxis(); + else if( aCommand.equals("DeleteMajorGrid") ) + this->executeDispatch_DeleteMajorGrid(); + else if( aCommand.equals("DeleteMinorGrid") ) + this->executeDispatch_DeleteMinorGrid(); //format objects - else if( aCommand.equals("DiagramObjects")) + else if( aCommand.equals("FormatSelection") ) this->executeDispatch_ObjectProperties(); else if( aCommand.equals("TransformDialog")) this->executeDispatch_PositionAndSize(); @@ -1405,15 +1467,23 @@ void ChartController::impl_initializeAccessible( const uno::Reference< lang::XIn ( C2U("Cut") ) ( C2U("Copy") ) ( C2U("Paste") ) ( C2U("DataRanges") ) ( C2U("DiagramData") ) // insert objects - ( C2U("InsertTitle") ) ( C2U("InsertLegend") ) ( C2U("InsertDescription") ) - ( C2U("InsertAxis") ) ( C2U("InsertGrids") ) ( C2U("InsertStatistics") ) - ( C2U("InsertSymbol") ) ( C2U("InsertTrendline") ) ( C2U("InsertTrendlineEquation") ) - ( C2U("InsertTrendlines") ) ( C2U("InsertMeanValue") ) ( C2U("InsertMeanValues") ) - ( C2U("InsertYErrorbars") ) ( C2U("InsertYErrorbar") ) - ( C2U("DeleteTrendline") ) ( C2U("DeleteMeanValue") ) ( C2U("DeleteYErrorbar") ) + ( C2U("InsertMenuTitles") ) ( C2U("InsertTitles") ) + ( C2U("InsertMenuLegend") ) ( C2U("InsertLegend") ) ( C2U("DeleteLegend") ) + ( C2U("InsertMenuDataLabels") ) + ( C2U("InsertMenuAxes") ) ( C2U("InsertRemoveAxes") ) ( C2U("InsertMenuGrids") ) + ( C2U("InsertSymbol") ) + ( C2U("InsertTrendlineEquation") ) ( C2U("InsertTrendlineEquationAndR2") ) + ( C2U("InsertR2Value") ) ( C2U("DeleteR2Value") ) + ( C2U("InsertMenuTrendlines") ) ( C2U("InsertTrendline") ) + ( C2U("InsertMenuMeanValues") ) ( C2U("InsertMeanValue") ) + ( C2U("InsertMenuYErrorBars") ) ( C2U("InsertYErrorBars") ) + ( C2U("InsertDataLabels") ) ( C2U("InsertDataLabel") ) + ( C2U("DeleteTrendline") ) ( C2U("DeleteMeanValue") ) ( C2U("DeleteTrendlineEquation") ) + ( C2U("DeleteYErrorBars") ) + ( C2U("DeleteDataLabels") ) ( C2U("DeleteDataLabel") ) //format objects //MENUCHANGE ( C2U("SelectSourceRanges") ) - ( C2U("DiagramObjects") ) ( C2U("TransformDialog") ) + ( C2U("FormatSelection") ) ( C2U("TransformDialog") ) ( C2U("DiagramType") ) ( C2U("View3D") ) ( C2U("Forward") ) ( C2U("Backward") ) ( C2U("MainTitle") ) ( C2U("SubTitle") ) @@ -1426,12 +1496,30 @@ void ChartController::impl_initializeAccessible( const uno::Reference< lang::XIn ( C2U("DiagramGridXHelp") ) ( C2U("DiagramGridYHelp") ) ( C2U("DiagramGridZHelp") ) ( C2U("DiagramGridAll") ) ( C2U("DiagramWall") ) ( C2U("DiagramFloor") ) ( C2U("DiagramArea") ) + + //context menu - format objects entries + ( C2U("FormatWall") ) ( C2U("FormatFloor") ) ( C2U("FormatChartArea") ) + ( C2U("FormatLegend") ) + + ( C2U("FormatAxis") ) ( C2U("FormatTitle") ) + ( C2U("FormatDataSeries") ) ( C2U("FormatDataPoint") ) + ( C2U("ResetAllDataPoints") ) ( C2U("ResetDataPoint") ) + ( C2U("FormatDataLabels") ) ( C2U("FormatDataLabel") ) + ( C2U("FormatMeanValue") ) ( C2U("FormatTrendline") ) ( C2U("FormatTrendlineEquation") ) + ( C2U("FormatYErrorBars") ) + ( C2U("FormatStockLoss") ) ( C2U("FormatStockGain") ) + + ( C2U("FormatMajorGrid") ) ( C2U("InsertMajorGrid") ) ( C2U("DeleteMajorGrid") ) + ( C2U("FormatMinorGrid") ) ( C2U("InsertMinorGrid") ) ( C2U("DeleteMinorGrid") ) + ( C2U("InsertAxis") ) ( C2U("DeleteAxis") ) ( C2U("InsertAxisTitle") ) + // toolbar commands ( C2U("ToggleGridHorizontal"))( C2U("ToggleLegend") ) ( C2U("ScaleText") ) ( C2U("NewArrangement") ) ( C2U("Update") ) ( C2U("DefaultColors") ) ( C2U("BarWidth") ) ( C2U("NumberOfLines") ) ( C2U("ArrangeRow") ) ( C2U("StatusBarVisible") ) + ( C2U("ChartElementSelector") ) ; } diff --git a/chart2/source/controller/main/ChartController.hxx b/chart2/source/controller/main/ChartController.hxx index 0b81df0a2367..edf94fb7aae8 100644 --- a/chart2/source/controller/main/ChartController.hxx +++ b/chart2/source/controller/main/ChartController.hxx @@ -594,26 +594,50 @@ private: void SAL_CALL executeDispatch_ObjectProperties(); void SAL_CALL executeDispatch_FormatObject( const ::rtl::OUString& rDispatchCommand ); void SAL_CALL executeDlg_ObjectProperties( const ::rtl::OUString& rObjectCID ); + bool executeDlg_ObjectProperties_withoutUndoGuard( const ::rtl::OUString& rObjectCID, bool bOkClickOnUnchangedDialogSouldBeRatedAsSuccessAlso ); void SAL_CALL executeDispatch_ChartType(); - void SAL_CALL executeDispatch_InsertTitle(); - void SAL_CALL executeDispatch_InsertLegend(); - void SAL_CALL executeDispatch_InsertDataLabel(); - void SAL_CALL executeDispatch_InsertAxis(); - void SAL_CALL executeDispatch_InsertGrid(); -// void SAL_CALL executeDispatch_InsertStatistic(); - void SAL_CALL executeDispatch_InsertYErrorbars(); - void SAL_CALL executeDispatch_InsertTrendlines(); - void SAL_CALL executeDispatch_InsertMeanValue(); - void SAL_CALL executeDispatch_InsertMeanValues(); - void SAL_CALL executeDispatch_InsertTrendline(); - void SAL_CALL executeDispatch_InsertTrendlineEquation(); - void SAL_CALL executeDispatch_InsertYErrorbar(); - - void SAL_CALL executeDispatch_DeleteMeanValue(); - void SAL_CALL executeDispatch_DeleteTrendline(); - void SAL_CALL executeDispatch_DeleteYErrorbar(); + void executeDispatch_InsertTitles(); + void executeDispatch_InsertLegend(); + void executeDispatch_DeleteLegend(); + void executeDispatch_OpenLegendDialog(); + void executeDispatch_InsertAxes(); + void executeDispatch_InsertGrid(); + + void executeDispatch_InsertMenu_DataLabels(); + void executeDispatch_InsertMenu_YErrorBars(); + void executeDispatch_InsertMenu_Trendlines(); + void executeDispatch_InsertMenu_MeanValues(); + + void executeDispatch_InsertMeanValue(); + void executeDispatch_InsertTrendline(); + void executeDispatch_InsertTrendlineEquation( bool bInsertR2=false ); + void executeDispatch_InsertYErrorBars(); + + void executeDispatch_InsertR2Value(); + void executeDispatch_DeleteR2Value(); + + void executeDispatch_DeleteMeanValue(); + void executeDispatch_DeleteTrendline(); + void executeDispatch_DeleteTrendlineEquation(); + void executeDispatch_DeleteYErrorBars(); + + void executeDispatch_InsertDataLabels(); + void executeDispatch_InsertDataLabel(); + void executeDispatch_DeleteDataLabels(); + void executeDispatch_DeleteDataLabel(); + + void executeDispatch_ResetAllDataPoints(); + void executeDispatch_ResetDataPoint(); + + void executeDispatch_InsertAxis(); + void executeDispatch_InsertAxisTitle(); + void executeDispatch_InsertMajorGrid(); + void executeDispatch_InsertMinorGrid(); + void executeDispatch_DeleteAxis(); + void executeDispatch_DeleteMajorGrid(); + void executeDispatch_DeleteMinorGrid(); void SAL_CALL executeDispatch_InsertSpecialCharacter(); void SAL_CALL executeDispatch_EditText(); diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx index d847965b6022..45213a4473dc 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -61,6 +61,9 @@ #include "StatisticsHelper.hxx" #include "ErrorBarItemConverter.hxx" #include "MultipleItemConverter.hxx" +#include "DataSeriesHelper.hxx" +#include "ObjectNameProvider.hxx" +#include "LegendHelper.hxx" #include <com/sun/star/chart2/XRegressionCurve.hpp> #include <com/sun/star/chart/ErrorBarStyle.hpp> @@ -80,6 +83,9 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; //............................................................................. @@ -114,7 +120,7 @@ namespace chart { //............................................................................. -void SAL_CALL ChartController::executeDispatch_InsertAxis() +void ChartController::executeDispatch_InsertAxes() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( @@ -152,7 +158,7 @@ void SAL_CALL ChartController::executeDispatch_InsertAxis() } } -void SAL_CALL ChartController::executeDispatch_InsertGrid() +void ChartController::executeDispatch_InsertGrid() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( @@ -189,7 +195,7 @@ void SAL_CALL ChartController::executeDispatch_InsertGrid() //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void SAL_CALL ChartController::executeDispatch_InsertTitle() +void ChartController::executeDispatch_InsertTitles() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( @@ -220,7 +226,29 @@ void SAL_CALL ChartController::executeDispatch_InsertTitle() } } -void SAL_CALL ChartController::executeDispatch_InsertLegend() +void ChartController::executeDispatch_DeleteLegend() +{ + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))), + m_xUndoManager, m_aModel->getModel() ); + + LegendHelper::hideLegend( m_aModel->getModel() ); + aUndoGuard.commitAction(); +} + +void ChartController::executeDispatch_InsertLegend() +{ + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))), + m_xUndoManager, m_aModel->getModel() ); + + Reference< chart2::XLegend > xLegend = LegendHelper::showLegend( m_aModel->getModel(), m_xCC ); + aUndoGuard.commitAction(); +} + +void ChartController::executeDispatch_OpenLegendDialog() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( @@ -251,13 +279,32 @@ void SAL_CALL ChartController::executeDispatch_InsertLegend() //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void SAL_CALL ChartController::executeDispatch_InsertDataLabel() +void ChartController::executeDispatch_InsertMenu_DataLabels() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_DATALABELS )))), m_xUndoManager, m_aModel->getModel() ); + //if a series is selected insert labels for that series only: + uno::Reference< chart2::XDataSeries > xSeries( + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xSeries.is() ) + { + // add labels + DataSeriesHelper::insertDataLabelsToSeriesAndAllPoints( xSeries ); + + rtl::OUString aChildParticle( ObjectIdentifier::getStringForType( OBJECTTYPE_DATA_LABELS ) ); + aChildParticle+=(C2U("=")); + rtl::OUString aObjectCID = ObjectIdentifier::createClassifiedIdentifierForParticles( + ObjectIdentifier::getSeriesParticleFromCID(m_aSelection.getSelectedCID()), aChildParticle ); + + bool bSuccess = ChartController::executeDlg_ObjectProperties_withoutUndoGuard( aObjectCID, true ); + if( bSuccess ) + aUndoGuard.commitAction(); + return; + } + try { wrapper::AllDataLabelItemConverter aItemConverter( @@ -295,11 +342,21 @@ void SAL_CALL ChartController::executeDispatch_InsertDataLabel() } } -void SAL_CALL ChartController::executeDispatch_InsertYErrorbars() +void ChartController::executeDispatch_InsertMenu_YErrorBars() { + //if a series is selected insert error bars for that series only: + uno::Reference< chart2::XDataSeries > xSeries( + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xSeries.is()) + { + executeDispatch_InsertYErrorBars(); + return; + } + + //if no series is selected insert error bars for all series UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_PAGE_YERROR_BARS )))), + ActionDescriptionProvider::INSERT, ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_ERRORS ) ), m_xUndoManager, m_aModel->getModel() ); try @@ -335,7 +392,7 @@ void SAL_CALL ChartController::executeDispatch_InsertYErrorbars() } } -void SAL_CALL ChartController::executeDispatch_InsertMeanValue() +void ChartController::executeDispatch_InsertMeanValue() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( @@ -346,23 +403,43 @@ void SAL_CALL ChartController::executeDispatch_InsertMeanValue() aUndoGuard.commitAction(); } -void SAL_CALL ChartController::executeDispatch_InsertMeanValues() +void ChartController::executeDispatch_InsertMenu_MeanValues() { - ::std::vector< uno::Reference< chart2::XDataSeries > > aSeries( - DiagramHelper::getDataSeriesFromDiagram( ChartModelHelper::findDiagram( m_aModel->getModel()))); UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AVERAGE_LINE )))), m_xUndoManager, m_aModel->getModel() ); - ::std::for_each( aSeries.begin(), aSeries.end(), lcl_InsertMeanValueLine( m_xCC )); + + uno::Reference< chart2::XDataSeries > xSeries( + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xSeries.is() ) + { + //if a series is selected insert mean value only for that series: + lcl_InsertMeanValueLine( m_xCC ).operator()(xSeries); + } + else + { + ::std::vector< uno::Reference< chart2::XDataSeries > > aSeries( + DiagramHelper::getDataSeriesFromDiagram( ChartModelHelper::findDiagram( m_aModel->getModel()))); + ::std::for_each( aSeries.begin(), aSeries.end(), lcl_InsertMeanValueLine( m_xCC )); + } aUndoGuard.commitAction(); } -void SAL_CALL ChartController::executeDispatch_InsertTrendlines() +void ChartController::executeDispatch_InsertMenu_Trendlines() { + //if a series is selected insert only for that series: + uno::Reference< chart2::XDataSeries > xSeries( + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xSeries.is()) + { + executeDispatch_InsertTrendline(); + return; + } + UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVES )))), + ActionDescriptionProvider::INSERT, ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_CURVE ) ), m_xUndoManager, m_aModel->getModel() ); try @@ -395,7 +472,7 @@ void SAL_CALL ChartController::executeDispatch_InsertTrendlines() } } -void SAL_CALL ChartController::executeDispatch_InsertTrendline() +void ChartController::executeDispatch_InsertTrendline() { uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); @@ -449,7 +526,7 @@ void SAL_CALL ChartController::executeDispatch_InsertTrendline() } } -void SAL_CALL ChartController::executeDispatch_InsertYErrorbar() +void ChartController::executeDispatch_InsertYErrorBars() { uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); @@ -457,7 +534,7 @@ void SAL_CALL ChartController::executeDispatch_InsertYErrorbar() { UndoLiveUpdateGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_ERROR_INDICATOR )))), + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_ERROR_BARS )))), m_xUndoManager, m_aModel->getModel() ); // add error bars with standard deviation @@ -499,10 +576,16 @@ void SAL_CALL ChartController::executeDispatch_InsertYErrorbar() } } -void SAL_CALL ChartController::executeDispatch_InsertTrendlineEquation() +void ChartController::executeDispatch_InsertTrendlineEquation( bool bInsertR2 ) { uno::Reference< chart2::XRegressionCurve > xRegCurve( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( !xRegCurve.is() ) + { + uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + xRegCurve.set( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ) ); + } if( xRegCurve.is()) { uno::Reference< beans::XPropertySet > xEqProp( xRegCurve->getEquationProperties()); @@ -514,13 +597,43 @@ void SAL_CALL ChartController::executeDispatch_InsertTrendlineEquation() ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))), m_xUndoManager, m_aModel->getModel() ); xEqProp->setPropertyValue( C2U("ShowEquation"), uno::makeAny( true )); - xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( false )); + xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( bInsertR2 )); aUndoGuard.commitAction(); } } } -void SAL_CALL ChartController::executeDispatch_DeleteMeanValue() +void ChartController::executeDispatch_InsertR2Value() +{ + uno::Reference< beans::XPropertySet > xEqProp( + ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xEqProp.is()) + { + UndoGuard aUndoGuard = UndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))), + m_xUndoManager, m_aModel->getModel() ); + xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( true )); + aUndoGuard.commitAction(); + } +} + +void ChartController::executeDispatch_DeleteR2Value() +{ + uno::Reference< beans::XPropertySet > xEqProp( + ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xEqProp.is()) + { + UndoGuard aUndoGuard = UndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))), + m_xUndoManager, m_aModel->getModel() ); + xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( false )); + aUndoGuard.commitAction(); + } +} + +void ChartController::executeDispatch_DeleteMeanValue() { uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); @@ -535,7 +648,7 @@ void SAL_CALL ChartController::executeDispatch_DeleteMeanValue() } } -void SAL_CALL ChartController::executeDispatch_DeleteTrendline() +void ChartController::executeDispatch_DeleteTrendline() { uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); @@ -550,7 +663,22 @@ void SAL_CALL ChartController::executeDispatch_DeleteTrendline() } } -void SAL_CALL ChartController::executeDispatch_DeleteYErrorbar() +void ChartController::executeDispatch_DeleteTrendlineEquation() +{ + uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xRegCurveCnt.is()) + { + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))), + m_xUndoManager, m_aModel->getModel()); + RegressionCurveHelper::removeEquations( xRegCurveCnt ); + aUndoGuard.commitAction(); + } +} + +void ChartController::executeDispatch_DeleteYErrorBars() { uno::Reference< chart2::XDataSeries > xDataSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel())); @@ -565,6 +693,256 @@ void SAL_CALL ChartController::executeDispatch_DeleteYErrorbar() } } +void ChartController::executeDispatch_InsertDataLabels() +{ + uno::Reference< chart2::XDataSeries > xSeries( + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xSeries.is() ) + { + UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, + ::rtl::OUString( String( SchResId( STR_OBJECT_DATALABELS )))), + m_xUndoManager, m_aModel->getModel() ); + DataSeriesHelper::insertDataLabelsToSeriesAndAllPoints( xSeries ); + aUndoGuard.commitAction(); + } +} + +void ChartController::executeDispatch_InsertDataLabel() +{ + UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, + ::rtl::OUString( String( SchResId( STR_OBJECT_LABEL )))), + m_xUndoManager, m_aModel->getModel() ); + DataSeriesHelper::insertDataLabelToPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), m_aModel->getModel() ) ); + aUndoGuard.commitAction(); +} + +void ChartController::executeDispatch_DeleteDataLabels() +{ + uno::Reference< chart2::XDataSeries > xSeries( + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xSeries.is() ) + { + UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, + ::rtl::OUString( String( SchResId( STR_OBJECT_DATALABELS )))), + m_xUndoManager, m_aModel->getModel()); + DataSeriesHelper::deleteDataLabelsFromSeriesAndAllPoints( xSeries ); + aUndoGuard.commitAction(); + } +} + +void ChartController::executeDispatch_DeleteDataLabel() +{ + UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, + ::rtl::OUString( String( SchResId( STR_OBJECT_LABEL )))), + m_xUndoManager, m_aModel->getModel()); + DataSeriesHelper::deleteDataLabelsFromPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), m_aModel->getModel() ) ); + aUndoGuard.commitAction(); +} + +void ChartController::executeDispatch_ResetAllDataPoints() +{ + UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::FORMAT, + ::rtl::OUString( String( SchResId( STR_OBJECT_DATAPOINTS )))), + m_xUndoManager, m_aModel->getModel()); + uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xSeries.is() ) + xSeries->resetAllDataPoints(); + aUndoGuard.commitAction(); +} +void ChartController::executeDispatch_ResetDataPoint() +{ + UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::FORMAT, + ::rtl::OUString( String( SchResId( STR_OBJECT_DATAPOINT )))), + m_xUndoManager, m_aModel->getModel()); + uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xSeries.is() ) + { + sal_Int32 nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( m_aSelection.getSelectedCID() ); + xSeries->resetDataPoint( nPointIndex ); + } + aUndoGuard.commitAction(); +} + +void ChartController::executeDispatch_InsertAxisTitle() +{ + try + { + uno::Reference< XTitle > xTitle; + { + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_TITLE )))), + m_xUndoManager, m_aModel->getModel() ); + + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() ); + sal_Int32 nDimensionIndex = -1; + sal_Int32 nCooSysIndex = -1; + sal_Int32 nAxisIndex = -1; + AxisHelper::getIndicesForAxis( xAxis, ChartModelHelper::findDiagram(m_aModel->getModel()), nCooSysIndex, nDimensionIndex, nAxisIndex ); + + TitleHelper::eTitleType eTitleType = TitleHelper::X_AXIS_TITLE; + if( nDimensionIndex==0 ) + eTitleType = nAxisIndex==0 ? TitleHelper::X_AXIS_TITLE : TitleHelper::SECONDARY_X_AXIS_TITLE; + else if( nDimensionIndex==1 ) + eTitleType = nAxisIndex==0 ? TitleHelper::Y_AXIS_TITLE : TitleHelper::SECONDARY_Y_AXIS_TITLE; + else + eTitleType = TitleHelper::Z_AXIS_TITLE; + + ::std::auto_ptr< ReferenceSizeProvider > apRefSizeProvider( impl_createReferenceSizeProvider()); + xTitle = TitleHelper::createTitle( eTitleType, ObjectNameProvider::getTitleNameByType(eTitleType), m_aModel->getModel(), m_xCC, apRefSizeProvider.get() ); + aUndoGuard.commitAction(); + } + + /* + if( xTitle.is() ) + { + OUString aTitleCID = ObjectIdentifier::createClassifiedIdentifierForObject( xTitle, m_aModel->getModel() ); + select( uno::makeAny(aTitleCID) ); + executeDispatch_EditText(); + } + */ + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } +} + +void ChartController::executeDispatch_InsertAxis() +{ + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AXIS )))), + m_xUndoManager, m_aModel->getModel() ); + + try + { + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() ); + if( xAxis.is() ) + { + AxisHelper::makeAxisVisible( xAxis ); + aUndoGuard.commitAction(); + } + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } +} + +void ChartController::executeDispatch_DeleteAxis() +{ + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_AXIS )))), + m_xUndoManager, m_aModel->getModel() ); + + try + { + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() ); + if( xAxis.is() ) + { + AxisHelper::makeAxisInvisible( xAxis ); + aUndoGuard.commitAction(); + } + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } +} + +void ChartController::executeDispatch_InsertMajorGrid() +{ + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))), + m_xUndoManager, m_aModel->getModel() ); + + try + { + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() ); + if( xAxis.is() ) + { + AxisHelper::makeGridVisible( xAxis->getGridProperties() ); + aUndoGuard.commitAction(); + } + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } +} + +void ChartController::executeDispatch_DeleteMajorGrid() +{ + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))), + m_xUndoManager, m_aModel->getModel() ); + + try + { + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() ); + if( xAxis.is() ) + { + AxisHelper::makeGridInvisible( xAxis->getGridProperties() ); + aUndoGuard.commitAction(); + } + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } +} + +void ChartController::executeDispatch_InsertMinorGrid() +{ + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))), + m_xUndoManager, m_aModel->getModel() ); + + try + { + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() ); + if( xAxis.is() ) + { + Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() ); + for( sal_Int32 nN=0; nN<aSubGrids.getLength(); nN++) + AxisHelper::makeGridVisible( aSubGrids[nN] ); + aUndoGuard.commitAction(); + } + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } +} + +void ChartController::executeDispatch_DeleteMinorGrid() +{ + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))), + m_xUndoManager, m_aModel->getModel() ); + + try + { + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() ); + if( xAxis.is() ) + { + Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() ); + for( sal_Int32 nN=0; nN<aSubGrids.getLength(); nN++) + AxisHelper::makeGridInvisible( aSubGrids[nN] ); + aUndoGuard.commitAction(); + } + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } +} //............................................................................. } //namespace chart diff --git a/chart2/source/controller/main/ChartController_Properties.cxx b/chart2/source/controller/main/ChartController_Properties.cxx index 530cd6f0aeb8..754e66ec7d17 100644 --- a/chart2/source/controller/main/ChartController_Properties.cxx +++ b/chart2/source/controller/main/ChartController_Properties.cxx @@ -62,6 +62,7 @@ #include "ResId.hxx" #include "Strings.hrc" #include "ReferenceSizeProvider.hxx" +#include "RegressionCurveHelper.hxx" #include <com/sun/star/chart2/XChartDocument.hpp> //for auto_ptr @@ -80,6 +81,8 @@ namespace chart //............................................................................. using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; +using ::com::sun::star::uno::Reference; +using ::rtl::OUString; namespace { @@ -437,34 +440,37 @@ rtl::OUString lcl_getGridCIDForCommand( const ::rtl::OString& rDispatchCommand, rtl::OUString aCID( ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel, nSubGridIndex ) ); return aCID; } -rtl::OUString lcl_getObjectCIDForCommand( const ::rtl::OString& rDispatchCommand, const uno::Reference< XChartDocument > & xChartDocument ) +rtl::OUString lcl_getObjectCIDForCommand( const ::rtl::OString& rDispatchCommand, const uno::Reference< XChartDocument > & xChartDocument, const rtl::OUString& rSelectedCID ) { ObjectType eObjectType = OBJECTTYPE_UNKNOWN; rtl::OUString aParticleID; uno::Reference< frame::XModel > xChartModel( xChartDocument, uno::UNO_QUERY ); + const ObjectType eSelectedType = ObjectIdentifier::getObjectType( rSelectedCID ); + uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rSelectedCID, xChartModel ); + uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( xSeries, uno::UNO_QUERY ); //------------------------------------------------------------------------- //legend - if( rDispatchCommand.equals("Legend")) + if( rDispatchCommand.equals("Legend") || rDispatchCommand.equals("FormatLegend") ) { eObjectType = OBJECTTYPE_LEGEND; //@todo set particular aParticleID if we have more than one legend } //------------------------------------------------------------------------- //wall floor area - else if( rDispatchCommand.equals("DiagramWall")) + else if( rDispatchCommand.equals("DiagramWall") || rDispatchCommand.equals("FormatWall") ) { //OBJECTTYPE_DIAGRAM; eObjectType = OBJECTTYPE_DIAGRAM_WALL; //@todo set particular aParticleID if we have more than one diagram } - else if( rDispatchCommand.equals("DiagramFloor")) + else if( rDispatchCommand.equals("DiagramFloor") || rDispatchCommand.equals("FormatFloor") ) { eObjectType = OBJECTTYPE_DIAGRAM_FLOOR; //@todo set particular aParticleID if we have more than one diagram } - else if( rDispatchCommand.equals("DiagramArea")) + else if( rDispatchCommand.equals("DiagramArea") || rDispatchCommand.equals("FormatChartArea") ) { eObjectType = OBJECTTYPE_PAGE; } @@ -507,6 +513,163 @@ rtl::OUString lcl_getObjectCIDForCommand( const ::rtl::OString& rDispatchCommand { return lcl_getGridCIDForCommand( rDispatchCommand, xChartModel ); } + //------------------------------------------------------------------------- + //data series + else if( rDispatchCommand.equals("FormatDataSeries") ) + { + if( eSelectedType == OBJECTTYPE_DATA_SERIES ) + return rSelectedCID; + else + return ObjectIdentifier::createClassifiedIdentifier( + OBJECTTYPE_DATA_SERIES, ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ) ); + } + //------------------------------------------------------------------------- + //data point + else if( rDispatchCommand.equals("FormatDataPoint") ) + { + return rSelectedCID; + } + //------------------------------------------------------------------------- + //data labels + else if( rDispatchCommand.equals("FormatDataLabels") ) + { + if( eSelectedType == OBJECTTYPE_DATA_LABELS ) + return rSelectedCID; + else + return ObjectIdentifier::createClassifiedIdentifierWithParent( + OBJECTTYPE_DATA_LABELS, ::rtl::OUString(), rSelectedCID ); + } + //------------------------------------------------------------------------- + //data labels + else if( rDispatchCommand.equals("FormatDataLabel") ) + { + if( eSelectedType == OBJECTTYPE_DATA_LABEL ) + return rSelectedCID; + else + { + sal_Int32 nPointIndex = ObjectIdentifier::getParticleID( rSelectedCID ).toInt32(); + if( nPointIndex>=0 ) + { + OUString aSeriesParticle = ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ); + OUString aChildParticle( ObjectIdentifier::getStringForType( OBJECTTYPE_DATA_LABELS ) ); + aChildParticle+=(C2U("=")); + OUString aLabelsCID = ObjectIdentifier::createClassifiedIdentifierForParticles( aSeriesParticle, aChildParticle ); + OUString aLabelCID_Stub = ObjectIdentifier::createClassifiedIdentifierWithParent( + OBJECTTYPE_DATA_LABEL, ::rtl::OUString(), aLabelsCID ); + + return ObjectIdentifier::createPointCID( aLabelCID_Stub, nPointIndex ); + } + } + } + //------------------------------------------------------------------------- + //mean value line + else if( rDispatchCommand.equals("FormatMeanValue") ) + { + if( eSelectedType == OBJECTTYPE_DATA_AVERAGE_LINE ) + return rSelectedCID; + else + return ObjectIdentifier::createDataCurveCID( + ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ), + RegressionCurveHelper::getRegressionCurveIndex( xRegCurveCnt, + RegressionCurveHelper::getMeanValueLine( xRegCurveCnt ) ), true ); + } + //------------------------------------------------------------------------- + //trend line + else if( rDispatchCommand.equals("FormatTrendline") ) + { + if( eSelectedType == OBJECTTYPE_DATA_CURVE ) + return rSelectedCID; + else + return ObjectIdentifier::createDataCurveCID( + ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ), + RegressionCurveHelper::getRegressionCurveIndex( xRegCurveCnt, + RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ) ), false ); + } + //------------------------------------------------------------------------- + //trend line equation + else if( rDispatchCommand.equals("FormatTrendlineEquation") ) + { + if( eSelectedType == OBJECTTYPE_DATA_CURVE_EQUATION ) + return rSelectedCID; + else + return ObjectIdentifier::createDataCurveEquationCID( + ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ), + RegressionCurveHelper::getRegressionCurveIndex( xRegCurveCnt, + RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ) ) ); + } + //------------------------------------------------------------------------- + // y error bars + else if( rDispatchCommand.equals("FormatYErrorBars") ) + { + if( eSelectedType == OBJECTTYPE_DATA_ERRORS ) + return rSelectedCID; + else + return ObjectIdentifier::createClassifiedIdentifierWithParent( + OBJECTTYPE_DATA_ERRORS, ::rtl::OUString(), rSelectedCID ); + } + //------------------------------------------------------------------------- + // axis + else if( rDispatchCommand.equals("FormatAxis") ) + { + if( eSelectedType == OBJECTTYPE_AXIS ) + return rSelectedCID; + else + { + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartModel ); + return ObjectIdentifier::createClassifiedIdentifierForObject( xAxis , xChartModel ); + } + } + //------------------------------------------------------------------------- + // major grid + else if( rDispatchCommand.equals("FormatMajorGrid") ) + { + if( eSelectedType == OBJECTTYPE_GRID ) + return rSelectedCID; + else + { + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartModel ); + return ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel ); + } + + } + //------------------------------------------------------------------------- + // minor grid + else if( rDispatchCommand.equals("FormatMinorGrid") ) + { + if( eSelectedType == OBJECTTYPE_SUBGRID ) + return rSelectedCID; + else + { + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartModel ); + return ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel, 0 /*sub grid index*/ ); + } + } + //------------------------------------------------------------------------- + // title + else if( rDispatchCommand.equals("FormatTitle") ) + { + if( eSelectedType == OBJECTTYPE_TITLE ) + return rSelectedCID; + } + //------------------------------------------------------------------------- + // stock loss + else if( rDispatchCommand.equals("FormatStockLoss") ) + { + if( eSelectedType == OBJECTTYPE_DATA_STOCK_LOSS ) + return rSelectedCID; + else + return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DATA_STOCK_LOSS, rtl::OUString()); + } + //------------------------------------------------------------------------- + // stock gain + else if( rDispatchCommand.equals("FormatStockGain") ) + { + if( eSelectedType == OBJECTTYPE_DATA_STOCK_GAIN ) + return rSelectedCID; + else + return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DATA_STOCK_GAIN, rtl::OUString() ); + } + return ObjectIdentifier::createClassifiedIdentifier( eObjectType, aParticleID ); } @@ -518,7 +681,7 @@ void SAL_CALL ChartController::executeDispatch_FormatObject(const ::rtl::OUStrin { uno::Reference< XChartDocument > xChartDocument( m_aModel->getModel(), uno::UNO_QUERY ); rtl::OString aCommand( rtl::OUStringToOString( rDispatchCommand, RTL_TEXTENCODING_ASCII_US ) ); - rtl::OUString rObjectCID = lcl_getObjectCIDForCommand( aCommand, xChartDocument ); + rtl::OUString rObjectCID = lcl_getObjectCIDForCommand( aCommand, xChartDocument, m_aSelection.getSelectedCID() ); executeDlg_ObjectProperties( rObjectCID ); } @@ -527,56 +690,74 @@ void SAL_CALL ChartController::executeDispatch_ObjectProperties() executeDlg_ObjectProperties( m_aSelection.getSelectedCID() ); } -void SAL_CALL ChartController::executeDlg_ObjectProperties( const ::rtl::OUString& rObjectCID ) +namespace +{ + +rtl::OUString lcl_getFormatCIDforSelectedCID( const ::rtl::OUString& rSelectedCID ) +{ + ::rtl::OUString aFormatCID(rSelectedCID); + + //get type of selected object + ObjectType eObjectType = ObjectIdentifier::getObjectType( aFormatCID ); + + // some legend entries are handled as if they were data series + if( OBJECTTYPE_LEGEND_ENTRY==eObjectType ) + { + rtl::OUString aParentParticle( ObjectIdentifier::getFullParentParticle( rSelectedCID ) ); + aFormatCID = ObjectIdentifier::createClassifiedIdentifierForParticle( aParentParticle ); + } + + // treat diagram as wall + if( OBJECTTYPE_DIAGRAM==eObjectType ) + aFormatCID = ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, rtl::OUString() ); + + return aFormatCID; +} + +}//end anonymous namespace + +void SAL_CALL ChartController::executeDlg_ObjectProperties( const ::rtl::OUString& rSelectedObjectCID ) +{ + rtl::OUString aObjectCID = lcl_getFormatCIDforSelectedCID( rSelectedObjectCID ); + + UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::FORMAT, + ObjectNameProvider::getName( ObjectIdentifier::getObjectType( aObjectCID ))), + m_xUndoManager, m_aModel->getModel() ); + + bool bSuccess = ChartController::executeDlg_ObjectProperties_withoutUndoGuard( aObjectCID, false ); + if( bSuccess ) + aUndoGuard.commitAction(); +} + +bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( const ::rtl::OUString& rObjectCID, bool bOkClickOnUnchangedDialogSouldBeRatedAsSuccessAlso ) { + //return true if the properties were changed successfully + bool bRet = false; if( !rObjectCID.getLength() ) { //DBG_ERROR("empty ObjectID"); - return; + return bRet; } try { - ::rtl::OUString aObjectCID(rObjectCID); NumberFormatterWrapper aNumberFormatterWrapper( uno::Reference< util::XNumberFormatsSupplier >(m_aModel->getModel(), uno::UNO_QUERY) ); //------------------------------------------------------------- - //get type of selected object - ObjectType eObjectType = ObjectIdentifier::getObjectType( aObjectCID ); + //get type of object + ObjectType eObjectType = ObjectIdentifier::getObjectType( rObjectCID ); if( OBJECTTYPE_UNKNOWN==eObjectType ) { //DBG_ERROR("unknown ObjectType"); - return; - } - - // some legend entries are handled as if they were data series - if( OBJECTTYPE_LEGEND_ENTRY==eObjectType ) - { - rtl::OUString aParentParticle( ObjectIdentifier::getFullParentParticle( aObjectCID ) ); - eObjectType = ObjectIdentifier::getObjectType( aParentParticle ); - aObjectCID = ObjectIdentifier::createClassifiedIdentifierForParticle( aParentParticle ); + return bRet; } - - // treat diagram as wall - if( OBJECTTYPE_DIAGRAM==eObjectType ) - { - aObjectCID = ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, rtl::OUString() ); - eObjectType = OBJECTTYPE_DIAGRAM_WALL; - } - if( OBJECTTYPE_DIAGRAM_WALL==eObjectType || OBJECTTYPE_DIAGRAM_FLOOR==eObjectType ) { if( !DiagramHelper::isSupportingFloorAndWall( ChartModelHelper::findDiagram( m_aModel->getModel() ) ) ) - return; + return bRet; } //------------------------------------------------------------- - UndoGuard aUndoGuard( - ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::FORMAT, - ObjectNameProvider::getName( ObjectIdentifier::getObjectType( aObjectCID ))), - m_xUndoManager, m_aModel->getModel() ); - - //------------------------------------------------------------- //convert properties to ItemSet awt::Size aPageSize( ChartModelHelper::getPageSize(m_aModel->getModel()) ); @@ -584,20 +765,20 @@ void SAL_CALL ChartController::executeDlg_ObjectProperties( const ::rtl::OUStrin ::std::auto_ptr< ReferenceSizeProvider > pRefSizeProv( impl_createReferenceSizeProvider()); ::std::auto_ptr< ::comphelper::ItemConverter > apItemConverter( - createItemConverter( aObjectCID, m_aModel->getModel(), m_xCC, + createItemConverter( rObjectCID, m_aModel->getModel(), m_xCC, m_pDrawModelWrapper->getSdrModel(), &aNumberFormatterWrapper, ExplicitValueProvider::getExplicitValueProvider(m_xChartView), pRefSizeProv )); if(!apItemConverter.get()) - return; + return bRet; SfxItemSet aItemSet = apItemConverter->CreateEmptyItemSet(); apItemConverter->FillItemSet( aItemSet ); //------------------------------------------------------------- //prepare dialog - ObjectPropertiesDialogParameter aDialogParameter = ObjectPropertiesDialogParameter( aObjectCID ); + ObjectPropertiesDialogParameter aDialogParameter = ObjectPropertiesDialogParameter( rObjectCID ); aDialogParameter.init( m_aModel->getModel() ); ViewElementListProvider aViewElementListProvider( m_pDrawModelWrapper.get() ); @@ -609,9 +790,9 @@ void SAL_CALL ChartController::executeDlg_ObjectProperties( const ::rtl::OUStrin { SfxItemSet* pSymbolShapeProperties=NULL; uno::Reference< beans::XPropertySet > xObjectProperties = - ObjectIdentifier::getObjectPropertySet( aObjectCID, m_aModel->getModel() ); + ObjectIdentifier::getObjectPropertySet( rObjectCID, m_aModel->getModel() ); wrapper::DataPointItemConverter aSymbolItemConverter( m_aModel->getModel(), m_xCC - , xObjectProperties, ObjectIdentifier::getDataSeriesForCID( aObjectCID, m_aModel->getModel() ) + , xObjectProperties, ObjectIdentifier::getDataSeriesForCID( rObjectCID, m_aModel->getModel() ) , m_pDrawModelWrapper->getSdrModel().GetItemPool() , m_pDrawModelWrapper->getSdrModel() , &aNumberFormatterWrapper @@ -629,24 +810,19 @@ void SAL_CALL ChartController::executeDlg_ObjectProperties( const ::rtl::OUStrin if( aDialogParameter.HasStatisticProperties() ) { aDlg.SetAxisMinorStepWidthForErrorBarDecimals( - InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( m_aModel->getModel(), m_xChartView, aObjectCID ) ); + InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( m_aModel->getModel(), m_xChartView, rObjectCID ) ); } //------------------------------------------------------------- //open the dialog - if( aDlg.Execute() == RET_OK ) + if( aDlg.Execute() == RET_OK || (bOkClickOnUnchangedDialogSouldBeRatedAsSuccessAlso && aDlg.DialogWasClosedWithOK()) ) { const SfxItemSet* pOutItemSet = aDlg.GetOutputItemSet(); if(pOutItemSet) { - bool bChanged = false; - { - ControllerLockGuard aCLGuard( m_aModel->getModel()); - bChanged = apItemConverter->ApplyItemSet( *pOutItemSet );//model should be changed now - } - - if( bChanged ) - aUndoGuard.commitAction(); + ControllerLockGuard aCLGuard( m_aModel->getModel()); + apItemConverter->ApplyItemSet( *pOutItemSet );//model should be changed now + bRet = true; } } } @@ -656,6 +832,7 @@ void SAL_CALL ChartController::executeDlg_ObjectProperties( const ::rtl::OUStrin catch( uno::RuntimeException& ) { } + return bRet; } void SAL_CALL ChartController::executeDispatch_View3D() diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx index fdbda4589abd..8dca62d93ee1 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -656,7 +656,7 @@ bool ChartController::executeDispatch_Delete() // using assignment for broken gcc 3.3 UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_ERROR_INDICATOR )))), + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_ERROR_BARS )))), m_xUndoManager, xModel ); { ControllerLockGuard aCtlLockGuard( xModel ); diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 2288bb602296..951bb127f117 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -51,9 +51,17 @@ #include "chartview/ExplicitValueProvider.hxx" #include "RelativePositionHelper.hxx" #include "chartview/DrawModelWrapper.hxx" +#include "RegressionCurveHelper.hxx" +#include "StatisticsHelper.hxx" +#include "DataSeriesHelper.hxx" +#include "ContainerHelper.hxx" +#include "AxisHelper.hxx" +#include "LegendHelper.hxx" +#include "servicenames_charttypes.hxx" #include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/chart2/RelativeSize.hpp> +#include <com/sun/star/chart2/XRegressionCurveContainer.hpp> #include <com/sun/star/frame/XDispatchHelper.hpp> #include <com/sun/star/frame/FrameSearchFlag.hpp> @@ -85,6 +93,13 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; +using ::com::sun::star::uno::Reference; +using ::rtl::OUString; + +//............................................................................. +namespace chart +{ +//............................................................................. namespace { @@ -138,13 +153,86 @@ void lcl_insertMenuCommand( xMenuEx->setCommand( nId, rCommand ); } -} // anonymous namespace +OUString lcl_getFormatCommandForObjectCID( const OUString& rCID ) +{ + OUString aDispatchCommand( C2U(".uno:FormatSelection") ); + ObjectType eObjectType = ObjectIdentifier::getObjectType( rCID ); -//............................................................................. -namespace chart -{ -//............................................................................. + switch(eObjectType) + { + case OBJECTTYPE_DIAGRAM: + case OBJECTTYPE_DIAGRAM_WALL: + aDispatchCommand = C2U(".uno:FormatWall"); + break; + case OBJECTTYPE_DIAGRAM_FLOOR: + aDispatchCommand = C2U(".uno:FormatFloor"); + break; + case OBJECTTYPE_PAGE: + aDispatchCommand = C2U(".uno:FormatChartArea"); + break; + case OBJECTTYPE_LEGEND: + aDispatchCommand = C2U(".uno:FormatLegend"); + break; + case OBJECTTYPE_TITLE: + aDispatchCommand = C2U(".uno:FormatTitle"); + break; + case OBJECTTYPE_LEGEND_ENTRY: + aDispatchCommand = C2U(".uno:FormatDataSeries"); + break; + case OBJECTTYPE_AXIS: + case OBJECTTYPE_AXIS_UNITLABEL: + aDispatchCommand = C2U(".uno:FormatAxis"); + break; + case OBJECTTYPE_GRID: + aDispatchCommand = C2U(".uno:FormatMajorGrid"); + break; + case OBJECTTYPE_SUBGRID: + aDispatchCommand = C2U(".uno:FormatMinorGrid"); + break; + case OBJECTTYPE_DATA_LABELS: + aDispatchCommand = C2U(".uno:FormatDataLabels"); + break; + case OBJECTTYPE_DATA_SERIES: + aDispatchCommand = C2U(".uno:FormatDataSeries"); + break; + case OBJECTTYPE_DATA_LABEL: + aDispatchCommand = C2U(".uno:FormatDataLabel"); + break; + case OBJECTTYPE_DATA_POINT: + aDispatchCommand = C2U(".uno:FormatDataPoint"); + break; + case OBJECTTYPE_DATA_AVERAGE_LINE: + aDispatchCommand = C2U(".uno:FormatMeanValue"); + break; + case OBJECTTYPE_DATA_ERRORS: + case OBJECTTYPE_DATA_ERRORS_X: + case OBJECTTYPE_DATA_ERRORS_Y: + case OBJECTTYPE_DATA_ERRORS_Z: + aDispatchCommand = C2U(".uno:FormatYErrorBars"); + break; + case OBJECTTYPE_DATA_CURVE: + aDispatchCommand = C2U(".uno:FormatTrendline"); + break; + case OBJECTTYPE_DATA_CURVE_EQUATION: + aDispatchCommand = C2U(".uno:FormatTrendlineEquation"); + break; + case OBJECTTYPE_DATA_STOCK_RANGE: + aDispatchCommand = C2U(".uno:FormatSelection"); + break; + case OBJECTTYPE_DATA_STOCK_LOSS: + aDispatchCommand = C2U(".uno:FormatStockLoss"); + break; + case OBJECTTYPE_DATA_STOCK_GAIN: + aDispatchCommand = C2U(".uno:FormatStockGain"); + break; + default: //OBJECTTYPE_UNKNOWN + break; + } + return aDispatchCommand; +} + +} // anonymous namespace const short HITPIX=2; //hit-tolerance in pixel @@ -830,36 +918,254 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) if( xPopupMenu.is() && xMenuEx.is()) { sal_Int16 nUniqueId = 1; - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DiagramObjects")); + ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ); + Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( m_aModel->getModel() ); + + OUString aFormatCommand( lcl_getFormatCommandForObjectCID( m_aSelection.getSelectedCID() ) ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, aFormatCommand ); + + //some commands for dataseries and points: + //----- + if( OBJECTTYPE_DATA_SERIES == eObjectType || OBJECTTYPE_DATA_POINT == eObjectType ) + { + bool bIsPoint = ( OBJECTTYPE_DATA_POINT == eObjectType ); + uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() ); + uno::Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, uno::UNO_QUERY ); + Reference< chart2::XRegressionCurve > xTrendline( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xCurveCnt ) ); + bool bHasEquation = RegressionCurveHelper::hasEquation( xTrendline ); + Reference< chart2::XRegressionCurve > xMeanValue( RegressionCurveHelper::getMeanValueLine( xCurveCnt ) ); + bool bHasYErrorBars = StatisticsHelper::hasErrorBars( xSeries, true ); + bool bHasDataLabelsAtSeries = DataSeriesHelper::hasDataLabelsAtSeries( xSeries ); + bool bHasDataLabelsAtPoints = DataSeriesHelper::hasDataLabelsAtPoints( xSeries ); + bool bHasDataLabelAtPoint = false; + sal_Int32 nPointIndex = -1; + if( bIsPoint ) + { + nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( m_aSelection.getSelectedCID() ); + bHasDataLabelAtPoint = DataSeriesHelper::hasDataLabelAtPoint( xSeries, nPointIndex ); + } + bool bSelectedPointIsFormatted = false; + bool bHasFormattedDataPointsOtherThanSelected = false; + + Reference< beans::XPropertySet > xSeriesProperties( xSeries, uno::UNO_QUERY ); + if( xSeriesProperties.is() ) + { + uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; + if( xSeriesProperties->getPropertyValue( C2U( "AttributedDataPoints" ) ) >>= aAttributedDataPointIndexList ) + { + if( aAttributedDataPointIndexList.hasElements() ) + { + if( bIsPoint ) + { + ::std::vector< sal_Int32 > aIndices( ContainerHelper::SequenceToVector( aAttributedDataPointIndexList ) ); + ::std::vector< sal_Int32 >::iterator aIt = ::std::find( aIndices.begin(), aIndices.end(), nPointIndex ); + if( aIt != aIndices.end()) + bSelectedPointIsFormatted = true; + else + bHasFormattedDataPointsOtherThanSelected = true; + } + else + bHasFormattedDataPointsOtherThanSelected = true; + } + } + } + + //const sal_Int32 nIdBeforeFormat = nUniqueId; + if( bIsPoint ) + { + if( bHasDataLabelAtPoint ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatDataLabel") ); + if( !bHasDataLabelAtPoint ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertDataLabel") ); + else + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteDataLabel") ); + if( bSelectedPointIsFormatted ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:ResetDataPoint")); + + xPopupMenu->insertSeparator( -1 ); + + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatDataSeries") ); + } + + Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); + if( xChartType->getChartType().equals(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) ) + { + try + { + Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY ); + if( xChartTypeProp.is() ) + { + bool bJapaneseStyle = false; + xChartTypeProp->getPropertyValue( C2U( "Japanese" ) ) >>= bJapaneseStyle; + + if( bJapaneseStyle ) + { + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockLoss") ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockGain") ); + } + } + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + + if( bHasDataLabelsAtSeries ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatDataLabels") ); + if( xTrendline.is() ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatTrendline") ); + if( bHasEquation ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatTrendlineEquation") ); + if( xMeanValue.is() ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatMeanValue") ); + if( bHasYErrorBars ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatYErrorBars") ); + + //if( nIdBeforeFormat != nUniqueId ) + xPopupMenu->insertSeparator( -1 ); + + //const sal_Int32 nIdBeforeInsert = nUniqueId; + + if( !bHasDataLabelsAtSeries ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertDataLabels") ); + if( !xTrendline.is() ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendline") ); + else if( !bHasEquation ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendlineEquation") ); + if( !xMeanValue.is() ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertMeanValue") ); + if( !bHasYErrorBars ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertYErrorBars") ); + + //if( nIdBeforeInsert != nUniqueId ) + // xPopupMenu->insertSeparator( -1 ); + + //const sal_Int32 nIdBeforeDelete = nUniqueId; + + if( bHasDataLabelsAtSeries || ( bHasDataLabelsAtPoints && bHasFormattedDataPointsOtherThanSelected ) ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteDataLabels") ); + if( xTrendline.is() ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteTrendline") ); + if( bHasEquation ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteTrendlineEquation") ); + if( xMeanValue.is() ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteMeanValue") ); + if( bHasYErrorBars ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteYErrorBars") ); + + if( bHasFormattedDataPointsOtherThanSelected ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:ResetAllDataPoints")); + + //if( nIdBeforeDelete != nUniqueId ) + xPopupMenu->insertSeparator( -1 ); + + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId, C2U(".uno:ArrangeRow")); + uno::Reference< awt::XPopupMenu > xArrangePopupMenu( + m_xCC->getServiceManager()->createInstanceWithContext( + C2U("com.sun.star.awt.PopupMenu"), m_xCC ), uno::UNO_QUERY ); + uno::Reference< awt::XMenuExtended > xArrangeMenuEx( xArrangePopupMenu, uno::UNO_QUERY ); + if( xArrangePopupMenu.is() && xArrangeMenuEx.is()) + { + sal_Int16 nSubId = nUniqueId + 1; + lcl_insertMenuCommand( xArrangePopupMenu, xArrangeMenuEx, nSubId++, C2U(".uno:Forward") ); + lcl_insertMenuCommand( xArrangePopupMenu, xArrangeMenuEx, nSubId, C2U(".uno:Backward") ); + xPopupMenu->setPopupMenu( nUniqueId, xArrangePopupMenu ); + nUniqueId = nSubId; + } + ++nUniqueId; + } + else if( OBJECTTYPE_DATA_CURVE == eObjectType ) + { + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatTrendlineEquation") ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendlineEquation") ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendlineEquationAndR2") ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertR2Value") ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteTrendlineEquation") ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteR2Value") ); + } + else if( OBJECTTYPE_DATA_CURVE_EQUATION == eObjectType ) + { + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertR2Value") ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteR2Value") ); + } + + //some commands for axes: and grids + //----- + else if( OBJECTTYPE_AXIS == eObjectType || OBJECTTYPE_GRID == eObjectType || OBJECTTYPE_SUBGRID == eObjectType ) + { + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() ); + if( xAxis.is() && xDiagram.is() ) + { + sal_Int32 nDimensionIndex = -1; + sal_Int32 nCooSysIndex = -1; + sal_Int32 nAxisIndex = -1; + AxisHelper::getIndicesForAxis( xAxis, xDiagram, nCooSysIndex, nDimensionIndex, nAxisIndex ); + bool bIsSecondaryAxis = nAxisIndex!=0; + bool bIsAxisVisible = AxisHelper::isAxisVisible( xAxis ); + bool bIsMajorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, true /*bMainGrid*/, xDiagram ); + bool bIsMinorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, false /*bMainGrid*/, xDiagram ); + bool bHasTitle = false; + uno::Reference< XTitled > xTitled( xAxis, uno::UNO_QUERY ); + if( xTitled.is()) + bHasTitle = TitleHelper::getCompleteString( xTitled->getTitleObject() ).getLength()>0; + + if( OBJECTTYPE_AXIS != eObjectType && bIsAxisVisible ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatAxis") ); + if( OBJECTTYPE_GRID != eObjectType && bIsMajorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatMajorGrid") ); + if( OBJECTTYPE_SUBGRID != eObjectType && bIsMinorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatMinorGrid") ); + + xPopupMenu->insertSeparator( -1 ); + + if( OBJECTTYPE_AXIS != eObjectType && !bIsAxisVisible ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertAxis") ); + if( OBJECTTYPE_GRID != eObjectType && !bIsMajorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertMajorGrid") ); + if( OBJECTTYPE_SUBGRID != eObjectType && !bIsMinorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertMinorGrid") ); + if( !bHasTitle ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertAxisTitle") ); + + if( bIsAxisVisible ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteAxis") ); + if( bIsMajorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteMajorGrid") ); + if( bIsMinorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteMinorGrid") ); + } + } + + if( OBJECTTYPE_DATA_STOCK_LOSS == eObjectType ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockGain") ); + else if( OBJECTTYPE_DATA_STOCK_GAIN == eObjectType ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockLoss") ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:TransformDialog")); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId, C2U(".uno:ArrangeRow")); - uno::Reference< awt::XPopupMenu > xArrangePopupMenu( - m_xCC->getServiceManager()->createInstanceWithContext( - C2U("com.sun.star.awt.PopupMenu"), m_xCC ), uno::UNO_QUERY ); - uno::Reference< awt::XMenuExtended > xArrangeMenuEx( xArrangePopupMenu, uno::UNO_QUERY ); - if( xArrangePopupMenu.is() && xArrangeMenuEx.is()) + + if( OBJECTTYPE_PAGE == eObjectType || OBJECTTYPE_DIAGRAM == eObjectType + || OBJECTTYPE_DIAGRAM_WALL == eObjectType + || OBJECTTYPE_DIAGRAM_FLOOR == eObjectType + || OBJECTTYPE_UNKNOWN == eObjectType ) { - sal_Int16 nSubId = nUniqueId + 1; - lcl_insertMenuCommand( xArrangePopupMenu, xArrangeMenuEx, nSubId++, C2U(".uno:Forward")); - lcl_insertMenuCommand( xArrangePopupMenu, xArrangeMenuEx, nSubId, C2U(".uno:Backward")); - xPopupMenu->setPopupMenu( nUniqueId, xArrangePopupMenu ); - nUniqueId = nSubId; + if( OBJECTTYPE_UNKNOWN != eObjectType ) + xPopupMenu->insertSeparator( -1 ); + bool bHasLegend = LegendHelper::hasLegend( xDiagram ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTitles") ); + if( !bHasLegend ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertLegend") ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertRemoveAxes") ); + if( bHasLegend ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteLegend") ); } - ++nUniqueId; + //----- + xPopupMenu->insertSeparator( -1 ); lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DiagramType")); lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DataRanges")); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:View3D")); - xPopupMenu->insertSeparator( -1 ); lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DiagramData")); - xPopupMenu->insertSeparator( -1 ); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertYErrorbar")); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteYErrorbar")); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertMeanValue")); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteMeanValue")); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendline")); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteTrendline")); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendlineEquation")); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:View3D")); xPopupMenu->insertSeparator( -1 ); lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:Cut")); lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:Copy")); diff --git a/chart2/source/controller/main/ControllerCommandDispatch.cxx b/chart2/source/controller/main/ControllerCommandDispatch.cxx index bde946fac5b6..d7e0514dee08 100644 --- a/chart2/source/controller/main/ControllerCommandDispatch.cxx +++ b/chart2/source/controller/main/ControllerCommandDispatch.cxx @@ -120,7 +120,7 @@ struct ControllerState // -- State variables ------- bool bHasSelectedObject; - bool bIsDraggableObject; + bool bIsPositionableObject; bool bIsTextObject; bool bIsDeleteableObjectSelected; bool bIsFormateableObjectSelected; @@ -133,18 +133,26 @@ struct ControllerState // trendlines bool bMayAddTrendline; bool bMayAddTrendlineEquation; + bool bMayAddR2Value; bool bMayAddMeanValue; bool bMayAddYErrorBars; bool bMayDeleteTrendline; + bool bMayDeleteTrendlineEquation; + bool bMayDeleteR2Value; bool bMayDeleteMeanValue; bool bMayDeleteYErrorBars; + + bool bMayFormatTrendline; + bool bMayFormatTrendlineEquation; + bool bMayFormatMeanValue; + bool bMayFormatYErrorBars; }; ControllerState::ControllerState() : bHasSelectedObject( false ), - bIsDraggableObject( false ), + bIsPositionableObject( false ), bIsTextObject(false), bIsDeleteableObjectSelected(false), bIsFormateableObjectSelected(false), @@ -152,11 +160,18 @@ ControllerState::ControllerState() : bMayMoveSeriesBackward( false ), bMayAddTrendline( false ), bMayAddTrendlineEquation( false ), + bMayAddR2Value( false ), bMayAddMeanValue( false ), bMayAddYErrorBars( false ), bMayDeleteTrendline( false ), + bMayDeleteTrendlineEquation( false ), + bMayDeleteR2Value( false ), bMayDeleteMeanValue( false ), - bMayDeleteYErrorBars( false ) + bMayDeleteYErrorBars( false ), + bMayFormatTrendline( false ), + bMayFormatTrendlineEquation( false ), + bMayFormatMeanValue( false ), + bMayFormatYErrorBars( false ) {} void ControllerState::update( @@ -175,9 +190,9 @@ void ControllerState::update( bHasSelectedObject = ((aSelObj >>= aSelObjCID) && aSelObjCID.getLength() > 0); - bIsDraggableObject = ObjectIdentifier::isDragableObject( aSelObjCID ); - ObjectType aObjectType(ObjectIdentifier::getObjectType( aSelObjCID )); + + bIsPositionableObject = (OBJECTTYPE_DATA_POINT != aObjectType) && ObjectIdentifier::isDragableObject( aSelObjCID ); bIsTextObject = OBJECTTYPE_TITLE == aObjectType; uno::Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel )); @@ -191,23 +206,30 @@ void ControllerState::update( bIsDeleteableObjectSelected = ChartController::isObjectDeleteable( aSelObj ); - bMayMoveSeriesForward = DiagramHelper::isSeriesMoveable( + bMayMoveSeriesForward = (OBJECTTYPE_DATA_POINT!=aObjectType) && DiagramHelper::isSeriesMoveable( ChartModelHelper::findDiagram( xModel ), xGivenDataSeries, MOVE_SERIES_FORWARD ); - bMayMoveSeriesBackward = DiagramHelper::isSeriesMoveable( + bMayMoveSeriesBackward = (OBJECTTYPE_DATA_POINT!=aObjectType) && DiagramHelper::isSeriesMoveable( ChartModelHelper::findDiagram( xModel ), xGivenDataSeries, MOVE_SERIES_BACKWARD ); bMayAddTrendline = false; bMayAddTrendlineEquation = false; + bMayAddR2Value = false; bMayAddMeanValue = false; bMayAddYErrorBars = false; bMayDeleteTrendline = false; + bMayDeleteTrendlineEquation = false; + bMayDeleteR2Value = false; bMayDeleteMeanValue = false; bMayDeleteYErrorBars = false; + bMayFormatTrendline = false; + bMayFormatTrendlineEquation = false; + bMayFormatMeanValue = false; + bMayFormatYErrorBars = false; if( bHasSelectedObject ) { if( xGivenDataSeries.is()) @@ -217,46 +239,63 @@ void ControllerState::update( DataSeriesHelper::getChartTypeOfSeries( xGivenDataSeries, xDiagram )); // trend lines/mean value line - if( ChartTypeHelper::isSupportingRegressionProperties( - xFirstChartType, nDimensionCount )) + if( (OBJECTTYPE_DATA_SERIES == aObjectType || OBJECTTYPE_DATA_POINT == aObjectType) + && ChartTypeHelper::isSupportingRegressionProperties( xFirstChartType, nDimensionCount )) { uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( xGivenDataSeries, uno::UNO_QUERY ); if( xRegCurveCnt.is()) { - bMayDeleteTrendline = RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ).is(); - bMayDeleteMeanValue = RegressionCurveHelper::hasMeanValueLine( xRegCurveCnt ); + uno::Reference< chart2::XRegressionCurve > xRegCurve( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ) ); + bMayFormatTrendline = bMayDeleteTrendline = xRegCurve.is(); + bMayFormatMeanValue = bMayDeleteMeanValue = RegressionCurveHelper::hasMeanValueLine( xRegCurveCnt ); bMayAddTrendline = ! bMayDeleteTrendline; bMayAddMeanValue = ! bMayDeleteMeanValue; + bMayFormatTrendlineEquation = bMayDeleteTrendlineEquation = RegressionCurveHelper::hasEquation( xRegCurve ); + bMayAddTrendlineEquation = !bMayDeleteTrendlineEquation; } } // error bars - if( ChartTypeHelper::isSupportingStatisticProperties( - xFirstChartType, nDimensionCount )) + if( (OBJECTTYPE_DATA_SERIES == aObjectType || OBJECTTYPE_DATA_POINT == aObjectType) + && ChartTypeHelper::isSupportingStatisticProperties( xFirstChartType, nDimensionCount )) { - bMayDeleteYErrorBars = StatisticsHelper::hasErrorBars( xGivenDataSeries ); + bMayFormatYErrorBars = bMayDeleteYErrorBars = StatisticsHelper::hasErrorBars( xGivenDataSeries ); bMayAddYErrorBars = ! bMayDeleteYErrorBars; } } + if( aObjectType == OBJECTTYPE_DATA_AVERAGE_LINE ) + bMayFormatMeanValue = true; + + if( aObjectType == OBJECTTYPE_DATA_ERRORS_Y || aObjectType == OBJECTTYPE_DATA_ERRORS ) + bMayFormatYErrorBars = true; + if( aObjectType == OBJECTTYPE_DATA_CURVE ) { + bMayFormatTrendline = true; uno::Reference< chart2::XRegressionCurve > xRegCurve( ObjectIdentifier::getObjectPropertySet( aSelObjCID, xModel ), uno::UNO_QUERY ); - if( xRegCurve.is()) + bMayFormatTrendlineEquation = bMayDeleteTrendlineEquation = RegressionCurveHelper::hasEquation( xRegCurve ); + bMayAddTrendlineEquation = !bMayDeleteTrendlineEquation; + } + else if( aObjectType == OBJECTTYPE_DATA_CURVE_EQUATION ) + { + bMayFormatTrendlineEquation = true; + bool bHasR2Value = false; + try { - uno::Reference< beans::XPropertySet > xEqProp( xRegCurve->getEquationProperties()); - bool bShowEq = false; - bool bShowCorr = false; + uno::Reference< beans::XPropertySet > xEqProp( + ObjectIdentifier::getObjectPropertySet( aSelObjCID, xModel ), uno::UNO_QUERY ); if( xEqProp.is()) - { - xEqProp->getPropertyValue( C2U("ShowEquation")) >>= bShowEq; - xEqProp->getPropertyValue( C2U("ShowCorrelationCoefficient")) >>= bShowCorr; - - bMayAddTrendlineEquation = ! (bShowEq || bShowCorr); - } + xEqProp->getPropertyValue( C2U("ShowCorrelationCoefficient") ) >>= bHasR2Value; } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } + bMayAddR2Value = !bHasR2Value; + bMayDeleteR2Value = bHasR2Value; } } } @@ -504,32 +543,52 @@ void ControllerCommandDispatch::updateCommandAvailability() m_aCommandAvailability[ C2U(".uno:DefaultColors")] = bIsWritable; m_aCommandAvailability[ C2U(".uno:BarWidth")] = bIsWritable; m_aCommandAvailability[ C2U(".uno:NumberOfLines")] = bIsWritable; - m_aCommandAvailability[ C2U(".uno:ArrangeRow")] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:ArrangeRow")] = m_apControllerState->bMayMoveSeriesForward || m_apControllerState->bMayMoveSeriesBackward; // insert objects - m_aCommandAvailability[ C2U(".uno:InsertTitle")] = bIsWritable; - m_aCommandAvailability[ C2U(".uno:InsertLegend")] = bIsWritable; - m_aCommandAvailability[ C2U(".uno:InsertDescription")] = bIsWritable; - m_aCommandAvailability[ C2U(".uno:InsertAxis")] = bIsWritable && m_apModelState->bSupportsAxes; - m_aCommandAvailability[ C2U(".uno:InsertGrids")] = bIsWritable && m_apModelState->bSupportsAxes; -// m_aCommandAvailability[ C2U(".uno:InsertStatistics")] = bIsWritable && m_apModelState->bSupportsStatistics; - m_aCommandAvailability[ C2U(".uno:InsertTrendlines")] = bIsWritable && m_apModelState->bSupportsStatistics; - m_aCommandAvailability[ C2U(".uno:InsertMeanValues")] = bIsWritable && m_apModelState->bSupportsStatistics; - m_aCommandAvailability[ C2U(".uno:InsertYErrorbars")] = bIsWritable && m_apModelState->bSupportsStatistics; + m_aCommandAvailability[ C2U(".uno:InsertTitles")] = m_aCommandAvailability[ C2U(".uno:InsertMenuTitles")] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:InsertLegend")] = m_aCommandAvailability[ C2U(".uno:InsertMenuLegend")] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:DeleteLegend")] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:InsertMenuDataLabels")] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:InsertRemoveAxes")] = m_aCommandAvailability[ C2U(".uno:InsertMenuAxes")] = bIsWritable && m_apModelState->bSupportsAxes; + m_aCommandAvailability[ C2U(".uno:InsertMenuGrids")] = bIsWritable && m_apModelState->bSupportsAxes; + m_aCommandAvailability[ C2U(".uno:InsertMenuTrendlines")] = bIsWritable && m_apModelState->bSupportsStatistics; + m_aCommandAvailability[ C2U(".uno:InsertMenuMeanValues")] = bIsWritable && m_apModelState->bSupportsStatistics; + m_aCommandAvailability[ C2U(".uno:InsertMenuYErrorBars")] = bIsWritable && m_apModelState->bSupportsStatistics; m_aCommandAvailability[ C2U(".uno:InsertSymbol")] = bIsWritable && m_apControllerState->bIsTextObject; // format objects - m_aCommandAvailability[ C2U(".uno:DiagramObjects")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bIsFormateableObjectSelected; + bool bFormatObjectAvailable = bIsWritable && bControllerStateIsValid && m_apControllerState->bIsFormateableObjectSelected; + m_aCommandAvailability[ C2U(".uno:FormatSelection")] = bFormatObjectAvailable; + m_aCommandAvailability[ C2U(".uno:FormatAxis")] = bFormatObjectAvailable; + m_aCommandAvailability[ C2U(".uno:FormatTitle")] = bFormatObjectAvailable; + m_aCommandAvailability[ C2U(".uno:FormatDataSeries")] = bFormatObjectAvailable; + m_aCommandAvailability[ C2U(".uno:FormatDataPoint")] = bFormatObjectAvailable; + m_aCommandAvailability[ C2U(".uno:FormatDataLabels")] = bFormatObjectAvailable; + m_aCommandAvailability[ C2U(".uno:FormatDataLabel")] = bFormatObjectAvailable; + m_aCommandAvailability[ C2U(".uno:FormatYErrorBars")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatYErrorBars; + m_aCommandAvailability[ C2U(".uno:FormatMeanValue")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatMeanValue; + m_aCommandAvailability[ C2U(".uno:FormatTrendline")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatTrendline; + m_aCommandAvailability[ C2U(".uno:FormatTrendlineEquation")] = bFormatObjectAvailable && bControllerStateIsValid && m_apControllerState->bMayFormatTrendlineEquation; + m_aCommandAvailability[ C2U(".uno:FormatStockLoss")] = bFormatObjectAvailable; + m_aCommandAvailability[ C2U(".uno:FormatStockGain")] = bFormatObjectAvailable; + m_aCommandAvailability[ C2U(".uno:DiagramType")] = bIsWritable; m_aCommandAvailability[ C2U(".uno:Legend")] = bIsWritable && m_apModelState->bHasLegend; m_aCommandAvailability[ C2U(".uno:DiagramWall")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasWall; m_aCommandAvailability[ C2U(".uno:DiagramArea")] = bIsWritable; - m_aCommandAvailability[ C2U(".uno:TransformDialog")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bHasSelectedObject && m_apControllerState->bIsDraggableObject; + m_aCommandAvailability[ C2U(".uno:TransformDialog")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bHasSelectedObject && m_apControllerState->bIsPositionableObject; // 3d commands m_aCommandAvailability[ C2U(".uno:View3D")] = bIsWritable && bModelStateIsValid && m_apModelState->bIsThreeD; m_aCommandAvailability[ C2U(".uno:DiagramFloor")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasFloor; + //some mor format commands with different ui text + m_aCommandAvailability[ C2U(".uno:FormatWall")] = m_aCommandAvailability[ C2U(".uno:DiagramWall")]; + m_aCommandAvailability[ C2U(".uno:FormatFloor")] = m_aCommandAvailability[ C2U(".uno:DiagramFloor")]; + m_aCommandAvailability[ C2U(".uno:FormatChartArea")] = m_aCommandAvailability[ C2U(".uno:DiagramArea")]; + m_aCommandAvailability[ C2U(".uno:FormatLegend")] = m_aCommandAvailability[ C2U(".uno:Legend")]; + // depending on own data m_aCommandAvailability[ C2U(".uno:DataRanges")] = bIsWritable && bModelStateIsValid && (! m_apModelState->bHasOwnData); m_aCommandAvailability[ C2U(".uno:DiagramData")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasOwnData; @@ -570,14 +629,36 @@ void ControllerCommandDispatch::updateCommandAvailability() m_aCommandAvailability[ C2U(".uno:Forward")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesForward; m_aCommandAvailability[ C2U(".uno:Backward")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesBackward; + m_aCommandAvailability[ C2U(".uno:InsertDataLabels")] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:InsertDataLabel")] = bIsWritable; m_aCommandAvailability[ C2U(".uno:InsertMeanValue")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddMeanValue; m_aCommandAvailability[ C2U(".uno:InsertTrendline")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddTrendline; m_aCommandAvailability[ C2U(".uno:InsertTrendlineEquation")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddTrendlineEquation; - m_aCommandAvailability[ C2U(".uno:InsertYErrorbar")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddYErrorBars; - - m_aCommandAvailability[ C2U(".uno:DeleteTrendline")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteTrendline; - m_aCommandAvailability[ C2U(".uno:DeleteMeanValue")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteMeanValue; - m_aCommandAvailability[ C2U(".uno:DeleteYErrorbar")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteYErrorBars; + m_aCommandAvailability[ C2U(".uno:InsertTrendlineEquationAndR2")] = m_aCommandAvailability[ C2U(".uno:InsertTrendlineEquation")]; + m_aCommandAvailability[ C2U(".uno:InsertR2Value")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddR2Value; + m_aCommandAvailability[ C2U(".uno:DeleteR2Value")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteR2Value; + + m_aCommandAvailability[ C2U(".uno:InsertYErrorBars")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddYErrorBars; + + m_aCommandAvailability[ C2U(".uno:DeleteDataLabels")] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:DeleteDataLabel") ] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:DeleteTrendline") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteTrendline; + m_aCommandAvailability[ C2U(".uno:DeleteTrendlineEquation") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteTrendlineEquation; + m_aCommandAvailability[ C2U(".uno:DeleteMeanValue") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteMeanValue; + m_aCommandAvailability[ C2U(".uno:DeleteYErrorBars") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteYErrorBars; + + m_aCommandAvailability[ C2U(".uno:ResetDataPoint") ] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:ResetAllDataPoints") ] = bIsWritable; + + m_aCommandAvailability[ C2U(".uno:InsertAxis") ] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:DeleteAxis") ] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:InsertAxisTitle") ] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:FormatMajorGrid") ] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:InsertMajorGrid") ] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:DeleteMajorGrid") ] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:FormatMinorGrid") ] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:InsertMinorGrid") ] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:DeleteMinorGrid") ] = bIsWritable; } bool ControllerCommandDispatch::commandAvailable( const OUString & rCommand ) @@ -593,11 +674,19 @@ void ControllerCommandDispatch::fireStatusEvent( const OUString & rURL, const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ ) { + bool bIsChartSelectorURL = rURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:ChartElementSelector") ); + if( rURL.getLength() == 0 || bIsChartSelectorURL ) + { + uno::Any aArg; + aArg <<= m_xController; + fireStatusEventForURL( C2U(".uno:ChartElementSelector"), aArg, true, xSingleListener ); + } + if( rURL.getLength() == 0 ) for( ::std::map< OUString, bool >::const_iterator aIt( m_aCommandAvailability.begin()); aIt != m_aCommandAvailability.end(); ++aIt ) fireStatusEventForURLImpl( aIt->first, xSingleListener ); - else + else if( !bIsChartSelectorURL ) fireStatusEventForURLImpl( rURL, xSingleListener ); // statusbar. Should be handled by base implementation diff --git a/chart2/source/controller/main/ElementSelector.cxx b/chart2/source/controller/main/ElementSelector.cxx new file mode 100644 index 000000000000..a79a256e3e4f --- /dev/null +++ b/chart2/source/controller/main/ElementSelector.cxx @@ -0,0 +1,328 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ElementSelector.cxx,v $ + * $Revision: 1.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "ElementSelector.hxx" +#include "macros.hxx" +#include "ObjectNameProvider.hxx" +#include "ObjectHierarchy.hxx" +#include "servicenames.hxx" +#include <chartview/ExplicitValueProvider.hxx> + +#include <toolkit/helper/vclunohelper.hxx> +#include <vos/mutex.hxx> +#include <vcl/svapp.hxx> + +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/frame/XControlNotificationListener.hpp> +#include <com/sun/star/util/XURLTransformer.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> + +namespace chart +{ + +using namespace com::sun::star; +using namespace com::sun::star::uno; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; + +namespace +{ +static const ::rtl::OUString lcl_aServiceName( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.ElementSelectorToolbarController" )); +} + +//------------------------------------------------------------------------------ + +SelectorListBox::SelectorListBox( Window* pParent, WinBits nStyle ) + : ListBox( pParent, nStyle ) + , m_bReleaseFocus( true ) +{ +} + +SelectorListBox::~SelectorListBox() +{ +} + +void lcl_addObjectsToList( const ObjectHierarchy& rHierarchy, const ObjectHierarchy::tCID & rParent, std::vector< ListBoxEntryData >& rEntries + , const sal_Int32 nHierarchyDepth, const Reference< chart2::XChartDocument >& xChartDoc ) +{ + ObjectHierarchy::tChildContainer aChildren( rHierarchy.getChildren(rParent) ); + ObjectHierarchy::tChildContainer::const_iterator aIt( aChildren.begin()); + while( aIt != aChildren.end() ) + { + ::rtl::OUString aCID = *aIt; + ListBoxEntryData aEntry; + aEntry.CID = aCID; + aEntry.UIName += ObjectNameProvider::getNameForCID( aCID, xChartDoc ); + aEntry.nHierarchyDepth = nHierarchyDepth; + rEntries.push_back(aEntry); + lcl_addObjectsToList( rHierarchy, aCID, rEntries, nHierarchyDepth+1, xChartDoc ); + ++aIt; + } +} + +void SelectorListBox::SetChartController( const Reference< frame::XController >& xChartController ) +{ + m_xChartController = xChartController; +} + +void SelectorListBox::UpdateChartElementsListAndSelection() +{ + Clear(); + m_aEntries.clear(); + + Reference< frame::XController > xChartController( m_xChartController ); + if( xChartController.is() ) + { + Reference< view::XSelectionSupplier > xSelectionSupplier( xChartController, uno::UNO_QUERY); + rtl::OUString aSelectedCID; + if( xSelectionSupplier.is() ) + xSelectionSupplier->getSelection() >>= aSelectedCID; + + Reference< chart2::XChartDocument > xChartDoc( xChartController->getModel(), uno::UNO_QUERY ); + ObjectType eType( ObjectIdentifier::getObjectType( aSelectedCID )); + bool bAddSelectionToList = false; + if( eType == OBJECTTYPE_DATA_POINT || eType == OBJECTTYPE_DATA_LABEL ) + bAddSelectionToList = true; + + Reference< uno::XInterface > xChartView; + Reference< lang::XMultiServiceFactory > xFact( xChartController->getModel(), uno::UNO_QUERY ); + if( xFact.is() ) + xChartView = xFact->createInstance( CHART_VIEW_SERVICE_NAME ); + ExplicitValueProvider* pExplicitValueProvider = 0;//ExplicitValueProvider::getExplicitValueProvider(xChartView); dies erzeugt alle sichtbaren datenpinkte, das ist zu viel + ObjectHierarchy aHierarchy( xChartDoc, pExplicitValueProvider, true /*bFlattenDiagram*/, true /*bOrderingForElementSelector*/ ); + lcl_addObjectsToList( aHierarchy, aHierarchy.getRootNodeCID(), m_aEntries, 0, xChartDoc ); + + std::vector< ListBoxEntryData >::iterator aIt( m_aEntries.begin() ); + if( bAddSelectionToList ) + { + rtl::OUString aSeriesCID = ObjectIdentifier::createClassifiedIdentifierForParticle( ObjectIdentifier::getSeriesParticleFromCID( aSelectedCID ) ); + for( aIt = m_aEntries.begin(); aIt != m_aEntries.end(); ++aIt ) + { + if( aIt->CID.match( aSeriesCID ) ) + { + ListBoxEntryData aEntry; + aEntry.UIName = ObjectNameProvider::getNameForCID( aSelectedCID, xChartDoc ); + aEntry.CID = aSelectedCID; + ++aIt; + if( aIt != m_aEntries.end() ) + m_aEntries.insert(aIt, aEntry); + else + m_aEntries.push_back( aEntry ); + break; + } + } + } + + USHORT nEntryPosToSelect = 0; bool bSelectionFound = false; + aIt = m_aEntries.begin(); + for( USHORT nN=0; aIt != m_aEntries.end(); ++aIt, ++nN ) + { + InsertEntry( aIt->UIName ); + if( !bSelectionFound && aSelectedCID.equals( aIt->CID ) ) + { + nEntryPosToSelect = nN; + bSelectionFound = true; + } + } + + if( bSelectionFound ) + SelectEntryPos(nEntryPosToSelect); + + USHORT nEntryCount = GetEntryCount(); + if( nEntryCount > 100 ) + nEntryCount = 100; + SetDropDownLineCount( nEntryCount ); + } + SaveValue();//remind current selection pos +} + +void SelectorListBox::ReleaseFocus_Impl() +{ + if ( !m_bReleaseFocus ) + { + m_bReleaseFocus = true; + return; + } + + Reference< frame::XController > xController( m_xChartController ); + Reference< frame::XFrame > xFrame( xController->getFrame() ); + if ( xFrame.is() && xFrame->getContainerWindow().is() ) + xFrame->getContainerWindow()->setFocus(); +} + +void SelectorListBox::Select() +{ + ListBox::Select(); + + if ( !IsTravelSelect() ) + { + USHORT nPos = GetSelectEntryPos(); + if( nPos < m_aEntries.size() ) + { + rtl::OUString aCID = m_aEntries[nPos].CID; + uno::Any aASelection( uno::makeAny(aCID) ); + Reference< view::XSelectionSupplier > xSelectionSupplier( m_xChartController.get(), uno::UNO_QUERY ); + if( xSelectionSupplier.is() ) + xSelectionSupplier->select(aASelection); + } + ReleaseFocus_Impl(); + } +} + +long SelectorListBox::Notify( NotifyEvent& rNEvt ) +{ + long nHandled = 0; + + if ( rNEvt.GetType() == EVENT_KEYINPUT ) + { + USHORT nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode(); + + switch ( nCode ) + { + case KEY_RETURN: + case KEY_TAB: + { + if ( KEY_TAB == nCode ) + m_bReleaseFocus = false; + else + nHandled = 1; + Select(); + break; + } + + case KEY_ESCAPE: + SelectEntryPos( GetSavedValue() ); //restore saved selection + ReleaseFocus_Impl(); + break; + } + } + else if ( EVENT_LOSEFOCUS == rNEvt.GetType() ) + { + if ( !HasFocus() ) + SelectEntryPos( GetSavedValue() ); + } + + return nHandled ? nHandled : ListBox::Notify( rNEvt ); +} + +Reference< ::com::sun::star::accessibility::XAccessible > SelectorListBox::CreateAccessible() +{ + UpdateChartElementsListAndSelection(); + return ListBox::CreateAccessible(); +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( ElementSelectorToolbarController, lcl_aServiceName ); + +//------------------------------------------------------------------------------ +Sequence< ::rtl::OUString > ElementSelectorToolbarController::getSupportedServiceNames_Static() +{ + Sequence< ::rtl::OUString > aServices(1); + aServices[ 0 ] = C2U( "com.sun.star.frame.ToolbarController" ); + return aServices; +} +// ----------------------------------------------------------------------------- +ElementSelectorToolbarController::ElementSelectorToolbarController( const uno::Reference< uno::XComponentContext > & xContext ) + : m_xCC( xContext ) +{ +} +// ----------------------------------------------------------------------------- +ElementSelectorToolbarController::~ElementSelectorToolbarController() +{ +} +// ----------------------------------------------------------------------------- +// XInterface +Any SAL_CALL ElementSelectorToolbarController::queryInterface( const Type& _rType ) throw (RuntimeException) +{ + Any aReturn = ToolboxController::queryInterface(_rType); + if (!aReturn.hasValue()) + aReturn = ElementSelectorToolbarController_BASE::queryInterface(_rType); + return aReturn; +} +// ----------------------------------------------------------------------------- +void SAL_CALL ElementSelectorToolbarController::acquire() throw () +{ + ToolboxController::acquire(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL ElementSelectorToolbarController::release() throw () +{ + ToolboxController::release(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL ElementSelectorToolbarController::initialize( const Sequence< Any >& rArguments ) throw (Exception, RuntimeException) +{ + ToolboxController::initialize(rArguments); +} +// ----------------------------------------------------------------------------- +void SAL_CALL ElementSelectorToolbarController::statusChanged( const frame::FeatureStateEvent& rEvent ) throw ( RuntimeException ) +{ + if( m_apSelectorListBox.get() ) + { + vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); + if( rEvent.FeatureURL.Path.equalsAscii( "ChartElementSelector" ) ) + { + Reference< frame::XController > xChartController; + rEvent.State >>= xChartController; + m_apSelectorListBox->SetChartController( xChartController ); + m_apSelectorListBox->UpdateChartElementsListAndSelection(); + } + } +} +// ----------------------------------------------------------------------------- +uno::Reference< awt::XWindow > SAL_CALL ElementSelectorToolbarController::createItemWindow( const uno::Reference< awt::XWindow >& xParent ) + throw (uno::RuntimeException) +{ + uno::Reference< awt::XWindow > xItemWindow; + if( !m_apSelectorListBox.get() ) + { + Window* pParent = VCLUnoHelper::GetWindow( xParent ); + if( pParent ) + { + m_apSelectorListBox = ::std::auto_ptr< SelectorListBox >( new SelectorListBox( pParent, WB_DROPDOWN|WB_AUTOHSCROLL|WB_BORDER ) ); + ::Size aLogicalSize( 95, 160 ); + ::Size aPixelSize = m_apSelectorListBox->LogicToPixel( aLogicalSize, MAP_APPFONT ); + m_apSelectorListBox->SetSizePixel( aPixelSize ); + m_apSelectorListBox->SetDropDownLineCount( 5 ); + } + } + if( m_apSelectorListBox.get() ) + xItemWindow = VCLUnoHelper::GetInterface( m_apSelectorListBox.get() ); + return xItemWindow; +} + +//.......................................................................... +} // chart2 +//.......................................................................... diff --git a/chart2/source/controller/main/ElementSelector.hxx b/chart2/source/controller/main/ElementSelector.hxx new file mode 100644 index 000000000000..3992745c9f02 --- /dev/null +++ b/chart2/source/controller/main/ElementSelector.hxx @@ -0,0 +1,125 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ElementSelector.hxx,v $ + * $Revision: 1.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART_ELEMENTSELECTOR_HXX +#define _CHART_ELEMENTSELECTOR_HXX + +#include "ServiceMacros.hxx" +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <cppuhelper/implbase1.hxx> +#include <svtools/toolboxcontroller.hxx> + +#include <vcl/lstbox.hxx> +#include <cppuhelper/weakref.hxx> + +#include <memory> + +//............................................................................. +namespace chart +{ +//............................................................................. + +struct ListBoxEntryData +{ + rtl::OUString UIName; + rtl::OUString CID; + sal_Int32 nHierarchyDepth; + + ListBoxEntryData() : nHierarchyDepth(0) + { + } +}; + +class SelectorListBox : public ListBox +{ + public: + SelectorListBox( Window* pParent, WinBits nStyle ); + virtual ~SelectorListBox(); + + virtual void Select(); + virtual long Notify( NotifyEvent& rNEvt ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); + + void ReleaseFocus_Impl(); + + void SetChartController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& xChartController ); + void UpdateChartElementsListAndSelection(); + + private: + ::com::sun::star::uno::WeakReference< + ::com::sun::star::frame::XController > m_xChartController; + + ::std::vector< ListBoxEntryData > m_aEntries; + + bool m_bReleaseFocus; +}; + +// ------------------------------------------------------------------ +// ------------------------------------------------------------------ + +typedef ::cppu::ImplHelper1 < ::com::sun::star::lang::XServiceInfo> ElementSelectorToolbarController_BASE; + +class ElementSelectorToolbarController : public ::svt::ToolboxController + , ElementSelectorToolbarController_BASE +{ +public: + ElementSelectorToolbarController( ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > const & xContext ); + virtual ~ElementSelectorToolbarController(); + + // XServiceInfo + APPHELPER_XSERVICEINFO_DECL() + APPHELPER_SERVICE_FACTORY_HELPER(ElementSelectorToolbarController) + + // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw ();
+ virtual void SAL_CALL release() throw ();
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ // XStatusListener
+ virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
+ // XToolbarController
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createItemWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& Parent ) throw (::com::sun::star::uno::RuntimeException);
+ +private: + //no default constructor + ElementSelectorToolbarController(){}
+
+private: + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xCC; + ::std::auto_ptr< SelectorListBox > m_apSelectorListBox; +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/main/ObjectHierarchy.cxx b/chart2/source/controller/main/ObjectHierarchy.cxx index 67297197cacc..5912847e4bfe 100644 --- a/chart2/source/controller/main/ObjectHierarchy.cxx +++ b/chart2/source/controller/main/ObjectHierarchy.cxx @@ -41,6 +41,8 @@ #include "macros.hxx" #include "LineProperties.hxx" #include "ChartTypeHelper.hxx" +#include "DataSeriesHelper.hxx" +#include "LegendHelper.hxx" #include <map> #include <algorithm> @@ -109,6 +111,18 @@ void lcl_getChildCIDs( } } +void lcl_addAxisTitle( const Reference< XAxis >& xAxis, ::chart::ObjectHierarchy::tChildContainer& rContainer, const Reference< frame::XModel >& xChartModel ) +{ + Reference< XTitled > xAxisTitled( xAxis, uno::UNO_QUERY ); + if( xAxisTitled.is()) + { + Reference< XTitle > xAxisTitle( xAxisTitled->getTitleObject()); + if( xAxisTitle.is()) + rContainer.push_back( + ::chart::ObjectIdentifier::createClassifiedIdentifierForObject( xAxisTitle, xChartModel )); + } +} + } // anonymous namespace @@ -123,7 +137,7 @@ public: explicit ImplObjectHierarchy( const Reference< XChartDocument > & xChartDocument, ExplicitValueProvider * pExplicitValueProvider, - bool bFlattenDiagram ); + bool bFlattenDiagram, bool bOrderingForElementSelector ); bool hasChildren( const OUString & rParent ); ObjectHierarchy::tChildContainer getChildren( const OUString & rParent ); @@ -133,13 +147,25 @@ public: private: void createTree( const Reference< XChartDocument > & xChartDocument ); + void createAxesTree( + ObjectHierarchy::tChildContainer & rContainer, + const Reference< XChartDocument > & xChartDoc, + const Reference< XDiagram > & xDiagram ); void createDiagramTree( ObjectHierarchy::tChildContainer & rContainer, const Reference< XChartDocument > & xChartDoc, const Reference< XDiagram > & xDiagram ); void createDataSeriesTree( ObjectHierarchy::tChildContainer & rOutDiagramSubContainer, - const Reference< XCoordinateSystemContainer > & xCooSysCnt ); + const Reference< XDiagram > & xDiagram ); + void createWallAndFloor( + ObjectHierarchy::tChildContainer & rContainer, + const Reference< XDiagram > & xDiagram ); + void createLegendTree( + ObjectHierarchy::tChildContainer & rContainer, + const Reference< XChartDocument > & xChartDoc, + const Reference< XDiagram > & xDiagram ); + ObjectHierarchy::tCID getParentImpl( const ObjectHierarchy::tCID & rParentCID, const ObjectHierarchy::tCID & rCID ); @@ -149,14 +175,17 @@ private: tChildMap m_aChildMap; ExplicitValueProvider * m_pExplicitValueProvider; bool m_bFlattenDiagram; + bool m_bOrderingForElementSelector; }; ImplObjectHierarchy::ImplObjectHierarchy( const Reference< XChartDocument > & xChartDocument, ExplicitValueProvider * pExplicitValueProvider, - bool bFlattenDiagram ) : + bool bFlattenDiagram, + bool bOrderingForElementSelector ) : m_pExplicitValueProvider( pExplicitValueProvider ), - m_bFlattenDiagram( bFlattenDiagram ) + m_bFlattenDiagram( bFlattenDiagram ), + m_bOrderingForElementSelector( bOrderingForElementSelector ) { createTree( xChartDocument ); // don't remember this helper to avoid access after lifetime @@ -170,10 +199,21 @@ void ImplObjectHierarchy::createTree( const Reference< XChartDocument > & xChart //@todo: change ObjectIdentifier to take an XChartDocument rather than XModel Reference< frame::XModel > xModel( xChartDocument, uno::UNO_QUERY ); + Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartDocument ) ); + OUString aDiaCID( ObjectIdentifier::createClassifiedIdentifierForObject( xDiagram, xModel )); ObjectHierarchy::tChildContainer aTopLevelContainer; // First Level + // Chart Area + if( m_bOrderingForElementSelector ) + { + aTopLevelContainer.push_back( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, OUString() ) ); + aTopLevelContainer.push_back( aDiaCID ); + createWallAndFloor( aTopLevelContainer, xDiagram ); + createLegendTree( aTopLevelContainer, xChartDocument, xDiagram ); + } + // Main Title Reference< XTitled > xDocTitled( xChartDocument, uno::UNO_QUERY ); if( xDocTitled.is()) @@ -184,7 +224,6 @@ void ImplObjectHierarchy::createTree( const Reference< XChartDocument > & xChart ObjectIdentifier::createClassifiedIdentifierForObject( xMainTitle, xModel )); } - Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartDocument )); if( xDiagram.is()) { // Sub Title. Note: This is interpreted of being top level @@ -197,24 +236,17 @@ void ImplObjectHierarchy::createTree( const Reference< XChartDocument > & xChart ObjectIdentifier::createClassifiedIdentifierForObject( xSubTitle, xModel )); } - // Axis Titles. Note: These are interpreted of being top level - Sequence< Reference< XAxis > > aAxes( AxisHelper::getAllAxesOfDiagram( xDiagram ) ); - for( sal_Int32 i=0; i<aAxes.getLength(); ++i ) + if( !m_bOrderingForElementSelector ) { - Reference< XTitled > xAxisTitled( aAxes[i], uno::UNO_QUERY ); - if( xAxisTitled.is()) - { - Reference< XTitle > xAxisTitle( xAxisTitled->getTitleObject()); - if( xAxisTitle.is()) - aTopLevelContainer.push_back( - ObjectIdentifier::createClassifiedIdentifierForObject( xAxisTitle, xModel )); - } + // Axis Titles. Note: These are interpreted of being top level + Sequence< Reference< XAxis > > aAxes( AxisHelper::getAllAxesOfDiagram( xDiagram ) ); + for( sal_Int32 i=0; i<aAxes.getLength(); ++i ) + lcl_addAxisTitle( aAxes[i], aTopLevelContainer, xModel ); + + // Diagram + aTopLevelContainer.push_back( aDiaCID ); } - // Diagram - OUString aDiaCID( ObjectIdentifier::createClassifiedIdentifierForObject( xDiagram, xModel )); - OSL_ASSERT( aDiaCID.getLength()); - aTopLevelContainer.push_back( aDiaCID ); if( m_bFlattenDiagram ) createDiagramTree( aTopLevelContainer, xChartDocument, xDiagram ); else @@ -225,61 +257,56 @@ void ImplObjectHierarchy::createTree( const Reference< XChartDocument > & xChart m_aChildMap[ aDiaCID ] = aSubContainer; } - - // Legend. Note: This is interpreted of being top level - Reference< XLegend > xLegend( xDiagram->getLegend()); - if( xLegend.is()) - { - Reference< beans::XPropertySet > xLegendProp( xLegend, uno::UNO_QUERY ); - bool bShow = false; - if( xLegendProp.is() && - (xLegendProp->getPropertyValue( C2U("Show")) >>= bShow) && - bShow ) - { - OUString aLegendCID( ObjectIdentifier::createClassifiedIdentifierForObject( xLegend, xModel )); - aTopLevelContainer.push_back( aLegendCID ); - - // iterate over child shapes of legend and search for matching CIDs - if( m_pExplicitValueProvider ) - { - Reference< container::XIndexAccess > xLegendShapeContainer( - m_pExplicitValueProvider->getShapeForCID( aLegendCID ), uno::UNO_QUERY ); - ObjectHierarchy::tChildContainer aLegendEntryCIDs; - lcl_getChildCIDs( aLegendEntryCIDs, xLegendShapeContainer ); - - m_aChildMap[ aLegendCID ] = aLegendEntryCIDs; - } - } - } + if( !m_bOrderingForElementSelector ) + createLegendTree( aTopLevelContainer, xChartDocument, xDiagram ); } // Chart Area - aTopLevelContainer.push_back( - ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, OUString() ) ); + if( !m_bOrderingForElementSelector ) + aTopLevelContainer.push_back( + ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, OUString() ) ); if( ! aTopLevelContainer.empty()) m_aChildMap[ ObjectHierarchy::getRootNodeCID() ] = aTopLevelContainer; } -void ImplObjectHierarchy::createDiagramTree( +void ImplObjectHierarchy::createLegendTree( ObjectHierarchy::tChildContainer & rContainer, const Reference< XChartDocument > & xChartDoc, - const Reference< XDiagram > & xDiagram ) + const Reference< XDiagram > & xDiagram ) { - // Data Series - Reference< XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW ); - createDataSeriesTree( rContainer, xCooSysCnt ); + if( xDiagram.is() && LegendHelper::hasLegend( xDiagram ) ) + { + OUString aLegendCID( ObjectIdentifier::createClassifiedIdentifierForObject( xDiagram->getLegend(), Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ) )); + rContainer.push_back( aLegendCID ); + + // iterate over child shapes of legend and search for matching CIDs + if( m_pExplicitValueProvider ) + { + Reference< container::XIndexAccess > xLegendShapeContainer( + m_pExplicitValueProvider->getShapeForCID( aLegendCID ), uno::UNO_QUERY ); + ObjectHierarchy::tChildContainer aLegendEntryCIDs; + lcl_getChildCIDs( aLegendEntryCIDs, xLegendShapeContainer ); - // Axes + m_aChildMap[ aLegendCID ] = aLegendEntryCIDs; + } + } +} + +void ImplObjectHierarchy::createAxesTree( + ObjectHierarchy::tChildContainer & rContainer, + const Reference< XChartDocument > & xChartDoc, + const Reference< XDiagram > & xDiagram ) +{ + Reference< XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW ); sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); uno::Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); bool bSupportsAxesGrids = ChartTypeHelper::isSupportingMainAxis( xChartType, nDimensionCount, 0 ); - bool bIsThreeD = ( nDimensionCount == 3 ); - bool bHasWall = DiagramHelper::isSupportingFloorAndWall( xDiagram ); if( bSupportsAxesGrids ) { Sequence< Reference< XAxis > > aAxes( AxisHelper::getAllAxesOfDiagram( xDiagram, /* bOnlyVisible = */ true ) ); - ::std::transform( aAxes.getConstArray(), aAxes.getConstArray() + aAxes.getLength(), + if( !m_bOrderingForElementSelector ) + ::std::transform( aAxes.getConstArray(), aAxes.getConstArray() + aAxes.getLength(), ::std::back_inserter( rContainer ), lcl_ObjectToCID( xChartDoc )); @@ -293,6 +320,24 @@ void ImplObjectHierarchy::createDiagramTree( if(!xAxis.is()) continue; + sal_Int32 nCooSysIndex = 0; + sal_Int32 nDimensionIndex = 0; + sal_Int32 nAxisIndex = 0; + AxisHelper::getIndicesForAxis( xAxis, xDiagram, nCooSysIndex, nDimensionIndex, nAxisIndex ); + if( nAxisIndex>0 && !ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimensionCount, nDimensionIndex ) ) + continue; + + if( m_bOrderingForElementSelector ) + { + // axis + if( AxisHelper::isAxisVisible( xAxis ) ) + rContainer.push_back( + ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, xChartModel ) ); + + // axis title + lcl_addAxisTitle( aAxes[nA], rContainer, xChartModel ); + } + Reference< beans::XPropertySet > xGridProperties( xAxis->getGridProperties() ); if( AxisHelper::isGridVisible( xGridProperties ) ) { @@ -315,31 +360,56 @@ void ImplObjectHierarchy::createDiagramTree( } } } +} - // Wall - if( bHasWall ) +void ImplObjectHierarchy::createWallAndFloor( + ObjectHierarchy::tChildContainer & rContainer, + const Reference< XDiagram > & xDiagram ) +{ + sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); + bool bIsThreeD = ( nDimensionCount == 3 ); + bool bHasWall = DiagramHelper::isSupportingFloorAndWall( xDiagram ); + if( bHasWall && bIsThreeD ) { rContainer.push_back( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, rtl::OUString())); - } - // Floor - if( bHasWall && bIsThreeD ) - { Reference< beans::XPropertySet > xFloor( xDiagram->getFloor()); if( xFloor.is()) rContainer.push_back( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_FLOOR, rtl::OUString())); } + +} + +void ImplObjectHierarchy::createDiagramTree( + ObjectHierarchy::tChildContainer & rContainer, + const Reference< XChartDocument > & xChartDoc, + const Reference< XDiagram > & xDiagram ) +{ + if( !m_bOrderingForElementSelector ) + { + createDataSeriesTree( rContainer, xDiagram ); + createAxesTree( rContainer, xChartDoc, xDiagram ); + createWallAndFloor( rContainer, xDiagram ); + } + else + { + createAxesTree( rContainer, xChartDoc, xDiagram ); + createDataSeriesTree( rContainer, xDiagram ); + } } void ImplObjectHierarchy::createDataSeriesTree( ObjectHierarchy::tChildContainer & rOutDiagramSubContainer, - const Reference< XCoordinateSystemContainer > & xCooSysCnt ) + const Reference< XDiagram > & xDiagram ) { + Reference< XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW ); + try { sal_Int32 nDiagramIndex = 0; + sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); Sequence< Reference< XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx ) @@ -348,10 +418,11 @@ void ImplObjectHierarchy::createDataSeriesTree( Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes()); for( sal_Int32 nCTIdx=0; nCTIdx<aChartTypeSeq.getLength(); ++nCTIdx ) { - Reference< XDataSeriesContainer > xDSCnt( aChartTypeSeq[nCTIdx], uno::UNO_QUERY_THROW ); + Reference< XChartType > xChartType( aChartTypeSeq[nCTIdx] ); + Reference< XDataSeriesContainer > xDSCnt( xChartType, uno::UNO_QUERY_THROW ); Sequence< Reference< XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries() ); const sal_Int32 nNumberOfSeries = - ChartTypeHelper::getNumberOfDisplayedSeries( aChartTypeSeq[nCTIdx], aSeriesSeq.getLength()); + ChartTypeHelper::getNumberOfDisplayedSeries( xChartType, aSeriesSeq.getLength()); for( sal_Int32 nSeriesIdx=0; nSeriesIdx<nNumberOfSeries; ++nSeriesIdx ) { @@ -364,41 +435,49 @@ void ImplObjectHierarchy::createDataSeriesTree( ObjectHierarchy::tChildContainer aSeriesSubContainer; + Reference< chart2::XDataSeries > xSeries( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY ); + + // data lablels + if( DataSeriesHelper::hasDataLabelsAtSeries( xSeries ) ) + { + rtl::OUString aChildParticle( ObjectIdentifier::getStringForType( OBJECTTYPE_DATA_LABELS ) ); + aChildParticle+=(C2U("=")); + aSeriesSubContainer.push_back( + ObjectIdentifier::createClassifiedIdentifierForParticles( aSeriesParticle, aChildParticle )); + } + // Statistics - Reference< chart2::XRegressionCurveContainer > xCurveCnt( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY ); - if( xCurveCnt.is()) + if( ChartTypeHelper::isSupportingStatisticProperties( xChartType, nDimensionCount ) ) { - Sequence< Reference< chart2::XRegressionCurve > > aCurves( xCurveCnt->getRegressionCurves()); - for( sal_Int32 nCurveIdx=0; nCurveIdx<aCurves.getLength(); ++nCurveIdx ) + Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, uno::UNO_QUERY ); + if( xCurveCnt.is()) { - bool bIsAverageLine = RegressionCurveHelper::isMeanValueLine( aCurves[nCurveIdx] ); - aSeriesSubContainer.push_back( - ObjectIdentifier::createDataCurveCID( aSeriesParticle, nCurveIdx, bIsAverageLine )); - Reference< beans::XPropertySet > xEqProp( aCurves[nCurveIdx]->getEquationProperties()); - bool bShowEq = false; - bool bShowCoeff = false; - if( xEqProp.is() && - ( (xEqProp->getPropertyValue( C2U("ShowEquation")) >>= bShowEq) || - (xEqProp->getPropertyValue( C2U("ShowCorrelationCoefficient")) >>= bShowCoeff) ) && - ( bShowEq || bShowCoeff ) ) + Sequence< Reference< chart2::XRegressionCurve > > aCurves( xCurveCnt->getRegressionCurves()); + for( sal_Int32 nCurveIdx=0; nCurveIdx<aCurves.getLength(); ++nCurveIdx ) { + bool bIsAverageLine = RegressionCurveHelper::isMeanValueLine( aCurves[nCurveIdx] ); aSeriesSubContainer.push_back( - ObjectIdentifier::createDataCurveEquationCID( aSeriesParticle, nCurveIdx )); + ObjectIdentifier::createDataCurveCID( aSeriesParticle, nCurveIdx, bIsAverageLine )); + if( RegressionCurveHelper::hasEquation( aCurves[nCurveIdx] ) ) + { + aSeriesSubContainer.push_back( + ObjectIdentifier::createDataCurveEquationCID( aSeriesParticle, nCurveIdx )); + } } - } - Reference< beans::XPropertySet > xSeriesProp( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY ); - Reference< beans::XPropertySet > xErrorBarProp; - if( xSeriesProp.is() && - (xSeriesProp->getPropertyValue( C2U("ErrorBarY")) >>= xErrorBarProp) && - xErrorBarProp.is()) - { - sal_Int32 nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE; - if( ( xErrorBarProp->getPropertyValue( C2U("ErrorBarStyle")) >>= nStyle ) && - ( nStyle != ::com::sun::star::chart::ErrorBarStyle::NONE ) ) + Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY ); + Reference< beans::XPropertySet > xErrorBarProp; + if( xSeriesProp.is() && + (xSeriesProp->getPropertyValue( C2U("ErrorBarY")) >>= xErrorBarProp) && + xErrorBarProp.is()) { - aSeriesSubContainer.push_back( - ObjectIdentifier::createClassifiedIdentifierWithParent( - OBJECTTYPE_DATA_ERRORS, OUString(), aSeriesParticle )); + sal_Int32 nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE; + if( ( xErrorBarProp->getPropertyValue( C2U("ErrorBarStyle")) >>= nStyle ) && + ( nStyle != ::com::sun::star::chart::ErrorBarStyle::NONE ) ) + { + aSeriesSubContainer.push_back( + ObjectIdentifier::createClassifiedIdentifierWithParent( + OBJECTTYPE_DATA_ERRORS, OUString(), aSeriesParticle )); + } } } } @@ -500,8 +579,9 @@ ObjectHierarchy::tCID ImplObjectHierarchy::getParent( ObjectHierarchy::ObjectHierarchy( const Reference< XChartDocument > & xChartDocument, ExplicitValueProvider * pExplicitValueProvider /* = 0 */, - bool bFlattenDiagram /* = false */ ) : - m_apImpl( new impl::ImplObjectHierarchy( xChartDocument, pExplicitValueProvider, bFlattenDiagram )) + bool bFlattenDiagram /* = false */, + bool bOrderingForElementSelector /* = false */) : + m_apImpl( new impl::ImplObjectHierarchy( xChartDocument, pExplicitValueProvider, bFlattenDiagram, bOrderingForElementSelector )) {} ObjectHierarchy::~ObjectHierarchy() diff --git a/chart2/source/controller/main/_serviceregistration_controller.cxx b/chart2/source/controller/main/_serviceregistration_controller.cxx index 7507aa9dd0cf..7de2e8fa8588 100644 --- a/chart2/source/controller/main/_serviceregistration_controller.cxx +++ b/chart2/source/controller/main/_serviceregistration_controller.cxx @@ -36,6 +36,7 @@ #include "dlg_ChartType_UNO.hxx" #include "ChartDocumentWrapper.hxx" #include "AccessibleChartView.hxx" +#include "ElementSelector.hxx" #include <cppuhelper/implementationentry.hxx> static struct ::cppu::ImplementationEntry g_entries_chart2_controller[] = @@ -88,6 +89,14 @@ static struct ::cppu::ImplementationEntry g_entries_chart2_controller[] = , 0 , 0 } + ,{ + ::chart::ElementSelectorToolbarController::create + , ::chart::ElementSelectorToolbarController::getImplementationName_Static + , ::chart::ElementSelectorToolbarController::getSupportedServiceNames_Static + , ::cppu::createSingleComponentFactory + , 0 + , 0 + } ,{ 0, 0, 0, 0, 0, 0 } }; diff --git a/chart2/source/controller/main/makefile.mk b/chart2/source/controller/main/makefile.mk index 6ee09d8c7c72..5d0ecadc0ae0 100644 --- a/chart2/source/controller/main/makefile.mk +++ b/chart2/source/controller/main/makefile.mk @@ -46,6 +46,7 @@ VISIBILITY_HIDDEN=TRUE #object files to build and link together to lib $(SLB)$/$(TARGET).lib SLOFILES = \ $(SLO)$/ConfigurationAccess.obj \ + $(SLO)$/ElementSelector.obj \ $(SLO)$/SelectionHelper.obj \ $(SLO)$/PositionAndSizeHelper.obj \ $(SLO)$/ChartWindow.obj \ |