diff options
author | Andreas Bille <abi@openoffice.org> | 2001-09-28 14:01:59 +0000 |
---|---|---|
committer | Andreas Bille <abi@openoffice.org> | 2001-09-28 14:01:59 +0000 |
commit | ac84ebf7f5819e448809c4514f4768a17bf05f2d (patch) | |
tree | 401fd83e9f35029b3b4ac446fb88c54046be17c3 | |
parent | e24bc241b69da6789351d9bf82eab5119f09c16c (diff) |
#91885#
Some more features specially needed by the webtop( helprprefix, Order property at module contents,
missing implementation of XPropertySet for cached dynamic result set on java side )
-rw-r--r-- | xmlhelp/source/cxxhelp/provider/content.cxx | 39 | ||||
-rw-r--r-- | xmlhelp/source/cxxhelp/provider/contentcaps.cxx | 12 | ||||
-rw-r--r-- | xmlhelp/source/cxxhelp/provider/databases.cxx | 55 | ||||
-rw-r--r-- | xmlhelp/source/cxxhelp/provider/makefile.mk | 6 | ||||
-rw-r--r-- | xmlhelp/source/cxxhelp/provider/provider.cxx | 243 | ||||
-rw-r--r-- | xmlhelp/source/cxxhelp/provider/resultsetbase.cxx | 71 | ||||
-rw-r--r-- | xmlhelp/source/cxxhelp/provider/urlparameter.cxx | 183 |
7 files changed, 366 insertions, 243 deletions
diff --git a/xmlhelp/source/cxxhelp/provider/content.cxx b/xmlhelp/source/cxxhelp/provider/content.cxx index 4deaa5956365..2bc5e386283d 100644 --- a/xmlhelp/source/cxxhelp/provider/content.cxx +++ b/xmlhelp/source/cxxhelp/provider/content.cxx @@ -2,9 +2,9 @@ * * $RCSfile: content.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: abi $ $Date: 2001-08-24 13:59:14 $ + * last change: $Author: abi $ $Date: 2001-09-28 15:01:59 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -428,31 +428,15 @@ Any SAL_CALL Content::execute( const Command& aCommand, Reference< XActiveDataSink > xActiveDataSink( aOpenCommand.Sink,UNO_QUERY ); if( xActiveDataSink.is() ) - { -// Reference< XInputStream > xInputStream; - -// // Necessary to avoid closing the fileinputstream -// if( ! m_aURLParameter.isRoot() ) -// xInputStream = m_pDatabases->getFromURL( m_aURLParameter.get_url() ); - -// if( ! xInputStream.is() ) -// { - m_aURLParameter.open( m_xSMgr,aCommand,CommandId,Environment,xActiveDataSink ); -// m_pDatabases->setFromURL( m_aURLParameter.get_url(), -// xActiveDataSink->getInputStream() ); -// } -// else -// xActiveDataSink->setInputStream( xInputStream ); - } + m_aURLParameter.open( m_xSMgr,aCommand,CommandId,Environment,xActiveDataSink ); Reference< XActiveDataStreamer > activeDataStreamer( aOpenCommand.Sink,UNO_QUERY ); if( activeDataStreamer.is() ) throw UnsupportedDataSinkException(); - Reference< XOutputStream > outputStream( aOpenCommand.Sink,UNO_QUERY ); - if( outputStream.is() ) - throw UnsupportedDataSinkException(); - + Reference< XOutputStream > xOutputStream( aOpenCommand.Sink,UNO_QUERY ); + if( xOutputStream.is() ) + m_aURLParameter.open( m_xSMgr,aCommand,CommandId,Environment,xOutputStream ); if( m_aURLParameter.isRoot() ) { @@ -587,6 +571,17 @@ Reference< XRow > Content::getPropertyValues( const Sequence< Property >& rPrope aAny <<= seq; xRow->appendObject( rProp,aAny ); } + else if( rProp.Name.compareToAscii( "Order" ) == 0 ) + { + StaticModuleInformation *inf = m_pDatabases->getStaticInformationForModule( + m_aURLParameter.get_module(), + m_aURLParameter.get_language() ); + + Any aAny; + if( inf ) + aAny <<= sal_Int32( inf->get_order() ); + xRow->appendObject( rProp,aAny ); + } else xRow->appendVoid( rProp ); else if( rProp.Name.compareToAscii( "AnchorName" ) == 0 && m_aURLParameter.isFile() ) diff --git a/xmlhelp/source/cxxhelp/provider/contentcaps.cxx b/xmlhelp/source/cxxhelp/provider/contentcaps.cxx index 440daa50ae00..b57a1a3c94a1 100644 --- a/xmlhelp/source/cxxhelp/provider/contentcaps.cxx +++ b/xmlhelp/source/cxxhelp/provider/contentcaps.cxx @@ -2,9 +2,9 @@ * * $RCSfile: contentcaps.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: abi $ $Date: 2001-08-21 13:26:25 $ + * last change: $Author: abi $ $Date: 2001-09-28 15:01:59 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -96,7 +96,7 @@ Sequence< Property > Content::getProperties( const Reference< XCommandEnvironmen bool isFile = m_aURLParameter.isFile(); sal_Int32 num = withMediaType ? 7 : 6; - if( isModule ) num+=5; + if( isModule ) num+=6; if( isFile ) num++; Sequence< Property > props(num); @@ -154,6 +154,12 @@ Sequence< Property > Content::getProperties( const Reference< XCommandEnvironmen if( isModule ) { props[idx++] = + Property( OUString( RTL_CONSTASCII_USTRINGPARAM( "Order" ) ), + -1, + getCppuType( static_cast< sal_Int32* >( 0 ) ), + PropertyAttribute::BOUND | PropertyAttribute::READONLY ); + + props[idx++] = Property( OUString( RTL_CONSTASCII_USTRINGPARAM( "KeywordList" ) ), -1, getCppuType( static_cast< const Sequence< OUString >* >( 0 ) ), diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx index 5e4a4d418126..d7554e1c4be8 100644 --- a/xmlhelp/source/cxxhelp/provider/databases.cxx +++ b/xmlhelp/source/cxxhelp/provider/databases.cxx @@ -2,9 +2,9 @@ * * $RCSfile: databases.cxx,v $ * - * $Revision: 1.21 $ + * $Revision: 1.22 $ * - * last change: $Author: abi $ $Date: 2001-09-04 11:58:35 $ + * last change: $Author: abi $ $Date: 2001-09-28 15:01:59 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -81,6 +81,7 @@ #ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_ #include <com/sun/star/lang/Locale.hpp> #endif +#include "inputstream.hxx" using namespace chelp; @@ -271,6 +272,7 @@ StaticModuleInformation* Databases::getStaticInformationForModule( const rtl::OU const sal_Unicode* str = fileContent.getStr(); rtl::OUString current,lang,program,startid,title,heading,fulltext; + rtl::OUString order = rtl::OUString::createFromAscii( "1" ); for( sal_Int32 i = 0;i < fileContent.getLength();i++ ) { @@ -305,13 +307,17 @@ StaticModuleInformation* Databases::getStaticInformationForModule( const rtl::OU { fulltext = current.copy( current.indexOf('=') + 1 ); } + else if( current.compareToAscii( "Order",5 ) == 0 ) + { + order = current.copy( current.indexOf('=') + 1 ); + } } pos = 0; } else lineBuffer[ pos++ ] = ch; } - it->second = new StaticModuleInformation( title,startid,program,heading,fulltext ); + it->second = new StaticModuleInformation( title,startid,program,heading,fulltext,order ); } } @@ -534,11 +540,10 @@ int KeywordInfo::Compare::operator()( const rtl::OUString& l,const rtl::OUString else { if( c1 == 0 ) - return ( m_xCollator->compareSubstring( l,1+l1,l2,r,1+r1,r2 ) <= 0 ) ? 1 : 0; + return ( m_xCollator->compareSubstring( l,1+l1,l2,r,1+r1,r2 ) < 0 ) ? 1 : 0; else return 1; } -// return ( m_xCollator->compareString( l,r ) <= 0 ) ? 1 : 0; } else return ( l <= r ) ? 1 : 0; @@ -652,34 +657,14 @@ KeywordInfo* Databases::getKeyword( const rtl::OUString& Database, -// Reference< XInputStream > Databases::getFromURL( const rtl::OUString& url ) -// { -// osl::MutexGuard aGuard( m_aMutex ); - -// Reference< XInputStream > xStream = m_aInputStreamTable[ url ]; -// if( xStream.is() ) -// m_aInputStreamTable[ url ] = Reference< XInputStream >( 0 ); - -// return xStream; -// } - - -// void Databases::setFromURL( const rtl::OUString& url,const Reference< XInputStream >& xStream ) -// { -// osl::MutexGuard aGuard( m_aMutex ); - -// m_aInputStreamTable[ url ] = xStream; -// } - - - Reference< XHierarchicalNameAccess > Databases::jarFile( const rtl::OUString& jar, const rtl::OUString& Language ) { if( ! jar.getLength() || ! Language.getLength() ) + { return Reference< XHierarchicalNameAccess >( 0 ); - + } rtl::OUString key = lang(Language) + rtl::OUString::createFromAscii( "/" ) + jar; osl::MutexGuard aGuard( m_aMutex ); @@ -689,11 +674,23 @@ Reference< XHierarchicalNameAccess > Databases::jarFile( const rtl::OUString& ja if( ! it->second.is() ) { + rtl::OUString zipFile; try { - rtl::OUString zipFile = getInstallPathAsURL() + key; + zipFile = getInstallPathAsURL() + key; Sequence< Any > aArguments( 1 ); - aArguments[ 0 ] <<= zipFile; + + XInputStream_impl* p = new XInputStream_impl( zipFile ); + if( p->CtorSuccess() ) + { + Reference< XInputStream > xInputStream( p ); + aArguments[ 0 ] <<= xInputStream; + } + else + { + delete p; + aArguments[ 0 ] <<= zipFile; + } Reference< XInterface > xIfc = m_xSMgr->createInstanceWithArguments( diff --git a/xmlhelp/source/cxxhelp/provider/makefile.mk b/xmlhelp/source/cxxhelp/provider/makefile.mk index 01f5e93f691e..55ef6d6d2f89 100644 --- a/xmlhelp/source/cxxhelp/provider/makefile.mk +++ b/xmlhelp/source/cxxhelp/provider/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.7 $ +# $Revision: 1.8 $ # -# last change: $Author: abi $ $Date: 2001-06-13 16:26:35 $ +# last change: $Author: abi $ $Date: 2001-09-28 15:01:59 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -91,6 +91,8 @@ SLOFILES=\ $(SLO)$/resultsetforquery.obj \ $(SLO)$/contentcaps.obj \ $(SLO)$/urlparameter.obj \ + $(SLO)$/inputstream.obj \ + $(SLO)$/debughelper.obj \ $(SLO)$/databases.obj # --- Targets ---------------------------------------------------------- diff --git a/xmlhelp/source/cxxhelp/provider/provider.cxx b/xmlhelp/source/cxxhelp/provider/provider.cxx index 1078f7e0df3f..fa5e7e5e265a 100644 --- a/xmlhelp/source/cxxhelp/provider/provider.cxx +++ b/xmlhelp/source/cxxhelp/provider/provider.cxx @@ -2,9 +2,9 @@ * * $RCSfile: provider.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: abi $ $Date: 2001-07-06 13:32:50 $ + * last change: $Author: abi $ $Date: 2001-09-28 15:01:59 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -118,10 +118,10 @@ using namespace chelp; //========================================================================= ContentProvider::ContentProvider( const Reference< XMultiServiceFactory >& rSMgr ) - : ::ucb::ContentProviderImplHelper( rSMgr ), - isInitialized( false ), - m_aScheme( OUString::createFromAscii( MYUCP_URL_SCHEME ) ), - m_pDatabases( 0 ) + : ::ucb::ContentProviderImplHelper( rSMgr ), + isInitialized( false ), + m_aScheme( OUString::createFromAscii( MYUCP_URL_SCHEME ) ), + m_pDatabases( 0 ) { } @@ -182,141 +182,154 @@ ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider ); // virtual Reference< XContent > SAL_CALL ContentProvider::queryContent( const Reference< XContentIdentifier >& xCanonicId ) - throw( IllegalIdentifierException, RuntimeException ) + throw( IllegalIdentifierException, RuntimeException ) { - if ( ! xCanonicId->getContentProviderScheme().equalsIgnoreAsciiCase( m_aScheme ) ) + if ( ! xCanonicId->getContentProviderScheme().equalsIgnoreAsciiCase( m_aScheme ) ) { // Wrong URL-scheme - throw IllegalIdentifierException(); + throw IllegalIdentifierException(); } - { - osl::MutexGuard aGuard( m_aMutex ); - if( ! isInitialized ) - init(); - } + { + osl::MutexGuard aGuard( m_aMutex ); + if( ! isInitialized ) + init(); + } - if( ! m_pDatabases ) - throw RuntimeException(); + if( ! m_pDatabases ) + throw RuntimeException(); + rtl::OUString aOUString( m_pDatabases->getInstallPathAsURL() ); + rtl::OString aOString( aOUString.getStr(), + aOUString.getLength(), + RTL_TEXTENCODING_UTF8 ); - // Check, if a content with given id already exists... - Reference< XContent > xContent - = queryExistingContent( xCanonicId ).getBodyPtr(); - if ( xContent.is() ) - return xContent; + // Check, if a content with given id already exists... + Reference< XContent > xContent + = queryExistingContent( xCanonicId ).getBodyPtr(); + if ( xContent.is() ) + return xContent; - xContent = new Content( m_xSMgr,this,xCanonicId,m_pDatabases ); + xContent = new Content( m_xSMgr,this,xCanonicId,m_pDatabases ); - // Further checks + // Further checks - if ( !xContent->getIdentifier().is() ) - throw IllegalIdentifierException(); + if ( !xContent->getIdentifier().is() ) + throw IllegalIdentifierException(); - return xContent; + return xContent; } +#include <provider/debughelper.hxx> void ContentProvider::init() { - isInitialized = true; - - rtl::OUString sProviderService = - rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationProvider" ); - - - Any aAny; - aAny <<= rtl::OUString::createFromAscii( "local" ); - PropertyValue aProp( rtl::OUString::createFromAscii( "servertype" ), - -1, - aAny, - PropertyState_DIRECT_VALUE ); - - Sequence< Any > seq(1); - seq[0] <<= aProp; - - Reference< XMultiServiceFactory > sProvider; - try + isInitialized = true; + +// rtl::OUString sProviderService = +// rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationProvider" ); + + +// Any aAny; +// aAny <<= rtl::OUString::createFromAscii( "local" ); +// PropertyValue aProp( rtl::OUString::createFromAscii( "servertype" ), +// -1, +// aAny, +// PropertyState_DIRECT_VALUE ); + +// Sequence< Any > seq(1); +// seq[0] <<= aProp; + +// Reference< XMultiServiceFactory > sProvider; +// try +// { +// sProvider = +// Reference< XMultiServiceFactory >( +// m_xSMgr->createInstanceWithArguments( sProviderService,seq ), +// UNO_QUERY ); +// } +// catch( const com::sun::star::uno::Exception& e ) +// { +// VOS_ENSHURE( sProvider.is()," cant instantiate the multiservicefactory " ); +// } + + +// if( ! sProvider.is() ) +// { +// return; +// } + +// rtl::OUString sReaderService = +// rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationAccess" ); + +// seq[0] <<= rtl::OUString::createFromAscii( "org.openoffice.Office.Common" ); + + +// Reference< XHierarchicalNameAccess > xHierAccess; +// try +// { +// xHierAccess = +// Reference< XHierarchicalNameAccess > +// ( sProvider->createInstanceWithArguments( sReaderService,seq ), +// UNO_QUERY ); +// } +// catch( const com::sun::star::uno::Exception& e ) +// { +// VOS_ENSHURE( xHierAccess.is()," cant instantiate the reader service " ); +// } + +// if( ! xHierAccess.is() ) +// return; + +// try +// { +// aAny = +// xHierAccess->getByHierarchicalName( rtl::OUString::createFromAscii("Path/Current/Help") ); +// } +// catch( const com::sun::star::container::NoSuchElementException& e ) +// { +// VOS_ENSHURE( false," path to help files could not be determined " ); +// return; +// } + + +// rtl::OUString instPath; +// bool err = ! ( aAny >>= instPath ); + +// if( err ) +// { +// VOS_ENSHURE( false," path to help files could not be determined " ); +// return; +// } + + rtl::OUString instPath( rtl::OUString::createFromAscii( "$(instpath)/help/" ) ); + + Reference< XConfigManager > xCfgMgr; + try { - sProvider = - Reference< XMultiServiceFactory >( - m_xSMgr->createInstanceWithArguments( sProviderService,seq ), - UNO_QUERY ); + xCfgMgr = + Reference< XConfigManager >( + m_xSMgr->createInstance( rtl::OUString::createFromAscii( "com.sun.star.config.SpecialConfigManager" ) ), + UNO_QUERY ); } - catch( const com::sun::star::uno::Exception& e ) + catch( const com::sun::star::uno::Exception& e ) { - VOS_ENSHURE( sProvider.is()," cant instantiate the multiservicefactory " ); + VOS_ENSHURE( xCfgMgr.is()," cant instantiate the special config manager " ); } - if( ! sProvider.is() ) + if( ! xCfgMgr.is() ) { - return; + fprintf( stderr,"specialconfigmanager not found\n" ); } + else + instPath = xCfgMgr->substituteVariables( instPath ); - rtl::OUString sReaderService = - rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationAccess" ); - - seq[0] <<= rtl::OUString::createFromAscii( "org.openoffice.Office.Common" ); - - - Reference< XHierarchicalNameAccess > xHierAccess; - try - { - xHierAccess = - Reference< XHierarchicalNameAccess > - ( sProvider->createInstanceWithArguments( sReaderService,seq ), - UNO_QUERY ); - } - catch( const com::sun::star::uno::Exception& e ) - { - VOS_ENSHURE( xHierAccess.is()," cant instantiate the reader service " ); - } - - if( ! xHierAccess.is() ) - return; - - try - { - aAny = - xHierAccess->getByHierarchicalName( rtl::OUString::createFromAscii("Path/Current/Help") ); - } - catch( const com::sun::star::container::NoSuchElementException& e ) - { - VOS_ENSHURE( false," path to help files could not be determined " ); - return; - } - - - rtl::OUString instPath; - bool err = ! ( aAny >>= instPath ); - - if( err ) - { - VOS_ENSHURE( false," path to help files could not be determined " ); - return; - } - - instPath = rtl::OUString::createFromAscii( "$(instpath)/help" ); - - Reference< XConfigManager > xCfgMgr; - try - { - xCfgMgr = - Reference< XConfigManager >( - m_xSMgr->createInstance( rtl::OUString::createFromAscii( "com.sun.star.config.SpecialConfigManager" ) ), - UNO_QUERY ); - } - catch( const com::sun::star::uno::Exception& e ) - { - VOS_ENSHURE( xCfgMgr.is()," cant instantiate the special config manager " ); - } - - - if( ! xCfgMgr.is() ) - return; + err_msg( "installpath as given by substituteVariables ", + instPath ); - instPath = xCfgMgr->substituteVariables( instPath ); - m_pDatabases = new Databases( instPath,m_xSMgr ); + instPath = rtl::OUString::createFromAscii( "/export/home/abi/src638_p2_01_49/help/" ); + m_pDatabases = new Databases( instPath, + m_xSMgr ); } diff --git a/xmlhelp/source/cxxhelp/provider/resultsetbase.cxx b/xmlhelp/source/cxxhelp/provider/resultsetbase.cxx index 27153fb4d945..9b49bac28ef5 100644 --- a/xmlhelp/source/cxxhelp/provider/resultsetbase.cxx +++ b/xmlhelp/source/cxxhelp/provider/resultsetbase.cxx @@ -2,9 +2,9 @@ * * $RCSfile: resultsetbase.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: abi $ $Date: 2001-05-16 14:53:27 $ + * last change: $Author: abi $ $Date: 2001-09-28 15:01:59 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -481,12 +481,75 @@ ResultSetBase::queryContent( +class XPropertySetInfoImpl + : public cppu::OWeakObject, + public beans::XPropertySetInfo +{ +public: + + XPropertySetInfoImpl( const uno::Sequence< beans::Property >& aSeq ) + : m_aSeq( aSeq ) + { + } + + void SAL_CALL acquire( void ) + throw( uno::RuntimeException ) + { + OWeakObject::acquire(); + } + + + void SAL_CALL release( void ) + throw( uno::RuntimeException ) + { + OWeakObject::release(); + } + + uno::Any SAL_CALL queryInterface( const uno::Type& rType ) + throw( uno::RuntimeException ) + { + uno::Any aRet = cppu::queryInterface( rType, + SAL_STATIC_CAST( beans::XPropertySetInfo*, this ) ); + return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ); + } + + uno::Sequence< beans::Property > SAL_CALL getProperties() + throw( uno::RuntimeException ) + { + return m_aSeq; + } + + beans::Property SAL_CALL getPropertyByName( const ::rtl::OUString& aName ) + throw( beans::UnknownPropertyException, + uno::RuntimeException) + { + for( int i = 0; i < m_aSeq.getLength(); ++i ) + if( aName == m_aSeq[i].Name ) + return m_aSeq[i]; + throw beans::UnknownPropertyException(); + } + + sal_Bool SAL_CALL hasPropertyByName( const ::rtl::OUString& Name ) + throw( uno::RuntimeException ) + { + for( int i = 0; i < m_aSeq.getLength(); ++i ) + if( Name == m_aSeq[i].Name ) + return true; + return false; + } + +private: + + uno::Sequence< beans::Property > m_aSeq; +}; + + + // XPropertySet uno::Reference< beans::XPropertySetInfo > SAL_CALL ResultSetBase::getPropertySetInfo() throw( uno::RuntimeException) { - uno::Sequence< beans::Property > seq(2); seq[0].Name = rtl::OUString::createFromAscii( "RowCount" ); seq[0].Handle = -1; @@ -499,7 +562,7 @@ ResultSetBase::getPropertySetInfo() seq[1].Attributes = beans::PropertyAttribute::READONLY; //t - return uno::Reference< beans::XPropertySetInfo > ( 0 ); + return uno::Reference< beans::XPropertySetInfo > ( new XPropertySetInfoImpl( seq ) ); } diff --git a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx index 8361ee8fd44b..ec342737f29e 100644 --- a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx +++ b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx @@ -2,9 +2,9 @@ * * $RCSfile: urlparameter.cxx,v $ * - * $Revision: 1.20 $ + * $Revision: 1.21 $ * - * last change: $Author: abi $ $Date: 2001-09-04 11:58:35 $ + * last change: $Author: abi $ $Date: 2001-09-28 15:01:59 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -93,6 +93,9 @@ #ifndef _DATABASES_HXX_ #include <provider/databases.hxx> #endif +#ifndef _RTL_URI_HXX_ +#include <rtl/uri.hxx> +#endif #ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HPP_ #include <com/sun/star/io/XActiveDataSink.hpp> #endif @@ -127,6 +130,7 @@ #include <com/sun/star/container/XHierarchicalNameAccess.hpp> #endif + namespace chelp { inline bool ascii_isDigit( sal_Unicode ch ) @@ -210,6 +214,8 @@ rtl::OString URLParameter::getByName( const char* par ) val = get_language(); else if( strcmp( par,"System" ) == 0 ) val = get_system(); + else if( strcmp( par,"HelpPrefix" ) == 0 ) + val = get_prefix(); return rtl::OString( val.getStr(),val.getLength(),RTL_TEXTENCODING_UTF8 ); } @@ -418,6 +424,9 @@ public: void addToBuffer( const char* buffer,int len ); + sal_Int8* getData() const { return (sal_Int8*) buffer; } + + sal_Int32 getLen() const { return sal_Int32( len ); } private: @@ -428,7 +437,73 @@ private: }; -// void doSomething(); + +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(); +} + void URLParameter::open( const Reference< XMultiServiceFactory >& rxSMgr, @@ -475,7 +550,11 @@ void URLParameter::parse() throw( com::sun::star::ucb::IllegalIdentifierExceptio if( lstIdx != -1 ) m_aExpr = m_aExpr.copy( 0,lstIdx ); - if( ! scheme() || ! name( module() ) || ! query() || ! m_aLanguage.getLength() || ! m_aSystem.getLength() ) + if( ! scheme() || + ! name( module() ) || + ! query() || + ! m_aLanguage.getLength() || + ! m_aSystem.getLength() ) throw com::sun::star::ucb::IllegalIdentifierException(); } @@ -606,7 +685,9 @@ bool URLParameter::query() else if( parameter.compareToAscii( "System" ) == 0 ) m_aSystem = value; else if( parameter.compareToAscii( "HelpPrefix" ) == 0 ) - m_aPrefix = value; + m_aPrefix = rtl::Uri::decode( value, + rtl_UriDecodeWithCharset, + RTL_TEXTENCODING_UTF8 ); else if( parameter.compareToAscii( "HitCount" ) == 0 ) m_nHitCount = value.toInt32(); else if( parameter.compareToAscii( "Active" ) == 0 ) @@ -709,8 +790,9 @@ InputStreamTransformer::InputStreamTransformer( URLParameter* urlParam, // Uses the implementation detail, that rtl::OString::getStr returns a zero terminated character-array - const char* parameter[13]; - rtl::OString parString[12]; + const char* parameter[29]; + rtl::OString parString[28]; + int last; parString[ 0] = "Program"; parString[ 1] = urlParam->getByName( "Program" ); @@ -724,10 +806,32 @@ InputStreamTransformer::InputStreamTransformer( URLParameter* urlParam, parString[ 9] = urlParam->getByName( "Language" ); parString[10] = "System"; parString[11] = urlParam->getByName( "System" ); + parString[12] = "hp"; + parString[13] = urlParam->getByName( "HelpPrefix" ); + last = 14; - for( int i = 0; i < 12; ++i ) + if( parString[13].getLength() ) + { + parString[14] = "sm"; + parString[15] = "vnd.sun.star.help%3A%2F%2F"; + parString[16] = "qm"; + parString[17] = "%3F"; + parString[18] = "es"; + parString[19] = "%3D"; + parString[20] = "am"; + parString[21] = "%26"; + parString[22] = "cl"; + parString[23] = "%3A"; + parString[24] = "sl"; + parString[25] = "%2F"; + parString[26] = "hm"; + parString[27] = "%23"; + last = 28; + } + + for( int i = 0; i < last; ++i ) parameter[i] = parString[i].getStr(); - parameter[12] = 0; + parameter[last] = 0; SablotHandle p; @@ -744,8 +848,8 @@ InputStreamTransformer::InputStreamTransformer( URLParameter* urlParam, #define OFFSET 5 #endif xslURLascii += rtl::OString( xslURL.getStr()+OFFSET, - xslURL.getLength()-OFFSET, - RTL_TEXTENCODING_UTF8 ); + xslURL.getLength()-OFFSET, + RTL_TEXTENCODING_UTF8 ); #undef OFFSET xslURLascii += "main_transform.xsl"; @@ -1071,63 +1175,6 @@ int schemehandlerclose( void *userData, } -// currently unused: - -// class XActiveDataSinkImpl -// : public OWeakObject, -// public XActiveDataSink -// { -// virtual Any SAL_CALL queryInterface( const Type& rType ) throw( RuntimeException ) -// { -// Any aRet = ::cppu::queryInterface( rType, -// SAL_STATIC_CAST( XActiveDataSink*,this ) ); - -// return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ); -// } - -// virtual void SAL_CALL acquire( void ) throw( RuntimeException ) -// { -// OWeakObject::acquire(); -// } - -// virtual void SAL_CALL release( void ) throw( RuntimeException ) -// { -// OWeakObject::release(); -// } - -// virtual void SAL_CALL setInputStream( const Reference< XInputStream >& xInputStream ) -// { -// m_xInputStream = xInputStream; -// } - -// virtual Reference< XInputStream > SAL_CALL getInputStream() -// { -// return m_xInputStream; -// } - - -// private: - -// Reference< XInputStream > m_xInputStream; -// }; - - - - - // error handling is missing - // better not to open the file every time it is requested -// url = -// m_pDatabases->getInstallPathAsURL() + -// rtl::OUString::createFromAscii( "custom.css" ); -// rtl::OUString service = rtl::OUString::createFromAscii( "com.sun.star.ucb.UniversalContentBroker" ); -// Reference< XContentProvider > provider( rxSMgr->createInstance( service ),UNO_QUERY ); -// Reference< XContentIdentifierFactory > factory( provider,UNO_QUERY ); -// Reference< XContentIdentifier > xIdentifier = factory->createContentIdentifier( url ); -// Reference< XContent > xContent = provider->queryContent( xIdentifier ); -// Reference< XCommandProcessor > processor( xContent,UNO_QUERY ); -// processor->execute( aCommand, -// CommandId, -// Environment ); |