Reapply "create ErrorHandlerFlags scoped enum for error handling flags""

This effectively reverts commit 32cae6a2eaa41568888df9c8fc5605debd8d704a.

Change-Id: I15bb0a5c4acaeee6d47dd93a71601d9687d701bc
Reviewed-on: https://gerrit.libreoffice.org/34028
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2017-02-08 11:12:00 +02:00
parent afc755fa61
commit bcad173faa
20 changed files with 175 additions and 155 deletions

View File

@ -441,7 +441,7 @@ namespace basic
for(const auto& rError : aErrors)
{
// show message to user
if ( ERRCODE_BUTTON_CANCEL == ErrorHandler::HandleError( rError.GetErrorId() ) )
if ( ErrorHandlerFlags::ButtonsCancel == ErrorHandler::HandleError( rError.GetErrorId() ) )
{
// user wants to break loading of BASIC-manager
delete _out_rpBasicManager;

View File

@ -636,7 +636,7 @@ void BasicManager::ImpMgrNotLoaded( const OUString& rStorageName )
{
// pErrInf is only destroyed if the error os processed by an
// ErrorHandler
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_MGROPEN, rStorageName, ERRCODE_BUTTON_OK );
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_MGROPEN, rStorageName, ErrorHandlerFlags::ButtonsOk );
aErrors.push_back(BasicError(*pErrInf, BasicErrorReason::OPENMGRSTREAM));
// Create a stdlib otherwise we crash!
@ -776,7 +776,7 @@ void BasicManager::LoadOldBasicManager( SotStorage& rStorage )
xManagerStream->Seek( nBasicStartOff );
if (!ImplLoadBasic( *xManagerStream, mpImpl->aLibs.front()->GetLibRef() ))
{
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_MGROPEN, aStorName, ERRCODE_BUTTON_OK );
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_MGROPEN, aStorName, ErrorHandlerFlags::ButtonsOk );
aErrors.push_back(BasicError(*pErrInf, BasicErrorReason::OPENMGRSTREAM));
// and it proceeds ...
}
@ -824,7 +824,7 @@ void BasicManager::LoadOldBasicManager( SotStorage& rStorage )
}
else
{
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_LIBLOAD, aStorName, ERRCODE_BUTTON_OK );
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_LIBLOAD, aStorName, ErrorHandlerFlags::ButtonsOk );
aErrors.push_back(BasicError(*pErrInf, BasicErrorReason::STORAGENOTFOUND));
}
}
@ -907,7 +907,7 @@ bool BasicManager::ImpLoadLibrary( BasicLibInfo* pLibInfo, SotStorage* pCurStora
if ( !xBasicStorage.is() || xBasicStorage->GetError() )
{
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_MGROPEN, xStorage->GetName(), ERRCODE_BUTTON_OK );
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_MGROPEN, xStorage->GetName(), ErrorHandlerFlags::ButtonsOk );
aErrors.push_back(BasicError(*pErrInf, BasicErrorReason::OPENLIBSTORAGE));
}
else
@ -916,7 +916,7 @@ bool BasicManager::ImpLoadLibrary( BasicLibInfo* pLibInfo, SotStorage* pCurStora
tools::SvRef<SotStorageStream> xBasicStream = xBasicStorage->OpenSotStream( pLibInfo->GetLibName(), eStreamReadMode );
if ( !xBasicStream.is() || xBasicStream->GetError() )
{
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_LIBLOAD , pLibInfo->GetLibName(), ERRCODE_BUTTON_OK );
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_LIBLOAD , pLibInfo->GetLibName(), ErrorHandlerFlags::ButtonsOk );
aErrors.push_back(BasicError(*pErrInf, BasicErrorReason::OPENLIBSTREAM));
}
else
@ -939,7 +939,7 @@ bool BasicManager::ImpLoadLibrary( BasicLibInfo* pLibInfo, SotStorage* pCurStora
}
if ( !bLoaded )
{
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_LIBLOAD, pLibInfo->GetLibName(), ERRCODE_BUTTON_OK );
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_LIBLOAD, pLibInfo->GetLibName(), ErrorHandlerFlags::ButtonsOk );
aErrors.push_back(BasicError(*pErrInf, BasicErrorReason::BASICLOADERROR));
}
else
@ -1123,7 +1123,7 @@ bool BasicManager::RemoveLib( sal_uInt16 nLib, bool bDelBasicFromStorage )
if( !nLib || nLib < mpImpl->aLibs.size() )
{
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_REMOVELIB, OUString(), ERRCODE_BUTTON_OK );
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_REMOVELIB, OUString(), ErrorHandlerFlags::ButtonsOk );
aErrors.push_back(BasicError(*pErrInf, BasicErrorReason::STDLIB));
return false;
}
@ -1159,7 +1159,7 @@ bool BasicManager::RemoveLib( sal_uInt16 nLib, bool bDelBasicFromStorage )
if ( !xBasicStorage.is() || xBasicStorage->GetError() )
{
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_REMOVELIB, OUString(), ERRCODE_BUTTON_OK );
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_REMOVELIB, OUString(), ErrorHandlerFlags::ButtonsOk );
aErrors.push_back(BasicError(*pErrInf, BasicErrorReason::OPENLIBSTORAGE));
}
else if (xBasicStorage->IsStream((*itLibInfo)->GetLibName()))
@ -1294,7 +1294,7 @@ bool BasicManager::LoadLib( sal_uInt16 nLib )
}
else
{
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_LIBLOAD, OUString(), ERRCODE_BUTTON_OK );
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_LIBLOAD, OUString(), ErrorHandlerFlags::ButtonsOk );
aErrors.push_back(BasicError(*pErrInf, BasicErrorReason::LIBNOTFOUND));
}
return bDone;

View File

@ -46,25 +46,6 @@ Warning || || |
Code
*/
#define ERRCODE_BUTTON_OK 0x01
#define ERRCODE_BUTTON_CANCEL 0x02
#define ERRCODE_BUTTON_RETRY 0x04
#define ERRCODE_BUTTON_OK_CANCEL 0x03
#define ERRCODE_BUTTON_NO 0x08
#define ERRCODE_BUTTON_YES 0x10
#define ERRCODE_BUTTON_YES_NO 0x18
#define ERRCODE_BUTTON_YES_NO_CANCEL 0x1a
#define ERRCODE_BUTTON_DEF_OK 0x100
#define ERRCODE_BUTTON_DEF_CANCEL 0x200
#define ERRCODE_BUTTON_DEF_YES 0x300
#define ERRCODE_BUTTON_DEF_NO 0x400
#define ERRCODE_MSG_ERROR 0x1000
#define ERRCODE_MSG_WARNING 0x2000
#define ERRCODE_MSG_INFO 0x3000
#define ERRCODE_MSG_QUERY 0x4000
#define ERRCODE_ERROR_MASK 0x3fffffffUL
#define ERRCODE_WARNING_MASK 0x80000000UL
#define ERRCODE_RES_MASK 0x7fff

View File

@ -26,6 +26,7 @@
#include <rtl/ustring.hxx>
#include <tools/errcode.hxx>
#include <tools/toolsdllapi.h>
#include <o3tl/typed_flags_set.hxx>
#include <memory>
// FIXME: horrible legacy dependency on VCL from tools.
@ -34,6 +35,35 @@ namespace vcl { class Window; }
class DynamicErrorInfo_Impl;
class ErrorHandler_Impl;
enum class ErrorHandlerFlags
{
NONE = 0x0000,
ButtonsOk = 0x0001,
ButtonsCancel = 0x0002,
ButtonsRetry = 0x0004,
ButtonsOkCancel = 0x0003,
ButtonsNo = 0x0008,
ButtonsYes = 0x0010,
ButtonsYesNo = 0x0018,
ButtonsYesNoCancel = 0x001a,
ButtonDefaultsOk = 0x0100,
ButtonDefaultsCancel = 0x0200,
ButtonDefaultsYes = 0x0300,
ButtonDefaultsNo = 0x0400,
MessageError = 0x1000,
MessageWarning = 0x2000,
MessageInfo = 0x3000,
MessageQuery = 0x4000,
MAX = USHRT_MAX,
};
namespace o3tl
{
template<> struct typed_flags<ErrorHandlerFlags> : is_typed_flags<ErrorHandlerFlags, 0xffff> {};
}
class SAL_WARN_UNUSED TOOLS_DLLPUBLIC ErrorInfo
{
private:
@ -59,11 +89,11 @@ private:
public:
DynamicErrorInfo(sal_uIntPtr lUserId, sal_uInt16 nMask);
DynamicErrorInfo(sal_uIntPtr lUserId, ErrorHandlerFlags nMask);
virtual ~DynamicErrorInfo() override;
operator sal_uIntPtr() const;
sal_uInt16 GetDialogMask() const;
ErrorHandlerFlags GetDialogMask() const;
};
class SAL_WARN_UNUSED TOOLS_DLLPUBLIC StringErrorInfo : public DynamicErrorInfo
@ -75,7 +105,7 @@ public:
StringErrorInfo( sal_uIntPtr lUserId,
const OUString& aStringP,
sal_uInt16 nMask = 0);
ErrorHandlerFlags nMask = ErrorHandlerFlags::NONE);
const OUString& GetErrorString() const { return aString; }
};
@ -88,7 +118,7 @@ private:
public:
TwoStringErrorInfo(sal_uIntPtr nUserID, const OUString & rTheArg1,
const OUString & rTheArg2, sal_uInt16 nMask):
const OUString & rTheArg2, ErrorHandlerFlags nMask):
DynamicErrorInfo(nUserID, nMask), aArg1(rTheArg1), aArg2(rTheArg2) {}
const OUString& GetArg1() const { return aArg1; }
@ -113,8 +143,8 @@ public:
static ErrorContext* GetContext();
};
typedef sal_uInt16 WindowDisplayErrorFunc(
vcl::Window *, sal_uInt16 nMask, const OUString &rErr, const OUString &rAction);
typedef ErrorHandlerFlags WindowDisplayErrorFunc(
vcl::Window *, ErrorHandlerFlags nMask, const OUString &rErr, const OUString &rAction);
typedef void BasicDisplayErrorFunc(
const OUString &rErr, const OUString &rAction);
@ -124,8 +154,8 @@ class SAL_WARN_UNUSED TOOLS_DLLPUBLIC ErrorHandler
friend class ErrorHandler_Impl;
private:
static sal_uInt16 HandleError_Impl( sal_uIntPtr lId,
sal_uInt16 nFlags,
static ErrorHandlerFlags HandleError_Impl( sal_uIntPtr lId,
ErrorHandlerFlags nFlags,
bool bJustCreateString,
OUString & rError);
protected:
@ -135,7 +165,7 @@ public:
ErrorHandler();
virtual ~ErrorHandler();
static sal_uInt16 HandleError ( sal_uIntPtr lId, sal_uInt16 nMask = USHRT_MAX );
static ErrorHandlerFlags HandleError ( sal_uIntPtr lId, ErrorHandlerFlags nMask = ErrorHandlerFlags::MAX );
static bool GetErrorString( sal_uIntPtr lId, OUString& rStr );
static void RegisterDisplay( BasicDisplayErrorFunc* );

View File

@ -220,13 +220,13 @@ sal_uInt32 ScXMLImportWrapper::ImportFromComponent(const uno::Reference<uno::XCo
(bMustBeSuccessfull ? SCERR_IMPORT_FILE_ROWCOL
: SCWARN_IMPORT_FILE_ROWCOL),
sDocName, sErr,
ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR );
ErrorHandlerFlags::ButtonsOk | ErrorHandlerFlags::MessageError );
}
else
{
OSL_ENSURE( bMustBeSuccessfull, "Warnings are not supported" );
nReturn = *new StringErrorInfo( SCERR_IMPORT_FORMAT_ROWCOL, sErr,
ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR );
ErrorHandlerFlags::ButtonsOk | ErrorHandlerFlags::MessageError );
}
}
}

View File

@ -2468,7 +2468,7 @@ bool ScDocShell::ConvertTo( SfxMedium &rMed )
SetError(*new StringErrorInfo(
SCWARN_EXPORT_NONCONVERTIBLE_CHARS,
aImExport.GetNonConvertibleChars(),
ERRCODE_BUTTON_OK | ERRCODE_MSG_INFO), OSL_LOG_PREFIX);
ErrorHandlerFlags::ButtonsOk | ErrorHandlerFlags::MessageInfo), OSL_LOG_PREFIX);
}
}
}

View File

@ -1090,10 +1090,10 @@ sal_uLong ScDocShell::DBaseExport( const OUString& rFullFileName, rtl_TextEncodi
OUString sEncoding( SvxTextEncodingTable().GetTextString( eCharSet));
nErr = *new TwoStringErrorInfo( (bEncErr ? SCERR_EXPORT_ENCODING :
SCERR_EXPORT_FIELDWIDTH), sPosition, sEncoding,
ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR);
ErrorHandlerFlags::ButtonsOk | ErrorHandlerFlags::MessageError);
}
else if ( !aException.Message.isEmpty() )
nErr = *new StringErrorInfo( (SCERR_EXPORT_SQLEXCEPTION), aException.Message, ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR);
nErr = *new StringErrorInfo( SCERR_EXPORT_SQLEXCEPTION, aException.Message, ErrorHandlerFlags::ButtonsOk | ErrorHandlerFlags::MessageError);
else
nErr = SCERR_EXPORT_DATA;
}

View File

@ -249,13 +249,13 @@ sal_Int32 ReadThroughComponent(
(bMustBeSuccessfull ? ERR_FORMAT_FILE_ROWCOL
: WARN_FORMAT_FILE_ROWCOL),
rStreamName, sErr,
ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR );
ErrorHandlerFlags::ButtonsOk | ErrorHandlerFlags::MessageError );
}
else
{
DBG_ASSERT( bMustBeSuccessfull, "Warnings are not supported" );
return *new StringErrorInfo( ERR_FORMAT_ROWCOL, sErr,
ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR );
ErrorHandlerFlags::ButtonsOk | ErrorHandlerFlags::MessageError );
}
}
catch (const xml::sax::SAXException& r)

View File

@ -2297,7 +2297,7 @@ bool SfxObjectShell::ImportFrom(SfxMedium& rMedium,
if (rWrapped.TargetException >>= e)
{
SetError(*new StringErrorInfo(ERRCODE_SFX_FORMAT_ROWCOL,
e.Message, ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR ), "");
e.Message, ErrorHandlerFlags::ButtonsOk | ErrorHandlerFlags::MessageError ), "");
}
}
catch (...)

View File

