2001-05-16 13:53:27 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: urlparameter.cxx,v $
|
|
|
|
*
|
2003-05-28 12:29:54 +00:00
|
|
|
* $Revision: 1.30 $
|
2001-05-16 13:53:27 +00:00
|
|
|
*
|
2003-05-28 12:29:54 +00:00
|
|
|
* last change: $Author: vg $ $Date: 2003-05-28 13:29:54 $
|
2001-05-16 13:53:27 +00:00
|
|
|
*
|
|
|
|
* The Contents of this file are made available subject to the terms of
|
|
|
|
* either of the following licenses
|
|
|
|
*
|
|
|
|
* - GNU Lesser General Public License Version 2.1
|
|
|
|
* - Sun Industry Standards Source License Version 1.1
|
|
|
|
*
|
|
|
|
* Sun Microsystems Inc., October, 2000
|
|
|
|
*
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2000 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Sun Industry Standards Source License Version 1.1
|
|
|
|
* =================================================
|
|
|
|
* The contents of this file are subject to the Sun Industry Standards
|
|
|
|
* Source License Version 1.1 (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.openoffice.org/license.html.
|
|
|
|
*
|
|
|
|
* Software provided under this License is provided on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
|
|
|
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
|
|
|
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
|
|
|
* See the License for the specific provisions governing your rights and
|
|
|
|
* obligations concerning the Software.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* Copyright: 2000 by Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): _______________________________________
|
|
|
|
*
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2002-04-08 09:30:12 +00:00
|
|
|
//#define WORKAROUND_98119
|
2002-03-28 11:38:08 +00:00
|
|
|
|
|
|
|
#ifdef WORKAROUND_98119
|
|
|
|
#include <provider/bufferedinputstream.hxx>
|
|
|
|
#endif
|
|
|
|
|
2001-06-06 13:48:47 +00:00
|
|
|
#include <string.h>
|
2001-05-17 14:46:30 +00:00
|
|
|
#ifndef _VOS_DIAGNOSE_HXX_
|
|
|
|
#include <vos/diagnose.hxx>
|
|
|
|
#endif
|
2001-10-05 13:38:57 +00:00
|
|
|
#ifndef _OSL_THREAD_H_
|
|
|
|
#include <osl/thread.h>
|
|
|
|
#endif
|
2001-05-23 13:15:56 +00:00
|
|
|
#ifndef _RTL_MEMORY_H_
|
|
|
|
#include <rtl/memory.h>
|
|
|
|
#endif
|
|
|
|
#ifndef _OSL_FILE_HXX_
|
|
|
|
#include <osl/file.hxx>
|
|
|
|
#endif
|
2001-05-22 13:57:13 +00:00
|
|
|
#ifndef _CPPUHELPER_WEAK_HXX_
|
|
|
|
#include <cppuhelper/weak.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
|
|
|
|
#include <cppuhelper/queryinterface.hxx>
|
|
|
|
#endif
|
2001-05-17 14:46:30 +00:00
|
|
|
#ifndef _RTL_URI_HXX_
|
|
|
|
#include <rtl/uri.hxx>
|
|
|
|
#endif
|
2001-06-06 13:48:47 +00:00
|
|
|
#ifndef SablotHIncl
|
2001-06-08 07:53:56 +00:00
|
|
|
#include <sablot/sablot.h>
|
2001-06-06 13:48:47 +00:00
|
|
|
#endif
|
|
|
|
#ifndef ShandlerHIncl
|
2001-06-08 07:53:56 +00:00
|
|
|
#include <sablot/shandler.h>
|
2001-06-06 13:48:47 +00:00
|
|
|
#endif
|
2001-05-16 06:36:23 +00:00
|
|
|
#ifndef _DB_CXX_H_
|
|
|
|
#include <berkeleydb/db_cxx.h>
|
|
|
|
#endif
|
|
|
|
#ifndef _URLPARAMETER_HXX_
|
|
|
|
#include <provider/urlparameter.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _DATABASES_HXX_
|
|
|
|
#include <provider/databases.hxx>
|
|
|
|
#endif
|
2001-09-28 14:01:59 +00:00
|
|
|
#ifndef _RTL_URI_HXX_
|
|
|
|
#include <rtl/uri.hxx>
|
|
|
|
#endif
|
2001-05-17 14:46:30 +00:00
|
|
|
#ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HPP_
|
|
|
|
#include <com/sun/star/io/XActiveDataSink.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
|
|
|
|
#include <com/sun/star/io/XInputStream.hpp>
|
|
|
|
#endif
|
2001-05-22 13:57:13 +00:00
|
|
|
#ifndef _COM_SUN_STAR_IO_XSEEKABLE_HPP_
|
|
|
|
#include <com/sun/star/io/XSeekable.hpp>
|
|
|
|
#endif
|
2001-05-17 14:46:30 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UCB_OPENCOMMANDARGUMENT2_HPP_
|
|
|
|
#include <com/sun/star/ucb/OpenCommandArgument2.hpp>
|
|
|
|
#endif
|
2001-05-23 13:15:56 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UCB_OPENMODE_HPP_
|
|
|
|
#include <com/sun/star/ucb/OpenMode.hpp>
|
|
|
|
#endif
|
2001-05-17 14:46:30 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UCB_XCOMMANDPROCESSOR_HPP_
|
|
|
|
#include <com/sun/star/ucb/XCommandProcessor.hpp>
|
|
|
|
#endif
|
2001-05-23 13:15:56 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UCB_XCOMMANDENVIRONMENT_HPP_
|
|
|
|
#include <com/sun/star/ucb/XCommandEnvironment.hpp>
|
|
|
|
#endif
|
2001-05-17 14:46:30 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UCB_XCONTENTIDENTIFIER_HPP_
|
|
|
|
#include <com/sun/star/ucb/XContentIdentifier.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UCB_XCONTENTPROVIDER_HPP_
|
|
|
|
#include <com/sun/star/ucb/XContentProvider.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UCB_XCONTENTIDENTIFIERFACTORY_HPP_
|
|
|
|
#include <com/sun/star/ucb/XContentIdentifierFactory.hpp>
|
|
|
|
#endif
|
2001-06-06 13:48:47 +00:00
|
|
|
#ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMEACCESS_HPP_
|
|
|
|
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
|
|
|
|
#endif
|
2001-05-16 06:36:23 +00:00
|
|
|
|
2001-09-28 14:01:59 +00:00
|
|
|
|
2001-05-16 06:36:23 +00:00
|
|
|
namespace chelp {
|
|
|
|
|
|
|
|
inline bool ascii_isDigit( sal_Unicode ch )
|
|
|
|
{
|
|
|
|
return ((ch >= 0x0030) && (ch <= 0x0039));
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool ascii_isLetter( sal_Unicode ch )
|
|
|
|
{
|
2001-06-19 12:41:05 +00:00
|
|
|
return ( ( (ch >= 0x0041) && (ch <= 0x005A) ) ||
|
|
|
|
( (ch >= 0x0061) && (ch <= 0x007A) ) );
|
2001-05-16 06:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline bool isLetterOrDigit( sal_Unicode ch )
|
|
|
|
{
|
|
|
|
return ascii_isLetter( ch ) || ascii_isDigit( ch );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2001-05-22 13:57:13 +00:00
|
|
|
using namespace cppu;
|
2001-05-17 14:46:30 +00:00
|
|
|
using namespace com::sun::star::io;
|
|
|
|
using namespace com::sun::star::uno;
|
|
|
|
using namespace com::sun::star::lang;
|
|
|
|
using namespace com::sun::star::ucb;
|
2001-06-06 13:48:47 +00:00
|
|
|
using namespace com::sun::star::container;
|
2001-05-16 06:36:23 +00:00
|
|
|
using namespace chelp;
|
|
|
|
|
|
|
|
|
2001-06-06 13:48:47 +00:00
|
|
|
URLParameter::URLParameter( const rtl::OUString& aURL,
|
|
|
|
Databases* pDatabases )
|
|
|
|
throw( com::sun::star::ucb::IllegalIdentifierException )
|
|
|
|
: m_aURL( aURL ),
|
|
|
|
m_pDatabases( pDatabases )
|
2001-05-16 06:36:23 +00:00
|
|
|
{
|
|
|
|
init( false );
|
|
|
|
parse();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
URLParameter::URLParameter( const rtl::OUString& aURL,
|
2001-06-06 13:48:47 +00:00
|
|
|
const rtl::OUString& aDefaultLanguage,
|
|
|
|
Databases* pDatabases )
|
|
|
|
throw( com::sun::star::ucb::IllegalIdentifierException )
|
2001-05-16 06:36:23 +00:00
|
|
|
: m_aURL( aURL ),
|
2001-06-06 13:48:47 +00:00
|
|
|
m_aDefaultLanguage( aDefaultLanguage ),
|
|
|
|
m_pDatabases( pDatabases )
|
2001-05-16 06:36:23 +00:00
|
|
|
{
|
|
|
|
init( true );
|
|
|
|
parse();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-21 12:26:25 +00:00
|
|
|
bool URLParameter::isErrorDocument()
|
|
|
|
{
|
|
|
|
if( isFile() )
|
|
|
|
{
|
|
|
|
Reference< XHierarchicalNameAccess > xNA = m_pDatabases->jarFile( get_jar(),
|
|
|
|
get_language() );
|
|
|
|
|
|
|
|
return ! ( xNA.is() && xNA->hasByHierarchicalName( get_path() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-13 08:10:13 +00:00
|
|
|
rtl::OString URLParameter::getByName( const char* par )
|
|
|
|
{
|
|
|
|
rtl::OUString val;
|
|
|
|
|
|
|
|
if( strcmp( par,"Program" ) == 0 )
|
|
|
|
val = get_program();
|
|
|
|
else if( strcmp( par,"Database" ) == 0 )
|
|
|
|
val = get_module();
|
|
|
|
else if( strcmp( par,"Id" ) == 0 )
|
|
|
|
val = get_id();
|
|
|
|
else if( strcmp( par,"Path" ) == 0 )
|
|
|
|
val = get_path();
|
|
|
|
else if( strcmp( par,"Language" ) == 0 )
|
|
|
|
val = get_language();
|
|
|
|
else if( strcmp( par,"System" ) == 0 )
|
|
|
|
val = get_system();
|
2001-09-28 14:01:59 +00:00
|
|
|
else if( strcmp( par,"HelpPrefix" ) == 0 )
|
|
|
|
val = get_prefix();
|
2001-06-13 08:10:13 +00:00
|
|
|
|
|
|
|
return rtl::OString( val.getStr(),val.getLength(),RTL_TEXTENCODING_UTF8 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-16 06:36:23 +00:00
|
|
|
rtl::OUString URLParameter::get_id()
|
|
|
|
{
|
2001-06-06 13:48:47 +00:00
|
|
|
if( m_aId.compareToAscii( "52821" ) == 0 || m_aId.compareToAscii("start") == 0 )
|
2001-05-16 06:36:23 +00:00
|
|
|
{ // module is set
|
|
|
|
StaticModuleInformation* inf =
|
2001-06-06 13:48:47 +00:00
|
|
|
m_pDatabases->getStaticInformationForModule( get_module(),
|
|
|
|
get_language() );
|
2001-05-16 06:36:23 +00:00
|
|
|
if( inf )
|
|
|
|
m_aId = inf->get_id();
|
|
|
|
|
|
|
|
m_bStart = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_aId;
|
|
|
|
}
|
|
|
|
|
|
|
|
rtl::OUString URLParameter::get_tag()
|
|
|
|
{
|
|
|
|
if( isFile() )
|
|
|
|
return get_the_tag();
|
|
|
|
else
|
|
|
|
return m_aTag;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rtl::OUString URLParameter::get_title()
|
|
|
|
{
|
|
|
|
if( isFile() )
|
|
|
|
return get_the_title();
|
|
|
|
else if( m_aModule.compareToAscii("") != 0 )
|
|
|
|
{
|
|
|
|
StaticModuleInformation* inf =
|
2001-06-06 13:48:47 +00:00
|
|
|
m_pDatabases->getStaticInformationForModule( get_module(),
|
|
|
|
get_language() );
|
2001-05-16 06:36:23 +00:00
|
|
|
if( inf )
|
|
|
|
m_aTitle = inf->get_title();
|
|
|
|
}
|
|
|
|
else // This must be the root
|
|
|
|
m_aTitle = rtl::OUString::createFromAscii("root");
|
|
|
|
|
|
|
|
return m_aTitle;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rtl::OUString URLParameter::get_language()
|
|
|
|
{
|
|
|
|
if( m_aLanguage.getLength() == 0 )
|
2001-05-16 13:53:27 +00:00
|
|
|
return m_aDefaultLanguage;
|
2001-05-16 06:36:23 +00:00
|
|
|
|
|
|
|
return m_aLanguage;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rtl::OUString URLParameter::get_program()
|
|
|
|
{
|
2001-08-21 12:26:25 +00:00
|
|
|
if( ! m_aProgram.getLength() )
|
2001-05-16 06:36:23 +00:00
|
|
|
{
|
|
|
|
StaticModuleInformation* inf =
|
2001-06-06 13:48:47 +00:00
|
|
|
m_pDatabases->getStaticInformationForModule( get_module(),
|
|
|
|
get_language() );
|
2001-05-16 06:36:23 +00:00
|
|
|
if( inf )
|
|
|
|
m_aProgram = inf->get_program();
|
|
|
|
}
|
|
|
|
return m_aProgram;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void URLParameter::init( bool bDefaultLanguageIsInitialized )
|
|
|
|
{
|
|
|
|
m_bBerkeleyRead = false;
|
|
|
|
m_bStart = false;
|
2001-05-17 08:58:55 +00:00
|
|
|
m_nHitCount = 100; // The default maximum hitcount
|
2001-05-16 06:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rtl::OUString URLParameter::get_the_tag()
|
|
|
|
{
|
|
|
|
if( ! m_bBerkeleyRead )
|
|
|
|
readBerkeley();
|
|
|
|
|
|
|
|
m_bBerkeleyRead = true;
|
|
|
|
|
|
|
|
return m_aTag;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rtl::OUString URLParameter::get_the_path()
|
|
|
|
{
|
|
|
|
if( ! m_bBerkeleyRead )
|
|
|
|
readBerkeley();
|
|
|
|
m_bBerkeleyRead = true;
|
|
|
|
|
|
|
|
return m_aPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rtl::OUString URLParameter::get_the_title()
|
|
|
|
{
|
|
|
|
if( ! m_bBerkeleyRead )
|
|
|
|
readBerkeley();
|
|
|
|
m_bBerkeleyRead = true;
|
|
|
|
|
|
|
|
return m_aTitle;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rtl::OUString URLParameter::get_the_jar()
|
|
|
|
{
|
|
|
|
if( ! m_bBerkeleyRead )
|
|
|
|
readBerkeley();
|
|
|
|
m_bBerkeleyRead = true;
|
|
|
|
|
|
|
|
return m_aJar;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-05-16 13:53:27 +00:00
|
|
|
void URLParameter::readBerkeley()
|
|
|
|
{
|
2001-08-23 10:39:42 +00:00
|
|
|
if( get_id().compareToAscii("") == 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
Db* db = m_pDatabases->getBerkeley( get_module(),
|
|
|
|
get_language() );
|
|
|
|
|
|
|
|
if( ! db )
|
|
|
|
return;
|
|
|
|
|
|
|
|
rtl::OString keyStr( m_aId.getStr(),m_aId.getLength(),RTL_TEXTENCODING_UTF8 );
|
|
|
|
Dbt key( static_cast< void* >( const_cast< sal_Char* >( keyStr.getStr() ) ),
|
|
|
|
keyStr.getLength() );
|
|
|
|
Dbt data;
|
|
|
|
|
|
|
|
int err = db->get( 0,&key,&data,0 );
|
|
|
|
|
|
|
|
DbtToStringConverter converter( static_cast< sal_Char* >( data.get_data() ),
|
|
|
|
data.get_size() );
|
|
|
|
m_aTitle = converter.getTitle();
|
2001-10-31 12:08:14 +00:00
|
|
|
m_pDatabases->replaceName( m_aTitle );
|
2001-08-23 10:39:42 +00:00
|
|
|
m_aPath = converter.getFile();
|
|
|
|
m_aJar = converter.getDatabase();
|
|
|
|
m_aTag = converter.getHash();
|
2001-05-16 06:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-17 14:46:30 +00:00
|
|
|
|
2001-05-22 13:57:13 +00:00
|
|
|
// Class encapsulating the transformation of the XInputStream to XHTML
|
|
|
|
|
|
|
|
|
|
|
|
class InputStreamTransformer
|
|
|
|
: public OWeakObject,
|
|
|
|
public XInputStream,
|
|
|
|
public XSeekable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2001-06-13 08:10:13 +00:00
|
|
|
InputStreamTransformer( URLParameter* urlParam,
|
2001-06-13 09:12:40 +00:00
|
|
|
Databases* pDatatabases,
|
|
|
|
bool isRoot = false );
|
2001-05-23 13:15:56 +00:00
|
|
|
|
2001-05-22 13:57:13 +00:00
|
|
|
~InputStreamTransformer();
|
|
|
|
|
|
|
|
virtual Any SAL_CALL queryInterface( const Type& rType ) throw( RuntimeException );
|
2001-10-24 10:17:19 +00:00
|
|
|
virtual void SAL_CALL acquire( void ) throw();
|
|
|
|
virtual void SAL_CALL release( void ) throw();
|
2001-05-22 13:57:13 +00:00
|
|
|
|
2001-05-23 13:15:56 +00:00
|
|
|
virtual sal_Int32 SAL_CALL readBytes( Sequence< sal_Int8 >& aData,sal_Int32 nBytesToRead )
|
|
|
|
throw( NotConnectedException,
|
|
|
|
BufferSizeExceededException,
|
|
|
|
IOException,
|
|
|
|
RuntimeException);
|
2001-05-22 13:57:13 +00:00
|
|
|
|
2001-05-23 13:15:56 +00:00
|
|
|
virtual sal_Int32 SAL_CALL readSomeBytes( Sequence< sal_Int8 >& aData,sal_Int32 nMaxBytesToRead )
|
|
|
|
throw( NotConnectedException,
|
|
|
|
BufferSizeExceededException,
|
|
|
|
IOException,
|
|
|
|
RuntimeException);
|
2001-05-22 13:57:13 +00:00
|
|
|
|
|
|
|
virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) throw( NotConnectedException,
|
|
|
|
BufferSizeExceededException,
|
|
|
|
IOException,
|
|
|
|
RuntimeException );
|
|
|
|
|
|
|
|
virtual sal_Int32 SAL_CALL available( void ) throw( NotConnectedException,
|
|
|
|
IOException,
|
|
|
|
RuntimeException );
|
|
|
|
|
|
|
|
virtual void SAL_CALL closeInput( void ) throw( NotConnectedException,
|
|
|
|
IOException,
|
|
|
|
RuntimeException );
|
|
|
|
|
|
|
|
virtual void SAL_CALL seek( sal_Int64 location ) throw( IllegalArgumentException,
|
|
|
|
IOException,
|
|
|
|
RuntimeException );
|
|
|
|
|
|
|
|
virtual sal_Int64 SAL_CALL getPosition( void ) throw( IOException,RuntimeException );
|
|
|
|
|
|
|
|
virtual sal_Int64 SAL_CALL getLength( void ) throw( IOException,RuntimeException );
|
|
|
|
|
2001-05-23 13:15:56 +00:00
|
|
|
void addToBuffer( const char* buffer,int len );
|
|
|
|
|
2001-09-28 14:01:59 +00:00
|
|
|
sal_Int8* getData() const { return (sal_Int8*) buffer; }
|
|
|
|
|
|
|
|
sal_Int32 getLen() const { return sal_Int32( len ); }
|
2001-05-22 13:57:13 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2001-06-06 13:48:47 +00:00
|
|
|
osl::Mutex m_aMutex;
|
|
|
|
|
2001-05-23 13:15:56 +00:00
|
|
|
int len,pos;
|
|
|
|
char *buffer;
|
2001-05-22 13:57:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-09-28 14:01:59 +00:00
|
|
|
|
|
|
|
void URLParameter::open( const Reference< XMultiServiceFactory >& rxSMgr,
|
|
|
|
const Command& aCommand,
|
|
|
|
sal_Int32 CommandId,
|
|
|
|
const Reference< XCommandEnvironment >& Environment,
|
|
|
|
const Reference< XOutputStream >& xDataSink )
|
|
|
|
{
|
|
|
|
if( ! xDataSink.is() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( isPicture() )
|
|
|
|
{
|
|
|
|
Reference< XInputStream > xStream;
|
|
|
|
Reference< XHierarchicalNameAccess > xNA =
|
|
|
|
m_pDatabases->jarFile( rtl::OUString::createFromAscii( "picture.jar" ),
|
|
|
|
get_language() );
|
|
|
|
|
|
|
|
rtl::OUString path = get_path();
|
|
|
|
if( xNA.is() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Any aEntry = xNA->getByHierarchicalName( path );
|
|
|
|
Reference< XActiveDataSink > xSink;
|
|
|
|
if( ( aEntry >>= xSink ) && xSink.is() )
|
|
|
|
xStream = xSink->getInputStream();
|
|
|
|
}
|
|
|
|
catch ( NoSuchElementException & )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( xStream.is() )
|
|
|
|
{
|
|
|
|
sal_Int32 ret;
|
|
|
|
Sequence< sal_Int8 > aSeq( 4096 );
|
|
|
|
while( true )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
ret = xStream->readBytes( aSeq,4096 );
|
|
|
|
xDataSink->writeBytes( aSeq );
|
|
|
|
if( ret < 4096 )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// a standard document or else an active help text, plug in the new input stream
|
|
|
|
InputStreamTransformer* p = new InputStreamTransformer( this,m_pDatabases,isRoot() );
|
|
|
|
try
|
|
|
|
{
|
|
|
|
xDataSink->writeBytes( Sequence< sal_Int8 >( p->getData(),p->getLen() ) );
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
delete p;
|
|
|
|
}
|
|
|
|
xDataSink->closeOutput();
|
|
|
|
}
|
|
|
|
|
2001-05-22 13:57:13 +00:00
|
|
|
|
2001-05-17 14:46:30 +00:00
|
|
|
|
|
|
|
void URLParameter::open( const Reference< XMultiServiceFactory >& rxSMgr,
|
2001-05-25 12:46:25 +00:00
|
|
|
const Command& aCommand,
|
2001-05-17 14:46:30 +00:00
|
|
|
sal_Int32 CommandId,
|
2001-05-22 13:57:13 +00:00
|
|
|
const Reference< XCommandEnvironment >& Environment,
|
|
|
|
const Reference< XActiveDataSink >& xDataSink )
|
2001-05-17 14:46:30 +00:00
|
|
|
{
|
2001-06-13 09:12:40 +00:00
|
|
|
if( isPicture() )
|
2001-05-17 14:46:30 +00:00
|
|
|
{
|
2001-06-13 09:12:40 +00:00
|
|
|
Reference< XInputStream > xStream;
|
|
|
|
Reference< XHierarchicalNameAccess > xNA =
|
|
|
|
m_pDatabases->jarFile( rtl::OUString::createFromAscii( "picture.jar" ),
|
|
|
|
get_language() );
|
2001-05-25 12:46:25 +00:00
|
|
|
|
2001-06-13 09:12:40 +00:00
|
|
|
rtl::OUString path = get_path();
|
|
|
|
if( xNA.is() )
|
2001-06-06 13:48:47 +00:00
|
|
|
{
|
2001-06-13 09:12:40 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Any aEntry = xNA->getByHierarchicalName( path );
|
|
|
|
Reference< XActiveDataSink > xSink;
|
|
|
|
if( ( aEntry >>= xSink ) && xSink.is() )
|
|
|
|
xStream = xSink->getInputStream();
|
|
|
|
}
|
|
|
|
catch ( NoSuchElementException & )
|
2001-06-06 13:48:47 +00:00
|
|
|
{
|
|
|
|
}
|
2001-05-29 14:14:49 +00:00
|
|
|
}
|
2002-03-28 11:38:08 +00:00
|
|
|
#ifdef WORKAROUND_98119
|
|
|
|
xDataSink->setInputStream( turnToSeekable(xStream) );
|
|
|
|
#else
|
2001-06-13 09:12:40 +00:00
|
|
|
xDataSink->setInputStream( xStream );
|
2002-03-28 11:38:08 +00:00
|
|
|
#endif
|
2001-05-17 14:46:30 +00:00
|
|
|
}
|
|
|
|
else
|
2001-06-13 08:10:13 +00:00
|
|
|
// a standard document or else an active help text, plug in the new input stream
|
2001-06-13 09:12:40 +00:00
|
|
|
xDataSink->setInputStream( new InputStreamTransformer( this,m_pDatabases,isRoot() ) );
|
2001-05-17 14:46:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-05-16 06:36:23 +00:00
|
|
|
void URLParameter::parse() throw( com::sun::star::ucb::IllegalIdentifierException )
|
|
|
|
{
|
|
|
|
m_aExpr = m_aURL;
|
|
|
|
|
|
|
|
sal_Int32 lstIdx = m_aExpr.lastIndexOf( sal_Unicode( '#' ) );
|
|
|
|
if( lstIdx != -1 )
|
|
|
|
m_aExpr = m_aExpr.copy( 0,lstIdx );
|
|
|
|
|
2001-09-28 14:01:59 +00:00
|
|
|
if( ! scheme() ||
|
|
|
|
! name( module() ) ||
|
|
|
|
! query() ||
|
|
|
|
! m_aLanguage.getLength() ||
|
|
|
|
! m_aSystem.getLength() )
|
2001-05-16 06:36:23 +00:00
|
|
|
throw com::sun::star::ucb::IllegalIdentifierException();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool URLParameter::scheme()
|
|
|
|
{
|
|
|
|
#define PREFIX_LENGTH 20
|
|
|
|
if( m_aExpr.compareToAscii( "vnd.sun.star.help://",PREFIX_LENGTH ) == 0 )
|
|
|
|
{
|
|
|
|
m_aExpr = m_aExpr.copy( PREFIX_LENGTH );
|
|
|
|
#undef PREFIX_LENGTH
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#define PREFIX_LENGTH 19
|
|
|
|
else if( m_aExpr.compareToAscii( "vnd.sun.star.help:/",PREFIX_LENGTH ) == 0 )
|
|
|
|
{
|
|
|
|
m_aExpr = m_aExpr.copy( PREFIX_LENGTH );
|
|
|
|
#undef PREFIX_LENGTH
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#define PREFIX_LENGTH 18
|
|
|
|
else if( m_aExpr.compareToAscii( "vnd.sun.star.help:",PREFIX_LENGTH ) == 0 )
|
|
|
|
{
|
|
|
|
m_aExpr = m_aExpr.copy( PREFIX_LENGTH );
|
|
|
|
#undef PREFIX_LENGTH
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool URLParameter::module()
|
|
|
|
{
|
|
|
|
sal_Int32 idx = 0,length = m_aExpr.getLength();
|
|
|
|
|
|
|
|
while( idx < length && isLetterOrDigit( (m_aExpr.getStr())[idx] ) )
|
|
|
|
++idx;
|
|
|
|
|
|
|
|
if( idx != 0 )
|
|
|
|
{
|
|
|
|
m_aModule = m_aExpr.copy( 0,idx );
|
|
|
|
m_aExpr = m_aExpr.copy( idx );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool URLParameter::name( bool modulePresent )
|
|
|
|
{
|
|
|
|
// if modulepresent, a name may be present, but must not
|
|
|
|
|
|
|
|
sal_Int32 length = m_aExpr.getLength();
|
|
|
|
|
|
|
|
if( length != 0 && (m_aExpr.getStr())[0] == sal_Unicode( '/' ) )
|
|
|
|
{
|
|
|
|
sal_Int32 idx = 1;
|
|
|
|
while( idx < length && isLetterOrDigit( (m_aExpr.getStr())[idx] ) )
|
|
|
|
++idx;
|
|
|
|
|
|
|
|
if( idx != 1 && ! modulePresent )
|
|
|
|
return false;
|
|
|
|
else
|
|
|
|
{
|
2001-05-17 08:58:55 +00:00
|
|
|
m_aId = m_aExpr.copy( 1,idx-1 );
|
2001-05-16 06:36:23 +00:00
|
|
|
m_aExpr = m_aExpr.copy( idx );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool URLParameter::query()
|
|
|
|
{
|
|
|
|
rtl::OUString query;
|
|
|
|
|
|
|
|
if( ! m_aExpr.getLength() )
|
|
|
|
return true;
|
|
|
|
else if( (m_aExpr.getStr())[0] == sal_Unicode( '?' ) )
|
|
|
|
query = m_aExpr.copy( 1 ).trim();
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
bool ret = true;
|
|
|
|
sal_Int32 delimIdx,equalIdx;
|
|
|
|
rtl::OUString parameter,value;
|
|
|
|
|
|
|
|
while( query.getLength() != 0 )
|
|
|
|
{
|
|
|
|
delimIdx = query.indexOf( sal_Unicode( '&' ) );
|
|
|
|
equalIdx = query.indexOf( sal_Unicode( '=' ) );
|
|
|
|
parameter = query.copy( 0,equalIdx ).trim();
|
|
|
|
if( delimIdx == -1 )
|
|
|
|
{
|
|
|
|
value = query.copy( equalIdx + 1 ).trim();
|
|
|
|
query = rtl::OUString();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
value = query.copy( equalIdx+1,delimIdx - equalIdx - 1 ).trim();
|
|
|
|
query = query.copy( delimIdx+1 ).trim();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( parameter.compareToAscii( "Language" ) == 0 )
|
|
|
|
m_aLanguage = value;
|
|
|
|
else if( parameter.compareToAscii( "Device" ) == 0 )
|
|
|
|
m_aDevice = value;
|
|
|
|
else if( parameter.compareToAscii( "Program" ) == 0 )
|
|
|
|
m_aProgram = value;
|
|
|
|
else if( parameter.compareToAscii( "Eid" ) == 0 )
|
|
|
|
m_aEid = value;
|
|
|
|
else if( parameter.compareToAscii( "Query" ) == 0 )
|
|
|
|
{
|
|
|
|
if( ! m_aQuery.getLength() )
|
|
|
|
m_aQuery = value;
|
|
|
|
else
|
|
|
|
m_aQuery += ( rtl::OUString::createFromAscii( " " ) + value );
|
|
|
|
}
|
|
|
|
else if( parameter.compareToAscii( "Scope" ) == 0 )
|
|
|
|
m_aScope = value;
|
|
|
|
else if( parameter.compareToAscii( "System" ) == 0 )
|
|
|
|
m_aSystem = value;
|
|
|
|
else if( parameter.compareToAscii( "HelpPrefix" ) == 0 )
|
2001-09-28 14:01:59 +00:00
|
|
|
m_aPrefix = rtl::Uri::decode( value,
|
|
|
|
rtl_UriDecodeWithCharset,
|
|
|
|
RTL_TEXTENCODING_UTF8 );
|
2001-05-16 06:36:23 +00:00
|
|
|
else if( parameter.compareToAscii( "HitCount" ) == 0 )
|
|
|
|
m_nHitCount = value.toInt32();
|
|
|
|
else if( parameter.compareToAscii( "Active" ) == 0 )
|
|
|
|
m_aActive = value;
|
|
|
|
else
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2001-05-22 13:57:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// InutStreamTransformerImpl //
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-05-23 13:15:56 +00:00
|
|
|
int schemehandlergetall( void *userData,
|
|
|
|
SablotHandle processor_,
|
|
|
|
const char *scheme,
|
|
|
|
const char *rest,
|
|
|
|
char **buffer,
|
|
|
|
int *byteCount);
|
|
|
|
int schemehandlerfreememory( void *userData,
|
|
|
|
SablotHandle processor_,
|
|
|
|
char *buffer );
|
|
|
|
int schemehandleropen( void *userData,
|
|
|
|
SablotHandle processor_,
|
|
|
|
const char *scheme,
|
|
|
|
const char *rest,
|
|
|
|
int *handle );
|
|
|
|
int schemehandlerget( void *userData,
|
|
|
|
SablotHandle processor_,
|
|
|
|
int handle,
|
|
|
|
char *buffer,
|
|
|
|
int *byteCount );
|
|
|
|
int schemehandlerput( void *userData,
|
|
|
|
SablotHandle processor_,
|
|
|
|
int handle,
|
|
|
|
const char *buffer,
|
|
|
|
int *byteCount );
|
|
|
|
int schemehandlerclose( void *userData,
|
|
|
|
SablotHandle processor_,
|
|
|
|
int handle );
|
|
|
|
|
|
|
|
|
|
|
|
struct UserData {
|
|
|
|
|
2001-06-13 08:10:13 +00:00
|
|
|
UserData( InputStreamTransformer* pTransformer,
|
2001-06-06 13:48:47 +00:00
|
|
|
URLParameter* pInitial,
|
|
|
|
Databases* pDatabases )
|
2001-06-13 08:10:13 +00:00
|
|
|
: m_pTransformer( pTransformer ),
|
2001-06-06 13:48:47 +00:00
|
|
|
m_pInitial( pInitial ),
|
|
|
|
m_pDatabases( pDatabases )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
InputStreamTransformer* m_pTransformer;
|
|
|
|
Databases* m_pDatabases;
|
|
|
|
URLParameter* m_pInitial;
|
2001-05-23 13:15:56 +00:00
|
|
|
};
|
2001-05-22 13:57:13 +00:00
|
|
|
|
|
|
|
|
2001-06-06 13:48:47 +00:00
|
|
|
|
2001-06-13 08:10:13 +00:00
|
|
|
InputStreamTransformer::InputStreamTransformer( URLParameter* urlParam,
|
2001-06-13 09:12:40 +00:00
|
|
|
Databases* pDatabases,
|
|
|
|
bool isRoot )
|
2001-05-23 13:15:56 +00:00
|
|
|
: len( 0 ),
|
|
|
|
pos( 0 ),
|
|
|
|
buffer( new char[0] )
|
2001-05-22 13:57:13 +00:00
|
|
|
{
|
2001-06-13 09:12:40 +00:00
|
|
|
if( isRoot )
|
|
|
|
{
|
|
|
|
delete[] buffer;
|
|
|
|
pDatabases->cascadingStylesheet( urlParam->get_language(),
|
|
|
|
&buffer,
|
|
|
|
&len );
|
|
|
|
}
|
|
|
|
else if( urlParam->isActive() )
|
2001-06-13 08:10:13 +00:00
|
|
|
{
|
|
|
|
delete[] buffer;
|
|
|
|
pDatabases->setActiveText( urlParam->get_module(),
|
|
|
|
urlParam->get_language(),
|
|
|
|
urlParam->get_id(),
|
|
|
|
&buffer,
|
|
|
|
&len );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SchemeHandler schemeHandler;
|
|
|
|
schemeHandler.getAll = schemehandlergetall;
|
|
|
|
schemeHandler.freeMemory = schemehandlerfreememory;
|
|
|
|
schemeHandler.open = schemehandleropen;
|
|
|
|
schemeHandler.get = schemehandlerget;
|
|
|
|
schemeHandler.put = schemehandlerput;
|
|
|
|
schemeHandler.close = schemehandlerclose;
|
|
|
|
|
|
|
|
UserData userData( this,urlParam,pDatabases );
|
|
|
|
|
|
|
|
// Uses the implementation detail, that rtl::OString::getStr returns a zero terminated character-array
|
|
|
|
|
2001-10-31 12:08:14 +00:00
|
|
|
const char* parameter[41];
|
|
|
|
rtl::OString parString[40];
|
2001-09-28 14:01:59 +00:00
|
|
|
int last;
|
2001-06-13 08:10:13 +00:00
|
|
|
|
|
|
|
parString[ 0] = "Program";
|
|
|
|
parString[ 1] = urlParam->getByName( "Program" );
|
|
|
|
parString[ 2] = "Database";
|
|
|
|
parString[ 3] = urlParam->getByName( "Database" );
|
|
|
|
parString[ 4] = "Id";
|
|
|
|
parString[ 5] = urlParam->getByName( "Id" );
|
|
|
|
parString[ 6] = "Path";
|
|
|
|
parString[ 7] = urlParam->getByName( "Path" );
|
|
|
|
parString[ 8] = "Language";
|
|
|
|
parString[ 9] = urlParam->getByName( "Language" );
|
|
|
|
parString[10] = "System";
|
|
|
|
parString[11] = urlParam->getByName( "System" );
|
2001-10-31 12:08:14 +00:00
|
|
|
parString[12] = "productname";
|
|
|
|
parString[13] = rtl::OString( pDatabases->getProductName().getStr(),
|
|
|
|
pDatabases->getProductName().getLength(),
|
|
|
|
RTL_TEXTENCODING_UTF8 );
|
|
|
|
parString[14] = "productversion";
|
|
|
|
parString[15] = rtl::OString( pDatabases->getProductVersion().getStr(),
|
|
|
|
pDatabases->getProductVersion().getLength(),
|
|
|
|
RTL_TEXTENCODING_UTF8 );
|
|
|
|
|
|
|
|
parString[16] = "hp";
|
|
|
|
parString[17] = urlParam->getByName( "HelpPrefix" );
|
|
|
|
last = 18;
|
|
|
|
|
|
|
|
if( parString[17].getLength() )
|
2001-09-28 14:01:59 +00:00
|
|
|
{
|
2001-10-31 12:08:14 +00:00
|
|
|
parString[18] = "sm";
|
|
|
|
parString[19] = "vnd.sun.star.help%3A%2F%2F";
|
|
|
|
parString[20] = "qm";
|
|
|
|
parString[21] = "%3F";
|
|
|
|
parString[22] = "es";
|
|
|
|
parString[23] = "%3D";
|
|
|
|
parString[24] = "am";
|
|
|
|
parString[25] = "%26";
|
|
|
|
parString[26] = "cl";
|
|
|
|
parString[27] = "%3A";
|
|
|
|
parString[28] = "sl";
|
|
|
|
parString[29] = "%2F";
|
|
|
|
parString[30] = "hm";
|
|
|
|
parString[31] = "%23";
|
|
|
|
parString[32] = "cs";
|
|
|
|
parString[33] = "css";
|
|
|
|
|
|
|
|
parString[34] = "vendorname";
|
|
|
|
parString[35] = rtl::OString( pDatabases->getVendorName().getStr(),
|
|
|
|
pDatabases->getVendorName().getLength(),
|
|
|
|
RTL_TEXTENCODING_UTF8 );
|
|
|
|
parString[36] = "vendorversion";
|
|
|
|
parString[37] = rtl::OString( pDatabases->getVendorVersion().getStr(),
|
|
|
|
pDatabases->getVendorVersion().getLength(),
|
|
|
|
RTL_TEXTENCODING_UTF8 );
|
|
|
|
parString[38] = "vendorshort";
|
|
|
|
parString[39] = rtl::OString( pDatabases->getVendorShort().getStr(),
|
|
|
|
pDatabases->getVendorShort().getLength(),
|
|
|
|
RTL_TEXTENCODING_UTF8 );
|
|
|
|
last = 40;
|
2001-09-28 14:01:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for( int i = 0; i < last; ++i )
|
2001-06-13 08:10:13 +00:00
|
|
|
parameter[i] = parString[i].getStr();
|
2001-09-28 14:01:59 +00:00
|
|
|
parameter[last] = 0;
|
2001-06-13 08:10:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
SablotHandle p;
|
|
|
|
SablotCreateProcessor(&p);
|
|
|
|
SablotRegHandler( p,HLR_SCHEME,&schemeHandler,(void*)(&userData) );
|
2001-09-04 10:58:35 +00:00
|
|
|
rtl::OUString xslURL = pDatabases->getInstallPathAsURLWithOutEncoding();
|
|
|
|
|
2003-05-28 12:29:54 +00:00
|
|
|
rtl::OString xslURLascii(
|
|
|
|
xslURL.getStr(),
|
|
|
|
xslURL.getLength(),
|
|
|
|
osl_getThreadTextEncoding());
|
2001-06-13 08:10:13 +00:00
|
|
|
xslURLascii += "main_transform.xsl";
|
|
|
|
|
|
|
|
SablotRunProcessor( p,
|
|
|
|
const_cast<char*>(xslURLascii.getStr()),
|
|
|
|
"vnd.sun.star.pkg:/",
|
|
|
|
"vnd.sun.star.resultat:/",
|
|
|
|
const_cast<char**>(parameter),
|
|
|
|
0 );
|
|
|
|
|
|
|
|
SablotDestroyProcessor( p );
|
|
|
|
}
|
2001-05-22 13:57:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
InputStreamTransformer::~InputStreamTransformer()
|
|
|
|
{
|
2001-05-23 13:15:56 +00:00
|
|
|
delete[] buffer;
|
2001-05-22 13:57:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Any SAL_CALL InputStreamTransformer::queryInterface( const Type& rType ) throw( RuntimeException )
|
|
|
|
{
|
2001-05-23 13:15:56 +00:00
|
|
|
Any aRet = ::cppu::queryInterface( rType,
|
2001-05-22 13:57:13 +00:00
|
|
|
SAL_STATIC_CAST( XInputStream*,this ),
|
|
|
|
SAL_STATIC_CAST( XSeekable*,this ) );
|
|
|
|
|
|
|
|
return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-10-24 10:17:19 +00:00
|
|
|
void SAL_CALL InputStreamTransformer::acquire( void ) throw()
|
2001-05-22 13:57:13 +00:00
|
|
|
{
|
|
|
|
OWeakObject::acquire();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-10-24 10:17:19 +00:00
|
|
|
void SAL_CALL InputStreamTransformer::release( void ) throw()
|
2001-05-22 13:57:13 +00:00
|
|
|
{
|
|
|
|
OWeakObject::release();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-06-06 13:48:47 +00:00
|
|
|
sal_Int32 SAL_CALL InputStreamTransformer::readBytes( Sequence< sal_Int8 >& aData,sal_Int32 nBytesToRead )
|
|
|
|
throw( NotConnectedException,
|
|
|
|
BufferSizeExceededException,
|
|
|
|
IOException,
|
|
|
|
RuntimeException)
|
2001-05-22 13:57:13 +00:00
|
|
|
{
|
2001-06-06 13:48:47 +00:00
|
|
|
osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
|
2001-05-23 13:15:56 +00:00
|
|
|
int curr,available = len-pos;
|
|
|
|
if( nBytesToRead <= available )
|
|
|
|
curr = nBytesToRead;
|
|
|
|
else
|
|
|
|
curr = available;
|
|
|
|
|
|
|
|
if( 0 <= curr && aData.getLength() < curr )
|
|
|
|
aData.realloc( curr );
|
2001-05-22 13:57:13 +00:00
|
|
|
|
2001-05-23 13:15:56 +00:00
|
|
|
for( int k = 0; k < curr; ++k )
|
|
|
|
aData[k] = buffer[pos++];
|
|
|
|
|
|
|
|
return curr > 0 ? curr : 0;
|
|
|
|
}
|
2001-05-22 13:57:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
sal_Int32 SAL_CALL InputStreamTransformer::readSomeBytes( Sequence< sal_Int8 >& aData,sal_Int32 nMaxBytesToRead )
|
|
|
|
throw( NotConnectedException,
|
|
|
|
BufferSizeExceededException,
|
|
|
|
IOException,
|
|
|
|
RuntimeException)
|
|
|
|
{
|
2001-05-23 13:15:56 +00:00
|
|
|
return readBytes( aData,nMaxBytesToRead );
|
2001-05-22 13:57:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SAL_CALL InputStreamTransformer::skipBytes( sal_Int32 nBytesToSkip ) throw( NotConnectedException,
|
|
|
|
BufferSizeExceededException,
|
|
|
|
IOException,
|
|
|
|
RuntimeException )
|
|
|
|
{
|
2001-06-06 13:48:47 +00:00
|
|
|
osl::MutexGuard aGuard( m_aMutex );
|
2001-05-23 13:15:56 +00:00
|
|
|
while( nBytesToSkip-- ) ++pos;
|
2001-05-22 13:57:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sal_Int32 SAL_CALL InputStreamTransformer::available( void ) throw( NotConnectedException,
|
|
|
|
IOException,
|
|
|
|
RuntimeException )
|
|
|
|
{
|
2001-06-06 13:48:47 +00:00
|
|
|
osl::MutexGuard aGuard( m_aMutex );
|
2001-05-23 13:15:56 +00:00
|
|
|
return len-pos > 0 ? len - pos : 0 ;
|
2001-05-22 13:57:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SAL_CALL InputStreamTransformer::closeInput( void ) throw( NotConnectedException,
|
|
|
|
IOException,
|
|
|
|
RuntimeException )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SAL_CALL InputStreamTransformer::seek( sal_Int64 location ) throw( IllegalArgumentException,
|
|
|
|
IOException,
|
|
|
|
RuntimeException )
|
|
|
|
{
|
2001-06-06 13:48:47 +00:00
|
|
|
osl::MutexGuard aGuard( m_aMutex );
|
2001-05-23 13:15:56 +00:00
|
|
|
if( location < 0 )
|
|
|
|
throw IllegalArgumentException();
|
|
|
|
else
|
|
|
|
pos = location;
|
|
|
|
|
|
|
|
if( pos > len )
|
|
|
|
pos = len;
|
2001-05-22 13:57:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sal_Int64 SAL_CALL InputStreamTransformer::getPosition( void ) throw( IOException,
|
|
|
|
RuntimeException )
|
|
|
|
{
|
2001-06-06 13:48:47 +00:00
|
|
|
osl::MutexGuard aGuard( m_aMutex );
|
2001-05-23 13:15:56 +00:00
|
|
|
return sal_Int64( pos );
|
2001-05-22 13:57:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sal_Int64 SAL_CALL InputStreamTransformer::getLength( void ) throw( IOException,RuntimeException )
|
|
|
|
{
|
2001-06-06 13:48:47 +00:00
|
|
|
osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
|
2001-05-23 13:15:56 +00:00
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InputStreamTransformer::addToBuffer( const char* buffer_,int len_ )
|
|
|
|
{
|
2001-06-06 13:48:47 +00:00
|
|
|
osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
|
2001-05-23 13:15:56 +00:00
|
|
|
char* tmp = buffer;
|
|
|
|
buffer = new char[ len+len_ ];
|
|
|
|
rtl_copyMemory( (void*)(buffer),(void*)(tmp),sal_uInt32( len ) );
|
|
|
|
rtl_copyMemory( (void*)(buffer+len),(void*)(buffer_),sal_uInt32( len_ ) );
|
2003-04-04 16:09:59 +00:00
|
|
|
delete[] tmp;
|
2001-05-23 13:15:56 +00:00
|
|
|
len += len_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-08-21 12:26:25 +00:00
|
|
|
|
|
|
|
|
2001-06-06 13:48:47 +00:00
|
|
|
/**
|
|
|
|
* getAll: open the URI and return the whole string
|
|
|
|
* scheme = URI scheme (e.g. "http")
|
|
|
|
* rest = the rest of the URI (without colon)
|
|
|
|
* the document is returned in a handler-allocated buffer
|
|
|
|
* byteCount holds the byte count on return
|
|
|
|
* return *buffer = NULL if not processed
|
|
|
|
*/
|
2001-05-23 13:15:56 +00:00
|
|
|
|
|
|
|
int schemehandlergetall( void *userData,
|
|
|
|
SablotHandle processor_,
|
|
|
|
const char *scheme,
|
|
|
|
const char *rest,
|
|
|
|
char **buffer,
|
|
|
|
int *byteCount )
|
|
|
|
{
|
2001-06-06 13:48:47 +00:00
|
|
|
rtl::OUString language,jar,path;
|
|
|
|
UserData *uData = reinterpret_cast< UserData* >( userData );
|
2001-05-23 13:15:56 +00:00
|
|
|
|
|
|
|
if( strcmp( scheme,"vnd.sun.star.help" ) == 0 )
|
|
|
|
{
|
|
|
|
URLParameter urlpar( rtl::OUString::createFromAscii( scheme ) +
|
|
|
|
rtl::OUString::createFromAscii( ":" ) +
|
2001-06-06 13:48:47 +00:00
|
|
|
rtl::OUString::createFromAscii( rest ),
|
|
|
|
uData->m_pDatabases );
|
2001-05-23 13:15:56 +00:00
|
|
|
|
2001-06-06 13:48:47 +00:00
|
|
|
jar = urlpar.get_jar();
|
|
|
|
language = urlpar.get_language();
|
|
|
|
path = urlpar.get_path();
|
2001-05-23 13:15:56 +00:00
|
|
|
}
|
|
|
|
else if( strcmp( scheme,"vnd.sun.star.pkg" ) == 0 )
|
2001-06-06 13:48:47 +00:00
|
|
|
{
|
|
|
|
if( uData->m_pInitial->get_eid().getLength() )
|
|
|
|
{
|
|
|
|
uData->m_pDatabases->popupDocument( uData->m_pInitial,buffer,byteCount );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
jar = uData->m_pInitial->get_jar();
|
|
|
|
language = uData->m_pInitial->get_language();
|
|
|
|
path = uData->m_pInitial->get_path();
|
|
|
|
}
|
|
|
|
}
|
2001-05-23 13:15:56 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
*buffer = 0;
|
|
|
|
*byteCount = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-06-06 13:48:47 +00:00
|
|
|
Reference< XInputStream > xInputStream;
|
|
|
|
Reference< XHierarchicalNameAccess > xNA = uData->m_pDatabases->jarFile( jar,language );
|
2001-05-23 13:15:56 +00:00
|
|
|
|
2001-06-06 13:48:47 +00:00
|
|
|
if( xNA.is() )
|
2001-05-23 13:15:56 +00:00
|
|
|
{
|
2001-06-06 13:48:47 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Any aEntry = xNA->getByHierarchicalName( path );
|
|
|
|
Reference< XActiveDataSink > xSink;
|
|
|
|
if( ( aEntry >>= xSink ) && xSink.is() )
|
|
|
|
xInputStream = xSink->getInputStream();
|
|
|
|
}
|
|
|
|
catch ( NoSuchElementException & )
|
|
|
|
{
|
|
|
|
}
|
2001-05-23 13:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( xInputStream.is() )
|
|
|
|
{
|
|
|
|
sal_Int32 size = 0;
|
|
|
|
|
2002-03-07 10:55:55 +00:00
|
|
|
Reference< XSeekable > xSeekable( xInputStream,UNO_QUERY );
|
|
|
|
|
2001-05-23 13:15:56 +00:00
|
|
|
if( xSeekable.is() )
|
|
|
|
size = sal_Int32( xSeekable->getLength() );
|
2002-03-07 10:55:55 +00:00
|
|
|
else
|
|
|
|
size = sal_Int32( xInputStream->available() );
|
2001-05-23 13:15:56 +00:00
|
|
|
|
|
|
|
*buffer = new char[ 1+size ];
|
|
|
|
(*buffer)[ size ] = 0;
|
|
|
|
|
|
|
|
Sequence< sal_Int8 > aSeq;
|
|
|
|
xInputStream->readBytes( aSeq,size );
|
|
|
|
|
|
|
|
rtl_copyMemory( (void*)(*buffer),(void*)(aSeq.getConstArray()),sal_uInt32(size) );
|
|
|
|
*byteCount = size;
|
|
|
|
}
|
|
|
|
else
|
2001-06-12 13:16:41 +00:00
|
|
|
uData->m_pDatabases->errorDocument( language,buffer,byteCount );
|
2001-05-23 13:15:56 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* freeMemory: free the buffer allocated by getAll
|
|
|
|
*/
|
|
|
|
|
|
|
|
int schemehandlerfreememory( void *userData,
|
|
|
|
SablotHandle processor_,
|
|
|
|
char *buffer )
|
|
|
|
{
|
|
|
|
delete[] buffer;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* open: open the URI and return a handle
|
|
|
|
scheme = URI scheme (e.g. "http")
|
|
|
|
rest = the rest of the URI (without colon)
|
|
|
|
the resulting handle is returned in '*handle'
|
|
|
|
*/
|
|
|
|
|
|
|
|
int schemehandleropen( void *userData,
|
|
|
|
SablotHandle processor_,
|
|
|
|
const char *scheme,
|
|
|
|
const char *rest,
|
|
|
|
int *handle )
|
|
|
|
{
|
|
|
|
*handle = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get: retrieve data from the URI
|
|
|
|
handle = the handle assigned on open
|
|
|
|
buffer = pointer to the data
|
|
|
|
*byteCount = number of bytes to read
|
|
|
|
(the number actually read is returned here)
|
|
|
|
*/
|
|
|
|
|
|
|
|
int schemehandlerget( void *userData,
|
|
|
|
SablotHandle processor_,
|
|
|
|
int handle,
|
|
|
|
char *buffer,
|
|
|
|
int *byteCount )
|
|
|
|
{
|
2001-05-25 12:46:25 +00:00
|
|
|
*byteCount = 0;
|
2001-05-23 13:15:56 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* put: save data to the URI (if possible)
|
|
|
|
handle = the handle assigned on open
|
|
|
|
buffer = pointer to the data
|
|
|
|
*byteCount = number of bytes to write
|
|
|
|
(the number actually written is returned here)
|
|
|
|
*/
|
|
|
|
int schemehandlerput( void *userData,
|
|
|
|
SablotHandle processor_,
|
|
|
|
int handle,
|
|
|
|
const char *buffer,
|
|
|
|
int *byteCount )
|
|
|
|
{
|
|
|
|
UserData *uData = reinterpret_cast< UserData* >( userData );
|
|
|
|
uData->m_pTransformer->addToBuffer( buffer,*byteCount );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* close: close the URI with the given handle
|
|
|
|
handle = the handle assigned on open
|
|
|
|
*/
|
|
|
|
|
|
|
|
int schemehandlerclose( void *userData,
|
|
|
|
SablotHandle processor_,
|
|
|
|
int handle )
|
|
|
|
{
|
|
|
|
return 0;
|
2001-05-22 13:57:13 +00:00
|
|
|
}
|
2001-06-13 08:10:13 +00:00
|
|
|
|
|
|
|
|
2001-06-13 09:12:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
|