diff options
Diffstat (limited to '')
27 files changed, 4221 insertions, 0 deletions
diff --git a/basic/source/inc/basiccharclass.hxx b/basic/source/inc/basiccharclass.hxx new file mode 100644 index 000000000..3b8109b89 --- /dev/null +++ b/basic/source/inc/basiccharclass.hxx @@ -0,0 +1,36 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_BASICCHARCLASS_HXX +#define INCLUDED_BASIC_SOURCE_INC_BASICCHARCLASS_HXX + +#include <sal/types.h> + +namespace BasicCharClass +{ + bool isLetter( sal_Unicode c ); + bool isLetterUnicode( sal_Unicode c ); + bool isAlpha( sal_Unicode c, bool bCompatible ); + bool isAlphaNumeric( sal_Unicode c, bool bCompatible ); + bool isWhitespace( sal_Unicode c ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/buffer.hxx b/basic/source/inc/buffer.hxx new file mode 100644 index 000000000..89d664453 --- /dev/null +++ b/basic/source/inc/buffer.hxx @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_BUFFER_HXX +#define INCLUDED_BASIC_SOURCE_INC_BUFFER_HXX + +#include <sal/types.h> +#include <memory> + +class SbiParser; + +class SbiBuffer { + SbiParser* pParser; // for error messages + std::unique_ptr<char[]> pBuf; + char* pCur; + sal_uInt32 nOff; + sal_uInt32 nSize; + short nInc; + bool Check( sal_Int32 ); +public: + SbiBuffer( SbiParser*, short ); // increment + ~SbiBuffer(); + void Patch( sal_uInt32, sal_uInt32 ); + void Chain( sal_uInt32 ); + void operator += (sal_Int8); // save character + void operator += (sal_Int16); // save integer + bool operator += (sal_uInt8); // save character + bool operator += (sal_uInt16); // save integer + bool operator += (sal_uInt32); // save integer + void operator += (sal_Int32); // save integer + char* GetBuffer(); // give out buffer (delete yourself!) + sal_uInt32 GetSize() const { 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 000000000..857968e26 --- /dev/null +++ b/basic/source/inc/codegen.hxx @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_CODEGEN_HXX +#define INCLUDED_BASIC_SOURCE_INC_CODEGEN_HXX + +class SbiParser; +class SbModule; +#include "opcodes.hxx" +#include "buffer.hxx" + +class SbiCodeGen { + SbiParser* pParser; // for error messages, line, column etc. + SbModule& rMod; + SbiBuffer aCode; + short nLine, nCol; // for stmnt command + short nForLevel; // #29955 + bool bStmnt; // true: statement-opcode is pending + +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(); // create statement-opcode maybe + sal_uInt32 GetPC() const; + sal_uInt32 GetOffset() const { return GetPC() + 1; } + void Save(); + + // #29955 service for-loop-level + void IncForLevel() { nForLevel++; } + void DecForLevel() { nForLevel--; } + + static sal_uInt32 calcNewOffSet( sal_uInt8 const * pCode, sal_uInt16 nOffset ); + static sal_uInt16 calcLegacyOffSet( sal_uInt8 const * 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; + + PCodeBuffConvertor(const PCodeBuffConvertor& ) = delete; + PCodeBuffConvertor& operator = ( const PCodeBuffConvertor& ) = delete; +public: + PCodeBuffConvertor( sal_uInt8* pCode, T nSize ): m_nSize( nSize ), m_pStart( pCode ), m_pCnvtdBuf( nullptr ), 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 +#define PARAM_INFO_WITHBRACKETS 0x0020000 + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/date.hxx b/basic/source/inc/date.hxx new file mode 100644 index 000000000..1a994ca3f --- /dev/null +++ b/basic/source/inc/date.hxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_DATE_HXX +#define INCLUDED_BASIC_SOURCE_INC_DATE_HXX + +#include <com/sun/star/util/Date.hpp> +#include <com/sun/star/util/Time.hpp> +#include <com/sun/star/util/DateTime.hpp> + +#include <basic/sbxvar.hxx> + +enum class SbDateCorrection +{ + None, + RollOver, + TruncateToMonth +}; + +bool implDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay, bool bUseTwoDigitYear, SbDateCorrection eCorr, double& rdRet ); +double implTimeSerial( sal_Int16 nHour, sal_Int16 nMinute, sal_Int16 nSecond); +bool implDateTimeSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay, + sal_Int16 nHour, sal_Int16 nMinute, sal_Int16 nSecond, + double& rdRet ); + +sal_Int16 implGetWeekDay( double aDate, bool bFirstDayParam = false, sal_Int16 nFirstDay = 0 ); + +sal_Int16 implGetDateYear( double aDate ); +sal_Int16 implGetDateMonth( double aDate ); +sal_Int16 implGetDateDay( double aDate ); + +sal_Int16 implGetHour( double dDate ); +sal_Int16 implGetMinute( double dDate ); +sal_Int16 implGetSecond( double dDate ); + +css::util::Date SbxDateToUNODate( const SbxValue* ); +void SbxDateFromUNODate( SbxValue*, const css::util::Date& ); +css::util::Time SbxDateToUNOTime( const SbxValue* ); +void SbxDateFromUNOTime( SbxValue*, const css::util::Time& ); +css::util::DateTime SbxDateToUNODateTime( const SbxValue* ); +void SbxDateFromUNODateTime( SbxValue*, const css::util::DateTime& ); + +#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 000000000..582e462ab --- /dev/null +++ b/basic/source/inc/dlgcont.hxx @@ -0,0 +1,152 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_DLGCONT_HXX +#define INCLUDED_BASIC_SOURCE_INC_DLGCONT_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* implCreateLibrary( const OUString& aName ) override; + virtual SfxLibrary* implCreateLibraryLink + ( const OUString& aName, const OUString& aLibInfoFileURL, + const OUString& StorageURL, bool ReadOnly ) override; + virtual css::uno::Any createEmptyLibraryElement() override; + virtual bool isLibraryElementValid(const css::uno::Any& rElement) const override; + virtual void writeLibraryElement + ( + const css::uno::Reference< css::container::XNameContainer>& xLibrary, + const OUString& aElementName, + const css::uno::Reference< css::io::XOutputStream >& xOutput + ) override; + + virtual css::uno::Any importLibraryElement + ( + const css::uno::Reference< css::container::XNameContainer>& xLibrary, + const OUString& aElementName, + const OUString& aFile, + const css::uno::Reference< css::io::XInputStream >& xElementStream ) override; + + virtual void importFromOldStorage( const OUString& aFile ) override; + + virtual SfxLibraryContainer* createInstanceImpl() override; + + virtual void onNewRootStorage() override; + + virtual const char* getInfoFileName() const override; + virtual const char* getOldInfoFileName() const override; + virtual const char* getLibElementFileExtension() const override; + virtual const char* getLibrariesDir() const override; + +public: + SfxDialogLibraryContainer(); + SfxDialogLibraryContainer( const css::uno::Reference< css::embed::XStorage >& xStorage ); + + // Methods XStorageBasedLibraryContainer + virtual void SAL_CALL storeLibrariesToStorage( + const css::uno::Reference< css::embed::XStorage >& RootStorage ) override; + + // Resource handling + css::uno::Reference< css::resource::XStringResourcePersistence > + implCreateStringResource( class SfxDialogLibrary* pDialog ); + + // Methods XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + // XLibraryQueryExecutable + virtual sal_Bool SAL_CALL HasExecutableCode(const OUString&) override; +}; + + +typedef ::cppu::ImplHelper1 < css::resource::XStringResourceSupplier + > SfxDialogLibrary_BASE; + +class SfxDialogLibrary :public SfxLibrary + ,public SfxDialogLibrary_BASE +{ + SfxDialogLibraryContainer* m_pParent; + css::uno::Reference< css::resource::XStringResourcePersistence> m_xStringResourcePersistence; + OUString m_aName; + + // Provide modify state including resources + virtual bool isModified() override; + virtual void storeResources() override; + virtual void storeResourcesAsURL( const OUString& URL, const OUString& NewName ) override; + virtual void storeResourcesToURL( const OUString& URL, + const css::uno::Reference< css::task::XInteractionHandler >& xHandler ) override; + virtual void storeResourcesToStorage( const css::uno::Reference + < css::embed::XStorage >& xStorage ) override; + +public: + SfxDialogLibrary + ( + ModifiableHelper& _rModifiable, + const OUString& aName, + const css::uno::Reference< css::ucb::XSimpleFileAccess3 >& xSFI, + SfxDialogLibraryContainer* pParent + ); + + SfxDialogLibrary + ( + ModifiableHelper& _rModifiable, + const OUString& aName, + const css::uno::Reference< css::ucb::XSimpleFileAccess3 >& xSFI, + const OUString& aLibInfoFileURL, const OUString& aStorageURL, bool ReadOnly, + SfxDialogLibraryContainer* pParent + ); + + DECLARE_XINTERFACE() + DECLARE_XTYPEPROVIDER() + + // XStringResourceSupplier + virtual css::uno::Reference< css::resource::XStringResourceResolver > + SAL_CALL getStringResource( ) override; + + const OUString& getName() const + { return m_aName; } + + const css::uno::Reference< css::resource::XStringResourcePersistence >& + getStringResourcePersistence() const + { + return m_xStringResourcePersistence; + } + + static bool containsValidDialog( const css::uno::Any& aElement ); + +protected: + virtual bool isLibraryElementValid(const css::uno::Any& rElement) const override; +}; + +} // 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 000000000..65c4722e3 --- /dev/null +++ b/basic/source/inc/errobject.hxx @@ -0,0 +1,43 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_ERROBJECT_HXX +#define INCLUDED_BASIC_SOURCE_INC_ERROBJECT_HXX +#include "sbunoobj.hxx" +#include <ooo/vba/XErrObject.hpp> + + +class SbxErrObject : public SbUnoObject +{ + class ErrObject* m_pErrObject; + css::uno::Reference< ooo::vba::XErrObject > m_xErr; + + SbxErrObject( const OUString& aName_, const css::uno::Any& aUnoObj_ ); + virtual ~SbxErrObject() override; + +public: + static SbxVariableRef const & getErrObject(); + static css::uno::Reference< ooo::vba::XErrObject > const & getUnoErrObject(); + + /// @throws css::uno::RuntimeException + void setNumberAndDescription( ::sal_Int32 _number, const OUString& _description ); +}; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/eventatt.hxx b/basic/source/inc/eventatt.hxx new file mode 100644 index 000000000..b38c83c59 --- /dev/null +++ b/basic/source/inc/eventatt.hxx @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_EVENTATT_HXX +#define INCLUDED_BASIC_SOURCE_INC_EVENTATT_HXX + +#include <sal/config.h> + +class SbxArray; + +// Instantiate "com.sun.star.awt.UnoControlDialog" on basis +// of a DialogLibrary entry: Convert from XML-ByteSequence +// and attach events. +void RTL_Impl_CreateUnoDialog(SbxArray& rPar); + +#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 000000000..d83594c49 --- /dev/null +++ b/basic/source/inc/expr.hxx @@ -0,0 +1,230 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_EXPR_HXX +#define INCLUDED_BASIC_SOURCE_INC_EXPR_HXX + +#include <memory> + +#include "opcodes.hxx" +#include "token.hxx" +#include <vector> + +class SbiExprNode; +class SbiExpression; +class SbiExprList; +class SbiParser; +class SbiCodeGen; +class SbiSymDef; +class SbiProcDef; + + +typedef std::unique_ptr<SbiExprList> SbiExprListPtr; +typedef std::vector<SbiExprListPtr> SbiExprListVector; + +struct SbVar { + SbiExprNode* pNext; // next element (for structures) + SbiSymDef* pDef; // symbol definition + SbiExprList* pPar; // optional parameters (is deleted) + SbiExprListVector* pvMorePar; // Array of arrays foo(pPar)(avMorePar[0])(avMorePar[1])... +}; + +struct KeywordSymbolInfo +{ + OUString m_aKeywordSymbol; + SbxDataType m_eSbxDataType; +}; + +enum SbiExprType { // expression types: + SbSTDEXPR, // normal expression + SbLVALUE, // any lValue + SbSYMBOL, // any composite symbol + SbOPERAND // variable/function +}; + +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 = value + SbxSTRVAL, // aStrVal = value, before #i59791/#i45570: nStringId = value + SbxVARVAL, // aVar = value + SbxTYPEOF, // TypeOf ObjExpr Is Type + SbxNODE, // Node + SbxNEW, // new <type> expression + SbxDUMMY +}; + +enum RecursiveMode +{ + UNDEFINED, + FORCE_CALL, + PREVENT_CALL +}; + +class SbiExprNode final { // operators (and operands) + friend class SbiExpression; + friend class SbiConstExpression; + union { + sal_uInt16 nTypeStrId; // pooled String-ID, #i59791/#i45570 Now only for TypeOf + double nVal; // numeric value + SbVar aVar; // or variable + }; + OUString aStrVal; // #i59791/#i45570 Store string directly + std::unique_ptr<SbiExprNode> pLeft; // left branch + std::unique_ptr<SbiExprNode> pRight; // right branch (NULL for unary ops) + SbiExprNode* pWithParent; // node, whose member is "this per with" + SbiNodeType eNodeType; + SbxDataType eType; + SbiToken eTok; + bool bError; // true: error + void FoldConstants(SbiParser*); + void FoldConstantsBinaryNode(SbiParser*); + void FoldConstantsUnaryNode(SbiParser*); + void CollectBits(); // converting numbers to strings + bool IsOperand() const + { return eNodeType != SbxNODE && eNodeType != SbxTYPEOF && eNodeType != SbxNEW; } + bool IsNumber() const; + bool IsLvalue() const; // true, if usable as Lvalue + void GenElement( SbiCodeGen&, SbiOpcode ); + +public: + SbiExprNode(); + SbiExprNode( double, SbxDataType ); + SbiExprNode( const OUString& ); + SbiExprNode( const SbiSymDef&, SbxDataType, SbiExprListPtr = nullptr ); + SbiExprNode( std::unique_ptr<SbiExprNode>, SbiToken, std::unique_ptr<SbiExprNode> ); + SbiExprNode( std::unique_ptr<SbiExprNode>, sal_uInt16 ); // #120061 TypeOf + SbiExprNode( sal_uInt16 ); // new <type> + ~SbiExprNode(); + + bool IsValid() const { return !bError; } + bool IsConstant() const // true: constant operand + { return eNodeType == SbxSTRVAL || eNodeType == SbxNUMVAL; } + void ConvertToIntConstIfPossible(); + bool IsVariable() const; + + void SetWithParent( SbiExprNode* p ) { pWithParent = p; } + + SbxDataType GetType() const { return eType; } + void SetType( SbxDataType eTp ) { eType = eTp; } + SbiNodeType GetNodeType() const { return eNodeType; } + SbiSymDef* GetVar(); + SbiSymDef* GetRealVar(); // last variable in x.y.z + SbiExprNode* GetRealNode(); // last node in x.y.z + const OUString& GetString() const { return aStrVal; } + short GetNumber() const { return static_cast<short>(nVal); } + SbiExprList* GetParameters() { return aVar.pPar; } + + void Optimize(SbiParser*); // tree matching + + void Gen( SbiCodeGen& rGen, RecursiveMode eRecMode = UNDEFINED ); // giving out a node +}; + +class SbiExpression { + friend class SbiExprList; +protected: + OUString aArgName; + SbiParser* pParser; + std::unique_ptr<SbiExprNode> pExpr; // expression tree + SbiExprType eCurExpr; // type of expression + SbiExprMode m_eMode; // expression context + bool bBased; // true: easy DIM-part (+BASE) + bool bError; + bool bByVal; // true: ByVal-Parameter + bool bBracket; // true: Parameter list with brackets + sal_uInt16 nParenLevel; + std::unique_ptr<SbiExprNode> Term( const KeywordSymbolInfo* pKeywordSymbolInfo = nullptr ); + std::unique_ptr<SbiExprNode> ObjTerm( SbiSymDef& ); + std::unique_ptr<SbiExprNode> Operand( bool bUsedForTypeOf = false ); + std::unique_ptr<SbiExprNode> Unary(); + std::unique_ptr<SbiExprNode> Exp(); + std::unique_ptr<SbiExprNode> MulDiv(); + std::unique_ptr<SbiExprNode> IntDiv(); + std::unique_ptr<SbiExprNode> Mod(); + std::unique_ptr<SbiExprNode> AddSub(); + std::unique_ptr<SbiExprNode> Cat(); + std::unique_ptr<SbiExprNode> Like(); + std::unique_ptr<SbiExprNode> VBA_Not(); + std::unique_ptr<SbiExprNode> Comp(); + std::unique_ptr<SbiExprNode> Boolean(); +public: + SbiExpression( SbiParser*, SbiExprType = SbSTDEXPR, + SbiExprMode eMode = EXPRMODE_STANDARD, const KeywordSymbolInfo* pKeywordSymbolInfo = nullptr ); // parsing Ctor + SbiExpression( SbiParser*, double, SbxDataType ); + SbiExpression( SbiParser*, const SbiSymDef&, SbiExprListPtr = nullptr ); + ~SbiExpression(); + OUString& GetName() { return aArgName; } + void SetBased() { bBased = true; } + bool IsBased() const { return bBased; } + void SetByVal() { bByVal = true; } + bool IsBracket() const { return bBracket; } + bool IsValid() const { return pExpr->IsValid(); } + bool IsVariable() const { return pExpr->IsVariable(); } + bool IsLvalue() const { return pExpr->IsLvalue(); } + void ConvertToIntConstIfPossible() { pExpr->ConvertToIntConstIfPossible(); } + const OUString& GetString() const { return pExpr->GetString(); } + SbiSymDef* GetRealVar() { return pExpr->GetRealVar(); } + SbiExprNode* GetExprNode() { return pExpr.get(); } + SbxDataType GetType() const { return pExpr->GetType(); } + void Gen( RecursiveMode eRecMode = UNDEFINED ); +}; + +class SbiConstExpression : public SbiExpression { + double nVal; + OUString aVal; + SbxDataType eType; +public: // numeric constant + SbiConstExpression( SbiParser* ); + SbxDataType GetType() const { return eType; } + const OUString& GetString() const { return aVal; } + double GetValue() const { return nVal; } + short GetShortValue(); +}; + +class SbiExprList final { // class for parameters and dims + std::vector<std::unique_ptr<SbiExpression>> aData; + short nDim; + bool bError; + bool bBracket; +public: + SbiExprList(); + ~SbiExprList(); + static SbiExprListPtr ParseParameters(SbiParser*, bool bStandaloneExpression = false, bool bPar = true); + static SbiExprListPtr ParseDimList( SbiParser* ); + bool IsBracket() const { return bBracket; } + bool IsValid() const { return !bError; } + short GetSize() const { return aData.size(); } + short GetDims() const { return nDim; } + SbiExpression* Get( size_t ); + void Gen( SbiCodeGen& rGen); // code generation + void addExpression( std::unique_ptr<SbiExpression>&& pExpr ); +}; + +#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 000000000..eb1990087 --- /dev/null +++ b/basic/source/inc/filefmt.hxx @@ -0,0 +1,192 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_FILEFMT_HXX +#define INCLUDED_BASIC_SOURCE_INC_FILEFMT_HXX + +class SvStream; + +// Version 2: data type of the return value for publics +// Version 3: new opcodes +// Version 4: new opcodes +// Version 5: bug (entry of STATIC-variables in the init code) +// Version 6: new opcodes and bug (construct globals, without ending the BASIC) +// Version 7: correction concerning the WITH-Parsing +// Version 8: correction concerning the IF-Parsing +// Version 9: end init code with LEAVE, too, if no SUB/FUNCTION follows +// Version A: #36374 at DIM AS NEW... construct variable too +// Version B: #40689 reorganized static +// Version C: #41606 bug at static +// Version D: #42678 bug at RTL-function spc +// Version E: #56204 DCREATE, to also construct arrays at DIM AS NEW +// Version F: #57844 introduction of SvNumberformat::StringToDouble +// Version 10: #29955 generate for-loop-level in Statement-PCodes +// Version 11: #29955 force anew compilation because of build-inconsistences +// Version 12: aoo#64377 increase code size that basic can handle +// tdf#75973 support user defined types B_USERTYPES in password protected macros +// Version 13: tdf#94617 store methods nStart information greater than sal_Int16 limit +// tdf#57113 store UTF-16 strings after legacy 1-byte-encoded strings in pool (no +// version number bump for backward compatibility; relies on magic number) +// + +#define B_LEGACYVERSION 0x00000011 +#define B_EXT_IMG_VERSION 0x00000012 +#define B_CURVERSION 0x00000013 + +// The file contains either a module- or a library-record. +// Those records contain further records. Every record's got +// the following header: + +// sal_uInt16 identifier +// sal_uInt32 the record's length without the header +// sal_uInt16 number of sub-elements + +// all the file-offsets in records are relative to the module's start! + +enum class FileOffset { + Library = 0x4C42, // BL Library Record + Module = 0x4D42, // BM Module Record + Name = 0x4E4D, // MN module name + Comment = 0x434D, // MC comment + Source = 0x4353, // SC source code + PCode = 0x4350, // PC p-code + OldPublics = 0x7550, // Pu publics + Publics = 0x5550, // PU publics + PoolDir = 0x4450, // PD symbol pool directory + SymPool = 0x5953, // SY symbol pool + StringPool = 0x5453, // ST symbol pool + LineRanges = 0x524C, // LR line ranges for publics + ModEnd = 0x454D, // ME module end + SbxObjects = 0x5853, // SX SBX objects + ExtSource = 0x5345, // ES extended source + UserTypes = 0x4369, // UT user defined types + + LastValue = UserTypes +}; + + +// A library record contains only module records +// sal_uInt16 identifier BL +// sal_uInt32 the record's length +// sal_uInt16 number of modules + +// A module-record contains all the other record types +// sal_uInt16 identifier BM +// sal_uInt32 the record's length +// sal_uInt16 1 +// Data: +// sal_uInt32 version number +// sal_uInt32 character set +// sal_uInt32 starting address initialisation code +// sal_uInt32 starting address sub main +// sal_uInt32 reserved +// sal_uInt32 reserved + +// module name, comment and source code: +// sal_uInt16 identifier MN, MC or SC +// sal_uInt32 the record's length +// sal_uInt16 1 +// Data: +// string instance + +// P-Code: +// sal_uInt16 identifier PC +// sal_uInt32 the record's length +// sal_uInt16 1 +// Data: +// the P-Code as bytesack + +// All symbols and strings are kept in a string-pool. +// References to these strings are in this pool in the form of an index. + +// List of all publics: +// sal_uInt16 identifier PU or Pu +// sal_uInt32 the record's length +// sal_uInt16 number of publics +// Data for every public-entry: +// sal_uInt16 string index +// sal_uInt32 starting address in the p-code-image (sal_uInt16 for old publics) +// sal_uInt16 data type of the return value (from version 2) + +// Register of the symbol tables: +// sal_uInt16 identifier SP +// sal_uInt32 the record's length +// sal_uInt16 number of symbol tables +// Data for every symbol table: +// sal_uInt16 stringindex of the name +// sal_uInt16 number of symbols +// sal_uInt16 scope identifier + +// symbol table: +// sal_uInt16 identifier SY +// sal_uInt32 the record's length +// sal_uInt16 number of symbols +// Data: +// sal_uInt16 stringindex of the name +// sal_uInt16 number of symbols +// Data for every symbol: +// sal_uInt16 stringindex of the name +// sal_uInt16 data type +// sal_uInt16 length for STRING*n-symbols (0x8000: STATIC variable) + +// Stringpool: +// sal_uInt16 identifier ST +// sal_uInt32 the record's length +// sal_uInt16 number of strings +// Data for every string: +// sal_uInt32 Offset in the block of all strings +// the block of all strings (ASCIIZ) follows then + +// line ranges: +// sal_uInt16 identifier LR +// sal_uInt32 the record's length +// sal_uInt16 number of strings +// Data for every public: +// sal_uInt16 1st line (Sub XXX) +// sal_uInt16 2nd line (End Sub) + +// SBX-objects: +// sal_uInt16 number of objects +// ... object data + +// user defined types B_USERTYPES : +// sal_uInt16 identifier UT +// sal_uInt32 the record's length +// sal_uInt16 number of types +// Data for every user defined type: +// string instance type name +// sal_Int16 number of type members +// Data for every type member: +// string name +// sal_Int16 type +// sal_uInt32 flags +// sal_Int16 hasObjects (0/1) +// If hasObjects +// If member type is nested type +// string nested type name +// Else (array declaration) +// sal_Int16 isFixedSize (0/1) +// sal_Int32 number of dimensions +// Data for every dimension: +// sal_Int32 lower bound +// sal_Int32 upper bound + +#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 000000000..ee1aaa416 --- /dev/null +++ b/basic/source/inc/image.hxx @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_IMAGE_HXX +#define INCLUDED_BASIC_SOURCE_INC_IMAGE_HXX + +#include <basic/sbx.hxx> +#include <rtl/ustring.hxx> +#include "filefmt.hxx" +#include <o3tl/typed_flags_set.hxx> + +// This class reads in the image that's been produced by the compiler +// and manages the access to the single elements. + +enum class SbiImageFlags +{ + NONE = 0, + EXPLICIT = 0x0001, // OPTION EXPLICIT is active + COMPARETEXT = 0x0002, // OPTION COMPARE TEXT is active + INITCODE = 0x0004, // Init-Code does exist + CLASSMODULE = 0x0008, // OPTION ClassModule is active +}; +namespace o3tl +{ + template<> struct typed_flags<SbiImageFlags> : is_typed_flags<SbiImageFlags, 0xf> {}; +} + +class SbiImage { + friend class SbiCodeGen; // compiler classes, that the private- + + SbxArrayRef rTypes; // User defined types + SbxArrayRef rEnums; // Enum types + std::vector<sal_uInt32> mvStringOffsets; // StringId-Offsets + std::unique_ptr<sal_Unicode[]> pStrings; // StringPool + std::unique_ptr<char[]> pCode; // Code-Image + std::unique_ptr<char[]> pLegacyPCode; // Code-Image + bool bError; + SbiImageFlags nFlags; + sal_uInt32 nStringSize; + sal_uInt32 nCodeSize; + sal_uInt16 nLegacyCodeSize; + sal_uInt16 nDimBase; // OPTION BASE value + rtl_TextEncoding eCharSet; + // temporary management-variable: + short nStringIdx; + sal_uInt32 nStringOff; // current Pos in the stringbuffer + // routines for the compiler: + void MakeStrings( short ); // establish StringPool + void AddString( const OUString& ); + void AddCode( std::unique_ptr<char[]>, sal_uInt32 ); + void AddType(SbxObject const *); + void AddEnum(SbxObject *); + +public: + OUString aName; // macro name + OUString aOUSource; // source code + OUString aComment; + bool bInit; + bool bFirstInit; + + SbiImage(); + ~SbiImage(); + void Clear(); + bool Load( SvStream&, sal_uInt32& nVer ); + // nVer is set to version + // of image + bool Save( SvStream&, sal_uInt32 = B_CURVERSION ); + bool IsError() const { return bError; } + + const char* GetCode() const { return pCode.get(); } + sal_uInt32 GetCodeSize() const { return nCodeSize; } + sal_uInt16 GetBase() const { return nDimBase; } + OUString GetString( short nId ) const; + const SbxObject* FindType (const OUString& aTypeName) const; + + const SbxArrayRef& GetEnums() const { return rEnums; } + + void SetFlag( SbiImageFlags n ) { nFlags |= n; } + bool IsFlag( SbiImageFlags n ) const { return bool(nFlags & n); } + sal_uInt16 CalcLegacyOffset( sal_Int32 nOffset ); + sal_uInt32 CalcNewOffset( sal_Int16 nOffset ); + void ReleaseLegacyBuffer(); + bool ExceedsLegacyLimits(); +}; + +#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 000000000..4931b86a3 --- /dev/null +++ b/basic/source/inc/iosys.hxx @@ -0,0 +1,112 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_IOSYS_HXX +#define INCLUDED_BASIC_SOURCE_INC_IOSYS_HXX + +#include <memory> +#include <tools/stream.hxx> +#include <o3tl/typed_flags_set.hxx> + +class SvStream; + +// Global files (channel numbers 256 to 511) are not +// implemented at the moment. + +#define CHANNELS 256 + +enum class SbiStreamFlags +{ + NONE = 0x0000, + Input = 0x0001, + Output = 0x0002, + Random = 0x0004, + Append = 0x0008, + Binary = 0x0010, +}; +namespace o3tl +{ + template<> struct typed_flags<SbiStreamFlags> : is_typed_flags<SbiStreamFlags, 0x1f> {}; +} + +class SbiStream +{ + std::unique_ptr<SvStream> pStrm; + sal_uInt64 nExpandOnWriteTo; // during writing access expand the stream to this size + OString aLine; + sal_uInt64 nLine; + short nLen; // buffer length + SbiStreamFlags nMode; + ErrCode nError; + void MapError(); + +public: + SbiStream(); + ~SbiStream(); + ErrCode const & Open( const OString&, StreamMode, SbiStreamFlags, short ); + ErrCode const & Close(); + ErrCode Read(OString&, sal_uInt16 = 0, bool bForceReadingPerByte=false); + ErrCode const & Read( char& ); + ErrCode Write( const OString& ); + + bool IsText() const { return !bool(nMode & SbiStreamFlags::Binary); } + bool IsRandom() const { return bool(nMode & SbiStreamFlags::Random); } + bool IsBinary() const { return bool(nMode & SbiStreamFlags::Binary); } + bool IsSeq() const { return !bool(nMode & SbiStreamFlags::Random); } + bool IsAppend() const { return bool(nMode & SbiStreamFlags::Append); } + short GetBlockLen() const { return nLen; } + SbiStreamFlags GetMode() const { return nMode; } + sal_uInt64 GetLine() const { return nLine; } + void SetExpandOnWriteTo( sal_uInt64 n ) { nExpandOnWriteTo = n; } + void ExpandFile(); + SvStream* GetStrm() { return pStrm.get(); } +}; + +class SbiIoSystem +{ + SbiStream* pChan[ CHANNELS ]; + OString aPrompt; + OString aIn; + OUString aOut; + short nChan; + ErrCode nError; + void ReadCon(OString&); + void WriteCon(const OUString&); +public: + SbiIoSystem(); + ~SbiIoSystem() COVERITY_NOEXCEPT_FALSE; + ErrCode GetError(); + void Shutdown(); + void SetPrompt(const OString& r) { aPrompt = r; } + void SetChannel( short n ) { nChan = n; } + short GetChannel() const { return nChan;} + void ResetChannel() { nChan = 0; } + void Open( short, const OString&, StreamMode, SbiStreamFlags, short ); + void Close(); + void Read(OString&); + char Read(); + void Write(const OUString&); + // 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 000000000..3a86f059c --- /dev/null +++ b/basic/source/inc/namecont.hxx @@ -0,0 +1,660 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_NAMECONT_HXX +#define INCLUDED_BASIC_SOURCE_INC_NAMECONT_HXX + +#include <unordered_map> +#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/XSimpleFileAccess3.hpp> +#include <com/sun/star/io/XOutputStream.hpp> +#include <com/sun/star/io/XInputStream.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 <com/sun/star/deployment/XPackage.hpp> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> +#include <com/sun/star/script/vba/XVBAScriptListener.hpp> +#include <com/sun/star/util/XChangesNotifier.hpp> + +#include <osl/mutex.hxx> +#include <unotools/eventlisteneradapter.hxx> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/weakref.hxx> +#include <cppuhelper/component.hxx> +#include <cppuhelper/basemutex.hxx> +#include <rtl/ref.hxx> +#include <comphelper/listenernotification.hxx> +#include <xmlscript/xmllib_imexp.hxx> + +class BasicManager; + +namespace basic +{ +typedef ::cppu::WeakImplHelper< + css::container::XNameContainer, + css::container::XContainer, + css::util::XChangesNotifier > NameContainer_BASE; + + +class NameContainer : public ::cppu::BaseMutex, public NameContainer_BASE +{ + typedef std::unordered_map < OUString, sal_Int32 > NameContainerNameMap; + + NameContainerNameMap mHashMap; + std::vector< OUString > mNames; + std::vector< css::uno::Any > mValues; + sal_Int32 mnElementCount; + + css::uno::Type mType; + css::uno::XInterface* mpxEventSource; + + ::comphelper::OInterfaceContainerHelper2 maContainerListeners; + ::comphelper::OInterfaceContainerHelper2 maChangesListeners; + +public: + NameContainer( const css::uno::Type& rType ) + : mnElementCount( 0 ) + , mType( rType ) + , mpxEventSource( nullptr ) + , maContainerListeners( m_aMutex ) + , maChangesListeners( m_aMutex ) + {} + + void setEventSource( css::uno::XInterface* pxEventSource ) + { mpxEventSource = pxEventSource; } + + /// @throws css::lang::IllegalArgumentException + /// @throws css::container::ElementExistException + /// @throws css::lang::WrappedTargetException + /// @throws css::uno::RuntimeException + void insertCheck(const OUString& aName, const css::uno::Any& aElement); + + /// @throws css::lang::IllegalArgumentException + /// @throws css::lang::WrappedTargetException + /// @throws css::uno::RuntimeException + void insertNoCheck(const OUString& aName, const css::uno::Any& aElement); + + // Methods XElementAccess + virtual css::uno::Type SAL_CALL getElementType( ) override; + virtual sal_Bool SAL_CALL hasElements( ) override; + + // Methods XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // Methods XNameReplace + virtual void SAL_CALL replaceByName( const OUString& aName, const css::uno::Any& aElement ) override; + + // Methods XNameContainer + virtual void SAL_CALL insertByName( const OUString& aName, const css::uno::Any& aElement ) override; + virtual void SAL_CALL removeByName( const OUString& Name ) override; + + // Methods XContainer + virtual void SAL_CALL addContainerListener( const css::uno::Reference<css::container::XContainerListener >& xListener ) override; + virtual void SAL_CALL removeContainerListener( const css::uno::Reference<css::container::XContainerListener >& xListener ) override; + + // Methods XChangesNotifier + virtual void SAL_CALL addChangesListener( const css::uno::Reference<css::util::XChangesListener >& xListener ) override; + virtual void SAL_CALL removeChangesListener( const css::uno::Reference<css::util::XChangesListener >& xListener ) override; +}; + + +class ModifiableHelper +{ +private: + ::comphelper::OInterfaceContainerHelper2 m_aModifyListeners; + ::cppu::OWeakObject& m_rEventSource; + bool mbModified; + +public: + ModifiableHelper( ::cppu::OWeakObject& _rEventSource, ::osl::Mutex& _rMutex ) + :m_aModifyListeners( _rMutex ) + ,m_rEventSource( _rEventSource ) + ,mbModified( false ) + { + } + + bool isModified() const { return mbModified; } + void setModified( bool _bModified ); + + void addModifyListener( const css::uno::Reference< css::util::XModifyListener >& _rxListener ) + { + m_aModifyListeners.addInterface( _rxListener ); + } + + void removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& _rxListener ) + { + m_aModifyListeners.removeInterface( _rxListener ); + } +}; + + +typedef ::comphelper::OListenerContainerBase< + css::script::vba::XVBAScriptListener, + css::script::vba::VBAScriptEvent > VBAScriptListenerContainer_BASE; + +class VBAScriptListenerContainer : public VBAScriptListenerContainer_BASE +{ +public: + explicit VBAScriptListenerContainer( ::osl::Mutex& rMutex ); + +private: + virtual bool implTypedNotify( + const css::uno::Reference< css::script::vba::XVBAScriptListener >& rxListener, + const css::script::vba::VBAScriptEvent& rEvent ) override; +}; + + +class SfxLibrary; + +typedef ::cppu::WeakComponentImplHelper< + css::lang::XInitialization, + css::script::XStorageBasedLibraryContainer, + css::script::XLibraryContainerPassword, + css::script::XLibraryContainerExport, + css::script::XLibraryContainer3, + css::container::XContainer, + css::script::XLibraryQueryExecutable, + css::script::vba::XVBACompatibility, + css::lang::XServiceInfo > SfxLibraryContainer_BASE; + +class SfxLibraryContainer + : public ::cppu::BaseMutex + , public SfxLibraryContainer_BASE + , public ::utl::OEventListenerAdapter +{ + VBAScriptListenerContainer maVBAScriptListeners; + sal_Int32 mnRunningVBAScripts; + bool mbVBACompat; + OUString msProjectName; +protected: + css::uno::Reference< css::uno::XComponentContext > mxContext; + css::uno::Reference< css::ucb::XSimpleFileAccess3 > mxSFI; + css::uno::Reference< css::util::XStringSubstitution > mxStringSubstitution; + css::uno::WeakReference< css::frame::XModel > mxOwnerDocument; + + ModifiableHelper maModifiable; + + rtl::Reference<NameContainer> maNameContainer; + bool mbOldInfoFormat; + bool mbOasis2OOoFormat; + + OUString maInitialDocumentURL; + OUString maInfoFileName; + OUString maOldInfoFileName; + OUString maLibElementFileExtension; + OUString maLibraryPath; + OUString maLibrariesDir; + + css::uno::Reference< css::embed::XStorage > mxStorage; + BasicManager* mpBasMgr; + bool mbOwnBasMgr; + + enum InitMode + { + DEFAULT, + CONTAINER_INIT_FILE, + LIBRARY_INIT_FILE, + OFFICE_DOCUMENT, + OLD_BASIC_STORAGE + } meInitMode; + + void implStoreLibrary( SfxLibrary* pLib, + const OUString& rName, + const css::uno::Reference< css::embed::XStorage >& rStorage ); + + // New variant for library export + void implStoreLibrary( SfxLibrary* pLib, + const OUString& rName, + const css::uno::Reference< css::embed::XStorage >& rStorage, + const OUString& rTargetURL, + const css::uno::Reference< css::ucb::XSimpleFileAccess3 >& rToUseSFI, + const css::uno::Reference< css::task::XInteractionHandler >& rHandler ); + + void implStoreLibraryIndexFile( SfxLibrary* pLib, const ::xmlscript::LibDescriptor& rLib, + const css::uno::Reference< css::embed::XStorage >& xStorage ); + + // New variant for library export + void implStoreLibraryIndexFile( SfxLibrary* pLib, const ::xmlscript::LibDescriptor& rLib, + const css::uno::Reference< css::embed::XStorage >& xStorage, + const OUString& aTargetURL, + const css::uno::Reference< css::ucb::XSimpleFileAccess3 >& rToUseSFI ); + + bool implLoadLibraryIndexFile( SfxLibrary* pLib, + ::xmlscript::LibDescriptor& rLib, + const css::uno::Reference< css::embed::XStorage >& xStorage, + const OUString& aIndexFileName ); + + void implImportLibDescriptor( SfxLibrary* pLib, ::xmlscript::LibDescriptor const & rLib ); + + // Methods to distinguish between different library types + virtual SfxLibrary* implCreateLibrary( const OUString& aName ) = 0; + virtual SfxLibrary* implCreateLibraryLink + ( const OUString& aName, const OUString& aLibInfoFileURL, + const OUString& StorageURL, bool ReadOnly ) = 0; + virtual css::uno::Any createEmptyLibraryElement() = 0; + virtual bool isLibraryElementValid(const css::uno::Any& rElement) const = 0; + /// @throws css::uno::Exception + virtual void writeLibraryElement + ( + const css::uno::Reference< css::container::XNameContainer>& xLibrary, + const OUString& aElementName, + const css::uno::Reference< css::io::XOutputStream >& xOutput + ) = 0; + + virtual css::uno::Any importLibraryElement + ( + const css::uno::Reference< css::container::XNameContainer>& xLibrary, + const OUString& aElementName, + const OUString& aFile, + const css::uno::Reference< css::io::XInputStream >& xElementStream ) = 0; + virtual void importFromOldStorage( const OUString& aFile ) = 0; + + // Password encryption + virtual bool implStorePasswordLibrary( SfxLibrary* pLib, const OUString& aName, + const css::uno::Reference< css::embed::XStorage >& xStorage, const css::uno::Reference< css::task::XInteractionHandler >& Handler ); + + // New variant for library export + virtual bool implStorePasswordLibrary( SfxLibrary* pLib, const OUString& aName, + const css::uno::Reference< css::embed::XStorage >& rStorage, + const OUString& aTargetURL, + const css::uno::Reference< css::ucb::XSimpleFileAccess3 >& rToUseSFI, const css::uno::Reference< css::task::XInteractionHandler >& Handler ); + + /// @throws css::lang::WrappedTargetException + /// @throws css::uno::RuntimeException + virtual bool implLoadPasswordLibrary( SfxLibrary* pLib, const OUString& Name, + bool bVerifyPasswordOnly=false ); + + virtual void onNewRootStorage() = 0; + + + // #56666, Creates another library container + // instance of the same derived class + virtual SfxLibraryContainer* createInstanceImpl() = 0; + + + // Interface to get the BasicManager (Hack for password implementation) + BasicManager* getBasicManager(); + OUString createAppLibraryFolder( SfxLibrary* pLib, const OUString& aName ); + + void init( const OUString& rInitialDocumentURL, + const css::uno::Reference< css::embed::XStorage >& _rxInitialStorage ); + + virtual const char* getInfoFileName() const = 0; + virtual const char* getOldInfoFileName() const = 0; + virtual const char* getLibElementFileExtension() const = 0; + virtual const char* getLibrariesDir() const = 0; + + // Handle maLibInfoFileURL and maStorageURL correctly + void checkStorageURL + ( + const OUString& aSourceURL, + OUString& aLibInfoFileURL, + OUString& aStorageURL, + OUString& aUnexpandedStorageURL + ); + /// @throws css::uno::RuntimeException + OUString expand_url( const OUString& url ); + + SfxLibrary* getImplLib( const OUString& rLibraryName ); + + void storeLibraries_Impl( + const css::uno::Reference< css::embed::XStorage >& xStorage, + bool bComplete ); + + void initializeFromDocument( const css::uno::Reference< css::document::XStorageBasedDocument >& _rxDocument ); + + // OEventListenerAdapter + virtual void _disposing( const css::lang::EventObject& _rSource ) override; + + // OComponentHelper + virtual void SAL_CALL disposing() override; + +private: + void init_Impl( const OUString& rInitialDocumentURL, + const css::uno::Reference< css::embed::XStorage >& _rxInitialStorage ); + void implScanExtensions(); + +public: + SfxLibraryContainer(); + virtual ~SfxLibraryContainer() override; + + + // Interface to set the BasicManager (Hack for password implementation) + void setBasicManager( BasicManager* pBasMgr ) + { + mpBasMgr = pBasMgr; + } + + void enterMethod(); + static void leaveMethod(); + + // Methods XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // Methods XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // Members XStorageBasedLibraryContainer + virtual css::uno::Reference< css::embed::XStorage > SAL_CALL getRootStorage() override; + virtual void SAL_CALL setRootStorage( const css::uno::Reference< css::embed::XStorage >& _rootstorage ) override; + virtual void SAL_CALL storeLibrariesToStorage( const css::uno::Reference< css::embed::XStorage >& RootStorage ) override; + + // Methods XModifiable (base of XPersistentLibraryContainer) + virtual sal_Bool SAL_CALL isModified( ) override; + virtual void SAL_CALL setModified( sal_Bool bModified ) override; + virtual void SAL_CALL addModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + virtual void SAL_CALL removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + + // Methods XPersistentLibraryContainer (base of XStorageBasedLibraryContainer) + virtual css::uno::Any SAL_CALL getRootLocation() override; + virtual OUString SAL_CALL getContainerLocationName() override; + virtual void SAL_CALL storeLibraries( ) override; + + //Methods XLibraryContainer3 + virtual OUString SAL_CALL getOriginalLibraryLinkURL( const OUString& Name ) override; + + // Methods XLibraryContainer2 (base of XPersistentLibraryContainer) + virtual sal_Bool SAL_CALL isLibraryLink( const OUString& Name ) override; + virtual OUString SAL_CALL getLibraryLinkURL( const OUString& Name ) override; + virtual sal_Bool SAL_CALL isLibraryReadOnly( const OUString& Name ) override; + virtual void SAL_CALL setLibraryReadOnly( const OUString& Name, sal_Bool bReadOnly ) override; + virtual void SAL_CALL renameLibrary( const OUString& Name, const OUString& NewName ) override; + + // Methods XLibraryContainer (base of XLibraryContainer2) + virtual css::uno::Reference< css::container::XNameContainer > SAL_CALL + createLibrary( const OUString& Name ) override; + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL createLibraryLink + ( const OUString& Name, const OUString& StorageURL, sal_Bool ReadOnly ) override; + virtual void SAL_CALL removeLibrary( const OUString& Name ) override; + virtual sal_Bool SAL_CALL isLibraryLoaded( const OUString& Name ) override; + virtual void SAL_CALL loadLibrary( const OUString& Name ) override; + + // Methods XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< + css::uno::Any >& aArguments ) override; + + // Methods XLibraryContainerPassword + virtual sal_Bool SAL_CALL isLibraryPasswordProtected( const OUString& Name ) override; + virtual sal_Bool SAL_CALL isLibraryPasswordVerified( const OUString& Name ) override; + virtual sal_Bool SAL_CALL verifyLibraryPassword( const OUString& Name, const OUString& Password ) override; + virtual void SAL_CALL changeLibraryPassword( const OUString& Name, + const OUString& OldPassword, const OUString& NewPassword ) override; + + // Methods XContainer + virtual void SAL_CALL addContainerListener( const css::uno::Reference< + css::container::XContainerListener >& xListener ) override; + virtual void SAL_CALL removeContainerListener( const css::uno::Reference< + css::container::XContainerListener >& xListener ) override; + + // Methods XLibraryContainerExport + virtual void SAL_CALL exportLibrary( const OUString& Name, const OUString& URL, + const css::uno::Reference< css::task::XInteractionHandler >& Handler ) override; + + // Methods XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override = 0; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override = 0; + // Methods XVBACompatibility + virtual sal_Bool SAL_CALL getVBACompatibilityMode() override; + virtual void SAL_CALL setVBACompatibilityMode( sal_Bool _vbacompatmodeon ) override; + virtual OUString SAL_CALL getProjectName() override { return msProjectName; } + virtual void SAL_CALL setProjectName( const OUString& _projectname ) override; + virtual sal_Int32 SAL_CALL getRunningVBAScripts() override; + virtual void SAL_CALL addVBAScriptListener( + const css::uno::Reference< css::script::vba::XVBAScriptListener >& Listener ) override; + virtual void SAL_CALL removeVBAScriptListener( + const css::uno::Reference< css::script::vba::XVBAScriptListener >& Listener ) override; + virtual void SAL_CALL broadcastVBAScriptEvent( sal_Int32 nIdentifier, const OUString& rModuleName ) override; +}; + + +class LibraryContainerMethodGuard +{ +public: + LibraryContainerMethodGuard( SfxLibraryContainer& _rContainer ) + { + _rContainer.enterMethod(); + } + + ~LibraryContainerMethodGuard() + { + basic::SfxLibraryContainer::leaveMethod(); + } +}; + + +class SfxLibrary + : public css::container::XNameContainer + , public css::container::XContainer + , public css::util::XChangesNotifier + , public ::cppu::BaseMutex + , public ::cppu::OComponentHelper +{ + friend class SfxLibraryContainer; + friend class SfxDialogLibraryContainer; + friend class SfxScriptLibraryContainer; + + css::uno::Reference< css::ucb::XSimpleFileAccess3 > mxSFI; + + ModifiableHelper& mrModifiable; + rtl::Reference<NameContainer> maNameContainer; + + bool mbLoaded; + bool mbIsModified; + bool mbInitialised; + +private: + + OUString maLibElementFileExtension; + OUString maLibInfoFileURL; + OUString maStorageURL; + OUString maUnexpandedStorageURL; + OUString maOriginalStorageURL; + + bool mbLink; + bool mbReadOnly; + bool mbReadOnlyLink; + bool mbPreload; + +protected: + bool mbPasswordProtected; +private: + bool mbPasswordVerified; + bool mbDoc50Password; + OUString maPassword; + + bool mbSharedIndexFile; + bool mbExtension; + + // Additional functionality for localisation + // Provide modify state including resources + virtual bool isModified() = 0; + virtual void storeResources() = 0; + virtual void storeResourcesAsURL( const OUString& URL, const OUString& NewName ) = 0; + virtual void storeResourcesToURL( const OUString& URL, + const css::uno::Reference< css::task::XInteractionHandler >& xHandler ) = 0; + virtual void storeResourcesToStorage( const css::uno::Reference< css::embed::XStorage >& xStorage ) = 0; + +protected: + bool implIsModified() const { return mbIsModified; } + void implSetModified( 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 OUString& _rElementName ); + +public: + SfxLibrary( + ModifiableHelper& _rModifiable, + const css::uno::Type& aType, + const css::uno::Reference< css::ucb::XSimpleFileAccess3 >& xSFI + ); + SfxLibrary( + ModifiableHelper& _rModifiable, + const css::uno::Type& aType, + const css::uno::Reference< css::ucb::XSimpleFileAccess3 >& xSFI, + const OUString& aLibInfoFileURL, + const OUString& aStorageURL, + bool ReadOnly + ); + + // Methods XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& rType ) override; + virtual void SAL_CALL acquire() throw() override { OComponentHelper::acquire(); } + virtual void SAL_CALL release() throw() override { OComponentHelper::release(); } + + // Methods XElementAccess + virtual css::uno::Type SAL_CALL getElementType( ) override; + virtual sal_Bool SAL_CALL hasElements( ) override; + + // Methods XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // Methods XNameReplace + virtual void SAL_CALL replaceByName( const OUString& aName, const css::uno::Any& aElement ) override; + + // Methods XNameContainer + virtual void SAL_CALL insertByName( const OUString& aName, const css::uno::Any& aElement ) override; + virtual void SAL_CALL removeByName( const OUString& Name ) override; + + // XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) override; + + // Methods XContainer + virtual void SAL_CALL addContainerListener( const css::uno::Reference< + css::container::XContainerListener >& xListener ) override; + virtual void SAL_CALL removeContainerListener( const css::uno::Reference< + css::container::XContainerListener >& xListener ) override; + + // Methods XChangesNotifier + virtual void SAL_CALL addChangesListener( const css::uno::Reference< + css::util::XChangesListener >& xListener ) override; + virtual void SAL_CALL removeChangesListener( const css::uno::Reference< + css::util::XChangesListener >& xListener ) override; + +public: + struct LibraryContainerAccess { friend class SfxLibraryContainer; private: LibraryContainerAccess() { } }; + void removeElementWithoutChecks( const OUString& _rElementName, LibraryContainerAccess ) + { + impl_removeWithoutChecks( _rElementName ); + } + +protected: + virtual bool isLoadedStorable(); + + virtual bool isLibraryElementValid(const css::uno::Any& rElement) const = 0; +}; + + +class ScriptSubPackageIterator +{ + css::uno::Reference< css::deployment::XPackage > m_xMainPackage; + + bool m_bIsValid; + bool m_bIsBundle; + + css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > m_aSubPkgSeq; + sal_Int32 m_nSubPkgCount; + sal_Int32 m_iNextSubPkg; + + static css::uno::Reference< css::deployment::XPackage > + implDetectScriptPackage( const css::uno::Reference + < css::deployment::XPackage >& rPackage, bool& rbPureDialogLib ); + +public: + ScriptSubPackageIterator( css::uno::Reference< css::deployment::XPackage > const & xMainPackage ); + + css::uno::Reference< css::deployment::XPackage > getNextScriptSubPackage( bool& rbPureDialogLib ); +}; + + +class ScriptExtensionIterator final +{ +public: + ScriptExtensionIterator(); + OUString nextBasicOrDialogLibrary( bool& rbPureDialogLib ); + +private: + css::uno::Reference< css::deployment::XPackage > + implGetNextUserScriptPackage( bool& rbPureDialogLib ); + css::uno::Reference< css::deployment::XPackage > + implGetNextSharedScriptPackage( bool& rbPureDialogLib ); + css::uno::Reference< css::deployment::XPackage > + implGetNextBundledScriptPackage( bool& rbPureDialogLib ); + + css::uno::Reference< css::uno::XComponentContext > m_xContext; + + enum IteratorState + { + USER_EXTENSIONS, + SHARED_EXTENSIONS, + BUNDLED_EXTENSIONS, + END_REACHED + } m_eState; + + css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > m_aUserPackagesSeq; + bool m_bUserPackagesLoaded; + + css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > m_aSharedPackagesSeq; + bool m_bSharedPackagesLoaded; + + css::uno::Sequence< css::uno::Reference< css::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/opcodes.hxx b/basic/source/inc/opcodes.hxx new file mode 100644 index 000000000..cb9711036 --- /dev/null +++ b/basic/source/inc/opcodes.hxx @@ -0,0 +1,159 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_OPCODES_HXX +#define INCLUDED_BASIC_SOURCE_INC_OPCODES_HXX + +// An opcode can have a length of 1, 3 or 5 bytes, +// depending on its numeric value (see below). + +enum class SbiOpcode { + // all opcodes without operands + NOP_ = 0, + + SbOP0_START = NOP_, + + // operators + // the following operators are ordered + // the same way as the enum SbxVarOp + EXP_, MUL_, DIV_, MOD_, PLUS_, MINUS_, NEG_, + EQ_, NE_, LT_, GT_, LE_, GE_, + IDIV_, AND_, OR_, XOR_, EQV_, IMP_, NOT_, + CAT_, + // end of enum SbxVarOp + LIKE_, IS_, + // load/save + ARGC_, // establish new Argv + ARGV_, // TOS ==> current Argv + INPUT_, // Input ==> TOS + LINPUT_, // Line Input ==> TOS + GET_, // touch TOS + SET_, // save object TOS ==> TOS-1 + PUT_, // TOS ==> TOS-1 + PUTC_, // TOS ==> TOS-1, then ReadOnly + DIM_, // DIM + REDIM_, // REDIM + REDIMP_, // REDIM PRESERVE + ERASE_, // delete TOS + // branch + STOP_, // end of program + INITFOR_, // initialize FOR-variable + NEXT_, // increment FOR-variable + CASE_, // beginning CASE + ENDCASE_, // end CASE + STDERROR_, // standard error handling + NOERROR_, // no error handling + LEAVE_, // leave UP + // E/A + CHANNEL_, // TOS = channel number + BPRINT_, // print TOS + PRINTF_, // print TOS in field + BWRITE_, // write TOS + RENAME_, // Rename Tos+1 to Tos + PROMPT_, // TOS = Prompt for Input + RESTART_, // define restart point + CHAN0_, // I/O-channel 0 + // miscellaneous + EMPTY_, // empty expression on stack + ERROR_, // TOS = error code + LSET_, // saving object TOS ==> TOS-1 + RSET_, // saving object 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 = BYVAL_, + + // all opcodes with one operand + + NUMBER_ = 0x40, // loading a numeric constant (+ID) + + SbOP1_START = NUMBER_, + + SCONST_, // loading a string constant (+ID) + CONST_, // Immediate Load (+ value) + ARGN_, // saving a named Arg in Argv (+StringID) + PAD_, // bring string to a firm length (+length) + // branch + JUMP_, // jump (+target) + JUMPT_, // evaluate TOS, conditional jump (+target) + JUMPF_, // evaluate TOS, conditional jump (+target) + ONJUMP_, // evaluate TOS, jump into JUMP-table (+MaxVal) + GOSUB_, // UP-call (+Target) + RETURN_, // UP-return (+0 or Target) + TESTFOR_, // test FOR-variable, increment (+Endlabel) + CASETO_, // Tos+1 <= Case <= Tos, 2xremove (+Target) + ERRHDL_, // error handler (+Offset) + RESUME_, // Resume after errors (+0 or 1 or Label) + // E/A + CLOSE_, // (+channel/0) + PRCHAR_, // (+char) + // management + SETCLASS_, // test set + class names (+StringId) + TESTCLASS_, // Check TOS class (+StringId) + LIB_, // set lib name for declare-procs (+StringId) + BASED_, // TOS is incremented by BASE, BASE is pushed before (+base) + // type adjustment in the Argv + ARGTYP_, // convert last parameter in Argv (+type) + VBASETCLASS_, // VBA-like Set + + SbOP1_END = VBASETCLASS_, + + // all opcodes with two operands + + RTL_ = 0x80, // load from the RTL (+StringID+Typ) + + SbOP2_START = RTL_, + + FIND_, // load (+StringID+Typ) + ELEM_, // load element (+StringID+Typ) + PARAM_, // parameters (+Offset+Typ) + // branch + CALL_, // call DECLARE-method (+StringID+Typ) + CALLC_, // call Cdecl-DECLARE-Method (+StringID+Typ) + CASEIS_, // case-test (+Test-Opcode+True-Target) + // management + STMNT_, // begin of a statement (+Line+Col) + // E/A + OPEN_, // (+StreamMode+Flags) + // objects + LOCAL_, // define locals variables (+StringID+Typ) + PUBLIC_, // module global variables (+StringID+Typ) + GLOBAL_, // define global variables, public command (+StringID+Typ) + CREATE_, // create object (+StringId+StringID) + STATIC_, // static variable (+StringID+Typ) JSM + TCREATE_, // create user-defined object + DCREATE_, // create object-array (+StringId+StringID) + GLOBAL_P_, // define global variable that's not overwritten on restarting + // the Basic, P=PERSIST (+StringID+Typ) + FIND_G_, // finds global variable with special treatment due to GLOBAL_P_ + DCREATE_REDIMP_, // redimension object-array (+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 = FIND_STATIC_ +}; + +#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 000000000..88f4f34b2 --- /dev/null +++ b/basic/source/inc/parser.hxx @@ -0,0 +1,144 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_PARSER_HXX +#define INCLUDED_BASIC_SOURCE_INC_PARSER_HXX + +#include "expr.hxx" +#include "codegen.hxx" +#include "symtbl.hxx" +#include <basic/sbx.hxx> + +#include <vector> + +struct SbiParseStack; + +class SbiParser : public SbiTokenizer +{ + friend class SbiExpression; + + SbiParseStack* pStack; + SbiProcDef* pProc; + SbiExprNode* pWithVar; + SbiToken eEndTok; + sal_uInt32 nGblChain; // for global DIMs + bool bGblDefs; // true: global definitions general + bool bNewGblDefs; // true: globale definitions before sub + bool bSingleLineIf; + bool bCodeCompleting; + + SbiSymDef* VarDecl( SbiExprListPtr*, bool, bool ); + SbiProcDef* ProcDecl(bool bDecl); + void DefStatic( bool bPrivate ); + void DefProc( bool bStatic, bool bPrivate ); // read in procedure + void DefVar( SbiOpcode eOp, bool bStatic ); // read in DIM/REDIM + void TypeDecl( SbiSymDef&, bool bAsNewAlreadyParsed=false ); // AS-declaration + void OpenBlock( SbiToken, SbiExprNode* = nullptr ); + void CloseBlock(); + bool Channel( bool bAlways=false ); // parse channel number + void StmntBlock( SbiToken ); + void DefType(); // Parse type declaration + void DefEnum( bool bPrivate ); // Parse enum declaration + void DefDeclare( bool bPrivate ); + void EnableCompatibility(); + static bool IsUnoInterface( const OUString& sTypeName ); +public: + SbxArrayRef rTypeArray; + SbxArrayRef rEnumArray; + SbiStringPool aGblStrings; // string-pool + SbiStringPool aLclStrings; // string-pool + SbiSymPool aGlobals; + SbiSymPool aPublics; // module global + SbiSymPool aRtlSyms; // Runtime-Library + SbiCodeGen aGen; // Code-Generator + SbiSymPool* pPool; + short nBase; // OPTION BASE-value + bool bExplicit; // true: OPTION EXPLICIT + bool bClassModule; // true: OPTION ClassModule + std::vector<OUString> aIfaceVector; // Holds all interfaces implemented by a class module + std::vector<OUString> aRequiredTypes; // Types used in Dim As New <type> outside subs +# define N_DEF_TYPES 26 + SbxDataType eDefTypes[N_DEF_TYPES]; // DEFxxx data types + + SbiParser( StarBASIC*, SbModule* ); + ~SbiParser( ); + bool Parse(); + void SetCodeCompleting( bool b ); + bool IsCodeCompleting() const { return bCodeCompleting;} + SbiExprNode* GetWithVar(); + + // from 31.3.1996, search symbol in the runtime-library + SbiSymDef* CheckRTLForSym( const OUString& rSym, SbxDataType eType ); + void AddConstants(); + + bool HasGlobalCode(); + + bool TestToken( SbiToken ); + bool TestSymbol(); + bool TestComma(); + void TestEoln(); + + void Symbol( const KeywordSymbolInfo* pKeywordSymbolInfo ); // let or call + void ErrorStmnt(); // ERROR n + void BadBlock(); // LOOP/WEND/NEXT + void NoIf(); // ELSE/ELSE IF without IF + void Assign(); // LET + void 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 000000000..c00673055 --- /dev/null +++ b/basic/source/inc/propacc.hxx @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_BASIC_SOURCE_INC_PROPACC_HXX +#define INCLUDED_BASIC_SOURCE_INC_PROPACC_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 <cppuhelper/implbase.hxx> + +#include <vector> + +typedef std::vector<css::beans::PropertyValue> SbPropertyValueArr_Impl; + +typedef ::cppu::WeakImplHelper< css::beans::XPropertySet, + css::beans::XPropertyAccess > SbPropertyValuesHelper; + + +class SbPropertyValues: public SbPropertyValuesHelper +{ + SbPropertyValueArr_Impl m_aPropVals; + css::uno::Reference< css::beans::XPropertySetInfo > m_xInfo; + +private: + size_t GetIndex_Impl( const OUString &rPropName ) const; + +public: + SbPropertyValues(); + virtual ~SbPropertyValues() override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( + const OUString& aPropertyName, + const css::uno::Any& aValue) override; + virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( + const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& ) override; + virtual void SAL_CALL removePropertyChangeListener( + const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& ) override; + virtual void SAL_CALL addVetoableChangeListener( + const OUString& aPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& ) override; + virtual void SAL_CALL removeVetoableChangeListener( + const OUString& aPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& ) override; + + // XPropertyAccess + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getPropertyValues() override; + virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue >& PropertyValues_) override; +}; + +class SbxArray; + +void RTL_Impl_CreatePropertySet( SbxArray& rPar ); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/rtlproto.hxx b/basic/source/inc/rtlproto.hxx new file mode 100644 index 000000000..6e26f9316 --- /dev/null +++ b/basic/source/inc/rtlproto.hxx @@ -0,0 +1,365 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_RTLPROTO_HXX +#define INCLUDED_BASIC_SOURCE_INC_RTLPROTO_HXX + +#include <basic/sbstar.hxx> + +#define RTLNAME( name ) &SbRtl_##name + +typedef void( *RtlCall ) ( StarBASIC* p, SbxArray& rArgs, bool bWrite ); + +// Properties + +extern void SbRtl_Date(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Err(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Erl(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_False(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Empty(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Nothing(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Null(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_True(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); + +extern void SbRtl_ATTR_NORMAL(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_ATTR_READONLY(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_ATTR_HIDDEN(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_ATTR_SYSTEM(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_ATTR_VOLUME(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_ATTR_DIRECTORY(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_ATTR_ARCHIVE(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); + +extern void SbRtl_V_EMPTY(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_V_NULL(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_V_INTEGER(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_V_LONG(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_V_SINGLE(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_V_DOUBLE(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_V_CURRENCY(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_V_DATE(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_V_STRING(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); + +extern void SbRtl_MB_OK(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_MB_OKCANCEL(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_MB_ABORTRETRYIGNORE(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_MB_YESNOCANCEL(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_MB_YESNO(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_MB_RETRYCANCEL(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_MB_ICONSTOP(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_MB_ICONQUESTION(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_MB_ICONEXCLAMATION(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_MB_ICONINFORMATION(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_MB_DEFBUTTON1(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_MB_DEFBUTTON2(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_MB_DEFBUTTON3(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_MB_APPLMODAL(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_MB_SYSTEMMODAL(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); + +extern void SbRtl_IDOK(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_IDCANCEL(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_IDABORT(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_IDRETRY(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_IDYES(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_IDNO(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); + +extern void SbRtl_CF_TEXT(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_CF_BITMAP(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_CF_METAFILEPICT(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); + +extern void SbRtl_PI(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); + +extern void SbRtl_SET_OFF(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_SET_ON(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TOGGLE(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); + +extern void SbRtl_TYP_AUTHORFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_CHAPTERFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_CONDTXTFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_DATEFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_DBFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_DBNAMEFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_DBNEXTSETFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_DBNUMSETFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_DBSETNUMBERFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_DDEFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_DOCINFOFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_DOCSTATFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_EXTUSERFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_FILENAMEFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_FIXDATEFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_FIXTIMEFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_FORMELFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_GETFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_GETREFFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_HIDDENPARAFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_HIDDENTXTFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_INPUTFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_MACROFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_NEXTPAGEFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_PAGENUMBERFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_POSTITFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_PREVPAGEFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_SEQFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_SETFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_SETINPFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_SETREFFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_TEMPLNAMEFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_TIMEFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_USERFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_USRINPFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_SETREFPAGEFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_GETREFPAGEFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_INTERNETFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TYP_JUMPEDITFLD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); + +extern void SbRtl_FRAMEANCHORPAGE(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_FRAMEANCHORPARA(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_FRAMEANCHORCHAR(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); + +extern void SbRtl_CLEAR_ALLTABS(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_CLEAR_TAB(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_SET_TAB(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); + +// Methods + +extern void SbRtl_CreateObject(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Error(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Sin(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Abs(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Asc(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Atn(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Chr(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_ChrW(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Cos(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_CurDir(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_ChDir(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // JSM +extern void SbRtl_ChDrive(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // JSM +extern void SbRtl_FileCopy(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // JSM +extern void SbRtl_Kill(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // JSM +extern void SbRtl_MkDir(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // JSM +extern void SbRtl_RmDir(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // JSM +extern void SbRtl_SendKeys(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // JSM +extern void SbRtl_DDB(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_DimArray(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Dir(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_DoEvents(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Exp(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_FileLen(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Fix(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_FV(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Hex(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Input(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_InStr(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_InStrRev(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Int(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_IPmt(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_IRR(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Join(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_LCase(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Left(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Log(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_LTrim(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Mid(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_MIRR(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_NPer(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_NPV(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Oct(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Pmt(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_PPmt(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_PV(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Rate(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Replace(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Right(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_RTrim(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_RTL(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Sgn(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_SLN(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Space(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Split(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Sqr(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Str(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_StrComp(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_String(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_StrReverse(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_SYD(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Tab(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Tan(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_UCase(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Val(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Len(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Spc(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_DateSerial(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TimeSerial(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_DateValue(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TimeValue(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Day(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Hour(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Minute(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Month(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_MonthName(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Now(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Second(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Time(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Timer(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Weekday(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_WeekdayName(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Year(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_InputBox(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Me(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_MsgBox(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_IsArray(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_IsDate(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_IsEmpty(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_IsError(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_IsNull(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_IsNumeric(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_IsObject(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_IsUnoStruct(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); + +extern void SbRtl_FileDateTime(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Format(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_FormatNumber(StarBASIC* pBasic, SbxArray& rPar, bool bWrite); +extern void SbRtl_GetAttr(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Randomize(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // JSM +extern void SbRtl_Round(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Frac(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Rnd(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Shell(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_VarType(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TypeName(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TypeLen(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); + +extern void SbRtl_EOF(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_FileAttr(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Loc(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Lof(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Seek(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_SetAttr(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // JSM +extern void SbRtl_Reset(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // JSM + +extern void SbRtl_DDEInitiate(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_DDETerminate(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_DDETerminateAll(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_DDERequest(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_DDEExecute(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_DDEPoke(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); + +extern void SbRtl_FreeFile(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_IsMissing(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_LBound(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_UBound(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_RGB(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_QBColor(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_StrConv(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); + +extern void SbRtl_Beep(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); + +extern void SbRtl_Load(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Unload(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_LoadPicture(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_SavePicture(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); + +extern void SbRtl_CallByName(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_CBool(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // JSM +extern void SbRtl_CByte(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // JSM +extern void SbRtl_CCur(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // JSM +extern void SbRtl_CDate(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // JSM +extern void SbRtl_CDbl(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // JSM +extern void SbRtl_CInt(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // JSM +extern void SbRtl_CLng(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // JSM +extern void SbRtl_CSng(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // JSM +extern void SbRtl_CStr(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // JSM +extern void SbRtl_CVar(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // JSM +extern void SbRtl_CVErr(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // JSM + +extern void SbRtl_Iif(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // JSM + +extern void SbRtl_DumpAllObjects(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); + +extern void SbRtl_GetSystemType(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_GetGUIType(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Red(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Green(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Blue(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); + +extern void SbRtl_Switch(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Wait(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +//i#64882# add new WaitUntil +extern void SbRtl_WaitUntil(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_FuncCaller(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); + +extern void SbRtl_GetGUIVersion(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Choose(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Trim(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); + +extern void SbRtl_DateAdd(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_DateDiff(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_DatePart(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_FormatDateTime(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_GetSolarVersion(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TwipsPerPixelX(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_TwipsPerPixelY(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_FreeLibrary(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Array(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_FindObject(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_FindPropertyObject(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_EnableReschedule(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); + +extern void SbRtl_Put(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Get(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_Environ(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_GetDialogZoomFactorX(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_GetDialogZoomFactorY(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_GetSystemTicks(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_GetPathSeparator(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_ResolvePath(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_CreateUnoStruct(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_CreateUnoService(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_CreateUnoServiceWithArguments(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_CreateUnoValue(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_GetProcessServiceManager(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_GetDefaultContext(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_CreatePropertySet(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_CreateUnoListener(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_HasUnoInterfaces(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_EqualUnoObjects(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_CreateUnoDialog(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_GlobalScope(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_FileExists(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_ConvertToUrl(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_ConvertFromUrl(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_CDateToUnoDate(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_CDateFromUnoDate(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_CDateToUnoTime(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_CDateFromUnoTime(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_CDateToUnoDateTime(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_CDateFromUnoDateTime(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_CDateToIso(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_CDateFromIso(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_CompatibilityMode(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_CDec(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); + +extern void SbRtl_Partition(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // Fong + +extern double Now_Impl(); +extern void Wait_Impl( bool bDurationBased, SbxArray& rPar ); + +#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 000000000..65be051e7 --- /dev/null +++ b/basic/source/inc/runtime.hxx @@ -0,0 +1,421 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_RUNTIME_HXX +#define INCLUDED_BASIC_SOURCE_INC_RUNTIME_HXX + +#include <basic/sberrors.hxx> +#include <basic/sbmeth.hxx> +#include <basic/sbstar.hxx> +#include <basic/sbx.hxx> + +#include <rtl/ustring.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <osl/file.hxx> +#include <rtl/math.hxx> +#include <i18nlangtag/lang.h> + +#include <vector> +#include <memory> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/container/XEnumeration.hpp> +#include <unotools/localedatawrapper.hxx> +#include <o3tl/deleter.hxx> +#include <o3tl/typed_flags_set.hxx> + +class SbiInstance; // active StarBASIC process +class SbiRuntime; // active StarBASIC procedure instance + +struct SbiArgv; // Argv stack element +struct SbiGosub; // GOSUB stack element +class SbiImage; // Code-Image +class SbiIoSystem; +class SbiDdeControl; +class SbiDllMgr; +class SvNumberFormatter; // time/date functions +enum class SbiImageFlags; + +enum class ForType { + To, + EachArray, + EachCollection, + EachXEnumeration, + Error, +}; + +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; + std::unique_ptr<sal_Int32[]> + pArrayCurIndices; + std::unique_ptr<sal_Int32[]> + pArrayLowerBounds; + std::unique_ptr<sal_Int32[]> + pArrayUpperBounds; + css::uno::Reference< css::container::XEnumeration > xEnumeration; + + SbiForStack() + : pNext(nullptr) + , eForType(ForType::To) + , nCurCollectionIndex(0) + {} +}; + +#define MAXRECURSION 500 //to prevent dead-recursions + +enum class SbAttributes { + NONE = 0x0000, + READONLY = 0x0001, + HIDDEN = 0x0002, + DIRECTORY = 0x0010 +}; + +namespace o3tl +{ + template<> struct typed_flags<SbAttributes> : is_typed_flags<SbAttributes, 0x13> {}; +} + +class WildCard; + +class SbiRTLData +{ +public: + + std::unique_ptr<osl::Directory> pDir; + SbAttributes nDirFlags; + short nCurDirPos; + + OUString sFullNameToBeChecked; + std::unique_ptr<WildCard> pWildCard; + + css::uno::Sequence< OUString > aDirSeq; + + SbiRTLData(); + ~SbiRTLData(); +}; + +// The instance matches a running StarBASIC. Many basics running at the same +// time are managed by chained instances. There is all the data that only lives +// when the BASIC is living too, like the I/O-system. + +typedef std::vector< css::uno::Reference< css::lang::XComponent > > ComponentVector_t; + + +class SbiInstance +{ + friend class SbiRuntime; + + SbiRTLData aRTLData; + + // file system + std::unique_ptr<SbiIoSystem, o3tl::default_delete<SbiIoSystem>> pIosys; + // DDE + std::unique_ptr<SbiDdeControl> pDdeCtrl; + // DLL-Calls (DECLARE) + std::unique_ptr<SbiDllMgr> pDllMgr; + std::shared_ptr<SvNumberFormatter> pNumberFormatter; + StarBASIC* pBasic; + LanguageType meFormatterLangType; + DateOrder meFormatterDateOrder; + sal_uInt32 nStdDateIdx, nStdTimeIdx, nStdDateTimeIdx; + + ErrCode nErr; + OUString aErrorMsg; // last error message for $ARG + sal_Int32 nErl; // current error line + bool bReschedule; // Flag: sal_True = Reschedule in main loop + bool bCompatibility; // Flag: sal_True = VBA runtime compatibility mode + + ComponentVector_t ComponentVector; +public: + SbiRuntime* pRun; // Call-Stack + + // #31460 new concept for StepInto/Over/Out, + // explanation see runtime.cxx at SbiInstance::CalcBreakCallLevel() + sal_uInt16 nCallLvl; + sal_uInt16 nBreakCallLvl; + void CalcBreakCallLevel( BasicDebugFlags nFlags ); + + SbiInstance( StarBASIC* ); + ~SbiInstance(); + + void Error( ErrCode ); // trappable Error + void Error( ErrCode, const OUString& rMsg ); // trappable Error with message + void ErrorVB( sal_Int32 nVBNumber, const OUString& rMsg ); + void setErrorVB( sal_Int32 nVBNumber ); + void FatalError( ErrCode ); // non-trappable Error + void FatalError( ErrCode, const OUString& ); // non-trappable Error + void Abort(); // with current error code + + void Stop(); + ErrCode const & GetErr() const { return nErr; } + const OUString& GetErrorMsg() const { return aErrorMsg; } + sal_Int32 GetErl() const { return nErl; } + void EnableReschedule( bool bEnable ) { bReschedule = bEnable; } + bool IsReschedule() const { return bReschedule; } + void EnableCompatibility( bool bEnable ) { bCompatibility = bEnable; } + bool IsCompatibility() const { return bCompatibility; } + + ComponentVector_t& getComponentVector() { return ComponentVector; } + + SbMethod* GetCaller( sal_uInt16 ); + SbModule* GetActiveModule(); + + SbiIoSystem* GetIoSystem() { return pIosys.get(); } + SbiDdeControl* GetDdeControl() { return pDdeCtrl.get(); } + StarBASIC* GetBasic() { return pBasic; } + SbiDllMgr* GetDllMgr(); + SbiRTLData& GetRTLData() const { return const_cast<SbiRTLData&>(aRTLData); } + + std::shared_ptr<SvNumberFormatter> const & GetNumberFormatter(); + sal_uInt32 GetStdDateIdx() const { return nStdDateIdx; } + sal_uInt32 GetStdTimeIdx() const { return nStdTimeIdx; } + sal_uInt32 GetStdDateTimeIdx() const { return nStdDateTimeIdx; } + + // offer NumberFormatter also static + static std::shared_ptr<SvNumberFormatter> PrepareNumberFormatter( sal_uInt32 &rnStdDateIdx, + sal_uInt32 &rnStdTimeIdx, sal_uInt32 &rnStdDateTimeIdx, + LanguageType const * peFormatterLangType=nullptr, DateOrder const * peFormatterDateOrder=nullptr ); +}; + +// There's one instance of this class for every executed sub-program. +// This instance is the heart of the BASIC-machine and contains only local data. + +class SbiRuntime +{ + friend void SbRtl_CallByName( StarBASIC* pBasic, SbxArray& rPar, 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-table group 0 + static pStep1 aStep1[]; + static pStep2 aStep2[]; + + StarBASIC& rBasic; // StarBASIC instance + SbiInstance* pInst; // current thread + SbModule* pMod; // current module + SbMethod* pMeth; // method instance + 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; // substitute for variables that weren't found + SbxVariable* mpExtCaller; // Caller ( external - e.g. button name, shape, range object etc. - only in vba mode ) + SbiForStack* pForStk; // FOR/NEXT-Stack + sal_uInt16 nExprLvl; // depth of the expr-stack + sal_uInt16 nForLvl; // #118235: Maintain for level + const sal_uInt8* pCode; // current Code-Pointer + const sal_uInt8* pStmnt; // beginning of the last statement + const sal_uInt8* pError; // address of the current error handler + const sal_uInt8* pRestart; // restart-address + const sal_uInt8* pErrCode; // restart-address RESUME NEXT + const sal_uInt8* pErrStmnt; // restart-address RESUME 0 + OUString aLibName; // Lib-name for declare-call + SbxArrayRef refParams; // current procedure parameters + SbxArrayRef refLocals; // local variable + SbxArrayRef refArgv; + // #74254, one refSaveObj is not enough! new: pRefSaveList (see above) + short nArgc; + bool bRun; + bool bError; // true: handle errors + bool bInError; // true: in an error handler + bool bBlocked; // true: blocked by next call level, #i48868 + bool bVBAEnabled; + BasicDebugFlags nFlags; // Debugging-Flags + ErrCode nError; + sal_uInt16 nOps; // opcode counter + sal_uInt32 m_nLastTime; + + std::vector<SbxVariableRef> aRefSaved; // #74254 save temporary references + std::vector<SbiGosub> pGosubStk; // GOSUB stack + std::vector<SbiArgv> pArgvStk; // ARGV-Stack + + + SbxVariable* FindElement + ( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt32 nOp2, ErrCode, bool bLocal, bool bStatic = false ); + void SetupArgs( SbxVariable*, sal_uInt32 ); + SbxVariable* CheckArray( SbxVariable* ); + + void PushVar( SbxVariable* ); + SbxVariableRef PopVar(); + SbxVariable* GetTOS(); + void TOSMakeTemp(); + void ClearExprStack(); + + void PushGosub( const sal_uInt8* ); + void PopGosub(); + + void PushArgv(); + void PopArgv(); + void ClearArgvStack(); + + void PushFor(); + void PushForEach(); + void PopFor(); + void ClearForStack(); + + void StepArith( SbxOperator ); + void StepUnary( SbxOperator ); + void StepCompare( SbxOperator ); + + void SetParameters( SbxArray* ); + + // HAS TO BE IMPLEMENTED SOME TIME + void DllCall( const OUString&, const OUString&, SbxArray*, SbxDataType, bool ); + + // #56204 swap out DIM-functionality into help method (step0.cxx) + void DimImpl(const SbxVariableRef& refVar); + + static bool implIsClass( SbxObject const * pObj, const OUString& aClass ); + + void StepSETCLASS_impl( sal_uInt32 nOp1, bool bHandleDflt ); + + // the following routines are called by the single + // stepper and implement the single 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 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(); + // all opcodes with one operand + 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 OUString& aClass, bool bRaiseErrors, bool bDefault ); + void StepCLOSE( sal_uInt32 ), StepPRCHAR( sal_uInt32 ), StepARGTYP( sal_uInt32 ); + // all opcodes with two operands + 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, ErrCode, bool bStatic = 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( + OUString const & aName, SbxDataType t, sal_uInt32 nOp2 ); + 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 ); + static void implHandleSbxFlags( SbxVariable* pVar, SbxDataType t, sal_uInt32 nOp2 ); +public: + void SetVBAEnabled( bool bEnabled ); + bool IsImageFlag( SbiImageFlags n ) const; + sal_uInt16 GetBase() const; + sal_Int32 nLine,nCol1,nCol2; + SbiRuntime* pNext; // Stack-Chain + + // tdf#79426, tdf#125180 - adds the information about a missing parameter + static void SetIsMissing( SbxVariable* ); + // tdf#79426, tdf#125180 - checks if a variable contains the information about a missing parameter + static bool IsMissing( SbxVariable*, sal_uInt16 ); + + SbiRuntime( SbModule*, SbMethod*, sal_uInt32 ); + ~SbiRuntime(); + void Error( ErrCode, bool bVBATranslationAlreadyDone = false ); // set error if != 0 + void Error( ErrCode, const OUString& ); // set error if != 0 + void FatalError( ErrCode ); // error handling = standard, set error + void FatalError( ErrCode, const OUString& ); // error handling = standard, set error + static sal_Int32 translateErrorToVba( ErrCode nError, OUString& rMsg ); + bool Step(); // single step (one opcode) + void Stop() { bRun = false; } + void block() { bBlocked = true; } + void unblock() { bBlocked = false; } + SbModule* GetModule() { return pMod; } + BasicDebugFlags GetDebugFlags() const { return nFlags; } + void SetDebugFlags( BasicDebugFlags nFl ) { nFlags = nFl; } + SbMethod* GetCaller() { return pMeth;} + SbxVariable* GetExternalCaller(){ return mpExtCaller; } + + SbiForStack* FindForStackItemForCollection( class BasicCollection const * pCollection ); + + SbxBase* FindElementExtern( const OUString& rName ); + static bool isVBAEnabled(); + +}; + +inline void checkArithmeticOverflow( double d ) +{ + if( !std::isfinite( d ) ) + StarBASIC::Error( ERRCODE_BASIC_MATH_OVERFLOW ); +} + +inline void checkArithmeticOverflow( SbxVariable const * pVar ) +{ + if( pVar->GetType() == SbxDOUBLE ) + { + double d = pVar->GetDouble(); + checkArithmeticOverflow( d ); + } +} + + +StarBASIC* GetCurrentBasic( StarBASIC* pRTBasic ); + +// Returns true if UNO is available, otherwise the old +// file system implementation has to be used +// (Implemented in iosys.cxx) +bool hasUno(); + +// Converts possibly relative paths to absolute paths +// according to the setting done by ChDir/ChDrive +// (Implemented in methods.cxx) +OUString getFullPath( const OUString& aRelPath ); + +// Implementation of StepRENAME with UCB +// (Implemented in methods.cxx, so step0.cxx +// has not to be infected with UNO) +void implStepRenameUCB( const OUString& aSource, const OUString& aDest ); + +void implStepRenameOSL( const OUString& aSource, const OUString& aDest ); +bool IsBaseIndexOne(); + +void removeDimAsNewRecoverItem( SbxVariable* pVar ); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/sbintern.hxx b/basic/source/inc/sbintern.hxx new file mode 100644 index 000000000..75e3ede9a --- /dev/null +++ b/basic/source/inc/sbintern.hxx @@ -0,0 +1,118 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_SBINTERN_HXX +#define INCLUDED_BASIC_SOURCE_INC_SBINTERN_HXX + +#include <basic/basicdllapi.h> +#include <basic/sbstar.hxx> +#include <sbxfac.hxx> +#include <unotools/transliterationwrapper.hxx> +#include <vcl/errcode.hxx> + +namespace utl +{ + class TransliterationWrapper; +} +class SbUnoFactory; +class SbTypeFactory; +class SbOLEFactory; +class SbFormFactory; +class SbiInstance; +class SbModule; +class BasicManager; + +class SbiFactory : public SbxFactory +{ +public: + virtual SbxBase* Create( sal_uInt16 nSbxId, sal_uInt32 ) override; + virtual SbxObject* CreateObject( const OUString& ) override; +}; + +struct SbClassData +{ + SbxArrayRef mxIfaces; + + // types this module depends on because of use in Dim As New <type> + // needed for initialization order of class modules + std::vector< OUString > maRequiredTypes; + + SbClassData(); + ~SbClassData() + { clear(); } + void clear(); +}; + +// #115824: Factory class to create class objects (type command) +// Implementation: sb.cxx +class SbClassFactory : public SbxFactory +{ + SbxObjectRef xClassModules; + +public: + SbClassFactory(); + virtual ~SbClassFactory() override; + + void AddClassModule( SbModule* pClassModule ); + void RemoveClassModule( SbModule* pClassModule ); + + virtual SbxBase* Create( sal_uInt16 nSbxId, sal_uInt32 ) override; + virtual SbxObject* CreateObject( const OUString& ) override; + + SbModule* FindClass( const OUString& rClassName ); +}; + +struct SbiGlobals +{ + static SbiGlobals* pGlobals; + SbiInstance* pInst; // all active runtime instances + std::unique_ptr<SbiFactory> pSbFac; // StarBASIC-Factory + std::unique_ptr<SbUnoFactory> pUnoFac; // Factory for Uno-Structs at 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; // currently active module + SbModule* pCompMod; // currently compiled module + short nInst; // number of BASICs + Link<StarBASIC*,bool> aErrHdl; // global error handler + Link<StarBASIC*,BasicDebugFlags> aBreakHdl; // global break handler + ErrCode nCode; + sal_Int32 nLine; + sal_Int32 nCol1,nCol2; // from... to... + bool bCompilerError; // flag for compiler error + bool bGlobalInitErr; + bool bRunInit; // true, if RunInit active from the Basic + OUString aErrMsg; // buffer for GetErrorText() + std::unique_ptr<::utl::TransliterationWrapper> pTransliterationWrapper; // For StrComp + bool bBlockCompilerError; + std::unique_ptr<BasicManager> pAppBasMgr; + StarBASIC* pMSOMacroRuntimLib; // Lib containing MSO Macro Runtime API entry symbols + + SbiGlobals(); + ~SbiGlobals(); +}; + +// utility macros and routines + +SbiGlobals* GetSbData(); + +#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 000000000..2e4abc509 --- /dev/null +++ b/basic/source/inc/sbjsmeth.hxx @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +#ifndef INCLUDED_BASIC_SOURCE_INC_SBJSMETH_HXX +#define INCLUDED_BASIC_SOURCE_INC_SBJSMETH_HXX + +#include <basic/sbmeth.hxx> + +// basic module for JavaScript sources +// All the basic-specific methods must be overridden virtually and must +// be deactivated. The differentiation of normal modules is done by RTTI. + +class SbJScriptMethod : public SbMethod +{ +public: + SbJScriptMethod( SbxDataType ); + virtual ~SbJScriptMethod() override; + + SBX_DECL_PERSIST_NODATA(SBXID_JSCRIPTMETH,2); +}; + + +#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 000000000..9d2d7d8f4 --- /dev/null +++ b/basic/source/inc/sbjsmod.hxx @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_SBJSMOD_HXX +#define INCLUDED_BASIC_SOURCE_INC_SBJSMOD_HXX + +#include <basic/sbmod.hxx> + +// basic module for JavaScript sources +// All the basic-specific methods must be overridden virtually and must +// be deactivated. The differentiation of normal modules is done by RTTI. + +class SbJScriptModule : public SbModule +{ + virtual bool LoadData( SvStream&, sal_uInt16 ) override; + virtual bool StoreData( SvStream& ) const override; +public: + SBX_DECL_PERSIST_NODATA(SBXID_JSCRIPTMOD,1); + SbJScriptModule(); // hand through +}; + +#endif + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/sbunoobj.hxx b/basic/source/inc/sbunoobj.hxx new file mode 100644 index 000000000..6827bf755 --- /dev/null +++ b/basic/source/inc/sbunoobj.hxx @@ -0,0 +1,395 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_BASIC_SOURCE_INC_SBUNOOBJ_HXX +#define INCLUDED_BASIC_SOURCE_INC_SBUNOOBJ_HXX + +#include <basic/sbxobj.hxx> +#include <basic/sbxmeth.hxx> +#include <sbxprop.hxx> +#include <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/lang/XComponent.hpp> +#include <com/sun/star/script/XInvocation.hpp> +#include <com/sun/star/reflection/XIdlClass.hpp> +#include <com/sun/star/reflection/XServiceTypeDescription2.hpp> +#include <rtl/ustring.hxx> +#include <unordered_map> +#include <vector> +#include <map> + +void registerComponentToBeDisposedForBasic( const css::uno::Reference< css::lang::XComponent >& xComponent, StarBASIC* pBasic ); + +class StructRefInfo +{ + css::uno::Any& maAny; + css::uno::Type maType; + sal_Int32 mnPos; +public: + StructRefInfo( css::uno::Any& aAny, css::uno::Type const & rType, sal_Int32 nPos ) : maAny( aAny ), maType( rType ), mnPos( nPos ) {} + + sal_Int32 getPos() const { return mnPos; } + const css::uno::Type& getType() const { return maType; } + OUString getTypeName() const; + css::uno::Any& getRootAnyRef() { return maAny; }; + + css::uno::TypeClass getTypeClass() const; + + void* getInst(); + bool isEmpty() const { return (mnPos == -1); } + + css::uno::Any getValue(); + void setValue( const css::uno::Any& ); +}; + +class SbUnoStructRefObject: public SbxObject +{ + struct caseLessComp + { + bool operator() (const OUString& rProp, const OUString& rOtherProp ) const + { + return rProp.compareToIgnoreAsciiCase( rOtherProp ) < 0; + } + }; + typedef std::map< OUString, std::unique_ptr<StructRefInfo>, caseLessComp > StructFieldInfo; + StructFieldInfo maFields; + StructRefInfo maMemberInfo; + bool mbMemberCacheInit; + void implCreateAll(); + void implCreateDbgProperties(); + void initMemberCache(); + OUString Impl_DumpProperties(); + OUString getDbgObjectName() const; +public: + StructRefInfo getStructMember( const OUString& rMember ); + const StructRefInfo& getStructInfo() const { return maMemberInfo; } + SbUnoStructRefObject( const OUString& aName_, const StructRefInfo& rMemberInfo ); + virtual ~SbUnoStructRefObject() override; + + // override Find to support e. g. NameAccess + virtual SbxVariable* Find( const OUString&, SbxClassType ) override; + + // Force creation of all properties for debugging + void createAllProperties() + { implCreateAll(); } + + // give out value + css::uno::Any getUnoAny(); + void Notify( SfxBroadcaster&, const SfxHint& rHint ) override; +}; + +class SbUnoObject: public SbxObject +{ + css::uno::Reference< css::beans::XIntrospectionAccess > mxUnoAccess; + css::uno::Reference< css::beans::XMaterialHolder > mxMaterialHolder; + css::uno::Reference< css::script::XInvocation > mxInvocation; + css::uno::Reference< css::beans::XExactName > mxExactName; + css::uno::Reference< css::beans::XExactName > mxExactNameInvocation; + bool bNeedIntrospection; + bool bNativeCOMObject; + css::uno::Any maTmpUnoObj; // Only to save obj for doIntrospection! + std::shared_ptr< SbUnoStructRefObject > maStructInfo; + // help method to establish the dbg_-properties + void implCreateDbgProperties(); + + // help method to establish all properties and methods + // (on the on-demand-mechanism required for the dbg_-properties) + void implCreateAll(); + +public: + static bool getDefaultPropName( SbUnoObject const * pUnoObj, OUString& sDfltProp ); + SbUnoObject( const OUString& aName_, const css::uno::Any& aUnoObj_ ); + virtual ~SbUnoObject() override; + + // #76470 do introspection on demand + void doIntrospection(); + + // override Find to support e. g. NameAccess + virtual SbxVariable* Find( const OUString&, SbxClassType ) override; + + // Force creation of all properties for debugging + void createAllProperties() + { implCreateAll(); } + + // give out value + css::uno::Any getUnoAny(); + const css::uno::Reference< css::beans::XIntrospectionAccess >& getIntrospectionAccess() const { return mxUnoAccess; } + const css::uno::Reference< css::script::XInvocation >& getInvocation() const { return mxInvocation; } + + void Notify( SfxBroadcaster&, const SfxHint& rHint ) override; + + bool isNativeCOMObject() const + { return bNativeCOMObject; } +}; +typedef tools::SvRef<SbUnoObject> SbUnoObjectRef; + +// #67781 delete return values of the uno-methods +void clearUnoMethods(); +void clearUnoMethodsForBasic( StarBASIC const * pBasic ); + +class SbUnoMethod : public SbxMethod +{ + friend class SbUnoObject; + friend void clearUnoMethods(); + friend void clearUnoMethodsForBasic( StarBASIC const * pBasic ); + + css::uno::Reference< css::reflection::XIdlMethod > m_xUnoMethod; + std::unique_ptr<css::uno::Sequence< css::reflection::ParamInfo >> pParamInfoSeq; + + // #67781 reference to the previous and the next method in the method list + SbUnoMethod* pPrev; + SbUnoMethod* pNext; + + bool mbInvocation; // Method is based on invocation + +public: + + SbUnoMethod( const OUString& aName_, SbxDataType eSbxType, css::uno::Reference< css::reflection::XIdlMethod > const & xUnoMethod_, + bool bInvocation ); + virtual ~SbUnoMethod() override; + virtual SbxInfo* GetInfo() override; + + const css::uno::Sequence< css::reflection::ParamInfo >& getParamInfos(); + + bool isInvocationBased() const + { return mbInvocation; } +}; + + +class SbUnoProperty : public SbxProperty +{ + friend class SbUnoObject; + friend class SbUnoStructRefObject; + + css::beans::Property aUnoProp; + sal_Int32 nId; + + bool mbInvocation; // Property is based on invocation + SbxDataType mRealType; + virtual ~SbUnoProperty() override; + bool mbUnoStruct; + SbUnoProperty( const SbUnoProperty&) = delete; + SbUnoProperty& operator = ( const SbUnoProperty&) = delete; +public: + + SbUnoProperty( const OUString& aName_, SbxDataType eSbxType, SbxDataType eRealSbxType, + const css::beans::Property& aUnoProp_, sal_Int32 nId_, bool bInvocation, bool bUnoStruct ); + + bool isUnoStruct() const { return mbUnoStruct; } + bool isInvocationBased() const + { return mbInvocation; } + SbxDataType getRealType() const { return mRealType; } +}; + +// factory class to create uno-structs per DIM AS NEW +class SbUnoFactory : public SbxFactory +{ +public: + virtual SbxBase* Create( sal_uInt16 nSbxId, sal_uInt32 ) override; + virtual SbxObject* CreateObject( const OUString& ) override; +}; + +// wrapper for a uno-class +class SbUnoClass : public SbxObject +{ + const css::uno::Reference< css::reflection::XIdlClass > m_xClass; + +public: + SbUnoClass( const OUString& aName_ ) + : SbxObject( aName_ ) + {} + SbUnoClass( const OUString& aName_, const css::uno::Reference< css::reflection::XIdlClass >& xClass_ ) + : SbxObject( aName_ ) + , m_xClass( xClass_ ) + {} + + + virtual SbxVariable* Find( const OUString&, SbxClassType ) override; + + + const css::uno::Reference< css::reflection::XIdlClass >& getUnoClass() const { return m_xClass; } + +}; + + +// function to find a global identifier in +// the UnoScope and to wrap it for Sbx +SbUnoClass* findUnoClass( const OUString& rName ); + + +// Wrapper for UNO Service +class SbUnoService : public SbxObject +{ + const css::uno::Reference< css::reflection::XServiceTypeDescription2 > m_xServiceTypeDesc; + bool m_bNeedsInit; + +public: + SbUnoService( const OUString& aName_, + const css::uno::Reference< css::reflection::XServiceTypeDescription2 >& xServiceTypeDesc ) + : SbxObject( aName_ ) + , m_xServiceTypeDesc( xServiceTypeDesc ) + , m_bNeedsInit( true ) + {} + + virtual SbxVariable* Find( const OUString&, SbxClassType ) override; + + void Notify( SfxBroadcaster&, const SfxHint& rHint ) override; +}; + +SbUnoService* findUnoService( const OUString& rName ); + + +class SbUnoServiceCtor : public SbxMethod +{ + friend class SbUnoService; + + css::uno::Reference< css::reflection::XServiceConstructorDescription > m_xServiceCtorDesc; + +public: + + SbUnoServiceCtor( const OUString& aName_, css::uno::Reference< css::reflection::XServiceConstructorDescription > const & xServiceCtorDesc ); + virtual ~SbUnoServiceCtor() override; + virtual SbxInfo* GetInfo() override; + + const css::uno::Reference< css::reflection::XServiceConstructorDescription >& getServiceCtorDesc() const + { return m_xServiceCtorDesc; } +}; + + +// Wrapper for UNO Singleton +class SbUnoSingleton : public SbxObject +{ +public: + SbUnoSingleton( const OUString& aName_ ); + + void Notify( SfxBroadcaster&, const SfxHint& rHint ) override; +}; + +SbUnoSingleton* findUnoSingleton( const OUString& rName ); + + +// #105565 Special Object to wrap a strongly typed Uno Any +class SbUnoAnyObject: public SbxObject +{ + css::uno::Any mVal; + +public: + SbUnoAnyObject( const css::uno::Any& rVal ) + : SbxObject( OUString() ) + , mVal( rVal ) + {} + + const css::uno::Any& getValue() const + { return mVal; } + +}; + + +// #112509 Special SbxArray to transport named parameters for calls +// to OLEAutomation objects through the UNO OLE automation bridge + +class AutomationNamedArgsSbxArray : public SbxArray +{ + css::uno::Sequence< OUString > maNameSeq; +public: + AutomationNamedArgsSbxArray( sal_Int32 nSeqSize ) + : maNameSeq( nSeqSize ) + {} + + css::uno::Sequence< OUString >& getNames() + { return maNameSeq; } +}; + + +class StarBASIC; + +// Impl-methods for RTL +void RTL_Impl_CreateUnoStruct( SbxArray& rPar ); +void RTL_Impl_CreateUnoService( SbxArray& rPar ); +void RTL_Impl_CreateUnoServiceWithArguments( SbxArray& rPar ); +void RTL_Impl_CreateUnoValue( SbxArray& rPar ); +void RTL_Impl_GetProcessServiceManager( SbxArray& rPar ); +void RTL_Impl_HasInterfaces( SbxArray& rPar ); +void RTL_Impl_IsUnoStruct( SbxArray& rPar ); +void RTL_Impl_EqualUnoObjects( SbxArray& rPar ); +void RTL_Impl_GetDefaultContext( SbxArray& rPar ); + +void disposeComVariablesForBasic( StarBASIC const * pBasic ); +void clearNativeObjectWrapperVector(); + + +// #118116 Collection object + +class BasicCollection : public SbxObject +{ + friend class SbiRuntime; + SbxArrayRef xItemArray; + static SbxInfoRef xAddInfo; + static SbxInfoRef xItemInfo; + + void Initialize(); + virtual ~BasicCollection() override; + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + sal_Int32 implGetIndex( SbxVariable const * pIndexVar ); + sal_Int32 implGetIndexForName( const OUString& rName ); + void CollAdd( SbxArray* pPar_ ); + void CollItem( SbxArray* pPar_ ); + void CollRemove( SbxArray* pPar_ ); + +public: + BasicCollection( const OUString& rClassname ); + virtual void Clear() override; +}; + +class VBAConstantHelper +{ +private: + std::vector< OUString > aConstCache; + std::unordered_map< OUString, css::uno::Any > aConstHash; + bool isInited; + VBAConstantHelper():isInited( false ) {} + VBAConstantHelper(const VBAConstantHelper&) = delete; + void init(); +public: + static VBAConstantHelper& instance(); + SbxVariable* getVBAConstant( const OUString& rName ); + bool isVBAConstantType( const OUString& rName ); +}; + +SbxVariable* getDefaultProp( SbxVariable* pRef ); + +css::uno::Reference< css::uno::XInterface > createComListener( const css::uno::Any& aControlAny, + const OUString& aVBAType, + const OUString& aPrefix, + const SbxObjectRef& xScopeObj ); + +bool checkUnoObjectType(SbUnoObject& refVal, const OUString& aClass); + +SbUnoObject* createOLEObject_Impl( const OUString& aType ); + +// #55226 ship additional information +bool handleToStringForCOMObjects( SbxObject* pObj, SbxValue* pVal ); + +void registerComListenerVariableForBasic( SbxVariable* pVar, StarBASIC* pBasic ); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/sbxmod.hxx b/basic/source/inc/sbxmod.hxx new file mode 100644 index 000000000..853715c4b --- /dev/null +++ b/basic/source/inc/sbxmod.hxx @@ -0,0 +1,30 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_SBXMOD_HXX +#define INCLUDED_BASIC_SOURCE_INC_SBXMOD_HXX + +#include <com/sun/star/frame/XModel.hpp> +#include <basic/sbstar.hxx> + +css::uno::Reference<css::frame::XModel> getDocumentModel(StarBASIC*); + +#endif // INCLUDED_BASIC_SOURCE_INC_SBXMOD_HXX + +/* 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 000000000..9b03b0adc --- /dev/null +++ b/basic/source/inc/scanner.hxx @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_SCANNER_HXX +#define INCLUDED_BASIC_SOURCE_INC_SCANNER_HXX + +#include <basic/sbxdef.hxx> +#include <vcl/errcode.hxx> + +// The scanner is stand-alone, i. e. it can be used from everywhere. +// A BASIC-instance is necessary for error messages. Without BASIC +// the errors are only counted. Also the BASIC is necessary when an +// advanced SBX-variable shall be used for data type recognition etc. + +class StarBASIC; + +class SbiScanner +{ + OUString aBuf; // input buffer + OUString aLine; + sal_Int32 nLineIdx; + sal_Int32 nSaveLineIdx; + StarBASIC* pBasic; // instance for error callbacks + + void scanAlphanumeric(); + void scanGoto(); + bool readLine(); +protected: + OUString aSym; + OUString aError; + SbxDataType eScanType; + double nVal; // numeric value + sal_Int32 nSavedCol1; + sal_Int32 nCol; + sal_Int32 nErrors; + sal_Int32 nColLock; // lock counter for Col1 + sal_Int32 nBufPos; + sal_Int32 nLine; + sal_Int32 nCol1, nCol2; + bool bSymbol; // true: symbol scanned + bool bNumber; // true: number scanned + bool bSpaces; // true: whitespace before token + bool bAbort; + bool bHash; // true: # has been read in + bool bError; // true: generate error + bool bCompatible; // true: OPTION compatible + bool bVBASupportOn; // true: OPTION VBASupport 1 otherwise default False + bool bPrevLineExtentsComment; // true: Previous line is comment and ends on "... _" + + bool bInStatement; + void GenError( ErrCode ); +public: + SbiScanner( const OUString&, StarBASIC* = nullptr ); + + void EnableErrors() { bError = false; } + bool IsHash() const { return bHash; } + bool IsCompatible() const { return bCompatible; } + void SetCompatible( bool b ) { bCompatible = b; } // #118206 + bool IsVBASupportOn() const { return bVBASupportOn; } + bool WhiteSpace() { return bSpaces; } + sal_Int32 GetErrors() const { return nErrors; } + sal_Int32 GetLine() const { return nLine; } + sal_Int32 GetCol1() const { return nCol1; } + void SetCol1( sal_Int32 n ) { nCol1 = n; } + StarBASIC* GetBasic() { return pBasic; } + void SaveLine() { nSaveLineIdx = nLineIdx; } + void RestoreLine() { nLineIdx = nSaveLineIdx; } + void LockColumn(); + void UnlockColumn(); + bool DoesColonFollow(); + + bool NextSym(); + const OUString& GetSym() const { return aSym; } + SbxDataType GetType() const { return eScanType; } + double GetDbl() const { return nVal; } +}; + +#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 000000000..98fce14b6 --- /dev/null +++ b/basic/source/inc/scriptcont.hxx @@ -0,0 +1,163 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_SCRIPTCONT_HXX +#define INCLUDED_BASIC_SOURCE_INC_SCRIPTCONT_HXX + +#include "namecont.hxx" +#include <basic/basmgr.hxx> +#include <com/sun/star/script/vba/XVBAModuleInfo.hpp> +#include <comphelper/uno3.hxx> +#include <cppuhelper/implbase1.hxx> + +namespace basic +{ + + +class SfxScriptLibraryContainer : public SfxLibraryContainer, public OldBasicPassword +{ + css::uno::Reference< css::container::XNameAccess > mxCodeNameAccess; + + // Methods to distinguish between different library types + virtual SfxLibrary* implCreateLibrary( const OUString& aName ) override; + virtual SfxLibrary* implCreateLibraryLink + ( const OUString& aName, const OUString& aLibInfoFileURL, + const OUString& StorageURL, bool ReadOnly ) override; + virtual css::uno::Any createEmptyLibraryElement() override; + virtual bool isLibraryElementValid(const css::uno::Any& rElement) const override; + virtual void writeLibraryElement + ( + const css::uno::Reference< css::container::XNameContainer>& xLibrary, + const OUString& aElementName, + const css::uno::Reference< css::io::XOutputStream >& xOutput + ) override; + + virtual css::uno::Any importLibraryElement + ( + const css::uno::Reference< css::container::XNameContainer>& xLibrary, + const OUString& aElementName, + const OUString& aFile, + const css::uno::Reference< css::io::XInputStream >& xElementStream ) override; + + virtual void importFromOldStorage( const OUString& aFile ) override; + + virtual SfxLibraryContainer* createInstanceImpl() override; + + + // Password encryption + virtual bool implStorePasswordLibrary( SfxLibrary* pLib, const OUString& aName, + const css::uno::Reference< css::embed::XStorage>& xStorage, const css::uno::Reference< css::task::XInteractionHandler >& Handler ) override; + + // New variant for library export + virtual bool implStorePasswordLibrary( SfxLibrary* pLib, const OUString& aName, + const css::uno::Reference< css::embed::XStorage >& xStorage, + const OUString& aTargetURL, + const css::uno::Reference< css::ucb::XSimpleFileAccess3 >& rToUseSFI, const css::uno::Reference< css::task::XInteractionHandler >& Handler ) override; + + virtual bool implLoadPasswordLibrary( SfxLibrary* pLib, const OUString& Name, + bool bVerifyPasswordOnly=false ) override; + + virtual void onNewRootStorage() override; + + + // OldBasicPassword interface + virtual void setLibraryPassword( const OUString& rLibraryName, const OUString& rPassword ) override; + + virtual const char* getInfoFileName() const override; + virtual const char* getOldInfoFileName() const override; + virtual const char* getLibElementFileExtension() const override; + virtual const char* getLibrariesDir() const override; + +public: + SfxScriptLibraryContainer(); + SfxScriptLibraryContainer( const css::uno::Reference< css::embed::XStorage >& xStorage ); + + + // Methods XLibraryContainerPassword + virtual sal_Bool SAL_CALL isLibraryPasswordProtected( const OUString& Name ) override; + virtual sal_Bool SAL_CALL isLibraryPasswordVerified( const OUString& Name ) override; + virtual sal_Bool SAL_CALL verifyLibraryPassword( const OUString& Name, const OUString& Password ) override; + virtual void SAL_CALL changeLibraryPassword( const OUString& Name, + const OUString& OldPassword, const OUString& NewPassword ) override; + // XLibraryQueryExecutable + virtual sal_Bool SAL_CALL HasExecutableCode(const OUString&) override; + // Methods XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; +}; + + +typedef std::unordered_map< OUString, css::script::ModuleInfo > ModuleInfoMap; + +typedef ::cppu::ImplHelper1< css::script::vba::XVBAModuleInfo > SfxScriptLibrary_BASE; + +class SfxScriptLibrary : public SfxLibrary, public SfxScriptLibrary_BASE +{ + friend class SfxScriptLibraryContainer; + + typedef std::unordered_map< OUString, css::script::ModuleInfo > ModuleInfoMap; + + bool mbLoadedSource; + bool mbLoadedBinary; + ModuleInfoMap mModuleInfo; + + // Provide modify state including resources + virtual bool isModified() override; + virtual void storeResources() override; + virtual void storeResourcesAsURL( const OUString& URL, const OUString& NewName ) override; + virtual void storeResourcesToURL( const OUString& URL, + const css::uno::Reference< css::task::XInteractionHandler >& xHandler ) override; + virtual void storeResourcesToStorage( const css::uno::Reference< css::embed::XStorage >& xStorage ) override; + virtual bool isLoadedStorable() override; + +public: + SfxScriptLibrary + ( + ModifiableHelper& _rModifiable, + const css::uno::Reference< css::ucb::XSimpleFileAccess3 >& xSFI + ); + + SfxScriptLibrary + ( + ModifiableHelper& _rModifiable, + const css::uno::Reference< css::ucb::XSimpleFileAccess3 >& xSFI, + const OUString& aLibInfoFileURL, const OUString& aStorageURL, bool ReadOnly + ); + + DECLARE_XINTERFACE() + DECLARE_XTYPEPROVIDER() + + // XVBAModuleInfo + virtual css::script::ModuleInfo SAL_CALL getModuleInfo( const OUString& ModuleName ) override; + virtual sal_Bool SAL_CALL hasModuleInfo( const OUString& ModuleName ) override; + virtual void SAL_CALL insertModuleInfo( const OUString& ModuleName, const css::script::ModuleInfo& ModuleInfo ) override; + virtual void SAL_CALL removeModuleInfo( const OUString& ModuleName ) override; + + static bool containsValidModule( const css::uno::Any& _rElement ); + +protected: + virtual bool isLibraryElementValid(const css::uno::Any& rElement) const override; +}; + + +} // namespace basic + +#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 000000000..d7bc4c176 --- /dev/null +++ b/basic/source/inc/stdobj.hxx @@ -0,0 +1,44 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_STDOBJ_HXX +#define INCLUDED_BASIC_SOURCE_INC_STDOBJ_HXX + +#include <basic/sbxobj.hxx> + +class StarBASIC; +class SbStdFactory; + +class SbiStdObject : public SbxObject +{ + std::unique_ptr<SbStdFactory> pStdFactory; + + virtual ~SbiStdObject() override; + using SbxVariable::GetInfo; + static SbxInfo* GetInfo( short ); + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; +public: + SbiStdObject( const OUString&, StarBASIC* ); + virtual SbxVariable* Find( const OUString&, SbxClassType ) override; + virtual void SetModified( bool ) override; +}; + +#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 000000000..2dfc9c758 --- /dev/null +++ b/basic/source/inc/symtbl.hxx @@ -0,0 +1,222 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_SYMTBL_HXX +#define INCLUDED_BASIC_SOURCE_INC_SYMTBL_HXX + +#include <memory> +#include <vector> +#include <basic/sbdef.hxx> + +class SbiConstDef; +class SbiParser; +class SbiProcDef; +class SbiStringPool; +class SbiSymDef; // base class + +enum SbiSymScope { SbLOCAL, SbPARAM, SbPUBLIC, SbGLOBAL, SbRTL }; + +// The string-pool collects string entries and +// makes sure that they don't exist twice. + +class SbiStringPool { + std::vector<OUString> aData; +public: + SbiStringPool(); + ~SbiStringPool(); + sal_uInt32 GetSize() const { return aData.size(); } + short Add( const OUString& ); + short Add( double, SbxDataType ); + OUString Find( sal_uInt32 ) const; +}; + + +class SbiSymPool final { + friend class SbiSymDef; + friend class SbiProcDef; + SbiStringPool& rStrings; + std::vector<std::unique_ptr<SbiSymDef>> m_Data; + SbiSymPool* pParent; + SbiParser* pParser; + SbiSymScope eScope; + sal_uInt16 nProcId; // for STATIC-variable + sal_uInt16 nCur; // iterator +public: + SbiSymPool( SbiStringPool&, SbiSymScope, SbiParser* pParser_ ); + ~SbiSymPool(); + + void SetParent( SbiSymPool* p ) { pParent = p; } + void SetProcId( short n ) { nProcId = n; } + sal_uInt16 GetSize() const { return m_Data.size(); } + SbiSymScope GetScope() const { return eScope; } + void SetScope( SbiSymScope s ) { eScope = s; } + SbiParser* GetParser() { return pParser; } + + SbiSymDef* AddSym( const OUString& ); + SbiProcDef* AddProc( const OUString& ); + void Add( SbiSymDef* ); + SbiSymDef* Find( const OUString&, bool bSearchInParents = true ); // variable name + SbiSymDef* Get( sal_uInt16 ); // find variable per position + SbiSymDef* First(), *Next(); // iterators + + sal_uInt32 Define( const OUString& ); + sal_uInt32 Reference( const OUString& ); + void CheckRefs(); +}; + + +class SbiSymDef { // general symbol entry + friend class SbiSymPool; +protected: + OUString aName; + SbxDataType eType; + SbiSymPool* pIn; // parent pool + std::unique_ptr<SbiSymPool> pPool; // pool for sub-elements + short nLen; // string length for STRING*n + short nDims; + sal_uInt16 nId; + sal_uInt16 nTypeId; // Dim X AS data type + sal_uInt16 nProcId; + sal_uInt16 nPos; + sal_uInt32 nChain; + bool bNew : 1; // true: Dim As New... + bool bChained : 1; // true: symbol is defined in code + bool bByVal : 1; // true: ByVal-parameter + bool bOpt : 1; // true: optional parameter + bool bStatic : 1; // true: STATIC variable + bool bAs : 1; // true: data type defined per AS XXX + bool bGlobal : 1; // true: global variable + bool bParamArray : 1; // true: ParamArray parameter + bool bWithEvents : 1; // true: Declared WithEvents + bool bWithBrackets : 1; // true: Followed by () + sal_uInt16 nDefaultId; // Symbol number of default value + short nFixedStringLength; // String length in: Dim foo As String*Length +public: + SbiSymDef( const OUString& ); + virtual ~SbiSymDef(); + virtual SbiProcDef* GetProcDef(); + virtual SbiConstDef* GetConstDef(); + + SbxDataType GetType() const { return eType; } + virtual void SetType( SbxDataType ); + const OUString& GetName(); + SbiSymScope GetScope() const; + 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; } + bool IsDefined() const{ return bChained; } + void SetOptional() { bOpt = true; } + void SetParamArray() { bParamArray = true; } + void SetWithEvents() { bWithEvents = true; } + void SetWithBrackets(){ bWithBrackets = true; } + void SetByVal( bool bByVal_ ) { bByVal = bByVal_; } + void SetStatic( bool bAsStatic = true ) { bStatic = bAsStatic; } + void SetNew() { bNew = true; } + void SetDefinedAs() { bAs = true; } + void SetGlobal(bool b){ bGlobal = b; } + void SetDefaultId( sal_uInt16 n ) { nDefaultId = n; } + sal_uInt16 GetDefaultId() const { return nDefaultId; } + bool IsOptional() const{ return bOpt; } + bool IsParamArray() const{ return bParamArray; } + bool IsWithEvents() const{ return bWithEvents; } + bool IsWithBrackets() const{ return bWithBrackets; } + bool IsByVal() const { return bByVal; } + bool IsStatic() const { return bStatic; } + bool IsNew() const { return bNew; } + bool IsDefinedAs() const { return bAs; } + bool IsGlobal() const { return bGlobal; } + short GetFixedStringLength() const { return nFixedStringLength; } + void SetFixedStringLength( short n ) { nFixedStringLength = n; } + + SbiSymPool& GetPool(); + sal_uInt32 Define(); // define symbol in code + sal_uInt32 Reference(); // reference symbol in code + +private: + SbiSymDef( const SbiSymDef& ) = delete; + +}; + +class SbiProcDef : public SbiSymDef { // procedure definition (from basic): + SbiSymPool aParams; + SbiSymPool aLabels; // local jump targets + OUString aLibName; + OUString aAlias; + sal_uInt16 nLine1, nLine2; // line area + PropertyMode mePropMode; // Marks if this is a property procedure and which + OUString maPropName; // Property name if property procedure (!= proc name) + bool bCdecl : 1; // true: CDECL given + bool bPublic : 1; // true: proc is PUBLIC + bool mbProcDecl : 1; // true: instantiated by SbiParser::ProcDecl +public: + SbiProcDef( SbiParser*, const OUString&, bool bProcDecl=false ); + virtual ~SbiProcDef() override; + virtual SbiProcDef* GetProcDef() override; + virtual void SetType( SbxDataType ) override; + SbiSymPool& GetParams() { return aParams; } + SbiSymPool& GetLabels() { return aLabels; } + SbiSymPool& GetLocals() { return GetPool();} + OUString& GetLib() { return aLibName; } + OUString& GetAlias() { return aAlias; } + void SetPublic( bool b ) { bPublic = b; } + bool IsPublic() const { return bPublic; } + void SetCdecl( bool b ) { bCdecl = b; } + bool IsCdecl() const { return bCdecl; } + 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() const { return mePropMode; } + void setPropertyMode( PropertyMode ePropMode ); + const OUString& GetPropName() const { return maPropName; } + + // Match with a forward-declaration. The parameter names are + // compared and the forward declaration is replaced by this + void Match( SbiProcDef* pForward ); + +private: + SbiProcDef( const SbiProcDef& ) = delete; + +}; + +class SbiConstDef : public SbiSymDef +{ + double nVal; + OUString aVal; +public: + SbiConstDef( const OUString& ); + virtual ~SbiConstDef() override; + virtual SbiConstDef* GetConstDef() override; + void Set( double, SbxDataType ); + void Set( const OUString& ); + double GetValue() const { return nVal; } + const OUString& GetString() const { 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 000000000..34abfce82 --- /dev/null +++ b/basic/source/inc/token.hxx @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASIC_SOURCE_INC_TOKEN_HXX +#define INCLUDED_BASIC_SOURCE_INC_TOKEN_HXX + +#include "scanner.hxx" + +// The tokenizer is stand-alone, i. e. he can be used from everywhere. +// A BASIC-instance is necessary for error messages. Without BASIC the +// errors are only counted. The BASIC is also necessary when an advanced +// SBX-variable shall be used for recognition of data types etc. + + +enum SbiToken { + NIL = 0, + // tokens between 0x20 and 0x3F are literals: + LPAREN = '(', RPAREN = ')', COMMA = ',', DOT = '.', EXCLAM = '!', + HASH = '#', SEMICOLON = ';', + + // commands: + FIRSTKWD = 0x40, + AS = FIRSTKWD, ALIAS, ASSIGN, + CALL, CASE, CLOSE, COMPARE, CONST_, + DECLARE, DIM, DO, + + // in the order of the data type enums! + DEFINT, DEFLNG, DEFSNG, DEFDBL, DEFCUR, DEFDATE, DEFSTR, DEFOBJ, + DEFERR, DEFBOOL, DEFVAR, + // in the order of the data type 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, + // end of all keywords + LASTKWD = ENDWITH, + // statement end + EOS, EOLN, + // operators: + EXPON, NEG, MUL, + DIV, IDIV, MOD, PLUS, MINUS, + EQ, NE, LT, GT, LE, GE, + NOT, AND, OR, XOR, EQV, + IMP, CAT, LIKE, IS, TYPEOF, + // miscellaneous: + FIRSTEXTRA, + NUMBER=FIRSTEXTRA, FIXSTRING, SYMBOL, CDECL_, BYVAL, BYREF, + OUTPUT, RANDOM, APPEND, BINARY, ACCESS, + LOCK, READ, PRESERVE, BASE, ANY, LIB, OPTIONAL_, PTRSAFE, + BASIC_EXPLICIT, COMPATIBLE, CLASSMODULE, PARAMARRAY, WITHEVENTS, + + // from here there are JavaScript-tokens (same enum so that same type) + 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-operators + // _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 +}; + +class SbiTokenizer : public SbiScanner { +protected: + SbiToken eCurTok; + SbiToken ePush; + sal_uInt16 nPLine, nPCol1, nPCol2; // pushback location + bool bEof; + bool bEos; + bool bAs; // last keyword was AS + bool bErrorIsSymbol; // Handle Error token as Symbol, not keyword +public: + SbiTokenizer( const OUString&, StarBASIC* = nullptr ); + + bool IsEof() const { return bEof; } + bool IsEos() const { return bEos; } + + void Push( SbiToken ); + const OUString& Symbol( SbiToken ); // reconversion + + SbiToken Peek(); // read the next token + SbiToken Next(); // read a token + bool MayBeLabel( bool= false ); + + void Error( ErrCode c ) { GenError( c ); } + void Error( ErrCode, SbiToken ); + void Error( ErrCode, const OUString &); + + static bool IsEoln( SbiToken t ) + { return t == EOS || t == EOLN || t == REM; } + static bool IsKwd( SbiToken t ) + { return t >= FIRSTKWD && t <= LASTKWD; } + static bool IsExtra( SbiToken t ) + { return t >= FIRSTEXTRA; } + static OUString GetKeywordCase( const OUString& sKeyword ); +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |