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
Created attachment 187852 [details] Error Demonstration Doc W/ Macro
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.