LCOV - code coverage report
Current view: top level - ucb/source/ucp/tdoc - tdoc_uri.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 18 31 58.1 %
Date: 2012-08-25 Functions: 8 13 61.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 5 6 83.3 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef INCLUDED_TDOC_URI_HXX
      30                 :            : #define INCLUDED_TDOC_URI_HXX
      31                 :            : 
      32                 :            : #include "rtl/ustring.hxx"
      33                 :            : 
      34                 :            : namespace tdoc_ucp {
      35                 :            : 
      36                 :            : //=========================================================================
      37                 :            : 
      38                 :            : #define TDOC_URL_SCHEME          "vnd.sun.star.tdoc"
      39                 :            : #define TDOC_URL_SCHEME_LENGTH   17
      40                 :            : 
      41                 :            : //=========================================================================
      42                 :            : 
      43                 :        755 : class Uri
      44                 :            : {
      45                 :            :     enum State { UNKNOWN, INVALID, VALID };
      46                 :            : 
      47                 :            :     mutable ::rtl::OUString m_aUri;
      48                 :            :     mutable ::rtl::OUString m_aParentUri;
      49                 :            :     mutable ::rtl::OUString m_aPath;
      50                 :            :     mutable ::rtl::OUString m_aDocId;
      51                 :            :     mutable ::rtl::OUString m_aInternalPath;
      52                 :            :     mutable ::rtl::OUString m_aName;
      53                 :            :     mutable ::rtl::OUString m_aDecodedName;
      54                 :            :     mutable State           m_eState;
      55                 :            : 
      56                 :            : private:
      57                 :            :     void init() const;
      58                 :            : 
      59                 :            : public:
      60                 :            :     Uri() : m_eState( UNKNOWN ) {}
      61                 :        755 :     Uri( const ::rtl::OUString & rUri )
      62                 :        755 :     : m_aUri( rUri ), m_eState( UNKNOWN ) {}
      63                 :            : 
      64                 :          0 :     bool operator== ( const Uri & rOther ) const
      65                 :          0 :     { init(); return m_aUri == rOther.m_aUri; }
      66                 :            : 
      67                 :          0 :     bool operator!= ( const Uri & rOther ) const
      68                 :          0 :     { return !operator==( rOther ); }
      69                 :            : 
      70                 :         45 :     sal_Bool isValid() const
      71                 :         45 :     { init(); return m_eState == VALID; }
      72                 :            : 
      73                 :        235 :     const ::rtl::OUString & getUri() const
      74                 :        235 :     { init(); return m_aUri; }
      75                 :            : 
      76                 :            :     inline void setUri( const ::rtl::OUString & rUri );
      77                 :            : 
      78                 :         95 :     const ::rtl::OUString & getParentUri() const
      79                 :         95 :     { init(); return m_aParentUri; }
      80                 :            : 
      81                 :            :     const ::rtl::OUString & getPath() const
      82                 :            :     { init(); return m_aPath; }
      83                 :            : 
      84                 :        235 :     const ::rtl::OUString & getDocumentId() const
      85                 :        235 :     { init(); return m_aDocId; }
      86                 :            : 
      87                 :            :     const ::rtl::OUString & getInternalPath() const
      88                 :            :     { init(); return m_aInternalPath; }
      89                 :            : 
      90                 :          0 :     const ::rtl::OUString & getName() const
      91                 :          0 :     { init(); return m_aName; }
      92                 :            : 
      93                 :          0 :     const ::rtl::OUString & getDecodedName() const
      94                 :          0 :     { init(); return m_aDecodedName; }
      95                 :            : 
      96                 :            :     inline sal_Bool isRoot() const;
      97                 :            : 
      98                 :            :     inline sal_Bool isDocument() const;
      99                 :            : 
     100                 :            :     inline sal_Bool isFolder() const;
     101                 :            : };
     102                 :            : 
     103                 :          0 : inline void Uri::setUri( const ::rtl::OUString & rUri )
     104                 :            : {
     105                 :          0 :     m_eState = UNKNOWN;
     106                 :          0 :     m_aUri = rUri;
     107                 :            :     m_aParentUri = m_aDocId = m_aInternalPath = m_aPath = m_aName
     108                 :          0 :         = m_aDecodedName = rtl::OUString();
     109                 :          0 : }
     110                 :            : 
     111                 :        285 : inline sal_Bool Uri::isRoot() const
     112                 :            : {
     113                 :        285 :     init();
     114                 :        285 :     return ( m_aPath.getLength() == 1 );
     115                 :            : }
     116                 :            : 
     117                 :        475 : inline sal_Bool Uri::isDocument() const
     118                 :            : {
     119                 :        475 :     init();
     120                 :        475 :     return ( ( !m_aDocId.isEmpty() ) /* not root */
     121 [ +  - ][ +  + ]:        475 :              && ( m_aPath.copy( m_aDocId.getLength() + 1 ).getLength() < 2 ) );
                 [ +  + ]
     122                 :            : }
     123                 :            : 
     124                 :            : inline sal_Bool Uri::isFolder() const
     125                 :            : {
     126                 :            :     init();
     127                 :            :     return ( m_aPath.lastIndexOf( '/' ) == m_aPath.getLength() - 1 );
     128                 :            : }
     129                 :            : 
     130                 :            : } // namespace tdoc_ucp
     131                 :            : 
     132                 :            : #endif /* !INCLUDED_TDOC_URI_HXX */
     133                 :            : 
     134                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10