fpicker/source/aqua/ControlHelper.mm                   |    5 +
 fpicker/source/aqua/SalAquaFilePicker.mm               |    3 
 fpicker/source/office/OfficeFilePicker.cxx             |    4 +
 fpicker/source/win32/VistaFilePicker.cxx               |    9 ++
 fpicker/source/win32/VistaFilePickerImpl.cxx           |    1 
 include/sfx2/docfile.hxx                               |    2 
 include/sfx2/filedlghelper.hxx                         |    3 
 include/unotools/filteroptions_settings.hxx            |   59 +++++++++++++++++
 offapi/com/sun/star/ui/dialogs/TemplateDescription.idl |   11 +++
 officecfg/registry/schema/org/openoffice/Office/UI.xcs |   18 +++++
 sc/inc/filtuno.hxx                                     |    1 
 sc/source/ui/dbgui/scuiasciiopt.cxx                    |   17 ++++
 sc/source/ui/inc/scuiasciiopt.hxx                      |    1 
 sc/source/ui/unoobj/filtuno.cxx                        |   12 ++-
 sc/uiconfig/scalc/ui/textimportcsv.ui                  |   18 ++++-
 sfx2/source/appl/appopen.cxx                           |   21 ++++--
 sfx2/source/dialog/filedlghelper.cxx                   |   43 ++++++++++--
 sfx2/source/doc/docfile.cxx                            |   17 +++-
 sfx2/source/doc/objstor.cxx                            |    7 ++
 uui/source/iahndl-filter.cxx                           |    8 ++
 vcl/qt5/QtFilePicker.cxx                               |    6 +
 vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx              |    7 ++
 vcl/unx/gtk3_kde5/gtk3_kde5_filepicker.cxx             |    6 +
 23 files changed, 261 insertions(+), 18 deletions(-)

New commits:
commit bd1c60bcf290d50a8d496246a785f346a20af04d
Author:     Shardul Vikram Singh <shardulvi...@gmail.com>
AuthorDate: Tue Mar 18 04:02:23 2025 +0530
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Fri Mar 28 14:50:32 2025 +0100

    [API CHANGE] tdf#74580 Add option to skip filter settings dialog
    
    Introduce a new set of setting under org.openoffice.Office.UI/FilePicker
    to control whether the settings dialogs of filters always appears. Add an
    "Edit Filter Settings" checkbox to the File Open dialog, using the new API
    constant FILEOPEN_READONLY_VERSION_FILTEROPTIONS (TemplateDescription.idl)
    to show additional controls: "Read Only", "Filter Options", and "Version"
    listbox.
    
    Modify the Calc's Text Import filter settings dialog to include an "Always
    Show on Import" checkbox.
    
    Co-authored-by: Mike Kaganski <mike.kagan...@collabora.com>
    
    Change-Id: Ic7bea0036ae2db8f8ab223f48499fb0cc8b18425
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183055
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins

diff --git a/fpicker/source/aqua/ControlHelper.mm 
b/fpicker/source/aqua/ControlHelper.mm
index ef8c00cdbc79..fd856048b470 100644
--- a/fpicker/source/aqua/ControlHelper.mm
+++ b/fpicker/source/aqua/ControlHelper.mm
@@ -221,6 +221,11 @@ void ControlHelper::initialize( sal_Int16 nTemplateId )
             m_bToggleVisibility[READONLY] = true;
             m_bListVisibility[VERSION] = true;
             break;
+        case FILEOPEN_READONLY_VERSION_FILTEROPTIONS:
+            m_bToggleVisibility[FILTEROPTIONS] = true;
+            m_bToggleVisibility[READONLY] = true;
+            m_bListVisibility[VERSION] = true;
+            break;
         case FILEOPEN_LINK_PREVIEW:
             m_bToggleVisibility[LINK] = true;
             m_bToggleVisibility[PREVIEW] = true;
diff --git a/fpicker/source/aqua/SalAquaFilePicker.mm 
b/fpicker/source/aqua/SalAquaFilePicker.mm
index 01e6f80e92b5..038c539de94f 100644
--- a/fpicker/source/aqua/SalAquaFilePicker.mm
+++ b/fpicker/source/aqua/SalAquaFilePicker.mm
@@ -423,6 +423,9 @@ void SAL_CALL SalAquaFilePicker::initialize( const 
uno::Sequence<uno::Any>& aArg
         case FILEOPEN_READONLY_VERSION:
             m_nDialogType = NAVIGATIONSERVICES_OPEN;
             break;
+        case FILEOPEN_READONLY_VERSION_FILTEROPTIONS:
+            m_nDialogType = NAVIGATIONSERVICES_OPEN;
+            break;
         case FILEOPEN_LINK_PREVIEW:
             m_nDialogType = NAVIGATIONSERVICES_OPEN;
             break;
diff --git a/fpicker/source/office/OfficeFilePicker.cxx 
b/fpicker/source/office/OfficeFilePicker.cxx
index 6d845f3fd0c3..5117d18042df 100644
--- a/fpicker/source/office/OfficeFilePicker.cxx
+++ b/fpicker/source/office/OfficeFilePicker.cxx
@@ -272,6 +272,10 @@ PickerFlags SvtFilePicker::getPickerFlags() const
     {
         nBits = PickerFlags::Open | PickerFlags::ReadOnly | 
PickerFlags::ShowVersions;
     }
+    else if ( m_nServiceType == 
TemplateDescription::FILEOPEN_READONLY_VERSION_FILTEROPTIONS )
+    {
+        nBits = PickerFlags::Open | PickerFlags::ReadOnly | 
PickerFlags::ShowVersions | PickerFlags::FilterOptions;
+    }
     else if ( m_nServiceType == TemplateDescription::FILEOPEN_LINK_PREVIEW )
     {
         nBits = PickerFlags::Open | PickerFlags::InsertAsLink | 
PickerFlags::ShowPreview;
diff --git a/fpicker/source/win32/VistaFilePicker.cxx 
b/fpicker/source/win32/VistaFilePicker.cxx
index ac35296f12fb..e4f5bd6ce599 100644
--- a/fpicker/source/win32/VistaFilePicker.cxx
+++ b/fpicker/source/win32/VistaFilePicker.cxx
@@ -439,6 +439,15 @@ void SAL_CALL VistaFilePicker::initialize(const 
css::uno::Sequence< css::uno::An
         }
         break;
 
+        case 
css::ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION_FILTEROPTIONS :
+        {
+            bFileOpenDialog  = true;
+            nFeatures        |= FEATURE_READONLY;
+            nFeatures        |= FEATURE_VERSION;
+            nFeatures        |= FEATURE_FILTEROPTIONS;
+        }
+        break;
+
         case css::ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW :
         {
             bFileOpenDialog  = true;
diff --git a/fpicker/source/win32/VistaFilePickerImpl.cxx 
b/fpicker/source/win32/VistaFilePickerImpl.cxx
index 3ffe0883d128..06df9a49aba3 100644
--- a/fpicker/source/win32/VistaFilePickerImpl.cxx
+++ b/fpicker/source/win32/VistaFilePickerImpl.cxx
@@ -543,6 +543,7 @@ void 
VistaFilePickerImpl::impl_sta_enableFeatures(::sal_Int32 nFeatures, ::sal_I
             break;
 
         case css::ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION :
+        case 
css::ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION_FILTEROPTIONS :
         case 
css::ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS
 :
             aGUID = CLIENTID_FILEDIALOG_OPTIONS;
             break;
diff --git a/include/sfx2/docfile.hxx b/include/sfx2/docfile.hxx
index 6ab8d2ce5571..0db2d3264283 100644
--- a/include/sfx2/docfile.hxx
+++ b/include/sfx2/docfile.hxx
@@ -204,6 +204,8 @@ public:
 
     [[nodiscard]] bool IsRepairPackage() const;
 
+    [[nodiscard]] bool ShowFilterDialog() const;
+
     css::uno::Reference< css::io::XInputStream > const &  GetInputStream();
 
     void                CreateTempFile( bool bReplace = true );
diff --git a/include/sfx2/filedlghelper.hxx b/include/sfx2/filedlghelper.hxx
index 94dac23f05be..bc8055e4d45f 100644
--- a/include/sfx2/filedlghelper.hxx
+++ b/include/sfx2/filedlghelper.hxx
@@ -299,7 +299,8 @@ ErrCode FileOpenDialog_Impl( weld::Window* pParent,
                              const OUString* pPath,
                              sal_Int16 nDialog,
                              const OUString& rStandardDir,
-                             const css::uno::Sequence< OUString >& rDenyList = 
css::uno::Sequence< OUString >());
+                             const css::uno::Sequence< OUString >& rDenyList,
+                             bool& rShowFilterDialog );
 
 css::uno::Reference<css::ui::dialogs::XFolderPicker2> SFX2_DLLPUBLIC 
createFolderPicker(const css::uno::Reference<css::uno::XComponentContext>& 
rContext, weld::Window* pPreferredParent);
 
diff --git a/include/unotools/filteroptions_settings.hxx 
b/include/unotools/filteroptions_settings.hxx
new file mode 100644
index 000000000000..2f4a3aea2b77
--- /dev/null
+++ b/include/unotools/filteroptions_settings.hxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include <sal/config.h>
+
+#include <rtl/ustring.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <officecfg/Office/UI.hxx>
+
+namespace utl
+{
+// Read-only access for elements under 
org.openoffice.Office.UI/FilePicker/ShowFilterDialog
+inline css::uno::Reference<css::beans::XPropertySet>
+getSettingsForFilterOptions(const OUString& filter)
+{
+    auto xNameAccess = 
officecfg::Office::UI::FilePicker::ShowFilterDialog::get();
+    if (xNameAccess->hasByName(filter))
+        return 
xNameAccess->getByName(filter).query<css::beans::XPropertySet>();
+    return {};
+}
+
+// Write access for elements under 
org.openoffice.Office.UI/FilePicker/ShowFilterDialog
+inline css::uno::Reference<css::beans::XPropertySet>
+getSettingsForFilterOptions(const OUString& filter,
+                            const 
std::shared_ptr<comphelper::ConfigurationChanges>& batch)
+{
+    auto xNameContainer = 
officecfg::Office::UI::FilePicker::ShowFilterDialog::get(batch);
+    if (!xNameContainer->hasByName(filter))
+    {
+        auto xFactory = 
xNameContainer.queryThrow<css::lang::XSingleServiceFactory>();
+        xNameContainer->insertByName(filter, 
css::uno::Any(xFactory->createInstance()));
+    }
+    return xNameContainer->getByName(filter).query<css::beans::XPropertySet>();
+}
+
+inline bool isShowFilterOptionsDialog(const OUString& filter)
+{
+    if (auto settings = getSettingsForFilterOptions(filter))
+        return settings->getPropertyValue(u"show"_ustr).get<bool>();
+    return true; // default is show
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/offapi/com/sun/star/ui/dialogs/TemplateDescription.idl 
b/offapi/com/sun/star/ui/dialogs/TemplateDescription.idl
index fe3ef6f97039..4f286bf1eb02 100644
--- a/offapi/com/sun/star/ui/dialogs/TemplateDescription.idl
+++ b/offapi/com/sun/star/ui/dialogs/TemplateDescription.idl
@@ -142,6 +142,17 @@ published constants TemplateDescription
         @since LibreOffice 6.1
     */
     const short FILEOPEN_LINK_PREVIEW_IMAGE_ANCHOR             = 13;
+
+    /** A FileOpen dialog with additional controls.
+        <ul>
+            <li>A checkbox "Read only"</li>
+            <li>A checkbox "Filter Options"</li>
+            <li>A listbox "Version" for selecting a document version</li>
+        </ul>
+
+        @since LibreOffice 25.8
+    */
+    const short FILEOPEN_READONLY_VERSION_FILTEROPTIONS        = 14;
 };
 
 
diff --git a/officecfg/registry/schema/org/openoffice/Office/UI.xcs 
b/officecfg/registry/schema/org/openoffice/Office/UI.xcs
index 82875cdb0249..1716cee951a4 100644
--- a/officecfg/registry/schema/org/openoffice/Office/UI.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/UI.xcs
@@ -1498,6 +1498,18 @@
         </prop>
       </group>
     </group>
+    <group oor:name="FilterDialogSettings">
+      <info>
+        <desc>Configuration related to display of a filter's settings 
dialog</desc>
+      </info>
+      <prop oor:name="show" oor:type="xs:boolean" oor:nillable="false">
+        <info>
+          <desc>A filter's settings dialog may be set to show or not.</desc>
+          <label>Show settings dialog for this filter</label>
+        </info>
+        <value>true</value>
+      </prop>
+    </group>
   </templates>
   <component>
     <group oor:name="FilterClassification">
@@ -1589,6 +1601,12 @@
           <value>30000</value>
         </prop>
       </group>
+      <set oor:name="ShowFilterDialog" oor:node-type="FilterDialogSettings">
+        <info>
+          <desc>Contains the flags controlling if a filter fialog should be 
shown for a given filter. The default is true.</desc>
+          <label>Should the settings dialog be shown for this filter</label>
+        </info>
+      </set>
     </group>
   </component>
 </oor:component-schema>
diff --git a/sc/inc/filtuno.hxx b/sc/inc/filtuno.hxx
index 100fdeb001d4..272a94fd6344 100644
--- a/sc/inc/filtuno.hxx
+++ b/sc/inc/filtuno.hxx
@@ -45,6 +45,7 @@ private:
     css::uno::Reference< css::io::XInputStream > xInputStream;
     css::uno::Reference< css::awt::XWindow > xDialogParent;
     bool         bExport;
+    bool mbForceShow = false;
 
 public:
                             ScFilterOptionsObj();
diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx 
b/sc/source/ui/dbgui/scuiasciiopt.cxx
index c44bf2ad222d..5a8c75a00f9d 100644
--- a/sc/source/ui/dbgui/scuiasciiopt.cxx
+++ b/sc/source/ui/dbgui/scuiasciiopt.cxx
@@ -43,6 +43,7 @@
 #include <unicode/ucsdet.h>
 #include <sfx2/objsh.hxx>
 #include <svx/txenctab.hxx>
+#include <unotools/filteroptions_settings.hxx>
 #include <unotools/viewoptions.hxx>
 
 //! TODO make dynamic
@@ -373,6 +374,7 @@ ScImportAsciiDlg::ScImportAsciiDlg(weld::Window* pParent, 
std::u16string_view aD
     , mxLbType(m_xBuilder->weld_combo_box(u"columntype"_ustr))
     , mxAltTitle(m_xBuilder->weld_label(u"textalttitle"_ustr))
     , mxTableBox(new ScCsvTableBox(*m_xBuilder))
+    , 
mxCkbAlwaysShowOnImport(m_xBuilder->weld_check_button(u"alwaysshowonimport"_ustr))
 {
     SvtViewOptions aDlgOpt(EViewType::Dialog, "TextImportCsvDialog");
     if (aDlgOpt.Exists())
@@ -390,6 +392,9 @@ ScImportAsciiDlg::ScImportAsciiDlg(weld::Window* pParent, 
std::u16string_view aD
                 aName += OUString::Concat(" - [") + aDatName + "]";
                 m_xDialog->set_title(aName);
             }
+            mxCkbAlwaysShowOnImport->show();
+            mxCkbAlwaysShowOnImport->set_active(
+                utl::isShowFilterOptionsDialog(SC_TEXT_CSV_FILTER_NAME));
             break;
         default:
             break;
@@ -689,6 +694,18 @@ void ScImportAsciiDlg::GetOptions( ScAsciiOptions& rOpt )
 
 void ScImportAsciiDlg::SaveParameters()
 {
+    if (mxCkbAlwaysShowOnImport->get_visible())
+    {
+        bool value(mxCkbAlwaysShowOnImport->get_active());
+        if (value != utl::isShowFilterOptionsDialog(SC_TEXT_CSV_FILTER_NAME))
+        {
+            auto pChange(comphelper::ConfigurationChanges::create());
+            auto xFilterDialogSettings(
+                utl::getSettingsForFilterOptions(SC_TEXT_CSV_FILTER_NAME, 
pChange));
+            xFilterDialogSettings->setPropertyValue(u"show"_ustr, Any(value));
+            pChange->commit();
+        }
+    }
     lcl_SaveSeparators( GetSeparators(), mxCbTextSep->get_active_text(), 
mxCkbAsOnce->get_active(),
                      mxCkbQuotedAsText->get_active(), 
mxCkbDetectNumber->get_active(), mxCkbDetectScientificNumber->get_active(),
                      mxRbFixed->get_active() ? FIXED : 
(mxRbDetectSep->get_active() ? DETECT_SEPARATOR : SEPARATOR),
diff --git a/sc/source/ui/inc/scuiasciiopt.hxx 
b/sc/source/ui/inc/scuiasciiopt.hxx
index 5b19b8c4d3ee..3c4d9057f92a 100644
--- a/sc/source/ui/inc/scuiasciiopt.hxx
+++ b/sc/source/ui/inc/scuiasciiopt.hxx
@@ -84,6 +84,7 @@ class ScImportAsciiDlg : public weld::GenericDialogController
     std::unique_ptr<weld::Label> mxAltTitle;
 
     std::unique_ptr<ScCsvTableBox> mxTableBox;
+    std::unique_ptr<weld::CheckButton> mxCkbAlwaysShowOnImport;
 
 public:
                                 ScImportAsciiDlg(
diff --git a/sc/source/ui/unoobj/filtuno.cxx b/sc/source/ui/unoobj/filtuno.cxx
index 575d66147b64..c0048fcc6132 100644
--- a/sc/source/ui/unoobj/filtuno.cxx
+++ b/sc/source/ui/unoobj/filtuno.cxx
@@ -20,6 +20,7 @@
 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
 #include <tools/urlobj.hxx>
 #include <vcl/svapp.hxx>
+#include <unotools/filteroptions_settings.hxx>
 #include <unotools/ucbstreamhelper.hxx>
 #include <connectivity/dbtools.hxx>
 #include <osl/diagnose.h>
@@ -188,11 +189,16 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute()
 
         ScopedVclPtr<AbstractScImportAsciiDlg> 
pDlg(pFact->CreateScImportAsciiDlg(Application::GetFrameWeld(xDialogParent), 
aPrivDatName,
                                                                                
   pInStream.get(), SC_IMPORTFILE));
-        if ( pDlg->Execute() == RET_OK )
+
+        const bool bShow = mbForceShow || 
utl::isShowFilterOptionsDialog(aFilterString);
+        const bool bOk = !bShow || pDlg->Execute() == RET_OK;
+
+        if (bOk)
         {
             ScAsciiOptions aOptions;
             pDlg->GetOptions( aOptions );
-            pDlg->SaveParameters();
+            if (bShow)
+                pDlg->SaveParameters();
             aFilterOptions = aOptions.WriteToString();
             nRet = ui::dialogs::ExecutableDialogResults::OK;
         }
@@ -366,6 +372,8 @@ void SAL_CALL ScFilterOptionsObj::initialize(const 
uno::Sequence<uno::Any>& rArg
     ::comphelper::NamedValueCollection aProperties(rArguments);
     if (aProperties.has(u"ParentWindow"_ustr))
         aProperties.get(u"ParentWindow"_ustr) >>= xDialogParent;
+    if (aProperties.has(u"ShowFilterDialog"_ustr))
+        aProperties.get(u"ShowFilterDialog"_ustr) >>= mbForceShow;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/uiconfig/scalc/ui/textimportcsv.ui 
b/sc/uiconfig/scalc/ui/textimportcsv.ui
index 943cfcc6415c..1bf43a871a5a 100644
--- a/sc/uiconfig/scalc/ui/textimportcsv.ui
+++ b/sc/uiconfig/scalc/ui/textimportcsv.ui
@@ -104,7 +104,7 @@
                 <property name="label-xalign">0</property>
                 <property name="shadow-type">none</property>
                 <child>
-                  <!-- n-columns=2 n-rows=3 -->
+                  <!-- n-columns=2 n-rows=4 -->
                   <object class="GtkGrid" id="grid1">
                     <property name="visible">True</property>
                     <property name="can-focus">False</property>
@@ -870,6 +870,22 @@
                         <property name="position">2</property>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkCheckButton" id="alwaysshowonimport">
+                        <property name="label" translatable="yes" 
context="textimportcsv|alwaysshow">_Always show on import</property>
+                        <property name="can-focus">True</property>
+                        <property name="receives-default">False</property>
+                        <property name="use-underline">True</property>
+                        <property name="active">True</property>
+                        <property name="draw-indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">3</property>
+                        <property name="padding">5</property>
+                      </packing>
+                    </child>
                   </object>
                 </child>
                 <child type="label">
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx
index 342c7c30c3e0..1bbf2ad7aa9c 100644
--- a/sfx2/source/appl/appopen.cxx
+++ b/sfx2/source/appl/appopen.cxx
@@ -44,7 +44,9 @@
 #include <rtl/ustring.hxx>
 
 #include <comphelper/processfactory.hxx>
+#include <comphelper/propertyvalue.hxx>
 #include <comphelper/sequence.hxx>
+#include <comphelper/SetFlagContextHelper.hxx>
 #include <comphelper/storagehelper.hxx>
 #include <comphelper/string.hxx>
 #include <comphelper/synchronousdispatch.hxx>
@@ -634,7 +636,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
         if ( pRemoteDialogItem && pRemoteDialogItem->GetValue())
             nDialog = SFX2_IMPL_DIALOG_REMOTE;
 
-        sal_Int16 nDialogType = 
ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION;
+        sal_Int16 nDialogType = 
ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION_FILTEROPTIONS;
         FileDialogFlags eDialogFlags = FileDialogFlags::MultiSelection;
         const SfxBoolItem* pSignPDFItem = 
rReq.GetArg<SfxBoolItem>(SID_SIGNPDF);
         if (pSignPDFItem && pSignPDFItem->GetValue())
@@ -655,15 +657,15 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
         if ( pDenyListItem )
             pDenyListItem->GetStringList( aDenyList );
 
+        bool bShowFilterDialog = true;
         weld::Window* pTopWindow = GetTopWindow();
         ErrCode nErr = sfx2::FileOpenDialog_Impl(pTopWindow,
                 nDialogType,
                 eDialogFlags, aURLList,
-                aFilter, pSet, &aPath, nDialog, sStandardDir, aDenyList);
+                aFilter, pSet, &aPath, nDialog, sStandardDir, aDenyList, 
bShowFilterDialog);
 
         if ( nErr == ERRCODE_ABORT )
         {
-            aURLList.clear();
             return;
         }
 
@@ -710,6 +712,11 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
                 rReq.AppendItem(SfxStringItem(SID_DOC_SERVICE, aDocService));
             }
 
+            // The actual use of bShowFilterDialog will be in the recursive 
call to OpenDocExec_Impl
+            std::optional<css::uno::ContextLayer> oLayer;
+            if (bShowFilterDialog)
+                
oLayer.emplace(comphelper::NewFlagContext(u"ShowFilterDialog"_ustr));
+
             for (auto const& url : aURLList)
             {
                 rReq.RemoveItem( SID_FILE_NAME );
@@ -740,10 +747,8 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
                 }
             }
 
-            aURLList.clear();
             return;
         }
-        aURLList.clear();
     }
 
     bool bHyperlinkUsed = false;
@@ -1078,6 +1083,12 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
         auto nIndex = static_cast<sal_Int32>(std::distance(std::cbegin(aArgs), 
pArg));
         comphelper::removeElementAt(aArgs, nIndex);
     }
+    if (comphelper::IsContextFlagActive(u"ShowFilterDialog"_ustr))
+    {
+        const auto i = aArgs.getLength();
+        aArgs.realloc(i + 1);
+        aArgs.getArray()[i] = 
comphelper::makePropertyValue(u"ShowFilterDialog"_ustr, true);
+    }
 
     // TODO/LATER: either remove LinkItem or create an asynchronous process 
for it
     if( bHidden || pLinkItem || rReq.IsSynchronCall() )
diff --git a/sfx2/source/dialog/filedlghelper.cxx 
b/sfx2/source/dialog/filedlghelper.cxx
index b6ba3a46685c..8d28908ae94a 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -73,6 +73,7 @@
 #include <svl/intitem.hxx>
 #include <vcl/dibtools.hxx>
 #include <vcl/graphicfilter.hxx>
+#include <unotools/filteroptions_settings.hxx>
 #include <unotools/viewoptions.hxx>
 #include <svtools/helpids.h>
 #include <comphelper/docpasswordrequest.hxx>
@@ -439,6 +440,7 @@ bool FileDialogHelper_Impl::isInOpenMode() const
         case FILEOPEN_PLAY:
         case FILEOPEN_LINK_PLAY:
         case FILEOPEN_READONLY_VERSION:
+        case FILEOPEN_READONLY_VERSION_FILTEROPTIONS:
         case FILEOPEN_LINK_PREVIEW:
         case FILEOPEN_PREVIEW:
             bRet = true;
@@ -452,10 +454,22 @@ void FileDialogHelper_Impl::updateFilterOptionsBox()
     if ( !m_bHaveFilterOptions )
         return;
 
-    updateExtendedControl(
-        ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS,
-        CheckFilterOptionsCapability( getCurrentSfxFilter() )
-    );
+    bool bFilterOptionsEnabled = 
CheckFilterOptionsCapability(getCurrentSfxFilter());
+
+    updateExtendedControl(ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS,
+                          bFilterOptionsEnabled);
+
+    if (isInOpenMode())
+    {
+        if (auto xCtrlAccess = mxFileDlg.query<XFilePickerControlAccess>())
+        {
+            OUString filter;
+            getRealFilter(filter);
+            bool bChecked = bFilterOptionsEnabled && 
utl::isShowFilterOptionsDialog(filter);
+            
xCtrlAccess->setValue(ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS, 0,
+                                  Any(bChecked));
+        }
+    }
 }
 
 void FileDialogHelper_Impl::updateExportButton()
@@ -876,6 +890,7 @@ static open_or_save_t lcl_OpenOrSave(sal_Int16 const 
nDialogType)
         case FILEOPEN_PLAY:
         case FILEOPEN_LINK_PLAY:
         case FILEOPEN_READONLY_VERSION:
+        case FILEOPEN_READONLY_VERSION_FILTEROPTIONS:
         case FILEOPEN_LINK_PREVIEW:
         case FILEOPEN_PREVIEW:
             return OPEN;
@@ -1066,6 +1081,18 @@ FileDialogHelper_Impl::FileDialogHelper_Impl(
                 mbHasVersions = true;
                 break;
 
+            case FILEOPEN_READONLY_VERSION_FILTEROPTIONS:
+                nTemplateDescription = 
TemplateDescription::FILEOPEN_READONLY_VERSION_FILTEROPTIONS;
+                m_bHaveFilterOptions = true;
+                if( xFactory.is() )
+                {
+                    mxFilterCFG.set(
+                        xFactory->createInstance( 
u"com.sun.star.document.FilterFactory"_ustr ),
+                        UNO_QUERY );
+                }
+                mbHasVersions = true;
+                break;
+
             case FILEOPEN_LINK_PREVIEW:
                 nTemplateDescription = 
TemplateDescription::FILEOPEN_LINK_PREVIEW;
                 mbHasPreview = true;
@@ -2891,7 +2918,8 @@ ErrCode FileOpenDialog_Impl( weld::Window* pParent,
                              const OUString* pPath,
                              sal_Int16 nDialog,
                              const OUString& rStandardDir,
-                             const css::uno::Sequence< OUString >& rDenyList )
+                             const css::uno::Sequence< OUString >& rDenyList,
+                             bool& rShowFilterDialog )
 {
     ErrCode nRet;
     std::unique_ptr<FileDialogHelper> pDialog;
@@ -2912,6 +2940,11 @@ ErrCode FileOpenDialog_Impl( weld::Window* pParent,
 
     if (rpSet && nFlags & FileDialogFlags::SignPDF)
         rpSet->Put(SfxBoolItem(SID_DOC_READONLY, true));
+
+    uno::Reference< ui::dialogs::XFilePickerControlAccess > xExtFileDlg( 
pDialog->GetFilePicker(), uno::UNO_QUERY );
+    uno::Any aVal = xExtFileDlg->getValue( 
ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS, 0 );
+    aVal >>= rShowFilterDialog;
+
     return nRet;
 }
 
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 335b8c178c91..ba0c49377e2e 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -412,6 +412,8 @@ public:
     /// if true, xStorage is an inner package and not directly from xStream
     bool m_bODFWholesomeEncryption = false;
 
+    bool m_bShowFilterDialog = false;
+
     OUString m_aName;
     OUString m_aLogicName;
     OUString m_aLongName;
@@ -3681,14 +3683,21 @@ SfxMedium::SfxMedium( const 
uno::Sequence<beans::PropertyValue>& aArgs ) :
 
 void SfxMedium::SetArgs(const uno::Sequence<beans::PropertyValue>& rArgs)
 {
-    static constexpr OUStringLiteral sStream(u"Stream");
-    static constexpr OUStringLiteral sInputStream(u"InputStream");
     comphelper::SequenceAsHashMap aArgsMap(rArgs);
-    aArgsMap.erase(sStream);
-    aArgsMap.erase(sInputStream);
+    aArgsMap.erase(u"Stream"_ustr);
+    aArgsMap.erase(u"InputStream"_ustr);
+
+    if (auto it = aArgsMap.find(u"ShowFilterDialog"_ustr); it != 
aArgsMap.end())
+    {
+        it->second >>= pImpl->m_bShowFilterDialog;
+        aArgsMap.erase(it);
+    }
+
     pImpl->m_aArgs = aArgsMap.getAsConstPropertyValueList();
 }
 
+bool SfxMedium::ShowFilterDialog() const { return pImpl->m_bShowFilterDialog; }
+
 const uno::Sequence<beans::PropertyValue> & SfxMedium::GetArgs() const { 
return pImpl->m_aArgs; }
 
 SfxMedium::SfxMedium( const uno::Reference < embed::XStorage >& rStor, const 
OUString& rBaseURL, const std::shared_ptr<SfxItemSet>& p ) :
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 0a52c32eab6b..d3836221e89f 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -64,6 +64,7 @@
 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
 #include <comphelper/fileformat.h>
 #include <comphelper/processfactory.hxx>
+#include <comphelper/propertyvalue.hxx>
 #include <svtools/langtab.hxx>
 #include <svtools/sfxecode.hxx>
 #include <unotools/configmgr.hxx>
@@ -1237,6 +1238,12 @@ ErrCode SfxObjectShell::HandleFilter( SfxMedium* 
pMedium, SfxObjectShell const *
 
                                 Sequence< PropertyValue > rProperties;
                                 TransformItems( SID_OPENDOC, rSet, rProperties 
);
+                                if (pMedium->ShowFilterDialog())
+                                {
+                                    const auto i = rProperties.getLength();
+                                    rProperties.realloc(i + 1);
+                                    rProperties.getArray()[i] = 
comphelper::makePropertyValue(u"ShowFilterDialog"_ustr, true);
+                                }
                                 rtl::Reference<RequestFilterOptions> 
pFORequest = new RequestFilterOptions( pDoc->GetModel(), rProperties );
 
                                 rHandler->handle( pFORequest );
diff --git a/uui/source/iahndl-filter.cxx b/uui/source/iahndl-filter.cxx
index 95b3450b9881..3fb3aa26783f 100644
--- a/uui/source/iahndl-filter.cxx
+++ b/uui/source/iahndl-filter.cxx
@@ -210,6 +210,13 @@ handleFilterOptionsRequest_(
             {
                 pProperty->Value >>= aFilterName;
             }
+            bool bShowFilterDialog = false;
+            pProperty = std::find_if(rRequest.rProperties.begin(), 
rRequest.rProperties.end(),
+                [](const beans::PropertyValue& rProp) { return rProp.Name == 
"ShowFilterDialog"; });
+            if (pProperty != rRequest.rProperties.end())
+            {
+                pProperty->Value >>= bShowFilterDialog;
+            }
 
             uno::Sequence < beans::PropertyValue > aProps;
             if ( xFilterCFG->getByName( aFilterName ) >>= aProps )
@@ -225,6 +232,7 @@ handleFilterOptionsRequest_(
                         uno::Sequence<uno::Any> 
aDialogArgs(comphelper::InitAnyPropertySequence(
                         {
                             {"ParentWindow", uno::Any(rWindow)},
+                            {"ShowFilterDialog", uno::Any(bShowFilterDialog)},
                         }));
 
                         uno::Reference<
diff --git a/vcl/qt5/QtFilePicker.cxx b/vcl/qt5/QtFilePicker.cxx
index 8faec2311fc5..e3e79b065695 100644
--- a/vcl/qt5/QtFilePicker.cxx
+++ b/vcl/qt5/QtFilePicker.cxx
@@ -680,6 +680,12 @@ void QtFilePicker::applyTemplate(sal_Int16 nTemplateId)
             addCustomControl(LISTBOX_VERSION);
             break;
 
+        case FILEOPEN_READONLY_VERSION_FILTEROPTIONS:
+            addCustomControl(CHECKBOX_READONLY);
+            addCustomControl(LISTBOX_VERSION);
+            addCustomControl(CHECKBOX_FILTEROPTIONS);
+            break;
+
         case FILEOPEN_LINK_PREVIEW:
             addCustomControl(CHECKBOX_LINK);
             addCustomControl(CHECKBOX_PREVIEW);
diff --git a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx 
b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx
index d2344fc39627..e4602128cfe3 100644
--- a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx
+++ b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx
@@ -1807,6 +1807,13 @@ void SalGtkFilePicker::impl_initialize(GtkWidget* 
pParentWidget, sal_Int16 templ
             mbToggleVisibility[READONLY] = true;
             mbListVisibility[VERSION] = true;
             break;
+        case FILEOPEN_READONLY_VERSION_FILTEROPTIONS:
+            eAction = GTK_FILE_CHOOSER_ACTION_OPEN;
+            first_button_text = sOpen.getStr();
+            mbToggleVisibility[FILTEROPTIONS] = true;
+            mbToggleVisibility[READONLY] = true;
+            mbListVisibility[VERSION] = true;
+            break;
         case FILEOPEN_LINK_PREVIEW:
             eAction = GTK_FILE_CHOOSER_ACTION_OPEN;
             first_button_text = sOpen.getStr();
diff --git a/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker.cxx 
b/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker.cxx
index d3a053a08008..827b1fa263f2 100644
--- a/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker.cxx
+++ b/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker.cxx
@@ -389,6 +389,12 @@ void SAL_CALL Gtk3KDE5FilePicker::initialize(const 
uno::Sequence<uno::Any>& args
             addCustomControl(LISTBOX_VERSION);
             break;
 
+        case FILEOPEN_READONLY_VERSION_FILTEROPTIONS:
+            addCustomControl(CHECKBOX_READONLY);
+            addCustomControl(LISTBOX_VERSION);
+            addCustomControl(CHECKBOX_FILTEROPTIONS);
+            break;
+
         case FILEOPEN_LINK_PREVIEW:
             addCustomControl(CHECKBOX_LINK);
             addCustomControl(CHECKBOX_PREVIEW);

Reply via email to