Impl. priorities:
    + Start tackling test/macro/interaction.
    + Object API impl.:
        + Range.Cells()
	+ Range.Offset()
	+ Worksheet.Cells()
	+ Range.Select()
	+ Range("<sheet name>")
	+ Range.Interior....
	+ Application.Selection
	+ Worksheet.Activate

TODO (thinking):
    + TOREAD:
	+ extensions/source/ole/*
    	+ extensions/test/ole/OleClient/clientTest.cxx#507
		+ Property with argument - a nice key ...
    + More elegant hooks
	+ we should prolly hook through the XHierarchicalNameAccess
	  service 'theCoreReflection', cf. sbunoobj.cxx /SbUnoFactory/
	  sb.cxx /AddFactory/ 
    + Page 96: 'Excel 2000 VBA'
	+ It is legal to have '[A1]' which evaluates to a 'Range'
	  via the 'Evaluate' method of 'Application'.
	+ We get pObj->Find("A1") called on the relevant object
	  ie. we should be able to trap it there ...
	+ Falls through to 'XNameAccess' - returns an Any.
	    + Problem is: this adds 'A1' to the global
	      namespace; not just for '[A1]' - a special case (!?)
			 ./sbx/sbxexec.cxx:116:  if( *p == '[' )
			 ./sbx/sbxexec.cxx:152:  if( aCharClass.isAlpha( *p ) || *p == '_' || *p == '[' )
			 ./sbx/sbxexec.cxx:410:          if( *p++ != '[' )
				+ interesting 'Element'->Symbol->QualifiedName etc.
			 ./comp/scanner.cxx:424: else if( *pLine == '"' || *pLine == '[' )
			 ./comp/scanner.cxx:427:         if( cSep == '[' )
	+ Ping maint. wrt. compatibility.
		

    + What about 'WorkSheets("Jim")' ?
	+ Via XNameAccess - I think. (or PropertyBag ?)
    + What about Range("A1") = 23.7 (ie. no Values access)
	+ Perhaps '23.7' is converted to a parameter ? Range("A1", 23.7) ?
	+ How would the data get set back again ?
	    + PropertyBag (- polluting the namespace-)
		[ pwrt. named ranges etc. ]
	    + audit list of interfaces used in basic at EOF
	+ What is SbxObject::GetDfltProperty ?
	    + seemingly unused except in automation tests.
	    + used in sbxvalue.cxx - 'TheRealValue' etc.
		+ with that set we can do:
		       Dim val As long
		       val = sheet.Range("A1")
	    + [ We may need an XVBATweaks interface:
		    + specifying the default property 'Value' for
		      Application & Range ]
	    + The 'Item' property is the 'default property' (or method?)
	      of Range: Cells(2,2) vs. Cells.Item(2,2)

	    + can the default property help us with casting ?
	+ a byref return value (?)
		+ [ add an implicit '.Value' query ? ]
	+ is the 'Evaluate' method - part of the explanation here ?
	+ svtools/inc/smplhint.hxx - SFX_HINT_DATACHANGED etc.
	+ basic/source/runtime/step0 StepSET_Impl - seems to
	  allow only SbxARRAY goodness ...
		StepSET_Impl refval '' refvar 'Range'
		not the right types error 2 9
	+ Can the parser tell ?
	    + SbiParser::Symbol 
	+ SbProcedureProperty
	    + no UNO wrapping.
	    + exported globally from basic/inc/sbprop.hxx
	    + seems to be for Basic-implemented proceedures.

    + Examine other special-cased interfaces:
	+ runtime/step2.cxx:477: Reference< XIndexAccess > ...
	+ runtime/runtime.cxx:1046: Reference< XEnumerationAccess > 
	+ classes/propacc.cxx:129: Reference< XPropertySetInfo > etc.
	+ other instances of 'SbUnoObject' etc.
    + create an object/declaration story:
	+ Dim a As Range
	+ FIXME: need to read up on how namespaces are
	  handled, wrt. Dim A as com.sun.star.sheet.Worksheet
	  etc. - possibly we can just do some 'Globals' magic
	  here.
    + Improve hooks into StarBASIC
	not using 'ThisComponent' anymore =>
	    can remove that & use something more native ?
    + collection objects; Worksheets, Workbooks etc.

* NonProblems:
    + 'For Each wbk in Workbooks' vs. Application.Workbooks.Index(n)
	+ We have to export the 'XEnumerationAccess' interface to let
	  StarBasic iterate over the items ...
    + Arguments issue
	+ 99% solved with the 'compatibility' mode turned on
	    + not combat/coding complete: some Anys are
	      not optional.
    + Named arguments work well:
	+ We need to get the argument names right in the IDL though
    + polymorphic constructor story
	+ Range("A1:B2"), Range(Cell(1,1), Cell(3,5));
	+ Range just takes 2 Variants
	    + interestingly 1 is optional, 1 is not.
    + ActiveWorkbook.Close <- really a 3 argument method

* VBA compatibility thoughts:

    + Basic types
    + Syntactic issues
    + Annoyances
    + Global objects
    + Object model 


* Basic types
#    + missing 'Date' type
	
	+ types manipulation:
	+ script/basic/source/classes/sb.cxx
		+ class SbTypeFactory
	+ script/basic/source/classes/sbunoobj.cxx
		+ types conversion
	+ svtools/inc/sbxdef.hxx
		+ defines data types (SbxDataType)
	+ svtools/source/sbx/
		+ sbx types implementation
		+ SbxDATE is a 'Date' type
		+ ./sbxdate.cxx
			+ handles 'Date' type
		+ should we add types here?
		
* Syntactic issues
	+ StarBasic - very global keywords cf. tokenizer
	+ do we tolerate eg. 'Option' as a method
	    + does MS.
    + Investigate operators: ':=' vs. '=' eg.

	+ Syntactic manipulation
	+ script/basic/source/classes/sbxmod.cxx
		+ Keywords list and tokenizer class
	+ script/basic/source/comp/parser.cxx
		+ defines statements functions
		+ implements the parser
		+ should add more statements?
	+ script/basic/source/comp/
		+ implements statements functions
		+ compiler implementation

* Annoyances
    + lots of errors on load cause massive dialog spewage
	+ extremely annoying.

* Global objects

    + Should we just hook off the global / ThisComponent object ?
      and slave to that ? (slower?)
    + mybasic.cxx Insert( (SbxObject*)xSbUnoObj ) - global ?
	    + sb.cxx ?

    + VBA has _lots_ of global / implicit objects

    + StarBasic seems to have 1: 'ThisComponent' / 'StarDesktop'
	+ ThisComponent usage / setup:
	    + framework/sfx2/source/appl/appbas.cxx	    x1
	    + framework/sfx2/source/control/macrconf.cxx    x4
	    + framework/sfx2/source/appl/appuno.cxx	    x6
	    + framework/sfx2/source/doc/objxtor.cxx	    x5
	    + framework/sfx2/source/doc/sfxbasemodel.cxx    x4
	    + script/basic/source/classes/eventatt.cxx	    x1
	    + sw/sw/source/ui/wizard/wizgo3.cxx		    x1
	+ StarDesktop usage / setup
		+ framework/sfx2/source/appl/appbas.cxx     x1
		+ framework/sfx2/source/control/macrconf.cxx    x1

    + 'ThisComponent' / 'StarDesktop' manipulation:
	+ appuno.cxx (loadMacro)
	    + push/pop 'ThisComponent'
		       + for load time method emission.
	+ macrconf.cxx (ExecuteMacro)
	    + push/pop 'ThisComponent'
	+ macrconf.cxx (CheckMacro)
		+ checks macros libraries, including 'StarDesktop'
		+ checks for macro errors like NO_METHOD
	+ appbas.cxx (GetBasicManager)
	    + sets global variables - library bits etc.
	      including 'ThisComponent' & 'Desktop'
		pBas->Insert(unoObj)
		(StarBASIC *pBas: pImp->pBasicMgr->GetLib(0))
	+ objxtor.cxx (InitBasicManager_Impl)
	    + create BasicManager, init 'ThisComponent'
		+ very similar to (GetBasicManager!?)
	+ objxtor.cxx (SfxObjectShell:SetWorkingDocument)
	    + sets ThisComponent nasty global variable
	    + GetWorkingDocument returns it ...
	+ sfxbasemodel.cxx (dispose)
	    + unsets global 'ThisComponent' if it is us.
	+ script/basic/source/classes/eventatt.cxx
	    + missing in OOO_1_1_1
	+ sw/sw/source/ui/wizard/wizgo3.cxx
	    + auto-creates a macro used in 


	+ Should be able to do all this off
	  the 'ThisComponent' (surely?)
	+ Global objects
	    + Selection
	    + ActiveCell
	    + WorksheetFunction.<ws fns>
	+ Global functions
	    + Range("")

	+ StarBasic Global function and property manipulation
	+ script/basic/source/runtime/stdobj.cxx
		+ defines globals functions and properties
		+ add here new global functions ?
		+ should add here Range("") function ?
	+ script/basic/source/runtime/props.cxx
		+ implements globals properties
	+ script/basic/source/runtime/methods.cxx
		+ implements most of globals functions
	+ script/basic/source/runtime/methods1.cxx
		+ implements remaining globals functions 
		
	+ svtools/inc/sbxobj.hxx, sbxvar.hxx
	    + interestingly SbxValue has a Date type. **
	    + SbxVariable has a 'Get/Set' UserData
	      method pair [ UINT32 !? ]

	+ Need to pass context through execution - somehow,
	  'This Sheet', 'This Workbook' etc.
		SbxStar::Insert / Remove.
		SbxObjectRef xUnoObj = GetSbUnoObject( DEFINE_CONST_UNICODE("ThisComponent"), aAny );
	+ Do this in interpr4.cxx (ScMacro) ?


* Object model
    + we need to expose these things as Objects in the full sense,
    + or - at least, expose a load of 'typedef Range Object'
      type things - everything constructed via a factory anyway (!?)

--------------------------------------------------------------------------------------------
sfx2/source/appl/appbas.cxx 
	+ SfxApplication::GetBasicManager()
		now gets the BasicManager thru GetAppBasicManager()
			[GetSbData()->pAppBasMgr]

basic/source/basmgr/basmgr.cxx
	+ BasicManager class

basic/source/classes/sbintern.cxx
	+ defines SbiGlobals
	    which has:
		-SbiInstance* pInst - all active run time instances
		-SbiFactory* pSbFac - StarBASIC Factory
		-SbUnoFactory*	pUnoFac	- Factory for UN Structs with DIM AS NEW ONE ??
		-SbTypeFactory*	pTypeFac - Factory for user defined types
		-SbClassFactory* pClassFac - Factory for user defined classes 
						(based on class modules)
		-SbOLEFactory* pOLEFac - Factory for OLE types
		-SbModule* pMod - Up-to-date active module
		-SbModule* pCompMod - Up-to-date compiled modules
		-short	nInst - Number of BASICs
		-Link	aErrHdl - global Error-Handler
		-Link	aBreakHdl - globaler Break-Handler
		-SbError nCode - current error code
		-xub_StrLen nLine - current line
		-xub_StrLen nCol1,nCol2 - current columns (of, to)
		-BOOL bCompiler - Flag for compiler error
		-BOOL bGlobalInitErr - With the GlobalInit a compiler error arose
		-BOOL bRunInit - TRUE, if RunInit of the basic is active
		-String aErrMsg - Buffer for GetErrorText()
		-SbLanguageMode	eLanguageMode - Flag for Visual basic Script mode
		-SbErrorStack* pErrStack - Stack for the in the event of an error diminished 										SbiRuntime chain ??
    		-::utl::TransliterationWrapper* pTransliterationWrapper - For StrComp
		-BOOL bBlockCompilerError;
    		-BasicManager* pAppBasMgr;


basic/source/classes/sb.cxx
	+ class StarBASIC
	+ sbClassFactory
	     Factory class to create class objects (type command) ?

Some Misc ramblings on experience debugging starBasic wrt. Collections impl, 
Default Method/properties
===============================================================================
e.g. 

a) Worksheets("sheet1") or

b)
myObj = Worksheets
myObj("sheets") ' simulates Worksheetss passed as arg to sub/func

Refering to Worksheets("sheet1") as a globally accessable function should be 
possible presently with the api if Workbooks is defined as a method like
any Worksheets(any index). Similarly for Workbooks

so Worksheets() should return a ref the XWorkSheets ref and
Worksheets("sheet1") should return a XWorkSheet ref for the named sheet

from some experimentation verified the following code works for the present api impl

uno::Any
ScVbaWorkbook::Worksheets( const ::uno::Any &rSheet ) throw (uno::RuntimeException)
{
        uno::Any result;
        if ( rSheet.getValueType() == ::getCppuVoidType() )
        {
                uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( mxModel, uno::UNO_QUERY );
                uno::Reference<sheet::XSpreadsheets> xSheets = xSpreadDoc->getSheets();

                result <<=  uno::Reference< vba::XWorksheets >( new ScVbaWorksheets(m_xContext,
                xSheets) );
        }
        else
        {
			// Try and extract string
			// find sheet by name and return uno::Reference< vba::XWorksheet >
		}
}

Note: the impl probably should call Item on the XWorksheets instance when a 
string is passed in. XCollection should change the spec for Item from

any  Item( [in] long Index )

and the implementation should do the appropriate checks on type e.g. string or
number ( so WorkSheets("sheet1") or WorkSheets(1) would both be valid )

Caution: AFAIR oobasic will transfer a number index to the smallest type it
fit it in so 1 -> probably will get passed as a byte to Item so care needed 
when looking at value type of Any ( maybe the << operator handles the 
convertion, need to check ).


Default Property/Method
=========================

The only way to support something like case b) above (it seems ) is by modifying
 the pcode emitted by the basic compiler.

* Some Notes where the byte code comes from and where its handled

All code in a module is compiled at some stage ( regardless of pressing the
compile button from the IDE, some stale detection is in place somewhere that
forces a recompile when the source had been changed )

code is compiled to pCode ( or pointer code ) meaning the op codes emitted as
a result of the compile can be translated into static function calls.

    * pCode is stored in and SbiImage class ( see other basic/notes re.
      token.cxx, parser.cxx that are already in this doc )
      loaded in basic/source/classed/image.cxx:150 ( ish ) 

	* image is obtained by instance of SbiRuntime from the SbModule ptr passed
      to its ctor from Module::Run() in 
      SbModule::Run( SbMethod* pMeth ) source/classes/sbxmod.cxx:777
      Note: SbiInstance represents a stack level for recursion support
      you can see the call levels being counted in the Run method

The static function calls that the pCode represents are part of the SbiRuntime 
class ( basic/source/runtime/runtime.cxx ). There are three types of functions;
   * those that take no param
   * those that take one param	
   * those that take two params
aStep0, aStep1, aStep2 respectively

Example 1.
==========

example pCode for  

Line 1	Sub Main
Line 2	msgbox("blaa")
Line 3	End Sub

format of o/p below

pCodeTable[ opCode/offset ] function ( params )

aStep2[ 135 ] SbiRuntime::StepSTMNT (2, 0)
aStep0[ 24 ] SbiRuntime::StepARGC
aStep1[ 65 ] SbiRuntime::StepLOADSC (11)
aStep0[ 25 ] SbiRuntime::StepARGV
aStep2[ 128 ] SbiRuntime::StepRTL (32780, 2)
aStep0[ 28 ] SbiRuntime::StepGET
aStep2[ 135 ] SbiRuntime::StepSTMNT (3, 0)
aStep0[ 43 ] SbiRuntime::StepLEAVE
aStep0[ 0 ] SbiRuntime::StepNOP

Example 2.
==========

Line 1	Sub Main
Line 2	thiscomponent("blaa")
Line 3	End Sub

aStep2[ 135 ] SbiRuntime::StepSTMNT (2, 0)
aStep0[ 24 ] SbiRuntime::StepARGC
aStep1[ 65 ] SbiRuntime::StepLOADSC (11)
aStep0[ 25 ] SbiRuntime::StepARGV
aStep2[ 129 ] SbiRuntime::StepFIND (32780, 0)
aStep0[ 28 ] SbiRuntime::StepGET
aStep2[ 135 ] SbiRuntime::StepSTMNT (3, 0)
aStep0[ 43 ] SbiRuntime::StepLEAVE
aStep0[ 0 ] SbiRuntime::StepNOP

interestingly this doesn't cause an error, however a little bit of 
dereferencing seems to kick in an error

Example 3.
==========

Line 1	Sub Main
Line 2	obj=thiscomponent("blaa")
Line 3	thiscomponent("blaa")
Line 4	End Sub

aStep2[ 135 ] SbiRuntime::StepSTMNT (1, 0)
aStep2[ 135 ] SbiRuntime::StepSTMNT (2, 0)
aStep2[ 129 ] SbiRuntime::StepFIND (11, 12)
aStep2[ 129 ] SbiRuntime::StepFIND (12, 12)
aStep0[ 30 ] SbiRuntime::StepPUT
aStep2[ 135 ] SbiRuntime::StepSTMNT (3, 0)
aStep0[ 24 ] SbiRuntime::StepARGC
aStep1[ 65 ] SbiRuntime::StepLOADSC (13)
aStep0[ 25 ] SbiRuntime::StepARGV
aStep2[ 129 ] SbiRuntime::StepFIND (32779, 12)
aStep0[ 28 ] SbiRuntime::StepGET
** aStep2[ 135 ] SbiRuntime::StepSTMNT (4, 0)
aStep0[ 43 ] SbiRuntime::StepLEAVE
aStep0[ 0 ] SbiRuntime::StepNOP


occurs at ** above in
basic/source/runtime/step2.cxx:716
which interstingly has a comment associated which translates as 

"If the Expr stack at the beginning contains statement a variable, 
 a nincompoop called X as function, although it is a variable!"

After alot of wasted effort I couldn't twist this into doing what was
required, I realised too late that when this is detected its too late and its 
gone past the point where we can process. The STMNT function where this
is detected is the next statement after the "real statement". Looking more
closely this StepSTMNT relatets to the line "end sub" and not the line for 
"obj("blaa")". So basically at this point the symantic info required is gone


Interestingly defining a func that doesn't exist seems to be caught somewhere else ( in the StepFind, but I suppose that makes sense 'cause it doesn't 
know about obj )

Example 4.
==========

Line 1	Sub Main
Line 2	obj("blaa")
Line 3	End Sub

aStep2[ 135 ] SbiRuntime::StepSTMNT (1, 0)
aStep2[ 135 ] SbiRuntime::StepSTMNT (2, 0)
aStep2[ 129 ] SbiRuntime::StepFIND (11, 12)
aStep2[ 129 ] SbiRuntime::StepFIND (12, 12)
aStep0[ 30 ] SbiRuntime::StepPUT
aStep2[ 135 ] SbiRuntime::StepSTMNT (3, 0)
aStep0[ 24 ] SbiRuntime::StepARGC
aStep1[ 65 ] SbiRuntime::StepLOADSC (13)
aStep0[ 25 ] SbiRuntime::StepARGV
** aStep2[ 129 ] SbiRuntime::StepFIND (32782, 0) 
aStep0[ 28 ] SbiRuntime::StepGET
aStep2[ 135 ] SbiRuntime::StepSTMNT (4, 0)
aStep0[ 43 ] SbiRuntime::StepLEAVE
aStep0[ 0 ] SbiRuntime::StepNOP

last example here shows a call to a method

Example 5.
==========

Line 1 Sub Main
Line 2 obj=WorkSheets
Line 3 obj.Item(1)
Line 4 end sub

aStep2[ 135 ] SbiRuntime::StepSTMNT (1, 0)
aStep2[ 135 ] SbiRuntime::StepSTMNT (2, 0)
aStep2[ 129 ] SbiRuntime::StepFIND (11, 12)
aStep2[ 129 ] SbiRuntime::StepFIND (12, 12)
aStep0[ 30 ] SbiRuntime::StepPUT
aStep2[ 135 ] SbiRuntime::StepSTMNT (3, 0)
aStep2[ 129 ] SbiRuntime::StepFIND (11, 9)
aStep0[ 24 ] SbiRuntime::StepARGC
aStep1[ 66 ] SbiRuntime::StepLOADI (1)
aStep0[ 25 ] SbiRuntime::StepARGV
aStep2[ 130 ] SbiRuntime::StepELEM (32781, 12)
aStep0[ 28 ] SbiRuntime::StepGET
aStep2[ 135 ] SbiRuntime::StepSTMNT (4, 0)
aStep0[ 43 ] SbiRuntime::StepLEAVE
aStep0[ 0 ] SbiRuntime::StepNOP

The key to solving this problem lies I guess with understanding how the
pcode is generated and seeing if the correct pcode can be generated. todo :-)


so The last example StepFIND and StepGET pcodes (in the failure cases ) seem 
to be the problem should be replaced by a StepELEM, with some hacking to get 
the object and the args.

brief desc & psuedo explanation of the pcode stuff above ( from Example 5 )

"Line 1 Sub Main"

aStep2[ 135 ] SbiRuntime::StepSTMNT (1, 0) ( defined in
    source/runtime/step2.cxx
	handles Line 1 ( the definition of main ) can't add any more here I 
    I know no more than that. 

"Line 2 obj=WorkSheets"
     
aStep2[ 135 ] SbiRuntime::StepSTMNT (2, 0)
    see above the definition of the statement
aStep2[ 129 ] SbiRuntime::StepFIND (11, 12)
    finds "obj" does a lookup of LocalRefs based on the code 11 which is 
the string id ( this generated in image.cxx see AddString() method  ), the 12
passed to this function relates to the type ( SbxVARIANT variant I think ) 
and puts it on top of stack.
aStep2[ 129 ] SbiRuntime::StepFIND (12, 12)
    does the same for WorkSheets which has a stringId of 12, with the same
type.
aStep0[ 30 ] SbiRuntime::StepPUT
    Pops the last two variabls from the top of stack and assigns them

Line 3 obj.Item(1)

aStep2[ 135 ] SbiRuntime::StepSTMNT (3, 0)
    see above for non-information about this function

aStep2[ 129 ] SbiRuntime::StepFIND (11, 9)
    does a find on string id 11 which is "obj" type is 9 (SbxOBJECT)

aStep0[ 24 ] SbiRuntime::StepARGC
    pushes argv onto the stack ( presume that previous args being processed )
sets up new Argv (SbxArray) to hold arguments ( params )

aStep1[ 66 ] SbiRuntime::StepLOADI (1)
    Creates a new SbxVariable containing integer 1 ( whats passed to Item ) 
and puts it on the (variable) stack.

aStep0[ 25 ] SbiRuntime::StepARGV
    Creates a structure to contain the param ( value ) and sets it up
with a variable poped from the variable stack

aStep2[ 130 ] SbiRuntime::StepELEM (32781, 12)
    will attempt to access method/attribute/property named by string-id
13 which is Item ( 32781 is logically &'d with 0x0800 to get the string id ) 
if bit 0x800 is set then there are params associated with this call and they
are processed. 
This method is the one that ends up calling SbxUnoObject::Find(Item) on object 
ref for "obj" it also sets up the params (if needed ) and calls the method. 

see trace below [1]

aStep0[ 28 ] SbiRuntime::StepGET
	calls BroadCast on the object top of the Stack, not sure what happens
here or what this is for.

Line 4    end sub
aStep2[ 135 ] SbiRuntime::StepSTMNT (4, 0)


[1] - trace of Line 3, method call for obj.Item(1)

#0  ScVbaWorksheets::Item (this=0xae43c790, nIndex=1) at /export/noel/downloads/OOBUILD/ooo-buildLatest/build/src680-m110/sc/source/ui/vba/vbaworksheets.cxx:85
#1  0xb30710e8 in Lcopy () from /export/noel/downloads/OOBUILD/ooo-buildLatest/InstallDir/program/libgcc3_uno.so
#2  0xb30713fd in (anonymous namespace)::cpp_call () from /export/noel/downloads/OOBUILD/ooo-buildLatest/InstallDir/program/libgcc3_uno.so
#3  0xb307179b in bridges::cpp_uno::shared::UnoInterfaceProxy::dispatch () from /export/noel/downloads/OOBUILD/ooo-buildLatest/InstallDir/program/libgcc3_uno.so
#4  0xae919950 in stoc_corefl::IdlInterfaceMethodImpl::invoke (this=0xae869e10, rObj=@0xbfffe4e8, rArgs=@0xbfffe4d8) at /export/noel/downloads/OOBUILD/ooo-buildLatest/build/src680-m110/stoc/source/corereflection/criface.cxx:763
#5  0xb341ae3c in SbUnoObject::Notify (this=0xae426ac8, rBC=@0xae421c30, rHint=@0xbfffe57c) at /export/noel/downloads/OOBUILD/ooo-buildLatest/build/src680-m110/basic/source/classes/sbunoobj.cxx:1973
#6  0xb7d35315 in SfxBroadcaster::Broadcast () from /export/noel/downloads/OOBUILD/ooo-buildLatest/InstallDir/program/libsvl680li.so
#7  0xb3482cc4 in SbxVariable::Broadcast (this=0xae440620, nHintId=65536) at /export/noel/downloads/OOBUILD/ooo-buildLatest/build/src680-m110/basic/source/sbx/sbxvar.cxx:186
#8  0xb347d495 in SbxValue (this=0xae43d118, __vtt_parm=0xb34c9e28, r=@0xae440620) at /export/noel/downloads/OOBUILD/ooo-buildLatest/build/src680-m110/basic/source/sbx/sbxvalue.cxx:328
#9  0xb3482572 in SbxVariable (this=0xae43d118, __vtt_parm=0xb34c9e24, r=@0xae440620) at /export/noel/downloads/OOBUILD/ooo-buildLatest/build/src680-m110/basic/source/sbx/sbxvar.cxx:101
#10 0xb3459998 in SbxMethod (this=0xae43d118, r=@0xae440620) at sbxmeth.hxx:77
#11 0xb345620d in SbiRuntime::FindElement (this=0xae43a580, pObj=0xae426ac8, nOp1=32781, nOp2=12, nNotFound=87570, bLocal=0 '\0') at /export/noel/downloads/OOBUILD/ooo-buildLatest/build/src680-m110/basic/source/runtime/step2.cxx:227
#12 0xb3457afa in SbiRuntime::StepELEM (this=0xae43a580, nOp1=32781, nOp2=12) at /export/noel/downloads/OOBUILD/ooo-buildLatest/build/src680-m110/basic/source/runtime/step2.cxx:592


Collection Support in basic

Seems there is some Collections support in basic, where is it used and when, 
what does it do

Where used/accessed

grep for SbxCollection yields

./inc/sbxdef.hxx          - defines SBXID_COLLECTION
./inc/sbx.hxx             - defines the SbxCollection class
./source/app/mybasic.cxx  - accesses it, but mybasic looks like a test harness

    MyBasic is referenced in
    ./inc/mybasic.hxx         - obvious
    ./source/app/app.cxx      - need to look
    ./source/app/app.hxx      - need to look
    ./source/app/mybasic.cxx  - need to look
    ./source/app/ttbasic.cxx  - need to look
    ./source/app/ttbasic.hxx  - need to look
    ./source/sample/object.cxx - ok instruction here how to bootstrap new 
    SampleObject

./source/sbx/sbxbase.cxx  - SbxBase* SbxBase::Create() bootstraps factories
  for creating various objects including SbxCollection
./source/sbx/sbxcoll.cxx  - implementation of SbxCollection
./source/sbx/sbxobj.cxx:536   -  
   void SbxObject::Insert( SbxVariable* pVar )
   does some checks to see if (this) is a collection and does something I dont
yet understand ( may need to come back here, not now though )

   at line 440 in the same file some more checks to see if (this) is a 
   collection and then does some more unknown stuff.

SbxObject::Make() & SbxObject::MakeObject() are where a SbxCollection is 
created 
    * where does this get called from
        * source/app/comm_bas.cxx:259
              SbxVariable* CommunicationWrapper::Find( const String& rName, 
                               SbxClassType t )
        * source/app/processw.cxx:198
              SbxVariable* ProcessWrapper::Find( const String& rName, 
                               SbxClassType t )
        * source/classes/sb.cxx:1620, 1623, 1625, 1627
              void BasicCollection::Initialize()
              Question: what is BasicCollection and what is its relationship
to SbxCollection? Where is BasicCollection used, seems like it also has Item, 
Add, Count, Remove functionality !

        * source/runtime/stdobj1.cxx many places, all setting up stuff to
             do with some sort of support for Picture & Font objects ???
        * source/runtime/stdobj.cxx:722
              SbxVariable* SbiStdObject::Find( const String& rName, 
                  SbxClassType t )
          Make is called on this object, presume SbiStdObject is SbxObject
        *  source/runtime/step2.cxx:1118
           void SbiRuntime::StepGLOBAL( USHORT nOp1, USHORT nOp2 )
           calls Make() on StarBasic, presume this will eventually end up
           in SbxObject::Make()
        * ./source/sbx/sbxcoll.cxx:129, 131, 133

./source/classes/sb.cxx contains a factory for creating BasicCollection ( name Collection ) mmm need to try this in IDE and see what it does... but does it have aything to do with SbxCollection ( doesn't seem to )

Other Possibility is StepCREATE from step2 however no evidence in codegen to backup this ( but I didn't look that hard )


interesting bits

* source/comp/codegen.cxx 
    ** some or all of the pcode generated from parser here.

* basic/source/sample this contains some new definition for a custom 
Sample object [?] looks like you need to hack mybasic.cxx to get this working 
(so it says in the comments anyway ) but hacking sb.cxx would probably do the same 

   ** NOTE: come back to this, could be interesting.

At the moment I don't see where SbxCollection is used, 
functionally the SbxCollection class seems to be more or less the same as 
BasicCollection which seems to be used at least in runtime.cxx 
( look for others ) 

BasicCollection has a factory entry in source/classes/sb.cxx:298 
        if( rClass.EqualsIgnoreCaseAscii( "Collection" ) )
        {
                String aCollectionName( RTL_CONSTASCII_USTRINGPARAM("Collection") );
                return new BasicCollection( aCollectionName );
        }

so a "Dim coll as Collection" should work

trying that...............


BasicCollection ( defined source/inc/sbunoobj.hxx, implemented in source/classes/sb.cxx )


usage standalone - the following works 

Sub Main
Dim coll as new Collection
coll.Add( Workbooks.Item(0) )
for each Item in coll 
    msgbox ( "name is " + item.name )
next Item
end sub


also interestingly something like
msgbox ( "name is " + coll(1).Name  also works :-)

but how does this work and how can we use it to our advantage, for example
certainly

coll = Worksheets will-not/does-not work ( of course ). But maybe we can copy 
the functionality of BasicCollection to a new VBACollection but have it 
    *  allow it to be assigned to an uno object that implement XCollection?
    *  delegate Item, Count etc. calls to the contained uno object that implements XCollection?

BasicCollection seem only to be used in;

./source/classes/sb.cxx just the implementation
./source/inc/sbunoobj.hxx just the definition
./source/runtime/runtime.cxx  support for "for each"
./source/runtime/step1.cxx support for "for each"
./source/runtime/step2.cxx  support for object(1) syntax


---------------------------------------------
Forms control event handling: How basic gets called
---------------------------------------------

follows just a dump of stuff to be reformated

classes involved
source/classes/eventatt.cxx

Firing for FormControl events, done in BasicScriptListener_Impl::firing_impl() seems there is also a DialogAllListener_Impl::firing_impl() for dialogs, but this delegates/uses a BasicScriptListener. So the BasicScriptListener is where its all at.

So I don't think BasicScriptListener::firing_impl() gets called for every event I think its tied to the event bindings somehow. Follows a trace which will tell

ehhh no, not done in firing_impl no breakpoint hit, ok time for another breakpoint.


#16 0x441327ed in SfxObjectShell::CallXScript () from /export/nld/OOBUILD/ooo-build/InstallDir/program/libsfx680li.so
#17 0x46c181f8 in FmXUndoEnvironment::firing_Impl (this=0x486bd538, evt=@0xbfffde00, pSyncRet=0x0) at /export/nld/OOBUILD/ooo-build/build/src680-m121/svx/source/form/fmundo.cxx:972
#18 0x46c18492 in FmXUndoEnvironment::firing (this=0x486bd538, evt=@0xbfffde00) at /export/nld/OOBUILD/ooo-build/build/src680-m121/svx/source/form/fmundo.cxx:990
#19 0x40bb7fb4 in comphelper::AttacherAllListener_Impl::firing () from /export/nld/OOBUILD/ooo-build/InstallDir/program/libcomphelp4gcc3.so
#20 0x480718cd in comp_EventAttacher::FilterAllListenerImpl::firing (this=0x48a5bbd0, Event=@0xbfffdeb0) at /export/nld/OOBUILD/ooo-build/build/src680-m121/eventattacher/source/eventattacher.cxx:549
#21 0x4806ff9d in comp_EventAttacher::InvocationToAllListenerMapper::invoke (this=0x48272a98, FunctionName=@0x485f48ec, Params=@0xbfffdfe0, OutParamIndex=@0xbfffdfc0, OutParam=@0xbfffdfa0) at /export/nld/OOBUILD/ooo-build/build/src680-m121/eventattacher/source/eventattacher.cxx:249
#22 0x4487c55d in Lcopy () from /export/nld/OOBUILD/ooo-build/InstallDir/program/libgcc3_uno.so
#23 0x4487c8dc in (anonymous namespace)::cpp_call () from /export/nld/OOBUILD/ooo-build/InstallDir/program/libgcc3_uno.so
#24 0x4487cdf6 in bridges::cpp_uno::shared::UnoInterfaceProxy::dispatch () from /export/nld/OOBUILD/ooo-build/InstallDir/program/libgcc3_uno.so
#25 0x482899ca in stoc_invadp::AdapterImpl::invoke () from /export/nld/OOBUILD/ooo-build/InstallDir/program/invocadapt.uno.so
#26 0x4828a09e in adapter_dispatch.2 () from /export/nld/OOBUILD/ooo-build/InstallDir/program/invocadapt.uno.so
#27 0x4487bb83 in (anonymous namespace)::cpp2uno_call () from /export/nld/OOBUILD/ooo-build/InstallDir/program/libgcc3_uno.so
#28 0x4487c0ed in cpp_vtable_call () from /export/nld/OOBUILD/ooo-build/InstallDir/program/libgcc3_uno.so
#29 0x4487cfda in privateSnippetExecutorVoid () from /export/nld/OOBUILD/ooo-build/InstallDir/program/libgcc3_uno.so


#32 0x47e3c493 in frm::OButtonControl::OnClick (this=0x47c40d70) at /export/nld/OOBUILD/ooo-build/build/src680-m121/forms/source/component/Button.cxx:408
#33 0x47e3c21c in frm::OButtonControl::LinkStubOnClick (pThis=0x47c40d70, pCaller=0x0) at /export/nld/OOBUILD/ooo-build/build/src680-m121/forms/source/component/Button.cxx:373
#34 0x403548ff in ImplHandleUserEvent () from /export/nld/OOBUILD/ooo-build/InstallDir/program/libvcl680li.so
#35 0x4035542f in ImplWindowFrameProc () from /export/nld/OOBUILD/ooo-build/InstallDir/program/libvcl680li.so
#36 0x4231a367 in SalDisplay::DispatchInternalEvent () from /export/nld/OOBUILD/ooo-build/InstallDir/program/libvclplug_gen680li.so

Ah, so firing really happens in svx/source/form/fmundo.cxx:972

and OnClick() does
400                         while(aIter.hasMoreElements() )
 401                         {
 406                                 try
 407                                 {
 408                                         static_cast< XActionListener* >( aIter.next() )->actionPerformed(aEvt);
 409                                 }
 416                                 catch( const Exception& )
 417                                 {
 418                                         DBG_ERROR( "OButtonControl::OnClick: caught a exception other than RuntimeException!" );
 419                                 }

OnClick and other routhines for other controls ( which are eventAttachers ) call appropriate handles (registered via registerScriptEventDescriptor )
so aIter get popluated from the attachermanager

trace of  populating aIter, ok so where is that called from

(gdb) where

#0  frm::OButtonControl::addActionListener (this=0x47cc4748, _rxListener=@0xbfffd1b0) at /export/nld/OOBUILD/ooo-build/build/src680-m121/forms/source/component/Button.cxx:479
#1  0x4487c55d in Lcopy () from /export/nld/OOBUILD/ooo-build/InstallDir/program/libgcc3_uno.so
#2  0x4487c8dc in (anonymous namespace)::cpp_call () from /export/nld/OOBUILD/ooo-build/InstallDir/program/libgcc3_uno.so
#3  0x4487cdf6 in bridges::cpp_uno::shared::UnoInterfaceProxy::dispatch () from /export/nld/OOBUILD/ooo-build/InstallDir/program/libgcc3_uno.so
#4  0x4805fc29 in stoc_corefl::IdlInterfaceMethodImpl::invoke () from /export/nld/OOBUILD/ooo-build/InstallDir/program/reflection.uno.so
#5  0x480726b9 in comp_EventAttacher::EventAttacherImpl::attachListener (this=0x47d63568, xObject=@0x44b1b114, AllListener=@0xbfffd640, Helper=@0x44b1b11c, ListenerType=@0x49522238, AddListenerParam=@0x49522240) at /export/nld/OOBUILD/ooo-build/build/src680-m121/eventattacher/source/eventattacher.cxx:735
#6  0x48072c95 in comp_EventAttacher::EventAttacherImpl::attachSingleEventListener (this=0x47d63568, xObject=@0x44b1b114, AllListener=@0xbfffd6f0, Helper=@0x44b1b11c, ListenerType=@0x49522238, AddListenerParam=@0x49522240, EventMethod=@0x4952223c) at /export/nld/OOBUILD/ooo-build/build/src680-m121/eventattacher/source/eventattacher.cxx:793
#7  0x40bbb8ac in comphelper::ImplEventAttacherManager::attach () from /export/nld/OOBUILD/ooo-build/InstallDir/program/libcomphelp4gcc3.so
#8  0x47dfdf4f in frm::OInterfaceContainer::attach (this=0x494dd2c0, nIndex=0, xObject=@0xbfffd790, aHelper=@0xbfffd780) at /export/nld/OOBUILD/ooo-build/build/src680-m121/forms/source/misc/InterfaceContainer.cxx:1165
#9  0x46c47972 in FmXFormController::addToEventAttacher (this=0x48a51978, xControl=@0xbfffd8f0) at /export/nld/OOBUILD/ooo-build/build/src680-m121/svx/source/form/fmctrler.cxx:1621
#10 0x46c4a42f in FmXFormController::implControlInserted (this=0x48a51978, _rxControl=@0xbfffd8f0, _bAddToEventAttacher=true) at /export/nld/OOBUILD/ooo-build/build/src680-m121/svx/source/form/fmctrler.cxx:2067
#11 0x46c481df in FmXFormController::setContainer (this=0x48a51978, xContainer=@0xbfffda60) at /export/nld/OOBUILD/ooo-build/build/src680-m121/svx/source/form/fmctrler.cxx:1714
#12 0x46c6f97d in FmXPageViewWinRec::setController (this=0x495ce100, xForm=@0xbfffda80, xCC=@0xbfffda60, pParent=0x0) at /export/nld/OOBUILD/ooo-build/build/src680-m121/svx/source/form/fmvwimp.cxx:472
#13 0x46c6ea99 in FmXPageViewWinRec (this=0x495ce100, _xORB=@0x49492ae0, rWindow=@0x495a1368, _pViewImpl=0x49492ac0) at

ms/source/misc/InterfaceContainer.cxx:1165 is where attach is called


eventattachManager.cxx ( comphelper/source/ )
has a registerScriptEvent method, it takes and index and a ScriptEventDescriptor

for each index ( there are a number of event attachers )
	* event attachers are attached using the attach method for a specified index

each event attacher has a list of Sequence of 
AttachedObject_Impl 
	each AttachedObject_Impl has a member  aAttachedListenerSeq ( a sequence of XAllListener(s) )	

every time a ScriptEvent is added for each aAttachedObjectImpl in the sequence a  new XEventListener is added to the aAttachedListenerSeq
 Reference< XAllListener > xAll =
            new AttacherAllListener_Impl( this, ScriptEvent.ScriptType, ScriptEvent.ScriptCode );
  pArray[nPos] = xAttacher->attachSingleEventListener( (*aObjIt).xTarget, xAll,
                        (*aObjIt).aHelper, ScriptEvent.ListenerType,
                        ScriptEvent.AddListenerParam, ScriptEvent.EventMethod );
xAttacher is and instance of "com.sun.star.script.EventAttacher"


ok where is registerScriptEvent method called
#1  0x40c15d9e in comphelper::ImplEventAttacherManager::registerScriptEvents (this=0x47daf030, nIndex=0, ScriptEvents=@0x4870eb9c) at /export/nld/OOBUILD/ooo-build/build/src680-m121/comphelper/source/eventattachermgr/eventattachermgr.cxx:666
/export/nld/OOBUILD/ooo-build/build/src680-m121/comphelper/source/eventattachermgr/eventattachermgr.cxx:666:24659:beg:0x40c15d9e
(gdb) up
#2  0x47e76ce4 in frm::OInterfaceContainer::registerScriptEvents (this=0x47dae750, nIndex=0, aScriptEvents=@0x4870eb9c) at /export/nld/OOBUILD/ooo-build/build/src680-m121/forms/source/misc/InterfaceContainer.cxx:1121
/export/nld/OOBUILD/ooo-build/build/src680-m121/forms/source/misc/InterfaceContainer.cxx:1121:38059:beg:0x47e76ce4
(gdb) up
#3  0x45244723 in xmloff::ODefaultEventAttacherManager::setEvents () from /export/nld/OOBUILD/ooo-build/InstallDir/program/libxo680li.so
called from ms/source/misc/InterfaceContainer.cxx:1121

in xmloff/source/forms/eventimport.cxx

OInterfaceContainer ( in the file above ) seems to be a high level wrapper around the eventattacher(mgr) functionality. Also it seems to do other stuff like do transfomations to/from older formats like so5.2 so6.0. ( see TransformEventToxxx )

you can see there is a call from xmloff ( from where the content.xml file got processed ) event definitions for scripts in FormControls are contained in the xml in content.xml



another route to this is from the propcontroller dialog for form controls
e.g. when you right-click on a form control in design mode, you are presented with dialog for setting up events for the control.


to set up a ScriptEventDesciptor you need to know
the 

a) ListenerType 	 listener type as string, same as listener-XIdlClass.getName().
b) EventMethod 	event method as string.
c) AddListenerParam 	data to be used if the addListener method needs an additional parameter.
d) ScriptType 	type of the script language as string; for example, "Basic" or "StarScript".
e) ScriptCode 	script code as string (the code has to correspond with the language defined by ScriptType).

so for a button the when initiating event is described by

ListenerType from xmloff is XActionListener
EventMethod from xmloff is actionPerformed
ScriptCode from xmloff is vnd.sun.star.script:Standard.Module1.OnButtonPress?language=Basic&location=document
ScriptType from xmloff is Script

some code also in xmloff re. older script binding e.g. which if memory serves me correctly would have had format 

ListenerType from xmloff is XActionListener
EventMethod from xmloff is actionPerformed
ScriptCode from document:Standard.Module1.OnButtonPress
ScriptType from StarBasic

finding out the ListenerTypes and evenmethods could do this by introspection I guess ( ok this is whats done in extenstions/source/propctrl/propcontroller/formcontroller.cxx )

ok, so thats not a problem, finding out what the valid events are is, these are
hardcoded "somewhere" gotta find out where, xmloff import/export maybe?
we need to find out what the valid set of events for each control is, then generated the appopriate vba-basic subroutine names for them


some code to dump all available listeners and their methods ( works if you put it in svx/source/form/fmctrler.cxx

will need this to set up the ScriptDescriptor. 


void DumpListenerClassAndMethods( const Reference< XControl >& xControl )
{

	Reference< XIntrospection > xIntrospection( 
		::comphelper::getProcessServiceFactory()->createInstance( 
			::rtl::OUString::createFromAscii( 
				"com.sun.star.beans.Introspection" ) ), UNO_QUERY );
	
	Reference< XIntrospectionAccess > xIntrospectionAccess;

	if  ( xIntrospection.is() )
	{
			xIntrospectionAccess = xIntrospection->inspect( 
				makeAny( xControl ) );
			Sequence< Type >	aModelListeners;
			aModelListeners = xIntrospectionAccess->getSupportedListeners();
			const Type* pListeners = aModelListeners.getConstArray();
			sal_Int32 nLength = aModelListeners.getLength();
			OSL_TRACE("** There are %d listener types for this control",
				nLength );	
			for ( sal_Int32 i = 0; i < nLength; ++i )
			{
				const Type* pListener = (pListeners + i );
				String aListenerClassName = pListener->getTypeName();
					OSL_TRACE("***Listener %d class name is %s", i,
						(const sal_Char *) rtl::OUStringToOString( aListenerClassName, RTL_TEXTENCODING_UTF8 )  );	
				Sequence< ::rtl::OUString> sMeths = getEventMethods(*pListener);
				sal_Int32 methLen = sMeths.getLength();
				const ::rtl::OUString* pMeths = sMeths.getConstArray();
				for ( sal_Int32 c = 0; c < methLen; ++c )
				{
					OSL_TRACE("\t meth[%d] is %s", c,
						(const sal_Char *) rtl::OUStringToOString( *(pMeths+c), RTL_TEXTENCODING_UTF8 )  );	
			
				}
			
				
			}

			
			
	}


}

seems there is a namereplace service somewhere that does the translation between the name thats in the xml to the listerer/listener-method pair

e.g. a binding in the document is 

<office:event-listeners><script:event-listener script:language="ooo:script" script:event-name="form:performaction" xlink:href="vnd.sun.star.script:Standard.Module1.OnButtonPress?language=Basic&amp;location=document"/></office:event-listeners>

so form:performaction gets translated to XActionListener:actionPerformed ( I think )

yes its done in a convoluted way in 

xmloff/source/script/XMLEventImportHelper.cxx:184
	XMLEventName aEventName( nMacroPrefix, sMacroName );
	NameMap::iterator aNameIter = pEventNameMap->find(aEventName);
	if (aNameIter != pEventNameMap->end()) 

if the find above succeed it will have succeed in translating performaction to XActionListener:performAction the map used I guess is set up based on the "form:" prefix somewhere.


need to check if multiple bindings can happen. also where propcontroler will
zap any manual bindings made or display them. Maybe we need 2 eventattachermgr?

multiple bindings are ok, but 
1) scripts that I register if they don't exist cause error msg to be displayed
	need either to supress that or ( maybe the old way behaves the same e.g.
	fails silently ) blame the scripting framework for this, old work haunts you eventually :-)

2) scripts for the basic event bindings will appear in the property browser, not sure I like that, additionally only one binding can appear ( even if there are multiple bindings )  ,,,,,

I see 2 approaches, 
	* jimme in some code that only will populate sub_mycontrolNameclick() for event ( or whatever the vba equiv handler is called only if a binding doesn't exist. This at least lets user override these default handlers that I need to set up to behave like vba. Bad news is they still will appear in the property editor for the control :-( ( could be confusing ) also means only one mechanism supported so for a specific event you can have the normal binding you make in the ui or you have the default sub_mycontrol....() you cant have both.
		* we could hide display of the default bindings based on their name
	* use a second attachermanager just for the vba bindings ( don't know how hard that is to do, see alot of special handling code for the exist attachmanager )
		* this would be a cleaner solution, no polution of the events defined for a form controller that a user would see. You could have both types of bindings simulataniously.

In anycase there is alot of stuff that needs to be done regardless of which approach is taken
	* for a given control you need to be able to determine the listeners and the listener methods that are valid. ( note introspection gives you all of the possible listerns and methods but not the ones supported via the ui which is a subset )
	* need to find the name of the sub_routine to be called for an event, afaik this is based on both the type of control and the name of the control. So for each control on the vba side need to accumulate the supported events and the names of the sub-routines that would get called, on the oo side get the listeners and methods for a control. Need then to see which events are common and generate some sort of translation mechanism on a per control basis. Need to be able to generate the sub_routine name on the fly based on the type of control and the instance ( e.g. the name of the control Button1..n etc )


---------------------------------------------

Some notes on VBA to SB (StarBasic) [from VbaStartBasicXref.pdf]

Though syntactically equivalent, both VBA and SB are not compatible
becuase of the differences in the Object Model followed.
SB has an object-oriented model where are excel macros are object-like
model and not fully object-oriented. 

a typical mapping eg.

In Excel, to determine the number of rows in the range, one can access the range
property using Range("MyTable").Rows.Count, Range("MyTable") is a named Range.

To determine the same - the number of rows in a range of cells, SB call would 
look like
ThisComponent.CurrentController.ActiveSheet.getCellRangeByName("MyTable").getRows.getCount()

Specific object types like Worksheet, Workbook, Range etc. in addition to Object 
in Excel where only generic Object type available in SB.
set statement is enforced in VBA and SB supports that.


A trace of the sb macro in execution [executed from ide with a breakpoint]:

#4  0x417057f4 in poll () from /lib/tls/libc.so.6
#5  0x422ec558 in g_main_context_iterate () from /opt/gnome/lib/libglib-2.0.so.0
#6  0x422ec6c3 in g_main_context_iteration () from /opt/gnome/lib/libglib-2.0.so.0
#7  0x41eb0b5e in GtkXLib::Yield () from ./libvclplug_gtk680li.so
#8  0x423bc4ef in X11SalInstance::Yield () from ./libvclplug_gen680li.so
#9  0x40174eb4 in Application::Yield () from ./libvcl680li.so
#10 0x4a10a263 in ModulWindow::BasicBreakHdl () from ./libbasctl680li.so
#11 0x4a1045ca in BasicIDEShell::CallBasicBreakHdl () from ./libbasctl680li.so
#12 0x4a130f40 in BasicIDEData::GlobalBasicBreakHdl () from ./libbasctl680li.so
#13 0x4a130de8 in BasicIDEData::LinkStubGlobalBasicBreakHdl () from ./libbasctl680li.so
#14 0x450ebd11 in StarBASIC::BreakPoint () from ./libsb680li.so
#15 0x45131322 in SbiRuntime::StepSTMNT () from ./libsb680li.so
#16 0x45128bca in SbiRuntime::Step () from ./libsb680li.so
#17 0x450f10ba in SbModule::Run () from ./libsb680li.so
#18 0x450f06cf in SbModule::Notify () from ./libsb680li.so
#19 0x4050b313 in SfxBroadcaster::Broadcast () from ./libsvl680li.so
#20 0x450f3d94 in SbMethod::Broadcast () from ./libsb680li.so
#21 0x40900b70 in SbxValue::Get () from ./libsvt680li.so
#22 0x4a121970 in BasicIDE::RunMethod () from ./libbasctl680li.so
#23 0x4a108833 in ModulWindow::BasicExecute () from ./libbasctl680li.so
#24 0x4a1088f2 in ModulWindow::BasicRun () from ./libbasctl680li.so
#25 0x4a10aed5 in ModulWindow::ExecuteCommand () from ./libbasctl680li.so
#26 0x4a105f72 in BasicIDEShell::ExecuteBasic () from ./libbasctl680li.so
#27 0x4a0fc122 in SfxStubBasicIDEShellExecuteBasic () from ./libbasctl680li.so
#28 0x44e98f93 in SfxDispatcher::Call_Impl () from ./libsfx680li.so
#29 0x44e9b7f9 in SfxDispatcher::PostMsgHandler () from ./libsfx680li.so
#30 0x44e9b70e in SfxDispatcher::LinkStubPostMsgHandler () from ./libsfx680li.so
#31 0x44ec103e in SfxHintPoster::Event () from ./libsfx680li.so
#32 0x44ec0fe9 in SfxHintPoster::LinkStubDoEvent_Impl () from ./libsfx680li.so
#33 0x40352bd8 in ImplHandleUserEvent () from ./libvcl680li.so
#34 0x403536f9 in ImplWindowFrameProc () from ./libvcl680li.so
#35 0x423b7ff9 in SalDisplay::DispatchInternalEvent () from ./libvclplug_gen680li.so
#36 0x41eb09ce in GtkXLib::userEventFn () from ./libvclplug_gtk680li.so
#37 0x422e8221 in g_idle_dispatch () from /opt/gnome/lib/libglib-2.0.so.0
#38 0x422e9e87 in g_main_context_dispatch () from /opt/gnome/lib/libglib-2.0.so.0
#39 0x422ec5c7 in g_main_context_iterate () from /opt/gnome/lib/libglib-2.0.so.0
#40 0x422ec6c3 in g_main_context_iteration () from /opt/gnome/lib/libglib-2.0.so.0
#41 0x41eb0b5e in GtkXLib::Yield () from ./libvclplug_gtk680li.so
#42 0x423bc4ef in X11SalInstance::Yield () from ./libvclplug_gen680li.so
#43 0x40174eb4 in Application::Yield () from ./libvcl680li.so
#44 0x40174dcb in Application::Execute () from ./libvcl680li.so
#45 0x0806f505 in desktop::Desktop::Main ()
#46 0x4017a973 in SVMain () from ./libvcl680li.so
#47 0x08068cdd in sal_main ()
#48 0x08068c8c in main ()


basctl\source\basicide\baside2.cxx
	+ handles the ide operations - compile-run-etc
	+ModulWindow::BasicExecute()

basctl\source\basicide\basobj3.cxx
	+BasicIDE::CreateMacro
	+BasicIDE::RunMethod
		and several other methods

basic\source\classes\sbxmod.cxx
	+SbModule is handled here
	+SbModule::Run
		+Implements a BASIC subroutine
	+SimpleTokenizer_Impl::setKeyWords
	+class SbMethod

sfx2/source/appl/appuno.cxx
	+loadMacro

basic/source/classes/sbunoobj.cxx
	+SbUnoObject
	+SbUnoFactory::CreateObject

sfx2/source/appl/appbas.cxx
	+SfxApplication::EnterBasicCall
	+GetBasic

basmgr.cxx
	+GetLib, StoreLib etc.

sfx2/source/notify/eventsupplier.cxx
	+SfxEvents_Impl::BlowUpMacro

basic/source/classes/eventatt.cxx
	+getModelFromBasic


-------------------
#5  0x4514d91d in SbUnoObject (this=0x48d81800, aName=@0xbfffa1a0,
    aUnoObj_=@0xbfffa210)
    at /home/mnicel/ooo-build-head/ooo-build/build/src680-m90/basic/source/class es/sbunoobj.cxx:2071
#6  0x451518fe in GetSbUnoObject (aName=@0xbfffa1a0, aUnoObj_=@0xbfffa210)
    at /home/mnicel/ooo-build-head/ooo-build/build/src680-m90/basic/source/class es/sbunoobj.cxx:2654
#7  0x44d69020 in SfxApplication::GetBasicManager (this=0x449b3870)
    at /home/mnicel/ooo-build-head/ooo-build/build/src680-m90/sfx2/source/appl/a ppbas.cxx:648
#8  0x44d69db5 in SfxApplication::GetBasic (this=0x449b3870)
    at /home/mnicel/ooo-build-head/ooo-build/build/src680-m90/sfx2/source/appl/a ppbas.cxx:731
#9  0x44d69e24 in SfxApplication::EnterBasicCall (this=0x449b3870)
    at /home/mnicel/ooo-build-head/ooo-build/build/src680-m90/sfx2/source/appl/a ppbas.cxx:753
#10 0x4820b742 in SvxImportMSVBasic::ImportCode_Impl () from ./libsvx680li.so
#11 0x4820a5a4 in SvxImportMSVBasic::Import () from ./libsvx680li.so
#12 0x4737bf74 in ImportExcel8::ReadBasic () from ./libsc680li.so
#13 0x47391a5b in ImportExcel8::Read () from ./libsc680li.so
#14 0x473704d7 in ScImportExcel () from ./libsc680li.so
#15 0x46ed3aa9 in ScDocShell::ConvertFrom () from ./libsc680li.so
#16 0x44e0ce46 in SfxObjectShell::DoLoad () at _hash_map.h:181
#17 0x44e56bda in SfxBaseModel::load () at _hashtable.h:151
#18 0x44e882f4 in SfxFrameLoader_Impl::load () at window.hxx:790
#19 0x453ead51 in framework::LoadEnv::impl_loadContent () from ./libfwk680li.so
#20 0x453e77ef in framework::LoadEnv::startLoading () from ./libfwk680li.so
#21 0x452c9c43 in framework::LoadDispatcher::dispatchWithNotification ()
   from ./libfwk680li.so
#22 0x452c9f74 in framework::LoadDispatcher::dispatch () from ./libfwk680li.so
#23 0x4547cd33 in framework::RecentFilesMenuController::ExecuteHdl_Impl ()
   from ./libfwk680li.so
#24 0x40352bd8 in ImplHandleUserEvent () from ./libvcl680li.so
#25 0x403536f9 in ImplWindowFrameProc () from ./libvcl680li.so
#26 0x423b7ff9 in SalDisplay::DispatchInternalEvent ()
   from ./libvclplug_gen680li.so
#27 0x41eb09ce in GtkXLib::userEventFn () from ./libvclplug_gtk680li.so
#28 0x422e8221 in g_idle_dispatch () from /opt/gnome/lib/libglib-2.0.so.0
#29 0x422e9e87 in g_main_context_dispatch ()
   from /opt/gnome/lib/libglib-2.0.so.0
#30 0x422ec5c7 in g_main_context_iterate ()
   from /opt/gnome/lib/libglib-2.0.so.0
#31 0x422ec6c3 in g_main_context_iteration ()
   from /opt/gnome/lib/libglib-2.0.so.0
#32 0x41eb0b5e in GtkXLib::Yield () from ./libvclplug_gtk680li.so
#33 0x423bc4ef in X11SalInstance::Yield () from ./libvclplug_gen680li.so
#34 0x40174eb4 in Application::Yield () from ./libvcl680li.so
#35 0x40174dcb in Application::Execute () from ./libvcl680li.so
#36 0x0806f505 in desktop::Desktop::Main ()
#37 0x4017a973 in SVMain () from ./libvcl680li.so
#38 0x08068cdd in sal_main ()
#39 0x08068c8c in main ()


---------------
sbxmod.cxx
	+SbModule::Find()
macrconf.cxx
	+SfxMacroConfig::Call
	+SfxQueryMacro
		gets the method
	+SfxQueryMacro_Impl

---------------
On executing a macro like this:

Sub Main
	Dim URLStr as String
	GlobalScope.BasicLibraries.LoadLibrary("Tools")
	URLStr = ThisComponent.getURL()
	msgbox FileNameOutOfPath(URLStr)
End Sub

sbunoobj.cxx/SbUnoObject::Find has the aUName values

as loadLibrary and getURL !?

---------------
trace when stopped in SbUnoObject::Find

#5  0x451673f3 in SbUnoObject::Find (this=0x489aa358, rName=@0xbfffda90, t=SbxCLASS_DONTCARE)
    at /home/mnicel/ooo-build-head/ooo-build/build/src680-m90/basic/source/classes/sbunoobj.cxx:2370
#6  0x4519fe86 in SbiRuntime::FindElement (this=0x5704caa8, pObj=0x489aa358, nOp1=32783, nOp2=12, nNotFound=87570,
    bLocal=0 '\0') at /home/mnicel/ooo-build-head/ooo-build/build/src680-m90/basic/source/runtime/step2.cxx:106
#7  0x451a1a2e in SbiRuntime::StepELEM (this=0x5704caa8, nOp1=32783, nOp2=12)
    at /home/mnicel/ooo-build-head/ooo-build/build/src680-m90/basic/source/runtime/step2.cxx:592
#8  0x45198e62 in SbiRuntime::Step (this=0x5704caa8)
    at /home/mnicel/ooo-build-head/ooo-build/build/src680-m90/basic/source/runtime/runtime.cxx:694
#9  0x45154041 in SbModule::Run (this=0x48976df8, pMeth=0x57048a68)
    at /home/mnicel/ooo-build-head/ooo-build/build/src680-m90/basic/source/classes/sbxmod.cxx:777
#10 0x451534b3 in SbModule::Notify (this=0x48976df8, rBC=@0x48971000, rHint=@0xbfffdd10)
    at /home/mnicel/ooo-build-head/ooo-build/build/src680-m90/basic/source/classes/sbxmod.cxx:524
#11 0x4050b313 in SfxBroadcaster::Broadcast () from ./libsvl680li.so
#12 0x45157852 in SbMethod::Broadcast (this=0x4895eed0, nHintId=65536)
    at /home/mnicel/ooo-build-head/ooo-build/build/src680-m90/basic/source/classes/sbxmod.cxx:1984
#13 0x40900b70 in SbxValue::Get () from ./libsvt680li.so
#14 0x4515762d in SbMethod::Call (this=0x4895eed0, pRet=0x570498a0)
    at /home/mnicel/ooo-build-head/ooo-build/build/src680-m90/basic/source/classes/sbxmod.cxx:1938
#15 0x56da6455 in basprov::BasicScriptImpl::invoke () from ./basprov680li.uno.so
#16 0x44e04a3b in SfxObjectShell::CallXScript (this=0x484b1120, rScriptURL=@0xbfffe2e0, aParams=@0xbfffe2d0,
    aRet=@0xbfffe310, aOutParamIndex=@0xbfffe2f0, aOutParam=@0xbfffe320)
    at /home/mnicel/ooo-build-head/ooo-build/build/src680-m90/sfx2/source/doc/objmisc.cxx:1439
#17 0x44d5fdb2 in SfxApplication::OfaExec_Impl (this=0x44667880, rReq=@0xbfffe5b0)
    at /home/mnicel/ooo-build-head/ooo-build/build/src680-m90/sfx2/source/appl/appserv.cxx:1034
#18 0x44d53478 in SfxStubSfxApplicationOfaExec_Impl () at resid.hxx:116
#19 0x44ec7013 in SfxDispatcher::Call_Impl () at solar.h:293
#20 0x44ec8194 in SfxDispatcher::_Execute () at solar.h:293
#21 0x44ed7300 in SfxBindings::Execute_Impl () at solar.h:293
#22 0x44ec045d in SfxDispatchController_Impl::dispatch () at solar.h:293
#23 0x44ebe6e9 in SfxOfficeDispatch::dispatch () at solar.h:293
#24 0x453b67aa in framework::MenuBarManager::Select () from ./libfwk680li.so
#25 0x453b5f00 in framework::MenuBarManager::LinkStubSelect () from ./libfwk680li.so
#26 0x402f53b1 in Menu::Select () from ./libvcl680li.so
#27 0x402f9384 in Menu::ImplCallSelect () from ./libvcl680li.so
#28 0x402f9366 in Menu::LinkStubImplCallSelect () from ./libvcl680li.so
#29 0x40352bd8 in ImplHandleUserEvent () from ./libvcl680li.so
#30 0x403536f9 in ImplWindowFrameProc () from ./libvcl680li.so
#31 0x423b7ff9 in SalDisplay::DispatchInternalEvent () from ./libvclplug_gen680li.so
#32 0x41eb09ce in GtkXLib::userEventFn () from ./libvclplug_gtk680li.so
#33 0x422e8221 in g_idle_dispatch () from /opt/gnome/lib/libglib-2.0.so.0
#34 0x422e9e87 in g_main_context_dispatch () from /opt/gnome/lib/libglib-2.0.so.0
#35 0x422ec5c7 in g_main_context_iterate () from /opt/gnome/lib/libglib-2.0.so.0
#36 0x422ec6c3 in g_main_context_iteration () from /opt/gnome/lib/libglib-2.0.so.0
#37 0x41eb0b5e in GtkXLib::Yield () from ./libvclplug_gtk680li.so
#38 0x423bc4ef in X11SalInstance::Yield () from ./libvclplug_gen680li.so
#39 0x40174eb4 in Application::Yield () from ./libvcl680li.so
#40 0x40174dcb in Application::Execute () from ./libvcl680li.so
#41 0x0806f505 in desktop::Desktop::Main ()
#42 0x4017a973 in SVMain () from ./libvcl680li.so
#43 0x08068cdd in sal_main ()
#44 0x08068c8c in main ()
-------------------------------------------------

Defining the interface and generating the code.

XWorkBook.idl
	-interface for WorkBook

	-under offapi/org/openoffice/vba/

generating source code. (manual invokation; yet to integrate with make)

idlc -C -I <path to solver/680/unxlngi4.pro/idl> XWorkBook.idl

>> that generates XWorkBook.urd

then, creating registry database,

regmerge vba.rdb /UCR XWorkBook.urd

>> should /UCR be used or something else? /UCR is the default key for type descriptions

cppumaker -BUCR -Torg.openoffice.vba.XWorkBook vba.rdb

>>generates XWorkBook.hdl and XWorkBook.hpp under org/openoffice/vba/ -- with the make integration this should go into unxlngpro4/ ??

[gave an error saying: cppumaker ERROR: cannot dump Type 'com/sun/star/uno/RuntimeException' ??]

--------------------------

Generating with makefiles:

- Have the .idl files under offapi/org/openoffice/vba

- create, offapi/org/openoffice/vba/makefile.mk

	- specify the idl files in there, and define PACKAGE as org/openoffice/vba

- update offapi/prj/d.lst to deliver the .idl files

- update offapi/util/makefile.mk

	-to create vba.db, the unoidl db of type UCR

- update offuh/prj/d.lst

	-to deliver the .hdl and .hpp created out of the .rdb from offapi

----------------

basic/ notes:

    Incoming byte stream into ->
	basic/source/comp/token.cxx
    split into tokens; eg. 'EQ' -> ( cf. token.hxx (SbiToken) )
        basic/source/comp/parser.cxx
    compiled into expressions, eg. SbiParser::Symbol,
    '_PUT', or '_SET' -> and whacked on a byte-stack
	basic/source/runtime/runtime.cxx
    executed as a byte-code: ->
	basic/source/runtime/step0.cxx
    eg. StepPUT() / StepSET()

    parser.cxx:
	+ SbiParser
	    + inherits from Tokenizer
		+ simple peek/next stream of tokens.
	    + stores macro-level-details:
		+ SbiParseStack *pStack - block stack
		+ SbiProcDef *pProc - proceedure
		+ SbiExprNode *pWithVar - 'with' var.
		+ ...
		+ SbiCodeGen aGen - byte code generator.
		+ SbiSymPool *pPool - pool of string/symbols
	    + [ is passed everywhere ]
	+ SbiToken
	    - an integer representing an op or a string ... (?)
	    + 'aSym' - the string symbol ...
	+ to read & compile an Expression we do:
	    SbiExpresion aFoo( this, SbFOO );
	    aFoo.Gen(); <-- this does all the work.
		+ calls 'Gen' on the SbiExprNode:: pExpr (exprgen.cxx)
	



---- UNO Interfaces used in basic/ ----

These interfaces look particularly interesting docs from:
com/sun/star/bridge/oleautomation/PropertyPutArgument.idl:

/** contains a value that is used as argument in a &quot;property put&quot
    operation on a Automation object.
    <p>
    If a Automation object is converted into a UNO object by a scripting
    bridge, such as
    <type scope="com::sun::star::bridge::oleautomation">BridgeSupplier</type>,
    then it is accessed through the 
    <type scope="com::sun::star::script">XInvocation</type> interface.
    The methods
    <member scope="com::sun::star::script">XInvocation::setValue</member>
    and
    <member scope="com::sun::star::script">XInvocation::getValue</member>
    are used to access properties which do not have additional
    arguments. To access a property with additional arguments, the
    method
    <member scope="com::sun::star::script">XInvocation::invoke</member>
    has to be used. The method implementation must decide, if the
    property is to be written or read so it can perform the proper
    operation on the Automation object. To make this decision, the
    caller has to provide the information if the current call is
    intended to be a write or read operation. This is done by
    providing either instances of <type>PropertyPutArgument</type> or
    <type>PropertyGetArgument</type> as arguments to
    <member scope="com::sun::star::script">XInvocation::Invoke</member>. 

    @since OOo 1.1.2
*/
com/sun/star/script/XInvocation.idl

 bridge::oleautomation::NamedArgument
 bridge::oleautomation::Date
 bridge::oleautomation::Decimal
 bridge::oleautomation::Currency
 bridge::XBridge 
 bridge::XBridgeFactory
 script::XAllListener 
 i18n::XCalendar 
 XComponent 
 uno::XComponentContext 
 XContainer
 XContainerListener 
 XContentProvider 
 XContentProviderManager 
 XControl
 XControlContainer 
 XControlModel 
 container::XEnumeration 
 container::XEnumerationAccess 
 XEventAttacher 
 XEventListener 
 container::XHierarchicalNameAccess 

 XImplementationRegistration 
 XIndexAccess 
 XInputStream 
 XInputStreamProvider 
 XIntrospection 
 XIntrospectionAccess 
 XInvocation 
 XInvocationAdapterFactory 
 XLibraryContainer 
 XMaterialHolder 
 XMultiComponentFactory
 lang::XMultiServiceFactory 
 XNameAccess 
 XNameContainer 
 XOutputStream 
 XSeekable 
 XServiceInfo 
 XSimpleFileAccess 
 XSimpleRegistry 
 XTypeConverter 
 XTypeDescription 
 XTypeProvider 
 XVetoableChangeListener 
 XWindow 

Interesting:
 XExactName - used for case insensitivity ...

Not likely interfaces:
 reflection::XIdlArray
 reflection::XIdlClass 
 reflection::XIdlField
 reflection::XIdlMethod 
 reflection::XIdlReflection 
 script::XScriptEventsAttacher 
 script::XScriptEventsSupplier 
 script::XScriptListener 
 script::provider::XScriptProvider 
 script::provider::XScriptProviderFactory 
 script::provider::XScriptProviderSupplier 
 script::provider::XScript
 beans::XPropertyAccess 
 beans::XPropertyChangeListener 
 beans::XPropertySet
 beans::XPropertySetInfo 
 XStarBasicAccess 
 XStarBasicDialogInfo 
 XStarBasicLibraryInfo 
 XStarBasicModuleInfo 

Unlikely looking interfaces:
 frame::XModel 
 XStream 
 XTextOutputStream 
 XToolkit
 io::XActiveDataSource 
