summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorAugust Sodora <augsod@gmail.com>2012-01-20 15:20:55 -0500
committerAugust Sodora <augsod@gmail.com>2012-01-20 15:21:37 -0500
commit81605eaafa4cd645ca92013120f8da0c753cdf42 (patch)
treedc1509542da6e2c19423c74712470f31a128a95d /basic
parentcce52394e979d02941e7f9f15f6706502a056800 (diff)
Replace BasicErrorManager with std::vector
Diffstat (limited to 'basic')
-rw-r--r--basic/inc/basic/basmgr.hxx13
-rw-r--r--basic/source/basmgr/basicmanagerrepository.cxx9
-rw-r--r--basic/source/basmgr/basmgr.cxx101
3 files changed, 21 insertions, 102 deletions
diff --git a/basic/inc/basic/basmgr.hxx b/basic/inc/basic/basmgr.hxx
index f5ac0aa968c4..04820ad5c8e3 100644
--- a/basic/inc/basic/basmgr.hxx
+++ b/basic/inc/basic/basmgr.hxx
@@ -34,6 +34,7 @@
#include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
#include <com/sun/star/script/XStarBasicAccess.hpp>
#include "basicdllapi.h"
+#include <vector>
// Basic XML Import/Export
BASIC_DLLPUBLIC com::sun::star::uno::Reference< com::sun::star::script::XStarBasicAccess >
@@ -72,12 +73,10 @@ public:
void SetErrorStr( const String& rStr) { aErrStr = rStr; }
};
-
-
class BasicLibs;
class ErrorManager;
class BasicLibInfo;
-class BasicErrorManager;
+
namespace basic { class BasicManagerCleaner; }
// Library password handling for 5.0 documents
@@ -127,7 +126,7 @@ class BASIC_DLLPUBLIC BasicManager : public SfxBroadcaster
private:
BasicLibs* pLibs;
- BasicErrorManager* pErrorMgr;
+ std::vector<BasicError> aErrors;
String aName;
String maStorageName;
@@ -140,7 +139,7 @@ private:
protected:
sal_Bool ImpLoadLibary( BasicLibInfo* pLibInfo ) const;
- sal_Bool ImpLoadLibary( BasicLibInfo* pLibInfo, SotStorage* pCurStorage, sal_Bool bInfosOnly = sal_False ) const;
+ sal_Bool ImpLoadLibary( BasicLibInfo* pLibInfo, SotStorage* pCurStorage, sal_Bool bInfosOnly = sal_False );
void ImpCreateStdLib( StarBASIC* pParentFromStdLib );
void ImpMgrNotLoaded( const String& rStorageName );
BasicLibInfo* CreateLibInfo();
@@ -198,9 +197,7 @@ public:
sal_Bool IsModified() const;
sal_Bool IsBasicModified() const;
- sal_Bool HasErrors();
- BasicError* GetFirstError();
- BasicError* GetNextError();
+ std::vector<BasicError>& GetErrors();
/** sets a global constant in the basic library, referring to some UNO object, to a new value.
diff --git a/basic/source/basmgr/basicmanagerrepository.cxx b/basic/source/basmgr/basicmanagerrepository.cxx
index fa219ad16d5d..8d0c2ebd9eda 100644
--- a/basic/source/basmgr/basicmanagerrepository.cxx
+++ b/basic/source/basmgr/basicmanagerrepository.cxx
@@ -454,21 +454,20 @@ namespace basic
_out_rpBasicManager = new BasicManager( *xDummyStor, String() /* TODO/LATER: xStorage */,
pAppBasic,
&aAppBasicDir, sal_True );
- if ( _out_rpBasicManager->HasErrors() )
+ if ( !_out_rpBasicManager->GetErrors().empty() )
{
// handle errors
- BasicError* pErr = _out_rpBasicManager->GetFirstError();
- while ( pErr )
+ std::vector<BasicError>& aErrors = _out_rpBasicManager->GetErrors();
+ for(std::vector<BasicError>::const_iterator i = aErrors.begin(); i != aErrors.end(); ++i)
{
// show message to user
- if ( ERRCODE_BUTTON_CANCEL == ErrorHandler::HandleError( pErr->GetErrorId() ) )
+ if ( ERRCODE_BUTTON_CANCEL == ErrorHandler::HandleError( i->GetErrorId() ) )
{
// user wants to break loading of BASIC-manager
BasicManagerCleaner::deleteBasicManager( _out_rpBasicManager );
xStorage.clear();
break;
}
- pErr = _out_rpBasicManager->GetNextError();
}
}
}
diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx
index 3e5a0dd698b7..234a1968f593 100644
--- a/basic/source/basmgr/basmgr.cxx
+++ b/basic/source/basmgr/basmgr.cxx
@@ -382,68 +382,6 @@ void SAL_CALL BasMgrContainerListenerImpl::elementRemoved( const ContainerEvent&
}
}
-
-//=====================================================================
-
-class BasicErrorManager
-{
-private:
- BasErrorLst aErrorList;
- size_t CurrentError;
-
-public:
- BasicErrorManager();
- ~BasicErrorManager();
-
- void Reset();
- void InsertError( const BasicError& rError );
-
- bool HasErrors() { return !aErrorList.empty(); }
- BasicError* GetFirstError();
- BasicError* GetNextError();
-};
-
-BasicErrorManager::BasicErrorManager()
- : CurrentError( 0 )
-{
-}
-
-BasicErrorManager::~BasicErrorManager()
-{
- Reset();
-}
-
-void BasicErrorManager::Reset()
-{
- for ( size_t i = 0, n = aErrorList.size(); i < n; ++i )
- delete aErrorList[ i ];
- aErrorList.clear();
-}
-
-void BasicErrorManager::InsertError( const BasicError& rError )
-{
- aErrorList.push_back( new BasicError( rError ) );
-}
-
-BasicError* BasicErrorManager::GetFirstError()
-{
- CurrentError = 0;
- return aErrorList.empty() ? NULL : aErrorList[ CurrentError ];
-}
-
-BasicError* BasicErrorManager::GetNextError()
-{
- if ( !aErrorList.empty()
- && CurrentError < ( aErrorList.size() - 1)
- )
- {
- ++CurrentError;
- return aErrorList[ CurrentError ];
- }
- return NULL;
-}
-
-
BasicError::BasicError( sal_uIntPtr nId, sal_uInt16 nR, const String& rErrStr ) :
aErrStr( rErrStr )
{
@@ -895,7 +833,7 @@ void BasicManager::ImpMgrNotLoaded( const String& rStorageName )
// pErrInf is only destroyed if the error os processed by an
// ErrorHandler
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_MGROPEN, rStorageName, ERRCODE_BUTTON_OK );
- pErrorMgr->InsertError( BasicError( *pErrInf, BASERR_REASON_OPENMGRSTREAM, rStorageName ) );
+ aErrors.push_back(BasicError(*pErrInf, BASERR_REASON_OPENMGRSTREAM, rStorageName));
// Create a stdlib otherwise we crash!
BasicLibInfo* pStdLibInfo = CreateLibInfo();
@@ -918,7 +856,6 @@ void BasicManager::ImpCreateStdLib( StarBASIC* pParentFromStdLib )
pStdLib->SetFlag( SBX_DONTSTORE | SBX_EXTSEARCH );
}
-
void BasicManager::LoadBasicManager( SotStorage& rStorage, const String& rBaseURL, sal_Bool bLoadLibs )
{
DBG_CHKTHIS( BasicManager, 0 );
@@ -1034,7 +971,7 @@ void BasicManager::LoadOldBasicManager( SotStorage& rStorage )
if( !ImplLoadBasic( *xManagerStream, pLibs->GetObject(0)->GetLibRef() ) )
{
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_MGROPEN, aStorName, ERRCODE_BUTTON_OK );
- pErrorMgr->InsertError( BasicError( *pErrInf, BASERR_REASON_OPENMGRSTREAM, aStorName ) );
+ aErrors.push_back(BasicError(*pErrInf, BASERR_REASON_OPENMGRSTREAM, aStorName));
// and it proceeds ...
}
xManagerStream->Seek( nBasicEndOff+1 ); // +1: 0x00 as separator
@@ -1079,7 +1016,7 @@ void BasicManager::LoadOldBasicManager( SotStorage& rStorage )
else
{
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_LIBLOAD, aStorName, ERRCODE_BUTTON_OK );
- pErrorMgr->InsertError( BasicError( *pErrInf, BASERR_REASON_STORAGENOTFOUND, aStorName ) );
+ aErrors.push_back(BasicError(*pErrInf, BASERR_REASON_STORAGENOTFOUND, aStorName));
}
}
}
@@ -1095,7 +1032,6 @@ BasicManager::~BasicManager()
// Destroy Basic-Infos...
// In reverse order
delete pLibs;
- delete pErrorMgr;
delete mpImpl;
}
@@ -1129,7 +1065,6 @@ void BasicManager::Init()
DBG_CHKTHIS( BasicManager, 0 );
bBasMgrModified = sal_False;
- pErrorMgr = new BasicErrorManager;
pLibs = new BasicLibs;
mpImpl = new BasicManagerImpl();
}
@@ -1143,7 +1078,7 @@ BasicLibInfo* BasicManager::CreateLibInfo()
return pInf;
}
-sal_Bool BasicManager::ImpLoadLibary( BasicLibInfo* pLibInfo, SotStorage* pCurStorage, sal_Bool bInfosOnly ) const
+sal_Bool BasicManager::ImpLoadLibary( BasicLibInfo* pLibInfo, SotStorage* pCurStorage, sal_Bool bInfosOnly )
{
DBG_CHKTHIS( BasicManager, 0 );
@@ -1179,7 +1114,7 @@ sal_Bool BasicManager::ImpLoadLibary( BasicLibInfo* pLibInfo, SotStorage* pCurSt
if ( !xBasicStorage.Is() || xBasicStorage->GetError() )
{
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_MGROPEN, xStorage->GetName(), ERRCODE_BUTTON_OK );
- pErrorMgr->InsertError( BasicError( *pErrInf, BASERR_REASON_OPENLIBSTORAGE, pLibInfo->GetLibName() ) );
+ aErrors.push_back(BasicError(*pErrInf, BASERR_REASON_OPENLIBSTORAGE, pLibInfo->GetLibName()));
}
else
{
@@ -1188,7 +1123,7 @@ sal_Bool BasicManager::ImpLoadLibary( BasicLibInfo* pLibInfo, SotStorage* pCurSt
if ( !xBasicStream.Is() || xBasicStream->GetError() )
{
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_LIBLOAD , pLibInfo->GetLibName(), ERRCODE_BUTTON_OK );
- pErrorMgr->InsertError( BasicError( *pErrInf, BASERR_REASON_OPENLIBSTREAM, pLibInfo->GetLibName() ) );
+ aErrors.push_back(BasicError(*pErrInf, BASERR_REASON_OPENLIBSTREAM, pLibInfo->GetLibName()));
}
else
{
@@ -1220,7 +1155,7 @@ sal_Bool BasicManager::ImpLoadLibary( BasicLibInfo* pLibInfo, SotStorage* pCurSt
if ( !bLoaded )
{
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_LIBLOAD, pLibInfo->GetLibName(), ERRCODE_BUTTON_OK );
- pErrorMgr->InsertError( BasicError( *pErrInf, BASERR_REASON_BASICLOADERROR, pLibInfo->GetLibName() ) );
+ aErrors.push_back(BasicError(*pErrInf, BASERR_REASON_BASICLOADERROR, pLibInfo->GetLibName()));
}
else
{
@@ -1402,7 +1337,7 @@ sal_Bool BasicManager::RemoveLib( sal_uInt16 nLib, sal_Bool bDelBasicFromStorage
if ( !pLibInfo || !nLib )
{
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_REMOVELIB, String(), ERRCODE_BUTTON_OK );
- pErrorMgr->InsertError( BasicError( *pErrInf, BASERR_REASON_STDLIB, pLibInfo->GetLibName() ) );
+ aErrors.push_back(BasicError(*pErrInf, BASERR_REASON_STDLIB, pLibInfo->GetLibName()));
return sal_False;
}
@@ -1425,7 +1360,7 @@ sal_Bool BasicManager::RemoveLib( sal_uInt16 nLib, sal_Bool bDelBasicFromStorage
if ( !xBasicStorage.Is() || xBasicStorage->GetError() )
{
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_REMOVELIB, String(), ERRCODE_BUTTON_OK );
- pErrorMgr->InsertError( BasicError( *pErrInf, BASERR_REASON_OPENLIBSTORAGE, pLibInfo->GetLibName() ) );
+ aErrors.push_back(BasicError(*pErrInf, BASERR_REASON_OPENLIBSTORAGE, pLibInfo->GetLibName()));
}
else if ( xBasicStorage->IsStream( pLibInfo->GetLibName() ) )
{
@@ -1594,7 +1529,7 @@ sal_Bool BasicManager::LoadLib( sal_uInt16 nLib )
else
{
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_LIBLOAD, String(), ERRCODE_BUTTON_OK );
- pErrorMgr->InsertError( BasicError( *pErrInf, BASERR_REASON_LIBNOTFOUND, String::CreateFromInt32(nLib) ) );
+ aErrors.push_back(BasicError(*pErrInf, BASERR_REASON_LIBNOTFOUND, String::CreateFromInt32(nLib)));
}
return bDone;
}
@@ -1706,23 +1641,11 @@ sal_Bool BasicManager::IsBasicModified() const
return sal_False;
}
-sal_Bool BasicManager::HasErrors()
-{
- DBG_CHKTHIS( BasicManager, 0 );
- return pErrorMgr->HasErrors();
-}
-
-BasicError* BasicManager::GetFirstError()
+std::vector<BasicError>& BasicManager::GetErrors()
{
- DBG_CHKTHIS( BasicManager, 0 );
- return pErrorMgr->GetFirstError();
+ return aErrors;
}
-BasicError* BasicManager::GetNextError()
-{
- DBG_CHKTHIS( BasicManager, 0 );
- return pErrorMgr->GetNextError();
-}
bool BasicManager::GetGlobalUNOConstant( const sal_Char* _pAsciiName, ::com::sun::star::uno::Any& aOut )
{
bool bRes = false;