21.08.2013 Views

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The StarDesktop 81<br />

This method is also defined in<br />

com.sun.star.frame.XStorable<br />

and can be used to define the location of the document:<br />

Dim URL As String<br />

Dim Dummy()<br />

Url = "file:///C:/test3.odt"<br />

Doc.storeAsURL(URL, Dummy())<br />

In addition to the preceding methods,<br />

com.sun.star.frame.XStorable<br />

also provides some help methods which are useful when saving documents. These are:<br />

hasLocation()<br />

specifies whether the document has already been assigned a URL.<br />

isReadonly()<br />

specifies whether a document has read-only protection.<br />

isModified()<br />

specifies whether a document has been modified since it was last saved.<br />

The code for saving a document can be extended by these options so that the document is<br />

only saved if the object has actually been modified and the file name is only queried if it is<br />

actually needed:<br />

If (Doc.isModified) Then<br />

If (Doc.hasLocation And (Not Doc.isReadOnly)) Then<br />

Doc.store()<br />

Else<br />

Doc.storeAsURL(URL, Dummy())<br />

End If<br />

End If<br />

The example first checks whether the relevant document has been modified since it was<br />

last saved. It only continues with the saving process if this is the case. If the document has<br />

already been assigned a URL and is not a read-only document, it is saved under the existing<br />

URL. If it does not have a URL or was opened in its read-only status, it is saved under a new<br />

URL.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!