LCOV - code coverage report
Current view: top level - ucb/source/ucp/tdoc - tdoc_uri.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 18 36 50.0 %
Date: 2015-06-13 12:38:46 Functions: 8 13 61.5 %
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             : 
      20             : #ifndef INCLUDED_UCB_SOURCE_UCP_TDOC_TDOC_URI_HXX
      21             : #define INCLUDED_UCB_SOURCE_UCP_TDOC_TDOC_URI_HXX
      22             : 
      23             : #include "rtl/ustring.hxx"
      24             : 
      25             : namespace tdoc_ucp {
      26             : 
      27             : 
      28             : 
      29             : #define TDOC_URL_SCHEME          "vnd.sun.star.tdoc"
      30             : #define TDOC_URL_SCHEME_LENGTH   17
      31             : 
      32             : 
      33             : 
      34        2638 : class Uri
      35             : {
      36             :     enum State { UNKNOWN, INVALID, VALID };
      37             : 
      38             :     mutable OUString m_aUri;
      39             :     mutable OUString m_aParentUri;
      40             :     mutable OUString m_aPath;
      41             :     mutable OUString m_aDocId;
      42             :     mutable OUString m_aInternalPath;
      43             :     mutable OUString m_aName;
      44             :     mutable OUString m_aDecodedName;
      45             :     mutable State           m_eState;
      46             : 
      47             : private:
      48             :     void init() const;
      49             : 
      50             : public:
      51             :     Uri() : m_eState( UNKNOWN ) {}
      52        2638 :     Uri( const OUString & rUri )
      53        2638 :     : m_aUri( rUri ), m_eState( UNKNOWN ) {}
      54             : 
      55           0 :     bool operator== ( const Uri & rOther ) const
      56           0 :     { init(); return m_aUri == rOther.m_aUri; }
      57             : 
      58           0 :     bool operator!= ( const Uri & rOther ) const
      59           0 :     { return !operator==( rOther ); }
      60             : 
      61         171 :     bool isValid() const
      62         171 :     { init(); return m_eState == VALID; }
      63             : 
      64         827 :     const OUString & getUri() const
      65         827 :     { init(); return m_aUri; }
      66             : 
      67             :     inline void setUri( const OUString & rUri );
      68             : 
      69         328 :     const OUString & getParentUri() const
      70         328 :     { init(); return m_aParentUri; }
      71             : 
      72             :     const OUString & getPath() const
      73             :     { init(); return m_aPath; }
      74             : 
      75         827 :     const OUString & getDocumentId() const
      76         827 :     { init(); return m_aDocId; }
      77             : 
      78             :     const OUString & getInternalPath() const
      79             :     { init(); return m_aInternalPath; }
      80             : 
      81           0 :     const OUString & getName() const
      82           0 :     { init(); return m_aName; }
      83             : 
      84           0 :     const OUString & getDecodedName() const
      85           0 :     { init(); return m_aDecodedName; }
      86             : 
      87             :     inline bool isRoot() const;
      88             : 
      89             :     inline bool isDocument() const;
      90             : 
      91             :     inline bool isFolder() const;
      92             : };
      93             : 
      94           0 : inline void Uri::setUri( const OUString & rUri )
      95             : {
      96           0 :     m_eState = UNKNOWN;
      97           0 :     m_aUri = rUri;
      98           0 :     m_aParentUri.clear();
      99           0 :     m_aDocId.clear();
     100           0 :     m_aInternalPath.clear();
     101           0 :     m_aPath.clear();
     102           0 :     m_aName.clear();
     103           0 :     m_aDecodedName.clear();
     104           0 : }
     105             : 
     106         984 : inline bool Uri::isRoot() const
     107             : {
     108         984 :     init();
     109         984 :     return ( m_aPath.getLength() == 1 );
     110             : }
     111             : 
     112        1640 : inline bool Uri::isDocument() const
     113             : {
     114        1640 :     init();
     115        1640 :     return ( ( !m_aDocId.isEmpty() ) /* not root */
     116        3280 :              && ( m_aPath.copy( m_aDocId.getLength() + 1 ).getLength() < 2 ) );
     117             : }
     118             : 
     119             : inline bool Uri::isFolder() const
     120             : {
     121             :     init();
     122             :     return m_aPath.isEmpty() || m_aPath.endsWith( "/" );
     123             : }
     124             : 
     125             : } // namespace tdoc_ucp
     126             : 
     127             : #endif // INCLUDED_UCB_SOURCE_UCP_TDOC_TDOC_URI_HXX
     128             : 
     129             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11