<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.openoffice.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Cking</id>
	<title>Apache OpenOffice Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.openoffice.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Cking"/>
	<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/wiki/Special:Contributions/Cking"/>
	<updated>2026-08-15T00:59:58Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.14</generator>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Renaissance:The_Roadmap&amp;diff=144031</id>
		<title>Renaissance:The Roadmap</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Renaissance:The_Roadmap&amp;diff=144031"/>
		<updated>2009-10-23T13:59:17Z</updated>

		<summary type="html">&lt;p&gt;Cking: Changed &amp;quot;fits very good to&amp;quot; to &amp;quot;fits very well with&amp;quot;.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User Experience Community}}&lt;br /&gt;
=Roadmap 2009=&lt;br /&gt;
&lt;br /&gt;
== Goal Towards OpenOffice.org 3.3 ==&lt;br /&gt;
Main focus towards OpenOffice.org 3.3 will be on Impress. Goal is to improve the most common interactions, to introduce direct object manipulation and to fix related UX issues[[Renaissance:Analyze | UX issues]]. This clean up based on the current UI will help us working towards a new interface and fits very well with OOo&amp;#039;s iterative development process.&lt;br /&gt;
&lt;br /&gt;
== Chart ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Renaissance-roadmap.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;October 2009&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Using_Services&amp;diff=94740</id>
		<title>Documentation/DevGuide/FirstSteps/Using Services</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Using_Services&amp;diff=94740"/>
		<updated>2008-10-07T22:03:22Z</updated>

		<summary type="html">&lt;p&gt;Cking: Back to multiple-inheritance interfaces&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/FirstStepsTOC&lt;br /&gt;
|FirstSteps2b=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/FirstSteps/Objects, Interfaces, and Services&lt;br /&gt;
|NextPage=Documentation/DevGuide/FirstSteps/Example: Working with a Spreadsheet Document&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Using Services}}&lt;br /&gt;
The concepts of interfaces and services were introduced for the following reasons:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Interfaces and services separate specification from implementation&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: The specification of an interface or service is &amp;#039;&amp;#039;abstract&amp;#039;&amp;#039;, that is, it does not define how objects supporting a certain functionality do this &amp;#039;&amp;#039;internally&amp;#039;&amp;#039;. Through the abstract specification of the {{OOo}} API, it is possible to pull the implementation out from under the API and install a different implementation if required.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Service names allow to create instances by specification name, not by class names&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: In Java or C++ you use the new operator to create a class instance. This approach is restricted: the class you get is hard-coded. You cannot later on exchange it by another class without editing the code. The concept of services solves this. The central object factory in {{OOo}}, the global service manager, is asked to create an object that can be used for a certain purpose without defining its internal implementation. This is possible because a service can be ordered from the factory by its &amp;#039;&amp;#039;service name&amp;#039;&amp;#039; and the factory decides which service implementation it returns. Which implementation you get makes no difference, you only use the well-defined interface of the service.&lt;br /&gt;
&lt;br /&gt;
===Interfaces===&lt;br /&gt;
Abstract interfaces are more reusable if they are fine-grained, i.e., if they are small and describe only a single aspect of an object.  To describe the many aspects of an object, objects can implement more than one of these fine-grained interfaces.  Being able to implementation multiple interfaces allows similar aspects of similar objects to be accessed with the same code.  For example, many objects support text:  text may be found in the body of a document, in text frames, in headers and footers, footnotes, table cells, and in drawing shapes.  These objects all support the same interface, so a procedure can use, for example, getText() to retrieve text from &amp;#039;&amp;#039;any&amp;#039;&amp;#039; of these objects.  &lt;br /&gt;
&lt;br /&gt;
Services, interfaces, and methods are illustrated in the figure below for the old-style service &amp;lt;idl&amp;gt;com.sun.star.text.TextDocument&amp;lt;/idl&amp;gt;, shown using [http://en.wikipedia.org/wiki/Unified_Modeling_Language UML] notation.  In this figure, services are shown on the left side.  The arrow between services indicates that one service provided by the upper (arrowhead) service are inherited by the lower service.  Interfaces exported by these services are shown on the right.  All interface names in the {{OOo}} API start with an X, so as to be distinguishable from the names of other entities.   Each interface contains methods, which are listed beneath the interface.  &lt;br /&gt;
&lt;br /&gt;
[[Image:TextDocumentWithMethods.png|none|thumb|450px|Figure.  TextDocument inherits the methods of OfficeDocument.]]&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; object provides the &amp;lt;idl&amp;gt;com.sun.star.text.TextDocument&amp;lt;/idl&amp;gt; service, which implements the interfaces, &amp;lt;code&amp;gt;XTextDocument&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;XSearchable&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;XRefreshable&amp;lt;/code&amp;gt;.  These interfaces provide, for example, the methods &amp;lt;code&amp;gt;getText()&amp;lt;/code&amp;gt;, for adding text to a document, and &amp;lt;code&amp;gt;findAll()&amp;lt;/code&amp;gt;, for searching the document.  &lt;br /&gt;
&lt;br /&gt;
As indicated by the arrow, the &amp;lt;idl&amp;gt;com.sun.star.text.TextDocument&amp;lt;/idl&amp;gt; service also inherits all the interfaces provided by the &amp;lt;idl&amp;gt;com.sun.star.document.OfficeDocument&amp;lt;/idl&amp;gt; service, so these interfaces are also provided to a &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; object.  These interfaces handle tasks common to the {{OOo}} applications:  printing, &amp;lt;code&amp;gt;XPrintable&amp;lt;/code&amp;gt;; storing, &amp;lt;code&amp;gt;XStorable&amp;lt;/code&amp;gt;; modifying, &amp;lt;code&amp;gt;XModifiable&amp;lt;/code&amp;gt;; and model handling, &amp;lt;code&amp;gt;XModel&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The interfaces shown in the figure are only the mandatory interfaces of a &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; object. A &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; has optional properties and interfaces, among them the properties &amp;lt;code&amp;gt;CharacterCount&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ParagraphCount&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;WordCount&amp;lt;/code&amp;gt;, and the interface  &amp;lt;code&amp;gt;XPropertySet&amp;lt;/code&amp;gt;, which must be supported if properties are present at all. The implementation of the &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; service in {{OOo}} supports both required and all optional interfaces as well. The usage of a &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; is described thoroughly in [[Documentation/DevGuide/Text/Text Documents|Text Documents]].&lt;br /&gt;
&lt;br /&gt;
C++ and Java require that the interface name be provided when accessing a method.  An old-style service may provide several interfaces to keep track of.  New-style services are easier to use because, since they have just one interface, the multiple-inheritance interface, all the methods are accessed through the same interface.&lt;br /&gt;
&lt;br /&gt;
===Using Interfaces===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.uno.XInterface&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The fact that every UNO object must be accessed through its interfaces has an effect in languages like Java and C++, where the compiler needs the correct type of an object reference before you can call a method from it. In Java or C++, you normally just cast an object before you access an interface it implements. When working with UNO objects this is different: You must ask the UNO environment to get the appropriate reference for you whenever you want to access methods of an interface which your object supports, but your compiler does not yet know about. Only then you can cast it safely.&lt;br /&gt;
&lt;br /&gt;
The Java UNO environment has a method &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; for this purpose. It looks complicated at first sight, but once you understand that &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; is about safe casting of UNO types across process boundaries, you will soon get used to it. Take a look at the second example FirstLoadComponent.java (in the sample directory, if you have installed the SDK on your computer), where a new Desktop object is created and, afterwards, the &amp;lt;idlm&amp;gt;queryInterface&amp;lt;/idlm&amp;gt;() method is used to get the &amp;lt;idls&amp;gt;com.sun.star.frame.XComponentLoader&amp;lt;/idls&amp;gt; interface.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  Object desktop = xRemoteServiceManager.createInstanceWithContext(&lt;br /&gt;
                &amp;quot;com.sun.star.frame.Desktop&amp;quot;, xRemoteContext);&lt;br /&gt;
 &lt;br /&gt;
  XComponentLoader xComponentLoader = (XComponentLoader)&lt;br /&gt;
                UnoRuntime.queryInterface(XComponentLoader.class, desktop);&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We asked the service manager to create a &amp;lt;idl&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idl&amp;gt; using its factory method createInstanceWithContext(). This method is defined to return a Java Object type, which should not surprise you—after all the factory must be able to return any type:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  java.lang.Object createInstanceWithContext(String serviceName, XComponentContext context)&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The object we receive is a &amp;lt;idl&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idl&amp;gt; service.  The point is, while we know that the object we ordered at the factory is a DesktopUnoUrlResolver and exports among other interfaces the interface &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt;, the compiler does &amp;#039;&amp;#039;not&amp;#039;&amp;#039;. Therefore, we have to use the UNO runtime environment to ask or &amp;#039;&amp;#039;query&amp;#039;&amp;#039; for the interface &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt;, since we want to use the &amp;lt;code&amp;gt;loadComponentFromURL()&amp;lt;/code&amp;gt; method on this interface. The method &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; makes sure we get a reference that can be cast to the needed interface type, no matter if the target object is a local or a remote object. There are two &amp;lt;code&amp;gt;queryInterface&amp;lt;/code&amp;gt; definitions in the Java UNO language binding:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  java.lang.Object UnoRuntime.queryInterface(java.lang.Class targetInterface, Object sourceObject)&lt;br /&gt;
  java.lang.Object UnoRuntime.queryInterface(com.sun.star.uno.Type targetInterface, Object sourceObject)&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since &amp;lt;code&amp;gt;UnoRuntime.queryInterface()&amp;lt;/code&amp;gt; is specified to return a java.lang.Object just like the factory method &amp;lt;code&amp;gt;createInstanceWithContext()&amp;lt;/code&amp;gt;, we still must explicitly cast our interface reference to the needed type. The difference is that after &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; we can safely cast the object to our interface type and, most important, that the reference will now work even with an object in another process. Here is the &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; call, explained step by step:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  XComponentLoader xComponentLoader = (XComponentLoader)&lt;br /&gt;
                  UnoRuntime.queryInterface(XComponentLoader.class, desktop);&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt; is the interface we want to use, so we define a &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt; variable named &amp;lt;code&amp;gt;xComponentLoader&amp;lt;/code&amp;gt; (lower x) to store the interface we expect from &amp;lt;code&amp;gt;queryInterface&amp;lt;/code&amp;gt;. &lt;br /&gt;
Then we query our desktop object for the &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt; interface, passing in &amp;lt;code&amp;gt;XComponentLoader.class&amp;lt;/code&amp;gt; as target interface and desktop as source object. Finally we cast the outcome to &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt; and assign the resulting reference to our variable &amp;lt;code&amp;gt;xComponentLoader&amp;lt;/code&amp;gt;.&lt;br /&gt;
If the source object does not support the interface we are querying for, &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; will return null.&lt;br /&gt;
&lt;br /&gt;
In Java, this call to &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; is necessary whenever you have a reference to an object which is known to support an interface that you need, but you do not have the proper reference type yet. Fortunately, you are not only allowed to &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;java.lang.Object&amp;lt;/code&amp;gt; source types, but you may also query an interface from another interface reference, like this:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // loading a blank spreadsheet document gives us its XComponent interface:&lt;br /&gt;
  XComponent xComponent = xComponentLoader.loadComponentFromURL(&lt;br /&gt;
  &amp;quot;private:factory/scalc&amp;quot;, &amp;quot;_blank&amp;quot;, 0, loadProps);&lt;br /&gt;
  &lt;br /&gt;
  // now we query the interface XSpreadsheetDocument from xComponent&lt;br /&gt;
  XSpreadsheetDocument xSpreadsheetDocument = (XSpreadsheetDocument)UnoRuntime.queryInterface(&lt;br /&gt;
                  XSpreadsheetDocument.class, xComponent);  &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Furthermore, if a method is defined in such a way that it already returns an interface type, you do not need to query the interface, but you can use its methods right away. In the snippet above, the method &amp;lt;code&amp;gt;loadComponentFromURL&amp;lt;/code&amp;gt; is specified to return an &amp;lt;idl&amp;gt;com.sun.star.lang.XComponent&amp;lt;/idl&amp;gt; interface, so you may call the &amp;lt;code&amp;gt;XComponent&amp;lt;/code&amp;gt; methods &amp;lt;code&amp;gt;addEventListener()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;removeEventListener()&amp;lt;/code&amp;gt; directly at the &amp;lt;code&amp;gt;xComponent&amp;lt;/code&amp;gt; variable, if you want to be notified that the document is being closed.&lt;br /&gt;
The corresponding step in C++ is done by a &amp;lt;code&amp;gt;Reference&amp;lt;&amp;gt;&amp;lt;/code&amp;gt; template that takes the source instance as parameter:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // instantiate a sample service with the servicemanager.&lt;br /&gt;
  Reference&amp;lt; XInterface &amp;gt; rInstance =&lt;br /&gt;
  rServiceManager-&amp;gt;createInstanceWithContext( &lt;br /&gt;
  OUString::createFromAscii(&amp;quot;com.sun.star.frame.Desktop&amp;quot; ),&lt;br /&gt;
  rComponentContext );&lt;br /&gt;
  &lt;br /&gt;
  // Query for the XComponentLoader interface&lt;br /&gt;
  Reference&amp;lt; XComponentLoader &amp;gt; rComponentLoader( rInstance, UNO_QUERY );&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In {{OOo}} Basic, querying for interfaces is not necessary; the Basic runtime engine takes care of that internally.&lt;br /&gt;
With the proliferation of multiple-inheritance interfaces in the {{OOo}} API, there will be less of a demand to explicitly query for specific interfaces in Java or C++. For example, with the hypothetical interfaces&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  interface XBase1 {   void fun1();&lt;br /&gt;
  };&lt;br /&gt;
  interface XBase2 {&lt;br /&gt;
      void fun2();&lt;br /&gt;
  };&lt;br /&gt;
  interface XBoth { // inherits from both XBase1 and XBase2&lt;br /&gt;
      interface XBase1;&lt;br /&gt;
      interface XBase2;&lt;br /&gt;
  };&lt;br /&gt;
  interface XFactory {&lt;br /&gt;
      XBoth getBoth();};&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
you can directly call both &amp;lt;code&amp;gt;fun1()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;fun2()&amp;lt;/code&amp;gt; on a reference obtained through &amp;lt;code&amp;gt;XFactory.getBoth()&amp;lt;/code&amp;gt;, without querying for either &amp;lt;code&amp;gt;XBase1&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;XBase2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Using Properties===&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
An object must offer its properties through interfaces that allow you to work with properties. The most basic form of these interfaces is the interface &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idl&amp;gt;. There are other interfaces for properties, such as &amp;lt;idl&amp;gt;com.sun.star.beans.XMultiPropertySet&amp;lt;/idl&amp;gt;, that gets and sets a multitude of properties with a single method call. The &amp;lt;code&amp;gt;XPropertySet&amp;lt;/code&amp;gt; is always supported when properties are present in a service.&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;XPropertySet&amp;lt;/code&amp;gt;, two methods carry out the property access, which are defined in Java as follows: &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  void setPropertyValue(String propertyName, Object propertyValue)&lt;br /&gt;
  Object getPropertyValue(String propertyName)&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the FirstLoadComponent example, the &amp;lt;code&amp;gt;XPropertySet&amp;lt;/code&amp;gt; interface was used to set the CellStyle property at a cell object. The cell object was a &amp;lt;code&amp;gt;com.sun.star.sheet.SheetCell&amp;lt;/code&amp;gt; and therefore supports also the &amp;lt;code&amp;gt;com.sun.star.table.CellProperties&amp;lt;/code&amp;gt; service which had a property &amp;lt;code&amp;gt;CellStyle&amp;lt;/code&amp;gt;. The following code explains how this property was set:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // query the XPropertySet interface from cell object&lt;br /&gt;
  XPropertySet xCellProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xCell);&lt;br /&gt;
  &lt;br /&gt;
  // set the CellStyle property&lt;br /&gt;
  xCellProps.setPropertyValue(&amp;quot;CellStyle&amp;quot;, &amp;quot;Result&amp;quot;);&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
You are now ready to start working with a {{PRODUCTNAME}} document.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/First Steps]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Talk:Documentation/DevGuide/FirstSteps/Using_Services&amp;diff=94739</id>
		<title>Talk:Documentation/DevGuide/FirstSteps/Using Services</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Talk:Documentation/DevGuide/FirstSteps/Using_Services&amp;diff=94739"/>
		<updated>2008-10-07T21:35:53Z</updated>

		<summary type="html">&lt;p&gt;Cking: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I [http://msdn.microsoft.com/en-us/library/ms973861.aspx read] that &amp;quot;multiple-inheritance interfaces&amp;quot; is more properly called &amp;quot;multiple interface implementation&amp;quot;, so I made the change.--[[User:Cking|Cking]] 21:22, 5 October 2008 (CEST)&lt;br /&gt;
&lt;br /&gt;
For old style services, &amp;quot;multiple interface implementation&amp;quot; indeed would be more accurate.  However, old style services (where a service implements multiple, unrelated interfaces) are deprecated, and should be superseded by new style services (where a service implements just one interface, but that interface is typically a multiple-inheritance interface that in turn inherits from multiple, otherwise unrelated interfaces).  So, I am undecided whether or not [http://wiki.services.openoffice.org/w/index.php?title=Documentation%2FDevGuide%2FFirstSteps%2FUsing_Services&amp;amp;diff=94529&amp;amp;oldid=94472 Created &amp;quot;Multiple Interface Implementation&amp;quot; section out of what was on the page] is an improvement.--[[User:Sb|Sb]] 13:49, 7 October 2008 (CEST)&lt;br /&gt;
&lt;br /&gt;
Thanks, again, for commenting.  I think I should go back with &amp;quot;multiple-inheritance interfaces&amp;quot; to be consistent with the rest of the guide.  Perhaps a definition/discussion of that term should be added earlier in the guide, so that, whether or not we like the term, we all know what it means.  The &amp;quot;Programmer&amp;#039;s Guide&amp;quot; needs to make sense not only to C++ and Java folks, but also to Basic programmers, as well. (My background is Visual Basic, which, until VB.net, hasn&amp;#039;t used interfaces.)--[[User:Cking|Cking]] 23:35, 7 October 2008 (CEST)&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Talk:Documentation/DevGuide/FirstSteps/Objects,_Interfaces,_and_Services&amp;diff=94736</id>
		<title>Talk:Documentation/DevGuide/FirstSteps/Objects, Interfaces, and Services</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Talk:Documentation/DevGuide/FirstSteps/Objects,_Interfaces,_and_Services&amp;diff=94736"/>
		<updated>2008-10-07T21:01:33Z</updated>

		<summary type="html">&lt;p&gt;Cking: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I don&amp;#039;t think the term &amp;quot;multiple-inheritance interfaces&amp;quot; makes sense.  Objects can inherit, but how can an interface inherit anything?  Perhaps a better term would be &amp;quot;nested interfaces&amp;quot;:  these could be defined as interfaces that, besides their own methods, include all the methods of other interfaces.  Java doesn&amp;#039;t support multiple-inheritance objects, so I doubt that OOo does.  I&amp;#039;ll put &amp;quot;nested interface&amp;quot; into the section on interfaces to see how it looks.&lt;br /&gt;
&lt;br /&gt;
Also, I&amp;#039;ve called the single interface of a new-style service a composite interface.&lt;br /&gt;
--[[User:Cking|Cking]] 20:17, 6 October 2008 (CEST)&lt;br /&gt;
&lt;br /&gt;
At least in UNO (and also in Java, and, equating abstract classes with interfaces, also in C++), interfaces &amp;#039;&amp;#039;can&amp;#039;&amp;#039; inherit from (multiple) other interfaces.  &amp;amp;ldquo;Multiple inheritance&amp;amp;rdquo; is an established term for this.  Consequently, I undid most of your recent modifications.--[[User:Sb|Sb]] 15:43, 7 October 2008 (CEST)&lt;br /&gt;
&lt;br /&gt;
Thanks for looking at it.  I&amp;#039;ve had a hard time understanding interfaces.  I&amp;#039;ll post to the mailing list first, next time.--[[User:Cking|Cking]] 23:01, 7 October 2008 (CEST)&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/BASIC_Guide/StarDesktop&amp;diff=94679</id>
		<title>Documentation/BASIC Guide/StarDesktop</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/BASIC_Guide/StarDesktop&amp;diff=94679"/>
		<updated>2008-10-06T22:25:22Z</updated>

		<summary type="html">&lt;p&gt;Cking: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:The StarDesktop}}&lt;br /&gt;
{{Documentation/BASICGuideTOC/v2&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|ShowPrevPage=block&lt;br /&gt;
|PrevPage=Documentation/BASIC Guide/Documents&lt;br /&gt;
|NextPage=Documentation/BASIC Guide/Templates&lt;br /&gt;
|docs=block&lt;br /&gt;
}} &lt;br /&gt;
 &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;
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. Unlike the old &amp;lt;tt&amp;gt;Application&amp;lt;/tt&amp;gt; object however it 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;
{{Documentation/Note|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;
&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 &amp;lt;tt&amp;gt;file:///&amp;lt;/tt&amp;gt; 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 &amp;lt;tt&amp;gt;test.odt&amp;lt;/tt&amp;gt; file in the doc directory on the C: drive.&lt;br /&gt;
&lt;br /&gt;
 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;
  &amp;#039; supplies file:///C:/doc/test.odt&lt;br /&gt;
MsgBox ConvertFromUrl(&amp;quot;file:///C:/doc/test.odt&amp;quot;)    &lt;br /&gt;
  &amp;#039;  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 ISO 8859-1 (ISO-Latin) 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 [[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. Alternatively, &amp;lt;tt&amp;gt;_hidden&amp;lt;/tt&amp;gt; can also be specified, and this ensures that the corresponding document is loaded but remains invisible. &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() &amp;#039;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 &amp;lt;tt&amp;gt;text.odt&amp;lt;/tt&amp;gt; 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;
{{Documentation/Note|&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; and &amp;lt;tt&amp;gt;_hidden&amp;lt;/tt&amp;gt; values for the &amp;lt;tt&amp;gt;Frame&amp;lt;/tt&amp;gt; parameter ensure 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 &amp;lt;tt&amp;gt;test.odt&amp;lt;/tt&amp;gt; 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 &amp;lt;tt&amp;gt;test2.odt&amp;lt;/tt&amp;gt; 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 &amp;lt;tt&amp;gt;\share\config\registry\instance\org\openoffice\office\TypeDetection.xml&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
;&amp;lt;tt&amp;gt;FilterOptions (String)&amp;lt;/tt&amp;gt;:defines additional options for filters.&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;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;:loads a read-only document.&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(0) 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:/csv.doc&amp;quot;&lt;br /&gt;
FileProperties(0).Name = &amp;quot;FilterName&amp;quot;&lt;br /&gt;
FileProperties(0).Value =&amp;quot;scalc: Text - txt - csv (OpenOffice.org Calc)&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; data field covers precisely one value because it records one option. 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.&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 &amp;lt;tt&amp;gt;\share\config\registry\instance\org\openoffice\office\TypeDetection.xml&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
;&amp;lt;tt&amp;gt;FilterOptions (String)&amp;lt;/tt&amp;gt;:defines additional options for 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;
&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;
&amp;#039; ... 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(sUrl, mFileProperties())&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;
&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(0) 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;
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   &amp;#039; corresponds to 20 cm&lt;br /&gt;
PaperSize.Height = 20000   &amp;#039; 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>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/BASIC_Guide/API_Intro&amp;diff=94675</id>
		<title>Documentation/BASIC Guide/API Intro</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/BASIC_Guide/API_Intro&amp;diff=94675"/>
		<updated>2008-10-06T21:41:25Z</updated>

		<summary type="html">&lt;p&gt;Cking: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:Introduction to the {{OOo}} API}}&lt;br /&gt;
{{Documentation/BASICGuideTOC/v2&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|ShowPrevPage=block&lt;br /&gt;
|PrevPage=Documentation/BASIC Guide/Other Functions (Runtime Library)&lt;br /&gt;
|NextPage=Documentation/BASIC Guide/UNO&lt;br /&gt;
|api=block&lt;br /&gt;
}}&lt;br /&gt;
 &lt;br /&gt;
{{OOo}} objects and methods, such as paragraphs, spreadsheets, and fonts, are accessible to {{OOo}} Basic through the {{OOo}} application programming interface, or API. Through the API, for example, documents can be created, opened, modified and printed.  The API can be used not only by {{OOo}} Basic, but also by other programming languages, such as Java and C++.  The interface between the API and various programming languages is provided by something called &amp;#039;&amp;#039;&amp;#039;Universal Network Objects&amp;#039;&amp;#039;&amp;#039; (UNO). &lt;br /&gt;
&lt;br /&gt;
This chapter provides a background on the API.  Building on this background, the following chapters will show how the API can be used to make {{OOo}} do what you want it to do.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Talk:Documentation/DevGuide/OfficeDev/Frames&amp;diff=94672</id>
		<title>Talk:Documentation/DevGuide/OfficeDev/Frames</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Talk:Documentation/DevGuide/OfficeDev/Frames&amp;diff=94672"/>
		<updated>2008-10-06T20:09:36Z</updated>

		<summary type="html">&lt;p&gt;Cking: New page: I wonder what a frame does.  Does it just pass a window reference on to the controller?  Or, perhaps the controller says &amp;quot;Here&amp;#039;s what needs to be drawn,&amp;quot; and the frame issues the drawing c...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I wonder what a frame does.  Does it just pass a window reference on to the controller?  Or, perhaps the controller says &amp;quot;Here&amp;#039;s what needs to be drawn,&amp;quot; and the frame issues the drawing commands.  If that&amp;#039;s what happens, perhaps the controller is operating-system-independent, and the frame is what gets changed for different operating systems.--[[User:Cking|Cking]] 22:09, 6 October 2008 (CEST)&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/Controllers&amp;diff=94670</id>
		<title>Documentation/DevGuide/OfficeDev/Controllers</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/Controllers&amp;diff=94670"/>
		<updated>2008-10-06T19:11:34Z</updated>

		<summary type="html">&lt;p&gt;Cking: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/OfficeDevTOC&lt;br /&gt;
|OfficeDev2a=block&lt;br /&gt;
|OfficeDevFramework=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/OfficeDev/Frames&lt;br /&gt;
|NextPage=Documentation/DevGuide/OfficeDev/Windows&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Controllers}}&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.frame.Controller;com.sun.star.frame.XController&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
Controllers in {{PRODUCTNAME}} are between a frame and document model. This is their basic role as expressed in &amp;lt;idl&amp;gt;com.sun.star.frame.XController&amp;lt;/idl&amp;gt;, which has methods &amp;lt;code&amp;gt;getModel()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;getFrame()&amp;lt;/code&amp;gt;. The method &amp;lt;code&amp;gt;getFrame()&amp;lt;/code&amp;gt; provides the frame that the controller is attached to. The method &amp;lt;code&amp;gt;getModel()&amp;lt;/code&amp;gt; returns a document model, but it may return an empty reference if the component does not have a model.&lt;br /&gt;
&lt;br /&gt;
Usually the controller objects support additional interfaces specific to the document type they control, such as &amp;lt;idl&amp;gt;com.sun.star.sheet.XSpreadsheetView&amp;lt;/idl&amp;gt; for Calc document controllers or &amp;lt;idl&amp;gt;com.sun.star.text.XTextViewCursorSupplier&amp;lt;/idl&amp;gt; for Writer document controllers.&lt;br /&gt;
&lt;br /&gt;
[[Image:FCMController.png|none|thumb|400px|Controller with Model and Frame]]&lt;br /&gt;
&lt;br /&gt;
A single document model can be controlled simultaneously by several controller instances, each associated with a separate frame. Multiple controllers and frames are created by {{PRODUCTNAME}} when the user clicks &amp;#039;&amp;#039;&amp;#039;Window - New Window&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Office Development]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/OpenOffice.org_Application_Environment&amp;diff=94669</id>
		<title>Documentation/DevGuide/OfficeDev/OpenOffice.org Application Environment</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/OpenOffice.org_Application_Environment&amp;diff=94669"/>
		<updated>2008-10-06T18:58:33Z</updated>

		<summary type="html">&lt;p&gt;Cking: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/OfficeDevTOC&lt;br /&gt;
|OfficeDev2a=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/OfficeDev/Office Development&lt;br /&gt;
|NextPage=Documentation/DevGuide/OfficeDev/Desktop Environment&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:{{PRODUCTNAME}} Application Environment}}&lt;br /&gt;
The {{PRODUCTNAME}} application environment is made up of the &amp;#039;&amp;#039;desktop environment&amp;#039;&amp;#039; and the &amp;#039;&amp;#039;framework API&amp;#039;&amp;#039;. &lt;br /&gt;
&lt;br /&gt;
[[Image:AppEnvironment.png|none|frame|The {{PRODUCTNAME}} Application Environment]]&lt;br /&gt;
&lt;br /&gt;
The desktop environment consists of the desktop service and auxiliary objects. The desktop environment&amp;#039;s functions are carried out by the framework API. The framework API has two parts: the &amp;#039;&amp;#039;component framework&amp;#039;&amp;#039; and the &amp;#039;&amp;#039;dispatch framework&amp;#039;&amp;#039;. The component framework follows a special Frame-Controller-Model paradigm to manage components viewable in {{PRODUCTNAME}}. The dispatch framework handles command requests sent by the GUI.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Office Development]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/Office_Development&amp;diff=94668</id>
		<title>Documentation/DevGuide/OfficeDev/Office Development</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/Office_Development&amp;diff=94668"/>
		<updated>2008-10-06T18:55:20Z</updated>

		<summary type="html">&lt;p&gt;Cking: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/OfficeDevTOC&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/AdvUNO/UNO Design Patterns and Coding Styles&lt;br /&gt;
|NextPage=Documentation/DevGuide/OfficeDev/OpenOffice.org Application Environment&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Office Development}}&lt;br /&gt;
This chapter describes the application environment of the {{PRODUCTNAME}} application. It assumes that you have read the chapter [[Documentation/DevGuide/FirstSteps/First Steps|First Steps]], and that you are able to connect to the office and load documents.&lt;br /&gt;
&lt;br /&gt;
In most cases, users use the functionality of {{PRODUCTNAME}} by opening and modifying documents. The interfaces and services common to all document types and how documents are embedded in the surrounding application environment are discussed.&lt;br /&gt;
&lt;br /&gt;
It is also possible to extend the functionality of {{PRODUCTNAME}} by replacing the services mentioned here by intercepting the communication between objects or by creating your own document type and integrating it into the desktop environment. All these things are discussed in this chapter.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Office Development]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Objects,_Interfaces,_and_Services&amp;diff=94667</id>
		<title>Documentation/DevGuide/FirstSteps/Objects, Interfaces, and Services</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Objects,_Interfaces,_and_Services&amp;diff=94667"/>
		<updated>2008-10-06T18:32:24Z</updated>

		<summary type="html">&lt;p&gt;Cking: Removed inheritance from interface section.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/FirstStepsTOC&lt;br /&gt;
|FirstSteps2b=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/FirstSteps/Working with Objects&lt;br /&gt;
|NextPage=Documentation/DevGuide/FirstSteps/Using Services&lt;br /&gt;
}}&lt;br /&gt;
[[zh:Zh/Documentation/DevGuide/FirstSteps/Objects, Interfaces, and Services]]&lt;br /&gt;
{{DISPLAYTITLE:Objects, Interfaces, and Services}}&lt;br /&gt;
===Objects===&lt;br /&gt;
&lt;br /&gt;
In UNO, an &amp;#039;&amp;#039;object&amp;#039;&amp;#039; is a software artifact that has methods that you can call and attributes that you can get and set. Exactly which methods and attributes an object offers is specified by the set of interfaces it supports.&lt;br /&gt;
&lt;br /&gt;
===Interfaces===&lt;br /&gt;
&lt;br /&gt;
An &amp;#039;&amp;#039;interface&amp;#039;&amp;#039; specifies a set of attributes and methods that together define one single aspect of an object. For instance, the interface &amp;lt;idl&amp;gt;com.sun.star.resource.XResourceBundle&amp;lt;/idl&amp;gt; specifies the attribute &amp;lt;code&amp;gt;Parent&amp;lt;/code&amp;gt; and the methods &amp;lt;code&amp;gt;getLocale()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;getDirectElement()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  module com { module sun { module star { module resource { interfaceXResourceBundle: com::sun::star::container::XNameAccess {&lt;br /&gt;
      [attribute] XResourceBundle Parent;&lt;br /&gt;
      com::sun::star::lang::Locale getLocale();&lt;br /&gt;
      any getDirectElement([in] string key);&lt;br /&gt;
  };&lt;br /&gt;
  }; }; }; };&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To allow for reuse of such interface specifications, one interface can include another.  For example, &amp;lt;idls&amp;gt;com.sun.star.resource.XResourceBundle&amp;lt;/idls&amp;gt; inherits all the attributes and methods of &amp;lt;idl&amp;gt;com.sun.star.container.XNameAccess&amp;lt;/idl&amp;gt;. The ability to create such nested, composite interfaces was introduced in {{OOo2.x}}.&lt;br /&gt;
&lt;br /&gt;
Strictly speaking, interface attributes are not needed in UNO. Each attribute could also be expressed as a combination of one method to get the attribute&amp;#039;s value, and another method to set it (or just one method to get the value for a read-only attribute). However, there are at least two good reasons for the inclusion of interface attributes in UNO: First, the need for such combinations of getting and setting a value seems to be widespread enough to warrant extra support. Second, with attributes, a designer of an interface can better express nuances among the different features of an object. Attributes can be used for those features that are not considered integral or structural parts of an object, while explicit methods are reserved to access the core features.&lt;br /&gt;
Historically, a UNO object typically supported a set of many independent interfaces, corresponding to its many different aspects. With composite interfaces, there is less need for this, as an object may now support just one interface that includes all the other interfaces that make up the object’s various aspects.&lt;br /&gt;
&lt;br /&gt;
===Services===&lt;br /&gt;
&lt;br /&gt;
Historically, the term “service” has been used with an unclear meaning in UNO. Starting with {{PRODUCTNAME}} {{OOo2.x}}, the underlying concepts have been made cleaner. Unfortunately, this leaves two different meanings for the term “service” within UNO. In the following, we will use the term &amp;quot;new-style service&amp;quot; to denote an entity that conforms to the clarified, {{PRODUCTNAME}}-{{OOo2.x}} service concept, while we use &amp;quot;old-style service&amp;quot; to denote an entity that only conforms to the historical, more vague concept. To make matters even more complicated, the term “service” is often used with still different meanings in contexts outside UNO.&lt;br /&gt;
&lt;br /&gt;
Although technically there should no longer be any need for old-style services, the {{PRODUCTNAME}} API still uses them extensively to remain backwards compatible. Therefore, be prepared to encounter uses of both service concepts in parallel when working with the {{PRODUCTNAME}} API.&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;new-style service&amp;#039;&amp;#039; is of the form&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  module com { module sun { module star { module bridge {   &lt;br /&gt;
      serviceUnoUrlResolver: XUnoUrlResolver;&lt;br /&gt;
  }; }; }; };&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and specifies that objects that support a certain interface (for example, &amp;lt;idl&amp;gt;com.sun.star.bridge.XUnoUrlResolver&amp;lt;/idl&amp;gt;) will be available under a certain service name (e.g., &amp;quot;com.sun.star.bridge.UnoUrlResolver&amp;quot;) at a component context’s service manager.  A new-style service has the feature that all of the interfaces, methods, and properties needed to define an object have been combined into a single, &amp;quot;composite interface&amp;quot;.  (Formally, new-style services are called “single-interface–based services.”)&lt;br /&gt;
&lt;br /&gt;
The various UNO language bindings offer special constructs to easily obtain instances of such new-style services, given a suitable component context; see [[Documentation/DevGuide/ProUNO/Java/Java Language Binding|Java Language Binding]] and [[Documentation/DevGuide/ProUNO/C++/C++ Language Binding|C++ Language Binding]].&lt;br /&gt;
&lt;br /&gt;
An &amp;#039;&amp;#039;old-style service&amp;#039;&amp;#039; (formally called an “accumulation-based service”) is of the form&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  module com { module sun { module star { module frame {serviceDesktop {&lt;br /&gt;
      service Frame;&lt;br /&gt;
      interface XDesktop;&lt;br /&gt;
      interface XComponentLoader;&lt;br /&gt;
      interface com::sun::star::document::XEventBroadcaster;&lt;br /&gt;
  };&lt;br /&gt;
  }; }; }; };&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and is used to specify any of the following:&lt;br /&gt;
