[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - chart2/source chart2/uiconfig

Tomaž Vajngerl quikee at gmail.com
Tue Dec 3 01:31:01 PST 2013


 chart2/source/controller/dialogs/res_Trendline.cxx                       |   56 ++++++----
 chart2/source/controller/dialogs/res_Trendline.hxx                       |    1 
 chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx |   15 ++
 chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx      |   16 ++
 chart2/source/inc/chartview/ChartSfxItemIds.hxx                          |    3 
 chart2/source/tools/RegressionCurveHelper.cxx                            |   12 ++
 chart2/source/tools/RegressionCurveModel.cxx                             |    9 +
 chart2/source/view/main/ChartItemPool.cxx                                |    1 
 chart2/uiconfig/ui/tp_Trendline.ui                                       |   45 ++++++--
 9 files changed, 127 insertions(+), 31 deletions(-)

New commits:
commit 04e704c1c28d6554bc0f03ece2fbff3a11b745ef
Author: Tomaž Vajngerl <quikee at gmail.com>
Date:   Sat Nov 23 16:06:28 2013 +0100

    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
    Reviewed-on: https://gerrit.libreoffice.org/6873
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>
    Reviewed-by: Thorsten Behrens <thb at documentfoundation.org>
    Tested-by: Thorsten Behrens <thb at documentfoundation.org>

diff --git a/chart2/source/controller/dialogs/res_Trendline.cxx b/chart2/source/controller/dialogs/res_Trendline.cxx
index db83486..76be297 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();
 
     Link aLink = LINK(this, TrendlineResources, SelectTrendLine );
@@ -110,6 +113,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 )
@@ -249,6 +262,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 9795774..8dd2e2e 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 6b28439..81f94d2 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 3693ea5..506be48 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 2b98848..7481cc8 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 d93fb64..a19affd 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 fb182c0..2ff4f45 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 b5c21d3..3718dad 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 a8be284..d095145 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>


More information about the Libreoffice-commits mailing list