Bug 115904 - Auto text does not properly insert field variables
Summary: Auto text does not properly insert field variables
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.0.1.1 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: AutoText Fields-Variable
  Show dependency treegraph
 
Reported: 2018-02-21 11:05 UTC by Sven Neuz (SERPENTEQ)
Modified: 2024-01-11 08:06 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Exampe for Auto text does not properly insert field variables (11.08 KB, application/vnd.oasis.opendocument.text)
2018-02-21 11:05 UTC, Sven Neuz (SERPENTEQ)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Neuz (SERPENTEQ) 2018-02-21 11:05:26 UTC
Created attachment 140035 [details]
Exampe for Auto text does not properly insert field variables

If I use AutoText to insert a text with a "Show variable" statement in it, the content of variable is not shown correctly. Instead of the Text "SQ-XXX" a "0" is shown. If I click on the field it correctly shows "Show variable" with the correct name

Steps: 
- Set a text variable to some string.
- Write some text with show variable in it.
- Put that text into AutoText
- Insert the AutoText again.

I've attached a document showing the issue.
First the variable is defined, then two times used manually and then one time inserted from AutoText. The Incremental counter after the variable works just fine but the text variable is not.
Comment 1 Buovjaga 2018-03-08 13:41:58 UTC
(In reply to sven.neuz from comment #0)
> - Put that text into AutoText

How do I do this? I tried to figure AutoText out today for another report, but failed.
Comment 2 Sven Neuz (SERPENTEQ) 2018-03-08 16:02:46 UTC
- Write any text, with formatting, table, ...
- Select the text
- Press Cntl+F3
- Select a category
- Enter a name (important!)
- Click on AutoText => New
Comment 3 Sven Neuz (SERPENTEQ) 2018-03-08 16:03:51 UTC
Note: To reproduce my issue, the AutoText needs to contain a field with function "Show variable"
Comment 4 Buovjaga 2018-03-08 16:19:59 UTC
Thank you very much for the explanation. I was able to test bug 115489 thanks to it. I could not reproduce bug 115489, though, so maybe you could try it.

Actually, I could not repro your problem either.
I selected the first SQ-XXX and turned it to an autotext entry.
When I insert it either from the autotext dialog or with shortcut + F3, I get SQ-XXX.

Arch Linux 64-bit
Version: 6.1.0.0.alpha0+
Build ID: b8fe96f1da2c42c04a8094ca8c57d49763b7bded
CPU threads: 8; OS: Linux 4.15; UI render: default; VCL: kde4; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group
Built on March 8th 2018
Comment 5 Buovjaga 2018-03-08 20:33:01 UTC
(In reply to Buovjaga from comment #4)
> Thank you very much for the explanation. I was able to test bug 115489
> thanks to it. I could not reproduce bug 115489, though, so maybe you could
> try it.

Ok, forget it: the reporter was talking about some 3rd party software.
Comment 6 Sven Neuz (SERPENTEQ) 2018-03-09 09:27:38 UTC
Did you add the complete document to AutoText?

Please try again and DO NOT SELECT THE FIRST LINE.

Why? The first line defines the variable PROJ which is referenced in the rest of the text. 

Select everything but the first line, then add it to AutoText.

Open a new document. 

Insert a field with Set Variable. Variable name = PROJ, value = anything

Insert AutoText. The variable will not be displayed.
Comment 7 Buovjaga 2018-03-09 12:41:12 UTC
(In reply to Sven Neuz (SERPENTEQ) from comment #6)
> Select everything but the first line, then add it to AutoText.
> 
> Open a new document. 
> 
> Insert a field with Set Variable. Variable name = PROJ, value = anything
> 
> Insert AutoText. The variable will not be displayed.

Ok, I repro.

Arch Linux 64-bit
Version: 6.1.0.0.alpha0+
Build ID: b8fe96f1da2c42c04a8094ca8c57d49763b7bded
CPU threads: 8; OS: Linux 4.15; UI render: default; VCL: kde4; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group
Built on March 8th 2018
Comment 8 Sven Neuz (SERPENTEQ) 2018-06-20 13:09:58 UTC
So this affects all platforms, not just Windows. I updated the issue accordingly. Hopefully this will be fixed soon as it has a huge impact on the usage of AutoText.
Comment 9 Sven Neuz (SERPENTEQ) 2018-06-22 09:27:15 UTC
I found a workaround.

-Insert the AutoText
-Save and close (!!!) the document
-Open it again
-Select the entire document
-Press F9
-Field variables will be updated and show the correct value

Closing the document is essential. It will not work otherwise.
Comment 10 QA Administrators 2019-06-23 02:51:13 UTC Comment hidden (obsolete)
Comment 11 Sven Neuz (SERPENTEQ) 2019-06-25 05:23:04 UTC
The bug is still present in the most recent version:
Version: 6.2.4.2 (x64)
Build ID: 2412653d852ce75f65fbfa83fb7e7b669a126d64
CPU threads: 12; OS: Windows 10.0; UI render: GL; VCL: win; 
Locale: de-DE (de_DE); UI-Language: en-US
Calc: threaded
Comment 12 QA Administrators 2021-06-25 03:17:51 UTC Comment hidden (obsolete)
Comment 13 Stéphane Guillou (stragu) 2023-01-02 16:13:26 UTC
Repro in:

Version: 7.5.0.1 (X86_64) / LibreOffice Community
Build ID: 77cd3d7ad4445740a0c6cf977992dafd8ebad8df
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

The text variable is "0", but the counter is correct.
Workaround from comment 9 works.
Comment 14 Andreas Heinisch 2024-01-11 08:06:50 UTC
Code pointer: https://opengrok.libreoffice.org/xref/core/sw/source/core/unocore/unofield.cxx?r=4df22b4d#1763

Somehow the subtype is not correctly retrieved for the field which leads to a formatting of the text as formula which is 0.