&lt;br /&gt;
* The general contract is that, if an object is documented to support a certain old-style service, then you can expect that object to support all interfaces exported by the service itself and any inherited services. For example, the method &amp;lt;idlml&amp;gt;com.sun.star.frame.XFrames:queryFrames&amp;lt;/idlml&amp;gt; returns a sequence of objects that should all support the old-style service &amp;lt;idl&amp;gt;com.sun.star.frame.Frame&amp;lt;/idl&amp;gt;, and thus all the interfaces exported by &amp;lt;idls&amp;gt;com.sun.star.frame.Frame&amp;lt;/idls&amp;gt;.&lt;br /&gt;
* Additionally, an old-style service may specify one or more properties, as in&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  module com { module sun { module star { module frame {service Frame {   &lt;br /&gt;
      interface com::sun::star::frame::XFrame;&lt;br /&gt;
      interface com::sun::star::frame::XDispatchProvider;&lt;br /&gt;
      // ...&lt;br /&gt;
      [property] string Title;&lt;br /&gt;
      [property, optional] XDispatchRecorderSupplier RecorderSupplier;&lt;br /&gt;
      // ...&lt;br /&gt;
  };&lt;br /&gt;
  }; }; }; };&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: Properties, which are explained in detail in the following section, are similar to interface attributes, in that they describe additional features of an object. The main difference is that interface attributes can be accessed directly, while the properties of an old-style service are typically accessed via generic interfaces like &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idl&amp;gt;. Often, interface attributes are used to represent integral features of an object, while properties represent additional, more volatile features.&lt;br /&gt;
&lt;br /&gt;
* Some old-style services are intended to be available at a component context’s service manager. For example, the service &amp;lt;idl&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idl&amp;gt; can be instantiated at a component context’s service manager under its service name &amp;quot;com.sun.star.frame.Desktop&amp;quot;. (The problem is that you cannot tell whether a given old-style service is intended to be available at a component context; using a new-style service instead makes that intent explicit.)&lt;br /&gt;
&lt;br /&gt;
* Other old-style services are designed as generic super-services that are inherited by other services. For example, the service &amp;lt;idl&amp;gt;com.sun.star.document.OfficeDocument&amp;lt;/idl&amp;gt; serves as a generic base for all different sorts of concrete document services, like &amp;lt;idl&amp;gt;com.sun.star.text.TextDocument&amp;lt;/idl&amp;gt; and &amp;lt;idl&amp;gt;com.sun.star.drawing.DrawingDocument&amp;lt;/idl&amp;gt;. (Multiple-inheritance interfaces are now the preferred mechanism to express such generic base services.)&lt;br /&gt;
&lt;br /&gt;
* Yet other old-style services only list properties, and do not export any interfaces at all. Instead of specifying the interfaces supported by certain objects, as the other kinds of old-style services do, such services are used to document a set of related properties. For example, the service &amp;lt;idl&amp;gt;com.sun.star.document.MediaDescriptor&amp;lt;/idl&amp;gt; lists all the properties that can be passed to &amp;lt;idlml&amp;gt;com.sun.star.frame.XComponentLoader:loadComponentFromURL&amp;lt;/idlml&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;property&amp;#039;&amp;#039; is a feature of an object which is typically not considered an integral or structural part of the object and therefore is handled through generic &amp;lt;code&amp;gt;getPropertyValue()&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;setPropertyValue()&amp;lt;/code&amp;gt; methods instead of specialized get methods, such as &amp;lt;code&amp;gt;getPrinter()&amp;lt;/code&amp;gt;. Old-style services offer a special syntax to list all the properties of an object. An object containing properties only has to support the &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idl&amp;gt; interface to be prepared to handle all kinds of properties. Typical examples are properties for character or paragraph formatting. With properties, you can set multiple features of an object through a single call to &amp;lt;code&amp;gt;setPropertyValues()&amp;lt;/code&amp;gt;, which greatly improves the remote performance. For instance, paragraphs support the &amp;lt;code&amp;gt;setPropertyValues()&amp;lt;/code&amp;gt; method through their &amp;lt;idl&amp;gt;com.sun.star.beans.XMultiPropertySet&amp;lt;/idl&amp;gt; interface.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/First Steps]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Talk:Documentation/DevGuide/FirstSteps/Objects,_Interfaces,_and_Services&amp;diff=94666</id>
		<title>Talk:Documentation/DevGuide/FirstSteps/Objects, Interfaces, and Services</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Talk:Documentation/DevGuide/FirstSteps/Objects,_Interfaces,_and_Services&amp;diff=94666"/>
		<updated>2008-10-06T18:17:50Z</updated>

		<summary type="html">&lt;p&gt;Cking: New page: I don&amp;#039;t think the term &amp;quot;multiple-inheritance interfaces&amp;quot; makes sense.  Objects can inherit, but how can an interface inherit anything?  Perhaps a better term would be &amp;quot;nested interfaces&amp;quot;: ...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I don&amp;#039;t think the term &amp;quot;multiple-inheritance interfaces&amp;quot; makes sense.  Objects can inherit, but how can an interface inherit anything?  Perhaps a better term would be &amp;quot;nested interfaces&amp;quot;:  these could be defined as interfaces that, besides their own methods, include all the methods of other interfaces.  Java doesn&amp;#039;t support multiple-inheritance objects, so I doubt that OOo does.  I&amp;#039;ll put &amp;quot;nested interface&amp;quot; into the section on interfaces to see how it looks.&lt;br /&gt;
&lt;br /&gt;
Also, I&amp;#039;ve called the single interface of a new-style service a composite interface.&lt;br /&gt;
--[[User:Cking|Cking]] 20:17, 6 October 2008 (CEST)&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Objects,_Interfaces,_and_Services&amp;diff=94665</id>
		<title>Documentation/DevGuide/FirstSteps/Objects, Interfaces, and Services</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Objects,_Interfaces,_and_Services&amp;diff=94665"/>
		<updated>2008-10-06T18:05:34Z</updated>

		<summary type="html">&lt;p&gt;Cking: Called the new-style service interface a &amp;quot;composite interface&amp;quot;.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/FirstStepsTOC&lt;br /&gt;
|FirstSteps2b=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/FirstSteps/Working with Objects&lt;br /&gt;
|NextPage=Documentation/DevGuide/FirstSteps/Using Services&lt;br /&gt;
}}&lt;br /&gt;
[[zh:Zh/Documentation/DevGuide/FirstSteps/Objects, Interfaces, and Services]]&lt;br /&gt;
{{DISPLAYTITLE:Objects, Interfaces, and Services}}&lt;br /&gt;
===Objects===&lt;br /&gt;
&lt;br /&gt;
In UNO, an &amp;#039;&amp;#039;object&amp;#039;&amp;#039; is a software artifact that has methods that you can call and attributes that you can get and set. Exactly which methods and attributes an object offers is specified by the set of interfaces it supports.&lt;br /&gt;
&lt;br /&gt;
===Interfaces===&lt;br /&gt;
&lt;br /&gt;
An &amp;#039;&amp;#039;interface&amp;#039;&amp;#039; specifies a set of attributes and methods that together define one single aspect of an object. For instance, the interface &amp;lt;idl&amp;gt;com.sun.star.resource.XResourceBundle&amp;lt;/idl&amp;gt; specifies the attribute &amp;lt;code&amp;gt;Parent&amp;lt;/code&amp;gt; and the methods &amp;lt;code&amp;gt;getLocale()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;getDirectElement()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  module com { module sun { module star { module resource { interfaceXResourceBundle: com::sun::star::container::XNameAccess {&lt;br /&gt;
      [attribute] XResourceBundle Parent;&lt;br /&gt;
      com::sun::star::lang::Locale getLocale();&lt;br /&gt;
      any getDirectElement([in] string key);&lt;br /&gt;
  };&lt;br /&gt;
  }; }; }; };&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To allow for reuse of such interface specifications, an interface can inherit one or more other interfaces (as, for example, &amp;lt;idls&amp;gt;com.sun.star.resource.XResourceBundle&amp;lt;/idls&amp;gt; inherits all the attributes and methods of &amp;lt;idl&amp;gt;com.sun.star.container.XNameAccess&amp;lt;/idl&amp;gt;). Multiple inheritance, the ability to inherit more than one interface, was introduced in {{PRODUCTNAME}} {{OOo2.x}}.&lt;br /&gt;
&lt;br /&gt;
Strictly speaking, interface attributes are not needed in UNO. Each attribute could also be expressed as a combination of one method to get the attribute&amp;#039;s value, and another method to set it (or just one method to get the value for a read-only attribute). However, there are at least two good reasons for the inclusion of interface attributes in UNO: First, the need for such combinations of getting and setting a value seems to be widespread enough to warrant extra support. Second, with attributes, a designer of an interface can better express nuances among the different features of an object. Attributes can be used for those features that are not considered integral or structural parts of an object, while explicit methods are reserved to access the core features.&lt;br /&gt;
Historically, a UNO object typically supported a set of many independent interfaces, corresponding to its many different aspects. With multiple-inheritance interfaces, there is less need for this, as an object may now support just one interface that inherits from all the other interfaces that make up the object’s various aspects.&lt;br /&gt;
&lt;br /&gt;
===Services===&lt;br /&gt;
&lt;br /&gt;
Historically, the term “service” has been used with an unclear meaning in UNO. Starting with {{PRODUCTNAME}} {{OOo2.x}}, the underlying concepts have been made cleaner. Unfortunately, this leaves two different meanings for the term “service” within UNO. In the following, we will use the term &amp;quot;new-style service&amp;quot; to denote an entity that conforms to the clarified, {{PRODUCTNAME}}-{{OOo2.x}} service concept, while we use &amp;quot;old-style service&amp;quot; to denote an entity that only conforms to the historical, more vague concept. To make matters even more complicated, the term “service” is often used with still different meanings in contexts outside UNO.&lt;br /&gt;
&lt;br /&gt;
Although technically there should no longer be any need for old-style services, the {{PRODUCTNAME}} API still uses them extensively to remain backwards compatible. Therefore, be prepared to encounter uses of both service concepts in parallel when working with the {{PRODUCTNAME}} API.&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;new-style service&amp;#039;&amp;#039; is of the form&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  module com { module sun { module star { module bridge {   &lt;br /&gt;
      serviceUnoUrlResolver: XUnoUrlResolver;&lt;br /&gt;
  }; }; }; };&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and specifies that objects that support a certain interface (for example, &amp;lt;idl&amp;gt;com.sun.star.bridge.XUnoUrlResolver&amp;lt;/idl&amp;gt;) will be available under a certain service name (e.g., &amp;quot;com.sun.star.bridge.UnoUrlResolver&amp;quot;) at a component context’s service manager.  A new-style service has the feature that all of the interfaces, methods, and properties needed to define an object have been combined into a single, &amp;quot;composite interface&amp;quot;.  (Formally, new-style services are called “single-interface–based services.”)&lt;br /&gt;
&lt;br /&gt;
The various UNO language bindings offer special constructs to easily obtain instances of such new-style services, given a suitable component context; see [[Documentation/DevGuide/ProUNO/Java/Java Language Binding|Java Language Binding]] and [[Documentation/DevGuide/ProUNO/C++/C++ Language Binding|C++ Language Binding]].&lt;br /&gt;
&lt;br /&gt;
An &amp;#039;&amp;#039;old-style service&amp;#039;&amp;#039; (formally called an “accumulation-based service”) is of the form&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  module com { module sun { module star { module frame {serviceDesktop {&lt;br /&gt;
      service Frame;&lt;br /&gt;
      interface XDesktop;&lt;br /&gt;
      interface XComponentLoader;&lt;br /&gt;
      interface com::sun::star::document::XEventBroadcaster;&lt;br /&gt;
  };&lt;br /&gt;
  }; }; }; };&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and is used to specify any of the following:&lt;br /&gt;
&lt;br /&gt;
* The general contract is that, if an object is documented to support a certain old-style service, then you can expect that object to support all interfaces exported by the service itself and any inherited services. For example, the method &amp;lt;idlml&amp;gt;com.sun.star.frame.XFrames:queryFrames&amp;lt;/idlml&amp;gt; returns a sequence of objects that should all support the old-style service &amp;lt;idl&amp;gt;com.sun.star.frame.Frame&amp;lt;/idl&amp;gt;, and thus all the interfaces exported by &amp;lt;idls&amp;gt;com.sun.star.frame.Frame&amp;lt;/idls&amp;gt;.&lt;br /&gt;
* Additionally, an old-style service may specify one or more properties, as in&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  module com { module sun { module star { module frame {service Frame {   &lt;br /&gt;
      interface com::sun::star::frame::XFrame;&lt;br /&gt;
      interface com::sun::star::frame::XDispatchProvider;&lt;br /&gt;
      // ...&lt;br /&gt;
      [property] string Title;&lt;br /&gt;
      [property, optional] XDispatchRecorderSupplier RecorderSupplier;&lt;br /&gt;
      // ...&lt;br /&gt;
  };&lt;br /&gt;
  }; }; }; };&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: Properties, which are explained in detail in the following section, are similar to interface attributes, in that they describe additional features of an object. The main difference is that interface attributes can be accessed directly, while the properties of an old-style service are typically accessed via generic interfaces like &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idl&amp;gt;. Often, interface attributes are used to represent integral features of an object, while properties represent additional, more volatile features.&lt;br /&gt;
&lt;br /&gt;
* Some old-style services are intended to be available at a component context’s service manager. For example, the service &amp;lt;idl&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idl&amp;gt; can be instantiated at a component context’s service manager under its service name &amp;quot;com.sun.star.frame.Desktop&amp;quot;. (The problem is that you cannot tell whether a given old-style service is intended to be available at a component context; using a new-style service instead makes that intent explicit.)&lt;br /&gt;
&lt;br /&gt;
* Other old-style services are designed as generic super-services that are inherited by other services. For example, the service &amp;lt;idl&amp;gt;com.sun.star.document.OfficeDocument&amp;lt;/idl&amp;gt; serves as a generic base for all different sorts of concrete document services, like &amp;lt;idl&amp;gt;com.sun.star.text.TextDocument&amp;lt;/idl&amp;gt; and &amp;lt;idl&amp;gt;com.sun.star.drawing.DrawingDocument&amp;lt;/idl&amp;gt;. (Multiple-inheritance interfaces are now the preferred mechanism to express such generic base services.)&lt;br /&gt;
&lt;br /&gt;
* Yet other old-style services only list properties, and do not export any interfaces at all. Instead of specifying the interfaces supported by certain objects, as the other kinds of old-style services do, such services are used to document a set of related properties. For example, the service &amp;lt;idl&amp;gt;com.sun.star.document.MediaDescriptor&amp;lt;/idl&amp;gt; lists all the properties that can be passed to &amp;lt;idlml&amp;gt;com.sun.star.frame.XComponentLoader:loadComponentFromURL&amp;lt;/idlml&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;property&amp;#039;&amp;#039; is a feature of an object which is typically not considered an integral or structural part of the object and therefore is handled through generic &amp;lt;code&amp;gt;getPropertyValue()&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;setPropertyValue()&amp;lt;/code&amp;gt; methods instead of specialized get methods, such as &amp;lt;code&amp;gt;getPrinter()&amp;lt;/code&amp;gt;. Old-style services offer a special syntax to list all the properties of an object. An object containing properties only has to support the &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idl&amp;gt; interface to be prepared to handle all kinds of properties. Typical examples are properties for character or paragraph formatting. With properties, you can set multiple features of an object through a single call to &amp;lt;code&amp;gt;setPropertyValues()&amp;lt;/code&amp;gt;, which greatly improves the remote performance. For instance, paragraphs support the &amp;lt;code&amp;gt;setPropertyValues()&amp;lt;/code&amp;gt; method through their &amp;lt;idl&amp;gt;com.sun.star.beans.XMultiPropertySet&amp;lt;/idl&amp;gt; interface.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/First Steps]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Using_Services&amp;diff=94556</id>
		<title>Documentation/DevGuide/FirstSteps/Using Services</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Using_Services&amp;diff=94556"/>
		<updated>2008-10-05T23:58:26Z</updated>

		<summary type="html">&lt;p&gt;Cking: Added paragraph about new-style services having just 1 interface to mess with.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/FirstStepsTOC&lt;br /&gt;
|FirstSteps2b=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/FirstSteps/Objects, Interfaces, and Services&lt;br /&gt;
|NextPage=Documentation/DevGuide/FirstSteps/Example: Working with a Spreadsheet Document&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Using Services}}&lt;br /&gt;
The concepts of interfaces and services were introduced for the following reasons:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Interfaces and services separate specification from implementation&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: The specification of an interface or service is &amp;#039;&amp;#039;abstract&amp;#039;&amp;#039;, that is, it does not define how objects supporting a certain functionality do this &amp;#039;&amp;#039;internally&amp;#039;&amp;#039;. Through the abstract specification of the {{OOo}} API, it is possible to pull the implementation out from under the API and install a different implementation if required.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Service names allow to create instances by specification name, not by class names&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: In Java or C++ you use the new operator to create a class instance. This approach is restricted: the class you get is hard-coded. You cannot later on exchange it by another class without editing the code. The concept of services solves this. The central object factory in {{OOo}}, the global service manager, is asked to create an object that can be used for a certain purpose without defining its internal implementation. This is possible because a service can be ordered from the factory by its &amp;#039;&amp;#039;service name&amp;#039;&amp;#039; and the factory decides which service implementation it returns. Which implementation you get makes no difference, you only use the well-defined interface of the service.&lt;br /&gt;
&lt;br /&gt;
===Multiple Interface Implementation===&lt;br /&gt;
Abstract interfaces are more reusable if they are fine-grained, i.e., if they are small and describe only a single aspect of an object.  To describe the many aspects of an object, objects can implement more than one of these fine-grained interfaces.  This &amp;quot;multiple interface implementation&amp;quot; allows same aspects of similar objects accessed with the same code.  For example, many objects support text:  text may be found in the body of a document, in text frames, in headers and footers, footnotes, table cells, and in drawing shapes.  These objects all support the same interface, so a procedure can use, for example, getText() to retrieve text from &amp;#039;&amp;#039;any&amp;#039;&amp;#039; of them.  &lt;br /&gt;
&lt;br /&gt;
Services, interfaces, and methods are illustrated in the figure below for the old-style service &amp;lt;idl&amp;gt;com.sun.star.text.TextDocument&amp;lt;/idl&amp;gt;, shown using [http://en.wikipedia.org/wiki/Unified_Modeling_Language UML] notation.  In this figure, services are shown on the left side.  The arrow between services indicates that one service provided by the upper (arrowhead) service are inherited by the lower service.  Interfaces exported by these services are shown on the right.  All interface names in the {{OOo}} API start with an X, so as to be distinguishable from the names of other entities.   Each interface contains methods, which are listed beneath the interface.  &lt;br /&gt;
&lt;br /&gt;
[[Image:TextDocumentWithMethods.png|none|thumb|450px|Figure.  TextDocument inherits the methods of OfficeDocument.]]&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; object provides the &amp;lt;idl&amp;gt;com.sun.star.text.TextDocument&amp;lt;/idl&amp;gt; service, which implements the interfaces, &amp;lt;code&amp;gt;XTextDocument&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;XSearchable&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;XRefreshable&amp;lt;/code&amp;gt;.  These interfaces provide, for example, the methods &amp;lt;code&amp;gt;getText()&amp;lt;/code&amp;gt;, for adding text to a document, and &amp;lt;code&amp;gt;findAll()&amp;lt;/code&amp;gt;, for searching the document.  &lt;br /&gt;
&lt;br /&gt;
As indicated by the arrow, the &amp;lt;idl&amp;gt;com.sun.star.text.TextDocument&amp;lt;/idl&amp;gt; service also inherits all the interfaces provided by the &amp;lt;idl&amp;gt;com.sun.star.document.OfficeDocument&amp;lt;/idl&amp;gt; service, so these interfaces are also provided to a &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; object.  These interfaces handle tasks common to the {{OOo}} applications:  printing, &amp;lt;code&amp;gt;XPrintable&amp;lt;/code&amp;gt;; storing, &amp;lt;code&amp;gt;XStorable&amp;lt;/code&amp;gt;; modifying, &amp;lt;code&amp;gt;XModifiable&amp;lt;/code&amp;gt;; and model handling, &amp;lt;code&amp;gt;XModel&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The interfaces shown in the figure are only the mandatory interfaces of a &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; object. A &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; has optional properties and interfaces, among them the properties &amp;lt;code&amp;gt;CharacterCount&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ParagraphCount&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;WordCount&amp;lt;/code&amp;gt;, and the interface  &amp;lt;code&amp;gt;XPropertySet&amp;lt;/code&amp;gt;, which must be supported if properties are present at all. The implementation of the &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; service in {{OOo}} supports both required and all optional interfaces as well. The usage of a &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; is described thoroughly in [[Documentation/DevGuide/Text/Text Documents|Text Documents]].&lt;br /&gt;
&lt;br /&gt;
C++ and Java require that the interface name be provided when accessing a method.  An old-style service may provide several interfaces to keep track of.  New-style services are easier to use because, since they have just one interface, all the methods are accessed through the same interface.&lt;br /&gt;
&lt;br /&gt;
===Using Interfaces===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.uno.XInterface&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The fact that every UNO object must be accessed through its interfaces has an effect in languages like Java and C++, where the compiler needs the correct type of an object reference before you can call a method from it. In Java or C++, you normally just cast an object before you access an interface it implements. When working with UNO objects this is different: You must ask the UNO environment to get the appropriate reference for you whenever you want to access methods of an interface which your object supports, but your compiler does not yet know about. Only then you can cast it safely.&lt;br /&gt;
&lt;br /&gt;
The Java UNO environment has a method &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; for this purpose. It looks complicated at first sight, but once you understand that &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; is about safe casting of UNO types across process boundaries, you will soon get used to it. Take a look at the second example FirstLoadComponent.java (in the sample directory, if you have installed the SDK on your computer), where a new Desktop object is created and, afterwards, the &amp;lt;idlm&amp;gt;queryInterface&amp;lt;/idlm&amp;gt;() method is used to get the &amp;lt;idls&amp;gt;com.sun.star.frame.XComponentLoader&amp;lt;/idls&amp;gt; interface.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  Object desktop = xRemoteServiceManager.createInstanceWithContext(&lt;br /&gt;
                &amp;quot;com.sun.star.frame.Desktop&amp;quot;, xRemoteContext);&lt;br /&gt;
 &lt;br /&gt;
  XComponentLoader xComponentLoader = (XComponentLoader)&lt;br /&gt;
                UnoRuntime.queryInterface(XComponentLoader.class, desktop);&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We asked the service manager to create a &amp;lt;idl&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idl&amp;gt; using its factory method createInstanceWithContext(). This method is defined to return a Java Object type, which should not surprise you—after all the factory must be able to return any type:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  java.lang.Object createInstanceWithContext(String serviceName, XComponentContext context)&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The object we receive is a &amp;lt;idl&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idl&amp;gt; service.  The point is, while we know that the object we ordered at the factory is a DesktopUnoUrlResolver and exports among other interfaces the interface &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt;, the compiler does &amp;#039;&amp;#039;not&amp;#039;&amp;#039;. Therefore, we have to use the UNO runtime environment to ask or &amp;#039;&amp;#039;query&amp;#039;&amp;#039; for the interface &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt;, since we want to use the &amp;lt;code&amp;gt;loadComponentFromURL()&amp;lt;/code&amp;gt; method on this interface. The method &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; makes sure we get a reference that can be cast to the needed interface type, no matter if the target object is a local or a remote object. There are two &amp;lt;code&amp;gt;queryInterface&amp;lt;/code&amp;gt; definitions in the Java UNO language binding:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  java.lang.Object UnoRuntime.queryInterface(java.lang.Class targetInterface, Object sourceObject)&lt;br /&gt;
  java.lang.Object UnoRuntime.queryInterface(com.sun.star.uno.Type targetInterface, Object sourceObject)&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since &amp;lt;code&amp;gt;UnoRuntime.queryInterface()&amp;lt;/code&amp;gt; is specified to return a java.lang.Object just like the factory method &amp;lt;code&amp;gt;createInstanceWithContext()&amp;lt;/code&amp;gt;, we still must explicitly cast our interface reference to the needed type. The difference is that after &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; we can safely cast the object to our interface type and, most important, that the reference will now work even with an object in another process. Here is the &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; call, explained step by step:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  XComponentLoader xComponentLoader = (XComponentLoader)&lt;br /&gt;
                  UnoRuntime.queryInterface(XComponentLoader.class, desktop);&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt; is the interface we want to use, so we define a &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt; variable named &amp;lt;code&amp;gt;xComponentLoader&amp;lt;/code&amp;gt; (lower x) to store the interface we expect from &amp;lt;code&amp;gt;queryInterface&amp;lt;/code&amp;gt;. &lt;br /&gt;
Then we query our desktop object for the &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt; interface, passing in &amp;lt;code&amp;gt;XComponentLoader.class&amp;lt;/code&amp;gt; as target interface and desktop as source object. Finally we cast the outcome to &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt; and assign the resulting reference to our variable &amp;lt;code&amp;gt;xComponentLoader&amp;lt;/code&amp;gt;.&lt;br /&gt;
If the source object does not support the interface we are querying for, &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; will return null.&lt;br /&gt;
&lt;br /&gt;
In Java, this call to &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; is necessary whenever you have a reference to an object which is known to support an interface that you need, but you do not have the proper reference type yet. Fortunately, you are not only allowed to &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;java.lang.Object&amp;lt;/code&amp;gt; source types, but you may also query an interface from another interface reference, like this:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // loading a blank spreadsheet document gives us its XComponent interface:&lt;br /&gt;
  XComponent xComponent = xComponentLoader.loadComponentFromURL(&lt;br /&gt;
  &amp;quot;private:factory/scalc&amp;quot;, &amp;quot;_blank&amp;quot;, 0, loadProps);&lt;br /&gt;
  &lt;br /&gt;
  // now we query the interface XSpreadsheetDocument from xComponent&lt;br /&gt;
  XSpreadsheetDocument xSpreadsheetDocument = (XSpreadsheetDocument)UnoRuntime.queryInterface(&lt;br /&gt;
                  XSpreadsheetDocument.class, xComponent);  &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Furthermore, if a method is defined in such a way that it already returns an interface type, you do not need to query the interface, but you can use its methods right away. In the snippet above, the method &amp;lt;code&amp;gt;loadComponentFromURL&amp;lt;/code&amp;gt; is specified to return an &amp;lt;idl&amp;gt;com.sun.star.lang.XComponent&amp;lt;/idl&amp;gt; interface, so you may call the &amp;lt;code&amp;gt;XComponent&amp;lt;/code&amp;gt; methods &amp;lt;code&amp;gt;addEventListener()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;removeEventListener()&amp;lt;/code&amp;gt; directly at the &amp;lt;code&amp;gt;xComponent&amp;lt;/code&amp;gt; variable, if you want to be notified that the document is being closed.&lt;br /&gt;
The corresponding step in C++ is done by a &amp;lt;code&amp;gt;Reference&amp;lt;&amp;gt;&amp;lt;/code&amp;gt; template that takes the source instance as parameter:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // instantiate a sample service with the servicemanager.&lt;br /&gt;
  Reference&amp;lt; XInterface &amp;gt; rInstance =&lt;br /&gt;
  rServiceManager-&amp;gt;createInstanceWithContext( &lt;br /&gt;
  OUString::createFromAscii(&amp;quot;com.sun.star.frame.Desktop&amp;quot; ),&lt;br /&gt;
  rComponentContext );&lt;br /&gt;
  &lt;br /&gt;
  // Query for the XComponentLoader interface&lt;br /&gt;
  Reference&amp;lt; XComponentLoader &amp;gt; rComponentLoader( rInstance, UNO_QUERY );&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In {{OOo}} Basic, querying for interfaces is not necessary; the Basic runtime engine takes care of that internally.&lt;br /&gt;
With the proliferation of multiple-inheritance interfaces in the {{OOo}} API, there will be less of a demand to explicitly query for specific interfaces in Java or C++. For example, with the hypothetical interfaces&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  interface XBase1 {   void fun1();&lt;br /&gt;
  };&lt;br /&gt;
  interface XBase2 {&lt;br /&gt;
      void fun2();&lt;br /&gt;
  };&lt;br /&gt;
  interface XBoth { // inherits from both XBase1 and XBase2&lt;br /&gt;
      interface XBase1;&lt;br /&gt;
      interface XBase2;&lt;br /&gt;
  };&lt;br /&gt;
  interface XFactory {&lt;br /&gt;
      XBoth getBoth();};&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
you can directly call both &amp;lt;code&amp;gt;fun1()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;fun2()&amp;lt;/code&amp;gt; on a reference obtained through &amp;lt;code&amp;gt;XFactory.getBoth()&amp;lt;/code&amp;gt;, without querying for either &amp;lt;code&amp;gt;XBase1&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;XBase2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Using Properties===&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
An object must offer its properties through interfaces that allow you to work with properties. The most basic form of these interfaces is the interface &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idl&amp;gt;. There are other interfaces for properties, such as &amp;lt;idl&amp;gt;com.sun.star.beans.XMultiPropertySet&amp;lt;/idl&amp;gt;, that gets and sets a multitude of properties with a single method call. The &amp;lt;code&amp;gt;XPropertySet&amp;lt;/code&amp;gt; is always supported when properties are present in a service.&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;XPropertySet&amp;lt;/code&amp;gt;, two methods carry out the property access, which are defined in Java as follows: &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  void setPropertyValue(String propertyName, Object propertyValue)&lt;br /&gt;
  Object getPropertyValue(String propertyName)&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the FirstLoadComponent example, the &amp;lt;code&amp;gt;XPropertySet&amp;lt;/code&amp;gt; interface was used to set the CellStyle property at a cell object. The cell object was a &amp;lt;code&amp;gt;com.sun.star.sheet.SheetCell&amp;lt;/code&amp;gt; and therefore supports also the &amp;lt;code&amp;gt;com.sun.star.table.CellProperties&amp;lt;/code&amp;gt; service which had a property &amp;lt;code&amp;gt;CellStyle&amp;lt;/code&amp;gt;. The following code explains how this property was set:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // query the XPropertySet interface from cell object&lt;br /&gt;
  XPropertySet xCellProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xCell);&lt;br /&gt;
  &lt;br /&gt;
  // set the CellStyle property&lt;br /&gt;
  xCellProps.setPropertyValue(&amp;quot;CellStyle&amp;quot;, &amp;quot;Result&amp;quot;);&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
You are now ready to start working with a {{PRODUCTNAME}} document.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/First Steps]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Objects,_Interfaces,_and_Services&amp;diff=94555</id>
		<title>Documentation/DevGuide/FirstSteps/Objects, Interfaces, and Services</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Objects,_Interfaces,_and_Services&amp;diff=94555"/>
		<updated>2008-10-05T23:30:22Z</updated>

		<summary type="html">&lt;p&gt;Cking: Added that new-style interface is created in a separate step&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/FirstStepsTOC&lt;br /&gt;
|FirstSteps2b=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/FirstSteps/Working with Objects&lt;br /&gt;
|NextPage=Documentation/DevGuide/FirstSteps/Using Services&lt;br /&gt;
}}&lt;br /&gt;
[[zh:Zh/Documentation/DevGuide/FirstSteps/Objects, Interfaces, and Services]]&lt;br /&gt;
{{DISPLAYTITLE:Objects, Interfaces, and Services}}&lt;br /&gt;
===Objects===&lt;br /&gt;
&lt;br /&gt;
In UNO, an &amp;#039;&amp;#039;object&amp;#039;&amp;#039; is a software artifact that has methods that you can call and attributes that you can get and set. Exactly which methods and attributes an object offers is specified by the set of interfaces it supports.&lt;br /&gt;
&lt;br /&gt;
===Interfaces===&lt;br /&gt;
&lt;br /&gt;
An &amp;#039;&amp;#039;interface&amp;#039;&amp;#039; specifies a set of attributes and methods that together define one single aspect of an object. For instance, the interface &amp;lt;idl&amp;gt;com.sun.star.resource.XResourceBundle&amp;lt;/idl&amp;gt; specifies the attribute &amp;lt;code&amp;gt;Parent&amp;lt;/code&amp;gt; and the methods &amp;lt;code&amp;gt;getLocale()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;getDirectElement()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  module com { module sun { module star { module resource { interfaceXResourceBundle: com::sun::star::container::XNameAccess {&lt;br /&gt;
      [attribute] XResourceBundle Parent;&lt;br /&gt;
      com::sun::star::lang::Locale getLocale();&lt;br /&gt;
      any getDirectElement([in] string key);&lt;br /&gt;
  };&lt;br /&gt;
  }; }; }; };&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To allow for reuse of such interface specifications, an interface can inherit one or more other interfaces (as, for example, &amp;lt;idls&amp;gt;com.sun.star.resource.XResourceBundle&amp;lt;/idls&amp;gt; inherits all the attributes and methods of &amp;lt;idl&amp;gt;com.sun.star.container.XNameAccess&amp;lt;/idl&amp;gt;). Multiple inheritance, the ability to inherit more than one interface, was introduced in {{PRODUCTNAME}} {{OOo2.x}}.&lt;br /&gt;
&lt;br /&gt;
Strictly speaking, interface attributes are not needed in UNO. Each attribute could also be expressed as a combination of one method to get the attribute&amp;#039;s value, and another method to set it (or just one method to get the value for a read-only attribute). However, there are at least two good reasons for the inclusion of interface attributes in UNO: First, the need for such combinations of getting and setting a value seems to be widespread enough to warrant extra support. Second, with attributes, a designer of an interface can better express nuances among the different features of an object. Attributes can be used for those features that are not considered integral or structural parts of an object, while explicit methods are reserved to access the core features.&lt;br /&gt;
Historically, a UNO object typically supported a set of many independent interfaces, corresponding to its many different aspects. With multiple-inheritance interfaces, there is less need for this, as an object may now support just one interface that inherits from all the other interfaces that make up the object’s various aspects.&lt;br /&gt;
&lt;br /&gt;
===Services===&lt;br /&gt;
&lt;br /&gt;
Historically, the term “service” has been used with an unclear meaning in UNO. Starting with {{PRODUCTNAME}} {{OOo2.x}}, the underlying concepts have been made cleaner. Unfortunately, this leaves two different meanings for the term “service” within UNO. In the following, we will use the term &amp;quot;new-style service&amp;quot; to denote an entity that conforms to the clarified, {{PRODUCTNAME}}-{{OOo2.x}} service concept, while we use &amp;quot;old-style service&amp;quot; to denote an entity that only conforms to the historical, more vague concept. To make matters even more complicated, the term “service” is often used with still different meanings in contexts outside UNO.&lt;br /&gt;
&lt;br /&gt;
Although technically there should no longer be any need for old-style services, the {{PRODUCTNAME}} API still uses them extensively to remain backwards compatible. Therefore, be prepared to encounter uses of both service concepts in parallel when working with the {{PRODUCTNAME}} API.&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;new-style service&amp;#039;&amp;#039; is of the form&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  module com { module sun { module star { module bridge {   &lt;br /&gt;
      serviceUnoUrlResolver: XUnoUrlResolver;&lt;br /&gt;
  }; }; }; };&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and specifies that objects that support a certain interface (for example, &amp;lt;idl&amp;gt;com.sun.star.bridge.XUnoUrlResolver&amp;lt;/idl&amp;gt;) will be available under a certain service name (e.g., &amp;quot;com.sun.star.bridge.UnoUrlResolver&amp;quot;) at a component context’s service manager. Formally, new-style services are called “single-interface–based services.”  That &amp;quot;single interface&amp;quot; is created in a separate step that combines all the interfaces needed to define the object.&lt;br /&gt;
&lt;br /&gt;
The various UNO language bindings offer special constructs to easily obtain instances of such new-style services, given a suitable component context; see [[Documentation/DevGuide/ProUNO/Java/Java Language Binding|Java Language Binding]] and [[Documentation/DevGuide/ProUNO/C++/C++ Language Binding|C++ Language Binding]].&lt;br /&gt;
&lt;br /&gt;
An &amp;#039;&amp;#039;old-style service&amp;#039;&amp;#039; (formally called an “accumulation-based service”) is of the form&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  module com { module sun { module star { module frame {serviceDesktop {&lt;br /&gt;
      service Frame;&lt;br /&gt;
      interface XDesktop;&lt;br /&gt;
      interface XComponentLoader;&lt;br /&gt;
      interface com::sun::star::document::XEventBroadcaster;&lt;br /&gt;
  };&lt;br /&gt;
  }; }; }; };&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and is used to specify any of the following:&lt;br /&gt;
&lt;br /&gt;
* The general contract is that, if an object is documented to support a certain old-style service, then you can expect that object to support all interfaces exported by the service itself and any inherited services. For example, the method &amp;lt;idlml&amp;gt;com.sun.star.frame.XFrames:queryFrames&amp;lt;/idlml&amp;gt; returns a sequence of objects that should all support the old-style service &amp;lt;idl&amp;gt;com.sun.star.frame.Frame&amp;lt;/idl&amp;gt;, and thus all the interfaces exported by &amp;lt;idls&amp;gt;com.sun.star.frame.Frame&amp;lt;/idls&amp;gt;.&lt;br /&gt;
* Additionally, an old-style service may specify one or more properties, as in&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  module com { module sun { module star { module frame {service Frame {   &lt;br /&gt;
      interface com::sun::star::frame::XFrame;&lt;br /&gt;
      interface com::sun::star::frame::XDispatchProvider;&lt;br /&gt;
      // ...&lt;br /&gt;
      [property] string Title;&lt;br /&gt;
      [property, optional] XDispatchRecorderSupplier RecorderSupplier;&lt;br /&gt;
      // ...&lt;br /&gt;
  };&lt;br /&gt;
  }; }; }; };&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: Properties, which are explained in detail in the following section, are similar to interface attributes, in that they describe additional features of an object. The main difference is that interface attributes can be accessed directly, while the properties of an old-style service are typically accessed via generic interfaces like &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idl&amp;gt;. Often, interface attributes are used to represent integral features of an object, while properties represent additional, more volatile features.&lt;br /&gt;
