[Libreoffice-commits] core.git: include/svtools svtools/source svtools/uiconfig svtools/UIConfig_svt.mk svx/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jul 10 08:36:09 UTC 2020
include/svtools/editbrowsebox.hxx | 165 +++++++++++++++++++++++++++++----
svtools/UIConfig_svt.mk | 1
svtools/source/brwbox/ebbcontrols.cxx | 149 ++++++++++++++---------------
svtools/uiconfig/ui/textviewcontrol.ui | 38 +++++++
svx/source/fmcomp/gridcell.cxx | 77 +++++----------
5 files changed, 286 insertions(+), 144 deletions(-)
New commits:
commit 12bfedfac3b141fe6c91b0e5ae5b3fb2ba817c48
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Jul 6 12:56:30 2020 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Jul 10 10:35:45 2020 +0200
weld MultiLineTextCell
Change-Id: Ib230720371552738a8c6152a98a84d31b900d062
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98209
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/svtools/editbrowsebox.hxx b/include/svtools/editbrowsebox.hxx
index 1b13daa0a565..b32518b0c1d0 100644
--- a/include/svtools/editbrowsebox.hxx
+++ b/include/svtools/editbrowsebox.hxx
@@ -31,7 +31,7 @@
#include <svtools/brwhead.hxx>
#include <tools/lineend.hxx>
#include <vcl/InterimItemWindow.hxx>
-#include <vcl/vclmedit.hxx>
+#include <vcl/edit.hxx>
#include <vcl/weldutils.hxx>
#include <o3tl/typed_flags_set.hxx>
@@ -141,6 +141,9 @@ namespace svt
virtual void SaveValue() = 0;
virtual void SetModifyHdl( const Link<LinkParamNone*,void>& _rLink ) = 0;
+ virtual bool CanUp() const = 0;
+ virtual bool CanDown() const = 0;
+
virtual void Cut() = 0;
virtual void Copy() = 0;
virtual void Paste() = 0;
@@ -197,9 +200,14 @@ namespace svt
virtual void GetFocus() override;
+ virtual bool ProcessKey(const KeyEvent& rKEvt);
+
protected:
void InitControlBase(weld::Widget* pWidget);
+ virtual void Draw(OutputDevice* pDevice, const Point& rPos, DrawFlags nFlags) override;
+
+ DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
private:
weld::Widget* m_pWidget;
};
@@ -220,8 +228,6 @@ namespace svt
private:
weld::Entry* m_pEntry;
-
- DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
};
class SVT_DLLPUBLIC EditControl final : public EditControlBase
@@ -335,6 +341,16 @@ namespace svt
m_aModifyHdl = rLink;
}
+ virtual bool CanUp() const override
+ {
+ return false;
+ }
+
+ virtual bool CanDown() const override
+ {
+ return false;
+ }
+
virtual void Cut() override
{
m_rEdit.get_widget().cut_clipboard();
@@ -358,27 +374,29 @@ namespace svt
/** a multi line edit which can be used in a cell of an EditBrowseBox
*/
- class UNLESS_MERGELIBS(SVT_DLLPUBLIC) MultiLineTextCell final : public VclMultiLineEdit
+ class UNLESS_MERGELIBS(SVT_DLLPUBLIC) MultiLineTextCell final : public ControlBase
{
public:
- MultiLineTextCell( vcl::Window* _pParent, WinBits _nStyle )
- : VclMultiLineEdit( _pParent, _nStyle )
+ MultiLineTextCell(BrowserDataWin* pParent);
+
+ virtual void GetFocus() override;
+
+ virtual void dispose() override;
+
+ void connect_changed(const Link<weld::TextView&, void>& rLink)
{
+ m_xWidget->connect_changed(rLink);
}
- private:
- // Window overridables
- virtual bool PreNotify( NotifyEvent& rNEvt ) override;
+ weld::TextView& get_widget() { return *m_xWidget; }
- // MultiLineEdit overridables
- virtual void Modify() override;
+ private:
+ std::unique_ptr<weld::TextView> m_xWidget;
- bool dispatchKeyEvent( const KeyEvent& _rEvent );
+ virtual bool ProcessKey(const KeyEvent& rKEvt) override;
};
-
//= concrete edit implementations
-
typedef GenericEditImplementation< Edit > EditImplementation_Base;
class EditImplementation final : public EditImplementation_Base
{
@@ -388,22 +406,129 @@ namespace svt
{
_rEdit.SetModifyHdl(LINK(this, EditImplementation, ModifyHdl));
}
+
+ virtual bool CanUp() const override
+ {
+ return false;
+ }
+
+ virtual bool CanDown() const override
+ {
+ return false;
+ }
};
- typedef GenericEditImplementation< MultiLineTextCell > MultiLineEditImplementation_Base;
- class UNLESS_MERGELIBS(SVT_DLLPUBLIC) MultiLineEditImplementation final : public MultiLineEditImplementation_Base
+ class SVT_DLLPUBLIC MultiLineEditImplementation : public IEditImplementation
{
- DECL_LINK(ModifyHdl, Edit&, void);
+ MultiLineTextCell& m_rEdit;
+ int m_nMaxTextLen;
+ Link<LinkParamNone*,void> m_aModifyHdl;
+
+ DECL_LINK(ModifyHdl, weld::TextView&, void);
public:
- MultiLineEditImplementation( MultiLineTextCell& _rEdit ) : MultiLineEditImplementation_Base( _rEdit )
+ MultiLineEditImplementation(MultiLineTextCell& rEdit)
+ : m_rEdit(rEdit)
+ , m_nMaxTextLen(EDIT_NOLIMIT)
+ {
+ m_rEdit.connect_changed(LINK(this, MultiLineEditImplementation, ModifyHdl));
+ }
+
+ virtual Control& GetControl() override
+ {
+ return m_rEdit;
+ }
+
+ virtual OUString GetText(LineEnd aSeparator) const override;
+
+ virtual void SetText(const OUString& rStr) override
+ {
+ return m_rEdit.get_widget().set_text(rStr);
+ }
+
+ virtual bool IsReadOnly() const override
+ {
+ return !m_rEdit.get_widget().get_editable();
+ }
+
+ virtual void SetReadOnly( bool bReadOnly ) override
+ {
+ m_rEdit.get_widget().set_editable(!bReadOnly);
+ }
+
+ virtual sal_Int32 GetMaxTextLen() const override
+ {
+ return m_nMaxTextLen;
+ }
+
+ virtual void SetMaxTextLen( sal_Int32 nMaxLen ) override
+ {
+ m_nMaxTextLen = nMaxLen;
+ m_rEdit.get_widget().set_max_length(nMaxLen == EDIT_NOLIMIT ? 0 : nMaxLen);
+ }
+
+ virtual Selection GetSelection() const override
+ {
+ int nStartPos, nEndPos;
+ m_rEdit.get_widget().get_selection_bounds(nStartPos, nEndPos);
+ return Selection(nStartPos, nEndPos);
+ }
+
+ virtual void SetSelection( const Selection& rSelection ) override
{
- _rEdit.SetModifyHdl(LINK(this, MultiLineEditImplementation, ModifyHdl));
+ auto nMin = rSelection.Min();
+ auto nMax = rSelection.Max();
+ m_rEdit.get_widget().select_region(nMin < 0 ? 0 : nMin, nMax == SELECTION_MAX ? -1 : nMax);
+ }
+
+ virtual void ReplaceSelected( const OUString& rStr ) override
+ {
+ m_rEdit.get_widget().replace_selection(rStr);
}
- virtual OUString GetText( LineEnd aSeparator ) const override;
virtual OUString GetSelected( LineEnd aSeparator ) const override;
+
+ virtual bool IsValueChangedFromSaved() const override
+ {
+ return m_rEdit.get_widget().get_value_changed_from_saved();
+ }
+
+ virtual void SaveValue() override
+ {
+ m_rEdit.get_widget().save_value();
+ }
+
+ virtual void SetModifyHdl( const Link<LinkParamNone*,void>& rLink ) override
+ {
+ m_aModifyHdl = rLink;
+ }
+
+ virtual bool CanUp() const override
+ {
+ return m_rEdit.get_widget().can_move_cursor_with_up();
+ }
+
+ virtual bool CanDown() const override
+ {
+ return m_rEdit.get_widget().can_move_cursor_with_down();
+ }
+
+ virtual void Cut() override
+ {
+ m_rEdit.get_widget().cut_clipboard();
+ }
+
+ virtual void Copy() override
+ {
+ m_rEdit.get_widget().copy_clipboard();
+ }
+
+ virtual void Paste() override
+ {
+ m_rEdit.get_widget().paste_clipboard();
+ }
};
+
//= EditCellController
class SVT_DLLPUBLIC EditCellController : public CellController
{
diff --git a/svtools/UIConfig_svt.mk b/svtools/UIConfig_svt.mk
index 23a9e7df778c..4b7cbecf4e75 100644
--- a/svtools/UIConfig_svt.mk
+++ b/svtools/UIConfig_svt.mk
@@ -29,6 +29,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svt,\
svtools/uiconfig/ui/querydeletedialog \
svtools/uiconfig/ui/restartdialog \
svtools/uiconfig/ui/spinfieldcontrol \
+ svtools/uiconfig/ui/textviewcontrol \
svtools/uiconfig/ui/thineditcontrol \
))
diff --git a/svtools/source/brwbox/ebbcontrols.cxx b/svtools/source/brwbox/ebbcontrols.cxx
index f6d6992adeed..febac63d4eb5 100644
--- a/svtools/source/brwbox/ebbcontrols.cxx
+++ b/svtools/source/brwbox/ebbcontrols.cxx
@@ -21,10 +21,10 @@
#include <vcl/spinfld.hxx>
#include <vcl/xtextedt.hxx>
#include <vcl/textview.hxx>
+#include <vcl/virdev.hxx>
namespace svt
{
-
//= ComboBoxControl
ComboBoxControl::ComboBoxControl(BrowserDataWin* pParent)
: ControlBase(pParent, "svt/ui/combocontrol.ui", "ComboControl")
@@ -302,20 +302,21 @@ namespace svt
}
//= MultiLineEditImplementation
-
-
- OUString MultiLineEditImplementation::GetText( LineEnd aSeparator ) const
+ OUString MultiLineEditImplementation::GetText(LineEnd eSeparator) const
{
- return const_cast< MultiLineEditImplementation* >( this )->GetEditWindow().GetText( aSeparator );
+ weld::TextView& rEntry = m_rEdit.get_widget();
+ return convertLineEnd(rEntry.get_text(), eSeparator);
}
-
- OUString MultiLineEditImplementation::GetSelected( LineEnd aSeparator ) const
+ OUString MultiLineEditImplementation::GetSelected(LineEnd eSeparator) const
{
- return const_cast< MultiLineEditImplementation* >( this )->GetEditWindow().GetSelected( aSeparator );
+ int nStartPos, nEndPos;
+ weld::TextView& rEntry = m_rEdit.get_widget();
+ rEntry.get_selection_bounds(nStartPos, nEndPos);
+ return convertLineEnd(rEntry.get_text().copy(nStartPos, nEndPos - nStartPos), eSeparator);
}
- IMPL_LINK_NOARG(MultiLineEditImplementation, ModifyHdl, Edit&, void)
+ IMPL_LINK_NOARG(MultiLineEditImplementation, ModifyHdl, weld::TextView&, void)
{
m_aModifyHdl.Call(nullptr);
}
@@ -359,6 +360,13 @@ namespace svt
return m_pWidget->has_focus();
}
+ void ControlBase::Draw(OutputDevice* pDevice, const Point& rPos, DrawFlags /*nFlags*/)
+ {
+ if (!m_pWidget)
+ return;
+ m_pWidget->draw(*pDevice, tools::Rectangle(rPos, GetSizePixel()));
+ }
+
void ControlBase::dispose()
{
m_pWidget = nullptr;
@@ -388,14 +396,19 @@ namespace svt
m_pEntry = pEntry;
m_pEntry->show();
m_pEntry->set_width_chars(1); // so a smaller than default width can be used
- m_pEntry->connect_key_press(LINK(this, EditControl, KeyInputHdl));
+ m_pEntry->connect_key_press(LINK(this, ControlBase, KeyInputHdl));
}
- IMPL_LINK(EditControlBase, KeyInputHdl, const KeyEvent&, rKEvt, bool)
+ bool ControlBase::ProcessKey(const KeyEvent& rKEvt)
{
return static_cast<BrowserDataWin*>(GetParent())->GetParent()->ProcessKey(rKEvt);
}
+ IMPL_LINK(ControlBase, KeyInputHdl, const KeyEvent&, rKEvt, bool)
+ {
+ return ProcessKey(rKEvt);
+ }
+
void EditControlBase::dispose()
{
m_pEntry = nullptr;
@@ -500,13 +513,25 @@ namespace svt
{
Selection aSel = m_pEditImplementation->GetSelection();
bResult = !aSel && aSel.Max() == m_pEditImplementation->GetText( LINEEND_LF ).getLength();
- } break;
+ break;
+ }
case KEY_HOME:
case KEY_LEFT:
{
Selection aSel = m_pEditImplementation->GetSelection();
bResult = !aSel && aSel.Min() == 0;
- } break;
+ break;
+ }
+ case KEY_DOWN:
+ {
+ bResult = !m_pEditImplementation->CanDown();
+ break;
+ }
+ case KEY_UP:
+ {
+ bResult = !m_pEditImplementation->CanUp();
+ break;
+ }
default:
bResult = true;
}
@@ -524,8 +549,6 @@ namespace svt
}
//= SpinCellController
-
-
SpinCellController::SpinCellController(SpinField* pWin)
:CellController(pWin)
{
@@ -591,79 +614,55 @@ namespace svt
static_cast<FormattedControl&>(GetWindow()).get_formatter().Commit();
}
- //= MultiLineTextCell
- void MultiLineTextCell::Modify()
+ MultiLineTextCell::MultiLineTextCell(BrowserDataWin* pParent)
+ : ControlBase(pParent, "svt/ui/textviewcontrol.ui", "TextViewControl")
+ , m_xWidget(m_xBuilder->weld_text_view("textview"))
{
- GetTextEngine()->SetModified( true );
- VclMultiLineEdit::Modify();
+ InitControlBase(m_xWidget.get());
+ m_xWidget->connect_key_press(LINK(this, ControlBase, KeyInputHdl));
+ // so any the natural size doesn't have an effect
+ m_xWidget->set_size_request(1, 1);
}
- bool MultiLineTextCell::dispatchKeyEvent( const KeyEvent& _rEvent )
+ void MultiLineTextCell::GetFocus()
{
- Selection aOldSelection( GetSelection() );
-
- bool bWasModified = IsModified();
- ClearModifyFlag( );
-
- bool bHandled = GetTextView()->KeyInput( _rEvent );
-
- bool bIsModified = IsModified();
- if ( bWasModified && !bIsModified )
- // not sure whether this can really happen
- SetModifyFlag();
-
- if ( bHandled ) // the view claimed it handled the key input
- {
- // unfortunately, KeyInput also returns <TRUE/> (means "I handled this key input")
- // when nothing really changed. Let's care for this.
- Selection aNewSelection( GetSelection() );
- if ( aNewSelection != aOldSelection // selection changed
- || bIsModified // or some other modification
- )
- return true;
- }
- return false;
+ if (m_xWidget)
+ m_xWidget->select_region(-1, 0);
+ ControlBase::GetFocus();
}
+ void MultiLineTextCell::dispose()
+ {
+ m_xWidget.reset();
+ ControlBase::dispose();
+ }
- bool MultiLineTextCell::PreNotify( NotifyEvent& rNEvt )
+ bool MultiLineTextCell::ProcessKey(const KeyEvent& rKEvt)
{
- if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
+ bool bSendToDataWindow = true;
+
+ sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
+ bool bShift = rKEvt.GetKeyCode().IsShift();
+ bool bCtrl = rKEvt.GetKeyCode().IsMod1();
+ bool bAlt = rKEvt.GetKeyCode().IsMod2();
+
+ if (!bAlt && !bCtrl && !bShift)
{
- if ( IsWindowOrChild( rNEvt.GetWindow() ) )
+ switch (nCode)
{
- // give the text view a chance to handle the keys
- // this is necessary since a lot of keys which are normally handled
- // by this view (in KeyInput) are intercepted by the EditBrowseBox,
- // which uses them for other reasons. An example is the KeyUp key,
- // which is used by both the text view and the edit browse box
-
- const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent();
- const vcl::KeyCode& rKeyCode = pKeyEvent->GetKeyCode();
- sal_uInt16 nCode = rKeyCode.GetCode();
-
- if ( ( nCode == KEY_RETURN ) && ( rKeyCode.GetModifier() == KEY_MOD1 ) )
- {
- KeyEvent aEvent( pKeyEvent->GetCharCode(),
- vcl::KeyCode( KEY_RETURN ),
- pKeyEvent->GetRepeat()
- );
- if ( dispatchKeyEvent( aEvent ) )
- return true;
- }
-
- if ( ( nCode != KEY_TAB ) && ( nCode != KEY_RETURN ) ) // everything but tab and enter
- {
- if ( dispatchKeyEvent( *pKeyEvent ) )
- return true;
- }
+ case KEY_DOWN:
+ bSendToDataWindow = !m_xWidget->can_move_cursor_with_down();
+ break;
+ case KEY_UP:
+ bSendToDataWindow = !m_xWidget->can_move_cursor_with_up();
+ break;
}
}
- return VclMultiLineEdit::PreNotify( rNEvt );
- }
-
+ if (bSendToDataWindow)
+ return ControlBase::ProcessKey(rKEvt);
+ return false;
+ }
} // namespace svt
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/uiconfig/ui/textviewcontrol.ui b/svtools/uiconfig/ui/textviewcontrol.ui
new file mode 100644
index 000000000000..f54674d03a39
--- /dev/null
+++ b/svtools/uiconfig/ui/textviewcontrol.ui
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.36.0 -->
+<interface domain="svt">
+ <requires lib="gtk+" version="3.18"/>
+ <object class="GtkBox" id="TextViewControl">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="shadow_type">none</property>
+ <property name="hscrollbar_policy">external</property>
+ <property name="vscrollbar_policy">external</property>
+ <child>
+ <object class="GtkTextView" id="textview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="accepts_tab">False</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+</interface>
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!" );
More information about the Libreoffice-commits
mailing list