The document events I'm using on a regular basis (currently with all my documents) are: OnViewCreated OnDocumentHasBeenSaved OnDocumentHasBeenSavedAs If a document is containing macros, and macro execution was not permitted when opening it (Security Options), the Sub stored to the local Standard library, and assigned to the mentioned events, are not called. Steps to reproduce: Edit Basic macros for LibO. (No document opened.) Create an arbitrary hello-world-macro in a module of the local Standard library. Assign this macro to 'On View Created' via >Tools>Customize>Events (LibreOffice as target). Have at hand any document containing a macro. Open it with either Macro Security 'High' or 'Medium' and macros not permitted. Expected: The mentioned hello-world-macro is executed. Experienced: No action. Open the same document permitting the execution of document macros. Expected: The mentioned hello-world-macro is executed. Experienced: As expected. The bug: Macro security should only concern document macros. Local macros and their bindings to events shouldn't be afflicted. Since the bug depends on the local settings and event bindings, it can't be demonstrated by an example file.
I added a Calc Hello World macro to My Macros > Standard > Module1 and it works with View Created even with High macro security. I got the macro from https://www.debugpoint.com/2014/09/writing-a-macro-in-libreoffice-calc-getting-started/ I tested both with 7.2.0 and the latest master. Arch Linux 64-bit Version: 7.4.0.0.alpha1+ / LibreOffice Community Build ID: ff2b4bff61d2e1679bb525d754c960c48b81c495 CPU threads: 8; OS: Linux 5.17; UI render: default; VCL: kf5 (cairo+xcb) Locale: fi-FI (fi_FI.UTF-8); UI: en-US Calc: threaded Built on 25 May 2022 Macro: REM ***** BASIC ***** sub hello_world dim document as object dim dispatcher as object document = ThisComponent.CurrentController.Frame dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") dim args1(0) as new com.sun.star.beans.PropertyValue dim args2(0) as new com.sun.star.beans.PropertyValue args1(0).Name = "ToPoint" args1(0).Value = "$A$1" dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1()) args2(0).Name = "StringName" args2(0).Value = "Hello World!" dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args2()) msgbox "Completed!" end sub
Created attachment 180375 [details] containing local code and a tiny "Hello World" macro. (In reply to Buovjaga from comment #1) > I added a Calc Hello World macro to My Macros > Standard > Module1 and it > works with View Created even with High macro security. ... I did neither see reasons for using a recorded macro for the test nor for using one specialized on Calc. It is expected to throw an error if a different doctype has created its view. The macro actually bound to onViewCreated by customization on my Win 10 system currently working with LibO V 7.3.3.2 is: Sub onViewCreated(pEvent) showFileLocationInTitleBar(pEvent.Source, preferredPathStyle, preferredLastModifiedFormat, queryPartContent) End Sub where the called macro does NOT call in turn any document macros. You will find every detail of probable interest in the attached example. I do not attach, however, my complete buser profile. ;-) If I open exactly this attached document on my customized install for which macro security is set to 'Medium', I experience the originallky reported bug: Having permitted the execution of dopcument macros I get all the additional information I want to see in the titlke bar. Having prohibited the execution of document macro no info is appeneded: The onViewCreated() macro simply is not called.
I had forgotten to test with a document containing a macro, so I did a new test. I can reproduce.