diff options
author | Kurt Zenker <kz@openoffice.org> | 2007-05-10 12:05:18 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2007-05-10 12:05:18 +0000 |
commit | c0f7a7031bf3248e27b2fbc6477fc4e144b5d8f9 (patch) | |
tree | 3031d90bd1ec80401aebae3a1fdb97c1f00941fd | |
parent | 0f375013f4bfb68387121d794dd834b4b9bf8dca (diff) |
INTEGRATION: CWS ucbfixes01 (1.1.2); FILE ADDED
2007/04/23 16:40:12 kso 1.1.2.1: #70959# - Eliminated multiple identical URI helper functionality
implementations.
-rw-r--r-- | ucb/source/ucp/inc/urihelper.hxx | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/ucb/source/ucp/inc/urihelper.hxx b/ucb/source/ucp/inc/urihelper.hxx new file mode 100644 index 000000000000..328c87b3e7dc --- /dev/null +++ b/ucb/source/ucp/inc/urihelper.hxx @@ -0,0 +1,84 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: urihelper.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: kz $ $Date: 2007-05-10 13:05:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_URIHELPER_HXX +#define INCLUDED_URIHELPER_HXX + +#include "rtl/ustring.hxx" +#include "rtl/ustrbuf.hxx" +#include "rtl/uri.hxx" + +//========================================================================= + +namespace ucb { namespace urihelper { + + inline ::rtl::OUString encodeSegment( const ::rtl::OUString & rSegment ) + { + return rtl::Uri::encode( rSegment, + rtl_UriCharClassPchar, + rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8 ); + } + + inline ::rtl::OUString decodeSegment( const rtl::OUString& rSegment ) + { + return rtl::Uri::decode( rSegment, + rtl_UriDecodeWithCharset, + RTL_TEXTENCODING_UTF8 ); + } + + inline ::rtl::OUString encodeURI( const ::rtl::OUString & rURI ) + { + rtl::OUStringBuffer aResult; + + sal_Int32 nIndex = 0; + do + { + aResult.append( + rtl::Uri::encode( rURI.getToken( 0, '/', nIndex ), + rtl_UriCharClassPchar, + rtl_UriEncodeCheckEscapes, + RTL_TEXTENCODING_UTF8 ) ); + if ( nIndex >= 0 ) + aResult.append( sal_Unicode( '/' ) ); + } + while ( nIndex >= 0 ); + + return aResult.makeStringAndClear(); + } + +} } // namespace + +#endif /* !INCLUDED_URIHELPER_HXX */ |