URL Basics

From Apache OpenOffice Wiki
Jump to: navigation, search

The following information is based on material found in:
StarOffice™ 7 Office Suite
A Sun™ ONE Software Offering
Basic Programmer's Guide on page 74.

Filenames in URL Notation

Since Apache OpenOffice is a platform-independent application, it uses URL notation (which is independent of any operating system), as defined in the Internet Standard RFC 1738 for filenames. Standard filenames using this system begin with the prefix file:///, followed by the local path. If the filename contains sub-directories, then these are separated by a single forward slash, not with a backslash usually used under Windows. The following path references the test.odt file in the doc directory on the C drive:

 file:///C:/doc/test.odt

To convert local filenames into an URL, Apache OpenOffice provides the ConvertToUrl function. To convert an URL into a local filename, Apache OpenOffice provides the ConvertFromUrl function:

MsgBox ConvertToUrl("C:\doc\test.odt") ' supplies file:///C:/doc/test.odt
MsgBox ConvertFromUrl("file:///C:/doc/test.odt") ' supplies (under Windows) c:\doc\test.odt

The example converts a local filename into a URL and displays it in a messagebox. It then converts a URL into a local filename and also displays this.

The Internet Standard RFC 1738, upon which this is based, permits use of the 0-9, a-z, and A-Z characters. All other characters are inserted as escape coding in the URLs. To do this, they are converted into their hexadecimal value in the ISO 8859-1 (ISO-Latin) set of characters and are preceded by a percent sign. For example, a space in a local filename therefore becomes a %20 in the URL.

Personal tools