diff options
Diffstat (limited to 'fpicker/source')
-rw-r--r-- | fpicker/source/office/PlaceEditDialog.cxx | 24 | ||||
-rw-r--r-- | fpicker/source/office/PlaceEditDialog.hrc | 3 | ||||
-rw-r--r-- | fpicker/source/office/PlaceEditDialog.hxx | 10 | ||||
-rw-r--r-- | fpicker/source/office/PlaceEditDialog.src | 20 | ||||
-rw-r--r-- | fpicker/source/office/ServerDetailsControls.cxx | 120 | ||||
-rw-r--r-- | fpicker/source/office/ServerDetailsControls.hxx | 19 | ||||
-rw-r--r-- | fpicker/source/office/iodlg.cxx | 3 |
7 files changed, 181 insertions, 18 deletions
diff --git a/fpicker/source/office/PlaceEditDialog.cxx b/fpicker/source/office/PlaceEditDialog.cxx index d305bc409c33..7480553465d1 100644 --- a/fpicker/source/office/PlaceEditDialog.cxx +++ b/fpicker/source/office/PlaceEditDialog.cxx @@ -60,7 +60,8 @@ PlaceEditDialog::PlaceEditDialog( Window* pParent ) : m_aFTCmisBinding( this, SvtResId( FT_ADDPLACE_CMIS_BINDING ) ), m_aEDCmisBinding( this, SvtResId( ED_ADDPLACE_CMIS_BINDING ) ), m_aFTCmisRepository( this, SvtResId( FT_ADDPLACE_CMIS_REPOSITORY ) ), - m_aEDCmisRepository( this, SvtResId( ED_ADDPLACE_CMIS_REPOSITORY ) ), + m_aLBCmisRepository( this, SvtResId( LB_ADDPLACE_CMIS_REPOSITORY ) ), + m_aBTCmisRepoRefresh( this, SvtResId( BT_ADDPLACE_CMIS_REPOREFRESH ) ), m_aFTUsername( this, SvtResId( FT_ADDPLACE_USERNAME ) ), m_aEDUsername( this, SvtResId( ED_ADDPLACE_USERNAME ) ), m_aBTOk( this, SvtResId( BT_ADDPLACE_OK ) ), @@ -77,6 +78,7 @@ PlaceEditDialog::PlaceEditDialog( Window* pParent ) : m_aBTDelete.Hide(); m_aLBServerType.SetSelectHdl( LINK( this, PlaceEditDialog, SelectTypeHdl ) ); + m_aEDUsername.SetModifyHdl( LINK( this, PlaceEditDialog, EditUsernameHdl ) ); InitDetails( ); } @@ -103,7 +105,8 @@ PlaceEditDialog::PlaceEditDialog( Window* pParent, const PlacePtr& pPlace ) : m_aFTCmisBinding( this, SvtResId( FT_ADDPLACE_CMIS_BINDING ) ), m_aEDCmisBinding( this, SvtResId( ED_ADDPLACE_CMIS_BINDING ) ), m_aFTCmisRepository( this, SvtResId( FT_ADDPLACE_CMIS_REPOSITORY ) ), - m_aEDCmisRepository( this, SvtResId( ED_ADDPLACE_CMIS_REPOSITORY ) ), + m_aLBCmisRepository( this, SvtResId( LB_ADDPLACE_CMIS_REPOSITORY ) ), + m_aBTCmisRepoRefresh( this, SvtResId( BT_ADDPLACE_CMIS_REPOREFRESH ) ), m_aFTUsername( this, SvtResId( FT_ADDPLACE_USERNAME ) ), m_aEDUsername( this, SvtResId( ED_ADDPLACE_USERNAME ) ), m_aBTOk( this, SvtResId( BT_ADDPLACE_OK ) ), @@ -148,7 +151,9 @@ rtl::OUString PlaceEditDialog::GetServerUrl() if ( m_pCurrentDetails.get( ) ) { INetURLObject aUrl = m_pCurrentDetails->getUrl(); - aUrl.SetUser( rtl::OUString( m_aEDUsername.GetText( ) ).trim( ) ); + rtl::OUString sUsername = rtl::OUString( m_aEDUsername.GetText( ) ).trim( ); + if ( !sUsername.isEmpty( ) ) + aUrl.SetUser( sUsername ); if ( !aUrl.HasError( ) ) sUrl = aUrl.GetMainURL( INetURLObject::NO_DECODE ); } @@ -212,7 +217,8 @@ void PlaceEditDialog::InitDetails( ) pCmisDetails->addControl( FT_ADDPLACE_CMIS_BINDING, &m_aFTCmisBinding ); pCmisDetails->addControl( ED_ADDPLACE_CMIS_BINDING, &m_aEDCmisBinding ); pCmisDetails->addControl( FT_ADDPLACE_CMIS_REPOSITORY, &m_aFTCmisRepository ); - pCmisDetails->addControl( ED_ADDPLACE_CMIS_REPOSITORY, &m_aEDCmisRepository ); + pCmisDetails->addControl( LB_ADDPLACE_CMIS_REPOSITORY, &m_aLBCmisRepository ); + pCmisDetails->addControl( BT_ADDPLACE_CMIS_REPOREFRESH, &m_aBTCmisRepoRefresh ); pCmisDetails->setChangeHdl( LINK( this, PlaceEditDialog, EditHdl ) ); if ( officecfg::Office::Common::Misc::ExperimentalMode::get() ) @@ -249,6 +255,16 @@ IMPL_LINK ( PlaceEditDialog, EditHdl, void *, EMPTYARG ) return 1; } +IMPL_LINK ( PlaceEditDialog, EditUsernameHdl, void *, EMPTYARG ) +{ + for ( std::vector< boost::shared_ptr< DetailsContainer > >::iterator it = m_aDetailsContainers.begin( ); + it != m_aDetailsContainers.end( ); ++it ) + { + ( *it )->setUsername( rtl::OUString( m_aEDUsername.GetText() ) ); + } + return 1; +} + IMPL_LINK( PlaceEditDialog, SelectTypeHdl, void*, EMPTYARG ) { // Compute the vertical space between two rows diff --git a/fpicker/source/office/PlaceEditDialog.hrc b/fpicker/source/office/PlaceEditDialog.hrc index 74900f72aec7..738d19d66b4a 100644 --- a/fpicker/source/office/PlaceEditDialog.hrc +++ b/fpicker/source/office/PlaceEditDialog.hrc @@ -56,7 +56,8 @@ #define FT_ADDPLACE_CMIS_BINDING 31 #define ED_ADDPLACE_CMIS_BINDING 32 #define FT_ADDPLACE_CMIS_REPOSITORY 33 -#define ED_ADDPLACE_CMIS_REPOSITORY 34 +#define LB_ADDPLACE_CMIS_REPOSITORY 34 +#define BT_ADDPLACE_CMIS_REPOREFRESH 35 #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/office/PlaceEditDialog.hxx b/fpicker/source/office/PlaceEditDialog.hxx index fd38f13b0d8e..b74eb617300f 100644 --- a/fpicker/source/office/PlaceEditDialog.hxx +++ b/fpicker/source/office/PlaceEditDialog.hxx @@ -71,7 +71,8 @@ private : FixedText m_aFTCmisBinding; Edit m_aEDCmisBinding; FixedText m_aFTCmisRepository; - Edit m_aEDCmisRepository; + ListBox m_aLBCmisRepository; + ImageButton m_aBTCmisRepoRefresh; FixedText m_aFTUsername; Edit m_aEDUsername; @@ -106,10 +107,11 @@ private: void InitDetails( ); - DECL_LINK ( OKHdl, Button * ); - DECL_LINK ( DelHdl, Button * ); - DECL_LINK ( EditHdl, void * ); + DECL_LINK ( OKHdl, Button * ); + DECL_LINK ( DelHdl, Button * ); + DECL_LINK ( EditHdl, void * ); DECL_LINK ( SelectTypeHdl, void * ); + DECL_LINK ( EditUsernameHdl, void * ); }; diff --git a/fpicker/source/office/PlaceEditDialog.src b/fpicker/source/office/PlaceEditDialog.src index 313f25bc16fd..0c312d552456 100644 --- a/fpicker/source/office/PlaceEditDialog.src +++ b/fpicker/source/office/PlaceEditDialog.src @@ -152,11 +152,27 @@ ModalDialog DLG_FPICKER_PLACE_EDIT Size = MAP_APPFONT ( 40 , 10 ) ; Text [ en-US ] = "Repository" ; }; - Edit ED_ADDPLACE_CMIS_REPOSITORY + ListBox LB_ADDPLACE_CMIS_REPOSITORY { Pos = MAP_APPFONT ( 55, 60 ) ; - Size = MAP_APPFONT ( 137 , 12 ) ; + Size = MAP_APPFONT ( 122 , 75 ) ; Border = TRUE ; + DropDown = TRUE; + }; + ImageButton BT_ADDPLACE_CMIS_REPOREFRESH + { + Pos = MAP_APPFONT ( 180, 60 ) ; + Size = MAP_APPFONT ( 12, 12 ); + TabStop = FALSE ; + QuickHelpText [ en-US ] = "Refresh" ; + ButtonImage = Image + { + ImageBitmap = Bitmap + { + File = "reload.png" ; + }; + MaskColor = Color { Red = 0xFF00; Green = 0x0000; Blue = 0xFF00; } ; + }; }; ListBox LB_ADDPLACE_SERVERTYPE { diff --git a/fpicker/source/office/ServerDetailsControls.cxx b/fpicker/source/office/ServerDetailsControls.cxx index bcc9cd3451af..69dfa4f74611 100644 --- a/fpicker/source/office/ServerDetailsControls.cxx +++ b/fpicker/source/office/ServerDetailsControls.cxx @@ -26,7 +26,16 @@ * instead of those above. */ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/task/XInteractionHandler.hpp> +#include <com/sun/star/ucb/XCommandEnvironment.hpp> +#include <com/sun/star/ucb/XContentAccess.hpp> +#include <com/sun/star/sdbc/XResultSet.hpp> +#include <com/sun/star/sdbc/XRow.hpp> + #include <rtl/uri.hxx> +#include <ucbhelper/content.hxx> +#include <ucbhelper/commandenvironment.hxx> #include "PlaceEditDialog.hrc" @@ -35,6 +44,11 @@ #include "ServerDetailsControls.hxx" using namespace std; +using namespace com::sun::star::lang; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::task; +using namespace com::sun::star::ucb; +using namespace com::sun::star::uno; DetailsContainer::DetailsContainer( ) : m_aControls( ), @@ -273,21 +287,30 @@ bool SmbDetailsContainer::setUrl( const INetURLObject& rUrl ) return bSuccess; } +CmisDetailsContainer::CmisDetailsContainer( ) : + DetailsContainer( ), + m_sUsername( ), + m_xCmdEnv( ) +{ + Reference< XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); + Reference< XInteractionHandler > xGlobalInteractionHandler = Reference< XInteractionHandler >( + xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.task.InteractionHandler") ) ), UNO_QUERY ); + m_xCmdEnv = new ucbhelper::CommandEnvironment( xGlobalInteractionHandler, Reference< XProgressHandler >() ); +} + INetURLObject CmisDetailsContainer::getUrl( ) { rtl::OUString sBindingUrl = rtl::OUString( static_cast< Edit* >( getControl( ED_ADDPLACE_CMIS_BINDING ) )->GetText() ).trim( ); - rtl::OUString sRepo = rtl::OUString( static_cast< Edit* >( getControl( ED_ADDPLACE_CMIS_REPOSITORY ) )->GetText() ).trim( ); rtl::OUString sUrl; - if ( !sBindingUrl.isEmpty( ) && !sRepo.isEmpty() ) + if ( !sBindingUrl.isEmpty( ) && !m_sRepoId.isEmpty() ) { rtl::OUString sEncodedBinding = rtl::Uri::encode( - sBindingUrl + "#" + sRepo, + sBindingUrl + "#" + m_sRepoId, rtl_UriCharClassRelSegment, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_UTF8 ); sUrl = "vnd.libreoffice.cmis+atom://" + sEncodedBinding; - INetURLObject test( sUrl ); } return INetURLObject( sUrl ); @@ -308,11 +331,98 @@ bool CmisDetailsContainer::setUrl( const INetURLObject& rUrl ) sRepositoryId = aHostUrl.GetMark( ); static_cast< Edit* >( getControl( ED_ADDPLACE_CMIS_BINDING ) )->SetText( sBindingUrl ); - static_cast< Edit* >( getControl( ED_ADDPLACE_CMIS_REPOSITORY ) )->SetText( sRepositoryId ); } return bSuccess; } +void CmisDetailsContainer::setUsername( const rtl::OUString& rUsername ) +{ + m_sUsername = rtl::OUString( rUsername ); +} + +void CmisDetailsContainer::addControl( sal_uInt16 nId, Control* pControl ) +{ + DetailsContainer::addControl( nId, pControl ); + + // Add listener on BT_ADDPLACE_CMIS_REPOREFRESH + if ( nId == BT_ADDPLACE_CMIS_REPOREFRESH ) + static_cast< ImageButton* >( pControl )->SetClickHdl( LINK( this, CmisDetailsContainer, RefreshReposHdl ) ); + if ( nId == LB_ADDPLACE_CMIS_REPOSITORY ) + static_cast< ListBox* >( pControl )->SetSelectHdl( LINK( this, CmisDetailsContainer, SelectRepoHdl ) ); +} + +void CmisDetailsContainer::selectRepository( ) +{ + // Get the repo ID and call the Change listener + ListBox* pReposList = static_cast< ListBox* >( getControl( LB_ADDPLACE_CMIS_REPOSITORY ) ); + sal_uInt16 nPos = pReposList->GetSelectEntryPos( ); + m_sRepoId = m_aRepoIds[nPos]; + + notifyChange( ); +} + +IMPL_LINK( CmisDetailsContainer, RefreshReposHdl, void *, EMPTYARG ) +{ + rtl::OUString sBindingUrl = rtl::OUString( static_cast< Edit* >( getControl( ED_ADDPLACE_CMIS_BINDING ) )->GetText() ).trim( ); + + // Clean the listbox + ListBox* pReposList = static_cast< ListBox* >( getControl( LB_ADDPLACE_CMIS_REPOSITORY ) ); + pReposList->Clear( ); + m_aRepoIds.clear( ); + + // Compute the URL + rtl::OUString sUrl; + if ( !sBindingUrl.isEmpty( ) ) + { + rtl::OUString sEncodedBinding = rtl::Uri::encode( + sBindingUrl, + rtl_UriCharClassRelSegment, + rtl_UriEncodeKeepEscapes, + RTL_TEXTENCODING_UTF8 ); + sUrl = "vnd.libreoffice.cmis+atom://" + sEncodedBinding; + } + + // Get the Content + ::ucbhelper::Content aCnt( sUrl, m_xCmdEnv ); + Sequence< rtl::OUString > aProps( 1 ); + aProps[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ); + + try + { + Reference< XResultSet > xResultSet( aCnt.createCursor( aProps ), UNO_QUERY_THROW ); + Reference< XContentAccess > xAccess( xResultSet, UNO_QUERY_THROW ); + while ( xResultSet->next() ) + { + rtl::OUString sURL = xAccess->queryContentIdentifierString( ); + INetURLObject aURL( sURL ); + rtl::OUString sId = aURL.GetURLPath( INetURLObject::DECODE_WITH_CHARSET ); + sId = sId.copy( 1 ); + m_aRepoIds.push_back( sId ); + + Reference< XRow > xRow( xResultSet, UNO_QUERY ); + rtl::OUString sName = xRow->getString( 1 ); + pReposList->InsertEntry( sName ); + } + } + catch ( const Exception& ) + { + } + + // Auto-select the first one + if ( pReposList->GetEntryCount( ) > 0 ) + { + pReposList->SelectEntryPos( 0 ); + selectRepository( ); + } + + return 0; +} + +IMPL_LINK( CmisDetailsContainer, SelectRepoHdl, void *, EMPTYARG ) +{ + selectRepository( ); + return 0; +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/office/ServerDetailsControls.hxx b/fpicker/source/office/ServerDetailsControls.hxx index 6543ded42154..206f1aaa5870 100644 --- a/fpicker/source/office/ServerDetailsControls.hxx +++ b/fpicker/source/office/ServerDetailsControls.hxx @@ -28,6 +28,8 @@ #ifndef _SERVERDETAILSCONTROLS_HXX #define _SERVERDETAILSCONTROLS_HXX +#include <com/sun/star/ucb/XCommandEnvironment.hpp> + #include <tools/urlobj.hxx> #include <vcl/ctrl.hxx> #include <vcl/edit.hxx> @@ -61,6 +63,8 @@ class DetailsContainer */ virtual bool setUrl( const INetURLObject& rUrl ); + virtual void setUsername( const rtl::OUString& /*rUsername*/ ) { }; + protected: void notifyChange( ); @@ -119,12 +123,25 @@ class SmbDetailsContainer : public DetailsContainer class CmisDetailsContainer : public DetailsContainer { + private: + rtl::OUString m_sUsername; + com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > m_xCmdEnv; + std::vector< rtl::OUString > m_aRepoIds; + rtl::OUString m_sRepoId; + public: - CmisDetailsContainer( ) : DetailsContainer( ) { }; + CmisDetailsContainer( ); ~CmisDetailsContainer( ) { }; virtual INetURLObject getUrl( ); virtual bool setUrl( const INetURLObject& rUrl ); + virtual void setUsername( const rtl::OUString& rUsername ); + virtual void addControl( sal_uInt16 nId, Control* pControl ); + + private: + void selectRepository( ); + DECL_LINK ( RefreshReposHdl, void * ); + DECL_LINK ( SelectRepoHdl, void * ); }; #endif diff --git a/fpicker/source/office/iodlg.cxx b/fpicker/source/office/iodlg.cxx index 13540848252b..c461addefd73 100644 --- a/fpicker/source/office/iodlg.cxx +++ b/fpicker/source/office/iodlg.cxx @@ -3349,7 +3349,8 @@ void SvtFileDialog::initDefaultPlaces( ) Sequence< ::rtl::OUString > placesUrlsList(officecfg::Office::Common::Misc::FilePickerPlacesUrls::get(m_context)); Sequence< ::rtl::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) + { PlacePtr pPlace(new Place(placesNamesList[nPlace], placesUrlsList[nPlace], true)); _pImp->_pPlaces->AppendPlace(pPlace); } |