<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.harlamenkov.ru/index.php?action=history&amp;feed=atom&amp;title=EN%2Fdocumentation%2Fbasic_guide%2Fstardesktop</id>
	<title>EN/documentation/basic guide/stardesktop - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.harlamenkov.ru/index.php?action=history&amp;feed=atom&amp;title=EN%2Fdocumentation%2Fbasic_guide%2Fstardesktop"/>
	<link rel="alternate" type="text/html" href="https://wiki.harlamenkov.ru/index.php?title=EN/documentation/basic_guide/stardesktop&amp;action=history"/>
	<updated>2026-11-11T13:56:47Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.33.0</generator>
	<entry>
		<id>https://wiki.harlamenkov.ru/index.php?title=EN/documentation/basic_guide/stardesktop&amp;diff=15920&amp;oldid=prev</id>
		<title>Sancho: Основной текст</title>
		<link rel="alternate" type="text/html" href="https://wiki.harlamenkov.ru/index.php?title=EN/documentation/basic_guide/stardesktop&amp;diff=15920&amp;oldid=prev"/>
		<updated>2011-09-02T12:13:32Z</updated>

		<summary type="html">&lt;p&gt;Основной текст&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;section begin=title /&amp;gt;&amp;lt;noinclude&amp;gt;{{DISPLAYTITLE:&amp;lt;/noinclude&amp;gt;The StarDesktop&amp;lt;noinclude&amp;gt;}}&amp;lt;/noinclude&amp;gt;&amp;lt;section end=title /&amp;gt;{{BreadCrumbL10n}}&lt;br /&gt;
