basctl/source/basicide/baside2.cxx          |    4 
 basic/qa/cppunit/basictest.cxx              |    2 
 basic/qa/cppunit/basictest.hxx              |    4 
 basic/qa/cppunit/test_compiler_checks.cxx   |    4 
 basic/source/basmgr/basmgr.cxx              |   38 ++--
 basic/source/classes/sb.cxx                 |   16 -
 basic/source/inc/sbintern.hxx               |    2 
 comphelper/source/misc/errcode.cxx          |  257 ++++++++++++++--------------
 cui/source/options/optdict.cxx              |    2 
 editeng/source/misc/splwrap.cxx             |    4 
 include/basic/basmgr.hxx                    |    6 
 include/basic/sbstar.hxx                    |    5 
 include/comphelper/errcode.hxx              |  126 +++++++++++--
 include/sfx2/app.hxx                        |    2 
 include/sfx2/docfile.hxx                    |   12 -
 include/sfx2/objsh.hxx                      |    8 
 include/sfx2/sfxbasemodel.hxx               |    3 
 include/svtools/ehdl.hxx                    |    4 
 include/vcl/errinf.hxx                      |  106 -----------
 sc/inc/xmlwrap.hxx                          |    4 
 sc/source/filter/xml/xmlwrap.cxx            |   18 -
 sc/source/ui/docshell/docsh.cxx             |    6 
 sc/source/ui/docshell/docsh4.cxx            |    2 
 sc/source/ui/docshell/docsh8.cxx            |    8 
 sc/source/ui/inc/docsh.hxx                  |    2 
 sc/source/ui/miscdlgs/instbdlg.cxx          |    2 
 sc/source/ui/miscdlgs/linkarea.cxx          |    4 
 sd/source/filter/xml/sdxmlwrp.cxx           |   16 -
 sd/source/ui/app/sdmod1.cxx                 |    2 
 sd/source/ui/func/fuinsert.cxx              |    3 
 sd/source/ui/view/viewshe2.cxx              |    2 
 sfx2/source/appl/app.cxx                    |    4 
 sfx2/source/appl/appopen.cxx                |    4 
 sfx2/source/doc/DocumentMetadataAccess.cxx  |    4 
 sfx2/source/doc/SfxDocumentMetaData.cxx     |    4 
 sfx2/source/doc/docfile.cxx                 |   25 +-
 sfx2/source/doc/new.cxx                     |    2 
 sfx2/source/doc/objmisc.cxx                 |   12 -
 sfx2/source/doc/objserv.cxx                 |   13 -
 sfx2/source/doc/objstor.cxx                 |    8 
 sfx2/source/doc/sfxbasemodel.cxx            |   35 +--
 sfx2/source/inc/objshimp.hxx                |    2 
 sfx2/source/view/viewfrm.cxx                |    2 
 svtools/source/misc/ehdl.cxx                |   32 +--
 sw/inc/docsh.hxx                            |    2 
 sw/inc/shellio.hxx                          |   24 +-
 sw/qa/extras/txtimport/txtimport.cxx        |    4 
 sw/qa/extras/uiwriter/uiwriter.cxx          |    2 
 sw/source/core/swg/SwXMLTextBlocks.cxx      |    2 
 sw/source/core/unocore/unocrsrhelper.cxx    |    2 
 sw/source/core/unocore/unostyle.cxx         |    2 
 sw/source/filter/ascii/parasc.cxx           |    2 
 sw/source/filter/basflt/shellio.cxx         |    8 
 sw/source/filter/docx/swdocxreader.cxx      |    2 
 sw/source/filter/docx/swdocxreader.hxx      |    2 
 sw/source/filter/html/swhtml.cxx            |    6 
 sw/source/filter/inc/fltini.hxx             |    4 
 sw/source/filter/rtf/swparrtf.cxx           |    8 
 sw/source/filter/writer/writer.cxx          |   18 -
 sw/source/filter/ww8/wrtww8.cxx             |    8 
 sw/source/filter/ww8/wrtww8.hxx             |    6 
 sw/source/filter/ww8/ww8par.cxx             |    2 
 sw/source/filter/ww8/ww8par.hxx             |    2 
 sw/source/filter/xml/swxml.cxx              |   16 -
 sw/source/filter/xml/wrtxml.cxx             |   12 -
 sw/source/filter/xml/wrtxml.hxx             |    8 
 sw/source/uibase/app/docsh.cxx              |   12 -
 sw/source/uibase/app/docsh2.cxx             |    8 
 sw/source/uibase/app/docshini.cxx           |    4 
 sw/source/uibase/misc/glosdoc.cxx           |    5 
 sw/source/uibase/shells/translatehelper.cxx |    4 
 sw/source/uibase/uiview/srcview.cxx         |    2 
 sw/source/uibase/uiview/view2.cxx           |    2 
 sw/source/uibase/uiview/viewling.cxx        |    2 
 uui/source/iahndl.cxx                       |    2 
 vcl/qa/cppunit/errorhandler.cxx             |   15 -
 vcl/source/window/errinf.cxx                |  135 +-------------
 77 files changed, 522 insertions(+), 632 deletions(-)

New commits:
commit d9e322d60f65ff20631dab87baa5a2c7c71daaa2
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sat Sep 30 20:47:46 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Oct 3 10:12:41 2023 +0200

    replace ErrorInfo with simpler mechanism
    
    Instead of returning ErrCode class everywhere, return a new
    class ErrrCodeMsg, which combines an ErrCode with the other
    parameters that are used to control the error reporting.
    
    I do not change everything that uses ErrCode here, I started
    from SfxBaseController/SfxMedium and worked outwards.
    
    This change serves two purposes
    
    (1) Replace the extremely whacky ErrorInfo mechanism we were
    using to smuggle information into the error handler reporting
    mechanism with a very straightforward approach of just combining it
    into the error class.
    (2) Allow us to capture the source location that produced the error,
    which makes debugging the source of a problem soooo much easier.
    
    Change-Id: I978b8f00c9851b41a216c7ebdef2ef94251d5519
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157440
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/basctl/source/basicide/baside2.cxx 
b/basctl/source/basicide/baside2.cxx
index bb6f0bb1f876..60d25cf74128 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -442,7 +442,7 @@ void ModulWindow::LoadBasic()
         GetEditorWindow().PaintImmediately();
         GetEditorWindow().ForceSyntaxTimeout();
         GetEditorWindow().DestroyProgress();
-        ErrCode nError = aMedium.GetErrorIgnoreWarning();
+        ErrCodeMsg nError = aMedium.GetErrorIgnoreWarning();
         if ( nError )
             ErrorHandler::HandleError( nError );
     }
@@ -484,7 +484,7 @@ void ModulWindow::SaveBasicSource()
         GetEditEngine()->Write( *pStream );
         aMedium.Commit();
         LeaveWait();
-        ErrCode nError = aMedium.GetErrorIgnoreWarning();
+        ErrCodeMsg nError = aMedium.GetErrorIgnoreWarning();
         if ( nError )
             ErrorHandler::HandleError( nError );
     }
diff --git a/basic/qa/cppunit/basictest.cxx b/basic/qa/cppunit/basictest.cxx
index 8cf9812d5212..13dc8c72e4cb 100644
--- a/basic/qa/cppunit/basictest.cxx
+++ b/basic/qa/cppunit/basictest.cxx
@@ -108,7 +108,7 @@ bool MacroSnippet::Compile()
 
 bool MacroSnippet::HasError() const { return mbError; }
 
-const ErrCode& MacroSnippet::getError() const { return maErrCode; }
+const ErrCodeMsg& MacroSnippet::getError() const { return maErrCode; }
 
 IMPL_LINK( MacroSnippet, BasicErrorHdl, StarBASIC *, /*pBasic*/, bool)
 {
diff --git a/basic/qa/cppunit/basictest.hxx b/basic/qa/cppunit/basictest.hxx
index 1901492bcfab..46af3542b82b 100644
--- a/basic/qa/cppunit/basictest.hxx
+++ b/basic/qa/cppunit/basictest.hxx
@@ -23,7 +23,7 @@ class MacroSnippet
 {
 private:
     bool mbError;
-    ErrCode maErrCode;
+    ErrCodeMsg maErrCode;
     BasicDLL maDll; // we need a dll instance for resource manager etc.
     SbModuleRef mpMod;
     StarBASICRef mpBasic;
@@ -46,7 +46,7 @@ public:
     DECL_LINK(BasicErrorHdl, StarBASIC*, bool);
 
     bool HasError() const;
-    const ErrCode& getError() const;
+    const ErrCodeMsg& getError() const;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/qa/cppunit/test_compiler_checks.cxx 
b/basic/qa/cppunit/test_compiler_checks.cxx
index 044977670e62..773719e9fd45 100644
--- a/basic/qa/cppunit/test_compiler_checks.cxx
+++ b/basic/qa/cppunit/test_compiler_checks.cxx
@@ -21,7 +21,7 @@ CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, 
testRedefineArgument)
                         "End Sub\n");
     aMacro.Compile();
     CPPUNIT_ASSERT(aMacro.HasError());
-    CPPUNIT_ASSERT_EQUAL(ERRCODE_BASIC_VAR_DEFINED, 
aMacro.getError().StripDynamic());
+    CPPUNIT_ASSERT_EQUAL(ERRCODE_BASIC_VAR_DEFINED, 
aMacro.getError().GetCode());
 }
 
 CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testDoubleArgument)
@@ -30,7 +30,7 @@ CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testDoubleArgument)
                         "End Sub\n");
     aMacro.Compile();
     CPPUNIT_ASSERT(aMacro.HasError());
-    CPPUNIT_ASSERT_EQUAL(ERRCODE_BASIC_VAR_DEFINED, 
aMacro.getError().StripDynamic());
+    CPPUNIT_ASSERT_EQUAL(ERRCODE_BASIC_VAR_DEFINED, 
aMacro.getError().GetCode());
 }
 
 CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testTdf149157)
diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx
index f7a4fb2ae192..6e2ce76d37ae 100644
--- a/basic/source/basmgr/basmgr.cxx
+++ b/basic/source/basmgr/basmgr.cxx
@@ -300,7 +300,7 @@ void SAL_CALL BasMgrContainerListenerImpl::elementRemoved( 
const container::Cont
     }
 }
 
-BasicError::BasicError( ErrCode nId, BasicErrorReason nR )
+BasicError::BasicError( ErrCodeMsg nId, BasicErrorReason nR )
 {
     nErrorId    = nId;
     nReason     = nR;
@@ -609,8 +609,8 @@ 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, DialogMask::ButtonsOk );
-    aErrors.emplace_back(*pErrInf, BasicErrorReason::OPENMGRSTREAM);
+    ErrCodeMsg aErrInf( ERRCODE_BASMGR_MGROPEN, rStorageName, 
DialogMask::ButtonsOk );
+    aErrors.emplace_back(aErrInf, BasicErrorReason::OPENMGRSTREAM);
 
     // Create a stdlib otherwise we crash!
     BasicLibInfo* pStdLibInfo = CreateLibInfo();
@@ -749,8 +749,8 @@ void BasicManager::LoadOldBasicManager( SotStorage& 
rStorage )
     xManagerStream->Seek( nBasicStartOff );
     if (!ImplLoadBasic( *xManagerStream, maLibs.front()->GetLibRef() ))
     {
-        StringErrorInfo* pErrInf = new StringErrorInfo( 
ERRCODE_BASMGR_MGROPEN, aStorName, DialogMask::ButtonsOk );
-        aErrors.emplace_back(*pErrInf, BasicErrorReason::OPENMGRSTREAM);
+        ErrCodeMsg aErrInf( ERRCODE_BASMGR_MGROPEN, aStorName, 
DialogMask::ButtonsOk );
+        aErrors.emplace_back(aErrInf, BasicErrorReason::OPENMGRSTREAM);
         // and it proceeds ...
     }
     xManagerStream->Seek( nBasicEndOff+1 ); // +1: 0x00 as separator
@@ -799,8 +799,8 @@ void BasicManager::LoadOldBasicManager( SotStorage& 
rStorage )
         }
         else
         {
-            StringErrorInfo* pErrInf = new StringErrorInfo( 
ERRCODE_BASMGR_LIBLOAD, aStorName, DialogMask::ButtonsOk );
-            aErrors.emplace_back(*pErrInf, BasicErrorReason::STORAGENOTFOUND);
+            ErrCodeMsg aErrInf( ERRCODE_BASMGR_LIBLOAD, aStorName, 
DialogMask::ButtonsOk );
+            aErrors.emplace_back(aErrInf, BasicErrorReason::STORAGENOTFOUND);
         }
     } while (nLibPos>=0);
 }
@@ -868,8 +868,8 @@ bool BasicManager::ImpLoadLibrary( BasicLibInfo* pLibInfo, 
SotStorage* pCurStora
 
     if ( !xBasicStorage.is() || xBasicStorage->GetError() )
     {
-        StringErrorInfo* pErrInf = new StringErrorInfo( 
ERRCODE_BASMGR_MGROPEN, xStorage->GetName(), DialogMask::ButtonsOk );
-        aErrors.emplace_back(*pErrInf, BasicErrorReason::OPENLIBSTORAGE);
+        ErrCodeMsg aErrInf( ERRCODE_BASMGR_MGROPEN, xStorage->GetName(), 
DialogMask::ButtonsOk );
+        aErrors.emplace_back(aErrInf, BasicErrorReason::OPENLIBSTORAGE);
     }
     else
     {
@@ -877,8 +877,8 @@ 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(), DialogMask::ButtonsOk );
-            aErrors.emplace_back(*pErrInf, BasicErrorReason::OPENLIBSTREAM);
+            ErrCodeMsg aErrInf( ERRCODE_BASMGR_LIBLOAD , 
pLibInfo->GetLibName(), DialogMask::ButtonsOk );
+            aErrors.emplace_back(aErrInf, BasicErrorReason::OPENLIBSTREAM);
         }
         else
         {
@@ -900,8 +900,8 @@ bool BasicManager::ImpLoadLibrary( BasicLibInfo* pLibInfo, 
SotStorage* pCurStora
             }
             if ( !bLoaded )
             {
-                StringErrorInfo* pErrInf = new StringErrorInfo( 
ERRCODE_BASMGR_LIBLOAD, pLibInfo->GetLibName(), DialogMask::ButtonsOk );
-                aErrors.emplace_back(*pErrInf, 
BasicErrorReason::BASICLOADERROR);
+                ErrCodeMsg aErrInf( ERRCODE_BASMGR_LIBLOAD, 
pLibInfo->GetLibName(), DialogMask::ButtonsOk );
+                aErrors.emplace_back(aErrInf, 
BasicErrorReason::BASICLOADERROR);
             }
             else
             {
@@ -1084,8 +1084,8 @@ bool BasicManager::RemoveLib( sal_uInt16 nLib, bool 
bDelBasicFromStorage )
 
     if( !nLib || nLib  < maLibs.size() )
     {
-        StringErrorInfo* pErrInf = new StringErrorInfo( 
ERRCODE_BASMGR_REMOVELIB, OUString(), DialogMask::ButtonsOk );
-        aErrors.emplace_back(*pErrInf, BasicErrorReason::STDLIB);
+        ErrCodeMsg aErrInf( ERRCODE_BASMGR_REMOVELIB, OUString(), 
DialogMask::ButtonsOk );
+        aErrors.emplace_back(aErrInf, BasicErrorReason::STDLIB);
         return false;
     }
 
@@ -1120,8 +1120,8 @@ bool BasicManager::RemoveLib( sal_uInt16 nLib, bool 
bDelBasicFromStorage )
 
             if ( !xBasicStorage.is() || xBasicStorage->GetError() )
             {
-                StringErrorInfo* pErrInf = new StringErrorInfo( 
ERRCODE_BASMGR_REMOVELIB, OUString(), DialogMask::ButtonsOk );
-                aErrors.emplace_back(*pErrInf, 
BasicErrorReason::OPENLIBSTORAGE);
+                ErrCodeMsg aErrInf( ERRCODE_BASMGR_REMOVELIB, OUString(), 
DialogMask::ButtonsOk );
+                aErrors.emplace_back(aErrInf, 
BasicErrorReason::OPENLIBSTORAGE);
             }
             else if (xBasicStorage->IsStream((*itLibInfo)->GetLibName()))
             {
@@ -1255,8 +1255,8 @@ bool BasicManager::LoadLib( sal_uInt16 nLib )
     }
     else
     {
-        StringErrorInfo* pErrInf = new StringErrorInfo( 
ERRCODE_BASMGR_LIBLOAD, OUString(), DialogMask::ButtonsOk );
-        aErrors.emplace_back(*pErrInf, BasicErrorReason::LIBNOTFOUND);
+        ErrCodeMsg aErrInf( ERRCODE_BASMGR_LIBLOAD, OUString(), 
DialogMask::ButtonsOk );
+        aErrors.emplace_back(aErrInf, BasicErrorReason::LIBNOTFOUND);
     }
     return bDone;
 }
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx
index 1070f1986e38..9d3a7706189c 100644
--- a/basic/source/classes/sb.cxx
+++ b/basic/source/classes/sb.cxx
@@ -1429,7 +1429,7 @@ sal_uInt16 StarBASIC::GetCol1()     { return 
GetSbData()->nCol1; }
 sal_uInt16 StarBASIC::GetCol2()     { return GetSbData()->nCol2; }
 
 // Specific to error handler
-ErrCode const & StarBASIC::GetErrorCode() { return GetSbData()->nCode; }
+ErrCodeMsg const & StarBASIC::GetErrorCode() { return GetSbData()->nCode; }
 const OUString& StarBASIC::GetErrorText() { return GetSbData()->aErrMsg; }
 
 // From 1996-03-29:
@@ -1531,7 +1531,7 @@ ErrCode StarBASIC::GetSfxFromVBError( sal_uInt16 nError )
 }
 
 // set Error- / Break-data
-void StarBASIC::SetErrorData( ErrCode nCode, sal_uInt16 nLine,
+void StarBASIC::SetErrorData( const ErrCodeMsg& nCode, sal_uInt16 nLine,
                               sal_uInt16 nCol1, sal_uInt16 nCol2 )
 {
     SbiGlobals& aGlobals = *GetSbData();
@@ -1620,11 +1620,12 @@ bool StarBASIC::CError( ErrCode code, const OUString& 
rMsg,
     MakeErrorText( code, rMsg );
 
     // Implementation of the code for the string transport to SFX-Error
+    ErrCodeMsg nErr = code;
     if( !rMsg.isEmpty() )
     {
-        code = *new StringErrorInfo( code, rMsg );
+        nErr = ErrCodeMsg( code, rMsg );
     }
-    SetErrorData( code, l, c1, c2 );
+    SetErrorData( nErr, l, c1, c2 );
     GetSbData()->bCompilerError = true;
     bool bRet;
     if( GetSbData()->aErrHdl.IsSet() )
@@ -1651,6 +1652,7 @@ bool StarBASIC::RTError( ErrCode code, const OUString& 
rMsg, sal_Int32 l, sal_In
     MakeErrorText( c, rMsg );
 
     // Implementation of the code for the string transport to SFX-Error
+    ErrCodeMsg nErr = code;
     if( !rMsg.isEmpty() )
     {
         // very confusing, even though MakeErrorText sets up the error text
@@ -1661,15 +1663,15 @@ bool StarBASIC::RTError( ErrCode code, const OUString& 
rMsg, sal_Int32 l, sal_In
         {
             OUString aTmp = "\'" + 
OUString::number(SbxErrObject::getUnoErrObject()->getNumber()) +
                             "\'\n" + (!GetSbData()->aErrMsg.isEmpty() ? 
GetSbData()->aErrMsg : rMsg);
-            code = *new StringErrorInfo( code, aTmp );
+            nErr = ErrCodeMsg( code, aTmp );
         }
         else
         {
-            code = *new StringErrorInfo( code, rMsg );
+            nErr = ErrCodeMsg( code, rMsg );
         }
     }
 
-    SetErrorData( code, l, c1, c2 );
+    SetErrorData( nErr, l, c1, c2 );
     if( GetSbData()->aErrHdl.IsSet() )
     {
         return GetSbData()->aErrHdl.Call( this );
diff --git a/basic/source/inc/sbintern.hxx b/basic/source/inc/sbintern.hxx
index 5ed41d5fb138..ae18e0f9e30b 100644
--- a/basic/source/inc/sbintern.hxx
+++ b/basic/source/inc/sbintern.hxx
@@ -124,7 +124,7 @@ struct SbiGlobals
     short           nInst;          // number of BASICs
     Link<StarBASIC*,bool>            aErrHdl;        // global error handler
     Link<StarBASIC*,BasicDebugFlags> aBreakHdl;      // global break handler
-    ErrCode         nCode;
+    ErrCodeMsg      nCode;
     sal_Int32       nLine;
     sal_Int32       nCol1,nCol2;    // from... to...
     bool            bCompilerError; // flag for compiler error
diff --git a/comphelper/source/misc/errcode.cxx 
b/comphelper/source/misc/errcode.cxx
index 77d58ac364be..e7b667745808 100644
--- a/comphelper/source/misc/errcode.cxx
+++ b/comphelper/source/misc/errcode.cxx
@@ -19,135 +19,129 @@
 
 #include <comphelper/errcode.hxx>
 #include <rtl/ustrbuf.hxx>
+#include <o3tl/runtimetooustring.hxx>
 
 COMPHELPER_DLLPUBLIC OUString ErrCode::toString() const
 {
-    OUStringBuffer buf(128);
-    buf.append(toHexString() + "(");
+    std::u16string_view pWarningError;
     if (IsWarning())
-        buf.append("Warning");
-    else
-        buf.append("Error");
-    if (IsDynamic())
-        buf.append(" Dynamic");
+        pWarningError = u"Warning";
     else
+        pWarningError = u"Error";
+
+    std::u16string_view pArea;
+    switch (GetArea())
     {
-        std::u16string_view pArea;
-        switch (GetArea())
-        {
-            case ErrCodeArea::Io:
-                pArea = u"Io";
-                break;
-            case ErrCodeArea::Sfx:
-                pArea = u"Sfx";
-                break;
-            case ErrCodeArea::Inet:
-                pArea = u"Inet";
-                break;
-            case ErrCodeArea::Vcl:
-                pArea = u"Vcl";
-                break;
-            case ErrCodeArea::Svx:
-                pArea = u"Svx";
-                break;
-            case ErrCodeArea::So:
-                pArea = u"So";
-                break;
-            case ErrCodeArea::Sbx:
-                pArea = u"Sbx";
-                break;
-            case ErrCodeArea::Uui:
-                pArea = u"Uui";
-                break;
-            case ErrCodeArea::Sc:
-                pArea = u"Sc";
-                break;
-            case ErrCodeArea::Sd:
-                pArea = u"Sd";
-                break;
-            case ErrCodeArea::Sw:
-                pArea = u"Sw";
-                break;
-        }
-        buf.append(OUString::Concat(" Area:") + pArea);
+        case ErrCodeArea::Io:
+            pArea = u"Io";
+            break;
+        case ErrCodeArea::Sfx:
+            pArea = u"Sfx";
+            break;
+        case ErrCodeArea::Inet:
+            pArea = u"Inet";
+            break;
+        case ErrCodeArea::Vcl:
+            pArea = u"Vcl";
+            break;
+        case ErrCodeArea::Svx:
+            pArea = u"Svx";
+            break;
+        case ErrCodeArea::So:
+            pArea = u"So";
+            break;
+        case ErrCodeArea::Sbx:
+            pArea = u"Sbx";
+            break;
+        case ErrCodeArea::Uui:
+            pArea = u"Uui";
+            break;
+        case ErrCodeArea::Sc:
+            pArea = u"Sc";
+            break;
+        case ErrCodeArea::Sd:
+            pArea = u"Sd";
+            break;
+        case ErrCodeArea::Sw:
+            pArea = u"Sw";
+            break;
+    }
 
-        std::u16string_view pClass;
-        switch (GetClass())
-        {
-            case ErrCodeClass::NONE:
-                pClass = u"NONE";
-                break;
-            case ErrCodeClass::Abort:
-                pClass = u"Abort";
-                break;
-            case ErrCodeClass::General:
-                pClass = u"General";
-                break;
-            case ErrCodeClass::NotExists:
-                pClass = u"NotExists";
-                break;
-            case ErrCodeClass::AlreadyExists:
-                pClass = u"AlreadyExists";
-                break;
-            case ErrCodeClass::Access:
-                pClass = u"Access";
-                break;
-            case ErrCodeClass::Path:
-                pClass = u"Path";
-                break;
-            case ErrCodeClass::Locking:
-                pClass = u"Locking";
-                break;
-            case ErrCodeClass::Parameter:
-                pClass = u"Parameter";
-                break;
-            case ErrCodeClass::Space:
-                pClass = u"Space";
-                break;
-            case ErrCodeClass::NotSupported:
-                pClass = u"NotSupported";
-                break;
-            case ErrCodeClass::Read:
-                pClass = u"Read";
-                break;
-            case ErrCodeClass::Write:
-                pClass = u"Write";
-                break;
-            case ErrCodeClass::Unknown:
-                pClass = u"Unknown";
-                break;
-            case ErrCodeClass::Version:
-                pClass = u"Version";
-                break;
-            case ErrCodeClass::Format:
-                pClass = u"Format";
-                break;
-            case ErrCodeClass::Create:
-                pClass = u"Create";
-                break;
-            case ErrCodeClass::Import:
-                pClass = u"Import";
-                break;
-            case ErrCodeClass::Export:
-                pClass = u"Export";
-                break;
-            case ErrCodeClass::So:
-                pClass = u"So";
-                break;
-            case ErrCodeClass::Sbx:
-                pClass = u"Sbx";
-                break;
-            case ErrCodeClass::Runtime:
-                pClass = u"Runtime";
-                break;
-            case ErrCodeClass::Compiler:
-                pClass = u"Compiler";
-                break;
-        }
-        buf.append(OUString::Concat(" Class:") + pClass + " Code:" + 
OUString::number(GetCode()));
+    std::u16string_view pClass;
+    switch (GetClass())
+    {
+        case ErrCodeClass::NONE:
+            pClass = u"NONE";
+            break;
+        case ErrCodeClass::Abort:
+            pClass = u"Abort";
+            break;
+        case ErrCodeClass::General:
+            pClass = u"General";
+            break;
+        case ErrCodeClass::NotExists:
+            pClass = u"NotExists";
+            break;
+        case ErrCodeClass::AlreadyExists:
+            pClass = u"AlreadyExists";
+            break;
+        case ErrCodeClass::Access:
+            pClass = u"Access";
+            break;
+        case ErrCodeClass::Path:
+            pClass = u"Path";
+            break;
+        case ErrCodeClass::Locking:
+            pClass = u"Locking";
+            break;
+        case ErrCodeClass::Parameter:
+            pClass = u"Parameter";
+            break;
+        case ErrCodeClass::Space:
+            pClass = u"Space";
+            break;
+        case ErrCodeClass::NotSupported:
+            pClass = u"NotSupported";
+            break;
+        case ErrCodeClass::Read:
+            pClass = u"Read";
+            break;
+        case ErrCodeClass::Write:
+            pClass = u"Write";
+            break;
+        case ErrCodeClass::Unknown:
+            pClass = u"Unknown";
+            break;
+        case ErrCodeClass::Version:
+            pClass = u"Version";
+            break;
+        case ErrCodeClass::Format:
+            pClass = u"Format";
+            break;
+        case ErrCodeClass::Create:
+            pClass = u"Create";
+            break;
+        case ErrCodeClass::Import:
+            pClass = u"Import";
+            break;
+        case ErrCodeClass::Export:
+            pClass = u"Export";
+            break;
+        case ErrCodeClass::So:
+            pClass = u"So";
+            break;
+        case ErrCodeClass::Sbx:
+            pClass = u"Sbx";
+            break;
+        case ErrCodeClass::Runtime:
+            pClass = u"Runtime";
+            break;
+        case ErrCodeClass::Compiler:
+            pClass = u"Compiler";
+            break;
     }
-    buf.append(")");
-    return buf.makeStringAndClear();
+    return toHexString() + "(" + pWarningError + " Area:" + pArea + " Class:" 
+ pClass
+           + " Code:" + OUString::number(GetCode()) + ")";
 }
 
 COMPHELPER_DLLPUBLIC std::ostream& operator<<(std::ostream& os, const ErrCode& 
err)
@@ -156,4 +150,25 @@ COMPHELPER_DLLPUBLIC std::ostream& 
operator<<(std::ostream& os, const ErrCode& e
     return os;
 }
 
+COMPHELPER_DLLPUBLIC OUString ErrCodeMsg::toString() const
+{
+    OUString s = mnCode.toString();
+    if (!maArg1.isEmpty())
+        s += " arg1=" + maArg1;
+    if (!maArg2.isEmpty())
+        s += " arg2=" + maArg2;
+#ifdef LIBO_ERRMSG_USE_SOURCE_LOCATION
+    if (!moLoc)
+        s += OUString::Concat(" func=") + 
o3tl::runtimeToOUString(moLoc->function_name()) + " src="
+             + o3tl::runtimeToOUString(moLoc->file_name()) + ":" + 
OUString::number(moLoc->line());
+#endif
+    return s;
+}
+
+COMPHELPER_DLLPUBLIC std::ostream& operator<<(std::ostream& os, const 
ErrCodeMsg& err)
+{
+    os << err.toString();
+    return os;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/options/optdict.cxx b/cui/source/options/optdict.cxx
index 66b2c7f06a0c..dbe7f80e3d6b 100644
--- a/cui/source/options/optdict.cxx
+++ b/cui/source/options/optdict.cxx
@@ -192,7 +192,7 @@ IMPL_LINK_NOARG(SvxNewDictionaryDialog, OKHdl_Impl, 
weld::Button&, void)
         // error: couldn't create new dictionary
         SfxErrorContext aContext( ERRCTX_SVX_LINGU_DICTIONARY, OUString(),
             m_xDialog.get(), RID_SVXERRCTX, SvxResLocale() );
-        ErrorHandler::HandleError( *new StringErrorInfo(
+        ErrorHandler::HandleError( ErrCodeMsg(
                 ERRCODE_SVX_LINGU_DICT_NOTWRITEABLE, sDict ) );
         m_xDialog->response(RET_CANCEL);
     }
diff --git a/editeng/source/misc/splwrap.cxx b/editeng/source/misc/splwrap.cxx
index 99658aad39b8..dd59113a6975 100644
--- a/editeng/source/misc/splwrap.cxx
+++ b/editeng/source/misc/splwrap.cxx
@@ -104,14 +104,14 @@ void SvxSpellWrapper::ShowLanguageErrors()
         {
             OUString aErr( SvtLanguageTable::GetLanguageString( nLang ) );
             ErrorHandler::HandleError(
-                *new StringErrorInfo( ERRCODE_SVX_LINGU_LANGUAGENOTEXISTS, 
aErr ) );
+                ErrCodeMsg( ERRCODE_SVX_LINGU_LANGUAGENOTEXISTS, aErr ) );
             nTmpSpell = SVX_LANG_MISSING;
         }
         if (SVX_LANG_MISSING_DO_WARN == nTmpHyph)
         {
             OUString aErr( SvtLanguageTable::GetLanguageString( nLang ) );
             ErrorHandler::HandleError(
-                *new StringErrorInfo( ERRCODE_SVX_LINGU_LANGUAGENOTEXISTS, 
aErr ) );
+                ErrCodeMsg( ERRCODE_SVX_LINGU_LANGUAGENOTEXISTS, aErr ) );
             nTmpHyph = SVX_LANG_MISSING;
         }
 
diff --git a/include/basic/basmgr.hxx b/include/basic/basmgr.hxx
index 072d92a6e417..1ef4f77cf16e 100644
--- a/include/basic/basmgr.hxx
+++ b/include/basic/basmgr.hxx
@@ -55,14 +55,14 @@ enum class BasicErrorReason
 class BasicError
 {
 private:
-    ErrCode nErrorId;
+    ErrCodeMsg nErrorId;
     BasicErrorReason  nReason;
 
 public:
             BasicError( const BasicError& rErr );
-            BasicError( ErrCode nId, BasicErrorReason nR );
+            BasicError( ErrCodeMsg nId, BasicErrorReason nR );
 
-    ErrCode const & GetErrorId() const                  { return nErrorId; }
+    ErrCodeMsg const & GetErrorId() const { return nErrorId; }
 };
 
 class BasicLibInfo;
diff --git a/include/basic/sbstar.hxx b/include/basic/sbstar.hxx
index 42f551bc403f..599f14aa4b1b 100644
--- a/include/basic/sbstar.hxx
+++ b/include/basic/sbstar.hxx
@@ -25,6 +25,7 @@
 #include <basic/sbmod.hxx>
 #include <rtl/ustring.hxx>
 #include <tools/link.hxx>
+#include <comphelper/errcode.hxx>
 
 #include <basic/sbdef.hxx>
 #include <basic/basicdllapi.h>
@@ -111,13 +112,13 @@ public:
     static sal_uInt16 GetLine();
     static sal_uInt16 GetCol1();
     static sal_uInt16 GetCol2();
-    static void     SetErrorData( ErrCode nCode, sal_uInt16 nLine,
+    static void     SetErrorData( const ErrCodeMsg& nCode, sal_uInt16 nLine,
                                   sal_uInt16 nCol1, sal_uInt16 nCol2 );
 
     // Specific to error handler
     static void     MakeErrorText( ErrCode, std::u16string_view aMsg );
     static const    OUString& GetErrorText();
-    static ErrCode const & GetErrorCode();
+    static ErrCodeMsg const & GetErrorCode();
     static sal_uInt16 GetVBErrorCode( ErrCode nError );
     static ErrCode  GetSfxFromVBError( sal_uInt16 nError );
     bool            IsBreak() const             { return bBreak; }
diff --git a/include/comphelper/errcode.hxx b/include/comphelper/errcode.hxx
index 7b4fffa1bb3a..6e5390b9a09b 100644
--- a/include/comphelper/errcode.hxx
+++ b/include/comphelper/errcode.hxx
@@ -21,6 +21,16 @@
 #include <rtl/ustring.hxx>
 #include <comphelper/comphelperdllapi.h>
 #include <ostream>
+#include <o3tl/typed_flags_set.hxx>
+#include <optional>
+
+#if (defined DBG_UTIL) && ((defined __GNUC__ && !defined __clang__) || 
(defined __clang__ && __clang_major__ >= 9)) && 
__has_include(<experimental/source_location>)
+#define LIBO_ERRMSG_USE_SOURCE_LOCATION
+#endif
+
+#ifdef LIBO_ERRMSG_USE_SOURCE_LOCATION
+#include <experimental/source_location>
+#endif
 
 /*
 
@@ -28,7 +38,7 @@
 ||   ||           ||   ||      |
 Warning           ||   ||      |
  |   ||           ||   ||      |
- Dynamic          ||   ||      |
+ Unused           ||   ||      |
       |           ||   ||      |
       Subsystemarea|   ||      |
                    |   ||      |
@@ -50,9 +60,6 @@ Warning           ||   ||      |
 
 #define ERRCODE_CLASS_MASK               (31UL << ERRCODE_CLASS_SHIFT)
 
-#define ERRCODE_DYNAMIC_COUNT            31UL
-#define ERRCODE_DYNAMIC_MASK             (31UL << ERRCODE_DYNAMIC_SHIFT)
-
 enum class ErrCodeArea;
 enum class ErrCodeClass;
 
@@ -107,20 +114,8 @@ public:
         return m_value && !IsWarning();
     }
 
-    bool IsDynamic() const {
-        return m_value & ERRCODE_DYNAMIC_MASK;
-    }
-
-    sal_uInt32 GetDynamic() const {
-        return (m_value & ERRCODE_DYNAMIC_MASK) >> ERRCODE_DYNAMIC_SHIFT;
-    }
-
-    ErrCode StripDynamic() const {
-        return ErrCode(m_value & ~ERRCODE_DYNAMIC_MASK);
-    }
-
-    constexpr ErrCode StripWarningAndDynamic() const {
-        return ErrCode(m_value & ~(ERRCODE_DYNAMIC_MASK | 
ERRCODE_WARNING_MASK));
+    constexpr ErrCode StripWarning() const {
+        return ErrCode(m_value & ~ERRCODE_WARNING_MASK);
     }
 
     constexpr ErrCodeArea GetArea() const {
@@ -154,6 +149,101 @@ private:
 
 COMPHELPER_DLLPUBLIC std::ostream& operator<<(std::ostream& os, const ErrCode& 
err);
 
+enum class DialogMask
+{
+    NONE                    = 0x0000,
+    ButtonsOk               = 0x0001,
+    ButtonsCancel           = 0x0002,
+    ButtonsRetry            = 0x0004,
+    ButtonsNo               = 0x0008,
+    ButtonsYes              = 0x0010,
+    ButtonsYesNo            = 0x0018,
+
+    ButtonDefaultsOk        = 0x0100,
+    ButtonDefaultsCancel    = 0x0200,
+    ButtonDefaultsYes       = 0x0300,
+    ButtonDefaultsNo        = 0x0400,
+
+    MessageError            = 0x1000,
+    MessageWarning          = 0x2000,
+    MessageInfo             = 0x3000,
+
+    MAX                     = USHRT_MAX,
+};
+namespace o3tl
+{
+    template<> struct typed_flags<DialogMask> : is_typed_flags<DialogMask, 
0xffff> {};
+}
+
+/** Wrap up an ErrCode and an explanation and the source location where the 
error was created,
+    helps with debugging when finding the source of a problem.
+*/
+class SAL_WARN_UNUSED ErrCodeMsg
+{
+public:
+    ErrCodeMsg() : mnCode(0) {}
+#ifdef LIBO_ERRMSG_USE_SOURCE_LOCATION
+    ErrCodeMsg(ErrCode code, const OUString& arg, 
std::experimental::source_location loc = 
std::experimental::source_location::current())
+        : mnCode(code), maArg1(arg),  mnDialogMask(DialogMask::NONE), 
moLoc(loc) {}
+    ErrCodeMsg(ErrCode code, const OUString& arg1, const OUString& arg2, 
std::experimental::source_location loc = 
std::experimental::source_location::current())
+        : mnCode(code), maArg1(arg1), maArg2(arg2), 
mnDialogMask(DialogMask::NONE), moLoc(loc) {}
+    ErrCodeMsg(ErrCode code, std::experimental::source_location loc = 
std::experimental::source_location::current())
+        : mnCode(code), mnDialogMask(DialogMask::NONE), moLoc(loc) {}
+    ErrCodeMsg(ErrCode code, const OUString& arg, DialogMask mask, 
std::experimental::source_location loc = 
std::experimental::source_location::current())
+        : mnCode(code), maArg1(arg), mnDialogMask(mask), moLoc(loc) {}
+    ErrCodeMsg(ErrCode code, const OUString& arg1, const OUString& arg2, 
DialogMask mask, std::experimental::source_location loc = 
std::experimental::source_location::current())
+        : mnCode(code), maArg1(arg1), maArg2(arg2), mnDialogMask(mask), 
moLoc(loc) {}
+#else
+    ErrCodeMsg(ErrCode code, const OUString& arg)
+        : mnCode(code), maArg1(arg), mnDialogMask(DialogMask::NONE) {}
+    ErrCodeMsg(ErrCode code, const OUString& arg1, const OUString& arg2)
+        : mnCode(code), maArg1(arg1), maArg2(arg2), 
mnDialogMask(DialogMask::NONE) {}
+    ErrCodeMsg(ErrCode code)
+        : mnCode(code), mnDialogMask(DialogMask::NONE) {}
+    ErrCodeMsg(ErrCode code, const OUString& arg, DialogMask mask)
+        : mnCode(code), maArg1(arg), mnDialogMask(mask) {}
+    ErrCodeMsg(ErrCode code, const OUString& arg1, const OUString& arg2, 
DialogMask mask)
+        : mnCode(code), maArg1(arg1), maArg2(arg2), mnDialogMask(mask) {}
+#endif
+
+    const ErrCode & GetCode() const { return mnCode; }
+    const OUString & GetArg1() const { return maArg1; }
+    const OUString & GetArg2() const { return maArg2; }
+    DialogMask GetDialogMask() const { return mnDialogMask; }
+
+#ifdef LIBO_ERRMSG_USE_SOURCE_LOCATION
+    const std::optional<std::experimental::source_location> & 
GetSourceLocation() const { return moLoc; }
+#endif
+
+    /** convert to ERRCODE_NONE if it's a warning, else return the error */
+    ErrCodeMsg IgnoreWarning() const { return mnCode.IsWarning() ? 
ErrCodeMsg(ErrCode(0)) : *this; }
+
+    bool IsWarning() const { return mnCode.IsWarning(); }
+    bool IsError() const { return mnCode.IsError(); }
+    explicit operator bool() const { return bool(mnCode); }
+    bool operator==(const ErrCodeMsg& rOther) const { return mnCode == 
rOther.mnCode; }
+    bool operator!=(const ErrCodeMsg& rOther) const { return mnCode != 
rOther.mnCode; }
+
+    /// Return a string suitable for debug output, the same as the operator<< 
function
+    COMPHELPER_DLLPUBLIC OUString toString() const;
+
+private:
+    ErrCode mnCode;
+    OUString maArg1;
+    OUString maArg2;
+    DialogMask mnDialogMask;
+#ifdef LIBO_ERRMSG_USE_SOURCE_LOCATION
+    std::optional<std::experimental::source_location> moLoc;
+#endif
+};
+
+COMPHELPER_DLLPUBLIC std::ostream& operator<<(std::ostream& os, const 
ErrCodeMsg& err);
+
+inline bool operator==(const ErrCodeMsg& lhs, ErrCode rhs) { return 
lhs.GetCode() == rhs; }
+inline bool operator!=(const ErrCodeMsg& lhs, ErrCode rhs) { return 
lhs.GetCode() != rhs; }
+inline bool operator==(ErrCode lhs, const ErrCodeMsg& rhs) { return lhs == 
rhs.GetCode(); }
+inline bool operator!=(ErrCode lhs, const ErrCodeMsg& rhs) { return lhs != 
rhs.GetCode(); }
+
 enum class ErrCodeArea {
     Io                  = 0 ,
     Sfx                 = 2 ,
diff --git a/include/sfx2/app.hxx b/include/sfx2/app.hxx
index bd214ce2f2e5..96bce367fd75 100644
--- a/include/sfx2/app.hxx
+++ b/include/sfx2/app.hxx
@@ -129,7 +129,7 @@ public:
     /**
     * @param pArgs Takes ownership
     */
-    ErrCode                     LoadTemplate( SfxObjectShellLock& xDoc, const 
OUString& rFileName, std::unique_ptr<SfxItemSet> pArgs );
+    ErrCodeMsg                  LoadTemplate( SfxObjectShellLock& xDoc, const 
OUString& rFileName, std::unique_ptr<SfxItemSet> pArgs );
     weld::Window*               GetTopWindow() const;
 
     // members
diff --git a/include/sfx2/docfile.hxx b/include/sfx2/docfile.hxx
index 0b1c417247f5..377bab62830f 100644
--- a/include/sfx2/docfile.hxx
+++ b/include/sfx2/docfile.hxx
@@ -143,14 +143,14 @@ public:
     void                Download( const Link<void*,void>& aLink = 
Link<void*,void>());
     void                SetDoneLink( const Link<void*,void>& rLink );
 
-    ErrCode             GetErrorCode() const;
-    ErrCode             GetErrorIgnoreWarning() const
+    ErrCodeMsg          GetErrorCode() const;
+    ErrCodeMsg          GetErrorIgnoreWarning() const
                         { return GetErrorCode().IgnoreWarning(); }
-    ErrCode             GetWarningError() const;
-    ErrCode const &     GetLastStorageCreationState() const;
+    ErrCodeMsg const &  GetWarningError() const;
+    ErrCodeMsg const &  GetLastStorageCreationState() const;
 
-    void                SetError(ErrCode nError);
-    void                SetWarningError(ErrCode nWarningError);
+    void                SetError(ErrCodeMsg nError);
+    void                SetWarningError(const ErrCodeMsg& nWarningError);
 
     void                CloseInStream();
     void                CloseOutStream();
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index a214c242a1c7..7e5cb97827a6 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -290,9 +290,9 @@ public:
     SAL_DLLPRIVATE void         SetMacroMode_Impl(bool bModal=true);
 
     void                        ResetError();
-    ErrCode                     GetErrorIgnoreWarning() const;
-    ErrCode                     GetErrorCode() const;
-    void                        SetError(ErrCode rErr);
+    ErrCodeMsg                  GetErrorIgnoreWarning() const;
+    ErrCodeMsg                  GetErrorCode() const;
+    void                        SetError(const ErrCodeMsg& rErr);
 
     /**
      * Initialize bare minimum just enough for unit test runs.
@@ -719,7 +719,7 @@ public:
 
     SAL_DLLPRIVATE static bool UseInteractionToHandleError(
                     const css::uno::Reference< css::task::XInteractionHandler 
>& xHandler,
-                    ErrCode nError );
+                    const ErrCodeMsg& nError );
     SAL_DLLPRIVATE const SfxObjectShell_Impl* Get_Impl() const { return 
pImpl.get(); }
 
     SAL_DLLPRIVATE void SetCreateMode_Impl( SfxObjectCreateMode nMode );
diff --git a/include/sfx2/sfxbasemodel.hxx b/include/sfx2/sfxbasemodel.hxx
index 2602387fad59..de7661104451 100644
--- a/include/sfx2/sfxbasemodel.hxx
+++ b/include/sfx2/sfxbasemodel.hxx
@@ -67,6 +67,7 @@
 #include <memory>
 
 class ErrCode;
+class ErrCodeMsg;
 class SfxMedium;
 class   SfxObjectShell                      ;
 class   SfxViewFrame;
@@ -738,7 +739,7 @@ private:
 
     SAL_DLLPRIVATE void loadCmisProperties();
 
-    SAL_DLLPRIVATE SfxMedium* handleLoadError( ErrCode nError, SfxMedium* 
pMedium );
+    SAL_DLLPRIVATE SfxMedium* handleLoadError( const ErrCodeMsg& nError, 
SfxMedium* pMedium );
 
 
 //  private variables and methods
diff --git a/include/svtools/ehdl.hxx b/include/svtools/ehdl.hxx
index 78bcf1723dfe..1f3b8d6cb17e 100644
--- a/include/svtools/ehdl.hxx
+++ b/include/svtools/ehdl.hxx
@@ -40,7 +40,7 @@ public:
     SfxErrorContext(
             sal_uInt16 nCtxIdP, OUString aArg1, weld::Window *pWin=nullptr,
             const ErrMsgCode* pIds = nullptr, const std::locale& rResLocaleP = 
SvtResLocale());
-    bool GetString(ErrCode nErrId, OUString &rStr) override;
+    bool GetString(const ErrCodeMsg& nErrId, OUString &rStr) override;
 
     void SetExtendedMessage(ErrCode nErrId, const OUString& rStr);
 
@@ -69,7 +69,7 @@ private:
     std::locale aResLocale;
 
     SVT_DLLPRIVATE static void GetClassString(ErrCodeClass lErrId, OUString &);
-    virtual bool          CreateString(const ErrorInfo *, OUString &) const 
override;
+    virtual bool          CreateString(const ErrCodeMsg&, OUString &) const 
override;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/errinf.hxx b/include/vcl/errinf.hxx
index 7f2976e23cee..0f4d8d781de7 100644
--- a/include/vcl/errinf.hxx
+++ b/include/vcl/errinf.hxx
@@ -24,7 +24,6 @@
 #include <utility>
 #include <comphelper/errcode.hxx>
 #include <vcl/dllapi.h>
-#include <o3tl/typed_flags_set.hxx>
 
 #include <vector>
 #include <memory>
@@ -35,15 +34,12 @@ namespace weld { class Window; }
 
 class ErrorHandler;
 class ErrorContext;
-class ErrorInfo;
-class DynamicErrorInfo;
-class ImplDynamicErrorInfo;
 enum class DialogMask;
 
 class VCL_DLLPUBLIC ErrorStringFactory
 {
 public:
-    static bool CreateString(const ErrorInfo*, OUString&);
+    static bool CreateString(const ErrCodeMsg&, OUString&);
 };
 
 typedef void (* DisplayFnPtr)();
@@ -59,7 +55,6 @@ class VCL_DLLPUBLIC ErrorRegistry
     friend class ErrorHandler;
     friend class ErrorContext;
     friend class ErrorStringFactory;
-    friend class ImplDynamicErrorInfo;
 
 public:
                                 ErrorRegistry();
@@ -78,39 +73,9 @@ private:
 
     bool m_bLock;
 
-    sal_uInt16                  nNextError;
-
     std::vector<ErrorHandler*>  errorHandlers;
     std::vector<ErrorContext*>  contexts;
-
-    DynamicErrorInfo*           ppDynErrInfo[ERRCODE_DYNAMIC_COUNT];
-};
-
-enum class DialogMask
-{
-    NONE                    = 0x0000,
-    ButtonsOk               = 0x0001,
-    ButtonsCancel           = 0x0002,
-    ButtonsRetry            = 0x0004,
-    ButtonsNo               = 0x0008,
-    ButtonsYes              = 0x0010,
-    ButtonsYesNo            = 0x0018,
-
-    ButtonDefaultsOk        = 0x0100,
-    ButtonDefaultsCancel    = 0x0200,
-    ButtonDefaultsYes       = 0x0300,
-    ButtonDefaultsNo        = 0x0400,
-
-    MessageError            = 0x1000,
-    MessageWarning          = 0x2000,
-    MessageInfo             = 0x3000,
-
-    MAX                     = USHRT_MAX,
 };
-namespace o3tl
-{
-    template<> struct typed_flags<DialogMask> : is_typed_flags<DialogMask, 
0xffff> {};
-}
 
 class SAL_WARN_UNUSED VCL_DLLPUBLIC ErrorHandler
 {
@@ -136,72 +101,11 @@ public:
 
         @return what sort of dialog to use, with what buttons
     */
-    static DialogMask       HandleError(ErrCode nId, weld::Window* pParent = 
nullptr, DialogMask nMask = DialogMask::MAX);
-    static bool             GetErrorString(ErrCode nId, OUString& rStr);
+    static DialogMask       HandleError(const ErrCodeMsg& nId, weld::Window* 
pParent = nullptr, DialogMask nMask = DialogMask::MAX);
+    static bool             GetErrorString(const ErrCodeMsg& nId, OUString& 
rStr);
 
 protected:
-    virtual bool            CreateString(const ErrorInfo*, OUString &) const = 
0;
-
-};
-
-class SAL_WARN_UNUSED VCL_DLLPUBLIC ErrorInfo
-{
-public:
-                            ErrorInfo(ErrCode nArgUserId) :
-                                nUserId(nArgUserId) {}
-    virtual                 ~ErrorInfo();
-
-    ErrCode const &         GetErrorCode() const { return nUserId; }
-
-    static std::unique_ptr<ErrorInfo> GetErrorInfo(ErrCode);
-
-private:
-    ErrCode                 nUserId;
-};
-
-class SAL_WARN_UNUSED VCL_DLLPUBLIC DynamicErrorInfo : public ErrorInfo
-{
-    friend class ImplDynamicErrorInfo;
-
-public:
-                            DynamicErrorInfo(ErrCode nUserId, DialogMask 
nMask);
-    virtual                 ~DynamicErrorInfo() override;
-
-    operator                ErrCode() const;
-    DialogMask              GetDialogMask() const;
-
-private:
-    std::unique_ptr<ImplDynamicErrorInfo> pImpl;
-
-};
-
-class SAL_WARN_UNUSED VCL_DLLPUBLIC StringErrorInfo final : public 
DynamicErrorInfo
-{
-public:
-                            StringErrorInfo(ErrCode nUserId,
-                                            OUString aStringP,
-                                            DialogMask nMask = 
DialogMask::NONE);
-
-    const OUString&         GetErrorString() const { return aString; }
-
-private:
-    OUString                aString;
-
-};
-
-class SAL_WARN_UNUSED VCL_DLLPUBLIC TwoStringErrorInfo final : public 
DynamicErrorInfo
-{
-public:
-    TwoStringErrorInfo(ErrCode nUserID, OUString aTheArg1,
-                       OUString aTheArg2, DialogMask nMask):
-        DynamicErrorInfo(nUserID, nMask), aArg1(std::move(aTheArg1)), 
aArg2(std::move(aTheArg2)) {}
-
-    const OUString& GetArg1() const { return aArg1; }
-    const OUString& GetArg2() const { return aArg2; }
-
-private:
-    OUString aArg1;
-    OUString aArg2;
+    virtual bool            CreateString(const ErrCodeMsg&, OUString &) const 
= 0;
 
 };
 
@@ -215,7 +119,7 @@ public:
                             ErrorContext(weld::Window *pWin);
     virtual                 ~ErrorContext();
 
-    virtual bool            GetString(ErrCode nErrId, OUString& rCtxStr) = 0;
+    virtual bool            GetString(const ErrCodeMsg& nErrId, OUString& 
rCtxStr) = 0;
     weld::Window*           GetParent();
 
     static ErrorContext*    GetContext();
diff --git a/sc/inc/xmlwrap.hxx b/sc/inc/xmlwrap.hxx
index 53d3b24f65f4..bfae5363cfbd 100644
--- a/sc/inc/xmlwrap.hxx
+++ b/sc/inc/xmlwrap.hxx
@@ -65,7 +65,7 @@ class ScXMLImportWrapper
 
     css::uno::Reference< css::task::XStatusIndicator> GetStatusIndicator() 
const;
 
-    ErrCode ImportFromComponent(const 
css::uno::Reference<css::uno::XComponentContext>& xContext,
+    ErrCodeMsg ImportFromComponent(const 
css::uno::Reference<css::uno::XComponentContext>& xContext,
         const css::uno::Reference<css::frame::XModel>& xModel,
         css::xml::sax::InputSource& aParserInput,
         const OUString& sComponentName, const OUString& sDocName,
@@ -85,7 +85,7 @@ public:
     ScXMLImportWrapper(
         ScDocShell& rDocSh, SfxMedium* pM, 
css::uno::Reference<css::embed::XStorage> xStor );
 
-    bool Import( ImportFlags nMode, ErrCode& rError );
+    bool Import( ImportFlags nMode, ErrCodeMsg& rError );
     bool Export(bool bStylesOnly);
 
     const sc::ImportPostProcessData& GetImportPostProcessData() const { return 
maPostProcessData;}
diff --git a/sc/source/filter/xml/xmlwrap.cxx b/sc/source/filter/xml/xmlwrap.cxx
index f7bbaa2a5301..d1a8677f0a5f 100644
--- a/sc/source/filter/xml/xmlwrap.cxx
+++ b/sc/source/filter/xml/xmlwrap.cxx
@@ -101,7 +101,7 @@ uno::Reference <task::XStatusIndicator> 
ScXMLImportWrapper::GetStatusIndicator()
     return xStatusIndicator;
 }
 
-ErrCode ScXMLImportWrapper::ImportFromComponent(const 
uno::Reference<uno::XComponentContext>& xContext,
+ErrCodeMsg ScXMLImportWrapper::ImportFromComponent(const 
uno::Reference<uno::XComponentContext>& xContext,
     const uno::Reference<frame::XModel>& xModel,
     xml::sax::InputSource& aParserInput,
     const OUString& sComponentName, const OUString& sDocName,
@@ -155,7 +155,7 @@ ErrCode ScXMLImportWrapper::ImportFromComponent(const 
uno::Reference<uno::XCompo
         xInfoSet->setPropertyValue( "StreamName", uno::Any( sStream ) );
     }
 
-    ErrCode nReturn = ERRCODE_NONE;
+    ErrCodeMsg nReturn = ERRCODE_NONE;
     rDoc.SetRangeOverflowType(ERRCODE_NONE);   // is modified by the importer 
if limits are exceeded
 
     uno::Reference<XInterface> xImportInterface =
@@ -219,7 +219,7 @@ ErrCode ScXMLImportWrapper::ImportFromComponent(const 
uno::Reference<uno::XCompo
 
             if( !sDocName.isEmpty() )
             {
-                nReturn = *new TwoStringErrorInfo(
+                nReturn = ErrCodeMsg(
                                 (bMustBeSuccessful ? SCERR_IMPORT_FILE_ROWCOL
                                                         : 
SCWARN_IMPORT_FILE_ROWCOL),
                                 sDocName, sErr,
@@ -228,7 +228,7 @@ ErrCode ScXMLImportWrapper::ImportFromComponent(const 
uno::Reference<uno::XCompo
             else
             {
                 OSL_ENSURE( bMustBeSuccessful, "Warnings are not supported" );
-                nReturn = *new StringErrorInfo( SCERR_IMPORT_FORMAT_ROWCOL, 
sErr,
+                nReturn = ErrCodeMsg( SCERR_IMPORT_FORMAT_ROWCOL, sErr,
                                  DialogMask::ButtonsOk | 
DialogMask::MessageError );
             }
         }
@@ -279,7 +279,7 @@ ErrCode ScXMLImportWrapper::ImportFromComponent(const 
uno::Reference<uno::XCompo
     return nReturn;
 }
 
-bool ScXMLImportWrapper::Import( ImportFlags nMode, ErrCode& rError )
+bool ScXMLImportWrapper::Import( ImportFlags nMode, ErrCodeMsg& rError )
 {
     uno::Reference<uno::XComponentContext> xContext = 
comphelper::getProcessComponentContext();
 
@@ -410,7 +410,7 @@ bool ScXMLImportWrapper::Import( ImportFlags nMode, 
ErrCode& rError )
     }
 
     // #i103539#: always read meta.xml for generator
-    ErrCode nMetaRetval(ERRCODE_NONE);
+    ErrCodeMsg nMetaRetval(ERRCODE_NONE);
     if (nMode & ImportFlags::Metadata)
     {
         uno::Sequence<uno::Any> aMetaArgs { Any(xInfoSet) };
@@ -448,7 +448,7 @@ bool ScXMLImportWrapper::Import( ImportFlags nMode, 
ErrCode& rError )
         Any(xObjectResolver)
     };
 
-    ErrCode nSettingsRetval(ERRCODE_NONE);
+    ErrCodeMsg nSettingsRetval(ERRCODE_NONE);
     if (nMode & ImportFlags::Settings)
     {
         //  Settings must be loaded first because of the printer setting,
@@ -467,7 +467,7 @@ bool ScXMLImportWrapper::Import( ImportFlags nMode, 
ErrCode& rError )
         SAL_INFO( "sc.filter", "settings import end" );
     }
 
-    ErrCode nStylesRetval(ERRCODE_NONE);
+    ErrCodeMsg nStylesRetval(ERRCODE_NONE);
     if (nMode & ImportFlags::Styles)
     {
         SAL_INFO( "sc.filter", "styles import start" );
@@ -481,7 +481,7 @@ bool ScXMLImportWrapper::Import( ImportFlags nMode, 
ErrCode& rError )
         SAL_INFO( "sc.filter", "styles import end" );
     }
 
-    ErrCode nDocRetval(ERRCODE_NONE);
+    ErrCodeMsg nDocRetval(ERRCODE_NONE);
     if (nMode & ImportFlags::Content)
     {
         if (mrDocShell.GetCreateMode() == SfxObjectCreateMode::INTERNAL)
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 32c7aa03022f..a869e740083c 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -509,7 +509,7 @@ bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const 
css::uno::Reference< css
     ScXMLImportWrapper aImport(*this, pLoadMedium, xStor);
 
     bool bRet = false;
-    ErrCode nError = ERRCODE_NONE;
+    ErrCodeMsg nError = ERRCODE_NONE;
     m_pDocument->LockAdjustHeight();
     if (GetCreateMode() == SfxObjectCreateMode::ORGANIZER)
         bRet = aImport.Import(ImportFlags::Styles, nError);
@@ -2606,7 +2606,7 @@ bool ScDocShell::ConvertTo( SfxMedium &rMed )
         rMed.CloseOutStream();
         bool bHasMemo = false;
 
-        ErrCode eError = DBaseExport(
+        ErrCodeMsg eError = DBaseExport(
             rMed.GetPhysicalName(), ScGlobal::GetCharsetValue(sCharSet), 
bHasMemo);
 
         INetURLObject aTmpFile( rMed.GetPhysicalName(), INetProtocol::File );
@@ -2717,7 +2717,7 @@ bool ScDocShell::ConvertTo( SfxMedium &rMed )
             bRet = aImExport.ExportStream(*pStream, rMed.GetBaseURL(true), 
SotClipboardFormatId::HTML);
             if (bRet && !aImExport.GetNonConvertibleChars().isEmpty())
             {
-                SetError(*new StringErrorInfo(
+                SetError(ErrCodeMsg(
                     SCWARN_EXPORT_NONCONVERTIBLE_CHARS,
                     aImExport.GetNonConvertibleChars(),
                     DialogMask::ButtonsOk | DialogMask::MessageInfo));
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 377b8cff1943..0843e6580946 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -834,7 +834,7 @@ void ScDocShell::Execute( SfxRequest& rReq )
                 ScDocShell* pOtherDocSh = new ScDocShell;
                 SfxObjectShellLock aDocShTablesRef = pOtherDocSh;
                 pOtherDocSh->DoLoad( pMed );
-                ErrCode nErr = pOtherDocSh->GetErrorCode();
+                ErrCodeMsg nErr = pOtherDocSh->GetErrorCode();
                 if (nErr)
                     ErrorHandler::HandleError( nErr );          // also 
warnings
 
diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx
index 83a2394d661c..44a080770a15 100644
--- a/sc/source/ui/docshell/docsh8.cxx
+++ b/sc/source/ui/docshell/docsh8.cxx
@@ -726,7 +726,7 @@ void lcl_getLongVarCharString(
 
 #endif // HAVE_FEATURE_DBCONNECTIVITY
 
-ErrCode ScDocShell::DBaseExport( const OUString& rFullFileName, 
rtl_TextEncoding eCharSet, bool& bHasMemo )
+ErrCodeMsg ScDocShell::DBaseExport( const OUString& rFullFileName, 
rtl_TextEncoding eCharSet, bool& bHasMemo )
 {
 #if !HAVE_FEATURE_DBCONNECTIVITY
     (void) rFullFileName;
@@ -739,7 +739,7 @@ ErrCode ScDocShell::DBaseExport( const OUString& 
rFullFileName, rtl_TextEncoding
     INetURLObject aDeleteObj( rFullFileName, INetProtocol::File );
     KillFile( aDeleteObj );
 
-    ErrCode nErr = ERRCODE_NONE;
+    ErrCodeMsg nErr = ERRCODE_NONE;
 
     SCCOL nFirstCol, nLastCol;
     SCROW  nFirstRow, nLastRow;
@@ -1060,12 +1060,12 @@ ErrCode ScDocShell::DBaseExport( const OUString& 
rFullFileName, rtl_TextEncoding
             }
             OUString sPosition(ScAddress(nDocCol, nDocRow, 
nTab).GetColRowString());
             OUString sEncoding(SvxTextEncodingTable::GetTextString(eCharSet));
-            nErr = *new TwoStringErrorInfo( (bEncErr ? SCERR_EXPORT_ENCODING :
+            nErr = ErrCodeMsg( (bEncErr ? SCERR_EXPORT_ENCODING :
                         SCERR_EXPORT_FIELDWIDTH), sPosition, sEncoding,
                     DialogMask::ButtonsOk | DialogMask::MessageError);
         }
         else if ( !aException.Message.isEmpty() )
-            nErr = *new StringErrorInfo( SCERR_EXPORT_SQLEXCEPTION, 
aException.Message, DialogMask::ButtonsOk | DialogMask::MessageError);
+            nErr = ErrCodeMsg( SCERR_EXPORT_SQLEXCEPTION, aException.Message, 
DialogMask::ButtonsOk | DialogMask::MessageError);
         else
             nErr = SCERR_EXPORT_DATA;
     }
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index 58741d563737..a2bbb5454573 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -137,7 +137,7 @@ class SC_DLLPUBLIC ScDocShell final: public SfxObjectShell, 
public SfxListener
 
     SAL_DLLPRIVATE ErrCode       DBaseImport( const OUString& rFullFileName, 
rtl_TextEncoding eCharSet,
                                              std::map<SCCOL, ScColWidthParam>& 
aColWidthParam, ScFlatBoolRowSegments& rRowHeightsRecalc );
-    SAL_DLLPRIVATE ErrCode       DBaseExport(
+    SAL_DLLPRIVATE ErrCodeMsg    DBaseExport(
                                     const OUString& rFullFileName, 
rtl_TextEncoding eCharSet, bool& bHasMemo );
 
     SAL_DLLPRIVATE static bool       MoveFile( const INetURLObject& rSource, 
const INetURLObject& rDest );
diff --git a/sc/source/ui/miscdlgs/instbdlg.cxx 
b/sc/source/ui/miscdlgs/instbdlg.cxx
index 8d92699e70f8..e34b22a6f336 100644
--- a/sc/source/ui/miscdlgs/instbdlg.cxx
+++ b/sc/source/ui/miscdlgs/instbdlg.cxx
@@ -325,7 +325,7 @@ IMPL_LINK( ScInsertTableDlg, DialogClosedHdl, 
sfx2::FileDialogHelper*, _pFileDlg
                 pDocShTables->DoLoad(pMed.release());
             }
 
-            ErrCode nErr = pDocShTables->GetErrorCode();
+            ErrCodeMsg nErr = pDocShTables->GetErrorCode();
             if ( nErr )
                 ErrorHandler::HandleError(nErr, m_xDialog.get()); // warnings, 
too
 
diff --git a/sc/source/ui/miscdlgs/linkarea.cxx 
b/sc/source/ui/miscdlgs/linkarea.cxx
index 00d508a6661b..f0cdad08e370 100644
--- a/sc/source/ui/miscdlgs/linkarea.cxx
+++ b/sc/source/ui/miscdlgs/linkarea.cxx
@@ -127,7 +127,7 @@ void ScLinkedAreaDlg::LoadDocument( const OUString& rFile, 
const OUString& rFilt
     m_pSourceShell = aLoader.GetDocShell();
     if (m_pSourceShell)
     {
-        ErrCode nErr = m_pSourceShell->GetErrorCode();
+        ErrCodeMsg nErr = m_pSourceShell->GetErrorCode();
         if (nErr)
             ErrorHandler::HandleError( nErr );      // including warnings
 
@@ -211,7 +211,7 @@ IMPL_LINK( ScLinkedAreaDlg, DialogClosedHdl, 
sfx2::FileDialogHelper*, _pFileDlg,
         aSourceRef = m_pSourceShell;
         m_pSourceShell->DoLoad( pMed.get() );
 
-        ErrCode nErr = m_pSourceShell->GetErrorCode();
+        ErrCodeMsg nErr = m_pSourceShell->GetErrorCode();
         if (nErr)
             ErrorHandler::HandleError( nErr );              // including 
warnings
 
diff --git a/sd/source/filter/xml/sdxmlwrp.cxx 
b/sd/source/filter/xml/sdxmlwrp.cxx
index 6dba0df7b4db..3c66afcd5f16 100644
--- a/sd/source/filter/xml/sdxmlwrp.cxx
+++ b/sd/source/filter/xml/sdxmlwrp.cxx
@@ -166,7 +166,7 @@ SdXMLFilter::~SdXMLFilter()
 namespace
 {
 
-ErrCode ReadThroughComponent(
+ErrCodeMsg ReadThroughComponent(
     const Reference<io::XInputStream>& xInputStream,
     const Reference<XComponent>& xModelComponent,
     const OUString& rStreamName,
@@ -259,7 +259,7 @@ ErrCode ReadThroughComponent(
 
         if (!rStreamName.isEmpty())
         {
-            return *new TwoStringErrorInfo(
+            return ErrCodeMsg(
                             (bMustBeSuccessful ? ERR_FORMAT_FILE_ROWCOL
                                                     : WARN_FORMAT_FILE_ROWCOL),
                             rStreamName, sErr,
@@ -268,7 +268,7 @@ ErrCode ReadThroughComponent(
         else
         {
             DBG_ASSERT( bMustBeSuccessful, "Warnings are not supported" );
-            return *new StringErrorInfo( ERR_FORMAT_ROWCOL, sErr,
+            return ErrCodeMsg( ERR_FORMAT_ROWCOL, sErr,
                              DialogMask::ButtonsOk | DialogMask::MessageError 
);
         }
     }
@@ -305,7 +305,7 @@ ErrCode ReadThroughComponent(
     return ERRCODE_NONE;
 }
 
-ErrCode ReadThroughComponent(
+ErrCodeMsg ReadThroughComponent(
     const uno::Reference < embed::XStorage >& xStorage,
     const Reference<XComponent>& xModelComponent,
     const char* pStreamName,
@@ -442,7 +442,7 @@ static void 
fixupOutlinePlaceholderNumberingDepths(SdDrawDocument* pDoc)
 
 bool SdXMLFilter::Import( ErrCode& nError )
 {
-    ErrCode nRet = ERRCODE_NONE;
+    ErrCodeMsg nRet = ERRCODE_NONE;
 
     // Get service factory
     Reference< uno::XComponentContext > rxContext =
@@ -591,8 +591,8 @@ bool SdXMLFilter::Import( ErrCode& nError )
 
         XML_SERVICES const * pServices = getServices( true, IsDraw(), 
mnStoreVer );
 
-        ErrCode nWarn = ERRCODE_NONE;
-        ErrCode nWarn2 = ERRCODE_NONE;
+        ErrCodeMsg nWarn = ERRCODE_NONE;
+        ErrCodeMsg nWarn2 = ERRCODE_NONE;
         // read storage streams
         // #i103539#: always read meta.xml for generator
         nWarn = ReadThroughComponent(
@@ -646,7 +646,7 @@ bool SdXMLFilter::Import( ErrCode& nError )
     if( nRet == ERRCODE_NONE )
         pDoc->UpdateAllLinks();
 
-    if( nRet.anyOf( ERRCODE_NONE, SD_XML_READERROR ) )
+    if( nRet == ERRCODE_NONE || nRet == SD_XML_READERROR )
         ;
     else if( nRet == ERRCODE_IO_BROKENPACKAGE && xStorage.is() )
         nError = ERRCODE_IO_BROKENPACKAGE;
diff --git a/sd/source/ui/app/sdmod1.cxx b/sd/source/ui/app/sdmod1.cxx
index 0a4f7d5e587b..e35ee5c3e518 100644
--- a/sd/source/ui/app/sdmod1.cxx
+++ b/sd/source/ui/app/sdmod1.cxx
@@ -421,7 +421,7 @@ SfxFrame* SdModule::CreateFromTemplate(const OUString& 
rTemplatePath, const Refe
     std::unique_ptr<SfxItemSet> pSet(new SfxAllItemSet( 
SfxGetpApp()->GetPool() ));
     pSet->Put( SfxBoolItem( SID_TEMPLATE, true ) );
 
-    ErrCode lErr = SfxGetpApp()->LoadTemplate( xDocShell, rTemplatePath, 
std::move(pSet) );
+    ErrCodeMsg lErr = SfxGetpApp()->LoadTemplate( xDocShell, rTemplatePath, 
std::move(pSet) );
 
     SfxObjectShell* pDocShell = xDocShell;
 
diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx
index 64b266f42060..28a4c102b3c0 100644
--- a/sd/source/ui/func/fuinsert.cxx
+++ b/sd/source/ui/func/fuinsert.cxx
@@ -423,8 +423,7 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
         }
         else
         {
-            ErrorHandler::HandleError(* new 
StringErrorInfo(ERRCODE_SFX_OLEGENERAL,
-                                        "" ) );
+            ErrorHandler::HandleError(ErrCodeMsg(ERRCODE_SFX_OLEGENERAL));
         }
     }
     else
diff --git a/sd/source/ui/view/viewshe2.cxx b/sd/source/ui/view/viewshe2.cxx
index fd4d2649b4fd..b7ae44f2c3e1 100644
--- a/sd/source/ui/view/viewshe2.cxx
+++ b/sd/source/ui/view/viewshe2.cxx
@@ -779,7 +779,7 @@ bool ViewShell::ActivateObject(SdrOle2Obj* pObj, sal_Int32 
nVerb)
 
     if (aErrCode != ERRCODE_NONE && !bAbort)
     {
-        ErrorHandler::HandleError(* new StringErrorInfo(aErrCode, OUString() ) 
);
+        ErrorHandler::HandleError(ErrCodeMsg(aErrCode));
     }
 
     return aErrCode == ERRCODE_NONE;
diff --git a/sfx2/source/appl/app.cxx b/sfx2/source/appl/app.cxx
index c5a1d1614145..6ae9810345e5 100644
--- a/sfx2/source/appl/app.cxx
+++ b/sfx2/source/appl/app.cxx
@@ -409,8 +409,8 @@ IMPL_STATIC_LINK( SfxApplication, GlobalBasicErrorHdl_Impl, 
StarBASIC*, pStarBas
     if (comphelper::LibreOfficeKit::isActive())
     {
         OUString aError;
-        std::unique_ptr<ErrorInfo> pErrorInfo = 
ErrorInfo::GetErrorInfo(StarBASIC::GetErrorCode());
-        if (ErrorStringFactory::CreateString(pErrorInfo.get(), aError))
+        ErrCodeMsg nErr = StarBASIC::GetErrorCode();
+        if (ErrorStringFactory::CreateString(nErr, aError))
         {
             const SfxViewFrame* pViewFrame = SfxViewFrame::Current();
             std::shared_ptr<weld::MessageDialog> xBox;
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx
index 5d35c403903d..8e069c14e256 100644
--- a/sfx2/source/appl/appopen.cxx
+++ b/sfx2/source/appl/appopen.cxx
@@ -287,7 +287,7 @@ ErrCode CheckPasswd_Impl
 }
 
 
-ErrCode SfxApplication::LoadTemplate( SfxObjectShellLock& xDoc, const OUString 
&rFileName, std::unique_ptr<SfxItemSet> pSet )
+ErrCodeMsg SfxApplication::LoadTemplate( SfxObjectShellLock& xDoc, const 
OUString &rFileName, std::unique_ptr<SfxItemSet> pSet )
 {
     std::shared_ptr<const SfxFilter> pFilter;
     SfxMedium aMedium( rFileName,  ( StreamMode::READ | 
StreamMode::SHARE_DENYNONE ) );
@@ -348,7 +348,7 @@ ErrCode SfxApplication::LoadTemplate( SfxObjectShellLock& 
xDoc, const OUString &
         SfxMedium *pMedium = new SfxMedium( rFileName, StreamMode::STD_READ, 
pFilter, std::move(pSet) );
         if(!xDoc->DoLoad(pMedium))
         {
-            ErrCode nErrCode = xDoc->GetErrorCode();
+            ErrCodeMsg nErrCode = xDoc->GetErrorCode();
             xDoc->DoClose();
             xDoc.Clear();
             return nErrCode;
diff --git a/sfx2/source/doc/DocumentMetadataAccess.cxx 
b/sfx2/source/doc/DocumentMetadataAccess.cxx
index 71ce92d22766..b58d8460ebd1 100644
--- a/sfx2/source/doc/DocumentMetadataAccess.cxx
+++ b/sfx2/source/doc/DocumentMetadataAccess.cxx
@@ -1361,13 +1361,13 @@ DocumentMetadataAccess::storeMetadataToMedium(
     const bool bOk = aMedium.Commit();
     aMedium.Close();
     if ( !bOk ) {
-        ErrCode nError = aMedium.GetErrorIgnoreWarning();
+        ErrCodeMsg nError = aMedium.GetErrorIgnoreWarning();
         if ( nError == ERRCODE_NONE ) {
             nError = ERRCODE_IO_GENERAL;
         }
         task::ErrorCodeIOException ex(
             "DocumentMetadataAccess::storeMetadataToMedium Commit failed: " + 
nError.toString(),
-            uno::Reference< uno::XInterface >(), sal_uInt32(nError));
+            uno::Reference< uno::XInterface >(), sal_uInt32(nError.GetCode()));
         throw lang::WrappedTargetException(OUString(), *this,
                 uno::Any(ex));
     }
diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx 
b/sfx2/source/doc/SfxDocumentMetaData.cxx
index 1e47fa955b48..c38e6bfd22cf 100644
--- a/sfx2/source/doc/SfxDocumentMetaData.cxx
+++ b/sfx2/source/doc/SfxDocumentMetaData.cxx
@@ -2127,14 +2127,14 @@ SfxDocumentMetaData::storeToMedium(const OUString & URL,
     const bool bOk = aMedium.Commit();
     aMedium.Close();
     if ( !bOk ) {
-        ErrCode nError = aMedium.GetErrorIgnoreWarning();
+        ErrCodeMsg nError = aMedium.GetErrorIgnoreWarning();
         if ( nError == ERRCODE_NONE ) {
             nError = ERRCODE_IO_GENERAL;
         }
 
         throw css::task::ErrorCodeIOException(
             "SfxDocumentMetaData::storeToMedium <" + URL + "> Commit failed: " 
+ nError.toString(),
-            css::uno::Reference< css::uno::XInterface >(), sal_uInt32(nError));
+            css::uno::Reference< css::uno::XInterface >(), 
sal_uInt32(nError.GetCode()));
 
     }
 }
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 7b65615da4df..3b975bb1add9 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -347,8 +347,8 @@ class SfxMedium_Impl
 {
 public:
     StreamMode m_nStorOpenMode;
-    ErrCode    m_eError;
-    ErrCode    m_eWarningError;
+    ErrCodeMsg m_eError;
+    ErrCodeMsg m_eWarningError;
 
     ::ucbhelper::Content aContent;
     bool bUpdatePickList:1;
@@ -411,7 +411,7 @@ public:
     uno::Reference<io::XStream> m_xLockingStream;
     uno::Reference<task::XInteractionHandler> xInteraction;
 
-    ErrCode  nLastStorageError;
+    ErrCodeMsg  nLastStorageError;
 
     OUString m_aBackupURL;
 
@@ -489,29 +489,29 @@ void SfxMedium::ResetError()
         pImpl->m_pOutStream->ResetError();
 }
 
-ErrCode SfxMedium::GetWarningError() const
+ErrCodeMsg const & SfxMedium::GetWarningError() const
 {
     return pImpl->m_eWarningError;
 }
 
-ErrCode const & SfxMedium::GetLastStorageCreationState() const
+ErrCodeMsg const & SfxMedium::GetLastStorageCreationState() const
 {
     return pImpl->nLastStorageError;
 }
 
-void SfxMedium::SetError(ErrCode nError)
+void SfxMedium::SetError(ErrCodeMsg nError)
 {
     pImpl->m_eError = nError;
 }
 
-void SfxMedium::SetWarningError(ErrCode nWarningError)
+void SfxMedium::SetWarningError(const ErrCodeMsg& nWarningError)
 {
     pImpl->m_eWarningError = nWarningError;
 }
 
-ErrCode SfxMedium::GetErrorCode() const
+ErrCodeMsg SfxMedium::GetErrorCode() const
 {
-    ErrCode lError = pImpl->m_eError;
+    ErrCodeMsg lError = pImpl->m_eError;
     if(!lError && pImpl->m_pInStream)
         lError = pImpl->m_pInStream->GetErrorCode();
     if(!lError && pImpl->m_pOutStream)
@@ -1786,7 +1786,8 @@ uno::Reference < embed::XStorage > SfxMedium::GetStorage( 
bool bCreateTempFile )
         // impossibility to create the storage is no error
     }
 
-    if( ( pImpl->nLastStorageError = GetErrorIgnoreWarning() ) != ERRCODE_NONE 
)
+    pImpl->nLastStorageError = GetErrorIgnoreWarning();
+    if( pImpl->nLastStorageError != ERRCODE_NONE )
     {
         pImpl->xStorage = nullptr;
         if ( pImpl->m_pInStream )
@@ -2907,8 +2908,8 @@ void SfxMedium::GetMedium_Impl()
 
     pImpl->bDownloadDone = true;
     pImpl->aDoneLink.ClearPendingCall();
-    ErrCode nError = GetErrorIgnoreWarning();
-    pImpl->aDoneLink.Call( reinterpret_cast<void*>(sal_uInt32(nError)) );
+    ErrCodeMsg nError = GetErrorIgnoreWarning();
+    pImpl->aDoneLink.Call( 
reinterpret_cast<void*>(sal_uInt32(nError.GetCode())) );
 }
 
 bool SfxMedium::IsRemote() const
diff --git a/sfx2/source/doc/new.cxx b/sfx2/source/doc/new.cxx
index a9bba4f0fc2d..a4d2153f6684 100644
--- a/sfx2/source/doc/new.cxx
+++ b/sfx2/source/doc/new.cxx
@@ -149,7 +149,7 @@ IMPL_LINK_NOARG(SfxNewFileDialog, Update, Timer*, void)
         std::unique_ptr<SfxItemSet> pSet(new 
SfxAllItemSet(pSfxApp->GetPool()));
         pSet->Put(SfxBoolItem(SID_TEMPLATE, true));
         pSet->Put(SfxBoolItem(SID_PREVIEW, true));
-        ErrCode lErr = pSfxApp->LoadTemplate(m_xDocShell, aFileName, 
std::move(pSet));
+        ErrCodeMsg lErr = pSfxApp->LoadTemplate(m_xDocShell, aFileName, 
std::move(pSet));
         if (lErr)
             ErrorHandler::HandleError(lErr);
         if (!m_xDocShell.Is())
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index db7b972b67d8..69d0ac4b3bea 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -209,7 +209,7 @@ std::vector<InfobarData>& 
SfxObjectShell::getPendingInfobars()
     return Get_Impl()->m_aPendingInfobars;
 }
 
-void SfxObjectShell::SetError(ErrCode lErr)
+void SfxObjectShell::SetError(const ErrCodeMsg& lErr)
 {
     if (pImpl->lErr==ERRCODE_NONE)
     {
@@ -217,14 +217,14 @@ void SfxObjectShell::SetError(ErrCode lErr)
     }
 }
 
-ErrCode SfxObjectShell::GetErrorIgnoreWarning() const
+ErrCodeMsg SfxObjectShell::GetErrorIgnoreWarning() const
 {
     return GetErrorCode().IgnoreWarning();
 }
 
-ErrCode SfxObjectShell::GetErrorCode() const
+ErrCodeMsg SfxObjectShell::GetErrorCode() const
 {
-    ErrCode lError=pImpl->lErr;
+    ErrCodeMsg lError=pImpl->lErr;
     if(!lError && GetMedium())
         lError=GetMedium()->GetErrorCode();
     return lError;
@@ -1693,7 +1693,7 @@ bool SfxObjectShell::IsUIActive() const
 
 bool SfxObjectShell::UseInteractionToHandleError(
                     const uno::Reference< task::XInteractionHandler >& 
xHandler,
-                    ErrCode nError )
+                    const ErrCodeMsg& nError )
 {
     bool bResult = false;
 
@@ -1709,7 +1709,7 @@ bool SfxObjectShell::UseInteractionToHandleError(
             };
 
             task::ErrorCodeRequest aErrorCode;
-            aErrorCode.ErrCode = sal_uInt32(nError);
+            aErrorCode.ErrCode = sal_uInt32(nError.GetCode());
             aInteraction <<= aErrorCode;
             xHandler->handle(::framework::InteractionRequest::CreateRequest 
(aInteraction,lContinuations));
             bResult = pAbort->wasSelected();
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 6308de92e3c6..7dddb84e5fac 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -447,9 +447,9 @@ uno::Reference<security::XCertificate> 
SfxObjectShell::GetSignPDFCertificate() c
     return uno::Reference<security::XCertificate>(it->second, uno::UNO_QUERY);
 }
 
-static void sendErrorToLOK(ErrCode error)
+static void sendErrorToLOK(ErrCodeMsg error)
 {
-    if (error.GetClass() == ErrCodeClass::NONE)
+    if (error.GetCode().GetClass() == ErrCodeClass::NONE)
         return;
 
     boost::property_tree::ptree aTree;
@@ -457,9 +457,8 @@ static void sendErrorToLOK(ErrCode error)
     aTree.put("kind", "");
     aTree.put("cmd", "");
 
-    std::unique_ptr<ErrorInfo> pInfo = ErrorInfo::GetErrorInfo(error);
     OUString aErr;
-    if (ErrorStringFactory::CreateString(pInfo.get(), aErr))
+    if (ErrorStringFactory::CreateString(error, aErr))
         aTree.put("message", aErr.toUtf8());
 
     std::stringstream aStream;
@@ -937,7 +936,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
             // at the end of the method
             aModelGuard.Init_Impl( uno::Reference< util::XCloseable >( 
GetModel(), uno::UNO_QUERY ) );
 
-            ErrCode nErrorCode = ERRCODE_NONE;
+            ErrCodeMsg nErrorCode = ERRCODE_NONE;
 
             // by default versions should be preserved always except in case 
of an explicit
             // SaveAs via GUI, so the flag must be set accordingly
@@ -1120,7 +1119,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
             // by default versions should be preserved always except in case 
of an explicit
             // SaveAs via GUI, so the flag must be reset to guarantee this
             pImpl->bPreserveVersions = true;
-            ErrCode lErr=GetErrorCode();
+            ErrCodeMsg lErr=GetErrorCode();
 
             if ( !lErr && nErrorCode )
                 lErr = nErrorCode;
@@ -1309,7 +1308,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
             }
 
             SetModified( false );
-            ErrCode lErr = GetErrorCode();
+            ErrCodeMsg lErr = GetErrorCode();
 
             if (comphelper::LibreOfficeKit::isActive())
                 sendErrorToLOK(lErr);
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index ee7358eed5be..8a1978681f99 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -2327,13 +2327,13 @@ bool SfxObjectShell::ImportFrom(SfxMedium& rMedium,
             io::WrongFormatException e;
             if (rWrapped.TargetException >>= e)
             {
-                SetError(*new StringErrorInfo(ERRCODE_SFX_FORMAT_ROWCOL,
+                SetError(ErrCodeMsg(ERRCODE_SFX_FORMAT_ROWCOL,
                     e.Message, DialogMask::ButtonsOk | 
DialogMask::MessageError ));
             }
         }
         catch (const css::io::IOException& e)
         {
-            SetError(*new StringErrorInfo(ERRCODE_SFX_FORMAT_ROWCOL,
+            SetError(ErrCodeMsg(ERRCODE_SFX_FORMAT_ROWCOL,
                 e.Message, DialogMask::ButtonsOk | DialogMask::MessageError ));
         }
         catch (const std::exception& e)
@@ -2341,7 +2341,7 @@ bool SfxObjectShell::ImportFrom(SfxMedium& rMedium,
             const char *msg = e.what();
             const OUString sError(msg, strlen(msg), RTL_TEXTENCODING_ASCII_US);
             SAL_WARN("sfx.doc", "exception importing " << sError);
-            SetError(*new StringErrorInfo(ERRCODE_SFX_DOLOADFAILED,
+            SetError(ErrCodeMsg(ERRCODE_SFX_DOLOADFAILED,
                 sError, DialogMask::ButtonsOk | DialogMask::MessageError));
         }
         catch (...)
@@ -2640,7 +2640,7 @@ bool SfxObjectShell::DoSave_Impl( const SfxItemSet* pArgs 
)
     else
     {
         // transfer error code from medium to objectshell
-        ErrCode errCode = pMediumTmp->GetErrorIgnoreWarning();
+        ErrCodeMsg errCode = pMediumTmp->GetErrorIgnoreWarning();
         SetError(errCode);
 
         if (errCode == ERRCODE_ABORT)
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index 761bd16d2a76..43d4bf3bdc19 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -1697,7 +1697,7 @@ void SAL_CALL SfxBaseModel::storeSelf( const    Sequence< 
beans::PropertyValue >
 
     pParams.reset();
 
-    ErrCode nErrCode = m_pData->m_pObjectShell->GetErrorIgnoreWarning() ? 
m_pData->m_pObjectShell->GetErrorIgnoreWarning()
+    ErrCodeMsg nErrCode = m_pData->m_pObjectShell->GetErrorIgnoreWarning() ? 
m_pData->m_pObjectShell->GetErrorIgnoreWarning()
                                                            : 
ERRCODE_IO_CANTWRITE;
     m_pData->m_pObjectShell->ResetError();
 
@@ -1714,7 +1714,7 @@ void SAL_CALL SfxBaseModel::storeSelf( const    Sequence< 
beans::PropertyValue >
 
         throw task::ErrorCodeIOException(
             "SfxBaseModel::storeSelf: " + nErrCode.toString(),
-            Reference< XInterface >(), sal_uInt32(nErrCode));
+            Reference< XInterface >(), sal_uInt32(nErrCode.GetCode()));
     }
 }
 
@@ -1882,14 +1882,14 @@ void SAL_CALL SfxBaseModel::initNew()
         throw frame::DoubleInitializationException();
 
     bool bRes = m_pData->m_pObjectShell->DoInitNew();
-    ErrCode nErrCode = m_pData->m_pObjectShell->GetErrorIgnoreWarning() ?
+    ErrCodeMsg nErrCode = m_pData->m_pObjectShell->GetErrorIgnoreWarning() ?
                        m_pData->m_pObjectShell->GetErrorIgnoreWarning() : 
ERRCODE_IO_CANTCREATE;
     m_pData->m_pObjectShell->ResetError();
 
     if ( !bRes )
         throw task::ErrorCodeIOException(
             "SfxBaseModel::initNew: " + nErrCode.toString(),
-            Reference< XInterface >(), sal_uInt32(nErrCode));
+            Reference< XInterface >(), sal_uInt32(nErrCode.GetCode()));
 }
 
 namespace {
@@ -1936,7 +1936,7 @@ void SAL_CALL SfxBaseModel::load(   const Sequence< 
beans::PropertyValue >& seqA
 
     SfxMedium* pMedium = new SfxMedium( seqArguments );
 
-    ErrCode nError = ERRCODE_NONE;
+    ErrCodeMsg nError = ERRCODE_NONE;
     if (!getFilterProvider(*pMedium).isEmpty())
     {
         if (!m_pData->m_pObjectShell->DoLoadExternal(pMedium))
@@ -2793,14 +2793,15 @@ void SfxBaseModel::loadCmisProperties( )
     }
 }
 
-SfxMedium* SfxBaseModel::handleLoadError( ErrCode nError, SfxMedium* pMedium )
+SfxMedium* SfxBaseModel::handleLoadError( const ErrCodeMsg& rError, SfxMedium* 
pMedium )
 {
-    if (!nError)
+    if (!rError)
     {
         // No error condition.
         return pMedium;
     }
 
+    ErrCodeMsg nError = rError;
     bool bSilent = false;
     const SfxBoolItem* pSilentItem = pMedium->GetItemSet().GetItem(SID_SILENT, 
false);
     if( pSilentItem )
@@ -2830,7 +2831,7 @@ SfxMedium* SfxBaseModel::handleLoadError( ErrCode nError, 
SfxMedium* pMedium )
         nError = nError ? nError : ERRCODE_IO_CANTREAD;
         throw task::ErrorCodeIOException(
             "SfxBaseModel::handleLoadError: 0x" + nError.toString(),
-            Reference< XInterface >(), sal_uInt32(nError));
+            Reference< XInterface >(), sal_uInt32(nError.GetCode()));
     }
     else
         pMedium->SetWarningError(nError);
@@ -3204,7 +3205,7 @@ void SfxBaseModel::impl_store(  const   OUString&         
          sURL
 
     pItemSet.reset();
 
-    ErrCode nErrCode = m_pData->m_pObjectShell->GetErrorCode();
+    ErrCodeMsg nErrCode = m_pData->m_pObjectShell->GetErrorCode();
     if ( !bRet && !nErrCode )
     {
         SAL_WARN("sfx.doc", "Storing has failed, no error is set!");
@@ -3223,7 +3224,7 @@ void SfxBaseModel::impl_store(  const   OUString&         
          sURL
                 SfxErrorContext aEc( ERRCTX_SFX_SAVEASDOC, 
m_pData->m_pObjectShell->GetTitle() );
 
                 task::ErrorCodeRequest aErrorCode;
-                aErrorCode.ErrCode = sal_uInt32(nErrCode);
+                aErrorCode.ErrCode = sal_uInt32(nErrCode.GetCode());
                 SfxMedium::CallApproveHandler( xHandler, Any( aErrorCode ), 
false );
             }
         }
@@ -3259,7 +3260,7 @@ void SfxBaseModel::impl_store(  const   OUString&         
          sURL
         aErrCode << nErrCode;
         throw task::ErrorCodeIOException(
             "SfxBaseModel::impl_store <" + sURL + "> failed: " + 
OUString::fromUtf8(aErrCode.str()),
-            Reference< XInterface >(), sal_uInt32(nErrCode));
+            Reference< XInterface >(), sal_uInt32(nErrCode.GetCode()));
     }
 }
 
@@ -3828,11 +3829,11 @@ void SAL_CALL SfxBaseModel::loadFromStorage( const 
Reference< embed::XStorage >&
     // load document
     if ( !m_pData->m_pObjectShell->DoLoad(pMedium) )
     {
-        ErrCode nError = m_pData->m_pObjectShell->GetErrorCode();
+        ErrCodeMsg nError = m_pData->m_pObjectShell->GetErrorCode();
         nError = nError ? nError : ERRCODE_IO_CANTREAD;
         throw task::ErrorCodeIOException(
             "SfxBaseModel::loadFromStorage: " + nError.toString(),
-            Reference< XInterface >(), sal_uInt32(nError));
+            Reference< XInterface >(), sal_uInt32(nError.GetCode()));
     }
     loadCmisProperties( );
 }
@@ -3881,7 +3882,7 @@ void SAL_CALL SfxBaseModel::storeToStorage( const 
Reference< embed::XStorage >&
         }
     }
 
-    ErrCode nError = m_pData->m_pObjectShell->GetErrorCode();
+    ErrCodeMsg nError = m_pData->m_pObjectShell->GetErrorCode();
     m_pData->m_pObjectShell->ResetError();
 
     // the warnings are currently not transported
@@ -3890,7 +3891,7 @@ void SAL_CALL SfxBaseModel::storeToStorage( const 
Reference< embed::XStorage >&
         nError = nError ? nError : ERRCODE_IO_GENERAL;
         throw task::ErrorCodeIOException(
             "SfxBaseModel::storeToStorage: " + nError.toString(),
-            Reference< XInterface >(), sal_uInt32(nError));
+            Reference< XInterface >(), sal_uInt32(nError.GetCode()));
     }
 }
 
@@ -3906,11 +3907,11 @@ void SAL_CALL SfxBaseModel::switchToStorage( const 
Reference< embed::XStorage >&
     {
         if ( !m_pData->m_pObjectShell->SwitchPersistence( xStorage ) )
         {
-            ErrCode nError = m_pData->m_pObjectShell->GetErrorCode();
+            ErrCodeMsg nError = m_pData->m_pObjectShell->GetErrorCode();
             nError = nError ? nError : ERRCODE_IO_GENERAL;
             throw task::ErrorCodeIOException(
                 "SfxBaseModel::switchToStorage: " + nError.toString(),
-                Reference< XInterface >(), sal_uInt32(nError));
+                Reference< XInterface >(), sal_uInt32(nError.GetCode()));
         }
         else
         {
diff --git a/sfx2/source/inc/objshimp.hxx b/sfx2/source/inc/objshimp.hxx
index 1bece81ce1c0..7f9624436a15 100644
--- a/sfx2/source/inc/objshimp.hxx
+++ b/sfx2/source/inc/objshimp.hxx
@@ -94,7 +94,7 @@ struct SfxObjectShell_Impl final : public 
::sfx2::IMacroDocumentAccess
                         m_bMacroCallsSeenWhileLoading:1; // whether or not the 
user options are checked after the Options dialog is closed.
 
     IndexBitSet         aBitSet;
-    ErrCode             lErr;
+    ErrCodeMsg          lErr;
     SfxEventHintId      nEventId;           // If Open/Create as to be sent
                                             // before Activate
     std::unique_ptr<AutoReloadTimer_Impl> pReloadTimer;
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index dd1fa74ea2be..8906fdce681e 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -533,7 +533,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
 
                 if( !bOK )
                 {
-                    ErrCode nErr = pMed->GetErrorCode();
+                    ErrCodeMsg nErr = pMed->GetErrorCode();
                     if ( pVersionItem )
                         nErr = ERRCODE_IO_ACCESSDENIED;
                     else
diff --git a/svtools/source/misc/ehdl.cxx b/svtools/source/misc/ehdl.cxx
index ef35b3975fca..ab602be60aaf 100644
--- a/svtools/source/misc/ehdl.cxx
+++ b/svtools/source/misc/ehdl.cxx
@@ -151,7 +151,7 @@ SfxErrorHandler::~SfxErrorHandler()
 {
 }
 
-bool SfxErrorHandler::CreateString(const ErrorInfo *pErr, OUString &rStr) const
+bool SfxErrorHandler::CreateString(const ErrCodeMsg& nErr, OUString &rStr) 
const
 
 /*  [Description]
 
@@ -160,25 +160,15 @@ bool SfxErrorHandler::CreateString(const ErrorInfo *pErr, 
OUString &rStr) const
     */
 
 {
-    ErrCode nErrCode(sal_uInt32(pErr->GetErrorCode()) & ERRCODE_ERROR_MASK);
-    if (pErr->GetErrorCode().GetArea() < lStart || lEnd < 
pErr->GetErrorCode().GetArea())
+    ErrCode nErrCode(sal_uInt32(nErr.GetCode()) & ERRCODE_ERROR_MASK);
+    if (nErr.GetCode().GetArea() < lStart || lEnd < nErr.GetCode().GetArea())
         return false;
     if(GetErrorString(nErrCode, rStr))
     {
-        const StringErrorInfo *pStringInfo = dynamic_cast<const 
StringErrorInfo *>(pErr);
-        if(pStringInfo)
-        {
-            rStr = rStr.replaceAll("$(ARG1)", pStringInfo->GetErrorString());
-        }
-        else
-        {
-            const TwoStringErrorInfo * pTwoStringInfo = dynamic_cast<const 
TwoStringErrorInfo* >(pErr);
-            if (pTwoStringInfo)
-            {
-                rStr = rStr.replaceAll("$(ARG1)", pTwoStringInfo->GetArg1());
-                rStr = rStr.replaceAll("$(ARG2)", pTwoStringInfo->GetArg2());
-            }
-        }
+        if(!nErr.GetArg1().isEmpty())
+            rStr = rStr.replaceAll("$(ARG1)", nErr.GetArg1());
+        if(!nErr.GetArg2().isEmpty())
+            rStr = rStr.replaceAll("$(ARG2)", nErr.GetArg2());
         return true;
     }
     return false;
@@ -219,7 +209,7 @@ bool SfxErrorHandler::GetErrorString(ErrCode lErrId, 
OUString &rStr) const
 
     for (const ErrMsgCode* pItem = pIds; pItem->second; ++pItem)
     {
-        if (pItem->second.StripWarningAndDynamic() == 
lErrId.StripWarningAndDynamic())
+        if (pItem->second.StripWarning() == lErrId.StripWarning())
         {
             rStr = rStr.replaceAll("$(ERROR)", Translate::get(pItem->first, 
aResLocale));
             bRet = true;
@@ -258,7 +248,7 @@ SfxErrorContext::SfxErrorContext(
         pIds = RID_ERRCTX;
 }
 
-bool SfxErrorContext::GetString(ErrCode nErrId, OUString &rStr)
+bool SfxErrorContext::GetString(const ErrCodeMsg& nErr, OUString &rStr)
 
 /*  [Description]
 
@@ -282,7 +272,7 @@ bool SfxErrorContext::GetString(ErrCode nErrId, OUString 
&rStr)
 
     if ( bRet )
     {
-        sal_uInt16 nId = nErrId.IsWarning() ? ERRCTX_WARNING : ERRCTX_ERROR;
+        sal_uInt16 nId = nErr.IsWarning() ? ERRCTX_WARNING : ERRCTX_ERROR;
         for (const ErrMsgCode* pItem = RID_ERRCTX; pItem->second; ++pItem)
         {
             if (sal_uInt32(pItem->second) == nId)
@@ -294,7 +284,7 @@ bool SfxErrorContext::GetString(ErrCode nErrId, OUString 
&rStr)
     }
 
     if (bRet)
-        if (auto it = m_extMessages.find(sal_uInt32(nErrId)); it != 
m_extMessages.end())
+        if (auto it = m_extMessages.find(sal_uInt32(nErr.GetCode())); it != 
m_extMessages.end())
             rStr += "\n" + it->second;
 
     return bRet;
diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx
index bc26384e16a0..301ba4748fd1 100644
--- a/sw/inc/docsh.hxx
+++ b/sw/inc/docsh.hxx
@@ -289,7 +289,7 @@ public:
 
     void ToggleLayoutMode(SwView* pView);
 
-    ErrCode LoadStylesFromFile(const OUString& rURL, SwgReaderOption& rOpt, 
bool bUnoCall);
+    ErrCodeMsg LoadStylesFromFile(const OUString& rURL, SwgReaderOption& rOpt, 
bool bUnoCall);
     void InvalidateModel();
     void ReactivateModel();
 
diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx
index f902194c6c00..5a7c6f2a7635 100644
--- a/sw/inc/shellio.hxx
+++ b/sw/inc/shellio.hxx
@@ -169,7 +169,7 @@ public:
     SwReader( css::uno::Reference < css::embed::XStorage > , OUString 
aFilename, SwPaM& );
 
     // The only export interface is SwReader::Read(...)!!!
-    ErrCode Read( const Reader& );
+    ErrCodeMsg Read( const Reader& );
 
     // Ask for glossaries.
     bool HasGlossaries( const Reader& );
@@ -275,7 +275,7 @@ public:
     void setSotStorageRef(const tools::SvRef<SotStorage>& pStgRef) { 
m_pStorage = pStgRef; };
 
 private:
-    virtual ErrCode Read(SwDoc &, const OUString& rBaseURL, SwPaM &, const 
OUString &)=0;
+    virtual ErrCodeMsg Read(SwDoc &, const OUString& rBaseURL, SwPaM &, const 
OUString &)=0;
 
     // Everyone who does not need the streams / storages open
     // has to override the method (W4W!!).
@@ -285,7 +285,7 @@ private:
 class AsciiReader final : public Reader
 {
     friend class SwReader;
-    virtual ErrCode Read( SwDoc &, const OUString& rBaseURL, SwPaM &, const 
OUString &) override;
+    virtual ErrCodeMsg Read( SwDoc &, const OUString& rBaseURL, SwPaM &, const 
OUString &) override;
 public:
     AsciiReader(): Reader() {}
 };
@@ -424,10 +424,10 @@ public:
     Writer();
     virtual ~Writer() override;
 
-    virtual ErrCode Write( SwPaM&, SfxMedium&, const OUString* );
-            ErrCode Write( SwPaM&, SvStream&,  const OUString* );
-    virtual ErrCode Write( SwPaM&, const css::uno::Reference < 
css::embed::XStorage >&, const OUString*, SfxMedium* = nullptr );
-    virtual ErrCode Write( SwPaM&, SotStorage&, const OUString* );
+    virtual ErrCodeMsg Write( SwPaM&, SfxMedium&, const OUString* );
+            ErrCodeMsg Write( SwPaM&, SvStream&,  const OUString* );
+    virtual ErrCodeMsg Write( SwPaM&, const css::uno::Reference < 
css::embed::XStorage >&, const OUString*, SfxMedium* = nullptr );
+    virtual ErrCodeMsg Write( SwPaM&, SotStorage&, const OUString* );
 
     virtual void SetupFilterOptions(SfxMedium& rMedium);
 
@@ -478,8 +478,8 @@ protected:
 
     // Create error at call.
     virtual ErrCode WriteStream() override;
-    virtual ErrCode WriteStorage() = 0;
-    virtual ErrCode WriteMedium( SfxMedium& ) = 0;
+    virtual ErrCodeMsg WriteStorage() = 0;
+    virtual ErrCodeMsg WriteMedium( SfxMedium& ) = 0;
 
     using Writer::Write;
 
@@ -488,8 +488,8 @@ public:
 
     virtual bool IsStgWriter() const override;
 
-    virtual ErrCode Write( SwPaM&, const css::uno::Reference < 
css::embed::XStorage >&, const OUString*, SfxMedium* = nullptr ) override;
-    virtual ErrCode Write( SwPaM&, SotStorage&, const OUString* ) override;
+    virtual ErrCodeMsg Write( SwPaM&, const css::uno::Reference < 
css::embed::XStorage >&, const OUString*, SfxMedium* = nullptr ) override;
+    virtual ErrCodeMsg Write( SwPaM&, SotStorage&, const OUString* ) override;
 
     SotStorage& GetStorage() const       { return *m_pStg; }
 };
@@ -509,7 +509,7 @@ class SW_DLLPUBLIC SwWriter
     bool m_bWriteAll;
 
 public:
-    ErrCode Write( WriterRef const & rxWriter, const OUString* = nullptr);
+    ErrCodeMsg Write( WriterRef const & rxWriter, const OUString* = nullptr);
 
     SwWriter( SvStream&, SwCursorShell &, bool bWriteAll = false );
     SwWriter( SvStream&, SwDoc & );
diff --git a/sw/qa/extras/txtimport/txtimport.cxx 
b/sw/qa/extras/txtimport/txtimport.cxx
index 99cb15b16ad2..410a9311621b 100644
--- a/sw/qa/extras/txtimport/txtimport.cxx
+++ b/sw/qa/extras/txtimport/txtimport.cxx
@@ -38,8 +38,8 @@ public:
         SvMemoryStream aMemoryStream;
 
         SwWriter aWriter(aMemoryStream, rPaM);
-        ErrCode nError = aWriter.Write(rAsciiWriter);
-        CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, nError);
+        ErrCodeMsg nError = aWriter.Write(rAsciiWriter);
+        CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, nError.GetCode());
 
         const char* pData = static_cast<const char*>(aMemoryStream.GetData());
         OString aResult(pData, aMemoryStream.GetSize());
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index 58ebbcde09ff..6d4e90ddad22 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -754,7 +754,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testImportRTF)
     SwReader aReader(aStream, OUString(), OUString(), *pWrtShell->GetCursor());
     Reader* pRTFReader = SwReaderWriter::GetRtfReader();
     CPPUNIT_ASSERT(pRTFReader != nullptr);
-    CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, aReader.Read(*pRTFReader));
+    CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, aReader.Read(*pRTFReader).GetCode());
 
     SwNodeOffset nIndex = pWrtShell->GetCursor()->GetPointNode().GetIndex();
     CPPUNIT_ASSERT_EQUAL(OUString("fooHello world!"), pDoc->GetNodes()[nIndex 
- 1]->GetTextNode()->GetText());
diff --git a/sw/source/core/swg/SwXMLTextBlocks.cxx 
b/sw/source/core/swg/SwXMLTextBlocks.cxx
index 3bb108cbf22e..efc3e530b0f2 100644
--- a/sw/source/core/swg/SwXMLTextBlocks.cxx
+++ b/sw/source/core/swg/SwXMLTextBlocks.cxx
@@ -317,7 +317,7 @@ ErrCode SwXMLTextBlocks::BeginPutDoc( const OUString& 
rShort, const OUString& rL
 
 ErrCode SwXMLTextBlocks::PutBlock()
 {
-    ErrCode nRes = ERRCODE_NONE; // dead variable, this always returns 0
+    ErrCodeMsg nRes = ERRCODE_NONE; // dead variable, this always returns 0
     SwXmlFlags nCommitFlags = m_nFlags;
 
     WriterRef xWrt;
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx 
b/sw/source/core/unocore/unocrsrhelper.cxx
index 935b165bf274..baac20bbf3d5 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -1144,7 +1144,7 @@ void InsertFile(SwUnoCursor* pUnoCursor, const OUString& 
rURL,
     SwNodeIndex aSave(  pUnoCursor->GetPoint()->GetNode(), -1 );
     sal_Int32 nContent = pUnoCursor->GetPoint()->GetContentIndex();
 
-    ErrCode nErrno = pRdr->Read( *pRead );   // and paste the document
+    ErrCodeMsg nErrno = pRdr->Read( *pRead );   // and paste the document
 
     if(!nErrno)
     {
diff --git a/sw/source/core/unocore/unostyle.cxx 
b/sw/source/core/unocore/unostyle.cxx
index 70fc8b712266..3be1ad0e23ec 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -962,7 +962,7 @@ void SwXStyleFamilies::loadStylesFromURL(const OUString& 
rURL,
 
         }
     }
-    const ErrCode nErr = m_pDocShell->LoadStylesFromFile( rURL, aOpt, true );
+    const ErrCodeMsg nErr = m_pDocShell->LoadStylesFromFile( rURL, aOpt, true 
);
     if(nErr)
         throw io::IOException();
 }
diff --git a/sw/source/filter/ascii/parasc.cxx 
b/sw/source/filter/ascii/parasc.cxx
index 1fff4268d8d1..b4e191df621d 100644
--- a/sw/source/filter/ascii/parasc.cxx
+++ b/sw/source/filter/ascii/parasc.cxx
@@ -78,7 +78,7 @@ public:
 }
 
 // Call for the general reader interface
-ErrCode AsciiReader::Read( SwDoc& rDoc, const OUString&, SwPaM &rPam, const 
OUString & )
+ErrCodeMsg AsciiReader::Read( SwDoc& rDoc, const OUString&, SwPaM &rPam, const 
OUString & )
 {
     if( !m_pStream )
     {
diff --git a/sw/source/filter/basflt/shellio.cxx 
b/sw/source/filter/basflt/shellio.cxx
index 66251f168525..888213aa9d5e 100644
--- a/sw/source/filter/basflt/shellio.cxx
+++ b/sw/source/filter/basflt/shellio.cxx
@@ -88,7 +88,7 @@ void SwAsciiOptions::Reset()
     m_bIncludeHidden = !utl::ConfigManager::IsFuzzing() && 
officecfg::Office::Writer::FilterFlags::ASCII::IncludeHiddenText::get();
 }
 
-ErrCode SwReader::Read( const Reader& rOptions )
+ErrCodeMsg SwReader::Read( const Reader& rOptions )
 {
     // copy variables
     Reader* po = const_cast<Reader*>(&rOptions);
@@ -109,7 +109,7 @@ ErrCode SwReader::Read( const Reader& rOptions )
         return ERR_SWG_FILE_FORMAT_ERROR;
     }
 
-    ErrCode nError = ERRCODE_NONE;
+    ErrCodeMsg nError = ERRCODE_NONE;
 
     GetDoc();
 
@@ -742,7 +742,7 @@ static bool isFlyNode(const SwPaM& pam)
            && (pam.GetPoint()->GetNode().IsOLENode() || 
pam.GetPoint()->GetNode().IsGrfNode());
 }
 
-ErrCode SwWriter::Write( WriterRef const & rxWriter, const OUString* 
pRealFileName )
+ErrCodeMsg SwWriter::Write( WriterRef const & rxWriter, const OUString* 
pRealFileName )
 {
     // #i73788#
     SwPauseThreadStarting aPauseThreadStarting;
@@ -867,7 +867,7 @@ ErrCode SwWriter::Write( WriterRef const & rxWriter, const 
OUString* pRealFileNa
     std::unique_ptr<PurgeGuard, o3tl::default_delete<PurgeGuard>> xGuard(new 
PurgeGuard(*pOutDoc));
 
     pOutDoc->SetInWriting(true);
-    ErrCode nError = ERRCODE_NONE;
+    ErrCodeMsg nError = ERRCODE_NONE;
     if( m_pMedium )
         nError = rxWriter->Write( *pPam, *m_pMedium, pRealFileName );
     else if( m_pStrm )
diff --git a/sw/source/filter/docx/swdocxreader.cxx 
b/sw/source/filter/docx/swdocxreader.cxx
index 4ceff14ecd44..d941e60f35cd 100644
--- a/sw/source/filter/docx/swdocxreader.cxx
+++ b/sw/source/filter/docx/swdocxreader.cxx
@@ -45,7 +45,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT Reader* ImportDOCX()
     return new SwDOCXReader;
 }
 
-ErrCode SwDOCXReader::Read(SwDoc& rDoc, const OUString& /* rBaseURL */, SwPaM& 
rPam, const OUString& /* FileName */ )
+ErrCodeMsg SwDOCXReader::Read(SwDoc& rDoc, const OUString& /* rBaseURL */, 
SwPaM& rPam, const OUString& /* FileName */ )
 {
     if (!m_pMedium->GetInStream())
         return ERR_SWG_READ_ERROR;
diff --git a/sw/source/filter/docx/swdocxreader.hxx 
b/sw/source/filter/docx/swdocxreader.hxx
index dc641d13c13d..0a8b8a91c4a0 100644
--- a/sw/source/filter/docx/swdocxreader.hxx
+++ b/sw/source/filter/docx/swdocxreader.hxx
@@ -32,7 +32,7 @@ public:
     virtual bool ReadGlossaries(SwTextBlocks& rBlocks, bool bSaveRelFiles) 
const override;
 
 private:
-    virtual ErrCode Read(SwDoc&, const OUString&, SwPaM&, const OUString&) 
override;
+    virtual ErrCodeMsg Read(SwDoc&, const OUString&, SwPaM&, const OUString&) 
override;
 
     static bool MakeEntries(SwDoc* pD, SwTextBlocks& rBlocks);
 };
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index 4e5138b135e6..5115b7c0ab40 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -203,7 +203,7 @@ bool HTMLReader::SetStrmStgPtr()
 }
 
 // Call for the general Reader-Interface
-ErrCode HTMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPam, 
const OUString & rName )
+ErrCodeMsg HTMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM 
&rPam, const OUString & rName )
 {
     SetupFilterOptions();
 
@@ -228,7 +228,7 @@ ErrCode HTMLReader::Read( SwDoc &rDoc, const OUString& 
rBaseURL, SwPaM &rPam, co
 
     // so nobody steals the document!
     rtl::Reference<SwDoc> xHoldAlive(&rDoc);
-    ErrCode nRet = ERRCODE_NONE;
+    ErrCodeMsg nRet = ERRCODE_NONE;
     tools::SvRef<SwHTMLParser> xParser = new SwHTMLParser( &rDoc, rPam, 
*m_pStream,
                                             rName, rBaseURL, !m_bInsertMode, 
m_pMedium,
                                             IsReadUTF8(),
@@ -244,7 +244,7 @@ ErrCode HTMLReader::Read( SwDoc &rDoc, const OUString& 
rBaseURL, SwPaM &rPam, co
             + "," + 
OUString::number(static_cast<sal_Int32>(xParser->GetLinePos())));
 
         // use the stream as transport for error number
-        nRet = *new StringErrorInfo( ERR_FORMAT_ROWCOL, sErr,
+        nRet = ErrCodeMsg( ERR_FORMAT_ROWCOL, sErr,
                                     DialogMask::ButtonsOk | 
DialogMask::MessageError );
     }
 
diff --git a/sw/source/filter/inc/fltini.hxx b/sw/source/filter/inc/fltini.hxx
index 1c0f1639b8e6..3ee0b3b539a9 100644
--- a/sw/source/filter/inc/fltini.hxx
+++ b/sw/source/filter/inc/fltini.hxx
@@ -42,12 +42,12 @@ class HTMLReader final : public Reader
 
 public:
     HTMLReader();
-    virtual ErrCode Read(SwDoc&, const OUString& rBaseURL, SwPaM&, const 
OUString&) override;
+    virtual ErrCodeMsg Read(SwDoc&, const OUString& rBaseURL, SwPaM&, const 
OUString&) override;
 };
 
 class XMLReader final : public Reader
 {
-    virtual ErrCode Read(SwDoc&, const OUString& rBaseURL, SwPaM&, const 
OUString&) override;
+    virtual ErrCodeMsg Read(SwDoc&, const OUString& rBaseURL, SwPaM&, const 
OUString&) override;
 
 public:
     virtual SwReaderType GetReaderType() override;
diff --git a/sw/source/filter/rtf/swparrtf.cxx 
b/sw/source/filter/rtf/swparrtf.cxx
index 0f0af73b2c95..56dd36530224 100644
--- a/sw/source/filter/rtf/swparrtf.cxx
+++ b/sw/source/filter/rtf/swparrtf.cxx
@@ -45,13 +45,13 @@ namespace
 /// Glue class to call RtfImport as an internal filter, needed by copy&paste 
support.
 class SwRTFReader : public Reader
 {
-    ErrCode Read(SwDoc& rDoc, const OUString& rBaseURL, SwPaM& rPam,
-                 const OUString& rFileName) override;
+    ErrCodeMsg Read(SwDoc& rDoc, const OUString& rBaseURL, SwPaM& rPam,
+                    const OUString& rFileName) override;
 };
 }
 
-ErrCode SwRTFReader::Read(SwDoc& rDoc, const OUString& /*rBaseURL*/, SwPaM& 
rPam,
-                          const OUString& /*rFileName*/)
+ErrCodeMsg SwRTFReader::Read(SwDoc& rDoc, const OUString& /*rBaseURL*/, SwPaM& 
rPam,
+                             const OUString& /*rFileName*/)
 {
     if (!m_pStream)
         return ERR_SWG_READ_ERROR;
diff --git a/sw/source/filter/writer/writer.cxx 
b/sw/source/filter/writer/writer.cxx
index 475da8cc5ab8..5ed18a2cad7c 100644
--- a/sw/source/filter/writer/writer.cxx
+++ b/sw/source/filter/writer/writer.cxx
@@ -201,11 +201,11 @@ void Writer::SetStream(SvStream *const pStream)
     m_pImpl->m_pStream = pStream;
 }
 
-ErrCode Writer::Write( SwPaM& rPaM, SvStream& rStrm, const OUString* pFName )
+ErrCodeMsg Writer::Write( SwPaM& rPaM, SvStream& rStrm, const OUString* pFName 
)
 {
     if ( IsStgWriter() )
     {
-        ErrCode nResult = ERRCODE_ABORT;
+        ErrCodeMsg nResult = ERRCODE_ABORT;
         try
         {
             tools::SvRef<SotStorage> aRef = new SotStorage( rStrm );
@@ -241,7 +241,7 @@ ErrCode Writer::Write( SwPaM& rPaM, SvStream& rStrm, const 
OUString* pFName )
 void Writer::SetupFilterOptions(SfxMedium& /*rMedium*/)
 {}
 
-ErrCode Writer::Write( SwPaM& rPam, SfxMedium& rMedium, const OUString* 
pFileName )
+ErrCodeMsg Writer::Write( SwPaM& rPam, SfxMedium& rMedium, const OUString* 
pFileName )
 {
     SetupFilterOptions(rMedium);
     // This method must be overridden in SwXMLWriter a storage from medium 
will be used there.
@@ -249,13 +249,13 @@ ErrCode Writer::Write( SwPaM& rPam, SfxMedium& rMedium, 
const OUString* pFileNam
     return Write( rPam, *rMedium.GetOutStream(), pFileName );
 }
 
-ErrCode Writer::Write( SwPaM& /*rPam*/, SotStorage&, const OUString* )
+ErrCodeMsg Writer::Write( SwPaM& /*rPam*/, SotStorage&, const OUString* )
 {
     OSL_ENSURE( false, "Write in Storages on a stream?" );
     return ERR_SWG_WRITE_ERROR;
 }
 
-ErrCode Writer::Write( SwPaM&, const uno::Reference < embed::XStorage >&, 
const OUString*, SfxMedium* )
+ErrCodeMsg Writer::Write( SwPaM&, const uno::Reference < embed::XStorage >&, 
const OUString*, SfxMedium* )
 {
     OSL_ENSURE( false, "Write in Storages on a stream?" );
     return ERR_SWG_WRITE_ERROR;
@@ -453,7 +453,7 @@ ErrCode StgWriter::WriteStream()
     return ERR_SWG_WRITE_ERROR;
 }
 
-ErrCode StgWriter::Write( SwPaM& rPaM, SotStorage& rStg, const OUString* 
pFName )
+ErrCodeMsg StgWriter::Write( SwPaM& rPaM, SotStorage& rStg, const OUString* 
pFName )
 {
     SetStream(nullptr);
     m_pStg = &rStg;
@@ -467,7 +467,7 @@ ErrCode StgWriter::Write( SwPaM& rPaM, SotStorage& rStg, 
const OUString* pFName
     // for comparison secure to the current Pam
     m_pOrigPam = &rPaM;
 
-    ErrCode nRet = WriteStorage();
+    ErrCodeMsg nRet = WriteStorage();
 
     m_pStg = nullptr;
     ResetWriter();
@@ -475,7 +475,7 @@ ErrCode StgWriter::Write( SwPaM& rPaM, SotStorage& rStg, 
const OUString* pFName
     return nRet;
 }
 
-ErrCode StgWriter::Write( SwPaM& rPaM, const uno::Reference < embed::XStorage 
>& rStg, const OUString* pFName, SfxMedium* pMedium )
+ErrCodeMsg StgWriter::Write( SwPaM& rPaM, const uno::Reference < 
embed::XStorage >& rStg, const OUString* pFName, SfxMedium* pMedium )
 {
     SetStream(nullptr);
     m_pStg = nullptr;
@@ -490,7 +490,7 @@ ErrCode StgWriter::Write( SwPaM& rPaM, const uno::Reference 
< embed::XStorage >&
     // for comparison secure to the current Pam
     m_pOrigPam = &rPaM;
 
-    ErrCode nRet = pMedium ? WriteMedium( *pMedium ) : WriteStorage();
+    ErrCodeMsg nRet = pMedium ? WriteMedium( *pMedium ) : WriteStorage();
 
     m_pStg = nullptr;
     ResetWriter();
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index fc2beabe9bef..7e31c40af268 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -3789,7 +3789,7 @@ void WW8Export::PrepareStorage()
         sfx2::SaveOlePropertySet( xDocProps, &GetWriter().GetStorage() );
 }
 
-ErrCode SwWW8Writer::WriteStorage()
+ErrCodeMsg SwWW8Writer::WriteStorage()
 {
     tools::SvRef<SotStorage> pOrigStg;
     uno::Reference< packages::XPackageEncryption > xPackageEncryption;
@@ -3923,16 +3923,16 @@ ErrCode SwWW8Writer::WriteStorageImpl()
     return err;
 }
 
-ErrCode SwWW8Writer::WriteMedium( SfxMedium& )
+ErrCodeMsg SwWW8Writer::WriteMedium( SfxMedium& )
 {
     return WriteStorage();
 }
 
-ErrCode SwWW8Writer::Write( SwPaM& rPaM, SfxMedium& rMed,
+ErrCodeMsg SwWW8Writer::Write( SwPaM& rPaM, SfxMedium& rMed,
                           const OUString* pFileName )
 {
     mpMedium = &rMed;
-    ErrCode nRet = StgWriter::Write( rPaM, rMed, pFileName );
+    ErrCodeMsg nRet = StgWriter::Write( rPaM, rMed, pFileName );
     mpMedium = nullptr;
     return nRet;
 }
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index c89dc02d216f..50d772d6b71c 100644
--- a/sw/source/filter/ww8/wrtww8.hxx

... etc. - the rest is truncated

Reply via email to