&lt;br /&gt;
* Some old-style services are intended to be available at a component context’s service manager. For example, the service &amp;lt;idl&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idl&amp;gt; can be instantiated at a component context’s service manager under its service name &amp;quot;com.sun.star.frame.Desktop&amp;quot;. (The problem is that you cannot tell whether a given old-style service is intended to be available at a component context; using a new-style service instead makes that intent explicit.)&lt;br /&gt;
&lt;br /&gt;
* Other old-style services are designed as generic super-services that are inherited by other services. For example, the service &amp;lt;idl&amp;gt;com.sun.star.document.OfficeDocument&amp;lt;/idl&amp;gt; serves as a generic base for all different sorts of concrete document services, like &amp;lt;idl&amp;gt;com.sun.star.text.TextDocument&amp;lt;/idl&amp;gt; and &amp;lt;idl&amp;gt;com.sun.star.drawing.DrawingDocument&amp;lt;/idl&amp;gt;. (Multiple-inheritance interfaces are now the preferred mechanism to express such generic base services.)&lt;br /&gt;
&lt;br /&gt;
* Yet other old-style services only list properties, and do not export any interfaces at all. Instead of specifying the interfaces supported by certain objects, as the other kinds of old-style services do, such services are used to document a set of related properties. For example, the service &amp;lt;idl&amp;gt;com.sun.star.document.MediaDescriptor&amp;lt;/idl&amp;gt; lists all the properties that can be passed to &amp;lt;idlml&amp;gt;com.sun.star.frame.XComponentLoader:loadComponentFromURL&amp;lt;/idlml&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;property&amp;#039;&amp;#039; is a feature of an object which is typically not considered an integral or structural part of the object and therefore is handled through generic &amp;lt;code&amp;gt;getPropertyValue()&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;setPropertyValue()&amp;lt;/code&amp;gt; methods instead of specialized get methods, such as &amp;lt;code&amp;gt;getPrinter()&amp;lt;/code&amp;gt;. Old-style services offer a special syntax to list all the properties of an object. An object containing properties only has to support the &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idl&amp;gt; interface to be prepared to handle all kinds of properties. Typical examples are properties for character or paragraph formatting. With properties, you can set multiple features of an object through a single call to &amp;lt;code&amp;gt;setPropertyValues()&amp;lt;/code&amp;gt;, which greatly improves the remote performance. For instance, paragraphs support the &amp;lt;code&amp;gt;setPropertyValues()&amp;lt;/code&amp;gt; method through their &amp;lt;idl&amp;gt;com.sun.star.beans.XMultiPropertySet&amp;lt;/idl&amp;gt; interface.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/First Steps]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/WritingUNO/Defining_a_Service&amp;diff=94554</id>
		<title>Documentation/DevGuide/WritingUNO/Defining a Service</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/WritingUNO/Defining_a_Service&amp;diff=94554"/>
		<updated>2008-10-05T22:52:00Z</updated>

		<summary type="html">&lt;p&gt;Cking: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/WritingUNOTOC&lt;br /&gt;
|WritingUNO2a=block&lt;br /&gt;
|WritingUNO2Spec=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/WritingUNO/Defining an Interface&lt;br /&gt;
|NextPage=Documentation/DevGuide/WritingUNO/Defining a Sequence&lt;br /&gt;
}}&lt;br /&gt;
[[zh:Zh/Documentation/DevGuide/WritingUNO/Defining a Service]]&lt;br /&gt;
{{DISPLAYTITLE:Defining a Service}}&lt;br /&gt;
The new-style UNOIDL services combine interfaces and properties to specify a certain functionality. In addition, old-style services can include other services. For these purposes, &amp;lt;code&amp;gt;interface&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;property&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;service&amp;lt;/code&amp;gt; declarations are used within service specifications. Usually, services are the basis for an object implementation, although there are old-style services in the {{PRODUCTNAME}} API that only serve as a foundation for, or addition to, other services, but are not meant to be implemented by themselves.&lt;br /&gt;
&amp;lt;!--fn The services [IDL:com.sun.star.text.BaseFrame] or [IDL:com.sun.star.style.CharacterProperties] are part of other services, but are not implemented as such anywhere.--&amp;gt; &lt;br /&gt;
&lt;br /&gt;
We are ready to assemble our &amp;lt;code&amp;gt;ImageShrink&amp;lt;/code&amp;gt; service. Our service will read image files from a source directory and write shrunk versions of the found images to a destination directory. Our &amp;lt;code&amp;gt;XImageShrink&amp;lt;/code&amp;gt; interface offers the needed capabilities, together with the interface &amp;lt;idl&amp;gt;com.sun.star.document.XFilter&amp;lt;/idl&amp;gt; that supports two methods:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  boolean filter( [in] sequence&amp;lt; com::sun::star::beans::PropertyValue &amp;gt; aDescriptor)&lt;br /&gt;
  void cancel()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
A new-style service can only encompass one interface, so we need to combine &amp;lt;code&amp;gt;XImageShrink&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;XFilter&amp;lt;/code&amp;gt; in a single, multiple-inheritance interface:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  #ifndef __org_openoffice_test_XImageShrinkFilter_idl__&lt;br /&gt;
  #define __org_openoffice_test_XImageShrinkFilter_idl__&lt;br /&gt;
  #include &amp;lt;com/sun/star/document/XFilter.idl&amp;gt;&lt;br /&gt;
  #include &amp;lt;org/openoffice/test/XImageShrink.idl&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  module org { module openoffice { module test {&lt;br /&gt;
  &lt;br /&gt;
  interface XImageShrinkFilter {&lt;br /&gt;
      interface XImageShrink;&lt;br /&gt;
      interface com::sun::star::document::XFilter;&lt;br /&gt;
  };&lt;br /&gt;
  &lt;br /&gt;
  }; }; };&lt;br /&gt;
  &lt;br /&gt;
  #endif&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The &amp;lt;code&amp;gt;ImageShrink&amp;lt;/code&amp;gt; service specification is provided by the following code:&lt;br /&gt;
&amp;lt;!--[SOURCE:Components/Thumbs/org/openoffice/test/ImageShrink.idl]--&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  #ifndef __org_openoffice_test_ImageShrink_idl__&lt;br /&gt;
  #define __org_openoffice_test_ImageShrink_idl__&lt;br /&gt;
  #include &amp;lt;org/openoffice/test/XImageShrinkFilter.idl&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  module org { module openoffice { module test {&lt;br /&gt;
  &lt;br /&gt;
  service ImageShrink: XImageShrinkFilter;&lt;br /&gt;
  &lt;br /&gt;
  }; }; };&lt;br /&gt;
  &lt;br /&gt;
  #endif&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
A new-style service is defined using the &amp;lt;code&amp;gt;service&amp;lt;/code&amp;gt; declaration. A new-style service opens with the keyword &amp;lt;code&amp;gt;service&amp;lt;/code&amp;gt;, followed by a service name, a colon, the name of the interface supported by the service, and, finally, a semicolon. The first letter of the service name should be upper-case.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  service ServiceName: XInterface;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An old-style service is much more complex. It opens with the keyword &amp;lt;code&amp;gt;service&amp;lt;/code&amp;gt;, followed by a service name and the service body in braces, and, finally, a semicolon.  The body of a service can reference interfaces and services using &amp;lt;code&amp;gt;interface&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;service&amp;lt;/code&amp;gt; instructions, and it can identify properties supported by the service through &amp;lt;code&amp;gt;[property]&amp;lt;/code&amp;gt; instructions.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;Interface&amp;lt;/code&amp;gt; keywords followed by interface names in a service body indicates that the service supports these interfaces. By default, the &amp;lt;code&amp;gt;interface&amp;lt;/code&amp;gt; forces the developer to implement this interface. To suggest an interface for a certain service, prepend an [optional] flag in front of the keyword &amp;lt;code&amp;gt;interface&amp;lt;/code&amp;gt;. This weakens the specification to a permission. An optional interface can be implemented. Use one interface declaration for each supported interface or give a comma-separated list of interfaces to be exported by a service. You must terminate the &amp;lt;code&amp;gt;interface&amp;lt;/code&amp;gt; instruction using a semicolon.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;service&amp;lt;/code&amp;gt; instructions in a service body include other services. The effect is that all interface and property definitions of the other services become part of the current service. A service reference can be optional using the &amp;lt;code&amp;gt;[optional]&amp;lt;/code&amp;gt; flag in front of the &amp;lt;code&amp;gt;service&amp;lt;/code&amp;gt; keyword. Use one declaration per service or a comma-separated list for the services to reference. The &amp;lt;code&amp;gt;service&amp;lt;/code&amp;gt; declaration ends with a semicolon.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;[property]&amp;lt;/code&amp;gt; declaration s describe qualities of a service that can be reached from the outside under a particular name and type. As opposed to interface attributes, these qualities are not considered to be a structural part of a service. Refer to the section [[Documentation/DevGuide/ProUNO/Properties|Properties]] in the chapter [[Documentation/DevGuide/ProUNO/Professional UNO|Professional UNO]] to determine when to use interface attributes and when to introduce properties in a service . The &amp;lt;code&amp;gt;property&amp;lt;/code&amp;gt; keyword must be enclosed in square brackets, and continue with a known type and a property identifier. Just like a service and an interface, make a property non-mandatory writing &amp;lt;code&amp;gt;[property, optional]&amp;lt;/code&amp;gt;. Besides optional,there is a number of other flags to use with properties. The following table shows all flags that can be used with &amp;lt;code&amp;gt;[property]&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=4 style=&amp;quot;border-collapse:collapse;&amp;quot;&lt;br /&gt;
|-bgcolor=#EDEDED&lt;br /&gt;
!Property Flags &lt;br /&gt;
!Description &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;optional&amp;lt;/code&amp;gt;  &lt;br /&gt;
|Property is non-mandatory. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;readonly&amp;lt;/code&amp;gt; &lt;br /&gt;
|The value of the property cannot be changed using the setter methods for properties, such as &amp;lt;code&amp;gt;setPropertyValue(string name)&amp;lt;/code&amp;gt;.  &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;bound&amp;lt;/code&amp;gt;  &lt;br /&gt;
|Changes of values are broadcast to &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertyChangeListener&amp;lt;/idl&amp;gt;s registered with the component. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;constrained&amp;lt;/code&amp;gt;  &lt;br /&gt;
|The component must broadcast an event before a value changes, listeners can veto. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;maybeambiguous&amp;lt;/code&amp;gt;  &lt;br /&gt;
|The value cannot be determined in some cases, for example, in multiple selections. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;maybedefault&amp;lt;/code&amp;gt;  &lt;br /&gt;
|The value might come from a style or the application environment instead of from the object itself. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;maybevoid&amp;lt;/code&amp;gt;  &lt;br /&gt;
|The property type determines the range of possible values, but sometimes there may be situations where there is no information available. Instead of defining special values for each type denoting that there are no meaningful values, the UNO type &amp;lt;code&amp;gt;void&amp;lt;/code&amp;gt; can be used. Its meaning is comparable to &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; in relational databases. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;removable&amp;lt;/code&amp;gt;  &lt;br /&gt;
|The property is removable. If a property is made removable, you must check for the existence of a property using &amp;lt;code&amp;gt;hasPropertyByName()&amp;lt;/code&amp;gt; at the interface &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySetInfo&amp;lt;/idl&amp;gt; and consider providing the capability to add or remove properties using &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertyContainer&amp;lt;/idl&amp;gt;. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;transient&amp;lt;/code&amp;gt;  &lt;br /&gt;
|The property will not be stored if the object is serialized (made persistent). &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* Several properties of the same type can be listed in one &amp;lt;code&amp;gt;property&amp;lt;/code&amp;gt; declaration. Remember to add a semicolon at the end. Implement the interface &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idl&amp;gt; when putting properties in your service, otherwise the properties specified will not work for others using the component.&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|Some old-style services, which specify no interfaces at all, only properties, are used as a sequence of &amp;lt;idl&amp;gt;com.sun.star.beans.PropertyValue&amp;lt;/idl&amp;gt; in {{PRODUCTNAME}}, for example, &amp;lt;idl&amp;gt;com.sun.star.document.MediaDescriptor&amp;lt;/idl&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
The following UNOIDL snippet shows the service, the interfaces and the properties supported by the old-style service &amp;lt;idl&amp;gt;com.sun.star.text.TextDocument&amp;lt;/idl&amp;gt; as defined in UNOIDL. Note the optional interfaces and the optional and read-only properties.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  service TextDocument&lt;br /&gt;
  {&lt;br /&gt;
  service com::sun::star::document::OfficeDocument;&lt;br /&gt;
  &lt;br /&gt;
  interface com::sun::star::text::XTextDocument;&lt;br /&gt;
  interface com::sun::star::util::XSearchable;&lt;br /&gt;
  interface com::sun::star::util::XRefreshable;&lt;br /&gt;
  interface com::sun::star::util::XNumberFormatsSupplier;&lt;br /&gt;
  &lt;br /&gt;
  [optional] interface com::sun::star::text::XFootnotesSupplier;&lt;br /&gt;
  [optional] interface com::sun::star::text::XEndnotesSupplier;&lt;br /&gt;
  [optional] interface com::sun::star::util::XReplaceable;&lt;br /&gt;
  [optional] interface com::sun::star::text::XPagePrintable;&lt;br /&gt;
  [optional] interface com::sun::star::text::XReferenceMarksSupplier;&lt;br /&gt;
  [optional] interface com::sun::star::text::XLineNumberingSupplier;&lt;br /&gt;
  [optional] interface com::sun::star::text::XChapterNumberingSupplier;&lt;br /&gt;
  [optional] interface com::sun::star::beans::XPropertySet;&lt;br /&gt;
  [optional] interface com::sun::star::text::XTextGraphicObjectsSupplier;&lt;br /&gt;
  [optional] interface com::sun::star::text::XTextEmbeddedObjectsSupplier;&lt;br /&gt;
  [optional] interface com::sun::star::text::XTextTablesSupplier;&lt;br /&gt;
  [optional] interface com::sun::star::style::XStyleFamiliesSupplier;&lt;br /&gt;
  &lt;br /&gt;
  [optional, property] com::sun::star::lang::Locale CharLocale;&lt;br /&gt;
  [optional, property] string WordSeparator;&lt;br /&gt;
  &lt;br /&gt;
  [optional, readonly, property] long CharacterCount;&lt;br /&gt;
  [optional, readonly, property] long ParagraphCount;&lt;br /&gt;
  [optional, readonly, property] long WordCount;&lt;br /&gt;
  &lt;br /&gt;
  };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
{{Documentation/Note|You might encounter two more keywords in old-style service bodies. The keyword &amp;lt;tt&amp;gt;observes&amp;lt;/tt&amp;gt; can stand in front of interface references and means that the given interfaces must be &amp;quot;observed&amp;quot;. Since the &amp;lt;tt&amp;gt;observes&amp;lt;/tt&amp;gt; concept is disapproved of, no further explanation is provided. &lt;br /&gt;
&lt;br /&gt;
If a service references another service using the keyword &amp;lt;tt&amp;gt;needs&amp;lt;/tt&amp;gt; in front of the reference, then this service depends on the availability of the needed service at runtime. Services should not use needs as it is considered too implementation specific.}}&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Writing UNO Components]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/WritingUNO/Defining_a_Service&amp;diff=94553</id>
		<title>Documentation/DevGuide/WritingUNO/Defining a Service</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/WritingUNO/Defining_a_Service&amp;diff=94553"/>
		<updated>2008-10-05T22:50:22Z</updated>

		<summary type="html">&lt;p&gt;Cking: Added a line showing the new-style service:  &amp;quot;service ServiceName: XInterface;&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/WritingUNOTOC&lt;br /&gt;
|WritingUNO2a=block&lt;br /&gt;
|WritingUNO2Spec=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/WritingUNO/Defining an Interface&lt;br /&gt;
|NextPage=Documentation/DevGuide/WritingUNO/Defining a Sequence&lt;br /&gt;
}}&lt;br /&gt;
[[zh:Zh/Documentation/DevGuide/WritingUNO/Defining a Service]]&lt;br /&gt;
{{DISPLAYTITLE:Defining a Service}}&lt;br /&gt;
The new-style UNOIDL Services combine interfaces and properties to specify a certain functionality. In addition, old-style services can include other services. For these purposes, &amp;lt;code&amp;gt;interface&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;property&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;service&amp;lt;/code&amp;gt; declarations are used within service specifications. Usually, services are the basis for an object implementation, although there are old-style services in the {{PRODUCTNAME}} API that only serve as a foundation for, or addition to, other services, but are not meant to be implemented by themselves.&lt;br /&gt;
&amp;lt;!--fn The services [IDL:com.sun.star.text.BaseFrame] or [IDL:com.sun.star.style.CharacterProperties] are part of other services, but are not implemented as such anywhere.--&amp;gt; &lt;br /&gt;
&lt;br /&gt;
We are ready to assemble our &amp;lt;code&amp;gt;ImageShrink&amp;lt;/code&amp;gt; service. Our service will read image files from a source directory and write shrunk versions of the found images to a destination directory. Our &amp;lt;code&amp;gt;XImageShrink&amp;lt;/code&amp;gt; interface offers the needed capabilities, together with the interface &amp;lt;idl&amp;gt;com.sun.star.document.XFilter&amp;lt;/idl&amp;gt; that supports two methods:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  boolean filter( [in] sequence&amp;lt; com::sun::star::beans::PropertyValue &amp;gt; aDescriptor)&lt;br /&gt;
  void cancel()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
A new-style service can only encompass one interface, so we need to combine &amp;lt;code&amp;gt;XImageShrink&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;XFilter&amp;lt;/code&amp;gt; in a single, multiple-inheritance interface:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  #ifndef __org_openoffice_test_XImageShrinkFilter_idl__&lt;br /&gt;
  #define __org_openoffice_test_XImageShrinkFilter_idl__&lt;br /&gt;
  #include &amp;lt;com/sun/star/document/XFilter.idl&amp;gt;&lt;br /&gt;
  #include &amp;lt;org/openoffice/test/XImageShrink.idl&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  module org { module openoffice { module test {&lt;br /&gt;
  &lt;br /&gt;
  interface XImageShrinkFilter {&lt;br /&gt;
      interface XImageShrink;&lt;br /&gt;
      interface com::sun::star::document::XFilter;&lt;br /&gt;
  };&lt;br /&gt;
  &lt;br /&gt;
  }; }; };&lt;br /&gt;
  &lt;br /&gt;
  #endif&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The &amp;lt;code&amp;gt;ImageShrink&amp;lt;/code&amp;gt; service specification is provided by the following code:&lt;br /&gt;
&amp;lt;!--[SOURCE:Components/Thumbs/org/openoffice/test/ImageShrink.idl]--&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  #ifndef __org_openoffice_test_ImageShrink_idl__&lt;br /&gt;
  #define __org_openoffice_test_ImageShrink_idl__&lt;br /&gt;
  #include &amp;lt;org/openoffice/test/XImageShrinkFilter.idl&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  module org { module openoffice { module test {&lt;br /&gt;
  &lt;br /&gt;
  service ImageShrink: XImageShrinkFilter;&lt;br /&gt;
  &lt;br /&gt;
  }; }; };&lt;br /&gt;
  &lt;br /&gt;
  #endif&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
A new-style service is defined using the &amp;lt;code&amp;gt;service&amp;lt;/code&amp;gt; declaration. A new-style service opens with the keyword &amp;lt;code&amp;gt;service&amp;lt;/code&amp;gt;, followed by a service name, a colon, the name of the interface supported by the service, and, finally, a semicolon. The first letter of the service name should be upper-case.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  service ServiceName: XInterface;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An old-style service is much more complex. It opens with the keyword &amp;lt;code&amp;gt;service&amp;lt;/code&amp;gt;, followed by a service name and the service body in braces, and, finally, a semicolon.  The body of a service can reference interfaces and services using &amp;lt;code&amp;gt;interface&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;service&amp;lt;/code&amp;gt; instructions, and it can identify properties supported by the service through &amp;lt;code&amp;gt;[property]&amp;lt;/code&amp;gt; instructions.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;Interface&amp;lt;/code&amp;gt; keywords followed by interface names in a service body indicates that the service supports these interfaces. By default, the &amp;lt;code&amp;gt;interface&amp;lt;/code&amp;gt; forces the developer to implement this interface. To suggest an interface for a certain service, prepend an [optional] flag in front of the keyword &amp;lt;code&amp;gt;interface&amp;lt;/code&amp;gt;. This weakens the specification to a permission. An optional interface can be implemented. Use one interface declaration for each supported interface or give a comma-separated list of interfaces to be exported by a service. You must terminate the &amp;lt;code&amp;gt;interface&amp;lt;/code&amp;gt; instruction using a semicolon.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;service&amp;lt;/code&amp;gt; instructions in a service body include other services. The effect is that all interface and property definitions of the other services become part of the current service. A service reference can be optional using the &amp;lt;code&amp;gt;[optional]&amp;lt;/code&amp;gt; flag in front of the &amp;lt;code&amp;gt;service&amp;lt;/code&amp;gt; keyword. Use one declaration per service or a comma-separated list for the services to reference. The &amp;lt;code&amp;gt;service&amp;lt;/code&amp;gt; declaration ends with a semicolon.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;[property]&amp;lt;/code&amp;gt; declaration s describe qualities of a service that can be reached from the outside under a particular name and type. As opposed to interface attributes, these qualities are not considered to be a structural part of a service. Refer to the section [[Documentation/DevGuide/ProUNO/Properties|Properties]] in the chapter [[Documentation/DevGuide/ProUNO/Professional UNO|Professional UNO]] to determine when to use interface attributes and when to introduce properties in a service . The &amp;lt;code&amp;gt;property&amp;lt;/code&amp;gt; keyword must be enclosed in square brackets, and continue with a known type and a property identifier. Just like a service and an interface, make a property non-mandatory writing &amp;lt;code&amp;gt;[property, optional]&amp;lt;/code&amp;gt;. Besides optional,there is a number of other flags to use with properties. The following table shows all flags that can be used with &amp;lt;code&amp;gt;[property]&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=4 style=&amp;quot;border-collapse:collapse;&amp;quot;&lt;br /&gt;
|-bgcolor=#EDEDED&lt;br /&gt;
!Property Flags &lt;br /&gt;
!Description &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;optional&amp;lt;/code&amp;gt;  &lt;br /&gt;
|Property is non-mandatory. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;readonly&amp;lt;/code&amp;gt; &lt;br /&gt;
|The value of the property cannot be changed using the setter methods for properties, such as &amp;lt;code&amp;gt;setPropertyValue(string name)&amp;lt;/code&amp;gt;.  &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;bound&amp;lt;/code&amp;gt;  &lt;br /&gt;
|Changes of values are broadcast to &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertyChangeListener&amp;lt;/idl&amp;gt;s registered with the component. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;constrained&amp;lt;/code&amp;gt;  &lt;br /&gt;
|The component must broadcast an event before a value changes, listeners can veto. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;maybeambiguous&amp;lt;/code&amp;gt;  &lt;br /&gt;
|The value cannot be determined in some cases, for example, in multiple selections. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;maybedefault&amp;lt;/code&amp;gt;  &lt;br /&gt;
|The value might come from a style or the application environment instead of from the object itself. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;maybevoid&amp;lt;/code&amp;gt;  &lt;br /&gt;
|The property type determines the range of possible values, but sometimes there may be situations where there is no information available. Instead of defining special values for each type denoting that there are no meaningful values, the UNO type &amp;lt;code&amp;gt;void&amp;lt;/code&amp;gt; can be used. Its meaning is comparable to &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; in relational databases. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;removable&amp;lt;/code&amp;gt;  &lt;br /&gt;
|The property is removable. If a property is made removable, you must check for the existence of a property using &amp;lt;code&amp;gt;hasPropertyByName()&amp;lt;/code&amp;gt; at the interface &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySetInfo&amp;lt;/idl&amp;gt; and consider providing the capability to add or remove properties using &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertyContainer&amp;lt;/idl&amp;gt;. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;transient&amp;lt;/code&amp;gt;  &lt;br /&gt;
|The property will not be stored if the object is serialized (made persistent). &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* Several properties of the same type can be listed in one &amp;lt;code&amp;gt;property&amp;lt;/code&amp;gt; declaration. Remember to add a semicolon at the end. Implement the interface &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idl&amp;gt; when putting properties in your service, otherwise the properties specified will not work for others using the component.&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|Some old-style services, which specify no interfaces at all, only properties, are used as a sequence of &amp;lt;idl&amp;gt;com.sun.star.beans.PropertyValue&amp;lt;/idl&amp;gt; in {{PRODUCTNAME}}, for example, &amp;lt;idl&amp;gt;com.sun.star.document.MediaDescriptor&amp;lt;/idl&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
The following UNOIDL snippet shows the service, the interfaces and the properties supported by the old-style service &amp;lt;idl&amp;gt;com.sun.star.text.TextDocument&amp;lt;/idl&amp;gt; as defined in UNOIDL. Note the optional interfaces and the optional and read-only properties.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  service TextDocument&lt;br /&gt;
  {&lt;br /&gt;
  service com::sun::star::document::OfficeDocument;&lt;br /&gt;
  &lt;br /&gt;
  interface com::sun::star::text::XTextDocument;&lt;br /&gt;
  interface com::sun::star::util::XSearchable;&lt;br /&gt;
  interface com::sun::star::util::XRefreshable;&lt;br /&gt;
  interface com::sun::star::util::XNumberFormatsSupplier;&lt;br /&gt;
  &lt;br /&gt;
  [optional] interface com::sun::star::text::XFootnotesSupplier;&lt;br /&gt;
  [optional] interface com::sun::star::text::XEndnotesSupplier;&lt;br /&gt;
  [optional] interface com::sun::star::util::XReplaceable;&lt;br /&gt;
  [optional] interface com::sun::star::text::XPagePrintable;&lt;br /&gt;
  [optional] interface com::sun::star::text::XReferenceMarksSupplier;&lt;br /&gt;
  [optional] interface com::sun::star::text::XLineNumberingSupplier;&lt;br /&gt;
  [optional] interface com::sun::star::text::XChapterNumberingSupplier;&lt;br /&gt;
  [optional] interface com::sun::star::beans::XPropertySet;&lt;br /&gt;
  [optional] interface com::sun::star::text::XTextGraphicObjectsSupplier;&lt;br /&gt;
  [optional] interface com::sun::star::text::XTextEmbeddedObjectsSupplier;&lt;br /&gt;
  [optional] interface com::sun::star::text::XTextTablesSupplier;&lt;br /&gt;
  [optional] interface com::sun::star::style::XStyleFamiliesSupplier;&lt;br /&gt;
  &lt;br /&gt;
  [optional, property] com::sun::star::lang::Locale CharLocale;&lt;br /&gt;
  [optional, property] string WordSeparator;&lt;br /&gt;
  &lt;br /&gt;
  [optional, readonly, property] long CharacterCount;&lt;br /&gt;
  [optional, readonly, property] long ParagraphCount;&lt;br /&gt;
  [optional, readonly, property] long WordCount;&lt;br /&gt;
  &lt;br /&gt;
  };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
{{Documentation/Note|You might encounter two more keywords in old-style service bodies. The keyword &amp;lt;tt&amp;gt;observes&amp;lt;/tt&amp;gt; can stand in front of interface references and means that the given interfaces must be &amp;quot;observed&amp;quot;. Since the &amp;lt;tt&amp;gt;observes&amp;lt;/tt&amp;gt; concept is disapproved of, no further explanation is provided. &lt;br /&gt;
&lt;br /&gt;
If a service references another service using the keyword &amp;lt;tt&amp;gt;needs&amp;lt;/tt&amp;gt; in front of the reference, then this service depends on the availability of the needed service at runtime. Services should not use needs as it is considered too implementation specific.}}&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Writing UNO Components]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/ProUNO/Services&amp;diff=94548</id>
		<title>Documentation/DevGuide/ProUNO/Services</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/ProUNO/Services&amp;diff=94548"/>
		<updated>2008-10-05T21:46:29Z</updated>

		<summary type="html">&lt;p&gt;Cking: Added blockquote about multiple-inheritance interface vs. multiple interface implementation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/ProUNOTOC&lt;br /&gt;
|ProUNO2a=block&lt;br /&gt;
|ProUNO2aDTypes=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/ProUNO/Interfaces&lt;br /&gt;
|NextPage=Documentation/DevGuide/ProUNO/Structs&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Services}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
We have seen that a single-inheritance interface describes only one aspect of an object. However, it is quite common that objects have more than one aspect. UNO uses &amp;#039;&amp;#039;multiple-inheritance interfaces&amp;#039;&amp;#039; and &amp;#039;&amp;#039;services&amp;#039;&amp;#039; to specify complete objects which can have many aspects.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
{{OOo}} objects can &amp;#039;&amp;#039;inherit&amp;#039;&amp;#039; services, including interfaces, from only one parent object.  However, objects can &amp;#039;&amp;#039;implement&amp;#039;&amp;#039; multiple interfaces.  Inherited methods can be provided by the parent of the object; implemented methods must be provide by the object itself.  Although {{OOo}} does not support true multiple-inheritance, objects can implement multiple interfaces, which gives them the appearance of having inherited methods from several other objects.  When the term &amp;#039;&amp;#039;multiple-inheritance interface&amp;#039;&amp;#039; is used in {{OOo}}, it actually refers to &amp;#039;&amp;#039;multiple interface implementation&amp;#039;&amp;#039;.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
In a first step, all the various aspects of an object (which are typically represented by single-inheritance interfaces) are grouped together in one multiple-inheritance interface type. If such an object is obtainable by calling specific factory methods, this step is all that is needed. The factory methods are specified to return values of the given, multiple-inheritance interface type. If, however, such an object is available as a general service at the global component context, a service description must be provided in a second step. This service description will be of the new style, mapping the service name (under which the service is available at the component context) to the given, multiple-inheritance interface type.&lt;br /&gt;
&lt;br /&gt;
For backward compatibility, there are also old-style services, which comprise a set of single-inheritance interfaces and properties that are needed to support a certain functionality. Such a service can include other old-style services as well. The main drawback of an old-style service is that it is unclear whether it describes objects that can be obtained through specific factory methods (and for which there would therefore be no new-style service description), or whether it describes a general service that is available at the global component context, and for which there would thus be a new-style service description.&lt;br /&gt;
&lt;br /&gt;
From the perspective of a &amp;#039;&amp;#039;user&amp;#039;&amp;#039; of a UNO object, the object offers one or sometimes even several independent, multiple-inheritance interfaces or old-style services described in the API reference. The services are utilized through method calls grouped in interfaces, and through properties, which are handled through special interfaces as well. Because the access to the functionality is provided by interfaces only, the implementation is irrelevant to a user who wants to use an object.&lt;br /&gt;
&lt;br /&gt;
From the perspective of an &amp;#039;&amp;#039;implementer&amp;#039;&amp;#039; of a UNO object, multiple-inheritance interfaces and old-style services are used to define a functionality independently of a programming language and without giving instructions about the internal implementation of the object. Implementing an object means that it must support all specified interfaces and properties. It is possible that a UNO object implements more than one independent, multiple-inheritance interface or old-style service. Sometimes it is useful to implement two or more independent, multiple-inheritance interfaces or services because they have related functionality, or because they support different views to the object.&lt;br /&gt;
&lt;br /&gt;
The [[:Image:RemoteControlImpl.png|RemoteControl service]] illustration shows the relationship between interfaces and services. The language independent specification of an old-style service with several interfaces is used to implement a UNO object that fulfills the specification. Such a UNO object is sometimes called a &amp;quot;component,&amp;quot; although that term is more correctly used to describe deployment entities within a UNO environment. The illustration uses an old-style service description that directly supports multiple interfaces; for a new-style service description, the only difference would be that it would only support one multiple-inheritance interface, which in turn would inherit the other interfaces.&lt;br /&gt;
&lt;br /&gt;
[[Image:RelationshipSpecImpl.png|none|thumb|400px|Interfaces, services and implementation ]]&lt;br /&gt;
&lt;br /&gt;
The functionality of a TV system with a TV set and a remote control can be described in terms of service specifications. The interfaces &amp;lt;code&amp;gt;XPower&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;XChannel&amp;lt;/code&amp;gt; described above would be part of a service specification &amp;lt;code&amp;gt;RemoteControl&amp;lt;/code&amp;gt;. The new service &amp;lt;code&amp;gt;TVSet&amp;lt;/code&amp;gt; consists of the three interfaces &amp;lt;code&amp;gt;XPower&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;XChannel&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;XStandby&amp;lt;/code&amp;gt; to control the power, the channel selection, the additional power function &amp;lt;code&amp;gt;standby()&amp;lt;/code&amp;gt; and a &amp;lt;code&amp;gt;timer()&amp;lt;/code&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
[[Image:TVRemoteServices.png|none|thumb|500px|TV System Specification ]]&lt;br /&gt;
&lt;br /&gt;
===Referencing Interfaces===&lt;br /&gt;
&lt;br /&gt;
References to interfaces in a service definition mean that an implementation of this service &amp;#039;&amp;#039;must&amp;#039;&amp;#039; offer the specified interfaces. However, optional interfaces are possible. If a multiple-inheritance interface inherits an optional interface, or an old-style service contains an optional interface, any given UNO object may or may not support this interface. If you utilize an optional interface of a UNO object, always check if the result of &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; is equal to &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; and react accordingly - otherwise your code will not be compatible with implementations without the optional interface and you might end up with null pointer exceptions. The following UNOIDL snippet shows a fragment of the specification for the old-style &amp;lt;idl&amp;gt;com.sun.star.text.TextDocument&amp;lt;/idl&amp;gt; service in the {{PRODUCTNAME}} API. Note the flag optional in square brackets, which makes the interfaces &amp;lt;code&amp;gt;XFootnotesSupplier&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;XEndnotesSupplier&amp;lt;/code&amp;gt; non-mandatory.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;// com.sun.star.text.TextDocument&lt;br /&gt;
  service TextDocument&lt;br /&gt;
  {&lt;br /&gt;
      ...&lt;br /&gt;
  &lt;br /&gt;
      interface com::sun::star::text::XTextDocument;&lt;br /&gt;
      interface com::sun::star::util::XSearchable;&lt;br /&gt;
      interface com::sun::star::util::XRefreshable;&lt;br /&gt;
      [optional] interface com::sun::star::text::XFootnotesSupplier;&lt;br /&gt;
      [optional] interface com::sun::star::text::XEndnotesSupplier;&lt;br /&gt;
  &lt;br /&gt;
      ...&lt;br /&gt;
  };&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Service Constructors===&lt;br /&gt;
&lt;br /&gt;
New-style services can have constructors, similar to interface methods:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  service SomeService: XSomeInterface { &lt;br /&gt;
      create1();&lt;br /&gt;
      create2([in] long arg1, [in] string arg2);&lt;br /&gt;
      create3([in] any... rest);&lt;br /&gt;
  };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
In the above example, there are three &amp;#039;&amp;#039;explicit&amp;#039;&amp;#039; constructors, named &amp;lt;code&amp;gt;create1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;create2&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;create3&amp;lt;/code&amp;gt;. The first has no parameters, the second has two normal parameters, and the third has a special &amp;#039;&amp;#039;rest&amp;#039;&amp;#039; parameter, which accepts an arbitrary number of any values. Constructor parameters may only be &amp;lt;code&amp;gt;[in]&amp;lt;/code&amp;gt;, and a rest parameter must be the only parameter of a constructor, and must be of type &amp;lt;code&amp;gt;any;&amp;lt;/code&amp;gt; also, unlike an interface method, a service constructor does not specify a return type.&lt;br /&gt;
&lt;br /&gt;
The various language bindings map the UNO constructors into language-specific constructs, which can be used in client code to obtain instances of those services, given a component context. The general convention (followed,for example, by the Java and C++ language bindings) is to map each constructor to a static method (resp. function) with the same name, that takes as a first parameter an &amp;lt;idls&amp;gt;com.sun.star.uno.XComponentContext&amp;lt;/idls&amp;gt;, followed by all the parameters specified in the constructor, and returns an (appropriately typed) service instance. If an instance cannot be obtained, a &amp;lt;idl&amp;gt;com.sun.star.uno.DeploymentException&amp;lt;/idl&amp;gt; is thrown. The above &amp;lt;code&amp;gt;SomeService&amp;lt;/code&amp;gt; would map to the following Java 1.5 class, for example:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  public class SomeService { &lt;br /&gt;
      public static XSomeInterface create1(&lt;br /&gt;
          com.sun.star.uno.XComponentContext context) { ... }&lt;br /&gt;
      public static XSomeInterface create2(&lt;br /&gt;
          com.sun.star.uno.XComponentContext context, int arg1, String arg2) { ... }&lt;br /&gt;
      public static XSomeInterface create3(&lt;br /&gt;
          com.sun.star.uno.XComponentContext context, Object... rest) { ... }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Service constructors can also have exception specifications (&amp;lt;code&amp;gt;&amp;quot;raises (Exception1, ...)&amp;quot;&amp;lt;/code&amp;gt;), which are treated in the same way as exception specifications of interface methods. (If a constructor has no exception specification, it may only throw runtime exceptions, &amp;lt;idl&amp;gt;com.sun.star.uno.DeploymentException&amp;lt;/idl&amp;gt; in particular.)&lt;br /&gt;
&lt;br /&gt;
If a new-style service is written using the short form,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  service SomeService: XSomeInterface;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
then it has an &amp;#039;&amp;#039;implicit&amp;#039;&amp;#039; constructor. The exact behavior of the implicit constructor is language-binding - specific, but it is typically named &amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt;, takes no arguments besides the &amp;lt;idls&amp;gt;com.sun.star.uno.XComponentContext&amp;lt;/idls&amp;gt;, and may only throw runtime exceptions.&lt;br /&gt;
&lt;br /&gt;
===Including Properties===&lt;br /&gt;
&lt;br /&gt;
When the structure of the {{PRODUCTNAME}} API was founded, the designers discovered that the objects in an office environment would have huge numbers of qualities that did not appear to be part of the structure of the objects, rather they seemed to be superficial changes to the underlying objects. It was also clear that not all qualities would be present in each object of a certain kind. Therefore, instead of defining a complicated pedigree of optional and non-optional interfaces for each and every quality, the concept of properties was introduced. Properties are data in an object that are provided by name over a generic interface for property access, that contains getPropertyValue() and setPropertyValue() access methods. The concept of properties has other advantages, and there is more to know about properties. Please refer to [[Documentation/DevGuide/ProUNO/Properties|Properties]] for further information about properties.&lt;br /&gt;
&lt;br /&gt;
Old-style services can list supported properties directly in the UNOIDL specification. A &amp;lt;code&amp;gt;property&amp;lt;/code&amp;gt; defines a member variable with a specific type that is accessible at the implementing component by a specific name. It is possible to add further restrictions to a property through additional flags. The following old-style service references one interface and three optional properties. All known API types can be valid property types:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;// com.sun.star.text.TextContent&lt;br /&gt;
  service TextContent&lt;br /&gt;
  {&lt;br /&gt;
      interface com::sun::star::text::XTextContent;&lt;br /&gt;
      [optional, property] com::sun::star::text::TextContentAnchorType AnchorType;&lt;br /&gt;
      [optional, readonly, property] sequence&amp;lt;com::sun::star::text::TextContentAnchorType&amp;gt; AnchorTypes;&lt;br /&gt;
      [optional, property] com::sun::star::text::WrapTextMode TextWrap;&lt;br /&gt;
  };&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Possible property flags are:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;optional&amp;lt;/code&amp;gt;&lt;br /&gt;
:The property does not have to be supported by the implementing component.&lt;br /&gt;
* &amp;lt;code&amp;gt;readonly&amp;lt;/code&amp;gt;&lt;br /&gt;
:The value of the property cannot be changed using [IDL:com.sun.star.beans.XPropertySet].&lt;br /&gt;
* &amp;lt;code&amp;gt;bound&amp;lt;/code&amp;gt;&lt;br /&gt;
:Changes of property values are broadcast to &amp;lt;idls&amp;gt;com.sun.star.beans.XPropertyChangeListener&amp;lt;/idls&amp;gt;, if any were registered through &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idl&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;constrained&amp;lt;/code&amp;gt; &lt;br /&gt;
:The property broadcasts an event before its value changes. Listeners have the right to veto the change.&lt;br /&gt;
* &amp;lt;code&amp;gt;maybeambiguous&amp;lt;/code&amp;gt;&lt;br /&gt;
:Possibly the property value cannot be determined in some cases, for example, in multiple selections with different values.&lt;br /&gt;
* &amp;lt;code&amp;gt;maybedefault&amp;lt;/code&amp;gt;&lt;br /&gt;
:The value might be stored in a style sheet or in the environment instead of the object itself.&lt;br /&gt;
* &amp;lt;code&amp;gt;maybevoid&amp;lt;/code&amp;gt;&lt;br /&gt;
:In addition to the range of the property type, the value can be void. It is similar to a null value in databases.&lt;br /&gt;
* &amp;lt;code&amp;gt;removable&amp;lt;/code&amp;gt;&lt;br /&gt;
:The property is removable, this is used for dynamic properties.&lt;br /&gt;
* &amp;lt;code&amp;gt;transient&amp;lt;/code&amp;gt;&lt;br /&gt;
:The property will not be stored if the object is serialized&lt;br /&gt;
&lt;br /&gt;
===Referencing other Services===&lt;br /&gt;
&lt;br /&gt;
Old-style services can include other old-style services. Such references may be optional. That a service is included by another service has nothing to do with implementation inheritance, only the specifications are combined. It is up to the implementer if he inherits or delegates the necessary functionality, or if he implements it from scratch. &lt;br /&gt;
&lt;br /&gt;
The old-style service &amp;lt;idl&amp;gt;com.sun.star.text.Paragraph&amp;lt;/idl&amp;gt; in the following UNOIDL example includes one mandatory service &amp;lt;idl&amp;gt;com.sun.star.text.TextContent&amp;lt;/idl&amp;gt; and five optional services. Every &amp;lt;code&amp;gt;Paragraph&amp;lt;/code&amp;gt; must be a &amp;lt;code&amp;gt;TextContent&amp;lt;/code&amp;gt;. It can be a &amp;lt;code&amp;gt;TextTable&amp;lt;/code&amp;gt; and it is used to support formatting properties for paragraphs and characters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  // com.sun.star.text.Paragraph&lt;br /&gt;
  service Paragraph&lt;br /&gt;
  {&lt;br /&gt;
      service com::sun::star::text::TextContent;&lt;br /&gt;
      [optional] service com::sun::star::text::TextTable;&lt;br /&gt;
      [optional] service com::sun::star::style::ParagraphProperties;&lt;br /&gt;
      [optional] service com::sun::star::style::CharacterProperties;&lt;br /&gt;
      [optional] service com::sun::star::style::CharacterPropertiesAsian;&lt;br /&gt;
      [optional] service com::sun::star::style::CharacterPropertiesComplex;&lt;br /&gt;
  &lt;br /&gt;
      ...&lt;br /&gt;
  };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If all the old-style services in the example above were multiple-inheritance interface types instead, the structure would be similar: the multiple-inheritance interface type &amp;lt;code&amp;gt;Paragraph&amp;lt;/code&amp;gt; would inherit the mandatory interface &amp;lt;code&amp;gt;TextContent&amp;lt;/code&amp;gt; and the optional interfaces &amp;lt;code&amp;gt;TextTable&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ParagraphProperties&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
&lt;br /&gt;
===Service Implementations in Components===&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;component&amp;#039;&amp;#039; is a shared library or Java archive containing implementations of one or more services in one of the target programming languages supported by UNO. Such a component must meet basic requirements, mostly different for the different target language, and it must support the specification of the implemented services. That means all specified interfaces and properties must be implemented. Components must be registered in the UNO runtime system. After the registration all implemented services can be used by ordering an instance of the service at the appropriate service factory and accessing the functionality over interfaces. &lt;br /&gt;
&lt;br /&gt;
Based on our example specifications for a &amp;lt;code&amp;gt;TVSet&amp;lt;/code&amp;gt; and a &amp;lt;code&amp;gt;RemoteControl&amp;lt;/code&amp;gt; service, a component &amp;lt;code&amp;gt;RemoteTVImpl&amp;lt;/code&amp;gt; could simulate a remote TV system:&lt;br /&gt;
&lt;br /&gt;
[[Image:RemoteTVComponent.png|none|thumb|400px|RemoteTVImpl Component]]&lt;br /&gt;
&lt;br /&gt;
Such a &amp;lt;code&amp;gt;RemoteTV&amp;lt;/code&amp;gt; component could be a jar file or a shared library. It would contain two service implementations, &amp;lt;code&amp;gt;TVSet&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RemoteControl&amp;lt;/code&amp;gt;. Once the &amp;lt;code&amp;gt;RemoteTV&amp;lt;/code&amp;gt; component is registered with the global service manager, users can call the factory method of the service manager and ask for a &amp;lt;code&amp;gt;TVSet&amp;lt;/code&amp;gt; or a &amp;lt;code&amp;gt;RemoteControl&amp;lt;/code&amp;gt; service. Then they could use their functionality over the interfaces &amp;lt;code&amp;gt;XPower&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;XChannel&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;XStandby&amp;lt;/code&amp;gt;. When a new implementation of these services with better performance or new features is available later on, the old component can be replaced without breaking existing code, provided that the new features are introduced by adding interfaces.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Professional UNO]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/ProUNO/Interfaces&amp;diff=94534</id>
		<title>Documentation/DevGuide/ProUNO/Interfaces</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/ProUNO/Interfaces&amp;diff=94534"/>
		<updated>2008-10-05T19:34:47Z</updated>

		<summary type="html">&lt;p&gt;Cking: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/ProUNOTOC&lt;br /&gt;
|ProUNO2a=block&lt;br /&gt;
|ProUNO2aDTypes=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/ProUNO/The Any Type&lt;br /&gt;
|NextPage=Documentation/DevGuide/ProUNO/Services&lt;br /&gt;
}}&lt;br /&gt;
[[zh:Zh/Documentation/DevGuide/ProUNO/Interfaces]]&lt;br /&gt;
{{DISPLAYTITLE:Interfaces}}&lt;br /&gt;
&lt;br /&gt;
Communication between UNO objects is based on object interfaces. Interfaces can be seen from the outside or the inside of an object. &lt;br /&gt;
&lt;br /&gt;
From the &amp;#039;&amp;#039;outside&amp;#039;&amp;#039; of an object, an interface provides a functionality or special aspect of the object. Interfaces provide access to objects by publishing a set of operations that cover a certain aspect of an object &amp;#039;&amp;#039;without telling anything about its internals&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
The concept of interfaces is quite natural and frequently used in everyday life. Interfaces allow the creation of things that fit in with each other without knowing internal details about them. A power plug that fits into a standard socket or a one-size-fits-all working glove are simple examples. They all work by standardizing the minimal conditions that must be met to make things work together. &lt;br /&gt;
&lt;br /&gt;
A more advanced example would be the &amp;quot;remote control aspect&amp;quot; of a simple TV system. One possible feature of a TV system is a remote control. The remote control functions can be described by an &amp;lt;code&amp;gt;XPower&amp;lt;/code&amp;gt; and an &amp;lt;code&amp;gt;XChannel&amp;lt;/code&amp;gt; interface. The illustration below shows a &amp;lt;code&amp;gt;RemoteControl&amp;lt;/code&amp;gt; object with these interfaces:&lt;br /&gt;
&lt;br /&gt;
[[Image:RemoteControlImpl.png|none|thumb|350px|RemoteControl service]]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;XPower&amp;lt;/code&amp;gt; interface has the functions &amp;lt;code&amp;gt;turnOn()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;turnOff()&amp;lt;/code&amp;gt; to control the power and the &amp;lt;code&amp;gt;XChannel&amp;lt;/code&amp;gt; interface has the functions &amp;lt;code&amp;gt;select()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;next()&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;previous()&amp;lt;/code&amp;gt; to control the current channel. The user of these interfaces does not care if he uses an original remote control that came with a TV set or a universal remote control as long as it carries out these functions. The user is only dissatisfied if some of the functions promised by the interface do not work with a remote control.&lt;br /&gt;
&lt;br /&gt;
From the &amp;#039;&amp;#039;inside&amp;#039;&amp;#039; of an object, or from the perspective of someone who implements a UNO object, interfaces are abstract specifications. The abstract specification of all the interfaces in the {{PRODUCTNAME}} API has the advantage that user and implementer can enter into a contract, agreeing to adhere to the interface specification. A program that strictly uses the {{PRODUCTNAME}} API according to the specification will always work, while an implementer can do whatever he wants with his objects, as long as he serves the contract.&lt;br /&gt;
&lt;br /&gt;
UNO uses the &amp;lt;code&amp;gt;interface&amp;lt;/code&amp;gt; type to describe such aspects of UNO objects. By convention, all interface names start with the letter X to distinguish them from other types. All interface types must inherit the &amp;lt;idl&amp;gt;com.sun.star.uno.XInterface&amp;lt;/idl&amp;gt; root interface, either directly or in the inheritance hierarchy. &amp;lt;code&amp;gt;XInterface&amp;lt;/code&amp;gt; is explained in [[Documentation/DevGuide/ProUNO/Using UNO Interfaces|Using UNO Interfaces]]. The &amp;lt;code&amp;gt;interface&amp;lt;/code&amp;gt; types define &amp;#039;&amp;#039;methods&amp;#039;&amp;#039; (sometimes also called &amp;#039;&amp;#039;operations&amp;#039;&amp;#039;) to provide access to the specified UNO objects.&lt;br /&gt;
&lt;br /&gt;
Interfaces allow access to the data inside an object through dedicated methods (member functions) which encapsulate the data of the object. The methods always have a parameter list and a return value, and they may define exceptions for smart error handling. &lt;br /&gt;
&lt;br /&gt;
The exception concept in the OpenOffice.org API is comparable with the exception concepts known from Java or C++. All operations can raise &amp;lt;idls&amp;gt;com.sun.star.uno.RuntimeException&amp;lt;/idls&amp;gt; without explicit specification, but all other exceptions must be specified. UNO exceptions are explained in the section [[Documentation/DevGuide/ProUNO/Exception Handling|Exception Handling]].&lt;br /&gt;
&lt;br /&gt;
Consider the following two examples for interface definitions in UNOIDL (UNO Interface Definition Language) notation. UNOIDL interfaces resemble Java interfaces, and methods look similar to Java method signatures. However, note the flags in square brackets in the following example:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;// base interface for all UNO interfaces &lt;br /&gt;
  interface XInterface &lt;br /&gt;
  { &lt;br /&gt;
          any queryInterface( [in] type aType ); &lt;br /&gt;
          [oneway] void acquire(); &lt;br /&gt;
          [oneway] void release(); &lt;br /&gt;
  &lt;br /&gt;
  };  &lt;br /&gt;
  &lt;br /&gt;
  // fragment of the Interface com.sun.star.io.XInputStream &lt;br /&gt;
  &lt;br /&gt;
  interface XInputStream: com::sun::star::uno::XInterface &lt;br /&gt;
  {  &lt;br /&gt;
      long readBytes( [out] sequence&amp;lt;byte&amp;gt; aData, &lt;br /&gt;
                      [in] long nBytesToRead ) &lt;br /&gt;
                  raises( com::sun::star::io::NotConnectedException, &lt;br /&gt;
                          com::sun::star::io::BufferSizeExceededException, &lt;br /&gt;
                          com::sun::star::io::IOException); &lt;br /&gt;
      ... &lt;br /&gt;
  };  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The &amp;lt;code&amp;gt;[oneway]&amp;lt;/code&amp;gt; flag indicates that an operation can be executed asynchronously if the underlying method invocation system does support this feature. For example, a UNO Remote Protocol (URP) bridge is a system that supports oneway calls.&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Caution|Although there are no general problems with the specification and the implementation of the UNO &amp;lt;tt&amp;gt;oneway&amp;lt;/tt&amp;gt; feature, there are several API remote usage scenarios where &amp;lt;tt&amp;gt;oneway&amp;lt;/tt&amp;gt; calls cause deadlocks in {{PRODUCTNAME}}. Therefore, do not introduce new &amp;lt;tt&amp;gt;oneway&amp;lt;/tt&amp;gt; methods with new {{PRODUCTNAME}} UNO APIs.}}&lt;br /&gt;
&lt;br /&gt;
There are also parameter flags. Each parameter definition begins with one of the direction flags in, out, or inout to specify the use of the parameter:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;in&amp;lt;/code&amp;gt; specifies that the parameter will be used as an input parameter only&lt;br /&gt;
* &amp;lt;code&amp;gt;out&amp;lt;/code&amp;gt; specifies that the parameter will be used as an output parameter only&lt;br /&gt;
* &amp;lt;code&amp;gt;inout&amp;lt;/code&amp;gt; specifies that the parameter will be used as an input and output parameter&lt;br /&gt;
&lt;br /&gt;
These parameter flags do not appear in the API reference. The fact that a parameter is an &amp;lt;code&amp;gt;[out]&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;[inout]&amp;lt;/code&amp;gt; parameter is explained in the method details. &lt;br /&gt;
&lt;br /&gt;
Interfaces consisting of methods form the basis for service specifications.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Professional UNO]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Talk:Documentation/DevGuide/FirstSteps/Using_Services&amp;diff=94530</id>
		<title>Talk:Documentation/DevGuide/FirstSteps/Using Services</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Talk:Documentation/DevGuide/FirstSteps/Using_Services&amp;diff=94530"/>
		<updated>2008-10-05T19:22:05Z</updated>

		<summary type="html">&lt;p&gt;Cking: New page: I [http://msdn.microsoft.com/en-us/library/ms973861.aspx read] that &amp;quot;multiple-inheritance interfaces&amp;quot; is more properly called &amp;quot;multiple interface implementation&amp;quot;, so I made the change.--~~...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I [http://msdn.microsoft.com/en-us/library/ms973861.aspx read] that &amp;quot;multiple-inheritance interfaces&amp;quot; is more properly called &amp;quot;multiple interface implementation&amp;quot;, so I made the change.--[[User:Cking|Cking]] 21:22, 5 October 2008 (CEST)&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Using_Services&amp;diff=94529</id>
		<title>Documentation/DevGuide/FirstSteps/Using Services</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Using_Services&amp;diff=94529"/>
		<updated>2008-10-05T19:19:42Z</updated>

		<summary type="html">&lt;p&gt;Cking: Created &amp;quot;Multiple Interface Implementation&amp;quot; section out of what was on the page.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/FirstStepsTOC&lt;br /&gt;
|FirstSteps2b=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/FirstSteps/Objects, Interfaces, and Services&lt;br /&gt;
|NextPage=Documentation/DevGuide/FirstSteps/Example: Working with a Spreadsheet Document&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Using Services}}&lt;br /&gt;
The concepts of interfaces and services were introduced for the following reasons:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Interfaces and services separate specification from implementation&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: The specification of an interface or service is &amp;#039;&amp;#039;abstract&amp;#039;&amp;#039;, that is, it does not define how objects supporting a certain functionality do this &amp;#039;&amp;#039;internally&amp;#039;&amp;#039;. Through the abstract specification of the {{OOo}} API, it is possible to pull the implementation out from under the API and install a different implementation if required.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Service names allow to create instances by specification name, not by class names&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: In Java or C++ you use the new operator to create a class instance. This approach is restricted: the class you get is hard-coded. You cannot later on exchange it by another class without editing the code. The concept of services solves this. The central object factory in {{OOo}}, the global service manager, is asked to create an object that can be used for a certain purpose without defining its internal implementation. This is possible because a service can be ordered from the factory by its &amp;#039;&amp;#039;service name&amp;#039;&amp;#039; and the factory decides which service implementation it returns. Which implementation you get makes no difference, you only use the well-defined interface of the service.&lt;br /&gt;
&lt;br /&gt;
===Multiple Interface Implementation===&lt;br /&gt;
Abstract interfaces are more reusable if they are fine-grained, i.e., if they are small and describe only a single aspect of an object.  To describe the many aspects of an object, objects can implement more than one of these fine-grained interfaces.  This &amp;quot;multiple interface implementation&amp;quot; allows same aspects of similar objects accessed with the same code.  For example, many objects support text:  text may be found in the body of a document, in text frames, in headers and footers, footnotes, table cells, and in drawing shapes.  These objects all support the same interface, so a procedure can use, for example, getText() to retrieve text from &amp;#039;&amp;#039;any&amp;#039;&amp;#039; of them.  &lt;br /&gt;
&lt;br /&gt;
Services, interfaces, and methods are illustrated in the figure below for the old-style service &amp;lt;idl&amp;gt;com.sun.star.text.TextDocument&amp;lt;/idl&amp;gt;, shown using [http://en.wikipedia.org/wiki/Unified_Modeling_Language UML] notation.  In this figure, services are shown on the left side.  The arrow between services indicates that one service provided by the upper (arrowhead) service are inherited by the lower service.  Interfaces exported by these services are shown on the right.  All interface names in the {{OOo}} API start with an X, so as to be distinguishable from the names of other entities.   Each interface contains methods, which are listed beneath the interface.  &lt;br /&gt;
&lt;br /&gt;
[[Image:TextDocumentWithMethods.png|none|thumb|450px|Figure.  TextDocument inherits the methods of OfficeDocument.]]&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; object provides the &amp;lt;idl&amp;gt;com.sun.star.text.TextDocument&amp;lt;/idl&amp;gt; service, which implements the interfaces, &amp;lt;code&amp;gt;XTextDocument&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;XSearchable&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;XRefreshable&amp;lt;/code&amp;gt;.  These interfaces provide, for example, the methods &amp;lt;code&amp;gt;getText()&amp;lt;/code&amp;gt;, for adding text to a document, and &amp;lt;code&amp;gt;findAll()&amp;lt;/code&amp;gt;, for searching the document.  &lt;br /&gt;
&lt;br /&gt;
As indicated by the arrow, the &amp;lt;idl&amp;gt;com.sun.star.text.TextDocument&amp;lt;/idl&amp;gt; service also inherits all the interfaces provided by the &amp;lt;idl&amp;gt;com.sun.star.document.OfficeDocument&amp;lt;/idl&amp;gt; service, so these interfaces are also provided to a &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; object.  These interfaces handle tasks common to the {{OOo}} applications:  printing, &amp;lt;code&amp;gt;XPrintable&amp;lt;/code&amp;gt;; storing, &amp;lt;code&amp;gt;XStorable&amp;lt;/code&amp;gt;; modifying, &amp;lt;code&amp;gt;XModifiable&amp;lt;/code&amp;gt;; and model handling, &amp;lt;code&amp;gt;XModel&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The interfaces shown in the figure are only the mandatory interfaces of a &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; object. A &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; has optional properties and interfaces, among them the properties &amp;lt;code&amp;gt;CharacterCount&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ParagraphCount&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;WordCount&amp;lt;/code&amp;gt;, and the interface  &amp;lt;code&amp;gt;XPropertySet&amp;lt;/code&amp;gt;, which must be supported if properties are present at all. The implementation of the &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; service in {{OOo}} supports both required and all optional interfaces as well. The usage of a &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; is described thoroughly in [[Documentation/DevGuide/Text/Text Documents|Text Documents]].&lt;br /&gt;
&lt;br /&gt;
===Using Interfaces===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.uno.XInterface&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The fact that every UNO object must be accessed through its interfaces has an effect in languages like Java and C++, where the compiler needs the correct type of an object reference before you can call a method from it. In Java or C++, you normally just cast an object before you access an interface it implements. When working with UNO objects this is different: You must ask the UNO environment to get the appropriate reference for you whenever you want to access methods of an interface which your object supports, but your compiler does not yet know about. Only then you can cast it safely.&lt;br /&gt;
&lt;br /&gt;
The Java UNO environment has a method &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; for this purpose. It looks complicated at first sight, but once you understand that &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; is about safe casting of UNO types across process boundaries, you will soon get used to it. Take a look at the second example FirstLoadComponent.java (in the sample directory, if you have installed the SDK on your computer), where a new Desktop object is created and, afterwards, the &amp;lt;idlm&amp;gt;queryInterface&amp;lt;/idlm&amp;gt;() method is used to get the &amp;lt;idls&amp;gt;com.sun.star.frame.XComponentLoader&amp;lt;/idls&amp;gt; interface.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  Object desktop = xRemoteServiceManager.createInstanceWithContext(&lt;br /&gt;
                &amp;quot;com.sun.star.frame.Desktop&amp;quot;, xRemoteContext);&lt;br /&gt;
 &lt;br /&gt;
  XComponentLoader xComponentLoader = (XComponentLoader)&lt;br /&gt;
                UnoRuntime.queryInterface(XComponentLoader.class, desktop);&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We asked the service manager to create a &amp;lt;idl&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idl&amp;gt; using its factory method createInstanceWithContext(). This method is defined to return a Java Object type, which should not surprise you—after all the factory must be able to return any type:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  java.lang.Object createInstanceWithContext(String serviceName, XComponentContext context)&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The object we receive is a &amp;lt;idl&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idl&amp;gt; service.  The point is, while we know that the object we ordered at the factory is a DesktopUnoUrlResolver and exports among other interfaces the interface &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt;, the compiler does &amp;#039;&amp;#039;not&amp;#039;&amp;#039;. Therefore, we have to use the UNO runtime environment to ask or &amp;#039;&amp;#039;query&amp;#039;&amp;#039; for the interface &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt;, since we want to use the &amp;lt;code&amp;gt;loadComponentFromURL()&amp;lt;/code&amp;gt; method on this interface. The method &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; makes sure we get a reference that can be cast to the needed interface type, no matter if the target object is a local or a remote object. There are two &amp;lt;code&amp;gt;queryInterface&amp;lt;/code&amp;gt; definitions in the Java UNO language binding:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  java.lang.Object UnoRuntime.queryInterface(java.lang.Class targetInterface, Object sourceObject)&lt;br /&gt;
  java.lang.Object UnoRuntime.queryInterface(com.sun.star.uno.Type targetInterface, Object sourceObject)&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since &amp;lt;code&amp;gt;UnoRuntime.queryInterface()&amp;lt;/code&amp;gt; is specified to return a java.lang.Object just like the factory method &amp;lt;code&amp;gt;createInstanceWithContext()&amp;lt;/code&amp;gt;, we still must explicitly cast our interface reference to the needed type. The difference is that after &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; we can safely cast the object to our interface type and, most important, that the reference will now work even with an object in another process. Here is the &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; call, explained step by step:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  XComponentLoader xComponentLoader = (XComponentLoader)&lt;br /&gt;
                  UnoRuntime.queryInterface(XComponentLoader.class, desktop);&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt; is the interface we want to use, so we define a &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt; variable named &amp;lt;code&amp;gt;xComponentLoader&amp;lt;/code&amp;gt; (lower x) to store the interface we expect from &amp;lt;code&amp;gt;queryInterface&amp;lt;/code&amp;gt;. &lt;br /&gt;
Then we query our desktop object for the &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt; interface, passing in &amp;lt;code&amp;gt;XComponentLoader.class&amp;lt;/code&amp;gt; as target interface and desktop as source object. Finally we cast the outcome to &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt; and assign the resulting reference to our variable &amp;lt;code&amp;gt;xComponentLoader&amp;lt;/code&amp;gt;.&lt;br /&gt;
If the source object does not support the interface we are querying for, &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; will return null.&lt;br /&gt;
&lt;br /&gt;
In Java, this call to &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; is necessary whenever you have a reference to an object which is known to support an interface that you need, but you do not have the proper reference type yet. Fortunately, you are not only allowed to &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;java.lang.Object&amp;lt;/code&amp;gt; source types, but you may also query an interface from another interface reference, like this:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // loading a blank spreadsheet document gives us its XComponent interface:&lt;br /&gt;
  XComponent xComponent = xComponentLoader.loadComponentFromURL(&lt;br /&gt;
  &amp;quot;private:factory/scalc&amp;quot;, &amp;quot;_blank&amp;quot;, 0, loadProps);&lt;br /&gt;
  &lt;br /&gt;
  // now we query the interface XSpreadsheetDocument from xComponent&lt;br /&gt;
  XSpreadsheetDocument xSpreadsheetDocument = (XSpreadsheetDocument)UnoRuntime.queryInterface(&lt;br /&gt;
                  XSpreadsheetDocument.class, xComponent);  &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Furthermore, if a method is defined in such a way that it already returns an interface type, you do not need to query the interface, but you can use its methods right away. In the snippet above, the method &amp;lt;code&amp;gt;loadComponentFromURL&amp;lt;/code&amp;gt; is specified to return an &amp;lt;idl&amp;gt;com.sun.star.lang.XComponent&amp;lt;/idl&amp;gt; interface, so you may call the &amp;lt;code&amp;gt;XComponent&amp;lt;/code&amp;gt; methods &amp;lt;code&amp;gt;addEventListener()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;removeEventListener()&amp;lt;/code&amp;gt; directly at the &amp;lt;code&amp;gt;xComponent&amp;lt;/code&amp;gt; variable, if you want to be notified that the document is being closed.&lt;br /&gt;
The corresponding step in C++ is done by a &amp;lt;code&amp;gt;Reference&amp;lt;&amp;gt;&amp;lt;/code&amp;gt; template that takes the source instance as parameter:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // instantiate a sample service with the servicemanager.&lt;br /&gt;
  Reference&amp;lt; XInterface &amp;gt; rInstance =&lt;br /&gt;
  rServiceManager-&amp;gt;createInstanceWithContext( &lt;br /&gt;
  OUString::createFromAscii(&amp;quot;com.sun.star.frame.Desktop&amp;quot; ),&lt;br /&gt;
  rComponentContext );&lt;br /&gt;
  &lt;br /&gt;
  // Query for the XComponentLoader interface&lt;br /&gt;
  Reference&amp;lt; XComponentLoader &amp;gt; rComponentLoader( rInstance, UNO_QUERY );&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In {{OOo}} Basic, querying for interfaces is not necessary; the Basic runtime engine takes care of that internally.&lt;br /&gt;
With the proliferation of multiple-inheritance interfaces in the {{OOo}} API, there will be less of a demand to explicitly query for specific interfaces in Java or C++. For example, with the hypothetical interfaces&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  interface XBase1 {   void fun1();&lt;br /&gt;
  };&lt;br /&gt;
  interface XBase2 {&lt;br /&gt;
      void fun2();&lt;br /&gt;
  };&lt;br /&gt;
  interface XBoth { // inherits from both XBase1 and XBase2&lt;br /&gt;
      interface XBase1;&lt;br /&gt;
      interface XBase2;&lt;br /&gt;
  };&lt;br /&gt;
  interface XFactory {&lt;br /&gt;
      XBoth getBoth();};&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
you can directly call both &amp;lt;code&amp;gt;fun1()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;fun2()&amp;lt;/code&amp;gt; on a reference obtained through &amp;lt;code&amp;gt;XFactory.getBoth()&amp;lt;/code&amp;gt;, without querying for either &amp;lt;code&amp;gt;XBase1&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;XBase2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Using Properties===&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
An object must offer its properties through interfaces that allow you to work with properties. The most basic form of these interfaces is the interface &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idl&amp;gt;. There are other interfaces for properties, such as &amp;lt;idl&amp;gt;com.sun.star.beans.XMultiPropertySet&amp;lt;/idl&amp;gt;, that gets and sets a multitude of properties with a single method call. The &amp;lt;code&amp;gt;XPropertySet&amp;lt;/code&amp;gt; is always supported when properties are present in a service.&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;XPropertySet&amp;lt;/code&amp;gt;, two methods carry out the property access, which are defined in Java as follows: &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  void setPropertyValue(String propertyName, Object propertyValue)&lt;br /&gt;
  Object getPropertyValue(String propertyName)&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the FirstLoadComponent example, the &amp;lt;code&amp;gt;XPropertySet&amp;lt;/code&amp;gt; interface was used to set the CellStyle property at a cell object. The cell object was a &amp;lt;code&amp;gt;com.sun.star.sheet.SheetCell&amp;lt;/code&amp;gt; and therefore supports also the &amp;lt;code&amp;gt;com.sun.star.table.CellProperties&amp;lt;/code&amp;gt; service which had a property &amp;lt;code&amp;gt;CellStyle&amp;lt;/code&amp;gt;. The following code explains how this property was set:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // query the XPropertySet interface from cell object&lt;br /&gt;
  XPropertySet xCellProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xCell);&lt;br /&gt;
  &lt;br /&gt;
  // set the CellStyle property&lt;br /&gt;
  xCellProps.setPropertyValue(&amp;quot;CellStyle&amp;quot;, &amp;quot;Result&amp;quot;);&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
You are now ready to start working with a {{PRODUCTNAME}} document.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/First Steps]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Example:_Hello_Text,_Hello_Table,_Hello_Shape&amp;diff=94484</id>
		<title>Documentation/DevGuide/FirstSteps/Example: Hello Text, Hello Table, Hello Shape</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Example:_Hello_Text,_Hello_Table,_Hello_Shape&amp;diff=94484"/>
		<updated>2008-10-05T02:09:42Z</updated>

		<summary type="html">&lt;p&gt;Cking: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/FirstStepsTOC&lt;br /&gt;
|FirstSteps2c=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/FirstSteps/How do I know Which Type I Have?&lt;br /&gt;
|NextPage=Documentation/DevGuide/FirstSteps/Common Mechanisms for Text, Tables and Drawings&lt;br /&gt;
}}&lt;br /&gt;
[[zh:Zh/Documentation/DevGuide/FirstSteps/Example: Hello Text, Hello Table, Hello Shape]]&lt;br /&gt;
{{DISPLAYTITLE:Example: Hello Text, Hello Table, Hello Shape}}&lt;br /&gt;
The goal of this section is to give a brief overview of those mechanisms in the {{OOo}} API that are common to all document types. The three main application areas of {{OOo}} are text, tables and drawing shapes. The point is: texts, tables and drawing shapes can occur in all three document types, no matter if you are dealing with a Writer, Calc or Draw/Impress file, but they are treated in the same manner everywhere. When you master the common mechanisms, you will be able to insert and use texts, tables and drawings in all document types.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/First Steps]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Element_Access&amp;diff=94483</id>
		<title>Documentation/DevGuide/FirstSteps/Element Access</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Element_Access&amp;diff=94483"/>
		<updated>2008-10-05T02:05:06Z</updated>

		<summary type="html">&lt;p&gt;Cking: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/FirstStepsTOC&lt;br /&gt;
|FirstSteps2b=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/FirstSteps/Sequence&lt;br /&gt;
|NextPage=Documentation/DevGuide/FirstSteps/How do I know Which Type I Have?&lt;br /&gt;
}}&lt;br /&gt;
[[zh:Zh/Documentation/DevGuide/FirstSteps/Element Access]]&lt;br /&gt;
{{DISPLAYTITLE:Element Access}}&lt;br /&gt;
We have already seen in the section [[Documentation/DevGuide/FirstSteps/How to get Objects in OpenOffice.org|How to get Objects in OpenOffice.org]] that sets of objects can also be provided through element access methods. The three most important kinds of element access interfaces are &amp;lt;idl&amp;gt;com.sun.star.container.XNameContainer&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.container.XIndexContainer&amp;lt;/idl&amp;gt; and &amp;lt;idl&amp;gt;com.sun.star.container.XEnumeration&amp;lt;/idl&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The three element access interfaces are examples of how the fine-grained interfaces of the {{PRODUCTNAME}} API allow consistent object design.&lt;br /&gt;
&lt;br /&gt;
All three interfaces inherit from &amp;lt;code&amp;gt;XElementAccess&amp;lt;/code&amp;gt;; therefore, they include the methods&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  type getElementType()&lt;br /&gt;
  boolean hasElements()&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
for finding out basic information about a set of elements. The method &amp;lt;code&amp;gt;hasElements()&amp;lt;/code&amp;gt; tells whether or not a set contains any elements at all; the method &amp;lt;code&amp;gt;getElementType()&amp;lt;/code&amp;gt; tells which type a set contains. In Java and C++, you can get information about a UNO type through &amp;lt;code&amp;gt;com.sun.star.uno.Type&amp;lt;/code&amp;gt;, cf, the Java UNO and the C++ UNO reference.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;idl&amp;gt;com.sun.star.container.XIndexContainer&amp;lt;/idl&amp;gt; and &amp;lt;idl&amp;gt;com.sun.star.container.XNameContainer&amp;lt;/idl&amp;gt; interface have a parallel design. Consider both interfaces in UML notation.&lt;br /&gt;
&lt;br /&gt;
[[Image:XNameIndexContainer.png|none|thumb|400px|Indexed and Named Container]]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;XIndexAccess/XNameAccess&amp;lt;/code&amp;gt; interfaces are about getting an &amp;#039;&amp;#039;element&amp;#039;&amp;#039;. The &amp;lt;code&amp;gt;XIndexReplace/XNameReplace&amp;lt;/code&amp;gt; interfaces allow you to &amp;#039;&amp;#039;replace existing&amp;#039;&amp;#039; elements without changing the number of elements in the set, whereas the &amp;lt;code&amp;gt;XIndexContainer/XNameContainer&amp;lt;/code&amp;gt; interfaces allow you to &amp;#039;&amp;#039;increase and decrease the number of elements&amp;#039;&amp;#039; by inserting and removing elements.&lt;br /&gt;
&lt;br /&gt;
Many sets of named or indexed objects do not support the whole inheritance hierarchy of &amp;lt;code&amp;gt;XIndexContainer&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;XNameContainer&amp;lt;/code&amp;gt;, because the capabilities added by every subclass are not always logical for any set of elements.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;XEumerationAccess&amp;lt;/code&amp;gt; interface works differently from named and indexed containers below the &amp;lt;code&amp;gt;XElementAccess&amp;lt;/code&amp;gt; interface. &amp;lt;code&amp;gt;XEnumerationAccess&amp;lt;/code&amp;gt; does not provide single elements like &amp;lt;code&amp;gt;XNameAccess&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;XIndexAccess&amp;lt;/code&amp;gt;, but it creates an enumeration of objects which has methods to go to the next element as long as there are more elements.&lt;br /&gt;
 &lt;br /&gt;
