chart2/source/controller/dialogs/res_Trendline.cxx |  270 ++++++++++-----------
 chart2/source/controller/dialogs/res_Trendline.hxx |   66 ++---
 chart2/source/controller/dialogs/tp_Trendline.cxx  |   11 
 chart2/source/controller/dialogs/tp_Trendline.hxx  |    2 
 chart2/uiconfig/ui/tp_Trendline.ui                 |  139 ++++------
 include/vcl/weld.hxx                               |   32 ++
 vcl/Library_vclplug_gtk3.mk                        |    1 
 vcl/source/app/salvtables.cxx                      |   47 +++
 vcl/unx/gtk3/gtk3gtkinst.cxx                       |  170 ++++++++++++-
 9 files changed, 475 insertions(+), 263 deletions(-)

New commits:
commit 39aa91cfb4620a650ceba01076a1c0aa2fbfdadf
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Wed Nov 14 15:44:08 2018 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu Nov 15 18:45:22 2018 +0100

    Resolves: tdf#121341 weld TrendlineTabPage
    
    Change-Id: I8ecc1901388986bd6a3822e8d0055e48d873586c
    Reviewed-on: https://gerrit.libreoffice.org/63387
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Tested-by: Caolán McNamara <caol...@redhat.com>

diff --git a/chart2/source/controller/dialogs/res_Trendline.cxx 
b/chart2/source/controller/dialogs/res_Trendline.cxx
index f75ce892183e..8f140428a9da 100644
--- a/chart2/source/controller/dialogs/res_Trendline.cxx
+++ b/chart2/source/controller/dialogs/res_Trendline.cxx
@@ -24,6 +24,7 @@
 #include <editeng/sizeitem.hxx>
 #include <svl/intitem.hxx>
 #include <svl/stritem.hxx>
+#include <svl/zforlist.hxx>
 #include <sfx2/tabdlg.hxx>
 
 #include <vector>
