[Libreoffice-commits] core.git: Branch 'feature/gsoc15-open-remote-files-dialog' - 2 commits - include/svtools svtools/source
Szymon Kłos
eszkadev at gmail.com
Thu Jun 25 03:17:57 PDT 2015
include/svtools/RemoteFilesDialog.hxx | 48 +-
svtools/source/dialogs/RemoteFilesDialog.cxx | 489 +++++++++++++--------------
2 files changed, 266 insertions(+), 271 deletions(-)
New commits:
commit c7eed91235876b75be2043bf78e50c07d201e41f
Author: Szymon Kłos <eszkadev at gmail.com>
Date: Thu Jun 25 12:10:54 2015 +0200
RemoteFilesDialog: consistent code in the whole file
Change-Id: I994d07e631b7c8c1efdeca351754c5b3e3997bb4
diff --git a/include/svtools/RemoteFilesDialog.hxx b/include/svtools/RemoteFilesDialog.hxx
index 0b8822c..b2686f1 100644
--- a/include/svtools/RemoteFilesDialog.hxx
+++ b/include/svtools/RemoteFilesDialog.hxx
@@ -59,8 +59,8 @@ enum SvtRemoteDlgType
REMOTEDLG_TYPE_PATHDLG = 1
};
-typedef std::shared_ptr<Place> ServicePtr;
-typedef ::com::sun::star::uno::Sequence<OUString> OUStringList;
+typedef std::shared_ptr< Place > ServicePtr;
+typedef ::com::sun::star::uno::Sequence< OUString > OUStringList;
class FileViewContainer;
class Breadcrumb;
@@ -69,7 +69,7 @@ class FolderTree;
class SVT_DLLPUBLIC RemoteFilesDialog : public ModalDialog
{
public:
- RemoteFilesDialog(vcl::Window* pParent, WinBits nBits);
+ RemoteFilesDialog( vcl::Window* pParent, WinBits nBits );
virtual ~RemoteFilesDialog();
virtual void dispose() SAL_OVERRIDE;
@@ -90,28 +90,28 @@ private:
OUString m_sPath;
- VclPtr<PushButton> m_pOpen_btn;
- VclPtr<PushButton> m_pSave_btn;
- VclPtr<CancelButton> m_pCancel_btn;
- VclPtr<MenuButton> m_pAddService_btn;
- VclPtr<ListBox> m_pServices_lb;
- VclPtr<Breadcrumb> m_pPath;
- VclPtr<Splitter> m_pSplitter;
- VclPtr<FolderTree> m_pTreeView;
- VclPtr<SvtFileView> m_pFileView;
- VclPtr<FileViewContainer> m_pContainer;
- VclPtr<ListBox> m_pFilter_lb;
- VclPtr<Edit> m_pName_ed;
-
- std::vector<ServicePtr> m_aServices;
- std::vector<OUString> m_aFilters;
+ VclPtr< PushButton > m_pOpen_btn;
+ VclPtr< PushButton > m_pSave_btn;
+ VclPtr< CancelButton > m_pCancel_btn;
+ VclPtr< MenuButton > m_pAddService_btn;
+ VclPtr< ListBox > m_pServices_lb;
+ VclPtr< Breadcrumb > m_pPath;
+ VclPtr< Splitter > m_pSplitter;
+ VclPtr< FolderTree > m_pTreeView;
+ VclPtr< SvtFileView > m_pFileView;
+ VclPtr< FileViewContainer > m_pContainer;
+ VclPtr< ListBox > m_pFilter_lb;
+ VclPtr< Edit > m_pName_ed;
+
+ std::vector< ServicePtr > m_aServices;
+ std::vector< OUString > m_aFilters;
void FillServicesListbox();
/* If failure returns < 0 */
int GetSelectedServicePos();
- OUString getCurrentFilter();
+ OUString GetCurrentFilter();
FileViewResult OpenURL( OUString sURL );
diff --git a/svtools/source/dialogs/RemoteFilesDialog.cxx b/svtools/source/dialogs/RemoteFilesDialog.cxx
index cee1b7b..405548e 100644
--- a/svtools/source/dialogs/RemoteFilesDialog.cxx
+++ b/svtools/source/dialogs/RemoteFilesDialog.cxx
@@ -227,25 +227,25 @@ class FileViewContainer : public vcl::Window
}
};
-RemoteFilesDialog::RemoteFilesDialog(vcl::Window* pParent, WinBits nBits)
- : ModalDialog(pParent, "RemoteFilesDialog", "svt/ui/remotefilesdialog.ui")
- , m_context(comphelper::getProcessComponentContext())
- , m_aFolderImage(SvtResId(IMG_SVT_FOLDER))
- , m_pSplitter(NULL)
- , m_pFileView(NULL)
- , m_pContainer(NULL)
+RemoteFilesDialog::RemoteFilesDialog( vcl::Window* pParent, WinBits nBits )
+ : ModalDialog( pParent, "RemoteFilesDialog", "svt/ui/remotefilesdialog.ui" )
+ , m_context( comphelper::getProcessComponentContext() )
+ , m_aFolderImage( SvtResId( IMG_SVT_FOLDER ) )
+ , m_pSplitter( NULL )
+ , m_pFileView( NULL )
+ , m_pContainer( NULL )
{
- get(m_pOpen_btn, "open");
- get(m_pSave_btn, "save");
- get(m_pCancel_btn, "cancel");
- get(m_pAddService_btn, "add_service_btn");
- get(m_pServices_lb, "services_lb");
- get(m_pFilter_lb, "filter_lb");
- get(m_pName_ed, "name_ed");
-
- m_eMode = (nBits & WB_SAVEAS) ? REMOTEDLG_MODE_SAVE : REMOTEDLG_MODE_OPEN;
- m_eType = (nBits & WB_PATH) ? REMOTEDLG_TYPE_PATHDLG : REMOTEDLG_TYPE_FILEDLG;
- m_bMultiselection = (nBits & WB_MULTISELECTION) ? true : false;
+ get( m_pOpen_btn, "open" );
+ get( m_pSave_btn, "save" );
+ get( m_pCancel_btn, "cancel" );
+ get( m_pAddService_btn, "add_service_btn" );
+ get( m_pServices_lb, "services_lb" );
+ get( m_pFilter_lb, "filter_lb" );
+ get( m_pName_ed, "name_ed" );
+
+ m_eMode = ( nBits & WB_SAVEAS ) ? REMOTEDLG_MODE_SAVE : REMOTEDLG_MODE_OPEN;
+ m_eType = ( nBits & WB_PATH ) ? REMOTEDLG_TYPE_PATHDLG : REMOTEDLG_TYPE_FILEDLG;
+ m_bMultiselection = ( nBits & WB_MULTISELECTION ) ? true : false;
m_bIsUpdated = false;
m_pOpen_btn->Enable( false );
@@ -253,7 +253,7 @@ RemoteFilesDialog::RemoteFilesDialog(vcl::Window* pParent, WinBits nBits)
m_pFilter_lb->Enable( false );
m_pName_ed->Enable( false );
- if(m_eMode == REMOTEDLG_MODE_OPEN)
+ if( m_eMode == REMOTEDLG_MODE_OPEN )
{
m_pSave_btn->Hide();
m_pOpen_btn->Show();
@@ -266,18 +266,18 @@ RemoteFilesDialog::RemoteFilesDialog(vcl::Window* pParent, WinBits nBits)
m_pOpen_btn->SetClickHdl( LINK( this, RemoteFilesDialog, OkHdl ) );
- m_pPath = VclPtr<Breadcrumb>::Create( get<vcl::Window>("breadcrumb_container") );
- m_pPath->set_hexpand(true);
+ m_pPath = VclPtr<Breadcrumb>::Create( get< vcl::Window >( "breadcrumb_container" ) );
+ m_pPath->set_hexpand( true );
m_pPath->SetClickHdl( LINK( this, RemoteFilesDialog, SelectBreadcrumbHdl ) );
m_pPath->SetMode( SvtBreadcrumbMode::ALL_VISITED );
m_pPath->Show();
- m_pContainer = VclPtr<FileViewContainer>::Create( get<vcl::Window>("container") );
+ m_pContainer = VclPtr< FileViewContainer >::Create( get< vcl::Window >("container") );
- m_pContainer->set_hexpand(true);
- m_pContainer->set_vexpand(true);
+ m_pContainer->set_hexpand( true );
+ m_pContainer->set_vexpand( true );
- m_pFileView = VclPtr<SvtFileView>::Create( m_pContainer, WB_BORDER | WB_TABSTOP,
+ m_pFileView = VclPtr< SvtFileView >::Create( m_pContainer, WB_BORDER | WB_TABSTOP,
REMOTEDLG_TYPE_PATHDLG == m_eType,
m_bMultiselection );
@@ -286,26 +286,26 @@ RemoteFilesDialog::RemoteFilesDialog(vcl::Window* pParent, WinBits nBits)
m_pFileView->SetDoubleClickHdl( LINK( this, RemoteFilesDialog, DoubleClickHdl ) );
m_pFileView->SetSelectHdl( LINK( this, RemoteFilesDialog, SelectHdl ) );
- m_pSplitter = VclPtr<Splitter>::Create( m_pContainer, WB_HSCROLL );
- m_pSplitter->SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor() ));
+ m_pSplitter = VclPtr< Splitter >::Create( m_pContainer, WB_HSCROLL );
+ m_pSplitter->SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor() ) );
m_pSplitter->SetSplitHdl( LINK( this, RemoteFilesDialog, SplitHdl ) );
m_pSplitter->Show();
- m_pTreeView = VclPtr<FolderTree>::Create( m_pContainer, WB_BORDER | WB_SORT | WB_TABSTOP );
- Size aSize(100, 200);
- m_pTreeView->set_height_request(aSize.Height());
- m_pTreeView->set_width_request(aSize.Width());
- m_pTreeView->SetSizePixel(aSize);
+ m_pTreeView = VclPtr< FolderTree >::Create( m_pContainer, WB_BORDER | WB_SORT | WB_TABSTOP );
+ Size aSize( 100, 200 );
+ m_pTreeView->set_height_request( aSize.Height() );
+ m_pTreeView->set_width_request( aSize.Width() );
+ m_pTreeView->SetSizePixel( aSize );
m_pTreeView->Show();
- m_pTreeView->SetDefaultCollapsedEntryBmp(m_aFolderImage);
- m_pTreeView->SetDefaultExpandedEntryBmp(m_aFolderImage);
+ m_pTreeView->SetDefaultCollapsedEntryBmp( m_aFolderImage );
+ m_pTreeView->SetDefaultExpandedEntryBmp( m_aFolderImage );
m_pTreeView->SetSelectHdl( LINK( this, RemoteFilesDialog, TreeSelectHdl ) );
sal_Int32 nPosX = m_pTreeView->GetSizePixel().Width();
- m_pSplitter->SetPosPixel(Point(nPosX, 0));
+ m_pSplitter->SetPosPixel( Point( nPosX, 0 ) );
nPosX += m_pSplitter->GetSizePixel().Width();
- m_pFileView->SetPosPixel(Point(nPosX, 0));
+ m_pFileView->SetPosPixel( Point( nPosX, 0 ) );
m_pContainer->init( m_pFileView, m_pSplitter, m_pTreeView, m_pAddService_btn, m_pFilter_lb );
m_pContainer->Show();
@@ -331,22 +331,22 @@ void RemoteFilesDialog::dispose()
{
m_pFileView->SetSelectHdl( Link<>() );
- if(m_bIsUpdated)
+ if( m_bIsUpdated )
{
- Sequence< OUString > placesUrlsList(m_aServices.size());
- Sequence< OUString > placesNamesList(m_aServices.size());
+ Sequence< OUString > placesUrlsList( m_aServices.size() );
+ Sequence< OUString > placesNamesList( m_aServices.size() );
int i = 0;
- for(std::vector<ServicePtr>::const_iterator it = m_aServices.begin(); it != m_aServices.end(); ++it)
+ for( std::vector< ServicePtr >::const_iterator it = m_aServices.begin(); it != m_aServices.end(); ++it )
{
- placesUrlsList[i] = (*it)->GetUrl();
- placesNamesList[i] = (*it)->GetName();
+ placesUrlsList[i] = ( *it )->GetUrl();
+ placesNamesList[i] = ( *it )->GetName();
++i;
}
- std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(m_context));
- officecfg::Office::Common::Misc::FilePickerPlacesUrls::set(placesUrlsList, batch);
- officecfg::Office::Common::Misc::FilePickerPlacesNames::set(placesNamesList, batch);
+ std::shared_ptr< comphelper::ConfigurationChanges > batch( comphelper::ConfigurationChanges::create( m_context ) );
+ officecfg::Office::Common::Misc::FilePickerPlacesUrls::set( placesUrlsList, batch );
+ officecfg::Office::Common::Misc::FilePickerPlacesNames::set( placesNamesList, batch );
batch->commit();
}
@@ -371,45 +371,45 @@ void RemoteFilesDialog::Resize()
{
ModalDialog::Resize();
- if(m_pFileView && m_pContainer)
+ if( m_pFileView && m_pContainer )
{
Size aSize = m_pContainer->GetSizePixel();
- m_pFileView->SetSizePixel(aSize);
+ m_pFileView->SetSizePixel( aSize );
}
}
-OUString lcl_GetServiceType(ServicePtr pService)
+OUString lcl_GetServiceType( ServicePtr pService )
{
INetProtocol aProtocol = pService->GetUrlObject().GetProtocol();
- switch(aProtocol)
+ switch( aProtocol )
{
case INetProtocol::Ftp:
- return OUString("FTP");
+ return OUString( "FTP" );
case INetProtocol::Cmis:
{
OUString sHost = pService->GetUrlObject().GetHost( INetURLObject::DECODE_WITH_CHARSET );
- if(sHost.startsWith(GDRIVE_BASE_URL))
- return OUString("Google Drive");
- else if(sHost.startsWith(ALFRESCO_CLOUD_BASE_URL))
- return OUString("Alfresco Cloud");
- else if(sHost.startsWith(ONEDRIVE_BASE_URL))
- return OUString("OneDrive");
+ if( sHost.startsWith( GDRIVE_BASE_URL ) )
+ return OUString( "Google Drive" );
+ else if( sHost.startsWith( ALFRESCO_CLOUD_BASE_URL ) )
+ return OUString( "Alfresco Cloud" );
+ else if( sHost.startsWith( ONEDRIVE_BASE_URL ) )
+ return OUString( "OneDrive" );
- return OUString("CMIS");
+ return OUString( "CMIS" );
}
case INetProtocol::Smb:
- return OUString("Windows Share");
+ return OUString( "Windows Share" );
case INetProtocol::File:
- return OUString("SSH");
+ return OUString( "SSH" );
case INetProtocol::Http:
- return OUString("WebDAV");
+ return OUString( "WebDAV" );
case INetProtocol::Https:
- return OUString("WebDAV");
+ return OUString( "WebDAV" );
case INetProtocol::Generic:
- return OUString("SSH");
+ return OUString( "SSH" );
default:
- return OUString("");
+ return OUString( "" );
}
}
@@ -419,30 +419,30 @@ void RemoteFilesDialog::FillServicesListbox()
m_aServices.clear();
// Load from user settings
- Sequence< OUString > placesUrlsList(officecfg::Office::Common::Misc::FilePickerPlacesUrls::get(m_context));
- Sequence< OUString > placesNamesList(officecfg::Office::Common::Misc::FilePickerPlacesNames::get(m_context));
+ Sequence< OUString > placesUrlsList( officecfg::Office::Common::Misc::FilePickerPlacesUrls::get( m_context ) );
+ Sequence< OUString > placesNamesList( officecfg::Office::Common::Misc::FilePickerPlacesNames::get( m_context ) );
- for(sal_Int32 nPlace = 0; nPlace < placesUrlsList.getLength() && nPlace < placesNamesList.getLength(); ++nPlace)
+ for( sal_Int32 nPlace = 0; nPlace < placesUrlsList.getLength() && nPlace < placesNamesList.getLength(); ++nPlace )
{
- ServicePtr pService(new Place(placesNamesList[nPlace], placesUrlsList[nPlace], true));
- m_aServices.push_back(pService);
+ ServicePtr pService( new Place( placesNamesList[nPlace], placesUrlsList[nPlace], true ) );
+ m_aServices.push_back( pService );
// Add to the listbox only remote services, not local bookmarks
- if(!pService->IsLocal())
+ if( !pService->IsLocal() )
{
- OUString sPrefix = lcl_GetServiceType(pService);
+ OUString sPrefix = lcl_GetServiceType( pService );
- if(!sPrefix.isEmpty())
+ if( !sPrefix.isEmpty() )
sPrefix += ": ";
- m_pServices_lb->InsertEntry(sPrefix + placesNamesList[nPlace]);
+ m_pServices_lb->InsertEntry( sPrefix + placesNamesList[nPlace] );
}
}
- if(m_pServices_lb->GetEntryCount() > 0)
- m_pServices_lb->SelectEntryPos(0);
+ if( m_pServices_lb->GetEntryCount() > 0 )
+ m_pServices_lb->SelectEntryPos( 0 );
else
- m_pServices_lb->Enable(false);
+ m_pServices_lb->Enable( false );
}
int RemoteFilesDialog::GetSelectedServicePos()
@@ -451,15 +451,15 @@ int RemoteFilesDialog::GetSelectedServicePos()
int nPos = 0;
int i = -1;
- if(m_aServices.size() == 0)
+ if( m_aServices.size() == 0 )
return -1;
- while(nPos < (int)m_aServices.size())
+ while( nPos < ( int )m_aServices.size() )
{
- while(m_aServices[nPos]->IsLocal())
+ while( m_aServices[nPos]->IsLocal() )
nPos++;
i++;
- if(i == nSelected)
+ if( i == nSelected )
break;
nPos++;
}
@@ -472,7 +472,7 @@ void RemoteFilesDialog::AddFilter( OUString sName, OUString sType )
m_aFilters.push_back( sType );
m_pFilter_lb->InsertEntry( sName );
- if(m_pFilter_lb->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND)
+ if( m_pFilter_lb->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND )
m_pFilter_lb->SelectEntryPos( 0 );
}
@@ -481,13 +481,13 @@ OUString RemoteFilesDialog::GetPath() const
return m_sPath;
}
-OUString RemoteFilesDialog::getCurrentFilter()
+OUString RemoteFilesDialog::GetCurrentFilter()
{
OUString sFilter;
int nPos = m_pFilter_lb->GetSelectEntryPos();
- if(nPos != LISTBOX_ENTRY_NOTFOUND)
+ if( nPos != LISTBOX_ENTRY_NOTFOUND )
sFilter = m_aFilters[nPos];
else
sFilter = FILTER_ALL;
@@ -499,10 +499,10 @@ FileViewResult RemoteFilesDialog::OpenURL( OUString sURL )
{
FileViewResult eResult = eFailure;
- if(m_pFileView)
+ if( m_pFileView )
{
OUStringList BlackList;
- OUString sFilter = getCurrentFilter();
+ OUString sFilter = GetCurrentFilter();
m_pFileView->EndInplaceEditing( false );
eResult = m_pFileView->Initialize( sURL, sFilter, NULL, BlackList );
@@ -522,24 +522,24 @@ FileViewResult RemoteFilesDialog::OpenURL( OUString sURL )
IMPL_LINK_NOARG ( RemoteFilesDialog, AddServiceHdl )
{
- ScopedVclPtrInstance< PlaceEditDialog > aDlg(this);
+ ScopedVclPtrInstance< PlaceEditDialog > aDlg( this );
short aRetCode = aDlg->Execute();
- switch(aRetCode)
+ switch( aRetCode )
{
case RET_OK :
{
ServicePtr newService = aDlg->GetPlace();
- m_aServices.push_back(newService);
- m_pServices_lb->Enable(true);
+ m_aServices.push_back( newService );
+ m_pServices_lb->Enable( true );
- OUString sPrefix = lcl_GetServiceType(newService);
+ OUString sPrefix = lcl_GetServiceType( newService );
if(!sPrefix.isEmpty())
sPrefix += ": ";
- m_pServices_lb->InsertEntry(sPrefix + newService->GetName());
- m_pServices_lb->SelectEntryPos(m_pServices_lb->GetEntryCount() - 1);
+ m_pServices_lb->InsertEntry( sPrefix + newService->GetName() );
+ m_pServices_lb->SelectEntryPos( m_pServices_lb->GetEntryCount() - 1 );
m_bIsUpdated = true;
break;
@@ -580,27 +580,27 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, SelectServiceHdl )
IMPL_LINK_TYPED ( RemoteFilesDialog, EditServiceMenuHdl, MenuButton *, pButton, void )
{
- OString sIdent(pButton->GetCurItemIdent());
- if(sIdent == "edit_service" && m_pServices_lb->GetEntryCount() > 0)
+ OString sIdent( pButton->GetCurItemIdent() );
+ if( sIdent == "edit_service" && m_pServices_lb->GetEntryCount() > 0 )
{
unsigned int nSelected = m_pServices_lb->GetSelectEntryPos();
int nPos = GetSelectedServicePos();
- if(nPos > 0)
+ if( nPos > 0 )
{
- ScopedVclPtrInstance< PlaceEditDialog > aDlg(this, m_aServices[nPos]);
+ ScopedVclPtrInstance< PlaceEditDialog > aDlg( this, m_aServices[nPos] );
short aRetCode = aDlg->Execute();
- switch(aRetCode)
+ switch( aRetCode )
{
case RET_OK :
{
ServicePtr pEditedService = aDlg->GetPlace();
m_aServices[nPos] = pEditedService;
- m_pServices_lb->RemoveEntry(nSelected);
- m_pServices_lb->InsertEntry(pEditedService->GetName(), nSelected);
- m_pServices_lb->SelectEntryPos(nSelected);
+ m_pServices_lb->RemoveEntry( nSelected );
+ m_pServices_lb->InsertEntry( pEditedService->GetName(), nSelected );
+ m_pServices_lb->SelectEntryPos( nSelected );
m_bIsUpdated = true;
break;
@@ -612,26 +612,26 @@ IMPL_LINK_TYPED ( RemoteFilesDialog, EditServiceMenuHdl, MenuButton *, pButton,
};
}
}
- else if(sIdent == "delete_service" && m_pServices_lb->GetEntryCount() > 0)
+ else if( sIdent == "delete_service" && m_pServices_lb->GetEntryCount() > 0 )
{
unsigned int nSelected = m_pServices_lb->GetSelectEntryPos();
int nPos = GetSelectedServicePos();
- if(nPos > 0)
+ if( nPos > 0 )
{
// TODO: Confirm dialog
- m_aServices.erase(m_aServices.begin() + nPos);
- m_pServices_lb->RemoveEntry(nSelected);
+ m_aServices.erase( m_aServices.begin() + nPos );
+ m_pServices_lb->RemoveEntry( nSelected );
- if(m_pServices_lb->GetEntryCount() > 0)
+ if( m_pServices_lb->GetEntryCount() > 0 )
{
- m_pServices_lb->SelectEntryPos(0);
+ m_pServices_lb->SelectEntryPos( 0 );
}
else
{
m_pServices_lb->SetNoSelection();
- m_pServices_lb->Enable(false);
+ m_pServices_lb->Enable( false );
}
m_bIsUpdated = true;
@@ -678,8 +678,8 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, SplitHdl )
sal_Int32 nSplitPos = m_pSplitter->GetSplitPosPixel();
// Resize the tree list box
- sal_Int32 nPlaceX = m_pTreeView->GetPosPixel( ).X();
- Size placeSize = m_pTreeView->GetSizePixel( );
+ sal_Int32 nPlaceX = m_pTreeView->GetPosPixel().X();
+ Size placeSize = m_pTreeView->GetSizePixel();
placeSize.Width() = nSplitPos - nPlaceX;
m_pTreeView->SetSizePixel( placeSize );
commit bc085941395cc8863074aa57e9f4865e4bad9ab4
Author: Szymon Kłos <eszkadev at gmail.com>
Date: Thu Jun 25 11:55:48 2015 +0200
Added a subclass of SvTreeView, tree's code moved to it
Change-Id: Ide6ea470ac198e02e42f8cd07aff72005e2f78e9
diff --git a/include/svtools/RemoteFilesDialog.hxx b/include/svtools/RemoteFilesDialog.hxx
index 033e8c0..0b8822c 100644
--- a/include/svtools/RemoteFilesDialog.hxx
+++ b/include/svtools/RemoteFilesDialog.hxx
@@ -64,6 +64,7 @@ typedef ::com::sun::star::uno::Sequence<OUString> OUStringList;
class FileViewContainer;
class Breadcrumb;
+class FolderTree;
class SVT_DLLPUBLIC RemoteFilesDialog : public ModalDialog
{
@@ -89,9 +90,6 @@ private:
OUString m_sPath;
- Reference< XCommandEnvironment > m_xEnv;
- ::osl::Mutex m_aMutex;
-
VclPtr<PushButton> m_pOpen_btn;
VclPtr<PushButton> m_pSave_btn;
VclPtr<CancelButton> m_pCancel_btn;
@@ -99,7 +97,7 @@ private:
VclPtr<ListBox> m_pServices_lb;
VclPtr<Breadcrumb> m_pPath;
VclPtr<Splitter> m_pSplitter;
- VclPtr<SvTreeListBox> m_pTreeView;
+ VclPtr<FolderTree> m_pTreeView;
VclPtr<SvtFileView> m_pFileView;
VclPtr<FileViewContainer> m_pContainer;
VclPtr<ListBox> m_pFilter_lb;
@@ -117,9 +115,6 @@ private:
FileViewResult OpenURL( OUString sURL );
- void fillTreeEntry( SvTreeListEntry* pParent );
- void setTreePath( OUString sPath );
-
DECL_LINK ( AddServiceHdl, void * );
DECL_LINK ( SelectServiceHdl, void * );
DECL_LINK_TYPED ( EditServiceMenuHdl, MenuButton *, void );
@@ -131,8 +126,7 @@ private:
DECL_LINK( SelectFilterHdl, void * );
- DECL_LINK( TreeSelectHdl, SvTreeListBox * );
- DECL_LINK( TreeExpandHdl, SvTreeListBox * );
+ DECL_LINK( TreeSelectHdl, FolderTree * );
DECL_LINK( SelectBreadcrumbHdl, Breadcrumb * );
diff --git a/svtools/source/dialogs/RemoteFilesDialog.cxx b/svtools/source/dialogs/RemoteFilesDialog.cxx
index c5aef0f..cee1b7b 100644
--- a/svtools/source/dialogs/RemoteFilesDialog.cxx
+++ b/svtools/source/dialogs/RemoteFilesDialog.cxx
@@ -10,22 +10,128 @@
#include <svtools/RemoteFilesDialog.hxx>
#include "../contnr/contentenumeration.hxx"
+class FolderTree : public SvTreeListBox
+{
+private:
+ Reference< XCommandEnvironment > m_xEnv;
+ ::osl::Mutex m_aMutex;
+
+public:
+ FolderTree( vcl::Window* pParent, WinBits nBits )
+ : SvTreeListBox( pParent, nBits )
+ {
+ Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
+ Reference< XInteractionHandler > xInteractionHandler(
+ InteractionHandler::createWithParent( xContext, 0 ), UNO_QUERY_THROW );
+ m_xEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler, Reference< XProgressHandler >() );
+ }
+
+ virtual void RequestingChildren( SvTreeListEntry* pEntry )
+ {
+ FillTreeEntry( pEntry );
+ }
+
+ void FillTreeEntry( SvTreeListEntry* pEntry )
+ {
+ // fill only empty entries
+ if( pEntry && GetChildCount( pEntry ) == 0 )
+ {
+ ::std::vector< SortingData_Impl* > aContent;
+
+ FileViewContentEnumerator* pContentEnumerator = new FileViewContentEnumerator(
+ m_xEnv, aContent, m_aMutex, NULL );
+
+ OUString* pURL = static_cast< OUString* >( pEntry->GetUserData() );
+
+ if( pURL )
+ {
+ FolderDescriptor aFolder( *pURL );
+ Sequence< OUString > aBlackList;
+
+ EnumerationResult eResult =
+ pContentEnumerator->enumerateFolderContentSync( aFolder, aBlackList );
+
+ if ( SUCCESS == eResult )
+ {
+ for( unsigned int i = 0; i < aContent.size(); i++ )
+ {
+ if( aContent[i]->mbIsFolder )
+ {
+ SvTreeListEntry* pNewEntry = InsertEntry( aContent[i]->GetTitle(), pEntry, true );
+
+ OUString* sData = new OUString( aContent[i]->maTargetURL );
+ pNewEntry->SetUserData( static_cast< void* >( sData ) );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ void SetTreePath( OUString sUrl )
+ {
+ INetURLObject aUrl( sUrl );
+ aUrl.setFinalSlash();
+
+ OUString sPath = aUrl.GetURLPath( INetURLObject::DECODE_WITH_CHARSET );
+
+ SvTreeListEntry* pEntry = First();
+ bool end = false;
+
+ while( pEntry && !end )
+ {
+ if( pEntry->GetUserData() )
+ {
+ OUString sNodeUrl = *static_cast< OUString* >( pEntry->GetUserData() );
+
+ INetURLObject aUrlObj( sNodeUrl );
+ aUrlObj.setFinalSlash();
+
+ sNodeUrl = aUrlObj.GetURLPath( INetURLObject::DECODE_WITH_CHARSET );
+
+ if( sPath == sNodeUrl )
+ {
+ Select( pEntry );
+
+ if( !IsExpanded( pEntry ) )
+ Expand( pEntry );
+
+ end = true;
+ }
+ else if( sPath.startsWith( sNodeUrl ) )
+ {
+ if( !IsExpanded( pEntry ) )
+ Expand( pEntry );
+
+ pEntry = FirstChild( pEntry );
+ }
+ else
+ {
+ pEntry = NextSibling( pEntry );
+ }
+ }
+ else
+ break;
+ }
+ }
+};
+
class FileViewContainer : public vcl::Window
{
private:
- VclPtr<SvtFileView> m_pFileView;
- VclPtr<SvTreeListBox> m_pTreeView;
- VclPtr<Splitter> m_pSplitter;
+ VclPtr< SvtFileView > m_pFileView;
+ VclPtr< FolderTree > m_pTreeView;
+ VclPtr< Splitter > m_pSplitter;
int m_nCurrentFocus;
vcl::Window* m_pFocusWidgets[4];
public:
- FileViewContainer(vcl::Window *pParent)
- : Window(pParent, WB_TABSTOP)
- , m_pFileView(NULL)
- , m_pTreeView(NULL)
- , m_pSplitter(NULL)
+ FileViewContainer( vcl::Window *pParent )
+ : Window( pParent, WB_TABSTOP )
+ , m_pFileView( NULL )
+ , m_pTreeView( NULL )
+ , m_pSplitter( NULL )
{
}
@@ -41,11 +147,11 @@ class FileViewContainer : public vcl::Window
vcl::Window::dispose();
}
- void init(SvtFileView* pFileView,
+ void init( SvtFileView* pFileView,
Splitter* pSplitter,
- SvTreeListBox* pTreeView,
+ FolderTree* pTreeView,
vcl::Window* pPrevSibling,
- vcl::Window* pNextSibling)
+ vcl::Window* pNextSibling )
{
m_pFileView = pFileView;
m_pTreeView = pTreeView;
@@ -60,39 +166,39 @@ class FileViewContainer : public vcl::Window
{
Window::Resize();
- if(!m_pFileView || !m_pTreeView)
+ if( !m_pFileView || !m_pTreeView )
return;
Size aSize = GetSizePixel();
Point aPos( m_pFileView->GetPosPixel() );
- Size aNewSize(aSize.Width() - aPos.X(), aSize.Height());
+ Size aNewSize( aSize.Width() - aPos.X(), aSize.Height() );
m_pFileView->SetSizePixel( aNewSize );
// Resize the Splitter to fit the height
- Size splitterNewSize = m_pSplitter->GetSizePixel( );
+ Size splitterNewSize = m_pSplitter->GetSizePixel();
splitterNewSize.Height() = aSize.Height();
m_pSplitter->SetSizePixel( splitterNewSize );
- sal_Int32 nMinX = m_pTreeView->GetPosPixel( ).X( );
- sal_Int32 nMaxX = m_pFileView->GetPosPixel( ).X( ) + m_pFileView->GetSizePixel( ).Width() - nMinX;
+ sal_Int32 nMinX = m_pTreeView->GetPosPixel().X();
+ sal_Int32 nMaxX = m_pFileView->GetPosPixel().X() + m_pFileView->GetSizePixel().Width() - nMinX;
m_pSplitter->SetDragRectPixel( Rectangle( Point( nMinX, 0 ), Size( nMaxX, aSize.Width() ) ) );
// Resize the tree list box to fit the height of the FileView
- Size placesNewSize(m_pTreeView->GetSizePixel());
+ Size placesNewSize( m_pTreeView->GetSizePixel() );
placesNewSize.Height() = aSize.Height();
m_pTreeView->SetSizePixel( placesNewSize );
}
- void changeFocus(bool bReverse)
+ void changeFocus( bool bReverse )
{
- if(!bReverse && m_nCurrentFocus < 4)
+ if( !bReverse && m_nCurrentFocus < 4 )
{
- m_pFocusWidgets[++m_nCurrentFocus]->SetFakeFocus(true);
+ m_pFocusWidgets[++m_nCurrentFocus]->SetFakeFocus( true );
m_pFocusWidgets[m_nCurrentFocus]->GrabFocus();
}
- else if(m_nCurrentFocus > 0)
+ else if( m_nCurrentFocus > 0 )
{
- m_pFocusWidgets[--m_nCurrentFocus]->SetFakeFocus(true);
+ m_pFocusWidgets[--m_nCurrentFocus]->SetFakeFocus( true );
m_pFocusWidgets[m_nCurrentFocus]->GrabFocus();
}
}
@@ -100,24 +206,24 @@ class FileViewContainer : public vcl::Window
virtual void GetFocus() SAL_OVERRIDE
{
m_nCurrentFocus = 1;
- m_pFocusWidgets[m_nCurrentFocus]->SetFakeFocus(true);
+ m_pFocusWidgets[m_nCurrentFocus]->SetFakeFocus( true );
m_pFocusWidgets[m_nCurrentFocus]->GrabFocus();
}
- virtual bool Notify(NotifyEvent& rNEvt)
+ virtual bool Notify( NotifyEvent& rNEvt )
{
- if(rNEvt.GetType() == MouseNotifyEvent::KEYINPUT)
+ if( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
{
const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent();
const vcl::KeyCode& rCode = pKeyEvent->GetKeyCode();
bool bShift = rCode.IsShift();
- if(rCode.GetCode() == KEY_TAB)
+ if( rCode.GetCode() == KEY_TAB )
{
- changeFocus(bShift);
+ changeFocus( bShift );
return true;
}
}
- return Window::Notify(rNEvt);
+ return Window::Notify( rNEvt );
}
};
@@ -137,11 +243,6 @@ RemoteFilesDialog::RemoteFilesDialog(vcl::Window* pParent, WinBits nBits)
get(m_pFilter_lb, "filter_lb");
get(m_pName_ed, "name_ed");
- Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
- Reference< XInteractionHandler > xInteractionHandler(
- InteractionHandler::createWithParent(xContext, 0), UNO_QUERY_THROW );
- m_xEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler, Reference< XProgressHandler >() );
-
m_eMode = (nBits & WB_SAVEAS) ? REMOTEDLG_MODE_SAVE : REMOTEDLG_MODE_OPEN;
m_eType = (nBits & WB_PATH) ? REMOTEDLG_TYPE_PATHDLG : REMOTEDLG_TYPE_FILEDLG;
m_bMultiselection = (nBits & WB_MULTISELECTION) ? true : false;
@@ -190,7 +291,7 @@ RemoteFilesDialog::RemoteFilesDialog(vcl::Window* pParent, WinBits nBits)
m_pSplitter->SetSplitHdl( LINK( this, RemoteFilesDialog, SplitHdl ) );
m_pSplitter->Show();
- m_pTreeView = VclPtr<SvTreeListBox>::Create( m_pContainer, WB_BORDER | WB_SORT | WB_TABSTOP );
+ m_pTreeView = VclPtr<FolderTree>::Create( m_pContainer, WB_BORDER | WB_SORT | WB_TABSTOP );
Size aSize(100, 200);
m_pTreeView->set_height_request(aSize.Height());
m_pTreeView->set_width_request(aSize.Width());
@@ -200,7 +301,6 @@ RemoteFilesDialog::RemoteFilesDialog(vcl::Window* pParent, WinBits nBits)
m_pTreeView->SetDefaultExpandedEntryBmp(m_aFolderImage);
m_pTreeView->SetSelectHdl( LINK( this, RemoteFilesDialog, TreeSelectHdl ) );
- m_pTreeView->SetExpandingHdl( LINK( this, RemoteFilesDialog, TreeExpandHdl ) );
sal_Int32 nPosX = m_pTreeView->GetSizePixel().Width();
m_pSplitter->SetPosPixel(Point(nPosX, 0));
@@ -410,7 +510,7 @@ FileViewResult RemoteFilesDialog::OpenURL( OUString sURL )
if( eResult == eSuccess )
{
m_pPath->SetURL( sURL );
- setTreePath( sURL );
+ m_pTreeView->SetTreePath( sURL );
m_pFilter_lb->Enable( true );
m_pName_ed->Enable( true );
m_pContainer->Enable( true );
@@ -420,98 +520,6 @@ FileViewResult RemoteFilesDialog::OpenURL( OUString sURL )
return eResult;
}
-void RemoteFilesDialog::fillTreeEntry( SvTreeListEntry* pParent )
-{
- if( pParent && !m_pTreeView->IsExpanded( pParent ) )
- {
- // fill only empty entries - containing only dummy entry
- if( m_pTreeView->GetChildCount( pParent ) == 1 && pParent->GetUserData() )
- {
- ::std::vector< SortingData_Impl* > aContent;
-
- FileViewContentEnumerator* pContentEnumerator = new FileViewContentEnumerator(
- m_xEnv, aContent, m_aMutex, NULL );
-
- OUString* pURL = static_cast< OUString* >( pParent->GetUserData() );
-
- if( pURL )
- {
- FolderDescriptor aFolder( *pURL );
- Sequence< OUString > aBlackList;
-
- EnumerationResult eResult =
- pContentEnumerator->enumerateFolderContentSync( aFolder, aBlackList );
-
- if ( SUCCESS == eResult )
- {
- unsigned int nChilds = 0;
-
- for( unsigned int i = 0; i < aContent.size(); i++ )
- {
- if( aContent[i]->mbIsFolder )
- {
- SvTreeListEntry* pEntry = m_pTreeView->InsertEntry( aContent[i]->GetTitle(), pParent, true );
-
- OUString* sData = new OUString( aContent[i]->maTargetURL );
- pEntry->SetUserData( static_cast< void* >( sData ) );
-
- nChilds++;
- }
- }
- }
- }
- }
- }
-}
-
-void RemoteFilesDialog::setTreePath( OUString sUrl )
-{
- INetURLObject aURL( sUrl );
- aURL.setFinalSlash();
-
- OUString sPath = aURL.GetURLPath( INetURLObject::DECODE_WITH_CHARSET );
-
- SvTreeListEntry* pEntry = m_pTreeView->First();
- bool end = false;
-
- while( pEntry && !end )
- {
- if( pEntry->GetUserData() )
- {
- OUString sNodeUrl = *static_cast< OUString* >( pEntry->GetUserData() );
-
- INetURLObject aUrlObj( sNodeUrl );
- aUrlObj.setFinalSlash();
-
- sNodeUrl = aUrlObj.GetURLPath( INetURLObject::DECODE_WITH_CHARSET );
-
- if( sPath == sNodeUrl)
- {
- m_pTreeView->Select( pEntry );
-
- if( !m_pTreeView->IsExpanded( pEntry ) )
- m_pTreeView->Expand( pEntry );
-
- end = true;
- }
- else if( sPath.startsWith( sNodeUrl ) )
- {
- if( !m_pTreeView->IsExpanded( pEntry ) )
- m_pTreeView->Expand( pEntry );
-
- pEntry = m_pTreeView->FirstChild( pEntry );
- pEntry = m_pTreeView->NextSibling( pEntry );
- }
- else
- {
- pEntry = m_pTreeView->NextSibling( pEntry );
- }
- }
- else
- break;
- }
-}
-
IMPL_LINK_NOARG ( RemoteFilesDialog, AddServiceHdl )
{
ScopedVclPtrInstance< PlaceEditDialog > aDlg(this);
@@ -549,7 +557,7 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, SelectServiceHdl )
{
int nPos = GetSelectedServicePos();
- if(nPos > 0)
+ if( nPos > 0 )
{
OUString sURL = m_aServices[nPos]->GetUrl();
OUString sName = m_aServices[nPos]->GetName();
@@ -699,7 +707,7 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, SelectFilterHdl )
return 1;
}
-IMPL_LINK ( RemoteFilesDialog, TreeSelectHdl, SvTreeListBox *, pBox )
+IMPL_LINK ( RemoteFilesDialog, TreeSelectHdl, FolderTree *, pBox )
{
OUString* sURL = static_cast< OUString* >( pBox->GetHdlEntry()->GetUserData() );
@@ -709,13 +717,6 @@ IMPL_LINK ( RemoteFilesDialog, TreeSelectHdl, SvTreeListBox *, pBox )
return 1;
}
-IMPL_LINK ( RemoteFilesDialog, TreeExpandHdl, SvTreeListBox *, pBox )
-{
- fillTreeEntry( pBox->GetHdlEntry() );
-
- return 1;
-}
-
IMPL_LINK ( RemoteFilesDialog, SelectBreadcrumbHdl, Breadcrumb*, pPtr )
{
if( pPtr )
More information about the Libreoffice-commits
mailing list