@ -32,9 +32,9 @@
#include <memory>
static sal_uInt16 aWndFunc(
static ErrorHandlerFlags aWndFunc(
vcl::Window *pWin, // Parent of the dialog
sal_uInt16 nFlags,
ErrorHandlerFlags nFlags,
const OUString &rErr, // error text
const OUString &rAction) // action text
@ -53,34 +53,35 @@ static sal_uInt16 aWndFunc(
// determine necessary WinBits from the flags
WinBits eBits=0;
if ( (ERRCODE_BUTTON_CANCEL|ERRCODE_BUTTON_RETRY) == (nFlags & (ERRCODE_BUTTON_CANCEL|ERRCODE_BUTTON_RETRY)) )
if ( nFlags & (ErrorHandlerFlags::ButtonsCancel | ErrorHandlerFlags::ButtonsRetry) )
eBits = WB_RETRY_CANCEL;
else if ( ERRCODE_BUTTON_OK_CANCEL == (nFlags & ERRCODE_BUTTON_OK_CANCEL) )
else if ( nFlags & ErrorHandlerFlags::ButtonsOkCancel )
eBits = WB_OK_CANCEL;
else if ( ERRCODE_BUTTON_OK == (nFlags & ERRCODE_BUTTON_OK) )
else if ( nFlags & ErrorHandlerFlags::ButtonsOk )
eBits = WB_OK;
else if ( ERRCODE_BUTTON_YES_NO_CANCEL == (nFlags & ERRCODE_BUTTON_YES_NO_CANCEL) )
else if ( nFlags & ErrorHandlerFlags::ButtonsYesNoCancel )
eBits = WB_YES_NO_CANCEL;
else if ( ERRCODE_BUTTON_YES_NO == (nFlags & ERRCODE_BUTTON_YES_NO) )
else if ( nFlags & ErrorHandlerFlags::ButtonsYesNo )
eBits = WB_YES_NO;
switch(nFlags & 0x0f00)
switch(nFlags & ErrorHandlerFlags(0x0f00))
{
case ERRCODE_BUTTON_DEF_OK:
case ErrorHandlerFlags::ButtonDefaultsOk:
eBits |= WB_DEF_OK;
break;
case ERRCODE_BUTTON_DEF_CANCEL:
case ErrorHandlerFlags::ButtonDefaultsCancel:
eBits |= WB_DEF_CANCEL;
break;
case ERRCODE_BUTTON_DEF_YES:
case ErrorHandlerFlags::ButtonDefaultsYes:
eBits |= WB_DEF_YES;
break;
case ERRCODE_BUTTON_DEF_NO:
case ErrorHandlerFlags::ButtonDefaultsNo:
eBits |= WB_DEF_NO;
break;
default: break;
}
OUString aErr(SvtResId(STR_ERR_HDLMESS).toString());
@ -91,48 +92,48 @@ static sal_uInt16 aWndFunc(
aErr = aErr.replaceAll("$(ERROR)", rErr);
VclPtr<MessBox> pBox;
switch ( nFlags & 0xf000 )
switch ( nFlags & ErrorHandlerFlags(0xf000) )
{
case ERRCODE_MSG_ERROR:
case ErrorHandlerFlags::MessageError:
pBox.reset(VclPtr<ErrorBox>::Create(pWin, eBits, aErr));
break;
case ERRCODE_MSG_WARNING:
case ErrorHandlerFlags::MessageWarning:
pBox.reset(VclPtr<WarningBox>::Create(pWin, eBits, aErr));
break;
case ERRCODE_MSG_INFO:
case ErrorHandlerFlags::MessageInfo:
pBox.reset(VclPtr<InfoBox>::Create(pWin, aErr));
break;
case ERRCODE_MSG_QUERY:
case ErrorHandlerFlags::MessageQuery:
pBox.reset(VclPtr<QueryBox>::Create(pWin, eBits, aErr));
break;
default:
{
SAL_WARN( "svtools.misc", "no MessBox type");
return ERRCODE_BUTTON_OK;
return ErrorHandlerFlags::ButtonsOk;
}
}
sal_uInt16 nRet = RET_CANCEL;
ErrorHandlerFlags nRet = ErrorHandlerFlags::NONE;
switch ( pBox->Execute() )
{
case RET_OK:
nRet = ERRCODE_BUTTON_OK;
nRet = ErrorHandlerFlags::ButtonsOk;
break;
case RET_CANCEL:
nRet = ERRCODE_BUTTON_CANCEL;
nRet = ErrorHandlerFlags::ButtonsCancel;
break;
case RET_RETRY:
nRet = ERRCODE_BUTTON_RETRY;
nRet = ErrorHandlerFlags::ButtonsRetry;
break;
case RET_YES:
nRet = ERRCODE_BUTTON_YES;
nRet = ErrorHandlerFlags::ButtonsYes;
break;
case RET_NO:
nRet = ERRCODE_BUTTON_NO;
nRet = ErrorHandlerFlags::ButtonsNo;
break;
default:
SAL_WARN( "svtools.misc", "Unknown MessBox return value" );

View File

@ -189,7 +189,7 @@ bool SwFEShell::InsertRow( sal_uInt16 nCnt, bool bBehind )
if( dynamic_cast< const SwDDETable* >(pFrame->ImplFindTabFrame()->GetTable()) != nullptr )
{
ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR,
ERRCODE_MSG_INFO | ERRCODE_BUTTON_DEF_OK );
ErrorHandlerFlags::MessageInfo | ErrorHandlerFlags::ButtonDefaultsOk );
return false;
}
@ -230,7 +230,7 @@ bool SwFEShell::InsertCol( sal_uInt16 nCnt, bool bBehind )
if( dynamic_cast< const SwDDETable* >(pFrame->ImplFindTabFrame()->GetTable()) != nullptr )
{
ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR,
ERRCODE_MSG_INFO | ERRCODE_BUTTON_DEF_OK );
ErrorHandlerFlags::MessageInfo | ErrorHandlerFlags::ButtonDefaultsOk );
return false;
}
@ -239,7 +239,7 @@ bool SwFEShell::InsertCol( sal_uInt16 nCnt, bool bBehind )
if( !CheckSplitCells( *this, nCnt + 1, nsSwTableSearchType::TBLSEARCH_COL ) )
{
ErrorHandler::HandleError( ERR_TBLINSCOL_ERROR,
ERRCODE_MSG_INFO | ERRCODE_BUTTON_DEF_OK );
ErrorHandlerFlags::MessageInfo | ErrorHandlerFlags::ButtonDefaultsOk );
return false;
}
@ -285,7 +285,7 @@ bool SwFEShell::DeleteCol()
if( dynamic_cast< const SwDDETable* >(pFrame->ImplFindTabFrame()->GetTable()) != nullptr )
{
ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR,
ERRCODE_MSG_INFO | ERRCODE_BUTTON_DEF_OK );
ErrorHandlerFlags::MessageInfo | ErrorHandlerFlags::ButtonDefaultsOk );
return false;
}
@ -336,7 +336,7 @@ bool SwFEShell::DeleteRow(bool bCompleteTable)
if( dynamic_cast< const SwDDETable* >(pFrame->ImplFindTabFrame()->GetTable()) != nullptr )
{
ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR,
ERRCODE_MSG_INFO | ERRCODE_BUTTON_DEF_OK );
ErrorHandlerFlags::MessageInfo | ErrorHandlerFlags::ButtonDefaultsOk );
return false;
}
@ -455,7 +455,7 @@ sal_uInt16 SwFEShell::MergeTab()
if( dynamic_cast< const SwDDETable* >(&pTableNd->GetTable()) != nullptr )
{
ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR,
ERRCODE_MSG_INFO | ERRCODE_BUTTON_DEF_OK );
ErrorHandlerFlags::MessageInfo | ErrorHandlerFlags::ButtonDefaultsOk );
}
else
{
@ -486,7 +486,7 @@ bool SwFEShell::SplitTab( bool bVert, sal_uInt16 nCnt, bool bSameHeight )
if( dynamic_cast< const SwDDETable* >(pFrame->ImplFindTabFrame()->GetTable()) != nullptr )
{
ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR,
ERRCODE_MSG_INFO | ERRCODE_BUTTON_DEF_OK );
ErrorHandlerFlags::MessageInfo | ErrorHandlerFlags::ButtonDefaultsOk );
return false;
}
@ -495,7 +495,7 @@ bool SwFEShell::SplitTab( bool bVert, sal_uInt16 nCnt, bool bSameHeight )
if( bVert && !CheckSplitCells( *this, nCnt + 1 ) )
{
ErrorHandler::HandleError( ERR_TBLSPLIT_ERROR,
ERRCODE_MSG_INFO | ERRCODE_BUTTON_DEF_OK );
ErrorHandlerFlags::MessageInfo | ErrorHandlerFlags::ButtonDefaultsOk );
return false;
}
StartAllAction();
@ -1295,7 +1295,7 @@ bool SwFEShell::DeleteTableSel()
if( dynamic_cast< const SwDDETable* >(pFrame->ImplFindTabFrame()->GetTable()) != nullptr )
{
ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR,
ERRCODE_MSG_INFO | ERRCODE_BUTTON_DEF_OK );
ErrorHandlerFlags::MessageInfo | ErrorHandlerFlags::ButtonDefaultsOk );
return false;
}
@ -2162,7 +2162,7 @@ bool SwFEShell::SetColRowWidthHeight( sal_uInt16 eType, sal_uInt16 nDiff )
dynamic_cast< const SwDDETable* >(pFrame->ImplFindTabFrame()->GetTable()) != nullptr )
{
ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR,
ERRCODE_MSG_INFO | ERRCODE_BUTTON_DEF_OK );
ErrorHandlerFlags::MessageInfo | ErrorHandlerFlags::ButtonDefaultsOk );
return false;
}

