Bug 153728 - Can't assign macro to autotext
Summary: Can't assign macro to autotext
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.2.5.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:7.6.0
Keywords: bibisectRequest, regression
Depends on:
Blocks:
 
Reported: 2023-02-19 10:12 UTC by Dorange-Pattoret Didier
Modified: 2023-02-27 09:03 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dorange-Pattoret Didier 2023-02-19 10:12:20 UTC
Description:
It is impossible to assign macro to an autotext.


Steps to Reproduce:
1.Write a macro in Standard Library like 
Sub PrintBefore
  Print "Before"
End Sub
2. Write and Select "Toto" in Writer.
3. Type Ctrl+F3 to create an autotext witch return "Toto" when you type to + F3
4. Try to assign the PrintBefore macro to.

Actual Results:
If I type to+F3, I get only "Toto"

Expected Results:
First run the macro (Print "Before") and then get "Toto"


Reproducible: Always


User Profile Reset: No

Additional Info:
It works fine with LO 6.2.4.2 and OpenOffice, but same problem with LO 7.3
So it's a regression.
Comment 1 raal 2023-02-20 19:04:01 UTC
Confirm with dev version. Seems to be a problem in Assign macro dialog - assignment is not saved.
Comment 2 raal 2023-02-20 19:33:49 UTC
Bisected to
 eba51f6eb336ff271fbade0e5fe108c8cb525f8c is the first bad commit
commit eba51f6eb336ff271fbade0e5fe108c8cb525f8c
Author: Jenkins Build User <tdf@pollux.tdf>
Date:   Sat Dec 18 07:03:33 2021 +0100

    source 1addd8c104f6ad390bdd0ca61cd5ce97b55ce218

https://git.libreoffice.org/core/+/1addd8c104f6ad390bdd0ca61cd5ce97b55ce218

Noel, Justin, is the bisect relevant? Thank you
Comment 3 Justin L 2023-02-20 20:21:17 UTC
Please detail more clearly exactly how you are getting the macro to run? I tried in 6.3 and get nothing.

I did:
-type "Toto" in writer. Select it, and press Ctrl-F3
   -select MyAutoText category, enter a name (jl) and a shortcut (jl)
   -select AutoText - New dropdown.
   -select MyAutoText - jl
   -select AutoText - Macro... - My Macros - Standard - Modules1 - Main
   -select AutoText - replace

-Tools - Macros - Edit  and put msgbox "hello" in Sub Main

- in Writer, type jl <F3>
I get the autotext (Toto), but no macro running. So what am I doing wrong in trying to assign the macro? How can you tell if there is a macro assigned?
Comment 4 Justin L 2023-02-20 20:22:39 UTC
Oh - I kept missing the "assign" button. I found it now.
Comment 5 Justin L 2023-02-20 20:44:36 UTC
I confirmed with bibisect 7.2 that you got the right commit. It doesn't make much sense though since it is just a revert.

And yet all these are autotext related commits, so somehow the macro bits must have adapted to the change made in 7.0. (I bibisected around the change made in 7.0, and it was working before Noel's commit too - so it wasn't something he "fixed".)
Comment 6 Justin L 2023-02-21 13:10:54 UTC
If we look at Noel's https://gerrit.libreoffice.org/c/core/+/86477, we can see in the relation chain that there is also 
    "convert XMLAutoTextEventImport to FastParser APIs"
which is the next commit made.

I tried to compile LO 7.0 at this commit, but had general compile errors (although I was able to compile last70onmaster). So I couldn't confirm that this is the dependent change, but it is quite likely.

I attempted to revert b8f932e1df1efb230230ab1f1b9c8cfc822a0f4c also, but it is not trivial to do, and I don't understand this code, so I didn't spend much time on it.

Likely the best thing to do is to revert my revert and find a proper fix for bug 144364. (I see an exception when running my unit test, so that is probably a good place to start for fixing that bug.  make CppunitTest_sw_uiwriter8 CPPUNIT_TEST_NAME=testTdf144364)
Comment 7 Noel Grandin 2023-02-21 14:15:23 UTC
fix is here: https://gerrit.libreoffice.org/c/core/+/147399
Comment 8 Commit Notification 2023-02-21 18:48:30 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/4d020dfe1439e963f0b2367ba984c2eb6eb153a5

tdf#153728 Can't assign macro to autotext

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 9 Dorange-Pattoret Didier 2023-02-23 09:10:05 UTC
Thanks for your work.
The patch will not be pushed in LO 7.5.1 ?
Best regards.
Comment 10 Dorange-Pattoret Didier 2023-02-23 09:14:19 UTC Comment hidden (obsolete)
Comment 11 Dorange-Pattoret Didier 2023-02-27 09:03:24 UTC
Hello,
I tried with LO Dev 7.6 : it works fine.
Thanks.
Why not in LO 7.5.1 ?