You don't need to use StarBasic to talk to this office like you don't need VBA to talk to MS Office.
StarBasic is a dialect of Basic that has been added to the predecessor of OOo when MS introduced Visual Basic for Applications. That was MSOffice '95 and Star Office 5.x. Unlike VBA StarBasic did not evolve since then.
StarBasic has some helper functions to connect more easily to the office, it comes with it's own editor and it is more easy to embed this type of code into documents. It's about ease-of-use for the developer. But all in all it's not a serious programming language. It is this office suite's preferred loudspeaker for API-calls.
The macro recorder records user-interactions in the current document's frame: Click here, select that, jump to there, click this ...
The frame is an abstract thing with 2 main-windows, all the bars and buttons, a model (the document) and a controller.
When the macro-recorder writes: document = ThisComponent.CurrentController.Frame
this statement is confusing since the symbol should be named as "frame" rather then "document".
ThisComponent is the document (aka model), that model has one or more views (aka controllers) to select items within the model and scroll through it. CurrentController is the one in the currently active frame and since every frame has zero or one controllers and every controller must belong to one frame, you can get the frame from the current controller of this component.
A "normal" document-frame has an outer ContainerWindow, inner CmponentWindow(showing the document content), a controller (select&scroll) and a model (aka component or document). The frame provides the whole dispatch-framework which is used to record the user's interactions in this frame.
And yes, all this is part of the API and this recorded Basic code ...
Code: Select all
sub Main
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$A$1:$D$23"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
end sub
... could be written in a true programming language as well, Python for instance ...
Code: Select all
import uno
def Main():
# we don't have predefined ThisComponent nor callable CreateUnoService()
ctx = uno.getComponentContext()
smgr = ctx.ServiceManager
# we don't have CreateUnoObject
dispatcher = smgr.createInstance("com.sun.star.frame.DispatchHelper")
dtp = smgr.createInstanceWithContext("com.sun.star.frame.Desktop", ctx)
# get document from desktop
ThisComponent = dtp.getCurrentComponent()
# get frame from controller and controller from document
frame = ThisComponent.CurrentController.Frame
# ---arrays in Python require different syntax-------------------------------------------
arg = uno.createUnoStruct("com.sun.star.beans.PropertyValue")
arg.Name = "ToPoint"
arg.Value = "$A$1:$D$23"
dispatcher.executeDispatch(frame, ".uno:GoToCell", "", 0, (arg,))
By the way: The "Desktop" (predefined StarDesktop in Basic) can be seen as the single collection of frames.
Go to oooforum.org and search for all tems "model, controller frame" by user "DannyB". It's worth reading.