Page 1 of 1

OpenOffice BASIC API viewer

Posted: Sat Jan 18, 2020 1:03 pm
by Evgeniy
Code:

Code: Select all

Function Replace(Source As String, Search As String, NewPart As String)
	Dim Result As String
	Result = join(split(Source, Search), NewPart)
	Replace = Result
End Function

Sub Show(obj_ As Object, type_ As Integer)
	Dim str As String
	
	if type_=0 then str = obj_.DBG_Methods
	if type_=1 then str = obj_.DBG_Properties
	if type_=2 then str = obj_.DBG_SupportedInterfaces
	
	str = Replace(str,Chr(10),"")
	str = Replace(str,";",";"&Chr(10))
	str = Replace(str,":",":"&Chr(10)&Chr(10)&" ")
	str = Replace(str,"Sbx","")	
	
	Dim s()
	s=Split(str,";")
	iter=0
	For i=LBound(s) to UBound(s)
		if type_=1 then
			s(i)=Replace(s(i),";","")
			if InStr(s(i),"BOOL")>0 then s(i)=Replace(s(i)," BOOL ","")&" As Boolean"
			if InStr(s(i),"INTEGER")>0 then s(i)=Replace(s(i)," INTEGER ","")&" As Integer"
			if InStr(s(i),"DOUBLE")>0 then s(i)=Replace(s(i)," DOUBLE ","")&" As Double"
			if InStr(s(i),"STRING")>0 then s(i)=Replace(s(i)," STRING ","")&" As String"
			if InStr(s(i),"OBJECT")>0 then s(i)=Replace(s(i)," OBJECT ","")&" As Object"
			if InStr(s(i),"LONG")>0 then s(i)=Replace(s(i)," LONG ","")&" As Long"
			if InStr(s(i),"ARRAY")>0 then s(i)=Replace(s(i)," ARRAY ","")&" As Array"
		endif
		's(i)=s(i)&"+"
		iter=iter+1
		if iter>30 then
			iter=0
			s(i)=s(i)&">>>"
		end if
	Next i
	str=Join(s)		
		
	s=Split(str,">>>")	
	For i=LBound(s) to UBound(s)
		msgbox "Page "+i+" of "+UBound(s)+Chr(10)+Chr(10)+s(i)
	Next i		

End Sub
Using:

Show(obj_ As Object, type_ As Integer)

obj_= any object as Frame, Imgae, etc.

type_ = is what we want to see:
0 - show all object methods
1 - show all object propertys
2 - show all object interfaces

Code: Select all

	Doc = ThisComponent
	Show(Doc,0)
Result:

Re: OpenOffice BASIC API viewer

Posted: Sat Jan 18, 2020 1:57 pm
by Villeroy

Re: OpenOffice BASIC API viewer

Posted: Sat Jan 18, 2020 7:04 pm
by Evgeniy
Yes, I saw this tool it is bulky. I still do not understand how to use it. Therefore, I wrote this function. So far, everything suits me.

Re: OpenOffice BASIC API viewer

Posted: Sat Jan 18, 2020 7:25 pm
by JeJe
Once MRI is installed and the library is loaded... its VERY easy to use. You just write MRI followed by the object you want inspected. eg

MRI ThisComponent

will give all the properties and methods and so on of ThisComponent and let you navigate from there to inspect other related objects. Instead of ThisComponent you can put any object or variable...

Edit: and you can put that line anywhere in your code... and an MRI dialog will pop up with all that information at that point... and your code will resume without halting

Re: OpenOffice BASIC API viewer

Posted: Sat Jan 18, 2020 7:46 pm
by Villeroy
That's why I posted the tutorial. Trying to write macros without MRI (or XRay at least) makes no sense. Most macro related questions on this forum can be answered with a little help from MRI. It is the first thing I call before writing anything.

Without writing any code
menu:Tools>Add-ins>Mri inspects the current component.
menu:Tools>Add-ins>"Mri <-- Selection" inspects the current selection.
If you assign some object's event to Basic macro MyMacros>MriLib>Module1>Mri then you get the inspection window for the calling event.
Just double-click one the line describing the property or method you are interested in.

When writing code:
This is an easy method to inspect your objVariable:

Code: Select all

  oMRI = CreateUnoService( "mytools.Mri" )
  oMRI.inspect( objVariable )
or this:

Code: Select all

GlobalScope.BasicLibraries.loadLibrary("MRILib2")
mri objVariable

Re: OpenOffice BASIC API viewer

Posted: Sun Jan 19, 2020 11:23 am
by Zizi64