[Libreoffice-commits] core.git: Branch 'feature/gsoc15-open-remote-files-dialog' - fpicker/source include/svtools svtools/source

Szymon Kłos eszkadev at gmail.com
Thu Jul 23 07:29:10 PDT 2015


 fpicker/source/office/RemoteFilesDialog.cxx |  180 +++++++++++++++++++++-------
 fpicker/source/office/RemoteFilesDialog.hxx |   12 +
 fpicker/source/office/asyncfilepicker.cxx   |    2 
 fpicker/source/office/asyncfilepicker.hxx   |    6 
 fpicker/source/office/fpdialogbase.hxx      |    7 +
 fpicker/source/office/iodlg.hxx             |   12 -
 include/svtools/breadcrumb.hxx              |    2 
 svtools/source/control/breadcrumb.cxx       |   12 +
 8 files changed, 180 insertions(+), 53 deletions(-)

New commits:
commit 8d9ce286c11ea14af10d46b2576105779d3b1c8f
Author: Szymon Kłos <eszkadev at gmail.com>
Date:   Thu Jul 23 16:22:33 2015 +0200

    RemoteFilesDialog integration with AsyncPickerAction
    
    Change-Id: If6ded1c2f2b056ce864589649b08ed19a73dc5dd

diff --git a/fpicker/source/office/RemoteFilesDialog.cxx b/fpicker/source/office/RemoteFilesDialog.cxx
index 4e69c9d..7106366 100644
--- a/fpicker/source/office/RemoteFilesDialog.cxx
+++ b/fpicker/source/office/RemoteFilesDialog.cxx
@@ -171,6 +171,7 @@ class FileViewContainer : public vcl::Window
 RemoteFilesDialog::RemoteFilesDialog( vcl::Window* pParent, WinBits nBits )
     : SvtFileDialog_Base( pParent, "RemoteFilesDialog", "fps/ui/remotefilesdialog.ui" )
     , m_context( comphelper::getProcessComponentContext() )
+    , m_pCurrentAsyncAction( NULL )
     , m_pFileNotifier( NULL )
     , m_pSplitter( NULL )
     , m_pFileView( NULL )
@@ -187,6 +188,7 @@ RemoteFilesDialog::RemoteFilesDialog( vcl::Window* pParent, WinBits nBits )
     m_bMultiselection = ( nBits & SFXWB_MULTISELECTION ) != 0;
     m_bIsUpdated = false;
     m_bIsConnected = false;
+    m_bServiceChanged = false;
     m_nCurrentFilter = LISTBOX_ENTRY_NOTFOUND;
 
     m_pFilter_lb->Enable( false );
@@ -201,6 +203,7 @@ RemoteFilesDialog::RemoteFilesDialog( vcl::Window* pParent, WinBits nBits )
     m_pOk_btn->Enable( false );
 
     m_pOk_btn->SetClickHdl( LINK( this, RemoteFilesDialog, OkHdl ) );
+    m_pCancel_btn->SetClickHdl( LINK( this, RemoteFilesDialog, CancelHdl ) );
 
     m_pPath = VclPtr<Breadcrumb>::Create( get< vcl::Window >( "breadcrumb_container" ) );
     m_pPath->set_hexpand( true );
@@ -462,7 +465,13 @@ FileViewResult RemoteFilesDialog::OpenURL( OUString const & sURL )
 
     if( m_pFileView )
     {
-        if( !sURL.isEmpty() && ContentIsFolder( sURL ) )
+        m_pTreeView->EndSelection();
+        DisableControls();
+
+        EnableChildPointerOverwrite( true );
+        SetPointer( PointerStyle::Wait );
+
+        if( !sURL.isEmpty() )
         {
             OUString sFilter = FILEDIALOG_FILTER_ALL;
 
@@ -473,33 +482,27 @@ FileViewResult RemoteFilesDialog::OpenURL( OUString const & sURL )
 
             m_pFileView->EndInplaceEditing( false );
 
-            EnableChildPointerOverwrite( true );
-            SetPointer( PointerStyle::Wait );
-
-            eResult = m_pFileView->Initialize( sURL, sFilter, NULL, GetBlackList() );
+            DBG_ASSERT( !m_pCurrentAsyncAction.is(), "SvtFileDialog::executeAsync: previous async action not yet finished!" );
 
-            if( eResult == eSuccess )
-            {
-                m_pPath->SetURL( sURL );
-
-                m_pTreeView->SetSelectHdl( Link<>() );
-                m_pTreeView->SetTreePath( sURL );
-                m_pTreeView->SetSelectHdl( LINK( this, RemoteFilesDialog, TreeSelectHdl ) );
+            m_pCurrentAsyncAction = new AsyncPickerAction( this, m_pFileView, AsyncPickerAction::Action::eOpenURL );
 
-                m_bIsConnected = true;
-                EnableControls();
-            }
-
-            SetPointer( PointerStyle::Arrow );
-            EnableChildPointerOverwrite( false );
+            // -1 timeout - sync
+            m_pCurrentAsyncAction->execute( sURL, sFilter, -1, -1, GetBlackList() );
         }
         else
         {
+            SetPointer( PointerStyle::Arrow );
+            EnableChildPointerOverwrite( false );
+
             // content doesn't exist
-            m_pTreeView->EndSelection();
             ErrorHandler::HandleError( ERRCODE_IO_NOTEXISTS );
+
+            EnableControls();
             return eFailure;
         }
+
+        SetPointer( PointerStyle::Arrow );
+        EnableChildPointerOverwrite( false );
     }
 
     return eResult;
