tdf#148806 doc vba: highest priority is ThisDocument AutoOpen
commit3d77fe0af515830001448fde0d394ef20a89002b
authorJustin Luth <justin.luth@collabora.com>
Thu, 6 Oct 2022 23:35:21 +0000 (6 19:35 -0400)
committerJustin Luth <jluth@mail.com>
Sat, 8 Oct 2022 14:14:05 +0000 (8 16:14 +0200)
treee67d4dcbeed77fc31ea3dd69d903f661eea93810
parent07211eda0c90d54d8993febd2af4d9811249a063
tdf#148806 doc vba: highest priority is ThisDocument AutoOpen

Word has three ways of running events at doc open,
although the two AutoOpen methods are exclusive.

One is the special ThisDocument Document_open subroutine.

Another is the AutoOpen subroutine, which is what this
patch is about. It can exist in any module - first come
first served (alphabetically) in doc - except that
ThisDocument is checked first.
[This is very different from Calc - which IGNORES these
functions in ThisWorksheet.]
//TODO: The subroutine must be public

And finally, there can be an AutoOpen module with a Main subroutine.
It is ignored if there is any AutoOpen subroutine.
//TODO: fix the third way.

I tried to create a unit test, but LO's Selection.TypeText
always starts at position 0 for each call, unlike Word
which also starts at position 0 for the first call,
but then remembers where it left off.

Change-Id: I4caf29eefd432c320b5acaf6210222f50a111e89
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141037
Tested-by: Justin Luth <jluth@mail.com>
Reviewed-by: Justin Luth <jluth@mail.com>
offapi/com/sun/star/script/vba/VBAEventId.idl
sw/source/ui/vba/vbaeventshelper.cxx
sw/source/uibase/app/docsh2.cxx