diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-18 18:26:28 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-23 22:20:31 +0200 |
commit | b9337e22ce1dbf2eba0e8c8db294ae99f4111f91 (patch) | |
tree | 53ee1bd3dfd213815a21579151983cb997922b05 /include/basic | |
parent | f4e1642a1761d5eab6ccdd89928869c2b2f1528a (diff) |
execute move of global headers
see https://gerrit.libreoffice.org/#/c/3367/
and Change-Id: I00c96fa77d04b33a6f8c8cd3490dfcd9bdc9e84a for details
Change-Id: I199a75bc4042af20817265d5ef85b1134a96ff5a
Diffstat (limited to 'include/basic')
26 files changed, 3457 insertions, 0 deletions
diff --git a/include/basic/basicdllapi.h b/include/basic/basicdllapi.h new file mode 100644 index 000000000000..5c5c4647cd4c --- /dev/null +++ b/include/basic/basicdllapi.h @@ -0,0 +1,23 @@ +/* -*- 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/. + */ +#ifndef INCLUDED_BASICDLLAPI_H +#define INCLUDED_BASICDLLAPI_H + +#include "sal/types.h" + +#if defined(BASIC_DLLIMPLEMENTATION) +#define BASIC_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define BASIC_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif +#define BASIC_DLLPRIVATE SAL_DLLPRIVATE + +#endif /* INCLUDED_BASICDLLAPI_H */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/basicmanagerrepository.hxx b/include/basic/basicmanagerrepository.hxx new file mode 100644 index 000000000000..411aeadb8545 --- /dev/null +++ b/include/basic/basicmanagerrepository.hxx @@ -0,0 +1,142 @@ +/* -*- 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 BASICMANAGERREPOSITORY_HXX +#define BASICMANAGERREPOSITORY_HXX + +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/embed/XStorage.hpp> +#include "basicdllapi.h" + +class BasicManager; + +//........................................................................ +namespace basic +{ +//........................................................................ + + //==================================================================== + //= BasicManagerRepository + //==================================================================== + /** specifies a callback for instances which are interested in BasicManagers + created by the BasicManagerRepository. + */ + class BASIC_DLLPUBLIC SAL_NO_VTABLE BasicManagerCreationListener + { + public: + /** is called when a BasicManager has been created + + @param _rxForDocument + denotes the document for which the BasicManager has been created. If this is <NULL/>, + then the BasicManager is the application-wide BasicManager. + + @param _pBasicManager + denotes the BasicManager which has been created. The listener might for instance + decide to add global variables to it, or otherwise initialize it. + */ + virtual void onBasicManagerCreated( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxForDocument, + BasicManager& _rBasicManager + ) = 0; + + protected: + ~BasicManagerCreationListener() {} + }; + + //==================================================================== + //= BasicManagerRepository + //==================================================================== + class BASIC_DLLPUBLIC BasicManagerRepository + { + public: + /** returns the BasicManager belonging to the given document + + If the BasicManager does not yet exist, it is created. In this case, if the application's + BasicManager does not yet exist, it is also created. This is necessary since + the application's BasicManager acts as parent for all document's BasicManagers. + + If you're interested in this case - the implicit creation of the application's BasicManager -, + then you need to register as BasicManagerCreationListener. + + @param _rxDocumentModel + denotes the document model whose BasicManager is to be retrieved. Must not be <NULL/>. + The document should support the XDocumentPropertiesSupplier + interface, for retrieving + its title, which is needed in some error conditions. + Also it <em>must</em> support the XStorageBasedDocument interface, since we + must be able to retrieve the document's storage. If this interface is <em>not</em> + supported, creating a new BasicManager will certainly fail. + + @return + the BasicManager for this model. + + @attention + The returned BasicManager instances is owned by the repository. In particular, + you are not allowed to delete it. Instead, the given model is observed: As soon + as it's closed, the associated BasicManager is deleted. + */ + static BasicManager* getDocumentBasicManager( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxDocumentModel + ); + + /** returns the application-wide BasicManager + + @param _bCreate + determines whether the BasicManager should be created (<TRUE/>) if it + does not yet exist. + + @attention + If the BasicManager is newly created, then it is still owned by the repository. + In particular, you are not allowed to delete it. Instead, call resetApplicationBasicManager + to release the BasicManager. + */ + static BasicManager* getApplicationBasicManager( bool _bCreate ); + + /** resets the application-wide BasicManager to <NULL/> + */ + static void resetApplicationBasicManager(); + + /** registers a BasicManagerCreationListener instance which is notified whenever + the repository creates a BasicManager instance. + + Note that this listener is <em>not</em> called when somebody else + creates BasicManager instances. + + If the same listener is registered multiple times, it is also notified + multiple times, and needs to be revoked once for each registration. + */ + static void registerCreationListener( + BasicManagerCreationListener& _rListener + ); + + /** reveokes a BasicManagerCreationListener instance which has previously + been registered to be notified about created BasicManager instances. + */ + static void revokeCreationListener( + BasicManagerCreationListener& _rListener + ); + }; + +//........................................................................ +} // namespace basic +//........................................................................ + +#endif // BASICMANAGERREPOSITORY_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/basmgr.hxx b/include/basic/basmgr.hxx new file mode 100644 index 000000000000..12bca4779565 --- /dev/null +++ b/include/basic/basmgr.hxx @@ -0,0 +1,238 @@ +/* -*- 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 _BASMGR_HXX +#define _BASMGR_HXX + +#include <svl/brdcst.hxx> +#include <basic/sbstar.hxx> +#include <com/sun/star/script/XStorageBasedLibraryContainer.hpp> +#include <com/sun/star/script/XStarBasicAccess.hpp> +#include "basicdllapi.h" +#include <vector> + +// Basic XML Import/Export +BASIC_DLLPUBLIC com::sun::star::uno::Reference< com::sun::star::script::XStarBasicAccess > + getStarBasicAccess( BasicManager* pMgr ); + +class SotStorage; + +#define BASERR_REASON_OPENSTORAGE 0x0001 +#define BASERR_REASON_OPENLIBSTORAGE 0x0002 +#define BASERR_REASON_OPENMGRSTREAM 0x0004 +#define BASERR_REASON_OPENLIBSTREAM 0x0008 +#define BASERR_REASON_LIBNOTFOUND 0x0010 +#define BASERR_REASON_STORAGENOTFOUND 0x0020 +#define BASERR_REASON_BASICLOADERROR 0x0040 +#define BASERR_REASON_NOSTORAGENAME 0x0080 + +#define BASERR_REASON_STDLIB 0x0100 + +class BASIC_DLLPUBLIC BasicError +{ +private: + sal_uIntPtr nErrorId; + sal_uInt16 nReason; + OUString aErrStr; + +public: + BasicError( const BasicError& rErr ); + BasicError( sal_uIntPtr nId, sal_uInt16 nR, const OUString& rErrStr ); + + sal_uIntPtr GetErrorId() const { return nErrorId; } + sal_uInt16 GetReason() const { return nReason; } + OUString GetErrorStr() { return aErrStr; } + + void SetErrorId( sal_uIntPtr n ) { nErrorId = n; } + void SetReason( sal_uInt16 n ) { nReason = n; } + void SetErrorStr( const OUString& rStr) { aErrStr = rStr; } +}; + +class BasicLibs; +class ErrorManager; +class BasicLibInfo; + +namespace basic { class BasicManagerCleaner; } + +// Library password handling for 5.0 documents +class BASIC_DLLPUBLIC OldBasicPassword +{ +public: + virtual void setLibraryPassword( const OUString& rLibraryName, const OUString& rPassword ) = 0; + virtual OUString getLibraryPassword( const OUString& rLibraryName ) = 0; + virtual void clearLibraryPassword( const OUString& rLibraryName ) = 0; + virtual sal_Bool hasLibraryPassword( const OUString& rLibraryName ) = 0; + +protected: + ~OldBasicPassword() {} +}; + +struct LibraryContainerInfo +{ + ::com::sun::star::uno::Reference< com::sun::star::script::XPersistentLibraryContainer > mxScriptCont; + ::com::sun::star::uno::Reference< com::sun::star::script::XPersistentLibraryContainer > mxDialogCont; + OldBasicPassword* mpOldBasicPassword; + + LibraryContainerInfo() + :mpOldBasicPassword( NULL ) + { + } + + LibraryContainerInfo + ( + com::sun::star::uno::Reference< com::sun::star::script::XPersistentLibraryContainer > xScriptCont, + com::sun::star::uno::Reference< com::sun::star::script::XPersistentLibraryContainer > xDialogCont, + OldBasicPassword* pOldBasicPassword + ) + : mxScriptCont( xScriptCont ) + , mxDialogCont( xDialogCont ) + , mpOldBasicPassword( pOldBasicPassword ) + {} +}; + +struct BasicManagerImpl; + + +#define LIB_NOTFOUND 0xFFFF + +class BASIC_DLLPUBLIC BasicManager : public SfxBroadcaster +{ + friend class LibraryContainer_Impl; + friend class StarBasicAccess_Impl; + friend class BasMgrContainerListenerImpl; + friend class ::basic::BasicManagerCleaner; + +private: + BasicLibs* pLibs; + std::vector<BasicError> aErrors; + + OUString aName; + OUString maStorageName; + bool mbDocMgr; + + BasicManagerImpl* mpImpl; + + BASIC_DLLPRIVATE void Init(); + +protected: + sal_Bool ImpLoadLibrary( BasicLibInfo* pLibInfo ) const; + sal_Bool ImpLoadLibrary( BasicLibInfo* pLibInfo, SotStorage* pCurStorage, sal_Bool bInfosOnly = sal_False ); + void ImpCreateStdLib( StarBASIC* pParentFromStdLib ); + void ImpMgrNotLoaded( const OUString& rStorageName ); + BasicLibInfo* CreateLibInfo(); + void LoadBasicManager( SotStorage& rStorage, const OUString& rBaseURL, sal_Bool bLoadBasics = sal_True ); + void LoadOldBasicManager( SotStorage& rStorage ); + sal_Bool ImplLoadBasic( SvStream& rStrm, StarBASICRef& rOldBasic ) const; + sal_Bool ImplEncryptStream( SvStream& rStream ) const; + BasicLibInfo* FindLibInfo( StarBASIC* pBasic ) const; + void CheckModules( StarBASIC* pBasic, sal_Bool bReference ) const; + ~BasicManager(); + +public: + TYPEINFO(); + BasicManager( SotStorage& rStorage, const OUString& rBaseURL, StarBASIC* pParentFromStdLib = NULL, OUString* pLibPath = NULL, bool bDocMgr = false ); + BasicManager( StarBASIC* pStdLib, OUString* pLibPath = NULL, bool bDocMgr = false ); + + /** deletes the given BasicManager instance + + This method is necessary since normally, BasicManager instances are owned by the BasicManagerRepository, + and expected to be deleted by the repository only. However, there exists quite some legacy code, + which needs to explicitly delete a BasicManager itself. This code must not use the (protected) + destructor, but LegacyDeleteBasicManager. + */ + static void LegacyDeleteBasicManager( BasicManager*& _rpManager ); + + void SetStorageName( const OUString& rName ) { maStorageName = rName; } + OUString GetStorageName() const { return maStorageName; } + void SetName( const OUString& rName ) { aName = rName; } + OUString GetName() const { return aName; } + + + sal_uInt16 GetLibCount() const; + StarBASIC* GetLib( sal_uInt16 nLib ) const; + StarBASIC* GetLib( const OUString& rName ) const; + sal_uInt16 GetLibId( const OUString& rName ) const; + + OUString GetLibName( sal_uInt16 nLib ); + + /** announces the library containers which belong to this BasicManager + + The method will automatically add two global constants, BasicLibraries and DialogLibraries, + to the BasicManager. + */ + void SetLibraryContainerInfo( const LibraryContainerInfo& rInfo ); + + const ::com::sun::star::uno::Reference< com::sun::star::script::XPersistentLibraryContainer >& + GetDialogLibraryContainer() const; + const ::com::sun::star::uno::Reference< com::sun::star::script::XPersistentLibraryContainer >& + GetScriptLibraryContainer() const; + + sal_Bool LoadLib( sal_uInt16 nLib ); + sal_Bool RemoveLib( sal_uInt16 nLib, sal_Bool bDelBasicFromStorage ); + + // Modify-Flag will be reset only during save. + sal_Bool IsBasicModified() const; + + std::vector<BasicError>& GetErrors(); + + /** sets a global constant in the basic library, referring to some UNO object, to a new value. + + If a constant with this name already existed before, its value is changed, and the old constant is + returned. If it does not yet exist, it is newly created, and inserted into the basic library. + */ + ::com::sun::star::uno::Any + SetGlobalUNOConstant( const sal_Char* _pAsciiName, const ::com::sun::star::uno::Any& _rValue ); + + /** retrieves a global constant in the basic library, referring to some UNO object, returns true if a value is found ( value is in aOut ) false otherwise. */ + bool GetGlobalUNOConstant( const sal_Char* _pAsciiName, ::com::sun::star::uno::Any& aOut ); + /** determines whether there are password-protected modules whose size exceedes the + legacy module size + @param _out_rModuleNames + takes the names of modules whose size exceeds the legacy limit + */ + bool LegacyPsswdBinaryLimitExceeded( ::com::sun::star::uno::Sequence< OUString >& _out_rModuleNames ); + bool HasExeCode( const OUString& ); + /// determines whether the Basic Manager has a given macro, given by fully qualified name + bool HasMacro( OUString const& i_fullyQualifiedName ) const; + /// executes a given macro + ErrCode ExecuteMacro( OUString const& i_fullyQualifiedName, SbxArray* i_arguments, SbxValue* i_retValue ); + /// executes a given macro + ErrCode ExecuteMacro( OUString const& i_fullyQualifiedName, OUString const& i_commaSeparatedArgs, SbxValue* i_retValue ); + +private: + BASIC_DLLPRIVATE sal_Bool IsReference( sal_uInt16 nLib ); + + BASIC_DLLPRIVATE sal_Bool SetLibName( sal_uInt16 nLib, const OUString& rName ); + + BASIC_DLLPRIVATE StarBASIC* GetStdLib() const; + BASIC_DLLPRIVATE StarBASIC* AddLib( SotStorage& rStorage, const OUString& rLibName, sal_Bool bReference ); + BASIC_DLLPRIVATE sal_Bool RemoveLib( sal_uInt16 nLib ); + BASIC_DLLPRIVATE sal_Bool HasLib( const OUString& rName ) const; + + BASIC_DLLPRIVATE StarBASIC* CreateLibForLibContainer( const OUString& rLibName, + const com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer >& + xScriptCont ); + // For XML import/export: + BASIC_DLLPRIVATE StarBASIC* CreateLib( const OUString& rLibName ); + BASIC_DLLPRIVATE StarBASIC* CreateLib( const OUString& rLibName, const OUString& Password, + const OUString& LinkTargetURL ); +}; + +#endif //_BASMGR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/basrdll.hxx b/include/basic/basrdll.hxx new file mode 100644 index 000000000000..20edde65b9cd --- /dev/null +++ b/include/basic/basrdll.hxx @@ -0,0 +1,52 @@ +/* -*- 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 _BASRDLL_HXX +#define _BASRDLL_HXX + +class ResMgr; + +#include <vcl/accel.hxx> +#include "basicdllapi.h" + +class BASIC_DLLPUBLIC BasicDLL +{ +private: + ResMgr* pBasResMgr; + + bool bDebugMode; + bool bBreakEnabled; + +public: + BasicDLL(); + ~BasicDLL(); + + ResMgr* GetBasResMgr() const { return pBasResMgr; } + + static void BasicBreak(); + + static void EnableBreak( bool bEnable ); + static void SetDebugMode( bool bDebugMode ); +}; + +#define BASIC_DLL() (*(BasicDLL**)GetAppData( SHL_BASIC ) ) + +#endif //_BASRDLL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/global.hxx b/include/basic/global.hxx new file mode 100644 index 000000000000..e63029da5785 --- /dev/null +++ b/include/basic/global.hxx @@ -0,0 +1,28 @@ +/* -*- 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: + * + */ + +#ifndef BASIC_SBGLOBAL_HXX +#define BASIC_SBGLOBAL_HXX + +namespace utl { + class TransliterationWrapper; +} + +class SbGlobal +{ +public: + static utl::TransliterationWrapper& GetTransliteration(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/modsizeexceeded.hxx b/include/basic/modsizeexceeded.hxx new file mode 100644 index 000000000000..05dd70b4b66d --- /dev/null +++ b/include/basic/modsizeexceeded.hxx @@ -0,0 +1,55 @@ +/* -*- 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 _BASIC_MODSIZEEXCEEDED_HXX +#define _BASIC_MODSIZEEXCEEDED_HXX + +#include <com/sun/star/task/XInteractionHandler.hpp> +#include <cppuhelper/implbase1.hxx> +#include "basicdllapi.h" + +class BASIC_DLLPUBLIC ModuleSizeExceeded : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionRequest > +{ + // C++ interface + public: + ModuleSizeExceeded( const com::sun::star::uno::Sequence<OUString>& sModules ); + + sal_Bool isAbort() const; + sal_Bool isApprove() const; + + // UNO interface + public: + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< com::sun::star::task::XInteractionContinuation > > SAL_CALL getContinuations() throw( ::com::sun::star::uno::RuntimeException ) { return m_lContinuations; } + com::sun::star::uno::Any SAL_CALL getRequest() throw( com::sun::star::uno::RuntimeException ) + { + return m_aRequest; + } + + // member + private: + OUString m_sMods; + com::sun::star::uno::Any m_aRequest; + com::sun::star::uno::Sequence< com::sun::star::uno::Reference< com::sun::star::task::XInteractionContinuation > > m_lContinuations; + com::sun::star::uno::Reference< com::sun::star::task::XInteractionContinuation > m_xAbort; + com::sun::star::uno::Reference< com::sun::star::task::XInteractionContinuation> m_xApprove; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/sbdef.hxx b/include/basic/sbdef.hxx new file mode 100644 index 000000000000..2bc29cbb08c3 --- /dev/null +++ b/include/basic/sbdef.hxx @@ -0,0 +1,68 @@ +/* -*- 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 _SB_SBDEF_HXX +#define _SB_SBDEF_HXX + +#include <basic/sbxdef.hxx> +#include <rtl/ustring.hxx> +#include "basicdllapi.h" + +// Returns type name for Basic type, array flag is ignored +// implementation: basic/source/runtime/methods.cxx +BASIC_DLLPUBLIC OUString getBasicTypeName( SbxDataType eType ); + +// Returns type name for Basic objects, especially +// important for SbUnoObj instances +// implementation: basic/source/classes/sbunoobj.cxx +class SbxObject; +BASIC_DLLPUBLIC OUString getBasicObjectTypeName( SbxObject* pObj ); + +// Allows Basic IDE to set watch mode to suppress errors +// implementation: basic/source/runtime/runtime.cxx +BASIC_DLLPUBLIC void setBasicWatchMode( bool bOn ); + +// Debug Flags: +#define SbDEBUG_BREAK 0x0001 // Break-Callback +#define SbDEBUG_STEPINTO 0x0002 // Single Step-Callback +#define SbDEBUG_STEPOVER 0x0004 // Additional flag Step Over +#define SbDEBUG_CONTINUE 0x0008 // Do not change flags +#define SbDEBUG_STEPOUT 0x0010 // Leave Sub + +#define SBXID_BASIC 0x6273 // sb: StarBASIC +#define SBXID_BASICMOD 0x6d62 // bm: StarBASIC Module +#define SBXID_BASICPROP 0x7262 // pr: StarBASIC Property +#define SBXID_BASICMETHOD 0x6d65 // me: StarBASIC Method +#define SBXID_JSCRIPTMOD 0x6a62 // jm: JavaScript Module +#define SBXID_JSCRIPTMETH 0x6a64 // jm: JavaScript Module + +#define SBX_HINT_BASICSTART SFX_HINT_USER04 +#define SBX_HINT_BASICSTOP SFX_HINT_USER05 + +enum PropertyMode +{ + PROPERTY_MODE_NONE, + PROPERTY_MODE_GET, + PROPERTY_MODE_LET, + PROPERTY_MODE_SET +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/sberrors.hxx b/include/basic/sberrors.hxx new file mode 100644 index 000000000000..f287f3afca88 --- /dev/null +++ b/include/basic/sberrors.hxx @@ -0,0 +1,418 @@ +/* -*- 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 _SB_SBERRORS_HXX +#define _SB_SBERRORS_HXX + +#include <basic/sbxdef.hxx> + +#ifndef __RSC +typedef sal_uIntPtr SbError; +#endif + +// Mapping to SbxError +#define ERRCODE_BASIC_SYNTAX ERRCODE_SBX_SYNTAX // unspecified syntax error +#define ERRCODE_BASIC_BAD_ARGUMENT ERRCODE_SBX_NOTIMP // Invalid procedure call +#define ERRCODE_BASIC_MATH_OVERFLOW ERRCODE_SBX_OVERFLOW // Overflow +#define ERRCODE_BASIC_OUT_OF_RANGE ERRCODE_SBX_BOUNDS // Subscript out of range +#define ERRCODE_BASIC_ZERODIV ERRCODE_SBX_ZERODIV // Division by zero +#define ERRCODE_BASIC_CONVERSION ERRCODE_SBX_CONVERSION // Type mismatch +#define ERRCODE_BASIC_BAD_PARAMETER ERRCODE_SBX_BAD_PARAMETER // Invalid Parameter +#define ERRCODE_BASIC_PROC_UNDEFINED ERRCODE_SBX_PROC_UNDEFINED // Sub or Function not defined +#define ERRCODE_BASIC_INTERNAL_ERROR ERRCODE_SBX_ERROR // internal error +#define ERRCODE_BASIC_NO_OBJECT ERRCODE_SBX_NO_OBJECT // Object variable not set +#define ERRCODE_BASIC_CANNOT_LOAD ERRCODE_SBX_CANNOT_LOAD // Can't load module +#define ERRCODE_BASIC_BAD_INDEX ERRCODE_SBX_BAD_INDEX // Invalid object index +#define ERRCODE_BASIC_NO_ACTIVE_OBJECT ERRCODE_SBX_NO_ACTIVE_OBJECT // No active view or document +#define ERRCODE_BASIC_BAD_PROP_VALUE ERRCODE_SBX_BAD_PROP_VALUE // Bad property value +#define ERRCODE_BASIC_PROP_READONLY ERRCODE_SBX_PROP_READONLY // Property is read only +#define ERRCODE_BASIC_PROP_WRITEONLY ERRCODE_SBX_PROP_WRITEONLY // Property is write only +#define ERRCODE_BASIC_INVALID_OBJECT ERRCODE_SBX_INVALID_OBJECT // Invalid object reference +#define ERRCODE_BASIC_NO_METHOD ERRCODE_SBX_NO_METHOD // Property or method not found +#define ERRCODE_BASIC_INVALID_USAGE_OBJECT ERRCODE_SBX_INVALID_USAGE_OBJECT // Invalid usee of object +#define ERRCODE_BASIC_NO_OLE ERRCODE_SBX_NO_OLE // Class does not support OLE +#define ERRCODE_BASIC_BAD_METHOD ERRCODE_SBX_BAD_METHOD // Object doesn't support method +#define ERRCODE_BASIC_OLE_ERROR ERRCODE_SBX_OLE_ERROR // OLE Automation error +#define ERRCODE_BASIC_BAD_ACTION ERRCODE_SBX_BAD_ACTION // Object doesn't support this action +#define ERRCODE_BASIC_NO_NAMED_ARGS ERRCODE_SBX_NO_NAMED_ARGS // Object doesn't support named args +#define ERRCODE_BASIC_BAD_LOCALE ERRCODE_SBX_BAD_LOCALE // Object doesn't support current locale setting +#define ERRCODE_BASIC_NAMED_NOT_FOUND ERRCODE_SBX_NAMED_NOT_FOUND // Named argument not found +#define ERRCODE_BASIC_NOT_OPTIONAL ERRCODE_SBX_NOT_OPTIONAL // Argument not optional +#define ERRCODE_BASIC_WRONG_ARGS ERRCODE_SBX_WRONG_ARGS // Wrong number of arguments +#define ERRCODE_BASIC_NOT_A_COLL ERRCODE_SBX_NOT_A_COLL // Object not a collection + +// Append Basic specific error messages to ERRCODE_AREA_SBX +#define ERRCODE_BASIC_NO_GOSUB ((LAST_SBX_ERROR_ID+1UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Return without Gosub +#define ERRCODE_BASIC_REDO_FROM_START ((LAST_SBX_ERROR_ID+2UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Redo form start (SB internal) +#define ERRCODE_BASIC_NO_MEMORY ((LAST_SBX_ERROR_ID+3UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Out of memory +#define ERRCODE_BASIC_ALREADY_DIM ((LAST_SBX_ERROR_ID+4UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Array already dimensioned +#define ERRCODE_BASIC_DUPLICATE_DEF ((LAST_SBX_ERROR_ID+5UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Duplicate definition +#define ERRCODE_BASIC_VAR_UNDEFINED ((LAST_SBX_ERROR_ID+6UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Variable undefined (SB) +#define ERRCODE_BASIC_USER_ABORT ((LAST_SBX_ERROR_ID+7UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // User interrupt occurred +#define ERRCODE_BASIC_BAD_RESUME ((LAST_SBX_ERROR_ID+8UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Resume without error +#define ERRCODE_BASIC_STACK_OVERFLOW ((LAST_SBX_ERROR_ID+9UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Out of stack space +#define ERRCODE_BASIC_BAD_DLL_LOAD ((LAST_SBX_ERROR_ID+10UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Error in loading DLL +#define ERRCODE_BASIC_BAD_DLL_CALL ((LAST_SBX_ERROR_ID+11UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Bad DLL calling convention +#define ERRCODE_BASIC_BAD_CHANNEL ((LAST_SBX_ERROR_ID+12UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Bad file name or number +#define ERRCODE_BASIC_FILE_NOT_FOUND ((LAST_SBX_ERROR_ID+13UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // File not found +#define ERRCODE_BASIC_BAD_FILE_MODE ((LAST_SBX_ERROR_ID+14UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Bad file mode +#define ERRCODE_BASIC_FILE_ALREADY_OPEN ((LAST_SBX_ERROR_ID+15UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // File already open +#define ERRCODE_BASIC_IO_ERROR ((LAST_SBX_ERROR_ID+16UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Device I/O error +#define ERRCODE_BASIC_FILE_EXISTS ((LAST_SBX_ERROR_ID+17UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // File already exists +#define ERRCODE_BASIC_BAD_RECORD_LENGTH ((LAST_SBX_ERROR_ID+18UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // bad record length +#define ERRCODE_BASIC_DISK_FULL ((LAST_SBX_ERROR_ID+19UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // disk full +#define ERRCODE_BASIC_READ_PAST_EOF ((LAST_SBX_ERROR_ID+20UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Input past end of file +#define ERRCODE_BASIC_BAD_RECORD_NUMBER ((LAST_SBX_ERROR_ID+21UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Bad record number +#define ERRCODE_BASIC_TOO_MANY_FILES ((LAST_SBX_ERROR_ID+22UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Too many files +#define ERRCODE_BASIC_NO_DEVICE ((LAST_SBX_ERROR_ID+23UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Device not available +#define ERRCODE_BASIC_ACCESS_DENIED ((LAST_SBX_ERROR_ID+24UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Permission denied +#define ERRCODE_BASIC_NOT_READY ((LAST_SBX_ERROR_ID+25UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Disk not ready +#define ERRCODE_BASIC_NOT_IMPLEMENTED ((LAST_SBX_ERROR_ID+26UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Feature not implemented +#define ERRCODE_BASIC_DIFFERENT_DRIVE ((LAST_SBX_ERROR_ID+27UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // No rename with different drive +#define ERRCODE_BASIC_ACCESS_ERROR ((LAST_SBX_ERROR_ID+28UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Path/File access error +#define ERRCODE_BASIC_PATH_NOT_FOUND ((LAST_SBX_ERROR_ID+29UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Path not found +#define ERRCODE_BASIC_BAD_PATTERN ((LAST_SBX_ERROR_ID+30UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Invalid pattern string +#define ERRCODE_BASIC_IS_NULL ((LAST_SBX_ERROR_ID+31UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Invalid use of Null + +// DDE messages from 250-299 +#define ERRCODE_BASIC_DDE_ERROR ((LAST_SBX_ERROR_ID+32UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) +#define ERRCODE_BASIC_DDE_WAITINGACK ((LAST_SBX_ERROR_ID+33UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) +#define ERRCODE_BASIC_DDE_OUTOFCHANNELS ((LAST_SBX_ERROR_ID+34UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) +#define ERRCODE_BASIC_DDE_NO_RESPONSE ((LAST_SBX_ERROR_ID+35UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) +#define ERRCODE_BASIC_DDE_MULT_RESPONSES ((LAST_SBX_ERROR_ID+36UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) +#define ERRCODE_BASIC_DDE_CHANNEL_LOCKED ((LAST_SBX_ERROR_ID+37UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) +#define ERRCODE_BASIC_DDE_NOTPROCESSED ((LAST_SBX_ERROR_ID+38UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) +#define ERRCODE_BASIC_DDE_TIMEOUT ((LAST_SBX_ERROR_ID+39UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) +#define ERRCODE_BASIC_DDE_USER_INTERRUPT ((LAST_SBX_ERROR_ID+40UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) +#define ERRCODE_BASIC_DDE_BUSY ((LAST_SBX_ERROR_ID+41UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) +#define ERRCODE_BASIC_DDE_NO_DATA ((LAST_SBX_ERROR_ID+42UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) +#define ERRCODE_BASIC_DDE_WRONG_DATA_FORMAT ((LAST_SBX_ERROR_ID+43UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) +#define ERRCODE_BASIC_DDE_PARTNER_QUIT ((LAST_SBX_ERROR_ID+44UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) +#define ERRCODE_BASIC_DDE_CONV_CLOSED ((LAST_SBX_ERROR_ID+45UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) +#define ERRCODE_BASIC_DDE_NO_CHANNEL ((LAST_SBX_ERROR_ID+46UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) +#define ERRCODE_BASIC_DDE_INVALID_LINK ((LAST_SBX_ERROR_ID+47UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) +#define ERRCODE_BASIC_DDE_QUEUE_OVERFLOW ((LAST_SBX_ERROR_ID+48UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) +#define ERRCODE_BASIC_DDE_LINK_ALREADY_EST ((LAST_SBX_ERROR_ID+49UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) +#define ERRCODE_BASIC_DDE_LINK_INV_TOPIC ((LAST_SBX_ERROR_ID+50UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) +#define ERRCODE_BASIC_DDE_DLL_NOT_FOUND ((LAST_SBX_ERROR_ID+51UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) + +#define ERRCODE_BASIC_NEEDS_OBJECT ((LAST_SBX_ERROR_ID+52UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Object required +#define ERRCODE_BASIC_BAD_ORDINAL ((LAST_SBX_ERROR_ID+53UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Invalid ordinal +#define ERRCODE_BASIC_DLLPROC_NOT_FOUND ((LAST_SBX_ERROR_ID+54UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Specified DLL function not found +#define ERRCODE_BASIC_BAD_CLIPBD_FORMAT ((LAST_SBX_ERROR_ID+55UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Invalid clipboard format + +// Debugger messages from 700-799 + +#define ERRCODE_BASIC_PROPERTY_NOT_FOUND ((LAST_SBX_ERROR_ID+56UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Class not have property +#define ERRCODE_BASIC_METHOD_NOT_FOUND ((LAST_SBX_ERROR_ID+57UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Class does not have method +#define ERRCODE_BASIC_ARG_MISSING ((LAST_SBX_ERROR_ID+58UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Missing required argument +#define ERRCODE_BASIC_BAD_NUMBER_OF_ARGS ((LAST_SBX_ERROR_ID+59UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Bad number of arguments +#define ERRCODE_BASIC_METHOD_FAILED ((LAST_SBX_ERROR_ID+60UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Method failed +#define ERRCODE_BASIC_SETPROP_FAILED ((LAST_SBX_ERROR_ID+61UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Unable to set property +#define ERRCODE_BASIC_GETPROP_FAILED ((LAST_SBX_ERROR_ID+62UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) // Unable to get property + +// Compiler Errors (do not occure at runtime) +// These IDs can shift at any time + +#define ERRCODE_BASIC_UNEXPECTED ((LAST_SBX_ERROR_ID+63UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Unexpected symbol: xx +#define ERRCODE_BASIC_EXPECTED ((LAST_SBX_ERROR_ID+64UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Expected: xx +#define ERRCODE_BASIC_SYMBOL_EXPECTED ((LAST_SBX_ERROR_ID+65UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Symbol expected +#define ERRCODE_BASIC_VAR_EXPECTED ((LAST_SBX_ERROR_ID+66UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Variable expected +#define ERRCODE_BASIC_LABEL_EXPECTED ((LAST_SBX_ERROR_ID+67UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Label expected +#define ERRCODE_BASIC_LVALUE_EXPECTED ((LAST_SBX_ERROR_ID+68UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Lvalue expected +#define ERRCODE_BASIC_VAR_DEFINED ((LAST_SBX_ERROR_ID+69UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Variable xxx already defined +#define ERRCODE_BASIC_PROC_DEFINED ((LAST_SBX_ERROR_ID+70UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Procedure xx already defined +#define ERRCODE_BASIC_LABEL_DEFINED ((LAST_SBX_ERROR_ID+71UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Label xxx already defined +#define ERRCODE_BASIC_UNDEF_VAR ((LAST_SBX_ERROR_ID+72UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Variable xx undefined +#define ERRCODE_BASIC_UNDEF_ARRAY ((LAST_SBX_ERROR_ID+73UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Array or function xx undefined +#define ERRCODE_BASIC_UNDEF_PROC ((LAST_SBX_ERROR_ID+74UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Procedure xxx undefined +#define ERRCODE_BASIC_UNDEF_LABEL ((LAST_SBX_ERROR_ID+75UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Label xxx undefined +#define ERRCODE_BASIC_UNDEF_TYPE ((LAST_SBX_ERROR_ID+76UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Unknown user defined type xxx +#define ERRCODE_BASIC_BAD_EXIT ((LAST_SBX_ERROR_ID+77UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Exit XXX expected +#define ERRCODE_BASIC_BAD_BLOCK ((LAST_SBX_ERROR_ID+78UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Unterminated statement block: missing XX +#define ERRCODE_BASIC_BAD_BRACKETS ((LAST_SBX_ERROR_ID+79UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Parentheses do not match +#define ERRCODE_BASIC_BAD_DECLARATION ((LAST_SBX_ERROR_ID+80UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Symbol xx defined differently +#define ERRCODE_BASIC_BAD_PARAMETERS ((LAST_SBX_ERROR_ID+81UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Parameters do not match +#define ERRCODE_BASIC_BAD_CHAR_IN_NUMBER ((LAST_SBX_ERROR_ID+82UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Bad character in number +#define ERRCODE_BASIC_MUST_HAVE_DIMS ((LAST_SBX_ERROR_ID+83UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Array needs dimensioning +#define ERRCODE_BASIC_NO_IF ((LAST_SBX_ERROR_ID+84UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Else/Endif without If +#define ERRCODE_BASIC_NOT_IN_SUBR ((LAST_SBX_ERROR_ID+85UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // xxx not allowed within a sub +#define ERRCODE_BASIC_NOT_IN_MAIN ((LAST_SBX_ERROR_ID+86UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // xxx not allowed outside a sub +#define ERRCODE_BASIC_WRONG_DIMS ((LAST_SBX_ERROR_ID+87UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Dimensions do not match +#define ERRCODE_BASIC_BAD_OPTION ((LAST_SBX_ERROR_ID+88UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Unknown option: xxx +#define ERRCODE_BASIC_CONSTANT_REDECLARED ((LAST_SBX_ERROR_ID+89UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Constant xx redeclared +#define ERRCODE_BASIC_PROG_TOO_LARGE ((LAST_SBX_ERROR_ID+90UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Program is too large +#define ERRCODE_BASIC_NO_STRINGS_ARRAYS ((LAST_SBX_ERROR_ID+91UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) + +#define ERRCODE_BASIC_EXCEPTION ((LAST_SBX_ERROR_ID+92UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_RUNTIME) + +#define ERRCODE_BASMGR_STDLIBOPEN (LAST_SBX_ERROR_ID+93UL) | ERRCODE_AREA_SBX +#define ERRCODE_BASMGR_STDLIBSAVE (LAST_SBX_ERROR_ID+94UL) | ERRCODE_AREA_SBX +#define ERRCODE_BASMGR_LIBLOAD (LAST_SBX_ERROR_ID+95UL) | ERRCODE_AREA_SBX +#define ERRCODE_BASMGR_LIBCREATE (LAST_SBX_ERROR_ID+96UL) | ERRCODE_AREA_SBX +#define ERRCODE_BASMGR_LIBSAVE (LAST_SBX_ERROR_ID+97UL) | ERRCODE_AREA_SBX +#define ERRCODE_BASMGR_LIBDEL (LAST_SBX_ERROR_ID+98UL) | ERRCODE_AREA_SBX +#define ERRCODE_BASMGR_MGROPEN (LAST_SBX_ERROR_ID+99UL) | ERRCODE_AREA_SBX +#define ERRCODE_BASMGR_MGRSAVE (LAST_SBX_ERROR_ID+100UL) | ERRCODE_AREA_SBX +#define ERRCODE_BASMGR_REMOVELIB (LAST_SBX_ERROR_ID+101UL) | ERRCODE_AREA_SBX +#define ERRCODE_BASMGR_UNLOADLIB (LAST_SBX_ERROR_ID+102UL) | ERRCODE_AREA_SBX + +#define ERRCODE_BASIC_ARRAY_FIX ((LAST_SBX_ERROR_ID+104UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // This array is fixed +#define ERRCODE_BASIC_STRING_OVERFLOW ((LAST_SBX_ERROR_ID+105UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Out of string space +#define ERRCODE_BASIC_EXPR_TOO_COMPLEX ((LAST_SBX_ERROR_ID+106UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Expression too complex +#define ERRCODE_BASIC_OPER_NOT_PERFORM ((LAST_SBX_ERROR_ID+107UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Can't perform requested operation +#define ERRCODE_BASIC_TOO_MANY_DLL ((LAST_SBX_ERROR_ID+108UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // Too many dll application clients +#define ERRCODE_BASIC_LOOP_NOT_INIT ((LAST_SBX_ERROR_ID+109UL) | ERRCODE_AREA_SBX | \ + ERRCODE_CLASS_COMPILER) // For loop not initialized + +#define ERRCODE_BASIC_COMPAT ((LAST_SBX_ERROR_ID+103UL)| ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) + +// Map old codes to new codes +#define SbERR_SYNTAX ERRCODE_BASIC_SYNTAX +#define SbERR_NO_GOSUB ERRCODE_BASIC_NO_GOSUB +#define SbERR_REDO_FROM_START ERRCODE_BASIC_REDO_FROM_START +#define SbERR_BAD_ARGUMENT ERRCODE_BASIC_BAD_ARGUMENT +#define SbERR_MATH_OVERFLOW ERRCODE_BASIC_MATH_OVERFLOW +#define SbERR_NO_MEMORY ERRCODE_BASIC_NO_MEMORY +#define SbERR_ALREADY_DIM ERRCODE_BASIC_ALREADY_DIM +#define SbERR_OUT_OF_RANGE ERRCODE_BASIC_OUT_OF_RANGE +#define SbERR_DUPLICATE_DEF ERRCODE_BASIC_DUPLICATE_DEF +#define SbERR_ZERODIV ERRCODE_BASIC_ZERODIV +#define SbERR_VAR_UNDEFINED ERRCODE_BASIC_VAR_UNDEFINED +#define SbERR_CONVERSION ERRCODE_BASIC_CONVERSION +#define SbERR_BAD_PARAMETER ERRCODE_BASIC_BAD_PARAMETER +#define SbERR_USER_ABORT ERRCODE_BASIC_USER_ABORT +#define SbERR_BAD_RESUME ERRCODE_BASIC_BAD_RESUME +#define SbERR_STACK_OVERFLOW ERRCODE_BASIC_STACK_OVERFLOW +#define SbERR_PROC_UNDEFINED ERRCODE_BASIC_PROC_UNDEFINED +#define SbERR_BAD_DLL_LOAD ERRCODE_BASIC_BAD_DLL_LOAD +#define SbERR_BAD_DLL_CALL ERRCODE_BASIC_BAD_DLL_CALL +#define SbERR_INTERNAL_ERROR ERRCODE_BASIC_INTERNAL_ERROR +#define SbERR_BAD_CHANNEL ERRCODE_BASIC_BAD_CHANNEL +#define SbERR_FILE_NOT_FOUND ERRCODE_BASIC_FILE_NOT_FOUND +#define SbERR_BAD_FILE_MODE ERRCODE_BASIC_BAD_FILE_MODE +#define SbERR_FILE_ALREADY_OPEN ERRCODE_BASIC_FILE_ALREADY_OPEN +#define SbERR_IO_ERROR ERRCODE_BASIC_IO_ERROR +#define SbERR_FILE_EXISTS ERRCODE_BASIC_FILE_EXISTS +#define SbERR_BAD_RECORD_LENGTH ERRCODE_BASIC_BAD_RECORD_LENGTH +#define SbERR_DISK_FULL ERRCODE_BASIC_DISK_FULL +#define SbERR_READ_PAST_EOF ERRCODE_BASIC_READ_PAST_EOF +#define SbERR_BAD_RECORD_NUMBER ERRCODE_BASIC_BAD_RECORD_NUMBER +#define SbERR_TOO_MANY_FILES ERRCODE_BASIC_TOO_MANY_FILES +#define SbERR_NO_DEVICE ERRCODE_BASIC_NO_DEVICE +#define SbERR_ACCESS_DENIED ERRCODE_BASIC_ACCESS_DENIED +#define SbERR_NOT_READY ERRCODE_BASIC_NOT_READY +#define SbERR_NOT_IMPLEMENTED ERRCODE_BASIC_NOT_IMPLEMENTED +#define SbERR_DIFFERENT_DRIVE ERRCODE_BASIC_DIFFERENT_DRIVE +#define SbERR_ACCESS_ERROR ERRCODE_BASIC_ACCESS_ERROR +#define SbERR_PATH_NOT_FOUND ERRCODE_BASIC_PATH_NOT_FOUND +#define SbERR_NO_OBJECT ERRCODE_BASIC_NO_OBJECT +#define SbERR_BAD_PATTERN ERRCODE_BASIC_BAD_PATTERN +#define SBERR_IS_NULL ERRCODE_BASIC_IS_NULL +#define SbERR_DDE_ERROR ERRCODE_BASIC_DDE_ERROR +#define SbERR_DDE_WAITINGACK ERRCODE_BASIC_DDE_WAITINGACK +#define SbERR_DDE_OUTOFCHANNELS ERRCODE_BASIC_DDE_OUTOFCHANNELS +#define SbERR_DDE_NO_RESPONSE ERRCODE_BASIC_DDE_NO_RESPONSE +#define SbERR_DDE_MULT_RESPONSES ERRCODE_BASIC_DDE_MULT_RESPONSES +#define SbERR_DDE_CHANNEL_LOCKED ERRCODE_BASIC_DDE_CHANNEL_LOCKED +#define SbERR_DDE_NOTPROCESSED ERRCODE_BASIC_DDE_NOTPROCESSED +#define SbERR_DDE_TIMEOUT ERRCODE_BASIC_DDE_TIMEOUT +#define SbERR_DDE_USER_INTERRUPT ERRCODE_BASIC_DDE_USER_INTERRUPT +#define SbERR_DDE_BUSY ERRCODE_BASIC_DDE_BUSY +#define SbERR_DDE_NO_DATA ERRCODE_BASIC_DDE_NO_DATA +#define SbERR_DDE_WRONG_DATA_FORMAT ERRCODE_BASIC_DDE_WRONG_DATA_FORMAT +#define SbERR_DDE_PARTNER_QUIT ERRCODE_BASIC_DDE_PARTNER_QUIT +#define SbERR_DDE_CONV_CLOSED ERRCODE_BASIC_DDE_CONV_CLOSED +#define SbERR_DDE_NO_CHANNEL ERRCODE_BASIC_DDE_NO_CHANNEL +#define SbERR_DDE_INVALID_LINK ERRCODE_BASIC_DDE_INVALID_LINK +#define SbERR_DDE_QUEUE_OVERFLOW ERRCODE_BASIC_DDE_QUEUE_OVERFLOW +#define SbERR_DDE_LINK_ALREADY_EST ERRCODE_BASIC_DDE_LINK_ALREADY_EST +#define SbERR_DDE_LINK_INV_TOPIC ERRCODE_BASIC_DDE_LINK_INV_TOPIC +#define SbERR_DDE_DLL_NOT_FOUND ERRCODE_BASIC_DDE_DLL_NOT_FOUND +#define SbERR_CANNOT_LOAD ERRCODE_BASIC_CANNOT_LOAD +#define SbERR_BAD_INDEX ERRCODE_BASIC_BAD_INDEX +#define SbERR_NO_ACTIVE_OBJECT ERRCODE_BASIC_NO_ACTIVE_OBJECT +#define SbERR_BAD_PROP_VALUE ERRCODE_BASIC_BAD_PROP_VALUE +#define SbERR_PROP_READONLY ERRCODE_BASIC_PROP_READONLY +#define SbERR_PROP_WRITEONLY ERRCODE_BASIC_PROP_WRITEONLY +#define SbERR_INVALID_OBJECT ERRCODE_BASIC_INVALID_OBJECT +#define SbERR_NO_METHOD ERRCODE_BASIC_NO_METHOD +#define SbERR_NEEDS_OBJECT ERRCODE_BASIC_NEEDS_OBJECT +#define SbERR_INVALID_USAGE_OBJECT ERRCODE_BASIC_INVALID_USAGE_OBJECT +#define SbERR_NO_OLE ERRCODE_BASIC_NO_OLE +#define SbERR_BAD_METHOD ERRCODE_BASIC_BAD_METHOD +#define SbERR_OLE_ERROR ERRCODE_BASIC_OLE_ERROR +#define SbERR_BAD_ACTION ERRCODE_BASIC_BAD_ACTION +#define SbERR_NO_NAMED_ARGS ERRCODE_BASIC_NO_NAMED_ARGS +#define SbERR_BAD_LOCALE ERRCODE_BASIC_BAD_LOCALE +#define SbERR_NAMED_NOT_FOUND ERRCODE_BASIC_NAMED_NOT_FOUND +#define SbERR_NOT_OPTIONAL ERRCODE_BASIC_NOT_OPTIONAL +#define SbERR_WRONG_ARGS ERRCODE_BASIC_WRONG_ARGS +#define SbERR_NOT_A_COLL ERRCODE_BASIC_NOT_A_COLL +#define SbERR_BAD_ORDINAL ERRCODE_BASIC_BAD_ORDINAL +#define SbERR_DLLPROC_NOT_FOUND ERRCODE_BASIC_DLLPROC_NOT_FOUND +#define SbERR_BAD_CLIPBD_FORMAT ERRCODE_BASIC_BAD_CLIPBD_FORMAT +#define SbERR_PROPERTY_NOT_FOUND ERRCODE_BASIC_PROPERTY_NOT_FOUND +#define SbERR_METHOD_NOT_FOUND ERRCODE_BASIC_METHOD_NOT_FOUND +#define SbERR_ARG_MISSING ERRCODE_BASIC_ARG_MISSING +#define SbERR_BAD_NUMBER_OF_ARGS ERRCODE_BASIC_BAD_NUMBER_OF_ARGS +#define SbERR_METHOD_FAILED ERRCODE_BASIC_METHOD_FAILED +#define SbERR_SETPROP_FAILED ERRCODE_BASIC_SETPROP_FAILED +#define SbERR_GETPROP_FAILED ERRCODE_BASIC_GETPROP_FAILED +#define SbERR_UNEXPECTED ERRCODE_BASIC_UNEXPECTED +#define SbERR_EXPECTED ERRCODE_BASIC_EXPECTED +#define SbERR_SYMBOL_EXPECTED ERRCODE_BASIC_SYMBOL_EXPECTED +#define SbERR_VAR_EXPECTED ERRCODE_BASIC_VAR_EXPECTED +#define SbERR_LABEL_EXPECTED ERRCODE_BASIC_LABEL_EXPECTED +#define SbERR_LVALUE_EXPECTED ERRCODE_BASIC_LVALUE_EXPECTED +#define SbERR_VAR_DEFINED ERRCODE_BASIC_VAR_DEFINED +#define SbERR_PROC_DEFINED ERRCODE_BASIC_PROC_DEFINED +#define SbERR_LABEL_DEFINED ERRCODE_BASIC_LABEL_DEFINED +#define SbERR_UNDEF_VAR ERRCODE_BASIC_UNDEF_VAR +#define SbERR_UNDEF_ARRAY ERRCODE_BASIC_UNDEF_ARRAY +#define SbERR_UNDEF_PROC ERRCODE_BASIC_UNDEF_PROC +#define SbERR_UNDEF_LABEL ERRCODE_BASIC_UNDEF_LABEL +#define SbERR_UNDEF_TYPE ERRCODE_BASIC_UNDEF_TYPE +#define SbERR_BAD_EXIT ERRCODE_BASIC_BAD_EXIT +#define SbERR_BAD_BLOCK ERRCODE_BASIC_BAD_BLOCK +#define SbERR_BAD_BRACKETS ERRCODE_BASIC_BAD_BRACKETS +#define SbERR_BAD_DECLARATION ERRCODE_BASIC_BAD_DECLARATION +#define SbERR_BAD_PARAMETERS ERRCODE_BASIC_BAD_PARAMETERS +#define SbERR_BAD_CHAR_IN_NUMBER ERRCODE_BASIC_BAD_CHAR_IN_NUMBER +#define SbERR_MUST_HAVE_DIMS ERRCODE_BASIC_MUST_HAVE_DIMS +#define SbERR_NO_IF ERRCODE_BASIC_NO_IF +#define SbERR_NOT_IN_SUBR ERRCODE_BASIC_NOT_IN_SUBR +#define SbERR_NOT_IN_MAIN ERRCODE_BASIC_NOT_IN_MAIN +#define SbERR_WRONG_DIMS ERRCODE_BASIC_WRONG_DIMS +#define SbERR_BAD_OPTION ERRCODE_BASIC_BAD_OPTION +#define SbERR_CONSTANT_REDECLARED ERRCODE_BASIC_CONSTANT_REDECLARED +#define SbERR_PROG_TOO_LARGE ERRCODE_BASIC_PROG_TOO_LARGE +#define SbERR_NO_STRINGS_ARRAYS ERRCODE_BASIC_NO_STRINGS_ARRAYS +#define SbERR_BASIC_EXCEPTION ERRCODE_BASIC_EXCEPTION +#define SbERR_BASIC_COMPAT ERRCODE_BASIC_COMPAT +#define SbERR_BASIC_ARRAY_FIX ERRCODE_BASIC_ARRAY_FIX +#define SbERR_BASIC_STRING_OVERFLOW ERRCODE_BASIC_STRING_OVERFLOW +#define SbERR_BASIC_EXPR_TOO_COMPLEX ERRCODE_BASIC_EXPR_TOO_COMPLEX +#define SbERR_BASIC_OPER_NOT_PERFORM ERRCODE_BASIC_OPER_NOT_PERFORM +#define SbERR_BASIC_TOO_MANY_DLL ERRCODE_BASIC_TOO_MANY_DLL +#define SbERR_BASIC_LOOP_NOT_INIT ERRCODE_BASIC_LOOP_NOT_INIT + +// Grid messages from 30000-30999 +// OLE messages from 31000-31999 + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/sbmeth.hxx b/include/basic/sbmeth.hxx new file mode 100644 index 000000000000..9d4afbc37a24 --- /dev/null +++ b/include/basic/sbmeth.hxx @@ -0,0 +1,91 @@ +/* -*- 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 _SB_SBMETH_HXX +#define _SB_SBMETH_HXX + +#include <tools/errcode.hxx> +#include <basic/sbxmeth.hxx> +#include <basic/sbdef.hxx> +#include "basicdllapi.h" + +class SbModule; + +class BASIC_DLLPUBLIC SbMethod : public SbxMethod +{ + friend class SbiRuntime; + friend class SbiFactory; + friend class SbModule; + friend class SbClassModuleObject; + friend class SbiCodeGen; + friend class SbJScriptMethod; + friend class SbIfaceMapperMethod; + + SbxVariable* mCaller; // caller + SbModule* pMod; + sal_uInt16 nDebugFlags; + sal_uInt16 nLine1, nLine2; + sal_uInt32 nStart; + sal_Bool bInvalid; + SbxArrayRef refStatics; + BASIC_DLLPRIVATE SbMethod( const OUString&, SbxDataType, SbModule* ); + BASIC_DLLPRIVATE SbMethod( const SbMethod& ); + virtual sal_Bool LoadData( SvStream&, sal_uInt16 ); + virtual sal_Bool StoreData( SvStream& ) const; + virtual ~SbMethod(); + +public: + SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_BASICMETHOD,2); + TYPEINFO(); + virtual SbxInfo* GetInfo(); + SbxArray* GetStatics(); + void ClearStatics(); + SbModule* GetModule() { return pMod; } + sal_uInt32 GetId() const { return nStart; } + sal_uInt16 GetDebugFlags() { return nDebugFlags; } + void SetDebugFlags( sal_uInt16 n ) { nDebugFlags = n; } + void GetLineRange( sal_uInt16&, sal_uInt16& ); + + // Interface to execute a method from the applications + virtual ErrCode Call( SbxValue* pRet = NULL, SbxVariable* pCaller = NULL ); + virtual void Broadcast( sal_uIntPtr nHintId ); +}; + +SV_DECL_IMPL_REF(SbMethod) + +class BASIC_DLLPUBLIC SbIfaceMapperMethod : public SbMethod +{ + friend class SbiRuntime; + + SbMethodRef mxImplMeth; + +public: + TYPEINFO(); + SbIfaceMapperMethod( const OUString& rName, SbMethod* pImplMeth ) + : SbMethod( rName, pImplMeth->GetType(), NULL ) + , mxImplMeth( pImplMeth ) + {} + virtual ~SbIfaceMapperMethod(); + SbMethod* getImplMethod( void ) + { return mxImplMeth; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/sbmod.hxx b/include/basic/sbmod.hxx new file mode 100644 index 000000000000..f94e2c9e8a36 --- /dev/null +++ b/include/basic/sbmod.hxx @@ -0,0 +1,164 @@ +/* -*- 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 _SB_SBMOD_HXX +#define _SB_SBMOD_HXX + +#include <com/sun/star/script/XInvocation.hpp> +#include <basic/sbdef.hxx> +#include <basic/sbxobj.hxx> +#include <basic/sbxdef.hxx> +#include <rtl/ustring.hxx> +#include <vector> +#include <deque> +#include <boost/utility.hpp> +#include "basicdllapi.h" + +class SbMethod; +class SbProperty; +class SbiRuntime; +typedef std::deque< sal_uInt16 > SbiBreakpoints; +class SbiImage; +class SbProcedureProperty; +class SbIfaceMapperMethod; +class SbClassModuleObject; + +class ModuleInitDependencyMap; +struct ClassModuleRunInitItem; +struct SbClassData; + +class BASIC_DLLPUBLIC SbModule : public SbxObject, private ::boost::noncopyable +{ + friend class SbiCodeGen; + friend class SbMethod; + friend class SbiRuntime; + friend class StarBASIC; + friend class SbClassModuleObject; + + std::vector< OUString > mModuleVariableNames; + + BASIC_DLLPRIVATE void implClearIfVarDependsOnDeletedBasic( SbxVariable* pVar, StarBASIC* pDeletedBasic ); + +protected: + com::sun::star::uno::Reference< com::sun::star::script::XInvocation > mxWrapper; + OUString aOUSource; + OUString aComment; + SbiImage* pImage; // the Image + SbiBreakpoints* pBreaks; // Breakpoints + SbClassData* pClassData; + bool mbVBACompat; + sal_Int32 mnType; + SbxObjectRef pDocObject; // an impl object ( used by Document Modules ) + bool bIsProxyModule; + + static void implProcessModuleRunInit( ModuleInitDependencyMap& rMap, ClassModuleRunInitItem& rItem ); + void StartDefinitions(); + SbMethod* GetMethod( const OUString&, SbxDataType ); + SbProperty* GetProperty( const OUString&, SbxDataType ); + SbProcedureProperty* GetProcedureProperty( const OUString&, SbxDataType ); + SbIfaceMapperMethod* GetIfaceMapperMethod( const OUString&, SbMethod* ); + void EndDefinitions( sal_Bool=sal_False ); + sal_uInt16 Run( SbMethod* ); + void RunInit(); + void ClearPrivateVars(); + void ClearVarsDependingOnDeletedBasic( StarBASIC* pDeletedBasic ); + void GlobalRunInit( bool bBasicStart ); // for all modules + void GlobalRunDeInit( void ); + const sal_uInt8* FindNextStmnt( const sal_uInt8*, sal_uInt16&, sal_uInt16& ) const; + const sal_uInt8* FindNextStmnt( const sal_uInt8*, sal_uInt16&, sal_uInt16&, + sal_Bool bFollowJumps, const SbiImage* pImg=NULL ) const; + virtual sal_Bool LoadData( SvStream&, sal_uInt16 ); + virtual sal_Bool StoreData( SvStream& ) const; + virtual sal_Bool LoadCompleted(); + virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, + const SfxHint& rHint, const TypeId& rHintType ); + void handleProcedureProperties( SfxBroadcaster& rBC, const SfxHint& rHint ); + virtual ~SbModule(); +public: + SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_BASICMOD,2); + TYPEINFO(); + SbModule( const OUString&, sal_Bool bCompat = sal_False ); + virtual void SetParent( SbxObject* ); + virtual void Clear(); + + virtual SbxVariable* Find( const OUString&, SbxClassType ); + + virtual const OUString& GetSource() const; + const OUString& GetSource32() const; + const OUString& GetComment() const { return aComment; } + virtual void SetSource( const OUString& r ); + void SetSource32( const OUString& r ); + + virtual sal_Bool Compile(); + virtual sal_Bool IsCompiled() const; + const SbxObject* FindType( OUString aTypeName ) const; + + virtual sal_Bool IsBreakable( sal_uInt16 nLine ) const; + virtual sal_Bool IsBP( sal_uInt16 nLine ) const; + virtual sal_Bool SetBP( sal_uInt16 nLine ); + virtual sal_Bool ClearBP( sal_uInt16 nLine ); + virtual void ClearAllBP(); + + // Store only image, no source (needed for new password protection) + sal_Bool StoreBinaryData( SvStream& ); + sal_Bool StoreBinaryData( SvStream&, sal_uInt16 nVer ); + sal_Bool LoadBinaryData( SvStream&, sal_uInt16 nVer ); + sal_Bool LoadBinaryData( SvStream& ); + sal_Bool ExceedsLegacyModuleSize(); + void fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg = NULL ) const; + bool HasExeCode(); + bool IsVBACompat() const; + void SetVBACompat( bool bCompat ); + sal_Int32 GetModuleType() { return mnType; } + void SetModuleType( sal_Int32 nType ) { mnType = nType; } + bool isProxyModule() { return bIsProxyModule; } + void AddVarName( const OUString& aName ); + void RemoveVars(); + ::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > GetUnoModule(); + bool createCOMWrapperForIface( ::com::sun::star::uno::Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject ); +}; + +SV_DECL_IMPL_REF(SbModule) + +// Object class for instances of class modules +class BASIC_DLLPUBLIC SbClassModuleObject : public SbModule +{ + SbModule* mpClassModule; + bool mbInitializeEventDone; + +public: + TYPEINFO(); + SbClassModuleObject( SbModule* pClassModule ); + ~SbClassModuleObject(); + + // Overridden to support NameAccess etc. + virtual SbxVariable* Find( const OUString&, SbxClassType ); + + virtual void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& ); + + SbModule* getClassModule( void ) + { return mpClassModule; } + + void triggerInitializeEvent( void ); + void triggerTerminateEvent( void ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/sbobjmod.hxx b/include/basic/sbobjmod.hxx new file mode 100644 index 000000000000..14ca48681688 --- /dev/null +++ b/include/basic/sbobjmod.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 _SB_OBJMOD_HXX +#define _SB_OBJMOD_HXX + +#include <rtl/ref.hxx> +#include <basic/sbmod.hxx> +#include <basic/sbstar.hxx> +#include <com/sun/star/script/ModuleInfo.hpp> +#include <com/sun/star/lang/XEventListener.hpp> +#include <com/sun/star/awt/XDialog.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include "basicdllapi.h" + +// Basic-Module for excel object. + +class BASIC_DLLPUBLIC SbObjModule : public SbModule +{ +protected: + virtual ~SbObjModule(); + +public: + TYPEINFO(); + SbObjModule( const OUString& rName, const com::sun::star::script::ModuleInfo& mInfo, bool bIsVbaCompatible ); + virtual SbxVariable* Find( const OUString& rName, SbxClassType t ); + + virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, + const SfxHint& rHint, const TypeId& rHintType ); + + using SbxValue::GetObject; + SbxVariable* GetObject(); + void SetUnoObject( const com::sun::star::uno::Any& aObj )throw ( com::sun::star::uno::RuntimeException ) ; +}; + +class FormObjEventListenerImpl; + +class BASIC_DLLPUBLIC SbUserFormModule : public SbObjModule +{ + com::sun::star::script::ModuleInfo m_mInfo; + ::rtl::Reference< FormObjEventListenerImpl > m_DialogListener; + css::uno::Reference<css::awt::XDialog> m_xDialog; + css::uno::Reference<css::frame::XModel> m_xModel; + OUString sFormName; + bool mbInit; + +//protected: + virtual void InitObject(); +public: + TYPEINFO(); + SbUserFormModule( const OUString& rName, const com::sun::star::script::ModuleInfo& mInfo, bool bIsVBACompat ); + virtual ~SbUserFormModule(); + virtual SbxVariable* Find( const OUString& rName, SbxClassType t ); + void ResetApiObj( bool bTriggerTerminateEvent = true ); + void Unload(); + void Load(); + void triggerMethod( const OUString& ); + void triggerMethod( const OUString&, css::uno::Sequence< css::uno::Any >& ); + void triggerActivateEvent(); + void triggerDeactivateEvent(); + void triggerInitializeEvent(); + void triggerTerminateEvent(); + void triggerLayoutEvent(); + void triggerResizeEvent(); + + bool getInitState( void ) + { return mbInit; } + void setInitState( bool bInit ) + { mbInit = bInit; } + + class SbUserFormModuleInstance* CreateInstance(); +}; + +class BASIC_DLLPUBLIC SbUserFormModuleInstance : public SbUserFormModule +{ + SbUserFormModule* m_pParentModule; + +public: + SbUserFormModuleInstance( SbUserFormModule* pParentModule, const OUString& rName, + const com::sun::star::script::ModuleInfo& mInfo, bool bIsVBACompat ); + + virtual sal_Bool IsClass( const OUString& ) const; + virtual SbxVariable* Find( const OUString& rName, SbxClassType t ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/sbprop.hxx b/include/basic/sbprop.hxx new file mode 100644 index 000000000000..463fd5d41c73 --- /dev/null +++ b/include/basic/sbprop.hxx @@ -0,0 +1,67 @@ +/* -*- 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 _SB_SBPROPERTY_HXX +#define _SB_SBPROPERTY_HXX + +#include <basic/sbxprop.hxx> +#include <basic/sbdef.hxx> +#include "basicdllapi.h" + +class SbModule; + +class BASIC_DLLPUBLIC SbProperty : public SbxProperty +{ + friend class SbiFactory; + friend class SbModule; + friend class SbProcedureProperty; + SbModule* pMod; + sal_Bool bInvalid; + BASIC_DLLPRIVATE SbProperty( const OUString&, SbxDataType, SbModule* ); + virtual ~SbProperty(); +public: + SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_BASICPROP,1); + TYPEINFO(); + SbModule* GetModule() { return pMod; } +}; + +SV_DECL_IMPL_REF(SbProperty) + +class BASIC_DLLPUBLIC SbProcedureProperty : public SbxProperty +{ + bool mbSet; // Flag for set command + + virtual ~SbProcedureProperty(); + +public: + SbProcedureProperty( const OUString& r, SbxDataType t ) + : SbxProperty( r, t ) // , pMod( p ) + , mbSet( false ) + {} + TYPEINFO(); + + bool isSet( void ) + { return mbSet; } + void setSet( bool bSet ) + { mbSet = bSet; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/sbstar.hxx b/include/basic/sbstar.hxx new file mode 100644 index 000000000000..c84b62494169 --- /dev/null +++ b/include/basic/sbstar.hxx @@ -0,0 +1,183 @@ +/* -*- 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 _SB_SBSTAR_HXX +#define _SB_SBSTAR_HXX + +#include <basic/sbx.hxx> +#include <basic/sbxobj.hxx> +#include <rtl/ustring.hxx> +#include <osl/mutex.hxx> +#include <tools/link.hxx> + +#include <basic/sbdef.hxx> +#include <basic/sberrors.hxx> +#include <com/sun/star/script/ModuleInfo.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include "basicdllapi.h" + +class SbModule; // completed module +class SbiInstance; // runtime instance +class SbiRuntime; // currently running procedure +class SbiImage; // compiled image +class BasicLibInfo; // info block for basic manager +class SbMethod; +class BasicManager; +class DocBasicItem; + +class BASIC_DLLPUBLIC StarBASIC : public SbxObject +{ + friend class SbiScanner; + friend class SbiExpression; // Access to RTL + friend class SbiInstance; + friend class SbiRuntime; + friend class DocBasicItem; + + SbxArrayRef pModules; // List of all modules + SbxObjectRef pRtl; // Runtime Library + SbxArrayRef xUnoListeners; // Listener handled by CreateUnoListener + + // Handler-Support: + Link aErrorHdl; // Error handler + Link aBreakHdl; // Breakpoint handler + bool bNoRtl; // if true: do not search RTL + bool bBreak; // if true: Break, otherwise Step + bool bDocBasic; + bool bVBAEnabled; + BasicLibInfo* pLibInfo; // Info block for basic manager + bool bQuit; + + SbxObjectRef pVBAGlobals; + BASIC_DLLPRIVATE SbxObject* getVBAGlobals( ); + + BASIC_DLLPRIVATE void implClearDependingVarsOnDelete( StarBASIC* pDeletedBasic ); + +protected: + sal_Bool CError( SbError, const OUString&, sal_Int32, sal_Int32, sal_Int32 ); +private: + BASIC_DLLPRIVATE sal_Bool RTError( SbError, sal_Int32, sal_Int32, sal_Int32 ); + BASIC_DLLPRIVATE sal_Bool RTError( SbError, const OUString& rMsg, sal_Int32, sal_Int32, sal_Int32 ); + BASIC_DLLPRIVATE sal_uInt16 BreakPoint( sal_Int32 nLine, sal_Int32 nCol1, sal_Int32 nCol2 ); + BASIC_DLLPRIVATE sal_uInt16 StepPoint( sal_Int32 nLine, sal_Int32 nCol1, sal_Int32 nCol2 ); + virtual sal_Bool LoadData( SvStream&, sal_uInt16 ); + virtual sal_Bool StoreData( SvStream& ) const; + +protected: + virtual sal_Bool ErrorHdl(); + virtual sal_uInt16 BreakHdl(); + virtual ~StarBASIC(); + +public: + + SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_BASIC,1); + TYPEINFO(); + + StarBASIC( StarBASIC* pParent = NULL, bool bIsDocBasic = false ); + + // #51727 SetModified overridden so that the Modfied-State is + // not delivered to Parent. + virtual void SetModified( sal_Bool ); + + void* operator new( size_t ); + void operator delete( void* ); + + virtual void Insert( SbxVariable* ); + using SbxObject::Remove; + virtual void Remove( SbxVariable* ); + virtual void Clear(); + + BasicLibInfo* GetLibInfo() { return pLibInfo; } + void SetLibInfo( BasicLibInfo* p ) { pLibInfo = p; } + + // Compiler-Interface + SbModule* MakeModule( const OUString& rName, const OUString& rSrc ); + SbModule* MakeModule32( const OUString& rName, const OUString& rSrc ); + SbModule* MakeModule32( const OUString& rName, const com::sun::star::script::ModuleInfo& mInfo, const OUString& rSrc ); + sal_Bool Compile( SbModule* ); + static void Stop(); + static void Error( SbError ); + static void Error( SbError, const OUString& rMsg ); + static void FatalError( SbError ); + static void FatalError( SbError, const OUString& rMsg ); + static bool IsRunning(); + static SbError GetErrBasic(); + // #66536 make additional message accessible by RTL function Error + static OUString GetErrorMsg(); + static sal_Int32 GetErl(); + + virtual SbxVariable* Find( const OUString&, SbxClassType ); + virtual sal_Bool Call( const OUString&, SbxArray* = NULL ); + + SbxArray* GetModules() { return pModules; } + SbxObject* GetRtl() { return pRtl; } + SbModule* FindModule( const OUString& ); + // Run init code of all modules (including the inserted Doc-Basics) + void InitAllModules( StarBASIC* pBasicNotToInit = NULL ); + void DeInitAllModules( void ); + void ClearAllModuleVars( void ); + + // Calls for error and break handler + static sal_uInt16 GetLine(); + static sal_uInt16 GetCol1(); + static sal_uInt16 GetCol2(); + static void SetErrorData( SbError nCode, sal_uInt16 nLine, + sal_uInt16 nCol1, sal_uInt16 nCol2 ); + + // Specific to error handler + static void MakeErrorText( SbError, const OUString& aMsg ); + static const OUString& GetErrorText(); + static SbError GetErrorCode(); + static bool IsCompilerError(); + static sal_uInt16 GetVBErrorCode( SbError nError ); + static SbError GetSfxFromVBError( sal_uInt16 nError ); + bool IsBreak() const { return bBreak; } + + static Link GetGlobalErrorHdl(); + static void SetGlobalErrorHdl( const Link& rNewHdl ); + Link GetErrorHdl() const { return aErrorHdl; } + void SetErrorHdl( const Link& r ) { aErrorHdl = r; } + + static void SetGlobalBreakHdl( const Link& rNewHdl ); + Link GetBreakHdl() const { return aBreakHdl; } + void SetBreakHdl( const Link& r ) { aBreakHdl = r; } + + SbxArrayRef getUnoListeners( void ); + + static SbxBase* FindSBXInCurrentScope( const OUString& rName ); + static SbMethod* GetActiveMethod( sal_uInt16 nLevel = 0 ); + static SbModule* GetActiveModule(); + void SetVBAEnabled( bool bEnabled ); + bool isVBAEnabled(); + + SbxObjectRef getRTL( void ) { return pRtl; } + bool IsDocBasic() { return bDocBasic; } + SbxVariable* VBAFind( const OUString& rName, SbxClassType t ); + bool GetUNOConstant( const sal_Char* _pAsciiName, ::com::sun::star::uno::Any& aOut ); + void QuitAndExitApplication(); + bool IsQuitApplication() { return bQuit; }; + + static ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > + GetModelFromBasic( SbxObject* pBasic ); +}; + +SV_DECL_IMPL_REF(StarBASIC) + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/sbstdobj.hxx b/include/basic/sbstdobj.hxx new file mode 100644 index 000000000000..75a5a6ecb452 --- /dev/null +++ b/include/basic/sbstdobj.hxx @@ -0,0 +1,136 @@ +/* -*- 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 _SBSTDOBJ1_HXX +#define _SBSTDOBJ1_HXX + +#include <basic/sbxobj.hxx> +#include <vcl/graph.hxx> +#include <basic/sbxfac.hxx> +#include "basicdllapi.h" + +//-------------------- +// class SbStdFactory +//-------------------- +class BASIC_DLLPUBLIC SbStdFactory : public SbxFactory +{ +public: + SbStdFactory(); + + virtual SbxObject* CreateObject( const OUString& rClassName ); +}; + +//-------------------- +// class SbStdPicture +//-------------------- +class BASIC_DLLPUBLIC SbStdPicture : public SbxObject +{ +protected: + Graphic aGraphic; + + ~SbStdPicture(); + virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, + const SfxHint& rHint, const TypeId& rHintType ); + + void PropType( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite ); + void PropWidth( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite ); + void PropHeight( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite ); + +public: + TYPEINFO(); + + SbStdPicture(); + virtual SbxVariable* Find( const OUString&, SbxClassType ); + + Graphic GetGraphic() const { return aGraphic; } + void SetGraphic( const Graphic& rGrf ) { aGraphic = rGrf; } +}; + +//----------------- +// class SbStdFont +//----------------- +class BASIC_DLLPUBLIC SbStdFont : public SbxObject +{ +protected: + sal_Bool bBold; + sal_Bool bItalic; + sal_Bool bStrikeThrough; + sal_Bool bUnderline; + sal_uInt16 nSize; + OUString aName; + + ~SbStdFont(); + virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, + const SfxHint& rHint, const TypeId& rHintType ); + + void PropBold( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite ); + void PropItalic( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite ); + void PropStrikeThrough( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite ); + void PropUnderline( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite ); + void PropSize( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite ); + void PropName( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite ); + +public: + TYPEINFO(); + + SbStdFont(); + virtual SbxVariable* Find( const OUString&, SbxClassType ); + + void SetBold( sal_Bool bB ) { bBold = bB; } + sal_Bool IsBold() const { return bBold; } + void SetItalic( sal_Bool bI ) { bItalic = bI; } + sal_Bool IsItalic() const { return bItalic; } + void SetStrikeThrough( sal_Bool bS ) { bStrikeThrough = bS; } + sal_Bool IsStrikeThrough() const { return bStrikeThrough; } + void SetUnderline( sal_Bool bU ) { bUnderline = bU; } + sal_Bool IsUnderline() const { return bUnderline; } + void SetSize( sal_uInt16 nS ) { nSize = nS; } + sal_uInt16 GetSize() const { return nSize; } + void SetFontName( const OUString& rName ) { aName = rName; } + OUString GetFontName() const { return aName; } +}; + +//---------------------- +// class SbStdClipboard +//---------------------- +class BASIC_DLLPUBLIC SbStdClipboard : public SbxObject +{ +protected: + + ~SbStdClipboard(); + virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, + const SfxHint& rHint, const TypeId& rHintType ); + + void MethClear( SbxVariable* pVar, SbxArray* pPar_, sal_Bool bWrite ); + void MethGetData( SbxVariable* pVar, SbxArray* pPar_, sal_Bool bWrite ); + void MethGetFormat( SbxVariable* pVar, SbxArray* pPar_, sal_Bool bWrite ); + void MethGetText( SbxVariable* pVar, SbxArray* pPar_, sal_Bool bWrite ); + void MethSetData( SbxVariable* pVar, SbxArray* pPar_, sal_Bool bWrite ); + void MethSetText( SbxVariable* pVar, SbxArray* pPar_, sal_Bool bWrite ); + +public: + TYPEINFO(); + + SbStdClipboard(); + virtual SbxVariable* Find( const OUString&, SbxClassType ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/sbuno.hxx b/include/basic/sbuno.hxx new file mode 100644 index 000000000000..55d487a48b75 --- /dev/null +++ b/include/basic/sbuno.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 _SB_SBUNO_HXX +#define _SB_SBUNO_HXX + +#include <basic/sbxobj.hxx> +#include "basicdllapi.h" + +namespace com { namespace sun { namespace star { namespace uno { class Any; }}}} + +// Returns a SbxObject that wrapps an Uno Interface +// Implementation in basic/source/classes/sbunoobj.cxx +BASIC_DLLPUBLIC SbxObjectRef GetSbUnoObject( const OUString& aName, const com::sun::star::uno::Any& aUnoObj_ ); + +// Force creation of all properties for debugging +BASIC_DLLPUBLIC void createAllObjectProperties( SbxObject* pObj ); +BASIC_DLLPUBLIC void SetSbUnoObjectDfltPropName( SbxObject* pObj ); + +BASIC_DLLPUBLIC ::com::sun::star::uno::Any sbxToUnoValue( SbxVariable* pVar ); + +BASIC_DLLPUBLIC void unoToSbxValue( SbxVariable* pVar, const ::com::sun::star::uno::Any& aValue ); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/sbx.hxx b/include/basic/sbx.hxx new file mode 100644 index 000000000000..d5fba159e510 --- /dev/null +++ b/include/basic/sbx.hxx @@ -0,0 +1,280 @@ +/* -*- 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 _SBXCLASS_HXX +#define _SBXCLASS_HXX + +#include "tools/ref.hxx" +#include "svl/smplhint.hxx" +#include "svl/lstner.hxx" + +#include <basic/sbxdef.hxx> +#include <basic/sbxform.hxx> +#include <basic/sbxobj.hxx> +#include <basic/sbxprop.hxx> +#include <basic/sbxmeth.hxx> +#include "basicdllapi.h" + +#include <boost/ptr_container/ptr_vector.hpp> + +class SvStream; +class SbxBase; +class SbxVariable; +class SbxProperty; +class SbxMethod; +class SbxObject; +class SbxArray; +class SbxDimArray; +class SbxFactory; + +class SfxBroadcaster; + +// Parameter information +struct SbxParamInfo +{ + const OUString aName; // Name of the parameter + SbxBaseRef aTypeRef; // Object, if object type + SbxDataType eType; // Data type + sal_uInt16 nFlags; // Flag-Bits + sal_uInt32 nUserData; // IDs etc. + SbxParamInfo( const OUString& s, SbxDataType t, sal_uInt16 n, SbxBase* b = NULL ) + : aName( s ), aTypeRef( b ), eType( t ), nFlags( n ), nUserData( 0 ) {} + ~SbxParamInfo() {} +}; + +typedef boost::ptr_vector<SbxParamInfo> SbxParams; + +class BASIC_DLLPUBLIC SbxInfo : public SvRefBase +{ + friend class SbxVariable; + friend class SbMethod; + + OUString aComment; + OUString aHelpFile; + sal_uInt32 nHelpId; + SbxParams aParams; + +protected: + sal_Bool LoadData( SvStream&, sal_uInt16 ); + sal_Bool StoreData( SvStream& ) const; + virtual ~SbxInfo(); +public: + SbxInfo(); + SbxInfo( const OUString&, sal_uInt32 ); + + void AddParam( const OUString&, SbxDataType, sal_uInt16=SBX_READ ); + const SbxParamInfo* GetParam( sal_uInt16 n ) const; // index starts with 1! + const OUString& GetComment() const { return aComment; } + const OUString& GetHelpFile() const { return aHelpFile; } + sal_uInt32 GetHelpId() const { return nHelpId; } + + void SetComment( const OUString& r ) { aComment = r; } + void SetHelpFile( const OUString& r ) { aHelpFile = r; } + void SetHelpId( sal_uInt32 nId ) { nHelpId = nId; } +}; + +class BASIC_DLLPUBLIC SbxHint : public SfxSimpleHint +{ + SbxVariable* pVar; +public: + TYPEINFO(); + SbxHint( sal_uIntPtr n, SbxVariable* v ) : SfxSimpleHint( n ), pVar( v ) {} + SbxVariable* GetVar() const { return pVar; } +}; + +// SbxAlias is an alias for a var or object +class BASIC_DLLPUBLIC SbxAlias : public SbxVariable, public SfxListener +{ + SbxVariableRef xAlias; + virtual ~SbxAlias(); + virtual void Broadcast( sal_uIntPtr ); + virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, + const SfxHint& rHint, const TypeId& rHintType ); +public: + SbxAlias( const SbxAlias& ); + SbxAlias& operator=( const SbxAlias& ); +}; + +// SbxArray is an unidimensional, dynamic Array +// The variables convert from SbxVariablen. Put()/Insert() into the +// declared datatype, if they are not SbxVARIANT. + +class SbxVarRefs; +class SbxVariableRef; + +class BASIC_DLLPUBLIC SbxArray : public SbxBase +{ +// #100883 Method to set method directly to parameter array + friend class SbMethod; + friend class SbClassModuleObject; + friend SbxObject* cloneTypeObjectImpl( const SbxObject& rTypeObj ); + BASIC_DLLPRIVATE void PutDirect( SbxVariable* pVar, sal_uInt32 nIdx ); + + SbxVarRefs* pData; // The variables + +protected: + SbxDataType eType; // Data type of the array + virtual ~SbxArray(); + virtual sal_Bool LoadData( SvStream&, sal_uInt16 ); + virtual sal_Bool StoreData( SvStream& ) const; + +public: + SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_ARRAY,1); + TYPEINFO(); + SbxArray( SbxDataType=SbxVARIANT ); + SbxArray( const SbxArray& ); + SbxArray& operator=( const SbxArray& ); + virtual void Clear(); + sal_uInt16 Count() const; + virtual SbxDataType GetType() const; + virtual SbxClassType GetClass() const; + SbxVariableRef& GetRef( sal_uInt16 ); + SbxVariable* Get( sal_uInt16 ); + void Put( SbxVariable*, sal_uInt16 ); + void Insert( SbxVariable*, sal_uInt16 ); + void Remove( sal_uInt16 ); + void Remove( SbxVariable* ); + void Merge( SbxArray* ); + const OUString& GetAlias( sal_uInt16 ); + void PutAlias( const OUString&, sal_uInt16 ); + SbxVariable* FindUserData( sal_uInt32 nUserData ); + virtual SbxVariable* Find( const OUString&, SbxClassType ); + + // Additional methods for 32-bit indices + sal_uInt32 Count32() const; + SbxVariableRef& GetRef32( sal_uInt32 ); + SbxVariable* Get32( sal_uInt32 ); + void Put32( SbxVariable*, sal_uInt32 ); + void Insert32( SbxVariable*, sal_uInt32 ); + void Remove32( sal_uInt32 ); +}; + +// SbxDimArray is an array that can dimensioned using BASIC conventions. +struct SbxDim; + +class BASIC_DLLPUBLIC SbxDimArray : public SbxArray +{ + SbxDim* pFirst, *pLast; // Links to Dimension table + short nDim; // Number of dimensions + BASIC_DLLPRIVATE void AddDimImpl32( sal_Int32, sal_Int32, sal_Bool bAllowSize0 ); + bool mbHasFixedSize; +protected: + sal_uInt16 Offset( const short* ); + sal_uInt32 Offset32( const sal_Int32* ); + sal_uInt32 Offset32( SbxArray* ); + virtual sal_Bool LoadData( SvStream&, sal_uInt16 ); + virtual sal_Bool StoreData( SvStream& ) const; + virtual ~SbxDimArray(); +public: + SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_DIMARRAY,1); + TYPEINFO(); + SbxDimArray( SbxDataType=SbxVARIANT ); + SbxDimArray( const SbxDimArray& ); + SbxDimArray& operator=( const SbxDimArray& ); + virtual void Clear(); + using SbxArray::GetRef; + using SbxArray::Get; + SbxVariable* Get( const short* ); + using SbxArray::Put; + void Put( SbxVariable*, const short* ); + SbxVariable* Get( SbxArray* ); + + short GetDims() const; + void AddDim( short, short ); + void unoAddDim( short, short ); + sal_Bool GetDim( short, short&, short& ) const; + + using SbxArray::GetRef32; + using SbxArray::Get32; + SbxVariable* Get32( const sal_Int32* ); + using SbxArray::Put32; + void Put32( SbxVariable*, const sal_Int32* ); + void AddDim32( sal_Int32, sal_Int32 ); + void unoAddDim32( sal_Int32, sal_Int32 ); + sal_Bool GetDim32( sal_Int32, sal_Int32&, sal_Int32& ) const; + bool hasFixedSize() { return mbHasFixedSize; }; + void setHasFixedSize( bool bHasFixedSize ) {mbHasFixedSize = bHasFixedSize; }; +}; + +class BASIC_DLLPUBLIC SbxCollection : public SbxObject +{ + BASIC_DLLPRIVATE void Initialize(); +protected: + virtual ~SbxCollection(); + virtual sal_Bool LoadData( SvStream&, sal_uInt16 ); + virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, + const SfxHint& rHint, const TypeId& rHintType ); + // Overridable methods (why not pure virtual?): + virtual void CollAdd( SbxArray* pPar ); + virtual void CollItem( SbxArray* pPar ); + virtual void CollRemove( SbxArray* pPar ); + +public: + SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_COLLECTION,1); + TYPEINFO(); + SbxCollection( const OUString& rClassname ); + SbxCollection( const SbxCollection& ); + SbxCollection& operator=( const SbxCollection& ); + virtual SbxVariable* FindUserData( sal_uInt32 nUserData ); + virtual SbxVariable* Find( const OUString&, SbxClassType ); + virtual void Clear(); +}; + +class BASIC_DLLPUBLIC SbxStdCollection : public SbxCollection +{ +protected: + OUString aElemClass; + sal_Bool bAddRemoveOk; + virtual ~SbxStdCollection(); + virtual sal_Bool LoadData( SvStream&, sal_uInt16 ); + virtual sal_Bool StoreData( SvStream& ) const; + virtual void CollAdd( SbxArray* pPar ); + virtual void CollRemove( SbxArray* pPar ); +public: + SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_FIXCOLLECTION,1); + TYPEINFO(); + SbxStdCollection( const OUString& rClassname, const OUString& rElemClass, sal_Bool=sal_True ); + SbxStdCollection( const SbxStdCollection& ); + SbxStdCollection& operator=( const SbxStdCollection& ); + virtual void Insert( SbxVariable* ); + const OUString& GetElementClass() const { return aElemClass; } +}; + +SV_IMPL_REF(SbxBase) + +SV_IMPL_REF(SbxVariable) + +#ifndef SBX_ARRAY_DECL_DEFINED +#define SBX_ARRAY_DECL_DEFINED +SV_DECL_REF(SbxArray) +#endif +SV_IMPL_REF(SbxArray) + +#ifndef SBX_INFO_DECL_DEFINED +#define SBX_INFO_DECL_DEFINED +SV_DECL_REF(SbxInfo) +#endif +SV_IMPL_REF(SbxInfo) + +SV_DECL_REF(SbxDimArray) +SV_IMPL_REF(SbxDimArray) + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/sbxbase.hxx b/include/basic/sbxbase.hxx new file mode 100644 index 000000000000..16484ee929d8 --- /dev/null +++ b/include/basic/sbxbase.hxx @@ -0,0 +1,52 @@ +/* -*- 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 _SBXBASE_HXX +#define _SBXBASE_HXX + +#include <i18nlangtag/lang.h> +#include <basic/sbxdef.hxx> +#include "basicdllapi.h" +#include <boost/ptr_container/ptr_vector.hpp> + +class SbxFactory; +class SbxVariable; +class SbxBasicFormater; + +typedef boost::ptr_vector<SbxFactory> SbxFacs; + +// AppData structure for SBX: +struct SbxAppData +{ + SbxError eSbxError; // Error code + SbxFacs aFacs; // Factories + SbxBasicFormater *pBasicFormater; // Pointer to Format()-Command helper class + + LanguageType eBasicFormaterLangType; + // It might be useful to store this class 'global' because some string reosurces are saved here + + SbxAppData() : eSbxError( SbxERR_OK ), aFacs(), pBasicFormater( NULL ) {} + ~SbxAppData(); +}; + +BASIC_DLLPUBLIC SbxAppData& GetSbxData_Impl(); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/sbxcore.hxx b/include/basic/sbxcore.hxx new file mode 100644 index 000000000000..4c71d1a5b977 --- /dev/null +++ b/include/basic/sbxcore.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 _SBXCORE_HXX +#define _SBXCORE_HXX + +#include <tools/rtti.hxx> +#include <tools/ref.hxx> +#include <tools/debug.hxx> + +#include <basic/sbxdef.hxx> +#include "basicdllapi.h" + +class SvStream; + +// The following Macro defines four (five) necessary methods within a +// SBX object. LoadPrivateData() and StorePrivateData() must be implemented. +// They are necessary for loading/storing the data of derived classes. +// Load() and Store() must not be overridden. + +// This version of the Macros does not define Load/StorePrivateData()-methods +#define SBX_DECL_PERSIST_NODATA( nCre, nSbxId, nVer ) \ + virtual sal_uInt32 GetCreator() const { return nCre; } \ + virtual sal_uInt16 GetVersion() const { return nVer; } \ + virtual sal_uInt16 GetSbxId() const { return nSbxId; } + +// This version of the macro defines Load/StorePrivateData()-methods +#define SBX_DECL_PERSIST( nCre, nSbxId, nVer ) \ + virtual sal_Bool LoadPrivateData( SvStream&, sal_uInt16 ); \ + virtual sal_Bool StorePrivateData( SvStream& ) const; \ + SBX_DECL_PERSIST_NODATA( nCre, nSbxId, nVer ) + +class SbxBase; +class SbxFactory; +class SbxObject; + +DBG_NAMEEX_VISIBILITY(SbxBase, BASIC_DLLPUBLIC) + +class BASIC_DLLPUBLIC SbxBase : virtual public SvRefBase +{ + virtual sal_Bool LoadData( SvStream&, sal_uInt16 ); + virtual sal_Bool StoreData( SvStream& ) const; +protected: + sal_uInt16 nFlags; // Flag-Bits + + SbxBase(); + SbxBase( const SbxBase& ); + SbxBase& operator=( const SbxBase& ); + virtual ~SbxBase(); + SBX_DECL_PERSIST(0,0,0); +public: + TYPEINFO(); + inline void SetFlags( sal_uInt16 n ); + inline sal_uInt16 GetFlags() const; + inline void SetFlag( sal_uInt16 n ); + inline void ResetFlag( sal_uInt16 n ); + inline sal_Bool IsSet( sal_uInt16 n ) const; + inline sal_Bool IsReset( sal_uInt16 n ) const; + inline sal_Bool CanRead() const; + inline sal_Bool CanWrite() const; + inline sal_Bool IsModified() const; + inline sal_Bool IsConst() const; + inline sal_Bool IsHidden() const; + inline sal_Bool IsVisible() const; + + virtual sal_Bool IsFixed() const; + virtual void SetModified( sal_Bool ); + + virtual SbxDataType GetType() const; + virtual SbxClassType GetClass() const; + + virtual void Clear(); + + static SbxBase* Load( SvStream& ); + static void Skip( SvStream& ); + sal_Bool Store( SvStream& ); + virtual sal_Bool LoadCompleted(); + virtual sal_Bool StoreCompleted(); + + static SbxError GetError(); + static void SetError( SbxError ); + static sal_Bool IsError(); + static void ResetError(); + + // Set the factory for Load/Store/Create + static void AddFactory( SbxFactory* ); + static void RemoveFactory( SbxFactory* ); + + static SbxBase* Create( sal_uInt16, sal_uInt32=SBXCR_SBX ); + static SbxObject* CreateObject( const OUString& ); +}; + +SV_DECL_REF(SbxBase) + +inline void SbxBase::SetFlags( sal_uInt16 n ) +{ //DBG_CHKTHIS( SbxBase, 0 ); + nFlags = n; } + +inline sal_uInt16 SbxBase::GetFlags() const +{ DBG_CHKTHIS( SbxBase, 0 ); return nFlags; } + +inline void SbxBase::SetFlag( sal_uInt16 n ) +{ //DBG_CHKTHIS( SbxBase, 0 ); + nFlags |= n; } + +inline void SbxBase::ResetFlag( sal_uInt16 n ) +{ //DBG_CHKTHIS( SbxBase, 0 ); + nFlags &= ~n; } + +inline sal_Bool SbxBase::IsSet( sal_uInt16 n ) const +{ DBG_CHKTHIS( SbxBase, 0 ); return sal_Bool( ( nFlags & n ) != 0 ); } + +inline sal_Bool SbxBase::IsReset( sal_uInt16 n ) const +{ DBG_CHKTHIS( SbxBase, 0 ); return sal_Bool( ( nFlags & n ) == 0 ); } + +inline sal_Bool SbxBase::CanRead() const +{ DBG_CHKTHIS( SbxBase, 0 ); return IsSet( SBX_READ ); } + +inline sal_Bool SbxBase::CanWrite() const +{ DBG_CHKTHIS( SbxBase, 0 ); return IsSet( SBX_WRITE ); } + +inline sal_Bool SbxBase::IsModified() const +{ DBG_CHKTHIS( SbxBase, 0 ); return IsSet( SBX_MODIFIED ); } + +inline sal_Bool SbxBase::IsConst() const +{ DBG_CHKTHIS( SbxBase, 0 ); return IsSet( SBX_CONST ); } + +inline sal_Bool SbxBase::IsHidden() const +{ DBG_CHKTHIS( SbxBase, 0 ); return IsSet( SBX_HIDDEN ); } + +inline sal_Bool SbxBase::IsVisible() const +{ DBG_CHKTHIS( SbxBase, 0 ); return IsReset( SBX_INVISIBLE ); } + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/sbxdef.hxx b/include/basic/sbxdef.hxx new file mode 100644 index 000000000000..781a71b3b430 --- /dev/null +++ b/include/basic/sbxdef.hxx @@ -0,0 +1,311 @@ +/* -*- 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 _SBXDEF_HXX +#define _SBXDEF_HXX + + +#ifndef __RSC +#include <tools/solar.h> +#include "tools/errcode.hxx" + +enum SbxClassType { // SBX-class-IDs (order is important!) + SbxCLASS_DONTCARE = 1, // don't care (search, not 0 due to StarBASIC) + SbxCLASS_ARRAY, // Array of SbxVariables + SbxCLASS_VALUE, // simple value + SbxCLASS_VARIABLE, // Variable (from here there is Broadcaster) + SbxCLASS_METHOD, // Method (Function or Sub) + SbxCLASS_PROPERTY, // Property + SbxCLASS_OBJECT // Object +}; + +enum SbxDataType { + SbxEMPTY = 0, // * Uninitialized + SbxNULL = 1, // * Contains no valid data + SbxINTEGER = 2, // * Integer (sal_Int16) + SbxLONG = 3, // * Long integer (sal_Int32) + SbxSINGLE = 4, // * Single-precision floating point number (float) + SbxDOUBLE = 5, // * Double-precision floating point number (double) + SbxCURRENCY = 6, // Currency (sal_Int64) + SbxDATE = 7, // * Date (double) + SbxSTRING = 8, // * String (StarView) + SbxOBJECT = 9, // * SbxBase object pointer + SbxERROR = 10, // * Error (sal_uInt16) + SbxBOOL = 11, // * Boolean (0 or -1) + + SbxVARIANT = 12, // * Display for variant datatype + SbxDATAOBJECT = 13, // * Common data object w/o ref count + + SbxCHAR = 16, // * signed char + SbxBYTE = 17, // * unsigned char + SbxUSHORT = 18, // * unsigned short (sal_uInt16) + SbxULONG = 19, // * unsigned long (sal_uInt32) + +//deprecated: // old 64bit types kept for backward compatibility in file I/O + SbxLONG64 = 20, // moved to SbxSALINT64 as 64bit int + SbxULONG64 = 21, // moved to SbxSALUINT64 as 64bit int + + SbxINT = 22, // * signed machine-dependent int + SbxUINT = 23, // * unsigned machine-dependent int + + SbxVOID = 24, // * no value (= SbxEMPTY) + SbxHRESULT = 25, // HRESULT + SbxPOINTER = 26, // generic pointer + SbxDIMARRAY = 27, // dimensioned array + SbxCARRAY = 28, // C style array + SbxUSERDEF = 29, // user defined + SbxLPSTR = 30, // * null terminated string + + SbxLPWSTR = 31, // wide null terminated string + SbxCoreSTRING = 32, // from 1997-4-10 for GetCoreString(), only for converting< + + SbxWSTRING = 33, // from 2000-10-4 Reimplemented for backwards compatibility (#78919) + SbxWCHAR = 34, // from 2000-10-4 Reimplemented for backwards compatibility (#78919) + SbxSALINT64 = 35, // for currency internal, signed 64-bit int and UNO hyper + SbxSALUINT64= 36, // for currency internal, unsigned 64-bit int and UNO unsigned hyper + SbxDECIMAL = 37, // for UNO/automation Decimal + + SbxVECTOR = 0x1000, // simple counted array + SbxARRAY = 0x2000, // array + SbxBYREF = 0x4000, // access by reference + + SbxSV1 = 128, // first defined data type for StarView + SbxMEMORYSTREAM, // SvMemoryStream + SbxSTORAGE, // SvStorage + + SbxUSER1 = 256, // first user defined data type + SbxUSERn = 2047 // last user defined data type +}; + +const sal_uInt32 SBX_TYPE_WITH_EVENTS_FLAG = 0x10000; +const sal_uInt32 SBX_TYPE_DIM_AS_NEW_FLAG = 0x20000; +const sal_uInt32 SBX_FIXED_LEN_STRING_FLAG = 0x10000; // same value as above as no conflict possible +const sal_uInt32 SBX_TYPE_VAR_TO_DIM_FLAG = 0x40000; + +enum SbxOperator { + // Arithmetical: + SbxEXP, // this ^ var + SbxMUL, // this * var + SbxDIV, // this / var + SbxMOD, // this MOD var (max INT32!) + SbxPLUS, // this + var + SbxMINUS, // this - var + SbxNEG, // -this (var is ignored) + SbxIDIV, // this / var (both operands max. sal_Int32!) + // Boolean operators (max sal_Int32!): + // Boolean operators (TODO deprecate this limit: max INT32!) + SbxAND, // this & var + SbxOR, // this | var + SbxXOR, // this ^ var + SbxEQV, // ~this ^ var + SbxIMP, // ~this | var + SbxNOT, // ~this (var is ignored) + + // String concatenation: + SbxCAT, // this & var (VBA: this + var) + + // Comparisons: + SbxEQ, // this = var + SbxNE, // this <> var + SbxLT, // this < var + SbxGT, // this > var + SbxLE, // this <= var + SbxGE // this >= var +}; + +enum SbxNameType { // Type of the questioned name of a variable + SbxNAME_NONE, // plain name + SbxNAME_SHORT, // Name(A,B) + SbxNAME_SHORT_TYPES, // Name%(A%,B$) + SbxNAME_LONG_TYPES // Name(A As Integer, B As String) As Integer +}; + +// from 1996/3/20: New error messages +typedef sal_uIntPtr SbxError; // Preserve old type + +#endif + + +// New error codes per define +#define ERRCODE_SBX_OK ERRCODE_NONE // processed + +#define ERRCODE_SBX_SYNTAX (1UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_COMPILER) +#define ERRCODE_SBX_NOTIMP (2UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_NOTSUPPORTED) +#define ERRCODE_SBX_OVERFLOW (3UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_SBX) // overflow +#define ERRCODE_SBX_BOUNDS (4UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_SBX) // Invalid array index +#define ERRCODE_SBX_ZERODIV (5UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_SBX) // Division by zero +#define ERRCODE_SBX_CONVERSION (6UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_SBX) // wrong data type +#define ERRCODE_SBX_BAD_PARAMETER (7UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // invalid Parameter +#define ERRCODE_SBX_PROC_UNDEFINED (8UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Sub or Func not def +#define ERRCODE_SBX_ERROR (9UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_UNKNOWN) // generic object error +#define ERRCODE_SBX_NO_OBJECT (10UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Object var not object +#define ERRCODE_SBX_CANNOT_LOAD (11UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_CREATE) // Object init/load fail +#define ERRCODE_SBX_BAD_INDEX (12UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_SBX) // Invalid object index +#define ERRCODE_SBX_NO_ACTIVE_OBJECT (13UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_ACCESS) // Object not active +#define ERRCODE_SBX_BAD_PROP_VALUE (14UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Bad property value +#define ERRCODE_SBX_PROP_READONLY (15UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_READ) // Property is read only +#define ERRCODE_SBX_PROP_WRITEONLY (16UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_WRITE) // Property is write only +#define ERRCODE_SBX_INVALID_OBJECT (17UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_ACCESS) // Invalid object reference +#define ERRCODE_SBX_NO_METHOD (18UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Property oder Methode unbekannt +#define ERRCODE_SBX_INVALID_USAGE_OBJECT (19UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_ACCESS) // Invalid object usage +#define ERRCODE_SBX_NO_OLE (20UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_ACCESS) // No OLE-Object +#define ERRCODE_SBX_BAD_METHOD (21UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Method not supported +#define ERRCODE_SBX_OLE_ERROR (22UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // OLE Automation Error +#define ERRCODE_SBX_BAD_ACTION (23UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_NOTSUPPORTED) // Action not supported +#define ERRCODE_SBX_NO_NAMED_ARGS (24UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // No named arguments +#define ERRCODE_SBX_BAD_LOCALE (25UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_NOTSUPPORTED) // Locale not supported +#define ERRCODE_SBX_NAMED_NOT_FOUND (26UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Unknown named argument +#define ERRCODE_SBX_NOT_OPTIONAL (27UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Argument not optional +#define ERRCODE_SBX_WRONG_ARGS (28UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_SBX) // Invalid number of arguments +#define ERRCODE_SBX_NOT_A_COLL (29UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Object contains no elements +#define LAST_SBX_ERROR_ID 29UL + +#ifndef __RSC + +// Map old codes to new ones +#define SbxERR_OK ERRCODE_SBX_OK +#define SbxERR_SYNTAX ERRCODE_SBX_SYNTAX +#define SbxERR_NOTIMP ERRCODE_SBX_NOTIMP +#define SbxERR_OVERFLOW ERRCODE_SBX_OVERFLOW +#define SbxERR_BOUNDS ERRCODE_SBX_BOUNDS +#define SbxERR_ZERODIV ERRCODE_SBX_ZERODIV +#define SbxERR_CONVERSION ERRCODE_SBX_CONVERSION +#define SbxERR_BAD_PARAMETER ERRCODE_SBX_BAD_PARAMETER +#define SbxERR_PROC_UNDEFINED ERRCODE_SBX_PROC_UNDEFINED +#define SbxERR_ERROR ERRCODE_SBX_ERROR +#define SbxERR_NO_OBJECT ERRCODE_SBX_NO_OBJECT +#define SbxERR_CANNOT_LOAD ERRCODE_SBX_CANNOT_LOAD +#define SbxERR_BAD_INDEX ERRCODE_SBX_BAD_INDEX +#define SbxERR_NO_ACTIVE_OBJECT ERRCODE_SBX_NO_ACTIVE_OBJECT +#define SbxERR_BAD_PROP_VALUE ERRCODE_SBX_BAD_PROP_VALUE +#define SbxERR_PROP_READONLY ERRCODE_SBX_PROP_READONLY +#define SbxERR_PROP_WRITEONLY ERRCODE_SBX_PROP_WRITEONLY +#define SbxERR_INVALID_OBJECT ERRCODE_SBX_INVALID_OBJECT +#define SbxERR_NO_METHOD ERRCODE_SBX_NO_METHOD +#define SbxERR_INVALID_USAGE_OBJECT ERRCODE_SBX_INVALID_USAGE_OBJECT +#define SbxERR_NO_OLE ERRCODE_SBX_NO_OLE +#define SbxERR_BAD_METHOD ERRCODE_SBX_BAD_METHOD +#define SbxERR_OLE_ERROR ERRCODE_SBX_OLE_ERROR +#define SbxERR_BAD_ACTION ERRCODE_SBX_BAD_ACTION +#define SbxERR_NO_NAMED_ARGS ERRCODE_SBX_NO_NAMED_ARGS +#define SbxERR_BAD_LOCALE ERRCODE_SBX_BAD_LOCALE +#define SbxERR_NAMED_NOT_FOUND ERRCODE_SBX_NAMED_NOT_FOUND +#define SbxERR_NOT_OPTIONAL ERRCODE_SBX_NOT_OPTIONAL +#define SbxERR_WRONG_ARGS ERRCODE_SBX_WRONG_ARGS +#define SbxERR_NOT_A_COLL ERRCODE_SBX_NOT_A_COLL + + +// Flag-Bits: +#define SBX_READ 0x0001 // Read permission +#define SBX_WRITE 0x0002 // Write permission +#define SBX_READWRITE 0x0003 // Read/Write permission +#define SBX_DONTSTORE 0x0004 // Don't store object +#define SBX_MODIFIED 0x0008 // Object was changed +#define SBX_FIXED 0x0010 // Fixed data type (SbxVariable) +#define SBX_CONST 0x0020 // Definition of const value +#define SBX_OPTIONAL 0x0040 // Parameter is optional +#define SBX_HIDDEN 0x0080 // Element is invisible +#define SBX_INVISIBLE 0x0100 // Element is not found by Find() +#define SBX_EXTSEARCH 0x0200 // Object is searched completely +#define SBX_EXTFOUND 0x0400 // Variable was found through extended search +#define SBX_GBLSEARCH 0x0800 // Global search via Parents +#define SBX_RESERVED 0x1000 // reserved +#define SBX_PRIVATE 0x1000 // #110004, #112015, cannot conflict with SBX_RESERVED +#define SBX_NO_BROADCAST 0x2000 // No broadcast on Get/Put +#define SBX_REFERENCE 0x4000 // Parameter is Reference (DLL-call) +#define SBX_NO_MODIFY 0x8000 // SetModified is suppressed +#define SBX_WITH_EVENTS 0x0080 // Same value as unused SBX_HIDDEN +#define SBX_DIM_AS_NEW 0x0800 // Same value as SBX_GBLSEARCH, cannot conflict as one + // is used for objects, the other for variables only +#define SBX_VAR_TO_DIM 0x2000 // Same value as SBX_NO_BROADCAST, cannot conflict as + // used for variables without broadcaster only + +// Broadcaster-IDs: +#define SBX_HINT_DYING SFX_HINT_DYING +#define SBX_HINT_DATAWANTED SFX_HINT_USER00 +#define SBX_HINT_DATACHANGED SFX_HINT_DATACHANGED +#define SBX_HINT_CONVERTED SFX_HINT_USER01 +#define SBX_HINT_INFOWANTED SFX_HINT_USER02 +#define SBX_HINT_OBJECTCHANGED SFX_HINT_USER03 + +// List of all creators for Load/Store + +#define SBXCR_SBX 0x20584253 // SBX(blank) + +// List of predefined SBX-IDs. New SBX-IDs must be precisly defined so that +// they are unique within the Stream and appropriate Factory. + +#define SBXID_VALUE 0x4E4E // NN: SbxValue +#define SBXID_VARIABLE 0x4156 // VA: SbxVariable +#define SBXID_ARRAY 0x5241 // AR: SbxArray +#define SBXID_DIMARRAY 0x4944 // DI: SbxDimArray +#define SBXID_OBJECT 0x424F // OB: SbxObject +#define SBXID_COLLECTION 0x4F43 // CO: SbxCollection +#define SBXID_FIXCOLLECTION 0x4346 // FC: SbxStdCollection +#define SBXID_METHOD 0x454D // ME: SbxMethod +#define SBXID_PROPERTY 0x5250 // PR: SbxProperty + +// StarBASIC restricts the base data type to different intervals. +// These intervals are fixed to create 'portability and independent +// of the implementation. Only type double is greedy and takes +// what it gets. + +#define SbxMAXCHAR ((sal_Unicode)65535) +#define SbxMINCHAR (0) +#define SbxMAXBYTE ( 255) +#define SbxMAXINT ( 32767) +#define SbxMININT (-32768) +#define SbxMAXUINT ((sal_uInt16) 65535) +#define SbxMAXLNG ( 2147483647) +#define SbxMINLNG ((sal_Int32)(-2147483647-1)) +#define SbxMAXULNG ((sal_uInt32) 0xffffffff) + +#define SbxMAXSALUINT64 SAL_MAX_UINT64 +#define SbxMAXSALINT64 SAL_MAX_INT64 +#define SbxMINSALINT64 SAL_MIN_INT64 + + // Currency stored as SbxSALINT64 == sal_Int64 + // value range limits are ~(2^63 - 1)/10000 + // fixed precision has 4 digits right of decimal pt +#define CURRENCY_FACTOR (10000) +#define CURRENCY_FACTOR_SQUARE (100000000) + +// TODO effective MAX/MINCURR limits: +// true value ( 922337203685477.5807) is too precise for correct comparison to 64bit double +#define SbxMAXCURR ( 922337203685477.5807) +#define SbxMINCURR (-922337203685477.5808) + +#define SbxMAXSNG ( 3.402823e+38) +#define SbxMINSNG (-3.402823e+38) +#define SbxMAXSNG2 ( 1.175494351e-38) +#define SbxMINSNG2 (-1.175494351e-38) + +// Max valid offset index of a Sbx-Array (due to 64K limit) +#define SBX_MAXINDEX 0x3FF0 +#define SBX_MAXINDEX32 SbxMAXLNG + +// The numeric values of sal_True and FALSE +enum SbxBOOL { SbxFALSE = 0, SbxTRUE = -1 }; + +#endif //ifndef __RSC + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/sbxfac.hxx b/include/basic/sbxfac.hxx new file mode 100644 index 000000000000..33035cf45c9b --- /dev/null +++ b/include/basic/sbxfac.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 __SBX_SBX_FACTORY_HXX +#define __SBX_SBX_FACTORY_HXX + +#include <basic/sbxdef.hxx> +#include <rtl/ustring.hxx> +#include "basicdllapi.h" + +class SbxBase; +class SbxObject; + +class BASIC_DLLPUBLIC SbxFactory +{ + bool bHandleLast; // true: Factory is asked at last because of its expensiveness +public: + virtual ~SbxFactory(); + SbxFactory( bool bLast=false ) { bHandleLast = bLast; } + bool IsHandleLast( void ) { return bHandleLast; } + virtual SbxBase* Create( sal_uInt16 nSbxId, sal_uInt32 = SBXCR_SBX ); + virtual SbxObject* CreateObject( const OUString& ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/sbxform.hxx b/include/basic/sbxform.hxx new file mode 100644 index 000000000000..589f3ec24fd0 --- /dev/null +++ b/include/basic/sbxform.hxx @@ -0,0 +1,173 @@ +/* -*- 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 _SBXFORM_HXX +#define _SBXFORM_HXX + +//==================================================================== +// Implementation class for Basic command: Format$( d,formatStr ) +//==================================================================== +/* + Grammar of format string (a try): + ----------------------------------------------- + + format_string := {\special_char} general_format | scientific_format {\special_char} {;format_string} + general_format := {#[,]}{0[,]}[.{0}{#}] + scientific_format := {0}[.{0}{#}](e | E)(+ | -){#}{0} + + percent_char := '%' + special_char := \char | + | - | ( | ) | $ | space_char + char := all_ascii_chars + space_char := ' ' + + {} repeated multiple times (incl. zero times) + [] exactly one or zero times + () parenthesis, e.g. (e | E) means e or E times + + Additional predefined formats for the format string: + "General Number" + "Currency" + "Fixed" + "Standard" + "Percent" + "Scientific" + "Yes/No" + "True/False" + "On/Off" + + Note: invalid format string are ignored just as in VisualBasic, the output is + probably 'undefined'. ASCII letters are outputted directly. + + Constraints in VisualBasic: + - the exponent (scientific syntax) has a maximum of three digits! + + Constraints of new implementation: + - the '+' sign is not allowed as wildcard in the mantissa + + TODO: + - Date formatting + Wildcards are: 'h', 'm', 's', 'y' + predefined String-Constants/Commands: + "AMPM", "Long Date", "Long Time" +*/ + +/* + There are two possibilities to get the number of digits of a number: + + a) use sprintf() + b) use log10() and pow() digit +*/ +#define _with_sprintf // use a) + +#include <rtl/ustring.hxx> +#include <rtl/ustrbuf.hxx> +#include "basicdllapi.h" + +class BASIC_DLLPUBLIC SbxBasicFormater { + public: + // Constructor takes signs for decimal point, thousand separation sign + // and necessary resource strings. + SbxBasicFormater( sal_Unicode _cDecPoint, sal_Unicode _cThousandSep, + OUString _sOnStrg, + OUString _sOffStrg, + OUString _sYesStrg, + OUString _sNoStrg, + OUString _sTrueStrg, + OUString _sFalseStrg, + OUString _sCurrencyStrg, + OUString _sCurrencyFormatStrg ); + + /* Basic command: Format$( number,format-string ) + + Parameter: + dNumber : number to be formated + sFormatStrg : the Format-String, e.g. ###0.0### + + Return value: + String containing the formatted output + */ + OUString BasicFormat( double dNumber, OUString sFormatStrg ); + OUString BasicFormatNull( OUString sFormatStrg ); + + static sal_Bool isBasicFormat( OUString sFormatStrg ); + + private: + BASIC_DLLPRIVATE inline void ShiftString( OUStringBuffer& sStrg, sal_uInt16 nStartPos ); + BASIC_DLLPRIVATE void AppendDigit( OUStringBuffer& sStrg, short nDigit ); + BASIC_DLLPRIVATE void LeftShiftDecimalPoint( OUStringBuffer& sStrg ); + BASIC_DLLPRIVATE void StrRoundDigit( OUStringBuffer& sStrg, short nPos, sal_Bool& bOverflow ); + BASIC_DLLPRIVATE void StrRoundDigit( OUStringBuffer& sStrg, short nPos ); + BASIC_DLLPRIVATE void ParseBack( OUStringBuffer& sStrg, const OUString& sFormatStrg, + short nFormatPos ); +#ifdef _with_sprintf + // Methods for string conversion with sprintf(): + BASIC_DLLPRIVATE void InitScan( double _dNum ); + BASIC_DLLPRIVATE void InitExp( double _dNewExp ); + BASIC_DLLPRIVATE short GetDigitAtPosScan( short nPos, sal_Bool& bFoundFirstDigit ); + BASIC_DLLPRIVATE short GetDigitAtPosExpScan( double dNewExponent, short nPos, + sal_Bool& bFoundFirstDigit ); + BASIC_DLLPRIVATE short GetDigitAtPosExpScan( short nPos, sal_Bool& bFoundFirstDigit ); +#else + // Methods for direct 'calculation' with log10() and pow(): + BASIC_DLLPRIVATE short GetDigitAtPos( double dNumber, short nPos, double& dNextNumber, + sal_Bool& bFoundFirstDigit ); + BASIC_DLLPRIVATE short RoundDigit( double dNumber ); +#endif + BASIC_DLLPRIVATE OUString GetPosFormatString( const OUString& sFormatStrg, sal_Bool & bFound ); + BASIC_DLLPRIVATE OUString GetNegFormatString( const OUString& sFormatStrg, sal_Bool & bFound ); + BASIC_DLLPRIVATE OUString Get0FormatString( const OUString& sFormatStrg, sal_Bool & bFound ); + BASIC_DLLPRIVATE OUString GetNullFormatString( const OUString& sFormatStrg, sal_Bool & bFound ); + BASIC_DLLPRIVATE short AnalyseFormatString( const OUString& sFormatStrg, + short& nNoOfDigitsLeft, short& nNoOfDigitsRight, + short& nNoOfOptionalDigitsLeft, + short& nNoOfExponentDigits, + short& nNoOfOptionalExponentDigits, + sal_Bool& bPercent, sal_Bool& bCurrency, sal_Bool& bScientific, + sal_Bool& bGenerateThousandSeparator, + short& nMultipleThousandSeparators ); + BASIC_DLLPRIVATE void ScanFormatString( double dNumber, const OUString& sFormatStrg, + OUString& sReturnStrg, sal_Bool bCreateSign ); + + //*** Data *** + sal_Unicode cDecPoint; // sign for the decimal point + sal_Unicode cThousandSep; // sign for thousand delimiter + // Text for output: + OUString sOnStrg; + OUString sOffStrg; + OUString sYesStrg; + OUString sNoStrg; + OUString sTrueStrg; + OUString sFalseStrg; + OUString sCurrencyStrg; + OUString sCurrencyFormatStrg; + + //*** temporary data for scan loop *** + //----------------------------------------------- + // String containing the number in scientific format + OUString sSciNumStrg; + // String containing the exponent of the number + OUString sNumExpStrg; + double dNum; // the number that is scanned + short nNumExp; // the exponent of the number + short nExpExp; // the number of digits in the exponent +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/sbxmeth.hxx b/include/basic/sbxmeth.hxx new file mode 100644 index 000000000000..227c00cbad88 --- /dev/null +++ b/include/basic/sbxmeth.hxx @@ -0,0 +1,40 @@ +/* -*- 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 __SBX_SBXMETHOD_HXX +#define __SBX_SBXMETHOD_HXX + +#include <basic/sbxvar.hxx> +#include "basicdllapi.h" + +class BASIC_DLLPUBLIC SbxMethod : public SbxVariable +{ +public: + SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_METHOD,1); + TYPEINFO(); + SbxMethod( const OUString& r, SbxDataType t ); + SbxMethod( const SbxMethod& r ); + ~SbxMethod(); + SbxMethod& operator=( const SbxMethod& r ) { SbxVariable::operator=( r ); return *this; } + virtual SbxClassType GetClass() const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/sbxobj.hxx b/include/basic/sbxobj.hxx new file mode 100644 index 000000000000..2dc4aa735513 --- /dev/null +++ b/include/basic/sbxobj.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 _SBX_SBXOBJECT_HXX +#define _SBX_SBXOBJECT_HXX + +#include <svl/lstner.hxx> +#include <basic/sbxvar.hxx> +#include "basicdllapi.h" + + +class SbxProperty; + +class BASIC_DLLPUBLIC SbxObject : public SbxVariable, public SfxListener +{ + BASIC_DLLPRIVATE SbxArray* FindVar( SbxVariable*, sal_uInt16& ); +protected: + SbxArrayRef pMethods; // Methods + SbxArrayRef pProps; // Properties + SbxArrayRef pObjs; // Objects + SbxProperty* pDfltProp; // Default-Property + OUString aClassName; // Classname + OUString aDfltPropName; + virtual sal_Bool LoadData( SvStream&, sal_uInt16 ); + virtual sal_Bool StoreData( SvStream& ) const; + virtual ~SbxObject(); + virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, + const SfxHint& rHint, const TypeId& rHintType ); +public: + SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_OBJECT,1); + TYPEINFO(); + SbxObject( const OUString& rClassname ); + SbxObject( const SbxObject& ); + SbxObject& operator=( const SbxObject& ); + virtual SbxDataType GetType() const; + virtual SbxClassType GetClass() const; + virtual void Clear(); + + virtual sal_Bool IsClass( const OUString& ) const; + const OUString& GetClassName() const { return aClassName; } + void SetClassName( const OUString &rNew ) { aClassName = rNew; } + // Default-Property + SbxProperty* GetDfltProperty(); + void SetDfltProperty( const OUString& r ); + // Search for an element + virtual SbxVariable* FindUserData( sal_uInt32 nUserData ); + virtual SbxVariable* Find( const OUString&, SbxClassType ); + SbxVariable* FindQualified( const OUString&, SbxClassType ); + // Quick-Call-Interface for Methods + virtual sal_Bool Call( const OUString&, SbxArray* = NULL ); + // Execution of DDE-Commands + SbxVariable* Execute( const OUString& ); + // Manage elements + virtual sal_Bool GetAll( SbxClassType ) { return sal_True; } + SbxVariable* Make( const OUString&, SbxClassType, SbxDataType ); + virtual SbxObject* MakeObject( const OUString&, const OUString& ); + virtual void Insert( SbxVariable* ); + // AB 23.4.1997, Optimization, Insertion without check for duplicate Entries and + // without Broadcasts, only used in SO2/auto.cxx + void QuickInsert( SbxVariable* ); + virtual void Remove( const OUString&, SbxClassType ); + virtual void Remove( SbxVariable* ); + + // Macro-Recording + virtual OUString GenerateSource( const OUString &rLinePrefix, + const SbxObject *pRelativeTo ); + // Direct access on arrays + SbxArray* GetMethods() { return pMethods; } + SbxArray* GetProperties() { return pProps; } + SbxArray* GetObjects() { return pObjs; } + // Debugging + void Dump( SvStream&, sal_Bool bDumpAll=sal_False ); +}; + +SV_DECL_REF(SbxObject) +SV_IMPL_REF(SbxObject) + +#endif /* _SBX_SBXOBJECT_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/sbxprop.hxx b/include/basic/sbxprop.hxx new file mode 100644 index 000000000000..89d774d4967f --- /dev/null +++ b/include/basic/sbxprop.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 __SBX_SBXPROPERTY_HXX +#define __SBX_SBXPROPERTY_HXX + +#include <basic/sbxvar.hxx> +#include "basicdllapi.h" + +class BASIC_DLLPUBLIC SbxProperty : public SbxVariable +{ +public: + SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_PROPERTY,1); + TYPEINFO(); + SbxProperty( const OUString& r, SbxDataType t ); + SbxProperty( const SbxProperty& r ) : SvRefBase( r ), SbxVariable( r ) {} + virtual ~SbxProperty(); + SbxProperty& operator=( const SbxProperty& r ) + { SbxVariable::operator=( r ); return *this; } + virtual SbxClassType GetClass() const; +}; + +SV_DECL_REF(SbxProperty) +SV_IMPL_REF(SbxProperty) + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/sbxvar.hxx b/include/basic/sbxvar.hxx new file mode 100644 index 000000000000..4d4a8b625bc3 --- /dev/null +++ b/include/basic/sbxvar.hxx @@ -0,0 +1,356 @@ +/* -*- 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 SBXVAR_HXX +#define SBXVAR_HXX + +#include <rtl/ustring.hxx> +#include <com/sun/star/bridge/oleautomation/Decimal.hpp> +#include <basic/sbxcore.hxx> +#include "basicdllapi.h" + + +class SbxDecimal; + +struct SbxValues +{ + union { + sal_uInt8 nByte; + sal_uInt16 nUShort; + sal_Unicode nChar; + sal_Int16 nInteger; + sal_uInt32 nULong; + sal_Int32 nLong; + unsigned int nUInt; + int nInt; + sal_uInt64 uInt64; + sal_Int64 nInt64; + + float nSingle; + double nDouble; + + OUString* pOUString; + SbxDecimal* pDecimal; + + SbxBase* pObj; + + sal_uInt8* pByte; + sal_uInt16* pUShort; + sal_Unicode* pChar; + sal_Int16* pInteger; + sal_uInt32* pULong; + sal_Int32* pLong; + unsigned int* pUInt; + int* pInt; + sal_uInt64* puInt64; + sal_Int64* pnInt64; + + float* pSingle; + double* pDouble; + + void* pData; + }; + SbxDataType eType; + + SbxValues(): pData( NULL ), eType(SbxEMPTY) {} + SbxValues( SbxDataType e ): eType(e) {} + SbxValues( char _nChar ): nChar( _nChar ), eType(SbxCHAR) {} + SbxValues( sal_uInt8 _nByte ): nByte( _nByte ), eType(SbxBYTE) {} + SbxValues( short _nInteger ): nInteger( _nInteger ), eType(SbxINTEGER ) {} + SbxValues( long _nLong ): nLong( _nLong ), eType(SbxLONG) {} + SbxValues( sal_uInt16 _nUShort ): nUShort( _nUShort ), eType(SbxUSHORT) {} + SbxValues( sal_uIntPtr _nULong ): nULong( _nULong ), eType(SbxULONG) {} + SbxValues( int _nInt ): nInt( _nInt ), eType(SbxINT) {} + SbxValues( unsigned int _nUInt ): nUInt( _nUInt ), eType(SbxUINT) {} + SbxValues( float _nSingle ): nSingle( _nSingle ), eType(SbxSINGLE) {} + SbxValues( double _nDouble ): nDouble( _nDouble ), eType(SbxDOUBLE) {} + SbxValues( const OUString* _pString ): pOUString( (OUString*)_pString ), eType(SbxSTRING) {} + SbxValues( SbxBase* _pObj ): pObj( _pObj ), eType(SbxOBJECT) {} + SbxValues( sal_Unicode* _pChar ): pChar( _pChar ), eType(SbxLPSTR) {} + SbxValues( void* _pData ): pData( _pData ), eType(SbxPOINTER) {} + +}; + +class BASIC_DLLPUBLIC SbxValue : public SbxBase +{ + // #55226 Transport additional infos + BASIC_DLLPRIVATE SbxValue* TheRealValue( sal_Bool bObjInObjError ) const; + BASIC_DLLPRIVATE SbxValue* TheRealValue() const; +protected: + SbxValues aData; // Data + OUString aPic; // Picture-String + OUString aToolString; // tool string copy + + virtual void Broadcast( sal_uIntPtr ); // Broadcast-Call + virtual ~SbxValue(); + virtual sal_Bool LoadData( SvStream&, sal_uInt16 ); + virtual sal_Bool StoreData( SvStream& ) const; +public: + SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_VALUE,1); + TYPEINFO(); + SbxValue(); + SbxValue( SbxDataType, void* = NULL ); + SbxValue( const SbxValue& ); + SbxValue& operator=( const SbxValue& ); + virtual void Clear(); + virtual sal_Bool IsFixed() const; + + sal_Bool IsInteger() const { return sal_Bool( GetType() == SbxINTEGER ); } + sal_Bool IsLong() const { return sal_Bool( GetType() == SbxLONG ); } + sal_Bool IsSingle() const { return sal_Bool( GetType() == SbxSINGLE ); } + sal_Bool IsDouble() const { return sal_Bool( GetType() == SbxDOUBLE ); } + sal_Bool IsString() const { return sal_Bool( GetType() == SbxSTRING ); } + sal_Bool IsDate() const { return sal_Bool( GetType() == SbxDATE ); } + sal_Bool IsCurrency()const { return sal_Bool( GetType() == SbxCURRENCY ); } + sal_Bool IsObject() const { return sal_Bool( GetType() == SbxOBJECT ); } + sal_Bool IsDataObject()const{return sal_Bool( GetType() == SbxDATAOBJECT);} + sal_Bool IsBool() const { return sal_Bool( GetType() == SbxBOOL ); } + sal_Bool IsErr() const { return sal_Bool( GetType() == SbxERROR ); } + sal_Bool IsEmpty() const { return sal_Bool( GetType() == SbxEMPTY ); } + sal_Bool IsNull() const { return sal_Bool( GetType() == SbxNULL ); } + sal_Bool IsChar() const { return sal_Bool( GetType() == SbxCHAR ); } + sal_Bool IsByte() const { return sal_Bool( GetType() == SbxBYTE ); } + sal_Bool IsUShort() const { return sal_Bool( GetType() == SbxUSHORT ); } + sal_Bool IsULong() const { return sal_Bool( GetType() == SbxULONG ); } + sal_Bool IsInt() const { return sal_Bool( GetType() == SbxINT ); } + sal_Bool IsUInt() const { return sal_Bool( GetType() == SbxUINT ); } + sal_Bool IspChar() const { return sal_Bool( GetType() == SbxLPSTR ); } + sal_Bool IsNumeric() const; + sal_Bool IsNumericRTL() const; // #41692 Interface for Basic + sal_Bool ImpIsNumeric( bool bOnlyIntntl ) const; // Implementation + + virtual SbxClassType GetClass() const; + virtual SbxDataType GetType() const; + SbxDataType GetFullType() const; + sal_Bool SetType( SbxDataType ); + + virtual sal_Bool Get( SbxValues& ) const; + const SbxValues& GetValues_Impl() const { return aData; } + virtual sal_Bool Put( const SbxValues& ); + + inline SbxValues * data() { return &aData; } + + sal_Unicode GetChar() const; + sal_Int16 GetInteger() const; + sal_Int32 GetLong() const; + sal_Int64 GetInt64() const; + sal_uInt64 GetUInt64() const; + + sal_Int64 GetCurrency() const; + SbxDecimal* GetDecimal() const; + + float GetSingle() const; + double GetDouble() const; + double GetDate() const; + + sal_Bool GetBool() const; + const OUString& GetCoreString() const; + OUString GetOUString() const; + + SbxBase* GetObject() const; + sal_uInt8 GetByte() const; + sal_uInt16 GetUShort() const; + sal_uInt32 GetULong() const; + + sal_Bool PutInteger( sal_Int16 ); + sal_Bool PutLong( sal_Int32 ); + sal_Bool PutSingle( float ); + sal_Bool PutDouble( double ); + sal_Bool PutDate( double ); + sal_Bool PutBool( sal_Bool ); + sal_Bool PutErr( sal_uInt16 ); + sal_Bool PutStringExt( const OUString& ); // with extended analysis (International, "sal_True"/"sal_False") + sal_Bool PutInt64( sal_Int64 ); + sal_Bool PutUInt64( sal_uInt64 ); + sal_Bool PutString( const OUString& ); + sal_Bool PutChar( sal_Unicode ); + sal_Bool PutByte( sal_uInt8 ); + sal_Bool PutUShort( sal_uInt16 ); + sal_Bool PutULong( sal_uInt32 ); + sal_Bool PutEmpty(); + sal_Bool PutNull(); + + // Special methods + sal_Bool PutDecimal( com::sun::star::bridge::oleautomation::Decimal& rAutomationDec ); + sal_Bool PutDecimal( SbxDecimal* pDecimal ); // This function is needed for Windows build, don't remove + sal_Bool fillAutomationDecimal( com::sun::star::bridge::oleautomation::Decimal& rAutomationDec ); + sal_Bool PutCurrency( const sal_Int64& ); + // Interface for CDbl in Basic + static SbxError ScanNumIntnl( const OUString& rSrc, double& nVal, bool bSingle = false ); + + sal_Bool PutObject( SbxBase* ); + + virtual sal_Bool Convert( SbxDataType ); + virtual sal_Bool Compute( SbxOperator, const SbxValue& ); + virtual sal_Bool Compare( SbxOperator, const SbxValue& ) const; + sal_Bool Scan( const OUString&, sal_uInt16* = NULL ); + void Format( OUString&, const OUString* = NULL ) const; + + // The following operators are definied for easier handling. + // TODO: Ensure error conditions (overflow, conversions) + // are taken into consideration in Compute and Compare + + inline int operator ==( const SbxValue& ) const; + inline int operator !=( const SbxValue& ) const; + inline int operator <( const SbxValue& ) const; + inline int operator >( const SbxValue& ) const; + inline int operator <=( const SbxValue& ) const; + inline int operator >=( const SbxValue& ) const; + + inline SbxValue& operator *=( const SbxValue& ); + inline SbxValue& operator /=( const SbxValue& ); + inline SbxValue& operator %=( const SbxValue& ); + inline SbxValue& operator +=( const SbxValue& ); + inline SbxValue& operator -=( const SbxValue& ); + inline SbxValue& operator &=( const SbxValue& ); + inline SbxValue& operator |=( const SbxValue& ); + inline SbxValue& operator ^=( const SbxValue& ); +}; + +inline int SbxValue::operator==( const SbxValue& r ) const +{ return Compare( SbxEQ, r ); } + +inline int SbxValue::operator!=( const SbxValue& r ) const +{ return Compare( SbxNE, r ); } + +inline int SbxValue::operator<( const SbxValue& r ) const +{ return Compare( SbxLT, r ); } + +inline int SbxValue::operator>( const SbxValue& r ) const +{ return Compare( SbxGT, r ); } + +inline int SbxValue::operator<=( const SbxValue& r ) const +{ return Compare( SbxLE, r ); } + +inline int SbxValue::operator>=( const SbxValue& r ) const +{ return Compare( SbxGE, r ); } + +inline SbxValue& SbxValue::operator*=( const SbxValue& r ) +{ Compute( SbxMUL, r ); return *this; } + +inline SbxValue& SbxValue::operator/=( const SbxValue& r ) +{ Compute( SbxDIV, r ); return *this; } + +inline SbxValue& SbxValue::operator%=( const SbxValue& r ) +{ Compute( SbxMOD, r ); return *this; } + +inline SbxValue& SbxValue::operator+=( const SbxValue& r ) +{ Compute( SbxPLUS, r ); return *this; } + +inline SbxValue& SbxValue::operator-=( const SbxValue& r ) +{ Compute( SbxMINUS, r ); return *this; } + +inline SbxValue& SbxValue::operator&=( const SbxValue& r ) +{ Compute( SbxAND, r ); return *this; } + +inline SbxValue& SbxValue::operator|=( const SbxValue& r ) +{ Compute( SbxOR, r ); return *this; } + +inline SbxValue& SbxValue::operator^=( const SbxValue& r ) +{ Compute( SbxXOR, r ); return *this; } + +class SbxArray; +class SbxInfo; + +#ifndef SBX_ARRAY_DECL_DEFINED +#define SBX_ARRAY_DECL_DEFINED +SV_DECL_REF(SbxArray) +#endif + +#ifndef SBX_INFO_DECL_DEFINED +#define SBX_INFO_DECL_DEFINED +SV_DECL_REF(SbxInfo) +#endif + +class SfxBroadcaster; + +class SbxVariableImpl; +class StarBASIC; + +class BASIC_DLLPUBLIC SbxVariable : public SbxValue +{ + friend class SbMethod; + + SbxVariableImpl* mpSbxVariableImpl; // Impl data + SfxBroadcaster* pCst; // Broadcaster, if needed + OUString maName; // Name, if available + SbxArrayRef mpPar; // Parameter-Array, if set + sal_uInt16 nHash; // Hash-ID for search + + BASIC_DLLPRIVATE SbxVariableImpl* getImpl( void ); + +protected: + SbxInfoRef pInfo; // Probably called information + sal_uIntPtr nUserData; // User data for Call() + SbxObject* pParent; // Currently attached object + virtual ~SbxVariable(); + virtual sal_Bool LoadData( SvStream&, sal_uInt16 ); + virtual sal_Bool StoreData( SvStream& ) const; +public: + SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_VARIABLE,2); + TYPEINFO(); + SbxVariable(); + SbxVariable( SbxDataType, void* = NULL ); + SbxVariable( const SbxVariable& ); + SbxVariable& operator=( const SbxVariable& ); + + void Dump( SvStream&, sal_Bool bDumpAll=sal_False ); + + virtual void SetName( const OUString& ); + virtual const OUString& GetName( SbxNameType = SbxNAME_NONE ) const; + sal_uInt16 GetHashCode() const { return nHash; } + + virtual void SetModified( sal_Bool ); + + sal_uIntPtr GetUserData() const { return nUserData; } + void SetUserData( sal_uIntPtr n ) { nUserData = n; } + + virtual SbxDataType GetType() const; + virtual SbxClassType GetClass() const; + + // Parameter-Interface + virtual SbxInfo* GetInfo(); + void SetInfo( SbxInfo* p ); + void SetParameters( SbxArray* p ); + SbxArray* GetParameters() const; + + // Sfx-Broadcasting-Support: + // Due to data reduction and better DLL-hierarchie currently via casting + SfxBroadcaster& GetBroadcaster(); + sal_Bool IsBroadcaster() const { return sal_Bool( pCst != NULL ); } + virtual void Broadcast( sal_uIntPtr nHintId ); + + inline const SbxObject* GetParent() const { return pParent; } + SbxObject* GetParent(); + virtual void SetParent( SbxObject* ); + + const OUString& GetDeclareClassName( void ); + void SetDeclareClassName( const OUString& ); + void SetComListener( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xComListener, + StarBASIC* pParentBasic ); + void ClearComListener( void ); + + static sal_uInt16 MakeHashCode( const OUString& rName ); +}; + +SV_DECL_REF(SbxVariable) + +#endif // SBXVAR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/vbahelper.hxx b/include/basic/vbahelper.hxx new file mode 100644 index 000000000000..c18b67b63cd1 --- /dev/null +++ b/include/basic/vbahelper.hxx @@ -0,0 +1,99 @@ +/* -*- 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 BASIC_VBAHELPR_HXX +#define BASIC_VBAHELPR_HXX + +#include <com/sun/star/container/XEnumeration.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <rtl/ustring.hxx> +#include "basicdllapi.h" + +namespace basic { +namespace vba { + +/* This header contains public helper functions for VBA used from this module + and from other VBA implementation modules such as vbahelper. + */ + +// ============================================================================ + +/** Locks or unlocks the controllers of all documents that have the same type + as the specified document. + + First, the global module manager (com.sun.star.frame.ModuleManager) is + asked for the type of the passed model, and all open documents with the + same type will be locked or unlocked. + + @param rxModel + A document model determining the type of the documents to be locked or + unlocked. + + @param bLockControllers + Passing true will lock all controllers, passing false will unlock them. + */ +BASIC_DLLPUBLIC void lockControllersOfAllDocuments( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel, + sal_Bool bLockControllers ); + +// ============================================================================ + +/** Enables or disables the container windows of all controllers of all + documents that have the same type as the specified document. + + First, the global module manager (com.sun.star.frame.ModuleManager) is + asked for the type of the passed model, and the container windows of all + open documents with the same type will be enabled or disabled. + + @param rxModel + A document model determining the type of the documents to be enabled or + disabled. + + @param bEnableWindows + Passing true will enable all container windows of all controllers, + passing false will disable them. + */ +BASIC_DLLPUBLIC void enableContainerWindowsOfAllDocuments( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel, + sal_Bool bEnableWindows ); + +// ============================================================================ + +/** Registers the passed path as working directory for the application the + passed document belongs to. + + @param rxModel + A document model determining the type of the application whose working + directory has been changed. + + @param rPath + The new working directory. + */ +BASIC_DLLPUBLIC void registerCurrentDirectory( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel, + const OUString& rPath ); + +// ============================================================================ + +} // namespace vba +} // namespace basic + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |