Files
libreoffice/ucb/source/ucp/hierarchy/hierarchyuri.cxx

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

179 lines
6.1 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: clarify Option->Language UI option Patch contributed by Herbert Duerr http://svn.apache.org/viewvc?view=revision&revision=1173991 cws mba34issues01: #i117712#: fix several resource errors introduced by IAccessible2 implementation Patch contributed by Mathias Bauer http://svn.apache.org/viewvc?view=revision&revision=1173991 cws mba34issues01: #i117709#: add missing string resource Patch contributed by Mathias Bauer http://svn.apache.org/viewvc?view=revision&revision=1172348 cws mba34issues01: #i117716#: fix missing resources my removing unused code Patch contributed by Mathias Bauer http://svn.apache.org/viewvc?view=revision&revision=1172345 re-add Crystal, Tango, Oxygen icon theme listings. correct method signature Patch contributed by Jean-Louis 'Hans' Fuchs http://svn.apache.org/viewvc?view=revision&revision=1306725 i#119063 - correct serf integration Patch contributed by Oliver-Rainer Wittmann http://svn.apache.org/viewvc?view=revision&revision=1300521 i#119036 - adapt serf integration -- use transfer-encoding 'chunked' on HTTPS -- switch transfer-encoding between 'chunked' and none on 413 HTTP status code -- refactoring -- improve user experience of certification dialog - only shown once Patch contributed by Oliver-Rainer Wittmann http://svn.apache.org/viewvc?view=revision&revision=1299727 118569: Use whole certification chain for verification. Patch contributed by Andre Fischer http://svn.apache.org/viewvc?view=revision&revision=1295493 serf integration: improve credential input handling Patch contributed by Oliver-Rainer Wittmann http://svn.apache.org/viewvc?view=revision&revision=1294557 warning-free ucb/source/ucp/webdav Patch contributed by Pavel Janik http://svn.apache.org/viewvc?view=revision&revision=1294086 some refactoring to PROPPATCH and PROPFIND requests Patch contributed by Oliver-Rainer Wittmann http://svn.apache.org/viewvc?view=revision&revision=1293281 i#118569: Replace neon with serf Patch contributed by Oliver-Rainer Wittmann http://svn.apache.org/viewvc?view=revision&revision=1292832 http://svn.apache.org/viewvc?view=revision&revision=1292794 remove OS/2 conditionals for now. re-enable webdav unit tests.
2012-10-04 11:25:41 +01:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2001-07-03 10:15:56 +00:00
2001-07-03 10:15:56 +00:00
/**************************************************************************
TODO
**************************************************************************
*************************************************************************/
#include "hierarchyuri.hxx"
using namespace hierarchy_ucp;
2001-07-03 10:15:56 +00:00
#define DEFAULT_DATA_SOURCE_SERVICE \
"com.sun.star.ucb.DefaultHierarchyDataSource"
2001-07-03 10:15:56 +00:00
// HierarchyUri Implementation.
2001-07-03 10:15:56 +00:00
void HierarchyUri::init() const
{
// Already inited?
if ( !m_aUri.isEmpty() && m_aPath.isEmpty() )
2001-07-03 10:15:56 +00:00
{
// Note: Maybe it's a re-init, setUri only resets m_aPath!
m_aService.clear();
m_aParentUri.clear();
2001-07-03 10:15:56 +00:00
// URI must match at least: <scheme>:
if ( m_aUri.getLength() < HIERARCHY_URL_SCHEME_LENGTH + 1 )
2001-07-03 10:15:56 +00:00
{
// error, but remember that we did an init().
m_aPath = "/";
return;
}
// Scheme is case insensitive.
OUString aScheme
= m_aUri.copy( 0, HIERARCHY_URL_SCHEME_LENGTH ).toAsciiLowerCase();
if ( aScheme == HIERARCHY_URL_SCHEME )
{
m_aUri = m_aUri.replaceAt( 0, aScheme.getLength(), aScheme );
2001-07-03 10:15:56 +00:00
sal_Int32 nPos = 0;
// If the URI has no service specifier, insert default service.
// This is for backward compatibility and for convenience.
2001-07-03 14:23:22 +00:00
if ( m_aUri.getLength() == HIERARCHY_URL_SCHEME_LENGTH + 1 )
{
// root folder URI without path and service specifier.
m_aUri += "//" DEFAULT_DATA_SOURCE_SERVICE "/";
m_aService = DEFAULT_DATA_SOURCE_SERVICE ;
2001-07-03 14:23:22 +00:00
nPos = m_aUri.getLength() - 1;
}
else if ( ( m_aUri.getLength() == HIERARCHY_URL_SCHEME_LENGTH + 2 )
&&
( m_aUri[ HIERARCHY_URL_SCHEME_LENGTH + 1 ] == '/' ) )
2001-07-03 10:15:56 +00:00
{
// root folder URI without service specifier.
m_aUri += "/" DEFAULT_DATA_SOURCE_SERVICE "/";
m_aService = DEFAULT_DATA_SOURCE_SERVICE;
2001-07-03 10:15:56 +00:00
nPos = m_aUri.getLength() - 1;
}
2001-07-03 14:23:22 +00:00
else if ( ( m_aUri.getLength() > HIERARCHY_URL_SCHEME_LENGTH + 2 )
&&
( m_aUri[ HIERARCHY_URL_SCHEME_LENGTH + 2 ] != '/' ) )
2001-07-03 10:15:56 +00:00
{
// other (no root folder) URI without service specifier.
m_aUri = m_aUri.replaceAt(
HIERARCHY_URL_SCHEME_LENGTH + 2,
0,
"/" DEFAULT_DATA_SOURCE_SERVICE "/" );
m_aService = DEFAULT_DATA_SOURCE_SERVICE;
2001-07-03 10:15:56 +00:00
nPos
= HIERARCHY_URL_SCHEME_LENGTH + 3 + m_aService.getLength();
2001-07-03 10:15:56 +00:00
}
else
{
// URI with service specifier.
sal_Int32 nStart = HIERARCHY_URL_SCHEME_LENGTH + 3;
2001-07-03 14:23:22 +00:00
// Here: - m_aUri has at least the form "<scheme>://"
// - nStart points to char after <scheme>:
2001-07-03 14:23:22 +00:00
// Only <scheme>:// ?
if ( nStart == m_aUri.getLength() )
{
// error, but remember that we did an init().
m_aPath = "/";
2001-07-03 14:23:22 +00:00
return;
}
// Empty path segments?
if ( m_aUri.indexOf("//", nStart) != -1 )
2001-07-03 14:23:22 +00:00
{
// error, but remember that we did an init().
m_aPath = "/";
2001-07-03 14:23:22 +00:00
return;
}
sal_Int32 nEnd = m_aUri.indexOf( '/', nStart );
// Only <scheme>:/// ?
if ( nEnd == nStart )
{
// error, but remember that we did an init().
m_aPath = "/";
2001-07-03 14:23:22 +00:00
return;
}
2001-07-03 10:15:56 +00:00
if ( nEnd == -1 )
{
// Trailing slash missing.
nEnd = m_aUri.getLength();
m_aUri += "/";
2001-07-03 10:15:56 +00:00
}
m_aService = m_aUri.copy( nStart, nEnd - nStart );
nPos = nEnd;
}
// Here: - m_aUri has at least the form "<scheme>://<service>/"
// - m_aService was set
2001-07-03 14:23:22 +00:00
// - m_aPath, m_aParentPath, m_aName not yet set
// - nPos points to slash after service specifier
2001-07-03 10:15:56 +00:00
// Remove trailing slash, if not a root folder URI.
sal_Int32 nEnd = m_aUri.lastIndexOf( '/' );
if ( ( nEnd > nPos ) && ( nEnd == ( m_aUri.getLength() - 1 ) ) )
m_aUri = m_aUri.copy( 0, nEnd );
// Path (includes leading slash)
m_aPath = m_aUri.copy( nPos );
// parent URI + name
sal_Int32 nLastSlash = m_aUri.lastIndexOf( '/' );
if ( ( nLastSlash != -1 ) &&
( nLastSlash != m_aUri.getLength() - 1 ) ) // root
{
m_aParentUri = m_aUri.copy( 0, nLastSlash );
}
// success
m_bValid = true;
}
else
{
// error, but remember that we did an init().
m_aPath = "/";
2001-07-03 10:15:56 +00:00
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */