OpenOffice.org BASIC Guide - OpenOffice.org wiki
OpenOffice.org BASIC Guide - OpenOffice.org wiki
OpenOffice.org BASIC Guide - OpenOffice.org wiki
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
The StarDesktop<br />
covers the loadComponentFromURL method, which is responsible for creating, importing, and opening<br />
documents.<br />
Note – StarOffice 5 : The name of the StarDesktop object dates back to StarOffice 5, in which all document<br />
windows were embedded in one common application called StarDesktop. In the present version of<br />
<strong>OpenOffice</strong>.<strong>org</strong>, a visible StarDesktop is no longer used. The name StarDesktop was, however, retained for<br />
the frame object of <strong>OpenOffice</strong>.<strong>org</strong> because it clearly indicates that this is a basic object for the entire application.<br />
The StarDesktop object replaces the Application object of StarOffice 5 which previously applied as a root<br />
object. However, unlike the old Application object, StarDesktop is primarily responsible for opening new<br />
documents. The functions resident in the old Application object for controlling the on-screen depiction of<br />
<strong>OpenOffice</strong>.<strong>org</strong> (for example, FullScreen, FunctionBarVisible, Height, Width, Top, Visible) are no<br />
longer used.<br />
Note – VBA : Whereas the active document in Word is accessed through Application.ActiveDocument<br />
and in Excel through Application.ActiveWorkbook, in <strong>OpenOffice</strong>.<strong>org</strong>, the StarDesktop is responsible<br />
for this task. The active document object is accessed in <strong>OpenOffice</strong>.<strong>org</strong> through the<br />
StarDesktop.CurrentComponent property, or through ThisComponent.<br />
ThisComponent<br />
The global name ThisComponent generally returns the same object as StarDesktop.CurrentComponent, with<br />
one significant advantage. If you are running from within the Basic IDE, debugging or exploring, then<br />
StarDesktop returns the Basic IDE itself. This is probably not what you want. ThisComponent returns the last<br />
previously active document.<br />
Basic Information about Documents in <strong>OpenOffice</strong>.<strong>org</strong><br />
When working with <strong>OpenOffice</strong>.<strong>org</strong> documents, it is useful to deal with some of the basic issues of document<br />
administration in <strong>OpenOffice</strong>.<strong>org</strong>. This includes the way in which file names are structured for <strong>OpenOffice</strong>.<strong>org</strong><br />
documents, as well as the format in which files are saved.<br />
File Names in URL Notation<br />
Since <strong>OpenOffice</strong>.<strong>org</strong> is a platform-independent application, it uses URL notation (which is independent of any<br />
operating system), as defined in the Internet Standard RFC 1738 for file names. Standard file names using this<br />
system begin with the prefix file:/// followed by the local path. If the file name contains sub-directories, then<br />
these are separated by a single forward slash, not with a backslash usually used under Windows. The following<br />
path references the test.odt file in the doc directory on the C: drive.<br />
file:///C:/doc/test.odt<br />
To convert local file names into an URL, <strong>OpenOffice</strong>.<strong>org</strong> provides the ConvertToUrl function. To convert a<br />
URL into a local file name, <strong>OpenOffice</strong>.<strong>org</strong> provides the ConvertFromUrl function:<br />
MsgBox ConvertToUrl("C:\doc\test.odt")<br />
' supplies file:///C:/doc/test.odt<br />
MsgBox ConvertFromUrl("file:///C:/doc/test.odt")<br />
' supplies (under Windows) c:\doc\test.odt<br />
The example converts a local file name into a URL and displays it in a message box. It then converts a URL into a<br />
local file name and also displays this.<br />
The Internet Standard RFC 1738, upon which this is based, permits use of the 0-9, a-z, and A-Z characters. All<br />
other characters are inserted as escape coding in the URLs. To do this, they are converted into their hexadecimal<br />
value in the UTF-8 set of characters and are preceded by a percent sign. A space in a local file name therefore, for<br />
example, becomes a %20 in the URL.<br />
60 <strong>OpenOffice</strong>.<strong>org</strong> 3.2 <strong>BASIC</strong> <strong>Guide</strong> · March 2010