From fd32788092fcb29526ae73ae3bae6767dbb1e490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= Date: Mon, 4 Jun 2012 10:13:17 +0200 Subject: CMIS UCP: changed URLs to have hierarchical path Hierarchical path is assumed in loads of places, changed the URLs to the following: * Binding URL is encoded in the authority part, the repository ID is set as a fragment of the binding URL. * The hierarchical path reflects one of the path to the document on the server :x Change-Id: I8214daeb1d9c9b0f6ab86bdf60875e7e4e5369f4 --- fpicker/source/office/ServerDetailsControls.cxx | 48 ++++++++----------------- 1 file changed, 14 insertions(+), 34 deletions(-) (limited to 'fpicker/source/office') diff --git a/fpicker/source/office/ServerDetailsControls.cxx b/fpicker/source/office/ServerDetailsControls.cxx index ae52de429e53..dc31dc54db64 100644 --- a/fpicker/source/office/ServerDetailsControls.cxx +++ b/fpicker/source/office/ServerDetailsControls.cxx @@ -26,6 +26,8 @@ * instead of those above. */ +#include + #include "PlaceEditDialog.hrc" #include "fpsofficeResMgr.hxx" @@ -279,10 +281,13 @@ INetURLObject CmisDetailsContainer::getUrl( ) 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; + rtl::OUString sEncodedBinding = rtl::Uri::encode( + sBindingUrl + "#" + sRepo, + rtl_UriCharClassUricNoSlash, + rtl_UriEncodeKeepEscapes, + RTL_TEXTENCODING_UTF8 ); + sUrl = "vnd.libreoffice.cmis+atom://" + sEncodedBinding; + INetURLObject test( sUrl ); } return INetURLObject( sUrl ); @@ -294,38 +299,13 @@ bool CmisDetailsContainer::setUrl( const INetURLObject& rUrl ) 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 sBindingUrl; 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; - } + rtl::OUString sDecodedHost = rUrl.GetHost( INetURLObject::DECODE_WITH_CHARSET ); + INetURLObject aHostUrl( sDecodedHost ); + sBindingUrl = aHostUrl.GetURLNoMark( ); + sRepositoryId = aHostUrl.GetMark( ); static_cast< Edit* >( getControl( ED_ADDPLACE_CMIS_BINDING ) )->SetText( sBindingUrl ); static_cast< Edit* >( getControl( ED_ADDPLACE_CMIS_REPOSITORY ) )->SetText( sRepositoryId ); -- cgit v1.2.1