diff options
Diffstat (limited to 'basic/source/inc')
28 files changed, 4675 insertions, 0 deletions
diff --git a/basic/source/inc/buffer.hxx b/basic/source/inc/buffer.hxx new file mode 100644 index 000000000000..24c4bc002f60 --- /dev/null +++ b/basic/source/inc/buffer.hxx @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _BUFFER_HXX +#define _BUFFER_HXX + +#include <tools/solar.h> +#include <tools/string.hxx> + +class SbiParser; + +class SbiBuffer { // Code/Konstanten-Puffer: + SbiParser* pParser; // fuer Fehlermeldungen + char* pBuf; // Puffer-Pointer + char* pCur; // aktueller Puffer-Pointer + sal_uInt32 nOff; // aktuelles Offset + sal_uInt32 nSize; // aktuelle Groesse + short nInc; // Inkrement + sal_Bool Check( sal_uInt16 ); // Buffergroesse testen +public: + SbiBuffer( SbiParser*, short ); // Inkrement + ~SbiBuffer(); + void Patch( sal_uInt32, sal_uInt32 ); // Patchen + void Chain( sal_uInt32 ); // Back-Chain + void Align( sal_Int32 ); // Alignment + sal_Bool Add( const void*, sal_uInt16 );// Element anfuegen + sal_Bool operator += (const String&);// Basic-String speichern + sal_Bool operator += (sal_Int8); // Zeichen speichern + sal_Bool operator += (sal_Int16); // Integer speichern + sal_Bool operator += (sal_uInt8); // Zeichen speichern + sal_Bool operator += (sal_uInt16); // Integer speichern + sal_Bool operator += (sal_uInt32); // Integer speichern + sal_Bool operator += (sal_Int32); // Integer speichern + char* GetBuffer(); // Puffer rausgeben (selbst loeschen!) + char* GetBufferPtr(){ return pBuf; } + sal_uInt32 GetSize() { return nOff; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/codegen.hxx b/basic/source/inc/codegen.hxx new file mode 100644 index 000000000000..21d19312fd17 --- /dev/null +++ b/basic/source/inc/codegen.hxx @@ -0,0 +1,95 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CODEGEN_HXX +#define _CODEGEN_HXX + +class SbiImage; +class SbiParser; +class SbModule; +#include "opcodes.hxx" +#include "buffer.hxx" + +class SbiCodeGen { // Code-Erzeugung: + SbiParser* pParser; // fuer Fehlermeldungen, Line, Column etc. + SbModule& rMod; // aktuelles Modul + SbiBuffer aCode; // Code-Puffer + short nLine, nCol; // Zeile, Spalte fuer Stmnt-Befehl + short nForLevel; // #29955 for-Schleifen-Ebene + sal_Bool bStmnt; // sal_True: Statement-Opcode liegt an +public: + SbiCodeGen( SbModule&, SbiParser*, short ); + SbiParser* GetParser() { return pParser; } + SbModule& GetModule() { return rMod; } + sal_uInt32 Gen( SbiOpcode ); + sal_uInt32 Gen( SbiOpcode, sal_uInt32 ); + sal_uInt32 Gen( SbiOpcode, sal_uInt32, sal_uInt32 ); + void Patch( sal_uInt32 o, sal_uInt32 v ){ aCode.Patch( o, v ); } + void BackChain( sal_uInt32 off ) { aCode.Chain( off ); } + void Statement(); + void GenStmnt(); // evtl. Statement-Opcode erzeugen + sal_uInt32 GetPC(); + sal_uInt32 GetOffset() { return GetPC() + 1; } + void Save(); + + // #29955 for-Schleifen-Ebene pflegen + void IncForLevel( void ) { nForLevel++; } + void DecForLevel( void ) { nForLevel--; } + + static sal_uInt32 calcNewOffSet( sal_uInt8* pCode, sal_uInt16 nOffset ); + static sal_uInt16 calcLegacyOffSet( sal_uInt8* pCode, sal_uInt32 nOffset ); + +}; + +template < class T, class S > +class PCodeBuffConvertor +{ + T m_nSize; // + sal_uInt8* m_pStart; + sal_uInt8* m_pCnvtdBuf; + S m_nCnvtdSize; // + + // Disable usual copying symantics and bodgy default ctor + PCodeBuffConvertor(); + PCodeBuffConvertor(const PCodeBuffConvertor& ); + PCodeBuffConvertor& operator = ( const PCodeBuffConvertor& ); +public: + PCodeBuffConvertor( sal_uInt8* pCode, T nSize ): m_nSize( nSize ), m_pStart( pCode ), m_pCnvtdBuf( NULL ), m_nCnvtdSize( 0 ){ convert(); } + S GetSize(){ return m_nCnvtdSize; } + void convert(); + // Caller owns the buffer returned + sal_uInt8* GetBuffer() { return m_pCnvtdBuf; } +}; + +// #111897 PARAM_INFO flags start at 0x00010000 to not +// conflict with DefaultId in SbxParamInfo::nUserData +#define PARAM_INFO_PARAMARRAY 0x0010000 + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/collelem.hxx b/basic/source/inc/collelem.hxx new file mode 100644 index 000000000000..2c39e711f993 --- /dev/null +++ b/basic/source/inc/collelem.hxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SAMPLE_COLLELEM_HXX +#define _SAMPLE_COLLELEM_HXX + +#include <basic/sbxobj.hxx> + +// Das Sample-Element ist ein kleines Objekt, das die Properties +// Name und Value enth„lt sowie die Methode Say, die den bergebenen +// Text mit dem eigenen Namen verkoppelt. Der Name ist von aussen setzbar. +// Die Implementation arbeitet ausschliesslich mit dynamischen Elementen. + +class SampleElement : public SbxObject +{ + // Broadcaster Notification + virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, + const SfxHint& rHint, const TypeId& rHintType ); +public: + SampleElement( const String& ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/disas.hxx b/basic/source/inc/disas.hxx new file mode 100644 index 000000000000..1756d36bfacf --- /dev/null +++ b/basic/source/inc/disas.hxx @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DISAS_HXX +#define _DISAS_HXX + +#include "image.hxx" +#include "opcodes.hxx" +// find a place for this limit ( also used in +class SvStream; +#define MAX_LABELS 0x2000L +class SbiDisas { + const SbiImage& rImg; + SbModule* pMod; + char cLabels[ MAX_LABELS ]; // Bitvektor fuer Labels + sal_uInt32 nOff; // aktuelle Position + sal_uInt32 nPC; // Position des Opcodes + SbiOpcode eOp; // Opcode + sal_uInt32 nOp1, nOp2; // Operanden + sal_uInt32 nParts; // 1, 2 oder 3 + sal_uInt32 nLine; // aktuelle Zeile + sal_Bool DisasLine( String& ); + sal_Bool Fetch(); // naechster Opcode +public: + SbiDisas( SbModule*, const SbiImage* ); + void Disas( SvStream& ); + void Disas( String& ); + // NICHT AUFRUFEN + void StrOp( String& ); + void Str2Op( String& ); + void ImmOp( String& ); + void OnOp( String& ); + void LblOp( String& ); + void ReturnOp( String& ); + void ResumeOp( String& ); + void PromptOp( String& ); + void CloseOp( String& ); + void CharOp( String& ); + void VarOp( String& ); + void VarDefOp( String& ); + void OffOp( String& ); + void TypeOp( String& ); + void CaseOp( String& ); + void StmntOp( String& ); + void StrmOp( String& ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/dlgcont.hxx b/basic/source/inc/dlgcont.hxx new file mode 100644 index 000000000000..94c10ca86b2e --- /dev/null +++ b/basic/source/inc/dlgcont.hxx @@ -0,0 +1,177 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef BASIC_DIALOGCONTAINER_HXX +#define BASIC_DIALOGCONTAINER_HXX + +#include "namecont.hxx" + +#include <com/sun/star/resource/XStringResourceSupplier.hpp> +#include "com/sun/star/resource/XStringResourcePersistence.hpp" + +#include <cppuhelper/implbase1.hxx> +#include <comphelper/uno3.hxx> + +namespace basic +{ + +//============================================================================ + +class SfxDialogLibraryContainer : public SfxLibraryContainer +{ + // Methods to distinguish between different library types + virtual SfxLibrary* SAL_CALL implCreateLibrary( const ::rtl::OUString& aName ); + virtual SfxLibrary* SAL_CALL implCreateLibraryLink + ( const ::rtl::OUString& aName, const ::rtl::OUString& aLibInfoFileURL, + const ::rtl::OUString& StorageURL, sal_Bool ReadOnly ); + virtual ::com::sun::star::uno::Any SAL_CALL createEmptyLibraryElement( void ); + virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const; + virtual void SAL_CALL writeLibraryElement + ( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary, + const ::rtl::OUString& aElementName, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutput + ) + throw(::com::sun::star::uno::Exception); + + virtual ::com::sun::star::uno::Any SAL_CALL importLibraryElement + ( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary, + const ::rtl::OUString& aElementName, + const ::rtl::OUString& aFile, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xElementStream ); + + virtual void SAL_CALL importFromOldStorage( const ::rtl::OUString& aFile ); + + virtual SfxLibraryContainer* createInstanceImpl( void ); + + virtual void onNewRootStorage(); + + virtual const sal_Char* SAL_CALL getInfoFileName() const; + virtual const sal_Char* SAL_CALL getOldInfoFileName() const; + virtual const sal_Char* SAL_CALL getLibElementFileExtension() const; + virtual const sal_Char* SAL_CALL getLibrariesDir() const; + +public: + SfxDialogLibraryContainer( void ); + SfxDialogLibraryContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ); + + // Methods XStorageBasedLibraryContainer + virtual void SAL_CALL storeLibrariesToStorage( + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& RootStorage ) + throw (::com::sun::star::uno::RuntimeException); + + // Resource handling + ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourcePersistence > + implCreateStringResource( class SfxDialogLibrary* pDialog ); + + // Methods XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) + throw (::com::sun::star::uno::RuntimeException); + // XLibraryQueryExecutable + virtual sal_Bool SAL_CALL HasExecutableCode(const rtl::OUString&) + throw (::com::sun::star::uno::RuntimeException); + // Service + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static(); + static ::rtl::OUString getImplementationName_static(); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Create + ( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xServiceManager ) + throw( ::com::sun::star::uno::Exception ); +}; + +//============================================================================ + +typedef ::cppu::ImplHelper1 < ::com::sun::star::resource::XStringResourceSupplier + > SfxDialogLibrary_BASE; + +class SfxDialogLibrary :public SfxLibrary + ,public SfxDialogLibrary_BASE +{ + SfxDialogLibraryContainer* m_pParent; + ::com::sun::star::uno::Reference + < ::com::sun::star::resource::XStringResourcePersistence> m_xStringResourcePersistence; + ::rtl::OUString m_aName; + + // Provide modify state including resources + virtual sal_Bool isModified( void ); + virtual void storeResources( void ); + virtual void storeResourcesAsURL( const ::rtl::OUString& URL, const ::rtl::OUString& NewName ); + virtual void storeResourcesToURL( const ::rtl::OUString& URL, + const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ); + virtual void storeResourcesToStorage( const ::com::sun::star::uno::Reference + < ::com::sun::star::embed::XStorage >& xStorage ); + +public: + SfxDialogLibrary + ( + ModifiableHelper& _rModifiable, + const ::rtl::OUString& aName, + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSF, + const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >& xSFI, + SfxDialogLibraryContainer* pParent + ); + + SfxDialogLibrary + ( + ModifiableHelper& _rModifiable, + const ::rtl::OUString& aName, + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSF, + const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >& xSFI, + const ::rtl::OUString& aLibInfoFileURL, const ::rtl::OUString& aStorageURL, sal_Bool ReadOnly, + SfxDialogLibraryContainer* pParent + ); + + DECLARE_XINTERFACE() + DECLARE_XTYPEPROVIDER() + + // XStringResourceSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceResolver > + SAL_CALL getStringResource( ) throw (::com::sun::star::uno::RuntimeException); + + ::rtl::OUString getName( void ) + { return m_aName; } + + ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourcePersistence > + getStringResourcePersistence( void ) + { + return m_xStringResourcePersistence; + } + + static bool containsValidDialog( const ::com::sun::star::uno::Any& aElement ); + +protected: + virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const; +}; + +} // namespace basic + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/errobject.hxx b/basic/source/inc/errobject.hxx new file mode 100644 index 000000000000..1e94a3927e93 --- /dev/null +++ b/basic/source/inc/errobject.hxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef ERROBJECT_HXX +#define ERROBJECT_HXX +#include "sbunoobj.hxx" +#include <ooo/vba/XErrObject.hpp> + + +class SbxErrObject : public SbUnoObject +{ + class ErrObject* m_pErrObject; + com::sun::star::uno::Reference< ooo::vba::XErrObject > m_xErr; + + SbxErrObject( const String& aName_, const com::sun::star::uno::Any& aUnoObj_ ); + ~SbxErrObject(); + + class ErrObject* getImplErrObject( void ) + { return m_pErrObject; } + +public: + static SbxVariableRef getErrObject(); + static com::sun::star::uno::Reference< ooo::vba::XErrObject > getUnoErrObject(); + + void setNumberAndDescription( ::sal_Int32 _number, const ::rtl::OUString& _description ) + throw (com::sun::star::uno::RuntimeException); +}; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/expr.hxx b/basic/source/inc/expr.hxx new file mode 100644 index 000000000000..0ae218d14c18 --- /dev/null +++ b/basic/source/inc/expr.hxx @@ -0,0 +1,275 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _EXPR_HXX +#define _EXPR_HXX + +#include "opcodes.hxx" +#include "token.hxx" + +class SbiExprNode; +class SbiExpression; +class SbiExprList; +class SbiDimList; +class SbiParameters; +class SbiParser; +class SbiCodeGen; +class SbiSymDef; +class SbiProcDef; + + +#include <vector> +typedef ::std::vector<SbiExprList*> SbiExprListVector; + +struct SbVar { // Variablen-Element: + SbiExprNode* pNext; // Weiteres Element (bei Strukturen) + SbiSymDef* pDef; // Symboldefinition + SbiExprList* pPar; // optionale Parameter (wird geloescht) + SbiExprListVector* pvMorePar; // Array of arrays foo(pPar)(avMorePar[0])(avMorePar[1])... +}; + +struct KeywordSymbolInfo +{ + String m_aKeywordSymbol; + SbxDataType m_eSbxDataType; + SbiToken m_eTok; +}; + +enum SbiExprType { // Expression-Typen: + SbSTDEXPR, // normaler Ausdruck + SbLVALUE, // beliebiger lValue + SbSYMBOL, // beliebiges zusammengesetztes Symbol + SbOPERAND // Variable/Funktion +}; + +enum SbiExprMode { // Expression context: + EXPRMODE_STANDARD, // default + EXPRMODE_STANDALONE, // a param1, param2 OR a( param1, param2 ) = 42 + EXPRMODE_LPAREN_PENDING, // start of parameter list with bracket, special handling + EXPRMODE_LPAREN_NOT_NEEDED, // pending LPAREN has not been used + EXPRMODE_ARRAY_OR_OBJECT, // '=' or '(' or '.' found after ')' on ParenLevel 0, stopping + // expression, assuming array syntax a(...)[(...)] = ? + // or a(...).b(...) + EXPRMODE_EMPTY_PAREN // It turned out that the paren don't contain anything: a() +}; + +enum SbiNodeType { + SbxNUMVAL, // nVal = Wert + SbxSTRVAL, // aStrVal = Wert, before #i59791/#i45570: nStringId = Wert + SbxVARVAL, // aVar = Wert + SbxTYPEOF, // TypeOf ObjExpr Is Type + SbxNODE, // Node + SbxNEW, // new <type> expression + SbxDUMMY +}; + +enum RecursiveMode +{ + UNDEFINED, + FORCE_CALL, + PREVENT_CALL +}; + +class SbiExprNode { // Operatoren (und Operanden) + friend class SbiExpression; + friend class SbiConstExpression; + union { + sal_uInt16 nTypeStrId; // gepoolter String-ID, #i59791/#i45570 Now only for TypeOf + double nVal; // numerischer Wert + SbVar aVar; // oder Variable + }; + String aStrVal; // #i59791/#i45570 Store string directly + SbiExprNode* pLeft; // linker Zweig + SbiExprNode* pRight; // rechter Zweig (NULL bei unaeren Ops) + SbiExprNode* pWithParent; // Knoten, dessen Member this per with ist + SbiCodeGen* pGen; // Code-Generator + SbiNodeType eNodeType; // Art des Nodes + SbxDataType eType; // aktueller Datentyp + SbiToken eTok; // Token des Operators + sal_Bool bComposite; // sal_True: Zusammengesetzter Ausdruck + sal_Bool bError; // sal_True: Fehlerhaft + void FoldConstants(); // Constant Folding durchfuehren + void CollectBits(); // Umwandeln von Zahlen in Strings + sal_Bool IsOperand() // sal_True, wenn Operand + { return sal_Bool( eNodeType != SbxNODE && eNodeType != SbxTYPEOF && eNodeType != SbxNEW ); } + sal_Bool IsTypeOf() + { return sal_Bool( eNodeType == SbxTYPEOF ); } + sal_Bool IsNew() + { return sal_Bool( eNodeType == SbxNEW ); } + sal_Bool IsNumber(); // sal_True bei Zahlen + sal_Bool IsString(); // sal_True bei Strings + sal_Bool IsLvalue(); // sal_True, falls als Lvalue verwendbar + void GenElement( SbiOpcode ); // Element + void BaseInit( SbiParser* p ); // Hilfsfunktion fuer Ctor, AB 17.12.95 +public: + SbiExprNode( void ); + SbiExprNode( SbiParser*, double, SbxDataType ); + SbiExprNode( SbiParser*, const String& ); + SbiExprNode( SbiParser*, const SbiSymDef&, SbxDataType, SbiExprList* = NULL ); + SbiExprNode( SbiParser*, SbiExprNode*, SbiToken, SbiExprNode* ); + SbiExprNode( SbiParser*, SbiExprNode*, sal_uInt16 ); // #120061 TypeOf + SbiExprNode( SbiParser*, sal_uInt16 ); // new <type> + virtual ~SbiExprNode(); + + sal_Bool IsValid() { return sal_Bool( !bError ); } + sal_Bool IsConstant() // sal_True bei konstantem Operanden + { return sal_Bool( eNodeType == SbxSTRVAL || eNodeType == SbxNUMVAL ); } + sal_Bool IsIntConst(); // sal_True bei Integer-Konstanten + sal_Bool IsVariable(); // sal_True, wenn Variable + + SbiExprNode* GetWithParent() { return pWithParent; } + void SetWithParent( SbiExprNode* p ) { pWithParent = p; } + + SbxDataType GetType() { return eType; } + void SetType( SbxDataType eTp ) { eType = eTp; } + SbiNodeType GetNodeType() { return eNodeType; } + SbiSymDef* GetVar(); // Variable (falls vorhanden) + SbiSymDef* GetRealVar(); // letzte Variable in x.y.z + SbiExprNode* GetRealNode(); // letzter Knoten in x.y.z + short GetDepth(); // Tiefe eines Baumes berechnen + const String& GetString() { return aStrVal; } + short GetNumber() { return (short)nVal; } + SbiExprList* GetParameters() { return aVar.pPar; } + SbiExprListVector* GetMoreParameters() { return aVar.pvMorePar; } + + void Optimize(); // Baumabgleich + + void Gen( RecursiveMode eRecMode = UNDEFINED ); // Ausgabe eines Nodes +}; + +class SbiExpression { // der Ausdruck: + friend class SbiExprList; + friend class SbiParameters; + friend class SbiDimList; +protected: + String aArgName; // Name fuer bananntes Argument + SbiParser* pParser; // fuer Fehlermeldungen, Parsing + SbiExpression* pNext; // Link bei Parameterlisten + SbiExprNode* pExpr; // Der Expression-Baum + SbiExprType eCurExpr; // Art des Ausdrucks + SbiExprMode m_eMode; // Expression context + sal_Bool bBased; // sal_True: einfacher DIM-Teil (+BASE) + sal_Bool bError; // sal_True: Fehler + sal_Bool bByVal; // sal_True: ByVal-Parameter + sal_Bool bBracket; // sal_True: Parameter list with brackets + sal_uInt16 nParenLevel; + SbiExprNode* Term( const KeywordSymbolInfo* pKeywordSymbolInfo = NULL ); + SbiExprNode* ObjTerm( SbiSymDef& ); + SbiExprNode* Operand( bool bUsedForTypeOf = false ); + SbiExprNode* Unary(); + SbiExprNode* Exp(); + SbiExprNode* MulDiv(); + SbiExprNode* IntDiv(); + SbiExprNode* Mod(); + SbiExprNode* AddSub(); + SbiExprNode* Cat(); + SbiExprNode* Like(); + SbiExprNode* VBA_Not(); + SbiExprNode* VBA_And(); + SbiExprNode* VBA_Or(); + SbiExprNode* VBA_Xor(); + SbiExprNode* VBA_Eqv(); + SbiExprNode* VBA_Imp(); + SbiExprNode* Comp(); + SbiExprNode* Boolean(); +public: + SbiExpression( SbiParser*, SbiExprType = SbSTDEXPR, + SbiExprMode eMode = EXPRMODE_STANDARD, const KeywordSymbolInfo* pKeywordSymbolInfo = NULL ); // Parsender Ctor + SbiExpression( SbiParser*, const String& ); + SbiExpression( SbiParser*, double, SbxDataType = SbxDOUBLE ); + SbiExpression( SbiParser*, const SbiSymDef&, SbiExprList* = NULL ); + SbiExpression( SbiParser*, SbiToken ); // Spezial-Expr mit Spezial-Tokens + ~SbiExpression(); + String& GetName() { return aArgName; } + void SetBased() { bBased = sal_True; } + sal_Bool IsBased() { return bBased; } + void SetByVal() { bByVal = sal_True; } + sal_Bool IsByVal() { return bByVal; } + sal_Bool IsBracket() { return bBracket; } + sal_Bool IsValid() { return pExpr->IsValid(); } + sal_Bool IsConstant() { return pExpr->IsConstant(); } + sal_Bool IsVariable() { return pExpr->IsVariable(); } + sal_Bool IsLvalue() { return pExpr->IsLvalue(); } + sal_Bool IsIntConstant() { return pExpr->IsIntConst(); } + const String& GetString() { return pExpr->GetString(); } + SbiSymDef* GetVar() { return pExpr->GetVar(); } + SbiSymDef* GetRealVar() { return pExpr->GetRealVar(); } + SbiExprNode* GetExprNode() { return pExpr; } + SbxDataType GetType() { return pExpr->GetType(); } + void SetType( SbxDataType eType){ pExpr->eType = eType; } + void Gen( RecursiveMode eRecMode = UNDEFINED ); // Ausgabe eines Nodes +}; + +class SbiConstExpression : public SbiExpression { + double nVal; + String aVal; + SbxDataType eType; +public: // numerische Konstante + SbiConstExpression( SbiParser* ); + SbxDataType GetType() { return eType; } + const String& GetString() { return aVal; } + double GetValue() { return nVal; } + short GetShortValue(); +}; + +class SbiExprList { // Basisklasse fuer Parameter und Dims +protected: + SbiParser* pParser; // Parser + SbiExpression* pFirst; // Expressions + short nExpr; // Anzahl Expressions + short nDim; // Anzahl Dimensionen + sal_Bool bError; // sal_True: Fehler + sal_Bool bBracket; // sal_True: Klammern +public: + SbiExprList( SbiParser* ); + virtual ~SbiExprList(); + sal_Bool IsBracket() { return bBracket; } + sal_Bool IsValid() { return sal_Bool( !bError ); } + short GetSize() { return nExpr; } + short GetDims() { return nDim; } + SbiExpression* Get( short ); + sal_Bool Test( const SbiProcDef& ); // Parameter-Checks + void Gen(); // Code-Erzeugung + void addExpression( SbiExpression* pExpr ); +}; + +class SbiParameters : public SbiExprList { +public: + SbiParameters( SbiParser*, sal_Bool bConst = sal_False, sal_Bool bPar = sal_True);// parsender Ctor +}; + +class SbiDimList : public SbiExprList { + sal_Bool bConst; // sal_True: Alles sind Integer-Konstanten +public: + SbiDimList( SbiParser* ); // Parsender Ctor + sal_Bool IsConstant() { return bConst; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/filefmt.hxx b/basic/source/inc/filefmt.hxx new file mode 100644 index 000000000000..caf6131aa9dd --- /dev/null +++ b/basic/source/inc/filefmt.hxx @@ -0,0 +1,180 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SB_FILEFMT_HXX +#define _SB_FILEFMT_HXX + +#include <tools/solar.h> + +class SvStream; + +// Version 2: Datentyp des Returnwerts fuer Publics +// Version 3: neue Opcodes +// Version 4: neue Opcodes +// Version 5: Bug (Ansprung von STATIC-Variablen im Init-Code) +// Version 6: Neue Opcodes und Bug (Globals anlegen, ohne BASIC zu beenden) +// Version 7: Korrektur im WITH-Parsing +// Version 8: Korrektur im IF-Parsing +// Version 9: Init-Code auch mit LEAVE beenden, wenn keine SUB/FUNCTION folgt +// Version A: #36374 Bei DIM AS NEW... auch Variablen anlegen +// Version B: #40689 Static umgestellt +// Version C: #41606 Bug bei Static +// Version D: #42678 Bug bei RTL-Function spc +// Version E: #56204 DCREATE, um auch bei DIM AS NEW Arrays anzulegen +// Version F: #57844 Einfuehrung von SvNumberformat::StringToDouble +// Version 10: #29955 For-Schleifen-Level in Statement-PCodes generieren +// Version 11: #29955 Wegen Build-Inkonsistenzen Neu-Compilieren erzwingen + +#define B_LEGACYVERSION 0x00000011L +#define B_CURVERSION 0x00000012L +#define B_EXT_IMG_VERSION 0x00000012L + +// Eine Datei enthaelt entweder einen Modul- oder einen Library-Record. +// Diese Records enthalten wiederum weitere Records. Jeder Record hat +// den folgenden Header: + +// sal_uInt16 Kennung +// sal_uInt32 Laenge des Records ohne Header +// sal_uInt16 Anzahl Unterelemente + +// Alle Datei-Offsets in Records sind relativ zum Start des Moduls! + +#define B_LIBRARY 0x4C42 // BL Library Record +#define B_MODULE 0x4D42 // BM Module Record +#define B_NAME 0x4E4D // MN module name +#define B_COMMENT 0x434D // MC comment +#define B_SOURCE 0x4353 // SC source code +#define B_PCODE 0x4350 // PC p-code +#define B_OLDPUBLICS 0x7550 // Pu publics +#define B_PUBLICS 0x5550 // PU publics +#define B_POOLDIR 0x4450 // PD symbol pool directory +#define B_SYMPOOL 0x5953 // SY symbol pool +#define B_STRINGPOOL 0x5453 // ST symbol pool +#define B_LINERANGES 0x524C // LR line ranges for publics +#define B_MODEND 0x454D // ME module end +#define B_SBXOBJECTS 0x5853 // SX SBX objects + +#define EXTENDED_BINARY_MODULES +#ifdef EXTENDED_BINARY_MODULES +#define B_EXTSOURCE 0x5345 // ES extended source +#endif + +// Ein Library Record enthaelt nur Module Records +// sal_uInt16 Kennung BL +// sal_uInt32 Laenge des Records +// sal_uInt16 Anzahl Module + +// Ein Modul-Record enthaelt alle anderen Recordtypen +// sal_uInt16 Kennung BM +// sal_uInt32 Laenge des Records +// sal_uInt16 1 +// Daten: +// sal_uInt32 Versionsnummer +// sal_uInt32 Zeichensatz +// sal_uInt32 Startadresse Initialisierungscode +// sal_uInt32 Startadresse Sub Main +// sal_uInt32 Reserviert +// sal_uInt32 Reserviert + +// Modulname, Kommentar und Quellcode: +// sal_uInt16 Kennung MN, MC oder SC +// sal_uInt32 Laenge des Records +// sal_uInt16 1 +// Daten: +// String-Instanz + +// P-Code: +// sal_uInt16 Kennung PC +// sal_uInt32 Laenge des Records +// sal_uInt16 1 +// Daten: +// Der P-Code als Bytesack + +// Alle Symbole und Strings werden in einem String-Pool gehalten. +// Verweise auf diese Strings sind in Form eines Indexes in diesen Pool. + +// Liste aller Publics: +// sal_uInt16 Kennung PU oder Pu +// sal_uInt32 Laenge des Records +// sal_uInt16 Anzahl der Publics +// Daten fuer jeden Public-Eintrag: +// sal_uInt16 String-Index +// sal_uInt32 Startadresse im P-Code-Image (sal_uInt16 fuer alte Publics) +// sal_uInt16 Datentyp des Returnwertes (ab Version 2) + +// Verzeichnis der Symbol-Tabellen: +// sal_uInt16 Kennung SP +// sal_uInt32 Laenge des Records +// sal_uInt16 Anzahl der Symboltabellen +// Daten fuer jede Symboltabelle: +// sal_uInt16 Stringindex des Namens +// sal_uInt16 Anzahl Symbole +// sal_uInt16 Scope-Kennung + +// Symboltabelle: +// sal_uInt16 Kennung SY +// sal_uInt32 Laenge des Records +// sal_uInt16 Anzahl der Symbole +// Daten: +// sal_uInt16 Stringindex des Namens +// sal_uInt16 Anzahl Symbole +// Daten fuer jedes Symbol: +// sal_uInt16 Stringindex des Namens +// sal_uInt16 Datentyp +// sal_uInt16 Laenge bei STRING*n-Symbolen (0x8000: STATIC-Variable) + +// Stringpool: +// sal_uInt16 Kennung ST +// sal_uInt32 Laenge des Records +// sal_uInt16 Anzahl der Strings +// Daten fuer jeden String: +// sal_uInt32 Offset in den Block aller Strings +// Danach folgt der Block aller Strings, die dort als ASCIIZ-Strings liegen. + +// Line Ranges: +// sal_uInt16 Kennung LR +// sal_uInt32 Laenge des Records +// sal_uInt16 Anzahl der Strings +// Daten fuer jedes Public: +// sal_uInt16 1. Zeile (Sub XXX) +// sal_uInt16 2. Zeile (End Sub) + +// SBX-Objekte: +// sal_uInt16 Anzahl Objekte +// .... Objektdaten + + +// Service-Routinen (in IMAGE.CXX) + +sal_Bool SbGood( SvStream& r ); +sal_uIntPtr SbOpenRecord( SvStream&, sal_uInt16 nSignature, sal_uInt16 nElem ); +void SbCloseRecord( SvStream&, sal_uIntPtr ); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/image.hxx b/basic/source/inc/image.hxx new file mode 100644 index 000000000000..0f0ffdf7df9a --- /dev/null +++ b/basic/source/inc/image.hxx @@ -0,0 +1,110 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SBIMAGE_HXX +#define _SBIMAGE_HXX + +#include "sbintern.hxx" +#include <rtl/ustring.hxx> +#include <filefmt.hxx> + +// Diese Klasse liest das vom Compiler erzeugte Image ein und verwaltet +// den Zugriff auf die einzelnen Elemente. + +struct SbPublicEntry; + +class SbiImage { + friend class SbiCodeGen; // Compiler-Klassen, die die private- + + SbxArrayRef rTypes; // User defined types + SbxArrayRef rEnums; // Enum types + sal_uInt32* pStringOff; // StringId-Offsets + sal_Unicode* pStrings; // StringPool + char* pCode; // Code-Image + char* pLegacyPCode; // Code-Image + sal_Bool bError; // sal_True: Fehler + sal_uInt16 nFlags; // Flags (s.u.) + short nStrings; // Anzahl Strings + sal_uInt32 nStringSize; // Groesse des String-Puffers + sal_uInt32 nCodeSize; // Groesse des Code-Blocks + sal_uInt16 nLegacyCodeSize; // Groesse des Code-Blocks + sal_uInt16 nDimBase; // OPTION BASE-Wert + rtl_TextEncoding eCharSet; // Zeichensatz fuer Strings + // temporaere Verwaltungs-Variable: + short nStringIdx; // aktueller String-Index + sal_uInt32 nStringOff; // aktuelle Pos im Stringpuffer + // Routinen fuer Compiler: + void MakeStrings( short ); // StringPool einrichten + void AddString( const String& );// String zufuegen + void AddCode( char*, sal_uInt32 ); // Codeblock dazu + void AddType(SbxObject *); // User-Type mit aufnehmen + void AddEnum(SbxObject *); // Register enum type + +public: + String aName; // Makroname + ::rtl::OUString aOUSource; // Quellcode + String aComment; // Kommentar + sal_Bool bInit; // sal_True: Init-Code ist gelaufen + sal_Bool bFirstInit; // sal_True, wenn das Image das erste mal nach + // dem Compilieren initialisiert wird. + SbiImage(); + ~SbiImage(); + void Clear(); // Inhalt loeschen + sal_Bool Load( SvStream&, sal_uInt32& nVer ); // Loads image from stream + // nVer is set to version + // of image + sal_Bool Load( SvStream& ); + sal_Bool Save( SvStream&, sal_uInt32 = B_CURVERSION ); + sal_Bool IsError() { return bError; } + + const char* GetCode() const { return pCode; } + sal_uInt32 GetCodeSize() const { return nCodeSize; } + ::rtl::OUString& GetSource32() { return aOUSource; } + sal_uInt16 GetBase() const { return nDimBase; } + String GetString( short nId ) const; + const SbxObject* FindType (String aTypeName) const; + + SbxArrayRef GetEnums() { return rEnums; } + + void SetFlag( sal_uInt16 n ) { nFlags |= n; } + sal_uInt16 GetFlag( sal_uInt16 n ) const { return nFlags & n; } + sal_uInt16 CalcLegacyOffset( sal_Int32 nOffset ); + sal_uInt32 CalcNewOffset( sal_Int16 nOffset ); + void ReleaseLegacyBuffer(); + sal_Bool ExceedsLegacyLimits(); + +}; + +#define SBIMG_EXPLICIT 0x0001 // OPTION EXPLICIT ist aktiv +#define SBIMG_COMPARETEXT 0x0002 // OPTION COMPARE TEXT ist aktiv +#define SBIMG_INITCODE 0x0004 // Init-Code vorhanden +#define SBIMG_CLASSMODULE 0x0008 // OPTION ClassModule is active + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/iosys.hxx b/basic/source/inc/iosys.hxx new file mode 100644 index 000000000000..48d6ce39d506 --- /dev/null +++ b/basic/source/inc/iosys.hxx @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SBIOSYS_HXX +#define _SBIOSYS_HXX + +#include <tools/stream.hxx> +#include <basic/sberrors.hxx> + +class SvStream; + +// Zur Zeit sind globale Dateien (Kanalnummern 256 bis 511) +// nicht implementiert. + +#define CHANNELS 256 +#define CONSOLE 0 + +#define SBSTRM_INPUT 0x0001 // Input +#define SBSTRM_OUTPUT 0x0002 // Output +#define SBSTRM_RANDOM 0x0004 // Random +#define SBSTRM_APPEND 0x0008 // Append +#define SBSTRM_BINARY 0x0010 // Binary + +class SbiStream { + SvStream* pStrm; // der Stream + sal_uIntPtr nExpandOnWriteTo; // bei Schreibzugriff, den Stream + // bis zu dieser Groesse aufblasen + ByteString aLine; // aktuelle Zeile + sal_uIntPtr nLine; // aktuelle Zeilennummer + short nLen; // Pufferlaenge + short nMode; // Bits: + short nChan; // aktueller Kanal + SbError nError; // letzter Fehlercode + void MapError(); // Fehlercode mappen + +public: + SbiStream(); + ~SbiStream(); + SbError Open( short, const ByteString&, short, short, short ); + SbError Close(); + SbError Read( ByteString&, sal_uInt16 = 0, bool bForceReadingPerByte=false ); + SbError Read( char& ); + SbError Write( const ByteString&, sal_uInt16 = 0 ); + + bool IsText() const { return (nMode & SBSTRM_BINARY) == 0; } + bool IsRandom() const { return (nMode & SBSTRM_RANDOM) != 0; } + bool IsBinary() const { return (nMode & SBSTRM_BINARY) != 0; } + bool IsSeq() const { return (nMode & SBSTRM_RANDOM) == 0; } + bool IsAppend() const { return (nMode & SBSTRM_APPEND) != 0; } + short GetBlockLen() const { return nLen; } + short GetMode() const { return nMode; } + sal_uIntPtr GetLine() const { return nLine; } + void SetExpandOnWriteTo( sal_uIntPtr n ) { nExpandOnWriteTo = n; } + void ExpandFile(); + SvStream* GetStrm() { return pStrm; } +}; + +class SbiIoSystem { + SbiStream* pChan[ CHANNELS ]; + ByteString aPrompt; // Input-Prompt + ByteString aIn, aOut; // Console-Buffer + short nChan; // aktueller Kanal + SbError nError; // letzter Fehlercode + void ReadCon( ByteString& ); + void WriteCon( const ByteString& ); +public: + SbiIoSystem(); + ~SbiIoSystem(); + SbError GetError(); + void Shutdown(); + void SetPrompt( const ByteString& r ) { aPrompt = r; } + void SetChannel( short n ) { nChan = n; } + short GetChannel() const { return nChan;} + void ResetChannel() { nChan = 0; } + void Open( short, const ByteString&, short, short, short ); + void Close(); + void Read( ByteString&, short = 0 ); + char Read(); + void Write( const ByteString&, short = 0 ); + short NextChannel(); + // 0 == bad channel or no SvStream (nChannel=0..CHANNELS-1) + SbiStream* GetStream( short nChannel ) const; + void CloseAll(); // JSM +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/namecont.hxx b/basic/source/inc/namecont.hxx new file mode 100644 index 000000000000..419230c1c2b6 --- /dev/null +++ b/basic/source/inc/namecont.hxx @@ -0,0 +1,774 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef BASIC_NAMECONTAINER_HXX +#define BASIC_NAMECONTAINER_HXX + +#include <boost/unordered_map.hpp> +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/script/XStorageBasedLibraryContainer.hpp> +#include <com/sun/star/script/XLibraryContainerPassword.hpp> +#include <com/sun/star/script/XLibraryContainerExport.hpp> +#include <com/sun/star/script/XLibraryQueryExecutable.hpp> +#include <com/sun/star/script/XLibraryContainer3.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/container/XContainer.hpp> +#include <com/sun/star/ucb/XSimpleFileAccess.hpp> +#include <com/sun/star/io/XOutputStream.hpp> +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/util/XMacroExpander.hpp> +#include <com/sun/star/util/XStringSubstitution.hpp> +#include <com/sun/star/document/XStorageBasedDocument.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <osl/mutex.hxx> +#include <unotools/eventlisteneradapter.hxx> +#include <cppuhelper/weakref.hxx> +#include <cppuhelper/component.hxx> +#include <cppuhelper/typeprovider.hxx> +#include <cppuhelper/interfacecontainer.hxx> +#include <cppuhelper/basemutex.hxx> +#include <sot/storage.hxx> +#include <xmlscript/xmllib_imexp.hxx> +#include <com/sun/star/deployment/XPackage.hpp> + +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/compbase8.hxx> +#include <cppuhelper/compbase9.hxx> +#include <cppuhelper/interfacecontainer.hxx> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> + +class BasicManager; + +namespace basic +{ + +typedef ::cppu::WeakComponentImplHelper9< + ::com::sun::star::lang::XInitialization, + ::com::sun::star::script::XStorageBasedLibraryContainer, + ::com::sun::star::script::XLibraryContainerPassword, + ::com::sun::star::script::XLibraryContainerExport, + ::com::sun::star::script::XLibraryContainer3, + ::com::sun::star::container::XContainer, + ::com::sun::star::script::XLibraryQueryExecutable, + ::com::sun::star::script::vba::XVBACompatibility, + ::com::sun::star::lang::XServiceInfo > LibraryContainerHelper; + +typedef ::cppu::WeakImplHelper2< ::com::sun::star::container::XNameContainer, + ::com::sun::star::container::XContainer > NameContainerHelper; + + +struct hashName_Impl +{ + size_t operator()(const ::rtl::OUString Str) const + { + return (size_t)Str.hashCode(); + } +}; + +struct eqName_Impl +{ + sal_Bool operator()(const ::rtl::OUString Str1, const ::rtl::OUString Str2) const + { + return ( Str1 == Str2 ); + } +}; + +typedef boost::unordered_map +< + ::rtl::OUString, + sal_Int32, + hashName_Impl, + eqName_Impl +> +NameContainerNameMap; + + +//============================================================================ + +class NameContainer : public ::cppu::BaseMutex, public NameContainerHelper +{ + NameContainerNameMap mHashMap; + ::com::sun::star::uno::Sequence< ::rtl::OUString > mNames; + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > mValues; + sal_Int32 mnElementCount; + + ::com::sun::star::uno::Type mType; + ::com::sun::star::uno::XInterface* mpxEventSource; + + ::cppu::OInterfaceContainerHelper maListenerContainer; + +public: + NameContainer( const ::com::sun::star::uno::Type& rType ) + : mnElementCount( 0 ) + , mType( rType ) + , mpxEventSource( NULL ) + , maListenerContainer( m_aMutex ) + {} + + void setEventSource( ::com::sun::star::uno::XInterface* pxEventSource ) + { mpxEventSource = pxEventSource; } + + // Methods XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) + throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements( ) + throw(::com::sun::star::uno::RuntimeException); + + // Methods XNameAccess + virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) + throw(::com::sun::star::container::NoSuchElementException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) + throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) + throw(::com::sun::star::uno::RuntimeException); + + // Methods XNameReplace + virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) + throw(::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // Methods XNameContainer + virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) + throw(::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::container::ElementExistException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeByName( const ::rtl::OUString& Name ) + throw(::com::sun::star::container::NoSuchElementException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // Methods XContainer + virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::container::XContainerListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::container::XContainerListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); +}; + +//============================================================================ + +class SfxLibrary; + +enum InitMode +{ + DEFAULT, + CONTAINER_INIT_FILE, + LIBRARY_INIT_FILE, + OFFICE_DOCUMENT, + OLD_BASIC_STORAGE +}; + +class ModifiableHelper +{ +private: + ::cppu::OInterfaceContainerHelper m_aModifyListeners; + ::cppu::OWeakObject& m_rEventSource; + sal_Bool mbModified; + +public: + ModifiableHelper( ::cppu::OWeakObject& _rEventSource, ::osl::Mutex& _rMutex ) + :m_aModifyListeners( _rMutex ) + ,m_rEventSource( _rEventSource ) + ,mbModified( sal_False ) + { + } + + inline sal_Bool isModified() const { return mbModified; } + void setModified( sal_Bool _bModified ); + + inline void addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& _rxListener ) + { + m_aModifyListeners.addInterface( _rxListener ); + } + + inline void removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& _rxListener ) + { + m_aModifyListeners.removeInterface( _rxListener ); + } +}; + +class SfxLibraryContainer :public LibraryContainerHelper + ,public ::utl::OEventListenerAdapter +{ + sal_Bool mbVBACompat; + rtl::OUString msProjectName; +protected: + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF; + ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > mxSFI; + ::com::sun::star::uno::Reference< ::com::sun::star::util::XMacroExpander > mxMacroExpander; + ::com::sun::star::uno::Reference< ::com::sun::star::util::XStringSubstitution > mxStringSubstitution; + ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > mxOwnerDocument; + + ::osl::Mutex maMutex; + ModifiableHelper maModifiable; + + NameContainer maNameContainer; + sal_Bool mbOldInfoFormat; + sal_Bool mbOasis2OOoFormat; + + ::rtl::OUString maInitialDocumentURL; + ::rtl::OUString maInfoFileName; + ::rtl::OUString maOldInfoFileName; + ::rtl::OUString maLibElementFileExtension; + ::rtl::OUString maLibraryPath; + ::rtl::OUString maLibrariesDir; + + ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > mxStorage; + BasicManager* mpBasMgr; + sal_Bool mbOwnBasMgr; + + InitMode meInitMode; + + void implStoreLibrary( SfxLibrary* pLib, + const ::rtl::OUString& aName, + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ); + + // New variant for library export + void implStoreLibrary( SfxLibrary* pLib, + const ::rtl::OUString& aName, + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, + const ::rtl::OUString& aTargetURL, + const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > xToUseSFI, + const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ); + + void implStoreLibraryIndexFile( SfxLibrary* pLib, const ::xmlscript::LibDescriptor& rLib, + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ); + + // New variant for library export + void implStoreLibraryIndexFile( SfxLibrary* pLib, const ::xmlscript::LibDescriptor& rLib, + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, + const ::rtl::OUString& aTargetURL, + const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > xToUseSFI ); + + sal_Bool implLoadLibraryIndexFile( SfxLibrary* pLib, + ::xmlscript::LibDescriptor& rLib, + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, + const ::rtl::OUString& aIndexFileName ); + + void implImportLibDescriptor( SfxLibrary* pLib, ::xmlscript::LibDescriptor& rLib ); + + // Methods to distinguish between deffirent library types + virtual SfxLibrary* SAL_CALL implCreateLibrary( const ::rtl::OUString& aName ) = 0; + virtual SfxLibrary* SAL_CALL implCreateLibraryLink + ( const ::rtl::OUString& aName, const ::rtl::OUString& aLibInfoFileURL, + const ::rtl::OUString& StorageURL, sal_Bool ReadOnly ) = 0; + virtual ::com::sun::star::uno::Any SAL_CALL createEmptyLibraryElement( void ) = 0; + virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const = 0; + virtual void SAL_CALL writeLibraryElement + ( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary, + const ::rtl::OUString& aElementName, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutput + ) + throw(::com::sun::star::uno::Exception) = 0; + + virtual ::com::sun::star::uno::Any SAL_CALL importLibraryElement + ( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary, + const ::rtl::OUString& aElementName, + const ::rtl::OUString& aFile, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xElementStream ) = 0; + virtual void SAL_CALL importFromOldStorage( const ::rtl::OUString& aFile ) = 0; + + // Password encryption + virtual sal_Bool implStorePasswordLibrary( SfxLibrary* pLib, const ::rtl::OUString& aName, + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler ); + + // New variant for library export + virtual sal_Bool implStorePasswordLibrary( SfxLibrary* pLib, const ::rtl::OUString& aName, + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, + const ::rtl::OUString& aTargetURL, + const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > xToUseSFI, const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler ); + + virtual sal_Bool implLoadPasswordLibrary( SfxLibrary* pLib, const ::rtl::OUString& Name, + sal_Bool bVerifyPasswordOnly=false ) + throw(::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + virtual void onNewRootStorage() = 0; + + + // #56666, Creates another library container + // instance of the same derived class + virtual SfxLibraryContainer* createInstanceImpl( void ) = 0; + + + // Interface to get the BasicManager (Hack for password implementation) + BasicManager* getBasicManager( void ); + ::rtl::OUString createAppLibraryFolder( SfxLibrary* pLib, const ::rtl::OUString& aName ); + + sal_Bool init( const ::rtl::OUString& rInitialDocumentURL, + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxInitialStorage ); + + virtual const sal_Char* SAL_CALL getInfoFileName() const = 0; + virtual const sal_Char* SAL_CALL getOldInfoFileName() const = 0; + virtual const sal_Char* SAL_CALL getLibElementFileExtension() const = 0; + virtual const sal_Char* SAL_CALL getLibrariesDir() const = 0; + + // Handle maLibInfoFileURL and maStorageURL correctly + void checkStorageURL + ( + const ::rtl::OUString& aSourceURL, + ::rtl::OUString& aLibInfoFileURL, + ::rtl::OUString& aStorageURL, + ::rtl::OUString& aUnexpandedStorageURL + ); + ::rtl::OUString expand_url( const ::rtl::OUString& url ) + throw(::com::sun::star::uno::RuntimeException); + + SfxLibrary* getImplLib( const String& rLibraryName ); + + void storeLibraries_Impl( + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, + sal_Bool bComplete ); + + void SAL_CALL initializeFromDocumentURL( const ::rtl::OUString& _rInitialDocumentURL ); + void SAL_CALL initializeFromDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XStorageBasedDocument >& _rxDocument ); + + // OEventListenerAdapter + virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource ); + + // OComponentHelper + virtual void SAL_CALL disposing(); + +private: + sal_Bool init_Impl( const ::rtl::OUString& rInitialDocumentURL, + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxInitialStorage ); + void implScanExtensions( void ); + +public: + SfxLibraryContainer( void ); + ~SfxLibraryContainer(); + + + // Interface to set the BasicManager (Hack for password implementation) + void setBasicManager( BasicManager* pBasMgr ) + { + mpBasMgr = pBasMgr; + } + + void enterMethod(); + void leaveMethod(); + bool isDisposed() const { return rBHelper.bInDispose || rBHelper.bDisposed; } + void checkDisposed() const; + + // Methods XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() + throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() + throw(::com::sun::star::uno::RuntimeException); + + // Methods XNameAccess + virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) + throw(::com::sun::star::container::NoSuchElementException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() + throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) + throw(::com::sun::star::uno::RuntimeException); + + // Members XStorageBasedLibraryContainer + virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > SAL_CALL getRootStorage() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setRootStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rootstorage ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL storeLibrariesToStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& RootStorage ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // Methods XModifiable (base of XPersistentLibraryContainer) + virtual ::sal_Bool SAL_CALL isModified( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setModified( ::sal_Bool bModified ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + + // Methods XPersistentLibraryContainer (base of XStorageBasedLibraryContainer) + virtual ::com::sun::star::uno::Any SAL_CALL getRootLocation() throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getContainerLocationName() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL storeLibraries( ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + //Methods XLibraryContainer3 + virtual ::rtl::OUString SAL_CALL getOriginalLibraryLinkURL( const ::rtl::OUString& Name ) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException); + + // Methods XLibraryContainer2 (base of XPersistentLibraryContainer) + virtual sal_Bool SAL_CALL isLibraryLink( const ::rtl::OUString& Name ) + throw (::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getLibraryLinkURL( const ::rtl::OUString& Name ) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isLibraryReadOnly( const ::rtl::OUString& Name ) + throw (::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setLibraryReadOnly( const ::rtl::OUString& Name, sal_Bool bReadOnly ) + throw (::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL renameLibrary( const ::rtl::OUString& Name, const ::rtl::OUString& NewName ) + throw (::com::sun::star::container::NoSuchElementException, + ::com::sun::star::container::ElementExistException, + ::com::sun::star::uno::RuntimeException); + + // Methods XLibraryContainer (base of XLibraryContainer2) + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > SAL_CALL + createLibrary( const ::rtl::OUString& Name ) + throw(::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::container::ElementExistException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL createLibraryLink + ( const ::rtl::OUString& Name, const ::rtl::OUString& StorageURL, sal_Bool ReadOnly ) + throw(::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::container::ElementExistException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeLibrary( const ::rtl::OUString& Name ) + throw(::com::sun::star::container::NoSuchElementException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isLibraryLoaded( const ::rtl::OUString& Name ) + throw(::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL loadLibrary( const ::rtl::OUString& Name ) + throw(::com::sun::star::container::NoSuchElementException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // Methods XInitialization + virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Any >& aArguments ) + throw (::com::sun::star::uno::Exception, + ::com::sun::star::uno::RuntimeException); + + // Methods XLibraryContainerPassword + virtual sal_Bool SAL_CALL isLibraryPasswordProtected( const ::rtl::OUString& Name ) + throw (::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isLibraryPasswordVerified( const ::rtl::OUString& Name ) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL verifyLibraryPassword( const ::rtl::OUString& Name, const ::rtl::OUString& Password ) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL changeLibraryPassword( const ::rtl::OUString& Name, + const ::rtl::OUString& OldPassword, const ::rtl::OUString& NewPassword ) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException); + + // Methods XContainer + virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::container::XContainerListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::container::XContainerListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + + // Methods XLibraryContainerExport + virtual void SAL_CALL exportLibrary( const ::rtl::OUString& Name, const ::rtl::OUString& URL, + const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler ) + throw (::com::sun::star::uno::Exception, + ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException); + + // Methods XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) + throw (::com::sun::star::uno::RuntimeException) = 0; + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) + throw (::com::sun::star::uno::RuntimeException) = 0; + // Methods XVBACompatibility + virtual ::sal_Bool SAL_CALL getVBACompatibilityMode() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setVBACompatibilityMode( ::sal_Bool _vbacompatmodeon ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getProjectName() throw (::com::sun::star::uno::RuntimeException) { return msProjectName; } + virtual void SAL_CALL setProjectName( const ::rtl::OUString& _projectname ) throw (::com::sun::star::uno::RuntimeException); +}; + +class LibraryContainerMethodGuard +{ +private: + SfxLibraryContainer& m_rContainer; +public: + LibraryContainerMethodGuard( SfxLibraryContainer& _rContainer ) + :m_rContainer( _rContainer ) + { + m_rContainer.enterMethod(); + } + + ~LibraryContainerMethodGuard() + { + m_rContainer.leaveMethod(); + } +}; + + +//============================================================================ + +class SfxLibrary + : public ::com::sun::star::container::XNameContainer + , public ::com::sun::star::container::XContainer + , public ::cppu::BaseMutex + , public ::cppu::OComponentHelper +{ + friend class SfxLibraryContainer; + friend class SfxDialogLibraryContainer; + friend class SfxScriptLibraryContainer; + + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF; + ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > mxSFI; + + ModifiableHelper& mrModifiable; + NameContainer maNameContainer; + + sal_Bool mbLoaded; + sal_Bool mbIsModified; + sal_Bool mbInitialised; + +private: + + ::rtl::OUString maLibElementFileExtension; + ::rtl::OUString maLibInfoFileURL; + ::rtl::OUString maStorageURL; + ::rtl::OUString maUnexpandedStorageURL; + ::rtl::OUString maOrignialStorageURL; + + sal_Bool mbLink; + sal_Bool mbReadOnly; + sal_Bool mbReadOnlyLink; + sal_Bool mbPreload; + + sal_Bool mbPasswordProtected; + sal_Bool mbPasswordVerified; + sal_Bool mbDoc50Password; + ::rtl::OUString maPassword; + + sal_Bool mbSharedIndexFile; + sal_Bool mbExtension; + + // Additional functionality for localisation + // Provide modify state including resources + virtual sal_Bool isModified( void ) = 0; + virtual void storeResources( void ) = 0; + virtual void storeResourcesAsURL( const ::rtl::OUString& URL, const ::rtl::OUString& NewName ) = 0; + virtual void storeResourcesToURL( const ::rtl::OUString& URL, + const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ) = 0; + virtual void storeResourcesToStorage( const ::com::sun::star::uno::Reference + < ::com::sun::star::embed::XStorage >& xStorage ) = 0; + +protected: + inline sal_Bool implIsModified() const { return mbIsModified; } + void implSetModified( sal_Bool _bIsModified ); + +private: + /** checks whether the lib is readonly, or a readonly link, throws an IllegalArgumentException if so + */ + void impl_checkReadOnly(); + /** checks whether the library is loaded, throws a LibraryNotLoadedException (wrapped in a WrappedTargetException), + if not. + */ + void impl_checkLoaded(); + +private: + void impl_removeWithoutChecks( const ::rtl::OUString& _rElementName ); + +public: + SfxLibrary( + ModifiableHelper& _rModifiable, + const ::com::sun::star::uno::Type& aType, + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSF, + const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >& xSFI + ); + SfxLibrary( + ModifiableHelper& _rModifiable, + const ::com::sun::star::uno::Type& aType, + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSF, + const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >& xSFI, + const ::rtl::OUString& aLibInfoFileURL, + const ::rtl::OUString& + aStorageURL, + sal_Bool ReadOnly + ); + + // Methods XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL acquire() throw() { OComponentHelper::acquire(); } + virtual void SAL_CALL release() throw() { OComponentHelper::release(); } + + // Methods XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) + throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements( ) + throw(::com::sun::star::uno::RuntimeException); + + // Methods XNameAccess + virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) + throw(::com::sun::star::container::NoSuchElementException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) + throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) + throw(::com::sun::star::uno::RuntimeException); + + // Methods XNameReplace + virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) + throw(::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // Methods XNameContainer + virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) + throw(::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::container::ElementExistException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeByName( const ::rtl::OUString& Name ) + throw(::com::sun::star::container::NoSuchElementException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XTypeProvider + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) + throw( ::com::sun::star::uno::RuntimeException ); + ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) + throw( ::com::sun::star::uno::RuntimeException ); + + // Methods XContainer + virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::container::XContainerListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::container::XContainerListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + +public: + struct LibraryContainerAccess { friend class SfxLibraryContainer; private: LibraryContainerAccess() { } }; + void removeElementWithoutChecks( const ::rtl::OUString& _rElementName, LibraryContainerAccess ) + { + impl_removeWithoutChecks( _rElementName ); + } + +protected: + virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const = 0; +}; + +//=================================================================== +class ScriptSubPackageIterator +{ + com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > m_xMainPackage; + + bool m_bIsValid; + bool m_bIsBundle; + + com::sun::star::uno::Sequence< com::sun::star::uno::Reference + < com::sun::star::deployment::XPackage > > m_aSubPkgSeq; + sal_Int32 m_nSubPkgCount; + sal_Int32 m_iNextSubPkg; + + com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > + implDetectScriptPackage( const com::sun::star::uno::Reference + < com::sun::star::deployment::XPackage > xPackage, bool& rbPureDialogLib ); + +public: + ScriptSubPackageIterator( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xMainPackage ); + + com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > getNextScriptSubPackage( bool& rbPureDialogLib ); +}; + +enum IteratorState +{ + USER_EXTENSIONS, + SHARED_EXTENSIONS, + BUNDLED_EXTENSIONS, + END_REACHED +}; + +class ScriptExtensionIterator +{ +public: + ScriptExtensionIterator( void ); + rtl::OUString nextBasicOrDialogLibrary( bool& rbPureDialogLib ); + +private: + com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetScriptPackageFromPackage + ( const com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage, + bool& rbPureDialogLib ); + +protected: + com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > + implGetNextUserScriptPackage( bool& rbPureDialogLib ); + com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > + implGetNextSharedScriptPackage( bool& rbPureDialogLib ); + com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > + implGetNextBundledScriptPackage( bool& rbPureDialogLib ); + + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext; + + IteratorState m_eState; + + com::sun::star::uno::Sequence< com::sun::star::uno::Reference + < com::sun::star::deployment::XPackage > > m_aUserPackagesSeq; + bool m_bUserPackagesLoaded; + + com::sun::star::uno::Sequence< com::sun::star::uno::Reference + < com::sun::star::deployment::XPackage > > m_aSharedPackagesSeq; + bool m_bSharedPackagesLoaded; + + com::sun::star::uno::Sequence< com::sun::star::uno::Reference + < com::sun::star::deployment::XPackage > > m_aBundledPackagesSeq; + bool m_bBundledPackagesLoaded; + + + int m_iUserPackage; + int m_iSharedPackage; + int m_iBundledPackage; + + + + ScriptSubPackageIterator* m_pScriptSubPackageIterator; + +}; // end class ScriptExtensionIterator + + + +} // namespace basic + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/object.hxx b/basic/source/inc/object.hxx new file mode 100644 index 000000000000..1b25ee41a25d --- /dev/null +++ b/basic/source/inc/object.hxx @@ -0,0 +1,101 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SAMPLE_OBJECT_HXX +#define _SAMPLE_OBJECT_HXX + +#include <basic/sbxfac.hxx> +#include <basic/sbxvar.hxx> +#include <basic/sbxobj.hxx> + +// 1) Properties: +// Name der Name, R/O +// Value ein double-Wert, R/W +// 2) Methoden: +// Display Ausgabe eines Textes +// Square Argument * Argument +// Event Aufruf eines Basic-Programms +// 3) Unterobjekte: +// eine Collection names "Elements". Der Zugriff ist sowohl als +// Property (fuer das gesamte Objekt) als auch als Methode (fuer +// einzelne Elemente, wird durchgereicht) implementiert. +// Diese Implementation ist ein Beispiel fuer eine tabellengesteuerte +// Version, die sehr viele Elemente enthalten kann. +// Die Collection findet sich in COLLECTN.*, die in der Collection +// enthaltenen Objekte in COLLELEM.* + +class SampleObject : public SbxObject +{ +using SbxVariable::GetInfo; + // Definition eines Tabelleneintrags. Dies wird hier gemacht, + // da dadurch die Methoden und Properties als private deklariert + // werden koennen. +#if defined ( ICC ) || defined ( C50 ) || defined ( C52 ) +public: +#endif + typedef void( SampleObject::*pMeth ) + ( SbxVariable* pThis, SbxArray* pArgs, sal_Bool bWrite ); +#if defined ( ICC ) +private: +#endif + + struct Methods { + const char* pName; // Name des Eintrags + SbxDataType eType; // Datentyp + pMeth pFunc; // Function Pointer + short nArgs; // Argumente und Flags + }; + static Methods aMethods[]; // Methodentabelle + + // Methoden + void Display( SbxVariable*, SbxArray*, sal_Bool ); + void Event( SbxVariable*, SbxArray*, sal_Bool ); + void Square( SbxVariable*, SbxArray*, sal_Bool ); + void Create( SbxVariable*, SbxArray*, sal_Bool ); + // Infoblock auffuellen + SbxInfo* GetInfo( short nIdx ); + // Broadcaster Notification + virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, + const SfxHint& rHint, const TypeId& rHintType ); +public: + SampleObject( const String& ); + // Suchen eines Elements + virtual SbxVariable* Find( const String&, SbxClassType ); +}; + +// Die dazugehoerige Factory: + +class SampleObjectFac : public SbxFactory +{ +public: + virtual SbxObject* CreateObject( const String& ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/opcodes.hxx b/basic/source/inc/opcodes.hxx new file mode 100644 index 000000000000..cbc98ac22fd4 --- /dev/null +++ b/basic/source/inc/opcodes.hxx @@ -0,0 +1,171 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _OPCODES_HXX +#define _OPCODES_HXX + +#include "sbintern.hxx" + +// Ein Opcode ist entweder 1, 3 oder 5 Bytes lang, je nach numerischen +// Wert des Opcodes (s.u.). + +enum SbiOpcode { + // Alle Opcodes ohne Operanden + _NOP = 0, + + SbOP0_START = _NOP, + + // Operatoren + // die folgenden Operatoren sind genauso angeordnet + // wie der enum SbxVarOp + _EXP, _MUL, _DIV, _MOD, _PLUS, _MINUS, _NEG, + _EQ, _NE, _LT, _GT, _LE, _GE, + _IDIV, _AND, _OR, _XOR, _EQV, _IMP, _NOT, + _CAT, + // Ende enum SbxVarOp + _LIKE, _IS, + // Laden/speichern + _ARGC, // neuen Argv einrichten + _ARGV, // TOS ==> aktueller Argv + _INPUT, // Input ==> TOS + _LINPUT, // Line Input ==> TOS + _GET, // TOS anfassen + _SET, // Speichern Objekt TOS ==> TOS-1 + _PUT, // TOS ==> TOS-1 + _PUTC, // TOS ==> TOS-1, dann ReadOnly + _DIM, // DIM + _REDIM, // REDIM + _REDIMP, // REDIM PRESERVE + _ERASE, // TOS loeschen + // Verzweigen + _STOP, // Programmende + _INITFOR, // FOR-Variable initialisieren + _NEXT, // FOR-Variable inkrementieren + _CASE, // Anfang CASE + _ENDCASE, // Ende CASE + _STDERROR, // Standard-Fehlerbehandlung + _NOERROR, // keine Fehlerbehandlung + _LEAVE, // UP verlassen + // E/A + _CHANNEL, // TOS = Kanalnummer + _BPRINT, // print TOS + _PRINTF, // print TOS in field + _BWRITE, // write TOS + _RENAME, // Rename Tos+1 to Tos + _PROMPT, // TOS = Prompt for Input + _RESTART, // Restartpunkt definieren + _CHAN0, // I/O-Kanal 0 + // Sonstiges + _EMPTY, // Leeren Ausdruck auf Stack + _ERROR, // TOS = Fehlercode + _LSET, // Speichern Objekt TOS ==> TOS-1 + _RSET, // Speichern Objekt TOS ==> TOS-1 + _REDIMP_ERASE, // Copies array to be later used by REDIM PRESERVE before erasing it + _INITFOREACH, + _VBASET, // VBA-like Set + _ERASE_CLEAR, // Erase array and clear variable + _ARRAYACCESS, // Assign parameters to TOS and get value, used for array of arrays + _BYVAL, // byref -> byval for lvalue parameter passed in call + SbOP0_END, + + // Alle Opcodes mit einem Operanden + + _NUMBER = 0x40, // Laden einer numerischen Konstanten (+ID) + + SbOP1_START = _NUMBER, + + _SCONST, // Laden einer Stringkonstanten (+ID) + _CONST, // Immediate Load (+Wert) + _ARGN, // Speichern eines named Args in Argv (+StringID) + _PAD, // String auf feste Laenge bringen (+Laenge) + // Verzweigungen + _JUMP, // Sprung (+Target) + _JUMPT, // TOS auswerten, bedingter Sprung (+Target) + _JUMPF, // TOS auswerten, bedingter Sprung (+Target) + _ONJUMP, // TOS auswerten, Sprung in JUMP-Tabelle (+MaxVal) + _GOSUB, // UP-Aufruf (+Target) + _RETURN, // UP-Return (+0 oder Target) + _TESTFOR, // FOR-Variable testen, inkrementieren (+Endlabel) + _CASETO, // Tos+1 <= Case <= Tos, 2xremove (+Target) + _ERRHDL, // Fehler-Handler (+Offset) + _RESUME, // Resume nach Fehlern (+0 or 1 or Label) + // E/A + _CLOSE, // (+Kanal/0) + _PRCHAR, // (+char) + // Verwaltung + _SETCLASS, // Set + Klassennamen testen (+StringId) + _TESTCLASS, // Check TOS class (+StringId) + _LIB, // Libnamen fuer Declare-Procs setzen (+StringId) + _BASED, // TOS wird um BASE erhoeht, BASE davor gepusht (+base) + // Typanpassung im Argv + _ARGTYP, // Letzten Parameter in Argv konvertieren (+Typ) + _VBASETCLASS, // VBA-like Set + SbOP1_END, + + // Alle Opcodes mit zwei Operanden + + _RTL = 0x80, // Laden aus RTL (+StringID+Typ) + + SbOP2_START = _RTL, + + _FIND, // Laden (+StringID+Typ) + _ELEM, // Laden Element (+StringID+Typ) + _PARAM, // Parameter (+Offset+Typ) + // Verzweigen + _CALL, // DECLARE-Methode rufen (+StringID+Typ) + _CALLC, // Cdecl-DECLARE-Methode rufen (+StringID+Typ) + _CASEIS, // Case-Test (+Test-Opcode+True-Target) + // Verwaltung + _STMNT, // Beginn eines Statements (+Line+Col) + // E/A + _OPEN, // (+SvStreamFlags+Flags) + // Objekte + _LOCAL, // Lokale Variable definieren (+StringID+Typ) + _PUBLIC, // Modulglobale Variable (+StringID+Typ) + _GLOBAL, // Globale Variable definieren, public-Anweisung (+StringID+Typ) + _CREATE, // Objekt kreieren (+StringId+StringID) + _STATIC, // Statische Variabl (+StringID+Typ) JSM + _TCREATE, // User Defined Objekt kreieren + _DCREATE, // Objekt-Array kreieren (+StringId+StringID) + _GLOBAL_P, // Globale Variable definieren, die beim Neustart von Basic + // nicht ueberschrieben wird, P=PERSIST (+StringID+Typ) + _FIND_G, // Sucht globale Variable mit Spezialbehandlung wegen _GLOBAL_P + _DCREATE_REDIMP, // Objekt-Array redimensionieren (+StringId+StringID) + _FIND_CM, // Search inside a class module (CM) to enable global search in time + _PUBLIC_P, // Module global Variable (persisted between calls)(+StringID+Typ) + _FIND_STATIC, // local static var lookup (+StringID+Typ) + + SbOP2_END + +}; + + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/parser.hxx b/basic/source/inc/parser.hxx new file mode 100644 index 000000000000..1b58e5d39f0b --- /dev/null +++ b/basic/source/inc/parser.hxx @@ -0,0 +1,157 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _PARSER_HXX +#define _PARSER_HXX + +#include "expr.hxx" +#include "codegen.hxx" +#include "symtbl.hxx" + + +#include <vector> +typedef ::std::vector< String > StringVector; + +struct SbiParseStack; + +class SbiParser : public SbiTokenizer +{ + friend class SbiExpression; + + SbiParseStack* pStack; // Block-Stack + SbiProcDef* pProc; // aktuelle Prozedur + SbiExprNode* pWithVar; // aktuelle With-Variable + SbiToken eEndTok; // das Ende-Token + sal_uInt32 nGblChain; // Chainkette fuer globale DIMs + sal_Bool bGblDefs; // sal_True globale Definitionen allgemein + sal_Bool bNewGblDefs; // sal_True globale Definitionen vor Sub + sal_Bool bSingleLineIf; // sal_True einzeiliges if-Statement + + SbiSymDef* VarDecl( SbiDimList**,sal_Bool,sal_Bool );// Variablen-Deklaration + SbiProcDef* ProcDecl(sal_Bool bDecl);// Prozedur-Deklaration + void DefStatic( sal_Bool bPrivate ); + void DefProc( sal_Bool bStatic, sal_Bool bPrivate ); // Prozedur einlesen + void DefVar( SbiOpcode eOp, sal_Bool bStatic ); // DIM/REDIM einlesen + void TypeDecl( SbiSymDef&, sal_Bool bAsNewAlreadyParsed=sal_False ); // AS-Deklaration + void OpenBlock( SbiToken, SbiExprNode* = NULL ); // Block oeffnen + void CloseBlock(); // Block aufloesen + sal_Bool Channel( sal_Bool=sal_False ); // Kanalnummer parsen + void StmntBlock( SbiToken ); // Statement-Block abarbeiten + void DefType( sal_Bool bPrivate ); // Parse type declaration + void DefEnum( sal_Bool bPrivate ); // Parse enum declaration + void DefDeclare( sal_Bool bPrivate ); + void EnableCompatibility(); +public: + SbxArrayRef rTypeArray; // das Type-Array + SbxArrayRef rEnumArray; // Enum types + SbiStringPool aGblStrings; // der String-Pool + SbiStringPool aLclStrings; // der String-Pool + SbiSymPool aGlobals; // globale Variable + SbiSymPool aPublics; // modulglobale Variable + SbiSymPool aRtlSyms; // Runtime-Library + SbiCodeGen aGen; // Code-Generator + StarBASIC* pBasic; // StarBASIC-Instanz + SbiSymPool* pPool; // aktueller Pool + SbiExprType eCurExpr; // aktueller Expr-Typ + short nBase; // OPTION BASE-Wert + sal_Bool bText; // OPTION COMPARE TEXT + sal_Bool bExplicit; // sal_True: OPTION EXPLICIT + sal_Bool bClassModule; // sal_True: OPTION ClassModule + StringVector aIfaceVector; // Holds all interfaces implemented by a class module + StringVector aRequiredTypes; // Types used in Dim As New <type> outside subs + SbxDataType eDefTypes[26]; // DEFxxx-Datentypen + + SbiParser( StarBASIC*, SbModule* ); + sal_Bool Parse(); // die Aktion + SbiExprNode* GetWithVar(); // Innerste With-Variable liefern + + // AB 31.3.1996, Symbol in Runtime-Library suchen + SbiSymDef* CheckRTLForSym( const String& rSym, SbxDataType eType ); + void AddConstants( void ); + + sal_Bool HasGlobalCode(); // Globaler Code definiert? + + sal_Bool TestToken( SbiToken ); // bestimmtes TOken? + sal_Bool TestSymbol( sal_Bool=sal_False ); // Symbol? + sal_Bool TestComma(); // Komma oder EOLN? + void TestEoln(); // EOLN? + + void Symbol( const KeywordSymbolInfo* pKeywordSymbolInfo = NULL ); // Let oder Call + void ErrorStmnt(); // ERROR n + void NotImp(); // nicht implementiert + void BadBlock(); // LOOP/WEND/NEXT + void BadSyntax(); // Falsches SbiToken + void NoIf(); // ELSE/ELSE IF ohne IF + void Assign(); // LET + void Attribute(); // Attribute + void Call(); // CALL + void Close(); // CLOSE + void Declare(); // DECLARE + void DefXXX(); // DEFxxx + void Dim(); // DIM + void ReDim(); // ReDim(); + void Erase(); // ERASE + void Exit(); // EXIT + void For(); // FOR...NEXT + void Goto(); // GOTO / GOSUB + void If(); // IF + void Implements(); // IMPLEMENTS + void Input(); // INPUT, INPUT # + void Line(); // LINE -> LINE INPUT [#] (#i92642) + void LineInput(); // LINE INPUT, LINE INPUT # + void LSet(); // LSET + void Name(); // NAME .. AS .. + void On(); // ON ERROR/variable + void OnGoto(); // ON...GOTO / GOSUB + void Open(); // OPEN + void Option(); // OPTION + void Print(); // PRINT, PRINT # + void SubFunc(); // SUB / FUNCTION + void Resume(); // RESUME + void Return(); // RETURN + void RSet(); // RSET + void DoLoop(); // DO...LOOP + void Select(); // SELECT ... CASE + void Set(); // SET + void Static(); // STATIC + void Stop(); // STOP/SYSTEM + void Type(); // TYPE...AS...END TYPE + void Enum(); // TYPE...END ENUM + void While(); // WHILE/WEND + void With(); // WITH + void Write(); // WRITE +}; + + + + + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/propacc.hxx b/basic/source/inc/propacc.hxx new file mode 100644 index 000000000000..1497bbc0df9d --- /dev/null +++ b/basic/source/inc/propacc.hxx @@ -0,0 +1,195 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SFX_PROPBAG_HXX +#define _SFX_PROPBAG_HXX + +#include <svl/svarray.hxx> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XPropertySetInfo.hpp> +#include <com/sun/star/beans/XPropertyAccess.hpp> +#include <com/sun/star/beans/XPropertyContainer.hpp> +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/implbase2.hxx> + +#define NS_BEANS ::com::sun::star::beans +#define NS_LANG ::com::sun::star::lang +#define NS_UNO ::com::sun::star::uno + +typedef NS_BEANS::PropertyValue* SbPropertyValuePtr; +SV_DECL_PTRARR( SbPropertyValueArr_Impl, SbPropertyValuePtr, 4, 4 ) + +typedef ::cppu::WeakImplHelper2< NS_BEANS::XPropertySet, + NS_BEANS::XPropertyAccess > SbPropertyValuesHelper; + + +//========================================================================== + +class SbPropertyValues: public SbPropertyValuesHelper +{ + SbPropertyValueArr_Impl _aPropVals; + NS_UNO::Reference< ::com::sun::star::beans::XPropertySetInfo > _xInfo; + +private: + sal_Int32 GetIndex_Impl( const ::rtl::OUString &rPropName ) const; + +public: + SbPropertyValues(); + virtual ~SbPropertyValues(); + + // XPropertySet + virtual NS_UNO::Reference< NS_BEANS::XPropertySetInfo > SAL_CALL + getPropertySetInfo(void) throw( NS_UNO::RuntimeException ); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& aPropertyName, + const NS_UNO::Any& aValue) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual NS_UNO::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) + throw( NS_BEANS::UnknownPropertyException, + NS_LANG::WrappedTargetException, + NS_UNO::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& aPropertyName, + const NS_UNO::Reference< NS_BEANS::XPropertyChangeListener >& ) + throw (); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& aPropertyName, + const NS_UNO::Reference< NS_BEANS::XPropertyChangeListener >& ) + throw (); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& aPropertyName, + const NS_UNO::Reference< NS_BEANS::XVetoableChangeListener >& ) + throw (); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& aPropertyName, + const NS_UNO::Reference< NS_BEANS::XVetoableChangeListener >& ) + throw (); + + // XPropertyAccess + virtual NS_UNO::Sequence< NS_BEANS::PropertyValue > SAL_CALL getPropertyValues(void) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValues(const NS_UNO::Sequence< NS_BEANS::PropertyValue >& PropertyValues_) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); +}; + +//========================================================================== + +typedef ::cppu::WeakImplHelper1< NS_BEANS::XPropertySetInfo > SbPropertySetInfoHelper; + +// AB 20.3.2000 Help Class for XPropertySetInfo implementation +class PropertySetInfoImpl +{ + friend class SbPropertySetInfo; + friend class SbPropertyContainer; + + NS_UNO::Sequence< NS_BEANS::Property > _aProps; + + sal_Int32 GetIndex_Impl( const ::rtl::OUString &rPropName ) const; + +public: + PropertySetInfoImpl(); + PropertySetInfoImpl( NS_UNO::Sequence< NS_BEANS::Property >& rProps ); + + // XPropertySetInfo + NS_UNO::Sequence< NS_BEANS::Property > SAL_CALL getProperties(void) throw (); + NS_BEANS::Property SAL_CALL getPropertyByName(const ::rtl::OUString& Name) + throw( NS_UNO::RuntimeException ); + sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& Name) + throw ( NS_UNO::RuntimeException ); +}; + +class SbPropertySetInfo: public SbPropertySetInfoHelper +{ + PropertySetInfoImpl aImpl; + +public: + SbPropertySetInfo(); + SbPropertySetInfo( const SbPropertyValueArr_Impl &rPropVals ); + virtual ~SbPropertySetInfo(); + + // XPropertySetInfo + virtual NS_UNO::Sequence< NS_BEANS::Property > SAL_CALL getProperties(void) + throw( NS_UNO::RuntimeException ); + virtual NS_BEANS::Property SAL_CALL getPropertyByName(const ::rtl::OUString& Name) + throw( NS_UNO::RuntimeException ); + virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& Name) + throw( NS_UNO::RuntimeException ); +}; + +//========================================================================== + +typedef ::cppu::WeakImplHelper2< NS_BEANS::XPropertySetInfo, NS_BEANS::XPropertyContainer > SbPropertyContainerHelper; + +class SbPropertyContainer: public SbPropertyContainerHelper +{ + PropertySetInfoImpl aImpl; + +public: + SbPropertyContainer(); + virtual ~SbPropertyContainer(); + + // XPropertyContainer + virtual void SAL_CALL addProperty( const ::rtl::OUString& Name, + sal_Int16 Attributes, + const NS_UNO::Any& DefaultValue) + throw( NS_BEANS::PropertyExistException, NS_BEANS::IllegalTypeException, + NS_LANG::IllegalArgumentException, NS_UNO::RuntimeException ); + virtual void SAL_CALL removeProperty(const ::rtl::OUString& Name) + throw( NS_BEANS::UnknownPropertyException, NS_UNO::RuntimeException ); + + // XPropertySetInfo + virtual NS_UNO::Sequence< NS_BEANS::Property > SAL_CALL getProperties(void) throw(); + virtual NS_BEANS::Property SAL_CALL getPropertyByName(const ::rtl::OUString& Name) + throw( NS_UNO::RuntimeException ); + virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& Name) + throw( NS_UNO::RuntimeException ); + + // XPropertyAccess + virtual NS_UNO::Sequence< NS_BEANS::PropertyValue > SAL_CALL getPropertyValues(void); + virtual void SAL_CALL setPropertyValues(const NS_UNO::Sequence< NS_BEANS::PropertyValue >& PropertyValues_); +}; + +//========================================================================= + +class StarBASIC; +class SbxArray; + +void RTL_Impl_CreatePropertySet( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ); + + +#undef NS_BEANS +#undef NS_LANG +#undef NS_UNO + + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/runtime.hxx b/basic/source/inc/runtime.hxx new file mode 100644 index 000000000000..3ef1c3f849e6 --- /dev/null +++ b/basic/source/inc/runtime.hxx @@ -0,0 +1,506 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SBRUNTIME_HXX +#define _SBRUNTIME_HXX + +#include <basic/sbx.hxx> + +#include "sb.hxx" + +#include <rtl/ustring.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <osl/file.hxx> +#include <rtl/math.hxx> +#include <i18npool/lang.h> + +#include <vector> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/container/XEnumeration.hpp> +#include <unotools/localedatawrapper.hxx> + +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::container; + + +namespace basicEncoder +{ + +// TODO: Use exported functionality (code is copied from deamons2/ucb) +class AsciiEncoder +{ +public: + static ::rtl::OUString decodeUnoUrlParamValue(const rtl::OUString & rSource); +}; + +} + +class SbiInstance; // aktiver StarBASIC-Prozess +class SbiRuntime; // aktive StarBASIC-Prozedur-Instanz + +struct SbiArgvStack; // Argv stack element +struct SbiGosubStack; // GOSUB stack element +class SbiImage; // Code-Image +class SbiIoSystem; // Dateisystem +class SbiDdeControl; // DDE-Steuerung +class SbiDllMgr; // Aufrufe in DLLs +class SvNumberFormatter; // Zeit/Datumsfunktionen + +enum ForType +{ + FOR_TO, + FOR_EACH_ARRAY, + FOR_EACH_COLLECTION, + FOR_EACH_XENUMERATION +}; + +struct SbiForStack { // for/next stack: + SbiForStack* pNext; // Chain + SbxVariableRef refVar; // loop variable + SbxVariableRef refEnd; // end expression / for each: Array/BasicCollection object + SbxVariableRef refInc; // increment expression + + // For each support + ForType eForType; + sal_Int32 nCurCollectionIndex; + sal_Int32* pArrayCurIndices; + sal_Int32* pArrayLowerBounds; + sal_Int32* pArrayUpperBounds; + Reference< XEnumeration > xEnumeration; + + SbiForStack( void ) + : pArrayCurIndices( NULL ) + , pArrayLowerBounds( NULL ) + , pArrayUpperBounds( NULL ) + {} + ~SbiForStack() + { + delete[] pArrayCurIndices; + delete[] pArrayLowerBounds; + delete[] pArrayUpperBounds; + } +}; + +struct SbiGosubStack { // GOSUB-Stack: + SbiGosubStack* pNext; // Chain + const sal_uInt8* pCode; // Return-Pointer + sal_uInt16 nStartForLvl; // #118235: For Level in moment of gosub +}; + +#define MAXRECURSION 500 // max. 500 Rekursionen + +#define Sb_ATTR_NORMAL 0x0000 +#define Sb_ATTR_HIDDEN 0x0002 +#define Sb_ATTR_SYSTEM 0x0004 +#define Sb_ATTR_VOLUME 0x0008 +#define Sb_ATTR_DIRECTORY 0x0010 +#define Sb_ATTR_ARCHIVE 0x0020 + + +class Dir; +class WildCard; + +class SbiRTLData +{ +public: + + ::osl::Directory* pDir; + sal_Int16 nDirFlags; + short nCurDirPos; + + String sFullNameToBeChecked; + WildCard* pWildCard; + + Sequence< ::rtl::OUString > aDirSeq; + + SbiRTLData(); + ~SbiRTLData(); +}; + +// Die Instanz entspricht einem laufenden StarBASIC. Mehrere gleichzeitig +// laufende BASICs werden ueber verkettete Instanzen verwaltet. Hier liegen +// alle Daten, die nur leben, wenn BASIC auch lebt, wie z.B. das I/O-System. + +typedef ::std::vector +< + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > +> +ComponentVector_t; + + +class SbiInstance +{ + friend class SbiRuntime; + + SbiRTLData aRTLData; + + SbiIoSystem* pIosys; // Dateisystem + SbiDdeControl* pDdeCtrl; // DDE + SbiDllMgr* pDllMgr; // DLL-Calls (DECLARE) + StarBASIC* pBasic; + SvNumberFormatter* pNumberFormatter; + LanguageType meFormatterLangType; + DateFormat meFormatterDateFormat; + sal_uInt32 nStdDateIdx, nStdTimeIdx, nStdDateTimeIdx; + + SbError nErr; // aktueller Fehlercode + String aErrorMsg; // letzte Error-Message fuer $ARG + sal_uInt16 nErl; // aktuelle Fehlerzeile + sal_Bool bReschedule; // Flag: sal_True = Reschedule in Hauptschleife + sal_Bool bCompatibility; // Flag: sal_True = VBA runtime compatibility mode + + ComponentVector_t ComponentVector; +public: + SbiRuntime* pRun; // Call-Stack + SbiInstance* pNext; // Instanzen-Chain + + // #31460 Neues Konzept fuer StepInto/Over/Out, + // Erklaerung siehe runtime.cxx bei SbiInstance::CalcBreakCallLevel() + sal_uInt16 nCallLvl; // Call-Level (wg. Rekursion) + sal_uInt16 nBreakCallLvl; // Call-Level zum Anhalten + void CalcBreakCallLevel( sal_uInt16 nFlags ); // Gemaess Flags setzen + + SbiInstance( StarBASIC* ); + ~SbiInstance(); + + void Error( SbError ); // trappable Error + void Error( SbError, const String& rMsg ); // trappable Error mit Message + void ErrorVB( sal_Int32 nVBNumber, const String& rMsg ); + void setErrorVB( sal_Int32 nVBNumber, const String& rMsg ); + void FatalError( SbError ); // non-trappable Error + void FatalError( SbError, const String& ); // non-trappable Error + void Abort(); // Abbruch mit aktuellem Fehlercode + + void Stop(); + SbError GetErr() { return nErr; } + String GetErrorMsg() { return aErrorMsg; } + xub_StrLen GetErl() { return nErl; } + void EnableReschedule( sal_Bool bEnable ) { bReschedule = bEnable; } + sal_Bool IsReschedule( void ) { return bReschedule; } + void EnableCompatibility( sal_Bool bEnable ) { bCompatibility = bEnable; } + sal_Bool IsCompatibility( void ) { return bCompatibility; } + + ComponentVector_t& getComponentVector( void ) { return ComponentVector; } + + SbMethod* GetCaller( sal_uInt16 ); + SbModule* GetActiveModule(); + SbxArray* GetLocals( SbMethod* ); + + SbiIoSystem* GetIoSystem() { return pIosys; } + SbiDdeControl* GetDdeControl() { return pDdeCtrl; } + StarBASIC* GetBasic( void ) { return pBasic; } + SbiDllMgr* GetDllMgr(); + SbiRTLData* GetRTLData() const { return (SbiRTLData*)&aRTLData; } + + SvNumberFormatter* GetNumberFormatter(); + sal_uInt32 GetStdDateIdx() const { return nStdDateIdx; } + sal_uInt32 GetStdTimeIdx() const { return nStdTimeIdx; } + sal_uInt32 GetStdDateTimeIdx() const { return nStdDateTimeIdx; } + + // NumberFormatter auch statisch anbieten + static void PrepareNumberFormatter( SvNumberFormatter*& rpNumberFormatter, + sal_uInt32 &rnStdDateIdx, sal_uInt32 &rnStdTimeIdx, sal_uInt32 &rnStdDateTimeIdx, + LanguageType* peFormatterLangType=NULL, DateFormat* peFormatterDateFormat=NULL ); +}; + +SbiIoSystem* SbGetIoSystem(); // das aktuelle I/O-System + + +// Verkettbare Items, um Referenzen temporaer zu halten +struct RefSaveItem +{ + SbxVariableRef xRef; + RefSaveItem* pNext; + + RefSaveItem() { pNext = NULL; } +}; + + +// Eine Instanz dieser Klasse wird fuer jedes ausgefuehrte Unterprogramm +// aufgesetzt. Diese Instanz ist das Herz der BASIC-Maschine und enthaelt +// nur lokale Daten. + +class SbiRuntime +{ + friend void SbRtl_CallByName( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ); + + typedef void( SbiRuntime::*pStep0 )(); + typedef void( SbiRuntime::*pStep1 )( sal_uInt32 nOp1 ); + typedef void( SbiRuntime::*pStep2 )( sal_uInt32 nOp1, sal_uInt32 nOp2 ); + static pStep0 aStep0[]; // Opcode-Tabelle Gruppe 0 + static pStep1 aStep1[]; // Opcode-Tabelle Gruppe 1 + static pStep2 aStep2[]; // Opcode-Tabelle Gruppe 2 + + StarBASIC& rBasic; // StarBASIC-Instanz + SbiInstance* pInst; // aktiver Thread + SbModule* pMod; // aktuelles Modul + SbMethod* pMeth; // Methoden-Instanz + SbiIoSystem* pIosys; // I/O-System + const SbiImage* pImg; // Code-Image + SbxArrayRef refExprStk; // expression stack + SbxArrayRef refCaseStk; // CASE expression stack + SbxArrayRef refRedimpArray; // Array saved to use for REDIM PRESERVE + SbxVariableRef refRedim; // Array saved to use for REDIM + SbxVariableRef xDummyVar; // Ersatz fuer nicht gefundene Variablen + SbxVariable* mpExtCaller; // Caller ( external - e.g. button name, shape, range object etc. - only in vba mode ) + SbiArgvStack* pArgvStk; // ARGV-Stack + SbiGosubStack* pGosubStk; // GOSUB stack + SbiForStack* pForStk; // FOR/NEXT-Stack + sal_uInt16 nExprLvl; // Tiefe des Expr-Stacks + sal_uInt16 nGosubLvl; // Zum Vermeiden von Tot-Rekursionen + sal_uInt16 nForLvl; // #118235: Maintain for level + const sal_uInt8* pCode; // aktueller Code-Pointer + const sal_uInt8* pStmnt; // Beginn des lezten Statements + const sal_uInt8* pError; // Adresse des aktuellen Error-Handlers + const sal_uInt8* pRestart; // Restart-Adresse + const sal_uInt8* pErrCode; // Restart-Adresse RESUME NEXT + const sal_uInt8* pErrStmnt; // Restart-Adresse RESUMT 0 + String aLibName; // Lib-Name fuer Declare-Call + SbxArrayRef refParams; // aktuelle Prozedur-Parameter + SbxArrayRef refLocals; // lokale Variable + SbxArrayRef refArgv; // aktueller Argv + // #74254, Ein refSaveObj reicht nicht! Neu: pRefSaveList (s.u.) + short nArgc; // aktueller Argc + sal_Bool bRun; // sal_True: Programm ist aktiv + sal_Bool bError; // sal_True: Fehler behandeln + sal_Bool bInError; // sal_True: in einem Fehler-Handler + sal_Bool bBlocked; // sal_True: blocked by next call level, #i48868 + sal_Bool bVBAEnabled; + sal_uInt16 nFlags; // Debugging-Flags + SbError nError; // letzter Fehler + sal_uInt16 nOps; // Opcode-Zaehler + sal_uInt32 m_nLastTime; + + RefSaveItem* pRefSaveList; // #74254 Temporaere Referenzen sichern + RefSaveItem* pItemStoreList; // Unbenutzte Items aufbewahren + void SaveRef( SbxVariable* pVar ) + { + RefSaveItem* pItem = pItemStoreList; + if( pItem ) + pItemStoreList = pItem->pNext; + else + pItem = new RefSaveItem(); + pItem->pNext = pRefSaveList; + pItem->xRef = pVar; + pRefSaveList = pItem; + } + void ClearRefs( void ) + { + while( pRefSaveList ) + { + RefSaveItem* pToClearItem = pRefSaveList; + pRefSaveList = pToClearItem->pNext; + pToClearItem->xRef = NULL; + pToClearItem->pNext = pItemStoreList; + pItemStoreList = pToClearItem; + } + } + + SbxVariable* FindElement + ( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt32 nOp2, SbError, sal_Bool bLocal, sal_Bool bStatic = sal_False ); + void SetupArgs( SbxVariable*, sal_uInt32 ); + SbxVariable* CheckArray( SbxVariable* ); + + void PushVar( SbxVariable* ); // Variable push + SbxVariableRef PopVar(); // Variable pop + SbxVariable* GetTOS( short=0 ); // Variable vom TOS holen + void TOSMakeTemp(); // TOS in temp. Variable wandeln + sal_Bool ClearExprStack(); // Expr-Stack freigeben + + void PushGosub( const sal_uInt8* ); // GOSUB-Element push + void PopGosub(); // GOSUB-Element pop + void ClearGosubStack(); // GOSUB-Stack freigeben + + void PushArgv(); // Argv-Element push + void PopArgv(); // Argv-Element pop + void ClearArgvStack(); // Argv-Stack freigeben + + void PushFor(); // For-Element push + void PushForEach(); // For-Each-Element push + void PopFor(); // For-Element pop + void ClearForStack(); // For-Stack freigeben + + void StepArith( SbxOperator ); // arithmetische Verknuepfungen + void StepUnary( SbxOperator ); // unaere Verknuepfungen + void StepCompare( SbxOperator );// Vergleiche + + void SetParameters( SbxArray* );// Parameter uebernehmen + + // MUSS NOCH IMPLEMENTIERT WERDEN + void DllCall( const String&, const String&, SbxArray*, SbxDataType, sal_Bool ); + + // #56204 DIM-Funktionalitaet in Hilfsmethode auslagern (step0.cxx) + void DimImpl( SbxVariableRef refVar ); + + bool implIsClass( SbxObject* pObj, const String& aClass ); + + void StepSETCLASS_impl( sal_uInt32 nOp1, bool bHandleDflt = false ); + + // Die nachfolgenden Routinen werden vom Single Stepper + // gerufen und implementieren die einzelnen Opcodes + void StepNOP(), StepEXP(), StepMUL(), StepDIV(); + void StepMOD(), StepPLUS(), StepMINUS(), StepNEG(); + void StepEQ(), StepNE(), StepLT(), StepGT(); + void StepLE(), StepGE(), StepIDIV(), StepAND(); + void StepOR(), StepXOR(), StepEQV(), StepIMP(); + void StepNOT(), StepCAT(), StepLIKE(), StepIS(); + void StepCLONE(), StepOLDBASED(), StepARGC(); + void StepARGV(), StepINPUT(), StepLINPUT(), StepSTOP(); + void StepGET(), StepSET(), StepVBASET(), StepPUT(), StepPUTC(); + void StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, bool bDefaultHandling = false ); + void StepDIM(), StepREDIM(), StepREDIMP(), StepERASE(); + void StepINITFOR(), StepNEXT(), StepERROR(), StepINITFOREACH(); + void StepCASE(), StepENDCASE(), StepSTDERROR(); + void StepNOERROR(), StepCHANNEL(), StepCHANNEL0(), StepPRINT(); + void StepPRINTF(), StepWRITE(), StepRENAME(), StepPROMPT(); + void StepRESTART(), StepEMPTY(), StepLEAVE(); + void StepLSET(), StepRSET(), StepREDIMP_ERASE(), StepERASE_CLEAR(); + void StepARRAYACCESS(), StepBYVAL(); + // Alle Opcodes mit einem Operanden + void StepLOADNC( sal_uInt32 ), StepLOADSC( sal_uInt32 ), StepLOADI( sal_uInt32 ); + void StepARGN( sal_uInt32 ), StepBASED( sal_uInt32 ), StepPAD( sal_uInt32 ); + void StepJUMP( sal_uInt32 ), StepJUMPT( sal_uInt32 ); + void StepJUMPF( sal_uInt32 ), StepONJUMP( sal_uInt32 ); + void StepGOSUB( sal_uInt32 ), StepRETURN( sal_uInt32 ); + void StepTESTFOR( sal_uInt32 ), StepCASETO( sal_uInt32 ), StepERRHDL( sal_uInt32 ); + void StepRESUME( sal_uInt32 ), StepSETCLASS( sal_uInt32 ), StepVBASETCLASS( sal_uInt32 ), StepTESTCLASS( sal_uInt32 ), StepLIB( sal_uInt32 ); + bool checkClass_Impl( const SbxVariableRef& refVal, const String& aClass, bool bRaiseErrors, bool bDefault = true ); + void StepCLOSE( sal_uInt32 ), StepPRCHAR( sal_uInt32 ), StepARGTYP( sal_uInt32 ); + // Alle Opcodes mit zwei Operanden + void StepRTL( sal_uInt32, sal_uInt32 ), StepPUBLIC( sal_uInt32, sal_uInt32 ), StepPUBLIC_P( sal_uInt32, sal_uInt32 ); + void StepPUBLIC_Impl( sal_uInt32, sal_uInt32, bool bUsedForClassModule ); + void StepFIND_Impl( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt32 nOp2, SbError, sal_Bool bLocal, sal_Bool bStatic = sal_False ); + void StepFIND( sal_uInt32, sal_uInt32 ), StepELEM( sal_uInt32, sal_uInt32 ); + void StepGLOBAL( sal_uInt32, sal_uInt32 ), StepLOCAL( sal_uInt32, sal_uInt32 ); + void StepPARAM( sal_uInt32, sal_uInt32), StepCREATE( sal_uInt32, sal_uInt32 ); + void StepCALL( sal_uInt32, sal_uInt32 ), StepCALLC( sal_uInt32, sal_uInt32 ); + void StepCASEIS( sal_uInt32, sal_uInt32 ), StepSTMNT( sal_uInt32, sal_uInt32 ); + SbxVariable* StepSTATIC_Impl( String& aName, SbxDataType& t ); + void StepOPEN( sal_uInt32, sal_uInt32 ), StepSTATIC( sal_uInt32, sal_uInt32 ); + void StepTCREATE(sal_uInt32,sal_uInt32), StepDCREATE(sal_uInt32,sal_uInt32); + void StepGLOBAL_P( sal_uInt32, sal_uInt32 ),StepFIND_G( sal_uInt32, sal_uInt32 ); + void StepDCREATE_REDIMP(sal_uInt32,sal_uInt32), StepDCREATE_IMPL(sal_uInt32,sal_uInt32); + void StepFIND_CM( sal_uInt32, sal_uInt32 ); + void StepFIND_STATIC( sal_uInt32, sal_uInt32 ); + void implHandleSbxFlags( SbxVariable* pVar, SbxDataType t, sal_uInt32 nOp2 ); +public: + void SetVBAEnabled( bool bEnabled ); + sal_uInt16 GetImageFlag( sal_uInt16 n ) const; + sal_uInt16 GetBase(); + xub_StrLen nLine,nCol1,nCol2; // aktuelle Zeile, Spaltenbereich + SbiRuntime* pNext; // Stack-Chain + + SbiRuntime( SbModule*, SbMethod*, sal_uInt32 ); + ~SbiRuntime(); + void Error( SbError, bool bVBATranslationAlreadyDone = false ); // Fehler setzen, falls != 0 + void Error( SbError, const String& ); // Fehler setzen, falls != 0 + void FatalError( SbError ); // Fehlerbehandlung=Standard, Fehler setzen + void FatalError( SbError, const String& ); // Fehlerbehandlung=Standard, Fehler setzen + static sal_Int32 translateErrorToVba( SbError nError, String& rMsg ); + void DumpPCode(); + sal_Bool Step(); // Einzelschritt (ein Opcode) + void Stop() { bRun = sal_False; } + sal_Bool IsRun() { return bRun; } + void block( void ) { bBlocked = sal_True; } + void unblock( void ) { bBlocked = sal_False; } + SbMethod* GetMethod() { return pMeth; } + SbModule* GetModule() { return pMod; } + sal_uInt16 GetDebugFlags() { return nFlags; } + void SetDebugFlags( sal_uInt16 nFl ) { nFlags = nFl; } + SbMethod* GetCaller(); + SbxArray* GetLocals(); + SbxArray* GetParams(); + SbxVariable* GetExternalCaller(){ return mpExtCaller; } + + SbxBase* FindElementExtern( const String& rName ); + static bool isVBAEnabled(); + +}; + +inline void checkArithmeticOverflow( double d ) +{ + if( !::rtl::math::isFinite( d ) ) + StarBASIC::Error( SbERR_MATH_OVERFLOW ); +} + +inline void checkArithmeticOverflow( SbxVariable* pVar ) +{ + if( pVar->GetType() == SbxDOUBLE ) + { + double d = pVar->GetDouble(); + checkArithmeticOverflow( d ); + } +} + +// Hilfsfunktion, um aktives Basic zu finden +StarBASIC* GetCurrentBasic( StarBASIC* pRTBasic ); + +// Get information if security restrictions should be +// used (File IO based on UCB, no RTL function SHELL +// no DDE functionality, no DLLCALL) in basic because +// of portal "virtual" users (portal user != UNIX user) +// (Implemented in iosys.cxx) +sal_Bool needSecurityRestrictions( void ); + +// Returns sal_True if UNO is available, otherwise the old +// file system implementation has to be used +// (Implemented in iosys.cxx) +sal_Bool hasUno( void ); + +// Converts possibly relative paths to absolute paths +// according to the setting done by ChDir/ChDrive +// (Implemented in methods.cxx) +String getFullPath( const String& aRelPath ); + +// Sets (virtual) current path for UCB file access +void implChDir( const String& aDir ); + +// Sets (virtual) current drive for UCB file access +void implChDrive( const String& aDrive ); + +// Returns (virtual) current path for UCB file access +String implGetCurDir( void ); + +// Implementation of StepRENAME with UCB +// (Implemented in methods.cxx, so step0.cxx +// has not to be infected with UNO) +void implStepRenameUCB( const String& aSource, const String& aDest ); + +//*** OSL file access *** +// #87427 OSL need File URLs, so map to getFullPath +inline String getFullPathUNC( const String& aRelPath ) +{ + return getFullPath( aRelPath ); +} +void implStepRenameOSL( const String& aSource, const String& aDest ); +bool IsBaseIndexOne(); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/sbcomp.hxx b/basic/source/inc/sbcomp.hxx new file mode 100644 index 000000000000..2918e67880f0 --- /dev/null +++ b/basic/source/inc/sbcomp.hxx @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SBCOMP_HXX +#define _SBCOMP_HXX + +// das folgende habe ich der neuen Datei von MD entnommen! (MT) +#include "sbintern.hxx" +#include "token.hxx" // Tokenizer +#include "symtbl.hxx" // Symbolverwaltung +#include "parser.hxx" // Parser +#include "codegen.hxx" // Code-Generator + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/sbdiagnose.hxx b/basic/source/inc/sbdiagnose.hxx new file mode 100644 index 000000000000..065efdb183e1 --- /dev/null +++ b/basic/source/inc/sbdiagnose.hxx @@ -0,0 +1,34 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2011 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef BASIC_SBDIAGNOSE_HXX +#define BASIC_SBDIAGNOSE_HXX + +#ifdef DBG_UTIL +void ResetCapturedAssertions(); +#endif + +#endif // BASIC_SBDIAGNOSE_HXX diff --git a/basic/source/inc/sbintern.hxx b/basic/source/inc/sbintern.hxx new file mode 100644 index 000000000000..34d08f6e8c21 --- /dev/null +++ b/basic/source/inc/sbintern.hxx @@ -0,0 +1,152 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SB_INTERN_HXX +#define _SB_INTERN_HXX + +#include <basic/sbxfac.hxx> +#include <unotools/transliterationwrapper.hxx> +#include "sb.hxx" + +namespace utl +{ + class TransliterationWrapper; +} +class SbUnoFactory; +class SbTypeFactory; +class SbOLEFactory; +class SbFormFactory; +class SbiInstance; +class SbModule; + +class SbiFactory : public SbxFactory +{ +public: + virtual SbxBase* Create( sal_uInt16 nSbxId, sal_uInt32 = SBXCR_SBX ); + virtual SbxObject* CreateObject( const String& ); +}; + +typedef ::std::vector< String > StringVector; + +struct SbClassData +{ + SbxArrayRef mxIfaces; + + // types this module depends on because of use in Dim As New <type> + // needed for initialization order of class modules + StringVector maRequiredTypes; + + SbClassData( void ); + ~SbClassData( void ) + { clear(); } + void clear( void ); +}; + +// #115824: Factory class to create class objects (type command) +// Implementation: sb.cxx +class SbClassFactory : public SbxFactory +{ + SbxObjectRef xClassModules; + +public: + SbClassFactory( void ); + virtual ~SbClassFactory(); + + void AddClassModule( SbModule* pClassModule ); + void RemoveClassModule( SbModule* pClassModule ); + + virtual SbxBase* Create( sal_uInt16 nSbxId, sal_uInt32 = SBXCR_SBX ); + virtual SbxObject* CreateObject( const String& ); + + SbModule* FindClass( const String& rClassName ); +}; + +// Stack fuer die im Fehlerfall abgebaute SbiRuntime Kette +class SbErrorStackEntry +{ +public: + SbErrorStackEntry(SbMethodRef aM, xub_StrLen nL, xub_StrLen nC1, xub_StrLen nC2) + : aMethod(aM), nLine(nL), nCol1(nC1), nCol2(nC2) {} + SbMethodRef aMethod; + xub_StrLen nLine; + xub_StrLen nCol1, nCol2; +}; + +SV_DECL_PTRARR_DEL(SbErrorStack, SbErrorStackEntry*, 1, 1) + + + +struct SbiGlobals +{ + SbiInstance* pInst; // alle aktiven Runtime-Instanzen + SbiFactory* pSbFac; // StarBASIC-Factory + SbUnoFactory* pUnoFac; // Factory fuer Uno-Structs bei DIM AS NEW + SbTypeFactory* pTypeFac; // Factory for user defined types + SbClassFactory* pClassFac; // Factory for user defined classes (based on class modules) + SbOLEFactory* pOLEFac; // Factory for OLE types + SbFormFactory* pFormFac; // Factory for user forms + SbModule* pMod; // aktuell aktives Modul + SbModule* pCompMod; // aktuell compiliertes Modul + short nInst; // Anzahl BASICs + Link aErrHdl; // globaler Error-Handler + Link aBreakHdl; // globaler Break-Handler + SbError nCode; // aktueller Fehlercode + xub_StrLen nLine; // aktuelle Zeile + xub_StrLen nCol1,nCol2; // aktuelle Spalten (von,bis) + sal_Bool bCompiler; // Flag fuer Compiler-Error + sal_Bool bGlobalInitErr; // Beim GlobalInit trat ein Compiler-Fehler auf + sal_Bool bRunInit; // sal_True, wenn RunInit vom Basic aktiv ist + String aErrMsg; // Puffer fuer GetErrorText() + SbLanguageMode eLanguageMode; // Flag fuer Visual-Basic-Script-Modus + SbErrorStack* pErrStack; // Stack fuer die im Fehlerfall abgebaute SbiRuntime Kette + ::utl::TransliterationWrapper* pTransliterationWrapper; // For StrComp + sal_Bool bBlockCompilerError; + BasicManager* pAppBasMgr; + StarBASIC* pMSOMacroRuntimLib; // Lib containing MSO Macro Runtime API entry symbols + + SbiGlobals(); + ~SbiGlobals(); +}; + +// Utility-Makros und -Routinen + +SbiGlobals* GetSbData(); + +#define pINST GetSbData()->pInst +#define pMOD GetSbData()->pMod +#define pCMOD GetSbData()->pCompMod +#define pSBFAC GetSbData()->pSbFac +#define pUNOFAC GetSbData()->pUnoFac +#define pTYPEFAC GetSbData()->pTypeFac +#define pCLASSFAC GetSbData()->pClassFac +#define pOLEFAC GetSbData()->pOLEFac +#define pFORMFAC GetSbData()->pFormFac + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/sbjsmeth.hxx b/basic/source/inc/sbjsmeth.hxx new file mode 100644 index 000000000000..f2cc8a3d3865 --- /dev/null +++ b/basic/source/inc/sbjsmeth.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifndef _SB_SBJSMETH_HXX +#define _SB_SBJSMETH_HXX + +#include <basic/sbmeth.hxx> + +// Basic-Modul fuer JavaScript-Sourcen. +// Alle Basic-spezifischen Methoden muessen virtuell ueberladen und deaktiviert +// werden. Die Unterscheidung von normalen Modulen erfolgt uebr RTTI. + +class SbJScriptMethod : public SbMethod +{ +public: + SbJScriptMethod( const String&, SbxDataType, SbModule* ); + virtual ~SbJScriptMethod(); + + SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_JSCRIPTMETH,2); + TYPEINFO(); +}; + +#ifndef __SB_SBJSCRIPTMETHODREF_HXX +#define __SB_SBJSCRIPTMETHODREF_HXX +SV_DECL_IMPL_REF(SbJScriptMethod) +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/sbjsmod.hxx b/basic/source/inc/sbjsmod.hxx new file mode 100644 index 000000000000..55091dc681c5 --- /dev/null +++ b/basic/source/inc/sbjsmod.hxx @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SB_SBJSMOD_HXX +#define _SB_SBJSMOD_HXX + +#include <basic/sbmod.hxx> + +// Basic-Modul fuer JavaScript-Sourcen. +// Alle Basic-spezifischen Methoden muessen virtuell ueberladen und deaktiviert +// werden. Die Unterscheidung von normalen Modulen erfolgt uebr RTTI. + +class SbJScriptModule : public SbModule +{ + virtual sal_Bool LoadData( SvStream&, sal_uInt16 ); + virtual sal_Bool StoreData( SvStream& ) const; +public: + SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_JSCRIPTMOD,1); + TYPEINFO(); + SbJScriptModule( const String& ); // DURCHREICHEN +}; + +#endif + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/sbtrace.hxx b/basic/source/inc/sbtrace.hxx new file mode 100644 index 000000000000..50e344fb63d2 --- /dev/null +++ b/basic/source/inc/sbtrace.hxx @@ -0,0 +1,44 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SBTRACE_HXX +#define _SBTRACE_HXX + +//#define DBG_TRACE_BASIC + +#ifdef DBG_TRACE_BASIC +void dbg_InitTrace( void ); +void dbg_DeInitTrace( void ); +void dbg_traceStep( SbModule* pModule, UINT32 nPC, INT32 nCallLvl ); +void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, INT32 nCallLvl, bool bLeave = false ); +void dbg_traceNotifyError( SbError nTraceErr, const String& aTraceErrMsg, bool bTraceErrHandled, INT32 nCallLvl ); +void dbg_RegisterTraceTextForPC( SbModule* pModule, UINT32 nPC, + const String& aTraceStr_STMNT, const String& aTraceStr_PCode ); +void RTL_Impl_TraceCommand( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite ); +#endif + +#endif diff --git a/basic/source/inc/sbunoobj.hxx b/basic/source/inc/sbunoobj.hxx new file mode 100644 index 000000000000..ea3d62c80e7f --- /dev/null +++ b/basic/source/inc/sbunoobj.hxx @@ -0,0 +1,358 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef SB_UNO_OBJ +#define SB_UNO_OBJ + +#include <basic/sbxobj.hxx> +#include <basic/sbxmeth.hxx> +#include <basic/sbxprop.hxx> +#include <basic/sbxfac.hxx> +#include <basic/sbx.hxx> +#include <com/sun/star/beans/XMaterialHolder.hpp> +#include <com/sun/star/beans/XExactName.hpp> +#include <com/sun/star/beans/XIntrospectionAccess.hpp> +#include <com/sun/star/beans/XIntrospection.hpp> +#include <com/sun/star/script/XInvocation.hpp> +#include <com/sun/star/reflection/XIdlClass.hpp> +#include <com/sun/star/reflection/XServiceTypeDescription2.hpp> +#include <com/sun/star/reflection/XSingletonTypeDescription.hpp> +#include <rtl/ustring.hxx> +#include <boost/unordered_map.hpp> +#include <vector> + +class SbUnoObject: public SbxObject +{ + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess > mxUnoAccess; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMaterialHolder > mxMaterialHolder; + ::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > mxInvocation; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XExactName > mxExactName; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XExactName > mxExactNameInvocation; + sal_Bool bNeedIntrospection; + sal_Bool bNativeCOMObject; + ::com::sun::star::uno::Any maTmpUnoObj; // Only to save obj for doIntrospection! + + // Hilfs-Methode zum Anlegen der dbg_-Properties + void implCreateDbgProperties( void ); + + // Hilfs-Methode zum Anlegen aller Properties und Methoden + // (Beim on-demand-Mechanismus erforderlich fuer die dbg_-Properties) + void implCreateAll( void ); + +public: + static bool getDefaultPropName( SbUnoObject* pUnoObj, String& sDfltProp ); + TYPEINFO(); + SbUnoObject( const String& aName_, const ::com::sun::star::uno::Any& aUnoObj_ ); + ~SbUnoObject(); + + // #76470 Introspection on Demand durchfuehren + void doIntrospection( void ); + + // Find ueberladen, um z.B. NameAccess zu unterstuetzen + virtual SbxVariable* Find( const String&, SbxClassType ); + + // Force creation of all properties for debugging + void createAllProperties( void ) + { implCreateAll(); } + + // Wert rausgeben + ::com::sun::star::uno::Any getUnoAny( void ); + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess > getIntrospectionAccess( void ) { return mxUnoAccess; } + ::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > getInvocation( void ) { return mxInvocation; } + + void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& ); + + bool isNativeCOMObject( void ) + { return bNativeCOMObject; } +}; +SV_DECL_IMPL_REF(SbUnoObject); + + +// #67781 Rueckgabewerte der Uno-Methoden loeschen +void clearUnoMethods( void ); +void clearUnoMethodsForBasic( StarBASIC* pBasic ); + +class SbUnoMethod : public SbxMethod +{ + friend class SbUnoObject; + friend void clearUnoMethods( void ); + friend void clearUnoMethodsForBasic( StarBASIC* pBasic ); + + ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlMethod > m_xUnoMethod; + ::com::sun::star::uno::Sequence< ::com::sun::star::reflection::ParamInfo >* pParamInfoSeq; + + // #67781 Verweis auf vorige und naechste Methode in der Methoden-Liste + SbUnoMethod* pPrev; + SbUnoMethod* pNext; + + bool mbInvocation; // Method is based on invocation + bool mbDirectInvocation; // Method should be used with XDirectInvocation interface + +public: + TYPEINFO(); + + SbUnoMethod( const String& aName_, SbxDataType eSbxType, ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlMethod > xUnoMethod_, + bool bInvocation, + bool bDirect = false ); + virtual ~SbUnoMethod(); + virtual SbxInfo* GetInfo(); + + const ::com::sun::star::uno::Sequence< ::com::sun::star::reflection::ParamInfo >& getParamInfos( void ); + + bool isInvocationBased( void ) + { return mbInvocation; } + bool needsDirectInvocation( void ) + { return mbDirectInvocation; } +}; + + +class SbUnoProperty : public SbxProperty +{ + friend class SbUnoObject; + + // Daten der Uno-Property + ::com::sun::star::beans::Property aUnoProp; + sal_Int32 nId; + + bool mbInvocation; // Property is based on invocation + + virtual ~SbUnoProperty(); +public: + TYPEINFO(); + SbUnoProperty( const String& aName_, SbxDataType eSbxType, + const ::com::sun::star::beans::Property& aUnoProp_, sal_Int32 nId_, bool bInvocation ); + + bool isInvocationBased( void ) + { return mbInvocation; } +}; + +// Factory-Klasse fuer das Anlegen von Uno-Structs per DIM AS NEW +class SbUnoFactory : public SbxFactory +{ +public: + virtual SbxBase* Create( sal_uInt16 nSbxId, sal_uInt32 = SBXCR_SBX ); + virtual SbxObject* CreateObject( const String& ); +}; + +// Wrapper fuer eine Uno-Klasse +class SbUnoClass : public SbxObject +{ + const ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass > m_xClass; + +public: + TYPEINFO(); + SbUnoClass( const String& aName_ ) + : SbxObject( aName_ ) + {} + SbUnoClass( const String& aName_, const ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass >& xClass_ ) + : SbxObject( aName_ ) + , m_xClass( xClass_ ) + {} + + // Find ueberladen, um Elemente on Demand anzulegen + virtual SbxVariable* Find( const String&, SbxClassType ); + + // Wert rausgeben + const ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass >& getUnoClass( void ) { return m_xClass; } + +}; +SV_DECL_IMPL_REF(SbUnoClass); + + +// Funktion, um einen globalen Bezeichner im +// UnoScope zu suchen und fuer Sbx zu wrappen +SbUnoClass* findUnoClass( const String& rName ); + + +// Wrapper for UNO Service +class SbUnoService : public SbxObject +{ + const ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XServiceTypeDescription2 > m_xServiceTypeDesc; + bool m_bNeedsInit; + +public: + TYPEINFO(); + SbUnoService( const String& aName_, + const ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XServiceTypeDescription2 >& xServiceTypeDesc ) + : SbxObject( aName_ ) + , m_xServiceTypeDesc( xServiceTypeDesc ) + , m_bNeedsInit( true ) + {} + + virtual SbxVariable* Find( const String&, SbxClassType ); + + void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& ); +}; +SV_DECL_IMPL_REF(SbUnoService); + +SbUnoService* findUnoService( const String& rName ); + + +void clearUnoServiceCtors( void ); + +class SbUnoServiceCtor : public SbxMethod +{ + friend class SbUnoService; + friend void clearUnoServiceCtors( void ); + + ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XServiceConstructorDescription > m_xServiceCtorDesc; + + SbUnoServiceCtor* pPrev; + SbUnoServiceCtor* pNext; + +public: + TYPEINFO(); + + SbUnoServiceCtor( const String& aName_, ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XServiceConstructorDescription > xServiceCtorDesc ); + virtual ~SbUnoServiceCtor(); + virtual SbxInfo* GetInfo(); + + ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XServiceConstructorDescription > getServiceCtorDesc( void ) + { return m_xServiceCtorDesc; } +}; + + +// Wrapper for UNO Singleton +class SbUnoSingleton : public SbxObject +{ + const ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XSingletonTypeDescription > m_xSingletonTypeDesc; + +public: + TYPEINFO(); + SbUnoSingleton( const String& aName_, + const ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XSingletonTypeDescription >& xSingletonTypeDesc ); + + void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& ); +}; +SV_DECL_IMPL_REF(SbUnoSingleton); + +SbUnoSingleton* findUnoSingleton( const String& rName ); + + +// #105565 Special Object to wrap a strongly typed Uno Any +class SbUnoAnyObject: public SbxObject +{ + ::com::sun::star::uno::Any mVal; + +public: + SbUnoAnyObject( const ::com::sun::star::uno::Any& rVal ) + : SbxObject( String() ) + , mVal( rVal ) + {} + + const ::com::sun::star::uno::Any& getValue( void ) + { return mVal; } + + TYPEINFO(); +}; + + +// #112509 Special SbxArray to transport named parameters for calls +// to OLEAutomation objects through the UNO OLE automation bridge + +class AutomationNamedArgsSbxArray : public SbxArray +{ + ::com::sun::star::uno::Sequence< ::rtl::OUString > maNameSeq; +public: + TYPEINFO(); + AutomationNamedArgsSbxArray( sal_Int32 nSeqSize ) + : maNameSeq( nSeqSize ) + {} + + ::com::sun::star::uno::Sequence< ::rtl::OUString >& getNames( void ) + { return maNameSeq; } +}; + + +class StarBASIC; + +// Impl-Methoden fuer RTL +void RTL_Impl_CreateUnoStruct( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ); +void RTL_Impl_CreateUnoService( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ); +void RTL_Impl_CreateUnoServiceWithArguments( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ); +void RTL_Impl_CreateUnoValue( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ); +void RTL_Impl_GetProcessServiceManager( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ); +void RTL_Impl_HasInterfaces( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ); +void RTL_Impl_IsUnoStruct( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ); +void RTL_Impl_EqualUnoObjects( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ); +void RTL_Impl_GetDefaultContext( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ); + +void disposeComVariablesForBasic( StarBASIC* pBasic ); +void clearNativeObjectWrapperVector( void ); + + +//======================================================================== +// #118116 Collection object + +class BasicCollection : public SbxObject +{ + friend class SbiRuntime; + SbxArrayRef xItemArray; + static SbxInfoRef xAddInfo; + static SbxInfoRef xItemInfo; + + void Initialize(); + virtual ~BasicCollection(); + virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, + const SfxHint& rHint, const TypeId& rHintType ); + sal_Int32 implGetIndex( SbxVariable* pIndexVar ); + sal_Int32 implGetIndexForName( const String& rName ); + void CollAdd( SbxArray* pPar_ ); + void CollItem( SbxArray* pPar_ ); + void CollRemove( SbxArray* pPar_ ); + +public: + TYPEINFO(); + BasicCollection( const String& rClassname ); + virtual SbxVariable* Find( const String&, SbxClassType ); + virtual void Clear(); +}; + +typedef boost::unordered_map< ::rtl::OUString, ::com::sun::star::uno::Any, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > VBAConstantsHash; + +typedef std::vector< rtl::OUString > VBAConstantsVector; + +class VBAConstantHelper +{ +private: + + VBAConstantsVector aConstCache; + VBAConstantsHash aConstHash; + bool isInited; + VBAConstantHelper():isInited( false ) {} + VBAConstantHelper(const VBAConstantHelper&); + void init(); +public: + static VBAConstantHelper& instance(); + SbxVariable* getVBAConstant( const String& rName ); + bool isVBAConstantType( const String& rName ); +}; + +#endif + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/scanner.hxx b/basic/source/inc/scanner.hxx new file mode 100644 index 000000000000..5abfc1efdd3c --- /dev/null +++ b/basic/source/inc/scanner.hxx @@ -0,0 +1,147 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SCANNER_HXX +#define _SCANNER_HXX + +#include <tools/string.hxx> +#include <basic/sberrors.hxx> + +// Der Scanner ist stand-alone, d.h. er kann von ueberallher verwendet +// werden. Eine BASIC-Instanz ist fuer Fehlermeldungen notwendig. Ohne +// BASIC werden die Fehler nur gezaehlt. Auch ist Basic notwendig, wenn +// eine erweiterte SBX-Variable zur Erkennung von Datentypen etc. verwendet +// werden soll. + +class StarBASIC; + +class SbiScanner +{ + ::rtl::OUString aBuf; // Input-Puffer + ::rtl::OUString aLine; // aktuelle Zeile + const sal_Unicode* pLine; // Pointer + const sal_Unicode* pSaveLine; // Merker fuer Line +protected: + String aSym; // Symbolpuffer + String aError; // Fehler-String + SbxDataType eScanType; // evtl. Datentyp + StarBASIC* pBasic; // Instanz fuer Fehler-Callbacks + double nVal; // numerischer Wert + short nCurCol1; // aktuelle Spalte 1 + short nSavedCol1; // gerettete Spalte 1 + short nCol; // aktuelle Spaltennummer + short nErrors; // Anzahl Fehler + short nColLock; // Lock-Zaehler fuer Col1 + sal_Int32 nBufPos; // aktuelle Buffer-Pos + sal_uInt16 nLine; // aktuelle Zeile + sal_uInt16 nCol1, nCol2; // aktuelle 1. und 2. Spalte + sal_Bool bSymbol; // sal_True: Symbol gescannt + sal_Bool bNumber; // sal_True: Zahl gescannt + sal_Bool bSpaces; // sal_True: Whitespace vor Token + sal_Bool bErrors; // sal_True: Fehler generieren + sal_Bool bAbort; // sal_True: abbrechen + sal_Bool bHash; // sal_True: # eingelesen + sal_Bool bError; // sal_True: Fehler generieren + sal_Bool bUsedForHilite; // sal_True: Nutzung fuer Highlighting + sal_Bool bCompatible; // sal_True: OPTION Compatibl + sal_Bool bVBASupportOn; // sal_True: OPTION VBASupport 1 otherwise default False + sal_Bool bPrevLineExtentsComment; // sal_True: Previous line is comment and ends on "... _" + + void GenError( SbError ); +public: + SbiScanner( const ::rtl::OUString&, StarBASIC* = NULL ); + ~SbiScanner(); + + void EnableErrors() { bError = sal_False; } + sal_Bool IsHash() { return bHash; } + sal_Bool IsCompatible() { return bCompatible; } + void SetCompatible( bool b ) { bCompatible = b; } // #118206 + sal_Bool IsVBASupportOn() { return bVBASupportOn; } + void SetVBASupportOn( bool b ) { bVBASupportOn = b; } + sal_Bool WhiteSpace() { return bSpaces; } + short GetErrors() { return nErrors; } + short GetLine() { return nLine; } + short GetCol1() { return nCol1; } + short GetCol2() { return nCol2; } + void SetCol1( short n ) { nCol1 = n; } + StarBASIC* GetBasic() { return pBasic; } + void SaveLine(void) { pSaveLine = pLine; } + void RestoreLine(void) { pLine = pSaveLine; } + void LockColumn(); + void UnlockColumn(); + sal_Bool DoesColonFollow(); + + sal_Bool NextSym(); // naechstes Symbol lesen + const String& GetSym() { return aSym; } + SbxDataType GetType() { return eScanType; } + double GetDbl() { return nVal; } +}; + +class LetterTable +{ + bool IsLetterTab[256]; + +public: + LetterTable( void ); + + inline bool isLetter( sal_Unicode c ) + { + bool bRet = (c < 256) ? IsLetterTab[c] : isLetterUnicode( c ); + return bRet; + } + bool isLetterUnicode( sal_Unicode c ); +}; + +class BasicSimpleCharClass +{ + static LetterTable aLetterTable; + +public: + static sal_Bool isAlpha( sal_Unicode c, bool bCompatible ) + { + sal_Bool bRet = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') + || (bCompatible && aLetterTable.isLetter( c )); + return bRet; + } + + static sal_Bool isDigit( sal_Unicode c ) + { + sal_Bool bRet = (c >= '0' && c <= '9'); + return bRet; + } + + static sal_Bool isAlphaNumeric( sal_Unicode c, bool bCompatible ) + { + sal_Bool bRet = isDigit( c ) || isAlpha( c, bCompatible ); + return bRet; + } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/scriptcont.hxx b/basic/source/inc/scriptcont.hxx new file mode 100644 index 000000000000..0966c258380a --- /dev/null +++ b/basic/source/inc/scriptcont.hxx @@ -0,0 +1,204 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef BASIC_SCRIPTCONTAINER_HXX +#define BASIC_SCRIPTCONTAINER_HXX + +#include "namecont.hxx" +#include <basic/basmgr.hxx> +#include <com/sun/star/script/vba/XVBAModuleInfo.hpp> +#include <comphelper/uno3.hxx> + +class BasicManager; + +//============================================================================ + +namespace basic +{ + +class SfxScriptLibraryContainer : public SfxLibraryContainer, public OldBasicPassword +{ + ::rtl::OUString maScriptLanguage; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > mxCodeNameAccess; + + // Methods to distinguish between deffirent library types + virtual SfxLibrary* SAL_CALL implCreateLibrary( const ::rtl::OUString& aName ); + virtual SfxLibrary* SAL_CALL implCreateLibraryLink + ( const ::rtl::OUString& aName, const ::rtl::OUString& aLibInfoFileURL, + const ::rtl::OUString& StorageURL, sal_Bool ReadOnly ); + virtual ::com::sun::star::uno::Any SAL_CALL createEmptyLibraryElement( void ); + virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const; + virtual void SAL_CALL writeLibraryElement + ( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary, + const ::rtl::OUString& aElementName, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutput + ) + throw(::com::sun::star::uno::Exception); + + virtual ::com::sun::star::uno::Any SAL_CALL importLibraryElement + ( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary, + const ::rtl::OUString& aElementName, + const ::rtl::OUString& aFile, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xElementStream ); + + virtual void SAL_CALL importFromOldStorage( const ::rtl::OUString& aFile ); + + virtual SfxLibraryContainer* createInstanceImpl( void ); + + + // Password encryption + virtual sal_Bool implStorePasswordLibrary( SfxLibrary* pLib, const ::rtl::OUString& aName, + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage>& xStorage, const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler ); + + // New variant for library export + virtual sal_Bool implStorePasswordLibrary( SfxLibrary* pLib, const ::rtl::OUString& aName, + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, + const ::rtl::OUString& aTargetURL, + const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > xToUseSFI, const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler ); + + virtual sal_Bool implLoadPasswordLibrary( SfxLibrary* pLib, const ::rtl::OUString& Name, + sal_Bool bVerifyPasswordOnly=false ) + throw(::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + virtual void onNewRootStorage(); + + + // OldBasicPassword interface + virtual void setLibraryPassword( const String& rLibraryName, const String& rPassword ); + virtual String getLibraryPassword( const String& rLibraryName ); + virtual void clearLibraryPassword( const String& rLibraryName ); + virtual sal_Bool hasLibraryPassword( const String& rLibraryName ); + + virtual const sal_Char* SAL_CALL getInfoFileName() const; + virtual const sal_Char* SAL_CALL getOldInfoFileName() const; + virtual const sal_Char* SAL_CALL getLibElementFileExtension() const; + virtual const sal_Char* SAL_CALL getLibrariesDir() const; + +public: + SfxScriptLibraryContainer( void ); + SfxScriptLibraryContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ); + + + // Methods XLibraryContainerPassword + virtual sal_Bool SAL_CALL isLibraryPasswordProtected( const ::rtl::OUString& Name ) + throw (::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isLibraryPasswordVerified( const ::rtl::OUString& Name ) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL verifyLibraryPassword( const ::rtl::OUString& Name, const ::rtl::OUString& Password ) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL changeLibraryPassword( const ::rtl::OUString& Name, + const ::rtl::OUString& OldPassword, const ::rtl::OUString& NewPassword ) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException); + // XLibraryQueryExecutable + virtual sal_Bool SAL_CALL HasExecutableCode(const rtl::OUString&) + throw (::com::sun::star::uno::RuntimeException); + // Methods XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) + throw (::com::sun::star::uno::RuntimeException); + + // Service + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static(); + static ::rtl::OUString getImplementationName_static(); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Create + ( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xServiceManager ) + throw( ::com::sun::star::uno::Exception ); + +}; + +//============================================================================ +typedef boost::unordered_map< ::rtl::OUString, ::com::sun::star::script::ModuleInfo, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > ModuleInfoMap; + +typedef ::cppu::ImplHelper1 < ::com::sun::star::script::vba::XVBAModuleInfo + > SfxScriptLibrary_BASE; + +class SfxScriptLibrary : public SfxLibrary + , public SfxScriptLibrary_BASE +{ + friend class SfxScriptLibraryContainer; + + sal_Bool mbLoadedSource; + sal_Bool mbLoadedBinary; + ModuleInfoMap mModuleInfos; + + // Provide modify state including resources + virtual sal_Bool isModified( void ); + virtual void storeResources( void ); + virtual void storeResourcesAsURL( const ::rtl::OUString& URL, const ::rtl::OUString& NewName ); + virtual void storeResourcesToURL( const ::rtl::OUString& URL, + const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ); + virtual void storeResourcesToStorage( const ::com::sun::star::uno::Reference + < ::com::sun::star::embed::XStorage >& xStorage ); + +public: + SfxScriptLibrary + ( + ModifiableHelper& _rModifiable, + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSF, + const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >& xSFI + ); + + SfxScriptLibrary + ( + ModifiableHelper& _rModifiable, + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSF, + const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >& xSFI, + const ::rtl::OUString& aLibInfoFileURL, const ::rtl::OUString& aStorageURL, sal_Bool ReadOnly + ); + + DECLARE_XINTERFACE() + DECLARE_XTYPEPROVIDER() + + // XVBAModuleInfo + virtual ::com::sun::star::script::ModuleInfo SAL_CALL getModuleInfo( const ::rtl::OUString& ModuleName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasModuleInfo( const ::rtl::OUString& ModuleName ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL insertModuleInfo( const ::rtl::OUString& ModuleName, const ::com::sun::star::script::ModuleInfo& ModuleInfo ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeModuleInfo( const ::rtl::OUString& ModuleName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + static bool containsValidModule( const ::com::sun::star::uno::Any& _rElement ); + +protected: + virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const; +}; + +} // namespace base + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/stdobj.hxx b/basic/source/inc/stdobj.hxx new file mode 100644 index 000000000000..7abaf47492f1 --- /dev/null +++ b/basic/source/inc/stdobj.hxx @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SBSTDOBJ_HXX +#define _SBSTDOBJ_HXX + +#include <basic/sbxobj.hxx> + +class StarBASIC; +class SbStdFactory; + +class SbiStdObject : public SbxObject +{ + SbStdFactory* pStdFactory; + + ~SbiStdObject(); + using SbxVariable::GetInfo; + SbxInfo* GetInfo( short ); + virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, + const SfxHint& rHint, const TypeId& rHintType ); +public: + SbiStdObject( const String&, StarBASIC* ); + virtual SbxVariable* Find( const String&, SbxClassType ); + virtual void SetModified( sal_Bool ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/symtbl.hxx b/basic/source/inc/symtbl.hxx new file mode 100644 index 000000000000..1d70b0e49e40 --- /dev/null +++ b/basic/source/inc/symtbl.hxx @@ -0,0 +1,249 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SYMTBL_HXX +#define _SYMTBL_HXX + +#include <svl/svarray.hxx> +#include <tools/string.hxx> +#include <basic/sbxdef.hxx> +#include <basic/sbdef.hxx> + +class SbiSymDef; // Basisklasse +class SbiProcDef; // Prozedur +class SbiConstDef; // Konstante +class SbiSymPool; // Symbol-Pool +class SbiStringPool; // gepoolte Strings + +class SvStream; +class SbiParser; + +enum SbiSymScope { SbLOCAL, SbPARAM, SbPUBLIC, SbGLOBAL, SbRTL }; + + +// Der String-Pool nimmt String-Eintraege auf und sorgt dafuer, +// dass sie nicht doppelt vorkommen. + +SV_DECL_PTRARR_DEL(SbiStrings,String*,5,5) + +class SbiStringPool { // String-Pool + SbiStrings aData; // Daten + String aEmpty; // for convenience + SbiParser* pParser; // der Parser +public: + SbiStringPool( SbiParser* ); + ~SbiStringPool(); + sal_uInt16 GetSize() const { return aData.Count(); } + // AB 8.4.1999, Default wegen #64236 auf sal_True geaendert + // Wenn der Bug sauber behoben ist, wieder auf sal_False aendern. + short Add( const String&, sal_Bool=sal_True ); + short Add( double, SbxDataType ); + const String& Find( sal_uInt16 ) const; + SbiParser* GetParser() { return pParser; } +}; + + +SV_DECL_PTRARR_DEL(SbiSymbols,SbiSymDef*,5,5) + +class SbiSymPool { // Symbol-Pool + friend class SbiSymDef; + friend class SbiProcDef; +protected: + SbiStringPool& rStrings; // verwendeter Stringpool + SbiSymbols aData; // Daten + SbiSymPool* pParent; // uebergeordneter Symbol-Pool + SbiParser* pParser; // der Parser + SbiSymScope eScope; // Scope des Pools + sal_uInt16 nProcId; // aktuelles ProcId fuer STATIC-Variable + sal_uInt16 nCur; // Iterator +public: + SbiSymPool( SbiStringPool&, SbiSymScope ); + ~SbiSymPool(); + + void Clear(); + + void SetParent( SbiSymPool* p ) { pParent = p; } + void SetProcId( short n ) { nProcId = n; } + sal_uInt16 GetSize() const { return aData.Count(); } + SbiSymScope GetScope() const { return eScope; } + void SetScope( SbiSymScope s ) { eScope = s; } + SbiParser* GetParser() { return pParser; } + + SbiSymDef* AddSym( const String& ); // Symbol hinzufuegen + SbiProcDef* AddProc( const String& );// Prozedur hinzufuegen + void Add( SbiSymDef* ); // Symbol uebernehmen + SbiSymDef* Find( const String& ) const;// Variablenname + SbiSymDef* FindId( sal_uInt16 ) const; // Variable per ID suchen + SbiSymDef* Get( sal_uInt16 ) const; // Variable per Position suchen + SbiSymDef* First(), *Next(); // Iteratoren + + sal_uInt32 Define( const String& ); // Label definieren + sal_uInt32 Reference( const String& ); // Label referenzieren + void CheckRefs(); // offene Referenzen suchen +}; + + +class SbiSymDef { // Allgemeiner Symboleintrag + friend class SbiSymPool; +protected: + String aName; // Name des Eintrags + SbxDataType eType; // Typ des Eintrags + SbiSymPool* pIn; // Parent-Pool + SbiSymPool* pPool; // Pool fuer Unterelemente + short nLen; // Stringlaenge bei STRING*n + short nDims; // Array-Dimensionen + sal_uInt16 nId; // Symbol-Nummer + sal_uInt16 nTypeId; // String-ID des Datentyps (Dim X AS Dytentyp) + sal_uInt16 nProcId; // aktuelles ProcId fuer STATIC-Variable + sal_uInt16 nPos; // Positions-Nummer + sal_uInt32 nChain; // Backchain-Kette + sal_Bool bNew : 1; // sal_True: Dim As New... + sal_Bool bChained : 1; // sal_True: Symbol ist in Code definiert + sal_Bool bByVal : 1; // sal_True: ByVal-Parameter + sal_Bool bOpt : 1; // sal_True: optionaler Parameter + sal_Bool bStatic : 1; // sal_True: STATIC-Variable + sal_Bool bAs : 1; // sal_True: Datentyp per AS XXX definiert + sal_Bool bGlobal : 1; // sal_True: Global-Variable + sal_Bool bParamArray : 1; // sal_True: ParamArray parameter + sal_Bool bWithEvents : 1; // sal_True: Declared WithEvents + sal_uInt16 nDefaultId; // Symbol number of default value + short nFixedStringLength; // String length in: Dim foo As String*Length +public: + SbiSymDef( const String& ); + virtual ~SbiSymDef(); + virtual SbiProcDef* GetProcDef(); + virtual SbiConstDef* GetConstDef(); + + SbxDataType GetType() const { return eType; } + virtual void SetType( SbxDataType ); + const String& GetName(); + SbiSymScope GetScope() const; + sal_uInt16 GetProcId() const{ return nProcId; } + sal_uInt32 GetAddr() const { return nChain; } + sal_uInt16 GetId() const { return nId; } + sal_uInt16 GetTypeId() const{ return nTypeId; } + void SetTypeId( sal_uInt16 n ) { nTypeId = n; eType = SbxOBJECT; } + sal_uInt16 GetPos() const { return nPos; } + void SetLen( short n ){ nLen = n; } + short GetLen() const { return nLen; } + void SetDims( short n ) { nDims = n; } + short GetDims() const { return nDims; } + sal_Bool IsDefined() const{ return bChained; } + void SetOptional() { bOpt = sal_True; } + void SetParamArray() { bParamArray = sal_True; } + void SetWithEvents() { bWithEvents = sal_True; } + void SetByVal( sal_Bool bByVal_ = sal_True ) + { bByVal = bByVal_; } + void SetStatic( sal_Bool bAsStatic = sal_True ) { bStatic = bAsStatic; } + void SetNew() { bNew = sal_True; } + void SetDefinedAs() { bAs = sal_True; } + void SetGlobal(sal_Bool b){ bGlobal = b; } + void SetDefaultId( sal_uInt16 n ) { nDefaultId = n; } + sal_uInt16 GetDefaultId( void ) { return nDefaultId; } + sal_Bool IsOptional() const{ return bOpt; } + sal_Bool IsParamArray() const{ return bParamArray; } + sal_Bool IsWithEvents() const{ return bWithEvents; } + sal_Bool IsByVal() const { return bByVal; } + sal_Bool IsStatic() const { return bStatic; } + sal_Bool IsNew() const { return bNew; } + sal_Bool IsDefinedAs() const { return bAs; } + sal_Bool IsGlobal() const { return bGlobal; } + short GetFixedStringLength( void ) const { return nFixedStringLength; } + void SetFixedStringLength( short n ) { nFixedStringLength = n; } + + SbiSymPool& GetPool(); + sal_uInt32 Define(); // Symbol in Code definieren + sal_uInt32 Reference(); // Symbol in Code referenzieren + +private: + SbiSymDef( const SbiSymDef& ); + +}; + +class SbiProcDef : public SbiSymDef { // Prozedur-Definition (aus Basic): + SbiSymPool aParams; // Parameter + SbiSymPool aLabels; // lokale Sprungziele + String aLibName; // LIB "name" + String aAlias; // ALIAS "name" + sal_uInt16 nLine1, nLine2; // Zeilenbereich + PropertyMode mePropMode; // Marks if this is a property procedure and which + String maPropName; // Property name if property procedure (!= proc name) + sal_Bool bCdecl : 1; // sal_True: CDECL angegeben + sal_Bool bPublic : 1; // sal_True: proc ist PUBLIC + sal_Bool mbProcDecl : 1; // sal_True: instanciated by SbiParser::ProcDecl +public: + SbiProcDef( SbiParser*, const String&, sal_Bool bProcDecl=false ); + virtual ~SbiProcDef(); + virtual SbiProcDef* GetProcDef(); + virtual void SetType( SbxDataType ); + SbiSymPool& GetParams() { return aParams; } + SbiSymPool& GetLabels() { return aLabels; } + SbiSymPool& GetLocals() { return GetPool();} + String& GetLib() { return aLibName; } + String& GetAlias() { return aAlias; } + void SetPublic( sal_Bool b ) { bPublic = b; } + sal_Bool IsPublic() const { return bPublic; } + void SetCdecl( sal_Bool b = sal_True) { bCdecl = b; } + sal_Bool IsCdecl() const { return bCdecl; } + sal_Bool IsUsedForProcDecl() const { return mbProcDecl; } + void SetLine1( sal_uInt16 n ) { nLine1 = n; } + sal_uInt16 GetLine1() const { return nLine1; } + void SetLine2( sal_uInt16 n ) { nLine2 = n; } + sal_uInt16 GetLine2() const { return nLine2; } + PropertyMode getPropertyMode() { return mePropMode; } + void setPropertyMode( PropertyMode ePropMode ); + const String& GetPropName() { return maPropName; } + + // Match mit einer Forward-Deklaration. Die Parameternamen + // werden abgeglichen und die Forward-Deklaration wird + // durch this ersetzt + void Match( SbiProcDef* pForward ); + +private: + SbiProcDef( const SbiProcDef& ); + +}; + +class SbiConstDef : public SbiSymDef +{ + double nVal; + String aVal; +public: + SbiConstDef( const String& ); + virtual ~SbiConstDef(); + virtual SbiConstDef* GetConstDef(); + void Set( double, SbxDataType ); + void Set( const String& ); + double GetValue() { return nVal; } + const String& GetString() { return aVal; } +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/token.hxx b/basic/source/inc/token.hxx new file mode 100644 index 000000000000..deb6764f2e2c --- /dev/null +++ b/basic/source/inc/token.hxx @@ -0,0 +1,184 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _TOKEN_HXX +#define _TOKEN_HXX + +#include "scanner.hxx" +#include <basic/sbdef.hxx> + +#if defined( SHARED ) +#define SbiTokenSHAREDTMPUNDEF +#undef SHARED +#endif + +// Der Tokenizer ist stand-alone, d.h. er kann von ueberallher verwendet +// werden. Eine BASIC-Instanz ist fuer Fehlermeldungen notwendig. Ohne +// BASIC werden die Fehler nur gezaehlt. Auch ist Basic notwendig, wenn +// eine erweiterte SBX-Variable zur Erkennung von Datentypen etc. verwendet +// werden soll. + +enum SbiToken { + NIL = 0, + // Token zwischen 0x20 und 0x3F sind Literale: + LPAREN = '(', RPAREN = ')', COMMA = ',', DOT = '.', EXCLAM = '!', + HASH = '#', SEMICOLON = ';', + + // Anweisungen: + FIRSTKWD = 0x40, + AS = FIRSTKWD, ALIAS, ASSIGN, + CALL, CASE, CLOSE, COMPARE, _CONST_, + DECLARE, DIM, DO, + + // in der Reihenfolge der Datentyp-Enums! + DEFINT, DEFLNG, DEFSNG, DEFDBL, DEFCUR, DEFDATE, DEFSTR, DEFOBJ, + DEFERR, DEFBOOL, DEFVAR, + // in der Reihenfolge der Datentyp-Enums! + DATATYPE1, + TINTEGER = DATATYPE1, + TLONG, TSINGLE, TDOUBLE, TCURRENCY, TDATE, TSTRING, TOBJECT, + _ERROR_, TBOOLEAN, TVARIANT, TBYTE, + DATATYPE2 = TBYTE, + + EACH, ELSE, ELSEIF, END, ERASE, EXIT, + FOR, FUNCTION, + GET, GLOBAL, GOSUB, GOTO, + IF, _IN_, INPUT, + LET, LINE, LINEINPUT, LOCAL, LOOP, LPRINT, LSET, + NAME, NEW, NEXT, + ON, OPEN, OPTION, ATTRIBUTE, IMPLEMENTS, + PRINT, PRIVATE, PROPERTY, PUBLIC, + REDIM, REM, RESUME, RETURN, RSET, + SELECT, SET, SHARED, STATIC, STEP, STOP, SUB, + TEXT, THEN, TO, TYPE, ENUM, + UNTIL, + WEND, WHILE, WITH, WRITE, + ENDENUM, ENDIF, ENDFUNC, ENDPROPERTY, ENDSUB, ENDTYPE, ENDSELECT, ENDWITH, + // Ende aller Keywords + LASTKWD = ENDWITH, + // Statement-Ende + EOS, EOLN, + // Operatoren: + EXPON, NEG, MUL, + DIV, IDIV, MOD, PLUS, MINUS, + EQ, NE, LT, GT, LE, GE, + NOT, AND, OR, XOR, EQV, + IMP, CAT, LIKE, IS, TYPEOF, + // Sonstiges: + FIRSTEXTRA, + NUMBER=FIRSTEXTRA, FIXSTRING, SYMBOL, _CDECL_, BYVAL, BYREF, + OUTPUT, RANDOM, APPEND, BINARY, ACCESS, + LOCK, READ, PRESERVE, BASE, ANY, LIB, _OPTIONAL_, + EXPLICIT, COMPATIBLE, CLASSMODULE, PARAMARRAY, WITHEVENTS, + + // Ab hier kommen JavaScript-Tokens (gleiches enum, damit gleicher Typ) + FIRSTJAVA, + JS_BREAK=FIRSTJAVA, JS_CONTINUE, JS_FOR, JS_FUNCTION, JS_IF, JS_NEW, + JS_RETURN, JS_THIS, JS_VAR, JS_WHILE, JS_WITH, + + // JavaScript-Operatoren + // _ASS_ = Assignment + JS_COMMA, JS_ASSIGNMENT, JS_ASS_PLUS, JS_ASS_MINUS, JS_ASS_MUL, + JS_ASS_DIV, JS_ASS_MOD, JS_ASS_LSHIFT, JS_ASS_RSHIFT, JS_ASS_RSHIFT_Z, + JS_ASS_AND, JS_ASS_XOR, JS_ASS_OR, + JS_COND_QUEST, JS_COND_SEL, JS_LOG_OR, JS_LOG_AND, JS_BIT_OR, + JS_BIT_XOR, JS_BIT_AND, JS_EQ, JS_NE, JS_LT, JS_LE, + JS_GT, JS_GE, JS_LSHIFT, JS_RSHIFT, JS_RSHIFT_Z, + JS_PLUS, JS_MINUS, JS_MUL, JS_DIV, JS_MOD, JS_LOG_NOT, JS_BIT_NOT, + JS_INC, JS_DEC, JS_LPAREN, JS_RPAREN, JS_LINDEX, JS_RINDEX + , VBASUPPORT +}; + +#ifdef SbiTokenSHAREDTMPUNDEF +#define SHARED +#undef SbiTokenSHAREDTMPUNDEF +#endif + +// #i109076 +class TokenLabelInfo +{ + bool* m_pTokenCanBeLabelTab; + +public: + TokenLabelInfo( void ); + TokenLabelInfo( const TokenLabelInfo& rInfo ) + : m_pTokenCanBeLabelTab( NULL ) + { (void)rInfo; } + ~TokenLabelInfo(); + + bool canTokenBeLabel( SbiToken eTok ) + { return m_pTokenCanBeLabelTab[eTok]; } +}; + +class SbiTokenizer : public SbiScanner { + TokenLabelInfo m_aTokenLabelInfo; + +protected: + SbiToken eCurTok; // aktuelles Token + SbiToken ePush; // Pushback-Token + sal_uInt16 nPLine, nPCol1, nPCol2; // Pushback-Location + sal_Bool bEof; // sal_True bei Dateiende + sal_Bool bEos; // sal_True bei Statement-Ende + sal_Bool bKeywords; // sal_True, falls Keywords geparst werden + sal_Bool bAs; // letztes Keyword war AS + sal_Bool bErrorIsSymbol; // Handle Error token as Symbol, not keyword +public: + SbiTokenizer( const ::rtl::OUString&, StarBASIC* = NULL ); + ~SbiTokenizer(); + + inline sal_Bool IsEof() { return bEof; } + inline sal_Bool IsEos() { return bEos; } + + void Push( SbiToken ); // Pushback eines Tokens + const String& Symbol( SbiToken );// Rueckumwandlung + + SbiToken Peek(); // das naechste Token lesen + SbiToken Next(); // Ein Token lesen + sal_Bool MayBeLabel( sal_Bool= sal_False ); // Kann es ein Label sein? + + void Hilite( SbTextPortions& ); // Syntax-Highlighting + + void Error( SbError c ) { GenError( c ); } + void Error( SbError, SbiToken ); + void Error( SbError, const char* ); + void Error( SbError, String ); + + void Keywords( sal_Bool b ) { bKeywords = b; } + + static sal_Bool IsEoln( SbiToken t ) + { return sal_Bool( t == EOS || t == EOLN || t == REM ); } + static sal_Bool IsKwd( SbiToken t ) + { return sal_Bool( t >= FIRSTKWD && t <= LASTKWD ); } + static sal_Bool IsExtra( SbiToken t ) + { return sal_Bool( t >= FIRSTEXTRA ); } +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |