Bug 155780 - FileName Field displays wrong content if IsFixed is True when inserted by Macro.
Summary: FileName Field displays wrong content if IsFixed is True when inserted by Macro.
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
7.4.3.2 release
Hardware: All Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro
  Show dependency treegraph
 
Reported: 2023-06-12 01:21 UTC by Don
Modified: 2025-07-11 03:11 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
Error Demonstration Doc W/ Macro (10.19 KB, application/vnd.oasis.opendocument.text)
2023-06-12 01:22 UTC, Don
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Don 2023-06-12 01:21:57 UTC
Description:
When inserting a FileName Field using a macro the FileName details are displayed incorrectly if IsFixed is set to True.

Steps to Reproduce:
1.Open included document  #OR# CREATE and SAVE a new document, and insert the MACRO included in Other Information.
2. run the MACRO.
3.

Actual Results:
com.sun.star.text.FilenameDisplayFormat.NAME_AND_EXT displays a File name in the format of com.sun.star.text.FilenameDisplayFormat.NAME instead.

Expected Results:
com.sun.star.text.FilenameDisplayFormat.NAME_AND_EXT should display a File name in the format of com.sun.star.text.FilenameDisplayFormat.NAME_AND_EXT


Reproducible: Always


User Profile Reset: Yes

Additional Info:
Version: 7.3.4.2 (x64) / LibreOffice Community
Build ID: 728fec16bd5f605073805c3c9e7c4212a0120dc5
CPU threads: 2; OS: Windows 6.1 Service Pack 1 Build 7601; UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL




MACRO to reproduce error.

REM  *****  BASIC  *****

Sub Main

Dim tDateStruct As New com.sun.star.util.DateTime
Dim oViewCursor, oFile
Dim sString, sText

 oViewCursor = ThisComponent.CurrentController.getViewCursor()
 
sText = "File Format = com.sun.star.text.FilenameDisplayFormat.FULL (0)" & Chr(13) & "Fixed = False"
oViewCursor.Text.insertString(oViewCursor,sText & Chr(13),False)

oFile = ThisComponent.createInstance("com.sun.star.text.TextField.FileName")
oFile.FileFormat = com.sun.star.text.FilenameDisplayFormat.FULL
oFile.IsFixed = False

oViewCursor.Text.insertTextContent(oViewCursor,oFile,False)

sText = Chr(13) &  "File Format = com.sun.star.text.FilenameDisplayFormat.FULL (0)" & Chr(13) & "Fixed = True"
oViewCursor.Text.insertString(oViewCursor,sText & Chr(13),False)

oFile = ThisComponent.createInstance("com.sun.star.text.TextField.FileName")
oFile.FileFormat = com.sun.star.text.FilenameDisplayFormat.FULL
oFile.IsFixed = True

oViewCursor.Text.insertTextContent(oViewCursor,oFile,False)

REM ====================================================

sText = Chr(13) & Chr(13) & "File Format = com.sun.star.text.FilenameDisplayFormat.PATH (1)" & Chr(13) & "Fixed = False"
oViewCursor.Text.insertString(oViewCursor,sText & Chr(13),False)

oFile = ThisComponent.createInstance("com.sun.star.text.TextField.FileName")
oFile.FileFormat = com.sun.star.text.FilenameDisplayFormat.PATH
oFile.IsFixed = False

oViewCursor.Text.insertTextContent(oViewCursor,oFile,False)

sText = Chr(13) & "File Format = com.sun.star.text.FilenameDisplayFormat.PATH (1)" & Chr(13) & "Fixed = True"
oViewCursor.Text.insertString(oViewCursor,sText & Chr(13),False)

oFile = ThisComponent.createInstance("com.sun.star.text.TextField.FileName")
oFile.FileFormat = com.sun.star.text.FilenameDisplayFormat.PATH
oFile.IsFixed = True

oViewCursor.Text.insertTextContent(oViewCursor,oFile,False)

REM ====================================================

