Bug 150542 - FILEOPEN DOCX Unused document variable not imported
Summary: FILEOPEN DOCX Unused document variable not imported
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium enhancement
Assignee: Vasily Melenchuk (CIB)
URL:
Whiteboard: target:7.6.0 target:7.5.3
Keywords:
Depends on:
Blocks: DOCX-Fields
  Show dependency treegraph
 
Reported: 2022-08-22 11:06 UTC by Gabor Kelemen (allotropia)
Modified: 2023-04-04 11:29 UTC (History)
1 user (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 Gabor Kelemen (allotropia) 2022-08-22 11:06:03 UTC
This is a followup to bug 150267

DOCX attachment 181588 [details] has set two document variables from VBA macro: 

   ActiveDocument.Variables.Add Name:="FullName", Value:=fName
   ActiveDocument.Variables.Add Name:="Unused", Value:=VarUnused

Of these FullName is inserted into the document as a field, Unused is not.

When this document is opened in Writer, the Unused variable is not imported.

STR:
1, Open  attachment 181588 [details] in Word
2, Run the following macro:

Sub GetDocVars()

   MsgBox ActiveDocument.Variables("FullName").Value & " " & ActiveDocument.Variables("Unused").Value

End Sub

This will show there are two document variables defined.

3, Open the docx file in Writer, go to the Fields dialog (Ctrl-F2), Variables tab.
4, Under User Field there is only the FullName variable listed with the correct Jeff Smith value.

Expected: the Unused field is also imported with the "Hello World" value.
Comment 1 Commit Notification 2023-03-31 12:58:51 UTC
Vasily Melenchuk committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/992d86b1b67a6bd28bbf5e63b2d2406881f476b7

tdf#150542: DOCX import: support for document varibles

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 2 Commit Notification 2023-04-04 06:55:51 UTC
Vasily Melenchuk committed a patch related to this issue.
It has been pushed to "libreoffice-7-5":

https://git.libreoffice.org/core/commit/184a805bc50c593cde950fb0b3253665cc748999

tdf#150542: DOCX import: support for document varibles

It will be available in 7.5.3.

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 3 Gabor Kelemen (allotropia) 2023-04-04 11:29:47 UTC
Verified in

Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: c4a58634753a84b09f20f7271d6525a6656522d3
CPU threads: 14; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: en-US (hu_HU); UI: de-DE
Calc: threaded

Now the "Unused" variable is visible in the Fields dialog.
Also survives changing its value and saving to docx.
Adding a new one in the Fields dialog and saving to docx is also working.
Such changes are correctly appearing in Word too.