summaryrefslogtreecommitdiff
path: root/scripting/source
diff options
context:
space:
mode:
authorSander Vesik <svesik@openoffice.org>2004-04-19 22:15:16 +0000
committerSander Vesik <svesik@openoffice.org>2004-04-19 22:15:16 +0000
commit45749febb1ded7ac541948f59c66ab0a90c02b6c (patch)
tree35993b146ad8f6107a883bc28c38d859a84cee7c /scripting/source
parent68904aa5c36820ca1aad37126c4e01acd548471d (diff)
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.
Diffstat (limited to 'scripting/source')
-rw-r--r--scripting/source/dlgprov/dlgprov.cxx80
-rw-r--r--scripting/source/dlgprov/dlgprov.hxx5
-rw-r--r--scripting/source/dlgprov/dlgprov.xml4
3 files changed, 43 insertions, 46 deletions
diff --git a/scripting/source/dlgprov/dlgprov.cxx b/scripting/source/dlgprov/dlgprov.cxx
index 899642441efb..9dfe4b43a489 100644
--- a/scripting/source/dlgprov/dlgprov.cxx
+++ b/scripting/source/dlgprov/dlgprov.cxx
@@ -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 )
+ Reference< XControlModel > DialogProviderImpl::createDialogModel( const ::rtl::OUString& sURL )
{
- ::rtl::OUString language;
- ::rtl::OUString attr;
- sal_Int32 len = sURL.indexOf( '?' );
- if( ( len < 0 ) || ( sURL.getLength() == 0 ) )
+ // parse URL
+ // TODO: use URL parsing class
+ // TODO: decoding of location
+ Reference< XMultiComponentFactory > xSMgr( m_xContext->getServiceManager(), UNO_QUERY );
+
+ if ( !xSMgr.is() )
{
- return language;
+ throw RuntimeException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogProviderImpl::getDialogModel: Couldn't instantiate MultiComponent factory" ) ),
+ Reference< XInterface >() );
}
- // if we have a match, then start the search after the ?
- len++;
- do
+ Reference< uri::XUriReferenceFactory > xFac (
+ xSMgr->createInstanceWithContext( rtl::OUString::createFromAscii(
+ "com.sun.star.uri.UriReferenceFactory"), m_xContext ) , UNO_QUERY );
+
+ if ( !xFac.is() )
{
- 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;
- }
+ throw RuntimeException(
+ ::rtl::OUString::createFromAscii( "DialogProviderImpl::getDialogModel(), could not instatiate UriReferenceFactory." ),
+ Reference< XInterface >() );
}
- while ( len >= 0 );
- return language;
- }
+ Reference< uri::XUriReference > uriRef(
+ xFac->parse( sURL ), UNO_QUERY );
- // -----------------------------------------------------------------------------
+ Reference < uri::XVndSunStarScriptUrl > sfUri( uriRef, UNO_QUERY );
- 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 )
+ if ( !uriRef.is() || !sfUri.is() )
{
- sDescription = sURL.copy( nSchemaLen, nLen - nSchemaLen );
+ ::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
diff --git a/scripting/source/dlgprov/dlgprov.hxx b/scripting/source/dlgprov/dlgprov.hxx
index 60d413cae940..3a048402f77a 100644
--- a/scripting/source/dlgprov/dlgprov.hxx
+++ b/scripting/source/dlgprov/dlgprov.hxx
@@ -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 );
diff --git a/scripting/source/dlgprov/dlgprov.xml b/scripting/source/dlgprov/dlgprov.xml
index caa05a694c40..bf84e34b5c24 100644
--- a/scripting/source/dlgprov/dlgprov.xml
+++ b/scripting/source/dlgprov/dlgprov.xml
@@ -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>