fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / ucb / source / ucp / tdoc / tdoc_uri.cxx
bloba5eecc14156b1bc548014afef533ce859c5c7ff3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 /**************************************************************************
22 TODO
23 **************************************************************************
25 *************************************************************************/
27 #include "rtl/ustrbuf.hxx"
28 #include "../inc/urihelper.hxx"
30 #include "tdoc_uri.hxx"
32 using namespace tdoc_ucp;
37 // Uri Implementation.
42 void Uri::init() const
44 // Already inited?
45 if ( m_eState == UNKNOWN )
47 m_eState = INVALID;
49 // Check for proper length: must be at least length of <sheme>:/
50 if ( ( m_aUri.getLength() < TDOC_URL_SCHEME_LENGTH + 2 ) )
52 // Invalid length (to short).
53 return;
56 // Check for proper scheme. (Scheme is case insensitive.)
57 OUString aScheme
58 = m_aUri.copy( 0, TDOC_URL_SCHEME_LENGTH ).toAsciiLowerCase();
59 if ( aScheme != TDOC_URL_SCHEME )
61 // Invalid scheme.
62 return;
65 // Remember normalized scheme string.
66 m_aUri = m_aUri.replaceAt( 0, aScheme.getLength(), aScheme );
68 if ( m_aUri[ TDOC_URL_SCHEME_LENGTH ] != ':' )
70 // Invalid (no ':' after <scheme>).
71 return;
74 if ( m_aUri[ TDOC_URL_SCHEME_LENGTH + 1 ] != '/' )
76 // Invalid (no '/' after <scheme>:).
77 return;
80 m_aPath = m_aUri.copy( TDOC_URL_SCHEME_LENGTH + 1 );
82 // Note: There must be at least one slash; see above.
83 sal_Int32 nLastSlash = m_aUri.lastIndexOf( '/' );
84 bool bTrailingSlash = false;
85 if ( nLastSlash == m_aUri.getLength() - 1 )
87 // ignore trailing slash
88 bTrailingSlash = true;
89 nLastSlash = m_aUri.lastIndexOf( '/', nLastSlash );
92 if ( nLastSlash != -1 ) // -1 is valid for the root folder
94 m_aParentUri = m_aUri.copy( 0, nLastSlash + 1 );
96 if ( bTrailingSlash )
97 m_aName = m_aUri.copy( nLastSlash + 1,
98 m_aUri.getLength() - nLastSlash - 2 );
99 else
100 m_aName = m_aUri.copy( nLastSlash + 1 );
102 m_aDecodedName = ::ucb_impl::urihelper::decodeSegment( m_aName );
104 sal_Int32 nSlash = m_aPath.indexOf( '/', 1 );
105 if ( nSlash == -1 )
106 m_aDocId = m_aPath.copy( 1 );
107 else
108 m_aDocId = m_aPath.copy( 1, nSlash - 1 );
111 if ( !m_aDocId.isEmpty() )
113 sal_Int32 nSlash = m_aPath.indexOf( '/', 1 );
114 if ( nSlash != - 1 )
115 m_aInternalPath = m_aPath.copy( nSlash );
116 else
117 m_aInternalPath = "/";
120 m_eState = VALID;
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */