1 // MARKER(update_precomp.py): autogen include statement, do not remove
2 #include "precompiled_basic.hxx"
3 #include "errobject.hxx"
5 #include <cppuhelper/implbase2.hxx>
6 #include <com/sun/star/script/XDefaultProperty.hpp>
7 #include "sbintern.hxx"
10 using namespace ::com::sun::star
;
11 using namespace ::ooo
;
13 typedef ::cppu::WeakImplHelper2
< vba::XErrObject
, script::XDefaultProperty
> ErrObjectImpl_BASE
;
15 class ErrObject
: public ErrObjectImpl_BASE
17 rtl::OUString m_sHelpFile
;
18 rtl::OUString m_sSource
;
19 rtl::OUString m_sDescription
;
21 sal_Int32 m_nHelpContext
;
27 virtual ::sal_Int32 SAL_CALL
getNumber() throw (uno::RuntimeException
);
28 virtual void SAL_CALL
setNumber( ::sal_Int32 _number
) throw (uno::RuntimeException
);
29 virtual ::sal_Int32 SAL_CALL
getHelpContext() throw (uno::RuntimeException
);
30 virtual void SAL_CALL
setHelpContext( ::sal_Int32 _helpcontext
) throw (uno::RuntimeException
);
31 virtual ::rtl::OUString SAL_CALL
getHelpFile() throw (uno::RuntimeException
);
32 virtual void SAL_CALL
setHelpFile( const ::rtl::OUString
& _helpfile
) throw (uno::RuntimeException
);
33 virtual ::rtl::OUString SAL_CALL
getDescription() throw (uno::RuntimeException
);
34 virtual void SAL_CALL
setDescription( const ::rtl::OUString
& _description
) throw (uno::RuntimeException
);
35 virtual ::rtl::OUString SAL_CALL
getSource() throw (uno::RuntimeException
);
36 virtual void SAL_CALL
setSource( const ::rtl::OUString
& _source
) throw (uno::RuntimeException
);
39 virtual void SAL_CALL
Clear( ) throw (uno::RuntimeException
);
40 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
);
42 virtual ::rtl::OUString SAL_CALL
getDefaultPropertyName( ) throw (uno::RuntimeException
);
46 ErrObject::~ErrObject()
50 ErrObject::ErrObject() : m_nNumber(0), m_nHelpContext(0)
55 ErrObject::getNumber() throw (uno::RuntimeException
)
61 ErrObject::setNumber( ::sal_Int32 _number
) throw (uno::RuntimeException
)
69 ErrObject::getHelpContext() throw (uno::RuntimeException
)
71 return m_nHelpContext
;
74 ErrObject::setHelpContext( ::sal_Int32 _helpcontext
) throw (uno::RuntimeException
)
76 m_nHelpContext
= _helpcontext
;
79 ::rtl::OUString SAL_CALL
80 ErrObject::getHelpFile() throw (uno::RuntimeException
)
86 ErrObject::setHelpFile( const ::rtl::OUString
& _helpfile
) throw (uno::RuntimeException
)
88 m_sHelpFile
= _helpfile
;
91 ::rtl::OUString SAL_CALL
92 ErrObject::getDescription() throw (uno::RuntimeException
)
94 return m_sDescription
;
98 ErrObject::setDescription( const ::rtl::OUString
& _description
) throw (uno::RuntimeException
)
100 m_sDescription
= _description
;
103 ::rtl::OUString SAL_CALL
104 ErrObject::getSource() throw (uno::RuntimeException
)
110 ErrObject::setSource( const ::rtl::OUString
& _source
) throw (uno::RuntimeException
)
117 ErrObject::Clear( ) throw (uno::RuntimeException
)
119 m_sHelpFile
= rtl::OUString();
120 m_sSource
= m_sHelpFile
;
121 m_sDescription
= m_sSource
;
127 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
)
129 if ( !Number
.hasValue() )
130 throw uno::RuntimeException( rtl::OUString::createFromAscii("Missing Required Paramater"), uno::Reference
< uno::XInterface
>() );
131 Description
>>= m_sDescription
;
132 Source
>>= m_sSource
;
133 HelpFile
>>= m_sHelpFile
;
134 HelpContext
>>= m_nHelpContext
;
135 Number
>>= m_nNumber
;
138 SbError n
= StarBASIC::GetSfxFromVBError( m_nNumber
);
140 n
= m_nNumber
; // force orig number, probably should have a specific table of vb ( localized ) errors
141 pINST
->Error( n
, m_sDescription
);
146 ::rtl::OUString SAL_CALL
147 ErrObject::getDefaultPropertyName( ) throw (uno::RuntimeException
)
149 static rtl::OUString
sDfltPropName( RTL_CONSTASCII_USTRINGPARAM("Number") );
150 return sDfltPropName
;
154 SbxErrObject::SbxErrObject( const String
& rName
, const Any
& rUnoObj
): SbUnoObject( rName
, rUnoObj
)
156 OSL_TRACE("SbxErrObject::SbxErrObject ctor");
159 SetDfltProperty( uno::Reference
< script::XDefaultProperty
>( m_xErr
, uno::UNO_QUERY_THROW
)->getDefaultPropertyName() ) ;
162 SbxErrObject::~SbxErrObject()
164 OSL_TRACE("SbxErrObject::~SbxErrObject dtor");
167 uno::Reference
< vba::XErrObject
>
168 SbxErrObject::getUnoErrObject()
170 SbxVariable
* pVar
= getErrObject();
171 SbxErrObject
* pGlobErr
= static_cast< SbxErrObject
* >( pVar
);
172 return pGlobErr
->m_xErr
;
176 SbxErrObject::getErrObject()
178 static SbxVariableRef pGlobErr
= new SbxErrObject( String( RTL_CONSTASCII_USTRINGPARAM("Err")), uno::makeAny( uno::Reference
< vba::XErrObject
>( new ErrObject() ) ) );