diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-07-01 17:00:44 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-07-02 20:22:05 +0200 |
commit | a751d9c414fc63f36ae4b54b8adbaba042b31f60 (patch) | |
tree | 14b16f3580b140e0e45da81bb93712ff321b6218 /chart2/source/controller | |
parent | 4582ac7de8291a81c867492aad770206fbaca224 (diff) |
weld FormattedControl
by using the newly split out Formatter to do the number formatting
but input/output to/from a weld::Entry
Change-Id: Ic9e619dc5d1ed2fae87e2d89a40dc51f3881468f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97660
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'chart2/source/controller')
-rw-r--r-- | chart2/source/controller/dialogs/DataBrowser.cxx | 33 | ||||
-rw-r--r-- | chart2/source/controller/dialogs/DataBrowser.hxx | 3 |
2 files changed, 20 insertions, 16 deletions
diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx index a693b142d6d0..6971be7433a9 100644 --- a/chart2/source/controller/dialogs/DataBrowser.cxx +++ b/chart2/source/controller/dialogs/DataBrowser.cxx @@ -497,7 +497,7 @@ DataBrowser::DataBrowser(const css::uno::Reference<css::awt::XWindow> &rParent, m_nSeekRow( 0 ), m_bIsReadOnly( false ), m_bDataValid( true ), - m_aNumberEditField( VclPtr<FormattedField>::Create( & EditBrowseBox::GetDataWindow(), WB_NOBORDER ) ), + m_aNumberEditField(VclPtr<FormattedControl>::Create(&EditBrowseBox::GetDataWindow())), m_aTextEditField(VclPtr<EditControl>::Create(&EditBrowseBox::GetDataWindow())), m_pColumnsWin(pColumns), m_pColorsWin(pColors), @@ -506,8 +506,9 @@ DataBrowser::DataBrowser(const css::uno::Reference<css::awt::XWindow> &rParent, { double fNan; ::rtl::math::setNan( & fNan ); - m_aNumberEditField->SetDefaultValue( fNan ); - m_aNumberEditField->TreatAsNumber( true ); + Formatter& rFormatter = m_aNumberEditField->get_formatter(); + rFormatter.SetDefaultValue( fNan ); + rFormatter.TreatAsNumber( true ); RenewTable(); } @@ -828,7 +829,7 @@ bool DataBrowser::IsDataValid() const { sal_uInt32 nDummy = 0; double fDummy = 0.0; - OUString aText( m_aNumberEditField->GetText()); + OUString aText(m_aNumberEditField->get_widget().get_text()); if( !aText.isEmpty() && m_spNumberFormatterWrapper && @@ -860,7 +861,8 @@ void DataBrowser::SetDataFromModel( std::make_shared<NumberFormatterWrapper>( Reference< util::XNumberFormatsSupplier >( m_xChartDoc, uno::UNO_QUERY )); - m_aNumberEditField->SetFormatter( m_spNumberFormatterWrapper->getSvNumberFormatter() ); + Formatter& rFormatter = m_aNumberEditField->get_formatter(); + rFormatter.SetFormatter( m_spNumberFormatterWrapper->getSvNumberFormatter() ); RenewTable(); @@ -1114,8 +1116,9 @@ bool DataBrowser::IsTabAllowed( bool bForward ) const if( CellContainsNumbers( nCol )) { - m_aNumberEditField->UseInputStringForFormatting(); - m_aNumberEditField->SetFormatKey( GetNumberFormatKey( nCol )); + Formatter& rFormatter = m_aNumberEditField->get_formatter(); + rFormatter.UseInputStringForFormatting(); + rFormatter.SetFormatKey( GetNumberFormatKey( nCol )); return m_rNumberEditController.get(); } @@ -1135,13 +1138,14 @@ void DataBrowser::InitController( else if( rController == m_rNumberEditController ) { // treat invalid and empty text as Nan - m_aNumberEditField->EnableNotANumber( true ); + Formatter& rFormatter = m_aNumberEditField->get_formatter(); + rFormatter.EnableNotANumber( true ); if( std::isnan( GetCellNumber( nRow, nCol ))) - m_aNumberEditField->SetTextValue( OUString()); + rFormatter.SetTextValue( OUString()); else - m_aNumberEditField->SetValue( GetCellNumber( nRow, nCol ) ); - OUString aText( m_aNumberEditField->GetText()); - m_aNumberEditField->SetSelection( ::Selection( 0, aText.getLength())); + rFormatter.SetValue( GetCellNumber( nRow, nCol ) ); + weld::Entry& rEntry = m_aNumberEditField->get_widget(); + rEntry.select_region(0, -1); } else { @@ -1194,7 +1198,7 @@ bool DataBrowser::SaveModified() { sal_uInt32 nDummy = 0; double fDummy = 0.0; - OUString aText( m_aNumberEditField->GetText()); + OUString aText(m_aNumberEditField->get_widget().get_text()); // an empty string is valid, if no numberformatter exists, all // values are treated as valid if( !aText.isEmpty() && pSvNumberFormatter && @@ -1204,7 +1208,8 @@ bool DataBrowser::SaveModified() } else { - double fData = m_aNumberEditField->GetValue(); + Formatter& rFormatter = m_aNumberEditField->get_formatter(); + double fData = rFormatter.GetValue(); bChangeValid = m_apDataBrowserModel->setCellNumber( nCol, nRow, fData ); } } diff --git a/chart2/source/controller/dialogs/DataBrowser.hxx b/chart2/source/controller/dialogs/DataBrowser.hxx index 7f213382cf81..a1991224b454 100644 --- a/chart2/source/controller/dialogs/DataBrowser.hxx +++ b/chart2/source/controller/dialogs/DataBrowser.hxx @@ -21,7 +21,6 @@ #define INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_DATABROWSER_HXX #include <svtools/editbrowsebox.hxx> -#include <vcl/fmtfield.hxx> #include <vcl/weld.hxx> #include <memory> @@ -160,7 +159,7 @@ private: bool m_bIsReadOnly; bool m_bDataValid; - VclPtr<FormattedField> m_aNumberEditField; + VclPtr<svt::FormattedControl> m_aNumberEditField; VclPtr<svt::EditControl> m_aTextEditField; weld::Container* m_pColumnsWin; weld::Container* m_pColorsWin; |