1 --- basic/source/runtime/stdobj.cxx.old 2009-04-02 10:49:15.000000000 +0000
2 +++ basic/source/runtime/stdobj.cxx 2009-04-06 16:41:58.000000000 +0000
4 #include <basic/sbstdobj.hxx>
5 #include "rtlproto.hxx"
6 #include "sbintern.hxx"
7 +#include "errobject.hxx"
9 // Das nArgs-Feld eines Tabelleneintrags ist wie folgt verschluesselt:
10 // Zur Zeit wird davon ausgegangen, dass Properties keine Parameter
11 @@ -655,6 +656,11 @@ SbiStdObject::~SbiStdObject()
13 SbxVariable* SbiStdObject::Find( const String& rName, SbxClassType t )
15 + // #TODO #FIXME hack for substituting ooo-basic Err with vba-ish
17 + static String sErr( RTL_CONSTASCII_USTRINGPARAM("Err") );
18 + if ( rName.EqualsIgnoreCaseAscii( sErr ) )
19 + return SbxErrObject::getErrObject();
20 // Bereits eingetragen?
21 SbxVariable* pVar = SbxObject::Find( rName, t );
23 --- basic/source/classes/makefile.mk.old 2009-04-02 10:49:17.000000000 +0000
24 +++ basic/source/classes/makefile.mk 2009-04-06 16:41:58.000000000 +0000
25 @@ -41,6 +41,14 @@ ENABLE_EXCEPTIONS=TRUE
27 .INCLUDE : settings.mk
30 + $(MISC)$/$(TARGET).don \
33 +$(MISC)$/$(TARGET).don : $(SOLARBINDIR)$/oovbaapi.rdb
34 + +$(CPPUMAKER) -O$(OUT)$/inc -BUCR $(SOLARBINDIR)$/oovbaapi.rdb -X$(SOLARBINDIR)$/types.rdb && echo > $@
37 # --- Allgemein -----------------------------------------------------------
40 @@ -50,7 +58,8 @@ COMMON_SLOFILES= \
41 $(SLO)$/sbintern.obj \
42 $(SLO)$/sbunoobj.obj \
46 + $(SLO)$/errobject.obj \
48 SLOFILES= $(COMMON_SLOFILES) \
50 --- basic/source/inc/errobject.hxx.old 1970-01-01 00:00:00.000000000 +0000
51 +++ basic/source/inc/errobject.hxx 2009-04-06 16:41:58.000000000 +0000
53 +#ifndef ERROBJECT_HXX
54 +#define ERROBJECT_HXX
55 +#include "sbunoobj.hxx"
56 +#include <ooo/vba/XErrObject.hpp>
59 +class SbxErrObject : public SbUnoObject
61 + com::sun::star::uno::Reference< ooo::vba::XErrObject > m_xErr;
62 + SbxErrObject( const String& aName_, const com::sun::star::uno::Any& aUnoObj_ );
65 + static SbxVariableRef getErrObject();
66 + static com::sun::star::uno::Reference< ooo::vba::XErrObject > getUnoErrObject();
69 --- basic/source/classes/errobject.cxx.old 1970-01-01 00:00:00.000000000 +0000
70 +++ basic/source/classes/errobject.cxx 2009-04-06 16:41:58.000000000 +0000
72 +// MARKER(update_precomp.py): autogen include statement, do not remove
73 +#include "precompiled_basic.hxx"
74 +#include "errobject.hxx"
76 +#include <cppuhelper/implbase2.hxx>
77 +#include <com/sun/star/script/XDefaultProperty.hpp>
78 +#include "sbintern.hxx"
79 +#include "runtime.hxx"
81 +using namespace ::com::sun::star;
82 +using namespace ::ooo;
84 +typedef ::cppu::WeakImplHelper2< vba::XErrObject, script::XDefaultProperty > ErrObjectImpl_BASE;
86 +class ErrObject : public ErrObjectImpl_BASE
88 + rtl::OUString m_sHelpFile;
89 + rtl::OUString m_sSource;
90 + rtl::OUString m_sDescription;
91 + sal_Int32 m_nNumber;
92 + sal_Int32 m_nHelpContext;
98 + virtual ::sal_Int32 SAL_CALL getNumber() throw (uno::RuntimeException);
99 + virtual void SAL_CALL setNumber( ::sal_Int32 _number ) throw (uno::RuntimeException);
100 + virtual ::sal_Int32 SAL_CALL getHelpContext() throw (uno::RuntimeException);
101 + virtual void SAL_CALL setHelpContext( ::sal_Int32 _helpcontext ) throw (uno::RuntimeException);
102 + virtual ::rtl::OUString SAL_CALL getHelpFile() throw (uno::RuntimeException);
103 + virtual void SAL_CALL setHelpFile( const ::rtl::OUString& _helpfile ) throw (uno::RuntimeException);
104 + virtual ::rtl::OUString SAL_CALL getDescription() throw (uno::RuntimeException);
105 + virtual void SAL_CALL setDescription( const ::rtl::OUString& _description ) throw (uno::RuntimeException);
106 + virtual ::rtl::OUString SAL_CALL getSource() throw (uno::RuntimeException);
107 + virtual void SAL_CALL setSource( const ::rtl::OUString& _source ) throw (uno::RuntimeException);
110 + virtual void SAL_CALL Clear( ) throw (uno::RuntimeException);
111 + 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);
112 + // XDefaultProperty
113 + virtual ::rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (uno::RuntimeException);
117 +ErrObject::~ErrObject()
121 +ErrObject::ErrObject() : m_nNumber(0), m_nHelpContext(0)
126 +ErrObject::getNumber() throw (uno::RuntimeException)
132 +ErrObject::setNumber( ::sal_Int32 _number ) throw (uno::RuntimeException)
134 + m_nNumber = _number;
139 +::sal_Int32 SAL_CALL
140 +ErrObject::getHelpContext() throw (uno::RuntimeException)
142 + return m_nHelpContext;
145 +ErrObject::setHelpContext( ::sal_Int32 _helpcontext ) throw (uno::RuntimeException)
147 + m_nHelpContext = _helpcontext;
150 +::rtl::OUString SAL_CALL
151 +ErrObject::getHelpFile() throw (uno::RuntimeException)
153 + return m_sHelpFile;
157 +ErrObject::setHelpFile( const ::rtl::OUString& _helpfile ) throw (uno::RuntimeException)
159 + m_sHelpFile = _helpfile;
162 +::rtl::OUString SAL_CALL
163 +ErrObject::getDescription() throw (uno::RuntimeException)
165 + return m_sDescription;
169 +ErrObject::setDescription( const ::rtl::OUString& _description ) throw (uno::RuntimeException)
171 + m_sDescription = _description;
174 +::rtl::OUString SAL_CALL
175 +ErrObject::getSource() throw (uno::RuntimeException)
181 +ErrObject::setSource( const ::rtl::OUString& _source ) throw (uno::RuntimeException)
183 + m_sSource = _source;
188 +ErrObject::Clear( ) throw (uno::RuntimeException)
190 + m_sHelpFile = rtl::OUString();
191 + m_sSource = m_sHelpFile;
192 + m_sDescription = m_sSource;
194 + m_nHelpContext = 0;
198 +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)
200 + if ( !Number.hasValue() )
201 + throw uno::RuntimeException( rtl::OUString::createFromAscii("Missing Required Paramater"), uno::Reference< uno::XInterface >() );
202 + Description >>= m_sDescription;
203 + Source >>= m_sSource;
204 + HelpFile >>= m_sHelpFile;
205 + HelpContext >>= m_nHelpContext;
206 + Number >>= m_nNumber;
209 + SbError n = StarBASIC::GetSfxFromVBError( m_nNumber );
211 + n = m_nNumber; // force orig number, probably should have a specific table of vb ( localized ) errors
212 + pINST->Error( n, m_sDescription );
217 +::rtl::OUString SAL_CALL
218 +ErrObject::getDefaultPropertyName( ) throw (uno::RuntimeException)
220 + static rtl::OUString sDfltPropName( RTL_CONSTASCII_USTRINGPARAM("Number") );
221 + return sDfltPropName;
225 +SbxErrObject::SbxErrObject( const String& rName, const Any& rUnoObj ): SbUnoObject( rName, rUnoObj )
227 + OSL_TRACE("SbxErrObject::SbxErrObject ctor");
228 + rUnoObj >>= m_xErr;
230 + SetDfltProperty( uno::Reference< script::XDefaultProperty >( m_xErr, uno::UNO_QUERY_THROW )->getDefaultPropertyName() ) ;
233 +SbxErrObject::~SbxErrObject()
235 + OSL_TRACE("SbxErrObject::~SbxErrObject dtor");
238 +uno::Reference< vba::XErrObject >
239 +SbxErrObject::getUnoErrObject()
241 + SbxVariable* pVar = getErrObject();
242 + SbxErrObject* pGlobErr = static_cast< SbxErrObject* >( pVar );
243 + return pGlobErr->m_xErr;
247 +SbxErrObject::getErrObject()
249 + static SbxVariableRef pGlobErr = new SbxErrObject( String( RTL_CONSTASCII_USTRINGPARAM("Err")), uno::makeAny( uno::Reference< vba::XErrObject >( new ErrObject() ) ) );
253 --- basic/source/runtime/runtime.cxx.old 2009-04-02 10:49:15.000000000 +0000
254 +++ basic/source/runtime/runtime.cxx 2009-04-06 16:41:58.000000000 +0000
256 #include <comphelper/processfactory.hxx>
257 #include <com/sun/star/container/XEnumerationAccess.hpp>
258 #include "sbunoobj.hxx"
259 +#include "errobject.hxx"
261 bool SbiRuntime::isVBAEnabled()
263 @@ -272,6 +273,7 @@ SbiInstance::SbiInstance( StarBASIC* p )
266 bCompatibility = FALSE;
267 + SbxErrObject::getUnoErrObject()->Clear();
270 SbiInstance::~SbiInstance()
271 @@ -792,7 +794,38 @@ BOOL SbiRuntime::Step()
272 void SbiRuntime::Error( SbError n )
277 + if ( isVBAEnabled() )
279 + String aMsg = pInst->GetErrorMsg();
280 + // If a message is defined use that ( in preference to
281 + // the defined one for the error ) NB #TODO
282 + // if there is an error defined it more than likely
283 + // is not the one you want ( some are the same though )
284 + // we really need a new vba compatible error list
287 + StarBASIC::MakeErrorText( n, aMsg );
288 + aMsg = StarBASIC::GetErrorText();
289 + if ( !aMsg.Len() ) // no message for err no.
290 + // need localized resource here
291 + aMsg = String( RTL_CONSTASCII_USTRINGPARAM("Internal Object Error:") );
293 + // no num? most likely then it *is* really a vba err
294 + SbxErrObject::getUnoErrObject()->setNumber( ( StarBASIC::GetVBErrorCode( n ) == 0 ) ? n : StarBASIC::GetVBErrorCode( n ) );
295 + SbxErrObject::getUnoErrObject()->setDescription( aMsg );
297 + // prepend an error number to the message.
298 + String aTmp = '\'';
299 + aTmp += String::CreateFromInt32( SbxErrObject::getUnoErrObject()->getNumber() );
300 + aTmp += String( RTL_CONSTASCII_USTRINGPARAM("\'\n") );
303 + pInst->aErrorMsg = aTmp;
304 + nError = SbERR_BASIC_COMPAT;
309 void SbiRuntime::FatalError( SbError n )
310 --- basic/source/classes/sb.cxx.old 2009-04-02 10:49:17.000000000 +0000
311 +++ basic/source/classes/sb.cxx 2009-04-06 16:41:58.000000000 +0000
312 @@ -199,6 +199,7 @@ const SFX_VB_ErrorItem __FAR_DATA SFX_VB
313 { 1004, SbERR_METHOD_FAILED },
314 { 1005, SbERR_SETPROP_FAILED },
315 { 1006, SbERR_GETPROP_FAILED },
316 + { 1007, SbERR_BASIC_COMPAT },
317 { 0xFFFF, 0xFFFFFFFFL } // End-Marke
320 --- basic/source/classes/sb.src.old 2009-04-02 10:49:17.000000000 +0000
321 +++ basic/source/classes/sb.src 2009-04-06 16:41:58.000000000 +0000
322 @@ -591,6 +591,12 @@ Resource RID_BASIC_START
324 Text [ en-US ] = "For loop not initialized." ;
326 + String ERRCODE_BASIC_COMPAT & ERRCODE_RES_MASK
328 + Text [ de ] = "$(ARG1)." ;
329 + Text [ en-US ] = "$(ARG1)." ;
330 + Text [ x-comment ] = " ";
333 // Hinweis: IDS_SBERR_TERMINATED = IDS_SBERR_START+2000.
334 String IDS_SBERR_TERMINATED
335 --- basic/inc/basic/sberrors.hxx.old 2009-04-02 10:49:18.000000000 +0000
336 +++ basic/inc/basic/sberrors.hxx 2009-04-06 16:41:58.000000000 +0000
337 @@ -290,6 +290,8 @@ typedef ULONG SbError;
338 #define ERRCODE_BASIC_LOOP_NOT_INIT ((LAST_SBX_ERROR_ID+109UL) | ERRCODE_AREA_SBX | \
339 ERRCODE_CLASS_COMPILER) // For loop not initialized
341 +#define ERRCODE_BASIC_COMPAT ((LAST_SBX_ERROR_ID+103UL)| ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME)
343 // Alte Codes auf neue mappen
344 #define SbERR_SYNTAX ERRCODE_BASIC_SYNTAX
345 #define SbERR_NO_GOSUB ERRCODE_BASIC_NO_GOSUB
346 @@ -413,6 +415,7 @@ typedef ULONG SbError;
347 #define SbERR_PROG_TOO_LARGE ERRCODE_BASIC_PROG_TOO_LARGE
348 #define SbERR_NO_STRINGS_ARRAYS ERRCODE_BASIC_NO_STRINGS_ARRAYS
349 #define SbERR_BASIC_EXCEPTION ERRCODE_BASIC_EXCEPTION
350 +#define SbERR_BASIC_COMPAT ERRCODE_BASIC_COMPAT
351 #define SbERR_BASIC_ARRAY_FIX ERRCODE_BASIC_ARRAY_FIX
352 #define SbERR_BASIC_STRING_OVERFLOW ERRCODE_BASIC_STRING_OVERFLOW
353 #define SbERR_BASIC_EXPR_TOO_COMPLEX ERRCODE_BASIC_EXPR_TOO_COMPLEX
354 --- basic/source/runtime/step0.cxx.old 2009-04-02 10:49:15.000000000 +0000
355 +++ basic/source/runtime/step0.cxx 2009-04-06 16:41:58.000000000 +0000
357 #include <vcl/msgbox.hxx>
358 #include <tools/fsys.hxx>
360 +#include "errobject.hxx"
361 #include "runtime.hxx"
362 #include "sbintern.hxx"
364 @@ -1119,6 +1120,7 @@ void SbiRuntime::StepSTDERROR()
368 + SbxErrObject::getUnoErrObject()->Clear();
371 void SbiRuntime::StepNOERROR()
372 @@ -1268,6 +1270,6 @@ void SbiRuntime::StepERROR()
373 SbxVariableRef refCode = PopVar();
374 USHORT n = refCode->GetUShort();
375 SbError error = StarBASIC::GetSfxFromVBError( n );
377 + pInst->Error( error );