diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2025-01-14 13:56:31 +0500 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2025-01-14 13:26:16 +0100 |
commit | 2e498d7dba898d19ef32aac7b0cc53e074fcca3d (patch) | |
tree | ee9837109ea435148cd6f31db0cc3e14d63c0ae1 | |
parent | 94e9c45d9a82d917738f46243173b4521e1ccd09 (diff) |
Use ErrorHandler::HandleError, instead of creating own message box
Change-Id: Ib4aeb52db1d81d9e3dcc4e0c6c880be8982b8120
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180219
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | fpicker/inc/strings.hrc | 2 | ||||
-rw-r--r-- | fpicker/source/office/iodlg.cxx | 21 | ||||
-rw-r--r-- | include/fpicker/fpsofficeResMgr.hxx | 3 |
3 files changed, 13 insertions, 13 deletions
diff --git a/fpicker/inc/strings.hrc b/fpicker/inc/strings.hrc index bb5f553f5067..e15adc6c8e60 100644 --- a/fpicker/inc/strings.hrc +++ b/fpicker/inc/strings.hrc @@ -29,7 +29,7 @@ #define STR_BUTTONSELECT NC_("STR_BUTTONSELECT", "~Select") #define STR_PREVIEW NC_("STR_PREVIEW", "File Preview") #define STR_DEFAULT_DIRECTORY NC_("STR_DEFAULT_DIRECTORY", "My Documents") -#define RID_FILEOPEN_NOTEXISTENTFILE NC_("RID_FILEOPEN_NOTEXISTENTFILE", "The file $name$ does not exist.\nMake sure you have entered the correct file name.") +#define RID_FILEOPEN_NOTEXISTENTFILE NC_("RID_FILEOPEN_NOTEXISTENTFILE", "The file $(ARG1) does not exist.\nMake sure you have entered the correct file name.") #define STR_SVT_NEW_FOLDER NC_("STR_SVT_NEW_FOLDER", "Folder") #define STR_SVT_NOREMOVABLEDEVICE NC_("STR_SVT_NOREMOVABLEDEVICE", "No removable storage device detected.\nMake sure it is plugged in properly and try again.") diff --git a/fpicker/source/office/iodlg.cxx b/fpicker/source/office/iodlg.cxx index 5400d4323099..09a246424c5d 100644 --- a/fpicker/source/office/iodlg.cxx +++ b/fpicker/source/office/iodlg.cxx @@ -37,6 +37,7 @@ #include <unotools/ucbhelper.hxx> #include <unotools/pathoptions.hxx> #include <unotools/viewoptions.hxx> +#include <svtools/ehdl.hxx> #include <svtools/sfxecode.hxx> #include <fpicker/strings.hrc> @@ -892,16 +893,14 @@ void SvtFileDialog::OpenHdl_Impl(void const * pVoid) if ( !bExists ) { - OUString sError(FpsResId(RID_FILEOPEN_NOTEXISTENTFILE)); - OUString sInvalidFile( aFileObj.GetMainURL( INetURLObject::DecodeMechanism::ToIUri ) ); // transform the URL into system notation osl_getSystemPathFromFileURL(sInvalidFile.pData, &sInvalidFile.pData); - sError = sError.replaceFirst( "$name$", sInvalidFile ); - - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(), - VclMessageType::Warning, VclButtonsType::Ok, sError)); - xBox->run(); + static constexpr ErrMsgCode ids[] + = { { RID_FILEOPEN_NOTEXISTENTFILE, ERRCODE_IO_NOTEXISTS }, { {}, {} } }; + SfxErrorHandler handler(ids, ErrCodeArea::Io, ErrCodeArea::Io, FpsResLocale()); + ErrorHandler::HandleError({ ERRCODE_IO_NOTEXISTS, sInvalidFile }, + m_xDialog.get()); return; } } @@ -1489,10 +1488,10 @@ bool SvtFileDialog::PrepareExecute() = aCnt.createCursor( aProps, ::ucbhelper::INCLUDE_FOLDERS_ONLY ); if ( xResultSet.is() && !xResultSet->next() ) { - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(), - VclMessageType::Warning, VclButtonsType::Ok, - FpsResId(STR_SVT_NOREMOVABLEDEVICE))); - xBox->run(); + static constexpr ErrMsgCode ids[] + = { { STR_SVT_NOREMOVABLEDEVICE, ERRCODE_IO_INVALIDDEVICE }, { {}, {} } }; + SfxErrorHandler handler(ids, ErrCodeArea::Io, ErrCodeArea::Io, FpsResLocale()); + ErrorHandler::HandleError(ERRCODE_IO_INVALIDDEVICE, m_xDialog.get()); return false; } } diff --git a/include/fpicker/fpsofficeResMgr.hxx b/include/fpicker/fpsofficeResMgr.hxx index a86a91509c38..83cf0f3d86f7 100644 --- a/include/fpicker/fpsofficeResMgr.hxx +++ b/include/fpicker/fpsofficeResMgr.hxx @@ -10,6 +10,7 @@ #include <unotools/resmgr.hxx> -inline OUString FpsResId(TranslateId aId) { return Translate::get(aId, Translate::Create("fps")); }; +inline std::locale FpsResLocale() { return Translate::Create("fps"); } +inline OUString FpsResId(TranslateId aId) { return Translate::get(aId, FpsResLocale()); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |