diff options
-rw-r--r-- | basic/source/runtime/methods1.cxx | 38 | ||||
-rw-r--r-- | basic/source/runtime/rtlproto.hxx | 7 | ||||
-rw-r--r-- | basic/source/runtime/stdobj.cxx | 8 |
3 files changed, 46 insertions, 7 deletions
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx index 43c43814d73d..23f7448f5aff 100644 --- a/basic/source/runtime/methods1.cxx +++ b/basic/source/runtime/methods1.cxx @@ -2,9 +2,9 @@ * * $RCSfile: methods1.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: ab $ $Date: 2001-05-17 13:42:39 $ + * last change: $Author: ab $ $Date: 2001-06-18 12:35:41 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -86,6 +86,8 @@ #ifndef _FSYS_HXX #include <tools/fsys.hxx> #endif +#include <tools/urlobj.hxx> +#include <osl/file.hxx> #ifdef OS2 #define INCL_DOS @@ -1301,5 +1303,37 @@ RTLFUNC(GlobalScope) refVar->PutObject( p ); } +// Helper functions to convert Url from/to system paths +RTLFUNC(ConvertToUrl) +{ + if ( rPar.Count() == 2 ) + { + String aStr = rPar.Get(1)->GetString(); + INetURLObject aURLObj( aStr, INET_PROT_FILE ); + OUString aFileURL = aURLObj.GetMainURL(); + if( !aFileURL.getLength() ) + ::osl::File::getFileURLFromSystemPath( aFileURL, aFileURL ); + if( !aFileURL.getLength() ) + aFileURL = aStr; + rPar.Get(0)->PutString( String(aFileURL) ); + } + else + StarBASIC::Error( SbERR_BAD_ARGUMENT ); +} + +RTLFUNC(ConvertFromUrl) +{ + if ( rPar.Count() == 2 ) + { + String aStr = rPar.Get(1)->GetString(); + OUString aSysPath; + ::osl::File::getSystemPathFromFileURL( aStr, aSysPath ); + if( !aSysPath.getLength() ) + aSysPath = aStr; + rPar.Get(0)->PutString( String(aSysPath) ); + } + else + StarBASIC::Error( SbERR_BAD_ARGUMENT ); +} diff --git a/basic/source/runtime/rtlproto.hxx b/basic/source/runtime/rtlproto.hxx index 0b70ac2476a5..d6def41f7c16 100644 --- a/basic/source/runtime/rtlproto.hxx +++ b/basic/source/runtime/rtlproto.hxx @@ -2,9 +2,9 @@ * * $RCSfile: rtlproto.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: ab $ $Date: 2001-05-17 13:41:55 $ + * last change: $Author: ab $ $Date: 2001-06-18 12:35:41 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -350,7 +350,8 @@ extern RTLFUNC(HasUnoInterfaces); extern RTLFUNC(EqualUnoObjects); extern RTLFUNC(CreateUnoDialog); extern RTLFUNC(GlobalScope); - +extern RTLFUNC(ConvertToUrl); +extern RTLFUNC(ConvertFromUrl); extern RTLFUNC(FileExists); diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx index 82faf9fdf833..1657eea3eca3 100644 --- a/basic/source/runtime/stdobj.cxx +++ b/basic/source/runtime/stdobj.cxx @@ -2,9 +2,9 @@ * * $RCSfile: stdobj.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: ab $ $Date: 2001-05-17 13:43:03 $ + * last change: $Author: ab $ $Date: 2001-06-18 12:35:41 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -159,6 +159,10 @@ static Methods aMethods[] = { { "CLng", SbxLONG, 1 | _FUNCTION, RTLNAME(CLng) }, { "expression", SbxVARIANT }, +{ "ConvertFromUrl", SbxSTRING, 1 | _FUNCTION, RTLNAME(ConvertFromUrl) }, + { "Url", SbxSTRING }, +{ "ConvertToUrl", SbxSTRING, 1 | _FUNCTION, RTLNAME(ConvertToUrl) }, + { "SystemPath", SbxSTRING }, { "Cos", SbxDOUBLE, 1 | _FUNCTION, RTLNAME(Cos) }, { "number", SbxDOUBLE }, { "CreateObject", SbxOBJECT, 1 | _FUNCTION, RTLNAME( CreateObject ) }, |