&lt;br /&gt;
{{Documentation/BASICGuideTOC&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|ShowPrevPage=block&lt;br /&gt;
|PrevPage=EN/documentation/basic_guide/documents&lt;br /&gt;
|NextPage=EN/documentation/basic_guide/templates&lt;br /&gt;
|docs=block&lt;br /&gt;
}} &lt;br /&gt;
__NOTOC__ &lt;br /&gt;
When working with documents, two services are used most frequently: &lt;br /&gt;
&lt;br /&gt;
* The &amp;lt;idl&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idl&amp;gt; service, which is similar to the core service of {{OOo}}. It provides the functions for the frame object of {{OOo}}, under which all document windows are classified. Documents can also be created, opened and imported using this service. &lt;br /&gt;
* The basic functionality for the individual document objects is provided by the &amp;lt;idl&amp;gt;com.sun.star.document.OfficeDocument&amp;lt;/idl&amp;gt; service. This provides the methods for saving, exporting and printing documents.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;idl&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idl&amp;gt; service is created automatically when {{OOo}} is started. This service can be addressed in {{OOo}} Basic using the global name &amp;lt;tt&amp;gt;StarDesktop&amp;lt;/tt&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
The most important interface of the &amp;lt;tt&amp;gt;StarDesktop&amp;lt;/tt&amp;gt; is &amp;lt;idl&amp;gt;com.sun.star.frame.XComponentLoader&amp;lt;/idl&amp;gt;. This basically covers the &amp;lt;tt&amp;gt;loadComponentFromURL&amp;lt;/tt&amp;gt; method, which is responsible for creating, importing, and opening documents.&lt;br /&gt;
&lt;br /&gt;
{{SO5note|The name of the &amp;lt;tt&amp;gt;StarDesktop&amp;lt;/tt&amp;gt; object dates back to StarOffice 5, in which all document windows were embedded in one common application called &amp;lt;tt&amp;gt;StarDesktop&amp;lt;/tt&amp;gt;. In the present version of {{OOo}}, a visible &amp;lt;tt&amp;gt;StarDesktop&amp;lt;/tt&amp;gt; is no longer used. The name &amp;lt;tt&amp;gt;StarDesktop&amp;lt;/tt&amp;gt; was, however, retained for the frame object of {{OOo}} because it clearly indicates that this is a basic object for the entire application. &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;StarDesktop&amp;lt;/tt&amp;gt; object replaces the &amp;lt;tt&amp;gt;Application&amp;lt;/tt&amp;gt; object of StarOffice 5 which previously applied as a root object. However, unlike the old &amp;lt;tt&amp;gt;Application&amp;lt;/tt&amp;gt; object, &amp;lt;tt&amp;gt;StarDesktop&amp;lt;/tt&amp;gt; is primarily responsible for opening new documents. The functions resident in the old &amp;lt;tt&amp;gt;Application&amp;lt;/tt&amp;gt; object for controlling the on-screen depiction of {{OOo}} (for example, &amp;lt;tt&amp;gt;FullScreen&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;FunctionBarVisible&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Height&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Width&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Top&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Visible&amp;lt;/tt&amp;gt;) are no longer used.}}&lt;br /&gt;
&lt;br /&gt;
{{VBAnote|Whereas the active document in Word is accessed through &amp;lt;tt&amp;gt;Application.ActiveDocument&amp;lt;/tt&amp;gt; and in Excel through &amp;lt;tt&amp;gt;Application.ActiveWorkbook,&amp;lt;/tt&amp;gt; in {{OOo}}, the &amp;lt;tt&amp;gt;StarDesktop&amp;lt;/tt&amp;gt; is responsible for this task. The active document object is accessed in {{OOo}} through the &amp;lt;tt&amp;gt;StarDesktop.CurrentComponent&amp;lt;/tt&amp;gt; property, or through &amp;lt;tt&amp;gt;ThisComponent&amp;lt;/tt&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
== ThisComponent ==&lt;br /&gt;
The global name &amp;lt;tt&amp;gt;ThisComponent&amp;lt;/tt&amp;gt; generally returns the same object as &amp;lt;tt&amp;gt;StarDesktop.CurrentComponent&amp;lt;/tt&amp;gt;, with one significant advantage. If you are running from within the Basic IDE, debugging or exploring, then &amp;lt;tt&amp;gt;StarDesktop&amp;lt;/tt&amp;gt; returns the Basic IDE itself. This is probably not what you want. &amp;lt;tt&amp;gt;ThisComponent&amp;lt;/tt&amp;gt; returns the last previously active document.&lt;br /&gt;
&lt;br /&gt;
== Basic Information about Documents in {{OOo}} ==&lt;br /&gt;
&lt;br /&gt;
When working with {{OOo}} documents, it is useful to deal with some of the basic issues of document administration in {{OOo}}. This includes the way in which file names are structured for {{OOo}} documents, as well as the format in which files are saved.&lt;br /&gt;
&lt;br /&gt;
=== File Names in URL Notation ===&lt;br /&gt;
&lt;br /&gt;
Since {{OOo}} 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 file names. Standard file names using this system begin with the prefix {{Path|file:///}} followed by the local path. If the file name 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 {{Path|test.odt}} file in the doc directory on the {{Path|C:}} drive.&lt;br /&gt;
&lt;br /&gt;
{{Path|file:///C:/doc/test.odt}}&lt;br /&gt;
&lt;br /&gt;
To convert local file names into an URL, {{OOo}} provides the &amp;lt;tt&amp;gt;ConvertToUrl&amp;lt;/tt&amp;gt; function. To convert a URL into a local file name, {{OOo}} provides the &amp;lt;tt&amp;gt;ConvertFromUrl&amp;lt;/tt&amp;gt; function: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
MsgBox ConvertToUrl(&amp;quot;C:\doc\test.odt&amp;quot;) &lt;br /&gt;
  ' supplies file:///C:/doc/test.odt&lt;br /&gt;
MsgBox ConvertFromUrl(&amp;quot;file:///C:/doc/test.odt&amp;quot;)    &lt;br /&gt;
  '  supplies (under Windows) c:\doc\test.odt&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example converts a local file name into a URL and displays it in a message box. It then converts a URL into a local file name and also displays this. &lt;br /&gt;
&lt;br /&gt;
The Internet Standard RFC 1738, upon which this is based, permits use of the &amp;lt;tt&amp;gt;0-9&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;a-z&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;A-Z&amp;lt;/tt&amp;gt; characters. All other characters are inserted as escape coding in the URLs. To do this, they are converted into their hexadecimal value in the UTF-8 set of characters and are preceded by a percent sign. A space in a local file name therefore, for example, becomes a &amp;lt;tt&amp;gt;%20&amp;lt;/tt&amp;gt; in the URL.&lt;br /&gt;
&lt;br /&gt;
=== XML File Format ===&lt;br /&gt;
&lt;br /&gt;
{{OOo}} documents are based on the XML file format.  XML-based files can be opened and edited with other programs.&lt;br /&gt;
&lt;br /&gt;
=== Compression of Files ===&lt;br /&gt;
&lt;br /&gt;
Since XML is based on standard text files, the resultant files are usually very large. {{OOo}} therefore compresses the files and saves them as a ZIP file. By means of a &amp;lt;tt&amp;gt;storeAsURL&amp;lt;/tt&amp;gt; method option, the user can save the original XML files directly. See [[EN/documentation/basic_guide/stardesktop#storeAsURL Method Options|storeAsURL Method Options]], below.&lt;br /&gt;
&lt;br /&gt;
== Creating, Opening and Importing Documents ==&lt;br /&gt;
&lt;br /&gt;
Documents are opened, imported and created using the method &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
StarDesktop.loadComponentFromURL(URL, Frame, SearchFlags, FileProperties)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first parameter of &amp;lt;tt&amp;gt;loadComponentFromURL&amp;lt;/tt&amp;gt; specifies the URL of the associated file. &lt;br /&gt;
&lt;br /&gt;
As the second parameter, &amp;lt;tt&amp;gt;loadComponentFromURL&amp;lt;/tt&amp;gt; expects a name for the frame object of the window that {{OOo}} creates internally for its administration. The predefined &amp;lt;tt&amp;gt;_blank&amp;lt;/tt&amp;gt; name is usually specified here, and this ensures that {{OOo}} creates a new window.&lt;br /&gt;
&lt;br /&gt;
Using these parameters, the user can open a {{OOo}} document, since place holders (dummy values) can be assigned to the last two parameters:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Url As String&lt;br /&gt;
Dim Dummy() 'An (empty) array of PropertyValues&lt;br /&gt;
&lt;br /&gt;
Url = &amp;quot;file:///C:/test.odt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Doc = StarDesktop.loadComponentFromURL(Url, &amp;quot;_blank&amp;quot;, 0, Dummy)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The preceding call opens the {{Path|test.odt}} file and displays this in a new window. &lt;br /&gt;
&lt;br /&gt;
Any number of documents can be opened in this way in {{OOo}} Basic and then edited using the returned document objects.&lt;br /&gt;
&lt;br /&gt;
{{SO5note|&amp;lt;tt&amp;gt;StarDesktop.loadComponentFromURL&amp;lt;/tt&amp;gt; supersedes the &amp;lt;tt&amp;gt;Documents.Add&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;Documents.Open&amp;lt;/tt&amp;gt; methods from the old {{OOo}} API.}}&lt;br /&gt;
&lt;br /&gt;
=== Replacing the Content of the Document Window ===&lt;br /&gt;
&lt;br /&gt;
The named &amp;lt;tt&amp;gt;_blank&amp;lt;/tt&amp;gt; value for the &amp;lt;tt&amp;gt;Frame&amp;lt;/tt&amp;gt; parameter ensures that {{OOo}} creates a new window for every call from &amp;lt;tt&amp;gt;loadComponentFromURL&amp;lt;/tt&amp;gt;. In some situations, it is useful to replace the content of an existing window. In this case, the frame object of the window should contain an explicit name. Note that this name must not begin with an underscore. Furthermore, the &amp;lt;tt&amp;gt;SearchFlags&amp;lt;/tt&amp;gt; parameter must be set so that the corresponding framework is created, if it does not already exist. The corresponding constant for &amp;lt;tt&amp;gt;SearchFlags&amp;lt;/tt&amp;gt; is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
SearchFlags = com.sun.star.frame.FrameSearchFlag.CREATE + _&lt;br /&gt;
              com.sun.star.frame.FrameSearchFlag.ALL&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following example shows how the content of an opened window can be replaced with the help of the frame parameter and &amp;lt;tt&amp;gt;SearchFlags&amp;lt;/tt&amp;gt;: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Dummy() &lt;br /&gt;
Dim Url As String&lt;br /&gt;
Dim SearchFlags As Long&lt;br /&gt;
 &lt;br /&gt;
SearchFlags = com.sun.star.frame.FrameSearchFlag.CREATE + _&lt;br /&gt;
              com.sun.star.frame.FrameSearchFlag.ALL&lt;br /&gt;
Url = &amp;quot;file:///C:/test.odt&amp;quot;&lt;br /&gt;
Doc = StarDesktop.loadComponentFromURL(Url, &amp;quot;MyFrame&amp;quot;, SearchFlags, Dummy)&lt;br /&gt;
MsgBox &amp;quot;Press OK to display the second document.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Url = &amp;quot;file:///C:/test2.odt&amp;quot;&lt;br /&gt;
Doc = StarDesktop.loadComponentFromURL(Url, &amp;quot;MyFrame&amp;quot;, _&lt;br /&gt;
      SearchFlags, Dummy)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example first opens the {{Path|test.odt}} file in a new window with the frame name of &amp;lt;tt&amp;gt;MyFrame&amp;lt;/tt&amp;gt;. Once the message box has been confirmed, it replaces the content of the window with the {{Path|test2.odt}} file.&lt;br /&gt;
&lt;br /&gt;
=== loadComponentFromURL Method Options ===&lt;br /&gt;
&lt;br /&gt;
The fourth parameter of the &amp;lt;tt&amp;gt;loadComponentFromURL&amp;lt;/tt&amp;gt; function is a &amp;lt;tt&amp;gt;PropertyValue&amp;lt;/tt&amp;gt; data field. which provides {{OOo}} with various options for opening and creating documents. The data field must provide a &amp;lt;tt&amp;gt;PropertyValue&amp;lt;/tt&amp;gt; structure for each option in which the name of the option is saved as a string as well as the associated value. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;loadComponentFromURL&amp;lt;/tt&amp;gt; supports the following options:&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;AsTemplate (Boolean)&amp;lt;/tt&amp;gt;:if true, loads a new, untitled document from the given URL. If is false, template files are loaded for editing.&lt;br /&gt;
;&amp;lt;tt&amp;gt;CharacterSet (String)&amp;lt;/tt&amp;gt;:defines which set of characters a document is based on.&lt;br /&gt;
;&amp;lt;tt&amp;gt;FilterName (String)&amp;lt;/tt&amp;gt;:specifies a special filter for the &amp;lt;tt&amp;gt;loadComponentFromURL&amp;lt;/tt&amp;gt; function. The filter names available are defined in the {{Path|\share\config\registry\instance\org\openoffice\office\TypeDetection.xml}} file.&lt;br /&gt;
;&amp;lt;tt&amp;gt;FilterData (String)&amp;lt;/tt&amp;gt;:defines additional options for filters.&lt;br /&gt;
;&amp;lt;tt&amp;gt;FilterOptions (String)&amp;lt;/tt&amp;gt;:defines additional options (used by old filters).&lt;br /&gt;
;&amp;lt;tt&amp;gt;Hidden (Boolean)&amp;lt;/tt&amp;gt;:value true loads the document in invisible mode.&lt;br /&gt;
;&amp;lt;tt&amp;gt;JumpMark (String)&amp;lt;/tt&amp;gt;:once a document has been opened, jumps to the position defined in JumpMark.&lt;br /&gt;
;&amp;lt;tt&amp;gt;MacroExecutionMode (Integer)&amp;lt;/tt&amp;gt;:indicates if document macros may be executed. Values : see &amp;lt;idl&amp;gt;com.sun.star.document.MacroExecMode&amp;lt;/idl&amp;gt;&lt;br /&gt;
;&amp;lt;tt&amp;gt;Password (String)&amp;lt;/tt&amp;gt;:transfers a password for a protected file.&lt;br /&gt;
;&amp;lt;tt&amp;gt;ReadOnly (Boolean)&amp;lt;/tt&amp;gt;:value true loads a document in read-only mode.&lt;br /&gt;
;&amp;lt;tt&amp;gt;UpdateDocMode (Integer)&amp;lt;/tt&amp;gt;:indicates how/if links will be updated. Values : see &amp;lt;idl&amp;gt;com.sun.star.document.UpdateDocMode&amp;lt;/idl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following example shows how a text file separated by a comma in {{OOo}} Calc can be opened using the &amp;lt;tt&amp;gt;FilterName&amp;lt;/tt&amp;gt; option. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim FileProperties(1) As New com.sun.star.beans.PropertyValue&lt;br /&gt;
Dim Url As String&lt;br /&gt;
&lt;br /&gt;
Url = &amp;quot;file:///C:/doc.csv&amp;quot;&lt;br /&gt;
FileProperties(0).Name = &amp;quot;FilterName&amp;quot;&lt;br /&gt;
FileProperties(0).Value =&amp;quot;Text - txt - csv (StarCalc)&amp;quot;&lt;br /&gt;
FileProperties(1).Name = &amp;quot;FilterOptions&amp;quot;&lt;br /&gt;
FileProperties(1).value  = &amp;quot;44,34,0,1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Doc = StarDesktop.loadComponentFromURL(Url, &amp;quot;_blank&amp;quot;, 0, FileProperties())&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;FileProperties&amp;lt;/tt&amp;gt; array has two elements, one for each option used. The &amp;lt;tt&amp;gt;Filtername&amp;lt;/tt&amp;gt; property defines whether {{OOo}} uses a {{OOo}} Calc text filter to open files. The &amp;lt;tt&amp;gt;FilterOptions&amp;lt;/tt&amp;gt; property contains the description of the syntax of the csv file.&lt;br /&gt;
&lt;br /&gt;
=== Creating New Documents ===&lt;br /&gt;
&lt;br /&gt;
{{OOo}} automatically creates a new document if the document specified in the URL is a template. &lt;br /&gt;
&lt;br /&gt;
Alternatively, if only an empty document without any adaptation is needed, a &amp;lt;tt&amp;gt;private:factory&amp;lt;/tt&amp;gt; URL can be specified:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Dummy() &lt;br /&gt;
Dim Url As String&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
&lt;br /&gt;
Url = &amp;quot;private:factory/swriter&amp;quot;&lt;br /&gt;
Doc = StarDesktop.loadComponentFromURL(Url, &amp;quot;_blank&amp;quot;, 0, Dummy())&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The call creates an empty {{OOo}} writer document.&lt;br /&gt;
&lt;br /&gt;
== Document Objects ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;loadComponentFromURL&amp;lt;/tt&amp;gt; function introduced in the previous section returns a document object. This supports the &amp;lt;idl&amp;gt;com.sun.star.document.OfficeDocument&amp;lt;/idl&amp;gt; service, which in turn provides two central interfaces: &lt;br /&gt;
&lt;br /&gt;
* The &amp;lt;idl&amp;gt;com.sun.star.frame.XStorable&amp;lt;/idl&amp;gt; interface, which is responsible for saving documents.&lt;br /&gt;
* The &amp;lt;idl&amp;gt;com.sun.star.view.XPrintable&amp;lt;/idl&amp;gt; interface, which contains the methods for printing documents. &lt;br /&gt;
&lt;br /&gt;
=== Saving and Exporting Documents ===&lt;br /&gt;
&lt;br /&gt;
{{OOo}} documents are saved directly through the document object. The &amp;lt;tt&amp;gt;store&amp;lt;/tt&amp;gt; method of the &amp;lt;idl&amp;gt;com.sun.star.frame.XStorable&amp;lt;/idl&amp;gt; interface is available for this purpose:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Doc.store()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This call functions provided that the document has already been assigned a memory space. This is not the case for new documents. In this instance, the &amp;lt;tt&amp;gt;storeAsURL&amp;lt;/tt&amp;gt; method is used. This method is also defined in &amp;lt;idl&amp;gt;com.sun.star.frame.XStorable&amp;lt;/idl&amp;gt; and can be used to define the location of the document: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim URL As String&lt;br /&gt;
Dim Dummy()&lt;br /&gt;
&lt;br /&gt;
Url = &amp;quot;file:///C:/test3.odt&amp;quot;&lt;br /&gt;
Doc.storeAsURL(URL, Dummy())&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In addition to the preceding methods, &amp;lt;idl&amp;gt;com.sun.star.frame.XStorable&amp;lt;/idl&amp;gt; also provides some help methods which are useful when saving documents. These are:&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;hasLocation()&amp;lt;/tt&amp;gt;:specifies whether the document has already been assigned a URL.&lt;br /&gt;
;&amp;lt;tt&amp;gt;isReadonly()&amp;lt;/tt&amp;gt;:specifies whether a document has read-only protection.&lt;br /&gt;
;&amp;lt;tt&amp;gt;isModified()&amp;lt;/tt&amp;gt;:specifies whether a document has been modified since it was last saved.&lt;br /&gt;
&lt;br /&gt;
The code for saving a document can be extended by these options so that the document is only saved if the object has actually been modified and the file name is only queried if it is actually needed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
If (Doc.isModified) Then&lt;br /&gt;
  If (Doc.hasLocation And (Not Doc.isReadOnly)) Then&lt;br /&gt;
    Doc.store()&lt;br /&gt;
  Else&lt;br /&gt;
    Doc.storeAsURL(URL, Dummy())&lt;br /&gt;
  End If&lt;br /&gt;
End If&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example first checks whether the relevant document has been modified since it was last saved. It only continues with the saving process if this is the case. If the document has already been assigned a URL and is not a read-only document, it is saved under the existing URL. If it does not have a URL or was opened in its read-only status, it is saved under a new URL.&lt;br /&gt;
&lt;br /&gt;
=== storeAsURL Method Options ===&lt;br /&gt;
&lt;br /&gt;
As with the &amp;lt;tt&amp;gt;loadComponentFromURL&amp;lt;/tt&amp;gt; method, some options can also be specified in the form of a &amp;lt;tt&amp;gt;PropertyValue&amp;lt;/tt&amp;gt; data field using the &amp;lt;tt&amp;gt;storeAsURL&amp;lt;/tt&amp;gt; method. These determine the procedure {{OOo}} uses when saving a document. &amp;lt;tt&amp;gt;storeAsURL&amp;lt;/tt&amp;gt; provides the following options:&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;CharacterSet (String)&amp;lt;/tt&amp;gt;:defines which set of characters a document is based on.&lt;br /&gt;
;&amp;lt;tt&amp;gt;FilterName (String)&amp;lt;/tt&amp;gt;:specifies a special filter for the &amp;lt;tt&amp;gt;loadComponentFromURL&amp;lt;/tt&amp;gt; function. The filter names available are defined in the {{Path|\share\config\registry\instance\org\openoffice\office\TypeDetection.xml}} file.&lt;br /&gt;
;&amp;lt;tt&amp;gt;FilterData (String)&amp;lt;/tt&amp;gt;:defines additional options for filters.&lt;br /&gt;
;&amp;lt;tt&amp;gt;FilterOptions (String)&amp;lt;/tt&amp;gt;:defines additional options (used by old filters).&lt;br /&gt;
;&amp;lt;tt&amp;gt;Overwrite (Boolean)&amp;lt;/tt&amp;gt;:allows a file which already exists to be overwritten without a query.&lt;br /&gt;
;&amp;lt;tt&amp;gt;Password (String)&amp;lt;/tt&amp;gt;:transfers the password for a protected file.&lt;br /&gt;
;&amp;lt;tt&amp;gt;Unpacked (Boolean)&amp;lt;/tt&amp;gt;:saves the document (not compressed) in sub-directories.&lt;br /&gt;
:The possibility to store documents in unpacked way is not currently supported, the &amp;quot;Unpacked&amp;quot; property is just ignored, see {{Bug|64364}}.&lt;br /&gt;
&lt;br /&gt;
The following example shows how the &amp;lt;tt&amp;gt;Overwrite&amp;lt;/tt&amp;gt; option can be used in conjunction with &amp;lt;tt&amp;gt;storeAsURL&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim FileProperties(0) As New com.sun.star.beans.PropertyValue&lt;br /&gt;
Dim Url As String&lt;br /&gt;
' ... Initialize Doc &lt;br /&gt;
&lt;br /&gt;
Url = &amp;quot;file:///c:/test3.odt&amp;quot;&lt;br /&gt;
FileProperties(0).Name = &amp;quot;Overwrite&amp;quot;&lt;br /&gt;
FileProperties(0).Value = True&lt;br /&gt;
Doc.storeAsURL(Url, FileProperties())&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example then saves &amp;lt;tt&amp;gt;Doc&amp;lt;/tt&amp;gt; under the specified file name if a file already exists under the name.&lt;br /&gt;
&lt;br /&gt;
=== Printing Documents ===&lt;br /&gt;
&lt;br /&gt;
Similar to saving, documents are printed out directly by means of the document object. The &amp;lt;tt&amp;gt;Print&amp;lt;/tt&amp;gt; method of the &amp;lt;idl&amp;gt;com.sun.star.view.Xprintable&amp;lt;/idl&amp;gt; interface is provided for this purpose. In its simplest form, the print call is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Dummy()&lt;br /&gt;
&lt;br /&gt;
Doc.print(Dummy())&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As in the case of the &amp;lt;tt&amp;gt;loadComponentFromURL&amp;lt;/tt&amp;gt; method, the Dummy parameter is a &amp;lt;tt&amp;gt;PropertyValue&amp;lt;/tt&amp;gt; data field through which {{OOo}} can specify several options for printing.&lt;br /&gt;
&lt;br /&gt;
=== The options of the print method ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;print&amp;lt;/tt&amp;gt; method expects a &amp;lt;tt&amp;gt;PropertyValue&amp;lt;/tt&amp;gt; data field as a parameter, which reflects the settings of the print dialog of {{OOo}}: &lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;CopyCount (Integer)&amp;lt;/tt&amp;gt;:specifies the number of copies to be printed.&lt;br /&gt;
;&amp;lt;tt&amp;gt;FileName (String)&amp;lt;/tt&amp;gt;:prints the document in the specified file.&lt;br /&gt;
;&amp;lt;tt&amp;gt;Collate (Boolean)&amp;lt;/tt&amp;gt;:advises the printer to collate the pages of the copies.&lt;br /&gt;
;&amp;lt;tt&amp;gt;Sort (Boolean)&amp;lt;/tt&amp;gt;:sorts the pages when printing out several copies (&amp;lt;tt&amp;gt;CopyCount&amp;lt;/tt&amp;gt; &amp;gt; 1).&lt;br /&gt;
;&amp;lt;tt&amp;gt;Pages (String)&amp;lt;/tt&amp;gt;:contains the list of the pages to be printed (syntax as specified in print dialog).&lt;br /&gt;
;&amp;lt;tt&amp;gt;Wait (Boolean)&amp;lt;/tt&amp;gt;:if set to True the print method will return ''after'' the job is stored on the waiting list for the printer. Use this option if you want to close the document after print.&lt;br /&gt;
&lt;br /&gt;
The following example shows how several pages of a document can be printed out using the &amp;lt;tt&amp;gt;Pages&amp;lt;/tt&amp;gt; option: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim PrintProperties(1) As New com.sun.star.beans.PropertyValue&lt;br /&gt;
&lt;br /&gt;
PrintProperties(0).Name=&amp;quot;Pages&amp;quot;&lt;br /&gt;
PrintProperties(0).Value=&amp;quot;1-3; 7; 9&amp;quot;&lt;br /&gt;
PrintProperties(1).Name=&amp;quot;Wait&amp;quot;&lt;br /&gt;
PrintProperties(1).Value=True&lt;br /&gt;
Doc.print(PrintProperties())&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Printer selection and settings ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;idl&amp;gt;com.sun.star.view.XPrintable&amp;lt;/idl&amp;gt; interface provides the &amp;lt;tt&amp;gt;Printer&amp;lt;/tt&amp;gt; property, which selects the printer. This property receives a &amp;lt;tt&amp;gt;PropertyValue&amp;lt;/tt&amp;gt; data field with the following settings: &lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;Name (String)&amp;lt;/tt&amp;gt;:specifies the name of printer.&lt;br /&gt;
;&amp;lt;tt&amp;gt;PaperOrientation (Enum)&amp;lt;/tt&amp;gt;:specifies the paper orientation (&amp;lt;idl&amp;gt;com.sun.star.view.PaperOrientation.PORTRAIT&amp;lt;/idl&amp;gt; value for portrait format, &amp;lt;idl&amp;gt;com.sun.star.view.PaperOrientation.LANDSCAPE&amp;lt;/idl&amp;gt; for landscape format).&lt;br /&gt;
;&amp;lt;tt&amp;gt;PaperFormat (Enum)&amp;lt;/tt&amp;gt;:specifies the paper format (for example, &amp;lt;idl&amp;gt;com.sun.star.view.PaperFormat.A4&amp;lt;/idl&amp;gt; for DIN A4 or &amp;lt;idl&amp;gt;com.sun.star.view.PaperFormat.Letter&amp;lt;/idl&amp;gt; for US letters).&lt;br /&gt;
;&amp;lt;tt&amp;gt;PaperSize (Size)&amp;lt;/tt&amp;gt;:specifies the paper size in hundredths of a millimeter.&lt;br /&gt;
&lt;br /&gt;
The following example shows how a printer can be changed and the paper size set with the help of the &amp;lt;tt&amp;gt;Printer&amp;lt;/tt&amp;gt; property. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim PrinterProperties(1) As New com.sun.star.beans.PropertyValue&lt;br /&gt;
Dim PaperSize As New com.sun.star.awt.Size&lt;br /&gt;
&lt;br /&gt;
PaperSize.Width = 20000   ' corresponds to 20 cm&lt;br /&gt;
PaperSize.Height = 20000   ' corresponds to 20 cm&lt;br /&gt;
PrinterProperties (0).Name=&amp;quot;Name&amp;quot;&lt;br /&gt;
PrinterProperties (0).Value=&amp;quot;My HP Laserjet&amp;quot;&lt;br /&gt;
PrinterProperties (1).Name=&amp;quot;PaperSize&amp;quot;&lt;br /&gt;
PrinterProperties (1).Value=PaperSize&lt;br /&gt;
Doc.Printer = PrinterProperties()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example defines an object named &amp;lt;tt&amp;gt;PaperSize&amp;lt;/tt&amp;gt; with the &amp;lt;idl&amp;gt;com.sun.star.awt.Size&amp;lt;/idl&amp;gt; type. This is needed to specify the paper size. Furthermore, it creates a data field for two &amp;lt;tt&amp;gt;PropertyValue&amp;lt;/tt&amp;gt; entries named &amp;lt;tt&amp;gt;PrinterProperties&amp;lt;/tt&amp;gt;. This data field is then initialized with the values to be set and assigned the &amp;lt;tt&amp;gt;Printer&amp;lt;/tt&amp;gt; property. From the standpoint of UNO, the printer is not a real property but an imitated one.&lt;br /&gt;
&lt;br /&gt;
 {{PDL1}}&lt;/div&gt;</summary>
		<author><name>Sancho</name></author>
		
	</entry>
</feed>