LCOV - code coverage report
Current view: top level - ucb/source/ucp/tdoc - tdoc_uri.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 36 0.0 %
Date: 2014-04-14 Functions: 0 1 0.0 %
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             : 
      21             : /**************************************************************************
      22             :                                 TODO
      23             :  **************************************************************************
      24             : 
      25             :  *************************************************************************/
      26             : 
      27             : #include "rtl/ustrbuf.hxx"
      28             : #include "../inc/urihelper.hxx"
      29             : 
      30             : #include "tdoc_uri.hxx"
      31             : 
      32             : using namespace tdoc_ucp;
      33             : 
      34             : 
      35             : 
      36             : 
      37             : // Uri Implementation.
      38             : 
      39             : 
      40             : 
      41             : 
      42           0 : void Uri::init() const
      43             : {
      44             :     // Already inited?
      45           0 :     if ( m_eState == UNKNOWN )
      46             :     {
      47           0 :         m_eState = INVALID;
      48             : 
      49             :         // Check for proper length: must be at least length of <sheme>:/
      50           0 :         if ( ( m_aUri.getLength() < TDOC_URL_SCHEME_LENGTH + 2 ) )
      51             :         {
      52             :             // Invaild length (to short).
      53           0 :             return;
      54             :         }
      55             : 
      56             :         // Check for proper scheme. (Scheme is case insensitive.)
      57             :         OUString aScheme
      58           0 :             = m_aUri.copy( 0, TDOC_URL_SCHEME_LENGTH ).toAsciiLowerCase();
      59           0 :         if ( aScheme != TDOC_URL_SCHEME )
      60             :         {
      61             :             // Invaild scheme.
      62           0 :             return;
      63             :         }
      64             : 
      65             :         // Remember normalized scheme string.
      66           0 :         m_aUri = m_aUri.replaceAt( 0, aScheme.getLength(), aScheme );
      67             : 
      68           0 :         if ( m_aUri[ TDOC_URL_SCHEME_LENGTH ] != ':' )
      69             :         {
      70             :             // Invaild (no ':' after <scheme>).
      71           0 :             return;
      72             :         }
      73             : 
      74           0 :         if ( m_aUri[ TDOC_URL_SCHEME_LENGTH + 1 ] != '/' )
      75             :         {
      76             :             // Invaild (no '/' after <scheme>:).
      77           0 :             return;
      78             :         }
      79             : 
      80           0 :         m_aPath = m_aUri.copy( TDOC_URL_SCHEME_LENGTH + 1 );
      81             : 
      82             :         // Note: There must be at least one slash; see above.
      83           0 :         sal_Int32 nLastSlash = m_aUri.lastIndexOf( '/' );
      84           0 :         bool bTrailingSlash = false;
      85           0 :         if ( nLastSlash == m_aUri.getLength() - 1 )
      86             :         {
      87             :             // ignore trailing slash
      88           0 :             bTrailingSlash = true;
      89           0 :             nLastSlash = m_aUri.lastIndexOf( '/', nLastSlash );
      90             :         }
      91             : 
      92           0 :         if ( nLastSlash != -1 ) // -1 is valid for the root folder
      93             :         {
      94           0 :             m_aParentUri = m_aUri.copy( 0, nLastSlash + 1 );
      95             : 
      96           0 :             if ( bTrailingSlash )
      97           0 :                 m_aName = m_aUri.copy( nLastSlash + 1,
      98           0 :                                        m_aUri.getLength() - nLastSlash - 2 );
      99             :             else
     100           0 :                 m_aName = m_aUri.copy( nLastSlash + 1 );
     101             : 
     102           0 :             m_aDecodedName = ::ucb_impl::urihelper::decodeSegment( m_aName );
     103             : 
     104           0 :             sal_Int32 nSlash = m_aPath.indexOf( '/', 1 );
     105           0 :             if ( nSlash == -1 )
     106           0 :                 m_aDocId = m_aPath.copy( 1 );
     107             :             else
     108           0 :                 m_aDocId = m_aPath.copy( 1, nSlash - 1 );
     109             :         }
     110             : 
     111           0 :         if ( !m_aDocId.isEmpty() )
     112             :         {
     113           0 :             sal_Int32 nSlash = m_aPath.indexOf( '/', 1 );
     114           0 :             if ( nSlash != - 1 )
     115           0 :                 m_aInternalPath = m_aPath.copy( nSlash );
     116             :             else
     117           0 :                 m_aInternalPath = "/";
     118             :         }
     119             : 
     120           0 :         m_eState = VALID;
     121             :     }
     122             : }
     123             : 
     124             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10