fpicker/source/office/OfficeControlAccess.cxx |   28 +++---
 fpicker/source/office/OfficeControlAccess.hxx |    5 -
 fpicker/source/office/fpdialogbase.hxx        |    6 +
 fpicker/source/office/iodlg.cxx               |  113 ++++++++++++--------------
 fpicker/source/office/iodlg.hxx               |    4 
 fpicker/source/office/pickercallbacks.hxx     |   11 --
 6 files changed, 81 insertions(+), 86 deletions(-)

New commits:
commit 1a8296db3365d33ca2036067fabe751fb37ad6b7
Author:     Michael Weghorn <[email protected]>
AuthorDate: Fri Dec 5 22:05:47 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Sat Dec 6 10:05:50 2025 +0100

    fpicker: Merge IFilePickerController into SvtFileDialog_Base
    
    It's the only subclass of that abstract base class/interface
    and already defines other similar purely virtual methods, so
    merge the two to simplify this a bit.
    
    Also rename OControlAccess::m_pFilePickerController,
    given it is no longer a IFilePickerController any more.
    
    Change-Id: I8a0951bb7c493c9f38c6960607d73b729a0a958c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195124
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/fpicker/source/office/OfficeControlAccess.cxx 
b/fpicker/source/office/OfficeControlAccess.cxx
index 783ac2dbd3a3..e675ea138e9e 100644
--- a/fpicker/source/office/OfficeControlAccess.cxx
+++ b/fpicker/source/office/OfficeControlAccess.cxx
@@ -152,11 +152,11 @@ namespace svt
         };
     }
 
