diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-07-06 12:56:30 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-07-10 10:35:45 +0200 |
commit | 12bfedfac3b141fe6c91b0e5ae5b3fb2ba817c48 (patch) | |
tree | 1e4311958ece62abc5177938e7a1bc05b456cfb9 /svx/source | |
parent | b5809f3272f8e0cc5c9b6540e475d6109e7dc3ec (diff) |
weld MultiLineTextCell
Change-Id: Ib230720371552738a8c6152a98a84d31b900d062
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98209
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx/source')
-rw-r--r-- | svx/source/fmcomp/gridcell.cxx | 77 |
1 files changed, 28 insertions, 49 deletions
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx index f4ccb57e1347..6ae6bae43b93 100644 --- a/svx/source/fmcomp/gridcell.cxx +++ b/svx/source/fmcomp/gridcell.cxx @@ -959,33 +959,10 @@ void DbCellControl::AlignControl(sal_Int16 nAlignment) lcl_implAlign( m_pPainter, nAlignmentBit ); } -void DbCellControl::PaintCell( OutputDevice& _rDev, const tools::Rectangle& _rRect ) +void DbCellControl::PaintCell(OutputDevice& rDev, const tools::Rectangle& rRect) { - if ( m_pPainter->GetParent() == &_rDev ) - { - m_pPainter->SetPaintTransparent( true ); - m_pPainter->SetBackground( ); - m_pPainter->SetControlBackground( _rDev.GetFillColor() ); - m_pPainter->SetControlForeground( _rDev.GetTextColor() ); - m_pPainter->SetTextColor( _rDev.GetTextColor() ); - m_pPainter->SetTextFillColor( _rDev.GetTextColor() ); - - vcl::Font aFont( _rDev.GetFont() ); - aFont.SetTransparent( true ); - m_pPainter->SetFont( aFont ); - - m_pPainter->SetPosSizePixel( _rRect.TopLeft(), _rRect.GetSize() ); - m_pPainter->Show(); - m_pPainter->PaintImmediately(); - m_pPainter->SetParentUpdateMode( false ); - m_pPainter->Hide(); - m_pPainter->SetParentUpdateMode( true ); - } - else - { - m_pPainter->SetSizePixel( _rRect.GetSize() ); - m_pPainter->Draw( &_rDev, _rRect.TopLeft(), DrawFlags::NONE ); - } + m_pPainter->SetSizePixel(rRect.GetSize()); + m_pPainter->Draw(&rDev, rRect.TopLeft(), DrawFlags::NONE); } void DbCellControl::PaintFieldToCell( OutputDevice& _rDev, const tools::Rectangle& _rRect, const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& _rxFormatter ) @@ -994,7 +971,6 @@ void DbCellControl::PaintFieldToCell( OutputDevice& _rDev, const tools::Rectangl PaintCell( _rDev, _rRect ); } - double DbCellControl::GetValue(const Reference< css::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter) const { double fValue = 0; @@ -1027,7 +1003,6 @@ double DbCellControl::GetValue(const Reference< css::sdb::XColumn >& _rxField, c return fValue; } - void DbCellControl::invalidatedController() { m_rColumn.GetParent().refreshController(m_rColumn.GetId(), DbGridControl::GrantControlAccess()); @@ -1079,17 +1054,7 @@ void DbTextField::Init(BrowserDataWin& rParent, const Reference< XRowSet >& xCur Reference< XPropertySet > xModel( m_rColumn.getModel() ); - WinBits nStyle = WB_LEFT; - switch (nAlignment) - { - case awt::TextAlign::RIGHT: - nStyle = WB_RIGHT; - break; - - case awt::TextAlign::CENTER: - nStyle = WB_CENTER; - break; - } + bool bLeftAlign = true; // is this a multi-line field? bool bIsMultiLine = false; @@ -1109,11 +1074,28 @@ void DbTextField::Init(BrowserDataWin& rParent, const Reference< XRowSet >& xCur m_bIsSimpleEdit = !bIsMultiLine; if ( bIsMultiLine ) { - m_pWindow = VclPtr<MultiLineTextCell>::Create( &rParent, nStyle ); - m_pEdit.reset(new MultiLineEditImplementation( *static_cast< MultiLineTextCell* >( m_pWindow.get() ) )); + auto xEditControl = VclPtr<MultiLineTextCell>::Create(&rParent); + auto xEditPainter = VclPtr<MultiLineTextCell>::Create(&rParent); - m_pPainter = VclPtr<MultiLineTextCell>::Create( &rParent, nStyle ); - m_pPainterImplementation.reset(new MultiLineEditImplementation( *static_cast< MultiLineTextCell* >( m_pPainter.get() ) )); + switch (nAlignment) + { + case awt::TextAlign::RIGHT: + xEditControl->get_widget().set_alignment(TxtAlign::Right); + xEditPainter->get_widget().set_alignment(TxtAlign::Right); + bLeftAlign = false; + break; + case awt::TextAlign::CENTER: + xEditControl->get_widget().set_alignment(TxtAlign::Center); + xEditPainter->get_widget().set_alignment(TxtAlign::Center); + bLeftAlign = false; + break; + } + + m_pWindow = xEditControl; + m_pEdit.reset(new MultiLineEditImplementation(*xEditControl)); + + m_pPainter = xEditPainter; + m_pPainterImplementation.reset(new MultiLineEditImplementation(*xEditPainter)); } else { @@ -1125,10 +1107,12 @@ void DbTextField::Init(BrowserDataWin& rParent, const Reference< XRowSet >& xCur case awt::TextAlign::RIGHT: xEditControl->get_widget().set_alignment(TxtAlign::Right); xEditPainter->get_widget().set_alignment(TxtAlign::Right); + bLeftAlign = false; break; case awt::TextAlign::CENTER: xEditControl->get_widget().set_alignment(TxtAlign::Center); xEditPainter->get_widget().set_alignment(TxtAlign::Center); + bLeftAlign = false; break; } @@ -1139,7 +1123,7 @@ void DbTextField::Init(BrowserDataWin& rParent, const Reference< XRowSet >& xCur m_pPainterImplementation.reset(new EntryImplementation(*xEditPainter)); } - if ( WB_LEFT == nStyle ) + if (bLeftAlign) { // this is so that when getting the focus, the selection is oriented left-to-right AllSettings aSettings = m_pWindow->GetSettings(); @@ -1155,13 +1139,11 @@ void DbTextField::Init(BrowserDataWin& rParent, const Reference< XRowSet >& xCur DbLimitedLengthField::Init( rParent, xCursor ); } - CellControllerRef DbTextField::CreateController() const { return new EditCellController( m_pEdit.get() ); } - void DbTextField::PaintFieldToCell( OutputDevice& _rDev, const tools::Rectangle& _rRect, const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& _rxFormatter ) { if ( m_pPainterImplementation ) @@ -1170,7 +1152,6 @@ void DbTextField::PaintFieldToCell( OutputDevice& _rDev, const tools::Rectangle& DbLimitedLengthField::PaintFieldToCell( _rDev, _rRect, _rxField, _rxFormatter ); } - OUString DbTextField::GetFormatText(const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter, Color** /*ppColor*/) { if (!_rxField.is()) @@ -1191,14 +1172,12 @@ OUString DbTextField::GetFormatText(const Reference< XColumn >& _rxField, const } - void DbTextField::UpdateFromField(const Reference< css::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter) { m_pEdit->SetText( GetFormatText( _rxField, xFormatter ) ); m_pEdit->SetSelection( Selection( SELECTION_MAX, SELECTION_MIN ) ); } - void DbTextField::updateFromModel( Reference< XPropertySet > _rxModel ) { OSL_ENSURE( _rxModel.is() && m_pWindow, "DbTextField::updateFromModel: invalid call!" ); |