weld DbNumericField item

Change-Id: I96b7945cdf9f00c3d0a4e043ee77666e19c8a072
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97896
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2020-07-03 20:09:37 +01:00
parent 291f1776a6
commit d5b3c5d509
10 changed files with 217 additions and 92 deletions

View File

@@ -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<FormattedControl>::Create(&EditBrowseBox::GetDataWindow())),
m_aNumberEditField(VclPtr<FormattedControl>::Create(&EditBrowseBox::GetDataWindow(), false)),
m_aTextEditField(VclPtr<EditControl>::Create(&EditBrowseBox::GetDataWindow())),
m_pColumnsWin(pColumns),
m_pColorsWin(pColors),

View File

@@ -186,26 +186,37 @@ namespace svt
virtual void Paste() override;
};
class SVT_DLLPUBLIC EditControlBase : public InterimItemWindow
class SVT_DLLPUBLIC ControlBase : public InterimItemWindow
{
public:
ControlBase(BrowserDataWin* pParent, const OUString& rUIXMLDescription, const OString& rID);
bool ControlHasFocus() const;
virtual void dispose() override;
virtual void GetFocus() override;
protected:
void InitControlBase(weld::Widget* pWidget);
private:
weld::Widget* m_pWidget;
};
class SVT_DLLPUBLIC EditControlBase : public ControlBase
{
public:
EditControlBase(BrowserDataWin* pParent);
virtual void dispose() override;
virtual void GetFocus() override
{
if (m_pEntry)
m_pEntry->grab_focus();
InterimItemWindow::GetFocus();
}
weld::Entry& get_widget() { return *m_pEntry; }
virtual void connect_changed(const Link<weld::Entry&, void>& rLink) = 0;
protected:
void init(weld::Entry* pEntry);
void InitEditControlBase(weld::Entry* pEntry);
private:
weld::Entry* m_pEntry;
@@ -422,9 +433,7 @@ namespace svt
DECL_LINK(ModifyHdl, LinkParamNone*, void);
};
//= SpinCellController
class UNLESS_MERGELIBS(SVT_DLLPUBLIC) SpinCellController final : public CellController
{
public:
@@ -440,9 +449,7 @@ namespace svt
DECL_LINK(ModifyHdl, Edit&, void);
};
//= CheckBoxControl
class SVT_DLLPUBLIC CheckBoxControl final : public Control
{
VclPtr<CheckBox> pBox;
@@ -489,19 +496,12 @@ namespace svt
};
//= ComboBoxControl
class SVT_DLLPUBLIC ComboBoxControl final : public InterimItemWindow
class SVT_DLLPUBLIC ComboBoxControl final : public ControlBase
{
friend class ComboBoxCellController;
public:
ComboBoxControl(vcl::Window* pParent);
virtual void GetFocus() override
{
if (m_xWidget)
m_xWidget->grab_focus();
InterimItemWindow::GetFocus();
}
ComboBoxControl(BrowserDataWin* pParent);
weld::ComboBox& get_widget() { return *m_xWidget; }
@@ -529,19 +529,12 @@ namespace svt
};
//= ListBoxControl
class SVT_DLLPUBLIC ListBoxControl final : public InterimItemWindow
class SVT_DLLPUBLIC ListBoxControl final : public ControlBase
{
friend class ListBoxCellController;
public:
ListBoxControl(vcl::Window* pParent);
virtual void GetFocus() override
{
if (m_xWidget)
m_xWidget->grab_focus();
InterimItemWindow::GetFocus();
}
ListBoxControl(BrowserDataWin* pParent);
weld::ComboBox& get_widget() { return *m_xWidget; }
@@ -567,30 +560,43 @@ namespace svt
DECL_LINK(ListBoxSelectHdl, weld::ComboBox&, void);
};
class SVT_DLLPUBLIC FormattedControl : public EditControlBase
class SVT_DLLPUBLIC FormattedControlBase : public EditControlBase
{
public:
FormattedControl(BrowserDataWin* pParent);
FormattedControlBase(BrowserDataWin* pParent, bool bSpinVariant);
virtual void dispose() override;
virtual void connect_changed(const Link<weld::Entry&, void>& rLink) override
{
m_xEntryFormatter->connect_changed(rLink);
}
virtual void connect_changed(const Link<weld::Entry&, void>& rLink) override;
weld::EntryFormatter& get_formatter() { return *m_xEntryFormatter; }
weld::EntryFormatter& get_formatter();
private:
protected:
bool m_bSpinVariant;
std::unique_ptr<weld::Entry> m_xEntry;
std::unique_ptr<weld::FormattedSpinButton> m_xSpinButton;
std::unique_ptr<weld::EntryFormatter> m_xEntryFormatter;
void InitFormattedControlBase();
};
class SVT_DLLPUBLIC FormattedControl : public FormattedControlBase
{
public:
FormattedControl(BrowserDataWin* pParent, bool bSpinVariant);
};
class SVT_DLLPUBLIC DoubleNumericControl : public FormattedControlBase
{
public:
DoubleNumericControl(BrowserDataWin* pParent, bool bSpinVariant);
};
//= FormattedFieldCellController
class SVT_DLLPUBLIC FormattedFieldCellController final : public EditCellController
{
public:
FormattedFieldCellController( FormattedControl* _pFormatted );
FormattedFieldCellController( FormattedControlBase* _pFormatted );
virtual void CommitModifications() override;
};
@@ -827,6 +833,8 @@ namespace svt
SVT_DLLPRIVATE void implActivateCellOnMouseEvent(const BrowserMouseEvent& _rEvt, bool _bUp);
bool ControlHasFocus() const;
DECL_DLLPRIVATE_LINK( ModifyHdl, LinkParamNone*, void );
DECL_DLLPRIVATE_LINK( StartEditHdl, void*, void );
DECL_DLLPRIVATE_LINK( EndEditHdl, void*, void );