View File

@ -227,7 +227,7 @@ sal_uLong HTMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPam,
// den Stream als Fehlernummer Transporter benutzen
nRet = *new StringErrorInfo( ERR_FORMAT_ROWCOL, sErr,
ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR );
ErrorHandlerFlags::ButtonsOk | ErrorHandlerFlags::MessageError );
}
return nRet;

View File

@ -210,13 +210,13 @@ sal_Int32 ReadThroughComponent(
(bMustBeSuccessfull ? ERR_FORMAT_FILE_ROWCOL
: WARN_FORMAT_FILE_ROWCOL),
rStreamName, sErr,
ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR );
ErrorHandlerFlags::ButtonsOk | ErrorHandlerFlags::MessageError );
}
else
{
OSL_ENSURE( bMustBeSuccessfull, "Warnings are not supported" );
return *new StringErrorInfo( ERR_FORMAT_ROWCOL, sErr,
ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR );
ErrorHandlerFlags::ButtonsOk | ErrorHandlerFlags::MessageError );
}
}
catch(const xml::sax::SAXException& r)

View File

@ -414,14 +414,14 @@ sal_uInt32 SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >&
{
if( !sErrFile.isEmpty() )
return *new StringErrorInfo( ERR_WRITE_ERROR_FILE, sErrFile,
ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR );
ErrorHandlerFlags::ButtonsOk | ErrorHandlerFlags::MessageError );
return ERR_SWG_WRITE_ERROR;
}
else if( bWarn )
{
if( !sWarnFile.isEmpty() )
return *new StringErrorInfo( WARN_WRITE_ERROR_FILE, sWarnFile,
ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR );
ErrorHandlerFlags::ButtonsOk | ErrorHandlerFlags::MessageError );
return WARN_SWG_FEATURES_LOST;
}

View File

@ -400,7 +400,7 @@ void SwGlossaries::UpdateGlosPath(bool bFull)
ErrorHandler::HandleError( *new StringErrorInfo(
ERR_AUTOPATH_ERROR, lcl_makePath(m_aInvalidPaths),
ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR ));
ErrorHandlerFlags::ButtonsOk | ErrorHandlerFlags::MessageError ) );
m_bError = true;
}
else
@ -420,7 +420,7 @@ void SwGlossaries::UpdateGlosPath(bool bFull)
void SwGlossaries::ShowError()
{
sal_uInt32 nPathError = *new StringErrorInfo(ERR_AUTOPATH_ERROR,
lcl_makePath(m_aInvalidPaths), ERRCODE_BUTTON_OK );
lcl_makePath(m_aInvalidPaths), ErrorHandlerFlags::ButtonsOk );
ErrorHandler::HandleError( nPathError );
}

View File

