OpenOffice.org OpenOffice - 3.0 Quick Start Guide Page 378

  • Download
  • Add to my manuals
  • Print
  • Page
    / 433
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 377
The dispatch framework can also be used to send “commands” back to
the UI (User Interface). For example, after saving the document, the
File Save command is disabled. As soon as the document has been
changed, the File Save command is enabled.
If we see a dispatch command, it is text such as .uno:InsertObject or
.uno:GoToStartOfLine. The command is sent to the document’s frame,
and the frame passes on the command until an object is found that can
handle the command.
How the macro recorder uses the dispatch
framework
The macro recorder records the generated dispatches. The recorder is
relatively simple to implement and the same commands that are issued
are recorded for later use. The problem is that not all dispatched
commands are complete. For example, inserting an object generates
the following code:
dispatcher.executeDispatch(document, ".uno:InsertObject", "", 0, Array())
It is not possible to specify what kind of object to create or insert. If an
object is inserted from a file, you cannot specify which file to insert.
I recorded a macro and used Tools > Options to open and modify
configuration items. The generated macro does not record any
configuration changes; in fact, the generated code is commented so it
will not even be run.
rem dispatcher.executeDispatch(document,
".uno:OptionsTreeDialog", "", 0, Array())
If a dialog is opened, the command to open the dialog is likely to be
generated. Any work done inside the dialog is not usually recorded.
Examples include macro organization dialogs, inserting special
characters, and similar types of dialogs. Other possible problems using
the macro recorder include things such as inserting a formula, setting
user data, setting filters in Calc, actions in database forms, and
exporting a document to an encrypted PDF file. You never know for
certain what will work unless you try it, however. The actions from the
search dialog are properly captured, for example.
Other options
When the macro recorder is not able to solve a specific problem, the
usual solution is to write code using the OpenOffice.org objects.
Unfortunately, there is a steep learning curve for the OOo objects. It is
usually best to start with simple examples and then branch out slowly
378 Getting Started with OpenOffice.org 3
Page view 377
1 2 ... 373 374 375 376 377 378 379 380 381 382 383 ... 432 433

Comments to this Manuals

No comments