View File

@@ -27,3 +27,4 @@ svtools/uiconfig/ui/restartdialog.ui://GtkLabel[@id='reason_skia'] orphan-label
svtools/uiconfig/ui/restartdialog.ui://GtkLabel[@id='label'] orphan-label
svtools/uiconfig/ui/spinfieldcontrol.ui://GtkSpinButton[@id='spinbutton'] no-labelled-by
svtools/uiconfig/ui/thineditcontrol.ui://GtkEntry[@id='entry'] no-labelled-by
svtools/uiconfig/ui/thineditcontrol.ui://GtkSpinButton[@id='spinbutton'] no-labelled-by

View File

@@ -26,17 +26,18 @@ namespace svt
{
//= ComboBoxControl
ComboBoxControl::ComboBoxControl(vcl::Window* pParent)
: InterimItemWindow(pParent, "svt/ui/combocontrol.ui", "ComboControl")
ComboBoxControl::ComboBoxControl(BrowserDataWin* pParent)
: ControlBase(pParent, "svt/ui/combocontrol.ui", "ComboControl")
, m_xWidget(m_xBuilder->weld_combo_box("combobox"))
{
InitControlBase(m_xWidget.get());
m_xWidget->set_entry_width_chars(1); // so a smaller than default width can be used
}
void ComboBoxControl::dispose()
{
m_xWidget.reset();
InterimItemWindow::dispose();
ControlBase::dispose();
}
//= ComboBoxCellController
@@ -103,17 +104,18 @@ namespace svt
}
//= ListBoxControl
ListBoxControl::ListBoxControl(vcl::Window* pParent)
: InterimItemWindow(pParent, "svt/ui/listcontrol.ui", "ListControl")
ListBoxControl::ListBoxControl(BrowserDataWin* pParent)
: ControlBase(pParent, "svt/ui/listcontrol.ui", "ListControl")
, m_xWidget(m_xBuilder->weld_combo_box("listbox"))
{
InitControlBase(m_xWidget.get());
m_xWidget->set_size_request(42, -1); // so a later narrow size request can stick
}
void ListBoxControl::dispose()
{
m_xWidget.reset();
InterimItemWindow::dispose();
ControlBase::dispose();
}
//= ListBoxCellController
@@ -345,34 +347,66 @@ namespace svt
m_aModifyHdl.Call(nullptr);
}
EditControlBase::EditControlBase(BrowserDataWin* pParent)
: InterimItemWindow(pParent, "svt/ui/thineditcontrol.ui", "EditControl") // *thin*editcontrol has no frame/border
ControlBase::ControlBase(BrowserDataWin* pParent, const OUString& rUIXMLDescription, const OString& rID)
: InterimItemWindow(pParent, rUIXMLDescription, rID)
{
}
void EditControlBase::init(weld::Entry* pEntry)
bool ControlBase::ControlHasFocus() const
{
if (!m_pWidget)
return false;
return m_pWidget->has_focus();
}
void ControlBase::dispose()
{
m_pWidget = nullptr;
InterimItemWindow::dispose();
}
void ControlBase::GetFocus()
{
if (m_pWidget)
m_pWidget->grab_focus();
InterimItemWindow::GetFocus();
}
void ControlBase::InitControlBase(weld::Widget* pWidget)
{
m_pWidget = pWidget;
}
EditControlBase::EditControlBase(BrowserDataWin* pParent)
: ControlBase(pParent, "svt/ui/thineditcontrol.ui", "EditControl") // *thin*editcontrol has no frame/border
{
}
void EditControlBase::InitEditControlBase(weld::Entry* pEntry)
{
InitControlBase(pEntry);
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));
}
IMPL_LINK(EditControlBase, KeyInputHdl, const KeyEvent&, rKEvt, bool)
{
return ChildKeyInput(rKEvt);
return static_cast<BrowserDataWin*>(GetParent())->GetParent()->ProcessKey(rKEvt);
}
void EditControlBase::dispose()
{
m_pEntry = nullptr;
InterimItemWindow::dispose();
ControlBase::dispose();
}
EditControl::EditControl(BrowserDataWin* pParent)
: EditControlBase(pParent)
, m_xWidget(m_xBuilder->weld_entry("entry"))
{
init(m_xWidget.get());
InitEditControlBase(m_xWidget.get());
}
void EditControl::dispose()
@@ -381,21 +415,62 @@ namespace svt
EditControlBase::dispose();
}
FormattedControl::FormattedControl(BrowserDataWin* pParent)
FormattedControlBase::FormattedControlBase(BrowserDataWin* pParent, bool bSpinVariant)
: EditControlBase(pParent)
, m_bSpinVariant(bSpinVariant)
, m_xEntry(m_xBuilder->weld_entry("entry"))
, m_xEntryFormatter(new weld::EntryFormatter(*m_xEntry))
, m_xSpinButton(m_xBuilder->weld_formatted_spin_button("spinbutton"))
{
init(m_xEntry.get());
}
void FormattedControl::dispose()
void FormattedControlBase::InitFormattedControlBase()
{
if (m_bSpinVariant)
m_xSpinButton->SetFormatter(m_xEntryFormatter.release());
InitEditControlBase(m_bSpinVariant ? m_xSpinButton.get() : m_xEntry.get());
}
void FormattedControlBase::connect_changed(const Link<weld::Entry&, void>& rLink)
{
get_formatter().connect_changed(rLink);
}
weld::EntryFormatter& FormattedControlBase::get_formatter()
{
if (m_bSpinVariant)
return static_cast<weld::EntryFormatter&>(m_xSpinButton->GetFormatter());
else
return *m_xEntryFormatter;
}
void FormattedControlBase::dispose()
{
m_xEntryFormatter.reset();
m_xSpinButton.reset();
m_xEntry.reset();
EditControlBase::dispose();
}
FormattedControl::FormattedControl(BrowserDataWin* pParent, bool bSpinVariant)
: FormattedControlBase(pParent, bSpinVariant)
{
if (bSpinVariant)
m_xEntryFormatter.reset(new weld::EntryFormatter(*m_xSpinButton));
else
m_xEntryFormatter.reset(new weld::EntryFormatter(*m_xEntry));
InitFormattedControlBase();
}
DoubleNumericControl::DoubleNumericControl(BrowserDataWin* pParent, bool bSpinVariant)
: FormattedControlBase(pParent, bSpinVariant)
{
if (bSpinVariant)
m_xEntryFormatter.reset(new weld::DoubleNumericEntry(*m_xSpinButton));
else
m_xEntryFormatter.reset(new weld::DoubleNumericEntry(*m_xEntry));
InitFormattedControlBase();
}
EditCellController::EditCellController(EditControlBase* pEdit)
: CellController(pEdit)
, m_pEditImplementation(new EntryImplementation(*pEdit))
@@ -506,7 +581,7 @@ namespace svt
}
//= FormattedFieldCellController
FormattedFieldCellController::FormattedFieldCellController( FormattedControl* _pFormatted )
FormattedFieldCellController::FormattedFieldCellController( FormattedControlBase* _pFormatted )
: EditCellController(_pFormatted)
{
}