sText = Chr(13) & Chr(13) & "File Format = com.sun.star.text.FilenameDisplayFormat.NAME (2)" & Chr(13) & "Fixed = False"
oViewCursor.Text.insertString(oViewCursor,sText & Chr(13),False)

oFile = ThisComponent.createInstance("com.sun.star.text.TextField.FileName")
oFile.FileFormat = com.sun.star.text.FilenameDisplayFormat.NAME
oFile.IsFixed = False

oViewCursor.Text.insertTextContent(oViewCursor,oFile,False)

sText = Chr(13) & "File Format = com.sun.star.text.FilenameDisplayFormat.NAME (2)" & Chr(13) & "Fixed = True"
oViewCursor.Text.insertString(oViewCursor,sText & Chr(13),False)

oFile = ThisComponent.createInstance("com.sun.star.text.TextField.FileName")
oFile.FileFormat = com.sun.star.text.FilenameDisplayFormat.NAME
oFile.IsFixed = True

oViewCursor.Text.insertTextContent(oViewCursor,oFile,False)

REM ====================================================

sText = Chr(13) & Chr(13) & "File Format = com.sun.star.text.FilenameDisplayFormat.NAME_AND_EXT (3)" & Chr(13) & "Fixed = False"
oViewCursor.Text.insertString(oViewCursor,sText & Chr(13),False)

oFile = ThisComponent.createInstance("com.sun.star.text.TextField.FileName")
oFile.FileFormat = com.sun.star.text.FilenameDisplayFormat.NAME_AND_EXT
oFile.IsFixed = False

oViewCursor.Text.insertTextContent(oViewCursor,oFile,False)

sText = Chr(13) &  "File Format = com.sun.star.text.FilenameDisplayFormat.NAME_AND_EXT (3)" & Chr(13) & "Fixed = True"
oViewCursor.Text.insertString(oViewCursor,sText & Chr(13),False)

oFile = ThisComponent.createInstance("com.sun.star.text.TextField.FileName")
oFile.FileFormat = com.sun.star.text.FilenameDisplayFormat.NAME_AND_EXT
oFile.IsFixed = True

oViewCursor.Text.insertTextContent(oViewCursor,oFile,False)

End Sub
Comment 1 Don 2023-06-12 01:22:41 UTC
Created attachment 187852 [details]
Error Demonstration Doc W/ Macro
Comment 2 russ 2023-07-10 21:50:27 UTC
Thank you for reporting the bug. I can confirm that the bug is present in

Version: 7.5.4.2 (X86_64) / LibreOffice Community
Build ID: 36ccfdc35048b057fd9854c757a8b67ec53977b6
CPU threads: 12; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: threaded

Reproduced on a new document using Don's macro. In addition to Don's observed behavior, additional incorrect behavior was observed when IsFixed is set to True:

Actual Results:
com.sun.star.text.FilenameDisplayFormat.FULL displays a File name in the format of com.sun.star.text.FilenameDisplayFormat.NAME_AND_EXT instead.
com.sun.star.text.FilenameDisplayFormat.PATH displays a File name in the format of com.sun.star.text.FilenameDisplayFormat.FULL instead.
com.sun.star.text.FilenameDisplayFormat.NAME displays a File name in the format of com.sun.star.text.FilenameDisplayFormat.PATH instead.

Expected Results:
com.sun.star.text.FilenameDisplayFormat.FULL should display a File name in the format of com.sun.star.text.FilenameDisplayFormat.FULL
com.sun.star.text.FilenameDisplayFormat.PATH should display a File name in the format of com.sun.star.text.FilenameDisplayFormat.PATH
com.sun.star.text.FilenameDisplayFormat.NAME should display a File name in the format of com.sun.star.text.FilenameDisplayFormat.NAME

There appears to be an off-by-one error when IsFixed is set to True.
Comment 3 QA Administrators 2025-07-11 03:11:39 UTC
Dear Don,

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword


Feel free to come ask questions or to say hello in our QA chat: https://web.libera.chat/?settings=#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-UntouchedBug