mirror of
https://github.com/LibreOffice/core.git
synced 2025-08-02 04:50:01 +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_BUTTONSELECT NC_("STR_BUTTONSELECT", "~Select")
|
||||||
#define STR_PREVIEW NC_("STR_PREVIEW", "File Preview")
|
#define STR_PREVIEW NC_("STR_PREVIEW", "File Preview")
|
||||||
#define STR_DEFAULT_DIRECTORY NC_("STR_DEFAULT_DIRECTORY", "My Documents")
|
#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_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.")
|
#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/ucbhelper.hxx>
|
||||||
#include <unotools/pathoptions.hxx>
|
#include <unotools/pathoptions.hxx>
|
||||||
#include <unotools/viewoptions.hxx>
|
#include <unotools/viewoptions.hxx>
|
||||||
|
#include <svtools/ehdl.hxx>
|
||||||
#include <svtools/sfxecode.hxx>
|
#include <svtools/sfxecode.hxx>
|
||||||
|
|
||||||
#include <fpicker/strings.hrc>
|
#include <fpicker/strings.hrc>
|
||||||
@ -892,16 +893,14 @@ void SvtFileDialog::OpenHdl_Impl(void const * pVoid)
|
|||||||
|
|
||||||
if ( !bExists )
|
if ( !bExists )
|
||||||
{
|
{
|
||||||
OUString sError(FpsResId(RID_FILEOPEN_NOTEXISTENTFILE));
|
|
||||||
|
|
||||||
OUString sInvalidFile( aFileObj.GetMainURL( INetURLObject::DecodeMechanism::ToIUri ) );
|
OUString sInvalidFile( aFileObj.GetMainURL( INetURLObject::DecodeMechanism::ToIUri ) );
|
||||||
// transform the URL into system notation
|
// transform the URL into system notation
|
||||||
osl_getSystemPathFromFileURL(sInvalidFile.pData, &sInvalidFile.pData);
|
osl_getSystemPathFromFileURL(sInvalidFile.pData, &sInvalidFile.pData);
|
||||||
sError = sError.replaceFirst( "$name$", sInvalidFile );
|
static constexpr ErrMsgCode ids[]
|
||||||
|
= { { RID_FILEOPEN_NOTEXISTENTFILE, ERRCODE_IO_NOTEXISTS }, { {}, {} } };
|
||||||
std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
|
SfxErrorHandler handler(ids, ErrCodeArea::Io, ErrCodeArea::Io, FpsResLocale());
|
||||||
VclMessageType::Warning, VclButtonsType::Ok, sError));
|
ErrorHandler::HandleError({ ERRCODE_IO_NOTEXISTS, sInvalidFile },
|
||||||
xBox->run();
|
m_xDialog.get());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1489,10 +1488,10 @@ bool SvtFileDialog::PrepareExecute()
|
|||||||
= aCnt.createCursor( aProps, ::ucbhelper::INCLUDE_FOLDERS_ONLY );
|
= aCnt.createCursor( aProps, ::ucbhelper::INCLUDE_FOLDERS_ONLY );
|
||||||
if ( xResultSet.is() && !xResultSet->next() )
|
if ( xResultSet.is() && !xResultSet->next() )
|
||||||
{
|
{
|
||||||
std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
|
static constexpr ErrMsgCode ids[]
|
||||||
VclMessageType::Warning, VclButtonsType::Ok,
|
= { { STR_SVT_NOREMOVABLEDEVICE, ERRCODE_IO_INVALIDDEVICE }, { {}, {} } };
|
||||||
FpsResId(STR_SVT_NOREMOVABLEDEVICE)));
|
SfxErrorHandler handler(ids, ErrCodeArea::Io, ErrCodeArea::Io, FpsResLocale());
|
||||||
xBox->run();
|
ErrorHandler::HandleError(ERRCODE_IO_INVALIDDEVICE, m_xDialog.get());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include <unotools/resmgr.hxx>
|
#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: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
Reference in New Issue
Block a user