View File

@@ -210,7 +210,7 @@ namespace svt
if (IsEditing())
{
EnableAndShow();
if (!aController->GetWindow().HasFocus() && (m_pFocusWhileRequest.get() == Application::GetFocusWindow()))
if (!ControlHasFocus() && (m_pFocusWhileRequest.get() == Application::GetFocusWindow()))
aController->GetWindow().GrabFocus();
}
}
@@ -450,7 +450,6 @@ namespace svt
}
}
void EditBrowseBox::MouseButtonUp( const BrowserMouseEvent& rEvt )
{
// absorb double clicks
@@ -466,6 +465,13 @@ namespace svt
implActivateCellOnMouseEvent(rEvt, true);
}
bool EditBrowseBox::ControlHasFocus() const
{
Window* pControlWindow = aController ? &aController->GetWindow() : nullptr;
if (ControlBase* pControlBase = dynamic_cast<ControlBase*>(pControlWindow))
return pControlBase->ControlHasFocus();
return pControlWindow && pControlWindow->HasChildPathFocus();
}
void EditBrowseBox::implActivateCellOnMouseEvent(const BrowserMouseEvent& _rEvt, bool _bUp)
{
@@ -473,7 +479,7 @@ namespace svt
ActivateCell();
else if (IsEditing() && !aController->GetWindow().IsEnabled())
DeactivateCell();
else if (IsEditing() && !aController->GetWindow().HasChildPathFocus())
else if (IsEditing() && !ControlHasFocus())
AsynchGetFocus();
if (!(IsEditing() && aController->GetWindow().IsEnabled() && aController->WantMouseEvent()))
@@ -652,7 +658,7 @@ namespace svt
{
if (rEvt.GetType() == MouseNotifyEvent::KEYINPUT)
{
if ( (IsEditing() && Controller()->GetWindow().HasChildPathFocus())
if ( (IsEditing() && ControlHasFocus())
|| rEvt.GetWindow() == &GetDataWindow()
|| (!IsEditing() && HasChildPathFocus())
)

View File

@@ -124,7 +124,7 @@ void EditBrowseBox::GrabTableFocus()
void EditBrowseBox::DetermineFocus( const GetFocusFlags _nGetFocusFlags )
{
bool bFocus = false;
bool bFocus = ControlHasFocus();
for (vcl::Window* pWindow = Application::GetFocusWindow();
pWindow && !bFocus;
pWindow = pWindow->GetParent())

View File

@@ -6,11 +6,12 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkEntry" id="entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="no_show_all">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="has_frame">False</property>
@@ -23,5 +24,17 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spinbutton">
<property name="can_focus">True</property>
<property name="no_show_all">True</property>
<property name="has_frame">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</interface>

View File

@@ -57,7 +57,6 @@
#include <rtl/math.hxx>
#include <svtools/calendar.hxx>
#include <vcl/button.hxx>
#include <vcl/fmtfield.hxx>
#include <svl/numuno.hxx>
#include <svl/zforlist.hxx>
#include <svx/dialmgr.hxx>
@@ -917,13 +916,29 @@ namespace
{
void lcl_implAlign( vcl::Window* _pWindow, WinBits _nAlignmentBit )
{
if (EditControlBase* pControl = dynamic_cast<EditControlBase*>(_pWindow))
{
switch (_nAlignmentBit)
{
case WB_LEFT:
pControl->get_widget().set_alignment(TxtAlign::Left);
break;
case WB_CENTER:
pControl->get_widget().set_alignment(TxtAlign::Center);
break;
case WB_RIGHT:
pControl->get_widget().set_alignment(TxtAlign::Right);
break;
}
return;
}
WinBits nStyle = _pWindow->GetStyle();
nStyle &= ~(WB_LEFT | WB_RIGHT | WB_CENTER);
_pWindow->SetStyle( nStyle | _nAlignmentBit );
}
}
void DbCellControl::AlignControl(sal_Int16 nAlignment)
{
WinBits nAlignmentBit = 0;
@@ -1247,8 +1262,8 @@ void DbFormattedField::Init( BrowserDataWin& rParent, const Reference< XRowSet >
Reference< css::beans::XPropertySet > xUnoModel = m_rColumn.getModel();
auto xEditControl = VclPtr<FormattedControl>::Create(&rParent);
auto xEditPainter = VclPtr<FormattedControl>::Create(&rParent);
auto xEditControl = VclPtr<FormattedControl>::Create(&rParent, false);
auto xEditPainter = VclPtr<FormattedControl>::Create(&rParent, false);
weld::EntryFormatter& rControlFormatter = xEditControl->get_formatter();
weld::EntryFormatter& rPainterFormatter = xEditPainter->get_formatter();
@@ -1452,7 +1467,7 @@ void DbFormattedField::Init( BrowserDataWin& rParent, const Reference< XRowSet >
CellControllerRef DbFormattedField::CreateController() const
{
return new ::svt::FormattedFieldCellController(static_cast<FormattedControl*>(m_pWindow.get()));
return new ::svt::FormattedFieldCellController(static_cast<FormattedControlBase*>(m_pWindow.get()));
}
void DbFormattedField::_propertyChanged( const PropertyChangeEvent& _rEvent )
@@ -1463,9 +1478,9 @@ void DbFormattedField::_propertyChanged( const PropertyChangeEvent& _rEvent )
DBG_ASSERT(m_pWindow && m_pPainter, "DbFormattedField::_propertyChanged : where are my windows ?");
if (m_pWindow)
static_cast<FormattedControl*>(m_pWindow.get())->get_formatter().SetFormatKey(nNewKey);
static_cast<FormattedControlBase*>(m_pWindow.get())->get_formatter().SetFormatKey(nNewKey);
if (m_pPainter)
static_cast<FormattedControl*>(m_pPainter.get())->get_formatter().SetFormatKey(nNewKey);
static_cast<FormattedControlBase*>(m_pPainter.get())->get_formatter().SetFormatKey(nNewKey);
}
else
{
@@ -1483,7 +1498,7 @@ OUString DbFormattedField::GetFormatText(const Reference< css::sdb::XColumn >& _
if (!_rxField.is())
return OUString();
FormattedControl* pControl = static_cast<FormattedControl*>(m_pPainter.get());
FormattedControlBase* pControl = static_cast<FormattedControlBase*>(m_pPainter.get());
weld::EntryFormatter& rPainterFormatter = pControl->get_formatter();
OUString aText;
@@ -1527,7 +1542,7 @@ void DbFormattedField::UpdateFromField(const Reference< css::sdb::XColumn >& _rx
{
try
{
FormattedControl* pEditControl = static_cast<FormattedControl*>(m_pWindow.get());
FormattedControlBase* pEditControl = static_cast<FormattedControlBase*>(m_pWindow.get());
weld::Entry& rEntry = pEditControl->get_widget();
weld::EntryFormatter& rEditFormatter = pEditControl->get_formatter();
@@ -1569,7 +1584,7 @@ void DbFormattedField::updateFromModel( Reference< XPropertySet > _rxModel )
{
OSL_ENSURE( _rxModel.is() && m_pWindow, "DbFormattedField::updateFromModel: invalid call!" );
FormattedControl* pEditControl = static_cast<FormattedControl*>(m_pWindow.get());
FormattedControlBase* pEditControl = static_cast<FormattedControlBase*>(m_pWindow.get());
weld::Entry& rEntry = pEditControl->get_widget();
weld::EntryFormatter& rEditFormatter = pEditControl->get_formatter();
@@ -1593,7 +1608,7 @@ bool DbFormattedField::commitControl()
{
Any aNewVal;
FormattedControl* pEditControl = static_cast<FormattedControl*>(m_pWindow.get());
FormattedControlBase* pEditControl = static_cast<FormattedControlBase*>(m_pWindow.get());
weld::Entry& rEntry = pEditControl->get_widget();
weld::EntryFormatter& rEditFormatter = pEditControl->get_formatter();
@@ -1883,6 +1898,10 @@ DbNumericField::DbNumericField( DbGridColumn& _rColumn )
doPropertyListening( FM_PROP_SHOWTHOUSANDSEP );
}
CellControllerRef DbNumericField::CreateController() const
{
return new ::svt::FormattedFieldCellController(static_cast<FormattedControlBase*>(m_pWindow.get()));
}
void DbNumericField::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
{
@@ -1898,13 +1917,13 @@ void DbNumericField::implAdjustGenericFieldSetting( const Reference< XPropertySe
sal_Int16 nScale = getINT16( _rxModel->getPropertyValue( FM_PROP_DECIMAL_ACCURACY ) );
bool bThousand = getBOOL( _rxModel->getPropertyValue( FM_PROP_SHOWTHOUSANDSEP ) );
Formatter& rEditFormatter = static_cast<DoubleNumericField*>(m_pWindow.get())->GetFormatter();
Formatter& rEditFormatter = static_cast<FormattedControlBase*>(m_pWindow.get())->get_formatter();
rEditFormatter.SetMinValue(nMin);
rEditFormatter.SetMaxValue(nMax);
rEditFormatter.SetSpinSize(nStep);
rEditFormatter.SetStrictFormat(bStrict);
Formatter& rPaintFormatter = static_cast<DoubleNumericField*>(m_pPainter.get())->GetFormatter();
Formatter& rPaintFormatter = static_cast<FormattedControlBase*>(m_pPainter.get())->get_formatter();
rPaintFormatter.SetMinValue(nMin);
rPaintFormatter.SetMaxValue(nMax);
rPaintFormatter.SetStrictFormat(bStrict);
@@ -1939,16 +1958,15 @@ void DbNumericField::implAdjustGenericFieldSetting( const Reference< XPropertySe
rPaintFormatter.SetFormat( sFormatString, aAppLanguage );
}
VclPtr<Control> DbNumericField::createField(BrowserDataWin* _pParent, bool bSpinButton, const Reference< XPropertySet >& /*_rxModel*/)
VclPtr<Control> DbNumericField::createField(BrowserDataWin* pParent, bool bSpinButton, const Reference<XPropertySet>& /*rxModel*/)
{
WinBits _nFieldStyle = bSpinButton ? (WB_REPEAT | WB_SPIN) : 0;
return VclPtr<DoubleNumericField>::Create( _pParent, _nFieldStyle );
return VclPtr<DoubleNumericControl>::Create(pParent, bSpinButton);
}
namespace
{
OUString lcl_setFormattedNumeric_nothrow( DoubleNumericField& _rField, const DbCellControl& _rControl,
OUString lcl_setFormattedNumeric_nothrow( FormattedControlBase& _rField, const DbCellControl& _rControl,
const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& _rxFormatter )
{
OUString sValue;
@@ -1959,8 +1977,8 @@ namespace
double fValue = _rControl.GetValue( _rxField, _rxFormatter );
if ( !_rxField->wasNull() )
{
_rField.GetFormatter().SetValue( fValue );
sValue = _rField.GetText();
_rField.get_formatter().SetValue(fValue);
sValue = _rField.get_widget().get_text();
}
}
catch( const Exception& )
@@ -1974,36 +1992,39 @@ namespace
OUString DbNumericField::GetFormatText(const Reference< css::sdb::XColumn >& _rxField, const Reference< css::util::XNumberFormatter >& _rxFormatter, Color** /*ppColor*/)
{
return lcl_setFormattedNumeric_nothrow(dynamic_cast<DoubleNumericField&>(*m_pPainter), *this, _rxField, _rxFormatter);
return lcl_setFormattedNumeric_nothrow(dynamic_cast<FormattedControlBase&>(*m_pPainter), *this, _rxField, _rxFormatter);
}
void DbNumericField::UpdateFromField(const Reference< css::sdb::XColumn >& _rxField, const Reference< css::util::XNumberFormatter >& _rxFormatter)
{
lcl_setFormattedNumeric_nothrow(dynamic_cast<DoubleNumericField&>(*m_pWindow), *this, _rxField, _rxFormatter);
lcl_setFormattedNumeric_nothrow(dynamic_cast<FormattedControlBase&>(*m_pWindow), *this, _rxField, _rxFormatter);
}
void DbNumericField::updateFromModel( Reference< XPropertySet > _rxModel )
{
OSL_ENSURE( _rxModel.is() && m_pWindow, "DbNumericField::updateFromModel: invalid call!" );
FormattedControlBase* pControl = static_cast<FormattedControlBase*>(m_pWindow.get());
double dValue = 0;
if ( _rxModel->getPropertyValue( FM_PROP_VALUE ) >>= dValue )
{
Formatter& rFormatter = static_cast<DoubleNumericField*>(m_pWindow.get())->GetFormatter();
Formatter& rFormatter = pControl->get_formatter();
rFormatter.SetValue(dValue);
}
else
m_pWindow->SetText( OUString() );
pControl->get_widget().set_text(OUString());
}
bool DbNumericField::commitControl()
{
OUString aText( m_pWindow->GetText());
FormattedControlBase* pControl = static_cast<FormattedControlBase*>(m_pWindow.get());
OUString aText(pControl->get_widget().get_text());
Any aVal;
if (!aText.isEmpty()) // not empty
{
Formatter& rFormatter = static_cast<DoubleNumericField*>(m_pWindow.get())->GetFormatter();
Formatter& rFormatter = pControl->get_formatter();
double fValue = rFormatter.GetValue();
aVal <<= fValue;
}

View File

@@ -628,11 +628,13 @@ protected:
virtual void implAdjustGenericFieldSetting( const css::uno::Reference< css::beans::XPropertySet >& _rxModel ) override;
};
class DbNumericField : public DbSpinField
{
public:
DbNumericField(DbGridColumn& _rColumn);
virtual ::svt::CellControllerRef CreateController() const override;
virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter, Color** ppColor = nullptr) override;
virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter) override;
@@ -652,7 +654,6 @@ protected:
void implAdjustGenericFieldSetting( const css::uno::Reference< css::beans::XPropertySet >& _rxModel ) override;
};
class DbFilterField final
:public DbCellControl
,public ::svxform::OSQLParserClient

View File

@@ -3182,7 +3182,7 @@ void SalInstanceEntry::set_alignment(TxtAlign eXAlign)
}
WinBits nBits = m_xEntry->GetStyle();
nBits &= ~(WB_LEFT | WB_CENTER | WB_RIGHT);
m_xEntry->SetStyle(nBits & nAlign);
m_xEntry->SetStyle(nBits | nAlign);
}
SalInstanceEntry::~SalInstanceEntry()