diff options
author | Szymon Kłos <eszkadev@gmail.com> | 2015-07-06 12:27:18 +0200 |
---|---|---|
committer | Szymon Kłos <eszkadev@gmail.com> | 2015-07-16 09:53:27 +0200 |
commit | e80181ee32806ebae56f0e64690f219b76bf5560 (patch) | |
tree | 8406e7eb955bd17a0f6a095ca185369f41ff28e6 /svtools/source | |
parent | e99d4307ef64894baacda8512244c3ba1627e14d (diff) |
RemoteFilesDialog: check if file/path exists
Change-Id: I72bcb9f14d4515e7a48d2330bf9757b7a7ca1438
Diffstat (limited to 'svtools/source')
-rw-r--r-- | svtools/source/dialogs/RemoteFilesDialog.cxx | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/svtools/source/dialogs/RemoteFilesDialog.cxx b/svtools/source/dialogs/RemoteFilesDialog.cxx index 25b98352f050..03c7bcf43492 100644 --- a/svtools/source/dialogs/RemoteFilesDialog.cxx +++ b/svtools/source/dialogs/RemoteFilesDialog.cxx @@ -763,7 +763,58 @@ IMPL_LINK ( RemoteFilesDialog, SelectBreadcrumbHdl, Breadcrumb*, pPtr ) IMPL_LINK_NOARG ( RemoteFilesDialog, OkHdl ) { - EndDialog( RET_OK ); + // check if file/path exists + + OUString sCurrentPath = m_pFileView->GetViewURL(); + OUString sSelectedItem = m_pFileView->GetCurrentURL(); + OUString sName = m_pName_ed->GetText(); + + bool bFileDlg = ( m_eType == REMOTEDLG_TYPE_FILEDLG ); + bool bSelected = ( m_pFileView->GetSelectionCount() > 0 ); + + if( !bSelected ) + { + m_sPath = sCurrentPath + "/" + INetURLObject::encode( sName, INetURLObject::PART_FPATH, INetURLObject::ENCODE_ALL ); + } + else + { + if( m_eType == REMOTEDLG_TYPE_PATHDLG ) + m_sPath = sCurrentPath; + else + m_sPath = sSelectedItem; + } + + bool bExists = false; + + Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext(); + Reference< XInteractionHandler > xInteractionHandler( + InteractionHandler::createWithParent( xContext, 0 ), UNO_QUERY_THROW ); + Reference< XCommandEnvironment > xEnv = new ::ucbhelper::CommandEnvironment( + xInteractionHandler, Reference< XProgressHandler >() ); + ::ucbhelper::Content m_aContent( m_sPath, xEnv, xContext ); + + try + { + if( bFileDlg ) + bExists = m_aContent.isDocument(); + else + bExists = m_aContent.isFolder(); + } + catch( const Exception& ) + { + bExists = false; + } + + if ( !bExists ) + { + // TODO + + return 0; + } + + if( bExists ) + EndDialog( RET_OK ); + return 1; } @@ -881,6 +932,9 @@ std::vector<OUString> RemoteFilesDialog::GetPathList() const pEntry = m_pFileView->NextSelected( pEntry ); } + if( aList.size() == 0 && !m_sPath.isEmpty() ) + aList.push_back( m_sPath ); + return aList; } |