https://bugs.documentfoundation.org/show_bug.cgi?id=173222

            Bug ID: 173222
           Summary: Windows FilePicker: setDefaultName() is ignored with
                    FILESAVE_SIMPLE because AUTOEXTENSION control is
                    unavailable
           Product: LibreOffice
           Version: 25.2.5.2 release
          Hardware: All
                OS: Windows (All)
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: framework
          Assignee: [email protected]
          Reporter: [email protected]

Description:
On Windows, XFilePicker::setDefaultName() does not populate the file name field
when the FilePicker is initialized with TemplateDescription::FILESAVE_SIMPLE.
The same call works correctly with TemplateDescription::FILESAVE_AUTOEXTENSION.
The issue is reproducible independently of file filters.

Steps to Reproduce:
1. In LibreOffice Basic, create a com.sun.star.ui.dialogs.FilePicker.
2. Initialize it with TemplateDescription.FILESAVE_SIMPLE.
3. Call setDefaultName("zz.txt").
4. Execute the FilePicker.

Minimal reproducer:

Sub TestFilePicker
    Dim oPicker As Object

    oPicker = CreateUnoService("com.sun.star.ui.dialogs.FilePicker")

    oPicker.initialize(Array( _
        com.sun.star.ui.dialogs.TemplateDescription.FILESAVE_SIMPLE))

    oPicker.setDefaultName("zz.txt")
    oPicker.execute()
End Sub

For comparison, replace FILESAVE_SIMPLE with FILESAVE_AUTOEXTENSION and execute
the same code again.

Actual Results:
With FILESAVE_SIMPLE, the native Windows Save dialog opens but the file name
field is empty.

With FILESAVE_AUTOEXTENSION, "file.txt" is correctly displayed in the file name
field.

The result with FILESAVE_SIMPLE is unchanged when no file filters are
configured, when a "*.*" filter is added, or when that filter is explicitly
selected as the current filter.

Expected Results:
setDefaultName("zz.txt") should populate the file name field with "zz.txt" when
using FILESAVE_SIMPLE, independently of whether the AUTOEXTENSION feature is
enabled.


Reproducible: Always


User Profile Reset: No

Additional Info:
Version: 26.2.5.2 (X86_64)
Build ID: cd7284b4cbbfeb507e630c1aac019f4157393acb
CPU threads: 28; OS: Windows 11 X86_64 (build 26200); UI render: Skia/Raster;
VCL: win
Locale: it-IT (it_IT); UI: it-IT
Calc: CL threaded

Source-code investigation:

In fpicker/source/win32/VistaFilePickerImpl.cxx,
VistaFilePickerImpl::impl_sta_SetDefaultName() queries
CHECKBOX_AUTOEXTENSION before calling IFileDialog::SetFileName().

If GetCheckButtonState() fails, the function returns immediately.

With FILESAVE_SIMPLE, VistaFilePicker::initialize() does not enable
FEATURE_AUTOEXTENSION. Therefore the AUTOEXTENSION control is not
available, and the call appears to fail before execution reaches
IFileDialog::SetFileName().

With FILESAVE_AUTOEXTENSION, FEATURE_AUTOEXTENSION is enabled and
setDefaultName() works as expected.

This suggests that failure to query the optional AUTOEXTENSION control
should not prevent the default file name itself from being set.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to