[[Image:XEnumerationAccess.png|none|thumb|200px|Enumerated Container]]&lt;br /&gt;
&lt;br /&gt;
Sets of objects sometimes support all element access methods, some also support only name, index, or enumeration access. Always look up the various types in the API reference to see which access methods are available.&lt;br /&gt;
&lt;br /&gt;
For instance, the method &amp;lt;code&amp;gt;getSheets()&amp;lt;/code&amp;gt; at the interface &amp;lt;idl&amp;gt;com.sun.star.sheet.XSpreadsheetDocument&amp;lt;/idl&amp;gt; is specified to return a &amp;lt;idl&amp;gt;com.sun.star.sheet.XSpreadsheets&amp;lt;/idl&amp;gt; interface inherited from &amp;lt;code&amp;gt;XNameContainer&amp;lt;/code&amp;gt;. In addition, the API reference tells you that the provided object supports the &amp;lt;idl&amp;gt;com.sun.star.sheet.Spreadsheets&amp;lt;/idl&amp;gt; service, which defines additional element access interfaces besides &amp;lt;code&amp;gt;XSpreadsheets&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Examples that show how to work with &amp;lt;code&amp;gt;XNameAccess&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;XIndexAccess&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;XEnumerationAccess&amp;lt;/code&amp;gt; are provided below.&lt;br /&gt;
&lt;br /&gt;
===Name Access===&lt;br /&gt;
The basic interface which hands out elements by name is the &amp;lt;idl&amp;gt;com.sun.star.container.XNameAccess&amp;lt;/idl&amp;gt; interface. It has three methods:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  any getByName( [in] string name)&lt;br /&gt;
  sequence&amp;lt; string &amp;gt; getElementNames()&lt;br /&gt;
  boolean hasByName( [in] string name)&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the FirstLoadComponent.java example above, the method &amp;lt;code&amp;gt;getSheets()&amp;lt;/code&amp;gt; returned a &amp;lt;idl&amp;gt;com.sun.star.sheet.XSpreadsheets&amp;lt;/idl&amp;gt; interface, which inherits from &amp;lt;code&amp;gt;XNameAccess&amp;lt;/code&amp;gt;. Therefore, you could use &amp;lt;code&amp;gt;getByName()&amp;lt;/code&amp;gt; to obtain the sheet &amp;quot;MySheet&amp;quot; by name from the &amp;lt;code&amp;gt;XSpreadsheets&amp;lt;/code&amp;gt; container:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  XSpreadsheets xSpreadsheets = xSpreadsheetDocument.getSheets();&lt;br /&gt;
  &lt;br /&gt;
  Object sheet = xSpreadsheets.getByName(&amp;quot;MySheet&amp;quot;);&lt;br /&gt;
  XSpreadsheet xSpreadsheet = (XSpreadsheet)UnoRuntime.queryInterface(&lt;br /&gt;
            XSpreadsheet.class, sheet);&lt;br /&gt;
  &lt;br /&gt;
  // use XSpreadsheet interface to get the cell A1 at position 0,0 and enter 42 as value&lt;br /&gt;
  XCell xCell = xSpreadsheet.getCellByPosition(0, 0);&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since &amp;lt;code&amp;gt;getByName()&amp;lt;/code&amp;gt; returns an any, you have to use &amp;lt;code&amp;gt;AnyConverter.toObject()&amp;lt;/code&amp;gt; and/or &amp;lt;code&amp;gt;UnoRuntime.queryInterface()&amp;lt;(code&amp;gt; before you can call methods at the spreadsheet object.&lt;br /&gt;
&lt;br /&gt;
===Index Access===&lt;br /&gt;
The interface which hands out elements by index is the &amp;lt;idl&amp;gt;com.sun.star.container.XIndexAccess&amp;lt;/idl&amp;gt; interface. It has two methods:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  any getByIndex( [in] long index)&lt;br /&gt;
  long getCount()&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The FirstLoadComponent example allows to demonstrate &amp;lt;code&amp;gt;XIndexAccess&amp;lt;/code&amp;gt;. The API reference tells us that the service returned by &amp;lt;code&amp;gt;getSheets()&amp;lt;/code&amp;gt; is a &amp;lt;idl&amp;gt;com.sun.star.sheet.Spreadsheet&amp;lt;/idl&amp;gt; service and supports not only the interface &amp;lt;idl&amp;gt;com.sun.star.sheet.XSpreadsheets&amp;lt;/idl&amp;gt;, but &amp;lt;code&amp;gt;XIndexAccess&amp;lt;/code&amp;gt; as well. Therefore, the sheets could have been accessed by index and not just by name by performing a query for the &amp;lt;code&amp;gt;XIndexAccess&amp;lt;/code&amp;gt; interface from our &amp;lt;code&amp;gt;xSpreadsheets&amp;lt;/code&amp;gt; variable:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  XIndexAccess xSheetIndexAccess = (XIndexAccess)UnoRuntime.queryInterface(&lt;br /&gt;
             XIndexAccess.class, xSpreadsheets);&lt;br /&gt;
    &lt;br /&gt;
  Object sheet = XSheetIndexAccess.getByIndex(0);&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Enumeration Access===&lt;br /&gt;
The interface &amp;lt;idl&amp;gt;com.sun.star.container.XEnumerationAccess&amp;lt;/idl&amp;gt; creates enumerations that allow traveling across a set of objects. It has one method:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  com.sun.star.container.XEnumeration createEnumeration()&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The enumeration object gained from &amp;lt;code&amp;gt;createEnumeration()&amp;lt;/code&amp;gt; supports the interface &amp;lt;idl&amp;gt;com.sun.star.container.XEnumeration&amp;lt;/idl&amp;gt;. With this interface we can keep pulling elements out of the enumeration as long as it has more elements. &amp;lt;code&amp;gt;XEnumeration&amp;lt;/code&amp;gt; supplies the methods:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  booleanhasMoreElements()&lt;br /&gt;
  any nextElement()&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which are meant to build loops such as:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  while (xCells.hasMoreElements()) {&lt;br /&gt;
  &lt;br /&gt;
      Object cell = xCells.nextElement();&lt;br /&gt;
      // do something with cell &lt;br /&gt;
  }&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, in spreadsheets you have the opportunity to find out which cells contain formulas. The resulting set of cells is provided as &amp;lt;code&amp;gt;XEnumerationAccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
 &lt;br /&gt;
The interface that queries for cells with formulas is &amp;lt;idl&amp;gt;com.sun.star.sheet.XCellRangesQuery&amp;lt;/idl&amp;gt;, it defines (among others) a method&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  XSheetCellRanges queryContentCells(short cellFlags)&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which queries for cells having content as defined in the constants group &amp;lt;idl&amp;gt;com.sun.star.sheet.CellFlags&amp;lt;/idl&amp;gt;. One of these cell flags is &amp;lt;code&amp;gt;FORMULA&amp;lt;/code&amp;gt;. From &amp;lt;code&amp;gt;queryContentCells()&amp;lt;/code&amp;gt; we receive an object with an &amp;lt;idl&amp;gt;com.sun.star.sheet.XSheetCellRanges&amp;lt;/idl&amp;gt; interface, which has these methods:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  XEnumerationAccessgetCells()&lt;br /&gt;
  StringgetRangeAddressesAsString()&lt;br /&gt;
  sequence&amp;lt; com.sun.star.table.CellRangeAddress &amp;gt; getRangeAddresses()&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method &amp;lt;code&amp;gt;getCells()&amp;lt;/code&amp;gt; can be used to list all formula cells and the containing formulas in the spreadsheet document from our FirstLoadComponent example, utilizing &amp;lt;code&amp;gt;XEnumerationAccess&amp;lt;code&amp;gt;. &amp;lt;!--[SOURCE:FirstSteps/FirstLoadComponent.java]--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  XCellRangesQuery xCellQuery = (XCellRangesQuery)UnoRuntime.queryInterface(&lt;br /&gt;
      XCellRangesQuery.class, sheet);&lt;br /&gt;
  XSheetCellRanges xFormulaCells = xCellQuery.queryContentCells(&lt;br /&gt;
      (short)com.sun.star.sheet.CellFlags.FORMULA);&lt;br /&gt;
  &lt;br /&gt;
  XEnumerationAccess xFormulas = xFormulaCells.getCells();&lt;br /&gt;
  XEnumeration xFormulaEnum = xFormulas.createEnumeration();&lt;br /&gt;
  &lt;br /&gt;
  while (xFormulaEnum.hasMoreElements()) {&lt;br /&gt;
  &lt;br /&gt;
      Object formulaCell = xFormulaEnum.nextElement();&lt;br /&gt;
  &lt;br /&gt;
      // do something with formulaCell&lt;br /&gt;
      xCell = (XCell)UnoRuntime.queryInterface(XCell.class, formulaCell);&lt;br /&gt;
      XCellAddressable xCellAddress = (XCellAddressable)UnoRuntime.queryInterface(&lt;br /&gt;
          XCellAddressable.class, xCell);&lt;br /&gt;
      System.out.print(&amp;quot;Formula cell in column &amp;quot; + xCellAddress.getCellAddress().Column&lt;br /&gt;
          + &amp;quot;, row &amp;quot; + xCellAddress.getCellAddress().Row&lt;br /&gt;
          + &amp;quot; contains &amp;quot; + xCell.getFormula());&lt;br /&gt;
  }&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/First Steps]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Any&amp;diff=94474</id>
		<title>Documentation/DevGuide/FirstSteps/Any</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Any&amp;diff=94474"/>
		<updated>2008-10-05T01:46:31Z</updated>

		<summary type="html">&lt;p&gt;Cking: minor formatting&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/FirstStepsTOC&lt;br /&gt;
|FirstSteps2b=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/FirstSteps/Struct&lt;br /&gt;
|NextPage=Documentation/DevGuide/FirstSteps/Sequence&lt;br /&gt;
}}&lt;br /&gt;
[[zh:Zh/Documentation/DevGuide/FirstSteps/Any]]&lt;br /&gt;
{{DISPLAYTITLE:Any}}&lt;br /&gt;
The {{OOo}} API frequently uses an &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt; type, which is the counterpart of the &amp;lt;code&amp;gt;Variant&amp;lt;/code&amp;gt; type known from other environments. The &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt; type holds one arbitrary UNO type. The &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt; type is especially used in generic UNO interfaces.&lt;br /&gt;
&lt;br /&gt;
Examples for the occurrence of any are the method parameters and return values of the following, frequently used methods:&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=4 style=&amp;quot;border-collapse:collapse;&amp;quot;&lt;br /&gt;
|-bgcolor=#EDEDED&lt;br /&gt;
!Interface!!returning an any type!!colspan=&amp;quot;2&amp;quot;|taking an any type&lt;br /&gt;
|-&lt;br /&gt;
|XPropertySet||any getPropertyValue(string propertyName)||colspan=&amp;quot;2&amp;quot;|void setPropertyValue(any value)&lt;br /&gt;
|-&lt;br /&gt;
|XNameContainer||any getByName(string name)||void replaceByName(string name, any element)||void insertByName(string name, any element)&lt;br /&gt;
|-&lt;br /&gt;
|XIndexContainer||any getByIndex(long index)||void replaceByIndex(long index, any element)||void insertByIndex(long index, any element)&lt;br /&gt;
|-&lt;br /&gt;
|XEnumeration||any nextElement()||colspan=&amp;quot;2&amp;quot;|-&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt; type also occurs in the &amp;lt;idl&amp;gt;com.sun.star.beans.PropertyValue&amp;lt;/idl&amp;gt; struct. &lt;br /&gt;
&lt;br /&gt;
[[Image:PropertyValue.png|none|thumb|200px|PropertyValue]]&lt;br /&gt;
&lt;br /&gt;
This &amp;lt;code&amp;gt;struct&amp;lt;/code&amp;gt; has two member variables, &amp;lt;code&amp;gt;Name&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Value&amp;lt;/code&amp;gt;, and is ubiquitous in sets of &amp;lt;code&amp;gt;PropertyValue&amp;lt;/code&amp;gt; structs, where every &amp;lt;code&amp;gt;PropertyValue&amp;lt;/code&amp;gt; is a name-value pair that describes a property by name and value. If you need to set the value of such a &amp;lt;code&amp;gt;PropertyValue struct&amp;lt;/code&amp;gt;, you must assign an &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt; type, and you must be able to interpret the contained &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;, if you are reading from a &amp;lt;code&amp;gt;PropertyValue&amp;lt;/code&amp;gt;.  How this is done depends on your language.&lt;br /&gt;
&lt;br /&gt;
In Java, the &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt; type is mapped to &amp;lt;code&amp;gt;java.lang.Object&amp;lt;/code&amp;gt;, but there is also a special Java class &amp;lt;code&amp;gt;com.sun.star.uno.Any&amp;lt;/code&amp;gt;, mainly used in those cases where a plain &amp;lt;code&amp;gt;Object&amp;lt;/code&amp;gt; would be ambiguous. There are two simple rules of thumb to follow:&lt;br /&gt;
&lt;br /&gt;
: 1. When you are supposed to pass in an &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt; value, always pass in a &amp;lt;code&amp;gt;java.lang.Object&amp;lt;/code&amp;gt; or a Java UNO object.&lt;br /&gt;
&lt;br /&gt;
For instance, if you use &amp;lt;code&amp;gt;setPropertyValue()&amp;lt;/code&amp;gt; to set a property that has a non-interface type in the target object, you must pass in a &amp;lt;code&amp;gt;java.lang.Object&amp;lt;/code&amp;gt; for the new value. If the new value is of a primitive type in Java, use the corresponding &amp;lt;code&amp;gt;Object&amp;lt;/code&amp;gt; type for the primitive type:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  xCellProps.setPropertyValue(&amp;quot;CharWeight&amp;quot;, new Double(200.0));&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another example would be a &amp;lt;code&amp;gt;PropertyValue&amp;lt;/code&amp;gt; struct you want to use for &amp;lt;code&amp;gt;loadComponentFromURL&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  com.sun.star.beans.PropertyValue aProperty = new com.sun.star.beans.PropertyValue();&lt;br /&gt;
  aProperty.Name = &amp;quot;ReadOnly&amp;quot;;&lt;br /&gt;
  aProperty.Value = Boolean.TRUE;&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: 2. When you &amp;#039;&amp;#039;receive&amp;#039;&amp;#039; an &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt; instance, always use the &amp;lt;code&amp;gt;com.sun.star.uno.AnyConverter&amp;lt;/code&amp;gt; to retrieve its value.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;AnyConverter&amp;lt;/code&amp;gt; requires a closer look. For instance, if you want to get a property which contains a primitive Java type, you must be aware that &amp;lt;code&amp;gt;getPropertyValue()&amp;lt;/code&amp;gt; returns a &amp;lt;code&amp;gt;java.lang.Object&amp;lt;/code&amp;gt; containing your primitive type wrapped in an any value. The &amp;lt;code&amp;gt;com.sun.star.uno.AnyConverter&amp;lt;/code&amp;gt; is a converter for such objects. Actually it can do more than just conversion, you can find its specification in the Java UNO reference. The following list sums up the conversion functions in the &amp;lt;code&amp;gt;AnyConverter&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  static java.lang.Object toArray(java.lang.Object object)&lt;br /&gt;
  static boolean toBoolean(java.lang.Object object) &lt;br /&gt;
  static byte toByte(java.lang.Object object) &lt;br /&gt;
  static char toChar(java.lang.Object object) &lt;br /&gt;
  static double toDouble(java.lang.Object object) &lt;br /&gt;
  static float toFloat(java.lang.Object object) &lt;br /&gt;
  static int toInt(java.lang.Object object) &lt;br /&gt;
  static long toLong(java.lang.Object object) &lt;br /&gt;
  static java.lang.Object toObject(Class clazz, java.lang.Object object) &lt;br /&gt;
  static java.lang.Object toObject(Type type, java.lang.Object object) &lt;br /&gt;
  static short toShort(java.lang.Object object) &lt;br /&gt;
  static java.lang.String toString(java.lang.Object object) &lt;br /&gt;
  static Type toType(java.lang.Object object)&lt;br /&gt;
  static int toUnsignedInt(java.lang.Object object)&lt;br /&gt;
  static long toUnsignedLong(java.lang.Object object)&lt;br /&gt;
  static short toUnsignedShort(java.lang.Object object)&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Its usage is straightforward:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  import com.sun.star.uno.AnyConverter;&lt;br /&gt;
  long cellColor = AnyConverter.toLong(xCellProps.getPropertyValue(&amp;quot;CharColor&amp;quot;));&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For convenience, for interface types you can directly use &amp;lt;code&amp;gt;UnoRuntime.queryInterface()&amp;lt;/code&amp;gt; without first calling &amp;lt;code&amp;gt;AnyConverter.getObject()&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  import com.sun.star.uno.AnyConverter;import com.sun.star.uno.UnoRuntime;&lt;br /&gt;
  Object ranges = xSpreadsheet.getPropertyValue(&amp;quot;NamedRanges&amp;quot;);&lt;br /&gt;
  XNamedRanges ranges1 = (XNamedRanges) UnoRuntime.queryInterface(&lt;br /&gt;
      XNamedRanges.class, AnyConverter.toObject(XNamedRanges.class, r));&lt;br /&gt;
  XNamedRanges ranges2 = (XNamedRanges) UnoRuntime.queryInterface(   XNamedRanges.class, r);&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In {{OOo}} Basic, the &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt; type becomes a Variant:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;vb&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;#039;OpenOffice.org Basic&lt;br /&gt;
  Dim cellColor as Variant&lt;br /&gt;
  cellColor = oCellProps.CharColor&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In C++, there are special operators for the &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt; type:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  //C++ has &amp;gt;&amp;gt;= and &amp;lt;&amp;lt;= for Any (the pointed brackets are always left)&lt;br /&gt;
  sal_Int32 cellColor;&lt;br /&gt;
  Any any;&lt;br /&gt;
  any = rCellProps-&amp;gt;getPropertyValue(OUString::createFromAscii( &amp;quot;CharColor&amp;quot; ));&lt;br /&gt;
  // extract the value from any&lt;br /&gt;
  any &amp;gt;&amp;gt;= cellColor;&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/First Steps]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Struct&amp;diff=94473</id>
		<title>Documentation/DevGuide/FirstSteps/Struct</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Struct&amp;diff=94473"/>
		<updated>2008-10-05T01:33:41Z</updated>

		<summary type="html">&lt;p&gt;Cking: Changed starbasic to OOo Basic&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/FirstStepsTOC&lt;br /&gt;
|FirstSteps2b=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/FirstSteps/Common Types&lt;br /&gt;
|NextPage=Documentation/DevGuide/FirstSteps/Any&lt;br /&gt;
}}&lt;br /&gt;
[[zh:Zh/Documentation/DevGuide/FirstSteps/Struct]]&lt;br /&gt;
{{DISPLAYTITLE:Struct}}&lt;br /&gt;
Structs in the {{OOo}} API are used to create compounds of other UNO types. They correspond to C structs or Java classes consisting of public member variables only.&lt;br /&gt;
While structs do not encapsulate data, they are easier to transport as a whole, instead of marshaling &amp;lt;code&amp;gt;get()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;set()&amp;lt;/code&amp;gt; calls back and forth. In particular, this has advantages for remote communication.&lt;br /&gt;
&lt;br /&gt;
You gain access to struct members through the . (dot) operator as in &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  aProperty.Name = &amp;quot;ReadOnly&amp;quot;;&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Java, C++ and {{OOo}} Basic, the keyword new instantiates structs. In OLE automation, use &amp;lt;idl&amp;gt;com.sun.star.reflection.CoreReflection&amp;lt;/idl&amp;gt; to get a UNO struct. Do not use the service manager to create structs.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  //In Java:&lt;br /&gt;
  com.sun.star.beans.PropertyValue aProperty &lt;br /&gt;
             = new com.sun.star.beans.PropertyValue();&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;vb&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;#039;In OpenOffice.org Basic&lt;br /&gt;
  Dim aProperty as new com.sun.star.beans.PropertyValue&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/First Steps]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Using_Services&amp;diff=94472</id>
		<title>Documentation/DevGuide/FirstSteps/Using Services</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Using_Services&amp;diff=94472"/>
		<updated>2008-10-05T01:22:19Z</updated>

		<summary type="html">&lt;p&gt;Cking: Reworded from the paragraph before the 1st figure through &amp;quot;Using Interfaces&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/FirstStepsTOC&lt;br /&gt;
|FirstSteps2b=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/FirstSteps/Objects, Interfaces, and Services&lt;br /&gt;
|NextPage=Documentation/DevGuide/FirstSteps/Example: Working with a Spreadsheet Document&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Using Services}}&lt;br /&gt;
The concepts of interfaces and services were introduced for the following reasons:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Interfaces and services separate specification from implementation&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: The specification of an interface or service is &amp;#039;&amp;#039;abstract&amp;#039;&amp;#039;, that is, it does not define how objects supporting a certain functionality do this &amp;#039;&amp;#039;internally&amp;#039;&amp;#039;. Through the abstract specification of the {{OOo}} API, it is possible to pull the implementation out from under the API and install a different implementation if required.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Service names allow to create instances by specification name, not by class names&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: In Java or C++ you use the new operator to create a class instance. This approach is restricted: the class you get is hard-coded. You cannot later on exchange it by another class without editing the code. The concept of services solves this. The central object factory in {{OOo}} the global service manager, is asked to create an object that can be used for a certain purpose without defining its internal implementation. This is possible, because a service can be ordered from the factory by its &amp;#039;&amp;#039;service name&amp;#039;&amp;#039; and the factory decides which service implementation it returns. Which implementation you get makes no difference, you only use the well-defined interface of the service.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Multiple-inheritance interfaces make fine-grained interfaces manageable&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: Abstract interfaces are more reusable if they are fine-grained, i.e., if they are small and describe only one aspect of an object, not several aspects. But then you need many of them to describe a useful object. Multiple-inheritance interfaces allow to have fine-grained interfaces on the one hand and to manage them easily by forging them into a collection. Since it is quite probable that objects in an office environment will share many aspects, this fine granularity allows the interfaces to be reused and thus to get objects that behave consistently. For instance, it was possible to realize a unified way to handle text, no matter if you are dealing with body text, text frames, header or footer text, footnotes, table cells or text in drawing shapes. It was not necessary to define separate interfaces for all of these purposes.&lt;br /&gt;
&lt;br /&gt;
How services, interfaces, and inheritance interact is illustrated by the old-style service &amp;lt;idl&amp;gt;com.sun.star.text.TextDocument&amp;lt;/idl&amp;gt;, shown using [http://en.wikipedia.org/wiki/Unified_Modeling_Language UML] notation in the figure below.  In this figure, services are shown on the left side.  The arrow between services indicates that services provided by the upper (arrowhead) service are passed on to the lower service.  Interfaces exported by these services are shown on the right.  All interface names in the {{OOo}} API start with an X, so as to be distinguishable from the names of other entities.   Each interface contains methods, which are listed beneath the interface.  &lt;br /&gt;
&lt;br /&gt;
[[Image:TextDocumentWithMethods.png|none|thumb|450px|Figure.  TextDocument inherits the methods of OfficeDocument.]]&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; object provides the &amp;lt;idl&amp;gt;com.sun.star.text.TextDocument&amp;lt;/idl&amp;gt; service, which provides the interfaces, &amp;lt;code&amp;gt;XTextDocument&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;XSearchable&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;XRefreshable&amp;lt;/code&amp;gt;.  These interfaces provide, for example, the methods &amp;lt;code&amp;gt;getText()&amp;lt;/code&amp;gt;, for adding text to a document, and &amp;lt;code&amp;gt;findAll()&amp;lt;/code&amp;gt;, for searching the document.  &lt;br /&gt;
&lt;br /&gt;
As indicated by the arrow, the &amp;lt;idl&amp;gt;com.sun.star.text.TextDocument&amp;lt;/idl&amp;gt; service also includes all the interfaces provided by the &amp;lt;idl&amp;gt;com.sun.star.document.OfficeDocument&amp;lt;/idl&amp;gt; service, so these interfaces are also provided to a &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; object.  These interfaces handle tasks common to the {{OOo}} applications:  printing, &amp;lt;code&amp;gt;XPrintable&amp;lt;/code&amp;gt;; storing, &amp;lt;code&amp;gt;XStorable&amp;lt;/code&amp;gt;; modifying, &amp;lt;code&amp;gt;XModifiable&amp;lt;/code&amp;gt;; and model handling, &amp;lt;code&amp;gt;XModel&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The interfaces shown in the figure are only the mandatory interfaces of a &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; object. A &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; has optional properties and interfaces, among them the properties &amp;lt;code&amp;gt;CharacterCount&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ParagraphCount&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;WordCount&amp;lt;/code&amp;gt;, and the interface  &amp;lt;code&amp;gt;XPropertySet&amp;lt;/code&amp;gt;, which must be supported if properties are present at all. The implementation of the &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; service in {{OOo}} supports both required and all optional interfaces as well. The usage of a &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; is described thoroughly in [[Documentation/DevGuide/Text/Text Documents|Text Documents]].&lt;br /&gt;
&lt;br /&gt;
===Using Interfaces===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.uno.XInterface&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The fact that every UNO object must be accessed through its interfaces has an effect in languages like Java and C++, where the compiler needs the correct type of an object reference before you can call a method from it. In Java or C++, you normally just cast an object before you access an interface it implements. When working with UNO objects this is different: You must ask the UNO environment to get the appropriate reference for you whenever you want to access methods of an interface which your object supports, but your compiler does not yet know about. Only then you can cast it safely.&lt;br /&gt;
&lt;br /&gt;
The Java UNO environment has a method &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; for this purpose. It looks complicated at first sight, but once you understand that &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; is about safe casting of UNO types across process boundaries, you will soon get used to it. Take a look at the second example FirstLoadComponent.java (in the sample directory, if you have installed the SDK on your computer), where a new Desktop object is created and, afterwards, the &amp;lt;idlm&amp;gt;queryInterface&amp;lt;/idlm&amp;gt;() method is used to get the &amp;lt;idls&amp;gt;com.sun.star.frame.XComponentLoader&amp;lt;/idls&amp;gt; interface.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  Object desktop = xRemoteServiceManager.createInstanceWithContext(&lt;br /&gt;
                &amp;quot;com.sun.star.frame.Desktop&amp;quot;, xRemoteContext);&lt;br /&gt;
 &lt;br /&gt;
  XComponentLoader xComponentLoader = (XComponentLoader)&lt;br /&gt;
                UnoRuntime.queryInterface(XComponentLoader.class, desktop);&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We asked the service manager to create a &amp;lt;idl&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idl&amp;gt; using its factory method createInstanceWithContext(). This method is defined to return a Java Object type, which should not surprise you—after all the factory must be able to return any type:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  java.lang.Object createInstanceWithContext(String serviceName, XComponentContext context)&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The object we receive is a &amp;lt;idl&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idl&amp;gt; service.&lt;br /&gt;
&lt;br /&gt;
The following figure  is a simplified specification in UML notation showing the relation to the &amp;lt;idl&amp;gt;com.sun.star.frame.Frame&amp;lt;/idl&amp;gt; service and the supported interfaces.The point is, while we know that the object we ordered at the factory is a DesktopUnoUrlResolver and exports among other interfaces the interface &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt;, the compiler does &amp;#039;&amp;#039;not&amp;#039;&amp;#039;. Therefore, we have to use the UNO runtime environment to ask or &amp;#039;&amp;#039;query&amp;#039;&amp;#039; for the interface &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt;, since we want to use the &amp;lt;code&amp;gt;loadComponentFromURL()&amp;lt;/code&amp;gt; method on this interface. The method &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; makes sure we get a reference that can be cast to the needed interface type, no matter if the target object is a local or a remote object. There are two &amp;lt;code&amp;gt;queryInterface&amp;lt;/code&amp;gt; definitions in the Java UNO language binding:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  java.lang.Object UnoRuntime.queryInterface(java.lang.Class targetInterface, Object sourceObject)&lt;br /&gt;
  java.lang.Object UnoRuntime.queryInterface(com.sun.star.uno.Type targetInterface, Object sourceObject)&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since &amp;lt;code&amp;gt;UnoRuntime.queryInterface()&amp;lt;/code&amp;gt; is specified to return a java.lang.Object just like the factory method &amp;lt;code&amp;gt;createInstanceWithContext()&amp;lt;/code&amp;gt;, we still must explicitly cast our interface reference to the needed type. The difference is that after &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; we can safely cast the object to our interface type and, most important, that the reference will now work even with an object in another process. Here is the &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; call, explained step by step:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  XComponentLoader xComponentLoader = (XComponentLoader)&lt;br /&gt;
                  UnoRuntime.queryInterface(XComponentLoader.class, desktop);&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt; is the interface we want to use, so we define a &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt; variable named &amp;lt;code&amp;gt;xComponentLoader&amp;lt;/code&amp;gt; (lower x) to store the interface we expect from &amp;lt;code&amp;gt;queryInterface&amp;lt;/code&amp;gt;. &lt;br /&gt;
Then we query our desktop object for the &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt; interface, passing in &amp;lt;code&amp;gt;XComponentLoader.class&amp;lt;/code&amp;gt; as target interface and desktop as source object. Finally we cast the outcome to &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt; and assign the resulting reference to our variable &amp;lt;code&amp;gt;xComponentLoader&amp;lt;/code&amp;gt;.&lt;br /&gt;
If the source object does not support the interface we are querying for, &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; will return null.&lt;br /&gt;
&lt;br /&gt;
In Java, this call to &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; is necessary whenever you have a reference to an object which is known to support an interface that you need, but you do not have the proper reference type yet. Fortunately, you are not only allowed to &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;java.lang.Object&amp;lt;/code&amp;gt; source types, but you may also query an interface from another interface reference, like this:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // loading a blank spreadsheet document gives us its XComponent interface:&lt;br /&gt;
  XComponent xComponent = xComponentLoader.loadComponentFromURL(&lt;br /&gt;
  &amp;quot;private:factory/scalc&amp;quot;, &amp;quot;_blank&amp;quot;, 0, loadProps);&lt;br /&gt;
  &lt;br /&gt;
  // now we query the interface XSpreadsheetDocument from xComponent&lt;br /&gt;
  XSpreadsheetDocument xSpreadsheetDocument = (XSpreadsheetDocument)UnoRuntime.queryInterface(&lt;br /&gt;
                  XSpreadsheetDocument.class, xComponent);  &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Furthermore, if a method is defined in such a way that it already returns an interface type, you do not need to query the interface, but you can use its methods right away. In the snippet above, the method &amp;lt;code&amp;gt;loadComponentFromURL&amp;lt;/code&amp;gt; is specified to return an &amp;lt;idl&amp;gt;com.sun.star.lang.XComponent&amp;lt;/idl&amp;gt; interface, so you may call the &amp;lt;code&amp;gt;XComponent&amp;lt;/code&amp;gt; methods &amp;lt;code&amp;gt;addEventListener()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;removeEventListener()&amp;lt;/code&amp;gt; directly at the &amp;lt;code&amp;gt;xComponent&amp;lt;/code&amp;gt; variable, if you want to be notified that the document is being closed.&lt;br /&gt;
The corresponding step in C++ is done by a &amp;lt;code&amp;gt;Reference&amp;lt;&amp;gt;&amp;lt;/code&amp;gt; template that takes the source instance as parameter:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // instantiate a sample service with the servicemanager.&lt;br /&gt;
  Reference&amp;lt; XInterface &amp;gt; rInstance =&lt;br /&gt;
  rServiceManager-&amp;gt;createInstanceWithContext( &lt;br /&gt;
  OUString::createFromAscii(&amp;quot;com.sun.star.frame.Desktop&amp;quot; ),&lt;br /&gt;
  rComponentContext );&lt;br /&gt;
  &lt;br /&gt;
  // Query for the XComponentLoader interface&lt;br /&gt;
  Reference&amp;lt; XComponentLoader &amp;gt; rComponentLoader( rInstance, UNO_QUERY );&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In {{OOo}} Basic, querying for interfaces is not necessary; the Basic runtime engine takes care of that internally.&lt;br /&gt;
With the proliferation of multiple-inheritance interfaces in the {{OOo}} API, there will be less of a demand to explicitly query for specific interfaces in Java or C++. For example, with the hypothetical interfaces&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  interface XBase1 {   void fun1();&lt;br /&gt;
  };&lt;br /&gt;
  interface XBase2 {&lt;br /&gt;
      void fun2();&lt;br /&gt;
  };&lt;br /&gt;
  interface XBoth { // inherits from both XBase1 and XBase2&lt;br /&gt;
      interface XBase1;&lt;br /&gt;
      interface XBase2;&lt;br /&gt;
  };&lt;br /&gt;
  interface XFactory {&lt;br /&gt;
      XBoth getBoth();};&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
you can directly call both &amp;lt;code&amp;gt;fun1()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;fun2()&amp;lt;/code&amp;gt; on a reference obtained through &amp;lt;code&amp;gt;XFactory.getBoth()&amp;lt;/code&amp;gt;, without querying for either &amp;lt;code&amp;gt;XBase1&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;XBase2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Using Properties===&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
An object must offer its properties through interfaces that allow you to work with properties. The most basic form of these interfaces is the interface &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idl&amp;gt;. There are other interfaces for properties, such as &amp;lt;idl&amp;gt;com.sun.star.beans.XMultiPropertySet&amp;lt;/idl&amp;gt;, that gets and sets a multitude of properties with a single method call. The &amp;lt;code&amp;gt;XPropertySet&amp;lt;/code&amp;gt; is always supported when properties are present in a service.&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;XPropertySet&amp;lt;/code&amp;gt;, two methods carry out the property access, which are defined in Java as follows: &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  void setPropertyValue(String propertyName, Object propertyValue)&lt;br /&gt;
  Object getPropertyValue(String propertyName)&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the FirstLoadComponent example, the &amp;lt;code&amp;gt;XPropertySet&amp;lt;/code&amp;gt; interface was used to set the CellStyle property at a cell object. The cell object was a &amp;lt;code&amp;gt;com.sun.star.sheet.SheetCell&amp;lt;/code&amp;gt; and therefore supports also the &amp;lt;code&amp;gt;com.sun.star.table.CellProperties&amp;lt;/code&amp;gt; service which had a property &amp;lt;code&amp;gt;CellStyle&amp;lt;/code&amp;gt;. The following code explains how this property was set:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // query the XPropertySet interface from cell object&lt;br /&gt;
  XPropertySet xCellProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xCell);&lt;br /&gt;
  &lt;br /&gt;
  // set the CellStyle property&lt;br /&gt;
  xCellProps.setPropertyValue(&amp;quot;CellStyle&amp;quot;, &amp;quot;Result&amp;quot;);&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
You are now ready to start working with a {{PRODUCTNAME}} document.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/First Steps]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/How_to_get_Objects_in_OpenOffice.org&amp;diff=94471</id>
		<title>Documentation/DevGuide/FirstSteps/How to get Objects in OpenOffice.org</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/How_to_get_Objects_in_OpenOffice.org&amp;diff=94471"/>
		<updated>2008-10-05T01:07:55Z</updated>

		<summary type="html">&lt;p&gt;Cking: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/FirstStepsTOC&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/FirstSteps/First Contact&lt;br /&gt;
|NextPage=Documentation/DevGuide/FirstSteps/Working with Objects&lt;br /&gt;
}}&lt;br /&gt;
[[zh:Zh/Documentation/DevGuide/FirstSteps/How to get Objects in OpenOffice.org]]&lt;br /&gt;
{{DISPLAYTITLE:How to get Objects in OpenOffice.org}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
An &amp;#039;&amp;#039;object&amp;#039;&amp;#039; in our context is a software artifact that has methods you can call. Objects are required to do something with {{PRODUCTNAME}}. But where do you obtain them?&lt;br /&gt;
&lt;br /&gt;
===New objects===&lt;br /&gt;
In general, new objects or objects which are necessary for a first access are created by &amp;#039;&amp;#039;service managers&amp;#039;&amp;#039; in {{PRODUCTNAME}}. In the &amp;lt;code&amp;gt;FirstLoadComponent&amp;lt;/code&amp;gt; example, the remote service manager creates the remote &amp;lt;code&amp;gt;Desktop&amp;lt;/code&amp;gt; object, which handles application windows and loaded documents in {{PRODUCTNAME}}: &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  Object desktop = xRemoteServiceManager.createInstanceWithContext(&lt;br /&gt;
                   &amp;quot;com.sun.star.frame.Desktop&amp;quot;, xRemoteContext);&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Document objects===&lt;br /&gt;