@ -47,8 +47,8 @@ struct TheEDcrData: public rtl::Static<EDcrData, TheEDcrData> {};
class DynamicErrorInfo_Impl
{
sal_uIntPtr lErrId;
sal_uInt16 nMask;
ErrCode lErrId;
ErrorHandlerFlags nMask;
void RegisterEDcr(DynamicErrorInfo *);
static void UnRegisterEDcr(DynamicErrorInfo const *);
@ -110,7 +110,7 @@ DynamicErrorInfo::operator sal_uIntPtr() const
return pImpl->lErrId;
}
DynamicErrorInfo::DynamicErrorInfo(sal_uIntPtr lArgUserId, sal_uInt16 nMask)
DynamicErrorInfo::DynamicErrorInfo(sal_uIntPtr lArgUserId, ErrorHandlerFlags nMask)
: ErrorInfo(lArgUserId),
pImpl(new DynamicErrorInfo_Impl)
{
@ -133,13 +133,13 @@ ErrorInfo* DynamicErrorInfo_Impl::GetDynamicErrorInfo(sal_uIntPtr lId)
return new ErrorInfo(lId & ~ERRCODE_DYNAMIC_MASK);
}
sal_uInt16 DynamicErrorInfo::GetDialogMask() const
ErrorHandlerFlags DynamicErrorInfo::GetDialogMask() const
{
return pImpl->nMask;
}
StringErrorInfo::StringErrorInfo(
sal_uIntPtr UserId, const OUString& aStringP, sal_uInt16 nMask)
sal_uIntPtr UserId, const OUString& aStringP, ErrorHandlerFlags nMask)
: DynamicErrorInfo(UserId, nMask), aString(aStringP)
{
}
@ -226,25 +226,25 @@ void ErrorHandler::RegisterDisplay(BasicDisplayErrorFunc *aDsp)
1. nFlags,
2. Resource Flags
3. Dynamic Flags
4. Default ERRCODE_BUTTON_OK, ERRCODE_MSG_ERROR
4. Default ButtonsOk, MessageError
@param lId error id
@param nErrCodeId error id
@param nFlags error flags.
@param bJustCreateString ???
@param rError ???
@return ???
*/
sal_uInt16 ErrorHandler::HandleError_Impl(
sal_uIntPtr lId, sal_uInt16 nFlags, bool bJustCreateString, OUString & rError)
ErrorHandlerFlags ErrorHandler::HandleError_Impl(
sal_uIntPtr nErrCodeId, ErrorHandlerFlags nFlags, bool bJustCreateString, OUString & rError)
{
OUString aErr;
OUString aAction;
if(!lId || lId == ERRCODE_ABORT)
return 0;
if(!nErrCodeId || nErrCodeId == ERRCODE_ABORT)
return ErrorHandlerFlags::NONE;
EDcrData &rData = TheEDcrData::get();
vcl::Window *pParent = nullptr;
ErrorInfo *pInfo = ErrorInfo::GetErrorInfo(lId);
ErrorInfo *pInfo = ErrorInfo::GetErrorInfo(nErrCodeId);
if (!rData.contexts.empty())
{
rData.contexts.front()->GetString(pInfo->GetErrorCode(), aAction);
@ -257,18 +257,18 @@ sal_uInt16 ErrorHandler::HandleError_Impl(
}
}
bool bWarning = ((lId & ERRCODE_WARNING_MASK) == ERRCODE_WARNING_MASK);
sal_uInt16 nErrFlags = ERRCODE_BUTTON_DEF_OK | ERRCODE_BUTTON_OK;
bool bWarning = ((nErrCodeId & ERRCODE_WARNING_MASK) == ERRCODE_WARNING_MASK);
ErrorHandlerFlags nErrFlags = ErrorHandlerFlags::ButtonDefaultsOk | ErrorHandlerFlags::ButtonsOk;
if (bWarning)
nErrFlags |= ERRCODE_MSG_WARNING;
nErrFlags |= ErrorHandlerFlags::MessageWarning;
else
nErrFlags |= ERRCODE_MSG_ERROR;
nErrFlags |= ErrorHandlerFlags::MessageError;
DynamicErrorInfo* pDynPtr=dynamic_cast<DynamicErrorInfo*>(pInfo);
if(pDynPtr)
{
sal_uInt16 nDynFlags = pDynPtr->GetDialogMask();
if( nDynFlags )
ErrorHandlerFlags nDynFlags = pDynPtr->GetDialogMask();
if( nDynFlags != ErrorHandlerFlags::NONE )
nErrFlags = nDynFlags;
}
@ -277,7 +277,7 @@ sal_uInt16 ErrorHandler::HandleError_Impl(
if (bJustCreateString)
{
rError = aErr;
return 1;
return ErrorHandlerFlags::ButtonsOk;
}
else
{
@ -295,11 +295,11 @@ sal_uInt16 ErrorHandler::HandleError_Impl(
if(!rData.bIsWindowDsp)
{
(*reinterpret_cast<BasicDisplayErrorFunc*>(rData.pDsp))(aErr,aAction);
return 0;
return ErrorHandlerFlags::NONE;
}
else
{
if (nFlags != USHRT_MAX)
if (nFlags != ErrorHandlerFlags::MAX)
nErrFlags = nFlags;
return (*reinterpret_cast<WindowDisplayErrorFunc*>(rData.pDsp))(
pParent, nErrFlags, aErr, aAction);
@ -311,27 +311,27 @@ sal_uInt16 ErrorHandler::HandleError_Impl(
// Error 1 is General Error in the Sfx
if(pInfo->GetErrorCode()!=1)
{
HandleError_Impl(1, USHRT_MAX, bJustCreateString, rError);
HandleError_Impl(1, ErrorHandlerFlags::MAX, bJustCreateString, rError);
}
else
{
OSL_FAIL("Error 1 nicht gehandeled");
}
delete pInfo;
return 0;
return ErrorHandlerFlags::NONE;
}
// static
bool ErrorHandler::GetErrorString(sal_uIntPtr lId, OUString& rStr)
{
return (bool)HandleError_Impl( lId, USHRT_MAX, true, rStr );
return HandleError_Impl( lId, ErrorHandlerFlags::MAX, true, rStr ) != ErrorHandlerFlags::NONE;
}
/** Handles an error.
@see ErrorHandler::HandleError_Impl
*/
sal_uInt16 ErrorHandler::HandleError(sal_uIntPtr lId, sal_uInt16 nFlags)
ErrorHandlerFlags ErrorHandler::HandleError(sal_uIntPtr lId, ErrorHandlerFlags nFlags)
{
OUString aDummy;
return HandleError_Impl( lId, nFlags, false, aDummy );

View File

@ -113,8 +113,8 @@ executeLoginDialog(
if ( bCanUseSysCreds )
xDialog->SetUseSystemCredentials( rInfo.GetIsUseSystemCredentials() );
rInfo.SetResult(xDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK :
ERRCODE_BUTTON_CANCEL);
rInfo.SetResult(xDialog->Execute() == RET_OK ? ErrorHandlerFlags::ButtonsOk :
ErrorHandlerFlags::ButtonsCancel);
rInfo.SetUserName(xDialog->GetName());
rInfo.SetPassword(xDialog->GetPassword());
rInfo.SetAccount(xDialog->GetAccount());
@ -276,7 +276,7 @@ handleAuthenticationRequest_(
rRequest.HasRealm ? rRequest.Realm : OUString());
switch (aInfo.GetResult())
{
case ERRCODE_BUTTON_OK:
case ErrorHandlerFlags::ButtonsOk:
if (xSupplyAuthentication.is())
{
if (xSupplyAuthentication->canSetUserName())
@ -390,7 +390,7 @@ handleAuthenticationRequest_(
}
break;
case ERRCODE_BUTTON_RETRY:
case ErrorHandlerFlags::ButtonsRetry:
if (xRetry.is())
xRetry->select();
break;
@ -419,7 +419,7 @@ executeMasterPasswordDialog(
ScopedVclPtrInstance< MasterPasswordCreateDialog > xDialog(
pParent, xManager.get());
rInfo.SetResult(xDialog->Execute()
== RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL);
== RET_OK ? ErrorHandlerFlags::ButtonsOk : ErrorHandlerFlags::ButtonsCancel);
aMaster = OUStringToOString(
xDialog->GetMasterPassword(), RTL_TEXTENCODING_UTF8);
}
@ -428,7 +428,7 @@ executeMasterPasswordDialog(
ScopedVclPtrInstance< MasterPasswordDialog > xDialog(
pParent, nMode, xManager.get());
rInfo.SetResult(xDialog->Execute()
== RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL);
== RET_OK ? ErrorHandlerFlags::ButtonsOk : ErrorHandlerFlags::ButtonsCancel);
aMaster = OUStringToOString(
xDialog->GetMasterPassword(), RTL_TEXTENCODING_UTF8);
}
@ -476,7 +476,7 @@ handleMasterPasswordRequest_(
switch (aInfo.GetResult())
{
case ERRCODE_BUTTON_OK:
case ErrorHandlerFlags::ButtonsOk:
if (xSupplyAuthentication.is())
{
if (xSupplyAuthentication->canSetPassword())
@ -485,7 +485,7 @@ handleMasterPasswordRequest_(
}
break;
case ERRCODE_BUTTON_RETRY:
case ErrorHandlerFlags::ButtonsRetry:
if (xRetry.is())
xRetry->select();
break;
@ -520,7 +520,7 @@ executePasswordDialog(
bIsPasswordToModify, bIsSimplePasswordRequest);
xDialog->SetMinLen(0);
rInfo.SetResult(xDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL);
rInfo.SetResult(xDialog->Execute() == RET_OK ? ErrorHandlerFlags::ButtonsOk : ErrorHandlerFlags::ButtonsCancel);
rInfo.SetPassword(xDialog->GetPassword());
}
else
@ -531,7 +531,7 @@ executePasswordDialog(
ScopedVclPtr<AbstractPasswordToOpenModifyDialog> const pDialog(
pFact->CreatePasswordToOpenModifyDialog(pParent, nMaxPasswdLen, bIsPasswordToModify));
rInfo.SetResult( pDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL );
rInfo.SetResult( pDialog->Execute() == RET_OK ? ErrorHandlerFlags::ButtonsOk : ErrorHandlerFlags::ButtonsCancel );
rInfo.SetPassword( pDialog->GetPasswordToOpen() );
rInfo.SetPasswordToModify( pDialog->GetPasswordToModify() );
rInfo.SetRecommendToOpenReadonly( pDialog->IsRecommendToOpenReadonly() );
@ -543,7 +543,7 @@ executePasswordDialog(
bIsPasswordToModify, bIsSimplePasswordRequest);
xDialog->SetMinLen(0);
rInfo.SetResult(xDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL);
rInfo.SetResult(xDialog->Execute() == RET_OK ? ErrorHandlerFlags::ButtonsOk : ErrorHandlerFlags::ButtonsCancel);
rInfo.SetPassword(bIsPasswordToModify ? OUString() : xDialog->GetPassword());
rInfo.SetPasswordToModify(bIsPasswordToModify ? xDialog->GetPassword() : OUString());
}
@ -582,7 +582,7 @@ handlePasswordRequest_(
switch (aInfo.GetResult())
{
case ERRCODE_BUTTON_OK:
case ErrorHandlerFlags::ButtonsOk:
OSL_ENSURE( !bIsPasswordToModify || xPassword2.is(), "PasswordToModify is requested, but there is no Interaction!" );
if (xPassword.is())
{
@ -597,7 +597,7 @@ handlePasswordRequest_(
}
break;
case ERRCODE_BUTTON_RETRY:
case ErrorHandlerFlags::ButtonsRetry:
if (xRetry.is())
xRetry->select();
break;

View File

@ -40,7 +40,7 @@ using namespace com::sun::star;
namespace {
sal_uInt16
ErrorHandlerFlags
executeErrorDialog(
vcl::Window * pParent,
task::InteractionClassification eClassification,
@ -101,27 +101,29 @@ executeErrorDialog(
throw uno::RuntimeException("out of memory");
}
sal_uInt16 aResult = xBox->Execute();
sal_uInt16 aMessResult = xBox->Execute();
xBox.disposeAndClear();
switch( aResult )
ErrorHandlerFlags aResult = ErrorHandlerFlags::NONE;
switch( aMessResult )
{
case RET_OK:
aResult = ERRCODE_BUTTON_OK;
aResult = ErrorHandlerFlags::ButtonsOk;
break;
case RET_CANCEL:
aResult = ERRCODE_BUTTON_CANCEL;
aResult = ErrorHandlerFlags::ButtonsCancel;
break;
case RET_YES:
aResult = ERRCODE_BUTTON_YES;
aResult = ErrorHandlerFlags::ButtonsYes;
break;
case RET_NO:
aResult = ERRCODE_BUTTON_NO;
aResult = ErrorHandlerFlags::ButtonsNo;
break;
case RET_RETRY:
aResult = ERRCODE_BUTTON_RETRY;
aResult = ErrorHandlerFlags::ButtonsRetry;
break;
default: assert(false);
}
return aResult;
@ -257,12 +259,12 @@ UUIInteractionHelper::handleErrorHandlerRequest(
}
}
sal_uInt16 nResult = executeErrorDialog(
ErrorHandlerFlags nResult = executeErrorDialog(
getParentProperty(), eClassification, aContext, aMessage, nButtonMask );
switch (nResult)
{
case ERRCODE_BUTTON_OK:
case ErrorHandlerFlags::ButtonsOk:
OSL_ENSURE(xApprove.is() || xAbort.is(), "unexpected situation");
if (xApprove.is())
xApprove->select();
@ -270,29 +272,31 @@ UUIInteractionHelper::handleErrorHandlerRequest(
xAbort->select();
break;
case ERRCODE_BUTTON_CANCEL:
case ErrorHandlerFlags::ButtonsCancel:
OSL_ENSURE(xAbort.is(), "unexpected situation");
if (xAbort.is())
xAbort->select();
break;
case ERRCODE_BUTTON_RETRY:
case ErrorHandlerFlags::ButtonsRetry:
OSL_ENSURE(xRetry.is(), "unexpected situation");
if (xRetry.is())
xRetry->select();
break;
case ERRCODE_BUTTON_NO:
case ErrorHandlerFlags::ButtonsNo:
OSL_ENSURE(xDisapprove.is(), "unexpected situation");
if (xDisapprove.is())
xDisapprove->select();
break;
case ERRCODE_BUTTON_YES:
case ErrorHandlerFlags::ButtonsYes:
OSL_ENSURE(xApprove.is(), "unexpected situation");
if (xApprove.is())
xApprove->select();
break;
default: break;
}
}

View File

@ -987,7 +987,7 @@ UUIInteractionHelper::getInteractionHandler()
namespace {
sal_uInt16
ErrorHandlerFlags
executeMessageBox(
vcl::Window * pParent,
OUString const & rTitle,
@ -998,24 +998,26 @@ executeMessageBox(
ScopedVclPtrInstance< MessBox > xBox(pParent, nButtonMask, rTitle, rMessage);
sal_uInt16 aResult = xBox->Execute();
switch( aResult )
sal_uInt16 aMessResult = xBox->Execute();
ErrorHandlerFlags aResult = ErrorHandlerFlags::NONE;
switch( aMessResult )
{
case RET_OK:
aResult = ERRCODE_BUTTON_OK;
aResult = ErrorHandlerFlags::ButtonsOk;
break;
case RET_CANCEL:
aResult = ERRCODE_BUTTON_CANCEL;
aResult = ErrorHandlerFlags::ButtonsCancel;
break;
case RET_YES:
aResult = ERRCODE_BUTTON_YES;
aResult = ErrorHandlerFlags::ButtonsYes;
break;
case RET_NO:
aResult = ERRCODE_BUTTON_NO;
aResult = ErrorHandlerFlags::ButtonsNo;
break;
case RET_RETRY:
aResult = ERRCODE_BUTTON_RETRY;
aResult = ErrorHandlerFlags::ButtonsRetry;
break;
default: assert(false);
}
return aResult;
@ -1270,23 +1272,25 @@ UUIInteractionHelper::handleBrokenPackageRequest(
switch (
executeMessageBox( getParentProperty(), title, aMessage, nButtonMask ) )
{
case ERRCODE_BUTTON_OK:
case ErrorHandlerFlags::ButtonsOk:
OSL_ENSURE( xAbort.is(), "unexpected situation" );
if (xAbort.is())
xAbort->select();
break;
case ERRCODE_BUTTON_NO:
case ErrorHandlerFlags::ButtonsNo:
OSL_ENSURE(xDisapprove.is(), "unexpected situation");
if (xDisapprove.is())
xDisapprove->select();
break;
case ERRCODE_BUTTON_YES:
case ErrorHandlerFlags::ButtonsYes:
OSL_ENSURE(xApprove.is(), "unexpected situation");
if (xApprove.is())
xApprove->select();
break;
default: break;
}
}

View File

@ -43,13 +43,13 @@ private:
OUString m_aPath;
OUString m_aErrorText;
sal_uInt8 m_nFlags;
sal_uInt16 m_nRet;
ErrorHandlerFlags m_nRet;
bool m_bRecommendToOpenReadonly;
public:
LoginErrorInfo()
: m_nFlags(LOGINERROR_FLAG_MODIFY_USER_NAME)
, m_nRet(ERRCODE_BUTTON_CANCEL)
, m_nRet(ErrorHandlerFlags::ButtonsCancel)
, m_bRecommendToOpenReadonly(false)
{
}
@ -71,8 +71,8 @@ public:
bool GetIsUseSystemCredentials() const
{ return ( m_nFlags & LOGINERROR_FLAG_IS_USE_SYSCREDS ) ==
LOGINERROR_FLAG_IS_USE_SYSCREDS; }
sal_uInt8 GetFlags() const { return m_nFlags; }
sal_uInt16 GetResult() const { return m_nRet; }
sal_uInt8 GetFlags() const { return m_nFlags; }
ErrorHandlerFlags GetResult() const { return m_nRet; }
void SetTitle( const OUString& aTitle )
{ m_aTitle = aTitle; }
@ -100,7 +100,7 @@ public:
inline void SetModifyAccount( bool bSet );
inline void SetModifyUserName( bool bSet );
void SetResult( sal_uInt16 nRet )
void SetResult( ErrorHandlerFlags nRet )
{ m_nRet = nRet; }
};