@@ -32,58 +33,57 @@
 namespace chart
 {
 
-static void lcl_setValue( FormattedField& rFmtField, double fValue )
+static void lcl_setValue(weld::FormattedSpinButton& rFmtField, double fValue )
 {
-    rFmtField.SetValue( fValue );
-    rFmtField.SetDefaultValue( fValue );
+    rFmtField.set_value(fValue);
+//TODO    rFmtField.SetDefaultValue( fValue );
 }
 
-TrendlineResources::TrendlineResources( vcl::Window * pParent, const 
SfxItemSet& rInAttrs ) :
-        m_eTrendLineType( SvxChartRegress::Linear ),
-        m_bTrendLineUnique( true ),
-        m_pNumFormatter( nullptr ),
-        m_nNbPoints( 0 )
+TrendlineResources::TrendlineResources(weld::Builder& rBuilder, const 
SfxItemSet& rInAttrs)
+    : m_eTrendLineType(SvxChartRegress::Linear)
+    , m_bTrendLineUnique(true)
+    , m_pNumFormatter(nullptr)
+    , m_nNbPoints(0)
+    , m_xRB_Linear(rBuilder.weld_radio_button("linear"))
+    , m_xRB_Logarithmic(rBuilder.weld_radio_button("logarithmic"))
+    , m_xRB_Exponential(rBuilder.weld_radio_button("exponential"))
+    , m_xRB_Power(rBuilder.weld_radio_button("power"))
+    , m_xRB_Polynomial(rBuilder.weld_radio_button("polynomial"))
+    , m_xRB_MovingAverage(rBuilder.weld_radio_button("movingAverage"))
+    , m_xFI_Linear(rBuilder.weld_image("imageLinear"))
+    , m_xFI_Logarithmic(rBuilder.weld_image("imageLogarithmic"))
+    , m_xFI_Exponential(rBuilder.weld_image("imageExponential"))
+    , m_xFI_Power(rBuilder.weld_image("imagePower"))
+    , m_xFI_Polynomial(rBuilder.weld_image("imagePolynomial"))
+    , m_xFI_MovingAverage(rBuilder.weld_image("imageMovingAverage"))
+    , m_xNF_Degree(rBuilder.weld_spin_button("degree"))
+    , m_xNF_Period(rBuilder.weld_spin_button("period"))
+    , m_xEE_Name(rBuilder.weld_entry("entry_name"))
+    , 
m_xFmtFld_ExtrapolateForward(rBuilder.weld_formatted_spin_button("extrapolateForward"))
+    , 
m_xFmtFld_ExtrapolateBackward(rBuilder.weld_formatted_spin_button("extrapolateBackward"))
+    , m_xCB_SetIntercept(rBuilder.weld_check_button("setIntercept"))
+    , 
m_xFmtFld_InterceptValue(rBuilder.weld_formatted_spin_button("interceptValue"))
+    , m_xCB_ShowEquation(rBuilder.weld_check_button("showEquation"))
+    , m_xEE_XName(rBuilder.weld_entry("entry_Xname"))
+    , m_xEE_YName(rBuilder.weld_entry("entry_Yname"))
+    , 
m_xCB_ShowCorrelationCoeff(rBuilder.weld_check_button("showCorrelationCoefficient"))
 {
-    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_pFmtFld_ExtrapolateForward,"extrapolateForward");
-    pTabPage->get(m_pFmtFld_ExtrapolateBackward,"extrapolateBackward");
-    pTabPage->get(m_pCB_SetIntercept,"setIntercept");
-    pTabPage->get(m_pFmtFld_InterceptValue,"interceptValue");
-    pTabPage->get(m_pCB_ShowEquation,"showEquation");
-    pTabPage->get(m_pEE_XName,"entry_Xname");
-    pTabPage->get(m_pEE_YName,"entry_Yname");
-    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<Button*,void> aLink = LINK(this, TrendlineResources, SelectTrendLine 
);
-    m_pRB_Linear->SetClickHdl( aLink );
-    m_pRB_Logarithmic->SetClickHdl( aLink );
-    m_pRB_Exponential->SetClickHdl( aLink );
-    m_pRB_Power->SetClickHdl( aLink );
-    m_pRB_Polynomial->SetClickHdl( aLink );
-    m_pRB_MovingAverage->SetClickHdl( aLink );
+    Link<weld::ToggleButton&,void> aLink = LINK(this, TrendlineResources, 
SelectTrendLine);
+    m_xRB_Linear->connect_toggled( aLink );
+    m_xRB_Logarithmic->connect_toggled( aLink );
+    m_xRB_Exponential->connect_toggled( aLink );
+    m_xRB_Power->connect_toggled( aLink );
+    m_xRB_Polynomial->connect_toggled( aLink );
+    m_xRB_MovingAverage->connect_toggled( aLink );
 
-    Link<Edit&,void> aLink2 = LINK(this, TrendlineResources, ChangeValue );
-    m_pNF_Degree->SetModifyHdl( aLink2 );
-    m_pNF_Period->SetModifyHdl( aLink2 );
-    m_pFmtFld_InterceptValue->SetModifyHdl( aLink2 );
+    Link<weld::SpinButton&,void> aLink2 = LINK(this, TrendlineResources, 
ChangeSpinValue);
+    m_xNF_Degree->connect_value_changed(aLink2);
+    m_xNF_Period->connect_value_changed(aLink2);
+    m_xFmtFld_InterceptValue->connect_value_changed(LINK(this, 
TrendlineResources, ChangeFormattedValue));
 
-    m_pCB_ShowEquation->SetToggleHdl( LINK(this, TrendlineResources, 
ShowEquation ) );
+    m_xCB_ShowEquation->connect_toggled(LINK(this, TrendlineResources, 
ShowEquation));
 
     Reset( rInAttrs );
     UpdateControlStates();
@@ -92,19 +92,19 @@ TrendlineResources::TrendlineResources( vcl::Window * 
pParent, const SfxItemSet&
 TrendlineResources::~TrendlineResources()
 {}
 
-IMPL_LINK( TrendlineResources, SelectTrendLine, Button *, pRadioButton, void )
+IMPL_LINK_NOARG(TrendlineResources, SelectTrendLine, weld::ToggleButton&, void)
 {
-    if( pRadioButton == m_pRB_Linear )
+    if (m_xRB_Linear->get_active())
         m_eTrendLineType = SvxChartRegress::Linear;
-    else if( pRadioButton == m_pRB_Logarithmic )
+    else if (m_xRB_Logarithmic->get_active())
         m_eTrendLineType = SvxChartRegress::Log;
-    else if( pRadioButton == m_pRB_Exponential )
+    else if (m_xRB_Exponential->get_active())
         m_eTrendLineType = SvxChartRegress::Exp;
-    else if( pRadioButton == m_pRB_Power )
+    else if (m_xRB_Power->get_active())
         m_eTrendLineType = SvxChartRegress::Power;
-    else if( pRadioButton == m_pRB_Polynomial )
+    else if (m_xRB_Polynomial->get_active())
         m_eTrendLineType = SvxChartRegress::Polynomial;
-    else if( pRadioButton == m_pRB_MovingAverage )
+    else if (m_xRB_MovingAverage->get_active())
         m_eTrendLineType = SvxChartRegress::MovingAverage;
     m_bTrendLineUnique = true;
 
@@ -118,29 +118,29 @@ void TrendlineResources::Reset( const SfxItemSet& 
rInAttrs )
     if( rInAttrs.GetItemState( SCHATTR_REGRESSION_CURVE_NAME, true, &pPoolItem 
) == SfxItemState::SET )
     {
         OUString aName = static_cast< const SfxStringItem* 
>(pPoolItem)->GetValue();
-        m_pEE_Name->SetText(aName);
+        m_xEE_Name->set_text(aName);
     }
     else
     {
-        m_pEE_Name->SetText("");
+        m_xEE_Name->set_text("");
     }
     if( rInAttrs.GetItemState( SCHATTR_REGRESSION_XNAME, true, &pPoolItem ) == 
SfxItemState::SET )
     {
         OUString aName = static_cast< const SfxStringItem* 
>(pPoolItem)->GetValue();
-        m_pEE_XName->SetText(aName);
+        m_xEE_XName->set_text(aName);
     }
     else
     {
-        m_pEE_XName->SetText("x");
+        m_xEE_XName->set_text("x");
     }
     if( rInAttrs.GetItemState( SCHATTR_REGRESSION_YNAME, true, &pPoolItem ) == 
SfxItemState::SET )
     {
         OUString aName = static_cast< const SfxStringItem* 
>(pPoolItem)->GetValue();
-        m_pEE_YName->SetText(aName);
+        m_xEE_YName->set_text(aName);
     }
     else
     {
-        m_pEE_YName->SetText("f(x)");
+        m_xEE_YName->set_text("f(x)");
     }
 
     SfxItemState aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_TYPE, 
true, &pPoolItem );
@@ -157,21 +157,21 @@ void TrendlineResources::Reset( const SfxItemSet& 
rInAttrs )
     if( rInAttrs.GetItemState( SCHATTR_REGRESSION_DEGREE, true, &pPoolItem ) 
== SfxItemState::SET )
     {
         sal_Int32 nDegree = static_cast< const SfxInt32Item * >( pPoolItem 
)->GetValue();
-        m_pNF_Degree->SetValue( nDegree );
+        m_xNF_Degree->set_value( nDegree );
     }
     else
     {
-        m_pNF_Degree->SetValue( 2 );
+        m_xNF_Degree->set_value( 2 );
     }
 
     if( rInAttrs.GetItemState( SCHATTR_REGRESSION_PERIOD, true, &pPoolItem ) 
== SfxItemState::SET )
     {
         sal_Int32 nPeriod = static_cast< const SfxInt32Item * >( pPoolItem 
)->GetValue();
-        m_pNF_Period->SetValue( nPeriod );
+        m_xNF_Period->set_value( nPeriod );
     }
     else
     {
-        m_pNF_Period->SetValue( 2 );
+        m_xNF_Period->set_value( 2 );
     }
 
     double nValue = 0.0;
@@ -179,59 +179,53 @@ void TrendlineResources::Reset( const SfxItemSet& 
rInAttrs )
     {
         nValue = static_cast<const SvxDoubleItem*>(pPoolItem)->GetValue() ;
     }
-    lcl_setValue( *m_pFmtFld_ExtrapolateForward, nValue );
+    lcl_setValue(*m_xFmtFld_ExtrapolateForward, nValue);
 
     nValue = 0.0;
     if( rInAttrs.GetItemState( SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD, true, 
&pPoolItem ) == SfxItemState::SET )
     {
         nValue = static_cast<const SvxDoubleItem*>(pPoolItem)->GetValue() ;
     }
-    lcl_setValue( *m_pFmtFld_ExtrapolateBackward, nValue );
+    lcl_setValue(*m_xFmtFld_ExtrapolateBackward, nValue);
 
     nValue = 0.0;
     if( rInAttrs.GetItemState( SCHATTR_REGRESSION_INTERCEPT_VALUE, true, 
&pPoolItem ) == SfxItemState::SET )
     {
         nValue = static_cast<const SvxDoubleItem*>(pPoolItem)->GetValue() ;
     }
-    lcl_setValue( *m_pFmtFld_InterceptValue, nValue );
+    lcl_setValue(*m_xFmtFld_InterceptValue, nValue);
 
     aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_SET_INTERCEPT, true, 
&pPoolItem );
     if( aState == SfxItemState::DONTCARE )
     {
-        m_pCB_SetIntercept->EnableTriState();
-        m_pCB_SetIntercept->SetState( TRISTATE_INDET );
+        m_xCB_SetIntercept->set_state(TRISTATE_INDET);
     }
     else
     {
-        m_pCB_SetIntercept->EnableTriState( false );
         if( aState == SfxItemState::SET )
-            m_pCB_SetIntercept->Check( static_cast< const SfxBoolItem * >( 
pPoolItem )->GetValue());
+            m_xCB_SetIntercept->set_active( static_cast< const SfxBoolItem * 
>( pPoolItem )->GetValue());
     }
 
     aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_SHOW_EQUATION, true, 
&pPoolItem );
     if( aState == SfxItemState::DONTCARE )
     {
-        m_pCB_ShowEquation->EnableTriState();
-        m_pCB_ShowEquation->SetState( TRISTATE_INDET );
+        m_xCB_ShowEquation->set_state(TRISTATE_INDET);
     }
     else
     {
-        m_pCB_ShowEquation->EnableTriState( false );
         if( aState == SfxItemState::SET )
-            m_pCB_ShowEquation->Check( static_cast< const SfxBoolItem * >( 
pPoolItem )->GetValue());
+            m_xCB_ShowEquation->set_active( static_cast< const SfxBoolItem * 
>( pPoolItem )->GetValue());
     }
 
     aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_SHOW_COEFF, true, 
&pPoolItem );
     if( aState == SfxItemState::DONTCARE )
     {
-        m_pCB_ShowCorrelationCoeff->EnableTriState();
-        m_pCB_ShowCorrelationCoeff->SetState( TRISTATE_INDET );
+        m_xCB_ShowCorrelationCoeff->set_state(TRISTATE_INDET);
     }
     else
     {
-        m_pCB_ShowCorrelationCoeff->EnableTriState( false );
         if( aState == SfxItemState::SET )
-            m_pCB_ShowCorrelationCoeff->Check( static_cast< const SfxBoolItem 
* >( pPoolItem )->GetValue());
+            m_xCB_ShowCorrelationCoeff->set_active( static_cast< const 
SfxBoolItem * >( pPoolItem )->GetValue());
     }
 
     if( m_bTrendLineUnique )
@@ -239,22 +233,22 @@ void TrendlineResources::Reset( const SfxItemSet& 
rInAttrs )
         switch( m_eTrendLineType )
         {
             case SvxChartRegress::Linear :
-                m_pRB_Linear->Check();
+                m_xRB_Linear->set_active(true);
                 break;
             case SvxChartRegress::Log :
-                m_pRB_Logarithmic->Check();
+                m_xRB_Logarithmic->set_active(true);
                 break;
             case SvxChartRegress::Exp :
-                m_pRB_Exponential->Check();
+                m_xRB_Exponential->set_active(true);
                 break;
             case SvxChartRegress::Power :
-                m_pRB_Power->Check();
+                m_xRB_Power->set_active(true);
                 break;
             case SvxChartRegress::Polynomial :
-                m_pRB_Polynomial->Check();
+                m_xRB_Polynomial->set_active(true);
                 break;
             case SvxChartRegress::MovingAverage :
-                m_pRB_MovingAverage->Check();
+                m_xRB_MovingAverage->set_active(true);
                 break;
             default:
                 break;
@@ -267,116 +261,117 @@ void TrendlineResources::FillItemSet(SfxItemSet* 
rOutAttrs) const
     if( m_bTrendLineUnique )
         rOutAttrs->Put( SvxChartRegressItem( m_eTrendLineType, 
SCHATTR_REGRESSION_TYPE ));
 
-    if( m_pCB_ShowEquation->GetState() != TRISTATE_INDET )
-        rOutAttrs->Put( SfxBoolItem( SCHATTR_REGRESSION_SHOW_EQUATION, 
m_pCB_ShowEquation->IsChecked() ));
+    if( m_xCB_ShowEquation->get_state() != TRISTATE_INDET )
+        rOutAttrs->Put( SfxBoolItem( SCHATTR_REGRESSION_SHOW_EQUATION, 
m_xCB_ShowEquation->get_active() ));
 
-    if( m_pCB_ShowCorrelationCoeff->GetState() != TRISTATE_INDET )
-        rOutAttrs->Put( SfxBoolItem( SCHATTR_REGRESSION_SHOW_COEFF, 
m_pCB_ShowCorrelationCoeff->IsChecked() ));
+    if( m_xCB_ShowCorrelationCoeff->get_state() != TRISTATE_INDET )
+        rOutAttrs->Put( SfxBoolItem( SCHATTR_REGRESSION_SHOW_COEFF, 
m_xCB_ShowCorrelationCoeff->get_active() ));
 
-    OUString aName = m_pEE_Name->GetText();
+    OUString aName = m_xEE_Name->get_text();
     rOutAttrs->Put(SfxStringItem(SCHATTR_REGRESSION_CURVE_NAME, aName));
-    aName = m_pEE_XName->GetText();
+    aName = m_xEE_XName->get_text();
     if ( aName.isEmpty() )
         aName = "x";
     rOutAttrs->Put(SfxStringItem(SCHATTR_REGRESSION_XNAME, aName));
-    aName = m_pEE_YName->GetText();
+    aName = m_xEE_YName->get_text();
     if ( aName.isEmpty() )
         aName = "f(x)";
     rOutAttrs->Put(SfxStringItem(SCHATTR_REGRESSION_YNAME, aName));
 
-    sal_Int32 aDegree = m_pNF_Degree->GetValue();
+    sal_Int32 aDegree = m_xNF_Degree->get_value();
     rOutAttrs->Put(SfxInt32Item( SCHATTR_REGRESSION_DEGREE, aDegree ) );
 
-    sal_Int32 aPeriod = m_pNF_Period->GetValue();
+    sal_Int32 aPeriod = m_xNF_Period->get_value();
     rOutAttrs->Put(SfxInt32Item( SCHATTR_REGRESSION_PERIOD, aPeriod ) );
 
     sal_uInt32 nIndex = 0;
     double aValue = 0.0;
-    
(void)m_pNumFormatter->IsNumberFormat(m_pFmtFld_ExtrapolateForward->GetText(),nIndex,aValue);
+    
(void)m_pNumFormatter->IsNumberFormat(m_xFmtFld_ExtrapolateForward->get_text(),nIndex,aValue);
     rOutAttrs->Put(SvxDoubleItem( aValue, 
SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD ) );
 
     aValue = 0.0;
-    
(void)m_pNumFormatter->IsNumberFormat(m_pFmtFld_ExtrapolateBackward->GetText(),nIndex,aValue);
+    
(void)m_pNumFormatter->IsNumberFormat(m_xFmtFld_ExtrapolateBackward->get_text(),nIndex,aValue);
     rOutAttrs->Put(SvxDoubleItem( aValue, 
SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD ) );
 
-    if( m_pCB_SetIntercept->GetState() != TRISTATE_INDET )
-        rOutAttrs->Put( SfxBoolItem( SCHATTR_REGRESSION_SET_INTERCEPT, 
m_pCB_SetIntercept->IsChecked() ));
+    if( m_xCB_SetIntercept->get_state() != TRISTATE_INDET )
+        rOutAttrs->Put( SfxBoolItem( SCHATTR_REGRESSION_SET_INTERCEPT, 
m_xCB_SetIntercept->get_active() ));
 
     aValue = 0.0;
-    
(void)m_pNumFormatter->IsNumberFormat(m_pFmtFld_InterceptValue->GetText(),nIndex,aValue);
+    
(void)m_pNumFormatter->IsNumberFormat(m_xFmtFld_InterceptValue->get_text(),nIndex,aValue);
     rOutAttrs->Put(SvxDoubleItem( aValue, SCHATTR_REGRESSION_INTERCEPT_VALUE ) 
);
 }
 
 void TrendlineResources::FillValueSets()
 {
-    m_pFI_Linear->SetImage(Image(BitmapEx(BMP_REGRESSION_LINEAR)));
-    m_pFI_Logarithmic->SetImage(Image(BitmapEx(BMP_REGRESSION_LOG)));
-    m_pFI_Exponential->SetImage(Image(BitmapEx(BMP_REGRESSION_EXP)));
-    m_pFI_Power->SetImage(Image(BitmapEx(BMP_REGRESSION_POWER)));
-    m_pFI_Polynomial->SetImage(Image(BitmapEx(BMP_REGRESSION_POLYNOMIAL)));
-    
m_pFI_MovingAverage->SetImage(Image(BitmapEx(BMP_REGRESSION_MOVING_AVERAGE)));
+    m_xFI_Linear->set_from_icon_name(BMP_REGRESSION_LINEAR);
+    m_xFI_Logarithmic->set_from_icon_name(BMP_REGRESSION_LOG);
+    m_xFI_Exponential->set_from_icon_name(BMP_REGRESSION_EXP);
+    m_xFI_Power->set_from_icon_name(BMP_REGRESSION_POWER);
+    m_xFI_Polynomial->set_from_icon_name(BMP_REGRESSION_POLYNOMIAL);
+    m_xFI_MovingAverage->set_from_icon_name(BMP_REGRESSION_MOVING_AVERAGE);
 }
 
 void TrendlineResources::UpdateControlStates()
 {
     if( m_nNbPoints > 0 )
     {
-        sal_Int32 nMaxValue = m_nNbPoints - 1 + ( 
m_pCB_SetIntercept->IsChecked()?1:0 );
-//        if( nMaxValue > 10) nMaxValue = 10;
-        m_pNF_Degree->SetMax( nMaxValue );
-        m_pNF_Period->SetMax( m_nNbPoints - 1 );
+        sal_Int32 nMaxValue = m_nNbPoints - 1 + 
(m_xCB_SetIntercept->get_active() ? 1 : 0);
+        m_xNF_Degree->set_max(nMaxValue);
+        m_xNF_Period->set_max(m_nNbPoints - 1);
     }
     bool bMovingAverage = ( m_eTrendLineType == SvxChartRegress::MovingAverage 
);
     bool bInterceptAvailable = ( m_eTrendLineType == SvxChartRegress::Linear )
                             || ( m_eTrendLineType == 
SvxChartRegress::Polynomial )
                             || ( m_eTrendLineType == SvxChartRegress::Exp );
-    m_pFmtFld_ExtrapolateForward->Enable( !bMovingAverage );
-    m_pFmtFld_ExtrapolateBackward->Enable( !bMovingAverage );
-    m_pCB_SetIntercept->Enable( bInterceptAvailable );
-    m_pFmtFld_InterceptValue->Enable( bInterceptAvailable );
+    m_xFmtFld_ExtrapolateForward->set_sensitive( !bMovingAverage );
+    m_xFmtFld_ExtrapolateBackward->set_sensitive( !bMovingAverage );
+    m_xCB_SetIntercept->set_sensitive( bInterceptAvailable );
+    m_xFmtFld_InterceptValue->set_sensitive( bInterceptAvailable );
     if( bMovingAverage )
     {
-        m_pCB_ShowEquation->SetState( TRISTATE_FALSE );
-        m_pCB_ShowCorrelationCoeff->SetState( TRISTATE_FALSE );
+        m_xCB_ShowEquation->set_state(TRISTATE_FALSE);
+        m_xCB_ShowCorrelationCoeff->set_state(TRISTATE_FALSE);
     }
-    m_pCB_ShowEquation->Enable( !bMovingAverage );
-    m_pCB_ShowCorrelationCoeff->Enable( !bMovingAverage );
-    m_pEE_XName->Enable( !bMovingAverage && m_pCB_ShowEquation->IsChecked() );
-    m_pEE_YName->Enable( !bMovingAverage && m_pCB_ShowEquation->IsChecked() );
+    m_xCB_ShowEquation->set_sensitive( !bMovingAverage );
+    m_xCB_ShowCorrelationCoeff->set_sensitive( !bMovingAverage );
+    m_xEE_XName->set_sensitive( !bMovingAverage && 
m_xCB_ShowEquation->get_active() );
+    m_xEE_YName->set_sensitive( !bMovingAverage && 
m_xCB_ShowEquation->get_active() );
 }
 
-IMPL_LINK( TrendlineResources, ChangeValue, Edit&, rNumericField, void)
+IMPL_LINK(TrendlineResources, ChangeSpinValue, weld::SpinButton&, 
rNumericField, void)
 {
-    if( &rNumericField == m_pNF_Degree )
+    if (&rNumericField == m_xNF_Degree.get())
     {
-        if( !m_pRB_Polynomial->IsChecked() )
+        if (!m_xRB_Polynomial->get_active())
         {
-                m_pRB_Polynomial->Check();
-                SelectTrendLine(m_pRB_Polynomial);
+            m_xRB_Polynomial->set_active(true);
+            SelectTrendLine(*m_xRB_Polynomial);
         }
     }
-    else if( &rNumericField == m_pNF_Period )
+    else if (&rNumericField == m_xNF_Period.get())
     {
-        if( !m_pRB_MovingAverage->IsChecked() )
+        if (!m_xRB_MovingAverage->get_active())
         {
-                m_pRB_MovingAverage->Check();
-                SelectTrendLine(m_pRB_MovingAverage);
+            m_xRB_MovingAverage->set_active(true);
+            SelectTrendLine(*m_xRB_MovingAverage);
         }
     }
-    else if( &rNumericField == m_pFmtFld_InterceptValue )
-    {
-        if( !m_pCB_SetIntercept->IsChecked() )
-                m_pCB_SetIntercept->Check();
-    }
+    UpdateControlStates();
+}
+
+IMPL_LINK_NOARG(TrendlineResources, ChangeFormattedValue, 
weld::FormattedSpinButton&, void)
+{
+    if (!m_xCB_SetIntercept->get_active())
+        m_xCB_SetIntercept->set_active(true);
     UpdateControlStates();
 }
 
 void TrendlineResources::SetNumFormatter( SvNumberFormatter* pFormatter )
 {
     m_pNumFormatter = pFormatter;
-    m_pFmtFld_ExtrapolateForward->SetFormatter( m_pNumFormatter );
-    m_pFmtFld_ExtrapolateBackward->SetFormatter( m_pNumFormatter );
-    m_pFmtFld_InterceptValue->SetFormatter( m_pNumFormatter );
+    m_xFmtFld_ExtrapolateForward->set_formatter( m_pNumFormatter );
+    m_xFmtFld_ExtrapolateBackward->set_formatter( m_pNumFormatter );
+    m_xFmtFld_InterceptValue->set_formatter( m_pNumFormatter );
 }
 
 void TrendlineResources::SetNbPoints( sal_Int32 nNbPoints )
@@ -385,13 +380,10 @@ void TrendlineResources::SetNbPoints( sal_Int32 nNbPoints 
)
     UpdateControlStates();
 }
 
-IMPL_LINK( TrendlineResources, ShowEquation, CheckBox&, rCheckBox, void)
+IMPL_LINK_NOARG(TrendlineResources, ShowEquation, weld::ToggleButton&, void)
 {
-    if( &rCheckBox == m_pCB_ShowEquation )
-    {
-        m_pEE_XName->Enable( m_pCB_ShowEquation->IsChecked() );
-        m_pEE_YName->Enable( m_pCB_ShowEquation->IsChecked() );
-    }
+    m_xEE_XName->set_sensitive(m_xCB_ShowEquation->get_active());
+    m_xEE_YName->set_sensitive(m_xCB_ShowEquation->get_active());
     UpdateControlStates();
 }
 
