dbaccess/source/ui/control/FieldDescControl.cxx | 26 +++++++++++++------ dbaccess/source/ui/inc/FieldDescControl.hxx | 2 + dbaccess/source/ui/inc/TableDesignView.hxx | 2 + dbaccess/source/ui/tabledesign/TableController.cxx | 4 +- dbaccess/source/ui/tabledesign/TableDesignView.cxx | 6 ++++ dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx | 5 +++ dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx | 2 + 7 files changed, 38 insertions(+), 9 deletions(-)
New commits: commit 3431eb08cd3f84c589f78791a1daedf309566cbc Author: Neil Roberts <[email protected]> AuthorDate: Tue Oct 21 00:45:27 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Sun Oct 26 16:24:47 2025 +0100 tdf#168970 OFieldDescControl: Add explicit method to flush changes Previously when the table edit window was about to be closed it relied on being able to trigger the OFieldDescControl to save its pending changes by making it lose the keyboard focus. This doesn’t work on the GTK3 backend and also seems like a bit of an unreliable approach anyway. This patch instead adds a method to explicitly make the control flush any pending changes. Change-Id: I8e7b8e55ce4f56323fe1c0779bf3237ce847e5e8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192976 Reviewed-by: Noel Grandin <[email protected]> Tested-by: Jenkins diff --git a/dbaccess/source/ui/control/FieldDescControl.cxx b/dbaccess/source/ui/control/FieldDescControl.cxx index fabba657313f..ba9d61d2c6fb 100644 --- a/dbaccess/source/ui/control/FieldDescControl.cxx +++ b/dbaccess/source/ui/control/FieldDescControl.cxx @@ -894,10 +894,7 @@ void OFieldDescControl::DisplayData(OFieldDescription* pFieldDescr ) } if (m_xDefault) - { m_xDefault->set_text(getControlDefault(pFieldDescr)); - m_xDefault->save_value(); - } if (m_xBoolDefault) { @@ -937,10 +934,7 @@ void OFieldDescControl::DisplayData(OFieldDescription* pFieldDescr ) } if (m_xTextLen) - { m_xTextLen->set_text(OUString::number(pFieldDescr->GetPrecision())); - m_xTextLen->save_value(); - } if( m_xNumType ) { @@ -989,6 +983,14 @@ void OFieldDescControl::DisplayData(OFieldDescription* pFieldDescr ) // Enable/disable Controls bool bRead(IsReadOnly()); + // Save the values that we loaded so we can detect any changes + iterateControls([] (OWidgetBase* pWidget) + { + if (pWidget) + pWidget->save_value(); + return false; + }); + SetReadOnly( bRead ); } @@ -1000,7 +1002,6 @@ IMPL_LINK(OFieldDescControl, OnControlFocusGot, weld::Widget&, rControl, void ) { if (pWidget && &rControl == pWidget->GetWidget()) { - pWidget->save_value(); strHelpText = pWidget->GetHelp(); return true; } @@ -1039,6 +1040,17 @@ IMPL_LINK(OFieldDescControl, OnControlFocusLost, weld::Widget&, rControl, void ) implFocusLost(&rControl); } +void OFieldDescControl::FlushModifiedData() +{ + iterateControls([&](OWidgetBase* pWidget) + { + if (pWidget && pWidget->get_value_changed_from_saved()) + CellModified(-1, pWidget->GetPos()); + + return false; + }); +} + void OFieldDescControl::SaveData( OFieldDescription* pFieldDescr ) { if( !pFieldDescr ) diff --git a/dbaccess/source/ui/inc/FieldDescControl.hxx b/dbaccess/source/ui/inc/FieldDescControl.hxx index 254f47422fe0..f07191802374 100644 --- a/dbaccess/source/ui/inc/FieldDescControl.hxx +++ b/dbaccess/source/ui/inc/FieldDescControl.hxx @@ -168,6 +168,8 @@ namespace dbaui OFieldDescControl(weld::Container* pPage, OTableDesignHelpBar* pHelpBar); virtual ~OFieldDescControl(); + void FlushModifiedData(); + void DisplayData(OFieldDescription* pFieldDescr ); void SaveData( OFieldDescription* pFieldDescr ); diff --git a/dbaccess/source/ui/inc/TableDesignView.hxx b/dbaccess/source/ui/inc/TableDesignView.hxx index 077eb211e3b4..ab83b21153b5 100644 --- a/dbaccess/source/ui/inc/TableDesignView.hxx +++ b/dbaccess/source/ui/inc/TableDesignView.hxx @@ -91,6 +91,8 @@ namespace dbaui OTableFieldDescWin* GetDescWin() const { return m_pWin ? m_pWin->GetDescWin() : nullptr; } OTableController& getController() const { return m_rController; } + void FlushModifiedData(); + const css::lang::Locale& getLocale() const { return m_aLocale;} // IClipboardTest diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx index 59b3bb492cc9..90ba1ac4da2a 100644 --- a/dbaccess/source/ui/tabledesign/TableController.cxx +++ b/dbaccess/source/ui/tabledesign/TableController.cxx @@ -510,8 +510,8 @@ sal_Bool SAL_CALL OTableController::suspend(sal_Bool /*_bSuspend*/) ::osl::MutexGuard aGuard( getMutex() ); if ( getView() && getView()->IsInModalMode() ) return false; - if ( getView() ) - static_cast<OTableDesignView*>(getView())->GrabFocus(); + if ( OTableDesignView* pView = static_cast<OTableDesignView*>(getView()) ) + pView->FlushModifiedData(); bool bCheck = true; if ( isModified() ) { diff --git a/dbaccess/source/ui/tabledesign/TableDesignView.cxx b/dbaccess/source/ui/tabledesign/TableDesignView.cxx index 4ae94dcf6e78..cb1ed139d287 100644 --- a/dbaccess/source/ui/tabledesign/TableDesignView.cxx +++ b/dbaccess/source/ui/tabledesign/TableDesignView.cxx @@ -255,4 +255,10 @@ void OTableDesignView::GetFocus() GetEditorCtrl()->GrabFocus(); } +void OTableDesignView::FlushModifiedData() +{ + if ( OTableFieldDescWin* pDescWin = GetDescWin() ) + pDescWin->FlushModifiedData(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx b/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx index 7aa12b498190..cdcccc084f30 100644 --- a/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx +++ b/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx @@ -72,6 +72,11 @@ void OTableFieldDescWin::SaveData( OFieldDescription* pFieldDescr ) m_xFieldControl->SaveData( pFieldDescr ); } +void OTableFieldDescWin::FlushModifiedData() +{ + m_xFieldControl->FlushModifiedData(); +} + IClipboardTest* OTableFieldDescWin::getActiveChild() const { IClipboardTest* pTest = nullptr; diff --git a/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx b/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx index f14e468c561e..602a05599e5d 100644 --- a/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx +++ b/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx @@ -61,6 +61,8 @@ namespace dbaui void SaveData( OFieldDescription* pFieldDescr ); void SetReadOnly( bool bReadOnly ); + void FlushModifiedData(); + void SetControlText( sal_uInt16 nControlId, const OUString& rText ) { m_xFieldControl->SetControlText(nControlId,rText); }
