Branch libreoffice-5-0-4
[LibreOffice.git] / include / tools / urlobj.hxx
blobf138514bded9f0ed55dfbfdfce120aa79b22989f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_TOOLS_URLOBJ_HXX
20 #define INCLUDED_TOOLS_URLOBJ_HXX
22 #include <tools/toolsdllapi.h>
23 #include <com/sun/star/uno/Reference.hxx>
24 #include <rtl/string.h>
25 #include <rtl/ustrbuf.hxx>
26 #include <rtl/textenc.h>
27 #include <sal/types.h>
29 #include <memory>
31 class SvMemoryStream;
33 namespace com { namespace sun { namespace star { namespace util {
34 class XStringWidth;
35 } } } }
37 // Common URL prefixes for various schemes:
38 #define INET_FTP_SCHEME "ftp://"
39 #define INET_HTTP_SCHEME "http://"
40 #define INET_HTTPS_SCHEME "https://"
41 #define INET_FILE_SCHEME "file://"
42 #define INET_MAILTO_SCHEME "mailto:"
43 #define INET_HID_SCHEME "hid:"
45 #define URL_PREFIX_PRIV_SOFFICE "private:"
46 enum
48 URL_PREFIX_PRIV_SOFFICE_LEN
49 = RTL_CONSTASCII_LENGTH(URL_PREFIX_PRIV_SOFFICE)
52 #define URL_PREFIX_PRIV_OBSOLETE URL_PREFIX_PRIV_SOFFICE
53 enum
55 URL_PREFIX_PRIV_OBSOLETE_LEN
56 = RTL_CONSTASCII_LENGTH(URL_PREFIX_PRIV_OBSOLETE)
59 #define URL_PREFIX_PRIV_EXTERN "staroffice:"
60 enum
62 URL_PREFIX_PRIV_EXTERN_LEN = RTL_CONSTASCII_LENGTH(URL_PREFIX_PRIV_EXTERN)
65 // Schemes:
66 enum class INetProtocol
68 NotValid,
69 Ftp,
70 Http,
71 File,
72 Mailto,
73 VndSunStarWebdav,
74 PrivSoffice,
75 VndSunStarHelp,
76 Https,
77 Slot,
78 Macro,
79 Javascript,
80 Data,
81 Cid,
82 VndSunStarHier,
83 Uno,
84 Component,
85 VndSunStarPkg,
86 Ldap,
87 Db,
88 VndSunStarCmd,
89 Telnet,
90 VndSunStarExpand,
91 VndSunStarTdoc,
92 Generic,
93 Smb,
94 Hid,
95 Sftp,
96 Cmis,
97 LAST = Cmis
100 class TOOLS_DLLPUBLIC SAL_WARN_UNUSED INetURLObject
102 public:
103 // Get- and Set-Methods:
105 /** The way input strings that represent (parts of) URIs are interpreted
106 in set-methods.
108 @descr UTF-32 characters in the range 0x80--0x10FFFF are replaced by
109 sequences of escape sequences, representing the UTF-8 coded characters.
111 @descr Along with an EncodeMechanism parameter, the set-methods all
112 take an rtl_TextEncoding parameter, which is ignored unless the
113 EncodeMechanism is WAS_ENCODED.
115 enum EncodeMechanism
117 /** All escape sequences that are already present are ignored, and are
118 interpreted as literal sequences of three characters.
120 ENCODE_ALL,
122 /** Sequences of escape sequences, that represent characters from the
123 specified character set and that can be converted to UTF-32
124 characters, are first decoded. If they have to be encoded, they
125 are converted to UTF-8 characters and are than translated into
126 (sequences of) escape sequences. Other escape sequences are
127 copied verbatim (but using upper case hex digits).
129 WAS_ENCODED,
131 /** All escape sequences that are already present are copied verbatim
132 (but using upper case hex digits).
134 NOT_CANONIC
137 /** The way strings that represent (parts of) URIs are returned from get-
138 methods.
140 @descr Along with a DecodeMechanism parameter, the get-methods all
141 take an rtl_TextEncoding parameter, which is ignored unless the
142 DecodeMechanism is DECODE_WITH_CHARSET or DECODE_UNAMBIGUOUS.
144 enum DecodeMechanism
146 /** The (part of the) URI is returned unchanged. Since URIs are
147 written using a subset of US-ASCII, the returned string is
148 guaranteed to contain only US-ASCII characters.
150 NO_DECODE,
152 /** All sequences of escape sequences that represent UTF-8 coded
153 UTF-32 characters with a numerical value greater than 0x7F, are
154 replaced by the respective UTF-16 characters. All other escape
155 sequences are not decoded.
157 DECODE_TO_IURI,
159 /** All (sequences of) escape sequences that represent characters from
160 the specified character set, and that can be converted to UTF-32,
161 are replaced by the respective UTF-16 characters. All other
162 escape sequences are not decoded.
164 DECODE_WITH_CHARSET,
166 /** All (sequences of) escape sequences that represent characters from
167 the specified character set, that can be converted to UTF-32, and
168 that (in the case of ASCII characters) can safely be decoded
169 without altering the meaning of the (part of the) URI, are
170 replaced by the respective UTF-16 characters. All other escape
171 sequences are not decoded.
173 DECODE_UNAMBIGUOUS
176 // General Structure:
178 inline INetURLObject():
179 m_eScheme(INetProtocol::NotValid), m_eSmartScheme(INetProtocol::Http) {}
181 inline bool HasError() const { return m_eScheme == INetProtocol::NotValid; }
183 inline OUString GetMainURL(DecodeMechanism eMechanism,
184 rtl_TextEncoding eCharset
185 = RTL_TEXTENCODING_UTF8) const
186 { return decode(m_aAbsURIRef, eMechanism, eCharset); }
188 OUString GetURLNoPass(DecodeMechanism eMechanism = DECODE_TO_IURI,
189 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
190 const;
192 OUString GetURLNoMark(DecodeMechanism eMechanism = DECODE_TO_IURI,
193 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
194 const;
196 OUString
197 getAbbreviated(com::sun::star::uno::Reference<
198 com::sun::star::util::XStringWidth > const &
199 rStringWidth,
200 sal_Int32 nWidth,
201 DecodeMechanism eMechanism = DECODE_TO_IURI,
202 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
203 const;
205 bool operator ==(INetURLObject const & rObject) const;
207 inline bool operator !=(INetURLObject const & rObject) const
208 { return !(*this == rObject); }
210 bool operator <(INetURLObject const & rObject) const;
212 inline bool operator >(INetURLObject const & rObject) const
213 { return rObject < *this; }
215 // Strict Parsing:
217 inline explicit INetURLObject(
218 OUString const & rTheAbsURIRef,
219 EncodeMechanism eMechanism = WAS_ENCODED,
220 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
222 inline bool SetURL(OUString const & rTheAbsURIRef,
223 EncodeMechanism eMechanism = WAS_ENCODED,
224 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
226 bool ConcatData(INetProtocol eTheScheme, OUString const & rTheUser,
227 OUString const & rThePassword,
228 OUString const & rTheHost, sal_uInt32 nThePort,
229 OUString const & rThePath,
230 EncodeMechanism eMechanism = WAS_ENCODED,
231 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
233 // Smart Parsing:
235 /** The supported notations for file system paths.
237 enum FSysStyle
239 /** VOS notation (e.g., "//server/dir/file").
241 FSYS_VOS = 0x1,
243 /** Unix notation (e.g., "/dir/file").
245 FSYS_UNX = 0x2,
247 /** DOS notation (e.g., "a:\dir\file" and "\\server\dir\file").
249 FSYS_DOS = 0x4,
251 /** Detect the used notation.
253 @descr For the following descriptions, please note that
254 whereas FSYS_DEFAULT includes all style bits, combinations of only
255 a few style bits are also possible, and are also described.
257 @descr When used to translate a file system path to a file URL,
258 the subset of the following productions for which the appropriate
259 style bit is set are checked in order (using the conventions of
260 RFC 2234, RFC 2396, and RFC 2732; UCS4 stands for any UCS4
261 character):
263 Production T1 (VOS local; FSYS_VOS only):
264 "//." ["/" *UCS4]
265 becomes
266 "file:///" *UCS4
268 Production T2 (VOS host; FSYS_VOS only):
269 "//" [host] ["/" *UCS4]
270 becomes
271 "file://" host "/" *UCS4
273 Production T3 (UNC; FSYS_DOS only):
274 "\\" [host] ["\" *UCS4]
275 becomes
276 "file://" host "/" *UCS4
277 replacing "\" by "/" within <*UCS4>
279 Production T4 (Unix-like DOS; FSYS_DOS only):
280 ALPHA ":" ["/" *UCS4]
281 becomes
282 "file:///" ALPHA ":/" *UCS4
283 replacing "\" by "/" within <*UCS4>
285 Production T5 (DOS; FSYS_DOS only):
286 ALPHA ":" ["\" *UCS4]
287 becomes
288 "file:///" ALPHA ":/" *UCS4
289 replacing "\" by "/" within <*UCS4>
291 Production T6 (any):
292 *UCS4
293 becomes
294 "file:///" *UCS4
295 replacing the delimiter by "/" within <*UCS4>. The delimiter is
296 that character from the set { "/", "\" } which appears most
297 often in <*UCS4> (if FSYS_UNX is not among the style bits, "/"
298 is removed from the set; if FSYS_DOS is not among the style
299 bits, "\" is removed from the set). If two or more
300 characters appear the same number of times, the character
301 mentioned first in that set is chosen. If the first character
302 of <*UCS4> is the delimiter, that character is not copied.
304 @descr When used to translate a file URL to a file system path,
305 the following productions are checked in order (using the
306 conventions of RFC 2234, RFC 2396, and RFC 2732):
308 Production F1 (VOS; FSYS_VOS):
309 "file://" host "/" fpath ["#" fragment]
310 becomes
311 "//" host "/" fpath
313 Production F2 (DOS; FSYS_DOS):
314 "file:///" ALPHA ":" ["/" fpath] ["#" fragment]
315 becomes
316 ALPHA ":" ["\" fpath]
317 replacing "/" by "\" in <fpath>
319 Production F3 (Unix; FSYS_UNX):
320 "file:///" fpath ["#" fragment]
321 becomes
322 "/" fpath
324 FSYS_DETECT = FSYS_VOS | FSYS_UNX | FSYS_DOS
327 inline INetURLObject(OUString const & rTheAbsURIRef,
328 INetProtocol eTheSmartScheme,
329 EncodeMechanism eMechanism = WAS_ENCODED,
330 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8,
331 FSysStyle eStyle = FSYS_DETECT);
333 inline void SetSmartProtocol(INetProtocol eTheSmartScheme)
334 { m_eSmartScheme = eTheSmartScheme; }
336 inline bool
337 SetSmartURL(OUString const & rTheAbsURIRef,
338 EncodeMechanism eMechanism = WAS_ENCODED,
339 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8,
340 FSysStyle eStyle = FSYS_DETECT);
342 inline INetURLObject
343 smartRel2Abs(OUString const & rTheRelURIRef,
344 bool & rWasAbsolute,
345 bool bIgnoreFragment = false,
346 EncodeMechanism eMechanism = WAS_ENCODED,
347 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8,
348 bool bRelativeNonURIs = false,
349 FSysStyle eStyle = FSYS_DETECT) const;
351 // Relative URLs:
353 inline bool
354 GetNewAbsURL(OUString const & rTheRelURIRef,
355 INetURLObject * pTheAbsURIRef,
356 EncodeMechanism eMechanism = WAS_ENCODED,
357 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8,
358 FSysStyle eStyle = FSYS_DETECT, bool bIgnoreFragment = false)
359 const;
361 /** @descr If rTheRelURIRef cannot be converted to an absolute URL
362 (because of syntactic reasons), either rTheRelURIRef or an empty
363 string is returned: If all of the parameters eEncodeMechanism,
364 eDecodeMechanism and eCharset have their respective default values,
365 then rTheRelURIRef is returned unmodified; otherwise, an empty string
366 is returned.
368 static OUString
369 GetAbsURL(OUString const & rTheBaseURIRef,
370 OUString const & rTheRelURIRef,
371 bool bIgnoreFragment = false,
372 EncodeMechanism eEncodeMechanism = WAS_ENCODED,
373 DecodeMechanism eDecodeMechanism = DECODE_TO_IURI,
374 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8,
375 FSysStyle eStyle = FSYS_DETECT);
377 static inline OUString
378 GetRelURL(OUString const & rTheBaseURIRef,
379 OUString const & rTheAbsURIRef,
380 EncodeMechanism eEncodeMechanism = WAS_ENCODED,
381 DecodeMechanism eDecodeMechanism = DECODE_TO_IURI,
382 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8,
383 FSysStyle eStyle = FSYS_DETECT);
385 // External URLs:
387 OUString getExternalURL(DecodeMechanism eMechanism = DECODE_TO_IURI,
388 rtl_TextEncoding eCharset
389 = RTL_TEXTENCODING_UTF8) const;
391 static inline bool translateToExternal(OUString const & rTheIntURIRef,
392 OUString & rTheExtURIRef,
393 DecodeMechanism eDecodeMechanism
394 = DECODE_TO_IURI,
395 rtl_TextEncoding eCharset
396 = RTL_TEXTENCODING_UTF8);
398 static inline bool translateToInternal(OUString const & rTheExtURIRef,
399 OUString & rTheIntURIRef,
400 DecodeMechanism eDecodeMechanism
401 = DECODE_TO_IURI,
402 rtl_TextEncoding eCharset
403 = RTL_TEXTENCODING_UTF8);
405 // Scheme:
407 struct SchemeInfo;
409 inline INetProtocol GetProtocol() const { return m_eScheme; }
411 /** Return the URL 'prefix' for a given scheme.
413 @param eTheScheme One of the supported URL schemes.
415 @return The 'prefix' of URLs of the given scheme.
417 static OUString GetScheme(INetProtocol eTheScheme);
419 /** Return the a human-readable name for a given scheme.
421 @param eTheScheme One of the supported URL schemes.
423 @return The protocol name of URLs of the given scheme.
425 static OUString GetSchemeName(INetProtocol eTheScheme);
427 static INetProtocol CompareProtocolScheme(OUString const &
428 rTheAbsURIRef);
430 // User Info:
432 inline bool HasUserData() const { return m_aUser.isPresent(); }
434 inline bool IsEmptyUser() const
435 { return m_aUser.isPresent() && m_aUser.isEmpty(); }
437 inline OUString GetUser(DecodeMechanism eMechanism = DECODE_TO_IURI,
438 rtl_TextEncoding eCharset
439 = RTL_TEXTENCODING_UTF8) const
440 { return decode(m_aUser, eMechanism, eCharset); }
442 inline OUString GetPass(DecodeMechanism eMechanism = DECODE_TO_IURI,
443 rtl_TextEncoding eCharset
444 = RTL_TEXTENCODING_UTF8) const
445 { return decode(m_aAuth, eMechanism, eCharset); }
447 inline bool SetUser(OUString const & rTheUser,
448 EncodeMechanism eMechanism = WAS_ENCODED,
449 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
450 { return setUser(rTheUser, false, eMechanism, eCharset); }
452 inline bool SetPass(OUString const & rThePassword,
453 EncodeMechanism eMechanism = WAS_ENCODED,
454 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
456 inline bool SetUserAndPass(OUString const & rTheUser,
457 OUString const & rThePassword,
458 EncodeMechanism eMechanism = WAS_ENCODED,
459 rtl_TextEncoding eCharset
460 = RTL_TEXTENCODING_UTF8);
462 // Host and Port:
464 inline bool HasPort() const { return m_aPort.isPresent(); }
466 inline OUString GetHost(DecodeMechanism eMechanism = DECODE_TO_IURI,
467 rtl_TextEncoding eCharset
468 = RTL_TEXTENCODING_UTF8) const
469 { return decode(m_aHost, eMechanism, eCharset); }
471 OUString GetHostPort(DecodeMechanism eMechanism = DECODE_TO_IURI,
472 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
474 sal_uInt32 GetPort() const;
476 inline bool SetHost(OUString const & rTheHost,
477 EncodeMechanism eMechanism = WAS_ENCODED,
478 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
479 { return setHost(rTheHost, false, eMechanism, eCharset); }
481 bool SetPort(sal_uInt32 nThePort);
483 // Path:
485 inline bool HasURLPath() const { return !m_aPath.isEmpty(); }
487 inline OUString GetURLPath(DecodeMechanism eMechanism = DECODE_TO_IURI,
488 rtl_TextEncoding eCharset
489 = RTL_TEXTENCODING_UTF8) const
490 { return decode(m_aPath, eMechanism, eCharset); }
492 inline bool SetURLPath(OUString const & rThePath,
493 EncodeMechanism eMechanism = WAS_ENCODED,
494 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
495 { return setPath(rThePath, false, eMechanism, eCharset); }
497 // Hierarchical Path:
499 /** A constant to address the last segment in various methods dealing with
500 hierarchical paths.
502 @descr It is often more efficient to address the last segment using
503 this constant, than to determine its ordinal value using
504 getSegmentCount().
506 enum { LAST_SEGMENT = -1 };
508 /** The number of segments in the hierarchical path.
510 @descr Using RFC 2396 and RFC 2234, a hierarchical path is of the
511 form
513 hierarchical-path = 1*("/" segment)
515 segment = name *(";" param)
517 name = [base ["." extension]]
519 base = 1*pchar
521 extension = *<any pchar except ".">
523 param = *pchar
525 @param bIgnoreFinalSlash If true, a final slash at the end of the
526 hierarchical path does not denote an empty segment, but is ignored.
528 @return The number of segments in the hierarchical path. If the path
529 is not hierarchical, 0 is returned.
531 sal_Int32 getSegmentCount(bool bIgnoreFinalSlash = true) const;
533 /** Remove a segment from the hierarchical path.
535 @param nIndex The non-negative index of the segment, or LAST_SEGMENT
536 if addressing the last segment.
538 @param bIgnoreFinalSlash If true, a final slash at the end of the
539 hierarchical path does not denote an empty segment, but is ignored.
541 @return True if the segment has successfully been removed (and the
542 resulting URI is still valid). If the path is not hierarchical, or
543 the specified segment does not exist, false is returned. If false is
544 returned, the object is not modified.
546 bool removeSegment(sal_Int32 nIndex = LAST_SEGMENT,
547 bool bIgnoreFinalSlash = true);
549 /** Insert a new segment into the hierarchical path.
551 @param rTheName The name part of the new segment. The new segment
552 will contain no parameters.
554 @param bAppendFinalSlash If the new segment is appended at the end of
555 the hierarchical path, this parameter specifies whether to add a final
556 slash after it or not.
558 @param nIndex The non-negative index of the segment before which
559 to insert the new segment. LAST_SEGMENT or an nIndex that equals
560 getSegmentCount() inserts the new segment at the end of the
561 hierarchical path.
563 @param bIgnoreFinalSlash If true, a final slash at the end of the
564 hierarchical path does not denote an empty segment, but is ignored.
566 @param eMechanism See the general discussion for set-methods.
568 @param eCharset See the general discussion for set-methods.
570 @return True if the segment has successfully been inserted (and the
571 resulting URI is still valid). If the path is not hierarchical, or
572 the specified place to insert the new segment does not exist, false is
573 returned. If false is returned, the object is not modified.
575 inline bool insertName(OUString const & rTheName,
576 bool bAppendFinalSlash = false,
577 sal_Int32 nIndex = LAST_SEGMENT,
578 bool bIgnoreFinalSlash = true,
579 EncodeMechanism eMechanism = WAS_ENCODED,
580 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
582 /** Get the name of a segment of the hierarchical path.
584 @param nIndex The non-negative index of the segment, or LAST_SEGMENT
585 if addressing the last segment.
587 @param bIgnoreFinalSlash If true, a final slash at the end of the
588 hierarchical path does not denote an empty segment, but is ignored.
590 @param eMechanism See the general discussion for get-methods.
592 @param eCharset See the general discussion for get-methods.
594 @return The name part of the specified segment. If the path is not
595 hierarchical, or the specified segment does not exits, an empty string
596 is returned.
598 OUString getName(sal_Int32 nIndex = LAST_SEGMENT,
599 bool bIgnoreFinalSlash = true,
600 DecodeMechanism eMechanism = DECODE_TO_IURI,
601 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
602 const;
604 /** Set the name of a segment (preserving any parameters and any query or
605 fragment part).
607 @param rTheName The new name.
609 @param nIndex The non-negative index of the segment, or LAST_SEGMENT
610 if addressing the last segment.
612 @param bIgnoreFinalSlash If true, a final slash at the end of the
613 hierarchical path does not denote an empty segment, but is ignored.
615 @param eMechanism See the general discussion for set-methods.
617 @param eCharset See the general discussion for set-methods.
619 @return True if the name has successfully been modified (and the
620 resulting URI is still valid). If the path is not hierarchical, or
621 the specified segment does not exist, false is returned. If false is
622 returned, the object is not modified.
624 bool setName(OUString const & rTheName,
625 sal_Int32 nIndex = LAST_SEGMENT,
626 bool bIgnoreFinalSlash = true,
627 EncodeMechanism eMechanism = WAS_ENCODED,
628 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
630 /** Get the base of the name of a segment.
632 @param nIndex The non-negative index of the segment, or LAST_SEGMENT
633 if addressing the last segment.
635 @param bIgnoreFinalSlash If true, a final slash at the end of the
636 hierarchical path does not denote an empty segment, but is ignored.
638 @param eMechanism See the general discussion for get-methods.
640 @param eCharset See the general discussion for get-methods.
642 @return The base part of the specified segment. If the path is
643 not hierarchical, or the specified segment does not exits, an empty
644 string is returned.
646 OUString getBase(sal_Int32 nIndex = LAST_SEGMENT,
647 bool bIgnoreFinalSlash = true,
648 DecodeMechanism eMechanism = DECODE_TO_IURI,
649 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
650 const;
652 /** Set the base of the name of a segment (preserving the extension).
654 @param rTheBase The new base.
656 @param nIndex The non-negative index of the segment, or LAST_SEGMENT
657 if addressing the last segment.
659 @param bIgnoreFinalSlash If true, a final slash at the end of the
660 hierarchical path does not denote an empty segment, but is ignored.
662 @param eMechanism See the general discussion for set-methods.
664 @param eCharset See the general discussion for set-methods.
666 @return True if the base has successfully been modified (and the
667 resulting URI is still valid). If the path is not hierarchical, or
668 the specified segment does not exist, false is returned. If false is
669 returned, the object is not modified.
671 bool setBase(OUString const & rTheBase,
672 sal_Int32 nIndex = LAST_SEGMENT,
673 bool bIgnoreFinalSlash = true,
674 EncodeMechanism eMechanism = WAS_ENCODED,
675 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
677 /** Determine whether the name of a segment has an extension.
679 @param nIndex The non-negative index of the segment, or LAST_SEGMENT
680 if addressing the last segment.
682 @param bIgnoreFinalSlash If true, a final slash at the end of the
683 hierarchical path does not denote an empty segment, but is ignored.
685 @return True if the name of the specified segment has an extension.
686 If the path is not hierarchical, or the specified segment does not
687 exist, false is returned.
689 bool hasExtension(sal_Int32 nIndex = LAST_SEGMENT,
690 bool bIgnoreFinalSlash = true) const;
692 /** Get the extension of the name of a segment.
694 @param nIndex The non-negative index of the segment, or LAST_SEGMENT
695 if addressing the last segment.
697 @param bIgnoreFinalSlash If true, a final slash at the end of the
698 hierarchical path does not denote an empty segment, but is ignored.
700 @param eMechanism See the general discussion for get-methods.
702 @param eCharset See the general discussion for get-methods.
704 @return The extension part of the specified segment. If the path is
705 not hierarchical, or the specified segment does not exits, an empty
706 string is returned.
708 OUString getExtension(sal_Int32 nIndex = LAST_SEGMENT,
709 bool bIgnoreFinalSlash = true,
710 DecodeMechanism eMechanism = DECODE_TO_IURI,
711 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
712 const;
714 /** Set the extension of the name of a segment (replacing an already
715 existing extension).
717 @param rTheExtension The new extension.
719 @param nIndex The non-negative index of the segment, or LAST_SEGMENT
720 if addressing the last segment.
722 @param bIgnoreFinalSlash If true, a final slash at the end of the
723 hierarchical path does not denote an empty segment, but is ignored.
725 @param eMechanism See the general discussion for set-methods.
727 @param eCharset See the general discussion for set-methods.
729 @return True if the extension has successfully been modified (and the
730 resulting URI is still valid). If the path is not hierarchical, or
731 the specified segment does not exist, false is returned. If false is
732 returned, the object is not modified.
734 bool setExtension(OUString const & rTheExtension,
735 sal_Int32 nIndex = LAST_SEGMENT,
736 bool bIgnoreFinalSlash = true,
737 EncodeMechanism eMechanism = WAS_ENCODED,
738 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
740 /** Remove the extension of the name of a segment.
742 @param nIndex The non-negative index of the segment, or LAST_SEGMENT
743 if addressing the last segment.
745 @param bIgnoreFinalSlash If true, a final slash at the end of the
746 hierarchical path does not denote an empty segment, but is ignored.
748 @return True if the extension has successfully been removed (and the
749 resulting URI is still valid), or if the name did not have an
750 extension. If the path is not hierarchical, or the specified segment
751 does not exist, false is returned. If false is returned, the object
752 is not modified.
754 bool removeExtension(sal_Int32 nIndex = LAST_SEGMENT,
755 bool bIgnoreFinalSlash = true);
757 /** Determine whether the hierarchical path ends in a final slash.
759 @return True if the hierarchical path ends in a final slash. If the
760 path is not hierarchical, false is returned.
762 bool hasFinalSlash() const;
764 /** Make the hierarchical path end in a final slash (if it does not
765 already do so).
767 @return True if a final slash has successfully been appended (and the
768 resulting URI is still valid), or if the hierarchical path already
769 ended in a final slash. If the path is not hierarchical, false is
770 returned. If false is returned, the object is not modified.
772 bool setFinalSlash();
774 /** Remove a final slash from the hierarchical path.
776 @return True if a final slash has successfully been removed (and the
777 resulting URI is still valid), or if the hierarchical path already did
778 not end in a final slash. If the path is not hierarchical, false is
779 returned. If false is returned, the object is not modified.
781 bool removeFinalSlash();
783 // Query:
785 inline bool HasParam() const { return m_aQuery.isPresent(); }
787 inline OUString GetParam(DecodeMechanism eMechanism = DECODE_TO_IURI,
788 rtl_TextEncoding eCharset
789 = RTL_TEXTENCODING_UTF8) const
790 { return decode(m_aQuery, eMechanism, eCharset); }
792 inline bool SetParam(OUString const & rTheQuery,
793 EncodeMechanism eMechanism = WAS_ENCODED,
794 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
796 // Fragment:
798 inline bool HasMark() const { return m_aFragment.isPresent(); }
800 inline OUString GetMark(DecodeMechanism eMechanism = DECODE_TO_IURI,
801 rtl_TextEncoding eCharset
802 = RTL_TEXTENCODING_UTF8) const
803 { return decode(m_aFragment, eMechanism, eCharset); }
805 inline bool SetMark(OUString const & rTheFragment,
806 EncodeMechanism eMechanism = WAS_ENCODED,
807 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
809 // File URLs:
811 /** Create an INetURLObject from a file system path.
813 @param rFSysPath A file system path. An URL is not allowed here!
815 @param eStyle The notation of rFSysPath.
817 inline INetURLObject(OUString const & rFSysPath, FSysStyle eStyle);
819 /** Set this INetURLObject to a file URL constructed from a file system
820 path.
822 @param rFSysPath A file system path. An URL is not allowed here!
824 @param eStyle The notation of rFSysPath.
826 @return True if this INetURLObject has successfully been changed. If
827 false is returned, this INetURLObject has not been modified.
829 bool setFSysPath(OUString const & rFSysPath, FSysStyle eStyle);
831 /** Return the file system path represented by a file URL (ignoring any
832 fragment part).
834 @param eStyle The notation of the returned file system path.
836 @param pDelimiter Upon successful return, this parameter can return
837 the character that is the 'main' delimiter within the returned file
838 system path (e.g., "/" for Unix, "\" for DOS). This is
839 especially useful for routines that later try to shorten the returned
840 file system path at a 'good' position, e.g. to fit it into some
841 limited display space.
843 @return The file system path represented by this file URL. If this
844 file URL does not represent a file system path according to the
845 specified notation, or if this is not a file URL at all, an empty
846 string is returned.
848 OUString getFSysPath(FSysStyle eStyle, sal_Unicode * pDelimiter = 0)
849 const;
851 // Data URLs:
852 std::unique_ptr<SvMemoryStream> getData();
854 // POP3 and URLs:
856 static OUString GetMsgId(DecodeMechanism eMechanism = DECODE_TO_IURI,
857 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
859 // Coding:
861 enum Part
863 PART_USER_PASSWORD = 0x00001,
864 PART_FPATH = 0x00008,
865 PART_AUTHORITY = 0x00010,
866 PART_REL_SEGMENT_EXTRA = 0x00020,
867 PART_URIC = 0x00040,
868 PART_HTTP_PATH = 0x00080,
869 PART_MESSAGE_ID_PATH = 0x00100,
870 PART_MAILTO = 0x00200,
871 PART_PATH_BEFORE_QUERY = 0x00400,
872 PART_PCHAR = 0x00800,
873 PART_VISIBLE = 0x01000,
874 PART_VISIBLE_NONSPECIAL = 0x02000,
875 PART_UNO_PARAM_VALUE = 0x04000,
876 PART_UNAMBIGUOUS = 0x08000,
877 PART_URIC_NO_SLASH = 0x10000,
878 PART_HTTP_QUERY = 0x20000, //TODO! unused?
881 enum EscapeType
883 ESCAPE_NO,
884 ESCAPE_OCTET,
885 ESCAPE_UTF32
888 /** Encode some text as part of a URI.
890 @param rText Some text (for its interpretation, see the general
891 discussion for set-methods).
893 @param ePart The part says which characters are 'forbidden' and must
894 be encoded (replaced by escape sequences). Characters outside the US-
895 ASCII range are always 'forbidden.'
897 @param eMechanism See the general discussion for set-methods.
899 @param eCharset See the general discussion for set-methods.
901 @return The text, encoded according to the given mechanism and
902 charset ('forbidden' characters replaced by escape sequences).
904 static inline OUString encode(OUString const & rText, Part ePart,
905 EncodeMechanism eMechanism,
906 rtl_TextEncoding eCharset
907 = RTL_TEXTENCODING_UTF8);
909 /** Decode some text.
911 @param rText Some (encoded) text.
913 @param eMechanism See the general discussion for get-methods.
915 @param eCharset See the general discussion for get-methods.
917 @return The text, decoded according to the given mechanism and
918 charset (escape sequences replaced by 'raw' characters).
920 static inline OUString decode(OUString const & rText,
921 DecodeMechanism eMechanism,
922 rtl_TextEncoding eCharset
923 = RTL_TEXTENCODING_UTF8);
925 static inline OUString decode(OUStringBuffer const & rText,
926 DecodeMechanism eMechanism,
927 rtl_TextEncoding eCharset
928 = RTL_TEXTENCODING_UTF8);
930 static void appendUCS4Escape(OUStringBuffer & rTheText, sal_uInt32 nUCS4);
932 static void appendUCS4(OUStringBuffer & rTheText, sal_uInt32 nUCS4,
933 EscapeType eEscapeType, bool bOctets, Part ePart,
934 rtl_TextEncoding eCharset, bool bKeepVisibleEscapes);
936 static sal_uInt32 getUTF32(sal_Unicode const *& rBegin,
937 sal_Unicode const * pEnd, bool bOctets,
938 EncodeMechanism eMechanism,
939 rtl_TextEncoding eCharset,
940 EscapeType & rEscapeType);
942 // Specialized helpers:
944 static sal_uInt32 scanDomain(sal_Unicode const *& rBegin,
945 sal_Unicode const * pEnd,
946 bool bEager = true);
948 // OBSOLETE Hierarchical Path:
950 OUString GetPartBeforeLastName(DecodeMechanism eMechanism
951 = DECODE_TO_IURI,
952 rtl_TextEncoding eCharset
953 = RTL_TEXTENCODING_UTF8) const;
955 /** Get the last segment in the path.
957 @param eMechanism See the general discussion for get-methods.
959 @param eCharset See the general discussion for get-methods.
961 @return For a hierarchical URL, the last segment (everything after
962 the last unencoded '/'). Not that this last segment may be empty. If
963 the URL is not hierarchical, an empty string is returned.
965 OUString GetLastName(DecodeMechanism eMechanism = DECODE_TO_IURI,
966 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
967 const;
969 /** Get the 'extension' of the last segment in the path.
971 @param eMechanism See the general discussion for get-methods.
973 @param eCharset See the general discussion for get-methods.
975 @return For a hierarchical URL, everything after the first unencoded
976 '.' in the last segment of the path. Note that this 'extension' may
977 be empty. If the URL is not hierarchical, or if the last segment does
978 not contain an unencoded '.', an empty string is returned.
980 OUString GetFileExtension(DecodeMechanism eMechanism = DECODE_TO_IURI,
981 rtl_TextEncoding eCharset
982 = RTL_TEXTENCODING_UTF8) const;
984 inline bool Append(OUString const & rTheSegment,
985 EncodeMechanism eMechanism = WAS_ENCODED,
986 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
987 { return appendSegment(rTheSegment, false, eMechanism, eCharset); }
989 bool CutLastName();
991 // OBSOLETE File URLs:
993 OUString PathToFileName() const;
995 OUString GetFull() const;
997 OUString GetPath() const;
999 void SetBase(OUString const & rTheBase);
1001 OUString GetBase() const;
1003 void SetName(OUString const & rTheName,
1004 EncodeMechanism eMechanism = WAS_ENCODED,
1005 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
1007 inline OUString GetName(DecodeMechanism eMechanism = DECODE_TO_IURI,
1008 rtl_TextEncoding eCharset
1009 = RTL_TEXTENCODING_UTF8) const
1010 { return GetLastName(eMechanism, eCharset); }
1012 void SetExtension(OUString const & rTheExtension,
1013 EncodeMechanism eMechanism = WAS_ENCODED,
1014 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
1016 inline OUString GetExtension(
1017 DecodeMechanism eMechanism = DECODE_TO_IURI,
1018 rtl_TextEncoding eCharset
1019 = RTL_TEXTENCODING_UTF8) const
1020 { return GetFileExtension(eMechanism, eCharset); }
1022 OUString CutExtension(DecodeMechanism eMechanism = DECODE_TO_IURI,
1023 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
1025 static bool IsCaseSensitive() { return true; }
1028 private:
1029 // General Structure:
1031 class SubString
1033 sal_Int32 m_nBegin;
1034 sal_Int32 m_nLength;
1036 public:
1037 explicit inline SubString(sal_Int32 nTheBegin = -1,
1038 sal_Int32 nTheLength = 0):
1039 m_nBegin(nTheBegin), m_nLength(nTheLength) {}
1041 inline bool isPresent() const { return m_nBegin != -1; }
1043 inline bool isEmpty() const { return m_nLength == 0; }
1045 inline sal_Int32 getBegin() const { return m_nBegin; }
1047 inline sal_Int32 getLength() const { return m_nLength; }
1049 inline sal_Int32 getEnd() const { return m_nBegin + m_nLength; }
1051 inline sal_Int32 clear();
1053 inline sal_Int32 set(OUStringBuffer & rString,
1054 OUString const & rSubString,
1055 sal_Int32 nTheBegin);
1057 inline sal_Int32 set(OUString & rString,
1058 OUString const & rSubString);
1060 inline sal_Int32 set(OUStringBuffer & rString,
1061 OUString const & rSubString);
1063 inline void operator +=(sal_Int32 nDelta);
1065 int compare(SubString const & rOther,
1066 OUStringBuffer const & rThisString,
1067 OUStringBuffer const & rOtherString) const;
1070 OUStringBuffer m_aAbsURIRef;
1071 SubString m_aScheme;
1072 SubString m_aUser;
1073 SubString m_aAuth;
1074 SubString m_aHost;
1075 SubString m_aPort;
1076 SubString m_aPath;
1077 SubString m_aQuery;
1078 SubString m_aFragment;
1079 INetProtocol m_eScheme;
1080 INetProtocol m_eSmartScheme;
1082 TOOLS_DLLPRIVATE void setInvalid();
1084 bool setAbsURIRef(
1085 OUString const & rTheAbsURIRef, bool bOctets,
1086 EncodeMechanism eMechanism, rtl_TextEncoding eCharset, bool bSmart,
1087 FSysStyle eStyle);
1089 // Relative URLs:
1091 bool convertRelToAbs(
1092 OUString const & rTheRelURIRef, bool bOctets,
1093 INetURLObject & rTheAbsURIRef, bool & rWasAbsolute,
1094 EncodeMechanism eMechanism, rtl_TextEncoding eCharset,
1095 bool bIgnoreFragment, bool bSmart, bool bRelativeNonURIs,
1096 FSysStyle eStyle) const;
1098 bool convertAbsToRel(
1099 OUString const & rTheAbsURIRef, bool bOctets,
1100 OUString & rTheRelURIRef, EncodeMechanism eEncodeMechanism,
1101 DecodeMechanism eDecodeMechanism, rtl_TextEncoding eCharset,
1102 FSysStyle eStyle) const;
1104 // External URLs:
1106 static bool convertIntToExt(
1107 OUString const & rTheIntURIRef, bool bOctets,
1108 OUString & rTheExtURIRef, DecodeMechanism eDecodeMechanism,
1109 rtl_TextEncoding eCharset);
1111 static bool convertExtToInt(
1112 OUString const & rTheExtURIRef, bool bOctets,
1113 OUString & rTheIntURIRef, DecodeMechanism eDecodeMechanism,
1114 rtl_TextEncoding eCharset);
1116 // Scheme:
1118 struct PrefixInfo;
1120 TOOLS_DLLPRIVATE static inline SchemeInfo const & getSchemeInfo(
1121 INetProtocol eTheScheme);
1123 TOOLS_DLLPRIVATE inline SchemeInfo const & getSchemeInfo() const;
1125 TOOLS_DLLPRIVATE static PrefixInfo const * getPrefix(
1126 sal_Unicode const *& rBegin, sal_Unicode const * pEnd);
1128 // Authority:
1130 TOOLS_DLLPRIVATE sal_Int32 getAuthorityBegin() const;
1132 TOOLS_DLLPRIVATE SubString getAuthority() const;
1134 // User Info:
1136 bool setUser(
1137 OUString const & rTheUser, bool bOctets,
1138 EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
1140 bool clearPassword();
1142 bool setPassword(
1143 OUString const & rThePassword, bool bOctets,
1144 EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
1146 // Host and Port:
1148 TOOLS_DLLPRIVATE static bool parseHost(
1149 sal_Unicode const *& rBegin, sal_Unicode const * pEnd,
1150 OUString & rCanonic);
1152 TOOLS_DLLPRIVATE static bool parseHostOrNetBiosName(
1153 sal_Unicode const * pBegin, sal_Unicode const * pEnd, bool bOctets,
1154 EncodeMechanism eMechanism, rtl_TextEncoding eCharset,
1155 bool bNetBiosName, OUStringBuffer* pCanonic);
1157 bool setHost(
1158 OUString const & rTheHost, bool bOctets,
1159 EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
1161 // Path:
1163 TOOLS_DLLPRIVATE static bool parsePath(
1164 INetProtocol eScheme, sal_Unicode const ** pBegin,
1165 sal_Unicode const * pEnd, bool bOctets, EncodeMechanism eMechanism,
1166 rtl_TextEncoding eCharset, bool bSkippedInitialSlash,
1167 sal_uInt32 nSegmentDelimiter, sal_uInt32 nAltSegmentDelimiter,
1168 sal_uInt32 nQueryDelimiter, sal_uInt32 nFragmentDelimiter,
1169 OUStringBuffer &rSynPath);
1171 bool setPath(
1172 OUString const & rThePath, bool bOctets,
1173 EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
1175 // Hierarchical Path:
1177 TOOLS_DLLPRIVATE bool checkHierarchical() const;
1179 bool appendSegment(
1180 OUString const & rTheSegment, bool bOctets,
1181 EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
1183 TOOLS_DLLPRIVATE SubString getSegment(
1184 sal_Int32 nIndex, bool bIgnoreFinalSlash) const;
1186 bool insertName(
1187 OUString const & rTheName, bool bOctets, bool bAppendFinalSlash,
1188 sal_Int32 nIndex, bool bIgnoreFinalSlash, EncodeMechanism eMechanism,
1189 rtl_TextEncoding eCharset);
1191 // Query:
1193 bool clearQuery();
1195 bool setQuery(
1196 OUString const & rTheQuery, bool bOctets,
1197 EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
1199 // Fragment:
1201 bool clearFragment();
1203 bool setFragment(
1204 OUString const & rTheMark, bool bOctets,
1205 EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
1207 // FILE URLs:
1209 TOOLS_DLLPRIVATE bool hasDosVolume(FSysStyle eStyle) const;
1211 // Coding:
1213 TOOLS_DLLPRIVATE static inline void appendEscape(
1214 OUStringBuffer & rTheText, sal_uInt32 nOctet);
1216 static OUString encodeText(
1217 sal_Unicode const * pBegin, sal_Unicode const * pEnd, bool bOctets,
1218 Part ePart, EncodeMechanism eMechanism, rtl_TextEncoding eCharset,
1219 bool bKeepVisibleEscapes);
1221 static inline OUString encodeText(
1222 OUString const & rTheText, bool bOctets, Part ePart,
1223 EncodeMechanism eMechanism, rtl_TextEncoding eCharset,
1224 bool bKeepVisibleEscapes);
1226 static OUString decode(
1227 sal_Unicode const * pBegin, sal_Unicode const * pEnd,
1228 DecodeMechanism, rtl_TextEncoding eCharset);
1230 inline OUString decode(
1231 SubString const & rSubString,
1232 DecodeMechanism eMechanism, rtl_TextEncoding eCharset) const;
1234 // Specialized helpers:
1236 TOOLS_DLLPRIVATE static bool scanIPv6reference(
1237 sal_Unicode const *& rBegin, sal_Unicode const * pEnd);
1239 private:
1240 void changeScheme(INetProtocol eTargetScheme);
1243 // static
1244 inline OUString INetURLObject::encodeText(OUString const & rTheText,
1245 bool bOctets, Part ePart,
1246 EncodeMechanism eMechanism,
1247 rtl_TextEncoding eCharset,
1248 bool bKeepVisibleEscapes)
1250 return encodeText(rTheText.getStr(),
1251 rTheText.getStr() + rTheText.getLength(), bOctets, ePart,
1252 eMechanism, eCharset, bKeepVisibleEscapes);
1255 inline OUString INetURLObject::decode(SubString const & rSubString,
1256 DecodeMechanism eMechanism,
1257 rtl_TextEncoding eCharset) const
1259 return rSubString.isPresent() ?
1260 decode(m_aAbsURIRef.getStr() + rSubString.getBegin(),
1261 m_aAbsURIRef.getStr() + rSubString.getEnd(),
1262 eMechanism, eCharset) :
1263 OUString();
1266 inline INetURLObject::INetURLObject(OUString const & rTheAbsURIRef,
1267 EncodeMechanism eMechanism,
1268 rtl_TextEncoding eCharset):
1269 m_eScheme(INetProtocol::NotValid), m_eSmartScheme(INetProtocol::Http)
1271 setAbsURIRef(rTheAbsURIRef, false, eMechanism, eCharset, false,
1272 FSysStyle(0));
1275 inline bool INetURLObject::SetURL(OUString const & rTheAbsURIRef,
1276 EncodeMechanism eMechanism,
1277 rtl_TextEncoding eCharset)
1279 return setAbsURIRef(rTheAbsURIRef, false, eMechanism, eCharset, false,
1280 FSysStyle(0));
1283 inline INetURLObject::INetURLObject(OUString const & rTheAbsURIRef,
1284 INetProtocol eTheSmartScheme,
1285 EncodeMechanism eMechanism,
1286 rtl_TextEncoding eCharset,
1287 FSysStyle eStyle):
1288 m_eScheme(INetProtocol::NotValid), m_eSmartScheme(eTheSmartScheme)
1290 setAbsURIRef(rTheAbsURIRef, false, eMechanism, eCharset, true, eStyle);
1293 inline bool INetURLObject::SetSmartURL(OUString const & rTheAbsURIRef,
1294 EncodeMechanism eMechanism,
1295 rtl_TextEncoding eCharset,
1296 FSysStyle eStyle)
1298 return setAbsURIRef(rTheAbsURIRef, false, eMechanism, eCharset, true,
1299 eStyle);
1302 inline INetURLObject
1303 INetURLObject::smartRel2Abs(OUString const & rTheRelURIRef,
1304 bool & rWasAbsolute,
1305 bool bIgnoreFragment,
1306 EncodeMechanism eMechanism,
1307 rtl_TextEncoding eCharset,
1308 bool bRelativeNonURIs,
1309 FSysStyle eStyle) const
1311 INetURLObject aTheAbsURIRef;
1312 convertRelToAbs(rTheRelURIRef, false, aTheAbsURIRef, rWasAbsolute,
1313 eMechanism, eCharset, bIgnoreFragment, true,
1314 bRelativeNonURIs, eStyle);
1315 return aTheAbsURIRef;
1318 inline bool INetURLObject::GetNewAbsURL(OUString const & rTheRelURIRef,
1319 INetURLObject * pTheAbsURIRef,
1320 EncodeMechanism eMechanism,
1321 rtl_TextEncoding eCharset,
1322 FSysStyle eStyle, bool bIgnoreFragment)
1323 const
1325 INetURLObject aTheAbsURIRef;
1326 bool bWasAbsolute;
1327 if (!convertRelToAbs(rTheRelURIRef, false, aTheAbsURIRef, bWasAbsolute,
1328 eMechanism, eCharset, bIgnoreFragment, false, false,
1329 eStyle))
1330 return false;
1331 if (pTheAbsURIRef)
1332 *pTheAbsURIRef = aTheAbsURIRef;
1333 return true;
1336 // static
1337 inline OUString INetURLObject::GetRelURL(OUString const & rTheBaseURIRef,
1338 OUString const & rTheAbsURIRef,
1339 EncodeMechanism eEncodeMechanism,
1340 DecodeMechanism eDecodeMechanism,
1341 rtl_TextEncoding eCharset,
1342 FSysStyle eStyle)
1344 OUString aTheRelURIRef;
1345 INetURLObject(rTheBaseURIRef, eEncodeMechanism, eCharset).
1346 convertAbsToRel(rTheAbsURIRef, false, aTheRelURIRef, eEncodeMechanism,
1347 eDecodeMechanism, eCharset, eStyle);
1348 return aTheRelURIRef;
1351 // static
1352 inline bool INetURLObject::translateToExternal(OUString const &
1353 rTheIntURIRef,
1354 OUString & rTheExtURIRef,
1355 DecodeMechanism
1356 eDecodeMechanism,
1357 rtl_TextEncoding eCharset)
1359 return convertIntToExt(rTheIntURIRef, false, rTheExtURIRef,
1360 eDecodeMechanism, eCharset);
1363 // static
1364 inline bool INetURLObject::translateToInternal(OUString const &
1365 rTheExtURIRef,
1366 OUString & rTheIntURIRef,
1367 DecodeMechanism
1368 eDecodeMechanism,
1369 rtl_TextEncoding eCharset)
1371 return convertExtToInt(rTheExtURIRef, false, rTheIntURIRef,
1372 eDecodeMechanism, eCharset);
1375 inline bool INetURLObject::SetPass(OUString const & rThePassword,
1376 EncodeMechanism eMechanism,
1377 rtl_TextEncoding eCharset)
1379 return rThePassword.isEmpty() ?
1380 clearPassword() :
1381 setPassword(rThePassword, false, eMechanism, eCharset);
1384 inline bool INetURLObject::SetUserAndPass(OUString const & rTheUser,
1385 OUString const & rThePassword,
1386 EncodeMechanism eMechanism,
1387 rtl_TextEncoding eCharset)
1389 return setUser(rTheUser, false, eMechanism, eCharset)
1390 && (rThePassword.isEmpty() ?
1391 clearPassword() :
1392 setPassword(rThePassword, false, eMechanism, eCharset));
1395 inline bool INetURLObject::insertName(OUString const & rTheName,
1396 bool bAppendFinalSlash,
1397 sal_Int32 nIndex,
1398 bool bIgnoreFinalSlash,
1399 EncodeMechanism eMechanism,
1400 rtl_TextEncoding eCharset)
1402 return insertName(rTheName, false, bAppendFinalSlash, nIndex,
1403 bIgnoreFinalSlash, eMechanism, eCharset);
1406 inline bool INetURLObject::SetParam(OUString const & rTheQuery,
1407 EncodeMechanism eMechanism,
1408 rtl_TextEncoding eCharset)
1410 return rTheQuery.isEmpty() ?
1411 clearQuery() :
1412 setQuery(rTheQuery, false, eMechanism, eCharset);
1415 inline bool INetURLObject::SetMark(OUString const & rTheFragment,
1416 EncodeMechanism eMechanism,
1417 rtl_TextEncoding eCharset)
1419 return rTheFragment.isEmpty() ?
1420 clearFragment() :
1421 setFragment(rTheFragment, false, eMechanism, eCharset);
1424 inline INetURLObject::INetURLObject(OUString const & rFSysPath,
1425 FSysStyle eStyle):
1426 m_eScheme(INetProtocol::NotValid), m_eSmartScheme(INetProtocol::Http)
1428 setFSysPath(rFSysPath, eStyle);
1431 // static
1432 inline OUString INetURLObject::encode(OUString const & rText, Part ePart,
1433 EncodeMechanism eMechanism,
1434 rtl_TextEncoding eCharset)
1436 return encodeText(rText, false, ePart, eMechanism, eCharset, false);
1439 // static
1440 inline OUString INetURLObject::decode(OUString const & rText,
1441 DecodeMechanism eMechanism,
1442 rtl_TextEncoding eCharset)
1444 return decode(rText.getStr(), rText.getStr() + rText.getLength(),
1445 eMechanism, eCharset);
1448 inline OUString INetURLObject::decode(OUStringBuffer const & rText,
1449 DecodeMechanism eMechanism,
1450 rtl_TextEncoding eCharset)
1452 return decode(rText.getStr(), rText.getStr() + rText.getLength(),
1453 eMechanism, eCharset);
1456 #endif
1458 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */