mirror of
https://github.com/LibreOffice/core.git
synced 2025-07-23 04:42:03 +00:00
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>
This commit is contained in:
@ -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.")
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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: */
|
||||
|
Reference in New Issue
Block a user