summaryrefslogtreecommitdiff
path: root/basic/source/classes
diff options
context:
space:
mode:
authornpower Developer <npower@openoffice.org>2010-05-07 10:54:26 +0100
committernpower Developer <npower@openoffice.org>2010-05-07 10:54:26 +0100
commit941fd2c887e2837fffa4c41449059dcfeb8442a1 (patch)
tree464361cc2e56fce25047c3e4d52ce7de991d9a79 /basic/source/classes
parent2735f8b116e58aa3ab1c6ddde23a2f985f482332 (diff)
ab75: #i110417# add andreas's improvements and additionally don't clear previous err object data
Diffstat (limited to 'basic/source/classes')
-rw-r--r--basic/source/classes/errobject.cxx59
-rw-r--r--basic/source/classes/sb.cxx43
2 files changed, 50 insertions, 52 deletions
diff --git a/basic/source/classes/errobject.cxx b/basic/source/classes/errobject.cxx
index 3e6b936146..4f661faeaf 100644
--- a/basic/source/classes/errobject.cxx
+++ b/basic/source/classes/errobject.cxx
@@ -43,10 +43,9 @@ class ErrObject : public ErrObjectImpl_BASE
{
rtl::OUString m_sHelpFile;
rtl::OUString m_sSource;
- rtl::OUString m_sDescription;
+ rtl::OUString m_sDescription;
sal_Int32 m_nNumber;
sal_Int32 m_nHelpContext;
- bool mbIsInError;
public:
ErrObject();
@@ -68,6 +67,10 @@ public:
virtual void SAL_CALL Raise( const uno::Any& Number, const uno::Any& Source, const uno::Any& Description, const uno::Any& HelpFile, const uno::Any& HelpContext ) throw (uno::RuntimeException);
// XDefaultProperty
virtual ::rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (uno::RuntimeException);
+
+ // Helper method
+ void setData( const uno::Any& Number, const uno::Any& Source, const uno::Any& Description,
+ const uno::Any& HelpFile, const uno::Any& HelpContext ) throw (uno::RuntimeException);
};
@@ -75,7 +78,7 @@ ErrObject::~ErrObject()
{
}
-ErrObject::ErrObject() : m_nNumber(0), m_nHelpContext(0), mbIsInError(false)
+ErrObject::ErrObject() : m_nNumber(0), m_nHelpContext(0)
{
}
@@ -88,9 +91,9 @@ ErrObject::getNumber() throw (uno::RuntimeException)
void SAL_CALL
ErrObject::setNumber( ::sal_Int32 _number ) throw (uno::RuntimeException)
{
-// m_nNumber = _number;
- if ( !mbIsInError )
- Raise( uno::makeAny( _number ), uno::Any(), uno::Any(), uno::Any(), uno::Any() );
+ pINST->setErrorVB( _number, String() );
+ ::rtl::OUString _description = pINST->GetErrorMsg();
+ setData( uno::makeAny( _number ), uno::Any(), uno::makeAny( _description ), uno::Any(), uno::Any() );
}
::sal_Int32 SAL_CALL
@@ -154,23 +157,9 @@ ErrObject::Clear( ) throw (uno::RuntimeException)
void SAL_CALL
ErrObject::Raise( const uno::Any& Number, const uno::Any& Source, const uno::Any& Description, const uno::Any& HelpFile, const uno::Any& HelpContext ) throw (uno::RuntimeException)
{
- if ( !Number.hasValue() )
- throw uno::RuntimeException( rtl::OUString::createFromAscii("Missing Required Paramater"), uno::Reference< uno::XInterface >() );
- mbIsInError = true;
- Clear();
- Description >>= m_sDescription;
- Source >>= m_sSource;
- HelpFile >>= m_sHelpFile;
- HelpContext >>= m_nHelpContext;
- Number >>= m_nNumber;
+ setData( Number, Source, Description, HelpFile, HelpContext );
if ( m_nNumber )
- {
- SbError n = StarBASIC::GetSfxFromVBError( m_nNumber );
- if ( !n )
- n = m_nNumber; // force orig number, probably should have a specific table of vb ( localized ) errors
- pINST->Error( n, m_sDescription );
- }
- mbIsInError = false;
+ pINST->ErrorVB( m_nNumber, m_sDescription );
}
// XDefaultProperty
@@ -181,13 +170,30 @@ ErrObject::getDefaultPropertyName( ) throw (uno::RuntimeException)
return sDfltPropName;
}
+void ErrObject::setData( const uno::Any& Number, const uno::Any& Source, const uno::Any& Description, const uno::Any& HelpFile, const uno::Any& HelpContext )
+ throw (uno::RuntimeException)
+{
+ if ( !Number.hasValue() )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii("Missing Required Paramater"), uno::Reference< uno::XInterface >() );
+ Number >>= m_nNumber;
+ Description >>= m_sDescription;
+ Source >>= m_sSource;
+ HelpFile >>= m_sHelpFile;
+ HelpContext >>= m_nHelpContext;
+}
+
// SbxErrObject
-SbxErrObject::SbxErrObject( const String& rName, const Any& rUnoObj ): SbUnoObject( rName, rUnoObj )
+SbxErrObject::SbxErrObject( const String& rName, const Any& rUnoObj )
+ : SbUnoObject( rName, rUnoObj )
+ , m_pErrObject( NULL )
{
OSL_TRACE("SbxErrObject::SbxErrObject ctor");
rUnoObj >>= m_xErr;
if ( m_xErr.is() )
+ {
SetDfltProperty( uno::Reference< script::XDefaultProperty >( m_xErr, uno::UNO_QUERY_THROW )->getDefaultPropertyName() ) ;
+ m_pErrObject = static_cast< ErrObject* >( m_xErr.get() );
+ }
}
SbxErrObject::~SbxErrObject()
@@ -210,3 +216,10 @@ SbxErrObject::getErrObject()
return pGlobErr;
}
+void SbxErrObject::setNumberAndDescription( ::sal_Int32 _number, const ::rtl::OUString& _description )
+ throw (uno::RuntimeException)
+{
+ if( m_pErrObject != NULL )
+ m_pErrObject->setData( uno::makeAny( _number ), uno::Any(), uno::makeAny( _description ), uno::Any(), uno::Any() );
+}
+
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx
index 519d738b2d..3ddc811964 100644
--- a/basic/source/classes/sb.cxx
+++ b/basic/source/classes/sb.cxx
@@ -1358,22 +1358,7 @@ BOOL StarBASIC::CError
// Umsetzung des Codes fuer String-Transport in SFX-Error
if( rMsg.Len() )
- {
- // very confusing, even though MakeErrorText sets up the error text
- // seems that this is not used ( if rMsg already has content )
- // In the case of VBA MakeErrorText also formats the error to be alittle more
- // like vba ( adds an error number etc )
- if ( SbiRuntime::isVBAEnabled() && ( code == SbERR_BASIC_COMPAT ) )
- {
- String aTmp = '\'';
- aTmp += String::CreateFromInt32( SbxErrObject::getUnoErrObject()->getNumber() );
- aTmp += String( RTL_CONSTASCII_USTRINGPARAM("\'\n") );
- aTmp += GetSbData()->aErrMsg.Len() ? GetSbData()->aErrMsg : rMsg;
- code = (ULONG)*new StringErrorInfo( code, aTmp );
- }
- else
code = (ULONG)*new StringErrorInfo( code, String(rMsg) );
- }
SetErrorData( code, l, c1, c2 );
GetSbData()->bCompiler = TRUE;
@@ -1403,22 +1388,22 @@ BOOL StarBASIC::RTError( SbError code, const String& rMsg, USHORT l, USHORT c1,
// Umsetzung des Codes fuer String-Transport in SFX-Error
if( rMsg.Len() )
+ {
+ // very confusing, even though MakeErrorText sets up the error text
+ // seems that this is not used ( if rMsg already has content )
+ // In the case of VBA MakeErrorText also formats the error to be alittle more
+ // like vba ( adds an error number etc )
+ if ( SbiRuntime::isVBAEnabled() && ( code == SbERR_BASIC_COMPAT ) )
{
- // very confusing, even though MakeErrorText sets up the error text
- // seems that this is not used ( if rMsg already has content )
- // In the case of VBA MakeErrorText also formats the error to be alittle more
- // like vba ( adds an error number etc )
- if ( SbiRuntime::isVBAEnabled() && ( code == SbERR_BASIC_COMPAT ) )
- {
- String aTmp = '\'';
- aTmp += String::CreateFromInt32( SbxErrObject::getUnoErrObject()->getNumber() );
- aTmp += String( RTL_CONSTASCII_USTRINGPARAM("\'\n") );
- aTmp += GetSbData()->aErrMsg.Len() ? GetSbData()->aErrMsg : rMsg;
- code = (ULONG)*new StringErrorInfo( code, aTmp );
- }
- else
- code = (ULONG)*new StringErrorInfo( code, String(rMsg) );
+ String aTmp = '\'';
+ aTmp += String::CreateFromInt32( SbxErrObject::getUnoErrObject()->getNumber() );
+ aTmp += String( RTL_CONSTASCII_USTRINGPARAM("\'\n") );
+ aTmp += GetSbData()->aErrMsg.Len() ? GetSbData()->aErrMsg : rMsg;
+ code = (ULONG)*new StringErrorInfo( code, aTmp );
}
+ else
+ code = (ULONG)*new StringErrorInfo( code, String(rMsg) );
+ }
SetErrorData( code, l, c1, c2 );
if( GetSbData()->aErrHdl.IsSet() )