[Libreoffice-commits] core.git: Branch 'feature/gsoc15-open-remote-files-dialog' - 2 commits - include/svtools svtools/source
Szymon Kłos
eszkadev at gmail.com
Mon Jul 6 04:42:21 PDT 2015
include/svtools/RemoteFilesDialog.hxx | 3 +
svtools/source/dialogs/RemoteFilesDialog.cxx | 77 ++++++++++++++++++++++++++-
2 files changed, 79 insertions(+), 1 deletion(-)
New commits:
commit 97a716119e121005c2a6ca5d73e0bc075802ae78
Author: Szymon Kłos <eszkadev at gmail.com>
Date: Mon Jul 6 12:27:18 2015 +0200
RemoteFilesDialog: check if file/path exists
Change-Id: I72bcb9f14d4515e7a48d2330bf9757b7a7ca1438
diff --git a/svtools/source/dialogs/RemoteFilesDialog.cxx b/svtools/source/dialogs/RemoteFilesDialog.cxx
index 25b9835..03c7bcf 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;
}
commit c894a3fbbc0fdbbf44d2398a01e6cb5d8b221765
Author: Szymon Kłos <eszkadev at gmail.com>
Date: Mon Jul 6 10:20:00 2015 +0200
RemoteFilesDialog: handlers for file name editing
Change-Id: I623beb2c9d8e4ed81a9c492a046bfffbd317cff6
diff --git a/include/svtools/RemoteFilesDialog.hxx b/include/svtools/RemoteFilesDialog.hxx
index 44236d7..1e9afcb 100644
--- a/include/svtools/RemoteFilesDialog.hxx
+++ b/include/svtools/RemoteFilesDialog.hxx
@@ -160,6 +160,9 @@ private:
DECL_LINK( DoubleClickHdl, void * );
DECL_LINK( SelectHdl, void * );
+ DECL_LINK( FileNameGetFocusHdl, void * );
+ DECL_LINK( FileNameModifyHdl, void * );
+
DECL_LINK( SplitHdl, void * );
DECL_LINK( SelectFilterHdl, void * );
diff --git a/svtools/source/dialogs/RemoteFilesDialog.cxx b/svtools/source/dialogs/RemoteFilesDialog.cxx
index 3c728cd..25b9835 100644
--- a/svtools/source/dialogs/RemoteFilesDialog.cxx
+++ b/svtools/source/dialogs/RemoteFilesDialog.cxx
@@ -317,6 +317,9 @@ RemoteFilesDialog::RemoteFilesDialog( vcl::Window* pParent, WinBits nBits )
m_pContainer->Show();
m_pContainer->Enable( false );
+ m_pName_ed->SetGetFocusHdl( LINK( this, RemoteFilesDialog, FileNameGetFocusHdl ) );
+ m_pName_ed->SetModifyHdl( LINK( this, RemoteFilesDialog, FileNameModifyHdl ) );
+
m_pAddService_btn->SetMenuMode( MENUBUTTON_MENUMODE_TIMED );
m_pAddService_btn->SetClickHdl( LINK( this, RemoteFilesDialog, AddServiceHdl ) );
m_pAddService_btn->SetSelectHdl( LINK( this, RemoteFilesDialog, EditServiceMenuHdl ) );
@@ -679,6 +682,24 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, SelectHdl )
return 1;
}
+IMPL_LINK_NOARG( RemoteFilesDialog, FileNameGetFocusHdl )
+{
+ m_pFileView->SetNoSelection();
+ return 1;
+}
+
+IMPL_LINK_NOARG( RemoteFilesDialog, FileNameModifyHdl )
+{
+ m_pFileView->SetNoSelection();
+
+ if( !m_pName_ed->GetText().isEmpty() )
+ m_pOpen_btn->Enable( true );
+ else
+ m_pOpen_btn->Enable( false );
+
+ return 1;
+}
+
IMPL_LINK_NOARG ( RemoteFilesDialog, SplitHdl )
{
sal_Int32 nSplitPos = m_pSplitter->GetSplitPosPixel();
More information about the Libreoffice-commits
mailing list