Difference between revisions of "Documentation/BASIC Guide/UNO Tools"

From Apache OpenOffice Wiki
Jump to: navigation, search
 
m (Debugging tools)
 
(16 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 +
{{DISPLAYTITLE:Tools for Working With UNO}}
 
{{Documentation/BASICGuideTOC/v2
 
{{Documentation/BASICGuideTOC/v2
 
|ShowPrevNext=block
 
|ShowPrevNext=block
Line 5: Line 6:
 
|NextPage=Documentation/BASIC Guide/Interface Overview
 
|NextPage=Documentation/BASIC Guide/Interface Overview
 
|api=block
 
|api=block
}}<!-- {{DISPLAYTITLE:Tools for Working With UNO -->
+
}}
 
+
 
+
= Tools for Working with UNO =
+
 
+
 
The question remains as to which objects — or services if we are going to remain with UNO terminology — support which properties, methods and interfaces and how these can be determined. In addition to this guide, you can get more information about objects from the following sources: the <tt>supportsService</tt> method, the debug methods as well as the Developer's Guide, and the API reference.  
 
The question remains as to which objects — or services if we are going to remain with UNO terminology — support which properties, methods and interfaces and how these can be determined. In addition to this guide, you can get more information about objects from the following sources: the <tt>supportsService</tt> method, the debug methods as well as the Developer's Guide, and the API reference.  
  
 
== The <tt>supportsService</tt> Method ==
 
== The <tt>supportsService</tt> Method ==
  
A number of UNO objects support the <tt>supportsService</tt> method, with which you can establish whether an object supports a particular service. The following call, for example, determines whether the <tt>TextElement</tt> object supports the <tt>com.sun.star.text.Paragraph</tt> service.
+
A number of UNO objects support the <tt>supportsService</tt> method, with which you can establish whether an object supports a particular service. The following call, for example, determines whether the <tt>TextElement</tt> object supports the <idl>com.sun.star.text.Paragraph</idl> service.
  
Ok = TextElement.supportsService("com.sun.star.text.Paragraph")
+
<source lang="oobas">
 +
Ok = TextElement.supportsService("com.sun.star.text.Paragraph")
 +
</source>
  
 
== Debug Properties ==
 
== Debug Properties ==
  
Every UNO object in {{OOo}} Basic knows what properties, methods and interfaces it already contains. It provides properties that return these in the form of a list. The corresponding properties are:  
+
Every UNO object knows what properties, methods and interfaces it already contains. {{OOo}} Basic provides properties that return these in the form of a string containing a list. The corresponding properties are:  
  
 
;<tt>DBG_properties</tt>:returns a string containing all properties of an object
 
;<tt>DBG_properties</tt>:returns a string containing all properties of an object
 
;<tt>DBG_methods</tt>:returns a string containing all methods of an object  
 
;<tt>DBG_methods</tt>:returns a string containing all methods of an object  
;<tt>DBG_supportetInterfaces</tt>:returns a string containing all interfaces which support an object.
+
;<tt>DBG_supportedInterfaces</tt>:returns a string containing all interfaces which support an object.
  
The following program code shows how <tt>DBG_properties</tt> and <tt>DBG_methods</tt> can be used in real-life applications. It first creates the <tt>com.sun.star.frame.Desktop</tt> service and then displays the supported properties and methods in message boxes.
+
The following program code shows how <tt>DBG_properties</tt> and <tt>DBG_methods</tt> can be used in real-life applications. It first creates the <idl>com.sun.star.frame.Desktop</idl> service and then displays the supported properties and methods in message boxes.
  
Dim Obj As Object
+
<source lang="oobas">
Obj = createUnoService("com.sun.star.frame.Desktop")
+
Dim Obj As Object
+
Obj = createUnoService("com.sun.star.frame.Desktop")
MsgBox Obj.DBG_Propierties
+
MsgBox Obj.DBG_methods
+
  
When using <tt>DBG_properties</tt>, note that the function returns all properties that one particular service can theoretically support. No assurances are, however, provided for whether these can also be used by the object in question. Before calling up properties, you must therefore use the <tt>IsEmpty</tt> function to check whether this is actually available.
+
MsgBox Obj.DBG_Properties
 +
MsgBox Obj.DBG_methods
 +
</source>
 +
 
 +
When using <tt>DBG_properties</tt>, note that the function returns all properties that the services offered by the object can theoretically support. No assurances are, however, provided for whether these can also be used by the object in question. In very rare cases, before calling up some property, use the <tt>IsEmpty</tt> function to check whether it is actually available.
 +
 
 +
== Debugging tools ==
 +
Using the '''<tt>DBG_</tt>''' properties is a very crude method to discover the contents of an API objects.
 +
 
 +
The watch window of the Basic IDE can display the properties of a Uno object (but not the methods, not the interfaces).
 +
 
 +
To display all information available from an object and link to the corresponding API documentation, use instead <b>[[Extensions_development_basic#Xray_tool|Xray tool]] or [http://extensions.services.openoffice.org/project/MRI MRI tool]</b>.
 +
 
 +
{{Documentation/VBAnote|{{OOo}} Basic does '''not''' provide code completion. Only at run-time can you find out which properties or methods are available for an object. All the above debug tools work on a running program. }}
  
 
== API Reference ==
 
== API Reference ==
Line 40: Line 51:
 
More information about the available services, and their interfaces, methods and properties can be found in the [http://api.openoffice.org/docs/common/ref/com/sun/star/module-ix.html reference for the {{OOo}} API].
 
More information about the available services, and their interfaces, methods and properties can be found in the [http://api.openoffice.org/docs/common/ref/com/sun/star/module-ix.html reference for the {{OOo}} API].
  
 
+
 +
{{InterWiki Languages BasicGuide|articletitle=Documentation/BASIC Guide/UNO Tools}}
 
{{PDL1}}
 
{{PDL1}}

Latest revision as of 06:36, 1 May 2016


The question remains as to which objects — or services if we are going to remain with UNO terminology — support which properties, methods and interfaces and how these can be determined. In addition to this guide, you can get more information about objects from the following sources: the supportsService method, the debug methods as well as the Developer's Guide, and the API reference.

The supportsService Method

A number of UNO objects support the supportsService method, with which you can establish whether an object supports a particular service. The following call, for example, determines whether the TextElement object supports the com.sun.star.text.Paragraph service.

Ok = TextElement.supportsService("com.sun.star.text.Paragraph")

Debug Properties

Every UNO object knows what properties, methods and interfaces it already contains. Apache OpenOffice Basic provides properties that return these in the form of a string containing a list. The corresponding properties are:

DBG_properties
returns a string containing all properties of an object
DBG_methods
returns a string containing all methods of an object
DBG_supportedInterfaces
returns a string containing all interfaces which support an object.

The following program code shows how DBG_properties and DBG_methods can be used in real-life applications. It first creates the com.sun.star.frame.Desktop service and then displays the supported properties and methods in message boxes.

Dim Obj As Object
Obj = createUnoService("com.sun.star.frame.Desktop")
 
MsgBox Obj.DBG_Properties
MsgBox Obj.DBG_methods

When using DBG_properties, note that the function returns all properties that the services offered by the object can theoretically support. No assurances are, however, provided for whether these can also be used by the object in question. In very rare cases, before calling up some property, use the IsEmpty function to check whether it is actually available.

Debugging tools

Using the DBG_ properties is a very crude method to discover the contents of an API objects.

The watch window of the Basic IDE can display the properties of a Uno object (but not the methods, not the interfaces).

To display all information available from an object and link to the corresponding API documentation, use instead Xray tool or MRI tool.

Documentation note.png VBA : Apache OpenOffice Basic does not provide code completion. Only at run-time can you find out which properties or methods are available for an object. All the above debug tools work on a running program.


API Reference

More information about the available services, and their interfaces, methods and properties can be found in the reference for the Apache OpenOffice API.


Content on this page is licensed under the Public Documentation License (PDL).
Personal tools