-    OControlAccess::OControlAccess(IFilePickerController* pController, 
SvtFileView* pFileView)
-        : m_pFilePickerController(pController)
+    OControlAccess::OControlAccess(SvtFileDialog_Base* pController, 
SvtFileView* pFileView)
+        : m_pFilePicker(pController)
         , m_pFileView(pFileView)
     {
-        DBG_ASSERT( m_pFilePickerController, "OControlAccess::OControlAccess: 
invalid control locator!" );
+        DBG_ASSERT( m_pFilePicker, "OControlAccess::OControlAccess: invalid 
control locator!" );
     }
 
     bool OControlAccess::IsFileViewWidget(weld::Widget const * pControl) const
@@ -235,7 +235,7 @@ namespace svt
         if ( aFoundRange.first != aFoundRange.second )
         {
             // get the VCL control determined by this id
-            pControl = m_pFilePickerController->getControl( 
aFoundRange.first->nControlId );
+            pControl = m_pFilePicker->getControl( 
aFoundRange.first->nControlId );
         }
 
         // if not found 'til here, the name is invalid, or we do not have the 
control in the current mode
@@ -275,7 +275,7 @@ namespace svt
         // collect the names of all _actually_existent_ controls
         for ( ControlDescIterator aControl = s_pControls; aControl != 
s_pControlsEnd; ++aControl )
         {
-            if ( m_pFilePickerController->getControl( aControl->nControlId ) )
+            if ( m_pFilePicker->getControl( aControl->nControlId ) )
                 *pControls++ = OUString::createFromAscii( 
aControl->pControlName );
         }
 
@@ -329,7 +329,7 @@ namespace svt
 
     void OControlAccess::setValue( sal_Int16 nControlId, sal_Int16 
nControlAction, const Any& rValue )
     {
-        weld::Widget* pControl = m_pFilePickerController->getControl( 
nControlId );
+        weld::Widget* pControl = m_pFilePicker->getControl( nControlId );
         DBG_ASSERT( pControl, "OControlAccess::SetValue: don't have this 
control in the current mode!" );
         if ( !pControl )
             return;
@@ -383,7 +383,7 @@ namespace svt
     {
         Any aRet;
 
-        weld::Widget* pControl = m_pFilePickerController->getControl( 
nControlId );
+        weld::Widget* pControl = m_pFilePicker->getControl( nControlId );
         DBG_ASSERT( pControl, "OControlAccess::GetValue: don't have this 
control in the current mode!" );
         if ( pControl )
         {
@@ -411,7 +411,7 @@ namespace svt
                     case LISTBOX_FILTER:
                         if ( ControlActions::GET_SELECTED_ITEM == 
nControlAction )
                         {
-                            aRet <<= m_pFilePickerController->getCurFilter();
+                            aRet <<= m_pFilePicker->getCurFilter();
                         }
                         else
                         {
@@ -451,7 +451,7 @@ namespace svt
 
     void OControlAccess::setLabel( sal_Int16 nId, const OUString &rLabel )
     {
-        weld::Widget* pControl = m_pFilePickerController->getControl(nId, 
true);
+        weld::Widget* pControl = m_pFilePicker->getControl(nId, true);
         if (weld::Label* pLabel = dynamic_cast<weld::Label*>(pControl))
         {
             pLabel->set_label(rLabel);
@@ -467,7 +467,7 @@ namespace svt
 
     OUString OControlAccess::getLabel( sal_Int16 nId ) const
     {
-        weld::Widget* pControl = m_pFilePickerController->getControl(nId, 
true);
+        weld::Widget* pControl = m_pFilePicker->getControl(nId, true);
         if (weld::Label* pLabel = dynamic_cast<weld::Label*>(pControl))
             return pLabel->get_label();
         if (weld::Button* pButton = dynamic_cast<weld::Button*>(pControl))
@@ -478,7 +478,7 @@ namespace svt
 
     void OControlAccess::enableControl(sal_Int16 nId, bool bEnable)
     {
-        m_pFilePickerController->enableControl(nId, bEnable);
+        m_pFilePicker->enableControl(nId, bEnable);
     }
 
     void OControlAccess::implDoListboxAction(weld::ComboBox* pListbox, 
sal_Int16 nControlAction, const Any& rValue)
@@ -527,12 +527,12 @@ namespace svt
     void OControlAccess::implSetControlProperty( sal_Int16 nControlId, 
weld::Widget* pControl, PropFlags _nProperty, const Any& rValue, bool 
_bIgnoreIllegalArgument )
     {
         if ( !pControl )
-            pControl = m_pFilePickerController->getControl( nControlId );
+            pControl = m_pFilePicker->getControl( nControlId );
         DBG_ASSERT( pControl, "OControlAccess::implSetControlProperty: invalid 
argument, this will crash!" );
         if ( !pControl )
             return;
 
-        DBG_ASSERT( pControl == m_pFilePickerController->getControl( 
nControlId ),
+        DBG_ASSERT( pControl == m_pFilePicker->getControl( nControlId ),
             "OControlAccess::implSetControlProperty: inconsistent parameters!" 
);
 
         switch ( _nProperty )
@@ -558,7 +558,7 @@ namespace svt
                 bool bEnabled = false;
                 if ( rValue >>= bEnabled )
                 {
-                    m_pFilePickerController->enableControl( nControlId, 
bEnabled );
+                    m_pFilePicker->enableControl( nControlId, bEnabled );
                 }
                 else if ( !_bIgnoreIllegalArgument )
                 {
diff --git a/fpicker/source/office/OfficeControlAccess.hxx 
b/fpicker/source/office/OfficeControlAccess.hxx
index 859ff15f270e..5a6959bea1bf 100644
--- a/fpicker/source/office/OfficeControlAccess.hxx
+++ b/fpicker/source/office/OfficeControlAccess.hxx
@@ -24,6 +24,7 @@
 #include <string_view>
 
 #include "fileview.hxx"
+#include "fpdialogbase.hxx"
 #include "pickercallbacks.hxx"
 #include <o3tl/typed_flags_set.hxx>
 
@@ -61,11 +62,11 @@ namespace svt
     */
     class OControlAccess
     {
-        IFilePickerController*  m_pFilePickerController;
+        SvtFileDialog_Base* m_pFilePicker;
         SvtFileView*     m_pFileView;
 
     public:
-        OControlAccess( IFilePickerController* pController, SvtFileView* 
pFileView );
+        OControlAccess(SvtFileDialog_Base* pFilePicker, SvtFileView* 
pFileView);
 
         // XControlAccess implementation
         void setControlProperty( std::u16string_view rControlName, const 
OUString& rControlProperty, const css::uno::Any& rValue );
diff --git a/fpicker/source/office/fpdialogbase.hxx 
b/fpicker/source/office/fpdialogbase.hxx
index d4dc7dd32dcc..6474220a99ec 100644
--- a/fpicker/source/office/fpdialogbase.hxx
+++ b/fpicker/source/office/fpdialogbase.hxx
@@ -54,7 +54,7 @@ inline constexpr OUString FILEDIALOG_FILTER_ALL = u"*.*"_ustr;
 
 // SvtFileDialog_Base
 
-class SvtFileDialog_Base : public weld::GenericDialogController, public 
::svt::IFilePickerController
+class SvtFileDialog_Base : public weld::GenericDialogController
 {
 public:
     SvtFileDialog_Base(weld::Window* pParent, const OUString& 
rUIXMLDescription, const OUString& rID)
@@ -74,6 +74,10 @@ public:
     virtual std::vector<OUString> GetPathList() const = 0;
     virtual bool ContentIsFolder( const OUString& rURL ) = 0;
 
+    virtual weld::Widget* getControl(sal_Int16 nControlId, bool bLabelControl 
= false) const = 0;
+    virtual void enableControl(sal_Int16 nControlId, bool bEnable) = 0;
+    virtual OUString getCurFilter() const = 0;
+
     virtual OUString getCurrentFileText() const = 0;
     virtual void setCurrentFileText( const OUString& rText, bool bSelectAll = 
false ) = 0;
 
diff --git a/fpicker/source/office/iodlg.hxx b/fpicker/source/office/iodlg.hxx
index acda0bfd4144..aba48e8e8dce 100644
--- a/fpicker/source/office/iodlg.hxx
+++ b/fpicker/source/office/iodlg.hxx
@@ -227,7 +227,6 @@ private:
 
     AdjustFilterFlags           adjustFilter( const OUString& _rFilter );
 
-    // IFilePickerController, needed by OControlAccess
     virtual weld::Widget*       getControl( sal_Int16 nControlId, bool 
bLabelControl = false ) const override;
     virtual void                enableControl( sal_Int16 _nControlId, bool 
_bEnable ) override;
     virtual OUString            getCurFilter( ) const override;
diff --git a/fpicker/source/office/pickercallbacks.hxx 
b/fpicker/source/office/pickercallbacks.hxx
index dcc82c0839a1..4552166a8f7f 100644
--- a/fpicker/source/office/pickercallbacks.hxx
+++ b/fpicker/source/office/pickercallbacks.hxx
@@ -26,17 +26,6 @@ namespace weld { class Widget; }
 
 namespace svt
 {
-    class IFilePickerController
-    {
-    public:
-        virtual weld::Widget* getControl( sal_Int16 nControlId, bool 
bLabelControl = false ) const = 0;
-        virtual void        enableControl( sal_Int16 nControlId, bool bEnable 
) = 0;
-        virtual OUString    getCurFilter( ) const = 0;
-
-    protected:
-        ~IFilePickerController() {}
-    };
-
     class IFilePickerListener
     {
     public:
commit 4aa234cdd559a76c6ea75d48a920ff6be5c8aa9d
Author:     Michael Weghorn <[email protected]>
AuthorDate: Fri Dec 5 21:36:48 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Sat Dec 6 10:05:41 2025 +0100

    fpicker: Turn lcl_autoUpdateFileExtension into SvtFileDialog method
    
    Turn the helper function into a class method instead of
    always passing the SvtDialog object itself as the
    first param.
    
    Change-Id: I405af45e0f518c5b10bcd14af4d8b7a99bbc3757
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195123
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/fpicker/source/office/iodlg.cxx b/fpicker/source/office/iodlg.cxx
index fdb6c8fd17ce..1f3a267af521 100644
--- a/fpicker/source/office/iodlg.cxx
+++ b/fpicker/source/office/iodlg.cxx
@@ -162,61 +162,6 @@ namespace
                 // no extension was present, append new one if not empty
     }
 
-    void lcl_autoUpdateFileExtension( SvtFileDialog* _pDialog, const OUString& 
_rLastFilterExt )
-    {
-        // if auto extension is enabled...
-        if ( !_pDialog->isAutoExtensionEnabled() )
-            return;
-
-        // automatically switch to the extension of the (maybe just newly 
selected) extension
-        OUString aNewFile = _pDialog->getCurrentFileText( );
-        OUString aExt = GetFsysExtension_Impl( aNewFile, _rLastFilterExt );
-
-        // but only if there already is an extension
-        if ( aExt.isEmpty() )
-            return;
-
-        // check if it is a real file extension, and not only the "post-dot" 
part in
-        // a directory name
-        bool bRealExtensions = true;
-        if ( -1 != aExt.indexOf( '/' ) )
-            bRealExtensions = false;
-        else if ( -1 != aExt.indexOf( '\' ) )
-            bRealExtensions = false;
-        else
-        {
-            // no easy way to tell, because the part containing the dot 
already is the last
-            // segment of the complete file name
-            // So we have to check if the file name denotes a folder or a file.
-            // For performance reasons, we do this for file urls only
-            INetURLObject aURL( aNewFile );
-            if ( INetProtocol::NotValid == aURL.GetProtocol() )
-            {
-                OUString sURL;
-                if ( osl::FileBase::getFileURLFromSystemPath( aNewFile, sURL )
-                     == osl::FileBase::E_None )
-                    aURL = INetURLObject( sURL );
-            }
-            if ( INetProtocol::File == aURL.GetProtocol() )
-            {
-                try
-                {
-                    bRealExtensions = !_pDialog->ContentIsFolder( 
aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
-                }
-                catch( const css::uno::Exception& )
-                {
-                    SAL_INFO( "fpicker.office", "Exception in 
lcl_autoUpdateFileExtension" );
-                }
-            }
-        }
-
-        if ( bRealExtensions )
-        {
-            SetFsysExtension_Impl( aNewFile, _pDialog->GetDefaultExt() );
-            _pDialog->setCurrentFileText( aNewFile );
-        }
-    }
-
 #if defined( UNX )
     bool lcl_getHomeDirectory( const OUString& _rForURL, OUString& /* [out] */ 
_rHomeDir )
     {
@@ -940,7 +885,7 @@ IMPL_LINK_NOARG( SvtFileDialog, FilterSelectHdl_Impl, 
weld::ComboBox&, void )
                 EraseDefaultExt( nSepPos );
 
             // update the extension of the current file if necessary
-            lcl_autoUpdateFileExtension( this, sLastFilterExt );
+            AutoUpdateFileExtension(sLastFilterExt);
 
             // if the user is traveling fast through the filterbox
             // do not filter instantly
@@ -1227,7 +1172,7 @@ IMPL_LINK_NOARG(SvtFileDialog, AutoExtensionHdl_Impl, 
weld::Toggleable&, void)
         m_pFileNotifier->notify(CTRL_STATE_CHANGED, CHECKBOX_AUTOEXTENSION);
 
     // update the extension of the current file if necessary
-    lcl_autoUpdateFileExtension( this, m_xImpl->GetCurFilter()->GetExtension() 
);
+    AutoUpdateFileExtension(m_xImpl->GetCurFilter()->GetExtension());
 }
 
 IMPL_LINK( SvtFileDialog, ClickHdl_Impl, weld::Toggleable&, rCheckBox, void )
@@ -1437,6 +1382,60 @@ void SvtFileDialog::EnableUI(bool bEnable)
     }
 }
 
+void SvtFileDialog::AutoUpdateFileExtension(const OUString& rLastFilterExt)
+{
+    // if auto extension is enabled...
+    if (!isAutoExtensionEnabled())
+        return;
+
+    // automatically switch to the extension of the (maybe just newly 
selected) extension
+    OUString aNewFile = getCurrentFileText();
+    OUString aExt = GetFsysExtension_Impl(aNewFile, rLastFilterExt);
+
+    // but only if there already is an extension
+    if (aExt.isEmpty())
+        return;
+
+    // check if it is a real file extension, and not only the "post-dot" part 
in
+    // a directory name
+    bool bRealExtensions = true;
+    if (-1 != aExt.indexOf('/'))
+        bRealExtensions = false;
+    else if (-1 != aExt.indexOf('\'))
+        bRealExtensions = false;
+    else
+    {
+        // no easy way to tell, because the part containing the dot already is 
the last
+        // segment of the complete file name
+        // So we have to check if the file name denotes a folder or a file.
+        // For performance reasons, we do this for file urls only
+        INetURLObject aURL(aNewFile);
+        if (INetProtocol::NotValid == aURL.GetProtocol())
+        {
+            OUString sURL;
+            if (osl::FileBase::getFileURLFromSystemPath(aNewFile, sURL) == 
osl::FileBase::E_None)
+                aURL = INetURLObject(sURL);
+        }
+        if (INetProtocol::File == aURL.GetProtocol())
+        {
+            try
+            {
+                bRealExtensions = 
!ContentIsFolder(aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE));
+            }
+            catch (const css::uno::Exception&)
+            {
+                SAL_INFO("fpicker.office", "Exception in 
SvtFileDialog::AutoUpdateFileExtension");
+            }
+        }
+    }
+
+    if (bRealExtensions)
+    {
+        SetFsysExtension_Impl(aNewFile, GetDefaultExt());
+        setCurrentFileText(aNewFile);
+    }
+}
+
 void SvtFileDialog::EnableControl(weld::Widget* pControl, bool bEnable)
 {
     if (!pControl)
diff --git a/fpicker/source/office/iodlg.hxx b/fpicker/source/office/iodlg.hxx
index 574ecbf248c9..acda0bfd4144 100644
--- a/fpicker/source/office/iodlg.hxx
+++ b/fpicker/source/office/iodlg.hxx
@@ -145,6 +145,9 @@ private:
         <member>EnableUI</member> for details.
     */
     void                        EnableControl(weld::Widget* pControl, bool 
bEnable);
+
+    void AutoUpdateFileExtension(const OUString& rLastFilterExt);
+
     virtual bool                PrepareExecute() override;
 
     void ImplDestroy();

Reply via email to