@@ -547,6 +550,22 @@ void RemoteFilesDialog::EnableControls()
         m_pContainer->Enable( false );
         m_pOk_btn->Enable( false );
     }
+
+    m_pPath->EnableFields( true );
+    m_pAddService_btn->Enable( true );
+}
+
+void RemoteFilesDialog::DisableControls()
+{
+    m_pServices_lb->Enable( false );
+    m_pFilter_lb->Enable( false );
+    m_pAddService_btn->Enable( false );
+    m_pName_ed->Enable( false );
+    m_pContainer->Enable( false );
+    m_pOk_btn->Enable( false );
+    m_pPath->EnableFields( false );
+
+    m_pCancel_btn->Enable( true );
 }
 
 IMPL_LINK_NOARG ( RemoteFilesDialog, AddServiceHdl )
@@ -591,23 +610,9 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, SelectServiceHdl )
     if( nPos >= 0 )
     {
         OUString sURL = m_aServices[nPos]->GetUrl();
-        OUString sName = m_aServices[nPos]->GetName();
-
-        if( OpenURL( sURL ) == eSuccess )
-        {
-            m_pPath->SetRootName( sName );
-            m_pTreeView->Clear();
-
-            SvTreeListEntry* pRoot = m_pTreeView->InsertEntry( sName, NULL, true );
-            OUString* sData = new OUString( sURL );
-            pRoot->SetUserData( static_cast< void* >( sData ) );
 
-            m_pTreeView->Expand( pRoot );
-
-            m_pName_ed->GrabFocus();
-
-            m_sLastServiceUrl = sURL;
-        }
+        m_bServiceChanged = true;
+        OpenURL( sURL );
     }
 
     return 1;
@@ -690,15 +695,23 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, DoubleClickHdl )
 {
     if( m_pFileView->GetSelectionCount() )
     {
-        OUString sURL = m_pFileView->GetCurrentURL();
+        SvTreeListEntry* pEntry = m_pFileView->FirstSelected();
 
-        if( ContentIsDocument( sURL ) )
-        {
-            EndDialog( RET_OK );
-        }
-        else
+        if( pEntry )
         {
-            OpenURL( sURL );
+            SvtContentEntry* pData = static_cast< SvtContentEntry* >( pEntry->GetUserData() );
+
+            if( pData )
+            {
+                if( !pData->mbIsFolder )
+                {
+                    EndDialog( RET_OK );
+                }
+                else
+                {
+                    OpenURL( pData->maURL );
+                }
+            }
         }
     }
 
@@ -789,7 +802,7 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, SelectFilterHdl )
 
         OUString sCurrentURL = m_pFileView->GetViewURL();
 
-        if( !sCurrentURL.isEmpty() )
+        if( !sCurrentURL.isEmpty() && m_bIsConnected )
             OpenURL( sCurrentURL );
     }
 
@@ -896,6 +909,20 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, OkHdl )
     return 1;
 }
 
+IMPL_LINK_NOARG ( RemoteFilesDialog, CancelHdl )
+{
+    if( m_pCurrentAsyncAction.is() )
+    {
+        m_pCurrentAsyncAction->cancel();
+        onAsyncOperationFinished();
+    }
+    else
+    {
+        EndDialog( RET_CANCEL );
+    }
+    return 1;
+}
+
 // SvtFileDialog_Base
 
 SvtFileView* RemoteFilesDialog::GetView()
@@ -941,6 +968,24 @@ void RemoteFilesDialog::SetPath( const OUString& rNewURL )
     }
 }
 
+OUString RemoteFilesDialog::getCurrentFileText() const
+{
+    OUString sReturn;
+    if( m_pName_ed )
+        sReturn = m_pName_ed->GetText();
+    return sReturn;
+}
+
+void RemoteFilesDialog::setCurrentFileText( const OUString& rText, bool bSelectAll )
+{
+    if( m_pName_ed )
+    {
+        m_pName_ed->SetText( rText );
+        if( bSelectAll )
+            m_pName_ed->SetSelection( Selection( 0, rText.getLength() ) );
+    }
+}
+
 void RemoteFilesDialog::AddFilterGroup(
                                   const OUString& rFilter,
                                   const com::sun::star::uno::Sequence< com::sun::star::beans::StringPair >& rFilters )
@@ -987,11 +1032,60 @@ void RemoteFilesDialog::SetCurFilter( const OUString& rFilter )
     }
 }
 
+void RemoteFilesDialog::FilterSelect()
+{
+}
+
 void RemoteFilesDialog::SetFileCallback( ::svt::IFilePickerListener *pNotifier )
 {
     m_pFileNotifier = pNotifier;
 }
 
+void RemoteFilesDialog::onAsyncOperationStarted()
+{
+    DisableControls();
+}
+
+void RemoteFilesDialog::onAsyncOperationFinished()
+{
+    m_pCurrentAsyncAction = NULL;
+    EnableControls();
+}
+
+void RemoteFilesDialog::UpdateControls( const OUString& rURL )
+{
+    int nPos = GetSelectedServicePos();
+
+    if( nPos >= 0 && m_bServiceChanged && rURL == m_aServices[nPos]->GetUrl() )
+    {
+        OUString sURL = m_aServices[nPos]->GetUrl();
+        OUString sName = m_aServices[nPos]->GetName();
+
+        m_pPath->SetRootName( sName );
+        m_pTreeView->Clear();
+
+        SvTreeListEntry* pRoot = m_pTreeView->InsertEntry( sName, NULL, true );
+        OUString* sData = new OUString( rURL );
+        pRoot->SetUserData( static_cast< void* >( sData ) );
+
+        m_pTreeView->Expand( pRoot );
+
+        m_pName_ed->GrabFocus();
+
+        m_sLastServiceUrl = sURL;
+
+        m_bServiceChanged = false;
+    }
+
+    m_pPath->SetURL( rURL );
+    m_pTreeView->SetSelectHdl( Link<>() );
+    m_pTreeView->SetTreePath( rURL );
+    m_pTreeView->SetSelectHdl( LINK( this, RemoteFilesDialog, TreeSelectHdl ) );
+
+    m_bIsConnected = true;
+    EnableControls();
+}
+
 void RemoteFilesDialog::EnableAutocompletion( bool )
 {
     // This dialog contains Breadcrumb, not Edit
diff --git a/fpicker/source/office/RemoteFilesDialog.hxx b/fpicker/source/office/RemoteFilesDialog.hxx
index b0f151e..a62b4cf 100644
--- a/fpicker/source/office/RemoteFilesDialog.hxx
+++ b/fpicker/source/office/RemoteFilesDialog.hxx
@@ -84,13 +84,20 @@ public:
     virtual bool ContentIsFolder( const OUString& rURL ) SAL_OVERRIDE;
     virtual bool ContentIsDocument( const OUString& rURL );
 
+    virtual OUString getCurrentFileText() const SAL_OVERRIDE;
+    virtual void setCurrentFileText( const OUString& rText, bool bSelectAll = false ) SAL_OVERRIDE;
+
     virtual void AddFilter( const OUString& rFilter, const OUString& rType ) SAL_OVERRIDE;
     virtual void AddFilterGroup( const OUString& _rFilter,
                                 const com::sun::star::uno::Sequence< com::sun::star::beans::StringPair >& rFilters ) SAL_OVERRIDE;
     virtual OUString GetCurFilter() const SAL_OVERRIDE;
     virtual void SetCurFilter( const OUString& rFilter ) SAL_OVERRIDE;
+    virtual void FilterSelect() SAL_OVERRIDE;
 
     virtual void SetFileCallback( ::svt::IFilePickerListener *pNotifier ) SAL_OVERRIDE;
+    virtual void onAsyncOperationStarted() SAL_OVERRIDE;
+    virtual void onAsyncOperationFinished() SAL_OVERRIDE;
+    virtual void UpdateControls( const OUString& rURL ) SAL_OVERRIDE;
 
     virtual void EnableAutocompletion( bool ) SAL_OVERRIDE;
 
@@ -114,12 +121,15 @@ private:
     bool m_bMultiselection;
     bool m_bIsUpdated;
     bool m_bIsConnected;
+    bool m_bServiceChanged;
 
     OUString m_sPath;
     OUString m_sStdDir;
     OUString m_sLastServiceUrl;
     unsigned int m_nCurrentFilter;
 
+    ::rtl::Reference< ::svt::AsyncPickerAction > m_pCurrentAsyncAction;
+
     ::com::sun::star::uno::Sequence< OUString > m_aBlackList;
     ::svt::IFilePickerListener* m_pFileNotifier;
 
@@ -148,6 +158,7 @@ private:
     void AddFileExtension();
 
     void EnableControls();
+    void DisableControls();
 
     DECL_LINK ( AddServiceHdl, void * );
     DECL_LINK ( SelectServiceHdl, void * );
@@ -168,6 +179,7 @@ private:
     DECL_LINK( SelectBreadcrumbHdl, Breadcrumb * );
 
     DECL_LINK( OkHdl, void * );
+    DECL_LINK( CancelHdl, void * );
 };
 
 #endif // INCLUDED_SVTOOLS_REMOTEFILESDIALOG_HXX
