From 9ebe58f0437bbb5714e629bd22e004ac895086d6 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 21 Jul 2020 11:34:19 +0100 Subject: weld PatternControl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie84778c2f127a6b393edbfa08e61b135ec3bcbc0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99174 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- svx/source/fmcomp/gridcell.cxx | 43 ++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'svx') diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx index 4005c0d2a7d1..b94f20727482 100644 --- a/svx/source/fmcomp/gridcell.cxx +++ b/svx/source/fmcomp/gridcell.cxx @@ -1728,7 +1728,6 @@ DbPatternField::DbPatternField( DbGridColumn& _rColumn, const Reference& _rxModel ) { DBG_ASSERT( m_pWindow, "DbPatternField::implAdjustGenericFieldSetting: not to be called without window!" ); @@ -1746,18 +1745,21 @@ void DbPatternField::implAdjustGenericFieldSetting( const Reference< XPropertySe OString aAsciiEditMask(OUStringToOString(aEditMask, RTL_TEXTENCODING_ASCII_US)); - static_cast< PatternField* >( m_pWindow.get() )->SetMask( aAsciiEditMask, aLitMask ); - static_cast< PatternField* >( m_pPainter.get() )->SetMask( aAsciiEditMask, aLitMask ); - static_cast< PatternField* >( m_pWindow.get() )->SetStrictFormat( bStrict ); - static_cast< PatternField* >( m_pPainter.get() )->SetStrictFormat( bStrict ); + weld::PatternFormatter& rEditFormatter = static_cast(m_pWindow.get())->get_formatter(); + rEditFormatter.SetMask(aAsciiEditMask, aLitMask); + rEditFormatter.SetStrictFormat(bStrict); + + weld::PatternFormatter& rPaintFormatter = static_cast(m_pPainter.get())->get_formatter(); + rPaintFormatter.SetMask(aAsciiEditMask, aLitMask); + rPaintFormatter.SetStrictFormat(bStrict); } void DbPatternField::Init(BrowserDataWin& rParent, const Reference< XRowSet >& xCursor) { m_rColumn.SetAlignmentFromModel(-1); - m_pWindow = VclPtr::Create( &rParent, 0 ); - m_pPainter= VclPtr::Create( &rParent, 0 ); + m_pWindow = VclPtr::Create(&rParent); + m_pPainter= VclPtr::Create(&rParent); Reference< XPropertySet > xModel( m_rColumn.getModel() ); implAdjustGenericFieldSetting( xModel ); @@ -1767,17 +1769,17 @@ void DbPatternField::Init(BrowserDataWin& rParent, const Reference< XRowSet >& x CellControllerRef DbPatternField::CreateController() const { - return new SpinCellController( static_cast< PatternField* >( m_pWindow.get() ) ); + return new EditCellController(static_cast(m_pWindow.get())); } OUString DbPatternField::impl_formatText( const OUString& _rText ) { - m_pPainter->SetText( _rText ); - static_cast< PatternField* >( m_pPainter.get() )->ReformatAll(); - return m_pPainter->GetText(); + weld::PatternFormatter& rPaintFormatter = static_cast(m_pPainter.get())->get_formatter(); + rPaintFormatter.get_widget().set_text(_rText); + rPaintFormatter.ReformatAll(); + return rPaintFormatter.get_widget().get_text(); } - OUString DbPatternField::GetFormatText(const Reference< css::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/, Color** /*ppColor*/) { bool bIsForPaint = _rxField != m_rColumn.GetField(); @@ -1800,11 +1802,11 @@ OUString DbPatternField::GetFormatText(const Reference< css::sdb::XColumn >& _rx return impl_formatText( sText ); } - void DbPatternField::UpdateFromField( const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& _rxFormatter ) { - static_cast< Edit* >( m_pWindow.get() )->SetText( GetFormatText( _rxField, _rxFormatter ) ); - static_cast< Edit* >( m_pWindow.get() )->SetSelection( Selection( SELECTION_MAX, SELECTION_MIN ) ); + weld::Entry& rEntry = static_cast(m_pWindow.get())->get_widget(); + rEntry.set_text(GetFormatText(_rxField, _rxFormatter)); + rEntry.select_region(-1, 0); } void DbPatternField::updateFromModel( Reference< XPropertySet > _rxModel ) @@ -1814,14 +1816,15 @@ void DbPatternField::updateFromModel( Reference< XPropertySet > _rxModel ) OUString sText; _rxModel->getPropertyValue( FM_PROP_TEXT ) >>= sText; - static_cast< Edit* >( m_pWindow.get() )->SetText( impl_formatText( sText ) ); - static_cast< Edit* >( m_pWindow.get() )->SetSelection( Selection( SELECTION_MAX, SELECTION_MIN ) ); + weld::Entry& rEntry = static_cast(m_pWindow.get())->get_widget(); + rEntry.set_text(impl_formatText(sText)); + rEntry.select_region(-1, 0); } bool DbPatternField::commitControl() { - OUString aText(m_pWindow->GetText()); - m_rColumn.getModel()->setPropertyValue(FM_PROP_TEXT, makeAny(aText)); + weld::Entry& rEntry = static_cast(m_pWindow.get())->get_widget(); + m_rColumn.getModel()->setPropertyValue(FM_PROP_TEXT, makeAny(rEntry.get_text())); return true; } @@ -2770,7 +2773,7 @@ CellControllerRef DbFilterField::CreateController() const if (m_bFilterList) xController = new ComboBoxCellController(static_cast(m_pWindow.get())); else - xController = new EditCellController(static_cast(m_pWindow.get())); + xController = new EditCellController(static_cast(m_pWindow.get())); } return xController; } -- cgit