/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * 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 .
*/
// INetURLObject supports only an intelligent method of parsing URL's. So write // back Complete to have a valid encoded URL in all cases!
_rURL.Complete = _rParser.GetMainURL( INetURLObject::DecodeMechanism::NONE );
// If INetURLObject knows this protocol let it parse if ( INetURLObject::CompareProtocolScheme( aProtocol ) != INetProtocol::NotValid )
{ // Initialize parser with given URL.
INetURLObject aParser( aURL.Complete );
// Get all information about this URL.
INetProtocol eINetProt = aParser.GetProtocol(); if ( eINetProt == INetProtocol::NotValid )
{ returnfalse;
} elseif ( !aParser.HasError() )
{
lcl_ParserHelper(aParser,aURL); // Return "URL is parsed". returntrue;
}
} else
{ // Minimal support for unknown protocols. This is mandatory to support the "Protocol Handlers" implemented // in framework!
aURL.Protocol = aProtocol;
aURL.Main = aURL.Complete;
aURL.Path = aURL.Complete.copy( nURLIndex+1 );
// Initialize parser with given URL.
INetURLObject aParser;
aParser.SetSmartProtocol( INetURLObject::CompareProtocolScheme( sSmartProtocol )); bool bOk = aParser.SetSmartURL( aURL.Complete ); if ( bOk )
{
lcl_ParserHelper(aParser,aURL); // Return "URL is parsed". returntrue;
} else
{ // Minimal support for unknown protocols. This is mandatory to support the "Protocol Handlers" implemented // in framework! if ( INetURLObject::CompareProtocolScheme( sSmartProtocol ) == INetProtocol::NotValid )
{ // Try to extract the protocol
sal_Int32 nIndex = aURL.Complete.indexOf( ':' ); if ( nIndex > 1 )
{
OUString aProtocol = aURL.Complete.copy( 0, nIndex+1 );
// If INetURLObject knows this protocol something is wrong as detected before => // give up and return false! if ( INetURLObject::CompareProtocolScheme( aProtocol ) != INetProtocol::NotValid ) returnfalse; else
aURL.Protocol = aProtocol;
} else returnfalse;
// Concat the name if it is provided, just support a final slash if ( !aURL.Name.isEmpty() )
{
sal_Int32 nIndex = aURL.Path.lastIndexOf( '/' ); if ( nIndex == ( aURL.Path.getLength() -1 ))
aCompletePath.append( aURL.Name ); else
{
aCompletePath.append( "/" + aURL.Name );
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.