Bug 150267 - FILEOPEN DOCX RTF Unused document variable not imported
Summary: FILEOPEN DOCX RTF Unused document variable not imported
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.5.0.0 alpha0+
Hardware: All All
: medium normal
Assignee: Samuel Mehrbrodt (allotropia)
URL: https://support.microsoft.com/en-us/t...
Whiteboard: target:7.5.0 target:7.4.1 target:7.4.2
Keywords:
Depends on:
Blocks: RTF-Fields
  Show dependency treegraph
 
Reported: 2022-08-04 15:23 UTC by Gabor Kelemen (allotropia)
Modified: 2023-01-02 01:25 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Example file from Word 2016 with a macro setting two variables (17.21 KB, application/vnd.ms-word.document.macroEnabled.12)
2022-08-04 15:23 UTC, Gabor Kelemen (allotropia)
Details
The example file saved as docx in Word 2016 (11.44 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2022-08-04 15:24 UTC, Gabor Kelemen (allotropia)
Details
The example file saved as rtf in Word 2016 (41.41 KB, application/msword)
2022-08-04 15:29 UTC, Gabor Kelemen (allotropia)
Details
Querying the document variables in Word with macro in the docx file (62.88 KB, image/png)
2022-08-04 15:32 UTC, Gabor Kelemen (allotropia)
Details
Querying the document variables in Word with macro in the rtf file (65.83 KB, image/png)
2022-08-04 15:33 UTC, Gabor Kelemen (allotropia)
Details
The Variables tab in Writer for the docx file (51.11 KB, image/png)
2022-08-04 15:34 UTC, Gabor Kelemen (allotropia)
Details
The Variables tab in Writer for the rtf file (59.56 KB, image/png)
2022-08-04 15:35 UTC, Gabor Kelemen (allotropia)
Details
attachment 181589 in Word and Writer (109.47 KB, image/png)
2022-09-05 17:46 UTC, Gabor Kelemen (allotropia)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gabor Kelemen (allotropia) 2022-08-04 15:23:58 UTC
Created attachment 181587 [details]
Example file from Word 2016 with a macro setting two variables

Attached document 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 saved as DOCX or RTF and opened in Writer, the Unused variable is not imported, and so it would be lost upon save as well.

1, Open attached docx, rtf files 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, rtf files 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.

Version: 7.5.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: 86b2bfd34a4f07c54f03c8c8dfe48e0810834628
CPU threads: 14; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win
Locale: en-US (hu_HU); UI: en-US
Calc: threaded
Comment 1 Gabor Kelemen (allotropia) 2022-08-04 15:24:27 UTC
Created attachment 181588 [details]
The example file saved as docx in Word 2016
Comment 2 Gabor Kelemen (allotropia) 2022-08-04 15:29:41 UTC
Created attachment 181589 [details]
The example file saved as rtf in Word 2016
Comment 3 Gabor Kelemen (allotropia) 2022-08-04 15:32:57 UTC
Created attachment 181590 [details]
Querying the document variables in Word with macro in the docx file
Comment 4 Gabor Kelemen (allotropia) 2022-08-04 15:33:33 UTC
Created attachment 181591 [details]
Querying the document variables in Word with macro in the rtf file
Comment 5 Gabor Kelemen (allotropia) 2022-08-04 15:34:29 UTC
Created attachment 181592 [details]
The Variables tab in Writer for the docx file
Comment 6 Gabor Kelemen (allotropia) 2022-08-04 15:35:11 UTC
Created attachment 181593 [details]
The Variables tab in Writer for the rtf file
Comment 7 Commit Notification 2022-08-22 06:49:58 UTC
Samuel Mehrbrodt committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/f1adf4e4672b805fbda5682f4e0e6f08aed5ce79

tdf#150267 RTF: Import/Export unused document variables

It will be available in 7.5.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 8 Samuel Mehrbrodt (allotropia) 2022-08-22 06:53:42 UTC
RTF Import/Export is fixed with above commit.

docx export was already implemented with this commit: https://cgit.freedesktop.org/libreoffice/core/commit/?id=ae5f469d3893de73850ccc369dbf426a4acd8f15

docx import is still missing as of today. Maybe open a new bug report for that?
Comment 9 Commit Notification 2022-08-22 09:39:07 UTC
Samuel Mehrbrodt committed a patch related to this issue.
It has been pushed to "libreoffice-7-4":

https://git.libreoffice.org/core/commit/8d36537cea6d976e3fc2a8471d7f52660603839d

tdf#150267 RTF: Import/Export unused document variables

It will be available in 7.4.1.

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 10 Gabor Kelemen (allotropia) 2022-09-05 17:46:42 UTC
Created attachment 182232 [details]
attachment 181589 [details] in Word and Writer

Checked RTF attachment 181589 [details] with:

Version: 7.5.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: dc92a4d973086ce8a6a5f75ba0f4d4c9ca05537a
CPU threads: 14; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win
Locale: en-US (hu_HU); UI: en-US
Calc: threaded

Unfortunately only the unused variables name is imported, its value is still not.
Comment 11 Gabor Kelemen (allotropia) 2022-09-05 17:48:01 UTC
Reopening: the "Unused" variable should have a value of "Hello World" in the Fields dialog, not 0.
Comment 12 Commit Notification 2022-09-12 13:15:19 UTC
Samuel Mehrbrodt committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/5eff45749464739706c9f25cca6c1edff3187f1d

tdf#150267 Import docvar value correctly

It will be available in 7.5.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 13 Commit Notification 2022-09-13 11:43:37 UTC
Samuel Mehrbrodt committed a patch related to this issue.
It has been pushed to "libreoffice-7-4":

https://git.libreoffice.org/core/commit/f2c4ecbd38a274ca36db21a61ef7712b3db8ca87

tdf#150267 Import docvar value correctly

It will be available in 7.4.2.

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 14 Gabor Kelemen (allotropia) 2022-09-13 13:53:27 UTC
Verified in

Version: 7.5.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: c0d09eb46665a0b2ab86f263cc95662f406d83d2
CPU threads: 14; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win
Locale: hu-HU (hu_HU); UI: en-US
Calc: threaded

The value is now correctly imported.