summaryrefslogtreecommitdiff
path: root/fpicker
diff options
context:
space:
mode:
authorSzymon Kłos <eszkadev@gmail.com>2015-07-23 16:22:33 +0200
committerSzymon Kłos <eszkadev@gmail.com>2015-07-24 12:29:08 +0200
commit3eee31157a320181c9d5c70681e62a085212c22e (patch)
treeb6098d9532ca66d3b39c3ef9ff7c408e40ec7bda /fpicker
parentdb33c7853e12e9593a530ce2327e9662bcab1480 (diff)
RemoteFilesDialog integration with AsyncPickerAction
Change-Id: If6ded1c2f2b056ce864589649b08ed19a73dc5dd
Diffstat (limited to 'fpicker')
-rw-r--r--fpicker/source/office/RemoteFilesDialog.cxx180
-rw-r--r--fpicker/source/office/RemoteFilesDialog.hxx12
-rw-r--r--fpicker/source/office/asyncfilepicker.cxx2
-rw-r--r--fpicker/source/office/asyncfilepicker.hxx6
-rw-r--r--fpicker/source/office/fpdialogbase.hxx7
-rw-r--r--fpicker/source/office/iodlg.hxx12
6 files changed, 166 insertions, 53 deletions
diff --git a/fpicker/source/office/RemoteFilesDialog.cxx b/fpicker/source/office/RemoteFilesDialog.cxx
index 4e69c9d0df59..7106366fb61d 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 b0f151e2b71e..a62b4cf447f5 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 cf6b17b07c8f..8e4c9e3d2ff6 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 2174eb50e6ca..bd40153ea8a8 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 7812737154ba..19a26a41890d 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 57482107fdc7..385613926d26 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);