LCOV - code coverage report
Current view: top level - include/tools - urlobj.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 95 116 81.9 %
Date: 2015-06-13 12:38:46 Functions: 48 55 87.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : #ifndef INCLUDED_TOOLS_URLOBJ_HXX
      20             : #define INCLUDED_TOOLS_URLOBJ_HXX
      21             : 
      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>
      28             : 
      29             : #include <memory>
      30             : 
      31             : class SvMemoryStream;
      32             : 
      33             : namespace com { namespace sun { namespace star { namespace util {
      34             :     class XStringWidth;
      35             : } } } }
      36             : 
      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:"
      44             : 
      45             : #define URL_PREFIX_PRIV_SOFFICE "private:"
      46             : enum
      47             : {
      48             :     URL_PREFIX_PRIV_SOFFICE_LEN
      49             :         = RTL_CONSTASCII_LENGTH(URL_PREFIX_PRIV_SOFFICE)
      50             : };
      51             : 
      52             : #define URL_PREFIX_PRIV_OBSOLETE URL_PREFIX_PRIV_SOFFICE
      53             : enum
      54             : {
      55             :     URL_PREFIX_PRIV_OBSOLETE_LEN
      56             :         = RTL_CONSTASCII_LENGTH(URL_PREFIX_PRIV_OBSOLETE)
      57             : };
      58             : 
      59             : #define URL_PREFIX_PRIV_EXTERN "staroffice:"
      60             : enum
      61             : {
      62             :     URL_PREFIX_PRIV_EXTERN_LEN = RTL_CONSTASCII_LENGTH(URL_PREFIX_PRIV_EXTERN)
      63             : };
      64             : 
      65             : // Schemes:
      66             : enum class INetProtocol
      67             : {
      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
      98             : };
      99             : 
     100     1204531 : class TOOLS_DLLPUBLIC SAL_WARN_UNUSED INetURLObject
     101             : {
     102             : public:
     103             :     // Get- and Set-Methods:
     104             : 
     105             :     /** The way input strings that represent (parts of) URIs are interpreted
     106             :         in set-methods.
     107             : 
     108             :         @descr  UTF-32 characters in the range 0x80--0x10FFFF are replaced by
     109             :         sequences of escape sequences, representing the UTF-8 coded characters.
     110             : 
     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.
     114             :      */
     115             :     enum EncodeMechanism
     116             :     {
     117             :         /** All escape sequences that are already present are ignored, and are
     118             :             interpreted as literal sequences of three characters.
     119             :          */
     120             :         ENCODE_ALL,
     121             : 
     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).
     128             :          */
     129             :         WAS_ENCODED,
     130             : 
     131             :         /** All escape sequences that are already present are copied verbatim
     132             :             (but using upper case hex digits).
     133             :          */
     134             :         NOT_CANONIC
     135             :     };
     136             : 
     137             :     /** The way strings that represent (parts of) URIs are returned from get-
     138             :         methods.
     139             : 
     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.
     143             :      */
     144             :     enum DecodeMechanism
     145             :     {
     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.
     149             :          */
     150             :         NO_DECODE,
     151             : 
     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.
     156             :          */
     157             :         DECODE_TO_IURI,
     158             : 
     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.
     163             :          */
     164             :         DECODE_WITH_CHARSET,
     165             : 
     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.
     172             :          */
     173             :         DECODE_UNAMBIGUOUS
     174             :     };
     175             : 
     176             :     // General Structure:
     177             : 
     178       15626 :     inline INetURLObject():
     179       15626 :         m_eScheme(INetProtocol::NotValid), m_eSmartScheme(INetProtocol::Http) {}
     180             : 
     181     1169092 :     inline bool HasError() const { return m_eScheme == INetProtocol::NotValid; }
     182             : 
     183      970060 :     inline OUString GetMainURL(DecodeMechanism eMechanism,
     184             :                                 rtl_TextEncoding eCharset
     185             :                                     = RTL_TEXTENCODING_UTF8) const
     186      970060 :     { return decode(m_aAbsURIRef, eMechanism, eCharset); }
     187             : 
     188             :     OUString GetURLNoPass(DecodeMechanism eMechanism = DECODE_TO_IURI,
     189             :                            rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
     190             :         const;
     191             : 
     192             :     OUString GetURLNoMark(DecodeMechanism eMechanism = DECODE_TO_IURI,
     193             :                            rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
     194             :         const;
     195             : 
     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;
     204             : 
     205             :     bool operator ==(INetURLObject const & rObject) const;
     206             : 
     207         700 :     inline bool operator !=(INetURLObject const & rObject) const
     208         700 :     { return !(*this == rObject); }
     209             : 
     210             :     bool operator <(INetURLObject const & rObject) const;
     211             : 
     212             :     inline bool operator >(INetURLObject const & rObject) const
     213             :     { return rObject < *this; }
     214             : 
     215             :     // Strict Parsing:
     216             : 
     217             :     inline explicit INetURLObject(
     218             :         OUString const & rTheAbsURIRef,
     219             :         EncodeMechanism eMechanism = WAS_ENCODED,
     220             :         rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
     221             : 
     222             :     inline bool SetURL(OUString const & rTheAbsURIRef,
     223             :                        EncodeMechanism eMechanism = WAS_ENCODED,
     224             :                        rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
     225             : 
     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);
     232             : 
     233             :     // Smart Parsing:
     234             : 
     235             :     /** The supported notations for file system paths.
     236             :      */
     237             :     enum FSysStyle
     238             :     {
     239             :         /** VOS notation (e.g., "//server/dir/file").
     240             :          */
     241             :         FSYS_VOS = 0x1,
     242             : 
     243             :         /** Unix notation (e.g., "/dir/file").
     244             :          */
     245             :         FSYS_UNX = 0x2,
     246             : 
     247             :         /** DOS notation (e.g., "a:\dir\file" and "\\server\dir\file").
     248             :          */
     249             :         FSYS_DOS = 0x4,
     250             : 
     251             :         /** Detect the used notation.
     252             : 
     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.
     256             : 
     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):
     262             : 
     263             :              Production T1 (VOS local; FSYS_VOS only):
     264             :                 "//." ["/" *UCS4]
     265             :               becomes
     266             :                 "file:///" *UCS4
     267             : 
     268             :              Production T2 (VOS host; FSYS_VOS only):
     269             :                 "//" [host] ["/" *UCS4]
     270             :               becomes
     271             :                 "file://" host "/" *UCS4
     272             : 
     273             :              Production T3 (UNC; FSYS_DOS only):
     274             :                 "\\" [host] ["\" *UCS4]
     275             :               becomes
     276             :                 "file://" host "/" *UCS4
     277             :               replacing "\" by "/" within <*UCS4>
     278             : 
     279             :              Production T4 (Unix-like DOS; FSYS_DOS only):
     280             :                 ALPHA ":" ["/" *UCS4]
     281             :               becomes
     282             :                 "file:///" ALPHA ":/" *UCS4
     283             :               replacing "\" by "/" within <*UCS4>
     284             : 
     285             :              Production T5 (DOS; FSYS_DOS only):
     286             :                 ALPHA ":" ["\" *UCS4]
     287             :               becomes
     288             :                 "file:///" ALPHA ":/" *UCS4
     289             :               replacing "\" by "/" within <*UCS4>
     290             : 
     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.
     303             : 
     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):
     307             : 
     308             :              Production F1 (VOS; FSYS_VOS):
     309             :                 "file://" host "/" fpath ["#" fragment]
     310             :               becomes
     311             :                 "//" host "/" fpath
     312             : 
     313             :              Production F2 (DOS; FSYS_DOS):
     314             :                 "file:///" ALPHA ":" ["/" fpath] ["#" fragment]
     315             :               becomes
     316             :                 ALPHA ":" ["\" fpath]
     317             :               replacing "/" by "\" in <fpath>
     318             : 
     319             :              Production F3 (Unix; FSYS_UNX):
     320             :                 "file:///" fpath ["#" fragment]
     321             :               becomes
     322             :                 "/" fpath
     323             :          */
     324             :         FSYS_DETECT = FSYS_VOS | FSYS_UNX | FSYS_DOS
     325             :     };
     326             : 
     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);
     332             : 
     333         296 :     inline void SetSmartProtocol(INetProtocol eTheSmartScheme)
     334         296 :     { m_eSmartScheme = eTheSmartScheme; }
     335             : 
     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);
     341             : 
     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;
     350             : 
     351             :     // Relative URLs:
     352             : 
     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;
     360             : 
     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.
     367             :      */
     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);
     376             : 
     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);
     384             : 
     385             :     // External URLs:
     386             : 
     387             :     OUString getExternalURL(DecodeMechanism eMechanism = DECODE_TO_IURI,
     388             :                              rtl_TextEncoding eCharset
     389             :                                  = RTL_TEXTENCODING_UTF8) const;
     390             : 
     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);
     397             : 
     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);
     404             : 
     405             :     // Scheme:
     406             : 
     407             :     struct SchemeInfo;
     408             : 
     409     1204883 :     inline INetProtocol GetProtocol() const { return m_eScheme; }
     410             : 
     411             :     /** Return the URL 'prefix' for a given scheme.
     412             : 
     413             :         @param eTheScheme  One of the supported URL schemes.
     414             : 
     415             :         @return  The 'prefix' of URLs of the given scheme.
     416             :      */
     417             :     static OUString GetScheme(INetProtocol eTheScheme);
     418             : 
     419             :     /** Return the a human-readable name for a given scheme.
     420             : 
     421             :         @param eTheScheme  One of the supported URL schemes.
     422             : 
     423             :         @return  The protocol name of URLs of the given scheme.
     424             :      */
     425             :     static OUString GetSchemeName(INetProtocol eTheScheme);
     426             : 
     427             :     static INetProtocol CompareProtocolScheme(OUString const &
     428             :                                                   rTheAbsURIRef);
     429             : 
     430             :     // User Info:
     431             : 
     432           1 :     inline bool HasUserData() const { return m_aUser.isPresent(); }
     433             : 
     434             :     inline bool IsEmptyUser() const
     435             :     { return m_aUser.isPresent() && m_aUser.isEmpty(); }
     436             : 
     437      418834 :     inline OUString GetUser(DecodeMechanism eMechanism = DECODE_TO_IURI,
     438             :                              rtl_TextEncoding eCharset
     439             :                                  = RTL_TEXTENCODING_UTF8) const
     440      418834 :     { return decode(m_aUser, eMechanism, eCharset); }
     441             : 
     442      418833 :     inline OUString GetPass(DecodeMechanism eMechanism = DECODE_TO_IURI,
     443             :                              rtl_TextEncoding eCharset
     444             :                                  = RTL_TEXTENCODING_UTF8) const
     445      418833 :     { return decode(m_aAuth, eMechanism, eCharset); }
     446             : 
     447           0 :     inline bool SetUser(OUString const & rTheUser,
     448             :                         EncodeMechanism eMechanism = WAS_ENCODED,
     449             :                         rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
     450           0 :     { return setUser(rTheUser, false, eMechanism, eCharset); }
     451             : 
     452             :     inline bool SetPass(OUString const & rThePassword,
     453             :                         EncodeMechanism eMechanism = WAS_ENCODED,
     454             :                         rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
     455             : 
     456             :     inline bool SetUserAndPass(OUString const & rTheUser,
     457             :                                OUString const & rThePassword,
     458             :                                EncodeMechanism eMechanism = WAS_ENCODED,
     459             :                                rtl_TextEncoding eCharset
     460             :                                    = RTL_TEXTENCODING_UTF8);
     461             : 
     462             :     // Host and Port:
     463             : 
     464         532 :     inline bool HasPort() const { return m_aPort.isPresent(); }
     465             : 
     466      418845 :     inline OUString GetHost(DecodeMechanism eMechanism = DECODE_TO_IURI,
     467             :                              rtl_TextEncoding eCharset
     468             :                                  = RTL_TEXTENCODING_UTF8) const
     469      418845 :     { return decode(m_aHost, eMechanism, eCharset); }
     470             : 
     471             :     OUString GetHostPort(DecodeMechanism eMechanism = DECODE_TO_IURI,
     472             :                           rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
     473             : 
     474             :     sal_uInt32 GetPort() const;
     475             : 
     476           0 :     inline bool SetHost(OUString const & rTheHost,
     477             :                         EncodeMechanism eMechanism = WAS_ENCODED,
     478             :                         rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
     479           0 :     { return setHost(rTheHost, false, eMechanism, eCharset); }
     480             : 
     481             :     bool SetPort(sal_uInt32 nThePort);
     482             : 
     483             :     // Path:
     484             : 
     485         532 :     inline bool HasURLPath() const { return !m_aPath.isEmpty(); }
     486             : 
     487      529091 :     inline OUString GetURLPath(DecodeMechanism eMechanism = DECODE_TO_IURI,
     488             :                                 rtl_TextEncoding eCharset
     489             :                                     = RTL_TEXTENCODING_UTF8) const
     490      529091 :     { return decode(m_aPath, eMechanism, eCharset); }
     491             : 
     492         122 :     inline bool SetURLPath(OUString const & rThePath,
     493             :                            EncodeMechanism eMechanism = WAS_ENCODED,
     494             :                            rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
     495         122 :     { return setPath(rThePath, false, eMechanism, eCharset); }
     496             : 
     497             :     // Hierarchical Path:
     498             : 
     499             :     /** A constant to address the last segment in various methods dealing with
     500             :         hierarchical paths.
     501             : 
     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().
     505             :      */
     506             :     enum { LAST_SEGMENT = -1 };
     507             : 
     508             :     /** The number of segments in the hierarchical path.
     509             : 
     510             :         @descr  Using RFC 2396 and RFC 2234, a hierarchical path is of the
     511             :         form
     512             : 
     513             :           hierarchical-path = 1*("/" segment)
     514             : 
     515             :           segment = name *(";" param)
     516             : 
     517             :           name = [base ["." extension]]
     518             : 
     519             :           base = 1*pchar
     520             : 
     521             :           extension = *<any pchar except ".">
     522             : 
     523             :           param = *pchar
     524             : 
     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.
     527             : 
     528             :         @return  The number of segments in the hierarchical path.  If the path
     529             :         is not hierarchical, 0 is returned.
     530             :      */
     531             :     sal_Int32 getSegmentCount(bool bIgnoreFinalSlash = true) const;
     532             : 
     533             :     /** Remove a segment from the hierarchical path.
     534             : 
     535             :         @param nIndex  The non-negative index of the segment, or LAST_SEGMENT
     536             :         if addressing the last segment.
     537             : 
     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.
     540             : 
     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.
     545             :      */
     546             :     bool removeSegment(sal_Int32 nIndex = LAST_SEGMENT,
     547             :                        bool bIgnoreFinalSlash = true);
     548             : 
     549             :     /** Insert a new segment into the hierarchical path.
     550             : 
     551             :         @param rTheName  The name part of the new segment.  The new segment
     552             :         will contain no parameters.
     553             : 
     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.
     557             : 
     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.
     562             : 
     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.
     565             : 
     566             :         @param eMechanism  See the general discussion for set-methods.
     567             : 
     568             :         @param eCharset  See the general discussion for set-methods.
     569             : 
     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.
     574             :      */
     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);
     581             : 
     582             :     /** Get the name of a segment of the hierarchical path.
     583             : 
     584             :         @param nIndex  The non-negative index of the segment, or LAST_SEGMENT
     585             :         if addressing the last segment.
     586             : 
     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.
     589             : 
     590             :         @param eMechanism  See the general discussion for get-methods.
     591             : 
     592             :         @param eCharset  See the general discussion for get-methods.
     593             : 
     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.
     597             :      */
     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;
     603             : 
     604             :     /** Set the name of a segment (preserving any parameters and any query or
     605             :         fragment part).
     606             : 
     607             :         @param rTheName  The new name.
     608             : 
     609             :         @param nIndex  The non-negative index of the segment, or LAST_SEGMENT
     610             :         if addressing the last segment.
     611             : 
     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.
     614             : 
     615             :         @param eMechanism  See the general discussion for set-methods.
     616             : 
     617             :         @param eCharset  See the general discussion for set-methods.
     618             : 
     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.
     623             :      */
     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);
     629             : 
     630             :     /** Get the base of the name of a segment.
     631             : 
     632             :         @param nIndex  The non-negative index of the segment, or LAST_SEGMENT
     633             :         if addressing the last segment.
     634             : 
     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.
     637             : 
     638             :         @param eMechanism  See the general discussion for get-methods.
     639             : 
     640             :         @param eCharset  See the general discussion for get-methods.
     641             : 
     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.
     645             :      */
     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;
     651             : 
     652             :     /** Set the base of the name of a segment (preserving the extension).
     653             : 
     654             :         @param rTheBase  The new base.
     655             : 
     656             :         @param nIndex  The non-negative index of the segment, or LAST_SEGMENT
     657             :         if addressing the last segment.
     658             : 
     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.
     661             : 
     662             :         @param eMechanism  See the general discussion for set-methods.
     663             : 
     664             :         @param eCharset  See the general discussion for set-methods.
     665             : 
     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.
     670             :      */
     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);
     676             : 
     677             :     /** Determine whether the name of a segment has an extension.
     678             : 
     679             :         @param nIndex  The non-negative index of the segment, or LAST_SEGMENT
     680             :         if addressing the last segment.
     681             : 
     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.
     684             : 
     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.
     688             :      */
     689             :     bool hasExtension(sal_Int32 nIndex = LAST_SEGMENT,
     690             :                       bool bIgnoreFinalSlash = true) const;
     691             : 
     692             :     /** Get the extension of the name of a segment.
     693             : 
     694             :         @param nIndex  The non-negative index of the segment, or LAST_SEGMENT
     695             :         if addressing the last segment.
     696             : 
     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.
     699             : 
     700             :         @param eMechanism  See the general discussion for get-methods.
     701             : 
     702             :         @param eCharset  See the general discussion for get-methods.
     703             : 
     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.
     707             :      */
     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;
     713             : 
     714             :     /** Set the extension of the name of a segment (replacing an already
     715             :         existing extension).
     716             : 
     717             :         @param rTheExtension  The new extension.
     718             : 
     719             :         @param nIndex  The non-negative index of the segment, or LAST_SEGMENT
     720             :         if addressing the last segment.
     721             : 
     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.
     724             : 
     725             :         @param eMechanism  See the general discussion for set-methods.
     726             : 
     727             :         @param eCharset  See the general discussion for set-methods.
     728             : 
     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.
     733             :      */
     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);
     739             : 
     740             :     /** Remove the extension of the name of a segment.
     741             : 
     742             :         @param nIndex  The non-negative index of the segment, or LAST_SEGMENT
     743             :         if addressing the last segment.
     744             : 
     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.
     747             : 
     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.
     753             :      */
     754             :     bool removeExtension(sal_Int32 nIndex = LAST_SEGMENT,
     755             :                          bool bIgnoreFinalSlash = true);
     756             : 
     757             :     /** Determine whether the hierarchical path ends in a final slash.
     758             : 
     759             :         @return  True if the hierarchical path ends in a final slash.  If the
     760             :         path is not hierarchical, false is returned.
     761             :      */
     762             :     bool hasFinalSlash() const;
     763             : 
     764             :     /** Make the hierarchical path end in a final slash (if it does not
     765             :         already do so).
     766             : 
     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.
     771             :      */
     772             :     bool setFinalSlash();
     773             : 
     774             :     /** Remove a final slash from the hierarchical path.
     775             : 
     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.
     780             :      */
     781             :     bool removeFinalSlash();
     782             : 
     783             :     // Query:
     784             : 
     785       33794 :     inline bool HasParam() const { return m_aQuery.isPresent(); }
     786             : 
     787      418833 :     inline OUString GetParam(DecodeMechanism eMechanism = DECODE_TO_IURI,
     788             :                               rtl_TextEncoding eCharset
     789             :                                   = RTL_TEXTENCODING_UTF8) const
     790      418833 :     { return decode(m_aQuery, eMechanism, eCharset); }
     791             : 
     792             :     inline bool SetParam(OUString const & rTheQuery,
     793             :                          EncodeMechanism eMechanism = WAS_ENCODED,
     794             :                          rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
     795             : 
     796             :     // Fragment:
     797             : 
     798       24834 :     inline bool HasMark() const { return m_aFragment.isPresent(); }
     799             : 
     800      385384 :     inline OUString GetMark(DecodeMechanism eMechanism = DECODE_TO_IURI,
     801             :                              rtl_TextEncoding eCharset
     802             :                                  = RTL_TEXTENCODING_UTF8) const
     803      385384 :     { return decode(m_aFragment, eMechanism, eCharset); }
     804             : 
     805             :     inline bool SetMark(OUString const & rTheFragment,
     806             :                         EncodeMechanism eMechanism = WAS_ENCODED,
     807             :                         rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
     808             : 
     809             :     // File URLs:
     810             : 
     811             :     /** Create an INetURLObject from a file system path.
     812             : 
     813             :         @param rFSysPath  A file system path.  An URL is not allowed here!
     814             : 
     815             :         @param eStyle  The notation of rFSysPath.
     816             :      */
     817             :     inline INetURLObject(OUString const & rFSysPath, FSysStyle eStyle);
     818             : 
     819             :     /** Set this INetURLObject to a file URL constructed from a file system
     820             :         path.
     821             : 
     822             :         @param rFSysPath  A file system path.  An URL is not allowed here!
     823             : 
     824             :         @param eStyle  The notation of rFSysPath.
     825             : 
     826             :         @return  True if this INetURLObject has successfully been changed.  If
     827             :         false is returned, this INetURLObject has not been modified.
     828             :      */
     829             :     bool setFSysPath(OUString const & rFSysPath, FSysStyle eStyle);
     830             : 
     831             :     /** Return the file system path represented by a file URL (ignoring any
     832             :         fragment part).
     833             : 
     834             :         @param eStyle  The notation of the returned file system path.
     835             : 
     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.
     842             : 
     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.
     847             :      */
     848             :     OUString getFSysPath(FSysStyle eStyle, sal_Unicode * pDelimiter = 0)
     849             :         const;
     850             : 
     851             :     // Data URLs:
     852             :     std::unique_ptr<SvMemoryStream> getData();
     853             : 
     854             :     // POP3 and URLs:
     855             : 
     856             :     static OUString GetMsgId(DecodeMechanism eMechanism = DECODE_TO_IURI,
     857             :                        rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
     858             : 
     859             :     // Coding:
     860             : 
     861             :     enum Part
     862             :     {
     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?
     879             :     };
     880             : 
     881             :     enum EscapeType
     882             :     {
     883             :         ESCAPE_NO,
     884             :         ESCAPE_OCTET,
     885             :         ESCAPE_UTF32
     886             :     };
     887             : 
     888             :     /** Encode some text as part of a URI.
     889             : 
     890             :         @param rText  Some text (for its interpretation, see the general
     891             :         discussion for set-methods).
     892             : 
     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.'
     896             : 
     897             :         @param eMechanism  See the general discussion for set-methods.
     898             : 
     899             :         @param eCharset  See the general discussion for set-methods.
     900             : 
     901             :         @return  The text, encoded according to the given mechanism and
     902             :         charset ('forbidden' characters replaced by escape sequences).
     903             :      */
     904             :     static inline OUString encode(OUString const & rText, Part ePart,
     905             :                                    EncodeMechanism eMechanism,
     906             :                                    rtl_TextEncoding eCharset
     907             :                                        = RTL_TEXTENCODING_UTF8);
     908             : 
     909             :     /** Decode some text.
     910             : 
     911             :         @param rText  Some (encoded) text.
     912             : 
     913             :         @param eMechanism  See the general discussion for get-methods.
     914             : 
     915             :         @param eCharset  See the general discussion for get-methods.
     916             : 
     917             :         @return  The text, decoded according to the given mechanism and
     918             :         charset (escape sequences replaced by 'raw' characters).
     919             :      */
     920             :     static inline OUString decode(OUString const & rText,
     921             :                                    DecodeMechanism eMechanism,
     922             :                                    rtl_TextEncoding eCharset
     923             :                                        = RTL_TEXTENCODING_UTF8);
     924             : 
     925             :     static inline OUString decode(OUStringBuffer const & rText,
     926             :                                    DecodeMechanism eMechanism,
     927             :                                    rtl_TextEncoding eCharset
     928             :                                        = RTL_TEXTENCODING_UTF8);
     929             : 
     930             :     static void appendUCS4Escape(OUStringBuffer & rTheText, sal_uInt32 nUCS4);
     931             : 
     932             :     static void appendUCS4(OUStringBuffer & rTheText, sal_uInt32 nUCS4,
     933             :                            EscapeType eEscapeType, bool bOctets, Part ePart,
     934             :                            rtl_TextEncoding eCharset, bool bKeepVisibleEscapes);
     935             : 
     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);
     941             : 
     942             :     // Specialized helpers:
     943             : 
     944             :     static sal_uInt32 scanDomain(sal_Unicode const *& rBegin,
     945             :                                  sal_Unicode const * pEnd,
     946             :                                  bool bEager = true);
     947             : 
     948             :     // OBSOLETE Hierarchical Path:
     949             : 
     950             :     OUString GetPartBeforeLastName(DecodeMechanism eMechanism
     951             :                                         = DECODE_TO_IURI,
     952             :                                     rtl_TextEncoding eCharset
     953             :                                         = RTL_TEXTENCODING_UTF8) const;
     954             : 
     955             :     /** Get the last segment in the path.
     956             : 
     957             :         @param eMechanism  See the general discussion for get-methods.
     958             : 
     959             :         @param eCharset  See the general discussion for get-methods.
     960             : 
     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.
     964             :      */
     965             :     OUString GetLastName(DecodeMechanism eMechanism = DECODE_TO_IURI,
     966             :                           rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
     967             :         const;
     968             : 
     969             :     /** Get the 'extension' of the last segment in the path.
     970             : 
     971             :         @param eMechanism  See the general discussion for get-methods.
     972             : 
     973             :         @param eCharset  See the general discussion for get-methods.
     974             : 
     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.
     979             :      */
     980             :     OUString GetFileExtension(DecodeMechanism eMechanism = DECODE_TO_IURI,
     981             :                                rtl_TextEncoding eCharset
     982             :                                    = RTL_TEXTENCODING_UTF8) const;
     983             : 
     984       17559 :     inline bool Append(OUString const & rTheSegment,
     985             :                        EncodeMechanism eMechanism = WAS_ENCODED,
     986             :                        rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
     987       17559 :     { return appendSegment(rTheSegment, false, eMechanism, eCharset); }
     988             : 
     989             :     bool CutLastName();
     990             : 
     991             :     // OBSOLETE File URLs:
     992             : 
     993             :     OUString PathToFileName() const;
     994             : 
     995             :     OUString GetFull() const;
     996             : 
     997             :     OUString GetPath() const;
     998             : 
     999             :     void SetBase(OUString const & rTheBase);
    1000             : 
    1001             :     OUString GetBase() const;
    1002             : 
    1003             :     void SetName(OUString const & rTheName,
    1004             :                  EncodeMechanism eMechanism = WAS_ENCODED,
    1005             :                  rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
    1006             : 
    1007      377964 :     inline OUString GetName(DecodeMechanism eMechanism = DECODE_TO_IURI,
    1008             :                              rtl_TextEncoding eCharset
    1009             :                                  = RTL_TEXTENCODING_UTF8) const
    1010      377964 :     { return GetLastName(eMechanism, eCharset); }
    1011             : 
    1012             :     void SetExtension(OUString const & rTheExtension,
    1013             :                       EncodeMechanism eMechanism = WAS_ENCODED,
    1014             :                       rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
    1015             : 
    1016         157 :     inline OUString GetExtension(
    1017             :                                   DecodeMechanism eMechanism = DECODE_TO_IURI,
    1018             :                                   rtl_TextEncoding eCharset
    1019             :                                       = RTL_TEXTENCODING_UTF8) const
    1020         157 :     { return GetFileExtension(eMechanism, eCharset); }
    1021             : 
    1022             :     OUString CutExtension(DecodeMechanism eMechanism = DECODE_TO_IURI,
    1023             :                            rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
    1024             : 
    1025        3644 :     static bool IsCaseSensitive() { return true; }
    1026             : 
    1027             : 
    1028             : private:
    1029             :     // General Structure:
    1030             : 
    1031             :     class SubString
    1032             :     {
    1033             :         sal_Int32 m_nBegin;
    1034             :         sal_Int32 m_nLength;
    1035             : 
    1036             :     public:
    1037    10642746 :         explicit inline SubString(sal_Int32 nTheBegin = -1,
    1038             :                                   sal_Int32 nTheLength = 0):
    1039    10642746 :             m_nBegin(nTheBegin), m_nLength(nTheLength) {}
    1040             : 
    1041     4607737 :         inline bool isPresent() const { return m_nBegin != -1; }
    1042             : 
    1043      507646 :         inline bool isEmpty() const { return m_nLength == 0; }
    1044             : 
    1045     1244598 :         inline sal_Int32 getBegin() const { return m_nBegin; }
    1046             : 
    1047      636546 :         inline sal_Int32 getLength() const { return m_nLength; }
    1048             : 
    1049      613679 :         inline sal_Int32 getEnd() const { return m_nBegin + m_nLength; }
    1050             : 
    1051             :         inline sal_Int32 clear();
    1052             : 
    1053             :         inline sal_Int32 set(OUStringBuffer & rString,
    1054             :                              OUString const & rSubString,
    1055             :                              sal_Int32 nTheBegin);
    1056             : 
    1057             :         inline sal_Int32 set(OUString & rString,
    1058             :                              OUString const & rSubString);
    1059             : 
    1060             :         inline sal_Int32 set(OUStringBuffer & rString,
    1061             :                              OUString const & rSubString);
    1062             : 
    1063             :         inline void operator +=(sal_Int32 nDelta);
    1064             : 
    1065             :         int compare(SubString const & rOther,
    1066             :             OUStringBuffer const & rThisString,
    1067             :             OUStringBuffer const & rOtherString) const;
    1068             :     };
    1069             : 
    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;
    1081             : 
    1082             :     TOOLS_DLLPRIVATE void setInvalid();
    1083             : 
    1084             :     bool setAbsURIRef(
    1085             :         OUString const & rTheAbsURIRef, bool bOctets,
    1086             :         EncodeMechanism eMechanism, rtl_TextEncoding eCharset, bool bSmart,
    1087             :         FSysStyle eStyle);
    1088             : 
    1089             :     // Relative URLs:
    1090             : 
    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;
    1097             : 
    1098             :     bool convertAbsToRel(
    1099             :         OUString const & rTheAbsURIRef, bool bOctets,
    1100             :         OUString & rTheRelURIRef, EncodeMechanism eEncodeMechanism,
    1101             :         DecodeMechanism eDecodeMechanism, rtl_TextEncoding eCharset,
    1102             :         FSysStyle eStyle) const;
    1103             : 
    1104             :     // External URLs:
    1105             : 
    1106             :     static bool convertIntToExt(
    1107             :         OUString const & rTheIntURIRef, bool bOctets,
    1108             :         OUString & rTheExtURIRef, DecodeMechanism eDecodeMechanism,
    1109             :         rtl_TextEncoding eCharset);
    1110             : 
    1111             :     static bool convertExtToInt(
    1112             :         OUString const & rTheExtURIRef, bool bOctets,
    1113             :         OUString & rTheIntURIRef, DecodeMechanism eDecodeMechanism,
    1114             :         rtl_TextEncoding eCharset);
    1115             : 
    1116             :     // Scheme:
    1117             : 
    1118             :     struct PrefixInfo;
    1119             : 
    1120             :     TOOLS_DLLPRIVATE static inline SchemeInfo const & getSchemeInfo(
    1121             :         INetProtocol eTheScheme);
    1122             : 
    1123             :     TOOLS_DLLPRIVATE inline SchemeInfo const & getSchemeInfo() const;
    1124             : 
    1125             :     TOOLS_DLLPRIVATE static PrefixInfo const * getPrefix(
    1126             :         sal_Unicode const *& rBegin, sal_Unicode const * pEnd);
    1127             : 
    1128             :     // Authority:
    1129             : 
    1130             :     TOOLS_DLLPRIVATE sal_Int32 getAuthorityBegin() const;
    1131             : 
    1132             :     TOOLS_DLLPRIVATE SubString getAuthority() const;
    1133             : 
    1134             :     // User Info:
    1135             : 
    1136             :     bool setUser(
    1137             :         OUString const & rTheUser, bool bOctets,
    1138             :         EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
    1139             : 
    1140             :     bool clearPassword();
    1141             : 
    1142             :     bool setPassword(
    1143             :         OUString const & rThePassword, bool bOctets,
    1144             :         EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
    1145             : 
    1146             :     // Host and Port:
    1147             : 
    1148             :     TOOLS_DLLPRIVATE static bool parseHost(
    1149             :         sal_Unicode const *& rBegin, sal_Unicode const * pEnd,
    1150             :         OUString & rCanonic);
    1151             : 
    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);
    1156             : 
    1157             :     bool setHost(
    1158             :         OUString const & rTheHost, bool bOctets,
    1159             :         EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
    1160             : 
    1161             :     // Path:
    1162             : 
    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);
    1170             : 
    1171             :     bool setPath(
    1172             :         OUString const & rThePath, bool bOctets,
    1173             :         EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
    1174             : 
    1175             :     // Hierarchical Path:
    1176             : 
    1177             :     TOOLS_DLLPRIVATE bool checkHierarchical() const;
    1178             : 
    1179             :     bool appendSegment(
    1180             :         OUString const & rTheSegment, bool bOctets,
    1181             :         EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
    1182             : 
    1183             :     TOOLS_DLLPRIVATE SubString getSegment(
    1184             :         sal_Int32 nIndex, bool bIgnoreFinalSlash) const;
    1185             : 
    1186             :     bool insertName(
    1187             :         OUString const & rTheName, bool bOctets, bool bAppendFinalSlash,
    1188             :         sal_Int32 nIndex, bool bIgnoreFinalSlash, EncodeMechanism eMechanism,
    1189             :         rtl_TextEncoding eCharset);
    1190             : 
    1191             :     // Query:
    1192             : 
    1193             :     bool clearQuery();
    1194             : 
    1195             :     bool setQuery(
    1196             :         OUString const & rTheQuery, bool bOctets,
    1197             :         EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
    1198             : 
    1199             :     // Fragment:
    1200             : 
    1201             :     bool clearFragment();
    1202             : 
    1203             :     bool setFragment(
    1204             :         OUString const & rTheMark, bool bOctets,
    1205             :         EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
    1206             : 
    1207             :     // FILE URLs:
    1208             : 
    1209             :     TOOLS_DLLPRIVATE bool hasDosVolume(FSysStyle eStyle) const;
    1210             : 
    1211             :     // Coding:
    1212             : 
    1213             :     TOOLS_DLLPRIVATE static inline void appendEscape(
    1214             :         OUStringBuffer & rTheText, sal_uInt32 nOctet);
    1215             : 
    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);
    1220             : 
    1221             :     static inline OUString encodeText(
    1222             :         OUString const & rTheText, bool bOctets, Part ePart,
    1223             :         EncodeMechanism eMechanism, rtl_TextEncoding eCharset,
    1224             :         bool bKeepVisibleEscapes);
    1225             : 
    1226             :     static OUString decode(
    1227             :         sal_Unicode const * pBegin, sal_Unicode const * pEnd,
    1228             :         DecodeMechanism, rtl_TextEncoding eCharset);
    1229             : 
    1230             :     inline OUString decode(
    1231             :         SubString const & rSubString,
    1232             :         DecodeMechanism eMechanism, rtl_TextEncoding eCharset) const;
    1233             : 
    1234             :     // Specialized helpers:
    1235             : 
    1236             :     TOOLS_DLLPRIVATE static bool scanIPv6reference(
    1237             :         sal_Unicode const *& rBegin, sal_Unicode const * pEnd);
    1238             : 
    1239             : private:
    1240             :     void changeScheme(INetProtocol eTargetScheme);
    1241             : };
    1242             : 
    1243             : // static
    1244       26271 : inline OUString INetURLObject::encodeText(OUString const & rTheText,
    1245             :                                            bool bOctets, Part ePart,
    1246             :                                            EncodeMechanism eMechanism,
    1247             :                                            rtl_TextEncoding eCharset,
    1248             :                                            bool bKeepVisibleEscapes)
    1249             : {
    1250             :     return encodeText(rTheText.getStr(),
    1251       26271 :                       rTheText.getStr() + rTheText.getLength(), bOctets, ePart,
    1252       52542 :                       eMechanism, eCharset, bKeepVisibleEscapes);
    1253             : }
    1254             : 
    1255     2589836 : inline OUString INetURLObject::decode(SubString const & rSubString,
    1256             :                                        DecodeMechanism eMechanism,
    1257             :                                        rtl_TextEncoding eCharset) const
    1258             : {
    1259     2589836 :     return rSubString.isPresent() ?
    1260      570412 :                decode(m_aAbsURIRef.getStr() + rSubString.getBegin(),
    1261      570412 :                       m_aAbsURIRef.getStr() + rSubString.getEnd(),
    1262             :                       eMechanism, eCharset) :
    1263     3730660 :                OUString();
    1264             : }
    1265             : 
    1266     1078119 : inline INetURLObject::INetURLObject(OUString const & rTheAbsURIRef,
    1267             :                                     EncodeMechanism eMechanism,
    1268             :                                     rtl_TextEncoding eCharset):
    1269     1078119 :     m_eScheme(INetProtocol::NotValid), m_eSmartScheme(INetProtocol::Http)
    1270             : {
    1271             :     setAbsURIRef(rTheAbsURIRef, false, eMechanism, eCharset, false,
    1272     1078119 :                  FSysStyle(0));
    1273     1078119 : }
    1274             : 
    1275        4810 : inline bool INetURLObject::SetURL(OUString const & rTheAbsURIRef,
    1276             :                                   EncodeMechanism eMechanism,
    1277             :                                   rtl_TextEncoding eCharset)
    1278             : {
    1279             :     return setAbsURIRef(rTheAbsURIRef, false, eMechanism, eCharset, false,
    1280        4810 :                         FSysStyle(0));
    1281             : }
    1282             : 
    1283       25310 : inline INetURLObject::INetURLObject(OUString const & rTheAbsURIRef,
    1284             :                                     INetProtocol eTheSmartScheme,
    1285             :                                     EncodeMechanism eMechanism,
    1286             :                                     rtl_TextEncoding eCharset,
    1287             :                                     FSysStyle eStyle):
    1288       25310 :     m_eScheme(INetProtocol::NotValid), m_eSmartScheme(eTheSmartScheme)
    1289             : {
    1290       25310 :     setAbsURIRef(rTheAbsURIRef, false, eMechanism, eCharset, true, eStyle);
    1291       25310 : }
    1292             : 
    1293        1066 : inline bool INetURLObject::SetSmartURL(OUString const & rTheAbsURIRef,
    1294             :                                        EncodeMechanism eMechanism,
    1295             :                                        rtl_TextEncoding eCharset,
    1296             :                                        FSysStyle eStyle)
    1297             : {
    1298             :     return setAbsURIRef(rTheAbsURIRef, false, eMechanism, eCharset, true,
    1299        1066 :                         eStyle);
    1300             : }
    1301             : 
    1302             : inline INetURLObject
    1303         188 : 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
    1310             : {
    1311         188 :     INetURLObject aTheAbsURIRef;
    1312             :     convertRelToAbs(rTheRelURIRef, false, aTheAbsURIRef, rWasAbsolute,
    1313             :                     eMechanism, eCharset, bIgnoreFragment, true,
    1314         188 :                     bRelativeNonURIs, eStyle);
    1315         188 :     return aTheAbsURIRef;
    1316             : }
    1317             : 
    1318         161 : inline bool INetURLObject::GetNewAbsURL(OUString const & rTheRelURIRef,
    1319             :                                         INetURLObject * pTheAbsURIRef,
    1320             :                                         EncodeMechanism eMechanism,
    1321             :                                         rtl_TextEncoding eCharset,
    1322             :                                         FSysStyle eStyle, bool bIgnoreFragment)
    1323             :     const
    1324             : {
    1325         161 :     INetURLObject aTheAbsURIRef;
    1326             :     bool bWasAbsolute;
    1327         161 :     if (!convertRelToAbs(rTheRelURIRef, false, aTheAbsURIRef, bWasAbsolute,
    1328             :                          eMechanism, eCharset, bIgnoreFragment, false, false,
    1329         161 :                          eStyle))
    1330           0 :         return false;
    1331         161 :     if (pTheAbsURIRef)
    1332         161 :         *pTheAbsURIRef = aTheAbsURIRef;
    1333         161 :     return true;
    1334             : }
    1335             : 
    1336             : // static
    1337          97 : inline OUString INetURLObject::GetRelURL(OUString const & rTheBaseURIRef,
    1338             :                                           OUString const & rTheAbsURIRef,
    1339             :                                           EncodeMechanism eEncodeMechanism,
    1340             :                                           DecodeMechanism eDecodeMechanism,
    1341             :                                           rtl_TextEncoding eCharset,
    1342             :                                           FSysStyle eStyle)
    1343             : {
    1344          97 :     OUString aTheRelURIRef;
    1345             :     INetURLObject(rTheBaseURIRef, eEncodeMechanism, eCharset).
    1346             :         convertAbsToRel(rTheAbsURIRef, false, aTheRelURIRef, eEncodeMechanism,
    1347          97 :                         eDecodeMechanism, eCharset, eStyle);
    1348          97 :     return aTheRelURIRef;
    1349             : }
    1350             : 
    1351             : // static
    1352           0 : inline bool INetURLObject::translateToExternal(OUString const &
    1353             :                                                    rTheIntURIRef,
    1354             :                                                OUString & rTheExtURIRef,
    1355             :                                                DecodeMechanism
    1356             :                                                    eDecodeMechanism,
    1357             :                                                rtl_TextEncoding eCharset)
    1358             : {
    1359             :     return convertIntToExt(rTheIntURIRef, false, rTheExtURIRef,
    1360           0 :                            eDecodeMechanism, eCharset);
    1361             : }
    1362             : 
    1363             : // static
    1364           0 : inline bool INetURLObject::translateToInternal(OUString const &
    1365             :                                                    rTheExtURIRef,
    1366             :                                                OUString & rTheIntURIRef,
    1367             :                                                DecodeMechanism
    1368             :                                                    eDecodeMechanism,
    1369             :                                                rtl_TextEncoding eCharset)
    1370             : {
    1371             :     return convertExtToInt(rTheExtURIRef, false, rTheIntURIRef,
    1372           0 :                            eDecodeMechanism, eCharset);
    1373             : }
    1374             : 
    1375           0 : inline bool INetURLObject::SetPass(OUString const & rThePassword,
    1376             :                                    EncodeMechanism eMechanism,
    1377             :                                    rtl_TextEncoding eCharset)
    1378             : {
    1379           0 :     return rThePassword.isEmpty() ?
    1380             :                clearPassword() :
    1381           0 :                setPassword(rThePassword, false, eMechanism, eCharset);
    1382             : }
    1383             : 
    1384           0 : inline bool INetURLObject::SetUserAndPass(OUString const & rTheUser,
    1385             :                                           OUString const & rThePassword,
    1386             :                                           EncodeMechanism eMechanism,
    1387             :                                           rtl_TextEncoding eCharset)
    1388             : {
    1389           0 :     return setUser(rTheUser, false, eMechanism, eCharset)
    1390           0 :            && (rThePassword.isEmpty() ?
    1391           0 :                    clearPassword() :
    1392           0 :                    setPassword(rThePassword, false, eMechanism, eCharset));
    1393             : }
    1394             : 
    1395        4032 : inline bool INetURLObject::insertName(OUString const & rTheName,
    1396             :                                       bool bAppendFinalSlash,
    1397             :                                       sal_Int32 nIndex,
    1398             :                                       bool bIgnoreFinalSlash,
    1399             :                                       EncodeMechanism eMechanism,
    1400             :                                       rtl_TextEncoding eCharset)
    1401             : {
    1402             :     return insertName(rTheName, false, bAppendFinalSlash, nIndex,
    1403        4032 :                       bIgnoreFinalSlash, eMechanism, eCharset);
    1404             : }
    1405             : 
    1406      385087 : inline bool INetURLObject::SetParam(OUString const & rTheQuery,
    1407             :                                     EncodeMechanism eMechanism,
    1408             :                                     rtl_TextEncoding eCharset)
    1409             : {
    1410      385087 :     return rTheQuery.isEmpty() ?
    1411             :                clearQuery() :
    1412      385087 :                setQuery(rTheQuery, false, eMechanism, eCharset);
    1413             : }
    1414             : 
    1415      396928 : inline bool INetURLObject::SetMark(OUString const & rTheFragment,
    1416             :                                    EncodeMechanism eMechanism,
    1417             :                                    rtl_TextEncoding eCharset)
    1418             : {
    1419      396928 :     return rTheFragment.isEmpty() ?
    1420             :                clearFragment() :
    1421      396928 :                setFragment(rTheFragment, false, eMechanism, eCharset);
    1422             : }
    1423             : 
    1424           0 : inline INetURLObject::INetURLObject(OUString const & rFSysPath,
    1425             :                                     FSysStyle eStyle):
    1426           0 :     m_eScheme(INetProtocol::NotValid), m_eSmartScheme(INetProtocol::Http)
    1427             : {
    1428           0 :     setFSysPath(rFSysPath, eStyle);
    1429           0 : }
    1430             : 
    1431             : // static
    1432        2085 : inline OUString INetURLObject::encode(OUString const & rText, Part ePart,
    1433             :                                        EncodeMechanism eMechanism,
    1434             :                                        rtl_TextEncoding eCharset)
    1435             : {
    1436        2085 :     return encodeText(rText, false, ePart, eMechanism, eCharset, false);
    1437             : }
    1438             : 
    1439             : // static
    1440         367 : inline OUString INetURLObject::decode(OUString const & rText,
    1441             :                                        DecodeMechanism eMechanism,
    1442             :                                        rtl_TextEncoding eCharset)
    1443             : {
    1444         367 :     return decode(rText.getStr(), rText.getStr() + rText.getLength(),
    1445         734 :                   eMechanism, eCharset);
    1446             : }
    1447             : 
    1448      970060 : inline OUString INetURLObject::decode(OUStringBuffer const & rText,
    1449             :                                        DecodeMechanism eMechanism,
    1450             :                                        rtl_TextEncoding eCharset)
    1451             : {
    1452      970060 :     return decode(rText.getStr(), rText.getStr() + rText.getLength(),
    1453     1940120 :                   eMechanism, eCharset);
    1454             : }
    1455             : 
    1456             : #endif
    1457             : 
    1458             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11