diff --git a/chart2/source/controller/dialogs/res_Trendline.hxx 
b/chart2/source/controller/dialogs/res_Trendline.hxx
index 604b8d38d236..0d5eb85e8a1f 100644
--- a/chart2/source/controller/dialogs/res_Trendline.hxx
+++ b/chart2/source/controller/dialogs/res_Trendline.hxx
@@ -19,12 +19,9 @@
 #ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_RES_TRENDLINE_HXX
 #define INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_RES_TRENDLINE_HXX
 
-#include <vcl/button.hxx>
-#include <vcl/fixed.hxx>
 #include <svl/itemset.hxx>
 #include <svx/chrtitem.hxx>
-#include <vcl/field.hxx>
-#include <vcl/fmtfield.hxx>
+#include <vcl/weld.hxx>
 
 class SvNumberFormatter;
 
@@ -34,7 +31,7 @@ namespace chart
 class TrendlineResources final
 {
 public:
-    TrendlineResources( vcl::Window* pParent, const SfxItemSet& rInAttrs );
+    TrendlineResources(weld::Builder& rParent, const SfxItemSet& rInAttrs);
     ~TrendlineResources();
 
     void Reset(const SfxItemSet& rInAttrs);
@@ -46,32 +43,6 @@ public:
     void SetNbPoints( sal_Int32 nNbPoints );
 
 private:
-    VclPtr<RadioButton> m_pRB_Linear;
-    VclPtr<RadioButton> m_pRB_Logarithmic;
-    VclPtr<RadioButton> m_pRB_Exponential;
-    VclPtr<RadioButton> m_pRB_Power;
-    VclPtr<RadioButton> m_pRB_Polynomial;
-    VclPtr<RadioButton> m_pRB_MovingAverage;
-
-    VclPtr<FixedImage>  m_pFI_Linear;
-    VclPtr<FixedImage>  m_pFI_Logarithmic;
-    VclPtr<FixedImage>  m_pFI_Exponential;
-    VclPtr<FixedImage>  m_pFI_Power;
-    VclPtr<FixedImage>  m_pFI_Polynomial;
-    VclPtr<FixedImage>  m_pFI_MovingAverage;
-
-    VclPtr<NumericField>    m_pNF_Degree;
-    VclPtr<NumericField>    m_pNF_Period;
-    VclPtr<Edit>            m_pEE_Name;
-    VclPtr<FormattedField>  m_pFmtFld_ExtrapolateForward;
-    VclPtr<FormattedField>  m_pFmtFld_ExtrapolateBackward;
-    VclPtr<CheckBox>        m_pCB_SetIntercept;
-    VclPtr<FormattedField>  m_pFmtFld_InterceptValue;
-    VclPtr<CheckBox>        m_pCB_ShowEquation;
-    VclPtr<Edit>            m_pEE_XName;
-    VclPtr<Edit>            m_pEE_YName;
-    VclPtr<CheckBox>        m_pCB_ShowCorrelationCoeff;
-
     SvxChartRegress     m_eTrendLineType;
 
     bool                m_bTrendLineUnique;
@@ -79,10 +50,37 @@ private:
     SvNumberFormatter*  m_pNumFormatter;
     sal_Int32           m_nNbPoints;
 
+    std::unique_ptr<weld::RadioButton> m_xRB_Linear;
+    std::unique_ptr<weld::RadioButton> m_xRB_Logarithmic;
+    std::unique_ptr<weld::RadioButton> m_xRB_Exponential;
+    std::unique_ptr<weld::RadioButton> m_xRB_Power;
+    std::unique_ptr<weld::RadioButton> m_xRB_Polynomial;
+    std::unique_ptr<weld::RadioButton> m_xRB_MovingAverage;
+
+    std::unique_ptr<weld::Image> m_xFI_Linear;
+    std::unique_ptr<weld::Image> m_xFI_Logarithmic;
+    std::unique_ptr<weld::Image> m_xFI_Exponential;
+    std::unique_ptr<weld::Image> m_xFI_Power;
+    std::unique_ptr<weld::Image> m_xFI_Polynomial;
+    std::unique_ptr<weld::Image> m_xFI_MovingAverage;
+
+    std::unique_ptr<weld::SpinButton> m_xNF_Degree;
+    std::unique_ptr<weld::SpinButton> m_xNF_Period;
+    std::unique_ptr<weld::Entry> m_xEE_Name;
+    std::unique_ptr<weld::FormattedSpinButton> m_xFmtFld_ExtrapolateForward;
+    std::unique_ptr<weld::FormattedSpinButton> m_xFmtFld_ExtrapolateBackward;
+    std::unique_ptr<weld::CheckButton> m_xCB_SetIntercept;
+    std::unique_ptr<weld::FormattedSpinButton> m_xFmtFld_InterceptValue;
+    std::unique_ptr<weld::CheckButton> m_xCB_ShowEquation;
+    std::unique_ptr<weld::Entry> m_xEE_XName;
+    std::unique_ptr<weld::Entry> m_xEE_YName;
+    std::unique_ptr<weld::CheckButton> m_xCB_ShowCorrelationCoeff;
+
     void UpdateControlStates();
-    DECL_LINK( SelectTrendLine, Button*, void );
-    DECL_LINK( ChangeValue, Edit&, void);
-    DECL_LINK( ShowEquation, CheckBox&, void);
+    DECL_LINK(SelectTrendLine, weld::ToggleButton&, void);
+    DECL_LINK(ChangeSpinValue, weld::SpinButton&, void);
+    DECL_LINK(ChangeFormattedValue, weld::FormattedSpinButton&, void);
+    DECL_LINK(ShowEquation, weld::ToggleButton&, void);
 };
 
 } //  namespace chart