diff --git a/fpicker/source/office/asyncfilepicker.cxx b/fpicker/source/office/asyncfilepicker.cxx
index cf6b17b..8e4c9e3 100644
--- a/fpicker/source/office/asyncfilepicker.cxx
+++ b/fpicker/source/office/asyncfilepicker.cxx
@@ -28,7 +28,7 @@
 
 namespace svt
 {
-    AsyncPickerAction::AsyncPickerAction( SvtFileDialog* _pDialog, SvtFileView* _pView, const Action _eAction )
+    AsyncPickerAction::AsyncPickerAction( SvtFileDialog_Base* _pDialog, SvtFileView* _pView, const Action _eAction )
         :m_eAction  ( _eAction )
         ,m_pView    ( _pView   )
         ,m_pDialog  ( _pDialog )
diff --git a/fpicker/source/office/asyncfilepicker.hxx b/fpicker/source/office/asyncfilepicker.hxx
index 2174eb5..bd40153 100644
--- a/fpicker/source/office/asyncfilepicker.hxx
+++ b/fpicker/source/office/asyncfilepicker.hxx
@@ -28,7 +28,7 @@
 #include <vcl/vclptr.hxx>
 
 class SvtFileView;
-class SvtFileDialog;
+class SvtFileDialog_Base;
 
 typedef ::com::sun::star::uno::Sequence< OUString >  OUStringList;
 
@@ -54,13 +54,13 @@ namespace svt
     private:
         Action                      m_eAction;
         VclPtr<SvtFileView>         m_pView;
-        VclPtr<SvtFileDialog>       m_pDialog;
+        VclPtr<SvtFileDialog_Base>  m_pDialog;
         OUString                    m_sURL;
         OUString                    m_sFileName;
         bool                        m_bRunning;
 
     public:
-        AsyncPickerAction( SvtFileDialog* _pDialog, SvtFileView* _pView, const Action _eAction );
+        AsyncPickerAction( SvtFileDialog_Base* _pDialog, SvtFileView* _pView, const Action _eAction );
 
         /** executes the action
 
diff --git a/fpicker/source/office/fpdialogbase.hxx b/fpicker/source/office/fpdialogbase.hxx
index 7812737..19a26a4 100644
--- a/fpicker/source/office/fpdialogbase.hxx
+++ b/fpicker/source/office/fpdialogbase.hxx
@@ -82,13 +82,20 @@ public:
     virtual std::vector<OUString> GetPathList() const = 0;
     virtual bool ContentIsFolder( const OUString& rURL ) = 0;
 
+    virtual OUString getCurrentFileText() const = 0;
+    virtual void setCurrentFileText( const OUString& rText, bool bSelectAll = false ) = 0;
+
     virtual void AddFilter( const OUString& rFilter, const OUString& rType ) = 0;
     virtual void AddFilterGroup( const OUString& _rFilter,
                                 const com::sun::star::uno::Sequence< com::sun::star::beans::StringPair >& rFilters ) = 0;
     virtual OUString GetCurFilter() const = 0;
     virtual void SetCurFilter( const OUString& rFilter ) = 0;
+    virtual void FilterSelect() = 0;
 
     virtual void SetFileCallback( ::svt::IFilePickerListener *pNotifier ) = 0;
+    virtual void onAsyncOperationStarted() = 0;
+    virtual void onAsyncOperationFinished() = 0;
+    virtual void UpdateControls( const OUString& rURL ) = 0;
 
     virtual void EnableAutocompletion( bool _bEnable = true ) = 0;
 
diff --git a/fpicker/source/office/iodlg.hxx b/fpicker/source/office/iodlg.hxx
index 5748210..3856139 100644
--- a/fpicker/source/office/iodlg.hxx
+++ b/fpicker/source/office/iodlg.hxx
@@ -178,7 +178,7 @@ public:
     virtual void                StartExecuteModal( const Link<>& rEndDialogHdl ) SAL_OVERRIDE;
 
             void                FileSelect();
-            void                FilterSelect();
+            void                FilterSelect() SAL_OVERRIDE;
 
     void                        SetBlackList( const ::com::sun::star::uno::Sequence< OUString >& rBlackList ) SAL_OVERRIDE;
     const ::com::sun::star::uno::Sequence< OUString >& GetBlackList() const SAL_OVERRIDE;
@@ -207,7 +207,7 @@ public:
     SvtFileView*                GetView() SAL_OVERRIDE;
 
     void                        InitSize();
-    void                        UpdateControls( const OUString& rURL );
+    void                        UpdateControls( const OUString& rURL ) SAL_OVERRIDE;
     void                        EnableAutocompletion( bool _bEnable = true ) SAL_OVERRIDE;
 
     void                        SetFileCallback( ::svt::IFilePickerListener *pNotifier ) SAL_OVERRIDE { _pFileNotifier = pNotifier; }
@@ -219,11 +219,11 @@ public:
     bool                        getShowState() SAL_OVERRIDE;
     bool                        isAutoExtensionEnabled();
 
-    OUString                    getCurrentFileText( ) const;
-    void                        setCurrentFileText( const OUString& _rText, bool _bSelectAll = false );
+    OUString                    getCurrentFileText( ) const SAL_OVERRIDE;
+    void                        setCurrentFileText( const OUString& _rText, bool _bSelectAll = false ) SAL_OVERRIDE;
 
-    void                        onAsyncOperationStarted();
-    void                        onAsyncOperationFinished();
+    void                        onAsyncOperationStarted() SAL_OVERRIDE;
+    void                        onAsyncOperationFinished() SAL_OVERRIDE;
 
     void                        RemovablePlaceSelected(bool enable = true);
 
diff --git a/include/svtools/breadcrumb.hxx b/include/svtools/breadcrumb.hxx
index 6e6ac5f..ddd377d 100644
--- a/include/svtools/breadcrumb.hxx
+++ b/include/svtools/breadcrumb.hxx
@@ -35,6 +35,7 @@ class SVT_DLLPUBLIC Breadcrumb : public VclHBox
 
         OUString m_sRootName;
         OUString m_sClickedURL;
+        OUString m_aCurrentURL;
 
         SvtBreadcrumbMode m_eMode;
 
@@ -50,6 +51,7 @@ class SVT_DLLPUBLIC Breadcrumb : public VclHBox
         virtual ~Breadcrumb();
 
         void dispose() SAL_OVERRIDE;
+        void EnableFields( bool bEnable );
 
         void SetClickHdl( const Link<>& rLink );
         OUString GetHdlURL();
diff --git a/svtools/source/control/breadcrumb.cxx b/svtools/source/control/breadcrumb.cxx
index f1725e9..5ae725d 100644
--- a/svtools/source/control/breadcrumb.cxx
+++ b/svtools/source/control/breadcrumb.cxx
@@ -32,6 +32,17 @@ void Breadcrumb::dispose()
     VclHBox::dispose();
 }
 
+void Breadcrumb::EnableFields( bool bEnable )
+{
+    VclHBox::Enable( bEnable, true );
+    if( bEnable )
+    {
+        INetURLObject aURL( m_aCurrentURL );
+        int nSegments = aURL.getSegmentCount();
+        m_aLinks[nSegments]->Enable( false );
+    }
+}
+
 void Breadcrumb::SetClickHdl( const Link<>& rLink )
 {
     m_aClickHdl = rLink;
@@ -59,6 +70,7 @@ void Breadcrumb::SetRootName( const OUString& rURL )
 
 void Breadcrumb::SetURL( const OUString& rURL )
 {
+    m_aCurrentURL = rURL;
     INetURLObject aURL( rURL );
     aURL.setFinalSlash();
 


More information about the Libreoffice-commits mailing list