INTEGRATION: CWS scriptingf5 (1.2.2); FILE MERGED

2004/03/05 10:33:45 npower 1.2.2.1: #i22570# Changes to support new URL parsing service. A side affect of using the new service is that the format of the URI has changed a little. The URI is now nt hierarchical. Changes to the files below involve removing methods to parse data from the URI instread new service UriReferenceFactory, adding the new types to build project xml  files.
This commit is contained in:
Sander Vesik
2004-04-19 22:15:16 +00:00
parent 68904aa5c3
commit 45749febb1
3 changed files with 47 additions and 50 deletions

View File

@@ -2,9 +2,9 @@
*
* $RCSfile: dlgprov.cxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: rt $ $Date: 2004-02-10 16:13:24 $
* last change: $Author: svesik $ $Date: 2004-04-19 23:14:47 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -96,6 +96,9 @@
#include <xmlscript/xmldlg_imexp.hxx>
#endif
#include <com/sun/star/uri/XUriReference.hpp>
#include <com/sun/star/uri/XUriReferenceFactory.hpp>
#include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
using namespace ::com::sun::star;
using namespace ::com::sun::star::awt;
@@ -185,64 +188,57 @@ namespace dlgprov
// -----------------------------------------------------------------------------
// TODO: this code needs removal after integration of URI parsing service
::rtl::OUString DialogProviderImpl::getLocationFromURL( const ::rtl::OUString& sURL )
{
::rtl::OUString language;
::rtl::OUString attr;
sal_Int32 len = sURL.indexOf( '?' );
if( ( len < 0 ) || ( sURL.getLength() == 0 ) )
{
return language;
}
// if we have a match, then start the search after the ?
len++;
do
{
attr = sURL.getToken( 0, '&', len );
//OSL_TRACE( "chunk is %s, len is %d",
// ::rtl::OUStringToOString( attr,
// RTL_TEXTENCODING_ASCII_US ).pData->buffer, len );
if( attr.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "location" ) )
== sal_True )
{
sal_Int32 len2 = attr.indexOf('=');
language = attr.copy( len2 + 1 );
//OSL_TRACE( "Language name is %s",
// ::rtl::OUStringToOString( language,
// RTL_TEXTENCODING_ASCII_US ).pData->buffer );
break;
}
}
while ( len >= 0 );
return language;
}
// -----------------------------------------------------------------------------
Reference< XControlModel > DialogProviderImpl::createDialogModel( const ::rtl::OUString& sURL )
{
// parse URL
// TODO: use URL parsing class
// TODO: decoding of location
::rtl::OUString sSchema( ::rtl::OUString::createFromAscii( "vnd.sun.star.script://" ) );
sal_Int32 nSchemaLen = sSchema.getLength();
sal_Int32 nLen = sURL.indexOf( '?' );
::rtl::OUString sDescription;
if ( nLen - nSchemaLen > 0 )
Reference< XMultiComponentFactory > xSMgr( m_xContext->getServiceManager(), UNO_QUERY );
if ( !xSMgr.is() )
{
sDescription = sURL.copy( nSchemaLen, nLen - nSchemaLen );
throw RuntimeException(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogProviderImpl::getDialogModel: Couldn't instantiate MultiComponent factory" ) ),
Reference< XInterface >() );
}
Reference< uri::XUriReferenceFactory > xFac (
xSMgr->createInstanceWithContext( rtl::OUString::createFromAscii(
"com.sun.star.uri.UriReferenceFactory"), m_xContext ) , UNO_QUERY );
if ( !xFac.is() )
{
throw RuntimeException(
::rtl::OUString::createFromAscii( "DialogProviderImpl::getDialogModel(), could not instatiate UriReferenceFactory." ),
Reference< XInterface >() );
}
Reference< uri::XUriReference > uriRef(
xFac->parse( sURL ), UNO_QUERY );
Reference < uri::XVndSunStarScriptUrl > sfUri( uriRef, UNO_QUERY );
if ( !uriRef.is() || !sfUri.is() )
{
::rtl::OUString errorMsg = ::rtl::OUString::createFromAscii( "DialogProviderImpl::getDialogModel: failed to parse URI: " );
errorMsg.concat( sURL );
throw IllegalArgumentException( errorMsg,
Reference< XInterface >(), 1 );
}
::rtl::OUString sDescription = sfUri->getName();
sal_Int32 nIndex = 0;
::rtl::OUString sLibName = sDescription.getToken( 0, (sal_Unicode)'.', nIndex );
::rtl::OUString sDlgName;
if ( nIndex != -1 )
sDlgName = sDescription.getToken( 0, (sal_Unicode)'.', nIndex );
::rtl::OUString sLocation( getLocationFromURL( sURL ) );
::rtl::OUString sLocation = sfUri->getParameter(
::rtl::OUString::createFromAscii( "location" ) );
// get dialog library container
// TODO: dialogs in packages

View File

@@ -2,9 +2,9 @@
*
* $RCSfile: dlgprov.hxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: rt $ $Date: 2004-02-10 16:13:42 $
* last change: $Author: svesik $ $Date: 2004-04-19 23:15:02 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -124,7 +124,6 @@ namespace dlgprov
::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel;
::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptEventsAttacher > m_xScriptEventsAttacher;
::rtl::OUString getLocationFromURL( const ::rtl::OUString& sURL );
::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > createDialogModel( const ::rtl::OUString& sURL );

View File

@@ -38,7 +38,9 @@
<type>com.sun.star.uno.XComponentContext</type>
<type>drafts.com.sun.star.script.provider.XScript</type>
<type>drafts.com.sun.star.script.provider.XScriptProvider</type>
<type>drafts.com.sun.star.script.provider.XScriptProviderSupplier</type>
<type> com.sun.star.uri.XUriReference </type>
<type> com.sun.star.uri.XUriReferenceFactory </type>
<type> com.sun.star.uri.XVndSunStarScriptUrl </type>
</component-description>
<project-build-dependency>sfx2</project-build-dependency>