xref: /AOO41X/main/tools/inc/tools/urlobj.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _URLOBJ_HXX
28 #define _URLOBJ_HXX
29 
30 #include "tools/toolsdllapi.h"
31 #include <tools/string.hxx>
32 #include "com/sun/star/uno/Reference.hxx"
33 #include "rtl/string.h"
34 #include "rtl/ustrbuf.hxx"
35 #include "rtl/textenc.h"
36 #include "sal/types.h"
37 
38 namespace com { namespace sun { namespace star { namespace util {
39     class XStringWidth;
40 } } } }
41 
42 //============================================================================
43 // Special tokens:
44 #define INET_PASS_TOKEN '@'
45 #define INET_DELIM_TOKEN ':'
46 #define INET_DELIM_IMAPID ';'
47 #define INET_ENC_DELIM_TOKEN '|'
48 #define INET_DELIM_HOST_TOKEN '.'
49 #define INET_PATH_TOKEN '/'
50 #define INET_DOSPATH_TOKEN '\\'
51 #define INET_MARK_TOKEN '#'
52 #define INET_PARAM_TOKEN '?'
53 #define INET_HEX_ESCAPE '%'
54 
55 //============================================================================
56 // Common URL prefixes for various schemes:
57 #define	INET_FTP_SCHEME "ftp://"
58 #define INET_HTTP_SCHEME "http://"
59 #define INET_HTTPS_SCHEME "https://"
60 #define INET_FILE_SCHEME "file://"
61 #define INET_GOPHER_SCHEME "gopher://"
62 #define INET_MAILTO_SCHEME "mailto:"
63 #define INET_CID_SCHEME "cid:"
64 #define INET_NEWS_SCHEME "news:"
65 #define INET_POP3_SCHEME "pop3://"
66 #define INET_LDAP_SCHEME "ldap://"
67 #define INET_PRIVATE_SCHEME "private:"
68 #define INET_BUGDOC_SCHEME "bugdoc:"
69 #define INET_SLOT_SCHEME "slot:"
70 #define INET_MACRO_SCHEME "macro:"
71 #define INET_JAVASCRIPT_SCHEME "javascript:"
72 #define INET_IMAP_SCHEME "imap://"
73 #define INET_DOWNPASS_SCHEME ".."
74 #define INET_DATA_SCHEME "data:"
75 #define INET_OUT_SCHEME "out://"
76 #define INET_FIF_SCHEME "fif://"
77 #define INET_CEPT_SCHEME "cept://"
78 #define INET_VIM_SCHEME "vim://"
79 #define INET_UNO_SCHEME ".uno:"
80 #define INET_COMPONENT_SCHEME ".component:"
81 #define INET_DB_SCHEME "db:"
82 #define INET_BUGID_SCHEME "bugid:"
83 #define INET_TELNET_SCHEME "telnet://"
84 #define INET_HID_SCHEME "hid:"
85 
86 #define URL_PREFIX_PRIV_SOFFICE "private:"
87 enum
88 {
89 	URL_PREFIX_PRIV_SOFFICE_LEN
90 	    = RTL_CONSTASCII_LENGTH(URL_PREFIX_PRIV_SOFFICE)
91 };
92 
93 #define URL_PREFIX_PRIV_OBSOLETE URL_PREFIX_PRIV_SOFFICE
94 enum
95 {
96 	URL_PREFIX_PRIV_OBSOLETE_LEN
97 	    = RTL_CONSTASCII_LENGTH(URL_PREFIX_PRIV_OBSOLETE)
98 };
99 
100 #define URL_PREFIX_PRIV_EXTERN "staroffice:"
101 enum
102 {
103 	URL_PREFIX_PRIV_EXTERN_LEN = RTL_CONSTASCII_LENGTH(URL_PREFIX_PRIV_EXTERN)
104 };
105 
106 //============================================================================
107 // Schemes:
108 enum INetProtocol
109 {
110 	INET_PROT_NOT_VALID = 0,
111 	INET_PROT_FTP = 1,
112 	INET_PROT_HTTP = 2,
113 	INET_PROT_FILE = 3,
114 	INET_PROT_MAILTO = 4,
115 	INET_PROT_VND_SUN_STAR_WEBDAV = 5,
116 	INET_PROT_NEWS = 6,
117 	INET_PROT_PRIV_SOFFICE = 7,
118 	INET_PROT_PRIVATE = INET_PROT_PRIV_SOFFICE, // obsolete
119 	INET_PROT_VND_SUN_STAR_HELP = 8,
120 	INET_PROT_HTTPS = 9,
121 	INET_PROT_SLOT = 10,
122 	INET_PROT_MACRO = 11,
123 	INET_PROT_JAVASCRIPT = 12,
124 	INET_PROT_IMAP = 13,
125 	INET_PROT_POP3 = 14,
126 	INET_PROT_DATA = 15,
127 	INET_PROT_CID = 16,
128 	INET_PROT_OUT = 17,
129 	INET_PROT_VND_SUN_STAR_HIER = 18,
130 	INET_PROT_VIM = 19,
131 	INET_PROT_UNO = 20,
132 	INET_PROT_COMPONENT = 21,
133 	INET_PROT_VND_SUN_STAR_PKG = 22,
134 	INET_PROT_LDAP = 23,
135 	INET_PROT_DB = 24,
136 	INET_PROT_VND_SUN_STAR_CMD = 25,
137 	INET_PROT_VND_SUN_STAR_ODMA = 26,
138     INET_PROT_TELNET = 27,
139     INET_PROT_VND_SUN_STAR_EXPAND = 28,
140     INET_PROT_VND_SUN_STAR_TDOC = 29,
141     INET_PROT_GENERIC = 30,
142     INET_PROT_SMB = 31,
143 	INET_PROT_HID = 32,
144 	INET_PROT_END = 33
145 };
146 
147 //============================================================================
148 class TOOLS_DLLPUBLIC INetURLObject
149 {
150 public:
151 	//========================================================================
152 	// Get- and Set-Methods:
153 
154 	/** The way input strings that represent (parts of) URIs are interpreted
155 		in set-methods.
156 
157 		@descr  Most set-methods accept either a ByteString or a rtl::OUString
158 		as input.  Using a ByteString, octets in the range 0x80--0xFF are
159 		replaced by single escape sequences.  Using a rtl::OUString , UTF-32
160 		characters in the range 0x80--0x10FFFF are replaced by sequences of
161 		escape sequences, representing the UTF-8 coded characters.
162 
163 		@descr  Along with an EncodeMechanism parameter, the set-methods all
164 		take an rtl_TextEncoding parameter, which is ignored unless the
165 		EncodeMechanism is WAS_ENCODED.
166 	 */
167 	enum EncodeMechanism
168 	{
169 		/** All escape sequences that are already present are ignored, and are
170 			interpreted as literal sequences of three characters.
171 		 */
172 		ENCODE_ALL,
173 
174 		/** Sequences of escape sequences, that represent characters from the
175 			specified character set and that can be converted to UTF-32
176 			characters, are first decoded.  If they have to be encoded, they
177 			are converted to UTF-8 characters and are than translated into
178 			(sequences of) escape sequences.  Other escape sequences are
179 			copied verbatim (but using upper case hex digits).
180 		 */
181 		WAS_ENCODED,
182 
183 		/** All escape sequences that are already present are copied verbatim
184 			(but using upper case hex digits).
185 		 */
186 		NOT_CANONIC
187 	};
188 
189 	/** The way strings that represent (parts of) URIs are returned from get-
190 		methods.
191 
192 		@descr  Along with a DecodeMechanism parameter, the get-methods all
193 		take an rtl_TextEncoding parameter, which is ignored unless the
194 		DecodeMechanism is DECODE_WITH_CHARSET or DECODE_UNAMBIGUOUS.
195 	 */
196 	enum DecodeMechanism
197 	{
198 		/** The (part of the) URI is returned unchanged.  Since URIs are
199 			written using a subset of US-ASCII, the returned string is
200 			guaranteed to contain only US-ASCII characters.
201 		 */
202 		NO_DECODE,
203 
204 		/** All sequences of escape sequences that represent UTF-8 coded
205 			UTF-32 characters with a numerical value greater than 0x7F, are
206 			replaced by the respective UTF-16 characters.  All other escape
207 			sequences are not decoded.
208 		 */
209 		DECODE_TO_IURI,
210 
211 		/** All (sequences of) escape sequences that represent characters from
212 			the specified character set, and that can be converted to UTF-32,
213 			are replaced by the respective UTF-16 characters.  All other
214 			escape sequences are not decoded.
215 		 */
216 		DECODE_WITH_CHARSET,
217 
218 		/** All (sequences of) escape sequences that represent characters from
219 			the specified character set, that can be converted to UTF-32, and
220 			that (in the case of ASCII characters) can safely be decoded
221 			without altering the meaning of the (part of the) URI, are
222 			replaced by the respective UTF-16 characters.  All other escape
223 			sequences are not decoded.
224 		 */
225 		DECODE_UNAMBIGUOUS
226 	};
227 
228 	//========================================================================
229 	// General Structure:
230 
231 	inline INetURLObject():
232 		m_eScheme(INET_PROT_NOT_VALID), m_eSmartScheme(INET_PROT_HTTP) {}
233 
234 	inline bool HasError() const { return m_eScheme == INET_PROT_NOT_VALID; }
235 
236 	inline rtl::OUString GetMainURL(DecodeMechanism eMechanism,
237 								rtl_TextEncoding eCharset
238 								    = RTL_TEXTENCODING_UTF8) const
239 	{ return decode(m_aAbsURIRef, getEscapePrefix(), eMechanism, eCharset); }
240 
241 	rtl::OUString GetURLNoPass(DecodeMechanism eMechanism = DECODE_TO_IURI,
242 						   rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
243 		const;
244 
245 	rtl::OUString GetURLNoMark(DecodeMechanism eMechanism = DECODE_TO_IURI,
246 						   rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
247 		const;
248 
249     rtl::OUString
250     getAbbreviated(com::sun::star::uno::Reference<
251                            com::sun::star::util::XStringWidth > const &
252                        rStringWidth,
253                    sal_Int32 nWidth,
254                    DecodeMechanism eMechanism = DECODE_TO_IURI,
255                    rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
256 		const;
257 
258 	bool operator ==(INetURLObject const & rObject) const;
259 
260 	inline bool operator !=(INetURLObject const & rObject) const
261 	{ return !(*this == rObject); }
262 
263 	bool operator <(INetURLObject const & rObject) const;
264 
265 	inline bool operator >(INetURLObject const & rObject) const
266 	{ return rObject < *this; }
267 
268 	//========================================================================
269 	// Strict Parsing:
270 
271 	inline INetURLObject(ByteString const & rTheAbsURIRef,
272 						 EncodeMechanism eMechanism = WAS_ENCODED,
273 						 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
274 
275 	inline INetURLObject(rtl::OUString const & rTheAbsURIRef,
276 						 EncodeMechanism eMechanism = WAS_ENCODED,
277 						 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
278 
279 	inline bool SetURL(ByteString const & rTheAbsURIRef,
280 					   EncodeMechanism eMechanism = WAS_ENCODED,
281 					   rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
282 
283 	inline bool SetURL(rtl::OUString const & rTheAbsURIRef,
284 					   EncodeMechanism eMechanism = WAS_ENCODED,
285 					   rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
286 
287 	bool ConcatData(INetProtocol eTheScheme, rtl::OUString const & rTheUser,
288 					rtl::OUString const & rThePassword,
289 					rtl::OUString const & rTheHost, sal_uInt32 nThePort,
290 					rtl::OUString const & rThePath,
291 					EncodeMechanism eMechanism = WAS_ENCODED,
292 					rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
293 
294 	//========================================================================
295 	// Smart Parsing:
296 
297 	/** The supported notations for file system paths.
298 	 */
299 	enum FSysStyle
300 	{
301 		/** VOS notation (e.g., "//server/dir/file").
302 		 */
303 		FSYS_VOS = 0x1,
304 
305 		/** Unix notation (e.g., "/dir/file").
306 		 */
307 		FSYS_UNX = 0x2,
308 
309 		/** DOS notation (e.g., "a:\dir\file" and "\\server\dir\file").
310 		 */
311 		FSYS_DOS = 0x4,
312 
313 		/** Mac notation (e.g., "dir:file").
314 		 */
315 		FSYS_MAC = 0x8,
316 
317 		/** Detect the used notation.
318 
319 			@descr  For the following descriptions, please note that
320 			whereas FSYS_DEFAULT includes all style bits, combinations of only
321 			a few style bits are also possible, and are also described.
322 
323 			@descr  When used to translate a file system path to a file URL,
324 			the subset of the following productions for which the appropriate
325 			style bit is set are checked in order (using the conventions of
326 			RFC 2234, RFC 2396, and RFC 2732; UCS4 stands for any UCS4
327 			character):
328 
329 			 Production T1 (VOS local; FSYS_VOS only):
330 			    "//." ["/" *UCS4]
331 			  becomes
332 			    "file:///" *UCS4
333 
334 			 Production T2 (VOS host; FSYS_VOS only):
335 			    "//" [host] ["/" *UCS4]
336 			  becomes
337 			    "file://" host "/" *UCS4
338 
339 			 Production T3 (UNC; FSYS_DOS only):
340 			    "\\" [host] ["\" *UCS4]
341 			  becomes
342 			    "file://" host "/" *UCS4
343 			  replacing "\" by "/" within <*UCS4>
344 
345 			 Production T4 (Unix-like DOS; FSYS_DOS only):
346 			    ALPHA ":" ["/" *UCS4]
347 			  becomes
348 			    "file:///" ALPHA ":/" *UCS4
349 			  replacing "\" by "/" within <*UCS4>
350 
351 			 Production T5 (DOS; FSYS_DOS only):
352 			    ALPHA ":" ["\" *UCS4]
353 			  becomes
354 			    "file:///" ALPHA ":/" *UCS4
355 			  replacing "\" by "/" within <*UCS4>
356 
357 			 Production T6 (any):
358 			    *UCS4
359 			  becomes
360 			    "file:///" *UCS4
361 			  replacing the delimiter by "/" within <*UCS4>.  The delimiter is
362 			  that character from the set { "/", "\", ":" } which appears most
363 			  often in <*UCS4> (if FSYS_UNX is not among the style bits, "/"
364 			  is removed from the set; if FSYS_DOS is not among the style
365 			  bits, "\" is removed from the set; if FSYS_MAC is not among the
366 			  style bits, ":" is removed from the set).  If two or more
367 			  characters appear the same number of times, the character
368 			  mentioned first in that set is chosen.  If the first character
369 			  of <*UCS4> is the delimiter, that character is not copied.
370 
371 			@descr  When used to translate a file URL to a file system path,
372 			the following productions are checked in order (using the
373 			conventions of RFC 2234, RFC 2396, and RFC 2732):
374 
375 			 Production F1 (VOS; FSYS_VOS):
376 			    "file://" host "/" fpath ["#" fragment]
377 			  becomes
378 			    "//" host "/" fpath
379 
380 			 Production F2 (DOS; FSYS_DOS):
381 			    "file:///" ALPHA ":" ["/" fpath] ["#" fragment]
382 			  becomes
383 			    ALPHA ":" ["\" fpath]
384 			  replacing "/" by "\" in <fpath>
385 
386 			 Production F3 (Unix; FSYS_UNX):
387 			    "file:///" fpath ["#" fragment]
388 			  becomes
389 			    "/" fpath
390 		 */
391 		FSYS_DETECT = FSYS_VOS | FSYS_UNX | FSYS_DOS
392 	};
393 
394 	inline INetURLObject(rtl::OUString const & rTheAbsURIRef,
395 						 INetProtocol eTheSmartScheme,
396 						 EncodeMechanism eMechanism = WAS_ENCODED,
397 						 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8,
398 						 FSysStyle eStyle = FSYS_DETECT);
399 
400 	inline void SetSmartProtocol(INetProtocol eTheSmartScheme)
401 	{ m_eSmartScheme = eTheSmartScheme; }
402 
403 	inline bool
404 	SetSmartURL(ByteString const & rTheAbsURIRef,
405 				EncodeMechanism eMechanism = WAS_ENCODED,
406 				rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8,
407 				FSysStyle eStyle = FSYS_DETECT);
408 
409 	inline bool
410 	SetSmartURL(rtl::OUString const & rTheAbsURIRef,
411 				EncodeMechanism eMechanism = WAS_ENCODED,
412 				rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8,
413 				FSysStyle eStyle = FSYS_DETECT);
414 
415 	inline INetURLObject
416 	smartRel2Abs(ByteString const & rTheRelURIRef,
417 				 bool & rWasAbsolute,
418 				 bool bIgnoreFragment = false,
419 				 EncodeMechanism eMechanism = WAS_ENCODED,
420 				 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8,
421 				 bool bRelativeNonURIs = false,
422 				 FSysStyle eStyle = FSYS_DETECT) const;
423 
424 	inline INetURLObject
425 	smartRel2Abs(rtl::OUString const & rTheRelURIRef,
426 				 bool & rWasAbsolute,
427 				 bool bIgnoreFragment = false,
428 				 EncodeMechanism eMechanism = WAS_ENCODED,
429 				 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8,
430 				 bool bRelativeNonURIs = false,
431 				 FSysStyle eStyle = FSYS_DETECT) const;
432 
433 	//========================================================================
434 	// Relative URLs:
435 
436 	inline bool
437 	GetNewAbsURL(ByteString const & rTheRelURIRef,
438 				 INetURLObject * pTheAbsURIRef,
439 				 EncodeMechanism eMechanism = WAS_ENCODED,
440 				 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8,
441 				 FSysStyle eStyle = FSYS_DETECT, bool bIgnoreFragment = false)
442         const;
443 
444 	inline bool
445 	GetNewAbsURL(rtl::OUString const & rTheRelURIRef,
446 				 INetURLObject * pTheAbsURIRef,
447 				 EncodeMechanism eMechanism = WAS_ENCODED,
448 				 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8,
449 				 FSysStyle eStyle = FSYS_DETECT, bool bIgnoreFragment = false)
450         const;
451 
452 	/** @descr  If rTheRelURIRef cannot be converted to an absolute URL
453 		(because of syntactic reasons), either rTheRelURIRef or an empty
454 		string is returned:  If all of the parameters eEncodeMechanism,
455 		eDecodeMechanism and eCharset have their respective default values,
456 		then rTheRelURIRef is returned unmodified; otherwise, an empty string
457 		is returned.
458 	 */
459     static rtl::OUString
460     GetAbsURL(rtl::OUString const & rTheBaseURIRef,
461               rtl::OUString const & rTheRelURIRef,
462               bool bIgnoreFragment = false,
463               EncodeMechanism eEncodeMechanism = WAS_ENCODED,
464               DecodeMechanism eDecodeMechanism = DECODE_TO_IURI,
465               rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8,
466               FSysStyle eStyle = FSYS_DETECT);
467 
468 	static inline rtl::OUString
469 	GetRelURL(ByteString const & rTheBaseURIRef,
470 			  ByteString const & rTheAbsURIRef,
471 			  EncodeMechanism eEncodeMechanism = WAS_ENCODED,
472 			  DecodeMechanism eDecodeMechanism = DECODE_TO_IURI,
473 			  rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8,
474 			  FSysStyle eStyle = FSYS_DETECT);
475 
476 	static inline rtl::OUString
477 	GetRelURL(rtl::OUString const & rTheBaseURIRef,
478 			  rtl::OUString const & rTheAbsURIRef,
479 			  EncodeMechanism eEncodeMechanism = WAS_ENCODED,
480 			  DecodeMechanism eDecodeMechanism = DECODE_TO_IURI,
481 			  rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8,
482 			  FSysStyle eStyle = FSYS_DETECT);
483 
484 	//========================================================================
485 	// External URLs:
486 
487 	rtl::OUString getExternalURL(DecodeMechanism eMechanism = DECODE_TO_IURI,
488 							 rtl_TextEncoding eCharset
489 							     = RTL_TEXTENCODING_UTF8) const;
490 
491 	static inline bool translateToExternal(ByteString const & rTheIntURIRef,
492 										   rtl::OUString & rTheExtURIRef,
493 										   DecodeMechanism eDecodeMechanism
494 										       = DECODE_TO_IURI,
495 										   rtl_TextEncoding eCharset
496 										       = RTL_TEXTENCODING_UTF8);
497 
498 	static inline bool translateToExternal(rtl::OUString const & rTheIntURIRef,
499 										   rtl::OUString & rTheExtURIRef,
500 										   DecodeMechanism eDecodeMechanism
501 										       = DECODE_TO_IURI,
502 										   rtl_TextEncoding eCharset
503 										       = RTL_TEXTENCODING_UTF8);
504 
505 	static inline bool translateToInternal(ByteString const & rTheExtURIRef,
506 										   rtl::OUString & rTheIntURIRef,
507 										   DecodeMechanism eDecodeMechanism
508 										       = DECODE_TO_IURI,
509 										   rtl_TextEncoding eCharset
510 										       = RTL_TEXTENCODING_UTF8);
511 
512     static inline bool translateToInternal(rtl::OUString const & rTheExtURIRef,
513                                            rtl::OUString & rTheIntURIRef,
514                                            DecodeMechanism eDecodeMechanism
515                                                = DECODE_TO_IURI,
516                                            rtl_TextEncoding eCharset
517                                                = RTL_TEXTENCODING_UTF8);
518 
519 	//========================================================================
520 	// Scheme:
521 
522 	struct SchemeInfo;
523 
524 	inline INetProtocol GetProtocol() const { return m_eScheme; }
525 
526 	/** Return the URL 'prefix' for a given scheme.
527 
528 		@param eTheScheme  One of the supported URL schemes.
529 
530 		@return  The 'prefix' of URLs of the given scheme.
531 	 */
532 	static rtl::OUString GetScheme(INetProtocol eTheScheme);
533 
534 	static inline INetProtocol CompareProtocolScheme(ByteString const &
535 													     rTheAbsURIRef)
536 	{ return CompareProtocolScheme(extend(rTheAbsURIRef)); }
537 
538 	static INetProtocol CompareProtocolScheme(rtl::OUString const &
539 											      rTheAbsURIRef);
540 
541 	//========================================================================
542 	// User Info:
543 
544 	inline bool HasUserData() const { return m_aUser.isPresent(); }
545 
546 	inline bool IsEmptyUser() const
547 	{ return m_aUser.isPresent() && m_aUser.isEmpty(); }
548 
549 	bool hasPassword() const;
550 
551 	inline bool IsEmptyPass() const
552 	{ return hasPassword() && m_aAuth.isEmpty(); }
553 
554 	inline rtl::OUString GetUser(DecodeMechanism eMechanism = DECODE_TO_IURI,
555 							 rtl_TextEncoding eCharset
556 							     = RTL_TEXTENCODING_UTF8) const
557 	{ return decode(m_aUser, getEscapePrefix(), eMechanism, eCharset); }
558 
559 	inline rtl::OUString GetPass(DecodeMechanism eMechanism = DECODE_TO_IURI,
560 							 rtl_TextEncoding eCharset
561 							     = RTL_TEXTENCODING_UTF8) const
562 	{ return decode(m_aAuth, getEscapePrefix(), eMechanism, eCharset); }
563 
564 	inline bool SetUser(ByteString const & rTheUser,
565 						EncodeMechanism eMechanism = WAS_ENCODED,
566 						rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
567 	{ return setUser(extend(rTheUser), true, eMechanism, eCharset); }
568 
569 	inline bool SetUser(rtl::OUString const & rTheUser,
570 						EncodeMechanism eMechanism = WAS_ENCODED,
571 						rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
572 	{ return setUser(rTheUser, false, eMechanism, eCharset); }
573 
574 	void makeAuthCanonic();
575 
576 	inline bool SetPass(ByteString const & rThePassword,
577 						EncodeMechanism eMechanism = WAS_ENCODED,
578 						rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
579 
580 	inline bool SetPass(rtl::OUString const & rThePassword,
581 						EncodeMechanism eMechanism = WAS_ENCODED,
582 						rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
583 
584 	inline bool SetUserAndPass(ByteString const & rTheUser,
585 							   ByteString const & rThePassword,
586 							   EncodeMechanism eMechanism = WAS_ENCODED,
587 							   rtl_TextEncoding eCharset
588 							       = RTL_TEXTENCODING_UTF8);
589 
590 	inline bool SetUserAndPass(rtl::OUString const & rTheUser,
591 							   rtl::OUString const & rThePassword,
592 							   EncodeMechanism eMechanism = WAS_ENCODED,
593 							   rtl_TextEncoding eCharset
594 							       = RTL_TEXTENCODING_UTF8);
595 
596 	//========================================================================
597 	// Host and Port:
598 
599 	inline bool HasPort() const { return m_aPort.isPresent(); }
600 
601 	inline rtl::OUString GetHost(DecodeMechanism eMechanism = DECODE_TO_IURI,
602 							 rtl_TextEncoding eCharset
603 							     = RTL_TEXTENCODING_UTF8) const
604 	{ return decode(m_aHost, getEscapePrefix(), eMechanism, eCharset); }
605 
606 	rtl::OUString GetHostPort(DecodeMechanism eMechanism = DECODE_TO_IURI,
607 						  rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
608 
609 	sal_uInt32 GetPort() const;
610 
611 	inline bool SetHost(ByteString const & rTheHost,
612 						EncodeMechanism eMechanism = WAS_ENCODED,
613 						rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
614 	{ return setHost(extend(rTheHost), true, eMechanism, eCharset); }
615 
616 	inline bool SetHost(rtl::OUString const & rTheHost,
617 						EncodeMechanism eMechanism = WAS_ENCODED,
618 						rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
619 	{ return setHost(rTheHost, false, eMechanism, eCharset); }
620 
621 	bool SetPort(sal_uInt32 nThePort);
622 
623 	void makePortCanonic();
624 
625 	/** Encode the <hostport> part of a URL.
626 
627 		@ATT  Obsolete, because at the moment the <hostport> part of a URL may
628 		not contain any escape sequences anyway, and because this method does
629 		not inform the caller whether the given <hostport> part is legal.
630 
631 		@param rTheHostPort  The <hostport> part of a URL (for its
632 		interpretation, see the general discussion for set-methods).
633 
634 		@param eMechanism  See the general discussion for set-methods.
635 
636 		@param eCharset  See the general discussion for set-methods.
637 
638 		@return  The <hostport> part, encoded according to the given mechanism
639 		and charset ('forbidden' characters replaced by escape sequences).
640 	 */
641 	static inline rtl::OUString encodeHostPort(ByteString const & rTheHostPort,
642 										   EncodeMechanism eMechanism,
643 										   rtl_TextEncoding eCharset
644 										       = RTL_TEXTENCODING_UTF8);
645 
646 	/** Encode the <hostport> part of a URL.
647 
648 		@ATT  Obsolete, because at the moment the <hostport> part of a URL may
649 		not contain any escape sequences anyway, and because this method does
650 		not inform the caller whether the given <hostport> part is legal.
651 
652 		@param rTheHostPort  The <hostport> part of a URL (for its
653 		interpretation, see the general discussion for set-methods).
654 
655 		@param eMechanism  See the general discussion for set-methods.
656 
657 		@param eCharset  See the general discussion for set-methods.
658 
659 		@return  The <hostport> part, encoded according to the given mechanism
660 		and charset ('forbidden' characters replaced by escape sequences).
661 	 */
662 	static inline rtl::OUString encodeHostPort(rtl::OUString const & rTheHostPort,
663 										   EncodeMechanism eMechanism,
664 										   rtl_TextEncoding eCharset
665 										       = RTL_TEXTENCODING_UTF8)
666 	{ return encodeHostPort(rTheHostPort, false, eMechanism, eCharset); }
667 
668 	//========================================================================
669 	// Path:
670 
671 	inline bool HasURLPath() const { return !m_aPath.isEmpty(); }
672 
673 	inline rtl::OUString GetURLPath(DecodeMechanism eMechanism = DECODE_TO_IURI,
674 								rtl_TextEncoding eCharset
675 								    = RTL_TEXTENCODING_UTF8) const
676 	{ return decode(m_aPath, getEscapePrefix(), eMechanism, eCharset); }
677 
678 	inline bool SetURLPath(ByteString const & rThePath,
679 						   EncodeMechanism eMechanism = WAS_ENCODED,
680 						   rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
681 	{ return setPath(extend(rThePath), true, eMechanism, eCharset); }
682 
683 	inline bool SetURLPath(rtl::OUString const & rThePath,
684 						   EncodeMechanism eMechanism = WAS_ENCODED,
685 						   rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
686 	{ return setPath(rThePath, false, eMechanism, eCharset); }
687 
688 	//========================================================================
689 	// Hierarchical Path:
690 
691 	/** A constant to address the last segment in various methods dealing with
692 		hierarchical paths.
693 
694 		@descr  It is often more efficient to address the last segment using
695 		this constant, than to determine its ordinal value using
696 		getSegmentCount().
697 	 */
698 	enum { LAST_SEGMENT = -1 };
699 
700 	/** The number of segments in the hierarchical path.
701 
702 		@descr  Using RFC 2396 and RFC 2234, a hierarchical path is of the
703 		form
704 
705 		  hierarchical-path = 1*("/" segment)
706 
707 		  segment = name *(";" param)
708 
709 		  name = [base ["." extension]]
710 
711 		  base = 1*pchar
712 
713 		  extension = *<any pchar except ".">
714 
715 		  param = *pchar
716 
717 		@param bIgnoreFinalSlash  If true, a final slash at the end of the
718 		hierarchical path does not denote an empty segment, but is ignored.
719 
720 		@return  The number of segments in the hierarchical path.  If the path
721 		is not hierarchical, 0 is returned.
722 	 */
723 	sal_Int32 getSegmentCount(bool bIgnoreFinalSlash = true) const;
724 
725 	/** Remove a segment from the hierarchical path.
726 
727 		@param nIndex  The non-negative index of the segment, or LAST_SEGMENT
728 		if addressing the last segment.
729 
730 		@param bIgnoreFinalSlash  If true, a final slash at the end of the
731 		hierarchical path does not denote an empty segment, but is ignored.
732 
733 		@return  True if the segment has successfully been removed (and the
734 		resulting URI is still valid).  If the path is not hierarchical, or
735 		the specified segment does not exist, false is returned.  If false is
736 		returned, the object is not modified.
737 	 */
738 	bool removeSegment(sal_Int32 nIndex = LAST_SEGMENT,
739 					   bool bIgnoreFinalSlash = true);
740 
741 	/** Insert a new segment into the hierarchical path.
742 
743 		@param rTheName  The name part of the new segment.  The new segment
744 		will contain no parameters.
745 
746 		@param bAppendFinalSlash  If the new segment is appended at the end of
747 		the hierarchical path, this parameter specifies whether to add a final
748 		slash after it or not.
749 
750 		@param nIndex  The non-negative index of the segment before which
751 		to insert the new segment.  LAST_SEGMENT or an nIndex that equals
752 		getSegmentCount() inserts the new segment at the end of the
753 		hierarchical path.
754 
755 		@param bIgnoreFinalSlash  If true, a final slash at the end of the
756 		hierarchical path does not denote an empty segment, but is ignored.
757 
758 		@param eMechanism  See the general discussion for set-methods.
759 
760 		@param eCharset  See the general discussion for set-methods.
761 
762 		@return  True if the segment has successfully been inserted (and the
763 		resulting URI is still valid).  If the path is not hierarchical, or
764 		the specified place to insert the new segment does not exist, false is
765 		returned.  If false is returned, the object is not modified.
766 	 */
767 	inline bool insertName(rtl::OUString const & rTheName,
768 						   bool bAppendFinalSlash = false,
769 						   sal_Int32 nIndex = LAST_SEGMENT,
770 						   bool bIgnoreFinalSlash = true,
771 						   EncodeMechanism eMechanism = WAS_ENCODED,
772 						   rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
773 
774 	/** Get the name of a segment of the hierarchical path.
775 
776 		@param nIndex  The non-negative index of the segment, or LAST_SEGMENT
777 		if addressing the last segment.
778 
779 		@param bIgnoreFinalSlash  If true, a final slash at the end of the
780 		hierarchical path does not denote an empty segment, but is ignored.
781 
782 		@param eMechanism  See the general discussion for get-methods.
783 
784 		@param eCharset  See the general discussion for get-methods.
785 
786 		@return  The name part of the specified segment.  If the path is not
787 		hierarchical, or the specified segment does not exits, an empty string
788 		is returned.
789 	 */
790 	rtl::OUString getName(sal_Int32 nIndex = LAST_SEGMENT,
791 					  bool bIgnoreFinalSlash = true,
792 					  DecodeMechanism eMechanism = DECODE_TO_IURI,
793 					  rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
794 		const;
795 
796 	/** Set the name of a segment (preserving any parameters and any query or
797 		fragment part).
798 
799 		@param rTheName  The new name.
800 
801 		@param nIndex  The non-negative index of the segment, or LAST_SEGMENT
802 		if addressing the last segment.
803 
804 		@param bIgnoreFinalSlash  If true, a final slash at the end of the
805 		hierarchical path does not denote an empty segment, but is ignored.
806 
807 		@param eMechanism  See the general discussion for set-methods.
808 
809 		@param eCharset  See the general discussion for set-methods.
810 
811 		@return  True if the name has successfully been modified (and the
812 		resulting URI is still valid).  If the path is not hierarchical, or
813 		the specified segment does not exist, false is returned.  If false is
814 		returned, the object is not modified.
815 	 */
816 	bool setName(rtl::OUString const & rTheName,
817 				 sal_Int32 nIndex = LAST_SEGMENT,
818 				 bool bIgnoreFinalSlash = true,
819 				 EncodeMechanism eMechanism = WAS_ENCODED,
820 				 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
821 
822 	/** Get the base of the name of a segment.
823 
824 		@param nIndex  The non-negative index of the segment, or LAST_SEGMENT
825 		if addressing the last segment.
826 
827 		@param bIgnoreFinalSlash  If true, a final slash at the end of the
828 		hierarchical path does not denote an empty segment, but is ignored.
829 
830 		@param eMechanism  See the general discussion for get-methods.
831 
832 		@param eCharset  See the general discussion for get-methods.
833 
834 		@return  The base part of the specified segment.  If the path is
835 		not hierarchical, or the specified segment does not exits, an empty
836 		string is returned.
837 	 */
838 	rtl::OUString getBase(sal_Int32 nIndex = LAST_SEGMENT,
839 					  bool bIgnoreFinalSlash = true,
840 					  DecodeMechanism eMechanism = DECODE_TO_IURI,
841 					  rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
842 		const;
843 
844 	/** Set the base of the name of a segment (preserving the extension).
845 
846 		@param rTheBase  The new base.
847 
848 		@param nIndex  The non-negative index of the segment, or LAST_SEGMENT
849 		if addressing the last segment.
850 
851 		@param bIgnoreFinalSlash  If true, a final slash at the end of the
852 		hierarchical path does not denote an empty segment, but is ignored.
853 
854 		@param eMechanism  See the general discussion for set-methods.
855 
856 		@param eCharset  See the general discussion for set-methods.
857 
858 		@return  True if the base has successfully been modified (and the
859 		resulting URI is still valid).  If the path is not hierarchical, or
860 		the specified segment does not exist, false is returned.  If false is
861 		returned, the object is not modified.
862 	 */
863 	bool setBase(rtl::OUString const & rTheBase,
864 				 sal_Int32 nIndex = LAST_SEGMENT,
865 				 bool bIgnoreFinalSlash = true,
866 				 EncodeMechanism eMechanism = WAS_ENCODED,
867 				 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
868 
869 	/** Determine whether the name of a segment has an extension.
870 
871 		@param nIndex  The non-negative index of the segment, or LAST_SEGMENT
872 		if addressing the last segment.
873 
874 		@param bIgnoreFinalSlash  If true, a final slash at the end of the
875 		hierarchical path does not denote an empty segment, but is ignored.
876 
877 		@return  True if the name of the specified segment has an extension.
878 		If the path is not hierarchical, or the specified segment does not
879 		exist, false is returned.
880 	 */
881 	bool hasExtension(sal_Int32 nIndex = LAST_SEGMENT,
882 					  bool bIgnoreFinalSlash = true) const;
883 
884 	/** Get the extension of the name of a segment.
885 
886 		@param nIndex  The non-negative index of the segment, or LAST_SEGMENT
887 		if addressing the last segment.
888 
889 		@param bIgnoreFinalSlash  If true, a final slash at the end of the
890 		hierarchical path does not denote an empty segment, but is ignored.
891 
892 		@param eMechanism  See the general discussion for get-methods.
893 
894 		@param eCharset  See the general discussion for get-methods.
895 
896 		@return  The extension part of the specified segment.  If the path is
897 		not hierarchical, or the specified segment does not exits, an empty
898 		string is returned.
899 	 */
900 	rtl::OUString getExtension(sal_Int32 nIndex = LAST_SEGMENT,
901 						   bool bIgnoreFinalSlash = true,
902 						   DecodeMechanism eMechanism = DECODE_TO_IURI,
903 						   rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
904 		const;
905 
906 	/** Set the extension of the name of a segment (replacing an already
907 		existing extension).
908 
909 		@param rTheExtension  The new extension.
910 
911 		@param nIndex  The non-negative index of the segment, or LAST_SEGMENT
912 		if addressing the last segment.
913 
914 		@param bIgnoreFinalSlash  If true, a final slash at the end of the
915 		hierarchical path does not denote an empty segment, but is ignored.
916 
917 		@param eMechanism  See the general discussion for set-methods.
918 
919 		@param eCharset  See the general discussion for set-methods.
920 
921 		@return  True if the extension has successfully been modified (and the
922 		resulting URI is still valid).  If the path is not hierarchical, or
923 		the specified segment does not exist, false is returned.  If false is
924 		returned, the object is not modified.
925 	 */
926 	bool setExtension(rtl::OUString const & rTheExtension,
927 					  sal_Int32 nIndex = LAST_SEGMENT,
928 					  bool bIgnoreFinalSlash = true,
929 					  EncodeMechanism eMechanism = WAS_ENCODED,
930 					  rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
931 
932 	/** Remove the extension of the name of a segment.
933 
934 		@param nIndex  The non-negative index of the segment, or LAST_SEGMENT
935 		if addressing the last segment.
936 
937 		@param bIgnoreFinalSlash  If true, a final slash at the end of the
938 		hierarchical path does not denote an empty segment, but is ignored.
939 
940 		@return  True if the extension has successfully been removed (and the
941 		resulting URI is still valid), or if the name did not have an
942 		extension.  If the path is not hierarchical, or the specified segment
943 		does not exist, false is returned.  If false is returned, the object
944 		is not modified.
945 	 */
946 	bool removeExtension(sal_Int32 nIndex = LAST_SEGMENT,
947 						 bool bIgnoreFinalSlash = true);
948 
949 	/** Determine whether the hierarchical path ends in a final slash.
950 
951 		@return  True if the hierarchical path ends in a final slash.  If the
952 		path is not hierarchical, false is returned.
953 	 */
954 	bool hasFinalSlash() const;
955 
956 	/** Make the hierarchical path end in a final slash (if it does not
957 		already do so).
958 
959 		@return  True if a final slash has successfully been appended (and the
960 		resulting URI is still valid), or if the hierarchical path already
961 		ended in a final slash.  If the path is not hierarchical, false is
962 		returned.  If false is returned, the object is not modified.
963 	 */
964 	bool setFinalSlash();
965 
966 	/** Remove a final slash from the hierarchical path.
967 
968 		@return  True if a final slash has successfully been removed (and the
969 		resulting URI is still valid), or if the hierarchical path already did
970 		not end in a final slash.  If the path is not hierarchical, false is
971 		returned.  If false is returned, the object is not modified.
972 	 */
973 	bool removeFinalSlash();
974 
975 	//========================================================================
976 	// Query:
977 
978 	inline bool HasParam() const { return m_aQuery.isPresent(); }
979 
980 	inline rtl::OUString GetParam(DecodeMechanism eMechanism = DECODE_TO_IURI,
981 							  rtl_TextEncoding eCharset
982 							      = RTL_TEXTENCODING_UTF8) const
983 	{ return decode(m_aQuery, getEscapePrefix(), eMechanism, eCharset); }
984 
985 	inline bool SetParam(ByteString const & rTheQuery,
986 						 EncodeMechanism eMechanism = WAS_ENCODED,
987 						 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
988 
989 	inline bool SetParam(rtl::OUString const & rTheQuery,
990 						 EncodeMechanism eMechanism = WAS_ENCODED,
991 						 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
992 
993 	//========================================================================
994 	// Fragment:
995 
996 	inline bool HasMark() const { return m_aFragment.isPresent(); }
997 
998 	inline rtl::OUString GetMark(DecodeMechanism eMechanism = DECODE_TO_IURI,
999 							 rtl_TextEncoding eCharset
1000 							     = RTL_TEXTENCODING_UTF8) const
1001 	{ return decode(m_aFragment, getEscapePrefix(), eMechanism, eCharset); }
1002 
1003 	inline bool SetMark(ByteString const & rTheFragment,
1004 						EncodeMechanism eMechanism = WAS_ENCODED,
1005 						rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
1006 
1007 	inline bool SetMark(rtl::OUString const & rTheFragment,
1008 						EncodeMechanism eMechanism = WAS_ENCODED,
1009 						rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
1010 
1011 	static rtl::OUString createFragment(rtl::OUString const & rText);
1012 
1013 	//========================================================================
1014 	// File URLs:
1015 
1016 	/** Create an INetURLObject from a file system path.
1017 
1018 		@param rFSysPath  A file system path.  An URL is not allowed here!
1019 
1020 		@param eStyle  The notation of rFSysPath.
1021 	 */
1022 	inline INetURLObject(rtl::OUString const & rFSysPath, FSysStyle eStyle);
1023 
1024 	/** Set this INetURLObject to a file URL constructed from a file system
1025 		path.
1026 
1027 		@param rFSysPath  A file system path.  An URL is not allowed here!
1028 
1029 		@param eStyle  The notation of rFSysPath.
1030 
1031 		@return  True if this INetURLObject has successfully been changed.  If
1032 		false is returned, this INetURLObject has not been modified.
1033 	 */
1034 	bool setFSysPath(rtl::OUString const & rFSysPath, FSysStyle eStyle);
1035 
1036 	/** Return the file system path represented by a file URL (ignoring any
1037 		fragment part).
1038 
1039 		@param eStyle  The notation of the returned file system path.
1040 
1041 		@param pDelimiter  Upon successful return, this parameter can return
1042 		the character that is the 'main' delimiter within the returned file
1043 		system path (e.g., "/" for Unix, "\" for DOS, ":" for Mac).  This is
1044 		especially useful for routines that later try to shorten the returned
1045 		file system path at a 'good' position, e.g. to fit it into some
1046 		limited display space.
1047 
1048 		@return  The file system path represented by this file URL.  If this
1049 		file URL does not represent a file system path according to the
1050 		specified notation, or if this is not a file URL at all, an empty
1051 		string is returned.
1052 	 */
1053 	rtl::OUString getFSysPath(FSysStyle eStyle, sal_Unicode * pDelimiter = 0)
1054 		const;
1055 
1056 	//========================================================================
1057 	// POP3 and URLs:
1058 
1059 	bool HasMsgId() const;
1060 
1061 	rtl::OUString GetMsgId(DecodeMechanism eMechanism = DECODE_TO_IURI,
1062 					   rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
1063 		const;
1064 
1065 	//========================================================================
1066 	// Coding:
1067 
1068 	enum Part
1069 	{
1070 		PART_OBSOLETE_NORMAL = 0x001, // Obsolete, do not use!
1071 		PART_OBSOLETE_FILE = 0x002, // Obsolete, do not use!
1072 		PART_OBSOLETE_PARAM = 0x004, // Obsolete, do not use!
1073 		PART_USER_PASSWORD = 0x008,
1074 		PART_IMAP_ACHAR = 0x010,
1075 		PART_VIM = 0x020,
1076 		PART_HOST_EXTRA = 0x040,
1077 		PART_FPATH = 0x080,
1078 		PART_AUTHORITY = 0x100,
1079 		PART_PATH_SEGMENTS_EXTRA = 0x200,
1080 		PART_REL_SEGMENT_EXTRA = 0x400,
1081 		PART_URIC = 0x800,
1082 		PART_HTTP_PATH = 0x1000,
1083 		PART_FILE_SEGMENT_EXTRA = 0x2000, // Obsolete, do not use!
1084 		PART_MESSAGE_ID = 0x4000,
1085 		PART_MESSAGE_ID_PATH = 0x8000,
1086 		PART_MAILTO = 0x10000,
1087 		PART_PATH_BEFORE_QUERY = 0x20000,
1088 		PART_PCHAR = 0x40000,
1089 		PART_FRAGMENT = 0x80000, // Obsolete, do not use!
1090 		PART_VISIBLE = 0x100000,
1091 		PART_VISIBLE_NONSPECIAL = 0x200000,
1092 		PART_CREATEFRAGMENT = 0x400000,
1093 		PART_UNO_PARAM_VALUE = 0x800000,
1094 		PART_UNAMBIGUOUS = 0x1000000,
1095 		PART_URIC_NO_SLASH = 0x2000000,
1096         PART_HTTP_QUERY = 0x4000000, //TODO! unused?
1097         PART_NEWS_ARTICLE_LOCALPART = 0x8000000,
1098 		max_part = 0x80000000
1099 			// Do not use!  Only there to allow compatible changes in the
1100 			// future.
1101 	};
1102 
1103 	enum EscapeType
1104 	{
1105 		ESCAPE_NO,
1106 		ESCAPE_OCTET,
1107 		ESCAPE_UTF32
1108 	};
1109 
1110 	/** Encode some text as part of a URI.
1111 
1112 		@param rText  Some text (for its interpretation, see the general
1113 		discussion for set-methods).
1114 
1115 		@param ePart  The part says which characters are 'forbidden' and must
1116 		be encoded (replaced by escape sequences).  Characters outside the US-
1117 		ASCII range are always 'forbidden.'
1118 
1119 		@param cEscapePrefix  The first character in an escape sequence
1120 		(normally '%').
1121 
1122 		@param eMechanism  See the general discussion for set-methods.
1123 
1124 		@param eCharset  See the general discussion for set-methods.
1125 
1126 		@return  The encoded representation of the text ('forbidden'
1127 		characters replaced by escape sequences).
1128 	 */
1129 	static inline rtl::OUString encode(ByteString const & rText, Part ePart,
1130 								   sal_Char cEscapePrefix,
1131 								   EncodeMechanism eMechanism,
1132 								   rtl_TextEncoding eCharset
1133 								       = RTL_TEXTENCODING_UTF8);
1134 
1135 	/** Encode some text as part of a URI.
1136 
1137 		@param rText  Some text (for its interpretation, see the general
1138 		discussion for set-methods).
1139 
1140 		@param ePart  The part says which characters are 'forbidden' and must
1141 		be encoded (replaced by escape sequences).  Characters outside the US-
1142 		ASCII range are always 'forbidden.'
1143 
1144 		@param cEscapePrefix  The first character in an escape sequence
1145 		(normally '%').
1146 
1147 		@param eMechanism  See the general discussion for set-methods.
1148 
1149 		@param eCharset  See the general discussion for set-methods.
1150 
1151 		@return  The text, encoded according to the given mechanism and
1152 		charset ('forbidden' characters replaced by escape sequences).
1153 	 */
1154 	static inline rtl::OUString encode(rtl::OUString const & rText, Part ePart,
1155 								   sal_Char cEscapePrefix,
1156 								   EncodeMechanism eMechanism,
1157 								   rtl_TextEncoding eCharset
1158 								       = RTL_TEXTENCODING_UTF8);
1159 
1160 	/** Decode some text.
1161 
1162 		@param rText  Some (encoded) text.
1163 
1164 		@param cEscapePrefix  The first character in an escape sequence
1165 		(normally '%').
1166 
1167 		@param eMechanism  See the general discussion for get-methods.
1168 
1169 		@param eCharset  See the general discussion for get-methods.
1170 
1171 		@return  The text, decoded according to the given mechanism and
1172 		charset (escape sequences replaced by 'raw' characters).
1173 	 */
1174 	static inline rtl::OUString decode(rtl::OUString const & rText,
1175 								   sal_Char cEscapePrefix,
1176 								   DecodeMechanism eMechanism,
1177 								   rtl_TextEncoding eCharset
1178 								       = RTL_TEXTENCODING_UTF8);
1179 
1180 	static inline rtl::OUString decode(rtl::OUStringBuffer const & rText,
1181 								   sal_Char cEscapePrefix,
1182 								   DecodeMechanism eMechanism,
1183 								   rtl_TextEncoding eCharset
1184 								       = RTL_TEXTENCODING_UTF8);
1185 
1186 	static void appendUCS4Escape(rtl::OUStringBuffer & rTheText,
1187 								 sal_Char cEscapePrefix,
1188 								 sal_uInt32 nUCS4);
1189 
1190 	static void appendUCS4(rtl::OUStringBuffer & rTheText, sal_uInt32 nUCS4,
1191 						   EscapeType eEscapeType, bool bOctets, Part ePart,
1192 						   sal_Char cEscapePrefix, rtl_TextEncoding eCharset,
1193 						   bool bKeepVisibleEscapes);
1194 
1195 	static sal_uInt32 getUTF32(sal_Unicode const *& rBegin,
1196 							   sal_Unicode const * pEnd, bool bOctets,
1197 							   sal_Char cEscapePrefix,
1198 							   EncodeMechanism eMechanism,
1199 							   rtl_TextEncoding eCharset,
1200 							   EscapeType & rEscapeType);
1201 
1202 	//========================================================================
1203 	// Specialized helpers:
1204 
1205 	static sal_uInt32 scanDomain(sal_Unicode const *& rBegin,
1206 								 sal_Unicode const * pEnd,
1207 								 bool bEager = true);
1208 
1209 	//========================================================================
1210 	// OBSOLETE Hierarchical Path:
1211 
1212 	rtl::OUString GetPartBeforeLastName(DecodeMechanism eMechanism
1213 									    = DECODE_TO_IURI,
1214 									rtl_TextEncoding eCharset
1215 									    = RTL_TEXTENCODING_UTF8) const;
1216 
1217 	/** Get the last segment in the path.
1218 
1219 		@param eMechanism  See the general discussion for get-methods.
1220 
1221 		@param eCharset  See the general discussion for get-methods.
1222 
1223 		@return  For a hierarchical URL, the last segment (everything after
1224 		the last unencoded '/').  Not that this last segment may be empty.  If
1225 		the URL is not hierarchical, an empty string is returned.
1226 	 */
1227 	rtl::OUString GetLastName(DecodeMechanism eMechanism = DECODE_TO_IURI,
1228 						  rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
1229 		const;
1230 
1231 	/** Get the 'extension' of the last segment in the path.
1232 
1233 		@param eMechanism  See the general discussion for get-methods.
1234 
1235 		@param eCharset  See the general discussion for get-methods.
1236 
1237 		@return  For a hierarchical URL, everything after the first unencoded
1238 		'.' in the last segment of the path.  Note that this 'extension' may
1239 		be empty.  If the URL is not hierarchical, or if the last segment does
1240 		not contain an unencoded '.', an empty string is returned.
1241 	 */
1242 	rtl::OUString GetFileExtension(DecodeMechanism eMechanism = DECODE_TO_IURI,
1243 							   rtl_TextEncoding eCharset
1244 							       = RTL_TEXTENCODING_UTF8) const;
1245 
1246 	inline bool Append(ByteString const & rTheSegment,
1247 					   EncodeMechanism eMechanism = WAS_ENCODED,
1248 					   rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
1249 	{ return appendSegment(extend(rTheSegment), true, eMechanism, eCharset); }
1250 
1251 	inline bool Append(rtl::OUString const & rTheSegment,
1252 					   EncodeMechanism eMechanism = WAS_ENCODED,
1253 					   rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
1254 	{ return appendSegment(rTheSegment, false, eMechanism, eCharset); }
1255 
1256 	bool CutLastName();
1257 
1258 	//========================================================================
1259 	// OBSOLETE File URLs:
1260 
1261 	rtl::OUString PathToFileName() const;
1262 
1263 	rtl::OUString GetFull() const;
1264 
1265 	rtl::OUString GetPath() const;
1266 
1267 	void SetBase(rtl::OUString const & rTheBase);
1268 
1269 	rtl::OUString GetBase() const;
1270 
1271 	void SetName(rtl::OUString const & rTheName,
1272 				 EncodeMechanism eMechanism = WAS_ENCODED,
1273 				 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
1274 
1275 	inline rtl::OUString GetName(DecodeMechanism eMechanism = DECODE_TO_IURI,
1276 							 rtl_TextEncoding eCharset
1277 							     = RTL_TEXTENCODING_UTF8) const
1278 	{ return GetLastName(eMechanism, eCharset); }
1279 
1280 	rtl::OUString CutName(DecodeMechanism eMechanism = DECODE_TO_IURI,
1281 					  rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
1282 
1283 	void SetExtension(rtl::OUString const & rTheExtension,
1284 					  EncodeMechanism eMechanism = WAS_ENCODED,
1285 					  rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
1286 
1287 	inline rtl::OUString GetExtension(
1288 								  DecodeMechanism eMechanism = DECODE_TO_IURI,
1289 								  rtl_TextEncoding eCharset
1290 								      = RTL_TEXTENCODING_UTF8) const
1291 	{ return GetFileExtension(eMechanism, eCharset); }
1292 
1293 	rtl::OUString CutExtension(DecodeMechanism eMechanism = DECODE_TO_IURI,
1294 						   rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
1295 
1296 	bool IsCaseSensitive() const;
1297 
1298 	//========================================================================
1299 
1300 private:
1301 	// General Structure:
1302 
1303 	class SubString
1304 	{
1305 		sal_Int32 m_nBegin;
1306 		sal_Int32 m_nLength;
1307 
1308 	public:
1309 		explicit inline SubString(sal_Int32 nTheBegin = -1,
1310 								  sal_Int32 nTheLength = 0):
1311 			m_nBegin(nTheBegin), m_nLength(nTheLength) {}
1312 
1313 		inline bool isPresent() const { return m_nBegin != -1; }
1314 
1315 		inline bool isEmpty() const { return m_nLength == 0; }
1316 
1317 		inline sal_Int32 getBegin() const { return m_nBegin; }
1318 
1319 		inline sal_Int32 getLength() const { return m_nLength; }
1320 
1321 		inline sal_Int32 getEnd() const { return m_nBegin + m_nLength; }
1322 
1323 		inline sal_Int32 clear();
1324 
1325 		inline sal_Int32 set(rtl::OUStringBuffer & rString,
1326 						     rtl::OUString const & rSubString,
1327 						     sal_Int32 nTheBegin);
1328 
1329 		inline sal_Int32 set(rtl::OUString & rString,
1330 						     rtl::OUString const & rSubString);
1331 
1332 		inline sal_Int32 set(rtl::OUStringBuffer & rString,
1333 						     rtl::OUString const & rSubString);
1334 
1335 		inline void operator +=(sal_Int32 nDelta);
1336 
1337 		int compare(SubString const & rOther,
1338 			rtl::OUStringBuffer const & rThisString,
1339 			rtl::OUStringBuffer const & rOtherString) const;
1340 	};
1341 
1342 	rtl::OUStringBuffer m_aAbsURIRef;
1343 	SubString m_aScheme;
1344 	SubString m_aUser;
1345 	SubString m_aAuth;
1346 	SubString m_aHost;
1347 	SubString m_aPort;
1348 	SubString m_aPath;
1349 	SubString m_aQuery;
1350 	SubString m_aFragment;
1351 	INetProtocol m_eScheme;
1352 	INetProtocol m_eSmartScheme;
1353 
1354     TOOLS_DLLPRIVATE void setInvalid();
1355 
1356     bool setAbsURIRef(
1357         rtl::OUString const & rTheAbsURIRef, bool bOctets,
1358         EncodeMechanism eMechanism, rtl_TextEncoding eCharset, bool bSmart,
1359         FSysStyle eStyle);
1360 
1361     // Relative URLs:
1362 
1363     bool convertRelToAbs(
1364         rtl::OUString const & rTheRelURIRef, bool bOctets,
1365         INetURLObject & rTheAbsURIRef, bool & rWasAbsolute,
1366         EncodeMechanism eMechanism, rtl_TextEncoding eCharset,
1367         bool bIgnoreFragment, bool bSmart, bool bRelativeNonURIs,
1368         FSysStyle eStyle) const;
1369 
1370     bool convertAbsToRel(
1371         rtl::OUString const & rTheAbsURIRef, bool bOctets,
1372         rtl::OUString & rTheRelURIRef, EncodeMechanism eEncodeMechanism,
1373         DecodeMechanism eDecodeMechanism, rtl_TextEncoding eCharset,
1374         FSysStyle eStyle) const;
1375 
1376     // External URLs:
1377 
1378     static bool convertIntToExt(
1379         rtl::OUString const & rTheIntURIRef, bool bOctets,
1380         rtl::OUString & rTheExtURIRef, DecodeMechanism eDecodeMechanism,
1381         rtl_TextEncoding eCharset);
1382 
1383     static bool convertExtToInt(
1384         rtl::OUString const & rTheExtURIRef, bool bOctets,
1385         rtl::OUString & rTheIntURIRef, DecodeMechanism eDecodeMechanism,
1386         rtl_TextEncoding eCharset);
1387 
1388     // Scheme:
1389 
1390     struct PrefixInfo;
1391 
1392     TOOLS_DLLPRIVATE static inline SchemeInfo const & getSchemeInfo(
1393         INetProtocol eTheScheme);
1394 
1395     TOOLS_DLLPRIVATE inline SchemeInfo const & getSchemeInfo() const;
1396 
1397     TOOLS_DLLPRIVATE static PrefixInfo const * getPrefix(
1398         sal_Unicode const *& rBegin, sal_Unicode const * pEnd);
1399 
1400     // Authority:
1401 
1402     TOOLS_DLLPRIVATE sal_Int32 getAuthorityBegin() const;
1403 
1404     TOOLS_DLLPRIVATE SubString getAuthority() const;
1405 
1406     // User Info:
1407 
1408     bool setUser(
1409         rtl::OUString const & rTheUser, bool bOctets,
1410         EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
1411 
1412     bool clearPassword();
1413 
1414     bool setPassword(
1415         rtl::OUString const & rThePassword, bool bOctets,
1416         EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
1417 
1418     // Host and Port:
1419 
1420     TOOLS_DLLPRIVATE static bool parseHost(
1421         sal_Unicode const *& rBegin, sal_Unicode const * pEnd,
1422         rtl::OUString & rCanonic);
1423 
1424     TOOLS_DLLPRIVATE static bool parseHostOrNetBiosName(
1425         sal_Unicode const * pBegin, sal_Unicode const * pEnd, bool bOctets,
1426         EncodeMechanism eMechanism, rtl_TextEncoding eCharset,
1427         bool bNetBiosName, rtl::OUStringBuffer* pCanonic);
1428 
1429     static rtl::OUString encodeHostPort(
1430         rtl::OUString const & rTheHostPort, bool bOctets,
1431         EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
1432 
1433     bool setHost(
1434         rtl::OUString const & rTheHost, bool bOctets,
1435         EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
1436 
1437     // Path:
1438 
1439     TOOLS_DLLPRIVATE static bool parsePath(
1440         INetProtocol eScheme, sal_Unicode const ** pBegin,
1441         sal_Unicode const * pEnd, bool bOctets, EncodeMechanism eMechanism,
1442         rtl_TextEncoding eCharset, bool bSkippedInitialSlash,
1443         sal_uInt32 nSegmentDelimiter, sal_uInt32 nAltSegmentDelimiter,
1444         sal_uInt32 nQueryDelimiter, sal_uInt32 nFragmentDelimiter,
1445         rtl::OUStringBuffer &rSynPath);
1446 
1447     bool setPath(
1448         rtl::OUString const & rThePath, bool bOctets,
1449         EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
1450 
1451     // Hierarchical Path:
1452 
1453     TOOLS_DLLPRIVATE bool checkHierarchical() const;
1454 
1455     bool appendSegment(
1456         rtl::OUString const & rTheSegment, bool bOctets,
1457         EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
1458 
1459     TOOLS_DLLPRIVATE SubString getSegment(
1460         sal_Int32 nIndex, bool bIgnoreFinalSlash) const;
1461 
1462     bool insertName(
1463         rtl::OUString const & rTheName, bool bOctets, bool bAppendFinalSlash,
1464         sal_Int32 nIndex, bool bIgnoreFinalSlash, EncodeMechanism eMechanism,
1465         rtl_TextEncoding eCharset);
1466 
1467     // Query:
1468 
1469     bool clearQuery();
1470 
1471     bool setQuery(
1472         rtl::OUString const & rTheQuery, bool bOctets,
1473         EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
1474 
1475     // Fragment:
1476 
1477     bool clearFragment();
1478 
1479     bool setFragment(
1480         rtl::OUString const & rTheMark, bool bOctets,
1481         EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
1482 
1483     // FTP URLs:
1484 
1485     enum FTPType { FTP_TYPE_NONE, FTP_TYPE_A, FTP_TYPE_I, FTP_TYPE_D };
1486 
1487     TOOLS_DLLPRIVATE FTPType getFTPType() const;
1488 
1489     // FILE URLs:
1490 
1491     TOOLS_DLLPRIVATE bool hasDosVolume(FSysStyle eStyle) const;
1492 
1493     // IMAP URLs:
1494 
1495     TOOLS_DLLPRIVATE sal_uInt32 getIMAPUID() const;
1496 
1497     // Coding:
1498 
1499     static inline rtl::OUString extend(ByteString const & rOctets)
1500     {
1501         return rtl::OUString(rOctets.GetBuffer(), rOctets.Len(),
1502             RTL_TEXTENCODING_ISO_8859_1);
1503     }
1504 
1505     static inline sal_Char getEscapePrefix(INetProtocol eTheScheme)
1506     { return eTheScheme == INET_PROT_VIM ? '=' : '%'; }
1507 
1508     inline sal_Char getEscapePrefix() const
1509     { return getEscapePrefix(m_eScheme); }
1510 
1511     TOOLS_DLLPRIVATE static inline void appendEscape(
1512         rtl::OUStringBuffer & rTheText, sal_Char cEscapePrefix,
1513         sal_uInt32 nOctet);
1514 
1515     static rtl::OUString encodeText(
1516         sal_Unicode const * pBegin, sal_Unicode const * pEnd, bool bOctets,
1517         Part ePart, sal_Char cEscapePrefix, EncodeMechanism eMechanism,
1518         rtl_TextEncoding eCharset, bool bKeepVisibleEscapes);
1519 
1520     static inline rtl::OUString encodeText(
1521         rtl::OUString const & rTheText, bool bOctets, Part ePart,
1522         sal_Char cEscapePrefix, EncodeMechanism eMechanism,
1523         rtl_TextEncoding eCharset, bool bKeepVisibleEscapes);
1524 
1525     static rtl::OUString decode(
1526         sal_Unicode const * pBegin, sal_Unicode const * pEnd,
1527         sal_Char cEscapePrefix, DecodeMechanism, rtl_TextEncoding eCharset);
1528 
1529     inline rtl::OUString decode(
1530         SubString const & rSubString, sal_Char cEscapePrefix,
1531         DecodeMechanism eMechanism, rtl_TextEncoding eCharset) const;
1532 
1533     // Specialized helpers:
1534 
1535     TOOLS_DLLPRIVATE static bool scanIPv6reference(
1536         sal_Unicode const *& rBegin, sal_Unicode const * pEnd);
1537 };
1538 
1539 // static
1540 inline rtl::OUString INetURLObject::encodeText(rtl::OUString const & rTheText,
1541 										   bool bOctets, Part ePart,
1542 										   sal_Char cEscapePrefix,
1543 										   EncodeMechanism eMechanism,
1544 										   rtl_TextEncoding eCharset,
1545 										   bool bKeepVisibleEscapes)
1546 {
1547 	return encodeText(rTheText.getStr(),
1548 					  rTheText.getStr() + rTheText.getLength(), bOctets, ePart,
1549 					  cEscapePrefix, eMechanism, eCharset,
1550 					  bKeepVisibleEscapes);
1551 }
1552 
1553 inline rtl::OUString INetURLObject::decode(SubString const & rSubString,
1554 									   sal_Char cEscapePrefix,
1555 									   DecodeMechanism eMechanism,
1556 									   rtl_TextEncoding eCharset) const
1557 {
1558     return rSubString.isPresent() ?
1559                decode(m_aAbsURIRef.getStr() + rSubString.getBegin(),
1560                       m_aAbsURIRef.getStr() + rSubString.getEnd(),
1561                       cEscapePrefix, eMechanism, eCharset) :
1562                rtl::OUString();
1563 }
1564 
1565 inline INetURLObject::INetURLObject(ByteString const & rTheAbsURIRef,
1566 									EncodeMechanism eMechanism,
1567 									rtl_TextEncoding eCharset):
1568 	m_eScheme(INET_PROT_NOT_VALID), m_eSmartScheme(INET_PROT_HTTP)
1569 {
1570 	setAbsURIRef(extend(rTheAbsURIRef), true, eMechanism, eCharset, false,
1571 				 FSysStyle(0));
1572 }
1573 
1574 inline INetURLObject::INetURLObject(rtl::OUString const & rTheAbsURIRef,
1575 									EncodeMechanism eMechanism,
1576 									rtl_TextEncoding eCharset):
1577 	m_eScheme(INET_PROT_NOT_VALID), m_eSmartScheme(INET_PROT_HTTP)
1578 {
1579 	setAbsURIRef(rTheAbsURIRef, false, eMechanism, eCharset, false,
1580 				 FSysStyle(0));
1581 }
1582 
1583 inline bool INetURLObject::SetURL(ByteString const & rTheAbsURIRef,
1584 								  EncodeMechanism eMechanism,
1585 								  rtl_TextEncoding eCharset)
1586 {
1587 	return setAbsURIRef(extend(rTheAbsURIRef), true, eMechanism, eCharset,
1588 						false, FSysStyle(0));
1589 }
1590 
1591 inline bool INetURLObject::SetURL(rtl::OUString const & rTheAbsURIRef,
1592 								  EncodeMechanism eMechanism,
1593 								  rtl_TextEncoding eCharset)
1594 {
1595 	return setAbsURIRef(rTheAbsURIRef, false, eMechanism, eCharset, false,
1596 						FSysStyle(0));
1597 }
1598 
1599 inline INetURLObject::INetURLObject(rtl::OUString const & rTheAbsURIRef,
1600 									INetProtocol eTheSmartScheme,
1601 									EncodeMechanism eMechanism,
1602 									rtl_TextEncoding eCharset,
1603 									FSysStyle eStyle):
1604 	m_eScheme(INET_PROT_NOT_VALID), m_eSmartScheme(eTheSmartScheme)
1605 {
1606 	setAbsURIRef(rTheAbsURIRef, false, eMechanism, eCharset, true, eStyle);
1607 }
1608 
1609 inline bool INetURLObject::SetSmartURL(ByteString const & rTheAbsURIRef,
1610 									   EncodeMechanism eMechanism,
1611 									   rtl_TextEncoding eCharset,
1612 									   FSysStyle eStyle)
1613 {
1614 	return setAbsURIRef(extend(rTheAbsURIRef), true, eMechanism, eCharset,
1615 						true, eStyle);
1616 }
1617 
1618 inline bool INetURLObject::SetSmartURL(rtl::OUString const & rTheAbsURIRef,
1619 									   EncodeMechanism eMechanism,
1620 									   rtl_TextEncoding eCharset,
1621 									   FSysStyle eStyle)
1622 {
1623 	return setAbsURIRef(rTheAbsURIRef, false, eMechanism, eCharset, true,
1624 						eStyle);
1625 }
1626 
1627 inline INetURLObject
1628 INetURLObject::smartRel2Abs(ByteString const & rTheRelURIRef,
1629 							bool & rWasAbsolute,
1630 							bool bIgnoreFragment,
1631 							EncodeMechanism eMechanism,
1632 							rtl_TextEncoding eCharset,
1633 							bool bRelativeNonURIs,
1634 							FSysStyle eStyle) const
1635 {
1636 	INetURLObject aTheAbsURIRef;
1637 	convertRelToAbs(extend(rTheRelURIRef), true, aTheAbsURIRef, rWasAbsolute,
1638 					eMechanism, eCharset, bIgnoreFragment, true,
1639 					bRelativeNonURIs, eStyle);
1640 	return aTheAbsURIRef;
1641 }
1642 
1643 inline INetURLObject
1644 INetURLObject::smartRel2Abs(rtl::OUString const & rTheRelURIRef,
1645 							bool & rWasAbsolute,
1646 							bool bIgnoreFragment,
1647 							EncodeMechanism eMechanism,
1648 							rtl_TextEncoding eCharset,
1649 							bool bRelativeNonURIs,
1650 							FSysStyle eStyle) const
1651 {
1652 	INetURLObject aTheAbsURIRef;
1653 	convertRelToAbs(rTheRelURIRef, false, aTheAbsURIRef, rWasAbsolute,
1654 					eMechanism, eCharset, bIgnoreFragment, true,
1655 					bRelativeNonURIs, eStyle);
1656 	return aTheAbsURIRef;
1657 }
1658 
1659 inline bool INetURLObject::GetNewAbsURL(ByteString const & rTheRelURIRef,
1660 										INetURLObject * pTheAbsURIRef,
1661 										EncodeMechanism eMechanism,
1662 										rtl_TextEncoding eCharset,
1663 										FSysStyle eStyle, bool bIgnoreFragment)
1664     const
1665 {
1666 	INetURLObject aTheAbsURIRef;
1667 	bool bWasAbsolute;
1668 	if (!convertRelToAbs(extend(rTheRelURIRef), true, aTheAbsURIRef,
1669 						 bWasAbsolute, eMechanism, eCharset, bIgnoreFragment,
1670                          false, false, eStyle))
1671 		return false;
1672 	if (pTheAbsURIRef)
1673 		*pTheAbsURIRef = aTheAbsURIRef;
1674 	return true;
1675 }
1676 
1677 inline bool INetURLObject::GetNewAbsURL(rtl::OUString const & rTheRelURIRef,
1678 										INetURLObject * pTheAbsURIRef,
1679 										EncodeMechanism eMechanism,
1680 										rtl_TextEncoding eCharset,
1681 										FSysStyle eStyle, bool bIgnoreFragment)
1682     const
1683 {
1684 	INetURLObject aTheAbsURIRef;
1685 	bool bWasAbsolute;
1686 	if (!convertRelToAbs(rTheRelURIRef, false, aTheAbsURIRef, bWasAbsolute,
1687 						 eMechanism, eCharset, bIgnoreFragment, false, false,
1688                          eStyle))
1689 		return false;
1690 	if (pTheAbsURIRef)
1691 		*pTheAbsURIRef = aTheAbsURIRef;
1692 	return true;
1693 }
1694 
1695 // static
1696 inline rtl::OUString INetURLObject::GetRelURL(ByteString const & rTheBaseURIRef,
1697 										  ByteString const & rTheAbsURIRef,
1698 										  EncodeMechanism eEncodeMechanism,
1699 										  DecodeMechanism eDecodeMechanism,
1700 										  rtl_TextEncoding eCharset,
1701 										  FSysStyle eStyle)
1702 {
1703 	rtl::OUString aTheRelURIRef;
1704 	INetURLObject(rTheBaseURIRef, eEncodeMechanism, eCharset).
1705 		convertAbsToRel(extend(rTheAbsURIRef), true, aTheRelURIRef,
1706 						eEncodeMechanism, eDecodeMechanism, eCharset, eStyle);
1707 	return aTheRelURIRef;
1708 }
1709 
1710 // static
1711 inline rtl::OUString INetURLObject::GetRelURL(rtl::OUString const & rTheBaseURIRef,
1712 										  rtl::OUString const & rTheAbsURIRef,
1713 										  EncodeMechanism eEncodeMechanism,
1714 										  DecodeMechanism eDecodeMechanism,
1715 										  rtl_TextEncoding eCharset,
1716 										  FSysStyle eStyle)
1717 {
1718 	rtl::OUString aTheRelURIRef;
1719 	INetURLObject(rTheBaseURIRef, eEncodeMechanism, eCharset).
1720 		convertAbsToRel(rTheAbsURIRef, false, aTheRelURIRef, eEncodeMechanism,
1721 						eDecodeMechanism, eCharset, eStyle);
1722 	return aTheRelURIRef;
1723 }
1724 
1725 // static
1726 inline bool INetURLObject::translateToExternal(ByteString const &
1727 											       rTheIntURIRef,
1728 											   rtl::OUString & rTheExtURIRef,
1729 											   DecodeMechanism
1730 											       eDecodeMechanism,
1731 											   rtl_TextEncoding eCharset)
1732 {
1733 	rtl::OUString aTheExtURIRef;
1734 	bool bRet = convertIntToExt(extend(rTheIntURIRef), true, aTheExtURIRef,
1735                                 eDecodeMechanism, eCharset);
1736 	rTheExtURIRef = aTheExtURIRef;
1737 	return bRet;
1738 }
1739 
1740 // static
1741 inline bool INetURLObject::translateToExternal(rtl::OUString const &
1742 											       rTheIntURIRef,
1743 											   rtl::OUString & rTheExtURIRef,
1744 											   DecodeMechanism
1745 											       eDecodeMechanism,
1746 											   rtl_TextEncoding eCharset)
1747 {
1748 	return convertIntToExt(rTheIntURIRef, false, rTheExtURIRef,
1749 						   eDecodeMechanism, eCharset);
1750 }
1751 
1752 // static
1753 inline bool INetURLObject::translateToInternal(ByteString const &
1754 											       rTheExtURIRef,
1755 											   rtl::OUString & rTheIntURIRef,
1756 											   DecodeMechanism
1757 											       eDecodeMechanism,
1758 											   rtl_TextEncoding eCharset)
1759 {
1760 	rtl::OUString aTheIntURIRef;
1761 	bool bRet = convertExtToInt(extend(rTheExtURIRef), true, aTheIntURIRef,
1762 						   eDecodeMechanism, eCharset);
1763 	rTheIntURIRef = aTheIntURIRef;
1764 	return bRet;
1765 }
1766 
1767 // static
1768 inline bool INetURLObject::translateToInternal(rtl::OUString const &
1769                                                    rTheExtURIRef,
1770                                                rtl::OUString & rTheIntURIRef,
1771                                                DecodeMechanism
1772                                                    eDecodeMechanism,
1773                                                rtl_TextEncoding eCharset)
1774 {
1775     return convertExtToInt(rTheExtURIRef, false, rTheIntURIRef,
1776                            eDecodeMechanism, eCharset);
1777 }
1778 
1779 inline bool INetURLObject::SetPass(ByteString const & rThePassword,
1780 								   EncodeMechanism eMechanism,
1781 								   rtl_TextEncoding eCharset)
1782 {
1783 	return rThePassword.Len() == 0 ?
1784 		       clearPassword() :
1785 		       setPassword(extend(rThePassword), true, eMechanism, eCharset);
1786 }
1787 
1788 inline bool INetURLObject::SetPass(rtl::OUString const & rThePassword,
1789 								   EncodeMechanism eMechanism,
1790 								   rtl_TextEncoding eCharset)
1791 {
1792 	return rThePassword.getLength() == 0 ?
1793 		       clearPassword() :
1794 		       setPassword(rThePassword, false, eMechanism, eCharset);
1795 }
1796 
1797 inline bool INetURLObject::SetUserAndPass(ByteString const & rTheUser,
1798 										  ByteString const & rThePassword,
1799 										  EncodeMechanism eMechanism,
1800 										  rtl_TextEncoding eCharset)
1801 {
1802 	return setUser(extend(rTheUser), true, eMechanism, eCharset)
1803 		   && (rThePassword.Len() == 0 ?
1804 			       clearPassword() :
1805 			       setPassword(extend(rThePassword), true, eMechanism,
1806 							   eCharset));
1807 }
1808 
1809 inline bool INetURLObject::SetUserAndPass(rtl::OUString const & rTheUser,
1810 										  rtl::OUString const & rThePassword,
1811 										  EncodeMechanism eMechanism,
1812 										  rtl_TextEncoding eCharset)
1813 {
1814 	return setUser(rTheUser, false, eMechanism, eCharset)
1815 		   && (rThePassword.getLength() == 0 ?
1816 			       clearPassword() :
1817 			       setPassword(rThePassword, false, eMechanism, eCharset));
1818 }
1819 
1820 // static
1821 inline rtl::OUString INetURLObject::encodeHostPort(ByteString const &
1822 											       rTheHostPort,
1823 											   EncodeMechanism eMechanism,
1824 											   rtl_TextEncoding eCharset)
1825 {
1826 	return encodeHostPort(extend(rTheHostPort), true, eMechanism, eCharset);
1827 }
1828 
1829 inline bool INetURLObject::insertName(rtl::OUString const & rTheName,
1830 									  bool bAppendFinalSlash,
1831 									  sal_Int32 nIndex,
1832 									  bool bIgnoreFinalSlash,
1833 									  EncodeMechanism eMechanism,
1834 									  rtl_TextEncoding eCharset)
1835 {
1836 	return insertName(rTheName, false, bAppendFinalSlash, nIndex,
1837 					  bIgnoreFinalSlash, eMechanism, eCharset);
1838 }
1839 
1840 inline bool INetURLObject::SetParam(ByteString const & rTheQuery,
1841 									EncodeMechanism eMechanism,
1842 									rtl_TextEncoding eCharset)
1843 {
1844 	return rTheQuery.Len() == 0 ?
1845 		       clearQuery() :
1846 		       setQuery(extend(rTheQuery), true, eMechanism, eCharset);
1847 }
1848 
1849 inline bool INetURLObject::SetParam(rtl::OUString const & rTheQuery,
1850 									EncodeMechanism eMechanism,
1851 									rtl_TextEncoding eCharset)
1852 {
1853 	return rTheQuery.getLength() == 0 ?
1854 		       clearQuery() :
1855 		       setQuery(rTheQuery, false, eMechanism, eCharset);
1856 }
1857 
1858 inline bool INetURLObject::SetMark(ByteString const & rTheFragment,
1859 								   EncodeMechanism eMechanism,
1860 								   rtl_TextEncoding eCharset)
1861 {
1862 	return rTheFragment.Len() == 0 ?
1863 		       clearFragment() :
1864 		       setFragment(extend(rTheFragment), true, eMechanism, eCharset);
1865 }
1866 
1867 inline bool INetURLObject::SetMark(rtl::OUString const & rTheFragment,
1868 								   EncodeMechanism eMechanism,
1869 								   rtl_TextEncoding eCharset)
1870 {
1871 	return rTheFragment.getLength() == 0 ?
1872 		       clearFragment() :
1873 		       setFragment(rTheFragment, false, eMechanism, eCharset);
1874 }
1875 
1876 inline INetURLObject::INetURLObject(rtl::OUString const & rFSysPath,
1877 									FSysStyle eStyle):
1878 	m_eScheme(INET_PROT_NOT_VALID), m_eSmartScheme(INET_PROT_HTTP)
1879 {
1880 	setFSysPath(rFSysPath, eStyle);
1881 }
1882 
1883 // static
1884 inline rtl::OUString INetURLObject::encode(ByteString const & rText, Part ePart,
1885 									   sal_Char cEscapePrefix,
1886 									   EncodeMechanism eMechanism,
1887 									   rtl_TextEncoding eCharset)
1888 {
1889 	return encodeText(extend(rText), true, ePart, cEscapePrefix, eMechanism,
1890 					  eCharset, false);
1891 }
1892 
1893 // static
1894 inline rtl::OUString INetURLObject::encode(rtl::OUString const & rText, Part ePart,
1895 									   sal_Char cEscapePrefix,
1896 									   EncodeMechanism eMechanism,
1897 									   rtl_TextEncoding eCharset)
1898 {
1899 	return encodeText(rText, false, ePart, cEscapePrefix, eMechanism,
1900 					  eCharset, false);
1901 }
1902 
1903 // static
1904 inline rtl::OUString INetURLObject::decode(rtl::OUString const & rText,
1905 									   sal_Char cEscapePrefix,
1906 									   DecodeMechanism eMechanism,
1907 									   rtl_TextEncoding eCharset)
1908 {
1909 	return decode(rText.getStr(), rText.getStr() + rText.getLength(),
1910 				  cEscapePrefix, eMechanism, eCharset);
1911 }
1912 
1913 inline rtl::OUString INetURLObject::decode(rtl::OUStringBuffer const & rText,
1914 									   sal_Char cEscapePrefix,
1915 									   DecodeMechanism eMechanism,
1916 									   rtl_TextEncoding eCharset)
1917 {
1918 	return decode(rText.getStr(), rText.getStr() + rText.getLength(),
1919 				  cEscapePrefix, eMechanism, eCharset);
1920 }
1921 
1922 #endif // _URLOBJ_HXX
1923