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
|
|
|
|
2013-10-23 19:18:27 +02:00
|
|
|
#ifndef INCLUDED_BASIC_SBMOD_HXX
|
|
|
|
#define INCLUDED_BASIC_SBMOD_HXX
|
2007-04-11 11:52:47 +00:00
|
|
|
|
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>
|
2013-11-09 13:29:54 -06:00
|
|
|
#include <basic/basicdllapi.h>
|
2013-07-19 22:00:29 +02:00
|
|
|
#include <basic/codecompletecache.hxx>
|
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
|
|
|
|
GSOC work week 2, getting infromation from variables and print on terminal
This is an early version. I use the BASIC parser to parse the source,
then the infromation is extracted from the symbol table built by parser.
Error reporting is suppressed, beacuse it is not needed fro code completition.
I placed my function inside SbModule, and created a struct called CodeCompletitionData, which holds the object's name, it's parent, and it's type name.
This function, SbMethod::GetCodeCompleteDataFromParse() is called from Basic IDE's Notify function, which updates a cache(actually, reassigns a viariable :) ).
Later, in the EditorWindow::KeyInput function there is a check wheteher dot key is pressed. After that, the actual variable (or word) is being looked up in the vector that holds code completition data. And finally, if it is found, it's methods are printed on the terminal.
Change-Id: Idaf19baa8f720b8b117a76dc3cc2f90dd04fd155
2013-06-21 14:10:31 +02: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;
|
|
|
|
|
2012-11-06 23:34:23 -06:00
|
|
|
std::vector< OUString > 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;
|
2012-11-06 23:34:23 -06:00
|
|
|
OUString aOUSource;
|
|
|
|
OUString aComment;
|
2009-04-25 00:18:20 +00:00
|
|
|
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();
|
2012-11-06 23:34:23 -06:00
|
|
|
SbMethod* GetMethod( const OUString&, SbxDataType );
|
|
|
|
SbProperty* GetProperty( const OUString&, SbxDataType );
|
|
|
|
SbProcedureProperty* GetProcedureProperty( const OUString&, SbxDataType );
|
|
|
|
SbIfaceMapperMethod* GetIfaceMapperMethod( const OUString&, SbMethod* );
|
2011-01-10 14:40:57 +01:00
|
|
|
void EndDefinitions( sal_Bool=sal_False );
|
2012-11-03 09:07:25 -05:00
|
|
|
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 );
|
2012-11-03 09:07:25 -05: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;
|
2011-01-10 14:40:57 +01:00
|
|
|
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();
|
2012-11-06 23:34:23 -06:00
|
|
|
SbModule( const OUString&, sal_Bool bCompat = sal_False );
|
2007-04-11 11:52:47 +00:00
|
|
|
virtual void SetParent( SbxObject* );
|
|
|
|
virtual void Clear();
|
|
|
|
|
2012-11-06 23:34:23 -06:00
|
|
|
virtual SbxVariable* Find( const OUString&, SbxClassType );
|
2007-04-11 11:52:47 +00:00
|
|
|
|
2012-11-06 23:34:23 -06:00
|
|
|
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 );
|
2007-04-11 11:52:47 +00:00
|
|
|
|
2012-11-06 23:34:23 -06:00
|
|
|
virtual sal_Bool Compile();
|
|
|
|
virtual sal_Bool IsCompiled() const;
|
|
|
|
const SbxObject* FindType( OUString aTypeName ) const;
|
2007-04-11 11:52:47 +00:00
|
|
|
|
2012-11-03 09:07:25 -05:00
|
|
|
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();
|
2007-04-11 11:52:47 +00:00
|
|
|
|
|
|
|
// Store only image, no source (needed for new password protection)
|
2012-11-03 09:07:25 -05:00
|
|
|
sal_Bool StoreBinaryData( SvStream& );
|
|
|
|
sal_Bool StoreBinaryData( SvStream&, sal_uInt16 nVer );
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_Bool LoadBinaryData( SvStream&, sal_uInt16 nVer );
|
|
|
|
sal_Bool LoadBinaryData( SvStream& );
|
|
|
|
sal_Bool ExceedsLegacyModuleSize();
|
2012-11-03 09:07:25 -05:00
|
|
|
void fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg = NULL ) const;
|
|
|
|
bool HasExeCode();
|
|
|
|
bool IsVBACompat() const;
|
|
|
|
void SetVBACompat( bool bCompat );
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_Int32 GetModuleType() { return mnType; }
|
2012-11-06 23:34:23 -06:00
|
|
|
void SetModuleType( sal_Int32 nType ) { mnType = nType; }
|
|
|
|
bool isProxyModule() { return bIsProxyModule; }
|
|
|
|
void AddVarName( const OUString& aName );
|
|
|
|
void RemoveVars();
|
2010-07-27 17:12:01 +02:00
|
|
|
::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 );
|
2013-07-24 17:27:02 +02:00
|
|
|
void GetCodeCompleteDataFromParse(CodeCompleteDataCache& aCache);
|
2013-07-07 19:43:05 +02:00
|
|
|
SbxArrayRef GetMethods();
|
2013-08-13 18:11:26 +02:00
|
|
|
OUString GetKeywordCase( const OUString& sKeyword ) const;
|
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-11-06 23:34:23 -06:00
|
|
|
virtual SbxVariable* Find( const 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: */
|