Document objects represent the files that are opened with {{PRODUCTNAME}}. They are created by the &amp;lt;code&amp;gt;Desktop&amp;lt;/code&amp;gt; object, which has a &amp;lt;code&amp;gt;loadComponentFromURL()&amp;lt;/code&amp;gt; method for this purpose.&lt;br /&gt;
&lt;br /&gt;
===Objects that are provided by other objects===&lt;br /&gt;
Objects can hand out other objects. There are two cases:&lt;br /&gt;
&lt;br /&gt;
* Features which are designed to be an integral part of the object that provides the feature can be obtained by get methods in the {{PRODUCTNAME}} API. It is common to get an object from a get method. For instance, &amp;lt;code&amp;gt;getSheets()&amp;lt;/code&amp;gt; is required for every Calc document, &amp;lt;code&amp;gt;getText()&amp;lt;/code&amp;gt; is essential for every Writer Document and &amp;lt;code&amp;gt;getDrawpages()&amp;lt;/code&amp;gt; is an essential part of every Draw document. After loading a document, these methods are used to get the Sheets, Text and Drawpages object of the corresponding document. Object-specific get methods are an important technique to get objects.&lt;br /&gt;
&lt;br /&gt;
* Features which are not considered integral for the architecture of an object are accessible through a set of universal methods. In the {{PRODUCTNAME}} API, these features are called properties, and generic methods are used, such as &amp;lt;code&amp;gt;getPropertyValue(String propertyName)&amp;lt;/code&amp;gt; to access them. In some cases such a non-integral feature is provided as an object, therefore the method &amp;lt;code&amp;gt;getPropertyValue()&amp;lt;/code&amp;gt; can be another source for objects. For instance, page styles for spreadsheets have the properties &amp;lt;code&amp;gt;&amp;quot;RightPageHeaderContent&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;quot;LeftPageHeaderContent&amp;quot;&amp;lt;/code&amp;gt;, that contain objects for the page header sections of a spreadsheet document. The generic &amp;lt;code&amp;gt;getPropertyValue()&amp;lt;/code&amp;gt; method can sometimes provide an object you need.&lt;br /&gt;
&lt;br /&gt;
===Sets of objects===&lt;br /&gt;
Objects can be elements in a set of similar objects. In sets, to access an object you need to know how to get a particular element from the set. The {{PRODUCTNAME}} API allows four ways to provide an element in a set. The first three ways are objects with element access methods that allow access by name, index, or enumeration. The fourth way is a sequence of elements which has no access methods but can be used as an array directly. How these sets of elements are used will be discussed later.&lt;br /&gt;
&lt;br /&gt;
The designer of an object decides which of those opportunities to offer, based on special conditions of the object, such as how it performs remotely or which access methods best work with implementation.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/First Steps]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Using_Services&amp;diff=94466</id>
		<title>Documentation/DevGuide/FirstSteps/Using Services</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Using_Services&amp;diff=94466"/>
		<updated>2008-10-04T22:18:23Z</updated>

		<summary type="html">&lt;p&gt;Cking: Worked on readability.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/FirstStepsTOC&lt;br /&gt;
|FirstSteps2b=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/FirstSteps/Objects, Interfaces, and Services&lt;br /&gt;
|NextPage=Documentation/DevGuide/FirstSteps/Example: Working with a Spreadsheet Document&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Using Services}}&lt;br /&gt;
The concepts of interfaces and services were introduced for the following reasons:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Interfaces and services separate specification from implementation&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: The specification of an interface or service is &amp;#039;&amp;#039;abstract&amp;#039;&amp;#039;, that is, it does not define how objects supporting a certain functionality do this &amp;#039;&amp;#039;internally&amp;#039;&amp;#039;. Through the abstract specification of the {{PRODUCTNAME}} API, it is possible to pull the implementation out from under the API and install a different implementation if required.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Service names allow to create instances by specification name, not by class names&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: In Java or C++ you use the new operator to create a class instance. This approach is restricted: the class you get is hard-coded. You cannot later on exchange it by another class without editing the code. The concept of services solves this. The central object factory in {{PRODUCTNAME}} the global service manager, is asked to create an object that can be used for a certain purpose without defining its internal implementation. This is possible, because a service can be ordered from the factory by its &amp;#039;&amp;#039;service name&amp;#039;&amp;#039; and the factory decides which service implementation it returns. Which implementation you get makes no difference, you only use the well-defined interface of the service.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Multiple-inheritance interfaces make fine-grained interfaces manageable&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: Abstract interfaces are more reusable if they are fine-grained, i.e., if they are small and describe only one aspect of an object, not several aspects. But then you need many of them to describe a useful object. Multiple-inheritance interfaces allow to have fine-grained interfaces on the one hand and to manage them easily by forging them into a collection. Since it is quite probable that objects in an office environment will share many aspects, this fine granularity allows the interfaces to be reused and thus to get objects that behave consistently. For instance, it was possible to realize a unified way to handle text, no matter if you are dealing with body text, text frames, header or footer text, footnotes, table cells or text in drawing shapes. It was not necessary to define separate interfaces for all of these purposes.&lt;br /&gt;
&lt;br /&gt;
Let us consider the old-style service &amp;lt;idl&amp;gt;com.sun.star.text.TextDocument&amp;lt;/idl&amp;gt; in UML notation. A &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; service has mandatory interfaces, all of which are depicted in the [http://en.wikipedia.org/wiki/Unified_Modeling_Language UML] chart, below. These interfaces express the basic aspects of a text document in {{PRODUCTNAME}}:  it contains text; it is searchable and refreshable; it is a model with URL and controller; and it is modifiable, printable and storable. The UML chart shows how this is specified in the API.&lt;br /&gt;
&lt;br /&gt;
[[Image:TextDocumentWithMethods.png|none|thumb|400px|Text Document]]&lt;br /&gt;
&lt;br /&gt;
Every &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; object includes, by definition, the services &amp;lt;idl&amp;gt;com.sun.star.text.TextDocument&amp;lt;/idl&amp;gt; and &amp;lt;idl&amp;gt;com.sun.star.document.OfficeDocument&amp;lt;/idl&amp;gt;, shown on the left side of the chart.  These services export the interfaces shown on the right side of the chart.  Also shown are the methods contained in each interface.  All interface names in the {{PRODUCTNAME}} API start with an X to be distinguishable from the names of other entities. &lt;br /&gt;
&lt;br /&gt;
Every &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; object must support three interfaces: &amp;lt;code&amp;gt;XTextDocument&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;XSearchable&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;XRefreshable&amp;lt;/code&amp;gt;. In addition, because a &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; is always an &amp;lt;code&amp;gt;OfficeDocument&amp;lt;/code&amp;gt;, it must also support the interfaces &amp;lt;code&amp;gt;XPrintable&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;XStorable&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;XModifiable&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;XModel&amp;lt;/code&amp;gt;. The methods contained in these interfaces cover these aspects: printing, storing, modification and model handling.&lt;br /&gt;
&lt;br /&gt;
Note that the interfaces shown in the illustration are only the mandatory interfaces of a &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt;. A &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; has optional properties and interfaces, among them the properties &amp;lt;code&amp;gt;CharacterCount&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ParagraphCount&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;WordCount&amp;lt;/code&amp;gt; and the &amp;lt;code&amp;gt;XPropertySet&amp;lt;/code&amp;gt; interface which must be supported if properties are present at all. The current implementation of the &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; service in {{PRODUCTNAME}} does not only support these interfaces, but all optional interfaces as well. The usage of a &amp;lt;code&amp;gt;TextDocument&amp;lt;/code&amp;gt; is described thoroughly in [[Documentation/DevGuide/Text/Text Documents|Text Documents]].&lt;br /&gt;
&lt;br /&gt;
===Using Interfaces===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.uno.XInterface&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The fact that every UNO object must be accessed through its interfaces has an effect in languages like Java and C++, where the compiler needs the correct type of an object reference before you can call a method from it. In Java or C++, you normally just cast an object before you access an interface it implements. When working with UNO objects this is different: You must ask the UNO environment to get the appropriate reference for you whenever you want to access methods of an interface which your object supports, but your compiler does not yet know about. Only then you can cast it safely.&lt;br /&gt;
&lt;br /&gt;
The Java UNO environment has a method &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; for this purpose. It looks complicated at first sight, but once you understand that &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; is about safe casting of UNO types across process boundaries, you will soon get used to it. Take a look to the second example FirstLoadComponent &amp;lt;!--[SOURCE:FirstSteps/FirstLoadComponent.java]--&amp;gt; where a new Desktop object is created and afterwards the &amp;lt;idlm&amp;gt;queryInterface&amp;lt;/idlm&amp;gt;() method is used to get the &amp;lt;idls&amp;gt;com.sun.star.frame.XComponentLoader&amp;lt;/idls&amp;gt; interface.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  Object desktop = xRemoteServiceManager.createInstanceWithContext(&lt;br /&gt;
                &amp;quot;com.sun.star.frame.Desktop&amp;quot;, xRemoteContext);&lt;br /&gt;
 &lt;br /&gt;
  XComponentLoader xComponentLoader = (XComponentLoader)&lt;br /&gt;
                UnoRuntime.queryInterface(XComponentLoader.class, desktop);&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We asked the service manager to create a &amp;lt;idl&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idl&amp;gt; using its factory method createInstanceWithContext(). This method is defined to return a Java Object type, which should not surprise you—after all the factory must be able to return any type:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  java.lang.Object createInstanceWithContext(String serviceName, XComponentContext context)&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The object we receive is a &amp;lt;idl&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idl&amp;gt; service.&lt;br /&gt;
&lt;br /&gt;
The following figure  is a simplified specification in UML notation showing the relation to the &amp;lt;idl&amp;gt;com.sun.star.frame.Frame&amp;lt;/idl&amp;gt; service and the supported interfaces.The point is, while we know that the object we ordered at the factory is a DesktopUnoUrlResolver and exports among other interfaces the interface &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt;, the compiler does &amp;#039;&amp;#039;not&amp;#039;&amp;#039;. Therefore, we have to use the UNO runtime environment to ask or &amp;#039;&amp;#039;query&amp;#039;&amp;#039; for the interface &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt;, since we want to use the &amp;lt;code&amp;gt;loadComponentFromURL()&amp;lt;/code&amp;gt; method on this interface. The method &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; makes sure we get a reference that can be cast to the needed interface type, no matter if the target object is a local or a remote object. There are two &amp;lt;code&amp;gt;queryInterface&amp;lt;/code&amp;gt; definitions in the Java UNO language binding:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  java.lang.Object UnoRuntime.queryInterface(java.lang.Class targetInterface, Object sourceObject)&lt;br /&gt;
  java.lang.Object UnoRuntime.queryInterface(com.sun.star.uno.Type targetInterface, Object sourceObject)&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since &amp;lt;code&amp;gt;UnoRuntime.queryInterface()&amp;lt;/code&amp;gt; is specified to return a java.lang.Object just like the factory method &amp;lt;code&amp;gt;createInstanceWithContext()&amp;lt;/code&amp;gt;, we still must explicitly cast our interface reference to the needed type. The difference is that after &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; we can safely cast the object to our interface type and, most important, that the reference will now work even with an object in another process. Here is the &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; call, explained step by step:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  XComponentLoader xComponentLoader = (XComponentLoader)&lt;br /&gt;
                  UnoRuntime.queryInterface(XComponentLoader.class, desktop);&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt; is the interface we want to use, so we define a &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt; variable named &amp;lt;code&amp;gt;xComponentLoader&amp;lt;/code&amp;gt; (lower x) to store the interface we expect from &amp;lt;code&amp;gt;queryInterface&amp;lt;/code&amp;gt;. &lt;br /&gt;
Then we query our desktop object for the &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt; interface, passing in &amp;lt;code&amp;gt;XComponentLoader.class&amp;lt;/code&amp;gt; as target interface and desktop as source object. Finally we cast the outcome to &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt; and assign the resulting reference to our variable &amp;lt;code&amp;gt;xComponentLoader&amp;lt;/code&amp;gt;.&lt;br /&gt;
If the source object does not support the interface we are querying for, &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; will return null.&lt;br /&gt;
&lt;br /&gt;
In Java, this call to &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; is necessary whenever you have a reference to an object which is known to support an interface that you need, but you do not have the proper reference type yet. Fortunately, you are not only allowed to &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;java.lang.Object&amp;lt;/code&amp;gt; source types, but you may also query an interface from another interface reference, like this:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // loading a blank spreadsheet document gives us its XComponent interface:&lt;br /&gt;
  XComponent xComponent = xComponentLoader.loadComponentFromURL(&lt;br /&gt;
  &amp;quot;private:factory/scalc&amp;quot;, &amp;quot;_blank&amp;quot;, 0, loadProps);&lt;br /&gt;
  &lt;br /&gt;
  // now we query the interface XSpreadsheetDocument from xComponent&lt;br /&gt;
  XSpreadsheetDocument xSpreadsheetDocument = (XSpreadsheetDocument)UnoRuntime.queryInterface(&lt;br /&gt;
                  XSpreadsheetDocument.class, xComponent);  &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Furthermore, if a method is defined in such a way that it already returns an interface type, you do not need to query the interface, but you can use its methods right away. In the snippet above, the method &amp;lt;code&amp;gt;loadComponentFromURL&amp;lt;/code&amp;gt; is specified to return an &amp;lt;idl&amp;gt;com.sun.star.lang.XComponent&amp;lt;/idl&amp;gt; interface, so you may call the &amp;lt;code&amp;gt;XComponent&amp;lt;/code&amp;gt; methods &amp;lt;code&amp;gt;addEventListener()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;removeEventListener()&amp;lt;/code&amp;gt; directly at the &amp;lt;code&amp;gt;xComponent&amp;lt;/code&amp;gt; variable, if you want to be notified that the document is being closed.&lt;br /&gt;
The corresponding step in C++ is done by a &amp;lt;code&amp;gt;Reference&amp;lt;&amp;gt;&amp;lt;/code&amp;gt; template that takes the source instance as parameter:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // instantiate a sample service with the servicemanager.&lt;br /&gt;
  Reference&amp;lt; XInterface &amp;gt; rInstance =&lt;br /&gt;
  rServiceManager-&amp;gt;createInstanceWithContext( &lt;br /&gt;
  OUString::createFromAscii(&amp;quot;com.sun.star.frame.Desktop&amp;quot; ),&lt;br /&gt;
  rComponentContext );&lt;br /&gt;
  &lt;br /&gt;
  // Query for the XComponentLoader interface&lt;br /&gt;
  Reference&amp;lt; XComponentLoader &amp;gt; rComponentLoader( rInstance, UNO_QUERY );&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In {{PRODUCTNAME}} Basic, querying for interfaces is not necessary, the Basic runtime engine takes care about that internally.&lt;br /&gt;
With the proliferation of multiple-inheritance interfaces in the {{PRODUCTNAME}} API, there will be less of a demand to explicitly query for specific interfaces in Java or C++. For example, with the hypothetical interfaces&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  interface XBase1 {   void fun1();&lt;br /&gt;
  };&lt;br /&gt;
  interface XBase2 {&lt;br /&gt;
      void fun2();&lt;br /&gt;
  };&lt;br /&gt;
  interface XBoth { // inherits from both XBase1 and XBase2&lt;br /&gt;
      interface XBase1;&lt;br /&gt;
      interface XBase2;&lt;br /&gt;
  };&lt;br /&gt;
  interface XFactory {&lt;br /&gt;
      XBoth getBoth();};&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
you can directly call both &amp;lt;code&amp;gt;fun1()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;fun2()&amp;lt;/code&amp;gt; on a reference obtained through &amp;lt;code&amp;gt;XFactory.getBoth()&amp;lt;/code&amp;gt;, without querying for either &amp;lt;code&amp;gt;XBase1&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;XBase2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Using Properties===&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
An object must offer its properties through interfaces that allow you to work with properties. The most basic form of these interfaces is the interface &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idl&amp;gt;. There are other interfaces for properties, such as &amp;lt;idl&amp;gt;com.sun.star.beans.XMultiPropertySet&amp;lt;/idl&amp;gt;, that gets and sets a multitude of properties with a single method call. The &amp;lt;code&amp;gt;XPropertySet&amp;lt;/code&amp;gt; is always supported when properties are present in a service.&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;XPropertySet&amp;lt;/code&amp;gt;, two methods carry out the property access, which are defined in Java as follows: &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  void setPropertyValue(String propertyName, Object propertyValue)&lt;br /&gt;
  Object getPropertyValue(String propertyName)&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the FirstLoadComponent example, the &amp;lt;code&amp;gt;XPropertySet&amp;lt;/code&amp;gt; interface was used to set the CellStyle property at a cell object. The cell object was a &amp;lt;code&amp;gt;com.sun.star.sheet.SheetCell&amp;lt;/code&amp;gt; and therefore supports also the &amp;lt;code&amp;gt;com.sun.star.table.CellProperties&amp;lt;/code&amp;gt; service which had a property &amp;lt;code&amp;gt;CellStyle&amp;lt;/code&amp;gt;. The following code explains how this property was set:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // query the XPropertySet interface from cell object&lt;br /&gt;
  XPropertySet xCellProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xCell);&lt;br /&gt;
  &lt;br /&gt;
  // set the CellStyle property&lt;br /&gt;
  xCellProps.setPropertyValue(&amp;quot;CellStyle&amp;quot;, &amp;quot;Result&amp;quot;);&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
You are now ready to start working with a {{PRODUCTNAME}} document.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/First Steps]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Objects,_Interfaces,_and_Services&amp;diff=94465</id>
		<title>Documentation/DevGuide/FirstSteps/Objects, Interfaces, and Services</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/Objects,_Interfaces,_and_Services&amp;diff=94465"/>
		<updated>2008-10-04T21:19:59Z</updated>

		<summary type="html">&lt;p&gt;Cking: what methods --&amp;gt; which methods&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/FirstStepsTOC&lt;br /&gt;
|FirstSteps2b=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/FirstSteps/Working with Objects&lt;br /&gt;
|NextPage=Documentation/DevGuide/FirstSteps/Using Services&lt;br /&gt;
}}&lt;br /&gt;
[[zh:Zh/Documentation/DevGuide/FirstSteps/Objects, Interfaces, and Services]]&lt;br /&gt;
{{DISPLAYTITLE:Objects, Interfaces, and Services}}&lt;br /&gt;
===Objects===&lt;br /&gt;
&lt;br /&gt;
In UNO, an &amp;#039;&amp;#039;object&amp;#039;&amp;#039; is a software artifact that has methods that you can call and attributes that you can get and set. Exactly which methods and attributes an object offers is specified by the set of interfaces it supports.&lt;br /&gt;
&lt;br /&gt;
===Interfaces===&lt;br /&gt;
&lt;br /&gt;
An &amp;#039;&amp;#039;interface&amp;#039;&amp;#039; specifies a set of attributes and methods that together define one single aspect of an object. For instance, the interface &amp;lt;idl&amp;gt;com.sun.star.resource.XResourceBundle&amp;lt;/idl&amp;gt; specifies the attribute &amp;lt;code&amp;gt;Parent&amp;lt;/code&amp;gt; and the methods &amp;lt;code&amp;gt;getLocale()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;getDirectElement()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  module com { module sun { module star { module resource { interfaceXResourceBundle: com::sun::star::container::XNameAccess {&lt;br /&gt;
      [attribute] XResourceBundle Parent;&lt;br /&gt;
      com::sun::star::lang::Locale getLocale();&lt;br /&gt;
      any getDirectElement([in] string key);&lt;br /&gt;
  };&lt;br /&gt;
  }; }; }; };&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To allow for reuse of such interface specifications, an interface can inherit one or more other interfaces (as, for example, &amp;lt;idls&amp;gt;com.sun.star.resource.XResourceBundle&amp;lt;/idls&amp;gt; inherits all the attributes and methods of &amp;lt;idl&amp;gt;com.sun.star.container.XNameAccess&amp;lt;/idl&amp;gt;). Multiple inheritance, the ability to inherit more than one interface, was introduced in {{PRODUCTNAME}} {{OOo2.x}}.&lt;br /&gt;
&lt;br /&gt;
Strictly speaking, interface attributes are not needed in UNO. Each attribute could also be expressed as a combination of one method to get the attribute&amp;#039;s value, and another method to set it (or just one method to get the value for a read-only attribute). However, there are at least two good reasons for the inclusion of interface attributes in UNO: First, the need for such combinations of getting and setting a value seems to be widespread enough to warrant extra support. Second, with attributes, a designer of an interface can better express nuances among the different features of an object. Attributes can be used for those features that are not considered integral or structural parts of an object, while explicit methods are reserved to access the core features.&lt;br /&gt;
Historically, a UNO object typically supported a set of many independent interfaces, corresponding to its many different aspects. With multiple-inheritance interfaces, there is less need for this, as an object may now support just one interface that inherits from all the other interfaces that make up the object’s various aspects.&lt;br /&gt;
&lt;br /&gt;
===Services===&lt;br /&gt;
&lt;br /&gt;
Historically, the term “service” has been used with an unclear meaning in UNO. Starting with {{PRODUCTNAME}} {{OOo2.x}}, the underlying concepts have been made cleaner. Unfortunately, this leaves two different meanings for the term “service” within UNO. In the following, we will use the term &amp;quot;new-style service&amp;quot; to denote an entity that conforms to the clarified, {{PRODUCTNAME}}-{{OOo2.x}} service concept, while we use &amp;quot;old-style service&amp;quot; to denote an entity that only conforms to the historical, more vague concept. To make matters even more complicated, the term “service” is often used with still different meanings in contexts outside UNO.&lt;br /&gt;
&lt;br /&gt;
Although technically there should no longer be any need for old-style services, the {{PRODUCTNAME}} API still uses them extensively to remain backwards compatible. Therefore, be prepared to encounter uses of both service concepts in parallel when working with the {{PRODUCTNAME}} API.&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;new-style service&amp;#039;&amp;#039; is of the form&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  module com { module sun { module star { module bridge {   &lt;br /&gt;
      serviceUnoUrlResolver: XUnoUrlResolver;&lt;br /&gt;
  }; }; }; };&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and specifies that objects that support a certain interface (for example, &amp;lt;idl&amp;gt;com.sun.star.bridge.XUnoUrlResolver&amp;lt;/idl&amp;gt;) will be available under a certain service name (e.g., &amp;quot;com.sun.star.bridge.UnoUrlResolver&amp;quot;) at a component context’s service manager. (Formally, new-style services are called “single-interface–based services.”)&lt;br /&gt;
&lt;br /&gt;
The various UNO language bindings offer special constructs to easily obtain instances of such new-style services, given a suitable component context; see [[Documentation/DevGuide/ProUNO/Java/Java Language Binding|Java Language Binding]] and [[Documentation/DevGuide/ProUNO/C++/C++ Language Binding|C++ Language Binding]].&lt;br /&gt;
&lt;br /&gt;
An &amp;#039;&amp;#039;old-style service&amp;#039;&amp;#039; (formally called an “accumulation-based service”) is of the form&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  module com { module sun { module star { module frame {serviceDesktop {&lt;br /&gt;
      service Frame;&lt;br /&gt;
      interface XDesktop;&lt;br /&gt;
      interface XComponentLoader;&lt;br /&gt;
      interface com::sun::star::document::XEventBroadcaster;&lt;br /&gt;
  };&lt;br /&gt;
  }; }; }; };&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and is used to specify any of the following:&lt;br /&gt;
&lt;br /&gt;
* The general contract is that, if an object is documented to support a certain old-style service, then you can expect that object to support all interfaces exported by the service itself and any inherited services. For example, the method &amp;lt;idlml&amp;gt;com.sun.star.frame.XFrames:queryFrames&amp;lt;/idlml&amp;gt; returns a sequence of objects that should all support the old-style service &amp;lt;idl&amp;gt;com.sun.star.frame.Frame&amp;lt;/idl&amp;gt;, and thus all the interfaces exported by &amp;lt;idls&amp;gt;com.sun.star.frame.Frame&amp;lt;/idls&amp;gt;.&lt;br /&gt;
* Additionally, an old-style service may specify one or more properties, as in&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  module com { module sun { module star { module frame {service Frame {   &lt;br /&gt;
      interface com::sun::star::frame::XFrame;&lt;br /&gt;
      interface com::sun::star::frame::XDispatchProvider;&lt;br /&gt;
      // ...&lt;br /&gt;
      [property] string Title;&lt;br /&gt;
      [property, optional] XDispatchRecorderSupplier RecorderSupplier;&lt;br /&gt;
      // ...&lt;br /&gt;
  };&lt;br /&gt;
  }; }; }; };&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: Properties, which are explained in detail in the following section, are similar to interface attributes, in that they describe additional features of an object. The main difference is that interface attributes can be accessed directly, while the properties of an old-style service are typically accessed via generic interfaces like &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idl&amp;gt;. Often, interface attributes are used to represent integral features of an object, while properties represent additional, more volatile features.&lt;br /&gt;
&lt;br /&gt;
* Some old-style services are intended to be available at a component context’s service manager. For example, the service &amp;lt;idl&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idl&amp;gt; can be instantiated at a component context’s service manager under its service name &amp;quot;com.sun.star.frame.Desktop&amp;quot;. (The problem is that you cannot tell whether a given old-style service is intended to be available at a component context; using a new-style service instead makes that intent explicit.)&lt;br /&gt;
&lt;br /&gt;
* Other old-style services are designed as generic super-services that are inherited by other services. For example, the service &amp;lt;idl&amp;gt;com.sun.star.document.OfficeDocument&amp;lt;/idl&amp;gt; serves as a generic base for all different sorts of concrete document services, like &amp;lt;idl&amp;gt;com.sun.star.text.TextDocument&amp;lt;/idl&amp;gt; and &amp;lt;idl&amp;gt;com.sun.star.drawing.DrawingDocument&amp;lt;/idl&amp;gt;. (Multiple-inheritance interfaces are now the preferred mechanism to express such generic base services.)&lt;br /&gt;
&lt;br /&gt;
* Yet other old-style services only list properties, and do not export any interfaces at all. Instead of specifying the interfaces supported by certain objects, as the other kinds of old-style services do, such services are used to document a set of related properties. For example, the service &amp;lt;idl&amp;gt;com.sun.star.document.MediaDescriptor&amp;lt;/idl&amp;gt; lists all the properties that can be passed to &amp;lt;idlml&amp;gt;com.sun.star.frame.XComponentLoader:loadComponentFromURL&amp;lt;/idlml&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;property&amp;#039;&amp;#039; is a feature of an object which is typically not considered an integral or structural part of the object and therefore is handled through generic &amp;lt;code&amp;gt;getPropertyValue()&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;setPropertyValue()&amp;lt;/code&amp;gt; methods instead of specialized get methods, such as &amp;lt;code&amp;gt;getPrinter()&amp;lt;/code&amp;gt;. Old-style services offer a special syntax to list all the properties of an object. An object containing properties only has to support the &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idl&amp;gt; interface to be prepared to handle all kinds of properties. Typical examples are properties for character or paragraph formatting. With properties, you can set multiple features of an object through a single call to &amp;lt;code&amp;gt;setPropertyValues()&amp;lt;/code&amp;gt;, which greatly improves the remote performance. For instance, paragraphs support the &amp;lt;code&amp;gt;setPropertyValues()&amp;lt;/code&amp;gt; method through their &amp;lt;idl&amp;gt;com.sun.star.beans.XMultiPropertySet&amp;lt;/idl&amp;gt; interface.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/First Steps]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/First_Contact&amp;diff=94463</id>
		<title>Documentation/DevGuide/FirstSteps/First Contact</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/FirstSteps/First_Contact&amp;diff=94463"/>
		<updated>2008-10-04T21:02:38Z</updated>

		<summary type="html">&lt;p&gt;Cking: Replaced &amp;quot;A service always exists in a component context&amp;#039;&amp;#039; with instead of   A service always exists in a &amp;#039;&amp;#039;component context&amp;#039;&amp;#039;...,&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/FirstStepsTOC&lt;br /&gt;
|FirstSteps2a=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/FirstSteps/Configuration&lt;br /&gt;
|NextPage=Documentation/DevGuide/FirstSteps/How to get Objects in OpenOffice.org&lt;br /&gt;
}}&lt;br /&gt;
[[zh:Zh/Documentation/DevGuide/FirstSteps/First Contact]]&lt;br /&gt;
{{DISPLAYTITLE:First Contact}}&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.uno.XComponentContext;com.sun.star.lang.XMultiComponentFactory;com.sun.star.lang.ServiceManager&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
Since {{PRODUCTNAME}} {{OOo2.x}} it is very simple to get a working environment that offers a transparent use of UNO functionality and of office functionality. The following demonstrates how to write a small program that initializes UNO, which means that it internally connects to an office or starts a new office process if necessary and tells you if it was able to get the office component context that provides the office service manager object. Start the Java IDE or source editor, and enter the following source code for the &amp;lt;code&amp;gt;FirstUnoContact&amp;lt;/code&amp;gt; class.&lt;br /&gt;
&lt;br /&gt;
To create and run the example in the NetBeans IDE, use the following steps:&lt;br /&gt;
&lt;br /&gt;
# From the &amp;#039;&amp;#039;&amp;#039;File&amp;#039;&amp;#039;&amp;#039; menu, select &amp;#039;&amp;#039;&amp;#039;New Project&amp;#039;&amp;#039;&amp;#039;. Select &amp;#039;&amp;#039;&amp;#039;OpenOffice.org&amp;#039;&amp;#039;&amp;#039; category and select the &amp;#039;&amp;#039;&amp;#039;OpenOffice.org Client Application&amp;#039;&amp;#039;&amp;#039;. On the next wizard panel insert &amp;#039;&amp;#039;&amp;#039;FirstUnoContact&amp;#039;&amp;#039;&amp;#039; as project name and maybe change the package and/or the location path. Press &amp;#039;&amp;#039;&amp;#039;Finish&amp;#039;&amp;#039;&amp;#039; to create the project.&lt;br /&gt;
# Navigate over the project node &amp;#039;&amp;#039;&amp;#039;FirstUnoContact&amp;#039;&amp;#039;&amp;#039; -&amp;gt; &amp;#039;&amp;#039;&amp;#039;Source Packages&amp;#039;&amp;#039;&amp;#039; -&amp;gt; ... to the generated &amp;#039;&amp;#039;&amp;#039;FirstUnoContact.java&amp;#039;&amp;#039;&amp;#039; skeleton.&lt;br /&gt;
# Complete the generated source code as shown below &amp;lt;!--[SOURCE:FirstSteps/FirstUnoContact.java].--&amp;gt;&lt;br /&gt;
# Build the project by pressing &amp;#039;&amp;#039;&amp;#039;F11&amp;#039;&amp;#039;&amp;#039; and run it by pressing &amp;#039;&amp;#039;&amp;#039;F6&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The FirstUnoContact example: &amp;lt;!--[SOURCE:FirstSteps/FirstUnoContact.java]--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  public class FirstUnoContact {&lt;br /&gt;
      ...&lt;br /&gt;
      public static void main(String[] args) {&lt;br /&gt;
          try {&lt;br /&gt;
              // get the remote office component context&lt;br /&gt;
              com.sun.star.uno.XComponentContext xContext =&lt;br /&gt;
                  com.sun.star.comp.helper.Bootstrap.bootstrap();&lt;br /&gt;
  &lt;br /&gt;
              System.out.println(&amp;quot;Connected to a running office ...&amp;quot;);&lt;br /&gt;
                  &lt;br /&gt;
              com.sun.star.lang.XMultiComponentFactory xMCF =&lt;br /&gt;
                  xContext.getServiceManager();&lt;br /&gt;
  &lt;br /&gt;
              String available = (xMCF != null ? &amp;quot;available&amp;quot; : &amp;quot;not available&amp;quot;);&lt;br /&gt;
              System.out.println( &amp;quot;remote ServiceManager is &amp;quot; + available );            &lt;br /&gt;
          }&lt;br /&gt;
          catch (java.lang.Exception e){&lt;br /&gt;
              e.printStackTrace();&lt;br /&gt;
          }&lt;br /&gt;
          finally {&lt;br /&gt;
              System.exit(0);&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Whereas in NetBeans the &amp;#039;&amp;#039;&amp;#039;OpenOffice.org Client Application&amp;#039;&amp;#039;&amp;#039; wizard prepares a working project environment for you, it should be easy possible to integrate the necessary steps in other IDEs as well or run an ant script directly.&lt;br /&gt;
&lt;br /&gt;
An example ant build script couild be as the following: &amp;lt;!--[SOURCE:FirstSteps/build_FirstUnoContact.xml]--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
  &amp;lt;project basedir=&amp;quot;.&amp;quot; default=&amp;quot;all&amp;quot; name=&amp;quot;FirstUnoContact&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
      &amp;lt;property name=&amp;quot;OFFICE_HOME&amp;quot; value=&amp;quot;c:/OpenOffice.org&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;property name=&amp;quot;OO_SDK_HOME&amp;quot; value=&amp;quot;c:/OpenOffice.org_SDK&amp;quot;/&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
      &amp;lt;target name=&amp;quot;init&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;property name=&amp;quot;OUTDIR&amp;quot; value=&amp;quot;${OO_SDK_HOME}/WINExample.out/class/FirstUnoContact&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/target&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
      &amp;lt;path id=&amp;quot;office.class.path&amp;quot;&amp;gt; &lt;br /&gt;
          &amp;lt;filelist dir=&amp;quot;${OFFICE_HOME}/program/classes&amp;quot;&lt;br /&gt;
              files=&amp;quot;jurt.jar,unoil.jar,ridl.jar,juh.jar&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/path&amp;gt; &lt;br /&gt;
      &lt;br /&gt;
      &amp;lt;fileset id=&amp;quot;bootstrap.glue.code&amp;quot; dir=&amp;quot;${OO_SDK_HOME}/classes&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;patternset&amp;gt;&lt;br /&gt;
              &amp;lt;include name=&amp;quot;com/sun/star/lib/loader/*.class&amp;quot;/&amp;gt;&lt;br /&gt;
              &amp;lt;include name=&amp;quot;win/unowinreg.dll&amp;quot;/&amp;gt;&lt;br /&gt;
          &amp;lt;/patternset&amp;gt;&lt;br /&gt;
      &amp;lt;/fileset&amp;gt;    &lt;br /&gt;
             &lt;br /&gt;
      &amp;lt;target name=&amp;quot;compile&amp;quot; depends=&amp;quot;init&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;mkdir dir=&amp;quot;${OUTDIR}&amp;quot;/&amp;gt;&lt;br /&gt;
          &amp;lt;javac debug=&amp;quot;true&amp;quot; deprecation=&amp;quot;true&amp;quot; destdir=&amp;quot;${OUTDIR}&amp;quot; srcdir=&amp;quot;.&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;classpath refid=&amp;quot;office.class.path&amp;quot;/&amp;gt;&lt;br /&gt;
          &amp;lt;/javac&amp;gt;&lt;br /&gt;
      &amp;lt;/target&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
      &amp;lt;target name=&amp;quot;jar&amp;quot; depends=&amp;quot;init,compile&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;jar basedir=&amp;quot;${OUTDIR}&amp;quot; compress=&amp;quot;true&amp;quot; &lt;br /&gt;
              jarfile=&amp;quot;${OUTDIR}/FirstUnoContact.jar&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;exclude name=&amp;quot;**/*.java&amp;quot;/&amp;gt;&lt;br /&gt;
              &amp;lt;exclude name=&amp;quot;*.jar&amp;quot;/&amp;gt;&lt;br /&gt;
              &amp;lt;fileset refid=&amp;quot;bootstrap.glue.code&amp;quot;/&amp;gt;&lt;br /&gt;
              &amp;lt;manifest&amp;gt;&lt;br /&gt;
                  &amp;lt;attribute name=&amp;quot;Main-Class&amp;quot; value=&amp;quot;com.sun.star.lib.loader.Loader&amp;quot;/&amp;gt;&lt;br /&gt;
                  &amp;lt;section name=&amp;quot;com/sun/star/lib/loader/Loader.class&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;attribute name=&amp;quot;Application-Class&amp;quot; value=&amp;quot;FirstUnoContact&amp;quot;/&amp;gt;&lt;br /&gt;
                  &amp;lt;/section&amp;gt;&lt;br /&gt;
              &amp;lt;/manifest&amp;gt;&lt;br /&gt;
          &amp;lt;/jar&amp;gt;&lt;br /&gt;
      &amp;lt;/target&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
      &amp;lt;target name=&amp;quot;all&amp;quot;  description=&amp;quot;Build everything.&amp;quot; depends=&amp;quot;init,compile,jar&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;echo message=&amp;quot;Application built. FirstUnoContact!&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/target&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
      &amp;lt;target name=&amp;quot;run&amp;quot; description=&amp;quot;Try running it.&amp;quot; depends=&amp;quot;init,all&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;java jar=&amp;quot;${OUTDIR}/FirstUnoContact.jar&amp;quot; failonerror=&amp;quot;true&amp;quot; fork=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;/java&amp;gt;&lt;br /&gt;
      &amp;lt;/target&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
      &amp;lt;target  name=&amp;quot;clean&amp;quot; description=&amp;quot;Clean all build products.&amp;quot; depends=&amp;quot;init&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;delete&amp;gt;&lt;br /&gt;
              &amp;lt;fileset dir=&amp;quot;${OUTDIR}&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;include name=&amp;quot;**/*.class&amp;quot;/&amp;gt;&lt;br /&gt;
              &amp;lt;/fileset&amp;gt;&lt;br /&gt;
          &amp;lt;/delete&amp;gt;&lt;br /&gt;
          &amp;lt;delete file=&amp;quot;${OUTDIR}/FirstUnoContact.jar&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/target&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;/project&amp;gt;&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For an example that connects to the office with C++, see chapter [[Documentation/DevGuide/ProUNO/C++/C++ Language Binding|C++ Language Binding]]. Accessing the office with {{PRODUCTNAME}} Basic is described in [[Documentation/DevGuide/Basic/First Steps with OpenOffice.org Basic|First Steps with OpenOffice.org Basic]].&lt;br /&gt;
The next section describes what happens during the connection between a Java program and {{PRODUCTNAME}}&lt;br /&gt;
&lt;br /&gt;
====Service Managers====&lt;br /&gt;
&lt;br /&gt;
UNO introduces the concept of service managers, which can be considered as “factories” that  create &amp;#039;&amp;#039;services&amp;#039;&amp;#039;. For now, it is sufficient to see services as UNO objects that can be used to perform specific tasks. Later on we will give a more precise definition for the term service.&lt;br /&gt;
For example, the following services are available:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;com.sun.star.frame.Desktop&amp;#039;&amp;#039;&lt;br /&gt;
: maintains loaded documents: is used to load documents, to get the current document, and access all loaded documents&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;com.sun.star.configuration.ConfigurationProvider&amp;#039;&amp;#039;&lt;br /&gt;
: yields access to the {{PRODUCTNAME}} configuration, for instance the settings in the Tools - Options dialog&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;com.sun.star.sdb.DatabaseContext&amp;#039;&amp;#039;&lt;br /&gt;
: holds databases registered with {{PRODUCTNAME}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;com.sun.star.system.SystemShellExecute&amp;#039;&amp;#039;&lt;br /&gt;
: executes system commands or documents registered for an application on the current platform&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;com.sun.star.text.GlobalSettings&amp;#039;&amp;#039;&lt;br /&gt;
: manages global view and print settings for text documents&lt;br /&gt;
&lt;br /&gt;
[[Image:Service.png|none|thumb|300px|Service manager]]&lt;br /&gt;
&lt;br /&gt;
A service always has a &amp;#039;&amp;#039;component context&amp;#039;&amp;#039;, which consists of the service manager that created the service and other data to be used by the service.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;FirstUnoContact&amp;lt;/code&amp;gt; class above is considered a client of the {{PRODUCTNAME}} process, {{PRODUCTNAME}} is the server in this respect. The server has its own component context and its own service manager, which can be accessed from client programs to use the office functionality. The client program initializes UNO and gets the component context from the {{PRODUCTNAME}} process. Internally, this initialization process creates a local service manager, establishes a pipe connection to a running {{PRODUCTNAME}} process (if necessary a new process is started) and returns the remote component context. In the first step this is the only thing you have to know. The &amp;lt;code&amp;gt;com.sun.star.comp.helper.Bootstrap.bootstrap()&amp;lt;/code&amp;gt; method initializes UNO and returns the remote component context of a running {{PRODUCTNAME}} process. You can find more details about bootstrapping UNO, the opportunities of different connection types and how to establish a connection to a UNO server process in the [[Documentation/DevGuide/ProUNO/UNO Concepts|UNO Concepts]]. &lt;br /&gt;
&lt;br /&gt;
After this first initialization step, you can use the method   &amp;lt;idlm&amp;gt;com.sun.star.uno.XComponentContext:getServiceManager&amp;lt;/idlm&amp;gt;() from the component context to get the remote service manager from the {{PRODUCTNAME}} process, which offers you access to the complete office functionality available through the API.&lt;br /&gt;
&lt;br /&gt;
====Failed Connections====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.lang.DisposedException&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
A remote connection can fail under certain conditions: &lt;br /&gt;
&lt;br /&gt;
* Client programs should be able to detect errors. For instance, sometimes the bridge might become unavailable. Simple clients that connect to the office, perform a certain task and exit afterwards should stop their work and inform the user if an error occurred.&lt;br /&gt;
* Clients that are supposed to run over a long period of time should not assume that a reference to an initial object will be valid over the whole runtime of the client. The client should resume even if the connection goes down for some reason and comes back later on. When the connection fails, a robust, long running client should stop the current work, inform the user that the connection is not available and release the references to the remote process. When the user tries to repeat the last action, the client should try to rebuild the connection. Do not force the user to restart your program just because the connection was temporarily unavailable. &lt;br /&gt;
&lt;br /&gt;
When the bridge has become unavailable and access is tried, it throws a &amp;lt;idls&amp;gt;com.sun.star.lang.DisposedException&amp;lt;/idls&amp;gt;. Whenever you access remote references in your program, catch this Exception in such a way that you set your remote references to null and inform the user accordingly. If your client is designed to run for a longer period of time, be prepared to get new remote references when you find that they are currently null. &lt;br /&gt;
&lt;br /&gt;
A more sophisticated way to handle lost connections is to register a listener at the underlying bridge object. The chapter [[Documentation/DevGuide/ProUNO/UNO Interprocess Connections|UNO Interprocess Connections]] shows how to write a connection-aware client.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/First Steps]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/OpenOffice.org_Application_Environment&amp;diff=94462</id>
		<title>Documentation/DevGuide/OfficeDev/OpenOffice.org Application Environment</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/OpenOffice.org_Application_Environment&amp;diff=94462"/>
		<updated>2008-10-04T19:49:52Z</updated>

		<summary type="html">&lt;p&gt;Cking: Improving readability&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/OfficeDevTOC&lt;br /&gt;
|OfficeDev2a=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/OfficeDev/Office Development&lt;br /&gt;
|NextPage=Documentation/DevGuide/OfficeDev/Desktop Environment&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:{{PRODUCTNAME}} Application Environment}}&lt;br /&gt;
The {{PRODUCTNAME}} application environment is made up of the &amp;#039;&amp;#039;desktop environment&amp;#039;&amp;#039; and the &amp;#039;&amp;#039;framework API&amp;#039;&amp;#039;. &lt;br /&gt;
&lt;br /&gt;
[[Image:AppEnvironment.png|none|frame|The {{PRODUCTNAME}} Application Environment]]&lt;br /&gt;
&lt;br /&gt;
The desktop environment consists of the desktop and auxiliary objects. The desktop environment&amp;#039;s functions are carried out by the framework API. The framework API has two parts: the &amp;#039;&amp;#039;component framework&amp;#039;&amp;#039; and the &amp;#039;&amp;#039;dispatch framework&amp;#039;&amp;#039;. The component framework follows a special Frame-Controller-Model paradigm to manage components viewable in {{PRODUCTNAME}}. The dispatch framework handles command requests sent by the GUI.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Office Development]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/Using_the_Desktop&amp;diff=94461</id>
		<title>Documentation/DevGuide/OfficeDev/Using the Desktop</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/Using_the_Desktop&amp;diff=94461"/>
		<updated>2008-10-04T19:24:57Z</updated>

		<summary type="html">&lt;p&gt;Cking: Increased thumb picture size from 400 to 450 px.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/OfficeDevTOC&lt;br /&gt;
|OfficeDev2a=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/OfficeDev/Dispatch Framework&lt;br /&gt;
|NextPage=Documentation/DevGuide/OfficeDev/Using the Component Framework&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Using the Desktop}}&lt;br /&gt;
&lt;br /&gt;
[[Image:framework.png|none|thumb|450px|Desktop Service and Component Framework]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.frame.Desktop;com.sun.star.frame.XDesktop;com.sun.star.frame.XComponentLoader;com.sun.star.document.XEventBroadcaster;com.sun.star.frame.XFrames&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The &amp;lt;idl&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idl&amp;gt; service available at the global service manager includes the service &amp;lt;idl&amp;gt;com.sun.star.frame.Frame&amp;lt;/idl&amp;gt;. The Desktop service specification provides three interfaces: &amp;lt;idl&amp;gt;com.sun.star.frame.XDesktop&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.frame.XComponentLoader&amp;lt;/idl&amp;gt; and &amp;lt;idl&amp;gt;com.sun.star.document.XEventBroadcaster&amp;lt;/idl&amp;gt;, as shown in the following UML chart:&lt;br /&gt;
&lt;br /&gt;
[[Image:Desktop.png|none|thumb|450px|UML description of the desktop service]]&lt;br /&gt;
&lt;br /&gt;
The interface &amp;lt;idl&amp;gt;com.sun.star.frame.XDesktop&amp;lt;/idl&amp;gt; provides access to frames and components, and controls the termination of the office process. It defines the following methods:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  com::sun::star::frame::XFrame getCurrentFrame ()&lt;br /&gt;
  com::sun::star::container::XEnumerationAccess getComponents ()&lt;br /&gt;
  com::sun::star::lang::XComponent getCurrentComponent ()&lt;br /&gt;
  boolean terminate ()&lt;br /&gt;
  void addTerminateListener ( [in] com::sun::star::frame::XTerminateListener xListener)&lt;br /&gt;
  void removeTerminateListener ( [in] com::sun::star::frame::XTerminateListener xListener)&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The methods &amp;lt;code&amp;gt;getCurrentFrame()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;getCurrentComponent()&amp;lt;/code&amp;gt; distribute the active frame and document model, whereas &amp;lt;code&amp;gt;getComponents()&amp;lt;/code&amp;gt; returns a &amp;lt;idl&amp;gt;com.sun.star.container.XEnumerationAccess&amp;lt;/idl&amp;gt; to all loaded documents. For documents loaded in the desktop environment the methods &amp;lt;code&amp;gt;getComponents()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;getCurrentComponent()&amp;lt;/code&amp;gt; always return the &amp;lt;idl&amp;gt;com.sun.star.lang.XComponent&amp;lt;/idl&amp;gt; interface of the document model. &lt;br /&gt;
&lt;br /&gt;
{{Documentation/Tip|If a specific document component is required, but you are not sure whether this component is the current component, use &amp;lt;tt&amp;gt;getComponents()&amp;lt;/tt&amp;gt; to get an enumeration of all document components, check each for the existence of the &amp;lt;idl&amp;gt;com.sun.star.frame.XModel&amp;lt;/idl&amp;gt; interface and use &amp;lt;tt&amp;gt;getURL()&amp;lt;/tt&amp;gt; at &amp;lt;tt&amp;gt;XModel&amp;lt;/tt&amp;gt; to identify your document. Since not all components have to support &amp;lt;tt&amp;gt;XModel&amp;lt;/tt&amp;gt;, test for &amp;lt;tt&amp;gt;XModel&amp;lt;/tt&amp;gt; before calling &amp;lt;tt&amp;gt;getURL()&amp;lt;/tt&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
The office process is usually terminated when the user selects &amp;#039;&amp;#039;&amp;#039;File - Exit&amp;#039;&amp;#039;&amp;#039; or after the last application window has been closed. Clients can terminate the office through a call to &amp;lt;code&amp;gt;terminate()&amp;lt;/code&amp;gt; and add a terminate listener to veto the shutdown process. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--[BUG641+]--&amp;gt;&lt;br /&gt;
As long as the Windows quickstarter is active, the soffice executable is not terminated. &lt;br /&gt;
&lt;br /&gt;
The following sample shows an &amp;lt;idl&amp;gt;com.sun.star.frame.XTerminateListener&amp;lt;/idl&amp;gt; implementation that prevents the office from being terminated when the class &amp;lt;code&amp;gt;TerminationTest&amp;lt;/code&amp;gt; is still active:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  import com.sun.star.frame.TerminationVetoException;&lt;br /&gt;
  import com.sun.star.frame.XTerminateListener;&lt;br /&gt;
  &lt;br /&gt;
  public class TerminateListener implements XTerminateListener {&lt;br /&gt;
  &lt;br /&gt;
      public void notifyTermination (com.sun.star.lang.EventObject eventObject) {&lt;br /&gt;
          System.out.println(&amp;quot;about to terminate...&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
      public void queryTermination (com.sun.star.lang.EventObject eventObject) &lt;br /&gt;
          throws TerminationVetoException {&lt;br /&gt;
  &lt;br /&gt;
          // test if we can terminate now&lt;br /&gt;
          if (TerminationTest.isAtWork() == true) {&lt;br /&gt;
              System.out.println(&amp;quot;Terminate while we are at work? No way!&amp;quot;);&lt;br /&gt;
              throw new TerminationVetoException() ; // this will veto the termination, &lt;br /&gt;
                                                     // a call to terminate() returns false&lt;br /&gt;
          }&lt;br /&gt;
      }    &lt;br /&gt;
  &lt;br /&gt;
      public void disposing (com.sun.star.lang.EventObject eventObject) {&lt;br /&gt;
      } &lt;br /&gt;
  }&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The following class &amp;lt;code&amp;gt;TerminationTest&amp;lt;/code&amp;gt; tests the &amp;lt;code&amp;gt;TerminateListener&amp;lt;/code&amp;gt; above.&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  import com.sun.star.bridge.XUnoUrlResolver;&lt;br /&gt;
  import com.sun.star.uno.UnoRuntime;&lt;br /&gt;
  import com.sun.star.uno.XComponentContext;&lt;br /&gt;
  import com.sun.star.lang.XMultiComponentFactory;&lt;br /&gt;
  import com.sun.star.beans.XPropertySet;&lt;br /&gt;
  import com.sun.star.beans.PropertyValue;&lt;br /&gt;
  &lt;br /&gt;
  import com.sun.star.frame.XDesktop;&lt;br /&gt;
  import com.sun.star.frame.TerminationVetoException;&lt;br /&gt;
  import com.sun.star.frame.XTerminateListener;&lt;br /&gt;
  &lt;br /&gt;
  public class TerminationTest extends java.lang.Object {&lt;br /&gt;
  &lt;br /&gt;
      private static boolean atWork = false;&lt;br /&gt;
    &lt;br /&gt;
      public static void main(String[] args) {&lt;br /&gt;
  &lt;br /&gt;
          XComponentContext xRemoteContext = null;&lt;br /&gt;
          XMultiComponentFactory xRemoteServiceManager = null;&lt;br /&gt;
          XDesktop xDesktop = null;&lt;br /&gt;
  &lt;br /&gt;
          try { &lt;br /&gt;
              // connect and retrieve a remote service manager and component context&lt;br /&gt;
              XComponentContext xLocalContext =&lt;br /&gt;
                  com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(null);&lt;br /&gt;
              XMultiComponentFactory xLocalServiceManager = xLocalContext.getServiceManager();&lt;br /&gt;
              Object urlResolver = xLocalServiceManager.createInstanceWithContext(&lt;br /&gt;
                  &amp;quot;com.sun.star.bridge.UnoUrlResolver&amp;quot;, xLocalContext );&lt;br /&gt;
              XUnoUrlResolver xUnoUrlResolver = (XUnoUrlResolver) UnoRuntime.queryInterface( &lt;br /&gt;
                  XUnoUrlResolver.class, urlResolver );&lt;br /&gt;
              Object initialObject = xUnoUrlResolver.resolve( &lt;br /&gt;
                  &amp;quot;uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager&amp;quot; );&lt;br /&gt;
              XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(&lt;br /&gt;
                  XPropertySet.class, initialObject);&lt;br /&gt;
              Object context = xPropertySet.getPropertyValue(&amp;quot;DefaultContext&amp;quot;); &lt;br /&gt;
              xRemoteContext = (XComponentContext)UnoRuntime.queryInterface(&lt;br /&gt;
                  XComponentContext.class, context);&lt;br /&gt;
              xRemoteServiceManager = xRemoteContext.getServiceManager();&lt;br /&gt;
  &lt;br /&gt;
              // get Desktop instance&lt;br /&gt;
              Object desktop = xRemoteServiceManager.createInstanceWithContext (&lt;br /&gt;
                  &amp;quot;com.sun.star.frame.Desktop&amp;quot;, xRemoteContext);&lt;br /&gt;
              xDesktop = (XDesktop)UnoRuntime.queryInterface(XDesktop.class, desktop);&lt;br /&gt;
  &lt;br /&gt;
              TerminateListener terminateListener = new TerminateListener ();&lt;br /&gt;
              xDesktop.addTerminateListener (terminateListener);&lt;br /&gt;
  &lt;br /&gt;
              // try to terminate while we are at work&lt;br /&gt;
              atWork = true;&lt;br /&gt;
              boolean terminated = xDesktop.terminate ();&lt;br /&gt;
              System.out.println(&amp;quot;The Office &amp;quot; +&lt;br /&gt;
                  (terminated == true ? &amp;quot;has been terminated&amp;quot; : &amp;quot;is still running, we are at work&amp;quot;));&lt;br /&gt;
  &lt;br /&gt;
              // no longer at work&lt;br /&gt;
              atWork = false;&lt;br /&gt;
              // once more: try to terminate &lt;br /&gt;
              terminated = xDesktop.terminate ();&lt;br /&gt;
              System.out.println(&amp;quot;The Office &amp;quot; + &lt;br /&gt;
                  (terminated == true ? &amp;quot;has been terminated&amp;quot; :&lt;br /&gt;
                      &amp;quot;is still running. Someone else prevents termination, e.g. the quickstarter&amp;quot;));&lt;br /&gt;
          }&lt;br /&gt;
          catch (java.lang.Exception e){&lt;br /&gt;
              e.printStackTrace();&lt;br /&gt;
          }&lt;br /&gt;
          finally {&lt;br /&gt;
              System.exit(0);&lt;br /&gt;
          }&lt;br /&gt;
  &lt;br /&gt;
      }&lt;br /&gt;
      public static boolean isAtWork() {&lt;br /&gt;
          return atWork;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;!--[BUG641+]--&amp;gt;&lt;br /&gt;
The office freezes when &amp;lt;code&amp;gt;terminate()&amp;lt;/code&amp;gt; is called if there are unsaved changes. As a workaround set all documents into an unmodified state through their &amp;lt;idl&amp;gt;com.sun.star.util.XModifiable&amp;lt;/idl&amp;gt; interface or store them using &amp;lt;idl&amp;gt;com.sun.star.frame.XStorable&amp;lt;/idl&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The Desktop offers a facility to load components through its interface &amp;lt;idl&amp;gt;com.sun.star.frame.XComponentLoader&amp;lt;/idl&amp;gt;. It has one method:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  com::sun::star::lang::XComponent loadComponentFromURL ( [in] string aURL,&lt;br /&gt;
                  [in] string aTargetFrameName,&lt;br /&gt;
                  [in] long nSearchFlags,&lt;br /&gt;
                  [in] sequence &amp;lt; com::sun::star::beans::PropertyValue aArgs &amp;gt; )&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
Refer to chapter [[Documentation/DevGuide/OfficeDev/Handling Documents|Handling Documents]] for details about the loading process.&lt;br /&gt;
&lt;br /&gt;
For versions beyond 641, the desktop also provides an interface that allows listeners to be notified about certain document events through its interface &amp;lt;idl&amp;gt;com.sun.star.document.XEventBroadcaster&amp;lt;/idl&amp;gt;. &lt;br /&gt;
 &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  void addEventListener ( [in] com::sun::star::document::XEventListener xListener)&lt;br /&gt;
  void removeEventListener ( [in] com::sun::star::document::XEventListener xListener)&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The &amp;lt;code&amp;gt;XEventListener&amp;lt;/code&amp;gt; must implement a single method (besides &amp;lt;code&amp;gt;disposing()&amp;lt;/code&amp;gt;):&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  [oneway] void notifyEvent ( [in] com::sun::star::document::EventObject Event )&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The struct &amp;lt;idl&amp;gt;com.sun.star.document.EventObject&amp;lt;/idl&amp;gt; has a &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; member &amp;lt;code&amp;gt;EventName&amp;lt;/code&amp;gt; that assumes one of the values specified in &amp;lt;idl&amp;gt;com.sun.star.document.Events&amp;lt;/idl&amp;gt;. The corresponding events are found on the Events tab of the &amp;#039;&amp;#039;&amp;#039;Tools - Configure&amp;#039;&amp;#039;&amp;#039; dialog when the option {{PRODUCTNAME}} is selected.&lt;br /&gt;
&lt;br /&gt;
The desktop broadcasts these events for all loaded documents.&lt;br /&gt;
&lt;br /&gt;
The current version of {{PRODUCTNAME}} does not have a GUI element as a desktop. The redesign of the {{PRODUCTNAME}} GUI in StarOffice 5.x and later resulted in the &amp;lt;idl&amp;gt;com.sun.star.frame.Frame&amp;lt;/idl&amp;gt; service part of the desktop service is now non-functional. While the &amp;lt;code&amp;gt;XFrame&amp;lt;/code&amp;gt; interface can still be queried from the desktop, almost all of its methods are dummy implementations. The default implementation of the desktop object in {{PRODUCTNAME}} is not able to contain a component and refuses to be attached to it, because the desktop is still a frame that is the root for the common hierarchy of all frames in {{PRODUCTNAME}}. The desktop has to be a frame because its &amp;lt;idl&amp;gt;com.sun.star.frame.XFramesSupplier&amp;lt;/idl&amp;gt; interface must be passed to [http://api.openoffice.org/docs/common/ref/com/sun/star/frame/XFrame.html#setCreator com.sun.star.frame.XFrame:setCreator]() at the child frames, therefore the desktop becomes the parent frame. However, the following functionality of &amp;lt;idl&amp;gt;com.sun.star.frame.Frame&amp;lt;/idl&amp;gt; is still in place:&lt;br /&gt;
&lt;br /&gt;
The desktop interface &amp;lt;idl&amp;gt;com.sun.star.frame.XFramesSupplier&amp;lt;/idl&amp;gt; offers methods to access frames. This interface inherits from &amp;lt;idl&amp;gt;com.sun.star.frame.XFrame&amp;lt;/idl&amp;gt;, and introduces the following methods:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  com::sun::star::frame::XFrames getFrames ()&lt;br /&gt;
  com::sun::star::frame::XFrame getActiveFrame ()&lt;br /&gt;
  void setActiveFrame ( [in] com::sun::star::frame::XFrame xFrame)&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The method &amp;lt;code&amp;gt;getFrames()&amp;lt;/code&amp;gt; returns a &amp;lt;idl&amp;gt;com.sun.star.frame.XFrames&amp;lt;/idl&amp;gt; container, that is a &amp;lt;idl&amp;gt;com.sun.star.container.XIndexAccess&amp;lt;/idl&amp;gt;, with additional methods to add and remove frames:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  void append ( [in] com::sun::star::frame::XFrame xFrame )&lt;br /&gt;
  sequence &amp;lt; com::sun::star::frame::XFrame &amp;gt; queryFrames ( [in] long nSearchFlags )&lt;br /&gt;
  void remove ( [in] com::sun::star::frame::XFrame xFrame )&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
This &amp;lt;code&amp;gt;XFrames&amp;lt;/code&amp;gt; collection is used when frames are added to the desktop to become application windows.&lt;br /&gt;
&lt;br /&gt;
Through &amp;lt;code&amp;gt;getActiveFrame()&amp;lt;/code&amp;gt;, you access the active sub-frame of the desktop frame, whereas &amp;lt;code&amp;gt;setActiveFrame()&amp;lt;/code&amp;gt; is called by a sub-frame to inform the desktop about the active sub-frame. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--[BUG641+]--&amp;gt;&lt;br /&gt;
The object returned by &amp;lt;code&amp;gt;getFrames()&amp;lt;/code&amp;gt; does not support &amp;lt;code&amp;gt;XTypeProvider&amp;lt;/code&amp;gt;, therefore it cannot be used with {{PRODUCTNAME}} Basic.&lt;br /&gt;
&lt;br /&gt;
The parent interface of &amp;lt;code&amp;gt;XFramesSupplier&amp;lt;/code&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.frame.XFrame&amp;lt;/idl&amp;gt; is functional by accessing the frame hierarchy below the desktop. These methods are discussed in the section [[Documentation/DevGuide/OfficeDev/Frames|Frames]] below:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  com::sun::star::frame::XFrame findFrame ( [in] string aTargetFrameName, [in] long nSearchFlags );&lt;br /&gt;
  boolean isTop ();&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The generic dispatch interface &amp;lt;idl&amp;gt;com.sun.star.frame.XDispatchProvider&amp;lt;/idl&amp;gt; executes functions of the internal &amp;lt;code&amp;gt;Desktop&amp;lt;/code&amp;gt; implementation that are not accessible through specialized interfaces. Dispatch functions are described by a command URL. The &amp;lt;code&amp;gt;XDispatchProvider&amp;lt;/code&amp;gt; returns a dispatch object that dispatches a given command URL. A reference of command URLs supported by the desktop is available on OpenOffice ([http://www.openoffice.org/files/documents/25/60/commands_11beta.html http://www.openoffice.org/files/documents/25/60/commands_11beta.html]). Through the &amp;lt;idl&amp;gt;com.sun.star.frame.XDispatchProviderInterception&amp;lt;/idl&amp;gt;, client code intercepts the command dispatches at the desktop. The dispatching process is described in section [[Documentation/DevGuide/OfficeDev/Using the Dispatch Framework|Using the Dispatch Framework]].&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Office Development]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/Command_URL&amp;diff=94460</id>
		<title>Documentation/DevGuide/OfficeDev/Command URL</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/Command_URL&amp;diff=94460"/>
		<updated>2008-10-04T19:16:51Z</updated>

		<summary type="html">&lt;p&gt;Cking: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/OfficeDevTOC&lt;br /&gt;
|OfficeDev2a=block&lt;br /&gt;
|OfficeDevDispatch=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/OfficeDev/Using the Dispatch Framework&lt;br /&gt;
|NextPage=Documentation/DevGuide/OfficeDev/Processing Chain&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Command URL}}&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.util.URL&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
In the dispatch framework, every possible user action is defined as an executable &amp;#039;&amp;#039;command&amp;#039;&amp;#039;, and every possible visualization as a reflection of something that is exposed by the component is defined as an &amp;#039;&amp;#039;attribute&amp;#039;&amp;#039;. Every executable command and every attribute is a feature of the office component, and the dispatch framework gives every feature a name called &amp;#039;&amp;#039;command URL&amp;#039;&amp;#039;. It is represented by a &amp;lt;idl&amp;gt;com.sun.star.util.URL&amp;lt;/idl&amp;gt; struct.&lt;br /&gt;
&lt;br /&gt;
Command URLs are strings that follow the &amp;#039;&amp;#039;protocol_scheme:protocol_specific_part&amp;#039;&amp;#039; pattern. Public URL schemes, such as &amp;#039;&amp;#039;file:&amp;#039;&amp;#039; or &amp;#039;&amp;#039;http&amp;#039;&amp;#039; can be used here.  Executing a request with a URL that points to a location of a document means that this document is loaded. In general, both parts of the command URL can be arbitrary strings, but a request cannot be executed if there is an object that does not know how to handle its command URL.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Office Development]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/Dispatch_Framework&amp;diff=94454</id>
		<title>Documentation/DevGuide/OfficeDev/Dispatch Framework</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/Dispatch_Framework&amp;diff=94454"/>
		<updated>2008-10-04T18:09:41Z</updated>

		<summary type="html">&lt;p&gt;Cking: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/OfficeDevTOC&lt;br /&gt;
|OfficeDev2a=block|OfficeDevFramework=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/OfficeDev/Windows&lt;br /&gt;
|NextPage=Documentation/DevGuide/OfficeDev/Using the Desktop&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Dispatch Framework}}&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.frame.XDispatchProvider&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The dispatch framework is designed to provide uniform access to components for a GUI by using command URLs that mirror menu items, such as &amp;#039;&amp;#039;&amp;#039;Edit - Select All&amp;#039;&amp;#039;&amp;#039;, with various document components. Only the component knows how to execute a command. Similarly, different document components trigger changes in the UI by common commands. For example, a controller might create UI elements like a menu bar, or open a hyperlink.&lt;br /&gt;
&lt;br /&gt;
Command dispatching follows a chain of responsibility. Calls to the dispatch API are moderated by the frame, so all dispatch API calls from the UI to the component and conversely are handled by the frame. The frame passes on the command until an object is found that can handle it. It is possible to restrict, extend or redirect commands at the frame through a different frame implementation or through other components connecting to the frame.&lt;br /&gt;
&lt;br /&gt;
It has already been discussed that frames and controllers have an interface &amp;lt;idl&amp;gt;com.sun.star.frame.XDispatchProvider&amp;lt;/idl&amp;gt;. The interface is used to query a dispatch object for a command URL from a frame and have the dispatch object execute the command. This interface is one element of the dispatch framework.&lt;br /&gt;
&lt;br /&gt;
By offering the interception of dispatches through the interface &amp;lt;idl&amp;gt;com.sun.star.frame.XDispatchProviderInterception&amp;lt;/idl&amp;gt;, the Frame service offers a method to modify a component&amp;#039;s handling of GUI events while keeping its whole API available simultaneously.&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|Normally, command URL dispatches go to a target frame, which decides what to do with it. A component can use globally accessible objects like the desktop service to bypass restrictions set by a frame, but this is not recommended. It is impossible to prevent an implementation of components against the design principles, because the framework API is made for components that adhere to its design.}}&lt;br /&gt;
&lt;br /&gt;
The usage of the Dispatch Framework is described in the section [[Documentation/DevGuide/OfficeDev/Using the Dispatch Framework|Using the Dispatch Framework]].&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Office Development]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/Controllers&amp;diff=94450</id>
		<title>Documentation/DevGuide/OfficeDev/Controllers</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/Controllers&amp;diff=94450"/>
		<updated>2008-10-04T18:01:15Z</updated>

		<summary type="html">&lt;p&gt;Cking: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/OfficeDevTOC&lt;br /&gt;
|OfficeDev2a=block&lt;br /&gt;
|OfficeDevFramework=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/OfficeDev/Frames&lt;br /&gt;
|NextPage=Documentation/DevGuide/OfficeDev/Windows&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Controllers}}&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.frame.Controller;com.sun.star.frame.XController&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
Controllers in {{PRODUCTNAME}} are between a frame and document model. This is their basic role as expressed in &amp;lt;idl&amp;gt;com.sun.star.frame.XController&amp;lt;/idl&amp;gt;, which has methods &amp;lt;code&amp;gt;getModel()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;getFrame()&amp;lt;/code&amp;gt;. The method &amp;lt;code&amp;gt;getFrame()&amp;lt;/code&amp;gt; provides the frame that the controller is attached to. The method &amp;lt;code&amp;gt;getModel()&amp;lt;/code&amp;gt; returns a document model, but it may return an empty reference if the component does not have a model.&lt;br /&gt;
&lt;br /&gt;
Usually the controller objects support additional interfaces specific to the document type they control, such as &amp;lt;idl&amp;gt;com.sun.star.sheet.XSpreadsheetView&amp;lt;/idl&amp;gt; for Calc document controllers or &amp;lt;idl&amp;gt;com.sun.star.text.XTextViewCursorSupplier&amp;lt;/idl&amp;gt; for Writer document controllers.&lt;br /&gt;
&lt;br /&gt;
[[Image:FCMController.png|none|thumb|400px|Controller with Model and Frame]]&lt;br /&gt;
&lt;br /&gt;
There can be more than one controller instance with frames of their own controlling the same document model simultaneously. Multiple controllers and frames are created by {{PRODUCTNAME}} when the user clicks &amp;#039;&amp;#039;&amp;#039;Window - New Window&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Office Development]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/Frames&amp;diff=94448</id>
		<title>Documentation/DevGuide/OfficeDev/Frames</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/Frames&amp;diff=94448"/>
		<updated>2008-10-04T17:48:31Z</updated>

		<summary type="html">&lt;p&gt;Cking: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/OfficeDevTOC&lt;br /&gt;
|OfficeDev2a=block&lt;br /&gt;
|OfficeDevFramework=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/OfficeDev/Frame-Controller-Model Paradigm in OpenOffice.org&lt;br /&gt;
|NextPage=Documentation/DevGuide/OfficeDev/Controllers&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Frames}}&lt;br /&gt;
=== Linking Components and Windows ===&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.frame.Frame;com.sun.star.frame.XFrame;com.sun.star.frame.XFrames;com.sun.star.awt.XWindow;com.sun.star.awt.XTopWindow&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The main role of a frame in the Frame-Controller-Model paradigm is to act as a liaison between viewable components and the window system. &lt;br /&gt;
&lt;br /&gt;
Frames can hold one component, or a component and one or more subframes. The following two illustrations depict both possibilities. The first illustration shows a frame containing only a component. It is connected with two window instances: the container window and component window.&lt;br /&gt;
&lt;br /&gt;
[[Image:FCMFrame.png|none|thumb|400px|Frame containing a component]]&lt;br /&gt;
&lt;br /&gt;
When a frame is constructed, the frame must be initialized with a container window using &amp;lt;idlml&amp;gt;com.sun.star.frame.XFrame:initialize&amp;lt;/idlml&amp;gt;(). This method expects the &amp;lt;idl&amp;gt;com.sun.star.awt.XWindow&amp;lt;/idl&amp;gt; interface of a surrounding window instance, which becomes the container window of the frame. The window instance passed to &amp;lt;code&amp;gt;initialize()&amp;lt;/code&amp;gt; must also support &amp;lt;idl&amp;gt;com.sun.star.awt.XTopWindow&amp;lt;/idl&amp;gt; to become a container window. The container window must broadcast window events, such as &amp;lt;code&amp;gt;windowActivated()&amp;lt;/code&amp;gt;, and appear in front of other windows or be sent to the background. The fact that container windows support &amp;lt;idl&amp;gt;com.sun.star.awt.XTopWindow&amp;lt;/idl&amp;gt; does not mean the container window is an independent window of the underlying window system with a title bar and a system menu. An &amp;lt;code&amp;gt;XTopWindow&amp;lt;/code&amp;gt; acts as a window if necessary, but it can also be docked or depend on a surrounding application window.&lt;br /&gt;
&lt;br /&gt;
After initializing the frame, a component is set into the frame by a frame loader implementation that loads a component into the frame. It calls &amp;lt;idlml&amp;gt;com.sun.star.frame.XFrame:setComponent&amp;lt;/idlml&amp;gt;() that takes another &amp;lt;idl&amp;gt;com.sun.star.awt.XWindow&amp;lt;/idl&amp;gt; instance and the &amp;lt;idl&amp;gt;com.sun.star.frame.XController&amp;lt;/idl&amp;gt; interface of a controller.Usually the controller is holding a model, therefore the component gets a component window of its own, separate from the container window.&lt;br /&gt;
&lt;br /&gt;
A frame with a component is associated with &amp;#039;&amp;#039;two&amp;#039;&amp;#039; windows: the &amp;#039;&amp;#039;container&amp;#039;&amp;#039; window which is an &amp;lt;code&amp;gt;XTopWindow&amp;lt;/code&amp;gt; and the &amp;#039;&amp;#039;component&amp;#039;&amp;#039; window, which is the rectangular area that displays the component and receives GUI events for the component while it is active. When a frame is initialized with an instance of a window in a call to &amp;lt;code&amp;gt;initialize()&amp;lt;/code&amp;gt;, this window becomes its container window. When a component is set into a frame using &amp;lt;code&amp;gt;setComponent()&amp;lt;/code&amp;gt;, another &amp;lt;idl&amp;gt;com.sun.star.awt.XWindow&amp;lt;/idl&amp;gt; instance is passed and becomes the component window.&lt;br /&gt;
&lt;br /&gt;
When a frame is added to the desktop frame hierarchy, the desktop becomes the parent frame of our frame. For this purpose, the &amp;lt;idl&amp;gt;com.sun.star.frame.XFramesSupplier&amp;lt;/idl&amp;gt; interface of the desktop is passed to the method &amp;lt;code&amp;gt;setCreator()&amp;lt;/code&amp;gt; at the &amp;lt;code&amp;gt;XFrame&amp;lt;/code&amp;gt; interface. This happens internally when the method &amp;lt;code&amp;gt;append()&amp;lt;/code&amp;gt; is called at the &amp;lt;idl&amp;gt;com.sun.star.frame.XFrames&amp;lt;/idl&amp;gt; interface supplied by the desktop.&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|A component window can have sub-windows, and that is the case with all documents in {{PRODUCTNAME}}. For instance, a text document has sub-windows for the toolbars and the editable text. Form controls are sub-windows, as well, however, these sub-windows depend on the component window and do not appear in the Frame-Controller-Model paradigm, as discussed above.}}&lt;br /&gt;
&lt;br /&gt;
The second diagram shows a frame with a component and a sub-frame with another component. Each frame has a container window and component window.&lt;br /&gt;
&lt;br /&gt;
[[Image:FCMSubframe.png|none|thumb|400px|Frame containing a component and a sub-frame]]&lt;br /&gt;
&lt;br /&gt;
In the {{PRODUCTNAME}} GUI, sub-frames appear as dependent windows. The sub-frame in the illustration above could be a dockable window, such as the beamer showing the database browser or a floating frame in a document created with &amp;#039;&amp;#039;&amp;#039;Insert - Frame&amp;#039;&amp;#039;&amp;#039;. &lt;br /&gt;
&lt;br /&gt;
Note that a frame with a component and sub-frame is associated with &amp;#039;&amp;#039;four&amp;#039;&amp;#039; windows. The frame and the sub-frame have a container window and a component window for the component.&lt;br /&gt;
&lt;br /&gt;
When a sub-frame is added to a surrounding frame, the frame becomes the parent of the sub-frame by a call to &amp;lt;code&amp;gt;setCreator()&amp;lt;/code&amp;gt; at the sub-frame. This happens internally when the method &amp;lt;code&amp;gt;append()&amp;lt;/code&amp;gt; is called at the &amp;lt;idl&amp;gt;com.sun.star.frame.XFrames&amp;lt;/idl&amp;gt; interface supplied by the surrounding frame.&lt;br /&gt;
&lt;br /&gt;
The section [[Documentation/DevGuide/OfficeDev/Creating Frames Manually|Creating Frames Manually]] shows examples for the usage of the &amp;lt;code&amp;gt;XFrame&amp;lt;/code&amp;gt; interface that creates frames in the desktop environment, constructs dockable and standalone windows, and inserts components into frames.&lt;br /&gt;
&lt;br /&gt;
=== Communication through Dispatch Framework ===&lt;br /&gt;
&lt;br /&gt;
Besides the main role of frames as expressed in the &amp;lt;idl&amp;gt;com.sun.star.frame.XFrame&amp;lt;/idl&amp;gt; interface, frames play another role by providing a communication context for the component they contain, that is, every communication from a controller to the desktop environment and the user interface, and conversely, is done through the frame. This aspect of a frame is published through the &amp;lt;idl&amp;gt;com.sun.star.frame.XDispatchProvider&amp;lt;/idl&amp;gt; interface, which uses special command requests to trigger actions.&lt;br /&gt;
&lt;br /&gt;
The section [[Documentation/DevGuide/OfficeDev/Using the Dispatch Framework|Using the Dispatch Framework]] discusses the usage of the dispatch API. &lt;br /&gt;
&lt;br /&gt;
=== Components in Frames ===&lt;br /&gt;
&lt;br /&gt;
The desktop environment section discussed the three kinds of viewable components that can be inserted into a frame. If the component has a controller &amp;#039;&amp;#039;and&amp;#039;&amp;#039; a model like a document, or if it has only a controller, such as the bibliography and database browser, it implements the &amp;lt;idl&amp;gt;com.sun.star.frame.Controller&amp;lt;/idl&amp;gt; service represented by the interface &amp;lt;idl&amp;gt;com.sun.star.frame.XController&amp;lt;/idl&amp;gt;. In the call to &amp;lt;idlml&amp;gt;com.sun.star.frame.XFrame:setComponent&amp;lt;/idlml&amp;gt;(), the controller is passed with the component window instance. If the component has no controller, it directly implements &amp;lt;idl&amp;gt;com.sun.star.lang.XComponent&amp;lt;/idl&amp;gt; and &amp;lt;idl&amp;gt;com.sun.star.awt.XWindow&amp;lt;/idl&amp;gt;. In this case, the component is passed as &amp;lt;code&amp;gt;XWindow&amp;lt;/code&amp;gt; parameter, and the &amp;lt;code&amp;gt;XController&amp;lt;/code&amp;gt; parameter must be an &amp;lt;code&amp;gt;XController&amp;lt;/code&amp;gt; reference set to null. &lt;br /&gt;
&lt;br /&gt;
If the viewable component is a &amp;#039;&amp;#039;trivial component&amp;#039;&amp;#039; (implementing &amp;lt;code&amp;gt;XWindow&amp;lt;/code&amp;gt; only), the frame holds a reference to the component window, controls the lifetime of the component and propagates certain events from the container window to the component window. If the viewable component is an &amp;#039;&amp;#039;office component&amp;#039;&amp;#039; (having a controller), the frame adds to these basic functions a set of features for integration of the component into the environment by supporting additional command URLs for the component at its &amp;lt;idl&amp;gt;com.sun.star.frame.XDispatchProvider&amp;lt;/idl&amp;gt; interface.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Office Development]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=File:AppEnvironment.png&amp;diff=94439</id>
		<title>File:AppEnvironment.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=File:AppEnvironment.png&amp;diff=94439"/>
		<updated>2008-10-04T17:14:06Z</updated>

		<summary type="html">&lt;p&gt;Cking: uploaded a new version of &amp;quot;Image:AppEnvironment.png&amp;quot;: oops.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=File:AppEnvironment.png&amp;diff=94438</id>
		<title>File:AppEnvironment.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=File:AppEnvironment.png&amp;diff=94438"/>
		<updated>2008-10-04T17:09:26Z</updated>

		<summary type="html">&lt;p&gt;Cking: uploaded a new version of &amp;quot;Image:AppEnvironment.png&amp;quot;: Made smallest font size 12, instead of 14.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/Frame-Controller-Model_Paradigm_in_Apache_OpenOffice&amp;diff=94431</id>
		<title>Documentation/DevGuide/OfficeDev/Frame-Controller-Model Paradigm in Apache OpenOffice</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/Frame-Controller-Model_Paradigm_in_Apache_OpenOffice&amp;diff=94431"/>
		<updated>2008-10-04T16:39:53Z</updated>

		<summary type="html">&lt;p&gt;Cking: dash, semicolons, &amp;amp; commas changed&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/OfficeDevTOC&lt;br /&gt;
|OfficeDev2a=block&lt;br /&gt;
|OfficeDevFramework=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/OfficeDev/Framework API&lt;br /&gt;
|NextPage=Documentation/DevGuide/OfficeDev/Frames&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Frame-Controller-Model Paradigm in OpenOffice.org}}&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.frame.XModel;com.sun.star.frame.XFrame;com.sun.star.frame.XController&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The well-known Model-View-Controller (MVC) paradigm separates three application areas: document data (&amp;#039;&amp;#039;model&amp;#039;&amp;#039;), presentation (&amp;#039;&amp;#039;view&amp;#039;&amp;#039;) and interaction (&amp;#039;&amp;#039;controller&amp;#039;&amp;#039;). {{PRODUCTNAME}} has a similar abstraction, called the Frame-Controller-Model (FCM) paradigm. The FCM paradigm shares certain aspects with MVC, but it has different purposes; therefore, it is best to approach FCM independently from MVC. The model and controller in MVC and FCM are quite different things.&lt;br /&gt;
&lt;br /&gt;
The FCM paradigm in {{PRODUCTNAME}} separates three application areas: document object (&amp;#039;&amp;#039;model&amp;#039;&amp;#039;), screen interaction with the model (&amp;#039;&amp;#039;controller&amp;#039;&amp;#039;) and controller-window linkage (&amp;#039;&amp;#039;frame&amp;#039;&amp;#039;). &lt;br /&gt;
&lt;br /&gt;
* The model holds the document data and has methods to change these data without using a controller object. Text, drawings, and spreadsheet cells are accessed directly at the model.&lt;br /&gt;
* The controller has knowledge about the current view status of the document and manipulates the screen presentation of the document, but not the document data. It observes changes made to the model, and can be duplicated to have multiple controllers for the same model.&lt;br /&gt;
* The frame contains the controller for a model and &amp;#039;&amp;#039;knows&amp;#039;&amp;#039; the windows that are used with it, but does not have window functionality.&lt;br /&gt;
&lt;br /&gt;
The purpose of FCM is to have three exchangeable parts that are used with an exchangeable window system:&lt;br /&gt;
&lt;br /&gt;
It is possible to write a new controller that presents an existing model in a different manner without changing the model or the frame. A controller depends on the model it presents; therefore, a new controller for a new model can be written.&lt;br /&gt;
&lt;br /&gt;
Developers can introduce new models for new document types without taking care of the frame and underlying window management system. However, since there is no default controller, it is necessary to write a suitable controller also.&lt;br /&gt;
&lt;br /&gt;
By keeping all window-related functionality separate from the frame, it is possible to use one single frame implementation for every possible window in the entire {{PRODUCTNAME}} application. Thus, the presentation of all visible components is customized by exchanging the frame implementation. At runtime you can access a frame and replace the controller, together with the model it controls, by a different controller instance.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Office Development]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/Desktop_Environment&amp;diff=94429</id>
		<title>Documentation/DevGuide/OfficeDev/Desktop Environment</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/Desktop_Environment&amp;diff=94429"/>
		<updated>2008-10-04T16:30:34Z</updated>

		<summary type="html">&lt;p&gt;Cking: Changed &amp;#039;Tools-Configure-Events&amp;#039; to &amp;quot;Tools-Customize-Events&amp;quot;.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/OfficeDevTOC&lt;br /&gt;
|OfficeDev2a=block&lt;br /&gt;
|OfficeDevUsing=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/OfficeDev/OpenOffice.org Application Environment&lt;br /&gt;
|NextPage=Documentation/DevGuide/OfficeDev/Framework API&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Desktop Environment}}&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The &amp;lt;idl&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idl&amp;gt; service is the central management instance for the {{PRODUCTNAME}} application framework. All {{PRODUCTNAME}} application windows are organized in a hierarchy of frames that contain viewable components. The desktop is the root frame for this hierarchy. From the desktop you can load viewable components, access frames and components, terminate the office, traverse the frame hierarchy and dispatch command requests.&lt;br /&gt;
&lt;br /&gt;
The name of this service originates at StarOffice 5.x, where all document windows were embedded into a common application window that was occupied by the StarOffice desktop, mirroring the Windows desktop. The root frame of this hierarchy was called the desktop frame. The name of this service and the interface name &amp;lt;idl&amp;gt;com.sun.star.frame.XDesktop&amp;lt;/idl&amp;gt; were kept for compatibility reasons.&lt;br /&gt;
&lt;br /&gt;
The desktop object and frame objects use auxiliary services, such as the &amp;lt;idl&amp;gt;com.sun.star.document.TypeDetection&amp;lt;/idl&amp;gt; service and other, opaque implementations that interact with the UNO-based office, but are not accessible through the {{PRODUCTNAME}} API. Examples for the latter are the global document event handling and its user interface (&amp;#039;&amp;#039;&amp;#039;Tools - Customize - Events&amp;#039;&amp;#039;&amp;#039;), and the menu bars that use the dispatch API without being UNO services themselves. The desktop service, together with these surrounding objects, is called the &amp;#039;&amp;#039;desktop environment&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:DesktopOverview.png|none|thumb|400px|The Desktop terminates the office and manages components and frames]]&lt;br /&gt;
&lt;br /&gt;
The viewable components managed by the desktop can be three different kinds of objects: full-blown office documents with a document model and controllers, components with a controller but no model, such as the bibliography and database browser, or simple windows without API-enabled controllers, for example, preview windows. The commonality between these types of components is the &amp;lt;idl&amp;gt;com.sun.star.lang.XComponent&amp;lt;/idl&amp;gt; interface. Components with controllers are also called office components, whereas simple window components are called trivial components.&lt;br /&gt;
&lt;br /&gt;
Frames in the {{PRODUCTNAME}} API are the connecting link between windows, components and the desktop environment. The relationship between frames and components is discussed in the next section,  [[Documentation/DevGuide/OfficeDev/Framework API|Framework API]].&lt;br /&gt;
&lt;br /&gt;
Like all other services, the &amp;lt;idl&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idl&amp;gt; service can be exchanged by another implementation that extends the functionality of {{PRODUCTNAME}}. By exchanging the desktop service it is possible to use different kinds of windows or to make {{PRODUCTNAME}} use MDI instead of SDI. This is not an easy thing to do, but it is possible without changing any code elsewhere in {{PRODUCTNAME}}.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Office Development]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/OpenOffice.org_Application_Environment&amp;diff=94427</id>
		<title>Documentation/DevGuide/OfficeDev/OpenOffice.org Application Environment</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/OpenOffice.org_Application_Environment&amp;diff=94427"/>
		<updated>2008-10-04T15:58:34Z</updated>

		<summary type="html">&lt;p&gt;Cking: Made picture full size, instead of thumb, to the text is clearer.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/OfficeDevTOC&lt;br /&gt;
|OfficeDev2a=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/OfficeDev/Office Development&lt;br /&gt;
|NextPage=Documentation/DevGuide/OfficeDev/Desktop Environment&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:{{PRODUCTNAME}} Application Environment}}&lt;br /&gt;
The {{PRODUCTNAME}} application environment is made up of the &amp;#039;&amp;#039;desktop environment&amp;#039;&amp;#039; and the &amp;#039;&amp;#039;framework API&amp;#039;&amp;#039;. &lt;br /&gt;
&lt;br /&gt;
[[Image:AppEnvironment.png|none|{{PRODUCTNAME}} Application Environment]]&lt;br /&gt;
&lt;br /&gt;
The desktop environment consists of the desktop and auxiliary objects. It employs the framework API to carry out its functions. The framework API has two parts: the &amp;#039;&amp;#039;component framework&amp;#039;&amp;#039; and &amp;#039;&amp;#039;dispatch framework&amp;#039;&amp;#039;. The component framework follows a special Frame-Controller-Model paradigm to manage components viewable in {{PRODUCTNAME}}. The dispatch framework handles command requests sent by the GUI.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Office Development]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=File:AppEnvironment.png&amp;diff=94426</id>
		<title>File:AppEnvironment.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=File:AppEnvironment.png&amp;diff=94426"/>
		<updated>2008-10-04T15:51:30Z</updated>

		<summary type="html">&lt;p&gt;Cking: uploaded a new version of &amp;quot;Image:AppEnvironment.png&amp;quot;: Put the two main components inside the application environment, so they won&amp;#039;t appear to be separate components.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/BASIC_Guide/StarDesktop&amp;diff=93842</id>
		<title>Documentation/BASIC Guide/StarDesktop</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/BASIC_Guide/StarDesktop&amp;diff=93842"/>
		<updated>2008-09-28T19:03:02Z</updated>

		<summary type="html">&lt;p&gt;Cking: Replaced {{OOo}} with OpenOffice.org in filtername value (still seems wrong)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:The StarDesktop}}&lt;br /&gt;
{{Documentation/BASICGuideTOC/v2&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|ShowPrevPage=block&lt;br /&gt;
|PrevPage=Documentation/BASIC Guide/Documents&lt;br /&gt;
|NextPage=Documentation/BASIC Guide/Templates&lt;br /&gt;
|docs=block&lt;br /&gt;
}} &lt;br /&gt;
 &lt;br /&gt;
When working with documents, there are two services which 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;
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. Unlike the old &amp;lt;tt&amp;gt;Application&amp;lt;/tt&amp;gt; object however it 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;
{{Documentation/Note|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;
&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 &amp;lt;tt&amp;gt;file:///&amp;lt;/tt&amp;gt; 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 &amp;lt;tt&amp;gt;test.odt&amp;lt;/tt&amp;gt; file in the doc directory on the C: drive.&lt;br /&gt;
&lt;br /&gt;
 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;
  &amp;#039; supplies file:///C:/doc/test.odt&lt;br /&gt;
MsgBox ConvertFromUrl(&amp;quot;file:///C:/doc/test.odt&amp;quot;)    &lt;br /&gt;
  &amp;#039;  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 ISO 8859-1 (ISO-Latin) 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 [[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. Alternatively, &amp;lt;tt&amp;gt;_hidden&amp;lt;/tt&amp;gt; can also be specified, and this ensures that the corresponding document is loaded but remains invisible. &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() &amp;#039;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 &amp;lt;tt&amp;gt;text.odt&amp;lt;/tt&amp;gt; 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;
{{Documentation/Note|&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; and &amp;lt;tt&amp;gt;_hidden&amp;lt;/tt&amp;gt; values for the &amp;lt;tt&amp;gt;Frame&amp;lt;/tt&amp;gt; parameter ensure 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 &amp;lt;tt&amp;gt;test.odt&amp;lt;/tt&amp;gt; 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 &amp;lt;tt&amp;gt;test2.odt&amp;lt;/tt&amp;gt; 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 &amp;lt;tt&amp;gt;\share\config\registry\instance\org\openoffice\office\TypeDetection.xml&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
;&amp;lt;tt&amp;gt;FilterOptions (String)&amp;lt;/tt&amp;gt;:defines additional options for filters.&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;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;:loads a read-only document.&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(0) 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:/csv.doc&amp;quot;&lt;br /&gt;
FileProperties(0).Name = &amp;quot;FilterName&amp;quot;&lt;br /&gt;
FileProperties(0).Value =&amp;quot;scalc: Text - txt - csv (OpenOffice.org Calc)&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; data field covers precisely one value because it records one option. 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.&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 &amp;lt;tt&amp;gt;\share\config\registry\instance\org\openoffice\office\TypeDetection.xml&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
;&amp;lt;tt&amp;gt;FilterOptions (String)&amp;lt;/tt&amp;gt;:defines additional options for 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;
&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;
&amp;#039; ... 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(sUrl, mFileProperties())&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;
&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(0) 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;
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   &amp;#039; corresponds to 20 cm&lt;br /&gt;
PaperSize.Height = 20000   &amp;#039; 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>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/BASIC_Guide/StarDesktop&amp;diff=93841</id>
		<title>Documentation/BASIC Guide/StarDesktop</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/BASIC_Guide/StarDesktop&amp;diff=93841"/>
		<updated>2008-09-28T18:11:14Z</updated>

		<summary type="html">&lt;p&gt;Cking: /* Compression of Files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:The StarDesktop}}&lt;br /&gt;
{{Documentation/BASICGuideTOC/v2&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|ShowPrevPage=block&lt;br /&gt;
|PrevPage=Documentation/BASIC Guide/Documents&lt;br /&gt;
|NextPage=Documentation/BASIC Guide/Templates&lt;br /&gt;
|docs=block&lt;br /&gt;
}} &lt;br /&gt;
 &lt;br /&gt;
When working with documents, there are two services which 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;
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. Unlike the old &amp;lt;tt&amp;gt;Application&amp;lt;/tt&amp;gt; object however it 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;
{{Documentation/Note|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;
&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 &amp;lt;tt&amp;gt;file:///&amp;lt;/tt&amp;gt; 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 &amp;lt;tt&amp;gt;test.odt&amp;lt;/tt&amp;gt; file in the doc directory on the C: drive.&lt;br /&gt;
&lt;br /&gt;
 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;
  &amp;#039; supplies file:///C:/doc/test.odt&lt;br /&gt;
MsgBox ConvertFromUrl(&amp;quot;file:///C:/doc/test.odt&amp;quot;)    &lt;br /&gt;
  &amp;#039;  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 ISO 8859-1 (ISO-Latin) 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 [[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. Alternatively, &amp;lt;tt&amp;gt;_hidden&amp;lt;/tt&amp;gt; can also be specified, and this ensures that the corresponding document is loaded but remains invisible. &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() &amp;#039;It is 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 &amp;lt;tt&amp;gt;text.odt&amp;lt;/tt&amp;gt; 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;
{{Documentation/Note|&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; and &amp;lt;tt&amp;gt;_hidden&amp;lt;/tt&amp;gt; values for the &amp;lt;tt&amp;gt;Frame&amp;lt;/tt&amp;gt; parameter ensure 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 &amp;lt;tt&amp;gt;test.odt&amp;lt;/tt&amp;gt; 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 &amp;lt;tt&amp;gt;test2.odt&amp;lt;/tt&amp;gt; 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 &amp;lt;tt&amp;gt;\share\config\registry\instance\org\openoffice\office\TypeDetection.xml&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
;&amp;lt;tt&amp;gt;FilterOptions (String)&amp;lt;/tt&amp;gt;:defines additional options for filters.&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;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;:loads a read-only document.&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(0) 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:/csv.doc&amp;quot;&lt;br /&gt;
FileProperties(0).Name = &amp;quot;FilterName&amp;quot;&lt;br /&gt;
FileProperties(0).Value =&amp;quot;scalc: Text - txt - csv ({{OOo}} Calc)&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; data field covers precisely one value because it records one option. 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.&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 &amp;lt;tt&amp;gt;\share\config\registry\instance\org\openoffice\office\TypeDetection.xml&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
;&amp;lt;tt&amp;gt;FilterOptions (String)&amp;lt;/tt&amp;gt;:defines additional options for 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;
&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;
&amp;#039; ... 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(sUrl, mFileProperties())&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;
&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(0) 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;
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   &amp;#039; corresponds to 20 cm&lt;br /&gt;
PaperSize.Height = 20000   &amp;#039; 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>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/BASIC_Guide/StarDesktop&amp;diff=93840</id>
		<title>Documentation/BASIC Guide/StarDesktop</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/BASIC_Guide/StarDesktop&amp;diff=93840"/>
		<updated>2008-09-28T18:05:24Z</updated>

		<summary type="html">&lt;p&gt;Cking: /* XML File Format */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:The StarDesktop}}&lt;br /&gt;
{{Documentation/BASICGuideTOC/v2&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|ShowPrevPage=block&lt;br /&gt;
|PrevPage=Documentation/BASIC Guide/Documents&lt;br /&gt;
|NextPage=Documentation/BASIC Guide/Templates&lt;br /&gt;
|docs=block&lt;br /&gt;
}} &lt;br /&gt;
 &lt;br /&gt;
When working with documents, there are two services which 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;
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. Unlike the old &amp;lt;tt&amp;gt;Application&amp;lt;/tt&amp;gt; object however it 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;
{{Documentation/Note|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;
&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 &amp;lt;tt&amp;gt;file:///&amp;lt;/tt&amp;gt; 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 &amp;lt;tt&amp;gt;test.odt&amp;lt;/tt&amp;gt; file in the doc directory on the C: drive.&lt;br /&gt;
&lt;br /&gt;
 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;
  &amp;#039; supplies file:///C:/doc/test.odt&lt;br /&gt;
MsgBox ConvertFromUrl(&amp;quot;file:///C:/doc/test.odt&amp;quot;)    &lt;br /&gt;
  &amp;#039;  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 ISO 8859-1 (ISO-Latin) 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 [[Documentation/BASIC Guide/StarDesktop#storeAsURL Method Options|storeAsURL Method Options]].&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. Alternatively, &amp;lt;tt&amp;gt;_hidden&amp;lt;/tt&amp;gt; can also be specified, and this ensures that the corresponding document is loaded but remains invisible. &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() &amp;#039;It is 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 &amp;lt;tt&amp;gt;text.odt&amp;lt;/tt&amp;gt; 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;
{{Documentation/Note|&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; and &amp;lt;tt&amp;gt;_hidden&amp;lt;/tt&amp;gt; values for the &amp;lt;tt&amp;gt;Frame&amp;lt;/tt&amp;gt; parameter ensure 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 &amp;lt;tt&amp;gt;test.odt&amp;lt;/tt&amp;gt; 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 &amp;lt;tt&amp;gt;test2.odt&amp;lt;/tt&amp;gt; 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 &amp;lt;tt&amp;gt;\share\config\registry\instance\org\openoffice\office\TypeDetection.xml&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
;&amp;lt;tt&amp;gt;FilterOptions (String)&amp;lt;/tt&amp;gt;:defines additional options for filters.&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;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;:loads a read-only document.&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(0) 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:/csv.doc&amp;quot;&lt;br /&gt;
FileProperties(0).Name = &amp;quot;FilterName&amp;quot;&lt;br /&gt;
FileProperties(0).Value =&amp;quot;scalc: Text - txt - csv ({{OOo}} Calc)&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; data field covers precisely one value because it records one option. 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.&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 &amp;lt;tt&amp;gt;\share\config\registry\instance\org\openoffice\office\TypeDetection.xml&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
;&amp;lt;tt&amp;gt;FilterOptions (String)&amp;lt;/tt&amp;gt;:defines additional options for 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;
&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;
&amp;#039; ... 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(sUrl, mFileProperties())&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;
&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(0) 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;
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   &amp;#039; corresponds to 20 cm&lt;br /&gt;
PaperSize.Height = 20000   &amp;#039; 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>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Basic/OpenOffice.org_Basic&amp;diff=93839</id>
		<title>Documentation/DevGuide/Basic/OpenOffice.org Basic</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Basic/OpenOffice.org_Basic&amp;diff=93839"/>
		<updated>2008-09-28T16:08:43Z</updated>

		<summary type="html">&lt;p&gt;Cking: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/BasicTOC&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Charts/How to Apply an Add-In to a Chart Document&lt;br /&gt;
|NextPage=Documentation/DevGuide/Basic/First Steps with OpenOffice.org Basic&lt;br /&gt;
}}&lt;br /&gt;
[[zh:Zh/Documentation/DevGuide/Basic/OpenOffice.org Basic]]&lt;br /&gt;
{{DISPLAYTITLE:{{OOo}} Basic}}&lt;br /&gt;
{{OOo}} Basic is used to create and manage macros and dialogs.  The following sections examine the usage of the {{OOo}} Basic programming environment.&lt;br /&gt;
&lt;br /&gt;
* [[Documentation/DevGuide/Basic/First Steps with OpenOffice.org Basic|First Steps with OpenOffice.org Basic]] guides you through the necessary steps to write {{OOo}} Basic UNO Programs. &lt;br /&gt;
* [[Documentation/DevGuide/Basic/OpenOffice.org Basic IDE|OpenOffice.org Basic IDE]] provides a reference to the functionality of the {{OOo}} Integrated Development Environment (IDE). It describes:&lt;br /&gt;
** The dialogs to manage Basic and dialog libraries.&lt;br /&gt;
** The functionality of the Basic IDE window: the Basic macro editor and debugger, and the Dialog editor.&lt;br /&gt;
** The assignment of macros to events&lt;br /&gt;
* [[Documentation/DevGuide/Basic/Features of OpenOffice.org Basic|Features of OpenOffice.org Basic]] describes the Basic programming language integrated in {{OOo}}, including&lt;br /&gt;
** Provides an overview about the general language features built into {{OOo}} Basic.&lt;br /&gt;
** Extends the UNO language binding chapter [[Documentation/DevGuide/ProUNO/Basic/OpenOffice.org Basic|OpenOffice.org Basic]] by information on how to access the application specific UNO API.&lt;br /&gt;
** Points out threading and rescheduling characteristics of {{OOo}} Basic that differ from other languages, such as, from Java, which can be important under certain circumstances.&lt;br /&gt;
* [[Documentation/DevGuide/Basic/Advanced Library Organization|Advanced Library Organization]] describes how the Basic library system stores and manages Basic macros and dialogs in {{OOo}}, and how the user can access libraries and library elements using the appropriate interfaces.&lt;br /&gt;
* [[Documentation/DevGuide/Basic/Programming Dialogs and Dialog Controls|Programming Dialogs and Dialog Controls]] describes the toolkit controls used to create dialogs in the dialog editor. In this section the different types of controls and their specific properties are explained in detail. &lt;br /&gt;
* [[Documentation/DevGuide/Basic/Creating Dialogs at Runtime|Creating Dialogs at Runtime]] describes how UNO dialogs can be created at runtime without using the dialog editor. This is useful to show dialogs from UNO components. As this is an advanced way to create dialogs, this section goes deeply into the Toolkit interfaces and extends the section [[Documentation/DevGuide/Basic/Programming Dialogs and Dialog Controls|Programming Dialogs and Dialog Controls]].&lt;br /&gt;
* [[Documentation/DevGuide/Basic/Library File Structure|Library File Structure]] discusses the various files used by the Basic IDE. &lt;br /&gt;
* [[Documentation/DevGuide/Basic/Library Deployment|Library Deployment]] discusses the automatic deployment of Basic libraries into a local or a shared {{OOo}} installation.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Basic and Dialogs]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Talk:Documentation/DevGuide/Basic/OpenOffice.org_Basic&amp;diff=93811</id>
		<title>Talk:Documentation/DevGuide/Basic/OpenOffice.org Basic</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Talk:Documentation/DevGuide/Basic/OpenOffice.org_Basic&amp;diff=93811"/>
		<updated>2008-09-28T02:51:51Z</updated>

		<summary type="html">&lt;p&gt;Cking: Title Change&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Title Change===&lt;br /&gt;
The previous title of this page was OpenOffice.org Basic and dialogs.  Dialogs are part of Basic, so there was no need to include dialogs in the title.  Therefore, I renamed the page to just OpenOffice.org Basic, and changed all links on the wiki that referred to the old page.  OpenOffice.org Basic.  A name you can sink your teeth into.--[[User:Cking|Cking]] 04:51, 28 September 2008 (CEST)&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Scripting/Scripting_Framework&amp;diff=93810</id>
		<title>Documentation/DevGuide/Scripting/Scripting Framework</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Scripting/Scripting_Framework&amp;diff=93810"/>
		<updated>2008-09-28T02:45:42Z</updated>

		<summary type="html">&lt;p&gt;Cking: Updated link to OOo Basic&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/ScriptingTOC&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Accessibility/XAccessibleHyperlink&lt;br /&gt;
|NextPage=Documentation/DevGuide/Scripting/Using the Scripting Framework&lt;br /&gt;
}}&lt;br /&gt;
[[zh:Zh/Documentation/DevGuide/Scripting/Scripting Framework]]&lt;br /&gt;
{{DISPLAYTITLE:Scripting Framework}}&lt;br /&gt;
A {{PRODUCTNAME}} macro is a short program used to automate a number of steps. The Scripting Framework is a new feature in {{PRODUCTNAME}} [VERSION]. It allows users to write and run macros for {{PRODUCTNAME}} in a number of programming and scripting languages including:&lt;br /&gt;
&lt;br /&gt;
* BeanShell (http://www.beanshell.org/)&lt;br /&gt;
* JavaScript (http://www.mozilla.org/rhino/)&lt;br /&gt;
* Java ([http://www.java.com/ http://www.java.com])&lt;br /&gt;
* {{PRODUCTNAME}} Basic [[Documentation/DevGuide/Basic/OpenOffice.org Basic|OpenOffice.org Basic]]&lt;br /&gt;
The framework is designed so that developers can add support for new languages.&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|In this chapter, the terms &amp;#039;&amp;#039;macro&amp;#039;&amp;#039; and &amp;#039;&amp;#039;script&amp;#039;&amp;#039; are interchangeable.}}&lt;br /&gt;
&lt;br /&gt;
=== Structure of this Chapter ===&lt;br /&gt;
&lt;br /&gt;
This chapter is organized into the following sections:&lt;br /&gt;
&lt;br /&gt;
* Section [[Documentation/DevGuide/Scripting/Using the Scripting Framework|Using the Scripting Framework]] describes the user interface features of the Scripting Framework&lt;br /&gt;
** Describes how to run a macro using the Run Macro dialog.&lt;br /&gt;
** Describes how to use the Organizer dialogs to create, edit and manage macros.&lt;br /&gt;
* Section [[Documentation/DevGuide/Scripting/Writing Macros|Writing Macros]] provides a guide on how to get started with writing Scripting Framework macros&lt;br /&gt;
** Describes how to write a simple HelloWorld macro.&lt;br /&gt;
** Describes how Scripting Framework macros interact with {{PRODUCTNAME}} and the {{PRODUCTNAME}} API.&lt;br /&gt;
** Describes how to create a dialog from a Scripting Framework macro.&lt;br /&gt;
** Describes how to compile and deploy a Java macro.&lt;br /&gt;
* Section [[Documentation/DevGuide/Scripting/How the Scripting Framework Works|How the Scripting Framework Works]] describes how the plug-able architecture of the Scripting Framework allows support for new scripting languages to be added easily.&lt;br /&gt;
* Section [[Documentation/DevGuide/Scripting/Writing a LanguageScriptProvider UNO Component using the Java Helper Classes|Writing a LanguageScriptProvider UNO Component using the Java Helper Classes]] describes how to use the Scripting Framework Java helper classes to add support for a new scripting language&lt;br /&gt;
** Describes how to use the ScriptProvider abstract base class.&lt;br /&gt;
** Describes how to add editor and management support.&lt;br /&gt;
** Describes how to build and register a ScriptProvider.&lt;br /&gt;
* Section [[Documentation/DevGuide/Scripting/Writing a LanguageScriptProvider UNO Component From Scratch|Writing a LanguageScriptProvider UNO Component From Scratch]] describes how to write a LanguageScriptProvider UNO component.&lt;br /&gt;
&lt;br /&gt;
=== Who Should Read this Chapter ===&lt;br /&gt;
&lt;br /&gt;
If you are interested in automating {{PRODUCTNAME}} using BeanShell, JavaScript, Java or {{PRODUCTNAME}} Basic then you should read sections [[Documentation/DevGuide/Scripting/Using the Scripting Framework|Using the Scripting Framework]] and [[Documentation/DevGuide/Scripting/Writing Macros|Writing Macros]].&lt;br /&gt;
&lt;br /&gt;
If you are interested in adding support to run and write macros in a language with a Java based interpreter then you should read section [[Documentation/DevGuide/Scripting/Writing a LanguageScriptProvider UNO Component using the Java Helper Classes|Writing a LanguageScriptProvider UNO Component using the Java Helper Classes]].&lt;br /&gt;
&lt;br /&gt;
If you are interested in adding support for a scripting language from scratch then you should read section [[Documentation/DevGuide/Scripting/Writing a LanguageScriptProvider UNO Component From Scratch|Writing a LanguageScriptProvider UNO Component From Scratch]].&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Scripting]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Scripting/Basic_and_Dialogs&amp;diff=93809</id>
		<title>Documentation/DevGuide/Scripting/Basic and Dialogs</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Scripting/Basic_and_Dialogs&amp;diff=93809"/>
		<updated>2008-09-28T02:44:39Z</updated>

		<summary type="html">&lt;p&gt;Cking: Updated link to OOo Basic&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/ScriptingTOC&lt;br /&gt;
|Scripting2b=block&lt;br /&gt;
|ScriptingEdit=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Scripting/JavaScript Editor&lt;br /&gt;
|NextPage=Documentation/DevGuide/Scripting/Macro Recording&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Basic and Dialogs}}&lt;br /&gt;
The {{PRODUCTNAME}} Basic and Dialog Organizers are described in the [[Documentation/DevGuide/Basic/OpenOffice.org Basic|OpenOffice.org Basic]] chapter.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Scripting]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/GUI/Graphical_User_Interfaces&amp;diff=93808</id>
		<title>Documentation/DevGuide/GUI/Graphical User Interfaces</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/GUI/Graphical_User_Interfaces&amp;diff=93808"/>
		<updated>2008-09-28T02:43:34Z</updated>

		<summary type="html">&lt;p&gt;Cking: Updated link to OOo Basic&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/GUITOC&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Scripting/Integration with Extension Manager&lt;br /&gt;
|NextPage=Documentation/DevGuide/GUI/Exception Handling&lt;br /&gt;
}}&lt;br /&gt;
[[zh:Zh/Documentation/DevGuide/GUI/Graphical User Interfaces]]&lt;br /&gt;
{{DISPLAYTITLE:Graphical User Interfaces}}&lt;br /&gt;
The &amp;lt;idlmodule&amp;gt;com.sun.star.awt&amp;lt;/idlmodule&amp;gt; API-module is used to access and design user interface features. The concepts that this module are based on are similar to java.awt. This module provides services and interfaces to create and handle the large set of GUI elements that are demanded by today&amp;#039;s modern components. This chapter is directed to extension developers who want to add functionality to their {{PRODUCTNAME}} application and want to create a consistent user interface.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Details ===&lt;br /&gt;
&lt;br /&gt;
You can use the UNO module Abstract Window Toolkit (UNO-AWT) to create a graphical user interface. The concept of UNO-AWT is based on Java/AWT. Java provides the AWT and Swing user interface design packages within its Java Foundation Classes class library. The implementation of java.awt components is based on the implementation of the peer components of the operating system. This is known as a &amp;quot;heavyweight&amp;quot; implementation. &amp;lt;idlmodule&amp;gt;com.sun.star.awt&amp;lt;/idlmodule&amp;gt; components are lightweight controls because their implementation is based solely on {{PRODUCTNAME}}. This gives you platform independence. The functionality of heavyweight controls may only be as high as the lowest common denominator of all involved operating systems, however, OpenOffice UI components are meant to emulate the design of the corresponding components of the operating system. The layer responsible for this is called VCL or Visual Class Library. The layer on top of the VCL is the Toolkit layer. This layer maps all interfaces of &amp;lt;idlmodule&amp;gt;com.sun.star.awt&amp;lt;/idlmodule&amp;gt; to VCL. &lt;br /&gt;
&lt;br /&gt;
=== Basic Concepts ===&lt;br /&gt;
&lt;br /&gt;
The basic concepts that are used in &amp;lt;idlmodule&amp;gt;com.sun.star.awt&amp;lt;/idlmodule&amp;gt; are described in previous chapters:&lt;br /&gt;
&lt;br /&gt;
* [[Documentation/DevGuide/ProUNO/Event Model|Event Model]] describes how to use event listeners at controls. With Event-Listeners at controls you can determine how a window reacts to mouse or keyboard driven events.&lt;br /&gt;
* [[Documentation/DevGuide/ProUNO/Exceptions|Exceptions]] explains how to handle errors as Exceptions. &lt;br /&gt;
* [[Documentation/DevGuide/ProUNO/Introduction|Introduction]] describes factories.&lt;br /&gt;
* [[Documentation/DevGuide/ProUNO/Data Types|Data Types]] describes the basic UNO types, and provides information about how to convert these types to and from various target languages.&lt;br /&gt;
* [[Documentation/DevGuide/Basic/OpenOffice.org Basic|OpenOffice.org Basic]] provides information for developers who want to implement Basic macros.&lt;br /&gt;
* [[Documentation/DevGuide/WritingUNO/Accessing Dialogs|Accessing Dialogs]] explains how dialogs created with the dialog engine can be embedded within {{PRODUCTNAME}} extensions.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Graphical User Interfaces]]&lt;/div&gt;</summary>
		<author><name>Cking</name></author>
	</entry>
</feed>