diff --git a/chart2/source/controller/dialogs/tp_Trendline.cxx 
b/chart2/source/controller/dialogs/tp_Trendline.cxx
index dc316a8fa54a..60d77bf29280 100644
--- a/chart2/source/controller/dialogs/tp_Trendline.cxx
+++ b/chart2/source/controller/dialogs/tp_Trendline.cxx
@@ -24,16 +24,15 @@
 namespace chart
 {
 
-TrendlineTabPage::TrendlineTabPage( vcl::Window* pParent, const SfxItemSet& 
rInAttrs ) :
-        SfxTabPage( pParent, "TP_TRENDLINE", 
"modules/schart/ui/tp_Trendline.ui", &rInAttrs ),
-        m_aTrendlineResources( this, rInAttrs )
+TrendlineTabPage::TrendlineTabPage(TabPageParent pParent, const SfxItemSet& 
rInAttrs)
+    : SfxTabPage(pParent, "modules/schart/ui/tp_Trendline.ui", "TP_TRENDLINE", 
&rInAttrs)
+    , m_aTrendlineResources(*m_xBuilder, rInAttrs)
 {
 }
 
-VclPtr<SfxTabPage> TrendlineTabPage::Create(
-    TabPageParent pParent, const SfxItemSet* rOutAttrs )
+VclPtr<SfxTabPage> TrendlineTabPage::Create(TabPageParent pParent, const 
SfxItemSet* rOutAttrs)
 {
-    return VclPtr<TrendlineTabPage>::Create( pParent.pParent, *rOutAttrs );
+    return VclPtr<TrendlineTabPage>::Create(pParent, *rOutAttrs);
 }
 
 bool TrendlineTabPage::FillItemSet( SfxItemSet* rOutAttrs )
diff --git a/chart2/source/controller/dialogs/tp_Trendline.hxx 
b/chart2/source/controller/dialogs/tp_Trendline.hxx
index 8981939b5009..03dd251cb91e 100644
--- a/chart2/source/controller/dialogs/tp_Trendline.hxx
+++ b/chart2/source/controller/dialogs/tp_Trendline.hxx
@@ -29,7 +29,7 @@ namespace chart
 class TrendlineTabPage : public SfxTabPage
 {
 public:
-    TrendlineTabPage ( vcl::Window* pParent, const SfxItemSet& rInAttrs );
+    TrendlineTabPage(TabPageParent pParent, const SfxItemSet& rInAttrs);
 
     static VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* 
rInAttrs );
     virtual bool FillItemSet( SfxItemSet* rOutAttrs ) override;
diff --git a/chart2/uiconfig/ui/tp_Trendline.ui 
b/chart2/uiconfig/ui/tp_Trendline.ui
index 697b001751e9..a9550a9ebe9d 100644
--- a/chart2/uiconfig/ui/tp_Trendline.ui
+++ b/chart2/uiconfig/ui/tp_Trendline.ui
@@ -1,4 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
 <interface domain="chart">
   <requires lib="gtk+" version="3.18"/>
   <object class="GtkAdjustment" id="adjustmentDegree">
@@ -7,7 +8,19 @@
     <property name="step_increment">1</property>
     <property name="page_increment">10</property>
   </object>
-  <object class="GtkAdjustment" id="adjustmentForwardBacward">
+  <object class="GtkAdjustment" id="adjustmentForwardBackward">
+    <property name="lower">-10000</property>
+    <property name="upper">10000</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustmentForwardBackward1">
+    <property name="lower">-10000</property>
+    <property name="upper">10000</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustmentForwardBackward2">
     <property name="lower">-10000</property>
     <property name="upper">10000</property>
     <property name="step_increment">1</property>
@@ -57,13 +70,10 @@
                     <property name="xalign">0</property>
                     <property name="active">True</property>
                     <property name="draw_indicator">True</property>
-                    <property name="group">logarithmic</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>
                 <child>
@@ -76,13 +86,11 @@
                     <property name="xalign">0</property>
                     <property name="active">True</property>
                     <property name="draw_indicator">True</property>
-                    <property name="group">exponential</property>
+                    <property name="group">linear</property>
                   </object>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="top_attach">1</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -95,13 +103,11 @@
                     <property name="xalign">0</property>
                     <property name="active">True</property>
                     <property name="draw_indicator">True</property>
-                    <property name="group">power</property>
+                    <property name="group">linear</property>
                   </object>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="top_attach">2</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -114,13 +120,11 @@
                     <property name="xalign">0</property>
                     <property name="active">True</property>
                     <property name="draw_indicator">True</property>
-                    <property name="group">polynomial</property>
+                    <property name="group">linear</property>
                   </object>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="top_attach">3</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -133,13 +137,11 @@
                     <property name="xalign">0</property>
                     <property name="active">True</property>
                     <property name="draw_indicator">True</property>
-                    <property name="group">movingAverage</property>
+                    <property name="group">linear</property>
                   </object>
                   <packing>
                     <property name="left_attach">3</property>
                     <property name="top_attach">0</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -157,8 +159,6 @@
                   <packing>
                     <property name="left_attach">3</property>
                     <property name="top_attach">2</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -171,33 +171,30 @@
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="label" translatable="yes" 
context="tp_Trendline|label3">Degree</property>
+                        <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">degree</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="GtkSpinButton" id="degree">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
+                        <property name="activates_default">True</property>
                         <property name="adjustment">adjustmentDegree</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>
                   <packing>
                     <property name="left_attach">3</property>
                     <property name="top_attach">1</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -210,33 +207,30 @@
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="label" translatable="yes" 
context="tp_Trendline|label4">Period</property>
+                        <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">period</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="GtkSpinButton" id="period">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
+                        <property name="activates_default">True</property>
                         <property name="adjustment">adjustmentPeriod</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>
                   <packing>
                     <property name="left_attach">3</property>
                     <property name="top_attach">3</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -248,8 +242,6 @@
                   <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>
@@ -261,8 +253,6 @@
                   <packing>
                     <property name="left_attach">0</property>
                     <property name="top_attach">1</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -274,8 +264,6 @@
                   <packing>
                     <property name="left_attach">0</property>
                     <property name="top_attach">2</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -287,8 +275,6 @@
                   <packing>
                     <property name="left_attach">0</property>
                     <property name="top_attach">3</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -300,8 +286,6 @@
                   <packing>
                     <property name="left_attach">2</property>
                     <property name="top_attach">0</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -313,8 +297,6 @@
                   <packing>
                     <property name="left_attach">2</property>
                     <property name="top_attach">2</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -367,58 +349,55 @@
                   <object class="GtkLabel" id="label7">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes" 
context="tp_Trendline|label7">Extrapolate Forward</property>
                     <property name="use_underline">True</property>
                     <property 
name="mnemonic_widget">extrapolateForward</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
                     <property name="top_attach">1</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="label8">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes" 
context="tp_Trendline|label8">Extrapolate Backward</property>
                     <property name="use_underline">True</property>
                     <property 
name="mnemonic_widget">extrapolateBackward</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
                     <property name="top_attach">2</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="svtlo-FormattedField" id="extrapolateForward">
+                  <object class="GtkSpinButton" id="extrapolateForward">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
+                    <property name="activates_default">True</property>
                     <property name="caps_lock_warning">False</property>
-                    <property name="input_purpose">number</property>
+                    <property 
name="adjustment">adjustmentForwardBackward</property>
+                    <property name="digits">2</property>
                   </object>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="top_attach">1</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="svtlo-FormattedField" 
id="extrapolateBackward">
+                  <object class="GtkSpinButton" id="extrapolateBackward">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
+                    <property name="activates_default">True</property>
+                    <property 
name="adjustment">adjustmentForwardBackward1</property>
+                    <property name="digits">2</property>
                   </object>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="top_attach">2</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -430,12 +409,13 @@
                     <property name="use_underline">True</property>
                     <property name="xalign">0</property>
                     <property name="draw_indicator">True</property>
+                    <accessibility>
+                      <relation type="label-for" target="interceptValue"/>
+                    </accessibility>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
                     <property name="top_attach">3</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -452,7 +432,6 @@
                     <property name="left_attach">0</property>
                     <property name="top_attach">4</property>
                     <property name="width">2</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -469,106 +448,100 @@
                     <property name="left_attach">0</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" 
context="tp_Trendline|label5">Trendline _Name</property>
                     <property name="use_underline">True</property>
                     <property name="mnemonic_widget">entry_name</property>
+                    <property name="xalign">0</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="activates_default">True</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>
                 <child>
-                  <object class="svtlo-FormattedField" id="interceptValue">
+                  <object class="GtkSpinButton" id="interceptValue">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="text" translatable="no">0</property>
+                    <property name="activates_default">True</property>
+                    <property name="text">0</property>
                     <property name="caps_lock_warning">False</property>
                     <property name="input_purpose">number</property>
+                    <property 
name="adjustment">adjustmentForwardBackward2</property>
+                    <property name="digits">2</property>
+                    <accessibility>
+                      <relation type="labelled-by" target="setIntercept"/>
+                    </accessibility>
                   </object>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="top_attach">3</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="label6">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes" 
context="tp_Trendline|label6">_X Variable Name</property>
                     <property name="use_underline">True</property>
                     <property name="mnemonic_widget">entry_Xname</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
                     <property name="top_attach">6</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkEntry" id="entry_Xname">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                </object>
+                    <property name="activates_default">True</property>
+                  </object>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="top_attach">6</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="label9">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes" 
context="tp_Trendline|label9">_Y Variable Name</property>
                     <property name="use_underline">True</property>
                     <property name="mnemonic_widget">entry_Yname</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
                     <property name="top_attach">7</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkEntry" id="entry_Yname">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                </object>
+                    <property name="activates_default">True</property>
+                  </object>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="top_attach">7</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
               </object>
@@ -593,4 +566,10 @@
       </packing>
     </child>
   </object>
+  <object class="GtkSizeGroup">
+    <widgets>
+      <widget name="label3"/>
+      <widget name="label4"/>
+    </widgets>
+  </object>
 </interface>
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index df4dcc5aeba0..dcc59a201603 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -24,6 +24,8 @@
 typedef css::uno::Reference<css::accessibility::XAccessible> a11yref;
 typedef css::uno::Reference<css::accessibility::XAccessibleRelationSet> 
a11yrelationset;
 
+class SvNumberFormatter;
+
 namespace vcl
 {
 class ILibreOfficeKitNotifier;
@@ -692,6 +694,34 @@ public:
     static unsigned int Power10(unsigned int n);
 };
 
+class VCL_DLLPUBLIC FormattedSpinButton : virtual public Entry
+{
+protected:
+    Link<FormattedSpinButton&, void> m_aValueChangedHdl;
+
+    void signal_value_changed() { m_aValueChangedHdl.Call(*this); }
+
+public:
+    virtual void set_value(double value) = 0;
+    virtual double get_value() const = 0;
+    virtual void set_range(double min, double max) = 0;
+    virtual void get_range(double& min, double& max) const = 0;
+
+    void set_max(double max)
+    {
+        double min, dummy;
+        get_range(min, dummy);
+        set_range(min, max);
+    }
+
+    virtual void set_formatter(SvNumberFormatter* pFormatter) = 0;
+
+    void connect_value_changed(const Link<FormattedSpinButton&, void>& rLink)
+    {
+        m_aValueChangedHdl = rLink;
+    }
+};
+
 class VCL_DLLPUBLIC Image : virtual public Widget
 {
 public:
@@ -1200,6 +1230,8 @@ public:
         = 0;
     virtual std::unique_ptr<MetricSpinButton>
     weld_metric_spin_button(const OString& id, FieldUnit eUnit, bool 
bTakeOwnership = false) = 0;
+    virtual std::unique_ptr<FormattedSpinButton>
+    weld_formatted_spin_button(const OString& id, bool bTakeOwnership = false) 
= 0;
     virtual std::unique_ptr<TimeSpinButton>
     weld_time_spin_button(const OString& id, TimeFieldFormat eFormat, bool 
bTakeOwnership = false)
         = 0;
diff --git a/vcl/Library_vclplug_gtk3.mk b/vcl/Library_vclplug_gtk3.mk
index 5ecf70bb4d0f..999eac743a9e 100644
--- a/vcl/Library_vclplug_gtk3.mk
+++ b/vcl/Library_vclplug_gtk3.mk
@@ -58,6 +58,7 @@ $(eval $(call gb_Library_add_libs,vclplug_gtk3,\
 
 $(eval $(call gb_Library_use_libraries,vclplug_gtk3,\
     vcl \
+    svl \
     tl \
     utl \
     sot \
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index cd6f0fc39417..82f1138c7537 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -2083,6 +2083,46 @@ IMPL_LINK(SalInstanceSpinButton, InputHdl, sal_Int64*, 
pResult, TriState)
     return eRet;
 }
 
+class SalInstanceFormattedSpinButton : public SalInstanceEntry, public virtual 
weld::FormattedSpinButton
+{
+private:
+    VclPtr<FormattedField> m_xButton;
+
+public:
+    SalInstanceFormattedSpinButton(FormattedField* pButton, bool 
bTakeOwnership)
+        : SalInstanceEntry(pButton, bTakeOwnership)
+        , m_xButton(pButton)
+    {
+    }
+
+    virtual double get_value() const override
+    {
+        return m_xButton->GetValue();
+    }
+
+    virtual void set_value(double value) override
+    {
+        m_xButton->SetValue(value);
+    }
+
+    virtual void set_range(double min, double max) override
+    {
+        m_xButton->SetMinValue(min);
+        m_xButton->SetMaxValue(max);
+    }
+
+    virtual void get_range(double& min, double& max) const override
+    {
+        min = m_xButton->GetMinValue();
+        max = m_xButton->GetMaxValue();
+    }
+
+    virtual void set_formatter(SvNumberFormatter* pFormatter) override
+    {
+        m_xButton->SetFormatter(pFormatter);
+    }
+};
+
 class SalInstanceLabel : public SalInstanceWidget, public virtual weld::Label
 {
 private:
@@ -2940,6 +2980,13 @@ public:
         return o3tl::make_unique<weld::MetricSpinButton>(std::move(xButton), 
eUnit);
     }
 
+    virtual std::unique_ptr<weld::FormattedSpinButton> 
weld_formatted_spin_button(const OString& id,
+                                                                               
   bool bTakeOwnership) override
+    {
+        FormattedField* pSpinButton = m_xBuilder->get<FormattedField>(id);
+        return pSpinButton ? 
o3tl::make_unique<SalInstanceFormattedSpinButton>(pSpinButton, bTakeOwnership) 
: nullptr;
+    }
+
     virtual std::unique_ptr<weld::TimeSpinButton> weld_time_spin_button(const 
OString& id, TimeFieldFormat eFormat,
                                                         bool bTakeOwnership) 
override
     {
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 05b622c24015..d23daa538d3f 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -30,6 +30,8 @@
 #include <cppuhelper/supportsservice.hxx>
 #include <rtl/bootstrap.hxx>
 #include <sal/log.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/zformat.hxx>
 #include <tools/fract.hxx>
 #include <tools/stream.hxx>
 #include <unotools/resmgr.hxx>
@@ -4401,18 +4403,18 @@ private:
         return pThis->signal_output();
     }
 
-    static gboolean signalInput(GtkSpinButton*, gdouble* new_value, gpointer 
widget)
+    static gint signalInput(GtkSpinButton*, gdouble* new_value, gpointer 
widget)
     {
         GtkInstanceSpinButton* pThis = 
static_cast<GtkInstanceSpinButton*>(widget);
         SolarMutexGuard aGuard;
         int result;
         TriState eHandled = pThis->signal_input(&result);
         if (eHandled == TRISTATE_INDET)
-            return false;
+            return 0;
         if (eHandled == TRISTATE_TRUE)
         {
             *new_value = pThis->toGtk(result);
-            return true;
+            return 1;
         }
         return GTK_INPUT_ERROR;
     }
@@ -4511,6 +4513,159 @@ public:
     }
 };
 
+class GtkInstanceFormattedSpinButton : public GtkInstanceEntry, public virtual 
weld::FormattedSpinButton
+{
+private:
+    GtkSpinButton* m_pButton;
+    SvNumberFormatter* m_pFormatter;
+    Color* m_pLastOutputColor;
+    sal_uInt32 m_nFormatKey;
+    gulong m_nValueChangedSignalId;
+    gulong m_nOutputSignalId;
+    gulong m_nInputSignalId;
+
+    bool signal_output()
+    {
+        if (!m_pFormatter)
+            return false;
+        double dVal = get_value();
+        OUString sNewText;
+        if (m_pFormatter->IsTextFormat(m_nFormatKey))
+        {
+            // first convert the number as string in standard format
+            OUString sTemp;
+            m_pFormatter->GetOutputString(dVal, 0, sTemp, &m_pLastOutputColor);
+            // then encode the string in the corresponding text format
+            m_pFormatter->GetOutputString(sTemp, m_nFormatKey, sNewText, 
&m_pLastOutputColor);
+        }
+        else
+        {
+            m_pFormatter->GetOutputString(dVal, m_nFormatKey, sNewText, 
&m_pLastOutputColor);
+        }
+        set_text(sNewText);
+        return true;
+    }
+
+    static gboolean signalOutput(GtkSpinButton*, gpointer widget)
+    {
+        GtkInstanceFormattedSpinButton* pThis = 
static_cast<GtkInstanceFormattedSpinButton*>(widget);
+        SolarMutexGuard aGuard;
+        return pThis->signal_output();
+    }
+
+    gint signal_input(double* value)
+    {
+        if (!m_pFormatter)
+            return 0;
+
+        sal_uInt32 nFormatKey = m_nFormatKey; // IsNumberFormat changes the 
FormatKey!
+
+        if (m_pFormatter->IsTextFormat(nFormatKey))
+            // for detection of values like "1,1" in fields that are formatted 
as text
+            nFormatKey = 0;
+
+        OUString sText(get_text());
+
+        // special treatment for percentage formatting
+        if (m_pFormatter->GetType(m_nFormatKey) == SvNumFormatType::PERCENT)
+        {
+            // the language of our format
+            LanguageType eLanguage = 
m_pFormatter->GetEntry(m_nFormatKey)->GetLanguage();
+            // the default number format for this language
+            sal_uLong nStandardNumericFormat = 
m_pFormatter->GetStandardFormat(SvNumFormatType::NUMBER, eLanguage);
+
+            sal_uInt32 nTempFormat = nStandardNumericFormat;
+            double dTemp;
+            if (m_pFormatter->IsNumberFormat(sText, nTempFormat, dTemp) &&
+                SvNumFormatType::NUMBER == m_pFormatter->GetType(nTempFormat))
+                // the string is equivalent to a number formatted one (has no 
% sign) -> append it
+                sText += "%";
+            // (with this, a input of '3' becomes '3%', which then by the 
formatter is translated
+            // into 0.03. Without this, the formatter would give us the double 
3 for an input '3',
+            // which equals 300 percent.
+        }
+        if (!m_pFormatter->IsNumberFormat(sText, nFormatKey, *value))
+            return GTK_INPUT_ERROR;
+
+        return 1;
+    }
+
+    static gint signalInput(GtkSpinButton*, gdouble* new_value, gpointer 
widget)
+    {
+        GtkInstanceFormattedSpinButton* pThis = 
static_cast<GtkInstanceFormattedSpinButton*>(widget);
+        SolarMutexGuard aGuard;
+        return pThis->signal_input(new_value);
+    }
+
+    static void signalValueChanged(GtkSpinButton*, gpointer widget)
+    {
+        GtkInstanceFormattedSpinButton* pThis = 
static_cast<GtkInstanceFormattedSpinButton*>(widget);
+        SolarMutexGuard aGuard;
+        pThis->signal_value_changed();
+    }
+
+public:
+    GtkInstanceFormattedSpinButton(GtkSpinButton* pButton, bool bTakeOwnership)
+        : GtkInstanceEntry(GTK_ENTRY(pButton), bTakeOwnership)
+        , m_pButton(pButton)
+        , m_pFormatter(nullptr)
+        , m_pLastOutputColor(nullptr)
+        , m_nFormatKey(0)
+        , m_nValueChangedSignalId(g_signal_connect(pButton, "value-changed", 
G_CALLBACK(signalValueChanged), this))
+        , m_nOutputSignalId(g_signal_connect(pButton, "output", 
G_CALLBACK(signalOutput), this))
+        , m_nInputSignalId(g_signal_connect(pButton, "input", 
G_CALLBACK(signalInput), this))
+    {
+    }
+
+    virtual double get_value() const override
+    {
+        return gtk_spin_button_get_value(m_pButton);
+    }
+
+    virtual void set_value(double value) override
+    {
+        disable_notify_events();
+        gtk_spin_button_set_value(m_pButton, value);
+        enable_notify_events();
+    }
+
+    virtual void set_range(double min, double max) override
+    {
+        disable_notify_events();
+        gtk_spin_button_set_range(m_pButton, min, max);
+        enable_notify_events();
+    }
+
+    virtual void get_range(double& min, double& max) const override
+    {
+        gtk_spin_button_get_range(m_pButton, &min, &max);
+    }
+
+    virtual void set_formatter(SvNumberFormatter* pFormatter) override
+    {
+        m_pFormatter = pFormatter;
+
+        // calc the default format key from the Office's UI locale
+        if (m_pFormatter)
+        {
+            // get the Office's locale and translate
+            LanguageType eSysLanguage = 
Application::GetSettings().GetUILanguageTag().getLanguageType( false);
+            // get the standard numeric format for this language
+            m_nFormatKey = m_pFormatter->GetStandardFormat( 
SvNumFormatType::NUMBER, eSysLanguage );
+        }
+        else
+            m_nFormatKey = 0;
+        signal_output();
+    }
+
+    virtual ~GtkInstanceFormattedSpinButton() override
+    {
+        g_signal_handler_disconnect(m_pButton, m_nInputSignalId);
+        g_signal_handler_disconnect(m_pButton, m_nOutputSignalId);
+        g_signal_handler_disconnect(m_pButton, m_nValueChangedSignalId);
+    }
+};
+
 class GtkInstanceLabel : public GtkInstanceWidget, public virtual weld::Label
 {
 private:
@@ -6224,6 +6379,15 @@ public:
         return o3tl::make_unique<weld::MetricSpinButton>(weld_spin_button(id, 
bTakeOwnership), eUnit);
     }
 
+    virtual std::unique_ptr<weld::FormattedSpinButton> 
weld_formatted_spin_button(const OString &id, bool bTakeOwnership) override
+    {
+        GtkSpinButton* pSpinButton = 
GTK_SPIN_BUTTON(gtk_builder_get_object(m_pBuilder, id.getStr()));
+        if (!pSpinButton)
+            return nullptr;
+        auto_add_parentless_widgets_to_container(GTK_WIDGET(pSpinButton));
+        return o3tl::make_unique<GtkInstanceFormattedSpinButton>(pSpinButton, 
bTakeOwnership);
+    }
+
     virtual std::unique_ptr<weld::TimeSpinButton> weld_time_spin_button(const 
OString& id, TimeFieldFormat eFormat,
                                                         bool bTakeOwnership) 
override
     {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to