Talk:Macros in Database Documents
From Apache OpenOffice Wiki
ThisComponent
We need to decide whether ThisComponent
should be the "invoking document", or the "document where the script is located". Several aspects have to be taken into account:
- Macros can be executed from within documents (usually, but not necessarily, by some user interaction), or from within the Basic IDE
- Macros can be located in the application-wide Basic libraries, or in some document-local Basic libraries
There's a number of different and independent options:
- Application Basic
ThisComponent
always points to the component which is, or was last, active. In particular, if a component is active which does not have an own model, such as for instance the query designer, thenThisComponent
will refer to the controller of this component.ThisComponent
always points to the document which was last active, in either being active itself, or having a sub frame which was last active.- Document Basic
ThisComponent
always refers to the component which is, or was last, active. As an immediate consequence, a second variable is needed for referring to the document in which the macro is actually embedded.ThisComponent
always refers to the document in which the macro is actually embedded. As a consequence, a second variable is needed for the component which is, or was last, active.
Notes
- Item 1.2 from above does not really sound appealing at all, does it? This is way too different from current associations people would have with
ThisComponent
. - The Developer's Guide states that
ThisComponent
in the application Basic is identical to desktop's CurrentComponent, modulo the Basic IDE. - If database components would participate in the desktop's CurrentComponent game (i.e. when you ask for the current component at the desktop, also database documents and their sub components are returned, provided that they were last active), then perhaps 2.2 wouldn't need a new dedicated variable for the active component, since this would be the same as Desktop.CurrentComponent then.
- On the contrary, Desktop.CurrentComponent isn't really recommended for usage: It depends on the focus of frames, and focus behavior is all but reliable and predictable on the different platforms.
- For completeness: The same unreliability and unpredictability holds for the application-level
ThisComponent
, as it also depends on the focus. - If a new variable is introduced, it is debatable whether
- it should appear in document's Basic only, but then in all document types
- it should appear only in database documents' Basic
The second would probably provide more consistency, but might be superfluous since in all document types except database documents, the new variable would always be the same as ThisComponent
- Feedback from users seems to tend into the direction that
ThisComponent
should be the component from which the macro was invoked (which should equal the active document at invocation time).