2010-10-27 13:11:31 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-17 12:30:48 +01:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2007-04-11 11:52:47 +00:00
|
|
|
|
|
|
|
#ifndef _SB_SBMOD_HXX
|
|
|
|
#define _SB_SBMOD_HXX
|
|
|
|
|
2010-07-01 16:23:26 +02:00
|
|
|
#include <com/sun/star/script/XInvocation.hpp>
|
2007-04-11 11:52:47 +00:00
|
|
|
#include <basic/sbdef.hxx>
|
|
|
|
#include <basic/sbxobj.hxx>
|
|
|
|
#include <basic/sbxdef.hxx>
|
|
|
|
#include <rtl/ustring.hxx>
|
2010-07-05 13:58:36 +02:00
|
|
|
#include <vector>
|
2010-10-07 22:07:22 +02:00
|
|
|
#include <deque>
|
2011-08-05 16:54:24 +01:00
|
|
|
#include <boost/utility.hpp>
|
2011-07-28 18:17:31 +02:00
|
|
|
#include "basicdllapi.h"
|
2010-10-07 22:07:22 +02:00
|
|
|
|
2007-04-11 11:52:47 +00:00
|
|
|
class SbMethod;
|
|
|
|
class SbProperty;
|
|
|
|
class SbiRuntime;
|
2011-01-10 14:40:57 +01:00
|
|
|
typedef std::deque< sal_uInt16 > SbiBreakpoints;
|
2007-04-11 11:52:47 +00:00
|
|
|
class SbiImage;
|
|
|
|
class SbProcedureProperty;
|
|
|
|
class SbIfaceMapperMethod;
|
2010-06-15 20:02:53 +02:00
|
|
|
class SbClassModuleObject;
|
2007-04-11 11:52:47 +00:00
|
|
|
|
2010-09-02 09:04:11 +02:00
|
|
|
class ModuleInitDependencyMap;
|
2010-08-05 11:52:07 +02:00
|
|
|
struct ClassModuleRunInitItem;
|
2007-04-11 11:52:47 +00:00
|
|
|
struct SbClassData;
|
|
|
|
|
2011-08-05 16:54:24 +01:00
|
|
|
class BASIC_DLLPUBLIC SbModule : public SbxObject, private ::boost::noncopyable
|
2007-04-11 11:52:47 +00:00
|
|
|
{
|
|
|
|
friend class SbiCodeGen;
|
|
|
|
friend class SbMethod;
|
|
|
|
friend class SbiRuntime;
|
|
|
|
friend class StarBASIC;
|
|
|
|
friend class SbClassModuleObject;
|
|
|
|
|
2010-07-05 13:58:36 +02:00
|
|
|
std::vector< String > mModuleVariableNames;
|
2007-04-11 11:52:47 +00:00
|
|
|
|
2011-07-28 18:17:31 +02:00
|
|
|
BASIC_DLLPRIVATE void implClearIfVarDependsOnDeletedBasic( SbxVariable* pVar, StarBASIC* pDeletedBasic );
|
2010-09-21 08:58:34 +02:00
|
|
|
|
2007-04-11 11:52:47 +00:00
|
|
|
protected:
|
2010-07-01 16:23:26 +02:00
|
|
|
com::sun::star::uno::Reference< com::sun::star::script::XInvocation > mxWrapper;
|
2009-04-25 00:18:20 +00:00
|
|
|
::rtl::OUString aOUSource;
|
|
|
|
String aComment;
|
|
|
|
SbiImage* pImage; // the Image
|
|
|
|
SbiBreakpoints* pBreaks; // Breakpoints
|
|
|
|
SbClassData* pClassData;
|
2012-04-20 20:01:54 +01:00
|
|
|
bool mbVBACompat;
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_Int32 mnType;
|
2010-03-02 12:39:31 +00:00
|
|
|
SbxObjectRef pDocObject; // an impl object ( used by Document Modules )
|
|
|
|
bool bIsProxyModule;
|
2007-04-11 11:52:47 +00:00
|
|
|
|
2010-09-02 09:04:11 +02:00
|
|
|
static void implProcessModuleRunInit( ModuleInitDependencyMap& rMap, ClassModuleRunInitItem& rItem );
|
2007-04-11 11:52:47 +00:00
|
|
|
void StartDefinitions();
|
|
|
|
SbMethod* GetMethod( const String&, SbxDataType );
|
|
|
|
SbProperty* GetProperty( const String&, SbxDataType );
|
|
|
|
SbProcedureProperty* GetProcedureProperty( const String&, SbxDataType );
|
|
|
|
SbIfaceMapperMethod* GetIfaceMapperMethod( const String&, SbMethod* );
|
2011-01-10 14:40:57 +01:00
|
|
|
void EndDefinitions( sal_Bool=sal_False );
|
|
|
|
sal_uInt16 Run( SbMethod* );
|
2007-04-11 11:52:47 +00:00
|
|
|
void RunInit();
|
|
|
|
void ClearPrivateVars();
|
2010-09-21 08:58:34 +02:00
|
|
|
void ClearVarsDependingOnDeletedBasic( StarBASIC* pDeletedBasic );
|
2012-09-07 04:59:11 +09:00
|
|
|
void GlobalRunInit( bool bBasicStart ); // for all modules
|
2007-04-11 11:52:47 +00:00
|
|
|
void GlobalRunDeInit( void );
|
2011-01-10 14:40:57 +01:00
|
|
|
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();
|
2007-04-11 11:52:47 +00:00
|
|
|
virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
|
|
|
|
const SfxHint& rHint, const TypeId& rHintType );
|
2010-08-23 10:54:49 +02:00
|
|
|
void handleProcedureProperties( SfxBroadcaster& rBC, const SfxHint& rHint );
|
2007-04-11 11:52:47 +00:00
|
|
|
virtual ~SbModule();
|
|
|
|
public:
|
|
|
|
SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_BASICMOD,2);
|
|
|
|
TYPEINFO();
|
2011-01-10 14:40:57 +01:00
|
|
|
SbModule( const String&, sal_Bool bCompat = sal_False );
|
2007-04-11 11:52:47 +00:00
|
|
|
virtual void SetParent( SbxObject* );
|
|
|
|
virtual void Clear();
|
|
|
|
|
2012-07-20 09:54:40 +01:00
|
|
|
virtual SbxVariable* Find( const rtl::OUString&, SbxClassType );
|
2007-04-11 11:52:47 +00:00
|
|
|
|
|
|
|
virtual const String& GetSource() const;
|
|
|
|
const ::rtl::OUString& GetSource32() const;
|
|
|
|
const String& GetComment() const { return aComment; }
|
|
|
|
virtual void SetSource( const String& r );
|
|
|
|
void SetSource32( const ::rtl::OUString& r );
|
|
|
|
|
2011-01-10 14:40:57 +01:00
|
|
|
virtual sal_Bool Compile();
|
|
|
|
virtual sal_Bool IsCompiled() const;
|
2007-04-11 11:52:47 +00:00
|
|
|
const SbxObject* FindType( String aTypeName ) const;
|
|
|
|
|
2011-01-10 14:40:57 +01:00
|
|
|
virtual sal_Bool IsBreakable( sal_uInt16 nLine ) const;
|
2010-10-07 22:07:22 +02:00
|
|
|
virtual size_t GetBPCount() const;
|
2011-01-10 14:40:57 +01:00
|
|
|
virtual sal_uInt16 GetBP( size_t n ) const;
|
|
|
|
virtual sal_Bool IsBP( sal_uInt16 nLine ) const;
|
|
|
|
virtual sal_Bool SetBP( sal_uInt16 nLine );
|
|
|
|
virtual sal_Bool ClearBP( sal_uInt16 nLine );
|
2007-04-11 11:52:47 +00:00
|
|
|
virtual void ClearAllBP();
|
|
|
|
|
2009-04-25 00:18:20 +00:00
|
|
|
// Lines of Subs
|
2011-01-10 14:40:57 +01:00
|
|
|
virtual SbMethod* GetFunctionForLine( sal_uInt16 );
|
2007-04-11 11:52:47 +00:00
|
|
|
|
|
|
|
// Store only image, no source (needed for new password protection)
|
2011-01-10 14:40:57 +01:00
|
|
|
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();
|
2007-04-11 11:52:47 +00:00
|
|
|
void fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg = NULL ) const;
|
2010-10-06 10:16:27 +01:00
|
|
|
bool HasExeCode();
|
2012-04-20 20:01:54 +01:00
|
|
|
bool IsVBACompat() const;
|
|
|
|
void SetVBACompat( bool bCompat );
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_Int32 GetModuleType() { return mnType; }
|
|
|
|
void SetModuleType( sal_Int32 nType ) { mnType = nType; }
|
2010-08-05 11:52:07 +02:00
|
|
|
bool isProxyModule() { return bIsProxyModule; }
|
2010-07-05 13:58:36 +02:00
|
|
|
void AddVarName( const String& aName );
|
2010-07-27 17:12:01 +02:00
|
|
|
void RemoveVars();
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > GetUnoModule();
|
2010-06-15 20:02:53 +02:00
|
|
|
bool createCOMWrapperForIface( ::com::sun::star::uno::Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject );
|
2007-04-11 11:52:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
SV_DECL_IMPL_REF(SbModule)
|
|
|
|
|
|
|
|
// Object class for instances of class modules
|
2011-07-28 18:17:31 +02:00
|
|
|
class BASIC_DLLPUBLIC SbClassModuleObject : public SbModule
|
2007-04-11 11:52:47 +00:00
|
|
|
{
|
|
|
|
SbModule* mpClassModule;
|
|
|
|
bool mbInitializeEventDone;
|
|
|
|
|
|
|
|
public:
|
|
|
|
TYPEINFO();
|
|
|
|
SbClassModuleObject( SbModule* pClassModule );
|
|
|
|
~SbClassModuleObject();
|
|
|
|
|
2009-04-25 00:18:20 +00:00
|
|
|
// Overridden to support NameAccess etc.
|
2012-07-20 09:54:40 +01:00
|
|
|
virtual SbxVariable* Find( const rtl::OUString&, SbxClassType );
|
2007-04-11 11:52:47 +00:00
|
|
|
|
|
|
|
virtual void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& );
|
|
|
|
|
|
|
|
SbModule* getClassModule( void )
|
|
|
|
{ return mpClassModule; }
|
|
|
|
|
|
|
|
void triggerInitializeEvent( void );
|
|
|
|
void triggerTerminateEvent( void );
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2010-10-27 13:11:31 +01:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|