OpenOffice BASIC API viewer

Creating Extension - Shared Libraries
Forum rules
For sharing working examples of macros / scripts. These can be in any script language supported by OpenOffice.org [Basic, Python, Netbean] or as source code files in Java or C# even - but requires the actual source code listing. This forum is not for asking questions about writing your own macros.

OpenOffice BASIC API viewer

Postby Evgeniy » Sat Jan 18, 2020 1:03 pm

Code:

Code: Select all   Expand viewCollapse view
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   Expand viewCollapse view
   Doc = ThisComponent
   Show(Doc,0)


Result:
Attachments
api.png
OpenOffice 4.1.7 OS: Win10 x32 + Win10 x64
User avatar
Evgeniy
 
Posts: 43
Joined: Thu Jan 09, 2020 9:31 pm
Location: Russia

Re: OpenOffice BASIC API viewer

Postby Villeroy » Sat Jan 18, 2020 1:57 pm

Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 29296
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: OpenOffice BASIC API viewer

Postby Evgeniy » Sat Jan 18, 2020 7:04 pm

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.
OpenOffice 4.1.7 OS: Win10 x32 + Win10 x64
User avatar
Evgeniy
 
Posts: 43
Joined: Thu Jan 09, 2020 9:31 pm
Location: Russia

Re: OpenOffice BASIC API viewer

Postby JeJe » Sat Jan 18, 2020 7:25 pm

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
Openoffice 4.1.6
Windows 8
JeJe
Volunteer
 
Posts: 1410
Joined: Wed Mar 09, 2016 2:40 pm

Re: OpenOffice BASIC API viewer

Postby Villeroy » Sat Jan 18, 2020 7:46 pm

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   Expand viewCollapse view
  oMRI = CreateUnoService( "mytools.Mri" )
  oMRI.inspect( objVariable )

or this:
Code: Select all   Expand viewCollapse view
GlobalScope.BasicLibraries.loadLibrary("MRILib2")
mri objVariable
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 29296
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: OpenOffice BASIC API viewer

Postby Zizi64 » Sun Jan 19, 2020 11:23 am

Tibor Kovacs, Hungary; LO6.1.6, 6.2.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-6.4.5;AOO4.1.7
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 9725
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary


Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 2 guests