diff options
author | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2012-05-31 14:18:55 +0200 |
---|---|---|
committer | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2012-06-04 13:28:13 +0200 |
commit | a57fca1bcabfbf6dae93eaafb4ab2d313a69f5a4 (patch) | |
tree | 4a4bc8fe9a5ab4812b5e3dcf70188c27e6186ce8 /fpicker | |
parent | 4880c6dcee9f1ae6a895f15293727eb6a76d6c5e (diff) |
fpicker: Added CMIS protocol for Experimental features
Change-Id: I Ib254cfbe2743b67bc19c2c9033908bc0bedc430c
Diffstat (limited to 'fpicker')
-rw-r--r-- | fpicker/source/office/PlaceEditDialog.cxx | 25 | ||||
-rw-r--r-- | fpicker/source/office/PlaceEditDialog.hrc | 4 | ||||
-rw-r--r-- | fpicker/source/office/PlaceEditDialog.hxx | 5 | ||||
-rw-r--r-- | fpicker/source/office/PlaceEditDialog.src | 25 | ||||
-rw-r--r-- | fpicker/source/office/ServerDetailsControls.cxx | 65 | ||||
-rw-r--r-- | fpicker/source/office/ServerDetailsControls.hxx | 10 |
6 files changed, 133 insertions, 1 deletions
diff --git a/fpicker/source/office/PlaceEditDialog.cxx b/fpicker/source/office/PlaceEditDialog.cxx index 1ecdb591a7ec..d305bc409c33 100644 --- a/fpicker/source/office/PlaceEditDialog.cxx +++ b/fpicker/source/office/PlaceEditDialog.cxx @@ -33,6 +33,7 @@ #include "PlaceEditDialog.hxx" #include "ServerDetailsControls.hxx" +#include <officecfg/Office/Common.hxx> #include <vcl/msgbox.hxx> using namespace boost; @@ -56,6 +57,10 @@ PlaceEditDialog::PlaceEditDialog( Window* pParent ) : m_aEDShare( this, SvtResId( ED_ADDPLACE_SHARE ) ), m_aFTSmbPath( this, SvtResId( FT_ADDPLACE_SMBPATH ) ), m_aEDSmbPath( this, SvtResId( ED_ADDPLACE_SMBPATH ) ), + 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_aFTUsername( this, SvtResId( FT_ADDPLACE_USERNAME ) ), m_aEDUsername( this, SvtResId( ED_ADDPLACE_USERNAME ) ), m_aBTOk( this, SvtResId( BT_ADDPLACE_OK ) ), @@ -95,6 +100,10 @@ PlaceEditDialog::PlaceEditDialog( Window* pParent, const PlacePtr& pPlace ) : m_aEDShare( this, SvtResId( ED_ADDPLACE_SHARE ) ), m_aFTSmbPath( this, SvtResId( FT_ADDPLACE_SMBPATH ) ), m_aEDSmbPath( this, SvtResId( ED_ADDPLACE_SMBPATH ) ), + 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_aFTUsername( this, SvtResId( FT_ADDPLACE_USERNAME ) ), m_aEDUsername( this, SvtResId( ED_ADDPLACE_USERNAME ) ), m_aBTOk( this, SvtResId( BT_ADDPLACE_OK ) ), @@ -198,6 +207,22 @@ void PlaceEditDialog::InitDetails( ) pSmbDetails->setChangeHdl( LINK( this, PlaceEditDialog, EditHdl ) ); m_aDetailsContainers.push_back( pSmbDetails ); + // Create CMIS control + shared_ptr< DetailsContainer > pCmisDetails( new CmisDetailsContainer( ) ); + 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->setChangeHdl( LINK( this, PlaceEditDialog, EditHdl ) ); + + if ( officecfg::Office::Common::Misc::ExperimentalMode::get() ) + m_aDetailsContainers.push_back( pCmisDetails ); + else + { + // Remove the CMIS entry, left it in src file for l10n + m_aLBServerType.RemoveEntry( m_aLBServerType.GetEntryCount( ) - 1 ); + } + // Set default to first value m_aLBServerType.SelectEntryPos( 0 ); SelectTypeHdl( &m_aLBServerType ); diff --git a/fpicker/source/office/PlaceEditDialog.hrc b/fpicker/source/office/PlaceEditDialog.hrc index b22f3f942995..74900f72aec7 100644 --- a/fpicker/source/office/PlaceEditDialog.hrc +++ b/fpicker/source/office/PlaceEditDialog.hrc @@ -53,6 +53,10 @@ #define ED_ADDPLACE_SHARE 28 #define FT_ADDPLACE_SMBPATH 29 #define ED_ADDPLACE_SMBPATH 30 +#define FT_ADDPLACE_CMIS_BINDING 31 +#define ED_ADDPLACE_CMIS_BINDING 32 +#define FT_ADDPLACE_CMIS_REPOSITORY 33 +#define ED_ADDPLACE_CMIS_REPOSITORY 34 #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/office/PlaceEditDialog.hxx b/fpicker/source/office/PlaceEditDialog.hxx index 68ee425ea747..53526e8e18ec 100644 --- a/fpicker/source/office/PlaceEditDialog.hxx +++ b/fpicker/source/office/PlaceEditDialog.hxx @@ -69,6 +69,11 @@ private : FixedText m_aFTSmbPath; Edit m_aEDSmbPath; + FixedText m_aFTCmisBinding; + Edit m_aEDCmisBinding; + FixedText m_aFTCmisRepository; + Edit m_aEDCmisRepository; + FixedText m_aFTUsername; Edit m_aEDUsername; OKButton m_aBTOk; diff --git a/fpicker/source/office/PlaceEditDialog.src b/fpicker/source/office/PlaceEditDialog.src index 15c614d1a0b2..313f25bc16fd 100644 --- a/fpicker/source/office/PlaceEditDialog.src +++ b/fpicker/source/office/PlaceEditDialog.src @@ -134,6 +134,30 @@ ModalDialog DLG_FPICKER_PLACE_EDIT Size = MAP_APPFONT ( 137 , 12 ) ; Border = TRUE ; }; + FixedText FT_ADDPLACE_CMIS_BINDING + { + Pos = MAP_APPFONT ( 12 , 46 ) ; + Size = MAP_APPFONT ( 40 , 10 ) ; + Text [ en-US ] = "Binding URL" ; + }; + Edit ED_ADDPLACE_CMIS_BINDING + { + Pos = MAP_APPFONT ( 55, 44 ) ; + Size = MAP_APPFONT ( 137 , 12 ) ; + Border = TRUE ; + }; + FixedText FT_ADDPLACE_CMIS_REPOSITORY + { + Pos = MAP_APPFONT ( 12 , 62 ) ; + Size = MAP_APPFONT ( 40 , 10 ) ; + Text [ en-US ] = "Repository" ; + }; + Edit ED_ADDPLACE_CMIS_REPOSITORY + { + Pos = MAP_APPFONT ( 55, 60 ) ; + Size = MAP_APPFONT ( 137 , 12 ) ; + Border = TRUE ; + }; ListBox LB_ADDPLACE_SERVERTYPE { Pos = MAP_APPFONT ( 55, 28 ) ; @@ -146,6 +170,7 @@ ModalDialog DLG_FPICKER_PLACE_EDIT < "FTP" ; >; < "SSH" ; >; < "Windows Share" ; >; + < "CMIS (Atom Binding)" ; >; }; }; FixedText FT_ADDPLACE_USERNAME diff --git a/fpicker/source/office/ServerDetailsControls.cxx b/fpicker/source/office/ServerDetailsControls.cxx index ca00481d3595..ae52de429e53 100644 --- a/fpicker/source/office/ServerDetailsControls.cxx +++ b/fpicker/source/office/ServerDetailsControls.cxx @@ -234,7 +234,6 @@ INetURLObject SmbDetailsContainer::getUrl( ) rtl::OUString sUrl; if ( !sHost.isEmpty( ) ) { - INetURLObject aUrl; sUrl = "smb://" + sHost + "/"; if ( !sShare.isEmpty( ) ) sUrl += sShare; @@ -272,4 +271,68 @@ bool SmbDetailsContainer::setUrl( const INetURLObject& rUrl ) return bSuccess; } +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() ) + { + sal_Int32 pos = sBindingUrl.indexOf( rtl::OUString::createFromAscii( "://" ) ); + if ( pos > 0 ) + sBindingUrl = sBindingUrl.copy( pos + 3 ); + sUrl = "cmis+atom://" + sBindingUrl + "?repo-id=" + sRepo; + } + + return INetURLObject( sUrl ); +} + +bool CmisDetailsContainer::setUrl( const INetURLObject& rUrl ) +{ + bool bSuccess = rUrl.GetProtocol() == INET_PROT_CMIS_ATOM; + + if ( bSuccess ) + { + rtl::OUString sBindingUrl( "http://" ); + sBindingUrl += rUrl.GetHost( ); + if ( rUrl.HasPort( ) ) + sBindingUrl += rtl::OUString::valueOf( sal_Int32( rUrl.GetPort( ) ) ); + sBindingUrl += rUrl.GetURLPath( ); + + // Split the query into bits and locate the repo-id key + rtl::OUString sQuery = rUrl.GetParam( ); + rtl::OUString sRepositoryId; + + while ( !sQuery.isEmpty() ) + { + sal_Int32 nPos = sQuery.indexOfAsciiL( "&", 1 ); + rtl::OUString sSegment; + if ( nPos > 0 ) + { + sSegment = sQuery.copy( 0, nPos ); + sQuery = sQuery.copy( nPos + 1 ); + } + else + { + sSegment = sQuery; + sQuery = rtl::OUString(); + } + + sal_Int32 nEqPos = sSegment.indexOfAsciiL( "=", 1 ); + rtl::OUString key = sSegment.copy( 0, nEqPos ); + rtl::OUString value = sSegment.copy( nEqPos +1 ); + + if ( key == "repo-id" ) + sRepositoryId = value; + } + + static_cast< Edit* >( getControl( ED_ADDPLACE_CMIS_BINDING ) )->SetText( sBindingUrl ); + static_cast< Edit* >( getControl( ED_ADDPLACE_CMIS_REPOSITORY ) )->SetText( sRepositoryId ); + } + + return bSuccess; +} + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/office/ServerDetailsControls.hxx b/fpicker/source/office/ServerDetailsControls.hxx index aafcc0c49ea0..a31e831cd68a 100644 --- a/fpicker/source/office/ServerDetailsControls.hxx +++ b/fpicker/source/office/ServerDetailsControls.hxx @@ -119,5 +119,15 @@ class SmbDetailsContainer : public DetailsContainer virtual bool setUrl( const INetURLObject& rUrl ); }; +class CmisDetailsContainer : public DetailsContainer +{ + public: + CmisDetailsContainer( ) : DetailsContainer( ) { }; + ~CmisDetailsContainer( ) { }; + + virtual INetURLObject getUrl( ); + virtual bool setUrl( const INetURLObject& rUrl ); +}; + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |