summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-07-03 12:08:02 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-07-05 16:44:09 +0200
commit95cfa85395f983df3ba044192b29ce0bbc5e6085 (patch)
tree24388695e580fab69539bc4d9304e8a5535ef6bf /chart2
parent7b6549811a929e004266a6ead26b69d499c73e0c (diff)
adjust FormattedSpinButton to be driven by an EntryFormatter
so we can have the same backend driving the FormattedSpinButtons as a FormattedEntry Change-Id: I07a472315a04787eb5fcf992cde8f758af742156 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97860 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/controller/dialogs/res_Trendline.cxx22
-rw-r--r--chart2/source/controller/dialogs/tp_AxisPositions.cxx27
-rw-r--r--chart2/source/controller/dialogs/tp_Scale.cxx76
3 files changed, 86 insertions, 39 deletions
diff --git a/chart2/source/controller/dialogs/res_Trendline.cxx b/chart2/source/controller/dialogs/res_Trendline.cxx
index 0eaea7b4e163..11514a19a84a 100644
--- a/chart2/source/controller/dialogs/res_Trendline.cxx
+++ b/chart2/source/controller/dialogs/res_Trendline.cxx
@@ -24,6 +24,7 @@
#include <svl/intitem.hxx>
#include <svl/stritem.hxx>
#include <svl/zforlist.hxx>
+#include <vcl/formatter.hxx>
#include <vcl/weld.hxx>
namespace chart
@@ -31,8 +32,9 @@ namespace chart
static void lcl_setValue(weld::FormattedSpinButton& rFmtField, double fValue )
{
- rFmtField.set_value(fValue);
-//TODO rFmtField.SetDefaultValue( fValue );
+ Formatter& rFieldFormatter = rFmtField.GetFormatter();
+ rFieldFormatter.SetValue(fValue);
+ rFieldFormatter.SetDefaultValue( fValue );
}
TrendlineResources::TrendlineResources(weld::Builder& rBuilder, const SfxItemSet& rInAttrs)
@@ -66,6 +68,16 @@ TrendlineResources::TrendlineResources(weld::Builder& rBuilder, const SfxItemSet
{
FillValueSets();
+ Formatter& rForwardFormatter = m_xFmtFld_ExtrapolateForward->GetFormatter();
+ rForwardFormatter.ClearMinValue();
+ rForwardFormatter.ClearMaxValue();
+ Formatter& rBackwardFormatter = m_xFmtFld_ExtrapolateBackward->GetFormatter();
+ rBackwardFormatter.ClearMinValue();
+ rBackwardFormatter.ClearMaxValue();
+ Formatter& rInterceptFormatter = m_xFmtFld_InterceptValue->GetFormatter();
+ rInterceptFormatter.ClearMinValue();
+ rInterceptFormatter.ClearMaxValue();
+
Link<weld::ToggleButton&,void> aLink = LINK(this, TrendlineResources, SelectTrendLine);
m_xRB_Linear->connect_toggled( aLink );
m_xRB_Logarithmic->connect_toggled( aLink );
@@ -369,9 +381,9 @@ IMPL_LINK_NOARG(TrendlineResources, ChangeFormattedValue, weld::FormattedSpinBut
void TrendlineResources::SetNumFormatter( SvNumberFormatter* pFormatter )
{
m_pNumFormatter = pFormatter;
- m_xFmtFld_ExtrapolateForward->set_formatter( m_pNumFormatter );
- m_xFmtFld_ExtrapolateBackward->set_formatter( m_pNumFormatter );
- m_xFmtFld_InterceptValue->set_formatter( m_pNumFormatter );
+ m_xFmtFld_ExtrapolateForward->GetFormatter().SetFormatter(m_pNumFormatter);
+ m_xFmtFld_ExtrapolateBackward->GetFormatter().SetFormatter(m_pNumFormatter);
+ m_xFmtFld_InterceptValue->GetFormatter().SetFormatter(m_pNumFormatter);
}
void TrendlineResources::SetNbPoints( sal_Int32 nNbPoints )
diff --git a/chart2/source/controller/dialogs/tp_AxisPositions.cxx b/chart2/source/controller/dialogs/tp_AxisPositions.cxx
index 89b8c3899881..f94f09b98690 100644
--- a/chart2/source/controller/dialogs/tp_AxisPositions.cxx
+++ b/chart2/source/controller/dialogs/tp_AxisPositions.cxx
@@ -25,6 +25,7 @@
#include <rtl/math.hxx>
#include <svx/chrtitem.hxx>
#include <svl/intitem.hxx>
+#include <vcl/formatter.hxx>
using namespace ::com::sun::star;
@@ -59,10 +60,12 @@ AxisPositionsTabPage::AxisPositionsTabPage(weld::Container* pPage, weld::DialogC
m_xLB_CrossesAt->connect_changed(LINK(this, AxisPositionsTabPage, CrossesAtSelectHdl));
m_xLB_PlaceLabels->connect_changed(LINK(this, AxisPositionsTabPage, PlaceLabelsSelectHdl));
- const double nMin = static_cast<double>(SAL_MIN_INT64);
- const double nMax = static_cast<double>(SAL_MAX_INT64);
- m_xED_CrossesAt->set_range(nMin, nMax);
- m_xED_LabelDistance->set_range(nMin, nMax);
+ Formatter& rCrossFormatter = m_xED_CrossesAt->GetFormatter();
+ rCrossFormatter.ClearMinValue();
+ rCrossFormatter.ClearMaxValue();
+ Formatter& rDistanceFormatter = m_xED_CrossesAt->GetFormatter();
+ rDistanceFormatter.ClearMinValue();
+ rDistanceFormatter.ClearMaxValue();
}
AxisPositionsTabPage::~AxisPositionsTabPage()
@@ -81,7 +84,8 @@ bool AxisPositionsTabPage::FillItemSet(SfxItemSet* rOutAttrs)
rOutAttrs->Put( SfxInt32Item( SCHATTR_AXIS_POSITION, nPos+1 ));
if( nPos==2 )
{
- double fCrossover = m_xED_CrossesAt->get_value();
+ Formatter& rCrossFormatter = m_xED_CrossesAt->GetFormatter();
+ double fCrossover = rCrossFormatter.GetValue();
if( m_bCrossingAxisIsCategoryAxis )
fCrossover = m_xED_CrossesAtCategory->get_active()+1;
rOutAttrs->Put(SvxDoubleItem(fCrossover,SCHATTR_AXIS_POSITION_VALUE));
@@ -167,7 +171,10 @@ void AxisPositionsTabPage::Reset(const SfxItemSet* rInAttrs)
if( m_bCrossingAxisIsCategoryAxis )
m_xED_CrossesAtCategory->set_active( static_cast<sal_uInt16>(::rtl::math::round(fCrossover-1.0)) );
else
- m_xED_CrossesAt->set_value(fCrossover);
+ {
+ Formatter& rCrossFormatter = m_xED_CrossesAt->GetFormatter();
+ rCrossFormatter.SetValue(fCrossover);
+ }
}
else
{
@@ -251,13 +258,15 @@ DeactivateRC AxisPositionsTabPage::DeactivatePage(SfxItemSet* pItemSet)
void AxisPositionsTabPage::SetNumFormatter( SvNumberFormatter* pFormatter )
{
m_pNumFormatter = pFormatter;
- m_xED_CrossesAt->set_formatter(m_pNumFormatter);
+ Formatter& rCrossFormatter = m_xED_CrossesAt->GetFormatter();
+ rCrossFormatter.SetFormatter(m_pNumFormatter);
+ rCrossFormatter.UseInputStringForFormatting();
const SfxPoolItem *pPoolItem = nullptr;
if( GetItemSet().GetItemState( SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT, true, &pPoolItem ) == SfxItemState::SET )
{
sal_uLong nFmt = static_cast<const SfxUInt32Item*>(pPoolItem)->GetValue();
- m_xED_CrossesAt->set_format_key( nFmt );
+ rCrossFormatter.SetFormatKey(nFmt);
}
}
@@ -288,7 +297,7 @@ IMPL_LINK_NOARG(AxisPositionsTabPage, CrossesAtSelectHdl, weld::ComboBox&, void)
m_xED_CrossesAtCategory->set_visible( (nPos==2) && m_bCrossingAxisIsCategoryAxis );
if (m_xED_CrossesAt->get_text().isEmpty())
- m_xED_CrossesAt->set_value(0.0);
+ m_xED_CrossesAt->GetFormatter().SetValue(0.0);
if (m_xED_CrossesAtCategory->get_active() == -1)
m_xED_CrossesAtCategory->set_active(0);
diff --git a/chart2/source/controller/dialogs/tp_Scale.cxx b/chart2/source/controller/dialogs/tp_Scale.cxx
index 0c626667790c..b9b31019803d 100644
--- a/chart2/source/controller/dialogs/tp_Scale.cxx
+++ b/chart2/source/controller/dialogs/tp_Scale.cxx
@@ -29,6 +29,7 @@
#include <svx/chrtitem.hxx>
#include <svl/eitem.hxx>
#include <svl/intitem.hxx>
+#include <vcl/formatter.hxx>
#include <vcl/weld.hxx>
#include <svl/zformat.hxx>
#include <vcl/svapp.hxx>
@@ -45,7 +46,7 @@ namespace
void lcl_setValue(weld::FormattedSpinButton& rFmtField, double fValue)
{
- rFmtField.set_value(fValue);
+ rFmtField.GetFormatter().SetValue(fValue);
}
}
@@ -97,12 +98,18 @@ ScaleTabPage::ScaleTabPage(weld::Container* pPage, weld::DialogController* pCont
m_xCbxAutoOrigin->connect_toggled(LINK(this, ScaleTabPage, EnableValueHdl));
m_xCbx_AutoTimeResolution->connect_toggled(LINK(this, ScaleTabPage, EnableValueHdl));
- const double nMin = static_cast<double>(SAL_MIN_INT64);
- const double nMax = static_cast<double>(SAL_MAX_INT64);
- m_xFmtFldMin->set_range(nMin, nMax);
- m_xFmtFldMax->set_range(nMin, nMax);
- m_xFmtFldStepMain->set_range(nMin, nMax);
- m_xFmtFldOrigin->set_range(nMin, nMax);
+ Formatter& rFmtFldMax = m_xFmtFldMax->GetFormatter();
+ rFmtFldMax.ClearMinValue();
+ rFmtFldMax.ClearMaxValue();
+ Formatter& rFmtFldMin = m_xFmtFldMin->GetFormatter();
+ rFmtFldMin.ClearMinValue();
+ rFmtFldMin.ClearMaxValue();
+ Formatter& rFmtFldStepMain = m_xFmtFldStepMain->GetFormatter();
+ rFmtFldStepMain.ClearMinValue();
+ rFmtFldStepMain.ClearMaxValue();
+ Formatter& rFmtFldOrigin = m_xFmtFldOrigin->GetFormatter();
+ rFmtFldOrigin.ClearMinValue();
+ rFmtFldOrigin.ClearMaxValue();
m_xLB_AxisType->connect_changed(LINK(this, ScaleTabPage, SelectAxisTypeHdl));
@@ -144,7 +151,7 @@ void ScaleTabPage::EnableControls()
if( bWasDateAxis )
lcl_setValue( *m_xFmtFldStepMain, m_xMt_MainDateStep->get_value() );
else
- m_xMt_MainDateStep->set_value(m_xFmtFldStepMain->get_value());
+ m_xMt_MainDateStep->set_value(m_xFmtFldStepMain->GetFormatter().GetValue());
}
m_xFmtFldStepMain->set_visible( bValueAxis && !bDateAxis );
@@ -379,11 +386,11 @@ DeactivateRC ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet)
bool bDateAxis = m_nAxisType == chart2::AxisType::DATE;
- sal_uInt32 nMinMaxOriginFmt = m_xFmtFldMax->get_format_key();
+ sal_uInt32 nMinMaxOriginFmt = m_xFmtFldMax->GetFormatter().GetFormatKey();
if (pNumFormatter->GetType(nMinMaxOriginFmt) == SvNumFormatType::TEXT)
nMinMaxOriginFmt = 0;
// numberformat_text cause numbers to fail being numbers... Shouldn't happen, but can.
- sal_uInt32 nStepFmt = m_xFmtFldStepMain->get_format_key();
+ sal_uInt32 nStepFmt = m_xFmtFldStepMain->GetFormatter().GetFormatKey();
if (pNumFormatter->GetType(nStepFmt) == SvNumFormatType::TEXT)
nStepFmt = 0;
@@ -391,10 +398,10 @@ DeactivateRC ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet)
const char* pErrStrId = nullptr;
double fDummy;
- fMax = m_xFmtFldMax->get_value();
- fMin = m_xFmtFldMin->get_value();
- fOrigin = m_xFmtFldOrigin->get_value();
- fStepMain = bDateAxis ? m_xMt_MainDateStep->get_value() : m_xFmtFldStepMain->get_value();
+ fMax = m_xFmtFldMax->GetFormatter().GetValue();
+ fMin = m_xFmtFldMin->GetFormatter().GetValue();
+ fOrigin = m_xFmtFldOrigin->GetFormatter().GetValue();
+ fStepMain = bDateAxis ? m_xMt_MainDateStep->get_value() : m_xFmtFldStepMain->GetFormatter().GetValue();
nStepHelp = m_xMtStepHelp->get_value();
m_nTimeResolution = m_xLB_TimeResolution->get_active();
m_nMainTimeUnit = m_xLB_MainTimeUnit->get_active();
@@ -491,10 +498,26 @@ DeactivateRC ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet)
void ScaleTabPage::SetNumFormatter( SvNumberFormatter* pFormatter )
{
pNumFormatter = pFormatter;
- m_xFmtFldMax->set_formatter( pNumFormatter );
- m_xFmtFldMin->set_formatter( pNumFormatter );
- m_xFmtFldStepMain->set_formatter( pNumFormatter );
- m_xFmtFldOrigin->set_formatter( pNumFormatter );
+
+ Formatter& rFmtFldMax = m_xFmtFldMax->GetFormatter();
+ Formatter& rFmtFldMin = m_xFmtFldMin->GetFormatter();
+ Formatter& rFmtFldStepMain = m_xFmtFldStepMain->GetFormatter();
+ Formatter& rFmtFldOrigin = m_xFmtFldOrigin->GetFormatter();
+
+ rFmtFldMax.SetFormatter( pNumFormatter );
+ rFmtFldMin.SetFormatter( pNumFormatter );
+ rFmtFldStepMain.SetFormatter( pNumFormatter );
+ rFmtFldOrigin.SetFormatter( pNumFormatter );
+
+ // #i6278# allow more decimal places than the output format. As
+ // the numbers shown in the edit fields are used for input, it makes more
+ // sense to display the values in the input format rather than the output
+ // format.
+ rFmtFldMax.UseInputStringForFormatting();
+ rFmtFldMin.UseInputStringForFormatting();
+ rFmtFldStepMain.UseInputStringForFormatting();
+ rFmtFldOrigin.UseInputStringForFormatting();
+
SetNumFormat();
}
@@ -507,9 +530,12 @@ void ScaleTabPage::SetNumFormat()
sal_uLong nFmt = static_cast<const SfxUInt32Item*>(pPoolItem)->GetValue();
- m_xFmtFldMax->set_format_key(nFmt);
- m_xFmtFldMin->set_format_key(nFmt);
- m_xFmtFldOrigin->set_format_key(nFmt);
+ Formatter& rFmtFldMax = m_xFmtFldMax->GetFormatter();
+ rFmtFldMax.SetFormatKey(nFmt);
+ Formatter& rFmtFldMin = m_xFmtFldMin->GetFormatter();
+ rFmtFldMin.SetFormatKey(nFmt);
+ Formatter& rFmtFldOrigin = m_xFmtFldOrigin->GetFormatter();
+ rFmtFldOrigin.SetFormatKey(nFmt);
if( pNumFormatter )
{
@@ -541,13 +567,13 @@ void ScaleTabPage::SetNumFormat()
else
nFmt = pNumFormatter->GetStandardFormat( SvNumFormatType::DATE );
- m_xFmtFldMax->set_format_key(nFmt);
- m_xFmtFldMin->set_format_key(nFmt);
- m_xFmtFldOrigin->set_format_key(nFmt);
+ rFmtFldMax.SetFormatKey(nFmt);
+ rFmtFldMin.SetFormatKey(nFmt);
+ rFmtFldOrigin.SetFormatKey(nFmt);
}
}
- m_xFmtFldStepMain->set_format_key(nFmt);
+ m_xFmtFldStepMain->GetFormatter().SetFormatKey(nFmt);
}
void ScaleTabPage::ShowAxisOrigin( bool bShowOrigin )