diff options
author | Tomaž Vajngerl <quikee@gmail.com> | 2013-11-23 16:06:28 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2013-11-24 19:43:16 +0100 |
commit | 6f62f3f0af9ae8c1b00d0d620f306cae914a3861 (patch) | |
tree | 9e6f39e28706a494db998531e4fd3bc423fc4a8d /chart2 | |
parent | f58e03e7bb0016c1ca789f7e7b35933c95378121 (diff) |
Custom name for a trend line (shown in legend).
Previously, a trendline name was fixed to a combination of the
trendline type and the name of the series. With this it is possible
to add a custom name for the trendline, which is shown in the
legend.
Change-Id: I61eaaf14e6df45088abdf1f3e9c24877d26ae8a7
Diffstat (limited to 'chart2')
9 files changed, 127 insertions, 31 deletions
diff --git a/chart2/source/controller/dialogs/res_Trendline.cxx b/chart2/source/controller/dialogs/res_Trendline.cxx index f8ba0fa7aa3b..7a4c4952a123 100644 --- a/chart2/source/controller/dialogs/res_Trendline.cxx +++ b/chart2/source/controller/dialogs/res_Trendline.cxx @@ -24,6 +24,7 @@ #include "chartview/ChartSfxItemIds.hxx" #include <svl/intitem.hxx> +#include <svl/stritem.hxx> #include <sfx2/tabdlg.hxx> #include <vector> @@ -36,26 +37,28 @@ TrendlineResources::TrendlineResources( Window * pParent, const SfxItemSet& rInA m_eTrendLineType( CHREGRESS_LINEAR ), m_bTrendLineUnique( true ) { - ((SfxTabPage*)pParent)->get(m_pRB_Linear,"linear"); - ((SfxTabPage*)pParent)->get(m_pRB_Logarithmic,"logarithmic"); - ((SfxTabPage*)pParent)->get(m_pRB_Exponential,"exponential"); - ((SfxTabPage*)pParent)->get(m_pRB_Power,"power"); - ((SfxTabPage*)pParent)->get(m_pRB_Polynomial,"polynomial"); - ((SfxTabPage*)pParent)->get(m_pRB_MovingAverage,"movingAverage"); - ((SfxTabPage*)pParent)->get(m_pNF_Degree,"degree"); - ((SfxTabPage*)pParent)->get(m_pNF_Period,"period"); - ((SfxTabPage*)pParent)->get(m_pNF_ExtrapolateForward,"extrapolateForward"); - ((SfxTabPage*)pParent)->get(m_pNF_ExtrapolateBackward,"extrapolateBackward"); - ((SfxTabPage*)pParent)->get(m_pCB_SetIntercept,"setIntercept"); - ((SfxTabPage*)pParent)->get(m_pNF_InterceptValue,"interceptValue"); - ((SfxTabPage*)pParent)->get(m_pCB_ShowEquation,"showEquation"); - ((SfxTabPage*)pParent)->get(m_pCB_ShowCorrelationCoeff,"showCorrelationCoefficient"); - ((SfxTabPage*)pParent)->get(m_pFI_Linear,"imageLinear"); - ((SfxTabPage*)pParent)->get(m_pFI_Logarithmic,"imageLogarithmic"); - ((SfxTabPage*)pParent)->get(m_pFI_Exponential,"imageExponential"); - ((SfxTabPage*)pParent)->get(m_pFI_Power,"imagePower"); - ((SfxTabPage*)pParent)->get(m_pFI_Polynomial,"imagePolynomial"); - ((SfxTabPage*)pParent)->get(m_pFI_MovingAverage,"imageMovingAverage"); + SfxTabPage* pTabPage = reinterpret_cast<SfxTabPage*>(pParent); + pTabPage->get(m_pRB_Linear,"linear"); + pTabPage->get(m_pRB_Logarithmic,"logarithmic"); + pTabPage->get(m_pRB_Exponential,"exponential"); + pTabPage->get(m_pRB_Power,"power"); + pTabPage->get(m_pRB_Polynomial,"polynomial"); + pTabPage->get(m_pRB_MovingAverage,"movingAverage"); + pTabPage->get(m_pNF_Degree,"degree"); + pTabPage->get(m_pNF_Period,"period"); + pTabPage->get(m_pEE_Name,"entry_name"); + pTabPage->get(m_pNF_ExtrapolateForward,"extrapolateForward"); + pTabPage->get(m_pNF_ExtrapolateBackward,"extrapolateBackward"); + pTabPage->get(m_pCB_SetIntercept,"setIntercept"); + pTabPage->get(m_pNF_InterceptValue,"interceptValue"); + pTabPage->get(m_pCB_ShowEquation,"showEquation"); + pTabPage->get(m_pCB_ShowCorrelationCoeff,"showCorrelationCoefficient"); + pTabPage->get(m_pFI_Linear,"imageLinear"); + pTabPage->get(m_pFI_Logarithmic,"imageLogarithmic"); + pTabPage->get(m_pFI_Exponential,"imageExponential"); + pTabPage->get(m_pFI_Power,"imagePower"); + pTabPage->get(m_pFI_Polynomial,"imagePolynomial"); + pTabPage->get(m_pFI_MovingAverage,"imageMovingAverage"); FillValueSets(); m_pRB_Linear->SetClickHdl( LINK(this, TrendlineResources, SelectTrendLine )); @@ -104,6 +107,16 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs ) { const SfxPoolItem *pPoolItem = NULL; + if( rInAttrs.GetItemState( SCHATTR_REGRESSION_CURVE_NAME, sal_True, &pPoolItem ) == SFX_ITEM_SET ) + { + OUString aName = static_cast< const SfxStringItem* >(pPoolItem)->GetValue(); + m_pEE_Name->SetText(aName); + } + else + { + m_pEE_Name->SetText(""); + } + SfxItemState aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_TYPE, sal_True, &pPoolItem ); m_bTrendLineUnique = ( aState != SFX_ITEM_DONTCARE ); if( aState == SFX_ITEM_SET ) @@ -243,6 +256,9 @@ sal_Bool TrendlineResources::FillItemSet(SfxItemSet& rOutAttrs) const if( m_pCB_ShowCorrelationCoeff->GetState() != STATE_DONTKNOW ) rOutAttrs.Put( SfxBoolItem( SCHATTR_REGRESSION_SHOW_COEFF, m_pCB_ShowCorrelationCoeff->IsChecked() )); + OUString aName = m_pEE_Name->GetText(); + rOutAttrs.Put(SfxStringItem(SCHATTR_REGRESSION_CURVE_NAME, aName)); + sal_Int32 aDegree = m_pNF_Degree->GetValue(); rOutAttrs.Put(SfxInt32Item( SCHATTR_REGRESSION_DEGREE, aDegree ) ); diff --git a/chart2/source/controller/dialogs/res_Trendline.hxx b/chart2/source/controller/dialogs/res_Trendline.hxx index 0c12d71c53ae..7aacb0810602 100644 --- a/chart2/source/controller/dialogs/res_Trendline.hxx +++ b/chart2/source/controller/dialogs/res_Trendline.hxx @@ -57,6 +57,7 @@ private: NumericField* m_pNF_Degree; NumericField* m_pNF_Period; + Edit* m_pEE_Name; NumericField* m_pNF_ExtrapolateForward; NumericField* m_pNF_ExtrapolateBackward; CheckBox* m_pCB_SetIntercept; diff --git a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx index 6b284393afc4..81f94d25ca73 100644 --- a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx @@ -29,6 +29,7 @@ // for SfxBoolItem #include <svl/eitem.hxx> #include <svl/intitem.hxx> +#include <svl/stritem.hxx> #include <svx/chrtitem.hxx> #include <functional> @@ -245,6 +246,13 @@ bool RegressionCurveItemConverter::ApplySpecialItem( } break; + case SCHATTR_REGRESSION_CURVE_NAME: + { + uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY ); + bChanged = lclConvertToPropertySet<OUString, SfxStringItem>(rItemSet, nWhichId, xProperties, "CurveName"); + } + break; + case SCHATTR_REGRESSION_SHOW_EQUATION: { uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties()); @@ -258,6 +266,7 @@ bool RegressionCurveItemConverter::ApplySpecialItem( bChanged = lclConvertToPropertySet<sal_Bool, SfxBoolItem>(rItemSet, nWhichId, xEqProp, "ShowCorrelationCoefficient"); } break; + } return bChanged; } @@ -318,6 +327,12 @@ void RegressionCurveItemConverter::FillSpecialItem(sal_uInt16 nWhichId, SfxItemS } break; + case SCHATTR_REGRESSION_CURVE_NAME: + { + lclConvertToItemSet<OUString, SfxStringItem>(rOutItemSet, nWhichId, xProperties, "CurveName"); + } + break; + case SCHATTR_REGRESSION_SHOW_EQUATION: { lclConvertToItemSet<sal_Bool, SfxBoolItem>(rOutItemSet, nWhichId, xCurve->getEquationProperties(), "ShowEquation"); diff --git a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx index 3693ea5f511e..506be486b0a5 100644 --- a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx @@ -526,7 +526,7 @@ bool StatisticsItemConverter::ApplySpecialItem( case SCHATTR_REGRESSION_SET_INTERCEPT: { uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet )); - bChanged = lclConvertToPropertySet<sal_Bool, SfxBoolItem>(rItemSet, nWhichId, xProperties, "InterceptValue"); + bChanged = lclConvertToPropertySet<sal_Bool, SfxBoolItem>(rItemSet, nWhichId, xProperties, "ForceIntercept"); } break; @@ -537,6 +537,13 @@ bool StatisticsItemConverter::ApplySpecialItem( } break; + case SCHATTR_REGRESSION_CURVE_NAME: + { + uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet )); + bChanged = lclConvertToPropertySet<OUString, SfxStringItem>(rItemSet, nWhichId, xProperties, "CurveName"); + } + break; + case SCHATTR_REGRESSION_SHOW_EQUATION: { uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet )); @@ -800,6 +807,13 @@ void StatisticsItemConverter::FillSpecialItem( } break; + case SCHATTR_REGRESSION_CURVE_NAME: + { + uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), 0 )); + lclConvertToItemSet<OUString, SfxStringItem>(rOutItemSet, nWhichId, xProperties, "CurveName"); + } + break; + case SCHATTR_REGRESSION_SHOW_EQUATION: { uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), 0 )); diff --git a/chart2/source/inc/chartview/ChartSfxItemIds.hxx b/chart2/source/inc/chartview/ChartSfxItemIds.hxx index 2b988481c3cb..7481cc88169a 100644 --- a/chart2/source/inc/chartview/ChartSfxItemIds.hxx +++ b/chart2/source/inc/chartview/ChartSfxItemIds.hxx @@ -167,7 +167,8 @@ #define SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD (SCHATTR_REGRESSION_START + 6) #define SCHATTR_REGRESSION_SET_INTERCEPT (SCHATTR_REGRESSION_START + 7) #define SCHATTR_REGRESSION_INTERCEPT_VALUE (SCHATTR_REGRESSION_START + 8) -#define SCHATTR_REGRESSION_END SCHATTR_REGRESSION_INTERCEPT_VALUE +#define SCHATTR_REGRESSION_CURVE_NAME (SCHATTR_REGRESSION_START + 9) +#define SCHATTR_REGRESSION_END SCHATTR_REGRESSION_CURVE_NAME #define SCHATTR_END SCHATTR_REGRESSION_END diff --git a/chart2/source/tools/RegressionCurveHelper.cxx b/chart2/source/tools/RegressionCurveHelper.cxx index d93fb6489206..a19affda5e32 100644 --- a/chart2/source/tools/RegressionCurveHelper.cxx +++ b/chart2/source/tools/RegressionCurveHelper.cxx @@ -590,6 +590,18 @@ OUString RegressionCurveHelper::getUINameForRegressionCurve( const Reference< XR if(!xServiceName.is()) return aResult; + Reference<XPropertySet> xProperties( xRegressionCurve, uno::UNO_QUERY ); + if( xProperties.is() ) + { + OUString aValue = OUString(); + if(xProperties->getPropertyValue("CurveName") >>= aValue) + { + if (!aValue.isEmpty()) + return aValue; + } + } + + // Did not get the curve name OUString aServiceName( xServiceName->getServiceName()); if( aServiceName == "com.sun.star.chart2.MeanValueRegressionCurve" ) { diff --git a/chart2/source/tools/RegressionCurveModel.cxx b/chart2/source/tools/RegressionCurveModel.cxx index fb182c0a3d6e..2ff4f4523e9d 100644 --- a/chart2/source/tools/RegressionCurveModel.cxx +++ b/chart2/source/tools/RegressionCurveModel.cxx @@ -62,7 +62,8 @@ enum PROPERTY_EXTRAPOLATE_FORWARD, PROPERTY_EXTRAPOLATE_BACKWARD, PROPERTY_FORCE_INTERCEPT, - PROPERTY_INTERCEPT_VALUE + PROPERTY_INTERCEPT_VALUE, + PROPERTY_CURVE_NAME }; void lcl_AddPropertiesToVector( @@ -109,6 +110,12 @@ void lcl_AddPropertiesToVector( ::getCppuType( reinterpret_cast< const double* >(0) ), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( "CurveName", + PROPERTY_CURVE_NAME, + ::getCppuType( reinterpret_cast< const OUString* >(0) ), + beans::PropertyAttribute::BOUND )); } struct StaticXXXDefaults_Initializer diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx index b5c21d3bc4fa..3718dad61348 100644 --- a/chart2/source/view/main/ChartItemPool.cxx +++ b/chart2/source/view/main/ChartItemPool.cxx @@ -157,6 +157,7 @@ ChartItemPool::ChartItemPool(): ppPoolDefaults[SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD); ppPoolDefaults[SCHATTR_REGRESSION_SET_INTERCEPT - SCHATTR_START] = new SfxBoolItem(SCHATTR_REGRESSION_SET_INTERCEPT, sal_False); ppPoolDefaults[SCHATTR_REGRESSION_INTERCEPT_VALUE - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_REGRESSION_INTERCEPT_VALUE); + ppPoolDefaults[SCHATTR_REGRESSION_CURVE_NAME - SCHATTR_START] = new SfxStringItem(SCHATTR_REGRESSION_CURVE_NAME, OUString()); /************************************************************************** * ItemInfos diff --git a/chart2/uiconfig/ui/tp_Trendline.ui b/chart2/uiconfig/ui/tp_Trendline.ui index a8be2849b2f3..d0951457465b 100644 --- a/chart2/uiconfig/ui/tp_Trendline.ui +++ b/chart2/uiconfig/ui/tp_Trendline.ui @@ -376,7 +376,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">0</property> + <property name="top_attach">1</property> <property name="width">1</property> <property name="height">1</property> </packing> @@ -392,7 +392,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">1</property> + <property name="top_attach">2</property> <property name="width">1</property> <property name="height">1</property> </packing> @@ -410,7 +410,7 @@ </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">0</property> + <property name="top_attach">1</property> <property name="width">1</property> <property name="height">1</property> </packing> @@ -425,7 +425,7 @@ </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">1</property> + <property name="top_attach">2</property> <property name="width">1</property> <property name="height">1</property> </packing> @@ -444,7 +444,7 @@ </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">2</property> + <property name="top_attach">3</property> <property name="width">1</property> <property name="height">1</property> </packing> @@ -464,7 +464,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">2</property> + <property name="top_attach">3</property> <property name="width">1</property> <property name="height">1</property> </packing> @@ -481,7 +481,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">3</property> + <property name="top_attach">4</property> <property name="width">2</property> <property name="height">1</property> </packing> @@ -498,11 +498,40 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">4</property> + <property name="top_attach">5</property> <property name="width">2</property> <property name="height">1</property> </packing> </child> + <child> + <object class="GtkLabel" id="label5"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Trendline Name</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">entry_name</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="entry_name"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="invisible_char">•</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> </object> </child> </object> |