diff --git a/chart2/source/controller/dialogs/ObjectNameProvider.cxx b/chart2/source/controller/dialogs/ObjectNameProvider.cxx index 1ed974814ea7..24b717adba7f 100644 --- a/chart2/source/controller/dialogs/ObjectNameProvider.cxx +++ b/chart2/source/controller/dialogs/ObjectNameProvider.cxx @@ -87,6 +87,16 @@ OUString lcl_getDataSeriesName( const rtl::OUString& rObjectCID, const Reference return aRet; } +OUString lcl_getFullSeriesName( const rtl::OUString& rObjectCID, const Reference< frame::XModel >& xChartModel ) +{ + OUString aRet = String(SchResId(STR_TIP_DATASERIES)); + OUString aWildcard( C2U("%SERIESNAME") ); + sal_Int32 nIndex = aRet.indexOf( aWildcard ); + if( nIndex != -1 ) + aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), lcl_getDataSeriesName( rObjectCID, xChartModel ) ); + return aRet; +} + void lcl_addText( OUString& rOut, const OUString& rSeparator, const OUString& rNext ) { if( rOut.getLength() && rNext.getLength() ) @@ -288,22 +298,27 @@ rtl::OUString ObjectNameProvider::getName( ObjectType eObjectType, bool bPlural aRet=String(SchResId(STR_OBJECT_LABEL)); break; case OBJECTTYPE_DATA_ERRORS: - aRet=String(SchResId(STR_OBJECT_ERROR_INDICATOR));//@todo? maybe distinguish plural singular + aRet=String(SchResId(STR_OBJECT_ERROR_BARS));//@todo? maybe distinguish plural singular break; case OBJECTTYPE_DATA_ERRORS_X: - aRet=String(SchResId(STR_OBJECT_ERROR_INDICATOR));//@todo? maybe specialize in future + aRet=String(SchResId(STR_OBJECT_ERROR_BARS));//@todo? maybe specialize in future break; case OBJECTTYPE_DATA_ERRORS_Y: - aRet=String(SchResId(STR_OBJECT_ERROR_INDICATOR));//@todo? maybe specialize in future + aRet=String(SchResId(STR_OBJECT_ERROR_BARS));//@todo? maybe specialize in future break; case OBJECTTYPE_DATA_ERRORS_Z: - aRet=String(SchResId(STR_OBJECT_ERROR_INDICATOR));//@todo? maybe specialize in future + aRet=String(SchResId(STR_OBJECT_ERROR_BARS));//@todo? maybe specialize in future break; case OBJECTTYPE_DATA_AVERAGE_LINE: aRet=String(SchResId(STR_OBJECT_AVERAGE_LINE)); break; case OBJECTTYPE_DATA_CURVE: - aRet=String(SchResId(STR_OBJECT_CURVE)); + { + if(bPlural) + aRet=String(SchResId(STR_OBJECT_CURVES)); + else + aRet=String(SchResId(STR_OBJECT_CURVE)); + } break; case OBJECTTYPE_DATA_STOCK_RANGE: //aRet=String(SchResId()); @@ -333,15 +348,24 @@ rtl::OUString ObjectNameProvider::getAxisName( const rtl::OUString& rObjectCID Reference< XAxis > xAxis( ObjectIdentifier::getObjectPropertySet( rObjectCID , xChartModel ), uno::UNO_QUERY ); - sal_Int32 nDimensionIndex = AxisHelper::getDimensionIndexOfAxis( xAxis, ChartModelHelper::findDiagram( xChartModel ) ); + sal_Int32 nCooSysIndex = 0; + sal_Int32 nDimensionIndex = 0; + sal_Int32 nAxisIndex = 0; + AxisHelper::getIndicesForAxis( xAxis, ChartModelHelper::findDiagram( xChartModel ), nCooSysIndex, nDimensionIndex, nAxisIndex ); switch(nDimensionIndex) { case 0://x-axis - aRet=String(SchResId(STR_OBJECT_AXIS_X)); + if( nAxisIndex == 0 ) + aRet=String(SchResId(STR_OBJECT_AXIS_X)); + else + aRet=String(SchResId(STR_OBJECT_SECONDARY_X_AXIS)); break; case 1://y-axis - aRet=String(SchResId(STR_OBJECT_AXIS_Y)); + if( nAxisIndex == 0 ) + aRet=String(SchResId(STR_OBJECT_AXIS_Y)); + else + aRet=String(SchResId(STR_OBJECT_SECONDARY_Y_AXIS)); break; case 2://z-axis aRet=String(SchResId(STR_OBJECT_AXIS_Z)); @@ -354,6 +378,45 @@ rtl::OUString ObjectNameProvider::getAxisName( const rtl::OUString& rObjectCID return aRet; } +//static +OUString ObjectNameProvider::getTitleNameByType( TitleHelper::eTitleType eType ) +{ + OUString aRet; + + switch(eType) + { + case TitleHelper::MAIN_TITLE: + aRet=String(SchResId(STR_OBJECT_TITLE_MAIN)); + break; + case TitleHelper::SUB_TITLE: + aRet=String(SchResId(STR_OBJECT_TITLE_SUB)); + break; + case TitleHelper::X_AXIS_TITLE: + aRet=String(SchResId(STR_OBJECT_TITLE_X_AXIS)); + break; + case TitleHelper::Y_AXIS_TITLE: + aRet=String(SchResId(STR_OBJECT_TITLE_Y_AXIS)); + break; + case TitleHelper::Z_AXIS_TITLE: + aRet=String(SchResId(STR_OBJECT_TITLE_Z_AXIS)); + break; + case TitleHelper::SECONDARY_X_AXIS_TITLE: + aRet=String(SchResId(STR_OBJECT_TITLE_SECONDARY_X_AXIS)); + break; + case TitleHelper::SECONDARY_Y_AXIS_TITLE: + aRet=String(SchResId(STR_OBJECT_TITLE_SECONDARY_Y_AXIS)); + break; + default: + DBG_ERROR("unknown title type"); + break; + } + + if( !aRet.getLength() ) + aRet=String(SchResId(STR_OBJECT_TITLE)); + + return aRet; +} + //static OUString ObjectNameProvider::getTitleName( const OUString& rObjectCID , const Reference< frame::XModel >& xChartModel ) @@ -366,35 +429,7 @@ OUString ObjectNameProvider::getTitleName( const OUString& rObjectCID { TitleHelper::eTitleType eType; if( TitleHelper::getTitleType( eType, xTitle, xChartModel ) ) - { - switch(eType) - { - case TitleHelper::MAIN_TITLE: - aRet=String(SchResId(STR_OBJECT_TITLE_MAIN)); - break; - case TitleHelper::SUB_TITLE: - aRet=String(SchResId(STR_OBJECT_TITLE_SUB)); - break; - case TitleHelper::X_AXIS_TITLE: - aRet=String(SchResId(STR_OBJECT_TITLE_X_AXIS)); - break; - case TitleHelper::Y_AXIS_TITLE: - aRet=String(SchResId(STR_OBJECT_TITLE_Y_AXIS)); - break; - case TitleHelper::Z_AXIS_TITLE: - aRet=String(SchResId(STR_OBJECT_TITLE_Z_AXIS)); - break; - case TitleHelper::SECONDARY_X_AXIS_TITLE: - aRet=String(SchResId(STR_OBJECT_TITLE_SECONDARY_X_AXIS)); - break; - case TitleHelper::SECONDARY_Y_AXIS_TITLE: - aRet=String(SchResId(STR_OBJECT_TITLE_SECONDARY_Y_AXIS)); - break; - default: - DBG_ERROR("unknown title type"); - break; - } - } + aRet = ObjectNameProvider::getTitleNameByType( eType ); } if( !aRet.getLength() ) aRet=String(SchResId(STR_OBJECT_TITLE)); @@ -481,12 +516,7 @@ rtl::OUString ObjectNameProvider::getHelpText( const rtl::OUString& rObjectCID, } else if( OBJECTTYPE_DATA_SERIES == eObjectType ) { - aRet=String(SchResId(STR_TIP_DATASERIES)); - - OUString aWildcard( C2U("%SERIESNAME") ); - sal_Int32 nIndex = aRet.indexOf( aWildcard ); - if( nIndex != -1 ) - aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), lcl_getDataSeriesName( rObjectCID, xChartModel ) ); + aRet = lcl_getFullSeriesName( rObjectCID, xChartModel ); } else if( OBJECTTYPE_DATA_POINT == eObjectType ) { @@ -753,7 +783,41 @@ rtl::OUString ObjectNameProvider::getNameForCID( case OBJECTTYPE_TITLE: return getTitleName( rObjectCID, xModel ); case OBJECTTYPE_GRID: + case OBJECTTYPE_SUBGRID: return getGridName( rObjectCID, xModel ); + case OBJECTTYPE_DATA_SERIES: + return lcl_getFullSeriesName( rObjectCID, xModel ); + //case OBJECTTYPE_LEGEND_ENTRY: + case OBJECTTYPE_DATA_POINT: + case OBJECTTYPE_DATA_LABELS: + case OBJECTTYPE_DATA_LABEL: + case OBJECTTYPE_DATA_ERRORS: + case OBJECTTYPE_DATA_ERRORS_X: + case OBJECTTYPE_DATA_ERRORS_Y: + case OBJECTTYPE_DATA_ERRORS_Z: + case OBJECTTYPE_DATA_CURVE: + case OBJECTTYPE_DATA_AVERAGE_LINE: + case OBJECTTYPE_DATA_CURVE_EQUATION: + { + rtl::OUString aRet = lcl_getFullSeriesName( rObjectCID, xModel ); + aRet += C2U(" "); + if( eType == OBJECTTYPE_DATA_POINT || eType == OBJECTTYPE_DATA_LABEL ) + { + aRet += getName( OBJECTTYPE_DATA_POINT ); + sal_Int32 nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( rObjectCID ); + aRet += C2U(" "); + aRet += OUString::valueOf(nPointIndex+1); + + if( eType == OBJECTTYPE_DATA_LABEL ) + { + aRet += C2U(" "); + aRet += getName( OBJECTTYPE_DATA_LABEL ); + } + } + else + aRet += getName( eType ); + return aRet; + } default: break; } @@ -761,6 +825,32 @@ rtl::OUString ObjectNameProvider::getNameForCID( return getName( eType ); } +//static +rtl::OUString ObjectNameProvider::getName_ObjectForSeries( + ObjectType eObjectType, + const rtl::OUString& rSeriesCID, + const uno::Reference< chart2::XChartDocument >& xChartDocument ) +{ + uno::Reference< frame::XModel> xChartModel( xChartDocument, uno::UNO_QUERY ); + Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rSeriesCID , xChartModel ), uno::UNO_QUERY ); + if( xSeries.is() ) + { + OUString aRet = String(SchResId(STR_OBJECT_FOR_SERIES)); + replaceParamterInString( aRet, C2U("%OBJECTNAME"), getName( eObjectType, false /*bPlural*/ ) ); + replaceParamterInString( aRet, C2U("%SERIESNAME"), lcl_getDataSeriesName( rSeriesCID, xChartModel ) ); + return aRet; + } + else + return ObjectNameProvider::getName_ObjectForAllSeries( eObjectType ); +} + +//static +rtl::OUString ObjectNameProvider::getName_ObjectForAllSeries( ObjectType eObjectType ) +{ + OUString aRet = String(SchResId(STR_OBJECT_FOR_ALL_SERIES)); + replaceParamterInString( aRet, C2U("%OBJECTNAME"), getName( eObjectType, true /*bPlural*/ ) ); + return aRet; +} //............................................................................. } //namespace chart diff --git a/chart2/source/controller/dialogs/Strings.src b/chart2/source/controller/dialogs/Strings.src index 3b384915f2d0..b7ef643e3ff3 100644 --- a/chart2/source/controller/dialogs/Strings.src +++ b/chart2/source/controller/dialogs/Strings.src @@ -84,9 +84,9 @@ String STR_PAGE_TRANSPARENCY Text [ en-US ] = "Transparency"; }; -String STR_PAGE_CHARACTERS +String STR_PAGE_FONT { - Text [ en-US ] = "Characters" ; + Text [ en-US ] = "Font" ; }; String STR_PAGE_FONT_EFFECTS @@ -183,6 +183,14 @@ String STR_OBJECT_AXIS_Z { Text [ en-US ] = "Z Axis" ; }; +String STR_OBJECT_SECONDARY_X_AXIS +{ + Text [ en-US ] = "Secondary X Axis" ; +}; +String STR_OBJECT_SECONDARY_Y_AXIS +{ + Text [ en-US ] = "Secondary Y Axis" ; +}; String STR_OBJECT_AXES { @@ -312,18 +320,18 @@ String STR_OBJECT_CURVE_EQUATION Text[ en-US ] = "Equation"; }; -String STR_OBJECT_ERROR_INDICATOR +String STR_OBJECT_ERROR_BARS { - Text [ en-US ] = "Error Indicator"; + Text [ en-US ] = "Error Bars"; }; String STR_OBJECT_STOCK_LOSS { - Text [ en-US ] = "Negative Deviation"; + Text [ en-US ] = "Stock Loss"; }; String STR_OBJECT_STOCK_GAIN { - Text [ en-US ] = "Positive Deviation"; + Text [ en-US ] = "Stock Gain"; }; String STR_OBJECT_PAGE @@ -403,6 +411,18 @@ String STR_STATUS_PIE_SEGMENT_EXPLODED Text [ en-US ] = "Pie exploded by %PERCENTVALUE percent"; }; +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +String STR_OBJECT_FOR_SERIES +{ + Text [ en-US ] = "%OBJECTNAME for Data Series '%SERIESNAME'" ; +}; + +String STR_OBJECT_FOR_ALL_SERIES +{ + Text [ en-US ] = "%OBJECTNAME for all Data Series" ; +}; + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- String STR_ACTION_EDIT_CHARTTYPE diff --git a/chart2/source/controller/dialogs/dlg_InsertDataLabel.cxx b/chart2/source/controller/dialogs/dlg_InsertDataLabel.cxx index 638a8f5f2994..d7eb3357e6e8 100644 --- a/chart2/source/controller/dialogs/dlg_InsertDataLabel.cxx +++ b/chart2/source/controller/dialogs/dlg_InsertDataLabel.cxx @@ -51,7 +51,8 @@ DataLabelsDialog::DataLabelsDialog(Window* pWindow, const SfxItemSet& rInAttrs, m_rInAttrs(rInAttrs) { FreeResource(); - SetText( ObjectNameProvider::getName(OBJECTTYPE_DATA_LABELS) ); + this->SetText( ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_LABELS ) ); + m_apDataLabelResources->SetNumberFormatter( pFormatter ); Reset(); } diff --git a/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx b/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx index e6b74c8e660a..535b07a7df38 100644 --- a/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx +++ b/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx @@ -42,6 +42,7 @@ #include "ObjectIdentifier.hxx" #include "DiagramHelper.hxx" #include "AxisHelper.hxx" +#include "ObjectNameProvider.hxx" #include #include @@ -70,7 +71,8 @@ InsertErrorBarsDialog::InsertErrorBarsDialog( /* bNoneAvailable = */ true, eType )) { FreeResource(); - this->SetText( String( SchResId( STR_PAGE_YERROR_BARS ))); + this->SetText( ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_ERRORS ) ); + m_apErrorBarResources->SetChartDocumentForRangeChoosing( xChartDocument ); } diff --git a/chart2/source/controller/dialogs/dlg_InsertTrendline.cxx b/chart2/source/controller/dialogs/dlg_InsertTrendline.cxx index 95c9754f3b7e..042baa292f65 100644 --- a/chart2/source/controller/dialogs/dlg_InsertTrendline.cxx +++ b/chart2/source/controller/dialogs/dlg_InsertTrendline.cxx @@ -42,6 +42,7 @@ #include "ObjectIdentifier.hxx" #include "DiagramHelper.hxx" #include "AxisHelper.hxx" +#include "ObjectNameProvider.hxx" #include #include @@ -74,7 +75,7 @@ InsertTrendlineDialog::InsertTrendlineDialog( Window* pParent, const SfxItemSet& m_apTrendlineResources( new TrendlineResources( this, rInAttrs, true )) { FreeResource(); - this->SetText( String( SchResId( STR_OBJECT_CURVES ))); + this->SetText( ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_CURVE ) ); } InsertTrendlineDialog::~InsertTrendlineDialog() diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx index fdc7c3766644..097c6c1d0107 100644 --- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx +++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx @@ -143,7 +143,7 @@ void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel uno::Reference< XChartType > xChartType = ChartModelHelper::getChartTypeOfSeries( xChartModel, xSeries ); sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); - bool bHasSeriesProperties = (OBJECTTYPE_DATA_SERIES==m_eObjectType || OBJECTTYPE_DATA_LABELS==m_eObjectType); + bool bHasSeriesProperties = (OBJECTTYPE_DATA_SERIES==m_eObjectType); bool bHasDataPointproperties = (OBJECTTYPE_DATA_POINT==m_eObjectType); if( bHasSeriesProperties || bHasDataPointproperties ) @@ -222,14 +222,37 @@ void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel { m_aLocalizedName = ObjectNameProvider::getAxisName( m_aObjectCID, xChartModel ); } + else if( !m_bAffectsMultipleObjects && ( OBJECTTYPE_GRID == m_eObjectType || OBJECTTYPE_SUBGRID == m_eObjectType ) ) + { + m_aLocalizedName = ObjectNameProvider::getGridName( m_aObjectCID, xChartModel ); + } + else if( !m_bAffectsMultipleObjects && OBJECTTYPE_TITLE == m_eObjectType ) + { + m_aLocalizedName = ObjectNameProvider::getTitleName( m_aObjectCID, xChartModel ); + } else { - ObjectType eType = m_eObjectType; - if( OBJECTTYPE_DATA_LABEL == eType ) - eType = OBJECTTYPE_DATA_POINT; - else if( OBJECTTYPE_DATA_LABELS == eType ) - eType = OBJECTTYPE_DATA_SERIES; - m_aLocalizedName = ObjectNameProvider::getName(eType,m_bAffectsMultipleObjects); + switch( m_eObjectType ) + { + case OBJECTTYPE_DATA_POINT: + case OBJECTTYPE_DATA_LABEL: + case OBJECTTYPE_DATA_LABELS: + case OBJECTTYPE_DATA_ERRORS: + case OBJECTTYPE_DATA_ERRORS_X: + case OBJECTTYPE_DATA_ERRORS_Y: + case OBJECTTYPE_DATA_ERRORS_Z: + case OBJECTTYPE_DATA_AVERAGE_LINE: + case OBJECTTYPE_DATA_CURVE: + case OBJECTTYPE_DATA_CURVE_EQUATION: + if( m_bAffectsMultipleObjects ) + m_aLocalizedName = ObjectNameProvider::getName_ObjectForAllSeries( m_eObjectType ); + else + m_aLocalizedName = ObjectNameProvider::getName_ObjectForSeries( m_eObjectType, m_aObjectCID, m_xChartDocument ); + break; + default: + m_aLocalizedName = ObjectNameProvider::getName(m_eObjectType,m_bAffectsMultipleObjects); + break; + } } } } @@ -355,7 +378,7 @@ SchAttribTabDlg::SchAttribTabDlg(Window* pParent, AddTabPage(RID_SVXPAGE_LINE, String(SchResId(STR_PAGE_BORDER))); AddTabPage(RID_SVXPAGE_AREA, String(SchResId(STR_PAGE_AREA))); AddTabPage(RID_SVXPAGE_TRANSPARENCE, String(SchResId(STR_PAGE_TRANSPARENCY))); - AddTabPage(RID_SVXPAGE_CHAR_NAME, String(SchResId(STR_PAGE_CHARACTERS))); + AddTabPage(RID_SVXPAGE_CHAR_NAME, String(SchResId(STR_PAGE_FONT))); AddTabPage(RID_SVXPAGE_CHAR_EFFECTS, String(SchResId(STR_PAGE_FONT_EFFECTS))); AddTabPage(TP_ALIGNMENT, String(SchResId(STR_PAGE_ALIGNMENT)), SchAlignmentTabPage::Create, NULL); if( aCJKOptions.IsAsianTypographyEnabled() ) @@ -366,7 +389,7 @@ SchAttribTabDlg::SchAttribTabDlg(Window* pParent, AddTabPage(RID_SVXPAGE_LINE, String(SchResId(STR_PAGE_BORDER))); AddTabPage(RID_SVXPAGE_AREA, String(SchResId(STR_PAGE_AREA))); AddTabPage(RID_SVXPAGE_TRANSPARENCE, String(SchResId(STR_PAGE_TRANSPARENCY))); - AddTabPage(RID_SVXPAGE_CHAR_NAME, String(SchResId(STR_PAGE_CHARACTERS))); + AddTabPage(RID_SVXPAGE_CHAR_NAME, String(SchResId(STR_PAGE_FONT))); AddTabPage(RID_SVXPAGE_CHAR_EFFECTS, String(SchResId(STR_PAGE_FONT_EFFECTS))); AddTabPage(TP_LEGEND_POS, String(SchResId(STR_PAGE_POSITION)), SchLegendPosTabPage::Create, NULL); if( aCJKOptions.IsAsianTypographyEnabled() ) @@ -375,27 +398,30 @@ SchAttribTabDlg::SchAttribTabDlg(Window* pParent, case OBJECTTYPE_DATA_SERIES: case OBJECTTYPE_DATA_POINT: - case OBJECTTYPE_DATA_LABEL: - case OBJECTTYPE_DATA_LABELS: - AddTabPage(RID_SVXPAGE_LINE, String(SchResId( m_pParameter->HasAreaProperties() ? STR_PAGE_BORDER : STR_PAGE_LINE ))); + if( m_pParameter->ProvidesSecondaryYAxis() || m_pParameter->ProvidesOverlapAndGapWidth() || m_pParameter->ProvidesMissingValueTreatments() ) + AddTabPage(TP_OPTIONS, String(SchResId(STR_PAGE_OPTIONS)),SchOptionTabPage::Create, NULL); + if( m_pParameter->ProvidesStartingAngle()) + AddTabPage(TP_POLAROPTIONS, String(SchResId(STR_PAGE_OPTIONS)),PolarOptionsTabPage::Create, NULL); + + if( m_pParameter->HasGeometryProperties() ) + AddTabPage(TP_LAYOUT, String(SchResId(STR_PAGE_LAYOUT)),SchLayoutTabPage::Create, NULL); + if(m_pParameter->HasAreaProperties()) { AddTabPage(RID_SVXPAGE_AREA, String(SchResId(STR_PAGE_AREA))); AddTabPage(RID_SVXPAGE_TRANSPARENCE, String(SchResId(STR_PAGE_TRANSPARENCY))); } - AddTabPage(RID_SVXPAGE_CHAR_NAME, String(SchResId(STR_PAGE_CHARACTERS))); + AddTabPage(RID_SVXPAGE_LINE, String(SchResId( m_pParameter->HasAreaProperties() ? STR_PAGE_BORDER : STR_PAGE_LINE ))); + break; + + case OBJECTTYPE_DATA_LABEL: + case OBJECTTYPE_DATA_LABELS: + AddTabPage(TP_DATA_DESCR, String(SchResId(STR_OBJECT_DATALABELS)), DataLabelsTabPage::Create, NULL); + AddTabPage(RID_SVXPAGE_CHAR_NAME, String(SchResId(STR_PAGE_FONT))); AddTabPage(RID_SVXPAGE_CHAR_EFFECTS, String(SchResId(STR_PAGE_FONT_EFFECTS))); if( aCJKOptions.IsAsianTypographyEnabled() ) AddTabPage(RID_SVXPAGE_PARA_ASIAN, String(SchResId(STR_PAGE_ASIAN))); - AddTabPage(TP_DATA_DESCR, String(SchResId(STR_OBJECT_DATALABELS)), DataLabelsTabPage::Create, NULL); -// if( m_pParameter->HasStatisticProperties() ) -// AddTabPage(TP_YERRORBAR, String(SchResId(STR_PAGE_YERROR_BARS)), ErrorBarsTabPage::Create, NULL); - if( m_pParameter->HasGeometryProperties() ) - AddTabPage(TP_LAYOUT, String(SchResId(STR_PAGE_LAYOUT)),SchLayoutTabPage::Create, NULL); - if( m_pParameter->ProvidesSecondaryYAxis() || m_pParameter->ProvidesOverlapAndGapWidth() || m_pParameter->ProvidesMissingValueTreatments() ) - AddTabPage(TP_OPTIONS, String(SchResId(STR_PAGE_OPTIONS)),SchOptionTabPage::Create, NULL); - if( m_pParameter->ProvidesStartingAngle()) - AddTabPage(TP_POLAROPTIONS, String(SchResId(STR_PAGE_OPTIONS)),PolarOptionsTabPage::Create, NULL); + break; case OBJECTTYPE_AXIS: @@ -409,7 +435,7 @@ SchAttribTabDlg::SchAttribTabDlg(Window* pParent, AddTabPage(TP_AXIS_LABEL, String(SchResId(STR_OBJECT_LABEL)), SchAxisLabelTabPage::Create, NULL); if( m_pParameter->HasNumberProperties() ) AddTabPage(RID_SVXPAGE_NUMBERFORMAT, String(SchResId(STR_PAGE_NUMBERS))); - AddTabPage(RID_SVXPAGE_CHAR_NAME, String(SchResId(STR_PAGE_CHARACTERS))); + AddTabPage(RID_SVXPAGE_CHAR_NAME, String(SchResId(STR_PAGE_FONT))); AddTabPage(RID_SVXPAGE_CHAR_EFFECTS, String(SchResId(STR_PAGE_FONT_EFFECTS))); if( aCJKOptions.IsAsianTypographyEnabled() ) AddTabPage(RID_SVXPAGE_PARA_ASIAN, String(SchResId(STR_PAGE_ASIAN))); @@ -456,7 +482,7 @@ SchAttribTabDlg::SchAttribTabDlg(Window* pParent, AddTabPage(RID_SVXPAGE_LINE, String(SchResId(STR_PAGE_BORDER))); AddTabPage(RID_SVXPAGE_AREA, String(SchResId(STR_PAGE_AREA))); AddTabPage(RID_SVXPAGE_TRANSPARENCE, String(SchResId(STR_PAGE_TRANSPARENCY))); - AddTabPage(RID_SVXPAGE_CHAR_NAME, String(SchResId(STR_PAGE_CHARACTERS))); + AddTabPage(RID_SVXPAGE_CHAR_NAME, String(SchResId(STR_PAGE_FONT))); AddTabPage(RID_SVXPAGE_CHAR_EFFECTS, String(SchResId(STR_PAGE_FONT_EFFECTS))); AddTabPage(RID_SVXPAGE_NUMBERFORMAT, String(SchResId(STR_PAGE_NUMBERS))); if( SvtLanguageOptions().IsCTLFontEnabled() ) diff --git a/chart2/source/controller/inc/ObjectHierarchy.hxx b/chart2/source/controller/inc/ObjectHierarchy.hxx index f0614f7a6d86..3281181c5be7 100644 --- a/chart2/source/controller/inc/ObjectHierarchy.hxx +++ b/chart2/source/controller/inc/ObjectHierarchy.hxx @@ -62,7 +62,8 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDocument, ExplicitValueProvider * pExplicitValueProvider = 0, - bool bFlattenDiagram = false ); + bool bFlattenDiagram = false, + bool bOrderingForElementSelector = false ); ~ObjectHierarchy(); static tCID getRootNodeCID(); diff --git a/chart2/source/controller/inc/ObjectNameProvider.hxx b/chart2/source/controller/inc/ObjectNameProvider.hxx index 2892c769c7a0..529f253fc20a 100644 --- a/chart2/source/controller/inc/ObjectNameProvider.hxx +++ b/chart2/source/controller/inc/ObjectNameProvider.hxx @@ -32,6 +32,7 @@ #define _CHART2_OBJECTNAME_PROVIDER_HXX #include "ObjectIdentifier.hxx" +#include "TitleHelper.hxx" #include #include @@ -57,12 +58,20 @@ public: static rtl::OUString getTitleName( const rtl::OUString& rObjectCID , const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel ); + static rtl::OUString getTitleNameByType( TitleHelper::eTitleType eType ); static rtl::OUString getNameForCID( const rtl::OUString& rObjectCID, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDocument ); + static rtl::OUString getName_ObjectForSeries( + ObjectType eObjectType, + const rtl::OUString& rSeriesCID, + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument >& xChartDocument ); + static rtl::OUString getName_ObjectForAllSeries( ObjectType eObjectType ); + /** Provides help texts for the various chart elements. The parameter rObjectCID has to be a ClassifiedIdentifier - see class ObjectIdentifier. */ 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 executeDispatch_InsertTitles(); + void executeDispatch_InsertLegend(); + void executeDispatch_DeleteLegend(); + void executeDispatch_OpenLegendDialog(); + void executeDispatch_InsertAxes(); + void executeDispatch_InsertGrid(); - void SAL_CALL executeDispatch_DeleteMeanValue(); - void SAL_CALL executeDispatch_DeleteTrendline(); - void SAL_CALL executeDispatch_DeleteYErrorbar(); + 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 #include @@ -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; nNgetModel() ); + + 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 //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,55 +690,73 @@ void SAL_CALL ChartController::executeDispatch_ObjectProperties() executeDlg_ObjectProperties( m_aSelection.getSelectedCID() ); } -void SAL_CALL ChartController::executeDlg_ObjectProperties( const ::rtl::OUString& rObjectCID ) +namespace { - if( !rObjectCID.getLength() ) + +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 ) { - //DBG_ERROR("empty ObjectID"); - return; + rtl::OUString aParentParticle( ObjectIdentifier::getFullParentParticle( rSelectedCID ) ); + aFormatCID = ObjectIdentifier::createClassifiedIdentifierForParticle( aParentParticle ); } - 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 ); - if( OBJECTTYPE_UNKNOWN==eObjectType ) - { - //DBG_ERROR("unknown ObjectType"); - return; - } + // treat diagram as wall + if( OBJECTTYPE_DIAGRAM==eObjectType ) + aFormatCID = ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, rtl::OUString() ); - // 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 aFormatCID; +} - // treat diagram as wall - if( OBJECTTYPE_DIAGRAM==eObjectType ) - { - aObjectCID = ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, rtl::OUString() ); - eObjectType = OBJECTTYPE_DIAGRAM_WALL; - } +}//end anonymous namespace - if( OBJECTTYPE_DIAGRAM_WALL==eObjectType || OBJECTTYPE_DIAGRAM_FLOOR==eObjectType ) - { - if( !DiagramHelper::isSupportingFloorAndWall( ChartModelHelper::findDiagram( m_aModel->getModel() ) ) ) - return; - } +void SAL_CALL ChartController::executeDlg_ObjectProperties( const ::rtl::OUString& rSelectedObjectCID ) +{ + rtl::OUString aObjectCID = lcl_getFormatCIDforSelectedCID( rSelectedObjectCID ); - //------------------------------------------------------------- - UndoGuard aUndoGuard( - ActionDescriptionProvider::createDescription( + 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 bRet; + } + try + { + NumberFormatterWrapper aNumberFormatterWrapper( uno::Reference< util::XNumberFormatsSupplier >(m_aModel->getModel(), uno::UNO_QUERY) ); + + //------------------------------------------------------------- + //get type of object + ObjectType eObjectType = ObjectIdentifier::getObjectType( rObjectCID ); + if( OBJECTTYPE_UNKNOWN==eObjectType ) + { + //DBG_ERROR("unknown ObjectType"); + return bRet; + } + if( OBJECTTYPE_DIAGRAM_WALL==eObjectType || OBJECTTYPE_DIAGRAM_FLOOR==eObjectType ) + { + if( !DiagramHelper::isSupportingFloorAndWall( ChartModelHelper::findDiagram( m_aModel->getModel() ) ) ) + return bRet; + } + //------------------------------------------------------------- //convert properties to ItemSet @@ -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 #include +#include #include #include @@ -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 - - -//............................................................................. -namespace chart +OUString lcl_getFormatCommandForObjectCID( const OUString& rCID ) { -//............................................................................. + OUString aDispatchCommand( C2U(".uno:FormatSelection") ); + + ObjectType eObjectType = ObjectIdentifier::getObjectType( rCID ); + + 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")); - 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()) + 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 ) { - 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; + 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; } - ++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")); + + if( OBJECTTYPE_PAGE == eObjectType || OBJECTTYPE_DIAGRAM == eObjectType + || OBJECTTYPE_DIAGRAM_WALL == eObjectType + || OBJECTTYPE_DIAGRAM_FLOOR == eObjectType + || OBJECTTYPE_UNKNOWN == eObjectType ) + { + 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") ); + } + //----- + 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: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: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: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 + * + * 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 + +#include +#include +#include + +#include +#include +#include +#include + +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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART_ELEMENTSELECTOR_HXX +#define _CHART_ELEMENTSELECTOR_HXX + +#include "ServiceMacros.hxx" +#include +#include +#include + +#include +#include + +#include + +//............................................................................. +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 #include @@ -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 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 & 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 ); - // Axes + // 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; + } + } +} + +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 > aChartTypeSeq( xCTCnt->getChartTypes()); for( sal_Int32 nCTIdx=0; nCTIdx 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 xCurveCnt( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY ); - if( xCurveCnt.is()) + Reference< chart2::XDataSeries > xSeries( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY ); + + // data lablels + if( DataSeriesHelper::hasDataLabelsAtSeries( xSeries ) ) { - Sequence< Reference< chart2::XRegressionCurve > > aCurves( xCurveCnt->getRegressionCurves()); - for( sal_Int32 nCurveIdx=0; nCurveIdx 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 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 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 \ diff --git a/chart2/source/inc/AxisHelper.hxx b/chart2/source/inc/AxisHelper.hxx index d6d7e14bc7d3..15d5e9cb4ae5 100644 --- a/chart2/source/inc/AxisHelper.hxx +++ b/chart2/source/inc/AxisHelper.hxx @@ -98,14 +98,14 @@ public: static sal_Bool isGridShown( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram ); - SAL_DLLPRIVATE static void makeAxisVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis ); + static void makeAxisVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis ); static void makeGridVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xGridProperties ); - SAL_DLLPRIVATE static void makeAxisInvisible( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis ); - SAL_DLLPRIVATE static void makeGridInvisible( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xGridProperties ); + static void makeAxisInvisible( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis ); + static void makeGridInvisible( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xGridProperties ); SAL_DLLPRIVATE static sal_Bool areAxisLabelsVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xAxisProperties ); - SAL_DLLPRIVATE static sal_Bool isAxisVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis ); + static sal_Bool isAxisVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis ); static sal_Bool isGridVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xGridProperties ); static ::com::sun::star::uno::Reference< diff --git a/chart2/source/inc/DataSeriesHelper.hxx b/chart2/source/inc/DataSeriesHelper.hxx index ae179e5c5e83..317c92849fb7 100644 --- a/chart2/source/inc/DataSeriesHelper.hxx +++ b/chart2/source/inc/DataSeriesHelper.hxx @@ -188,6 +188,27 @@ OOO_DLLPUBLIC_CHARTTOOLS sal_Int32 translateIndexFromHiddenToFullSequence( sal_Int32 nClippedIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence >& xDataSequence, bool bTranslate ); +OOO_DLLPUBLIC_CHARTTOOLS bool hasDataLabelsAtSeries( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries >& xSeries ); + +OOO_DLLPUBLIC_CHARTTOOLS bool hasDataLabelsAtPoints( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries >& xSeries ); + +OOO_DLLPUBLIC_CHARTTOOLS bool hasDataLabelAtPoint( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries >& xSeries, sal_Int32 nPointIndex ); + +OOO_DLLPUBLIC_CHARTTOOLS void insertDataLabelsToSeriesAndAllPoints( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries >& xSeries ); + +OOO_DLLPUBLIC_CHARTTOOLS void insertDataLabelToPoint( const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet >& xPointPropertySet ); + +OOO_DLLPUBLIC_CHARTTOOLS void deleteDataLabelsFromSeriesAndAllPoints( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries >& xSeries ); + +OOO_DLLPUBLIC_CHARTTOOLS void deleteDataLabelsFromPoint( const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet >& xPointPropertySet ); + } // namespace DataSeriesHelper } // namespace chart diff --git a/chart2/source/inc/LegendHelper.hxx b/chart2/source/inc/LegendHelper.hxx index f6c792ab48f1..f88e2cba0aae 100644 --- a/chart2/source/inc/LegendHelper.hxx +++ b/chart2/source/inc/LegendHelper.hxx @@ -50,6 +50,16 @@ namespace chart class OOO_DLLPUBLIC_CHARTTOOLS LegendHelper { public: + static ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XLegend > + showLegend( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xModel + , const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext >& xContext ); + + static void hideLegend( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xModel ); + static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XLegend > getLegend( const ::com::sun::star::uno::Reference< diff --git a/chart2/source/inc/RegressionCurveHelper.hxx b/chart2/source/inc/RegressionCurveHelper.hxx index 3f18fa6c46c8..7dbc9e33bf3d 100644 --- a/chart2/source/inc/RegressionCurveHelper.hxx +++ b/chart2/source/inc/RegressionCurveHelper.hxx @@ -151,6 +151,10 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XRegressionCurveContainer > & xRegCnt ); + static void removeEquations( + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XRegressionCurveContainer > & xRegCnt ); + /** adds the given regression curve if there was none before. If there are regression curves, the first one is replaced by the one given by the type. All remaining curves are remnoved. @@ -225,6 +229,10 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XRegressionCurve > & xCurve ); + static bool hasEquation( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XRegressionCurve > & xCurve ); + private: // not implemented RegressionCurveHelper(); diff --git a/chart2/source/inc/Strings.hrc b/chart2/source/inc/Strings.hrc index 1092efe6e900..fea8bb867057 100644 --- a/chart2/source/inc/Strings.hrc +++ b/chart2/source/inc/Strings.hrc @@ -33,7 +33,7 @@ // this includes no link dependency #include -//next free is 286 +//next free is 290 //single free is: 134 //#define RID_APP_START 30000 @@ -231,8 +231,11 @@ #define STR_OBJECT_DATASERIES (RID_APP_START + 204) #define STR_OBJECT_DATASERIES_PLURAL (RID_APP_START + 205) +#define STR_OBJECT_FOR_SERIES (RID_APP_START + 288) +#define STR_OBJECT_FOR_ALL_SERIES (RID_APP_START + 289) + #define STR_OBJECT_AVERAGE_LINE (RID_APP_START + 174) -#define STR_OBJECT_ERROR_INDICATOR (RID_APP_START + 175) +#define STR_OBJECT_ERROR_BARS (RID_APP_START + 175) #define STR_OBJECT_CURVE (RID_APP_START + 176) #define STR_OBJECT_CURVES (RID_APP_START + 130) @@ -245,6 +248,9 @@ #define STR_OBJECT_AXIS_Y (RID_APP_START + 212) #define STR_OBJECT_AXIS_Z (RID_APP_START + 213) +#define STR_OBJECT_SECONDARY_X_AXIS (RID_APP_START + 286) +#define STR_OBJECT_SECONDARY_Y_AXIS (RID_APP_START + 287) + #define STR_OBJECT_GRID (RID_APP_START + 214) #define STR_OBJECT_GRIDS (RID_APP_START + 215) @@ -268,7 +274,7 @@ #define STR_PAGE_BORDER (RID_APP_START + 217) #define STR_PAGE_AREA (RID_APP_START + 218) #define STR_PAGE_TRANSPARENCY (RID_APP_START + 219) -#define STR_PAGE_CHARACTERS (RID_APP_START + 220) +#define STR_PAGE_FONT (RID_APP_START + 220) #define STR_PAGE_FONT_EFFECTS (RID_APP_START + 221) #define STR_PAGE_LAYOUT (RID_APP_START + 222) #define STR_PAGE_OPTIONS (RID_APP_START + 223) diff --git a/chart2/source/model/inc/DataSeries.hxx b/chart2/source/model/inc/DataSeries.hxx index 387d69d1f9ab..e483cc96e5b5 100644 --- a/chart2/source/model/inc/DataSeries.hxx +++ b/chart2/source/model/inc/DataSeries.hxx @@ -111,6 +111,10 @@ protected: SAL_CALL getDataPointByIndex( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL resetDataPoint( sal_Int32 nIndex ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL resetAllDataPoints() + throw (::com::sun::star::uno::RuntimeException); // ____ XDataSink ____ // ___________________ diff --git a/chart2/source/model/main/DataSeries.cxx b/chart2/source/model/main/DataSeries.cxx index 9f331ce2a215..0d76aab40366 100644 --- a/chart2/source/model/main/DataSeries.cxx +++ b/chart2/source/model/main/DataSeries.cxx @@ -419,6 +419,31 @@ Reference< beans::XPropertySet > // \-- } +void SAL_CALL DataSeries::resetDataPoint( sal_Int32 nIndex ) + throw (uno::RuntimeException) +{ + MutexGuard aGuard( GetMutex() ); + tDataPointAttributeContainer::iterator aIt( m_aAttributedDataPoints.find( nIndex )); + if( aIt != m_aAttributedDataPoints.end()) + { + Reference< beans::XPropertySet > xDataPointProp( (*aIt).second ); + Reference< util::XModifyBroadcaster > xBroadcaster( xDataPointProp, uno::UNO_QUERY ); + if( xBroadcaster.is() && m_xModifyEventForwarder.is()) + xBroadcaster->removeModifyListener( m_xModifyEventForwarder ); + m_aAttributedDataPoints.erase(aIt); + fireModifyEvent(); + } +} + +void SAL_CALL DataSeries::resetAllDataPoints() + throw (uno::RuntimeException) +{ + MutexGuard aGuard( GetMutex() ); + ModifyListenerHelper::removeListenerFromAllMapElements( m_aAttributedDataPoints, m_xModifyEventForwarder ); + m_aAttributedDataPoints.clear(); + fireModifyEvent(); +} + // ____ XDataSink ____ void SAL_CALL DataSeries::setData( const uno::Sequence< Reference< chart2::data::XLabeledDataSequence > >& aData ) throw (uno::RuntimeException) diff --git a/chart2/source/tools/DataSeriesHelper.cxx b/chart2/source/tools/DataSeriesHelper.cxx index 61fecf18b5e7..7203f9ad6e63 100644 --- a/chart2/source/tools/DataSeriesHelper.cxx +++ b/chart2/source/tools/DataSeriesHelper.cxx @@ -36,6 +36,7 @@ #include "macros.hxx" #include "ContainerHelper.hxx" #include +#include #include #include #include @@ -57,6 +58,7 @@ #include using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; @@ -155,6 +157,50 @@ void lcl_getCooSysAndChartTypeOfSeries( } } +void lcl_insertOrDeleteDataLabelsToSeriesAndAllPoints( const Reference< chart2::XDataSeries >& xSeries, bool bInsert ) +{ + try + { + Reference< beans::XPropertySet > xSeriesProperties( xSeries, uno::UNO_QUERY ); + if( xSeriesProperties.is() ) + { + DataPointLabel aLabelAtSeries; + xSeriesProperties->getPropertyValue( C2U( "Label" ) ) >>= aLabelAtSeries; + aLabelAtSeries.ShowNumber = bInsert; + if( !bInsert ) + { + aLabelAtSeries.ShowNumberInPercent = false; + aLabelAtSeries.ShowCategoryName = false; + } + xSeriesProperties->setPropertyValue( C2U( "Label" ), uno::makeAny( aLabelAtSeries ) ); + uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; + if( xSeriesProperties->getPropertyValue( C2U( "AttributedDataPoints" ) ) >>= aAttributedDataPointIndexList ) + { + for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;) + { + Reference< beans::XPropertySet > xPointProp( xSeries->getDataPointByIndex(aAttributedDataPointIndexList[nN]) ); + if( xPointProp.is() ) + { + DataPointLabel aLabel; + xPointProp->getPropertyValue( C2U( "Label" ) ) >>= aLabel; + aLabel.ShowNumber = bInsert; + if( !bInsert ) + { + aLabel.ShowNumberInPercent = false; + aLabel.ShowCategoryName = false; + } + xPointProp->setPropertyValue( C2U( "Label" ), uno::makeAny( aLabel ) ); + } + } + } + } + } + catch( uno::Exception &e) + { + ASSERT_EXCEPTION( e ); + } +} + } // anonymous namespace // ---------------------------------------- @@ -735,5 +781,141 @@ sal_Int32 translateIndexFromHiddenToFullSequence( sal_Int32 nIndex, const Refere return nIndex; } +bool hasDataLabelsAtSeries( const Reference< chart2::XDataSeries >& xSeries ) +{ + bool bRet = false; + try + { + Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY ); + if( xProp.is() ) + { + DataPointLabel aLabel; + if( (xProp->getPropertyValue( C2U( "Label" ) ) >>= aLabel) ) + bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent || aLabel.ShowCategoryName; + } + } + catch( uno::Exception &e) + { + ASSERT_EXCEPTION( e ); + } + return bRet; +} + +bool hasDataLabelsAtPoints( const Reference< chart2::XDataSeries >& xSeries ) +{ + bool bRet = false; + try + { + Reference< beans::XPropertySet > xSeriesProperties( xSeries, uno::UNO_QUERY ); + if( xSeriesProperties.is() ) + { + uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; + if( xSeriesProperties->getPropertyValue( C2U( "AttributedDataPoints" ) ) >>= aAttributedDataPointIndexList ) + { + for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;) + { + Reference< beans::XPropertySet > xPointProp( xSeries->getDataPointByIndex(aAttributedDataPointIndexList[nN]) ); + if( xPointProp.is() ) + { + DataPointLabel aLabel; + if( (xPointProp->getPropertyValue( C2U( "Label" ) ) >>= aLabel) ) + bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent || aLabel.ShowCategoryName; + if( bRet ) + break; + } + } + } + } + } + catch( uno::Exception &e) + { + ASSERT_EXCEPTION( e ); + } + return bRet; +} + +bool hasDataLabelAtPoint( const Reference< chart2::XDataSeries >& xSeries, sal_Int32 nPointIndex ) +{ + bool bRet = false; + try + { + Reference< beans::XPropertySet > xProp; + Reference< beans::XPropertySet > xSeriesProperties( xSeries, uno::UNO_QUERY ); + if( xSeriesProperties.is() ) + { + uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; + if( xSeriesProperties->getPropertyValue( C2U( "AttributedDataPoints" ) ) >>= aAttributedDataPointIndexList ) + { + ::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()) + xProp = xSeries->getDataPointByIndex(nPointIndex); + else + xProp = xSeriesProperties; + } + if( xProp.is() ) + { + DataPointLabel aLabel; + if( (xProp->getPropertyValue( C2U( "Label" ) ) >>= aLabel) ) + bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent || aLabel.ShowCategoryName; + } + } + } + catch( uno::Exception &e) + { + ASSERT_EXCEPTION( e ); + } + return bRet; +} + +void insertDataLabelsToSeriesAndAllPoints( const Reference< chart2::XDataSeries >& xSeries ) +{ + lcl_insertOrDeleteDataLabelsToSeriesAndAllPoints( xSeries, true /*bInsert*/ ); +} + +void deleteDataLabelsFromSeriesAndAllPoints( const Reference< chart2::XDataSeries >& xSeries ) +{ + lcl_insertOrDeleteDataLabelsToSeriesAndAllPoints( xSeries, false /*bInsert*/ ); +} + + +void insertDataLabelToPoint( const Reference< beans::XPropertySet >& xPointProp ) +{ + try + { + if( xPointProp.is() ) + { + DataPointLabel aLabel; + xPointProp->getPropertyValue( C2U( "Label" ) ) >>= aLabel; + aLabel.ShowNumber = true; + xPointProp->setPropertyValue( C2U( "Label" ), uno::makeAny( aLabel ) ); + } + } + catch( uno::Exception &e) + { + ASSERT_EXCEPTION( e ); + } +} + +void deleteDataLabelsFromPoint( const Reference< beans::XPropertySet >& xPointProp ) +{ + try + { + if( xPointProp.is() ) + { + DataPointLabel aLabel; + xPointProp->getPropertyValue( C2U( "Label" ) ) >>= aLabel; + aLabel.ShowNumber = false; + aLabel.ShowNumberInPercent = false; + aLabel.ShowCategoryName = false; + xPointProp->setPropertyValue( C2U( "Label" ), uno::makeAny( aLabel ) ); + } + } + catch( uno::Exception &e) + { + ASSERT_EXCEPTION( e ); + } +} + } // namespace DataSeriesHelper } // namespace chart diff --git a/chart2/source/tools/LegendHelper.cxx b/chart2/source/tools/LegendHelper.cxx index 6d21d13f0dc7..60da06f2b638 100644 --- a/chart2/source/tools/LegendHelper.cxx +++ b/chart2/source/tools/LegendHelper.cxx @@ -32,18 +32,66 @@ #include "precompiled_chart2.hxx" #include "LegendHelper.hxx" #include "macros.hxx" +#include +#include +#include #include #include #include #include using namespace ::com::sun::star; +using ::com::sun::star::uno::Reference; //............................................................................. namespace chart { //............................................................................. + +//static +Reference< chart2::XLegend > LegendHelper::showLegend( const Reference< frame::XModel >& xModel + , const uno::Reference< uno::XComponentContext >& xContext ) +{ + uno::Reference< chart2::XLegend > xLegend = LegendHelper::getLegend( xModel, xContext, true ); + uno::Reference< beans::XPropertySet > xProp( xLegend, uno::UNO_QUERY ); + if( xProp.is()) + { + xProp->setPropertyValue( C2U("Show"), uno::makeAny(sal_True) ); + + chart2::RelativePosition aRelativePosition; + if( !(xProp->getPropertyValue( C2U( "RelativePosition" )) >>= aRelativePosition) ) + { + chart2::LegendPosition ePos = chart2::LegendPosition_LINE_END; + if( !(xProp->getPropertyValue( C2U( "AnchorPosition" )) >>= ePos ) ) + xProp->setPropertyValue( C2U( "AnchorPosition" ), uno::makeAny( ePos )); + + chart2::LegendExpansion eExpansion = + ( ePos == chart2::LegendPosition_LINE_END || + ePos == chart2::LegendPosition_LINE_START ) + ? chart2::LegendExpansion_HIGH + : chart2::LegendExpansion_WIDE; + if( !(xProp->getPropertyValue( C2U( "Expansion" )) >>= eExpansion ) ) + xProp->setPropertyValue( C2U( "Expansion" ), uno::makeAny( eExpansion )); + + xProp->setPropertyValue( C2U( "RelativePosition" ), uno::Any()); + } + + } + return xLegend; +} + +//static +void LegendHelper::hideLegend( const Reference< frame::XModel >& xModel ) +{ + uno::Reference< chart2::XLegend > xLegend = LegendHelper::getLegend( xModel, 0, false ); + uno::Reference< beans::XPropertySet > xProp( xLegend, uno::UNO_QUERY ); + if( xProp.is()) + { + xProp->setPropertyValue( C2U("Show"), uno::makeAny(sal_False) ); + } +} + // static uno::Reference< chart2::XLegend > LegendHelper::getLegend( const uno::Reference< frame::XModel >& xModel diff --git a/chart2/source/tools/RegressionCurveHelper.cxx b/chart2/source/tools/RegressionCurveHelper.cxx index 7686b2c7009d..8a4fd8ce4f7e 100644 --- a/chart2/source/tools/RegressionCurveHelper.cxx +++ b/chart2/source/tools/RegressionCurveHelper.cxx @@ -457,6 +457,39 @@ bool RegressionCurveHelper::removeAllExceptMeanValueLine( return bRemovedSomething; } +void RegressionCurveHelper::removeEquations( + uno::Reference< chart2::XRegressionCurveContainer > & xRegCnt ) +{ + if( xRegCnt.is()) + { + try + { + uno::Sequence< uno::Reference< chart2::XRegressionCurve > > aCurves( + xRegCnt->getRegressionCurves()); + for( sal_Int32 i = 0; i < aCurves.getLength(); ++i ) + { + if( !isMeanValueLine( aCurves[i] ) ) + { + uno::Reference< chart2::XRegressionCurve > xRegCurve( aCurves[ i ] ); + if( xRegCurve.is() ) + { + uno::Reference< beans::XPropertySet > xEqProp( xRegCurve->getEquationProperties() ) ; + if( xEqProp.is()) + { + xEqProp->setPropertyValue( C2U("ShowEquation"), uno::makeAny( false )); + xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( false )); + } + } + } + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } +} + // static void RegressionCurveHelper::replaceOrAddCurveAndReduceToOne( tRegressionType eType, @@ -683,6 +716,24 @@ sal_Int32 RegressionCurveHelper::getRegressionCurveIndex( return -1; } +bool RegressionCurveHelper::hasEquation( const Reference< chart2::XRegressionCurve > & xCurve ) +{ + bool bHasEquation = false; + if( xCurve.is()) + { + uno::Reference< beans::XPropertySet > xEquationProp( xCurve->getEquationProperties()); + if( xEquationProp.is()) + { + bool bShowEquation = false; + bool bShowCoefficient = false; + xEquationProp->getPropertyValue( C2U("ShowEquation")) >>= bShowEquation; + xEquationProp->getPropertyValue( C2U("ShowCorrelationCoefficient")) >>= bShowCoefficient; + bHasEquation = bShowEquation || bShowCoefficient; + } + } + return bHasEquation; +} + //............................................................................. } //namespace chart //............................................................................. diff --git a/chart2/uiconfig/menubar/menubar.xml b/chart2/uiconfig/menubar/menubar.xml index 63f72f67d592..788dac2fc90b 100644 --- a/chart2/uiconfig/menubar/menubar.xml +++ b/chart2/uiconfig/menubar/menubar.xml @@ -43,22 +43,22 @@ - - - - + + + + - - - - + + + + - + @@ -82,6 +82,7 @@ + @@ -107,7 +108,6 @@ - diff --git a/chart2/uiconfig/toolbar/toolbar.xml b/chart2/uiconfig/toolbar/toolbar.xml index 042dc7fbe973..41d5bd41ab63 100644 --- a/chart2/uiconfig/toolbar/toolbar.xml +++ b/chart2/uiconfig/toolbar/toolbar.xml @@ -1,6 +1,9 @@ + + +