FieldDescControl: Fix conditions needed to update the format sample

OnControlFocusLost has a long if-chain of actions to perform for each
control. The last one looks like it was trying to update the format
sample whenever the default value changes. However, there’s already a
case further up the chain that handles the case where the default value
text box loses focus and the value is different from the saved value.
That means the format sample would only end up being updated if the
default value control loses focus but nothing was changed in it, which
seems pretty clearly like a mistake. It makes it so the only way to make
the format sample update after changing the default value is to first
move the focus to another control, move it back to the default value and
then move it away again.

This patch just moves the format sample update into the same branch of
the if-chain that already exists to handle the default value control.

Change-Id: Ia4885589a7f50e01479972cceb4e7c6875efbde0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192753
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
This commit is contained in:
Neil Roberts
2025-10-21 07:59:19 +02:00
committed by Noel Grandin
parent 9b0debcf45
commit 037a9b4e3c
@@ -1078,7 +1078,10 @@ IMPL_LINK(OFieldDescControl, OnControlFocusLost, weld::Widget&, rControl, void )
else if (m_xColumnName && &rControl == m_xColumnName->GetWidget() && m_xColumnName->get_value_changed_from_saved())
CellModified(-1, m_xColumnName->GetPos());
else if (m_xDefault && &rControl == m_xDefault->GetWidget() && m_xDefault->get_value_changed_from_saved())
{
CellModified(-1, m_xDefault->GetPos());
UpdateFormatSample(pActFieldDescr);
}
else if (m_xFormatSample && &rControl == m_xFormatSample->GetWidget() && m_xFormatSample->get_value_changed_from_saved())
CellModified(-1, m_xFormatSample->GetPos());
else if (m_xAutoIncrementValue && &rControl == m_xAutoIncrementValue->GetWidget() && m_xAutoIncrementValue->get_value_changed_from_saved())
@@ -1093,8 +1096,6 @@ IMPL_LINK(OFieldDescControl, OnControlFocusLost, weld::Widget&, rControl, void )
CellModified(-1, m_xBoolDefault->GetPos());
else if (m_xType && &rControl == m_xType->GetWidget() && m_xType->get_value_changed_from_saved())
CellModified(-1, m_xType->GetPos());
else if (m_xDefault && &rControl == m_xDefault->GetWidget())
UpdateFormatSample(pActFieldDescr);
implFocusLost(&rControl);
}