diff options
author | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2012-05-03 16:55:22 +0200 |
---|---|---|
committer | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2012-05-04 12:19:26 +0200 |
commit | e00e06ce4306e8e9e0b76e0b641c001734186347 (patch) | |
tree | 6838914a0afad71832a328d8cb9218dff9bb38b1 /fpicker | |
parent | 09ff698215ebd82b8ec63d5f7f79b9dad7203a59 (diff) |
fpicker: make the place edition dialog working
Change-Id: If290ea4c1418162902e00bcc29c3afe69685ec5d
Diffstat (limited to 'fpicker')
-rw-r--r-- | fpicker/AllLangResTarget_fps_office.mk | 6 | ||||
-rw-r--r-- | fpicker/Library_fps_office.mk | 6 | ||||
-rw-r--r-- | fpicker/Module_fpicker.mk | 1 | ||||
-rw-r--r-- | fpicker/Package_inc.mk | 13 | ||||
-rw-r--r-- | fpicker/inc/fpicker/fpicker.hrc | 52 | ||||
-rw-r--r-- | fpicker/source/aqua/resourceprovider.mm | 3 | ||||
-rw-r--r-- | fpicker/source/office/OfficeFilePicker.hrc | 47 | ||||
-rw-r--r-- | fpicker/source/office/OfficeFilePicker.src | 2 | ||||
-rw-r--r-- | fpicker/source/office/PlaceEditDialog.cxx | 254 | ||||
-rw-r--r-- | fpicker/source/office/PlaceEditDialog.hrc | 58 | ||||
-rw-r--r-- | fpicker/source/office/PlaceEditDialog.hxx | 68 | ||||
-rw-r--r-- | fpicker/source/office/PlaceEditDialog.src | 183 | ||||
-rw-r--r-- | fpicker/source/office/PlacesListBox.cxx | 3 | ||||
-rw-r--r-- | fpicker/source/office/PlacesListBox.hxx | 1 | ||||
-rw-r--r-- | fpicker/source/office/ServerDetailsControls.cxx | 275 | ||||
-rw-r--r-- | fpicker/source/office/ServerDetailsControls.hxx | 123 | ||||
-rw-r--r-- | fpicker/source/office/iodlg.cxx | 13 | ||||
-rw-r--r-- | fpicker/source/office/iodlg.hrc | 17 | ||||
-rw-r--r-- | fpicker/source/office/iodlg.src | 110 | ||||
-rw-r--r-- | fpicker/source/win32/misc/resourceprovider.cxx | 2 |
20 files changed, 1028 insertions, 209 deletions
diff --git a/fpicker/AllLangResTarget_fps_office.mk b/fpicker/AllLangResTarget_fps_office.mk index 5d666bb474d7..88c1b767985d 100644 --- a/fpicker/AllLangResTarget_fps_office.mk +++ b/fpicker/AllLangResTarget_fps_office.mk @@ -40,9 +40,15 @@ $(eval $(call gb_SrsTarget_use_packages,fps_office/res,\ svtools_inc \ )) +$(eval $(call gb_SrsTarget_set_include,fps_office/res,\ + $$(INCLUDE) \ + -I$(SRCDIR)/fpicker/inc \ +)) + $(eval $(call gb_SrsTarget_add_files,fps_office/res,\ fpicker/source/office/OfficeFilePicker.src \ fpicker/source/office/iodlg.src \ + fpicker/source/office/PlaceEditDialog.src \ )) # vim: set noet sw=4 ts=4: diff --git a/fpicker/Library_fps_office.mk b/fpicker/Library_fps_office.mk index af5bc1b1265a..b9c94146b976 100644 --- a/fpicker/Library_fps_office.mk +++ b/fpicker/Library_fps_office.mk @@ -34,6 +34,11 @@ $(eval $(call gb_Library_use_api,fps_office,\ udkapi \ )) +$(eval $(call gb_Library_set_include,fps_office,\ + $$(INCLUDE) \ + -I$(SRCDIR)/fpicker/inc \ +)) + $(eval $(call gb_Library_use_libraries,fps_office,\ comphelper \ cppu \ @@ -62,6 +67,7 @@ $(eval $(call gb_Library_add_exception_objects,fps_office,\ fpicker/source/office/OfficeFolderPicker \ fpicker/source/office/PlaceEditDialog \ fpicker/source/office/PlacesListBox \ + fpicker/source/office/ServerDetailsControls \ )) # vim: set noet sw=4 ts=4: diff --git a/fpicker/Module_fpicker.mk b/fpicker/Module_fpicker.mk index 1edc7c9d17ef..30da957260bc 100644 --- a/fpicker/Module_fpicker.mk +++ b/fpicker/Module_fpicker.mk @@ -33,6 +33,7 @@ $(eval $(call gb_Module_add_targets,fpicker,\ AllLangResTarget_fps_office \ Library_fpicker \ Library_fps_office \ + Package_inc \ )) ifeq ($(GUIBASE),aqua) diff --git a/fpicker/Package_inc.mk b/fpicker/Package_inc.mk new file mode 100644 index 000000000000..81113e9e125d --- /dev/null +++ b/fpicker/Package_inc.mk @@ -0,0 +1,13 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# Copyright 2012 LibreOffice contributors. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Package_Package,fpicker_inc,$(SRCDIR)/fpicker/inc)) +$(eval $(call gb_Package_add_file,fpicker_inc,inc/fpicker/fpicker.hrc,fpicker/fpicker.hrc)) + +# vim: set noet sw=4 ts=4: diff --git a/fpicker/inc/fpicker/fpicker.hrc b/fpicker/inc/fpicker/fpicker.hrc new file mode 100644 index 000000000000..32d7eb9961e1 --- /dev/null +++ b/fpicker/inc/fpicker/fpicker.hrc @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * [ Copyright (C) 2012 SUSE <cbosdonnat@suse.com> (initial developer) ] + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ +#ifndef _FPICKER_HRC +#define _FPICKER_HRC + +#include <svl/solar.hrc> + +#define STR_SVT_FILEPICKER_START (RID_FPICKER_START+1) +#define STR_SVT_FILEPICKER_AUTO_EXTENSION (STR_SVT_FILEPICKER_START+ 0) +#define STR_SVT_FILEPICKER_PASSWORD (STR_SVT_FILEPICKER_START+ 1) +#define STR_SVT_FILEPICKER_FILTER_OPTIONS (STR_SVT_FILEPICKER_START+ 2) +#define STR_SVT_FILEPICKER_READONLY (STR_SVT_FILEPICKER_START+ 3) +#define STR_SVT_FILEPICKER_INSERT_AS_LINK (STR_SVT_FILEPICKER_START+ 4) +#define STR_SVT_FILEPICKER_SHOW_PREVIEW (STR_SVT_FILEPICKER_START+ 5) +#define STR_SVT_FILEPICKER_PLAY (STR_SVT_FILEPICKER_START+ 6) +#define STR_SVT_FILEPICKER_VERSION (STR_SVT_FILEPICKER_START+ 7) +#define STR_SVT_FILEPICKER_TEMPLATES (STR_SVT_FILEPICKER_START+ 8) +#define STR_SVT_FILEPICKER_IMAGE_TEMPLATE (STR_SVT_FILEPICKER_START+ 9) +#define STR_SVT_FILEPICKER_SELECTION (STR_SVT_FILEPICKER_START+10) +#define STR_SVT_FILEPICKER_FILTER_TITLE (STR_SVT_FILEPICKER_START+11) +#define STR_SVT_FOLDERPICKER_DEFAULT_TITLE (STR_SVT_FILEPICKER_START+12) +#define STR_SVT_FOLDERPICKER_DEFAULT_DESCRIPTION (STR_SVT_FILEPICKER_START+13) +#define STR_SVT_FILEPICKER_END (STR_SVT_FOLDERPICKER_DEFAULT_DESCRIPTION) + + +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/aqua/resourceprovider.mm b/fpicker/source/aqua/resourceprovider.mm index bc821ec4730a..92efaac1dfc5 100644 --- a/fpicker/source/aqua/resourceprovider.mm +++ b/fpicker/source/aqua/resourceprovider.mm @@ -38,8 +38,7 @@ #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp> #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> -#include <svtools/svtools.hrc> - +#include "fpicker.hrc" #include <svtools/filedlg2.hrc> #include "NSString_OOoAdditions.hxx" diff --git a/fpicker/source/office/OfficeFilePicker.hrc b/fpicker/source/office/OfficeFilePicker.hrc new file mode 100644 index 000000000000..adbd32898b16 --- /dev/null +++ b/fpicker/source/office/OfficeFilePicker.hrc @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * [ Copyright (C) 2012 SUSE <cbosdonnat@suse.com> (initial developer) ] + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ +#ifndef _FPICKER_OFFICEFILEPICKER_HRC +#define _FPICKER_OFFICEFILEPICKER_HRC + +#include <fpicker/fpicker.hrc> + +#define DLG_FPICKER_EXPLORERFILE (RID_FPICKER_START+14) +#define DLG_FPICKER_QUERYFOLDERNAME (RID_FPICKER_START+15) +#define DLG_FPICKER_PLACE_EDIT (RID_FPICKER_START+16) + +#define RID_FILEPICKER_IMAGES (RID_FPICKER_START+17) +#define STR_SVT_NEW_FOLDER (RID_FPICKER_START+19) +#define STR_SVT_ALREADYEXISTOVERWRITE (RID_FPICKER_START+20) +#define RID_FILEOPEN_INVALIDFOLDER (RID_FPICKER_START+23) +#define RID_FILEOPEN_NOTEXISTENTFILE (RID_FPICKER_START+24) +#define STR_SVT_NOREMOVABLEDEVICE (RID_FPICKER_START+25) +#define STR_SVT_ALLFORMATS (RID_FPICKER_START+26) + + +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/office/OfficeFilePicker.src b/fpicker/source/office/OfficeFilePicker.src index 8fbbc35a40e5..dfc3253faf13 100644 --- a/fpicker/source/office/OfficeFilePicker.src +++ b/fpicker/source/office/OfficeFilePicker.src @@ -25,7 +25,7 @@ * ************************************************************************/ -#include "svtools/svtools.hrc" +#include "OfficeFilePicker.hrc" String STR_SVT_FILEPICKER_AUTO_EXTENSION { diff --git a/fpicker/source/office/PlaceEditDialog.cxx b/fpicker/source/office/PlaceEditDialog.cxx index d7569b41f31c..1ecdb591a7ec 100644 --- a/fpicker/source/office/PlaceEditDialog.cxx +++ b/fpicker/source/office/PlaceEditDialog.cxx @@ -26,87 +26,183 @@ * instead of those above. */ -#include "iodlg.hrc" -#include <svtools/svtools.hrc> -#include <vcl/msgbox.hxx> - +#include "OfficeFilePicker.hrc" +#include "PlaceEditDialog.hrc" #include "fpsofficeResMgr.hxx" #include "PlacesListBox.hxx" #include "PlaceEditDialog.hxx" +#include "ServerDetailsControls.hxx" +#include <vcl/msgbox.hxx> + +using namespace boost; PlaceEditDialog::PlaceEditDialog( Window* pParent ) : - ModalDialog( pParent, SvtResId( DLG_SVT_ADDPLACE ) ), - m_aFTServerUrl( this, SvtResId( FT_ADDPLACE_SERVERURL ) ), + ModalDialog( pParent, SvtResId( DLG_FPICKER_PLACE_EDIT ) ), m_aFTServerName( this, SvtResId( FT_ADDPLACE_SERVERNAME ) ), m_aFTServerType( this, SvtResId( FT_ADDPLACE_SERVERTYPE ) ), - m_aFTServerLogin( this, SvtResId( FT_ADDPLACE_SERVERLOGIN ) ), - m_aFTServerPassword( this, SvtResId( FT_ADDPLACE_SERVERPASSWORD) ), - m_aEDServerUrl ( this, SvtResId( ED_ADDPLACE_SERVERURL ) ), m_aEDServerName ( this, SvtResId( ED_ADDPLACE_SERVERNAME ) ), - m_aEDServerType ( this, SvtResId( ED_ADDPLACE_SERVERTYPE ) ), - m_aEDServerLogin ( this, SvtResId( ED_ADDPLACE_SERVERLOGIN ) ), - m_aEDServerPassword ( this, SvtResId( ED_ADDPLACE_SERVERPASSWORD ) ), + m_aLBServerType ( this, SvtResId( LB_ADDPLACE_SERVERTYPE ) ), + m_pCurrentDetails( ), + m_aFTHost( this, SvtResId( FT_ADDPLACE_HOST ) ), + m_aEDHost( this, SvtResId( ED_ADDPLACE_HOST ) ), + m_aFTPort( this, SvtResId( FT_ADDPLACE_PORT ) ), + m_aEDPort( this, SvtResId( ED_ADDPLACE_PORT ) ), + m_aFTPath( this, SvtResId( FT_ADDPLACE_PATH ) ), + m_aEDPath( this, SvtResId( ED_ADDPLACE_PATH ) ), + m_aCBDavs( this, SvtResId( CB_ADDPLACE_DAVS ) ), + m_aEDSmbHost( this, SvtResId( ED_ADDPLACE_SMBHOST ) ), + m_aFTShare( this, SvtResId( FT_ADDPLACE_SHARE ) ), + m_aEDShare( this, SvtResId( ED_ADDPLACE_SHARE ) ), + m_aFTSmbPath( this, SvtResId( FT_ADDPLACE_SMBPATH ) ), + m_aEDSmbPath( this, SvtResId( ED_ADDPLACE_SMBPATH ) ), + m_aFTUsername( this, SvtResId( FT_ADDPLACE_USERNAME ) ), + m_aEDUsername( this, SvtResId( ED_ADDPLACE_USERNAME ) ), m_aBTOk( this, SvtResId( BT_ADDPLACE_OK ) ), m_aBTCancel ( this, SvtResId ( BT_ADDPLACE_CANCEL ) ), m_aBTDelete ( this, SvtResId (BT_ADDPLACE_DELETE ) ) { - // This constructor is called when user request a place creation, so - // delete button is hidden. m_aBTOk.SetClickHdl( LINK( this, PlaceEditDialog, OKHdl) ); m_aBTOk.Enable( sal_False ); m_aEDServerName.SetModifyHdl( LINK( this, PlaceEditDialog, EditHdl) ); - m_aEDServerUrl.SetModifyHdl( LINK( this, PlaceEditDialog, EditHdl) ); - m_aEDServerUrl.SetUrlFilter( &m_UrlFilter ); - Edit aDummyEdit ( this, SvtResId( ED_ADDPLACE_SERVERURL ) ); - m_aEDServerUrl.SetPosSizePixel( aDummyEdit.GetPosPixel(), aDummyEdit.GetSizePixel() ); - m_aEDServerUrl.Show(); + // This constructor is called when user request a place creation, so + // delete button is hidden. m_aBTDelete.Hide(); + + m_aLBServerType.SetSelectHdl( LINK( this, PlaceEditDialog, SelectTypeHdl ) ); + + InitDetails( ); } -PlaceEditDialog::PlaceEditDialog( Window* pParent, PlacePtr pPlace ) : - ModalDialog( pParent, SvtResId( DLG_SVT_ADDPLACE ) ), - m_aFTServerUrl( this, SvtResId( FT_ADDPLACE_SERVERURL ) ), +PlaceEditDialog::PlaceEditDialog( Window* pParent, const PlacePtr& pPlace ) : + ModalDialog( pParent, SvtResId( DLG_FPICKER_PLACE_EDIT ) ), m_aFTServerName( this, SvtResId( FT_ADDPLACE_SERVERNAME ) ), m_aFTServerType( this, SvtResId( FT_ADDPLACE_SERVERTYPE ) ), - m_aFTServerLogin( this, SvtResId( FT_ADDPLACE_SERVERLOGIN ) ), - m_aFTServerPassword( this, SvtResId( FT_ADDPLACE_SERVERPASSWORD) ), - m_aEDServerUrl ( this, SvtResId( ED_ADDPLACE_SERVERURL ) ), m_aEDServerName ( this, SvtResId( ED_ADDPLACE_SERVERNAME ) ), - m_aEDServerType ( this, SvtResId( ED_ADDPLACE_SERVERTYPE ) ), - m_aEDServerLogin ( this, SvtResId( ED_ADDPLACE_SERVERLOGIN ) ), - m_aEDServerPassword ( this, SvtResId( ED_ADDPLACE_SERVERPASSWORD ) ), + m_aLBServerType ( this, SvtResId( LB_ADDPLACE_SERVERTYPE ) ), + m_pCurrentDetails( ), + m_aFTHost( this, SvtResId( FT_ADDPLACE_HOST ) ), + m_aEDHost( this, SvtResId( ED_ADDPLACE_HOST ) ), + m_aFTPort( this, SvtResId( FT_ADDPLACE_PORT ) ), + m_aEDPort( this, SvtResId( ED_ADDPLACE_PORT ) ), + m_aFTPath( this, SvtResId( FT_ADDPLACE_PATH ) ), + m_aEDPath( this, SvtResId( ED_ADDPLACE_PATH ) ), + m_aCBDavs( this, SvtResId( CB_ADDPLACE_DAVS ) ), + m_aEDSmbHost( this, SvtResId( ED_ADDPLACE_SMBHOST ) ), + m_aFTShare( this, SvtResId( FT_ADDPLACE_SHARE ) ), + m_aEDShare( this, SvtResId( ED_ADDPLACE_SHARE ) ), + m_aFTSmbPath( this, SvtResId( FT_ADDPLACE_SMBPATH ) ), + m_aEDSmbPath( this, SvtResId( ED_ADDPLACE_SMBPATH ) ), + m_aFTUsername( this, SvtResId( FT_ADDPLACE_USERNAME ) ), + m_aEDUsername( this, SvtResId( ED_ADDPLACE_USERNAME ) ), m_aBTOk( this, SvtResId( BT_ADDPLACE_OK ) ), m_aBTCancel ( this, SvtResId ( BT_ADDPLACE_CANCEL ) ), m_aBTDelete ( this, SvtResId (BT_ADDPLACE_DELETE ) ) { - m_aBTOk.SetClickHdl( LINK( this, PlaceEditDialog, OKHdl) ); - m_aBTDelete.SetClickHdl ( LINK( this, PlaceEditDialog, DelHdl) ); + m_aBTOk.SetClickHdl( LINK( this, PlaceEditDialog, OKHdl) ); + m_aBTDelete.SetClickHdl ( LINK( this, PlaceEditDialog, DelHdl) ); - m_aEDServerName.SetModifyHdl( LINK( this, PlaceEditDialog, EditHdl) ); - m_aEDServerUrl.SetModifyHdl( LINK( this, PlaceEditDialog, EditHdl) ); + m_aEDServerName.SetModifyHdl( LINK( this, PlaceEditDialog, EditHdl) ); + m_aLBServerType.SetSelectHdl( LINK( this, PlaceEditDialog, SelectTypeHdl ) ); + + InitDetails( ); - m_aEDServerUrl.SetUrlFilter( &m_UrlFilter ); - Edit aDummyEdit ( this, SvtResId( ED_ADDPLACE_SERVERURL ) ); - m_aEDServerUrl.SetPosSizePixel( aDummyEdit.GetPosPixel(), aDummyEdit.GetSizePixel() ); - m_aEDServerUrl.Show(); + m_aEDServerName.SetText( pPlace->GetName() ); - m_aEDServerName.SetText( pPlace->GetName() ); - m_aEDServerUrl.SetText( pPlace->GetUrl() ); + // Fill the boxes with the URL parts + bool bSuccess = false; + for ( size_t i = 0 ; i < m_aDetailsContainers.size( ) && !bSuccess; ++i ) + { + INetURLObject& rUrl = pPlace->GetUrlObject( ); + bSuccess = m_aDetailsContainers[i]->setUrl( rUrl ); + if ( bSuccess ) + { + m_aLBServerType.SelectEntryPos( i ); + SelectTypeHdl( &m_aLBServerType ); + + // Fill the Username field + if ( rUrl.HasUserData( ) ) + m_aEDUsername.SetText( rUrl.GetUser( ) ); + } + } } PlaceEditDialog::~PlaceEditDialog() { } +rtl::OUString PlaceEditDialog::GetServerUrl() +{ + rtl::OUString sUrl; + if ( m_pCurrentDetails.get( ) ) + { + INetURLObject aUrl = m_pCurrentDetails->getUrl(); + aUrl.SetUser( rtl::OUString( m_aEDUsername.GetText( ) ).trim( ) ); + if ( !aUrl.HasError( ) ) + sUrl = aUrl.GetMainURL( INetURLObject::NO_DECODE ); + } + + return sUrl; +} + PlacePtr PlaceEditDialog::GetPlace() { - PlacePtr newPlace( new Place( m_aEDServerName.GetText(), m_aEDServerUrl.GetURL(), true) ); + PlacePtr newPlace( new Place( m_aEDServerName.GetText(), GetServerUrl(), true ) ); return newPlace; } +void PlaceEditDialog::InitDetails( ) +{ + // Create WebDAV / FTP / SSH details control + shared_ptr< DetailsContainer > pDavDetails( new DavDetailsContainer( ) ); + pDavDetails->addControl( FT_ADDPLACE_HOST, &m_aFTHost ); + pDavDetails->addControl( ED_ADDPLACE_HOST, &m_aEDHost ); + pDavDetails->addControl( FT_ADDPLACE_PORT, &m_aFTPort ); + pDavDetails->addControl( ED_ADDPLACE_PORT, &m_aEDPort ); + pDavDetails->addControl( FT_ADDPLACE_PATH, &m_aFTPath ); + pDavDetails->addControl( ED_ADDPLACE_PATH, &m_aEDPath ); + pDavDetails->addControl( CB_ADDPLACE_DAVS, &m_aCBDavs ); + pDavDetails->setChangeHdl( LINK( this, PlaceEditDialog, EditHdl ) ); + m_aDetailsContainers.push_back( pDavDetails ); + + shared_ptr< DetailsContainer > pFtpDetails( new HostDetailsContainer( 21, "ftp" ) ); + pFtpDetails->addControl( FT_ADDPLACE_HOST, &m_aFTHost ); + pFtpDetails->addControl( ED_ADDPLACE_HOST, &m_aEDHost ); + pFtpDetails->addControl( FT_ADDPLACE_PORT, &m_aFTPort ); + pFtpDetails->addControl( ED_ADDPLACE_PORT, &m_aEDPort ); + pFtpDetails->addControl( FT_ADDPLACE_PATH, &m_aFTPath ); + pFtpDetails->addControl( ED_ADDPLACE_PATH, &m_aEDPath ); + pFtpDetails->setChangeHdl( LINK( this, PlaceEditDialog, EditHdl ) ); + m_aDetailsContainers.push_back( pFtpDetails ); + + shared_ptr< DetailsContainer > pSshDetails( new HostDetailsContainer( 22, "ssh" ) ); + pSshDetails->addControl( FT_ADDPLACE_HOST, &m_aFTHost ); + pSshDetails->addControl( ED_ADDPLACE_HOST, &m_aEDHost ); + pSshDetails->addControl( FT_ADDPLACE_PORT, &m_aFTPort ); + pSshDetails->addControl( ED_ADDPLACE_PORT, &m_aEDPort ); + pSshDetails->addControl( FT_ADDPLACE_PATH, &m_aFTPath ); + pSshDetails->addControl( ED_ADDPLACE_PATH, &m_aEDPath ); + pSshDetails->setChangeHdl( LINK( this, PlaceEditDialog, EditHdl ) ); + m_aDetailsContainers.push_back( pSshDetails ); + + // Create Windows Share control + shared_ptr< DetailsContainer > pSmbDetails( new SmbDetailsContainer( ) ); + pSmbDetails->addControl( FT_ADDPLACE_HOST, &m_aFTHost ); + pSmbDetails->addControl( ED_ADDPLACE_SMBHOST, &m_aEDSmbHost ); + pSmbDetails->addControl( FT_ADDPLACE_SHARE, &m_aFTShare ); + pSmbDetails->addControl( ED_ADDPLACE_SHARE, &m_aEDShare ); + pSmbDetails->addControl( FT_ADDPLACE_SMBPATH, &m_aFTSmbPath ); + pSmbDetails->addControl( ED_ADDPLACE_SMBPATH, &m_aEDSmbPath ); + pSmbDetails->setChangeHdl( LINK( this, PlaceEditDialog, EditHdl ) ); + m_aDetailsContainers.push_back( pSmbDetails ); + + // Set default to first value + m_aLBServerType.SelectEntryPos( 0 ); + SelectTypeHdl( &m_aLBServerType ); +} + IMPL_LINK ( PlaceEditDialog, OKHdl, Button *, EMPTYARG ) { EndDialog( RET_OK ); @@ -120,24 +216,74 @@ IMPL_LINK ( PlaceEditDialog, DelHdl, Button *, EMPTYARG ) return 1; } -IMPL_LINK ( PlaceEditDialog, EditHdl, Edit *, EMPTYARG ) +IMPL_LINK ( PlaceEditDialog, EditHdl, void *, EMPTYARG ) { - String anUrl = m_aEDServerUrl.GetText(); - anUrl.EraseLeadingChars().EraseTrailingChars(); - String aName = m_aEDServerName.GetText(); - aName.EraseLeadingChars().EraseTrailingChars(); - if ( ( anUrl.Len() ) && ( aName.Len() ) ) - { - if ( !m_aBTOk.IsEnabled() ) - m_aBTOk.Enable( sal_True ); - } - else - { - if ( m_aBTOk.IsEnabled() ) - m_aBTOk.Enable( sal_False ); - } + rtl::OUString sUrl = GetServerUrl( ); + rtl::OUString sName = rtl::OUString( m_aEDServerName.GetText() ).trim( ); + m_aBTOk.Enable( !sName.isEmpty( ) && !sUrl.isEmpty( ) ); return 1; } +IMPL_LINK( PlaceEditDialog, SelectTypeHdl, void*, EMPTYARG ) +{ + // Compute the vertical space between two rows + long nRowDelta = m_aLBServerType.GetPosPixel().getY() - m_aEDServerName.GetPosPixel().getY(); + long nRowSpace = nRowDelta - m_aEDServerName.GetSizePixel().getHeight(); + + long nOldHeight = 0; + if ( m_pCurrentDetails.get( ) ) + { + m_pCurrentDetails->show( false ); + Rectangle aOldBounds = m_pCurrentDetails->getBounds( ); + if ( !aOldBounds.IsEmpty() ) + nOldHeight = aOldBounds.getHeight(); + } + + sal_uInt16 nPos = m_aLBServerType.GetSelectEntryPos( ); + m_pCurrentDetails = m_aDetailsContainers[nPos]; + + m_pCurrentDetails->show( true ); + Rectangle aNewBounds = m_pCurrentDetails->getBounds(); + + long nNewHeight = 0; + if ( !aNewBounds.IsEmpty() ) + { + nNewHeight = aNewBounds.getHeight(); + + // Add row space if old height was 0 + if ( nOldHeight == 0 ) + nNewHeight += nRowSpace; + } + + // If the new height is 0, but not the old one, then remove the doubled row space + if ( nNewHeight == 0 && nOldHeight > 0 ) + nNewHeight -= nRowSpace; + + long nHeightDelta = nNewHeight - nOldHeight; + Control* pToMove[] = + { + &m_aFTUsername, + &m_aEDUsername, + &m_aBTOk, + &m_aBTCancel, + &m_aBTDelete + }; + + Control** pCurrent = pToMove; + for ( sal_Int32 i = 0; i < sal_Int32(SAL_N_ELEMENTS( pToMove )); ++i, ++pCurrent ) + { + Point aPos = ( *pCurrent )->GetPosPixel( ); + aPos.setY( aPos.getY( ) + nHeightDelta ); + ( *pCurrent )->SetPosPixel( aPos ); + } + + // Resize the dialog too + Size aDlgSize = GetSizePixel( ); + aDlgSize.setHeight( aDlgSize.getHeight( ) + nHeightDelta ); + SetSizePixel( aDlgSize ); + + + return 0; +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/office/PlaceEditDialog.hrc b/fpicker/source/office/PlaceEditDialog.hrc new file mode 100644 index 000000000000..b22f3f942995 --- /dev/null +++ b/fpicker/source/office/PlaceEditDialog.hrc @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * [ Copyright (C) 2012 SUSE <cbosdonnat@suse.com> (initial developer) ] + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +#ifndef _FPICKER_PLACEEDITDLG_HRC +#define _FPICKER_PLACEEDITDLG_HRC + +#include <svl/solar.hrc> + +// DLG_FPICKER_PLACE_EDIT ------------------------------ +#define FT_ADDPLACE_SERVERNAME 10 +#define FT_ADDPLACE_SERVERTYPE 11 +#define ED_ADDPLACE_SERVERNAME 12 +#define LB_ADDPLACE_SERVERTYPE 13 +#define BT_ADDPLACE_OK 14 +#define BT_ADDPLACE_CANCEL 15 +#define BT_ADDPLACE_DELETE 16 +#define FT_ADDPLACE_HOST 17 +#define ED_ADDPLACE_HOST 18 +#define FT_ADDPLACE_PORT 19 +#define ED_ADDPLACE_PORT 20 +#define FT_ADDPLACE_PATH 21 +#define ED_ADDPLACE_PATH 22 +#define CB_ADDPLACE_DAVS 23 +#define FT_ADDPLACE_USERNAME 24 +#define ED_ADDPLACE_USERNAME 25 +#define ED_ADDPLACE_SMBHOST 26 +#define FT_ADDPLACE_SHARE 27 +#define ED_ADDPLACE_SHARE 28 +#define FT_ADDPLACE_SMBPATH 29 +#define ED_ADDPLACE_SMBPATH 30 + +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/office/PlaceEditDialog.hxx b/fpicker/source/office/PlaceEditDialog.hxx index 4c6bb2879ea3..68ee425ea747 100644 --- a/fpicker/source/office/PlaceEditDialog.hxx +++ b/fpicker/source/office/PlaceEditDialog.hxx @@ -25,63 +25,89 @@ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable * instead of those above. */ -#ifndef _SVTPLACEDIALOG_HXX -#define _SVTPLACEDIALOG_HXX +#ifndef _PLACEEDITDIALOG_HXX +#define _PLACEEDITDIALOG_HXX +#include "fpsofficeResMgr.hxx" #include "PlacesListBox.hxx" +#include "ServerDetailsControls.hxx" #include <vcl/button.hxx> #include <vcl/dialog.hxx> -#include <vcl/fixed.hxx> #include <vcl/edit.hxx> +#include <vcl/fixed.hxx> +#include <vcl/lstbox.hxx> #include <svtools/inettbc.hxx> -#include <svl/restrictedpaths.hxx> +#include <boost/shared_ptr.hpp> +#include <vector> class Place; class PlaceEditDialog : public ModalDialog { private : - FixedText m_aFTServerUrl; FixedText m_aFTServerName; FixedText m_aFTServerType; - FixedText m_aFTServerLogin; - FixedText m_aFTServerPassword; - - SvtURLBox m_aEDServerUrl; Edit m_aEDServerName; - Edit m_aEDServerType; - Edit m_aEDServerLogin; - Edit m_aEDServerPassword; - + ListBox m_aLBServerType; + boost::shared_ptr< DetailsContainer > m_pCurrentDetails; + + FixedText m_aFTHost; + Edit m_aEDHost; + FixedText m_aFTPort; + NumericField m_aEDPort; + FixedText m_aFTPath; + Edit m_aEDPath; + CheckBox m_aCBDavs; + + Edit m_aEDSmbHost; + FixedText m_aFTShare; + Edit m_aEDShare; + FixedText m_aFTSmbPath; + Edit m_aEDSmbPath; + + FixedText m_aFTUsername; + Edit m_aEDUsername; OKButton m_aBTOk; CancelButton m_aBTCancel; PushButton m_aBTDelete; - ::svt::RestrictedPaths m_UrlFilter; - - DECL_LINK( OKHdl, Button *); - DECL_LINK ( DelHdl, Button *); + /** Vector holding the details UI control for each server type. - DECL_LINK ( EditHdl, Edit *); + The elements in this vector need to match the order in the type listbox, e.g. + the m_aDetailsContainer[0] will be shown for the type corresponding to entry 0 + in the listbox. + */ + std::vector< boost::shared_ptr< DetailsContainer > > m_aDetailsContainers; public : PlaceEditDialog( Window* pParent); - PlaceEditDialog( Window* pParent, PlacePtr pPlace ); + PlaceEditDialog( Window* pParent, const PlacePtr& pPlace ); ~PlaceEditDialog(); // Returns a place instance with given informations PlacePtr GetPlace(); rtl::OUString GetServerName() { return m_aEDServerName.GetText(); } - rtl::OUString GetServerUrl() { return m_aEDServerUrl.GetText(); } + rtl::OUString GetServerUrl(); + + ResId GetResId( sal_uInt16 nId ) { return SvtResId( nId ); }; + +private: + + void InitDetails( ); + + DECL_LINK ( OKHdl, Button * ); + DECL_LINK ( DelHdl, Button * ); + DECL_LINK ( EditHdl, void * ); + DECL_LINK ( SelectTypeHdl, void * ); }; -#endif //_SVTPLACEDIALOG_HXX +#endif //_PLACEEDITDIALOG_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/office/PlaceEditDialog.src b/fpicker/source/office/PlaceEditDialog.src new file mode 100644 index 000000000000..15c614d1a0b2 --- /dev/null +++ b/fpicker/source/office/PlaceEditDialog.src @@ -0,0 +1,183 @@ + +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * [ Copyright (C) 2012 SUSE <cbosdonnat@suse.com> (initial developer) ] + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +#include "PlaceEditDialog.hrc" +#include "OfficeFilePicker.hrc" + +// Place Edit Dialog -------------------------------------------------------------- + +ModalDialog DLG_FPICKER_PLACE_EDIT +{ + OutputSize = TRUE ; + Border = TRUE ; + SVLook = TRUE ; + Moveable = TRUE ; + Closeable = TRUE ; + Sizeable = TRUE; + Size = MAP_APPFONT ( 200 , 76 ) ; + FixedText FT_ADDPLACE_SERVERNAME + { + Pos = MAP_APPFONT ( 12 , 14 ) ; + Size = MAP_APPFONT ( 40 , 10 ) ; + Text [ en-US ] = "Name" ; + }; + FixedText FT_ADDPLACE_SERVERTYPE + { + Pos = MAP_APPFONT ( 12 , 30 ) ; + Size = MAP_APPFONT ( 40 , 10 ) ; + Text [ en-US ] = "Type" ; + }; + FixedText FT_ADDPLACE_HOST + { + Pos = MAP_APPFONT ( 12 , 46 ) ; + Size = MAP_APPFONT ( 40 , 10 ) ; + Text [ en-US ] = "Host" ; + }; + Edit ED_ADDPLACE_HOST + { + Pos = MAP_APPFONT ( 55, 44 ) ; + Size = MAP_APPFONT ( 71 , 12 ) ; + Border = TRUE ; + }; + FixedText FT_ADDPLACE_PORT + { + Pos = MAP_APPFONT ( 129 , 46 ) ; + Size = MAP_APPFONT ( 20 , 10 ) ; + Text [ en-US ] = "Port" ; + }; + NumericField ED_ADDPLACE_PORT + { + Pos = MAP_APPFONT ( 152, 44 ) ; + Size = MAP_APPFONT ( 40 , 12 ) ; + Border = TRUE ; + Spin = TRUE ; + Minimum = 0 ; + Maximum = 65535 ; + }; + FixedText FT_ADDPLACE_PATH + { + Pos = MAP_APPFONT ( 12 , 62 ) ; + Size = MAP_APPFONT ( 40 , 10 ) ; + Text [ en-US ] = "Path" ; + }; + Edit ED_ADDPLACE_PATH + { + Pos = MAP_APPFONT ( 55, 60 ) ; + Size = MAP_APPFONT ( 137 , 12 ) ; + Border = TRUE ; + }; + CheckBox CB_ADDPLACE_DAVS + { + Pos = MAP_APPFONT ( 55, 74 ) ; + Size = MAP_APPFONT ( 137 , 10 ) ; + Text[ en-US ] = "Secured WebDAV (HTTPS)" ; + }; + Edit ED_ADDPLACE_SMBHOST + { + Pos = MAP_APPFONT ( 55, 44 ) ; + Size = MAP_APPFONT ( 137 , 12 ) ; + Border = TRUE ; + }; + FixedText FT_ADDPLACE_SHARE + { + Pos = MAP_APPFONT ( 12 , 62 ) ; + Size = MAP_APPFONT ( 40 , 10 ) ; + Text [ en-US ] = "Share" ; + }; + Edit ED_ADDPLACE_SHARE + { + Pos = MAP_APPFONT ( 55, 60 ) ; + Size = MAP_APPFONT ( 137 , 12 ) ; + Border = TRUE ; + }; + FixedText FT_ADDPLACE_SMBPATH + { + Pos = MAP_APPFONT ( 12 , 78 ) ; + Size = MAP_APPFONT ( 40 , 10 ) ; + Text [ en-US ] = "Path" ; + }; + Edit ED_ADDPLACE_SMBPATH + { + Pos = MAP_APPFONT ( 55, 76 ) ; + Size = MAP_APPFONT ( 137 , 12 ) ; + Border = TRUE ; + }; + Edit ED_ADDPLACE_SERVERNAME + { + Pos = MAP_APPFONT ( 55, 12 ) ; + Size = MAP_APPFONT ( 137 , 12 ) ; + Border = TRUE ; + }; + ListBox LB_ADDPLACE_SERVERTYPE + { + Pos = MAP_APPFONT ( 55, 28 ) ; + Size = MAP_APPFONT ( 137 , 75 ) ; + Border = TRUE ; + DropDown = TRUE; + StringList [ en-US ] = + { + < "WebDAV" ; >; + < "FTP" ; >; + < "SSH" ; >; + < "Windows Share" ; >; + }; + }; + FixedText FT_ADDPLACE_USERNAME + { + Pos = MAP_APPFONT ( 12 , 46 ) ; + Size = MAP_APPFONT ( 40 , 10 ) ; + Text [ en-US ] = "Login" ; + }; + Edit ED_ADDPLACE_USERNAME + { + Pos = MAP_APPFONT ( 55, 44 ) ; + Size = MAP_APPFONT ( 137 , 12 ) ; + Border = TRUE ; + }; + OKButton BT_ADDPLACE_OK + { + Pos = MAP_APPFONT ( 80 , 60 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + DefButton = TRUE ; + }; + CancelButton BT_ADDPLACE_CANCEL + { + Pos = MAP_APPFONT ( 140, 60 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + }; + PushButton BT_ADDPLACE_DELETE + { + Pos = MAP_APPFONT ( 10 , 60 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + Text [ en-US ] = "Delete" ; + }; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/office/PlacesListBox.cxx b/fpicker/source/office/PlacesListBox.cxx index 708b50009ebc..e6595c60bbb3 100644 --- a/fpicker/source/office/PlacesListBox.cxx +++ b/fpicker/source/office/PlacesListBox.cxx @@ -165,13 +165,14 @@ IMPL_LINK ( PlacesListBox, DoubleClick, void*, EMPTYARG ) PlacePtr pPlace = maPlaces[nSelected]; if ( pPlace->IsEditable() == true ) { - PlaceEditDialog aDlg(mpDlg,pPlace); + PlaceEditDialog aDlg( mpDlg, pPlace ); short aRetCode = aDlg.Execute(); switch(aRetCode) { case RET_OK : { pPlace->SetName ( aDlg.GetServerName() ); pPlace->SetUrl( aDlg.GetServerUrl() ); + mbUpdated = true; break; } case RET_NO : diff --git a/fpicker/source/office/PlacesListBox.hxx b/fpicker/source/office/PlacesListBox.hxx index 16ba19ae6070..30e4cc76f9db 100644 --- a/fpicker/source/office/PlacesListBox.hxx +++ b/fpicker/source/office/PlacesListBox.hxx @@ -62,6 +62,7 @@ class Place rtl::OUString& GetName( ) { return msName; } rtl::OUString GetUrl( ) { return maUrl.GetMainURL( INetURLObject::NO_DECODE ); } + INetURLObject& GetUrlObject( ) { return maUrl; } sal_Bool IsLocal( ) { return maUrl.GetProtocol() == INET_PROT_FILE; }; sal_Bool& IsEditable( ) { return mbEditable; } }; diff --git a/fpicker/source/office/ServerDetailsControls.cxx b/fpicker/source/office/ServerDetailsControls.cxx new file mode 100644 index 000000000000..ca00481d3595 --- /dev/null +++ b/fpicker/source/office/ServerDetailsControls.cxx @@ -0,0 +1,275 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * [ Copyright (C) 2012 SUSE <cbosdonnat@suse.com> (initial developer) ] + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +#include "PlaceEditDialog.hrc" + +#include "fpsofficeResMgr.hxx" +#include "PlaceEditDialog.hxx" +#include "ServerDetailsControls.hxx" + +using namespace std; + +DetailsContainer::DetailsContainer( ) : + m_aControls( ), + m_bShown( false ) +{ +} + +DetailsContainer::~DetailsContainer( ) +{ + m_aControls.clear( ); +} + +void DetailsContainer::addControl( sal_uInt16 nId, Control* pControl ) +{ + m_aControls.insert( pair< sal_uInt16, Control* >( nId, pControl ) ); + pControl->Show( m_bShown ); + + if ( pControl->GetType( ) == WINDOW_EDIT ) + static_cast< Edit* >( pControl )->SetModifyHdl( LINK( this, DetailsContainer, ValueChangeHdl ) ); + else if ( pControl->GetType( ) == WINDOW_NUMERICFIELD ) + static_cast< NumericField* >( pControl )->SetModifyHdl( LINK( this, DetailsContainer, ValueChangeHdl ) ); + else if ( pControl->GetType( ) == WINDOW_CHECKBOX ) + static_cast< CheckBox* >( pControl )->SetToggleHdl( LINK( this, DetailsContainer, ValueChangeHdl ) ); +} + +Control* DetailsContainer::getControl( sal_uInt16 nId ) +{ + Control* pControl = NULL; + map< sal_uInt16, Control* >::iterator it = m_aControls.find( nId ); + if ( it != m_aControls.end( ) ) + pControl = it->second; + return pControl; +} + +Rectangle DetailsContainer::getBounds( ) +{ + Rectangle aBounds; + for ( map< sal_uInt16, Control* >::iterator it = m_aControls.begin( ); it != m_aControls.end( ); ++it ) + { + Rectangle aControlBounds( it->second->GetPosPixel(), it->second->GetSizePixel() ); + aBounds = aBounds.GetUnion( aControlBounds ); + } + + return aBounds; +} + +void DetailsContainer::show( bool bShow ) +{ + m_bShown = bShow; + for ( map< sal_uInt16, Control* >::iterator it = m_aControls.begin( ); it != m_aControls.end( ); ++it ) + { + it->second->Show( m_bShown ); + } +} + +INetURLObject DetailsContainer::getUrl( ) +{ + // Don't use that class directly: make it smarter by subclassing it. + return INetURLObject( ); +} + +bool DetailsContainer::setUrl( const INetURLObject& ) +{ + // That class doesn't contain any logic... it defers the dirty work + // to the sub classes. + return false; +} + +void DetailsContainer::notifyChange( ) +{ + m_aChangeHdl.Call( this ); +} + +IMPL_LINK( DetailsContainer, ValueChangeHdl, void *, EMPTYARG ) +{ + notifyChange( ); + return 0; +} + +HostDetailsContainer::HostDetailsContainer( sal_uInt16 nPort, rtl::OUString sScheme ) : + DetailsContainer( ), + m_nDefaultPort( nPort ), + m_sScheme( sScheme ) +{ +} + +void HostDetailsContainer::show( bool bShow ) +{ + DetailsContainer::show( bShow ); + if ( bShow ) + static_cast< NumericField* >( getControl( ED_ADDPLACE_PORT ) )->SetValue( m_nDefaultPort ); +} + +INetURLObject HostDetailsContainer::getUrl( ) +{ + rtl::OUString sHost = rtl::OUString( static_cast< Edit* >( getControl( ED_ADDPLACE_HOST ) )->GetText() ).trim( ); + sal_Int64 nPort = static_cast< NumericField* >( getControl( ED_ADDPLACE_PORT ) )->GetValue(); + rtl::OUString sPath = rtl::OUString( static_cast< Edit* >( getControl( ED_ADDPLACE_PATH ) )->GetText() ).trim( ); + + rtl::OUString sUrl; + if ( !sHost.isEmpty( ) ) + { + sUrl = m_sScheme + "://" + sHost; + if ( nPort != m_nDefaultPort ) + sUrl += ":" + rtl::OUString::valueOf( nPort ); + if ( !sPath.isEmpty( ) ) + if ( sPath.indexOf( "/" ) != 0 ) + sUrl += "/"; + sUrl += sPath; + } + + return INetURLObject( sUrl ); +} + +bool HostDetailsContainer::setUrl( const INetURLObject& rUrl ) +{ + bool bSuccess = false; + + bSuccess = verifyScheme( INetURLObject::GetScheme( rUrl.GetProtocol( ) ) ); + + if ( bSuccess ) + { + static_cast< Edit* >( getControl( ED_ADDPLACE_HOST ) )->SetText( rUrl.GetHost( ) ); + static_cast< NumericField* >( getControl( ED_ADDPLACE_PORT ) )->SetValue( rUrl.GetPort( ) ); + static_cast< Edit* >( getControl( ED_ADDPLACE_PATH ) )->SetText( rUrl.GetURLPath() ); + } + + return bSuccess; +} + +bool HostDetailsContainer::verifyScheme( const rtl::OUString& sScheme ) +{ + return sScheme.equals( m_sScheme + "://" ); +} + +DavDetailsContainer::DavDetailsContainer( ) : + HostDetailsContainer( 80, "http" ) +{ +} + +void DavDetailsContainer::addControl( sal_uInt16 nId, Control* pControl ) +{ + DetailsContainer::addControl( nId, pControl ); + + // Add listener on CB_ADDPLACE_DAVS + if ( nId == CB_ADDPLACE_DAVS ) + static_cast< CheckBox* >( pControl )->SetToggleHdl( LINK( this, DavDetailsContainer, ToggledDavsHdl ) ); +} + +void DavDetailsContainer::show( bool bShow ) +{ + HostDetailsContainer::show( bShow ); + if ( bShow ) + static_cast< CheckBox* >( getControl( CB_ADDPLACE_DAVS ) )->Check( false ); +} + +bool DavDetailsContainer::verifyScheme( const rtl::OUString& rScheme ) +{ + bool bValid = false; + if ( rScheme.equals( "http://" ) ) + { + bValid = true; + static_cast< CheckBox* >( getControl( CB_ADDPLACE_DAVS ) )->Check( false ); + } + else if ( rScheme.equals( "https://" ) ) + { + bValid = true; + static_cast< CheckBox* >( getControl( CB_ADDPLACE_DAVS ) )->Check( true ); + } + return bValid; +} + +IMPL_LINK( DavDetailsContainer, ToggledDavsHdl, CheckBox*, pCheckBox ) +{ + // Change default port if needed + sal_Bool bCheckedDavs = pCheckBox->IsChecked(); + NumericField* pPortField = static_cast< NumericField* >( getControl( ED_ADDPLACE_PORT ) ); + if ( pPortField->GetValue() == 80 && bCheckedDavs == sal_True) + pPortField->SetValue( 443 ); + else if ( pPortField->GetValue() == 443 && bCheckedDavs == sal_False ) + pPortField->SetValue( 80 ); + + rtl::OUString sScheme( "http" ); + if ( bCheckedDavs ) + sScheme = "https"; + setScheme( sScheme ); + + notifyChange( ); + + return 0; +} + +INetURLObject SmbDetailsContainer::getUrl( ) +{ + rtl::OUString sHost = rtl::OUString( static_cast< Edit* >( getControl( ED_ADDPLACE_SMBHOST ) )->GetText() ).trim( ); + rtl::OUString sShare = rtl::OUString( static_cast< Edit* >( getControl( ED_ADDPLACE_SHARE ) )->GetText() ).trim( ); + rtl::OUString sPath = rtl::OUString( static_cast< Edit* >( getControl( ED_ADDPLACE_SMBPATH ) )->GetText() ).trim( ); + + rtl::OUString sUrl; + if ( !sHost.isEmpty( ) ) + { + INetURLObject aUrl; + sUrl = "smb://" + sHost + "/"; + if ( !sShare.isEmpty( ) ) + sUrl += sShare; + if ( !sPath.isEmpty( ) ) + if ( sPath.indexOf( "/" ) != 0 ) + sUrl += "/"; + sUrl += sPath; + } + + return INetURLObject( sUrl ); +} + +bool SmbDetailsContainer::setUrl( const INetURLObject& rUrl ) +{ + bool bSuccess = rUrl.GetProtocol() == INET_PROT_SMB; + + if ( bSuccess ) + { + rtl::OUString sShare = rUrl.getName( 0 ); + rtl::OUString sFullPath = rUrl.GetURLPath( ); + rtl::OUString sPath; + if ( sFullPath.getLength( ) > sShare.getLength( ) ) + { + sal_Int32 nPos = sShare.getLength( ); + if ( nPos != 0 ) + ++nPos; + sPath = sFullPath.copy( nPos ); + } + + static_cast< Edit* >( getControl( ED_ADDPLACE_SMBHOST ) )->SetText( rUrl.GetHost( ) ); + static_cast< Edit* >( getControl( ED_ADDPLACE_SHARE ) )->SetText( sShare ); + static_cast< Edit* >( getControl( ED_ADDPLACE_SMBPATH ) )->SetText( sPath ); + } + + return bSuccess; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/office/ServerDetailsControls.hxx b/fpicker/source/office/ServerDetailsControls.hxx new file mode 100644 index 000000000000..aafcc0c49ea0 --- /dev/null +++ b/fpicker/source/office/ServerDetailsControls.hxx @@ -0,0 +1,123 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * [ Copyright (C) 2012 SUSE <cbosdonnat@suse.com> (initial developer) ] + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ +#ifndef _SERVERDETAILSCONTROLS_HXX +#define _SERVERDETAILSCONTROLS_HXX + +#include <tools/urlobj.hxx> +#include <vcl/ctrl.hxx> +#include <vcl/edit.hxx> +#include <vcl/field.hxx> +#include <vcl/fixed.hxx> + +class PlaceEditDialog; + +class DetailsContainer +{ + private: + std::map< sal_uInt16, Control* > m_aControls; + bool m_bShown; + Link m_aChangeHdl; + + public: + DetailsContainer( ); + virtual ~DetailsContainer( ); + + virtual void addControl( sal_uInt16 nId, Control* pControl ); + Control* getControl( sal_uInt16 nId ); + Rectangle getBounds( ); + + void setChangeHdl( const Link& rLink ) { m_aChangeHdl = rLink; } + + virtual void show( bool bShow = true ); + virtual INetURLObject getUrl( ); + + /** Try to split the URL in the controls of that container. + + \param sUrl the URL to split + \return true if the split worked, false otherwise. + */ + virtual bool setUrl( const INetURLObject& rUrl ); + + protected: + void notifyChange( ); + + private: + DECL_LINK ( ValueChangeHdl, void * ); +}; + +class HostDetailsContainer : public DetailsContainer +{ + private: + sal_uInt16 m_nDefaultPort; + rtl::OUString m_sScheme; + + public: + HostDetailsContainer( sal_uInt16 nPort, rtl::OUString sScheme ); + virtual ~HostDetailsContainer( ) { }; + + virtual void show( bool bShow = true ); + virtual INetURLObject getUrl( ); + virtual bool setUrl( const INetURLObject& rUrl ); + + protected: + void setScheme( rtl::OUString sScheme ) { m_sScheme = sScheme; } + + /** Verifies that the schement split from the URL can be handled by + the container and set the proper controls accordingly if needed. + */ + virtual bool verifyScheme( const rtl::OUString& rScheme ); +}; + +class DavDetailsContainer : public HostDetailsContainer +{ + public: + DavDetailsContainer( ); + ~DavDetailsContainer( ) { }; + + virtual void addControl( sal_uInt16 nId, Control* pControl ); + virtual void show( bool bShow = true ); + + protected: + virtual bool verifyScheme( const rtl::OUString& rScheme ); + + private: + DECL_LINK ( ToggledDavsHdl, CheckBox * pCheckBox ); +}; + +class SmbDetailsContainer : public DetailsContainer +{ + public: + SmbDetailsContainer( ) : DetailsContainer( ) { }; + ~SmbDetailsContainer( ) { }; + + virtual INetURLObject getUrl( ); + virtual bool setUrl( const INetURLObject& rUrl ); +}; + +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/office/iodlg.cxx b/fpicker/source/office/iodlg.cxx index 64797c5c69b9..4de4a0c0bfb8 100644 --- a/fpicker/source/office/iodlg.cxx +++ b/fpicker/source/office/iodlg.cxx @@ -52,8 +52,9 @@ #include <toolkit/helper/vclunohelper.hxx> #include <unotools/localfilehelper.hxx> -#include "svtools/svtools.hrc" #include "svtools/helpid.hrc" +#include <svtools/svtools.hrc> +#include "OfficeFilePicker.hrc" #include "iodlg.hrc" #include "asyncfilepicker.hxx" #include "iodlgimp.hxx" @@ -398,7 +399,7 @@ SvtFileDialog::SvtFileDialog WinBits nBits, WinBits nExtraBits ) : - ModalDialog( _pParent, SvtResId( DLG_SVT_EXPLORERFILE ) ) + ModalDialog( _pParent, SvtResId( DLG_FPICKER_EXPLORERFILE ) ) ,_pUserControls( NULL ) ,_pCbReadOnly( NULL ) @@ -423,7 +424,7 @@ SvtFileDialog::SvtFileDialog //***************************************************************************** SvtFileDialog::SvtFileDialog ( Window* _pParent, WinBits nBits ) - :ModalDialog( _pParent, SvtResId( DLG_SVT_EXPLORERFILE ) ) + :ModalDialog( _pParent, SvtResId( DLG_FPICKER_EXPLORERFILE ) ) ,_pUserControls( NULL ) ,_pCbReadOnly( NULL ) ,_pCbLinkBox( NULL) @@ -2164,7 +2165,7 @@ short SvtFileDialog::PrepareExecute() // set up initial filter sal_uInt16 nFilterCount = GetFilterCount(); - String aAll( SvtResId( STR_FILTERNAME_ALL ) ); + rtl::OUString aAll = SvtResId( STR_FILTERNAME_ALL ).toString(); sal_Bool bHasAll = _pImp->HasFilterListEntry( aAll ); if ( _pImp->GetCurFilter() || nFilterCount == 1 || ( nFilterCount == 2 && bHasAll ) ) { @@ -2178,7 +2179,7 @@ short SvtFileDialog::PrepareExecute() nPos = nFilterCount; while ( nPos-- ) { - if ( GetFilterName( nPos ) != aAll ) + if ( aAll != rtl::OUString( GetFilterName( nPos ) ) ) break; } } @@ -3370,7 +3371,7 @@ QueryFolderNameDialog::QueryFolderNameDialog const String& rDefaultText, String* pGroupName ) : - ModalDialog( _pParent, SvtResId( DLG_SVT_QUERYFOLDERNAME ) ), + ModalDialog( _pParent, SvtResId( DLG_FPICKER_QUERYFOLDERNAME ) ), aNameText ( this, SvtResId( FT_SVT_QUERYFOLDERNAME_DLG_NAME ) ), aNameEdit ( this, SvtResId( ED_SVT_QUERYFOLDERNAME_DLG_NAME ) ), diff --git a/fpicker/source/office/iodlg.hrc b/fpicker/source/office/iodlg.hrc index 3e089fc7a6f4..94a127fe9348 100644 --- a/fpicker/source/office/iodlg.hrc +++ b/fpicker/source/office/iodlg.hrc @@ -28,7 +28,6 @@ #ifndef _SVTOOLS_IODLGIMPL_HRC #define _SVTOOLS_IODLGIMPL_HRC -#include "svtools/svtools.hrc" #include "svtools/helpid.hrc" // ModalDialog DLG_SVT_EXPLORERFILE @@ -78,22 +77,6 @@ #define STR_DEFAULT_DIRECTORY 9 #define STR_PLACES_TITLE 10 -// DLG_SVT_ADDPLACE ------------------------------ - -#define FT_ADDPLACE_SERVERURL 10 -#define FT_ADDPLACE_SERVERNAME 11 -#define FT_ADDPLACE_SERVERTYPE 12 -#define FT_ADDPLACE_SERVERLOGIN 13 -#define FT_ADDPLACE_SERVERPASSWORD 14 -#define ED_ADDPLACE_SERVERURL 15 -#define ED_ADDPLACE_SERVERNAME 16 -#define ED_ADDPLACE_SERVERTYPE 17 -#define ED_ADDPLACE_SERVERLOGIN 18 -#define ED_ADDPLACE_SERVERPASSWORD 19 -#define BT_ADDPLACE_OK 20 -#define BT_ADDPLACE_CANCEL 21 -#define BT_ADDPLACE_DELETE 22 - // DLG_SVT_QUERYFOLDERNAME ----------------------- #define FT_SVT_QUERYFOLDERNAME_DLG_NAME 10 diff --git a/fpicker/source/office/iodlg.src b/fpicker/source/office/iodlg.src index 881b7411c914..0c788374e107 100644 --- a/fpicker/source/office/iodlg.src +++ b/fpicker/source/office/iodlg.src @@ -26,9 +26,10 @@ ************************************************************************/ // includes ****************************************************************** -#include "svtools/svtools.hrc" #include "svtools/helpid.hrc" +#include "svtools/svtools.hrc" #include "iodlg.hrc" +#include "OfficeFilePicker.hrc" #define FILEPICKER_IL_IDLIST \ IdList = \ @@ -57,7 +58,7 @@ ImageList RID_FILEPICKER_IMAGES // dialogs ******************************************************************* -ModalDialog DLG_SVT_EXPLORERFILE +ModalDialog DLG_FPICKER_EXPLORERFILE { OutputSize = TRUE ; SVLook = TRUE ; @@ -255,112 +256,9 @@ ModalDialog DLG_SVT_EXPLORERFILE }; }; -// Add Place Dialog -------------------------------------------------------------- - -ModalDialog DLG_SVT_ADDPLACE -{ - OutputSize = TRUE ; - Border = TRUE ; - SVLook = TRUE ; - Moveable = TRUE ; - Closeable = TRUE ; - Sizeable = TRUE; - HelpId = HID_EXPLORERDLG_FILE ; - Size = MAP_APPFONT ( 200 , 140 ) ; - FixedText FT_ADDPLACE_SERVERURL - { - Pos = MAP_APPFONT ( 12 , 14 ) ; - Size = MAP_APPFONT ( 40 , 10 ) ; - Text [ en-US ] = "Server Url" ; - }; - FixedText FT_ADDPLACE_SERVERNAME - { - Pos = MAP_APPFONT ( 12 , 34 ) ; - Size = MAP_APPFONT ( 40 , 10 ) ; - Text [ en-US ] = "Server Name" ; - }; - FixedText FT_ADDPLACE_SERVERTYPE - { - Pos = MAP_APPFONT ( 12 , 54 ) ; - Size = MAP_APPFONT ( 40 , 10 ) ; - Text [ en-US ] = "Type" ; - }; - FixedText FT_ADDPLACE_SERVERLOGIN - { - Pos = MAP_APPFONT ( 12 , 74 ) ; - Size = MAP_APPFONT ( 30 , 10 ) ; - Text [ en-US ] = "Login" ; - }; - FixedText FT_ADDPLACE_SERVERPASSWORD - { - Pos = MAP_APPFONT ( 12 , 94 ) ; - Size = MAP_APPFONT ( 40 , 10 ) ; - Text [ en-US ] = "Password" ; - }; - Edit ED_ADDPLACE_SERVERURL - { - //HelpID = "fpicker:Edit:DLG_SVT_QUERYFOLDERNAME:ED_SVT_QUERYFOLDERNAME_DLG_NAME"; - Pos = MAP_APPFONT ( 62, 12 ) ; - Size = MAP_APPFONT ( 130 , 12 ) ; - Border = TRUE ; - //Left = TRUE ; - }; - Edit ED_ADDPLACE_SERVERNAME - { - //HelpID = "fpicker:Edit:DLG_SVT_QUERYFOLDERNAME:ED_SVT_QUERYFOLDERNAME_DLG_NAME"; - Pos = MAP_APPFONT ( 62, 32 ) ; - Size = MAP_APPFONT ( 130 , 12 ) ; - Border = TRUE ; - //Left = TRUE ; - }; - Edit ED_ADDPLACE_SERVERTYPE - { - //HelpID = "fpicker:Edit:DLG_SVT_QUERYFOLDERNAME:ED_SVT_QUERYFOLDERNAME_DLG_NAME"; - Pos = MAP_APPFONT ( 62, 52 ) ; - Size = MAP_APPFONT ( 130 , 12 ) ; - Border = TRUE ; - //Left = TRUE ; - }; - Edit ED_ADDPLACE_SERVERLOGIN - { - //HelpID = "fpicker:Edit:DLG_SVT_QUERYFOLDERNAME:ED_SVT_QUERYFOLDERNAME_DLG_NAME"; - Pos = MAP_APPFONT ( 62, 72 ) ; - Size = MAP_APPFONT ( 130 , 12 ) ; - Border = TRUE ; - //Left = TRUE ; - }; - Edit ED_ADDPLACE_SERVERPASSWORD - { - //HelpID = "fpicker:Edit:DLG_SVT_QUERYFOLDERNAME:ED_SVT_QUERYFOLDERNAME_DLG_NAME"; - Pos = MAP_APPFONT ( 62, 92 ) ; - Size = MAP_APPFONT ( 130 , 12 ) ; - Border = TRUE ; - //Left = TRUE ; - }; - OKButton BT_ADDPLACE_OK - { - Pos = MAP_APPFONT ( 80 , 120 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - DefButton = TRUE ; - }; - CancelButton BT_ADDPLACE_CANCEL - { - Pos = MAP_APPFONT ( 140, 120 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - }; - PushButton BT_ADDPLACE_DELETE - { - //HelpID = "fpicker:PushButton:DLG_SVT_EXPLORERFILE:BTN_EXPLORERFILE_CONNECT_TO_SERVER"; - Pos = MAP_APPFONT ( 10 , 120 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - Text [ en-US ] = "Delete" ; - //QuickHelpText [ en-US ] = "Connect To Server" ; - }; -}; - // QueryFolderNameDialog ---------------------------------------------------------- -ModalDialog DLG_SVT_QUERYFOLDERNAME +ModalDialog DLG_FPICKER_QUERYFOLDERNAME { HelpID = "fpicker:ModalDialog:DLG_SVT_QUERYFOLDERNAME"; Border = TRUE ; diff --git a/fpicker/source/win32/misc/resourceprovider.cxx b/fpicker/source/win32/misc/resourceprovider.cxx index 629d19548417..6fb8e17d986b 100644 --- a/fpicker/source/win32/misc/resourceprovider.cxx +++ b/fpicker/source/win32/misc/resourceprovider.cxx @@ -40,7 +40,7 @@ #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp> #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> -#include <svtools/svtools.hrc> +#include "fpicker.hrc" //------------------------------------------------------------ // namespace directives |