<?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=Beppec56</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=Beppec56"/>
	<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/wiki/Special:Contributions/Beppec56"/>
	<updated>2026-11-21T11:08:23Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.14</generator>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Text/Printing_Text_Documents&amp;diff=132480</id>
		<title>Documentation/DevGuide/Text/Printing Text Documents</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Text/Printing_Text_Documents&amp;diff=132480"/>
		<updated>2009-06-20T16:36:31Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/TextTOC&lt;br /&gt;
|Text2a=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Text/Saving Text Documents&lt;br /&gt;
|NextPage=Documentation/DevGuide/Text/Working with Text Documents&lt;br /&gt;
}}&lt;br /&gt;
{{Documentation/DevGuideLanguages|Documentation/DevGuide/Text/{{SUBPAGENAME}}}} &lt;br /&gt;
 {{DISPLAYTITLE:Printing Text Documents}}&lt;br /&gt;
=== Printer and Print Job Settings ===&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.view.XPrintable&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
Printing is a common office functionality. The chapter [[Documentation/DevGuide/OfficeDev/Office Development|Office Development]] provides in-depth information about it. The writer document implements the &amp;lt;idl&amp;gt;com.sun.star.view.XPrintable&amp;lt;/idl&amp;gt; interface for printing. It consists of three methods:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  sequence&amp;lt; com::sun::star::beans::PropertyValue &amp;gt; getPrinter ()&lt;br /&gt;
  void setPrinter ( [in] sequence&amp;lt; com::sun::star::beans::PropertyValue &amp;gt; aPrinter)&lt;br /&gt;
  void print ( [in] sequence&amp;lt; com::sun::star::beans::PropertyValue &amp;gt; xOptions)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The following code is used with a given document xDoc to print to the standard printer without any settings: &lt;br /&gt;
&amp;lt;!--[SOURCE:Text/TextDocuments.java]--&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // query the XPrintable interface from your document&lt;br /&gt;
  XPrintable xPrintable = (XPrintable)UnoRuntime.queryInterface(XPrintable.class, xDoc);&lt;br /&gt;
  &lt;br /&gt;
  // create an empty printOptions array&lt;br /&gt;
  PropertyValue[] printOpts = new PropertyValue[0];&lt;br /&gt;
  &lt;br /&gt;
  // kick off printing&lt;br /&gt;
  xPrintable.print(printOpts);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
There are two groups of properties involved in general printing. The first one is used with &amp;lt;code&amp;gt;setPrinter()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;getPrinter()&amp;lt;/code&amp;gt; that controls the printer, and the second one is passed to &amp;lt;code&amp;gt;print()&amp;lt;/code&amp;gt; and controls the print job.&lt;br /&gt;
&lt;br /&gt;
[http://api.openoffice.org/docs/common/ref/com/sun/star/view/PrinterDescriptor.html :com.sun.star.view.PrinterDescriptor] comprises the properties for the printer:&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;
!colspan=&amp;quot;2&amp;quot;|Properties of &amp;lt;idl&amp;gt;com.sun.star.view.PrinterDescriptor&amp;lt;/idl&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.view.PrinterDescriptor:Name&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; - Specifies the name of the printer queue to be used. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.view.PrinterDescriptor:PaperOrientation&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;idl&amp;gt;com.sun.star.view.PaperOrientation&amp;lt;/idl&amp;gt;. Specifies the orientation of the paper.  &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.view.PrinterDescriptor:PaperFormat&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;idl&amp;gt;com.sun.star.view.PaperFormat&amp;lt;/idl&amp;gt;. Specifies a predefined paper size or if the paper size is a user-defined size. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.view.PrinterDescriptor:PaperSize&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;idl&amp;gt;com.sun.star.awt.Size&amp;lt;/idl&amp;gt;. Specifies the size of the paper in 1/100 mm. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.view.PrinterDescriptor:IsBusy&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; - Indicates if the printer is busy. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.view.PrinterDescriptor:CanSetPaperOrientation&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; - Indicates if the printer allows changes to &amp;lt;code&amp;gt;PaperOrientation&amp;lt;/code&amp;gt;. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.view.PrinterDescriptor:CanSetPaperFormat&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; - Indicates if the printer allows changes to &amp;lt;code&amp;gt;PaperFormat&amp;lt;/code&amp;gt;. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.view.PrinterDescriptor:CanSetPaperSize&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; - Indicates if the printer allows changes to &amp;lt;code&amp;gt;PaperSize&amp;lt;/code&amp;gt;. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;idl&amp;gt;com.sun.star.view.PrintOptions&amp;lt;/idl&amp;gt; contains the following possibilities for a print job:&lt;br /&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;
!colspan=&amp;quot;2&amp;quot;|Properties of &amp;lt;idl&amp;gt;com.sun.star.view.PrintOptions&amp;lt;/idl&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.view.PrintOptions:CopyCount&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;short&amp;lt;/code&amp;gt; - Specifies the number of copies to print. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.view.PrintOptions:FileName&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; - Specifies the name of a file to print to, if set. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.view.PrintOptions:Collate&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; - Advises the printer to collate the pages of the copies. If true, a whole document is printed prior to the next copy, otherwise the page copies are completed together. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.view.PrintOptions:Pages&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; - Specifies the pages to print in the same format as in the print dialog of the GUI (e.g. &amp;quot;1, 3, 4-7, 9-&amp;quot;) &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.view.PrintOptions:Wait&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; - Advises that the print job should be performed synchronously, i.e. wait until printing is complete before returning from printing. Otherwise return is immediate and following actions (e.g. closing the corresponding model) may fail until printing is complete. Default is false.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following method uses &amp;lt;code&amp;gt;PrinterDescriptor&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PrintOptions&amp;lt;/code&amp;gt; to print to a special printer, and preselect the pages to print. &lt;br /&gt;
&amp;lt;!--[SOURCE:Text/TextDocuments.java]--&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  protected void printDocComponent(XComponent xDoc) throws java.lang.Exception {&lt;br /&gt;
      XPrintable xPrintable = (XPrintable)UnoRuntime.queryInterface(XPrintable.class, xDoc);&lt;br /&gt;
      PropertyValue[] printerDesc = new PropertyValue[1];&lt;br /&gt;
      printerDesc[0] = new PropertyValue();&lt;br /&gt;
      printerDesc[0].Name = &amp;quot;Name&amp;quot;;&lt;br /&gt;
      printerDesc[0].Value = &amp;quot;5D PDF Creator&amp;quot;; &lt;br /&gt;
  &lt;br /&gt;
      xPrintable.setPrinter(printerDesc); &lt;br /&gt;
  &lt;br /&gt;
      PropertyValue[] printOpts = new PropertyValue[1];&lt;br /&gt;
      printOpts[0] = new PropertyValue();&lt;br /&gt;
      printOpts[0].Name = &amp;quot;Pages&amp;quot;;&lt;br /&gt;
      printOpts[0].Value = &amp;quot;3-5,7&amp;quot;; &lt;br /&gt;
  &lt;br /&gt;
      xPrintable.print(printOpts);&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Printing Multiple Pages on one Page ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.text.XPagePrintable&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The interface &amp;lt;idl&amp;gt;com.sun.star.text.XPagePrintable&amp;lt;/idl&amp;gt; is used to print more than one document page to a single printed page. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  sequence&amp;lt; com::sun::star::beans::PropertyValue &amp;gt; getPagePrintSettings()&lt;br /&gt;
  void setPagePrintSettings( [in] sequence&amp;lt; com::sun::star::beans::PropertyValue &amp;gt; aSettings)&lt;br /&gt;
  void printPages( [in] sequence&amp;lt; com::sun::star::beans::PropertyValue &amp;gt; xOptions) &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The first two methods &amp;lt;code&amp;gt;getPagePrintSettings()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;setPagePrintSettings()&amp;lt;/code&amp;gt; control the page printing. They use a sequence of &amp;lt;idl&amp;gt;com.sun.star.beans.PropertyValue&amp;lt;/idl&amp;gt;s whose possible values are defined in &amp;lt;idl&amp;gt;com.sun.star.text.PagePrintSettings&amp;lt;/idl&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;
!colspan=&amp;quot;2&amp;quot;|Properties of &amp;lt;idl&amp;gt;com.sun.star.text.PagePrintSettings&amp;lt;/idl&amp;gt;  &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.text.PagePrintSettings:PageRows&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;short&amp;lt;/code&amp;gt; - Number of rows in which document pages should appear on the output page. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.text.PagePrintSettings:PageColumns&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;short&amp;lt;/code&amp;gt; - Number of columns in which document pages should appear on the output page. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.text.PagePrintSettings:LeftMargin&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;long&amp;lt;/code&amp;gt; - Left margin on the output page. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.text.PagePrintSettings:RightMargin&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;long&amp;lt;/code&amp;gt; - Right margin on the output page. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.text.PagePrintSettings:TopMargin&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;long&amp;lt;/code&amp;gt; - Top margin on the output page. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.text.PagePrintSettings:BottomMargin&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;long&amp;lt;/code&amp;gt; - Bottom margin on the output page. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.text.PagePrintSettings:HoriMargin&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;long&amp;lt;/code&amp;gt; - Margin between the columns on the output page. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.text.PagePrintSettings:VertMargin&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;long&amp;lt;/code&amp;gt; - Margin between the rows on the output page. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.text.PagePrintSettings:IsLandscape&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; - Determines if the output page is in landscape format. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The method &amp;lt;code&amp;gt;printPages()&amp;lt;/code&amp;gt; prints the document according to the previous settings. The argument for the &amp;lt;code&amp;gt;printPages()&amp;lt;/code&amp;gt; method may contain the &amp;lt;code&amp;gt;PrintOptions&amp;lt;/code&amp;gt; as described in the section above (containing the properties &amp;lt;code&amp;gt;CopyCount&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;FileName&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Collate&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Pages&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Text Documents]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Text/Saving_Text_Documents&amp;diff=132479</id>
		<title>Documentation/DevGuide/Text/Saving Text Documents</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Text/Saving_Text_Documents&amp;diff=132479"/>
		<updated>2009-06-20T16:33:46Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/TextTOC&lt;br /&gt;
|Text2a=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Text/Handling Text Document Files&lt;br /&gt;
|NextPage=Documentation/DevGuide/Text/Printing Text Documents&lt;br /&gt;
}}&lt;br /&gt;
{{Documentation/DevGuideLanguages|Documentation/DevGuide/Text/{{SUBPAGENAME}}}} &lt;br /&gt;
 {{DISPLAYTITLE:Saving Text Documents}}&lt;br /&gt;
=== Storing ===&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.frame.XStorable&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
Documents are storable through their interface &amp;lt;idl&amp;gt;com.sun.star.frame.XStorable&amp;lt;/idl&amp;gt;. This interface is discussed in detail in [[Documentation/DevGuide/OfficeDev/Office Development|Office Development]]. An &amp;lt;code&amp;gt;XStorable&amp;lt;/code&amp;gt; implements these operations:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  boolean hasLocation()&lt;br /&gt;
  string getLocation()&lt;br /&gt;
  boolean isReadonly()&lt;br /&gt;
  void store() &lt;br /&gt;
  void storeAsURL( [in] string aURL, sequence&amp;lt; com::sun::star::beans::PropertyValue &amp;gt; aArgs)&lt;br /&gt;
  void storeToURL( [in] string aURL, sequence&amp;lt; com::sun::star::beans::PropertyValue &amp;gt; aArgs) &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The method names are evident. The method &amp;lt;code&amp;gt;storeAsUrl()&amp;lt;/code&amp;gt; is the exact representation of &amp;#039;&amp;#039;&amp;#039;File - Save As&amp;#039;&amp;#039;&amp;#039;,that is, it changes the current document location. In contrast, &amp;lt;code&amp;gt;storeToUrl()&amp;lt;/code&amp;gt; stores a copy to a new location, but leaves the current document URL untouched. &lt;br /&gt;
&lt;br /&gt;
=== Exporting ===&lt;br /&gt;
&lt;br /&gt;
For exporting purposes, a filter name can be passed to &amp;lt;code&amp;gt;storeAsURL()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;storeToURL()&amp;lt;/code&amp;gt; that triggers an export to other file formats. The property needed for this purpose is the string argument FilterName that takes filter names defined in the configuration file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;OfficePath&amp;gt;\share\config\registry\instance\org\openoffice\Office\TypeDetection.xml&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
In &amp;#039;&amp;#039;TypeDetection.xml&amp;#039;&amp;#039;, look for &amp;lt;code&amp;gt;&amp;lt;Filter/&amp;gt;&amp;lt;/code&amp;gt; elements, their &amp;lt;code&amp;gt;cfg:name&amp;lt;/code&amp;gt; attribute contains the needed strings for &amp;lt;code&amp;gt;FilterName&amp;lt;/code&amp;gt;. The proper filter name for StarWriter 5.x is &amp;quot;StarWriter 5.0&amp;quot;, and the export format &amp;quot;MS Word 97&amp;quot; is also popular. This is the element in &amp;#039;&amp;#039;TypeDetection.xml&amp;#039;&amp;#039; that describes the MS Word 97 filter:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;Filter cfg:name=&amp;quot;MS Word 97&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;Installed cfg:type=&amp;quot;boolean&amp;quot;&amp;gt;true&amp;lt;/Installed&amp;gt; &lt;br /&gt;
     &amp;lt;UIName cfg:type=&amp;quot;string&amp;quot; cfg:localized=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
       &amp;lt;cfg:value xml:lang=&amp;quot;en-US&amp;quot;&amp;gt;Microsoft Word 97/2000/XP&amp;lt;/cfg:value&amp;gt; &lt;br /&gt;
     &amp;lt;/UIName&amp;gt;&lt;br /&gt;
     &amp;lt;Data cfg:type=&amp;quot;string&amp;quot;&amp;gt;3,writer_MS_Word_97,com.sun.star.text.TextDocument,,67,CWW8,0,,&amp;lt;/Data&amp;gt; &lt;br /&gt;
  &amp;lt;/Filter&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The following method stores a document using this filter: &lt;br /&gt;
&amp;lt;!--[SOURCE:Text/TextDocuments.java]--&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  /** Store a document, using the MS Word 97/2000/XP Filter */&lt;br /&gt;
      protected void storeDocComponent(XComponent xDoc, String storeUrl) throws java.lang.Exception {&lt;br /&gt;
  &lt;br /&gt;
          XStorable xStorable = (XStorable)UnoRuntime.queryInterface(XStorable.class, xDoc);&lt;br /&gt;
          PropertyValue[] storeProps = new PropertyValue[1];&lt;br /&gt;
          storeProps[0] = new PropertyValue();&lt;br /&gt;
          storeProps[0].Name = &amp;quot;FilterName&amp;quot;;&lt;br /&gt;
          storeProps[0].Value = &amp;quot;MS Word 97&amp;quot;; &lt;br /&gt;
          xStorable.storeAsURL(storeUrl, storeProps); &lt;br /&gt;
      } &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If an empty array of &amp;lt;code&amp;gt;PropertyValue&amp;lt;/code&amp;gt; structs is passed, the native &amp;#039;&amp;#039;.odt&amp;#039;&amp;#039; format of {{PRODUCTNAME}} is used.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Text Documents]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Text/Handling_Text_Document_Files&amp;diff=132478</id>
		<title>Documentation/DevGuide/Text/Handling Text Document Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Text/Handling_Text_Document_Files&amp;diff=132478"/>
		<updated>2009-06-20T16:31:12Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/TextTOC&lt;br /&gt;
|Text2a=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Text/Example: Visible Cursor Position&lt;br /&gt;
|NextPage=Documentation/DevGuide/Text/Saving Text Documents&lt;br /&gt;
}}&lt;br /&gt;
{{Documentation/DevGuideLanguages|Documentation/DevGuide/Text/{{SUBPAGENAME}}}} &lt;br /&gt;
 {{DISPLAYTITLE:Handling Text Document Files}}&lt;br /&gt;
=== Creating and Loading Text Documents ===&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.frame.XComponentLoader&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
If a document in {{PRODUCTNAME}} is required, begin by getting a &amp;lt;idl&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idl&amp;gt; service from the service manager. The desktop handles all document components in {{PRODUCTNAME}}, among other things. It is discussed thoroughly in the chapter [[Documentation/DevGuide/OfficeDev/Office Development|Office Development]]. Office documents are often called components, because they support the &amp;lt;idl&amp;gt;com.sun.star.lang.XComponent&amp;lt;/idl&amp;gt; interface. An &amp;lt;code&amp;gt;XComponent&amp;lt;/code&amp;gt; is a UNO object that can be disposed explicitly and broadcast an event to other UNO objects when this happens.&lt;br /&gt;
&lt;br /&gt;
The Desktop can load new and existing components from a URL. For this purpose it has a &amp;lt;idl&amp;gt;com.sun.star.frame.XComponentLoader&amp;lt;/idl&amp;gt; interface that has one single method to load and instantiate components from a URL into a frame:&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 &amp;gt; aArgs );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The interesting parameters in our context are the URL that describes which resource should be loaded and the sequence of load arguments. For the target frame pass &amp;quot;&amp;lt;code&amp;gt;_blank&amp;lt;/code&amp;gt;&amp;quot; and set the search flags to 0. In most cases you will not want to reuse an existing frame.&lt;br /&gt;
&lt;br /&gt;
The URL can be a &amp;lt;code&amp;gt;file:&amp;lt;/code&amp;gt; URL, a &amp;lt;code&amp;gt;http:&amp;lt;/code&amp;gt; URL, an &amp;lt;code&amp;gt;ftp:&amp;lt;/code&amp;gt; URL or a &amp;lt;code&amp;gt;private:&amp;lt;/code&amp;gt; URL. Look up the correct URL format in the load URL box in the function bar of {{PRODUCTNAME}}. For new writer documents, a special URL scheme has to be used. The scheme is &amp;quot;private:&amp;quot;, followed by &amp;quot;factory&amp;quot; as hostname. The resource is &amp;quot;swriter&amp;quot; for {{PRODUCTNAME}} writer documents. For a new writer document, use &amp;quot;&amp;lt;code&amp;gt;private:factory/swriter&amp;lt;/code&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The load arguments are described in &amp;lt;idl&amp;gt;com.sun.star.document.MediaDescriptor&amp;lt;/idl&amp;gt;. The arguments &amp;lt;code&amp;gt;AsTemplate&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Hidden&amp;lt;/code&amp;gt; have properties that are boolean values. If &amp;lt;code&amp;gt;AsTemplate&amp;lt;/code&amp;gt; is true, the loader creates a new untitled document from the given URL. If it is false, template files are loaded for editing. If &amp;lt;code&amp;gt;Hidden&amp;lt;/code&amp;gt; is true, the document is loaded in the background. This is useful when generating a document in the background without letting the user observe; for example, it can be used to generate a document and print it without previewing. [[Documentation/DevGuide/OfficeDev/Office Development|Office development]] describes other available options.&lt;br /&gt;
&lt;br /&gt;
The section [[Documentation/DevGuide/Text/Example: Fields in a Template|Example: Fields in a Template]] discusses a complete example about how loading works. The following snippet loads a document in hidden mode: &lt;br /&gt;
&amp;lt;!--[SOURCE:Text/TextDocuments.java]--&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // (the method getRemoteServiceManager is described in the chapter First Steps)&lt;br /&gt;
  mxRemoteServiceManager = this.getRemoteServiceManager(unoUrl);&lt;br /&gt;
  &lt;br /&gt;
  // retrieve the Desktop object, we need its XComponentLoader&lt;br /&gt;
  Object desktop = mxRemoteServiceManager.createInstanceWithContext(&lt;br /&gt;
  &amp;quot;com.sun.star.frame.Desktop&amp;quot;, mxRemoteContext);&lt;br /&gt;
  &lt;br /&gt;
  // query the XComponentLoader interface from the Desktop service&lt;br /&gt;
  XComponentLoader xComponentLoader = (XComponentLoader)UnoRuntime.queryInterface(&lt;br /&gt;
      XComponentLoader.class, desktop);&lt;br /&gt;
  &lt;br /&gt;
  // define load properties according to com.sun.star.document.MediaDescriptor&lt;br /&gt;
  &lt;br /&gt;
  /* or simply create an empty array of com.sun.star.beans.PropertyValue structs:&lt;br /&gt;
     PropertyValue[] loadProps = new PropertyValue[0]&lt;br /&gt;
   */&lt;br /&gt;
  &lt;br /&gt;
  // the boolean property Hidden tells the office to open a file in hidden mode&lt;br /&gt;
  PropertyValue[] loadProps = new PropertyValue[1];&lt;br /&gt;
  loadProps[0] = new PropertyValue();&lt;br /&gt;
  loadProps[0].Name = &amp;quot;Hidden&amp;quot;;&lt;br /&gt;
  loadProps[0].Value = new Boolean(true); &lt;br /&gt;
  &lt;br /&gt;
  // load&lt;br /&gt;
  return xComponentLoader.loadComponentFromURL(loadUrl, &amp;quot;_blank&amp;quot;, 0, loadProps); &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Text Documents]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Text/Example:_Visible_Cursor_Position&amp;diff=132477</id>
		<title>Documentation/DevGuide/Text/Example: Visible Cursor Position</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Text/Example:_Visible_Cursor_Position&amp;diff=132477"/>
		<updated>2009-06-20T16:28:15Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/TextTOC&lt;br /&gt;
|TextExample=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Text/Example: Fields in a Template&lt;br /&gt;
|NextPage=Documentation/DevGuide/Text/Handling Text Document Files&lt;br /&gt;
}}&lt;br /&gt;
{{Documentation/DevGuideLanguages|Documentation/DevGuide/Text/{{SUBPAGENAME}}}} &lt;br /&gt;
 {{DISPLAYTITLE:Example: Visible Cursor Position}}&lt;br /&gt;
As discussed earlier, the {{PRODUCTNAME}} API distinguishes between the model and controller. This difference is mirrored in two different kinds of cursors in the API: model cursors and visible cursors. The visible cursor is also called view cursor. &lt;br /&gt;
&lt;br /&gt;
The second example assumes that the user has selected a text range in a paragraph and expects something to happen at that cursor position. Setting character and paragraph styles, and retrieving the current page number at the view cursor position is demonstrated in the example. The view cursor will be transformed into a model cursor.&lt;br /&gt;
&lt;br /&gt;
We want to work with the current document, therefore we cannot use &amp;lt;code&amp;gt;loadComponentFromURL()&amp;lt;/code&amp;gt;. Rather, we ask the &amp;lt;idl&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idl&amp;gt; service for the current component. Once we have the current component - which is our document model - we go from the model to the controller and get the view cursor.&lt;br /&gt;
&lt;br /&gt;
The view cursor has properties for the current character and paragraph style. The example uses built-in styles and sets the property &amp;lt;code&amp;gt;CharStyleName&amp;lt;/code&amp;gt; to &amp;quot;&amp;lt;code&amp;gt;Quotation&amp;lt;/code&amp;gt;&amp;quot; and &amp;lt;code&amp;gt;ParaStyleName&amp;lt;/code&amp;gt; to &amp;quot;&amp;lt;code&amp;gt;Quotations&amp;lt;/code&amp;gt;&amp;quot;. Furthermore, the view cursor knows about the automatic page breaks. Because we are interested in the current page number, we get it from the view cursor and print it out.&lt;br /&gt;
&lt;br /&gt;
The model cursor is much more powerful than the view cursor when it comes to possible movements and editing capabilities. We create a model cursor from the view cursor. Two steps are necessary: We ask the view cursor for its Text service, then we have the Text service create a model cursor based on the current cursor position. The model cursor knows where the paragraph ends, so we go there and insert a string. &lt;br /&gt;
&amp;lt;!--[SOURCE:Text/TextDocuments.java]--&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  /** Sample for document changes, starting at the current view cursor position&lt;br /&gt;
      The sample changes the paragraph style and the character style at the current&lt;br /&gt;
      view cursor selection&lt;br /&gt;
      Open the sample file ViewCursorExampleFile, select some text and run the example&lt;br /&gt;
      The current paragraph will be set to Quotations paragraph style &lt;br /&gt;
      The selected text will be set to Quotation character style&lt;br /&gt;
   */&lt;br /&gt;
  private void viewCursorExample() throws java.lang.Exception {&lt;br /&gt;
      // get the remote service manager&lt;br /&gt;
      mxRemoteServiceManager = this.getRemoteServiceManager(unoUrl);&lt;br /&gt;
  &lt;br /&gt;
      // get the Desktop service&lt;br /&gt;
      Object desktop = mxRemoteServiceManager.createInstanceWithContext(&lt;br /&gt;
          &amp;quot;com.sun.star.frame.Desktop&amp;quot;, mxRemoteContext);&lt;br /&gt;
      &lt;br /&gt;
      // query its XDesktop interface, we need the current component&lt;br /&gt;
      XDesktop xDesktop = (XDesktop)UnoRuntime.queryInterface(&lt;br /&gt;
          XDesktop.class, desktop);&lt;br /&gt;
      &lt;br /&gt;
      // retrieve the current component and access the controller&lt;br /&gt;
      XComponent xCurrentComponent = xDesktop.getCurrentComponent();&lt;br /&gt;
      &lt;br /&gt;
      // get the XModel interface from the component&lt;br /&gt;
      XModel xModel = (XModel)UnoRuntime.queryInterface(XModel.class, xCurrentComponent);&lt;br /&gt;
      &lt;br /&gt;
      // the model knows its controller&lt;br /&gt;
      XController xController = xModel.getCurrentController();&lt;br /&gt;
      &lt;br /&gt;
      // the controller gives us the TextViewCursor&lt;br /&gt;
      // query the viewcursor supplier interface &lt;br /&gt;
      XTextViewCursorSupplier xViewCursorSupplier = &lt;br /&gt;
          (XTextViewCursorSupplier)UnoRuntime.queryInterface(&lt;br /&gt;
              XTextViewCursorSupplier.class, xController);&lt;br /&gt;
      &lt;br /&gt;
      // get the cursor &lt;br /&gt;
      XTextViewCursor xViewCursor = xViewCursorSupplier.getViewCursor();&lt;br /&gt;
      &lt;br /&gt;
      // query its XPropertySet interface, we want to set character and paragraph properties&lt;br /&gt;
      XPropertySet xCursorPropertySet = (XPropertySet)UnoRuntime.queryInterface(&lt;br /&gt;
          XPropertySet.class, xViewCursor);&lt;br /&gt;
      &lt;br /&gt;
      // set the appropriate properties for character and paragraph style&lt;br /&gt;
      xCursorPropertySet.setPropertyValue(&amp;quot;CharStyleName&amp;quot;, &amp;quot;Quotation&amp;quot;);&lt;br /&gt;
          xCursorPropertySet.setPropertyValue(&amp;quot;ParaStyleName&amp;quot;, &amp;quot;Quotations&amp;quot;);&lt;br /&gt;
      &lt;br /&gt;
      // print the current page number - we need the XPageCursor interface for this&lt;br /&gt;
      XPageCursor xPageCursor = (XPageCursor)UnoRuntime.queryInterface(&lt;br /&gt;
          XPageCursor.class, xViewCursor);&lt;br /&gt;
      System.out.println(&amp;quot;The current page number is &amp;quot; + xPageCursor.getPage());&lt;br /&gt;
      &lt;br /&gt;
      // the model cursor is much more powerful, so &lt;br /&gt;
      // we create a model cursor at the current view cursor position with the following steps:&lt;br /&gt;
      // we get the Text service from the TextViewCursor, the cursor is an XTextRange and has &lt;br /&gt;
      // therefore a method getText()&lt;br /&gt;
      XText xDocumentText = xViewCursor.getText();&lt;br /&gt;
      &lt;br /&gt;
      // the text creates a model cursor from the viewcursor&lt;br /&gt;
      XTextCursor xModelCursor = xDocumentText.createTextCursorByRange(xViewCursor.getStart());&lt;br /&gt;
      &lt;br /&gt;
      // now we could query XWordCursor, XSentenceCursor and XParagraphCursor&lt;br /&gt;
      // or XDocumentInsertable, XSortable or XContentEnumerationAccess&lt;br /&gt;
      // and work with the properties of com.sun.star.text.TextCursor&lt;br /&gt;
      // in this case we just go to the end of the paragraph and add some text.&lt;br /&gt;
      XParagraphCursor xParagraphCursor = (XParagraphCursor)UnoRuntime.queryInterface(&lt;br /&gt;
          XParagraphCursor.class, xModelCursor);&lt;br /&gt;
      &lt;br /&gt;
      // goto the end of the paragraph&lt;br /&gt;
      xParagraphCursor.gotoEndOfParagraph(false);&lt;br /&gt;
      xParagraphCursor.setString(&amp;quot; ***** Fin de semana! ******&amp;quot;);&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/Text Documents]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Text/Example:_Fields_in_a_Template&amp;diff=132475</id>
		<title>Documentation/DevGuide/Text/Example: Fields in a Template</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Text/Example:_Fields_in_a_Template&amp;diff=132475"/>
		<updated>2009-06-20T16:26:27Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/TextTOC&lt;br /&gt;
|TextExample=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Text/Text Documents&lt;br /&gt;
|NextPage=Documentation/DevGuide/Text/Example: Visible Cursor Position&lt;br /&gt;
}}&lt;br /&gt;
{{Documentation/DevGuideLanguages|Documentation/DevGuide/Text/{{SUBPAGENAME}}}} &lt;br /&gt;
 {{DISPLAYTITLE:Example: Fields in a Template}}&lt;br /&gt;
All following code samples are contained in &amp;#039;&amp;#039;TextDocuments.java&amp;#039;&amp;#039;. This file is located in the Samples folder that comes with the resources for the developer&amp;#039;s manual.&lt;br /&gt;
&lt;br /&gt;
The examples use the environment from chapter [[Documentation/DevGuide/FirstSteps/First Steps|First Steps]], for instance, connecting using the &amp;lt;code&amp;gt;getRemoteServiceManager()&amp;lt;/code&amp;gt; method.&lt;br /&gt;
&lt;br /&gt;
We want to use a template file containing text fields and bookmarks and insert text into the fields and at the cursor position. The suitable template file &amp;#039;&amp;#039;TextTemplateWithUserFields.odt&amp;#039;&amp;#039; lies in the Samples folder, as well. Edit the path to this file below before running the sample.&lt;br /&gt;
&lt;br /&gt;
The first step is to load the file as a template, so that {{PRODUCTNAME}} creates a new, untitled document. As in the chapter [[Documentation/DevGuide/FirstSteps/First Steps|First Steps]], we have to connect, get the Desktop object, query its &amp;lt;code&amp;gt;XComponentLoader&amp;lt;/code&amp;gt; interface and call &amp;lt;code&amp;gt;loadComponentFromUrl()&amp;lt;/code&amp;gt;. This time we tell {{PRODUCTNAME}} how it should load the file. The key for loading parameters is the sequence of &amp;lt;code&amp;gt;PropertyValue&amp;lt;/code&amp;gt; structs passed to &amp;lt;code&amp;gt;loadComponentFromUrl()&amp;lt;/code&amp;gt;. The appropriate &amp;lt;code&amp;gt;PropertyValue&amp;lt;/code&amp;gt; name is &amp;lt;code&amp;gt;AsTemplate&amp;lt;/code&amp;gt; and we have to set &amp;lt;code&amp;gt;AsTemplate&amp;lt;/code&amp;gt; to true. &lt;br /&gt;
&amp;lt;!--[SOURCE:Text/TextDocuments.java]--&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  /** Load a document as template */&lt;br /&gt;
  protected XComponent newDocComponentFromTemplate(String loadUrl) throws java.lang.Exception {&lt;br /&gt;
      // get the remote service manager&lt;br /&gt;
      mxRemoteServiceManager = this.getRemoteServiceManager(unoUrl);&lt;br /&gt;
      // retrieve the Desktop object, we need its XComponentLoader&lt;br /&gt;
      Object desktop = mxRemoteServiceManager.createInstanceWithContext(&lt;br /&gt;
          &amp;quot;com.sun.star.frame.Desktop&amp;quot;, mxRemoteContext);&lt;br /&gt;
      XComponentLoader xComponentLoader = (XComponentLoader)UnoRuntime.queryInterface(&lt;br /&gt;
          XComponentLoader.class, desktop);&lt;br /&gt;
  &lt;br /&gt;
      // define load properties according to com.sun.star.document.MediaDescriptor&lt;br /&gt;
      // the boolean property AsTemplate tells the office to create a new document&lt;br /&gt;
      // from the given file&lt;br /&gt;
      PropertyValue[] loadProps = new PropertyValue[1];&lt;br /&gt;
      loadProps[0] = new PropertyValue();&lt;br /&gt;
      loadProps[0].Name = &amp;quot;AsTemplate&amp;quot;;&lt;br /&gt;
      loadProps[0].Value = new Boolean(true); &lt;br /&gt;
      // load&lt;br /&gt;
      return xComponentLoader.loadComponentFromURL(loadUrl, &amp;quot;_blank&amp;quot;, 0, loadProps); &lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Now that we are able to load a text document as template, we will open an existing template file that contains five text fields and a bookmark. We want to demonstrate how to insert text at predefined positions in a document.&lt;br /&gt;
&lt;br /&gt;
Text fields and bookmarks are supplied by the appropriate &amp;lt;code&amp;gt;XTextFieldsSupplier&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;XBookmarksSupplier&amp;lt;/code&amp;gt; interfaces. Their fully qualified names are &amp;lt;idl&amp;gt;com.sun.star.text.XTextFieldsSupplier&amp;lt;/idl&amp;gt; and &amp;lt;idl&amp;gt;com.sun.star.text.XBookmarksSupplier&amp;lt;/idl&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;XTextFieldsSupplier&amp;lt;/code&amp;gt; provides collections of text fields in our text. We use document variable fields for our purpose, which are &amp;lt;idl&amp;gt;com.sun.star.text.textfield.User&amp;lt;/idl&amp;gt; services. All User fields have a field master that holds the actual content of the variable. Therefore, the &amp;lt;code&amp;gt;TextFields&amp;lt;/code&amp;gt; collection, as well as the &amp;lt;code&amp;gt;FieldMasters&amp;lt;/code&amp;gt; are required for our example. We get the field masters for the five fields by name and set their &amp;lt;code&amp;gt;Content&amp;lt;/code&amp;gt; property. Finally, we refresh the text fields so that they reflect the changes made to the field masters.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;XBookmarksSupplier&amp;lt;/code&amp;gt; returns all bookmarks in our document. The collection of bookmarks is a &amp;lt;idl&amp;gt;com.sun.star.container.XNameAccess&amp;lt;/idl&amp;gt;, so that the bookmarks are retrieved by name. Every object in a text supports the interface &amp;lt;code&amp;gt;XTextContent&amp;lt;/code&amp;gt; that has a method &amp;lt;code&amp;gt;getAnchor()&amp;lt;/code&amp;gt;. The anchor is the text range an object takes up, so &amp;lt;code&amp;gt;getAnchor()&amp;lt;/code&amp;gt; retrieves is an &amp;lt;code&amp;gt;XTextRange&amp;lt;/code&amp;gt;. From the chapter [[Documentation/DevGuide/FirstSteps/First Steps|First Steps]], a &amp;lt;idl&amp;gt;com.sun.star.text.XTextRange&amp;lt;/idl&amp;gt; allows setting the string of a text range. Our bookmark is a text content and therefore must support &amp;lt;code&amp;gt;XTextContent&amp;lt;/code&amp;gt;. Inserting text at a bookmark position is straightforward: get the anchor of the bookmark and set its string. &lt;br /&gt;
&amp;lt;!--[SOURCE:Text/TextDocuments.java]--&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  /** Sample for use of templates&lt;br /&gt;
      This sample uses the file TextTemplateWithUserFields.odt from the Samples folder.&lt;br /&gt;
      The file contains a number of User text fields (Variables - User) and a bookmark&lt;br /&gt;
      which we use to fill in various values&lt;br /&gt;
   */&lt;br /&gt;
  protected void templateExample() throws java.lang.Exception {&lt;br /&gt;
      // create a small hashtable that simulates a rowset with columns&lt;br /&gt;
      Hashtable recipient = new Hashtable();&lt;br /&gt;
      recipient.put(&amp;quot;Company&amp;quot;, &amp;quot;Manatee Books&amp;quot;);&lt;br /&gt;
      recipient.put(&amp;quot;Contact&amp;quot;, &amp;quot;Rod Martin&amp;quot;);&lt;br /&gt;
      recipient.put(&amp;quot;ZIP&amp;quot;, &amp;quot;34567&amp;quot;);&lt;br /&gt;
      recipient.put(&amp;quot;City&amp;quot;, &amp;quot;Fort Lauderdale&amp;quot;);&lt;br /&gt;
      recipient.put(&amp;quot;State&amp;quot;, &amp;quot;Florida&amp;quot;);&lt;br /&gt;
      &lt;br /&gt;
      // load template with User fields and bookmark&lt;br /&gt;
      XComponent xTemplateComponent = newDocComponentFromTemplate(&lt;br /&gt;
      &amp;quot;file:///X:/devmanual/Samples/TextTemplateWithUserFields.odt&amp;quot;);&lt;br /&gt;
      &lt;br /&gt;
      // get XTextFieldsSupplier and XBookmarksSupplier interfaces from document component&lt;br /&gt;
      XTextFieldsSupplier xTextFieldsSupplier = (XTextFieldsSupplier)UnoRuntime.queryInterface(&lt;br /&gt;
          XTextFieldsSupplier.class, xTemplateComponent);&lt;br /&gt;
      XBookmarksSupplier xBookmarksSupplier = (XBookmarksSupplier)UnoRuntime.queryInterface(&lt;br /&gt;
          XBookmarksSupplier.class, xTemplateComponent);&lt;br /&gt;
      &lt;br /&gt;
      // access the TextFields and the TextFieldMasters collections&lt;br /&gt;
      XNameAccess xNamedFieldMasters = xTextFieldsSupplier.getTextFieldMasters();&lt;br /&gt;
      XEnumerationAccess xEnumeratedFields = xTextFieldsSupplier.getTextFields();&lt;br /&gt;
      &lt;br /&gt;
      // iterate over hashtable and insert values into field masters&lt;br /&gt;
      java.util.Enumeration keys = recipient.keys();&lt;br /&gt;
      while (keys.hasMoreElements()) {&lt;br /&gt;
          // get column name&lt;br /&gt;
          String key = (String)keys.nextElement();&lt;br /&gt;
          &lt;br /&gt;
          // access corresponding field master&lt;br /&gt;
          Object fieldMaster = xNamedFieldMasters.getByName(&lt;br /&gt;
              &amp;quot;com.sun.star.text.fieldmaster.User.&amp;quot; + key);&lt;br /&gt;
          &lt;br /&gt;
          // query the XPropertySet interface, we need to set the Content property&lt;br /&gt;
          XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(&lt;br /&gt;
              XPropertySet.class, fieldMaster);&lt;br /&gt;
          &lt;br /&gt;
          // insert the column value into field master&lt;br /&gt;
          xPropertySet.setPropertyValue(&amp;quot;Content&amp;quot;, recipient.get(key));&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      // afterwards we must refresh the textfields collection&lt;br /&gt;
      XRefreshable xRefreshable = (XRefreshable)UnoRuntime.queryInterface(&lt;br /&gt;
          XRefreshable.class, xEnumeratedFields);&lt;br /&gt;
      xRefreshable.refresh();&lt;br /&gt;
      &lt;br /&gt;
      // accessing the Bookmarks collection of the document&lt;br /&gt;
      XNameAccess xNamedBookmarks = xBookmarksSupplier.getBookmarks();&lt;br /&gt;
      &lt;br /&gt;
      // find the bookmark named &amp;quot;Subscription&amp;quot;&lt;br /&gt;
      Object bookmark = xNamedBookmarks.getByName(&amp;quot;Subscription&amp;quot;);&lt;br /&gt;
      &lt;br /&gt;
      // we need its XTextRange which is available from getAnchor(), &lt;br /&gt;
      // so query for XTextContent&lt;br /&gt;
      XTextContent xBookmarkContent = (XTextContent)UnoRuntime.queryInterface(&lt;br /&gt;
          XTextContent.class, bookmark);&lt;br /&gt;
      &lt;br /&gt;
      // get the anchor of the bookmark (its XTextRange)&lt;br /&gt;
      XTextRange xBookmarkRange = xBookmarkContent.getAnchor();&lt;br /&gt;
      &lt;br /&gt;
      // set string at the bookmark position&lt;br /&gt;
      xBookmarkRange.setString(&amp;quot;subscription for the Manatee Journal&amp;quot;);&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/Text Documents]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/How_to_Apply_an_Add-In_to_a_Chart_Document&amp;diff=108475</id>
		<title>Documentation/DevGuide/Charts/How to Apply an Add-In to a Chart Document</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/How_to_Apply_an_Add-In_to_a_Chart_Document&amp;diff=108475"/>
		<updated>2009-01-21T10:14:23Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/ChartsTOC&lt;br /&gt;
|Charts2c=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Charts/How Add-Ins Work&lt;br /&gt;
|NextPage=Documentation/DevGuide/Basic/OpenOffice.org Basic&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:How to Apply an Add-In to a Chart Document}}&lt;br /&gt;
There is no method to set an add-in as a chart type for an existing chart in the graphical user interface. To set the chart type, use an API script, for instance, in {{PRODUCTNAME}} Basic. The following example sets the add-in with service name “&amp;lt;code&amp;gt;com.sun.star.comp.Chart.JavaSampleChartAddIn&amp;lt;/code&amp;gt;” at the current document. To avoid problems, it is advisable to create a chart that has the same type as the one that the add-in sets as &amp;lt;code&amp;gt;BaseDiagram&amp;lt;/code&amp;gt; type.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
  Sub SetAddIn&lt;br /&gt;
  Dim oDoc As Object&lt;br /&gt;
  Dim oSheet As Object&lt;br /&gt;
  Dim oTableChart As Object&lt;br /&gt;
  Dim oChart As Object&lt;br /&gt;
  Dim oAddIn As Object&lt;br /&gt;
  &lt;br /&gt;
      &amp;#039; assume that the current document is a spreadsheet&lt;br /&gt;
      oDoc = ThisComponent&lt;br /&gt;
      oSheet = oDoc.Sheets( 0 )&lt;br /&gt;
      &lt;br /&gt;
      &amp;#039; assume also that you already added a chart&lt;br /&gt;
      &amp;#039; named &amp;quot;MyChart&amp;quot; on the first sheet&lt;br /&gt;
      oTableChart = oSheet.Charts.getByName( &amp;quot;MyChart&amp;quot; )&lt;br /&gt;
    &lt;br /&gt;
      If Not IsNull( oTableChart ) Then&lt;br /&gt;
          oChart = oTableChart.EmbeddedObject&lt;br /&gt;
          If Not IsNull( oChart ) Then&lt;br /&gt;
              oAddIn = oChart.createInstance( &amp;quot;com.sun.star.comp.Chart.JavaSampleChartAddIn&amp;quot; )&lt;br /&gt;
              If Not IsNull( oAddIn ) Then&lt;br /&gt;
                  oChart.setDiagram( oAddIn )&lt;br /&gt;
              End If&lt;br /&gt;
          End If&lt;br /&gt;
      End If&lt;br /&gt;
  End Sub&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
{{Documentation/Tip|If you want to create an XML-File on your own and want to activate your add-in for a chart; set the attribute &amp;lt;tt&amp;gt;chart:class&amp;lt;/tt&amp;gt; of the &amp;lt;tt&amp;gt;chart:chart&amp;lt;/tt&amp;gt; element to “add-in” and the attribute &amp;lt;tt&amp;gt;chart:add-in-name&amp;lt;/tt&amp;gt; to the service name that uniquely identifies your component.}}&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Charts]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/How_Add-Ins_Work&amp;diff=108473</id>
		<title>Documentation/DevGuide/Charts/How Add-Ins Work</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/How_Add-Ins_Work&amp;diff=108473"/>
		<updated>2009-01-21T10:13:17Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/ChartsTOC&lt;br /&gt;
|Charts2c=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Charts/Prerequisites&lt;br /&gt;
|NextPage=Documentation/DevGuide/Charts/How to Apply an Add-In to a Chart Document&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:How Add-Ins Work}}&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.util.XRefreshable&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The method &amp;lt;code&amp;gt;initialize()&amp;lt;/code&amp;gt; from the &amp;lt;idl&amp;gt;com.sun.star.lang.XInitialization&amp;lt;/idl&amp;gt; interface is the first method that is called for an add-in. It is called directly after it is created by the &amp;lt;idl&amp;gt;com.sun.star.lang.XMultiServiceFactory&amp;lt;/idl&amp;gt; provided by the chart document. This method gets the &amp;lt;code&amp;gt;XChartDocument&amp;lt;/code&amp;gt; object. &lt;br /&gt;
&lt;br /&gt;
When &amp;lt;code&amp;gt;initialize()&amp;lt;/code&amp;gt; is called, the argument returned is the chart document. Store this as a member to that it can be called later in the &amp;lt;code&amp;gt;refresh()&amp;lt;/code&amp;gt; call to access all elements of the chart. The following is an example for the &amp;lt;code&amp;gt;initialize()&amp;lt;/code&amp;gt; method of an add-in written in Java:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // XInitialization&lt;br /&gt;
  public void initialize(Object[] aArguments) throws Exception, RuntimeException {&lt;br /&gt;
      if (aArguments.length &amp;gt; 0) {&lt;br /&gt;
          // maChartDocument is a member&lt;br /&gt;
          // which is set to the parent chart document &lt;br /&gt;
          // that is given as first argument&lt;br /&gt;
          maChartDocument = (XChartDocument) UnoRuntime.queryInterface(&lt;br /&gt;
              XChartDocument.class, aArguments[0]);&lt;br /&gt;
          &lt;br /&gt;
          XPropertySet aDocProp = (XPropertySet) UnoRuntime.queryInterface(&lt;br /&gt;
              XPropertySet.class, maChartDocument);&lt;br /&gt;
          if (aDocProp != null) {&lt;br /&gt;
              // set base diagram which will be extended in refresh()&lt;br /&gt;
              aDocProp.setPropertyValue(&amp;quot;BaseDiagram&amp;quot;, &amp;quot;com.sun.star.chart.XYDiagram&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          &lt;br /&gt;
          // remember the draw page, as it is frequently used by refresh()&lt;br /&gt;
          // (this is not necessary but convenient)&lt;br /&gt;
          XDrawPageSupplier aPageSupp = (XDrawPageSupplier) UnoRuntime.queryInterface(&lt;br /&gt;
              XDrawPageSupplier.class, maChartDocument);&lt;br /&gt;
          if( aPageSupp != null )&lt;br /&gt;
              maDrawPage = (XDrawPage) UnoRuntime.queryInterface(&lt;br /&gt;
                  XDrawPage.class, aPageSupp.getDrawPage());&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
An important method of an add-in component is &amp;lt;code&amp;gt;refresh()&amp;lt;/code&amp;gt; from the &amp;lt;idl&amp;gt;com.sun.star.util.XRefreshable&amp;lt;/idl&amp;gt;. This method is called every time the chart is rebuilt. A change of data results in a refresh, but also a resizing or changing of a property that affects the layout calls the &amp;lt;code&amp;gt;refresh()&amp;lt;/code&amp;gt; method. For example, the property &amp;lt;code&amp;gt;HasLegend&amp;lt;/code&amp;gt; that switches the legend on and off.&lt;br /&gt;
&lt;br /&gt;
To add shapes to the chart, create them once and modify them later during the refresh calls. In the following example, a line is created in &amp;lt;code&amp;gt;initialize()&amp;lt;/code&amp;gt; and modified during &amp;lt;code&amp;gt;refresh()&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // XInitialization&lt;br /&gt;
  public void initialize(Object[] aArguments) throws Exception, RuntimeException {&lt;br /&gt;
      // get document and page -- see above&lt;br /&gt;
      // ...&lt;br /&gt;
    &lt;br /&gt;
          // get a shape factory&lt;br /&gt;
          maShapeFactory = ...;&lt;br /&gt;
          &lt;br /&gt;
          // create top line&lt;br /&gt;
          maTopLine = (XShape) UnoRuntime.queryInterface(&lt;br /&gt;
              XShape.class, maShapeFactory.createInstance(&amp;quot;com.sun.star.drawing.LineShape&amp;quot;));&lt;br /&gt;
          maDrawPage.add(maTopLine);&lt;br /&gt;
          &lt;br /&gt;
          // make line red and thicker&lt;br /&gt;
          XPropertySet aShapeProp = (XPropertySet)UnoRuntime.queryInterface(&lt;br /&gt;
              XPropertySet.class, maTopLine);&lt;br /&gt;
          aShapeProp.setPropertyValue(&amp;quot;LineColor&amp;quot;, new Integer(0xe01010));&lt;br /&gt;
          aShapeProp.setPropertyValue(&amp;quot;LineWidth&amp;quot;, new Integer(50));&lt;br /&gt;
          &lt;br /&gt;
          // create bottom line&lt;br /&gt;
          maBottomLine = (XShape) UnoRuntime.queryInterface(&lt;br /&gt;
              XShape.class, maShapeFactory.createInstance(&amp;quot;com.sun.star.drawing.LineShape&amp;quot;));&lt;br /&gt;
          maDrawPage.add(maBottomLine);&lt;br /&gt;
          &lt;br /&gt;
          // make line green and thicker&lt;br /&gt;
          aShapeProp = (XPropertySet) UnoRuntime.queryInterface(&lt;br /&gt;
              XPropertySet.class, maBottomLine);&lt;br /&gt;
          aShapeProp.setPropertyValue(&amp;quot;LineColor&amp;quot;, new Integer(0x10e010));&lt;br /&gt;
          aShapeProp.setPropertyValue(&amp;quot;LineWidth&amp;quot;, new Integer(50));&lt;br /&gt;
      }&lt;br /&gt;
    &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  // XRefreshable&lt;br /&gt;
  public void refresh() throws RuntimeException {&lt;br /&gt;
      // position lines&lt;br /&gt;
      // --------------&lt;br /&gt;
      &lt;br /&gt;
      // get data&lt;br /&gt;
      XChartDataArray aDataArray = (XChartDataArray) UnoRuntime.queryInterface(&lt;br /&gt;
          XChartDataArray.class, maChartDocument.getData());&lt;br /&gt;
      double aData[][] = aDataArray.getData();&lt;br /&gt;
      &lt;br /&gt;
      // get axes&lt;br /&gt;
      XDiagram aDiagram = maChartDocument.getDiagram();&lt;br /&gt;
      XShape aXAxis = (XShape) UnoRuntime.queryInterface(&lt;br /&gt;
          XShape.class, ((XAxisXSupplier) UnoRuntime.queryInterface( &lt;br /&gt;
              XAxisXSupplier.class, aDiagram)).getXAxis());&lt;br /&gt;
      XShape aYAxis = (XShape) UnoRuntime.queryInterface(&lt;br /&gt;
          XShape.class, ((XAxisYSupplier) UnoRuntime.queryInterface(&lt;br /&gt;
              XAxisYSupplier.class, aDiagram)).getYAxis());&lt;br /&gt;
      &lt;br /&gt;
      // calculate points for hull&lt;br /&gt;
      final int nLength = aData.length;&lt;br /&gt;
      int i, j;&lt;br /&gt;
      double fMax, fMin;&lt;br /&gt;
      &lt;br /&gt;
      Point aMaxPtSeq[][] = new Point[1][];&lt;br /&gt;
      aMaxPtSeq[0] = new Point[nLength];&lt;br /&gt;
      Point aMinPtSeq[][] = new Point[1][];&lt;br /&gt;
      aMinPtSeq[0] = new Point[nLength];&lt;br /&gt;
      &lt;br /&gt;
      for (i = 0; i &amp;lt; nLength; i++) {&lt;br /&gt;
          fMin = fMax = aData[i][1];&lt;br /&gt;
          for (j = 1; j &amp;lt; aData[i].length; j++) {&lt;br /&gt;
              if (aData[i][j] &amp;gt; fMax)&lt;br /&gt;
                  fMax = aData[i][j];&lt;br /&gt;
              else if (aData[i][j] &amp;lt; fMin)&lt;br /&gt;
                  fMin = aData[i][j];&lt;br /&gt;
          }&lt;br /&gt;
          aMaxPtSeq[0][i] = new Point(getAxisPosition(aXAxis, aData[i][0], false),&lt;br /&gt;
              getAxisPosition(aYAxis, fMax, true));&lt;br /&gt;
          aMinPtSeq[0][i] = new Point(getAxisPosition(aXAxis, aData[i][0], false),&lt;br /&gt;
              getAxisPosition(aYAxis, fMin, true));&lt;br /&gt;
      }&lt;br /&gt;
          &lt;br /&gt;
      // apply point sequences to lines&lt;br /&gt;
      try {&lt;br /&gt;
          XPropertySet aShapeProp = (XPropertySet) UnoRuntime.queryInterface(&lt;br /&gt;
              XPropertySet.class, maTopLine);&lt;br /&gt;
          aShapeProp.setPropertyValue(&amp;quot;PolyPolygon&amp;quot;, aMaxPtSeq);&lt;br /&gt;
          &lt;br /&gt;
          aShapeProp = (XPropertySet) UnoRuntime.queryInterface(&lt;br /&gt;
              XPropertySet.class, maBottomLine);&lt;br /&gt;
          aShapeProp.setPropertyValue(&amp;quot;PolyPolygon&amp;quot;, aMinPtSeq);&lt;br /&gt;
      } catch (Exception ex) {&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  // determine the position of a value along an axis&lt;br /&gt;
  // bVertical is true for the y-axis and false for the x-axis&lt;br /&gt;
  private int getAxisPosition(XShape aAxis, double fValue, boolean bVertical) {&lt;br /&gt;
      int nResult = 0;&lt;br /&gt;
      &lt;br /&gt;
      if (aAxis != null) {&lt;br /&gt;
          XPropertySet aAxisProp = (XPropertySet) UnoRuntime.queryInterface(&lt;br /&gt;
              XPropertySet.class, aAxis);&lt;br /&gt;
    &lt;br /&gt;
          try {&lt;br /&gt;
              double fMin, fMax;&lt;br /&gt;
              fMin = ((Double) aAxisProp.getPropertyValue(&amp;quot;Min&amp;quot;)).doubleValue();&lt;br /&gt;
              fMax = ((Double) aAxisProp.getPropertyValue(&amp;quot;Max&amp;quot;)).doubleValue();&lt;br /&gt;
              double fRange = fMax - fMin;&lt;br /&gt;
          &lt;br /&gt;
              if (fMin &amp;lt;= fValue &amp;amp;&amp;amp; fValue &amp;lt;= fMax &amp;amp;&amp;amp; fRange != 0) {&lt;br /&gt;
                  if (bVertical) {&lt;br /&gt;
                      // y==0 is at the top, thus take 1.0 - ...&lt;br /&gt;
                      nResult = aAxis.getPosition().Y +&lt;br /&gt;
                          (int)((double)(aAxis.getSize().Height) * (1.0 - ((fValue - fMin) / fRange)));&lt;br /&gt;
                  } else {&lt;br /&gt;
                      nResult = aAxis.getPosition().X +&lt;br /&gt;
                          (int)((double)(aAxis.getSize().Width) * ((fValue - fMin) / fRange));&lt;br /&gt;
                  }&lt;br /&gt;
              }&lt;br /&gt;
          } catch (Exception ex) {&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
  return nResult;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The subroutine &amp;lt;code&amp;gt;getAxisPosition()&amp;lt;/code&amp;gt; is a helper to determine the position of a point inside the diagram coordinates. This add-in calculates the maximum and minimum values for each slice of data points, and creates two polygons based on these points.&lt;br /&gt;
&lt;br /&gt;
For an add-in example written in C++, look at the [http://graphics.openoffice.org/source/browse/graphics/sch/source/addin/ sample addin] of the graphics/sch project on [http://www.openoffice.org http://www.openoffice.org].&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Charts]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/Chart_Document_Controller&amp;diff=108468</id>
		<title>Documentation/DevGuide/Charts/Chart Document Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/Chart_Document_Controller&amp;diff=108468"/>
		<updated>2009-01-21T10:11:38Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/ChartsTOC&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Charts/Stock Charts&lt;br /&gt;
|NextPage=Documentation/DevGuide/Charts/Chart Add-Ins&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Chart Document Controller}}&lt;br /&gt;
The chart document model implements &amp;lt;idl&amp;gt;com.sun.star.frame.XModel&amp;lt;/idl&amp;gt;. Therefore, controllers can be registered with the method &amp;lt;code&amp;gt;connectController()&amp;lt;/code&amp;gt;.  When one of the registered controllers is set as current one with &amp;lt;code&amp;gt;setCurrentController()&amp;lt;/code&amp;gt;, this one is also returned in the method &amp;lt;code&amp;gt;getCurrentController()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Apart from using the controller directly, there are three other useful methods:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  void lockControllers()&lt;br /&gt;
  void unlockControllers()&lt;br /&gt;
  boolean hasControllersLocked()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
With a call to &amp;lt;code&amp;gt;lockControllers()&amp;lt;/code&amp;gt; all registered controllers will no longer be notified about changes in the model.  If there are changes those are notified no earlier than after calling &amp;lt;code&amp;gt;unlockControllers()&amp;lt;/code&amp;gt;.  This is especially useful if you do many changes to the chart model at a time but do not need the view to be updated after every single change.  The method &amp;lt;code&amp;gt;hasControllersLocked()&amp;lt;/code&amp;gt; just gives you the state whether controllers are locked or not.&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note| You can nest calls to &amp;lt;tt&amp;gt;lockControllers()&amp;lt;/tt&amp;gt;.  Every call to &amp;lt;tt&amp;gt;lockControllers()&amp;lt;/tt&amp;gt; needs a corresponding &amp;lt;tt&amp;gt;unlockControllers()&amp;lt;/tt&amp;gt; call. Only after the correct number of unlocking calls, notifications of the model will be sent again.  So, you can safely lock and unlock the controllers in your code without having to check if they have already been locked or not. Just make sure that you call both methods and do not leave the controllers in a locked state after your code finishes.}}&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Charts]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/Pie_Charts&amp;diff=108466</id>
		<title>Documentation/DevGuide/Charts/Pie Charts</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/Pie_Charts&amp;diff=108466"/>
		<updated>2009-01-21T10:10:01Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/ChartsTOC&lt;br /&gt;
|Charts2b=block&lt;br /&gt;
|ChartsParts=block&lt;br /&gt;
|ChartsFeat=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Charts/3-D Charts&lt;br /&gt;
|NextPage=Documentation/DevGuide/Charts/Stock Charts&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Pie Charts}}&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.chart.ChartPieSegmentProperties&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
Pie charts support the offset of pie segments with the service &amp;lt;idl&amp;gt;com.sun.star.chart.ChartPieSegmentProperties&amp;lt;/idl&amp;gt; that has a property &amp;lt;code&amp;gt;SegmentOffset&amp;lt;/code&amp;gt; to drag pie slices radially from the center up to an amount equal to the radius of the pie. This property reflects a percentage, that is, values can go from 0 to 100.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // ...&lt;br /&gt;
  &lt;br /&gt;
  // drag the fourth segment 50% out&lt;br /&gt;
  aPointProp = maDiagram.getDataPointProperties(3, 0)&lt;br /&gt;
  aPointProp.setPropertyValue(&amp;quot;SegmentOffset&amp;quot;, 50)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note that the &amp;lt;code&amp;gt;SegmentOffset&amp;lt;/code&amp;gt; property is not available for donut charts and three-dimensional pie charts.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Charts]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/3-D_Charts&amp;diff=108465</id>
		<title>Documentation/DevGuide/Charts/3-D Charts</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/3-D_Charts&amp;diff=108465"/>
		<updated>2009-01-21T10:08:43Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/ChartsTOC&lt;br /&gt;
|Charts2b=block&lt;br /&gt;
|ChartsParts=block&lt;br /&gt;
|ChartsFeat=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Charts/Statistics&lt;br /&gt;
|NextPage=Documentation/DevGuide/Charts/Pie Charts&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:3-D Charts}}&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.chart.Dim3DDiagram;com.sun.star.chart.Chart3DBarProperties&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
Some chart types can display a 3-dimensional representation. To switch a chart to 3-dimensional, set the boolean property &amp;lt;code&amp;gt;Dim3D&amp;lt;/code&amp;gt; of the service &amp;lt;idl&amp;gt;com.sun.star.chart.Dim3DDiagram&amp;lt;/idl&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In addition to this property, bar charts support a property called &amp;lt;code&amp;gt;Deep&amp;lt;/code&amp;gt; (see service &amp;lt;idl&amp;gt;com.sun.star.chart.BarDiagram&amp;lt;/idl&amp;gt;) that arranges the series of a bar chart along the z-axis, which in a chart, points away from the spectator. The service &amp;lt;idl&amp;gt;com.sun.star.chart.Chart3DBarProperties&amp;lt;/idl&amp;gt; offers a property &amp;lt;code&amp;gt;SolidType&amp;lt;/code&amp;gt; to set the style of the data point solids. The solid styles can be selected from cuboids, cylinders, cones, and pyramids with a square base (see constants in &amp;lt;idl&amp;gt;com.sun.star.chart.ChartSolidType&amp;lt;/idl&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;XDiagram&amp;lt;/code&amp;gt; of a 3-dimensional chart is also a scene object that supports modification of the rotation and light sources. The example below shows how to rotate the scene object and add another light source.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // prerequisite: maDiagram contains a valid bar diagram&lt;br /&gt;
  // ...&lt;br /&gt;
  &lt;br /&gt;
  import com.sun.star.drawing.HomogenMatrix;&lt;br /&gt;
  import com.sun.star.drawing.HomogenMatrixLine;&lt;br /&gt;
  import com.sun.star.chart.X3DDisplay;&lt;br /&gt;
  import com.sun.star.beans.XPropertySet;&lt;br /&gt;
  &lt;br /&gt;
  XPropertySet aDiaProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, maDiagram);&lt;br /&gt;
  Boolean aTrue = new Boolean(true);&lt;br /&gt;
  &lt;br /&gt;
  aDiaProp.setPropertyValue(&amp;quot;Dim3D&amp;quot;, aTrue);&lt;br /&gt;
  aDiaProp.setPropertyValue(&amp;quot;Deep&amp;quot;, aTrue);&lt;br /&gt;
  &lt;br /&gt;
  // from service Chart3DBarProperties:&lt;br /&gt;
  aDiaProp.setPropertyValue(&amp;quot;SolidType&amp;quot;, new Integer(&lt;br /&gt;
      com.sun.star.chart.ChartSolidType.CYLINDER));&lt;br /&gt;
  &lt;br /&gt;
  // change floor color to Magenta6&lt;br /&gt;
  XPropertySet aFloor = ((X3DDisplay) UnoRuntime.queryInterface( &lt;br /&gt;
      X3DDisplay.class, maDiagram)).getFloor();&lt;br /&gt;
  aFloor.setPropertyValue(&amp;quot;FillColor&amp;quot;, new Integer(0x6b2394));&lt;br /&gt;
  &lt;br /&gt;
  // rotate the scene using a homogen 4x4 matrix&lt;br /&gt;
  // -------------------------------------------&lt;br /&gt;
  HomogenMatrix aMatrix = new HomogenMatrix();&lt;br /&gt;
  // initialize matrix with identity&lt;br /&gt;
  HomogenMatrixLine aLines[] = new HomogenMatrixLine[] {&lt;br /&gt;
          new HomogenMatrixLine(1.0, 0.0, 0.0, 0.0),&lt;br /&gt;
          new HomogenMatrixLine(0.0, 1.0, 0.0, 0.0),&lt;br /&gt;
          new HomogenMatrixLine(0.0, 0.0, 1.0, 0.0),&lt;br /&gt;
          new HomogenMatrixLine(0.0, 0.0, 0.0, 1.0)&lt;br /&gt;
      };&lt;br /&gt;
  &lt;br /&gt;
  aMatrix.Line1 = aLines[0];&lt;br /&gt;
  aMatrix.Line2 = aLines[1];&lt;br /&gt;
  aMatrix.Line3 = aLines[2];&lt;br /&gt;
  aMatrix.Line4 = aLines[3];&lt;br /&gt;
  &lt;br /&gt;
  // rotate 10 degrees along the x axis&lt;br /&gt;
  double fAngle = 10.0;&lt;br /&gt;
  double fCosX = java.lang.Math.cos(java.lang.Math.PI / 180.0 * fAngle);&lt;br /&gt;
  double fSinX = java.lang.Math.sin(java.lang.Math.PI / 180.0 * fAngle);&lt;br /&gt;
  &lt;br /&gt;
  // rotate -20 degrees along the y axis&lt;br /&gt;
  fAngle = -20.0;&lt;br /&gt;
  double fCosY = java.lang.Math.cos(java.lang.Math.PI / 180.0 * fAngle);&lt;br /&gt;
  double fSinY = java.lang.Math.sin(java.lang.Math.PI / 180.0 * fAngle);&lt;br /&gt;
  &lt;br /&gt;
  // rotate -5 degrees along the z axis&lt;br /&gt;
  fAngle = -5.0;&lt;br /&gt;
  double fCosZ = java.lang.Math.cos(java.lang.Math.PI / 180.0 * fAngle);&lt;br /&gt;
  double fSinZ = java.lang.Math.sin(java.lang.Math.PI / 180.0 * fAngle);&lt;br /&gt;
  &lt;br /&gt;
  // set the matrix such that it represents all three rotations in the order&lt;br /&gt;
  // rotate around x axis then around y axis and finally around the z axis&lt;br /&gt;
  aMatrix.Line1.Column1 = fCosY * fCosZ;&lt;br /&gt;
  aMatrix.Line1.Column2 = fCosY * -fSinZ;&lt;br /&gt;
  aMatrix.Line1.Column3 = fSinY;&lt;br /&gt;
  &lt;br /&gt;
  aMatrix.Line2.Column1 = fSinX * fSinY * fCosZ + fCosX * fSinZ;&lt;br /&gt;
  aMatrix.Line2.Column2 = -fSinX * fSinY * fSinZ + fCosX * fCosZ;&lt;br /&gt;
  aMatrix.Line2.Column3 = -fSinX * fCosY;&lt;br /&gt;
  &lt;br /&gt;
  aMatrix.Line3.Column1 = -fCosX * fSinY * fCosZ + fSinX * fSinZ;&lt;br /&gt;
  aMatrix.Line3.Column2 = fCosX * fSinY * fSinZ + fSinX * fCosZ;&lt;br /&gt;
  aMatrix.Line3.Column3 = fCosX * fCosY;&lt;br /&gt;
  &lt;br /&gt;
  aDiaProp.setPropertyValue(&amp;quot;D3DTransformMatrix&amp;quot;, aMatrix);&lt;br /&gt;
  &lt;br /&gt;
  // add a red light source&lt;br /&gt;
  // ----------------------&lt;br /&gt;
  &lt;br /&gt;
  // in a chart by default only the second (non-specular) light source is switched on&lt;br /&gt;
  // light source 1 is the only specular light source that is used here&lt;br /&gt;
  &lt;br /&gt;
  // set direction&lt;br /&gt;
  com.sun.star.drawing.Direction3D aDirection = new com.sun.star.drawing.Direction3D();&lt;br /&gt;
  &lt;br /&gt;
  aDirection.DirectionX = -0.75;&lt;br /&gt;
  aDirection.DirectionY = 0.5;&lt;br /&gt;
  aDirection.DirectionZ = 0.5;&lt;br /&gt;
  &lt;br /&gt;
  aDiaProp.setPropertyValue(&amp;quot;D3DSceneLightDirection1&amp;quot;, aDirection);&lt;br /&gt;
  aDiaProp.setPropertyValue(&amp;quot;D3DSceneLightColor1&amp;quot;, new Integer(0xff3333));&lt;br /&gt;
  aDiaProp.setPropertyValue(&amp;quot;D3DSceneLightOn1&amp;quot;, new Boolean(true));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Refer to [[Documentation/DevGuide/Drawings/Drawing Documents and Presentation Documents|Drawing Documents and Presentation Documents]] for additional details about three-dimensional properties.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Charts]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/Data_Access&amp;diff=108375</id>
		<title>Documentation/DevGuide/Charts/Data Access</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/Data_Access&amp;diff=108375"/>
		<updated>2009-01-20T13:53:51Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/ChartsTOC&lt;br /&gt;
|Charts2b=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Charts/Working With Charts&lt;br /&gt;
|NextPage=Documentation/DevGuide/Charts/Chart Document Parts&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Data Access}}&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.chart.XChartData;com.sun.star.chart.ChartData;com.sun.star.chart.XChartDataArray;com.sun.star.chart.ChartDataArray&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
Data can only be accessed for reading when a chart resides inside a spreadsheet document and was inserted as a table chart, that is, the table chart obtains its data from cell ranges of spreadsheets. To change the underlying data, modify the content of the spreadsheet cells. For OLE charts, that is, charts that were inserted as &amp;lt;code&amp;gt;OLE2Shape&amp;lt;/code&amp;gt; objects, modify the data.&lt;br /&gt;
&lt;br /&gt;
The data of a chart is acquired from the &amp;lt;idl&amp;gt;com.sun.star.chart.XChartDocument&amp;lt;/idl&amp;gt; interface of the chart document model using the method [http://api.openoffice.org/docs/common/ref/com/sun/star/chart/XChartDocument.html#getData com.sun.star.chart.XChartDocument:getData](). The current implementation of {{PRODUCTNAME}} charts provides a &amp;lt;idl&amp;gt;com.sun.star.chart.XChartDataArray&amp;lt;/idl&amp;gt; interface, derived from &amp;lt;idl&amp;gt;com.sun.star.chart.XChartData&amp;lt;/idl&amp;gt; and supports the service &amp;lt;idl&amp;gt;com.sun.star.chart.ChartDataArray&amp;lt;/idl&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|Note that the interface definition of &amp;lt;idl&amp;gt;com.sun.star.chart.XChartDocument&amp;lt;/idl&amp;gt; does not require &amp;lt;tt&amp;gt;XChartDocument.getData()&amp;lt;/tt&amp;gt; to return an &amp;lt;tt&amp;gt;XChartDataArray&amp;lt;/tt&amp;gt;, but &amp;lt;tt&amp;gt;XChartData&amp;lt;/tt&amp;gt;, so there may be implementations that do not offer access to the values.}}&lt;br /&gt;
&lt;br /&gt;
The methods of &amp;lt;code&amp;gt;XChartDataArray&amp;lt;/code&amp;gt; are:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  sequence &amp;lt;sequence &amp;lt; double &amp;gt; &amp;gt; getData()&lt;br /&gt;
  void setData( [in] sequence &amp;lt;sequence &amp;lt; double &amp;gt; &amp;gt; aData)&lt;br /&gt;
  &lt;br /&gt;
  sequence &amp;lt; string &amp;gt; getRowDescriptions ()&lt;br /&gt;
  void setRowDescriptions(sequence &amp;lt; string aRowDescriptions &amp;gt;)&lt;br /&gt;
  &lt;br /&gt;
  sequence &amp;lt; string &amp;gt; getColumnDescriptions()&lt;br /&gt;
  void setColumnDescriptions(sequence &amp;lt; string aColumnDescriptions &amp;gt;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Included are the following methods from &amp;lt;code&amp;gt;XChartData&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  void addChartDataChangeEventListener( &lt;br /&gt;
      [in] com::sun::star::chart::XChartDataChangeEventListener aListener)&lt;br /&gt;
  void removeChartDataChangeEventListener (&lt;br /&gt;
      [in] com::sun::star::chart::XChartDataChangeEventListener aListener)&lt;br /&gt;
  &lt;br /&gt;
  double getNotANumber()&lt;br /&gt;
  boolean isNotANumber( [in] double nNumber)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The &amp;lt;idl&amp;gt;com.sun.star.chart.XChartDataArray&amp;lt;/idl&amp;gt; interface offers several methods to access data. A sequence of sequences is obtained containing double values by calling &amp;lt;code&amp;gt;getData()&amp;lt;/code&amp;gt;. With &amp;lt;code&amp;gt;setData()&amp;lt;/code&amp;gt;, such an array of values can be applied to the &amp;lt;code&amp;gt;XChartDataArray&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The arrays are a nested array, not two-dimensional. Java has only nested arrays, but in Basic a nested array must be used instead of a multidimensional array. The following example shows how to apply values to a chart in Basic:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;#039; create data with dimensions 2 x 3&lt;br /&gt;
  &amp;#039; 2 is called outer dimension and 3 inner dimension&lt;br /&gt;
  &lt;br /&gt;
  &amp;#039; assume that oChartDocument contains a valid &lt;br /&gt;
  &amp;#039; com.sun.star.chart.XChartDocument&lt;br /&gt;
  &lt;br /&gt;
  Dim oData As Object&lt;br /&gt;
  Dim oDataArray( 0 To 1 ) As Object&lt;br /&gt;
  Dim oSeries1( 0 To 2 ) As Double&lt;br /&gt;
  Dim oSeries2( 0 To 2 ) As Double&lt;br /&gt;
  &lt;br /&gt;
  oSeries1( 0 ) = 3.141&lt;br /&gt;
  oSeries1( 1 ) = 2.718&lt;br /&gt;
  oSeries1( 2 ) = 1.0&lt;br /&gt;
  &lt;br /&gt;
  oSeries2( 0 ) = 17.0&lt;br /&gt;
  oSeries2( 1 ) = 23.0&lt;br /&gt;
  oSeries2( 2 ) = 42.0&lt;br /&gt;
  &lt;br /&gt;
  oDataArray( 0 ) = oSeries1()&lt;br /&gt;
  oDataArray( 1 ) = oSeries2()&lt;br /&gt;
  &lt;br /&gt;
  &amp;#039; call getData() method of XChartDocument to get the XChartDataArray&lt;br /&gt;
  oData = oChartDocument.Data&lt;br /&gt;
  &lt;br /&gt;
  &amp;#039; call setData() method of XChartDataArray to apply the data&lt;br /&gt;
  oData.Data = oDataArray()&lt;br /&gt;
  &lt;br /&gt;
  &amp;#039; Note: to use the series arrays here as values for the series in the chart&lt;br /&gt;
  &amp;#039;       you have to set the DataRowSource of the XDiagram object to&lt;br /&gt;
  &amp;#039;       com.sun.star.chart.ChartDataRowSource.ROWS (default is COLUMNS)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|The Data obtained is a sequence that contains one sequence for each row. If you want to interpret the inner sequences as data for the series, set the &amp;lt;tt&amp;gt;DataRowSource&amp;lt;/tt&amp;gt; of your &amp;lt;tt&amp;gt;XDiagram&amp;lt;/tt&amp;gt; to &amp;lt;idl&amp;gt;com.sun.star.chart.ChartDataRowSource&amp;lt;/idl&amp;gt;&amp;lt;tt&amp;gt;.ROWS&amp;lt;/tt&amp;gt;, otherwise, the data for the &amp;#039;&amp;#039;n&amp;#039;&amp;#039;&amp;lt;sup&amp;gt;th&amp;lt;/sup&amp;gt; series is in the &amp;#039;&amp;#039;n&amp;#039;&amp;#039;&amp;lt;sup&amp;gt;th&amp;lt;/sup&amp;gt; element of each &amp;#039;&amp;#039;inner&amp;#039;&amp;#039; series.}}&lt;br /&gt;
&lt;br /&gt;
With the methods of the &amp;lt;code&amp;gt;XChartData&amp;lt;/code&amp;gt; interface, check if a number from the chart has to be interpreted as non-existent, that is, the number is not a number (NaN).&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Caution|In the current implementation of {{PRODUCTNAME}} Chart, the value of NaN is not the standard ISO value for NaN of the C++ double type, but instead &amp;lt;tt&amp;gt;DBL_MIN&amp;lt;/tt&amp;gt; which is &amp;lt;tt&amp;gt;2.2250738585072014&amp;lt;sup&amp;gt;-308&amp;lt;/sup&amp;gt;&amp;lt;/tt&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
Additionally, the &amp;lt;code&amp;gt;XChartData&amp;lt;/code&amp;gt; interface is used to connect a component as a listener on data changes. For example, to use a spreadsheet as the source of the data of a chart that resides inside a presentation. It can also be used in the opposite direction: the spreadsheet could display the data from a chart that resides in a presentation document. To achieve this, the &amp;lt;idl&amp;gt;com.sun.star.table.CellRange&amp;lt;/idl&amp;gt; service also points to the XChartData interface, so that a listener can be attached to update the chart OLE object.&lt;br /&gt;
&lt;br /&gt;
The following class &amp;lt;code&amp;gt;ListenAtCalcRangeInDraw&amp;lt;/code&amp;gt; demonstrates how to synchronize the data of a spreadsheet range with a chart residing in another document. Here the chart is placed into a drawing document.&lt;br /&gt;
&lt;br /&gt;
The class &amp;lt;code&amp;gt;ListenAtCalcRangeInDraw&amp;lt;/code&amp;gt; in the example below implements a &amp;lt;idl&amp;gt;com.sun.star.lang.XEventListener&amp;lt;/idl&amp;gt; to get notified when the spreadsheet document or drawing document are closed.&lt;br /&gt;
&lt;br /&gt;
It also implements a &amp;lt;idl&amp;gt;com.sun.star.chart.XChartDataChangeEventListener&amp;lt;/idl&amp;gt; that listens for changes in the underlying &amp;lt;code&amp;gt;XchartData&amp;lt;/code&amp;gt;. In this case, it is the range in the spreadsheet. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  import com.sun.star.uno.UnoRuntime;&lt;br /&gt;
  import com.sun.star.lang.XEventListener;&lt;br /&gt;
  import com.sun.star.beans.XPropertySet;&lt;br /&gt;
  import com.sun.star.lang.XComponent;&lt;br /&gt;
  &lt;br /&gt;
  import com.sun.star.chart.*;&lt;br /&gt;
  import com.sun.star.sheet.XSpreadsheetDocument;&lt;br /&gt;
  &lt;br /&gt;
  // implement an XEventListener for listening to the disposing&lt;br /&gt;
  // of documents. Also implement XChartDataChangeEventListener&lt;br /&gt;
  // to get informed about changes of data in a chart&lt;br /&gt;
  &lt;br /&gt;
  public class ListenAtCalcRangeInDraw implements XChartDataChangeEventListener {&lt;br /&gt;
      public ListenAtCalcRangeInDraw(String args[]) {&lt;br /&gt;
          // create a spreadsheet document in maSheetDoc&lt;br /&gt;
          // create a drawing document in maDrawDoc&lt;br /&gt;
          // put a chart into the drawing document&lt;br /&gt;
          // and store it in maChartDocument&lt;br /&gt;
          // ...&lt;br /&gt;
          &lt;br /&gt;
          com.sun.star.table.XCellRange aRange;&lt;br /&gt;
          // assign a range from the spreadsheet to aRange&lt;br /&gt;
          // ...&lt;br /&gt;
          &lt;br /&gt;
          // attach the data coming from the cell range to the chart&lt;br /&gt;
          maChartData = (XChartData) UnoRuntime.queryInterface(XChartData.class, aRange);&lt;br /&gt;
          maChartDocument.attachData(maChartData);&lt;br /&gt;
      }&lt;br /&gt;
          &lt;br /&gt;
      public void run() { &lt;br /&gt;
          try {&lt;br /&gt;
              // show a sub title to inform about last update&lt;br /&gt;
              ((XPropertySet) UnoRuntime.queryInterface( &lt;br /&gt;
                  XPropertySet.class, maChartDocument)).setPropertyValue(&lt;br /&gt;
                      &amp;quot;HasSubTitle&amp;quot;, new Boolean(true));&lt;br /&gt;
              &lt;br /&gt;
              // start listening for death of spreadsheet&lt;br /&gt;
              ((XComponent) UnoRuntime.queryInterface(XComponent.class,&lt;br /&gt;
                  maSheetDoc)).addEventListener(this);&lt;br /&gt;
              &lt;br /&gt;
              // start listening for death of chart&lt;br /&gt;
              ((XComponent) UnoRuntime.queryInterface(XComponent.class,&lt;br /&gt;
                  maChartDocument)).addEventListener(this);&lt;br /&gt;
              &lt;br /&gt;
              //start listening for change of data&lt;br /&gt;
              maChartData.addChartDataChangeEventListener(this);&lt;br /&gt;
          } catch (com.sun.star.uno.Exception ex) {&lt;br /&gt;
              System.out.println(&amp;quot;Oops: &amp;quot; + ex);&lt;br /&gt;
          }&lt;br /&gt;
          &lt;br /&gt;
          // call listener once for initialization&lt;br /&gt;
          ChartDataChangeEvent aEvent = new ChartDataChangeEvent();&lt;br /&gt;
          aEvent.Type = ChartDataChangeType.ALL;&lt;br /&gt;
          chartDataChanged(aEvent);&lt;br /&gt;
      }&lt;br /&gt;
          &lt;br /&gt;
      // XEventListener (base interface of XChartDataChangeEventListener)&lt;br /&gt;
      public void disposing(com.sun.star.lang.EventObject aSourceObj)&lt;br /&gt;
      {&lt;br /&gt;
          // test if the Source object is a chart document&lt;br /&gt;
          if( UnoRuntime.queryInterface(XChartDocument.class, aSourceObj.Source) != null)&lt;br /&gt;
              System.out.println(&amp;quot;Disconnecting Listener because Chart was shut down&amp;quot;);&lt;br /&gt;
          &lt;br /&gt;
          // test if the Source object is a spreadsheet document&lt;br /&gt;
          if (UnoRuntime.queryInterface(XSpreadsheetDocument.class, aSourceObj.Source) != null)&lt;br /&gt;
              System.out.println(&amp;quot;Disconnecting Listener because Spreadsheet was shut down&amp;quot;);&lt;br /&gt;
          &lt;br /&gt;
          // remove data change listener&lt;br /&gt;
          maChartData.removeChartDataChangeEventListener(this);&lt;br /&gt;
          &lt;br /&gt;
          // remove dispose listeners&lt;br /&gt;
          ((XComponent) UnoRuntime.queryInterface(XComponent.class,&lt;br /&gt;
              maSheetDoc)).removeEventListener(this);&lt;br /&gt;
          ((XComponent) UnoRuntime.queryInterface(XComponent.class,&lt;br /&gt;
              maChartDocument)).removeEventListener(this);&lt;br /&gt;
          // this program cannot do anything any more&lt;br /&gt;
          System.exit(0);&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      // XChartDataChangeEventListener&lt;br /&gt;
      public void chartDataChanged(ChartDataChangeEvent aEvent)&lt;br /&gt;
      {&lt;br /&gt;
          // update subtitle with current date&lt;br /&gt;
          String aTitle = new String(&amp;quot;Last Update: &amp;quot; + new java.util.Date(System.currentTimeMillis()));&lt;br /&gt;
          &lt;br /&gt;
          try {&lt;br /&gt;
              ((XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,&lt;br /&gt;
                  maChartDocument.getSubTitle())).setPropertyValue(&lt;br /&gt;
                      &amp;quot;String&amp;quot;, aTitle);&lt;br /&gt;
              &lt;br /&gt;
              maChartDocument.attachData(maChartData);&lt;br /&gt;
          } catch(Exception ex) {&lt;br /&gt;
              System.out.println(&amp;quot;Oops: &amp;quot; + ex);&lt;br /&gt;
          }&lt;br /&gt;
                        &lt;br /&gt;
          System.out.println(&amp;quot;Data has changed&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      // private&lt;br /&gt;
      private com.sun.star.sheet.XSpreadsheetDocument maSheetDoc;&lt;br /&gt;
      private com.sun.star.frame.XModel maDrawDoc;&lt;br /&gt;
      private com.sun.star.chart.XChartDocument maChartDocument;&lt;br /&gt;
      private com.sun.star.chart.XChartData maChartData;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Charts]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/Statistics&amp;diff=108370</id>
		<title>Documentation/DevGuide/Charts/Statistics</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/Statistics&amp;diff=108370"/>
		<updated>2009-01-20T12:39:15Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/ChartsTOC&lt;br /&gt;
|Charts2b=block&lt;br /&gt;
|ChartsParts=block&lt;br /&gt;
|ChartsFeat=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Charts/Features of Special Chart Types&lt;br /&gt;
|NextPage=Documentation/DevGuide/Charts/3-D Charts&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Statistics}}&lt;br /&gt;
Statistical properties like error indicators or regression curves can be applied. The regression curves can only be used for xy-diagrams that have tuples of values for each data point. The following example shows how to add a linear regression curve to an xy-diagram.&lt;br /&gt;
&lt;br /&gt;
Additionally, the mean value line is displayed and error indicators for the standard deviation are applied.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // get the diagram&lt;br /&gt;
  // ...&lt;br /&gt;
  &lt;br /&gt;
  // get the properties of a single series&lt;br /&gt;
  XPropertySet aProp = maDiagram.getDataRowProperties(1)&lt;br /&gt;
  &lt;br /&gt;
  // set a linear regression&lt;br /&gt;
  aProp.setPropertyValue(&amp;quot;RegressionCurves&amp;quot;, ChartRegressionCurveType.LINEAR);&lt;br /&gt;
  &lt;br /&gt;
  // show a line at y = mean of the series&amp;#039; values&lt;br /&gt;
  aProp.setPropertyValue(&amp;quot;MeanValue&amp;quot;, new Boolean(true));&lt;br /&gt;
  &lt;br /&gt;
  // add error indicators in both directions&lt;br /&gt;
  // with the length of the standard deviation&lt;br /&gt;
  aProp.setPropertyValue(&amp;quot;ErrorCategory&amp;quot;, ChartErrorCategory.STANDARD_DEVIATION);&lt;br /&gt;
  aProp.setPropertyValue(&amp;quot;ErrorIndicator&amp;quot;, ChartErrorIndicatorType.TOP_AND_BOTTOM);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Charts]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/Common_Parts_of_all_Chart_Types&amp;diff=108369</id>
		<title>Documentation/DevGuide/Charts/Common Parts of all Chart Types</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/Common_Parts_of_all_Chart_Types&amp;diff=108369"/>
		<updated>2009-01-20T12:30:20Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/ChartsTOC&lt;br /&gt;
|Charts2b=block&lt;br /&gt;
|ChartsParts=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Charts/Chart Document Parts&lt;br /&gt;
|NextPage=Documentation/DevGuide/Charts/Features of Special Chart Types&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Common Parts of all Chart Types}}&lt;br /&gt;
=== Diagram ===&lt;br /&gt;
&lt;br /&gt;
The diagram object is an important object of a chart document. The diagram represents the visualization of the underlying data. The diagram object is a graphic object group that lies on the same level as the titles and the legend. From the diagram, data rows and data points are obtain that are also graphic objects that represent the respective data. Several properties can be set at a diagram to influence its appearance. Note that the term data series is used instead of data rows.&lt;br /&gt;
&lt;br /&gt;
Some diagrams support the service &amp;lt;idl&amp;gt;com.sun.star.chart.Dim3DDiagram&amp;lt;/idl&amp;gt; that contains the property &amp;lt;code&amp;gt;Dim3D&amp;lt;/code&amp;gt;. If this is set to true, you get a three-dimensional view of the chart, which in {{PRODUCTNAME}} is usually rendered in OpenGL. In 3-D charts, you can access the z-axis, which is not available in 2-D.&lt;br /&gt;
&lt;br /&gt;
The service &amp;lt;idl&amp;gt;com.sun.star.chart.StackableDiagram&amp;lt;/idl&amp;gt; offers the properties &amp;#039;&amp;#039;Percent&amp;#039;&amp;#039; and &amp;#039;&amp;#039;Stacked&amp;#039;&amp;#039;. With these properties, accumulated values can be stacked for viewing. When setting &amp;lt;code&amp;gt;Percent&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;, all slices through the series are summed up to 100 percent, so that for an &amp;lt;code&amp;gt;AreaDiagram&amp;lt;/code&amp;gt; the whole diagram space would be filled with the series. Note that setting the &amp;lt;code&amp;gt;Percent&amp;lt;/code&amp;gt; property also sets the &amp;lt;code&amp;gt;Stacked&amp;lt;/code&amp;gt; property, because &amp;lt;code&amp;gt;Percent&amp;lt;/code&amp;gt; is an addition to &amp;lt;code&amp;gt;Stacked&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There is a third service that extends a base diagram type for displaying statistical elements called &amp;lt;idl&amp;gt;com.sun.star.chart.ChartStatistics&amp;lt;/idl&amp;gt;. With this service, error indicators or a mean value line are added. The mean value line represents the mean of all values of a series. The regression curve is only available for the &amp;lt;code&amp;gt;XYDiagram&amp;lt;/code&amp;gt;, because a numeric x-axis, is required.&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram.png|none|thumb|400px|Diagram]]&lt;br /&gt;
&lt;br /&gt;
The illustration above shows that there are eight base types of diagrams. The three services, &amp;lt;code&amp;gt;StackableDiagram&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Dim3DDiagram&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ChartStatistics&amp;lt;/code&amp;gt; are also supported for several diagram types and allows extensions of the base types as discussed. For instance, a three-dimensional pie chart can be created, because the &amp;lt;idl&amp;gt;com.sun.star.chart.PieDiagram&amp;lt;/idl&amp;gt; service points to the &amp;lt;idl&amp;gt;com.sun.star.chart.Dim3DDiagram&amp;lt;/idl&amp;gt; service.&lt;br /&gt;
&lt;br /&gt;
The services &amp;lt;idl&amp;gt;com.sun.star.chart.AreaDiagram&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.chart.LineDiagram&amp;lt;/idl&amp;gt;, and &amp;lt;idl&amp;gt;com.sun.star.chart.BarDiagram&amp;lt;/idl&amp;gt; support all three feature services.&lt;br /&gt;
&lt;br /&gt;
=== Axis ===&lt;br /&gt;
&lt;br /&gt;
All charts can have one or more axis, except for pie charts. A typical two-dimensional chart has two axis, an x- and y-axis. Secondary x- or y-axis can be added to have up to four axis. In a three-dimensional chart, there are typically three axis, x-, y- and z-axis. There are no secondary axis in 3-dimensional charts.&lt;br /&gt;
&lt;br /&gt;
An axis combines two types of properties:&lt;br /&gt;
&lt;br /&gt;
* Scaling properties that affect other objects in the chart. A minimum and maximum values are set that spans the visible area for the displayed data. A step value can also be set that determines the distance between two tick-marks, and the distance between two grid-lines if grids are switched on for the corresponding axis.&lt;br /&gt;
* Graphical properties that influence the visual impression. These are character properties (see &amp;lt;idl&amp;gt;com.sun.star.style.CharacterProperties&amp;lt;/idl&amp;gt;) affecting the labels and line properties (see &amp;lt;idl&amp;gt;com.sun.star.drawing.LineProperties&amp;lt;/idl&amp;gt;) that are applied to the axis line and the tick-marks.&lt;br /&gt;
&lt;br /&gt;
[[Image:Axis.png|none|thumb|400px|Axis]]&lt;br /&gt;
&lt;br /&gt;
Different diagram types support a different number of axis. In the above illustration, a &amp;lt;idl&amp;gt;com.sun.star.chart.XYDiagram&amp;lt;/idl&amp;gt;, also known as a scatter diagram, is shown. The scatter diagram supports x- and y-axis, but not a z-axis as there is no 3-dimensional mode. The &amp;lt;idl&amp;gt;com.sun.star.chart.PieDiagram&amp;lt;/idl&amp;gt; supports no axis at all. The &amp;lt;idl&amp;gt;com.sun.star.chart.BarDiagram&amp;lt;/idl&amp;gt; supports all kinds of axis. Note that the z-Axis is only supported in a three-dimensional chart. Note that there is a &amp;lt;idl&amp;gt;com.sun.star.chart.ChartTwoAxisXSupplier&amp;lt;/idl&amp;gt; that includes the [IDL:com.sun.star.chart.ChartAxisXSupplier] and is supported by all diagrams in {{PRODUCTNAME}} required to support the service &amp;lt;code&amp;gt;ChartAxisXSupplier&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The following example shows how to obtain an axis and how to change the number format.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  import com.sun.star.chart.*;&lt;br /&gt;
  import com.sun.star.beans.XPropertySet;&lt;br /&gt;
  import com.sun.star.util.XNumberFormatsSupplier;&lt;br /&gt;
  &lt;br /&gt;
  ...&lt;br /&gt;
  &lt;br /&gt;
  // class members&lt;br /&gt;
  XChartDocument aChartDocument;&lt;br /&gt;
  XDiagram aDiagram;&lt;br /&gt;
  &lt;br /&gt;
  ...&lt;br /&gt;
  &lt;br /&gt;
  // get an XChartDocument and assign it to aChartDocument&lt;br /&gt;
  // get the diagram from the document and assign it to aDiagram&lt;br /&gt;
  // ...&lt;br /&gt;
  &lt;br /&gt;
  // check whether the current chart supports a y-axis&lt;br /&gt;
  XAxisYSupplier aYAxisSupplier = (XAxisYSupplier) UnoRuntime.queryInterface(&lt;br /&gt;
      XAxisYSupplier.class, aDiagram);&lt;br /&gt;
  &lt;br /&gt;
  if (aYAxisSupplier != null) {&lt;br /&gt;
      XPropertySet aAxisProp = aYAxisSupplier.getYAxis();&lt;br /&gt;
      &lt;br /&gt;
      // initialize new format with value for standard&lt;br /&gt;
      int nNewNumberFormat = 0;&lt;br /&gt;
      &lt;br /&gt;
      XNumberFormatsSupplier aNumFmtSupp = (XNumberFormatsSupplier)&lt;br /&gt;
          UnoRuntime.queryInterface(XNumberFormatsSupplier.class,&lt;br /&gt;
              aChartDocument);&lt;br /&gt;
      &lt;br /&gt;
      if (aNumFmtSupp != null) {&lt;br /&gt;
          com.sun.star.util.XNumberFormats aFormats = aNumFmtSupp.getNumberFormats();&lt;br /&gt;
      &lt;br /&gt;
          Locale aLocale = new Locale(&amp;quot;de&amp;quot;, &amp;quot;DE&amp;quot;, &amp;quot;de&amp;quot;);&lt;br /&gt;
          &lt;br /&gt;
          String aFormatStr = aFormats.generateFormat(&lt;br /&gt;
              0,        // base key&lt;br /&gt;
              aLocale,  // locale&lt;br /&gt;
              true,     // thousands separator on&lt;br /&gt;
              true,     // negative values in red&lt;br /&gt;
              (short)3, // number of decimal places&lt;br /&gt;
              (short)1  // number of leading ciphers&lt;br /&gt;
          );&lt;br /&gt;
          &lt;br /&gt;
          nNewNumberFormat = aFormats.addNew(aFormatStr, aLocale);&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      aAxisProp.setPropertyValue(&amp;quot;NumberFormat&amp;quot;, new Integer(nNewNumberFormat));&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Data Series and Data Points ===&lt;br /&gt;
&lt;br /&gt;
The objects that visualize the actual data are data series. The API calls them data rows that are not rows in a two-dimensional spreadsheet table, but as sets of data, because the data for a &amp;#039;&amp;#039;data row&amp;#039;&amp;#039; can reside in a column of a spreadsheet table.&lt;br /&gt;
&lt;br /&gt;
The data rows contain data points. The following two methods at the &amp;lt;idl&amp;gt;com.sun.star.chart.XDiagram&amp;lt;/idl&amp;gt; interface allow changes to the properties of a whole series or single data point:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  com::sun::star::beans::XPropertySet getDataRowProperties( [in] long nRow)&lt;br /&gt;
  com::sun::star::beans::XPropertySet getDataPointProperties( [in] long nCol,&lt;br /&gt;
                                                              [in] long nRow) &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The index provided in these methods is 0-based, that is, 0 is the first series. In &amp;lt;code&amp;gt;XYDiagrams&amp;lt;/code&amp;gt;, the first series has an index 1, because the first array of values contains the x-values of the diagram that is not visualized. This behavior exists for historical reasons.&lt;br /&gt;
&lt;br /&gt;
In a spreadsheet context, the indexes for &amp;lt;code&amp;gt;getDataPointProperties()&amp;lt;/code&amp;gt; are called &amp;lt;code&amp;gt;nCol&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;nRow&amp;lt;/code&amp;gt; and are misleading. The &amp;lt;code&amp;gt;nRow&amp;lt;/code&amp;gt; parameter gives the data row, that is, the series index. The &amp;lt;code&amp;gt;nCol&amp;lt;/code&amp;gt; gives the index of the data point inside the series, regardless if the series is taken from rows or columns in the underlying table. To get the sixth point of the third series, write &amp;lt;code&amp;gt;getDataPointProperties(5, 2)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Data rows and data points have &amp;lt;idl&amp;gt;com.sun.star.drawing.LineProperties&amp;lt;/idl&amp;gt; and &amp;lt;idl&amp;gt;com.sun.star.drawing.FillProperties&amp;lt;/idl&amp;gt;. They also support &amp;lt;idl&amp;gt;com.sun.star.style.CharacterProperties&amp;lt;/idl&amp;gt; for text descriptions that can be displayed next to data points.&lt;br /&gt;
&lt;br /&gt;
Properties can be set for symbols and the type of descriptive text desired. With the &amp;lt;code&amp;gt;SymbolType&amp;lt;/code&amp;gt; property, one of several predefined symbols can be set. With &amp;lt;code&amp;gt;SymbolBitmapURL&amp;lt;/code&amp;gt;, a URL that points to a graphic in a format known by {{PRODUCTNAME}} can be set that is then used as a symbol in a &amp;lt;idl&amp;gt;com.sun.star.chart.LineDiagram&amp;lt;/idl&amp;gt; or &amp;lt;idl&amp;gt;com.sun.star.chart.XYDiagram&amp;lt;/idl&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The following example demonstrates how to set properties of a data point. Before implementing this example, create a chart document and diagram of the type &amp;lt;code&amp;gt;XYDiagram&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  com.sun.star.chart.XChartDocument aChartDocument;&lt;br /&gt;
  com.sun.star.chart.XDiagram aXYDiagram;&lt;br /&gt;
  &lt;br /&gt;
  // get a chart document and assign it to aChartDocument&lt;br /&gt;
  // set an &amp;quot;XYDiagram&amp;quot; and remember the diagram in aXYDiagram&lt;br /&gt;
  // ...&lt;br /&gt;
  &lt;br /&gt;
  // get the properties of the fifth data point of the first series&lt;br /&gt;
  // note that index 1 is the first series only in XYDiagrams&lt;br /&gt;
  try {&lt;br /&gt;
      com.sun.star.beans.XPropertySet aPointProp = maDiagram.getDataPointProperties(4, 1);&lt;br /&gt;
  } catch (com.sun.star.lang.IndexOutOfBoundsException ex) {&lt;br /&gt;
      System.out.println(&amp;quot;Index is out of bounds: &amp;quot; + ex);&lt;br /&gt;
      System.exit(0);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  try {&lt;br /&gt;
      // set a bitmap via URL as symbol for the first series&lt;br /&gt;
      aPointProp.setPropertyValue(&amp;quot;SymbolType&amp;quot;, new Integer(ChartSymbolType.BITMAPURL));&lt;br /&gt;
      aPointProp.setPropertyValue(&amp;quot;SymbolBitmapURL&amp;quot;, &lt;br /&gt;
          &amp;quot;http://graphics.openoffice.org/chart/bullet1.gif&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
      // add a label text with bold font, bordeaux red 14pt&lt;br /&gt;
      aPointProp.setPropertyValue(&amp;quot;DataCaption&amp;quot;, new Integer(ChartDataCaption.VALUE));&lt;br /&gt;
      aPointProp.setPropertyValue(&amp;quot;CharHeight&amp;quot;, new Float(14.0));&lt;br /&gt;
      aPointProp.setPropertyValue(&amp;quot;CharColor&amp;quot;, new Integer(0x993366));&lt;br /&gt;
      aPointProp.setPropertyValue(&amp;quot;CharWeight&amp;quot;, new Float(FontWeight.BOLD));&lt;br /&gt;
  } catch (com.sun.star.uno.Exception ex) {&lt;br /&gt;
      System.out.println(&amp;quot;Exception caught: &amp;quot; + ex);&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Charts]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/Data_Access&amp;diff=108368</id>
		<title>Documentation/DevGuide/Charts/Data Access</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/Data_Access&amp;diff=108368"/>
		<updated>2009-01-20T12:25:33Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/ChartsTOC&lt;br /&gt;
|Charts2b=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Charts/Working With Charts&lt;br /&gt;
|NextPage=Documentation/DevGuide/Charts/Chart Document Parts&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Data Access}}&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.chart.XChartData;com.sun.star.chart.ChartData;com.sun.star.chart.XChartDataArray;com.sun.star.chart.ChartDataArray&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
Data can only be accessed for reading when a chart resides inside a spreadsheet document and was inserted as a table chart, that is, the table chart obtains its data from cell ranges of spreadsheets. To change the underlying data, modify the content of the spreadsheet cells. For OLE charts, that is, charts that were inserted as &amp;lt;code&amp;gt;OLE2Shape&amp;lt;/code&amp;gt; objects, modify the data.&lt;br /&gt;
&lt;br /&gt;
The data of a chart is acquired from the &amp;lt;idl&amp;gt;com.sun.star.chart.XChartDocument&amp;lt;/idl&amp;gt; interface of the chart document model using the method [http://api.openoffice.org/docs/common/ref/com/sun/star/chart/XChartDocument.html#getData com.sun.star.chart.XChartDocument:getData](). The current implementation of {{PRODUCTNAME}} charts provides a &amp;lt;idl&amp;gt;com.sun.star.chart.XChartDataArray&amp;lt;/idl&amp;gt; interface, derived from &amp;lt;idl&amp;gt;com.sun.star.chart.XChartData&amp;lt;/idl&amp;gt; and supports the service &amp;lt;idl&amp;gt;com.sun.star.chart.ChartDataArray&amp;lt;/idl&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|Note that the interface definition of &amp;lt;idl&amp;gt;com.sun.star.chart.XChartDocument&amp;lt;/idl&amp;gt; does not require &amp;lt;tt&amp;gt;XChartDocument.getData()&amp;lt;/tt&amp;gt; to return an &amp;lt;tt&amp;gt;XChartDataArray&amp;lt;/tt&amp;gt;, but &amp;lt;tt&amp;gt;XChartData&amp;lt;/tt&amp;gt;, so there may be implementations that do not offer access to the values.}}&lt;br /&gt;
&lt;br /&gt;
The methods of &amp;lt;code&amp;gt;XChartDataArray&amp;lt;/code&amp;gt; are:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  sequence &amp;lt;sequence &amp;lt; double &amp;gt; &amp;gt; getData()&lt;br /&gt;
  void setData( [in] sequence &amp;lt;sequence &amp;lt; double &amp;gt; &amp;gt; aData)&lt;br /&gt;
  &lt;br /&gt;
  sequence &amp;lt; string &amp;gt; getRowDescriptions ()&lt;br /&gt;
  void setRowDescriptions(sequence &amp;lt; string aRowDescriptions &amp;gt;)&lt;br /&gt;
  &lt;br /&gt;
  sequence &amp;lt; string &amp;gt; getColumnDescriptions()&lt;br /&gt;
  void setColumnDescriptions(sequence &amp;lt; string aColumnDescriptions &amp;gt;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Included are the following methods from &amp;lt;code&amp;gt;XChartData&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  void addChartDataChangeEventListener( &lt;br /&gt;
      [in] com::sun::star::chart::XChartDataChangeEventListener aListener)&lt;br /&gt;
  void removeChartDataChangeEventListener (&lt;br /&gt;
      [in] com::sun::star::chart::XChartDataChangeEventListener aListener)&lt;br /&gt;
  &lt;br /&gt;
  double getNotANumber()&lt;br /&gt;
  boolean isNotANumber( [in] double nNumber)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The &amp;lt;idl&amp;gt;com.sun.star.chart.XChartDataArray&amp;lt;/idl&amp;gt; interface offers several methods to access data. A sequence of sequences is obtained containing double values by calling &amp;lt;code&amp;gt;getData()&amp;lt;/code&amp;gt;. With &amp;lt;code&amp;gt;setData()&amp;lt;/code&amp;gt;, such an array of values can be applied to the &amp;lt;code&amp;gt;XChartDataArray&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The arrays are a nested array, not two-dimensional. Java has only nested arrays, but in Basic a nested array must be used instead of a multidimensional array. The following example shows how to apply values to a chart in Basic:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;#039; create data with dimensions 2 x 3&lt;br /&gt;
  &amp;#039; 2 is called outer dimension and 3 inner dimension&lt;br /&gt;
  &lt;br /&gt;
  &amp;#039; assume that oChartDocument contains a valid &lt;br /&gt;
  &amp;#039; com.sun.star.chart.XChartDocument&lt;br /&gt;
  &lt;br /&gt;
  Dim oData As Object&lt;br /&gt;
  Dim oDataArray( 0 To 1 ) As Object&lt;br /&gt;
  Dim oSeries1( 0 To 2 ) As Double&lt;br /&gt;
  Dim oSeries2( 0 To 2 ) As Double&lt;br /&gt;
  &lt;br /&gt;
  oSeries1( 0 ) = 3.141&lt;br /&gt;
  oSeries1( 1 ) = 2.718&lt;br /&gt;
  oSeries1( 2 ) = 1.0&lt;br /&gt;
  &lt;br /&gt;
  oSeries2( 0 ) = 17.0&lt;br /&gt;
  oSeries2( 1 ) = 23.0&lt;br /&gt;
  oSeries2( 2 ) = 42.0&lt;br /&gt;
  &lt;br /&gt;
  oDataArray( 0 ) = oSeries1()&lt;br /&gt;
  oDataArray( 1 ) = oSeries2()&lt;br /&gt;
  &lt;br /&gt;
  &amp;#039; call getData() method of XChartDocument to get the XChartDataArray&lt;br /&gt;
  oData = oChartDocument.Data&lt;br /&gt;
  &lt;br /&gt;
  &amp;#039; call setData() method of XChartDataArray to apply the data&lt;br /&gt;
  oData.Data = oDataArray()&lt;br /&gt;
  &lt;br /&gt;
  &amp;#039; Note: to use the series arrays here as values for the series in the chart&lt;br /&gt;
  &amp;#039;       you have to set the DataRowSource of the XDiagram object to&lt;br /&gt;
  &amp;#039;       com.sun.star.chart.ChartDataRowSource.ROWS (default is COLUMNS)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|The Data obtained is a sequence that contains one sequence for each row. If you want to interpret the inner sequences as data for the series, set the &amp;lt;tt&amp;gt;DataRowSource&amp;lt;/tt&amp;gt; of your &amp;lt;tt&amp;gt;XDiagram&amp;lt;/tt&amp;gt; to &amp;lt;idl&amp;gt;com.sun.star.chart.ChartDataRowSource&amp;lt;/idl&amp;gt;tt&amp;gt;.ROWS&amp;lt;/tt&amp;gt;, otherwise, the data for the &amp;#039;&amp;#039;n&amp;#039;&amp;#039;&amp;lt;sup&amp;gt;th&amp;lt;/sup&amp;gt; series is in the &amp;#039;&amp;#039;n&amp;#039;&amp;#039;&amp;lt;sup&amp;gt;th&amp;lt;/sup&amp;gt; element of each &amp;#039;&amp;#039;inner&amp;#039;&amp;#039; series.}}&lt;br /&gt;
&lt;br /&gt;
With the methods of the &amp;lt;code&amp;gt;XChartData&amp;lt;/code&amp;gt; interface, check if a number from the chart has to be interpreted as non-existent, that is, the number is not a number (NaN).&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Caution|In the current implementation of {{PRODUCTNAME}} Chart, the value of NaN is not the standard ISO value for NaN of the C++ double type, but instead &amp;lt;tt&amp;gt;DBL_MIN&amp;lt;/tt&amp;gt; which is &amp;lt;tt&amp;gt;2.2250738585072014&amp;lt;sup&amp;gt;-308&amp;lt;/sup&amp;gt;&amp;lt;/tt&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
Additionally, the &amp;lt;code&amp;gt;XChartData&amp;lt;/code&amp;gt; interface is used to connect a component as a listener on data changes. For example, to use a spreadsheet as the source of the data of a chart that resides inside a presentation. It can also be used in the opposite direction: the spreadsheet could display the data from a chart that resides in a presentation document. To achieve this, the &amp;lt;idl&amp;gt;com.sun.star.table.CellRange&amp;lt;/idl&amp;gt; service also points to the XChartData interface, so that a listener can be attached to update the chart OLE object.&lt;br /&gt;
&lt;br /&gt;
The following class &amp;lt;code&amp;gt;ListenAtCalcRangeInDraw&amp;lt;/code&amp;gt; demonstrates how to synchronize the data of a spreadsheet range with a chart residing in another document. Here the chart is placed into a drawing document.&lt;br /&gt;
&lt;br /&gt;
The class &amp;lt;code&amp;gt;ListenAtCalcRangeInDraw&amp;lt;/code&amp;gt; in the example below implements a &amp;lt;idl&amp;gt;com.sun.star.lang.XEventListener&amp;lt;/idl&amp;gt; to get notified when the spreadsheet document or drawing document are closed.&lt;br /&gt;
&lt;br /&gt;
It also implements a &amp;lt;idl&amp;gt;com.sun.star.chart.XChartDataChangeEventListener&amp;lt;/idl&amp;gt; that listens for changes in the underlying &amp;lt;code&amp;gt;XchartData&amp;lt;/code&amp;gt;. In this case, it is the range in the spreadsheet. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  import com.sun.star.uno.UnoRuntime;&lt;br /&gt;
  import com.sun.star.lang.XEventListener;&lt;br /&gt;
  import com.sun.star.beans.XPropertySet;&lt;br /&gt;
  import com.sun.star.lang.XComponent;&lt;br /&gt;
  &lt;br /&gt;
  import com.sun.star.chart.*;&lt;br /&gt;
  import com.sun.star.sheet.XSpreadsheetDocument;&lt;br /&gt;
  &lt;br /&gt;
  // implement an XEventListener for listening to the disposing&lt;br /&gt;
  // of documents. Also implement XChartDataChangeEventListener&lt;br /&gt;
  // to get informed about changes of data in a chart&lt;br /&gt;
  &lt;br /&gt;
  public class ListenAtCalcRangeInDraw implements XChartDataChangeEventListener {&lt;br /&gt;
      public ListenAtCalcRangeInDraw(String args[]) {&lt;br /&gt;
          // create a spreadsheet document in maSheetDoc&lt;br /&gt;
          // create a drawing document in maDrawDoc&lt;br /&gt;
          // put a chart into the drawing document&lt;br /&gt;
          // and store it in maChartDocument&lt;br /&gt;
          // ...&lt;br /&gt;
          &lt;br /&gt;
          com.sun.star.table.XCellRange aRange;&lt;br /&gt;
          // assign a range from the spreadsheet to aRange&lt;br /&gt;
          // ...&lt;br /&gt;
          &lt;br /&gt;
          // attach the data coming from the cell range to the chart&lt;br /&gt;
          maChartData = (XChartData) UnoRuntime.queryInterface(XChartData.class, aRange);&lt;br /&gt;
          maChartDocument.attachData(maChartData);&lt;br /&gt;
      }&lt;br /&gt;
          &lt;br /&gt;
      public void run() { &lt;br /&gt;
          try {&lt;br /&gt;
              // show a sub title to inform about last update&lt;br /&gt;
              ((XPropertySet) UnoRuntime.queryInterface( &lt;br /&gt;
                  XPropertySet.class, maChartDocument)).setPropertyValue(&lt;br /&gt;
                      &amp;quot;HasSubTitle&amp;quot;, new Boolean(true));&lt;br /&gt;
              &lt;br /&gt;
              // start listening for death of spreadsheet&lt;br /&gt;
              ((XComponent) UnoRuntime.queryInterface(XComponent.class,&lt;br /&gt;
                  maSheetDoc)).addEventListener(this);&lt;br /&gt;
              &lt;br /&gt;
              // start listening for death of chart&lt;br /&gt;
              ((XComponent) UnoRuntime.queryInterface(XComponent.class,&lt;br /&gt;
                  maChartDocument)).addEventListener(this);&lt;br /&gt;
              &lt;br /&gt;
              //start listening for change of data&lt;br /&gt;
              maChartData.addChartDataChangeEventListener(this);&lt;br /&gt;
          } catch (com.sun.star.uno.Exception ex) {&lt;br /&gt;
              System.out.println(&amp;quot;Oops: &amp;quot; + ex);&lt;br /&gt;
          }&lt;br /&gt;
          &lt;br /&gt;
          // call listener once for initialization&lt;br /&gt;
          ChartDataChangeEvent aEvent = new ChartDataChangeEvent();&lt;br /&gt;
          aEvent.Type = ChartDataChangeType.ALL;&lt;br /&gt;
          chartDataChanged(aEvent);&lt;br /&gt;
      }&lt;br /&gt;
          &lt;br /&gt;
      // XEventListener (base interface of XChartDataChangeEventListener)&lt;br /&gt;
      public void disposing(com.sun.star.lang.EventObject aSourceObj)&lt;br /&gt;
      {&lt;br /&gt;
          // test if the Source object is a chart document&lt;br /&gt;
          if( UnoRuntime.queryInterface(XChartDocument.class, aSourceObj.Source) != null)&lt;br /&gt;
              System.out.println(&amp;quot;Disconnecting Listener because Chart was shut down&amp;quot;);&lt;br /&gt;
          &lt;br /&gt;
          // test if the Source object is a spreadsheet document&lt;br /&gt;
          if (UnoRuntime.queryInterface(XSpreadsheetDocument.class, aSourceObj.Source) != null)&lt;br /&gt;
              System.out.println(&amp;quot;Disconnecting Listener because Spreadsheet was shut down&amp;quot;);&lt;br /&gt;
          &lt;br /&gt;
          // remove data change listener&lt;br /&gt;
          maChartData.removeChartDataChangeEventListener(this);&lt;br /&gt;
          &lt;br /&gt;
          // remove dispose listeners&lt;br /&gt;
          ((XComponent) UnoRuntime.queryInterface(XComponent.class,&lt;br /&gt;
              maSheetDoc)).removeEventListener(this);&lt;br /&gt;
          ((XComponent) UnoRuntime.queryInterface(XComponent.class,&lt;br /&gt;
              maChartDocument)).removeEventListener(this);&lt;br /&gt;
          // this program cannot do anything any more&lt;br /&gt;
          System.exit(0);&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      // XChartDataChangeEventListener&lt;br /&gt;
      public void chartDataChanged(ChartDataChangeEvent aEvent)&lt;br /&gt;
      {&lt;br /&gt;
          // update subtitle with current date&lt;br /&gt;
          String aTitle = new String(&amp;quot;Last Update: &amp;quot; + new java.util.Date(System.currentTimeMillis()));&lt;br /&gt;
          &lt;br /&gt;
          try {&lt;br /&gt;
              ((XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,&lt;br /&gt;
                  maChartDocument.getSubTitle())).setPropertyValue(&lt;br /&gt;
                      &amp;quot;String&amp;quot;, aTitle);&lt;br /&gt;
              &lt;br /&gt;
              maChartDocument.attachData(maChartData);&lt;br /&gt;
          } catch(Exception ex) {&lt;br /&gt;
              System.out.println(&amp;quot;Oops: &amp;quot; + ex);&lt;br /&gt;
          }&lt;br /&gt;
                        &lt;br /&gt;
          System.out.println(&amp;quot;Data has changed&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      // private&lt;br /&gt;
      private com.sun.star.sheet.XSpreadsheetDocument maSheetDoc;&lt;br /&gt;
      private com.sun.star.frame.XModel maDrawDoc;&lt;br /&gt;
      private com.sun.star.chart.XChartDocument maChartDocument;&lt;br /&gt;
      private com.sun.star.chart.XChartData maChartData;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Charts]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/Working_With_Charts&amp;diff=108367</id>
		<title>Documentation/DevGuide/Charts/Working With Charts</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/Working_With_Charts&amp;diff=108367"/>
		<updated>2009-01-20T12:22:08Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/ChartsTOC&lt;br /&gt;
|Charts2b=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Charts/Accessing Existing Chart Documents&lt;br /&gt;
|NextPage=Documentation/DevGuide/Charts/Data Access&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Working with Charts}}&lt;br /&gt;
=== Document Structure ===&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.chart.ChartDocument;com.sun.star.chart.ChartData;com.sun.star.chart.ChartDataArray;com.sun.star.table.XTableChartsSupplier;com.sun.star.drawing.OLE2Shape&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The important service for charts is &amp;lt;idl&amp;gt;com.sun.star.chart.ChartDocument&amp;lt;/idl&amp;gt;. The chart document contains all the top-level graphic objects, such as a legend, up to two titles called &amp;lt;code&amp;gt;Title&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Subtitle&amp;lt;/code&amp;gt;, an axis title object for each primary axis if the chart supports axis. The &amp;lt;idl&amp;gt;com.sun.star.chart.ChartArea&amp;lt;/idl&amp;gt; always exists. This is the rectangular region covering the complete chart documents background. The important graphical object is the diagram that actually contains the visualized data.&lt;br /&gt;
&lt;br /&gt;
Apart from the graphical objects, the chart document is linked to some data. The required service for the data component is &amp;lt;idl&amp;gt;com.sun.star.chart.ChartData&amp;lt;/idl&amp;gt;. It is used for attaching a data change listener and querying general properties of the data source, such as the number to be interpreted as NaN (&amp;quot;not a number&amp;quot;), that is, a missing value. The derived class &amp;lt;idl&amp;gt;com.sun.star.chart.ChartDataArray&amp;lt;/idl&amp;gt; allows access to the actual values. Every component providing the &amp;lt;code&amp;gt;ChartData&amp;lt;/code&amp;gt; service should also support &amp;lt;code&amp;gt;ChartDataArray&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the services contained in a chart and their relationships.&lt;br /&gt;
&lt;br /&gt;
[[Image:ChartDocument.png|none|thumb|400px|ChartDocument]]&lt;br /&gt;
&lt;br /&gt;
The name spaces in the diagram have been omitted to improve readability. The services are all in the name space &amp;lt;idlmodule&amp;gt;com.sun.star.chart&amp;lt;/idlmodule&amp;gt;. The interfaces in this diagram are &amp;lt;idl&amp;gt;com.sun.star.chart.XChartDocument&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.drawing.XShape&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.lang.XComponent&amp;lt;/idl&amp;gt;, and &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idl&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The chart document model passes its elements through the interface &amp;lt;idl&amp;gt;com.sun.star.chart.XChartDocument&amp;lt;/idl&amp;gt;. This interface consists of the following methods:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  com::sun::star::chart::XChartData getData()&lt;br /&gt;
  void attachData( [in] com::sun::star::chart::XChartData xData)&lt;br /&gt;
  com::sun::star::drawing::XShape getTitle()&lt;br /&gt;
  com::sun::star::drawing::XShape getSubTitle()&lt;br /&gt;
  com::sun::star::drawing::XShape getLegend()&lt;br /&gt;
  com::sun::star::beans::XPropertySet getArea()&lt;br /&gt;
  com::sun::star::chart::XDiagram getDiagram()&lt;br /&gt;
  void setDiagram( [in] com::sun::star::chart::XDiagram xDiagram)&lt;br /&gt;
  &lt;br /&gt;
  void dispose()&lt;br /&gt;
  void addEventListener( [in] com::sun::star::lang::XEventListener xListener)&lt;br /&gt;
  void removeEventListener( [in] com::sun::star::lang::XEventListener aListener)&lt;br /&gt;
  boolean attachResource( [in] string aURL,&lt;br /&gt;
  [in] sequence &amp;lt;com::sun::star::beans::PropertyValue aArgs)&lt;br /&gt;
  string getURL()&lt;br /&gt;
  sequence &amp;lt;com::sun::star::beans::PropertyValue &amp;gt; getArgs()&lt;br /&gt;
  &lt;br /&gt;
  void connectController( [in] com::sun::star::frame::XController xController)&lt;br /&gt;
  void disconnectController( [in] com::sun::star::frame::XController xController)&lt;br /&gt;
  void lockControllers()&lt;br /&gt;
  void unlockControllers()&lt;br /&gt;
  boolean hasControllersLocked()&lt;br /&gt;
  com::sun::star::frame::XController getCurrentController()&lt;br /&gt;
  void setCurrentController( [in] com::sun::star::frame::XController xController)&lt;br /&gt;
  com::sun::star::uno::XInterface getCurrentSelection()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Charts]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/Creating_a_Chart_OLE_Object_in_Draw_and_Impress&amp;diff=108366</id>
		<title>Documentation/DevGuide/Charts/Creating a Chart OLE Object in Draw and Impress</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/Creating_a_Chart_OLE_Object_in_Draw_and_Impress&amp;diff=108366"/>
		<updated>2009-01-20T12:20:12Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/ChartsTOC&lt;br /&gt;
|Charts2a=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Charts/Creating and Adding a Chart to a Spreadsheet&lt;br /&gt;
|NextPage=Documentation/DevGuide/Charts/Setting the Chart Type&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Creating a Chart OLE Object in Draw and Impress}}&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.drawing.XDrawPagesSupplier&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The alternative is to create an OLE shape and insert it into a draw page. Writer, Spreadsheet documents and Draw/Impress documents have access to a draw page. The shape is told to be a chart by setting the unique class-id.&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|The unique Class-Id string for charts is &amp;quot;&amp;lt;tt&amp;gt;12dcae26-281f-416f-a234-c3086127382e&amp;lt;/tt&amp;gt;&amp;quot;.}}&lt;br /&gt;
&lt;br /&gt;
A draw page collection is obtained from the &amp;lt;idl&amp;gt;com.sun.star.drawing.XDrawPagesSupplier&amp;lt;/idl&amp;gt; of a draw or presentation document. To retrieve a single draw page, use &amp;lt;idl&amp;gt;com.sun.star.container.XIndexAccess&amp;lt;/idl&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A spreadsheet document is also a &amp;lt;idl&amp;gt;com.sun.star.drawing.XDrawPagesSupplier&amp;lt;/idl&amp;gt; that provides draw pages for all sheets, that is, the draw page for the third sheet is obtained by calling &amp;lt;code&amp;gt;getByIndex(2)&amp;lt;/code&amp;gt; on the interface &amp;lt;idl&amp;gt;com.sun.star.container.XIndexAccess&amp;lt;/idl&amp;gt; of the container, returned by [http://api.openoffice.org/docs/common/ref/com/sun/star/drawing/XDrawPagesSupplier.html#getDrawPages com.sun.star.drawing.XDrawPagesSupplier:getDrawPages]().&lt;br /&gt;
&lt;br /&gt;
A spreadsheet draw page can be acquired directly at the corresponding sheet object. A single sheet supports the service &amp;lt;idl&amp;gt;com.sun.star.sheet.Spreadsheet&amp;lt;/idl&amp;gt; that supplies a single page, &amp;lt;idl&amp;gt;com.sun.star.drawing.XDrawPageSupplier&amp;lt;/idl&amp;gt;, where the page is acquired using the method &amp;lt;code&amp;gt;getDrawPage()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The {{PRODUCTNAME}} Writer currently does not support the creation of OLE Charts or Charts based on a text table in a Writer document using the API.&lt;br /&gt;
&lt;br /&gt;
The document model is required once a chart is inserted. In charts inserted as OLE2Shape, the document model is available at the property &amp;lt;code&amp;gt;Model&amp;lt;/code&amp;gt; of the OLE2Shape after setting the &amp;lt;code&amp;gt;CLSID&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|Note, that the mechanism described for OLE objects seems to work in Writer, that is, you can see the OLE-Chart inside the Text document after executing the API calls described, but it is not treated as a real OLE object by the Writer. Thus, you can not activate it by double-clicking, because it puts the document into an inconsistent state.}}&lt;br /&gt;
&lt;br /&gt;
The following example assumes a valid drawing document in the variable &amp;lt;code&amp;gt;aDrawDoc&amp;lt;/code&amp;gt; and creates a chart in a Draw document. See [[Documentation/DevGuide/Drawings/Drawing Documents and Presentation Documents|Drawing Documents and Presentation Documents]] for an example of how to create a drawing document. &lt;br /&gt;
&amp;lt;!--[SOURCE:Charts/ChartHelper.java]--&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  ...&lt;br /&gt;
  final String msChartClassID = &amp;quot;12dcae26-281f-416f-a234-c3086127382e&amp;quot;;&lt;br /&gt;
  com.sun.star.frame.XModel aDrawDoc;&lt;br /&gt;
  &lt;br /&gt;
  // get a draw document into aDrawDoc&lt;br /&gt;
  // ...&lt;br /&gt;
  &lt;br /&gt;
  // this will become the resulting chart&lt;br /&gt;
  XChartDocument aChartDoc;&lt;br /&gt;
  &lt;br /&gt;
  com.sun.star.drawing.XDrawPagesSupplier aSupplier = (com.sun.star.drawing.XDrawPagesSupplier)&lt;br /&gt;
      UnoRuntime.queryInterface(com.sun.star.drawing.XDrawPagesSupplier.class, aDrawDoc);&lt;br /&gt;
  &lt;br /&gt;
  com.sun.star.drawing.XShapes aPage = null;&lt;br /&gt;
  try {&lt;br /&gt;
      // get first page&lt;br /&gt;
      aPage = (com.sun.star.drawing.XShapes) aSupplier.getDrawPages().getByIndex(0);&lt;br /&gt;
  } catch (com.sun.star.lang.IndexOutOfBoundsException ex) {&lt;br /&gt;
      System.out.println(&amp;quot;Document has no pages: &amp;quot; + ex);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  if (aPage != null) {&lt;br /&gt;
      // the document should be a factory that can create shapes&lt;br /&gt;
      XMultiServiceFactory aFact = (XMultiServiceFactory) UnoRuntime.queryInterface(&lt;br /&gt;
          XMultiServiceFactory.class, aDrawDoc);&lt;br /&gt;
  &lt;br /&gt;
      if (aFact != null) {&lt;br /&gt;
          try {&lt;br /&gt;
              // create an OLE 2 shape&lt;br /&gt;
              com.sun.star.drawing.XShape aShape = (com.sun.star.drawing.XShape)&lt;br /&gt;
                  UnoRuntime.queryInterface(&lt;br /&gt;
                      com.sun.star.drawing.XShape.class,&lt;br /&gt;
                          aFact.createInstance(&amp;quot;com.sun.star.drawing.OLE2Shape&amp;quot;));&lt;br /&gt;
  &lt;br /&gt;
              // insert the shape into the page&lt;br /&gt;
              aPage.add(aShape);&lt;br /&gt;
              aShape.setPosition(new com.sun.star.awt.Point(1000, 1000));&lt;br /&gt;
              aShape.setSize(new com.sun.star.awt.Size(15000, 9271));&lt;br /&gt;
    &lt;br /&gt;
              // make the OLE shape a chart&lt;br /&gt;
              XPropertySet aShapeProp = (XPropertySet) UnoRuntime.queryInterface(&lt;br /&gt;
                  XPropertySet.class, aShape );&lt;br /&gt;
    &lt;br /&gt;
              // set the class id for charts&lt;br /&gt;
              aShapeProp.setPropertyValue(&amp;quot;CLSID&amp;quot;, msChartClassID);&lt;br /&gt;
  &lt;br /&gt;
              // retrieve the chart document as model of the OLE shape&lt;br /&gt;
              aChartDoc = (XChartDocument) UnoRuntime.queryInterface(&lt;br /&gt;
                  XChartDocument.class,&lt;br /&gt;
                  aShapeProp.getPropertyValue(&amp;quot;Model&amp;quot;));&lt;br /&gt;
          } catch(com.sun.star.uno.Exception ex) {&lt;br /&gt;
              System.out.println(&amp;quot;Couldn&amp;#039;t change the OLE shape into a chart: &amp;quot; + ex);&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Charts]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/Setting_the_Chart_Type&amp;diff=108365</id>
		<title>Documentation/DevGuide/Charts/Setting the Chart Type</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/Setting_the_Chart_Type&amp;diff=108365"/>
		<updated>2009-01-20T12:19:08Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/ChartsTOC&lt;br /&gt;
|Charts2a=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Charts/Creating a Chart OLE Object in Draw and Impress&lt;br /&gt;
|NextPage=Documentation/DevGuide/Charts/Accessing Existing Chart Documents&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Setting the Chart Type}}&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.chart.Diagram;com.sun.star.chart.XYDiagram&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The default when creating a chart is a bar diagram with vertical bars. If a different chart type is required, apply a different diagram type to this initial chart. For example, to create a pie chart, insert the default bar chart and change it to a pie chart.&lt;br /&gt;
&lt;br /&gt;
To change the type of a chart, create an instance of the required diagram service by its service name using the service factory provided by the &amp;lt;idl&amp;gt;com.sun.star.chart.XChartDocument&amp;lt;/idl&amp;gt;. This interface is available at the chart document model. After this service instance is created, set it using the &amp;lt;code&amp;gt;setDiagram()&amp;lt;/code&amp;gt; method of the chart document.&lt;br /&gt;
&lt;br /&gt;
In the following example, we change the chart type to a &amp;lt;idl&amp;gt;com.sun.star.chart.XYDiagram&amp;lt;/idl&amp;gt;, also known as a scatter chart. We have assumed that there is a chart document in the variable &amp;lt;code&amp;gt;aChartDoc&amp;lt;/code&amp;gt; already. The previous sections described how to create a document.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // let aChartDoc be a valid XChartDocument&lt;br /&gt;
  &lt;br /&gt;
  // get the factory that can create diagrams&lt;br /&gt;
  XMultiServiceFactory aFact = (XMultiServiceFactory) UnoRuntime.queryInterface(&lt;br /&gt;
      XMultiServiceFactory.class, aChartDoc);&lt;br /&gt;
  &lt;br /&gt;
  XDiagram aDiagram = (XDiagram) UnoRuntime.queryInterface(&lt;br /&gt;
      XDiagram.class, aFact.createInstance(&amp;quot;com.sun.star.chart.XYDiagram&amp;quot;));&lt;br /&gt;
  &lt;br /&gt;
  aChartDoc.setDiagram(aDiagram);&lt;br /&gt;
  &lt;br /&gt;
  // now we have an xy-chart&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&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;
!Diagram Service Names &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;com.sun.star.chart.BarDiagram&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;com.sun.star.chart.AreaDiagram&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;com.sun.star.chart.LineDiagram&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;com.sun.star.chart.PieDiagram&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;com.sun.star.chart.DonutDiagram&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;com.sun.star.chart.NetDiagram&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;com.sun.star.chart.XYDiagram&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;com.sun.star.chart.StockDiagram&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Charts]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/Creating_and_Adding_a_Chart_to_a_Spreadsheet&amp;diff=108364</id>
		<title>Documentation/DevGuide/Charts/Creating and Adding a Chart to a Spreadsheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/Creating_and_Adding_a_Chart_to_a_Spreadsheet&amp;diff=108364"/>
		<updated>2009-01-20T12:15:50Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/ChartsTOC&lt;br /&gt;
|Charts2a=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Charts/Handling Chart Documents&lt;br /&gt;
|NextPage=Documentation/DevGuide/Charts/Creating a Chart OLE Object in Draw and Impress&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Creating and Adding a Chart to a Spreadsheet}}&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.table.XTableChartsSupplier&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
Charts are used in spreadsheet documents to visualize the data that they contain. A spreadsheet is one single sheet in a spreadsheet document and offers a &amp;lt;idl&amp;gt;com.sun.star.table.XTableChartsSupplier&amp;lt;/idl&amp;gt; interface, that is required by the service &amp;lt;idl&amp;gt;com.sun.star.sheet.Spreadsheet&amp;lt;/idl&amp;gt;. With this interface, a collection of table charts that are a container for the actual charts can be accessed. To retrieve the chart document model from a table chart object, use the method &amp;lt;code&amp;gt;getEmbeddedObject()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The following example shows how to insert a chart into a spreadsheet document and retrieve its chart document model. The example assumes that there is a &amp;lt;idl&amp;gt;com.sun.star.sheet.XSpreadsheet&amp;lt;/idl&amp;gt; to insert the chart and an array of cell range addresses that contain the regions in which the data for the chart can be found. Refer to [[Documentation/DevGuide/Spreadsheets/Spreadsheet Documents|Spreadsheet Documents]] for more information about how to get or create these objects. The following snippet shows how to insert a chart into a Calc document.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  import com.sun.star.chart.*;&lt;br /&gt;
  import com.sun.star.uno.UnoRuntime;&lt;br /&gt;
  import com.sun.star.container.XNameAccess;&lt;br /&gt;
  import com.sun.star.document.XEmbeddedObjectSupplier;&lt;br /&gt;
  &lt;br /&gt;
  final String sChartName = &amp;quot;MyChart&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  com.sun.star.table.XTableChartsSupplier aSheet;&lt;br /&gt;
  com.sun.star.table.CellRangeAddress[] aAddresses;&lt;br /&gt;
  &lt;br /&gt;
  // get the sheet in which you want to insert a chart&lt;br /&gt;
  // and query it for XTableChartsSupplier and store it in aSheet&lt;br /&gt;
  //&lt;br /&gt;
  // also get an array of CellRangeAddresses containing&lt;br /&gt;
  // the data you want to visualize and store them in aAddresses&lt;br /&gt;
  //&lt;br /&gt;
  // for details see documentation of Spreadsheets&lt;br /&gt;
  &lt;br /&gt;
  // ...&lt;br /&gt;
  &lt;br /&gt;
  XChartDocument aChartDocument = null;&lt;br /&gt;
  &lt;br /&gt;
  com.sun.star.table.XTableCharts aChartCollection = aSheet.getCharts();&lt;br /&gt;
  XNameAccess aChartCollectionNA = (XNameAccess) UnoRuntime.queryInterface(&lt;br /&gt;
      XNameAccess.class, aChartCollection );&lt;br /&gt;
  &lt;br /&gt;
  // only insert the chart if it does not already exist&lt;br /&gt;
  if (aChartCollectionNA != null &amp;amp;&amp;amp; !aChartCollectionNA.hasByName(sChartName)) {&lt;br /&gt;
      // following rectangle parameters are measured in 1/100 mm&lt;br /&gt;
      com.sun.star.awt.Rectangle aRect = new com.sun.star.awt.Rectangle(1000, 1000, 15000, 9271);&lt;br /&gt;
      &lt;br /&gt;
      // first bool: ColumnHeaders&lt;br /&gt;
      // second bool: RowHeaders&lt;br /&gt;
      aChartCollection.addNewByName(sChartName, aRect, aAddresses, true, false);&lt;br /&gt;
      &lt;br /&gt;
      try {&lt;br /&gt;
          com.sun.star.table.XTableChart aTableChart = (com.sun.star.table.XTableChart)&lt;br /&gt;
              UnoRuntime.queryInterface(&lt;br /&gt;
                  com.sun.star.table.XTableChart.class,&lt;br /&gt;
                  aChartCollectionNA.getByName(sChartName));&lt;br /&gt;
    &lt;br /&gt;
          // the table chart is an embedded object which contains the chart document&lt;br /&gt;
          aChartDocument = (XChartDocument) UnoRuntime.queryInterface(&lt;br /&gt;
              XChartDocument.class,&lt;br /&gt;
              ((XEmbeddedObjectSupplier) UnoRuntime.queryInterface(&lt;br /&gt;
                  XEmbeddedObjectSupplier.class,&lt;br /&gt;
                  aTableChart )).getEmbeddedObject());&lt;br /&gt;
    &lt;br /&gt;
      } catch (com.sun.star.container.NoSuchElementException ex) {&lt;br /&gt;
          System.out.println(&amp;quot;Couldn&amp;#039;t find chart with name &amp;quot; + sChartName + &amp;quot;: &amp;quot; + ex); &lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  // now aChartDocument should contain an XChartDocument representing the newly inserted chart&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Charts]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=User:Beppec56/Collections/Charts&amp;diff=108358</id>
		<title>User:Beppec56/Collections/Charts</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=User:Beppec56/Collections/Charts&amp;diff=108358"/>
		<updated>2009-01-20T11:27:05Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Charts ==&lt;br /&gt;
=== The Charts API Management ===&lt;br /&gt;
;Charts&lt;br /&gt;
:[[Documentation/DevGuide/Charts/Charts]]&lt;br /&gt;
:[[Documentation/DevGuide/Charts/Handling Chart Documents]]&lt;br /&gt;
:[[Documentation/DevGuide/Charts/Creating and Adding a Chart to a Spreadsheet]]&lt;br /&gt;
:[[Documentation/DevGuide/Charts/Creating a Chart OLE Object in Draw and Impress]]&lt;br /&gt;
:[[Documentation/DevGuide/Charts/Setting the Chart Type]]&lt;br /&gt;
:[[Documentation/DevGuide/Charts/Accessing Existing Chart Documents]]&lt;br /&gt;
:[[Documentation/DevGuide/Charts/Working With Charts]]&lt;br /&gt;
:[[Documentation/DevGuide/Charts/Data Access]]&lt;br /&gt;
:[[Documentation/DevGuide/Charts/Chart Document Parts]]&lt;br /&gt;
:[[Documentation/DevGuide/Charts/Common Parts of all Chart Types]]&lt;br /&gt;
:[[Documentation/DevGuide/Charts/Features of Special Chart Types]]&lt;br /&gt;
:[[Documentation/DevGuide/Charts/Statistics]]&lt;br /&gt;
:[[Documentation/DevGuide/Charts/3-D Charts]]&lt;br /&gt;
:[[Documentation/DevGuide/Charts/Pie Charts]]&lt;br /&gt;
:[[Documentation/DevGuide/Charts/Stock Charts]]&lt;br /&gt;
:[[Documentation/DevGuide/Charts/Chart Document Controller]]&lt;br /&gt;
:[[Documentation/DevGuide/Charts/Chart Add-Ins]]&lt;br /&gt;
:[[Documentation/DevGuide/Charts/Prerequisites]]&lt;br /&gt;
:[[Documentation/DevGuide/Charts/How Add-Ins Work]]&lt;br /&gt;
:[[Documentation/DevGuide/Charts/How to Apply an Add-In to a Chart Document]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Collections]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Talk:Documentation/DevGuide/WritingUNO/Disable_Commands&amp;diff=100709</id>
		<title>Talk:Documentation/DevGuide/WritingUNO/Disable Commands</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Talk:Documentation/DevGuide/WritingUNO/Disable_Commands&amp;diff=100709"/>
		<updated>2008-12-01T18:20:24Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: Removed comments, hints from framework@dev.openoffice.org&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/WritingUNO/Disable_Commands&amp;diff=100708</id>
		<title>Documentation/DevGuide/WritingUNO/Disable Commands</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/WritingUNO/Disable_Commands&amp;diff=100708"/>
		<updated>2008-12-01T18:19:09Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: Some few editings following suggestions on dev@framework.openoffice.org&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/WritingUNOTOC&lt;br /&gt;
|WritingUNO2e=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/WritingUNO/AddOns/Installation&lt;br /&gt;
|NextPage=Documentation/DevGuide/WritingUNO/Intercepting Context Menus&lt;br /&gt;
}}&lt;br /&gt;
[[zh:Zh/Documentation/DevGuide/WritingUNO/Disable Commands]]&lt;br /&gt;
{{DISPLAYTITLE:Disable Commands}}&lt;br /&gt;
In {{PRODUCTNAME}}, there may be situations where functions should be disabled to prevent users from changing or destroying documents inadvertently. {{PRODUCTNAME}} maintains a list of disabled commands that can be maintained by users and developers through the configuration API.&lt;br /&gt;
&lt;br /&gt;
A command request can be created by any object, but in most cases, user interface objects create these requests. Consider, for instance, a toolbox where different functions acting on the office component are presented as buttons. Once a button is clicked, the desired functionality should be executed. If the code assigned to the button is provided with a suitable command URL, the dispatch framework can handle the user action by creating the request and finding a component that can handle it.&lt;br /&gt;
&lt;br /&gt;
The dispatch framework works with the design pattern &amp;#039;&amp;#039;chain of responsibility&amp;#039;&amp;#039;: everything a component needs to know if it wants to execute a request is the last link in a chain of objects capable of executing requests. If this object gets the request, it checks whether it can handle it or otherwise passes it to the next chain member until the request is executed or the end of the chain is reached.The disable commands implementation is the first chain member and can therefore work as a wall for all disabled commands. They are not be sent to the next chain member, and disappear.&lt;br /&gt;
&lt;br /&gt;
The illustration below shows how the disable commands feature affects the normal command application flow.&lt;br /&gt;
&lt;br /&gt;
[[Image:DisableCommands_ApplicationFlow.png|none|thumb|400px|How the disable commands feature works]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Caution|Since the disable commands implementation is the first part in the dispatch chain, there is no way to circumvent it. The disabled command must be removed from the list, otherwise it remains disabled.}}&lt;br /&gt;
&lt;br /&gt;
=== Configuration ===&lt;br /&gt;
&lt;br /&gt;
The disable commands feature uses the configuration branch &amp;#039;&amp;#039;org.openoffice.Office.Commands&amp;#039;&amp;#039; to read which commands should be disabled. The following schema applies:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;?xml version=&amp;#039;1.0&amp;#039; encoding=&amp;#039;UTF-8&amp;#039;?&amp;gt;&lt;br /&gt;
  &amp;lt;oor:component-schema oor:name=&amp;quot;Commands&amp;quot; oor:package=&amp;quot;org.openoffice.Office&amp;quot; xml:lang=&amp;quot;en-US&amp;quot; xmlns:oor=&amp;quot;http://openoffice.org/2001/registry&amp;quot; xmlns:xs=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;templates&amp;gt;&lt;br /&gt;
          &amp;lt;group oor:name=&amp;quot;CommandType&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;prop oor:name=&amp;quot;Command&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;/&amp;gt;&lt;br /&gt;
          &amp;lt;/group&amp;gt;&lt;br /&gt;
      &amp;lt;/templates&amp;gt;&lt;br /&gt;
      &amp;lt;component&amp;gt;&lt;br /&gt;
          &amp;lt;group oor:name=&amp;quot;Execute&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;set oor:name=&amp;quot;Disabled&amp;quot; oor:node-type=&amp;quot;CommandType&amp;quot;/&amp;gt;&lt;br /&gt;
          &amp;lt;/group&amp;gt;&lt;br /&gt;
      &amp;lt;/component&amp;gt;&lt;br /&gt;
  &amp;lt;/oor:component-schema&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The configuration schema for disabled commands is very simple. The &amp;#039;&amp;#039;org.openoffice.Office.Commands&amp;#039;&amp;#039; branch has a group called &amp;lt;code&amp;gt;Execute&amp;lt;/code&amp;gt;. This group has only one set called &amp;lt;code&amp;gt;Disabled&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt;Disabled&amp;lt;/code&amp;gt; set supports nodes of the type &amp;lt;code&amp;gt;CommandType&amp;lt;/code&amp;gt;. The following table describes the supported properties of &amp;lt;code&amp;gt;CommandType&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;
!colspan=&amp;quot;2&amp;quot;|Properties of the &amp;lt;code&amp;gt;CommandType&amp;lt;/code&amp;gt; group &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;oor:component-data&amp;lt;/code&amp;gt; &lt;br /&gt;
|string. It must be unique inside the &amp;lt;code&amp;gt;Disabled&amp;lt;/code&amp;gt; set, but has no additional meaning for the implementation of the disable commands feature. Use a consecutive numbering scheme; even numbers are allowed. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;Command&amp;lt;/code&amp;gt; &lt;br /&gt;
|string. This is the command name with the preceding protocol. That means the command URL &amp;#039;&amp;#039;.uno:Open&amp;#039;&amp;#039; (which shows the &amp;#039;&amp;#039;&amp;#039;File – Open&amp;#039;&amp;#039;&amp;#039; dialog) must be written as &amp;lt;code&amp;gt;Open&amp;lt;/code&amp;gt;.&lt;br /&gt;
The valid commands can be found in the document &amp;#039;&amp;#039;Index of Command Names&amp;#039;&amp;#039; in the [http://framework.openoffice.org/servlets/ProjectDocumentList Documentation section of the framework project] on the OpenOffice.org web page. The {{PRODUCTNAME}} SDK also includes the latest [http://www.openoffice.org/files/documents/25/60/commands_11beta.html list of command names]. &lt;br /&gt;
Additional information regarding Command names is available in: [http://wiki.services.openoffice.org/wiki/Framework/Article/OpenOffice.org_2.x_Commands]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The example below shows a configuration file that disables the commands for &amp;#039;&amp;#039;&amp;#039;File – Open&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;Edit – Select All&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;Help – About {{PRODUCTNAME}}&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;File – Exit&amp;#039;&amp;#039;&amp;#039;.&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;oor:component-data oor:name=&amp;quot;Commands&amp;quot; oor:package=&amp;quot;org.openoffice.Office&amp;quot; xmlns:oor=&amp;quot;http://openoffice.org/2001/registry&amp;quot; xmlns:xs=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;node oor:name=&amp;quot;Execute&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;node oor:name=&amp;quot;Disabled&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;node oor:name=&amp;quot;com.mycompany.a-chosen-unique-name.m1&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;prop oor:name=&amp;quot;Command&amp;quot;&amp;gt;&lt;br /&gt;
                      &amp;lt;value&amp;gt;Open&amp;lt;/value&amp;gt;&lt;br /&gt;
                  &amp;lt;/prop&amp;gt;&lt;br /&gt;
              &amp;lt;/node&amp;gt;&lt;br /&gt;
              &amp;lt;node oor:name=&amp;quot;com.mycompany.a-chosen-unique-name.m2&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;prop oor:name=&amp;quot;Command&amp;quot;&amp;gt;&lt;br /&gt;
                      &amp;lt;value&amp;gt;SelectAll&amp;lt;/value&amp;gt;&lt;br /&gt;
                  &amp;lt;/prop&amp;gt;&lt;br /&gt;
              &amp;lt;/node&amp;gt;&lt;br /&gt;
              &amp;lt;node oor:name=&amp;quot;com.mycompany.a-chosen-unique-name.m3&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;prop oor:name=&amp;quot;Command&amp;quot;&amp;gt;&lt;br /&gt;
                      &amp;lt;value&amp;gt;About&amp;lt;/value&amp;gt;&lt;br /&gt;
                  &amp;lt;/prop&amp;gt;&lt;br /&gt;
              &amp;lt;/node&amp;gt;&lt;br /&gt;
              &amp;lt;node oor:name=&amp;quot;com.mycompany.a-chosen-unique-name.m4&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;prop oor:name=&amp;quot;Command&amp;quot;&amp;gt;&lt;br /&gt;
                      &amp;lt;value&amp;gt;Quit&amp;lt;/value&amp;gt;&lt;br /&gt;
                  &amp;lt;/prop&amp;gt;&lt;br /&gt;
              &amp;lt;/node&amp;gt;&lt;br /&gt;
          &amp;lt;/node&amp;gt;&lt;br /&gt;
      &amp;lt;/node&amp;gt;&lt;br /&gt;
  &amp;lt;/oor:component-data&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A few lines on the node name &amp;#039;com.mycompany.a-chosen-unique-name.m1&amp;#039; in the xml example above.&lt;br /&gt;
&lt;br /&gt;
The node name is chosen in order to be unique in the &amp;#039;Disable&amp;#039; data set, and is given as a suggestion.&lt;br /&gt;
&lt;br /&gt;
You can use whatever name you like, it has no additional meaning for the implementation of the disable commands feature.&lt;br /&gt;
&lt;br /&gt;
A good idea would be to use a consecutive numbering at the name end, the name must be unique.&lt;br /&gt;
&lt;br /&gt;
=== Disabling Commands at Runtime ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.configuration.ConfigurationUpdateAccess;com.sun.star.configuration.ConfigurationProvider;com.sun.star.util.XChangesBatch&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The following code example first removes all commands that were defined in the user layer of the configuration branch &amp;lt;code&amp;gt;org.openoffice.Office.Commands&amp;lt;/code&amp;gt; as having a defined starting point. Then it checks if it can get dispatch objects for some pre-defined commands.Then the example disables these commands and tries to get dispatch objects for them again. At the end, the code removes the disabled commands again, otherwise {{PRODUCTNAME}} would not be fully usable any longer.&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;
  import com.sun.star.lang.XMultiServiceFactory;&lt;br /&gt;
  import com.sun.star.lang.XSingleServiceFactory;&lt;br /&gt;
  import com.sun.star.util.XURLTransformer;&lt;br /&gt;
  import com.sun.star.frame.XDesktop;&lt;br /&gt;
  &lt;br /&gt;
  import com.sun.star.beans.UnknownPropertyException;&lt;br /&gt;
  &lt;br /&gt;
  /*&lt;br /&gt;
   *  Provides example code how to enable/disable&lt;br /&gt;
   *  commands.&lt;br /&gt;
   */&lt;br /&gt;
  public class DisableCommandsTest extends java.lang.Object {&lt;br /&gt;
  &lt;br /&gt;
      /*&lt;br /&gt;
       *  A list of command names&lt;br /&gt;
       */&lt;br /&gt;
      final static private String[] aCommandURLTestSet =&lt;br /&gt;
      {&lt;br /&gt;
          new String( &amp;quot;Open&amp;quot; ),&lt;br /&gt;
          new String( &amp;quot;About&amp;quot; ),&lt;br /&gt;
          new String( &amp;quot;SelectAll&amp;quot; ),&lt;br /&gt;
          new String( &amp;quot;Quit&amp;quot; ),&lt;br /&gt;
      };&lt;br /&gt;
  &lt;br /&gt;
      private static XComponentContext xRemoteContext = null;&lt;br /&gt;
      private static XMultiComponentFactory xRemoteServiceManager = null;&lt;br /&gt;
      private static XURLTransformer xTransformer = null;&lt;br /&gt;
      private static XMultiServiceFactory xConfigProvider = null;&lt;br /&gt;
      &lt;br /&gt;
      /*&lt;br /&gt;
       *  @param args the command line arguments&lt;br /&gt;
       */&lt;br /&gt;
      public static void main(String[] args) {&lt;br /&gt;
      &lt;br /&gt;
          try {&lt;br /&gt;
              // connect&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;
              Object transformer = xRemoteServiceManager.createInstanceWithContext(&lt;br /&gt;
                  &amp;quot;com.sun.star.util.URLTransformer&amp;quot;, xRemoteContext);&lt;br /&gt;
              xTransformer = (com.sun.star.util.XURLTransformer)UnoRuntime.queryInterface(&lt;br /&gt;
                  com.sun.star.util.XURLTransformer.class, transformer);&lt;br /&gt;
      &lt;br /&gt;
              Object configProvider = xRemoteServiceManager.createInstanceWithContext(&lt;br /&gt;
                  &amp;quot;com.sun.star.configuration.ConfigurationProvider&amp;quot;, xRemoteContext);&lt;br /&gt;
              xConfigProvider = (com.sun.star.lang.XMultiServiceFactory)UnoRuntime.queryInterface(&lt;br /&gt;
                  com.sun.star.lang.XMultiServiceFactory.class, configProvider);&lt;br /&gt;
    &lt;br /&gt;
              // First we need a defined starting point. So we have to remove&lt;br /&gt;
              // all commands from the disabled set!&lt;br /&gt;
              enableCommands();&lt;br /&gt;
  &lt;br /&gt;
              // Check if the commands are usable&lt;br /&gt;
              testCommands(false);&lt;br /&gt;
          &lt;br /&gt;
              // Disable the commands&lt;br /&gt;
              disableCommands();&lt;br /&gt;
          &lt;br /&gt;
              // Now the commands should not be usable anymore&lt;br /&gt;
              testCommands(true);&lt;br /&gt;
  &lt;br /&gt;
              // Remove disable commands to make Office usable again&lt;br /&gt;
              enableCommands();&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;
      /**&lt;br /&gt;
       *  Test the commands that we enabled/disabled&lt;br /&gt;
       */&lt;br /&gt;
      private static void testCommands(boolean bDisabledCmds) throws com.sun.star.uno.Exception {&lt;br /&gt;
          // We need the desktop to get access to the current frame&lt;br /&gt;
          Object desktop = xRemoteServiceManager.createInstanceWithContext(&lt;br /&gt;
              &amp;quot;com.sun.star.frame.Desktop&amp;quot;, xRemoteContext );&lt;br /&gt;
          com.sun.star.frame.XDesktop xDesktop = (com.sun.star.frame.XDesktop)UnoRuntime.queryInterface(&lt;br /&gt;
              com.sun.star.frame.XDesktop.class, desktop);&lt;br /&gt;
          com.sun.star.frame.XFrame xFrame = xDesktop.getCurrentFrame();&lt;br /&gt;
          com.sun.star.frame.XDispatchProvider xDispatchProvider = null;&lt;br /&gt;
          if (xFrame != null) {&lt;br /&gt;
              // We have a frame. Now we need access to the dispatch provider.&lt;br /&gt;
              xDispatchProvider = (com.sun.star.frame.XDispatchProvider)UnoRuntime.queryInterface( &lt;br /&gt;
                  com.sun.star.frame.XDispatchProvider.class, xFrame );&lt;br /&gt;
              if (xDispatchProvider != null) {&lt;br /&gt;
                  // As we have the dispatch provider we can now check if we get a dispatch&lt;br /&gt;
                  // object or not.&lt;br /&gt;
                  for (int n = 0; n &amp;lt; aCommandURLTestSet.length; n++) {&lt;br /&gt;
                      // Prepare the URL&lt;br /&gt;
                      com.sun.star.util.URL[] aURL = new com.sun.star.util.URL[1];&lt;br /&gt;
                      aURL[0] = new com.sun.star.util.URL();&lt;br /&gt;
                      com.sun.star.frame.XDispatch xDispatch = null;&lt;br /&gt;
    &lt;br /&gt;
                      aURL[0].Complete = &amp;quot;.uno:&amp;quot; + aCommandURLTestSet[n];&lt;br /&gt;
                      xTransformer.parseSmart(aURL, &amp;quot;.uno:&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
                      // Try to get a dispatch object for our URL&lt;br /&gt;
                      xDispatch = xDispatchProvider.queryDispatch(aURL[0], &amp;quot;&amp;quot;, 0);&lt;br /&gt;
    &lt;br /&gt;
                      if (xDispatch != null) {&lt;br /&gt;
                          if (bDisabledCmds)&lt;br /&gt;
                              System.out.println(&amp;quot;Something is wrong, I got dispatch object for &amp;quot; &lt;br /&gt;
                                  + aURL[0].Complete);&lt;br /&gt;
                          else&lt;br /&gt;
                              System.out.println(&amp;quot;Ok, dispatch object for &amp;quot; + aURL[0].Complete);&lt;br /&gt;
                      }&lt;br /&gt;
                      else {&lt;br /&gt;
                          if (!bDisabledCmds)&lt;br /&gt;
                              System.out.println(&amp;quot;Something is wrong, I cannot get dispatch   object for &amp;quot; &lt;br /&gt;
                                  + aURL[0].Complete);&lt;br /&gt;
                          else&lt;br /&gt;
                              System.out.println(&amp;quot;Ok, no dispatch object for &amp;quot; + aURL[0].Complete);&lt;br /&gt;
                      }&lt;br /&gt;
                      resetURL(aURL[0]);&lt;br /&gt;
                  }&lt;br /&gt;
              }&lt;br /&gt;
              else&lt;br /&gt;
                  System.out.println(&amp;quot;Couldn&amp;#039;t get XDispatchProvider from Frame!&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else&lt;br /&gt;
              System.out.println(&amp;quot;Couldn&amp;#039;t get current Frame from Desktop!&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
    &lt;br /&gt;
      /**&lt;br /&gt;
       *  Ensure that there are no disabled commands in the user layer. The&lt;br /&gt;
       *  implementation removes all commands from the disabled set!&lt;br /&gt;
       */&lt;br /&gt;
      private static void enableCommands() {&lt;br /&gt;
          // Set the root path for our configuration access&lt;br /&gt;
          com.sun.star.beans.PropertyValue[] lParams = new com.sun.star.beans.PropertyValue[1];&lt;br /&gt;
  &lt;br /&gt;
          lParams[0] = new com.sun.star.beans.PropertyValue();&lt;br /&gt;
          lParams[0].Name = new String(&amp;quot;nodepath&amp;quot;);&lt;br /&gt;
          lParams[0].Value = &amp;quot;/org.openoffice.Office.Commands/Execute/Disabled&amp;quot;;&lt;br /&gt;
      &lt;br /&gt;
          try {&lt;br /&gt;
              // Create configuration update access to have write access to the configuration&lt;br /&gt;
              Object xAccess = xConfigProvider.createInstanceWithArguments( &lt;br /&gt;
&amp;quot;com.sun.star.configuration.ConfigurationUpdateAccess&amp;quot;, lParams);&lt;br /&gt;
  &lt;br /&gt;
              com.sun.star.container.XNameAccess xNameAccess = (com.sun.star.container.XNameAccess)&lt;br /&gt;
              UnoRuntime.queryInterface(com.sun.star.container.XNameAccess.class, xAccess);&lt;br /&gt;
              if (xNameAccess != null) {&lt;br /&gt;
                  // We need the XNameContainer interface to remove the nodes by name&lt;br /&gt;
                  com.sun.star.container.XNameContainer xNameContainer =&lt;br /&gt;
                      (com.sun.star.container.XNameContainer)&lt;br /&gt;
                  UnoRuntime.queryInterface(com.sun.star.container.XNameContainer.class, xAccess);&lt;br /&gt;
    &lt;br /&gt;
                  // Retrieves the names of all Disabled nodes&lt;br /&gt;
                  String[] aCommandsSeq = xNameAccess.getElementNames();&lt;br /&gt;
                  for (int n = 0; n &amp;lt; aCommandsSeq.length; n++) {&lt;br /&gt;
                      try {&lt;br /&gt;
                          // remove the node&lt;br /&gt;
                          xNameContainer.removeByName( aCommandsSeq[n]);&lt;br /&gt;
                      }&lt;br /&gt;
                      catch (com.sun.star.lang.WrappedTargetException e) {&lt;br /&gt;
                      }&lt;br /&gt;
                      catch (com.sun.star.container.NoSuchElementException e) {&lt;br /&gt;
                      }&lt;br /&gt;
                  }&lt;br /&gt;
              } &lt;br /&gt;
    &lt;br /&gt;
              // Commit our changes&lt;br /&gt;
              com.sun.star.util.XChangesBatch xFlush =&lt;br /&gt;
              (com.sun.star.util.XChangesBatch)UnoRuntime.queryInterface(&lt;br /&gt;
                  com.sun.star.util.XChangesBatch.class, xAccess);&lt;br /&gt;
              xFlush.commitChanges();&lt;br /&gt;
          }    &lt;br /&gt;
          catch (com.sun.star.uno.Exception e) {&lt;br /&gt;
              System.out.println(&amp;quot;Exception detected!&amp;quot;);&lt;br /&gt;
              System.out.println(e);&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
    &lt;br /&gt;
      /**&lt;br /&gt;
       *  Disable all commands defined in the aCommandURLTestSet array&lt;br /&gt;
       */&lt;br /&gt;
      private static void disableCommands() {&lt;br /&gt;
      // Set the root path for our configuration access&lt;br /&gt;
      com.sun.star.beans.PropertyValue[] lParams = new com.sun.star.beans.PropertyValue[1];&lt;br /&gt;
      lParams[0] = new com.sun.star.beans.PropertyValue();&lt;br /&gt;
      lParams[0].Name = new String(&amp;quot;nodepath&amp;quot;);&lt;br /&gt;
      lParams[0].Value = &amp;quot;/org.openoffice.Office.Commands/Execute/Disabled&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
      try {&lt;br /&gt;
          // Create configuration update access to have write access to the configuration&lt;br /&gt;
          Object xAccess = xConfigProvider.createInstanceWithArguments( &lt;br /&gt;
          &amp;quot;com.sun.star.configuration.ConfigurationUpdateAccess&amp;quot;, lParams);&lt;br /&gt;
    &lt;br /&gt;
          com.sun.star.lang.XSingleServiceFactory xSetElementFactory = &lt;br /&gt;
          (com.sun.star.lang.XSingleServiceFactory)UnoRuntime.queryInterface(&lt;br /&gt;
              com.sun.star.lang.XSingleServiceFactory.class, xAccess);&lt;br /&gt;
          &lt;br /&gt;
          com.sun.star.container.XNameContainer xNameContainer =&lt;br /&gt;
          (com.sun.star.container.XNameContainer)UnoRuntime.queryInterface(&lt;br /&gt;
              com.sun.star.container.XNameContainer.class, xAccess );&lt;br /&gt;
  &lt;br /&gt;
          if (xSetElementFactory != null &amp;amp;&amp;amp; xNameContainer != null) {&lt;br /&gt;
              Object[] aArgs = new Object[0];&lt;br /&gt;
    &lt;br /&gt;
              for (int i = 0; i &amp;lt; aCommandURLTestSet.length; i++) {&lt;br /&gt;
                  // Create the nodes with the XSingleServiceFactory of the configuration&lt;br /&gt;
                      Object xNewElement = xSetElementFactory.createInstanceWithArguments( aArgs );&lt;br /&gt;
                      if (xNewElement != null) {&lt;br /&gt;
                          // We have a new node. To set the properties of the node we need&lt;br /&gt;
                          // the XPropertySet interface.&lt;br /&gt;
                          com.sun.star.beans.XPropertySet xPropertySet = &lt;br /&gt;
                          (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class,&lt;br /&gt;
                              xNewElement );&lt;br /&gt;
  &lt;br /&gt;
                          if (xPropertySet != null) {&lt;br /&gt;
                              // Create a unique node name.&lt;br /&gt;
                              String aCmdNodeName = new String(&amp;quot;Command-&amp;quot;);&lt;br /&gt;
                              aCmdNodeName += i;&lt;br /&gt;
    &lt;br /&gt;
                              // Insert the node into the Disabled set&lt;br /&gt;
                              xPropertySet.setPropertyValue(&amp;quot;Command&amp;quot;, aCommandURLTestSet[i]);&lt;br /&gt;
                              xNameContainer.insertByName(aCmdNodeName, xNewElement);&lt;br /&gt;
                          }&lt;br /&gt;
                      }&lt;br /&gt;
                  }&lt;br /&gt;
    &lt;br /&gt;
                  // Commit our changes&lt;br /&gt;
                  com.sun.star.util.XChangesBatch xFlush = (com.sun.star.util.XChangesBatch)&lt;br /&gt;
                  UnoRuntime.queryInterface(com.sun.star.util.XChangesBatch.class, xAccess);&lt;br /&gt;
                  xFlush.commitChanges();&lt;br /&gt;
              } &lt;br /&gt;
          }&lt;br /&gt;
          catch (com.sun.star.uno.Exception e) {&lt;br /&gt;
              System.out.println(&amp;quot;Exception detected!&amp;quot;);&lt;br /&gt;
              System.out.println(e);&lt;br /&gt;
          }&lt;br /&gt;
      } &lt;br /&gt;
      &lt;br /&gt;
      /**&lt;br /&gt;
       *  reset URL so it can be reused&lt;br /&gt;
       *&lt;br /&gt;
       *  @param aURL&lt;br /&gt;
       *  the URL that should be reseted&lt;br /&gt;
       */&lt;br /&gt;
      private static void resetURL(com.sun.star.util.URL aURL) {&lt;br /&gt;
          aURL.Protocol = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.User = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Password = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Server = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Port = 0;&lt;br /&gt;
          aURL.Path = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Name = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Arguments = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Mark = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Main = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Complete = &amp;quot;&amp;quot;;&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;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>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Talk:Documentation/DevGuide/WritingUNO/Disable_Commands&amp;diff=100476</id>
		<title>Talk:Documentation/DevGuide/WritingUNO/Disable Commands</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Talk:Documentation/DevGuide/WritingUNO/Disable_Commands&amp;diff=100476"/>
		<updated>2008-11-29T15:59:02Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: New page: beppec56:  I added a few comments on naming of configuration file. Can someone have a look? I&amp;#039;ll post few lines to dev@framework.openoffice.org, anyway.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;beppec56:&lt;br /&gt;
&lt;br /&gt;
I added a few comments on naming of configuration file.&lt;br /&gt;
Can someone have a look?&lt;br /&gt;
I&amp;#039;ll post few lines to dev@framework.openoffice.org, anyway.&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/WritingUNO/Disable_Commands&amp;diff=100475</id>
		<title>Documentation/DevGuide/WritingUNO/Disable Commands</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/WritingUNO/Disable_Commands&amp;diff=100475"/>
		<updated>2008-11-29T15:56:59Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/WritingUNOTOC&lt;br /&gt;
|WritingUNO2e=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/WritingUNO/AddOns/Installation&lt;br /&gt;
|NextPage=Documentation/DevGuide/WritingUNO/Intercepting Context Menus&lt;br /&gt;
}}&lt;br /&gt;
[[zh:Zh/Documentation/DevGuide/WritingUNO/Disable Commands]]&lt;br /&gt;
{{DISPLAYTITLE:Disable Commands}}&lt;br /&gt;
In {{PRODUCTNAME}}, there may be situations where functions should be disabled to prevent users from changing or destroying documents inadvertently. {{PRODUCTNAME}} maintains a list of disabled commands that can be maintained by users and developers through the configuration API.&lt;br /&gt;
&lt;br /&gt;
A command request can be created by any object, but in most cases, user interface objects create these requests. Consider, for instance, a toolbox where different functions acting on the office component are presented as buttons. Once a button is clicked, the desired functionality should be executed. If the code assigned to the button is provided with a suitable command URL, the dispatch framework can handle the user action by creating the request and finding a component that can handle it.&lt;br /&gt;
&lt;br /&gt;
The dispatch framework works with the design pattern &amp;#039;&amp;#039;chain of responsibility&amp;#039;&amp;#039;: everything a component needs to know if it wants to execute a request is the last link in a chain of objects capable of executing requests. If this object gets the request, it checks whether it can handle it or otherwise passes it to the next chain member until the request is executed or the end of the chain is reached.The disable commands implementation is the first chain member and can therefore work as a wall for all disabled commands. They are not be sent to the next chain member, and disappear.&lt;br /&gt;
&lt;br /&gt;
The illustration below shows how the disable commands feature affects the normal command application flow.&lt;br /&gt;
&lt;br /&gt;
[[Image:DisableCommands_ApplicationFlow.png|none|thumb|400px|How the disable commands feature works]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Caution|Since the disable commands implementation is the first part in the dispatch chain, there is no way to circumvent it. The disabled command must be removed from the list, otherwise it remains disabled.}}&lt;br /&gt;
&lt;br /&gt;
=== Configuration ===&lt;br /&gt;
&lt;br /&gt;
The disable commands feature uses the configuration branch &amp;#039;&amp;#039;org.openoffice.Office.Commands&amp;#039;&amp;#039; to read which commands should be disabled. The following schema applies:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;?xml version=&amp;#039;1.0&amp;#039; encoding=&amp;#039;UTF-8&amp;#039;?&amp;gt;&lt;br /&gt;
  &amp;lt;oor:component-schema oor:name=&amp;quot;Commands&amp;quot; oor:package=&amp;quot;org.openoffice.Office&amp;quot; xml:lang=&amp;quot;en-US&amp;quot; xmlns:oor=&amp;quot;http://openoffice.org/2001/registry&amp;quot; xmlns:xs=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;templates&amp;gt;&lt;br /&gt;
          &amp;lt;group oor:name=&amp;quot;CommandType&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;prop oor:name=&amp;quot;Command&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;/&amp;gt;&lt;br /&gt;
          &amp;lt;/group&amp;gt;&lt;br /&gt;
      &amp;lt;/templates&amp;gt;&lt;br /&gt;
      &amp;lt;component&amp;gt;&lt;br /&gt;
          &amp;lt;group oor:name=&amp;quot;Execute&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;set oor:name=&amp;quot;Disabled&amp;quot; oor:node-type=&amp;quot;CommandType&amp;quot;/&amp;gt;&lt;br /&gt;
          &amp;lt;/group&amp;gt;&lt;br /&gt;
      &amp;lt;/component&amp;gt;&lt;br /&gt;
  &amp;lt;/oor:component-schema&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The configuration schema for disabled commands is very simple. The &amp;#039;&amp;#039;org.openoffice.Office.Commands&amp;#039;&amp;#039; branch has a group called &amp;lt;code&amp;gt;Execute&amp;lt;/code&amp;gt;. This group has only one set called &amp;lt;code&amp;gt;Disabled&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt;Disabled&amp;lt;/code&amp;gt; set supports nodes of the type &amp;lt;code&amp;gt;CommandType&amp;lt;/code&amp;gt;. The following table describes the supported properties of &amp;lt;code&amp;gt;CommandType&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;
!colspan=&amp;quot;2&amp;quot;|Properties of the &amp;lt;code&amp;gt;CommandType&amp;lt;/code&amp;gt; group &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;oor:component-data&amp;lt;/code&amp;gt; &lt;br /&gt;
|string. It must be unique inside the &amp;lt;code&amp;gt;Disabled&amp;lt;/code&amp;gt; set, but has no additional meaning for the implementation of the disable commands feature. Use a consecutive numbering scheme; even numbers are allowed. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;Command&amp;lt;/code&amp;gt; &lt;br /&gt;
|string. This is the command name with the preceding protocol. That means the command URL &amp;#039;&amp;#039;.uno:Open&amp;#039;&amp;#039; (which shows the &amp;#039;&amp;#039;&amp;#039;File – Open&amp;#039;&amp;#039;&amp;#039; dialog) must be written as &amp;lt;code&amp;gt;Open&amp;lt;/code&amp;gt;.&lt;br /&gt;
The valid commands can be found in the document &amp;#039;&amp;#039;Index of Command Names&amp;#039;&amp;#039; in the [http://framework.openoffice.org/servlets/ProjectDocumentList Documentation section of the framework project] on the OpenOffice.org web page. The {{PRODUCTNAME}} SDK also includes the latest [http://www.openoffice.org/files/documents/25/60/commands_11beta.html list of command names]. &lt;br /&gt;
Additional information regarding Command names is available in: [http://wiki.services.openoffice.org/wiki/Framework/Article/OpenOffice.org_2.x_Commands]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The example below shows a configuration file that disables the commands for &amp;#039;&amp;#039;&amp;#039;File – Open&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;Edit – Select All&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;Help – About {{PRODUCTNAME}}&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;File – Exit&amp;#039;&amp;#039;&amp;#039;.&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;oor:component-data oor:name=&amp;quot;Commands&amp;quot; oor:package=&amp;quot;org.openoffice.Office&amp;quot; xmlns:oor=&amp;quot;http://openoffice.org/2001/registry&amp;quot; xmlns:xs=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;node oor:name=&amp;quot;Execute&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;node oor:name=&amp;quot;Disabled&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;node oor:name=&amp;quot;m1&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;prop oor:name=&amp;quot;Command&amp;quot;&amp;gt;&lt;br /&gt;
                      &amp;lt;value&amp;gt;Open&amp;lt;/value&amp;gt;&lt;br /&gt;
                  &amp;lt;/prop&amp;gt;&lt;br /&gt;
              &amp;lt;/node&amp;gt;&lt;br /&gt;
              &amp;lt;node oor:name=&amp;quot;m2&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;prop oor:name=&amp;quot;Command&amp;quot;&amp;gt;&lt;br /&gt;
                      &amp;lt;value&amp;gt;SelectAll&amp;lt;/value&amp;gt;&lt;br /&gt;
                  &amp;lt;/prop&amp;gt;&lt;br /&gt;
              &amp;lt;/node&amp;gt;&lt;br /&gt;
              &amp;lt;node oor:name=&amp;quot;m3&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;prop oor:name=&amp;quot;Command&amp;quot;&amp;gt;&lt;br /&gt;
                      &amp;lt;value&amp;gt;About&amp;lt;/value&amp;gt;&lt;br /&gt;
                  &amp;lt;/prop&amp;gt;&lt;br /&gt;
              &amp;lt;/node&amp;gt;&lt;br /&gt;
              &amp;lt;node oor:name=&amp;quot;m4&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;prop oor:name=&amp;quot;Command&amp;quot;&amp;gt;&lt;br /&gt;
                      &amp;lt;value&amp;gt;Quit&amp;lt;/value&amp;gt;&lt;br /&gt;
                  &amp;lt;/prop&amp;gt;&lt;br /&gt;
              &amp;lt;/node&amp;gt;&lt;br /&gt;
          &amp;lt;/node&amp;gt;&lt;br /&gt;
      &amp;lt;/node&amp;gt;&lt;br /&gt;
  &amp;lt;/oor:component-data&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A few lines on the &amp;#039;m1&amp;#039;, &amp;#039;m2&amp;#039;, &amp;#039;m3&amp;#039; and &amp;#039;m4&amp;#039; node names in the xml example above.&lt;br /&gt;
&lt;br /&gt;
If you plan to use the disable command feature in an extension using a configuration file, it&amp;#039;s important to use a unique name for the &amp;#039;CommandType&amp;#039; node.&lt;br /&gt;
As an example you can use the extension identifier plus other qualifiers.&lt;br /&gt;
&lt;br /&gt;
Looking at the extension naming suggestion given in the [[Documentation/DevGuide/Extensions/Example|extension description example]], in the example above you may have used &amp;#039;com.mycompany.extensions.my_extension.m1&amp;#039; instead of &amp;#039;m1&amp;#039;, &amp;#039;com.mycompany.extensions.my_extension.&amp;#039; instead of &amp;#039;m2&amp;#039; and so on.&lt;br /&gt;
In this way the node is unique throughout the command disabled configuration tree.&lt;br /&gt;
&lt;br /&gt;
=== Disabling Commands at Runtime ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.configuration.ConfigurationUpdateAccess;com.sun.star.configuration.ConfigurationProvider;com.sun.star.util.XChangesBatch&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The following code example first removes all commands that were defined in the user layer of the configuration branch &amp;lt;code&amp;gt;org.openoffice.Office.Commands&amp;lt;/code&amp;gt; as having a defined starting point. Then it checks if it can get dispatch objects for some pre-defined commands.Then the example disables these commands and tries to get dispatch objects for them again. At the end, the code removes the disabled commands again, otherwise {{PRODUCTNAME}} would not be fully usable any longer.&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;
  import com.sun.star.lang.XMultiServiceFactory;&lt;br /&gt;
  import com.sun.star.lang.XSingleServiceFactory;&lt;br /&gt;
  import com.sun.star.util.XURLTransformer;&lt;br /&gt;
  import com.sun.star.frame.XDesktop;&lt;br /&gt;
  &lt;br /&gt;
  import com.sun.star.beans.UnknownPropertyException;&lt;br /&gt;
  &lt;br /&gt;
  /*&lt;br /&gt;
   *  Provides example code how to enable/disable&lt;br /&gt;
   *  commands.&lt;br /&gt;
   */&lt;br /&gt;
  public class DisableCommandsTest extends java.lang.Object {&lt;br /&gt;
  &lt;br /&gt;
      /*&lt;br /&gt;
       *  A list of command names&lt;br /&gt;
       */&lt;br /&gt;
      final static private String[] aCommandURLTestSet =&lt;br /&gt;
      {&lt;br /&gt;
          new String( &amp;quot;Open&amp;quot; ),&lt;br /&gt;
          new String( &amp;quot;About&amp;quot; ),&lt;br /&gt;
          new String( &amp;quot;SelectAll&amp;quot; ),&lt;br /&gt;
          new String( &amp;quot;Quit&amp;quot; ),&lt;br /&gt;
      };&lt;br /&gt;
  &lt;br /&gt;
      private static XComponentContext xRemoteContext = null;&lt;br /&gt;
      private static XMultiComponentFactory xRemoteServiceManager = null;&lt;br /&gt;
      private static XURLTransformer xTransformer = null;&lt;br /&gt;
      private static XMultiServiceFactory xConfigProvider = null;&lt;br /&gt;
      &lt;br /&gt;
      /*&lt;br /&gt;
       *  @param args the command line arguments&lt;br /&gt;
       */&lt;br /&gt;
      public static void main(String[] args) {&lt;br /&gt;
      &lt;br /&gt;
          try {&lt;br /&gt;
              // connect&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;
              Object transformer = xRemoteServiceManager.createInstanceWithContext(&lt;br /&gt;
                  &amp;quot;com.sun.star.util.URLTransformer&amp;quot;, xRemoteContext);&lt;br /&gt;
              xTransformer = (com.sun.star.util.XURLTransformer)UnoRuntime.queryInterface(&lt;br /&gt;
                  com.sun.star.util.XURLTransformer.class, transformer);&lt;br /&gt;
      &lt;br /&gt;
              Object configProvider = xRemoteServiceManager.createInstanceWithContext(&lt;br /&gt;
                  &amp;quot;com.sun.star.configuration.ConfigurationProvider&amp;quot;, xRemoteContext);&lt;br /&gt;
              xConfigProvider = (com.sun.star.lang.XMultiServiceFactory)UnoRuntime.queryInterface(&lt;br /&gt;
                  com.sun.star.lang.XMultiServiceFactory.class, configProvider);&lt;br /&gt;
    &lt;br /&gt;
              // First we need a defined starting point. So we have to remove&lt;br /&gt;
              // all commands from the disabled set!&lt;br /&gt;
              enableCommands();&lt;br /&gt;
  &lt;br /&gt;
              // Check if the commands are usable&lt;br /&gt;
              testCommands(false);&lt;br /&gt;
          &lt;br /&gt;
              // Disable the commands&lt;br /&gt;
              disableCommands();&lt;br /&gt;
          &lt;br /&gt;
              // Now the commands should not be usable anymore&lt;br /&gt;
              testCommands(true);&lt;br /&gt;
  &lt;br /&gt;
              // Remove disable commands to make Office usable again&lt;br /&gt;
              enableCommands();&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;
      /**&lt;br /&gt;
       *  Test the commands that we enabled/disabled&lt;br /&gt;
       */&lt;br /&gt;
      private static void testCommands(boolean bDisabledCmds) throws com.sun.star.uno.Exception {&lt;br /&gt;
          // We need the desktop to get access to the current frame&lt;br /&gt;
          Object desktop = xRemoteServiceManager.createInstanceWithContext(&lt;br /&gt;
              &amp;quot;com.sun.star.frame.Desktop&amp;quot;, xRemoteContext );&lt;br /&gt;
          com.sun.star.frame.XDesktop xDesktop = (com.sun.star.frame.XDesktop)UnoRuntime.queryInterface(&lt;br /&gt;
              com.sun.star.frame.XDesktop.class, desktop);&lt;br /&gt;
          com.sun.star.frame.XFrame xFrame = xDesktop.getCurrentFrame();&lt;br /&gt;
          com.sun.star.frame.XDispatchProvider xDispatchProvider = null;&lt;br /&gt;
          if (xFrame != null) {&lt;br /&gt;
              // We have a frame. Now we need access to the dispatch provider.&lt;br /&gt;
              xDispatchProvider = (com.sun.star.frame.XDispatchProvider)UnoRuntime.queryInterface( &lt;br /&gt;
                  com.sun.star.frame.XDispatchProvider.class, xFrame );&lt;br /&gt;
              if (xDispatchProvider != null) {&lt;br /&gt;
                  // As we have the dispatch provider we can now check if we get a dispatch&lt;br /&gt;
                  // object or not.&lt;br /&gt;
                  for (int n = 0; n &amp;lt; aCommandURLTestSet.length; n++) {&lt;br /&gt;
                      // Prepare the URL&lt;br /&gt;
                      com.sun.star.util.URL[] aURL = new com.sun.star.util.URL[1];&lt;br /&gt;
                      aURL[0] = new com.sun.star.util.URL();&lt;br /&gt;
                      com.sun.star.frame.XDispatch xDispatch = null;&lt;br /&gt;
    &lt;br /&gt;
                      aURL[0].Complete = &amp;quot;.uno:&amp;quot; + aCommandURLTestSet[n];&lt;br /&gt;
                      xTransformer.parseSmart(aURL, &amp;quot;.uno:&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
                      // Try to get a dispatch object for our URL&lt;br /&gt;
                      xDispatch = xDispatchProvider.queryDispatch(aURL[0], &amp;quot;&amp;quot;, 0);&lt;br /&gt;
    &lt;br /&gt;
                      if (xDispatch != null) {&lt;br /&gt;
                          if (bDisabledCmds)&lt;br /&gt;
                              System.out.println(&amp;quot;Something is wrong, I got dispatch object for &amp;quot; &lt;br /&gt;
                                  + aURL[0].Complete);&lt;br /&gt;
                          else&lt;br /&gt;
                              System.out.println(&amp;quot;Ok, dispatch object for &amp;quot; + aURL[0].Complete);&lt;br /&gt;
                      }&lt;br /&gt;
                      else {&lt;br /&gt;
                          if (!bDisabledCmds)&lt;br /&gt;
                              System.out.println(&amp;quot;Something is wrong, I cannot get dispatch   object for &amp;quot; &lt;br /&gt;
                                  + aURL[0].Complete);&lt;br /&gt;
                          else&lt;br /&gt;
                              System.out.println(&amp;quot;Ok, no dispatch object for &amp;quot; + aURL[0].Complete);&lt;br /&gt;
                      }&lt;br /&gt;
                      resetURL(aURL[0]);&lt;br /&gt;
                  }&lt;br /&gt;
              }&lt;br /&gt;
              else&lt;br /&gt;
                  System.out.println(&amp;quot;Couldn&amp;#039;t get XDispatchProvider from Frame!&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else&lt;br /&gt;
              System.out.println(&amp;quot;Couldn&amp;#039;t get current Frame from Desktop!&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
    &lt;br /&gt;
      /**&lt;br /&gt;
       *  Ensure that there are no disabled commands in the user layer. The&lt;br /&gt;
       *  implementation removes all commands from the disabled set!&lt;br /&gt;
       */&lt;br /&gt;
      private static void enableCommands() {&lt;br /&gt;
          // Set the root path for our configuration access&lt;br /&gt;
          com.sun.star.beans.PropertyValue[] lParams = new com.sun.star.beans.PropertyValue[1];&lt;br /&gt;
  &lt;br /&gt;
          lParams[0] = new com.sun.star.beans.PropertyValue();&lt;br /&gt;
          lParams[0].Name = new String(&amp;quot;nodepath&amp;quot;);&lt;br /&gt;
          lParams[0].Value = &amp;quot;/org.openoffice.Office.Commands/Execute/Disabled&amp;quot;;&lt;br /&gt;
      &lt;br /&gt;
          try {&lt;br /&gt;
              // Create configuration update access to have write access to the configuration&lt;br /&gt;
              Object xAccess = xConfigProvider.createInstanceWithArguments( &lt;br /&gt;
&amp;quot;com.sun.star.configuration.ConfigurationUpdateAccess&amp;quot;, lParams);&lt;br /&gt;
  &lt;br /&gt;
              com.sun.star.container.XNameAccess xNameAccess = (com.sun.star.container.XNameAccess)&lt;br /&gt;
              UnoRuntime.queryInterface(com.sun.star.container.XNameAccess.class, xAccess);&lt;br /&gt;
              if (xNameAccess != null) {&lt;br /&gt;
                  // We need the XNameContainer interface to remove the nodes by name&lt;br /&gt;
                  com.sun.star.container.XNameContainer xNameContainer =&lt;br /&gt;
                      (com.sun.star.container.XNameContainer)&lt;br /&gt;
                  UnoRuntime.queryInterface(com.sun.star.container.XNameContainer.class, xAccess);&lt;br /&gt;
    &lt;br /&gt;
                  // Retrieves the names of all Disabled nodes&lt;br /&gt;
                  String[] aCommandsSeq = xNameAccess.getElementNames();&lt;br /&gt;
                  for (int n = 0; n &amp;lt; aCommandsSeq.length; n++) {&lt;br /&gt;
                      try {&lt;br /&gt;
                          // remove the node&lt;br /&gt;
                          xNameContainer.removeByName( aCommandsSeq[n]);&lt;br /&gt;
                      }&lt;br /&gt;
                      catch (com.sun.star.lang.WrappedTargetException e) {&lt;br /&gt;
                      }&lt;br /&gt;
                      catch (com.sun.star.container.NoSuchElementException e) {&lt;br /&gt;
                      }&lt;br /&gt;
                  }&lt;br /&gt;
              } &lt;br /&gt;
    &lt;br /&gt;
              // Commit our changes&lt;br /&gt;
              com.sun.star.util.XChangesBatch xFlush =&lt;br /&gt;
              (com.sun.star.util.XChangesBatch)UnoRuntime.queryInterface(&lt;br /&gt;
                  com.sun.star.util.XChangesBatch.class, xAccess);&lt;br /&gt;
              xFlush.commitChanges();&lt;br /&gt;
          }    &lt;br /&gt;
          catch (com.sun.star.uno.Exception e) {&lt;br /&gt;
              System.out.println(&amp;quot;Exception detected!&amp;quot;);&lt;br /&gt;
              System.out.println(e);&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
    &lt;br /&gt;
      /**&lt;br /&gt;
       *  Disable all commands defined in the aCommandURLTestSet array&lt;br /&gt;
       */&lt;br /&gt;
      private static void disableCommands() {&lt;br /&gt;
      // Set the root path for our configuration access&lt;br /&gt;
      com.sun.star.beans.PropertyValue[] lParams = new com.sun.star.beans.PropertyValue[1];&lt;br /&gt;
      lParams[0] = new com.sun.star.beans.PropertyValue();&lt;br /&gt;
      lParams[0].Name = new String(&amp;quot;nodepath&amp;quot;);&lt;br /&gt;
      lParams[0].Value = &amp;quot;/org.openoffice.Office.Commands/Execute/Disabled&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
      try {&lt;br /&gt;
          // Create configuration update access to have write access to the configuration&lt;br /&gt;
          Object xAccess = xConfigProvider.createInstanceWithArguments( &lt;br /&gt;
          &amp;quot;com.sun.star.configuration.ConfigurationUpdateAccess&amp;quot;, lParams);&lt;br /&gt;
    &lt;br /&gt;
          com.sun.star.lang.XSingleServiceFactory xSetElementFactory = &lt;br /&gt;
          (com.sun.star.lang.XSingleServiceFactory)UnoRuntime.queryInterface(&lt;br /&gt;
              com.sun.star.lang.XSingleServiceFactory.class, xAccess);&lt;br /&gt;
          &lt;br /&gt;
          com.sun.star.container.XNameContainer xNameContainer =&lt;br /&gt;
          (com.sun.star.container.XNameContainer)UnoRuntime.queryInterface(&lt;br /&gt;
              com.sun.star.container.XNameContainer.class, xAccess );&lt;br /&gt;
  &lt;br /&gt;
          if (xSetElementFactory != null &amp;amp;&amp;amp; xNameContainer != null) {&lt;br /&gt;
              Object[] aArgs = new Object[0];&lt;br /&gt;
    &lt;br /&gt;
              for (int i = 0; i &amp;lt; aCommandURLTestSet.length; i++) {&lt;br /&gt;
                  // Create the nodes with the XSingleServiceFactory of the configuration&lt;br /&gt;
                      Object xNewElement = xSetElementFactory.createInstanceWithArguments( aArgs );&lt;br /&gt;
                      if (xNewElement != null) {&lt;br /&gt;
                          // We have a new node. To set the properties of the node we need&lt;br /&gt;
                          // the XPropertySet interface.&lt;br /&gt;
                          com.sun.star.beans.XPropertySet xPropertySet = &lt;br /&gt;
                          (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class,&lt;br /&gt;
                              xNewElement );&lt;br /&gt;
  &lt;br /&gt;
                          if (xPropertySet != null) {&lt;br /&gt;
                              // Create a unique node name.&lt;br /&gt;
                              String aCmdNodeName = new String(&amp;quot;Command-&amp;quot;);&lt;br /&gt;
                              aCmdNodeName += i;&lt;br /&gt;
    &lt;br /&gt;
                              // Insert the node into the Disabled set&lt;br /&gt;
                              xPropertySet.setPropertyValue(&amp;quot;Command&amp;quot;, aCommandURLTestSet[i]);&lt;br /&gt;
                              xNameContainer.insertByName(aCmdNodeName, xNewElement);&lt;br /&gt;
                          }&lt;br /&gt;
                      }&lt;br /&gt;
                  }&lt;br /&gt;
    &lt;br /&gt;
                  // Commit our changes&lt;br /&gt;
                  com.sun.star.util.XChangesBatch xFlush = (com.sun.star.util.XChangesBatch)&lt;br /&gt;
                  UnoRuntime.queryInterface(com.sun.star.util.XChangesBatch.class, xAccess);&lt;br /&gt;
                  xFlush.commitChanges();&lt;br /&gt;
              } &lt;br /&gt;
          }&lt;br /&gt;
          catch (com.sun.star.uno.Exception e) {&lt;br /&gt;
              System.out.println(&amp;quot;Exception detected!&amp;quot;);&lt;br /&gt;
              System.out.println(e);&lt;br /&gt;
          }&lt;br /&gt;
      } &lt;br /&gt;
      &lt;br /&gt;
      /**&lt;br /&gt;
       *  reset URL so it can be reused&lt;br /&gt;
       *&lt;br /&gt;
       *  @param aURL&lt;br /&gt;
       *  the URL that should be reseted&lt;br /&gt;
       */&lt;br /&gt;
      private static void resetURL(com.sun.star.util.URL aURL) {&lt;br /&gt;
          aURL.Protocol = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.User = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Password = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Server = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Port = 0;&lt;br /&gt;
          aURL.Path = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Name = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Arguments = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Mark = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Main = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Complete = &amp;quot;&amp;quot;;&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;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>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=User:Beppec56/Collections/Extensions&amp;diff=98916</id>
		<title>User:Beppec56/Collections/Extensions</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=User:Beppec56/Collections/Extensions&amp;diff=98916"/>
		<updated>2008-11-16T08:42:17Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Extensions ==&lt;br /&gt;
;Extensions&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Extensions|Extensions]]&lt;br /&gt;
;Extension Manager&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Extension Manager|Extension Manager]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Deployment Items|Deployment Items]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Installing Extensions for All or a Single User|Installing Extensions for All or a Single User]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Extension Manager in OpenOffice.org|Extension Manager in OpenOffice.org]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/unopkg|unopkg]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Location of Installed Extensions|Location of Installed Extensions]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Extension Layers|Extension Layers]]&lt;br /&gt;
;Checklist for Writing Extensions&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Checklist for Writing Extensions|Checklist for Writing Extensions]]&lt;br /&gt;
;File Format&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/File Format|File Format]]&lt;br /&gt;
;description.xml&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/description.xml|description.xml]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Description of XML Elements|Description of XML Elements]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Localized XML Elements|Localized XML Elements]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Example|Example]]&lt;br /&gt;
;General Information on Extensions&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Display Name|Display Name]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Icon|Icon]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Extension Description|Extension Description]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Extension Identifiers|Extension Identifiers]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Extension Versions|Extension Versions]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Target Platform|Target Platform]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Simple License|Simple License]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Dependencies|Dependencies]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Publisher Information|Publisher Information]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/System Integration|System Integration]]&lt;br /&gt;
;Online Update of Extensions&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Online Update of Extensions|Online Update of Extensions]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Running Online - Update|Running Online - Update]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Concept|Concept]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Example Scenario for Providing Updates|Example Scenario for Providing Updates]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Migration of Update Information|Migration of Update Information]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Description of the Update Information|Description of the Update Information]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Description of Atom Feed|Description of Atom Feed]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Examples|Examples]]&lt;br /&gt;
;Options Management&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Options Dialog|Options Dialog]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Creating the GUI of the Options Page|Creating the GUI of the Options Page]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Saving and Reading Data for the Options Page|Saving and Reading Data for the Options Page]]&lt;br /&gt;
;Defining the Usage of Options Pages&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Defining the Usage of Options Pages|Defining the Usage of Options Pages]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/The Options Dialog of the Extension Manager|The Options Dialog of the Extension Manager]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Adding a Leaf to an Existing Node|Adding a Leaf to an Existing Node]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Adding Several Leaves|Adding Several Leaves]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Grouping of Leaves|Grouping of Leaves]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Adding Nodes|Adding Nodes]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Adding Several Nodes|Adding Several Nodes]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Absolute Position of Leaves|Absolute Position of Leaves]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Grouping of Nodes|Grouping of Nodes]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Assigning Nodes to Modules|Assigning Nodes to Modules]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Defining a Module|Defining a Module]]&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Absolute Position of Nodes|Absolute Position of Nodes]]&lt;br /&gt;
;Help Content&lt;br /&gt;
:[[Documentation/DevGuide/Extensions/Help Content|Help Content]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Collections]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=User:Beppec56/Collections/Extensions&amp;diff=98915</id>
		<title>User:Beppec56/Collections/Extensions</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=User:Beppec56/Collections/Extensions&amp;diff=98915"/>
		<updated>2008-11-16T08:41:39Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Extensions ==&lt;br /&gt;
;Extensions&lt;br /&gt;
&lt;br /&gt;
[[Category:Collections]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/WritingUNO/Disable_Commands&amp;diff=98042</id>
		<title>Documentation/DevGuide/WritingUNO/Disable Commands</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/WritingUNO/Disable_Commands&amp;diff=98042"/>
		<updated>2008-11-08T11:58:42Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: removed  the &amp;lt;/nowiki&amp;gt; tag inside xml and code example&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/WritingUNOTOC&lt;br /&gt;
|WritingUNO2e=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/WritingUNO/AddOns/Installation&lt;br /&gt;
|NextPage=Documentation/DevGuide/WritingUNO/Intercepting Context Menus&lt;br /&gt;
}}&lt;br /&gt;
[[zh:Zh/Documentation/DevGuide/WritingUNO/Disable Commands]]&lt;br /&gt;
{{DISPLAYTITLE:Disable Commands}}&lt;br /&gt;
In {{PRODUCTNAME}}, there may be situations where functions should be disabled to prevent users from changing or destroying documents inadvertently. {{PRODUCTNAME}} maintains a list of disabled commands that can be maintained by users and developers through the configuration API.&lt;br /&gt;
&lt;br /&gt;
A command request can be created by any object, but in most cases, user interface objects create these requests. Consider, for instance, a toolbox where different functions acting on the office component are presented as buttons. Once a button is clicked, the desired functionality should be executed. If the code assigned to the button is provided with a suitable command URL, the dispatch framework can handle the user action by creating the request and finding a component that can handle it.&lt;br /&gt;
&lt;br /&gt;
The dispatch framework works with the design pattern &amp;#039;&amp;#039;chain of responsibility&amp;#039;&amp;#039;: everything a component needs to know if it wants to execute a request is the last link in a chain of objects capable of executing requests. If this object gets the request, it checks whether it can handle it or otherwise passes it to the next chain member until the request is executed or the end of the chain is reached.The disable commands implementation is the first chain member and can therefore work as a wall for all disabled commands. They are not be sent to the next chain member, and disappear.&lt;br /&gt;
&lt;br /&gt;
The illustration below shows how the disable commands feature affects the normal command application flow.&lt;br /&gt;
&lt;br /&gt;
[[Image:DisableCommands_ApplicationFlow.png|none|thumb|400px|How the disable commands feature works]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Caution|Since the disable commands implementation is the first part in the dispatch chain, there is no way to circumvent it. The disabled command must be removed from the list, otherwise it remains disabled.}}&lt;br /&gt;
&lt;br /&gt;
=== Configuration ===&lt;br /&gt;
&lt;br /&gt;
The disable commands feature uses the configuration branch &amp;#039;&amp;#039;org.openoffice.Office.Commands&amp;#039;&amp;#039; to read which commands should be disabled. The following schema applies:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;?xml version=&amp;#039;1.0&amp;#039; encoding=&amp;#039;UTF-8&amp;#039;?&amp;gt;&lt;br /&gt;
  &amp;lt;oor:component-schema oor:name=&amp;quot;Commands&amp;quot; oor:package=&amp;quot;org.openoffice.Office&amp;quot; xml:lang=&amp;quot;en-US&amp;quot; xmlns:oor=&amp;quot;http://openoffice.org/2001/registry&amp;quot; xmlns:xs=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;templates&amp;gt;&lt;br /&gt;
          &amp;lt;group oor:name=&amp;quot;CommandType&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;prop oor:name=&amp;quot;Command&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;/&amp;gt;&lt;br /&gt;
          &amp;lt;/group&amp;gt;&lt;br /&gt;
      &amp;lt;/templates&amp;gt;&lt;br /&gt;
      &amp;lt;component&amp;gt;&lt;br /&gt;
          &amp;lt;group oor:name=&amp;quot;Execute&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;set oor:name=&amp;quot;Disabled&amp;quot; oor:node-type=&amp;quot;CommandType&amp;quot;/&amp;gt;&lt;br /&gt;
          &amp;lt;/group&amp;gt;&lt;br /&gt;
      &amp;lt;/component&amp;gt;&lt;br /&gt;
  &amp;lt;/oor:component-schema&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The configuration schema for disabled commands is very simple. The &amp;#039;&amp;#039;org.openoffice.Office.Commands&amp;#039;&amp;#039; branch has a group called &amp;lt;code&amp;gt;Execute&amp;lt;/code&amp;gt;. This group has only one set called &amp;lt;code&amp;gt;Disabled&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt;Disabled&amp;lt;/code&amp;gt; set supports nodes of the type &amp;lt;code&amp;gt;CommandType&amp;lt;/code&amp;gt;. The following table describes the supported properties of &amp;lt;code&amp;gt;CommandType&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;
!colspan=&amp;quot;2&amp;quot;|Properties of the &amp;lt;code&amp;gt;CommandType&amp;lt;/code&amp;gt; group &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;oor:component-data&amp;lt;/code&amp;gt; &lt;br /&gt;
|string. It must be unique inside the &amp;lt;code&amp;gt;Disabled&amp;lt;/code&amp;gt; set, but has no additional meaning for the implementation of the disable commands feature. Use a consecutive numbering scheme; even numbers are allowed. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;Command&amp;lt;/code&amp;gt; &lt;br /&gt;
|string. This is the command name with the preceding protocol. That means the command URL &amp;#039;&amp;#039;.uno:Open&amp;#039;&amp;#039; (which shows the &amp;#039;&amp;#039;&amp;#039;File – Open&amp;#039;&amp;#039;&amp;#039; dialog) must be written as &amp;lt;code&amp;gt;Open&amp;lt;/code&amp;gt;.&lt;br /&gt;
The valid commands can be found in the document &amp;#039;&amp;#039;Index of Command Names&amp;#039;&amp;#039; in the [http://framework.openoffice.org/servlets/ProjectDocumentList Documentation section of the framework project] on the OpenOffice.org web page. The {{PRODUCTNAME}} SDK also includes the latest [http://www.openoffice.org/files/documents/25/60/commands_11beta.html list of command names]. &lt;br /&gt;
Additional information regarding Command names is available in: [http://wiki.services.openoffice.org/wiki/Framework/Article/OpenOffice.org_2.x_Commands]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The example below shows a configuration file that disables the commands for &amp;#039;&amp;#039;&amp;#039;File – Open&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;Edit – Select All&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;Help – About {{PRODUCTNAME}}&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;File – Exit&amp;#039;&amp;#039;&amp;#039;.&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;oor:component-data oor:name=&amp;quot;Commands&amp;quot; oor:package=&amp;quot;org.openoffice.Office&amp;quot; xmlns:oor=&amp;quot;http://openoffice.org/2001/registry&amp;quot; xmlns:xs=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;node oor:name=&amp;quot;Execute&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;node oor:name=&amp;quot;Disabled&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;node oor:name=&amp;quot;m1&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;prop oor:name=&amp;quot;Command&amp;quot;&amp;gt;&lt;br /&gt;
                      &amp;lt;value&amp;gt;Open&amp;lt;/value&amp;gt;&lt;br /&gt;
                  &amp;lt;/prop&amp;gt;&lt;br /&gt;
              &amp;lt;/node&amp;gt;&lt;br /&gt;
              &amp;lt;node oor:name=&amp;quot;m2&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;prop oor:name=&amp;quot;Command&amp;quot;&amp;gt;&lt;br /&gt;
                      &amp;lt;value&amp;gt;SelectAll&amp;lt;/value&amp;gt;&lt;br /&gt;
                  &amp;lt;/prop&amp;gt;&lt;br /&gt;
              &amp;lt;/node&amp;gt;&lt;br /&gt;
              &amp;lt;node oor:name=&amp;quot;m3&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;prop oor:name=&amp;quot;Command&amp;quot;&amp;gt;&lt;br /&gt;
                      &amp;lt;value&amp;gt;About&amp;lt;/value&amp;gt;&lt;br /&gt;
                  &amp;lt;/prop&amp;gt;&lt;br /&gt;
              &amp;lt;/node&amp;gt;&lt;br /&gt;
              &amp;lt;node oor:name=&amp;quot;m4&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;prop oor:name=&amp;quot;Command&amp;quot;&amp;gt;&lt;br /&gt;
                      &amp;lt;value&amp;gt;Quit&amp;lt;/value&amp;gt;&lt;br /&gt;
                  &amp;lt;/prop&amp;gt;&lt;br /&gt;
              &amp;lt;/node&amp;gt;&lt;br /&gt;
          &amp;lt;/node&amp;gt;&lt;br /&gt;
      &amp;lt;/node&amp;gt;&lt;br /&gt;
  &amp;lt;/oor:component-data&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Disabling Commands at Runtime ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.configuration.ConfigurationUpdateAccess;com.sun.star.configuration.ConfigurationProvider;com.sun.star.util.XChangesBatch&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The following code example first removes all commands that were defined in the user layer of the configuration branch &amp;lt;code&amp;gt;org.openoffice.Office.Commands&amp;lt;/code&amp;gt; as having a defined starting point. Then it checks if it can get dispatch objects for some pre-defined commands.Then the example disables these commands and tries to get dispatch objects for them again. At the end, the code removes the disabled commands again, otherwise {{PRODUCTNAME}} would not be fully usable any longer.&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;
  import com.sun.star.lang.XMultiServiceFactory;&lt;br /&gt;
  import com.sun.star.lang.XSingleServiceFactory;&lt;br /&gt;
  import com.sun.star.util.XURLTransformer;&lt;br /&gt;
  import com.sun.star.frame.XDesktop;&lt;br /&gt;
  &lt;br /&gt;
  import com.sun.star.beans.UnknownPropertyException;&lt;br /&gt;
  &lt;br /&gt;
  /*&lt;br /&gt;
   *  Provides example code how to enable/disable&lt;br /&gt;
   *  commands.&lt;br /&gt;
   */&lt;br /&gt;
  public class DisableCommandsTest extends java.lang.Object {&lt;br /&gt;
  &lt;br /&gt;
      /*&lt;br /&gt;
       *  A list of command names&lt;br /&gt;
       */&lt;br /&gt;
      final static private String[] aCommandURLTestSet =&lt;br /&gt;
      {&lt;br /&gt;
          new String( &amp;quot;Open&amp;quot; ),&lt;br /&gt;
          new String( &amp;quot;About&amp;quot; ),&lt;br /&gt;
          new String( &amp;quot;SelectAll&amp;quot; ),&lt;br /&gt;
          new String( &amp;quot;Quit&amp;quot; ),&lt;br /&gt;
      };&lt;br /&gt;
  &lt;br /&gt;
      private static XComponentContext xRemoteContext = null;&lt;br /&gt;
      private static XMultiComponentFactory xRemoteServiceManager = null;&lt;br /&gt;
      private static XURLTransformer xTransformer = null;&lt;br /&gt;
      private static XMultiServiceFactory xConfigProvider = null;&lt;br /&gt;
      &lt;br /&gt;
      /*&lt;br /&gt;
       *  @param args the command line arguments&lt;br /&gt;
       */&lt;br /&gt;
      public static void main(String[] args) {&lt;br /&gt;
      &lt;br /&gt;
          try {&lt;br /&gt;
              // connect&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;
              Object transformer = xRemoteServiceManager.createInstanceWithContext(&lt;br /&gt;
                  &amp;quot;com.sun.star.util.URLTransformer&amp;quot;, xRemoteContext);&lt;br /&gt;
              xTransformer = (com.sun.star.util.XURLTransformer)UnoRuntime.queryInterface(&lt;br /&gt;
                  com.sun.star.util.XURLTransformer.class, transformer);&lt;br /&gt;
      &lt;br /&gt;
              Object configProvider = xRemoteServiceManager.createInstanceWithContext(&lt;br /&gt;
                  &amp;quot;com.sun.star.configuration.ConfigurationProvider&amp;quot;, xRemoteContext);&lt;br /&gt;
              xConfigProvider = (com.sun.star.lang.XMultiServiceFactory)UnoRuntime.queryInterface(&lt;br /&gt;
                  com.sun.star.lang.XMultiServiceFactory.class, configProvider);&lt;br /&gt;
    &lt;br /&gt;
              // First we need a defined starting point. So we have to remove&lt;br /&gt;
              // all commands from the disabled set!&lt;br /&gt;
              enableCommands();&lt;br /&gt;
  &lt;br /&gt;
              // Check if the commands are usable&lt;br /&gt;
              testCommands(false);&lt;br /&gt;
          &lt;br /&gt;
              // Disable the commands&lt;br /&gt;
              disableCommands();&lt;br /&gt;
          &lt;br /&gt;
              // Now the commands should not be usable anymore&lt;br /&gt;
              testCommands(true);&lt;br /&gt;
  &lt;br /&gt;
              // Remove disable commands to make Office usable again&lt;br /&gt;
              enableCommands();&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;
      /**&lt;br /&gt;
       *  Test the commands that we enabled/disabled&lt;br /&gt;
       */&lt;br /&gt;
      private static void testCommands(boolean bDisabledCmds) throws com.sun.star.uno.Exception {&lt;br /&gt;
          // We need the desktop to get access to the current frame&lt;br /&gt;
          Object desktop = xRemoteServiceManager.createInstanceWithContext(&lt;br /&gt;
              &amp;quot;com.sun.star.frame.Desktop&amp;quot;, xRemoteContext );&lt;br /&gt;
          com.sun.star.frame.XDesktop xDesktop = (com.sun.star.frame.XDesktop)UnoRuntime.queryInterface(&lt;br /&gt;
              com.sun.star.frame.XDesktop.class, desktop);&lt;br /&gt;
          com.sun.star.frame.XFrame xFrame = xDesktop.getCurrentFrame();&lt;br /&gt;
          com.sun.star.frame.XDispatchProvider xDispatchProvider = null;&lt;br /&gt;
          if (xFrame != null) {&lt;br /&gt;
              // We have a frame. Now we need access to the dispatch provider.&lt;br /&gt;
              xDispatchProvider = (com.sun.star.frame.XDispatchProvider)UnoRuntime.queryInterface( &lt;br /&gt;
                  com.sun.star.frame.XDispatchProvider.class, xFrame );&lt;br /&gt;
              if (xDispatchProvider != null) {&lt;br /&gt;
                  // As we have the dispatch provider we can now check if we get a dispatch&lt;br /&gt;
                  // object or not.&lt;br /&gt;
                  for (int n = 0; n &amp;lt; aCommandURLTestSet.length; n++) {&lt;br /&gt;
                      // Prepare the URL&lt;br /&gt;
                      com.sun.star.util.URL[] aURL = new com.sun.star.util.URL[1];&lt;br /&gt;
                      aURL[0] = new com.sun.star.util.URL();&lt;br /&gt;
                      com.sun.star.frame.XDispatch xDispatch = null;&lt;br /&gt;
    &lt;br /&gt;
                      aURL[0].Complete = &amp;quot;.uno:&amp;quot; + aCommandURLTestSet[n];&lt;br /&gt;
                      xTransformer.parseSmart(aURL, &amp;quot;.uno:&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
                      // Try to get a dispatch object for our URL&lt;br /&gt;
                      xDispatch = xDispatchProvider.queryDispatch(aURL[0], &amp;quot;&amp;quot;, 0);&lt;br /&gt;
    &lt;br /&gt;
                      if (xDispatch != null) {&lt;br /&gt;
                          if (bDisabledCmds)&lt;br /&gt;
                              System.out.println(&amp;quot;Something is wrong, I got dispatch object for &amp;quot; &lt;br /&gt;
                                  + aURL[0].Complete);&lt;br /&gt;
                          else&lt;br /&gt;
                              System.out.println(&amp;quot;Ok, dispatch object for &amp;quot; + aURL[0].Complete);&lt;br /&gt;
                      }&lt;br /&gt;
                      else {&lt;br /&gt;
                          if (!bDisabledCmds)&lt;br /&gt;
                              System.out.println(&amp;quot;Something is wrong, I cannot get dispatch   object for &amp;quot; &lt;br /&gt;
                                  + aURL[0].Complete);&lt;br /&gt;
                          else&lt;br /&gt;
                              System.out.println(&amp;quot;Ok, no dispatch object for &amp;quot; + aURL[0].Complete);&lt;br /&gt;
                      }&lt;br /&gt;
                      resetURL(aURL[0]);&lt;br /&gt;
                  }&lt;br /&gt;
              }&lt;br /&gt;
              else&lt;br /&gt;
                  System.out.println(&amp;quot;Couldn&amp;#039;t get XDispatchProvider from Frame!&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else&lt;br /&gt;
              System.out.println(&amp;quot;Couldn&amp;#039;t get current Frame from Desktop!&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
    &lt;br /&gt;
      /**&lt;br /&gt;
       *  Ensure that there are no disabled commands in the user layer. The&lt;br /&gt;
       *  implementation removes all commands from the disabled set!&lt;br /&gt;
       */&lt;br /&gt;
      private static void enableCommands() {&lt;br /&gt;
          // Set the root path for our configuration access&lt;br /&gt;
          com.sun.star.beans.PropertyValue[] lParams = new com.sun.star.beans.PropertyValue[1];&lt;br /&gt;
  &lt;br /&gt;
          lParams[0] = new com.sun.star.beans.PropertyValue();&lt;br /&gt;
          lParams[0].Name = new String(&amp;quot;nodepath&amp;quot;);&lt;br /&gt;
          lParams[0].Value = &amp;quot;/org.openoffice.Office.Commands/Execute/Disabled&amp;quot;;&lt;br /&gt;
      &lt;br /&gt;
          try {&lt;br /&gt;
              // Create configuration update access to have write access to the configuration&lt;br /&gt;
              Object xAccess = xConfigProvider.createInstanceWithArguments( &lt;br /&gt;
&amp;quot;com.sun.star.configuration.ConfigurationUpdateAccess&amp;quot;, lParams);&lt;br /&gt;
  &lt;br /&gt;
              com.sun.star.container.XNameAccess xNameAccess = (com.sun.star.container.XNameAccess)&lt;br /&gt;
              UnoRuntime.queryInterface(com.sun.star.container.XNameAccess.class, xAccess);&lt;br /&gt;
              if (xNameAccess != null) {&lt;br /&gt;
                  // We need the XNameContainer interface to remove the nodes by name&lt;br /&gt;
                  com.sun.star.container.XNameContainer xNameContainer =&lt;br /&gt;
                      (com.sun.star.container.XNameContainer)&lt;br /&gt;
                  UnoRuntime.queryInterface(com.sun.star.container.XNameContainer.class, xAccess);&lt;br /&gt;
    &lt;br /&gt;
                  // Retrieves the names of all Disabled nodes&lt;br /&gt;
                  String[] aCommandsSeq = xNameAccess.getElementNames();&lt;br /&gt;
                  for (int n = 0; n &amp;lt; aCommandsSeq.length; n++) {&lt;br /&gt;
                      try {&lt;br /&gt;
                          // remove the node&lt;br /&gt;
                          xNameContainer.removeByName( aCommandsSeq[n]);&lt;br /&gt;
                      }&lt;br /&gt;
                      catch (com.sun.star.lang.WrappedTargetException e) {&lt;br /&gt;
                      }&lt;br /&gt;
                      catch (com.sun.star.container.NoSuchElementException e) {&lt;br /&gt;
                      }&lt;br /&gt;
                  }&lt;br /&gt;
              } &lt;br /&gt;
    &lt;br /&gt;
              // Commit our changes&lt;br /&gt;
              com.sun.star.util.XChangesBatch xFlush =&lt;br /&gt;
              (com.sun.star.util.XChangesBatch)UnoRuntime.queryInterface(&lt;br /&gt;
                  com.sun.star.util.XChangesBatch.class, xAccess);&lt;br /&gt;
              xFlush.commitChanges();&lt;br /&gt;
          }    &lt;br /&gt;
          catch (com.sun.star.uno.Exception e) {&lt;br /&gt;
              System.out.println(&amp;quot;Exception detected!&amp;quot;);&lt;br /&gt;
              System.out.println(e);&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
    &lt;br /&gt;
      /**&lt;br /&gt;
       *  Disable all commands defined in the aCommandURLTestSet array&lt;br /&gt;
       */&lt;br /&gt;
      private static void disableCommands() {&lt;br /&gt;
      // Set the root path for our configuration access&lt;br /&gt;
      com.sun.star.beans.PropertyValue[] lParams = new com.sun.star.beans.PropertyValue[1];&lt;br /&gt;
      lParams[0] = new com.sun.star.beans.PropertyValue();&lt;br /&gt;
      lParams[0].Name = new String(&amp;quot;nodepath&amp;quot;);&lt;br /&gt;
      lParams[0].Value = &amp;quot;/org.openoffice.Office.Commands/Execute/Disabled&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
      try {&lt;br /&gt;
          // Create configuration update access to have write access to the configuration&lt;br /&gt;
          Object xAccess = xConfigProvider.createInstanceWithArguments( &lt;br /&gt;
          &amp;quot;com.sun.star.configuration.ConfigurationUpdateAccess&amp;quot;, lParams);&lt;br /&gt;
    &lt;br /&gt;
          com.sun.star.lang.XSingleServiceFactory xSetElementFactory = &lt;br /&gt;
          (com.sun.star.lang.XSingleServiceFactory)UnoRuntime.queryInterface(&lt;br /&gt;
              com.sun.star.lang.XSingleServiceFactory.class, xAccess);&lt;br /&gt;
          &lt;br /&gt;
          com.sun.star.container.XNameContainer xNameContainer =&lt;br /&gt;
          (com.sun.star.container.XNameContainer)UnoRuntime.queryInterface(&lt;br /&gt;
              com.sun.star.container.XNameContainer.class, xAccess );&lt;br /&gt;
  &lt;br /&gt;
          if (xSetElementFactory != null &amp;amp;&amp;amp; xNameContainer != null) {&lt;br /&gt;
              Object[] aArgs = new Object[0];&lt;br /&gt;
    &lt;br /&gt;
              for (int i = 0; i &amp;lt; aCommandURLTestSet.length; i++) {&lt;br /&gt;
                  // Create the nodes with the XSingleServiceFactory of the configuration&lt;br /&gt;
                      Object xNewElement = xSetElementFactory.createInstanceWithArguments( aArgs );&lt;br /&gt;
                      if (xNewElement != null) {&lt;br /&gt;
                          // We have a new node. To set the properties of the node we need&lt;br /&gt;
                          // the XPropertySet interface.&lt;br /&gt;
                          com.sun.star.beans.XPropertySet xPropertySet = &lt;br /&gt;
                          (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class,&lt;br /&gt;
                              xNewElement );&lt;br /&gt;
  &lt;br /&gt;
                          if (xPropertySet != null) {&lt;br /&gt;
                              // Create a unique node name.&lt;br /&gt;
                              String aCmdNodeName = new String(&amp;quot;Command-&amp;quot;);&lt;br /&gt;
                              aCmdNodeName += i;&lt;br /&gt;
    &lt;br /&gt;
                              // Insert the node into the Disabled set&lt;br /&gt;
                              xPropertySet.setPropertyValue(&amp;quot;Command&amp;quot;, aCommandURLTestSet[i]);&lt;br /&gt;
                              xNameContainer.insertByName(aCmdNodeName, xNewElement);&lt;br /&gt;
                          }&lt;br /&gt;
                      }&lt;br /&gt;
                  }&lt;br /&gt;
    &lt;br /&gt;
                  // Commit our changes&lt;br /&gt;
                  com.sun.star.util.XChangesBatch xFlush = (com.sun.star.util.XChangesBatch)&lt;br /&gt;
                  UnoRuntime.queryInterface(com.sun.star.util.XChangesBatch.class, xAccess);&lt;br /&gt;
                  xFlush.commitChanges();&lt;br /&gt;
              } &lt;br /&gt;
          }&lt;br /&gt;
          catch (com.sun.star.uno.Exception e) {&lt;br /&gt;
              System.out.println(&amp;quot;Exception detected!&amp;quot;);&lt;br /&gt;
              System.out.println(e);&lt;br /&gt;
          }&lt;br /&gt;
      } &lt;br /&gt;
      &lt;br /&gt;
      /**&lt;br /&gt;
       *  reset URL so it can be reused&lt;br /&gt;
       *&lt;br /&gt;
       *  @param aURL&lt;br /&gt;
       *  the URL that should be reseted&lt;br /&gt;
       */&lt;br /&gt;
      private static void resetURL(com.sun.star.util.URL aURL) {&lt;br /&gt;
          aURL.Protocol = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.User = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Password = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Server = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Port = 0;&lt;br /&gt;
          aURL.Path = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Name = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Arguments = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Mark = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Main = &amp;quot;&amp;quot;;&lt;br /&gt;
          aURL.Complete = &amp;quot;&amp;quot;;&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;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>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Seeing_Changes_in_Result_Sets&amp;diff=79191</id>
		<title>Documentation/DevGuide/Database/Seeing Changes in Result Sets</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Seeing_Changes_in_Result_Sets&amp;diff=79191"/>
		<updated>2008-05-31T15:36:06Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/DatabaseTOC&lt;br /&gt;
|Database2c=block&lt;br /&gt;
|DatabaseResult=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Database/Delete&lt;br /&gt;
|NextPage=Documentation/DevGuide/Database/ResultSetMetaData&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Seeing Changes in Result Sets}}&lt;br /&gt;
When data is modified in a &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; object, the change is always visible immediately. That is, if the same query is re-executed, a new result set is produced based on the data currently in a table. This result set reflects the earlier changes.&lt;br /&gt;
&lt;br /&gt;
If the changes made by you or others are visible while the &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; object is open, is dependent on the DBMS, the driver, and the type of &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; object.&lt;br /&gt;
&lt;br /&gt;
With a &amp;lt;code&amp;gt;SCROLL_SENSITIVE ResultSetType&amp;lt;/code&amp;gt; object, the updates to column values are visible. As well, insertions and deletions are visible, but to ensure this information is returned, use the &amp;lt;idl&amp;gt;com.sun.star.sdbc.XDatabaseMetaData&amp;lt;/idl&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
The amount of visibility for changes can be regulated by raising or lowering the transaction isolation level for the connection with the database. For example, the following line of code, where con is an active &amp;lt;code&amp;gt;Connection&amp;lt;/code&amp;gt; object, sets the connection&amp;#039;s isolation level to &amp;lt;code&amp;gt;READ_COMMITTED&amp;lt;/code&amp;gt;: &lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  con.setTransactionIsolation(TransactionIsolation.READ_COMMITTED);&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
With this isolation level, the &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; object does not show changes before they are committed, but it shows changes that may have other consistency problems. To allow fewer data inconsistencies, raise the transaction isolation level to &amp;lt;code&amp;gt;REPEATABLE_READ&amp;lt;/code&amp;gt;. Note that the higher the isolation level, the poorer the performance. The database and driver also limited what is actually provided. Many programmers use their database&amp;#039;s default transaction isolation level. Consult the DBMS manual for more information about transaction isolation levels.&lt;br /&gt;
&lt;br /&gt;
In a &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; object that is &amp;lt;code&amp;gt;SCROLL_INSENSITIVE&amp;lt;/code&amp;gt;, changes are not visible while it is still open. Some programmers only use this type of &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; object to get a consistent view of the data without seeing changes made by others.&lt;br /&gt;
&lt;br /&gt;
The method &amp;lt;code&amp;gt;refreshRow()&amp;lt;/code&amp;gt; is used to get the latest values for a row straight from the database. This method is time consuming, especially if the DBMS returns multiple rows &amp;lt;code&amp;gt;refreshRow()&amp;lt;/code&amp;gt; is called. The method &amp;lt;code&amp;gt;refreshRow()&amp;lt;/code&amp;gt; can be valuable if it is critical to have the latest data. Even when a result set is sensitive and changes are visible, an application may not always see the latest changes that have been made to a row if the driver retrieves several rows at a time and caches them. Thus, using the method &amp;lt;code&amp;gt;refreshRow()&amp;lt;/code&amp;gt; ensures that only up-to-date data is visible.&lt;br /&gt;
&lt;br /&gt;
The following code sample illustrates how an application might use the method &amp;lt;code&amp;gt;refreshRow()&amp;lt;/code&amp;gt; when it is critical to see the latest changes. Note that the result set should be sensitive. If the method &amp;lt;code&amp;gt;refreshRow()&amp;lt;/code&amp;gt; with a &amp;lt;code&amp;gt;SCROLL_INSENSITIVE ResultSet&amp;lt;/code&amp;gt; is used, &amp;lt;code&amp;gt;refreshRow()&amp;lt;/code&amp;gt; does nothing. Getting the latest data for the table &amp;lt;code&amp;gt;SALES&amp;lt;/code&amp;gt; is not realistic with these methods. A more realistic scenario is when an airline reservation clerk needs to ensure that the seat he is about to reserve is still available. &lt;br /&gt;
&amp;lt;!--[SOURCE:Database/Sales.java]--&amp;gt;&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  XStatement stmt = con.createStatement();&lt;br /&gt;
  &lt;br /&gt;
  XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, stmt);&lt;br /&gt;
  xProp.setPropertyValue(&amp;quot;ResultSetType&amp;quot;,new java.lang.Integer(ResultSetType.SCROLL_SENSITIVE));&lt;br /&gt;
  xProp.setPropertyValue(&amp;quot;ResultSetConcurrency&amp;quot;, new java.lang.Integer(ResultSetConcurrency.READ_ONLY));&lt;br /&gt;
  &lt;br /&gt;
  XResultSet rs = stmt.executeQuery(&amp;quot;SELECT NAME, PRICE FROM SALES&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
  XRow row = (XRow)UnoRuntime.queryInterface(XRow.class, rs);&lt;br /&gt;
  &lt;br /&gt;
  rs.absolute(4);&lt;br /&gt;
  &lt;br /&gt;
  float price1 = row.getFloat(2);&lt;br /&gt;
  // do something ...&lt;br /&gt;
  rs.absolute(4);&lt;br /&gt;
  rs.refreshRow();&lt;br /&gt;
  float price2 = row.getFloat(2);&lt;br /&gt;
  if (price2 != price1) {&lt;br /&gt;
      // do something ...&lt;br /&gt;
  }&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
[[Category: Database Access]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Delete&amp;diff=79190</id>
		<title>Documentation/DevGuide/Database/Delete</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Delete&amp;diff=79190"/>
		<updated>2008-05-31T15:34:58Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/DatabaseTOC&lt;br /&gt;
|Database2c=block&lt;br /&gt;
|DatabaseResult=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Database/Insert&lt;br /&gt;
|NextPage=Documentation/DevGuide/Database/Seeing Changes in Result Sets&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Delete}}&lt;br /&gt;
In the previous sections, how to update a column and insert a new row was explained. This section discusses how to modify the &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; object by deleting a row. The method &amp;lt;code&amp;gt;deleteRow()&amp;lt;/code&amp;gt; is called to delete the row where the cursor is placed. For example, to delete the fourth row in the &amp;lt;code&amp;gt;ResultSet rs&amp;lt;/code&amp;gt;, the code looks like this: &lt;br /&gt;
&amp;lt;!--[SOURCE:Database/Sales.java]--&amp;gt;&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  rs.absolute(4);&lt;br /&gt;
  &lt;br /&gt;
  XResultSetUpdate updateRs = (XResultSetUpdate)UnoRuntime.queryInterface(XResultSetUpdate.class, rs);&lt;br /&gt;
  updateRs.deleteRow();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The fourth row is removed from &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt; and also from the database.&lt;br /&gt;
&lt;br /&gt;
The only issue about deletions is what the &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; object does when it deletes a row. With some SDBC drivers, a deleted row is removed and no longer visible in a result set. Other SDBC drivers use a blank row as a placeholder (a &amp;quot;hole&amp;quot;) where the deleted row used to be. If there is a blank row in place of the deleted row, the method &amp;lt;code&amp;gt;absolute()&amp;lt;/code&amp;gt; can be used with the original row positions to move the cursor, because the row numbers in the result set are not changed by the deletion.&lt;br /&gt;
&lt;br /&gt;
Remember that different SDBC drivers handle deletions differently. For example, if an application is meant to run with different databases, the code should not depends on holes in a result set.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
[[Category: Database Access]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Insert&amp;diff=79189</id>
		<title>Documentation/DevGuide/Database/Insert</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Insert&amp;diff=79189"/>
		<updated>2008-05-31T15:34:15Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/DatabaseTOC&lt;br /&gt;
|Database2c=block&lt;br /&gt;
|DatabaseResult=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Database/Update&lt;br /&gt;
|NextPage=Documentation/DevGuide/Database/Delete&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Insert}}&lt;br /&gt;
The previous section described how to modify a column value using methods in the SDBC API, rather than SQL commands. With the SDBC API, a new row can also be inserted into a table or an existing row deleted programmatically.&lt;br /&gt;
&lt;br /&gt;
Suppose our salesman Bob sold a new product to one of our customers, FTOP Darjeeling tea, and we need to add the new sale to the database. Using the previous example, write code that passes an SQL insert statement to the DBMS. The following code fragment, in which &amp;lt;code&amp;gt;stmt&amp;lt;/code&amp;gt; is a &amp;lt;code&amp;gt;Statement&amp;lt;/code&amp;gt; object, shows this approach: &lt;br /&gt;
&amp;lt;!--[SOURCE:Database/Sales.java]--&amp;gt;&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  stmt.executeUpdate(&amp;quot;INSERT INTO SALES &amp;quot; +&lt;br /&gt;
      &amp;quot;VALUES (4, 102, 5, &amp;#039;FTOP Darjeeling tea&amp;#039;, &amp;#039;2002-01-02&amp;#039;,150)&amp;quot;);&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The same thing can be done, without using any SQL commands, by using &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; methods in the SDBC API. After a &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; object is obtained with the results from the table &amp;lt;code&amp;gt;SALES&amp;lt;/code&amp;gt;, build the new row and then insert it into the result set and the table &amp;lt;code&amp;gt;SALES&amp;lt;/code&amp;gt; in one step. First, build a new row in the insert row, a special row associated with every &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; object. This row is not part of the result set. It can be considered as a separate buffer in which a new row is composed prior to insertion.&lt;br /&gt;
&lt;br /&gt;
The next step is to move the cursor to the insert row by invoking the method &amp;lt;code&amp;gt;moveToInsertRow()&amp;lt;/code&amp;gt;. Then set a value for each column in the row that should not be null by calling the appropriate &amp;lt;code&amp;gt;updateXXX()&amp;lt;/code&amp;gt; method for each value. Note that these are the same &amp;lt;code&amp;gt;updateXXX()&amp;lt;/code&amp;gt; methods used to change a column value in the previous section. &lt;br /&gt;
&lt;br /&gt;
Finally, call &amp;lt;code&amp;gt;insertRow()&amp;lt;/code&amp;gt; to insert the row that was populated with values into the result set. This method simultaneously inserts the row into the &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; object, as well as the database table from where the result set was selected.&lt;br /&gt;
&lt;br /&gt;
The following code fragment creates a scrollable and modifiable &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; object rs that contains all of the rows and columns in the table &amp;lt;code&amp;gt;SALES&amp;lt;/code&amp;gt;: &lt;br /&gt;
&amp;lt;!--[SOURCE:Database/Sales.java]--&amp;gt;&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  XConnection con = XDriverManager.getConnection(&amp;quot;jdbc:mySubprotocol:mySubName&amp;quot;);&lt;br /&gt;
  XStatement stmt = con.createStatement();&lt;br /&gt;
  &lt;br /&gt;
  XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, stmt);&lt;br /&gt;
  xProp.setPropertyValue(&amp;quot;ResultSetType&amp;quot;, new java.lang.Integer(ResultSetType.SCROLL_INSENSITIVE));&lt;br /&gt;
  xProp.setPropertyValue(&amp;quot;ResultSetConcurrency&amp;quot;, new java.lang.Integer(ResultSetConcurrency.UPDATABLE));&lt;br /&gt;
  &lt;br /&gt;
  XResultSet rs = stmt.executeQuery(&amp;quot;SELECT * FROM SALES&amp;quot;);&lt;br /&gt;
  XRow row = (XRow)UnoRuntime.queryInterface(XRow.class, rs);&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The next code fragment uses the &amp;lt;code&amp;gt;XResultSetUpdate&amp;lt;/code&amp;gt; interface of &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt; to insert the row for FTOP Darjeeling tea, shown in the SQL code example. It moves the cursor to the insert row, sets the six column values, and inserts the new row into &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SALES&amp;lt;/code&amp;gt;: &lt;br /&gt;
&amp;lt;!--[SOURCE:Database/Sales.java]--&amp;gt;&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  XRowUpdate updateRow = (XRowUpdate)UnoRuntime.queryInterface(XRowUpdate.class, rs);&lt;br /&gt;
  XResultSetUpdate updateRs = (XResultSetUpdate)UnoRuntime.queryInterface(XResultSetUpdate.class, rs);&lt;br /&gt;
  &lt;br /&gt;
  updateRs.moveToInsertRow();&lt;br /&gt;
  &lt;br /&gt;
  updateRow.updateInt(1, 4);&lt;br /&gt;
  updateRow.updateInt(2, 102);&lt;br /&gt;
  updateRow.updateInt(3, 5);&lt;br /&gt;
  updateRow.updateString(4, &amp;quot;FTOP Darjeeling tea&amp;quot;);&lt;br /&gt;
  updateRow.updateDate(5, new Date((short)1, (short)2, (short)2002));&lt;br /&gt;
  updateRow.updateFloat(6, 150);&lt;br /&gt;
  &lt;br /&gt;
  updateRs.insertRow();&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The &amp;lt;code&amp;gt;updateXXX()&amp;lt;/code&amp;gt; methods behave differently from the way they behaved in the update examples. In those examples, the value set with an &amp;lt;code&amp;gt;updateXXX()&amp;lt;/code&amp;gt; method immediately replaced the column value in the result set, because the cursor was on a row in the result set. When the cursor is on the insert row, the value set with an &amp;lt;code&amp;gt;updateXXX()&amp;lt;/code&amp;gt; method is immediately set, but it is set in the insert row rather than in the result set itself. &lt;br /&gt;
&lt;br /&gt;
In updates and insertions, calling an &amp;lt;code&amp;gt;updateXXX()&amp;lt;/code&amp;gt; method does not affect the underlying database table. The method &amp;lt;code&amp;gt;updateRow()&amp;lt;/code&amp;gt; must be called to have updates occur in the database. For insertions, the method &amp;lt;code&amp;gt;insertRow()&amp;lt;/code&amp;gt; inserts the new row into the result set and the database at the same time.&lt;br /&gt;
&lt;br /&gt;
If a value is not supplied for a column that was defined to accept SQL &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt; values, then the value assigned to that column is &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt;. If a column does not accept null values, an &amp;lt;code&amp;gt;SQLException&amp;lt;/code&amp;gt; is returned when an &amp;lt;code&amp;gt;updateXXX()&amp;lt;/code&amp;gt; method is not called to set a value for it. This is also true if a table column is missing in the &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; object. In the example above, the query was &amp;lt;code&amp;gt;SELECT * FROM SALES&amp;lt;/code&amp;gt;, which produced a result set with all the columns of all the rows. To insert one or more rows, the query does not have to select all rows, but it is advisable to select all columns. Additionally if the table has many rows, use a &amp;lt;code&amp;gt;WHERE&amp;lt;/code&amp;gt; clause to limit the number of rows returned by the &amp;lt;code&amp;gt;SELECT&amp;lt;/code&amp;gt; statement.&lt;br /&gt;
&lt;br /&gt;
After the method &amp;lt;code&amp;gt;insertRow()&amp;lt;/code&amp;gt; is called, start building another insert row, or move the cursor back to a result set row. Any of the methods can be executed that move the cursor to a specific row, such as &amp;lt;code&amp;gt;first()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;last()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beforeFirst()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;afterLast()&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;absolute()&amp;lt;/code&amp;gt;. The methods &amp;lt;code&amp;gt;previous()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;relative()&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;moveToCurrentRow()&amp;lt;/code&amp;gt; can also be used. Note that only &amp;lt;code&amp;gt;moveToCurrentRow()&amp;lt;/code&amp;gt; can be invoked as long as the cursor is on the insert row. &lt;br /&gt;
&lt;br /&gt;
When the method &amp;lt;code&amp;gt;moveToInsertRow()&amp;lt;/code&amp;gt; is called, the result set records which row the cursor is in, that is by definition the current row. As a consequence, the method &amp;lt;code&amp;gt;moveToCurrentRow()&amp;lt;/code&amp;gt; can move the cursor from the insert row back to the row that was the current row previously. This also explains why the methods &amp;lt;code&amp;gt;previous()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;relative()&amp;lt;/code&amp;gt; can be used, because require movement relative to the current row.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
[[Category: Database Access]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Update&amp;diff=79188</id>
		<title>Documentation/DevGuide/Database/Update</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Update&amp;diff=79188"/>
		<updated>2008-05-31T15:31:54Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/DatabaseTOC&lt;br /&gt;
|Database2c=block&lt;br /&gt;
|DatabaseResult=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Database/Modifiable Result Sets&lt;br /&gt;
|NextPage=Documentation/DevGuide/Database/Insert&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Update}}&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.sdbc.XRowUpdate&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
An update is the modification of a column value in the current row. Suppose the price of orange juice is lowered to 0.99. Using the example above, the update would look like this:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  stmt.executeUpdate(&amp;quot;UPDATE SALES SET PRICE = 0.99&amp;quot; +&lt;br /&gt;
      &amp;quot;WHERE SALENR = 4&amp;quot;);&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The following code fragment shows another way to accomplish the same update, this time using SDBC: &lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  rs.last();&lt;br /&gt;
  XRowUpdate updateRow = (XRowUpdate)UnoRuntime.queryInterface(XRowUpdate.class, rs);&lt;br /&gt;
  updateRow.updateFloat(2, (float)0.99);&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
Update operations in the SDBC API affect column values in the row where the cursor is positioned. In the first line, the &amp;lt;code&amp;gt;ResultSet rs&amp;lt;/code&amp;gt; calls &amp;lt;code&amp;gt;last()&amp;lt;/code&amp;gt; to move the cursor to the last row where the column &amp;lt;code&amp;gt;NAME&amp;lt;/code&amp;gt; has the value &amp;lt;code&amp;gt;Orange juice&amp;lt;/code&amp;gt;. Once the cursor is on the last row, all of the update methods that are called operate on that row until the cursor is moved to another row. &lt;br /&gt;
&lt;br /&gt;
The second line changes the value of the &amp;lt;code&amp;gt;PRICE&amp;lt;/code&amp;gt; column to 0.99 by calling &amp;lt;code&amp;gt;updateFloat()&amp;lt;/code&amp;gt;. This method is used because the column value we want to update is a float in Java programming language.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;updateXXX()&amp;lt;/code&amp;gt; methods in &amp;lt;idl&amp;gt;com.sun.star.sdbc.XRowUpdate&amp;lt;/idl&amp;gt; take two parameters: the number of the column to update and the new column value. There are specialized &amp;lt;code&amp;gt;updateXXX()&amp;lt;/code&amp;gt; methods for each data type, such as &amp;lt;code&amp;gt;updateString()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;updateInt()&amp;lt;/code&amp;gt;, just like the &amp;lt;code&amp;gt;getXXX&amp;lt;/code&amp;gt; methods discussed above.&lt;br /&gt;
&lt;br /&gt;
At this point, the price in &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt; for Orange juice is 0.99, but the price in the table &amp;lt;code&amp;gt;SALES&amp;lt;/code&amp;gt; in the database is still 1.50. To ensure the update takes effect in the database and not just the result set, the &amp;lt;idl&amp;gt;com.sun.star.sdbc.XResultSetUpdate&amp;lt;/idl&amp;gt; method &amp;lt;code&amp;gt;updateRow()&amp;lt;/code&amp;gt; is called. Here is what the code should look like to update &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SALES&amp;lt;/code&amp;gt;: &lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  rs.last();&lt;br /&gt;
  &lt;br /&gt;
  XRowUpdate updateRow = (XRowUpdate)UnoRuntime.queryInterface(XRowUpdate.class, rs);&lt;br /&gt;
  updateRow.updateFloat(2, (float)0.99);&lt;br /&gt;
  XResultSetUpdate updateRs = (XResultSetUpdate)UnoRuntime.queryInterface(XResultSetUpdate.class, rs);&lt;br /&gt;
  &lt;br /&gt;
  // update the data in DBMS&lt;br /&gt;
  updateRs.updateRow();&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
If the cursor is moved to a different row before calling &amp;lt;code&amp;gt;updateRow()&amp;lt;/code&amp;gt;, the update is lost. The update can be canceled by calling &amp;lt;code&amp;gt;cancelRowUpdates()&amp;lt;/code&amp;gt;, for instance, the price should have been 0.79 instead of 0.99. The &amp;lt;code&amp;gt;cancelRowUpdates()&amp;lt;/code&amp;gt; has to be invoked before invoking &amp;lt;code&amp;gt;updateRow()&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt;cancelRowUpdates()&amp;lt;/code&amp;gt; does nothing when &amp;lt;code&amp;gt;updateRow()&amp;lt;/code&amp;gt; has been called. Note that &amp;lt;code&amp;gt;cancelRowUpdates&amp;lt;/code&amp;gt; cancels all the updates in a row, that is, if there were more than one &amp;lt;code&amp;gt;updateXXX&amp;lt;/code&amp;gt; method in the row, they are all canceled. The following code fragment cancels the update to the price column to 0.99, and then updates it to 0.79: &lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  rs.last();&lt;br /&gt;
  &lt;br /&gt;
  updateRow.updateFloat(2, (float)0.99);&lt;br /&gt;
  updateRs.cancelRowUpdates();&lt;br /&gt;
  updateRow.updateFloat(2, (float)0.79);&lt;br /&gt;
  updateRs.updateRow();&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
In the above example, only one column value is updated, but an appropriate &amp;lt;code&amp;gt;updateXXX()&amp;lt;/code&amp;gt; method can be called for any or all of the column values in a single row. Updates and related operations apply to the row where the cursor is positioned. Even if there are many calls to updateXXX methods, it takes only one call to the method &amp;lt;code&amp;gt;updateRow()&amp;lt;/code&amp;gt; to update the database with all changes made in the current row.&lt;br /&gt;
&lt;br /&gt;
To update the price for beef as well, move the cursor to the row containing that product. The row for beef immediately precedes the row for orange juice, so the method &amp;lt;code&amp;gt;previous()&amp;lt;/code&amp;gt; can be called to position the cursor on the row for Beef. The following code fragment changes the price in that row to 10.79 in the result set and underlying table in the database: &lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  rs.previous();&lt;br /&gt;
  &lt;br /&gt;
  updateRow.updateFloat(2, (float)10.79);&lt;br /&gt;
  updateRs.updateRow();&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
All cursor movements refer to rows in a &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; object, not to rows in the underlying database. If a query selects five rows from a database table, there are five rows in the result set with the first row being row 1, the second row being row 2, and so on. Row 1 can also be identified as the first row, and in a result set with five rows, row 5 is the last.&lt;br /&gt;
&lt;br /&gt;
The order of the rows in the result set has nothing to do with the physical order of the rows in the underlying table. In fact, the order of the rows in a database table is indeterminate. The DBMS keeps track of which rows were selected, and it makes updates to the proper rows, but they may be located anywhere in the table physically. When a row is inserted, there is no way to know where in the table it was inserted.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
[[Category: Database Access]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Modifiable_Result_Sets&amp;diff=79187</id>
		<title>Documentation/DevGuide/Database/Modifiable Result Sets</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Modifiable_Result_Sets&amp;diff=79187"/>
		<updated>2008-05-31T15:30:05Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/DatabaseTOC&lt;br /&gt;
|Database2c=block&lt;br /&gt;
|DatabaseResult=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Database/Scrollable Result Sets&lt;br /&gt;
|NextPage=Documentation/DevGuide/Database/Update&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Modifiable Result Sets}}&lt;br /&gt;
Another feature of SDBC is the ability to update rows in a result set using methods in the programming language, rather than sending an SQL command. Before doing this, a modifiable result set must be created. To create a modifiable result set, supply the &amp;lt;code&amp;gt;ResultSetConcurrency&amp;lt;/code&amp;gt; constant &amp;lt;code&amp;gt;UPDATABLE&amp;lt;/code&amp;gt; to the &amp;lt;code&amp;gt;Statement&amp;lt;/code&amp;gt; property &amp;lt;code&amp;gt;ResultSetConcurrency&amp;lt;/code&amp;gt;, so that the &amp;lt;code&amp;gt;Statement&amp;lt;/code&amp;gt; object creates an modifiable &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; object each time it executes a query. &lt;br /&gt;
&lt;br /&gt;
The following code fragment creates a modifiable &amp;lt;code&amp;gt;XResultSet&amp;lt;/code&amp;gt; object &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt;. Note that the code also makes &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt; scrollable. A modifiable &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; object does not have to be scrollable, but when changes are made to a result set, the user may want to move around in it. With a scrollable result set, there is the ability to move to particular rows that you can work with. If the type is &amp;lt;code&amp;gt;SCROLL_SENSITIVE&amp;lt;/code&amp;gt;, the new value in a row can be obtained after it has changed without refreshing the whole result set.&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  XStatement stmt = con.createStatement();&lt;br /&gt;
  &lt;br /&gt;
  XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, stmt);&lt;br /&gt;
  xProp.setPropertyValue(&amp;quot;ResultSetType&amp;quot;, new java.lang.Integer(ResultSetType.SCROLL_INSENSITIVE));&lt;br /&gt;
  xProp.setPropertyValue(&amp;quot;ResultSetConcurrency&amp;quot;, new java.lang.Integer(ResultSetConcurrency.UPDATABLE));&lt;br /&gt;
  &lt;br /&gt;
  XResultSet rs = stmt.executeQuery(&amp;quot;SELECT NAME, PRICE FROM SALES&amp;quot;);&lt;br /&gt;
  XRow row = (XRow)UnoRuntime.queryInterface(XRow.class, rs);&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; object rs may look similar to this:&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;
!NAME &lt;br /&gt;
!PRICE &lt;br /&gt;
|-&lt;br /&gt;
|Linux &lt;br /&gt;
|$30.00 &lt;br /&gt;
|-&lt;br /&gt;
|Beef &lt;br /&gt;
|$15.78 &lt;br /&gt;
|-&lt;br /&gt;
|Orange juice &lt;br /&gt;
|$1.50 &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The methods can now be used in the &amp;lt;idl&amp;gt;com.sun.star.sdbc.XRowUpdate&amp;lt;/idl&amp;gt; interface of the result set to insert a new row into &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt;, delete an existing row from &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt;, or modify a column value in &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
[[Category: Database Access]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Scrollable_Result_Sets&amp;diff=79186</id>
		<title>Documentation/DevGuide/Database/Scrollable Result Sets</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Scrollable_Result_Sets&amp;diff=79186"/>
		<updated>2008-05-31T15:29:23Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/DatabaseTOC&lt;br /&gt;
|Database2c=block&lt;br /&gt;
|DatabaseResult=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Database/Using the getXXX Methods&lt;br /&gt;
|NextPage=Documentation/DevGuide/Database/Modifiable Result Sets&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Scrollable Result Sets}}&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.sdbc.XResultSet&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The interface &amp;lt;idl&amp;gt;com.sun.star.sdbc.XResultSet&amp;lt;/idl&amp;gt; offers methods to move the cursor back and forth to an arbitrary row, and get the current position of the cursor. Scrollable result sets are necessary to create GUI tools that can browse result sets. It also may be required to move a specific row to work with it. Before taking advantage of these features, create a scrollable &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; object. The following lines of code illustrate one way to create a scrollable &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; object:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  XStatement xStatement = xConnection.createStatement();&lt;br /&gt;
  XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xStatement);&lt;br /&gt;
  &lt;br /&gt;
  xProp.setPropertyValue(&amp;quot;ResultSetType&amp;quot;,new java.lang.Integer(ResultSetType.SCROLL_INSENSITIVE));&lt;br /&gt;
  xProp.setPropertyValue(&amp;quot;ResultSetConcurrency&amp;quot;, new java.lang.Integer(ResultSetConcurrency.UPDATABLE));&lt;br /&gt;
  &lt;br /&gt;
  XResultSet xResult = xStatement.executeQuery(&amp;quot;SELECT FIRSTNAME, LASTNAME FROM SALES&amp;quot;);&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
This code is similar to what was used earlier, except that it sets two property values at the &amp;lt;code&amp;gt;Statementobject&amp;lt;/code&amp;gt;. These properties have to be set before the statement is executed.&lt;br /&gt;
&lt;br /&gt;
The value of the property &amp;lt;code&amp;gt;ResultSetType&amp;lt;/code&amp;gt; must be one of three constants defined in &amp;lt;idl&amp;gt;com.sun.star.sdbc.ResultSetType&amp;lt;/idl&amp;gt;: &amp;lt;code&amp;gt;FORWARD_ONLY&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;SCROLL_INSENSITIVE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SCROLL_SENSITIVE&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The property &amp;lt;code&amp;gt;ResultSetConcurrency&amp;lt;/code&amp;gt; must be one out of the two &amp;lt;idl&amp;gt;com.sun.star.sdbc.ResultSetConcurrency&amp;lt;/idl&amp;gt; constants &amp;lt;code&amp;gt;READ_ONLY&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;UPDATABLE&amp;lt;/code&amp;gt;. When a &amp;lt;code&amp;gt;ResultSetType&amp;lt;/code&amp;gt; is specified, it must be specified if it is read-only or modifiable.&lt;br /&gt;
&lt;br /&gt;
If any constants for the type and modifiability of a &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; object are not specified, &amp;lt;code&amp;gt;FORWARD_ONLY&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;READ_ONLY&amp;lt;/code&amp;gt; will automatically be created.&lt;br /&gt;
&lt;br /&gt;
Specifying the constant &amp;lt;code&amp;gt;FORWARD_ONLY&amp;lt;/code&amp;gt; creates a non-scrollable result set, that is, the cursor moves forward only. A scrollable &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; is obtained by specifying &amp;lt;code&amp;gt;SCROLL_INSENSITIVE&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;SCROLL_SENSITIVE&amp;lt;/code&amp;gt;. Sensitive or insensitive refers to changes made to the underlying data after the result set has been opened. A &amp;lt;code&amp;gt;SCROLL_INSENSITIVE&amp;lt;/code&amp;gt; result set does not reflect changes to the underlying data, while a &amp;lt;code&amp;gt;SCROLL_SENSITIVE&amp;lt;/code&amp;gt; result set shows changes. However, not all drivers and databases support change sensitivity.&lt;br /&gt;
&lt;br /&gt;
In scrollable result sets, the counterpart to &amp;lt;code&amp;gt;next()&amp;lt;/code&amp;gt; is the method &amp;lt;code&amp;gt;previous()&amp;lt;/code&amp;gt;, which moves the cursor backward. Both methods return false when the cursor goes to the position after the last row or before the first row. This allows them to be used in a while loop.&lt;br /&gt;
&lt;br /&gt;
The following two examples show the usage of &amp;lt;code&amp;gt;next()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;previous()&amp;lt;/code&amp;gt; together with while: &lt;br /&gt;
&amp;lt;!--[SOURCE:Database/Sales.java]--&amp;gt;&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  XStatement stmt = con.createStatement();&lt;br /&gt;
  &lt;br /&gt;
  XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, stmt);&lt;br /&gt;
  xProp.setPropertyValue(&amp;quot;ResultSetType&amp;quot;,new java.lang.Integer(ResultSetType.SCROLL_INSENSITIVE));&lt;br /&gt;
  xProp.setPropertyValue(&amp;quot;ResultSetConcurrency&amp;quot;, new java.lang.Integer(ResultSetConcurrency.READ_ONLY));&lt;br /&gt;
  &lt;br /&gt;
  XResultSet srs = stmt.executeQuery(&amp;quot;SELECT NAME, PRICE FROM SALES&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
  XRow row = (XRow)UnoRuntime.queryInterface(XRow.class, srs);&lt;br /&gt;
  &lt;br /&gt;
  while (srs.next()) {&lt;br /&gt;
      String name = row.getString(1);&lt;br /&gt;
      float price = row.getFloat(2);&lt;br /&gt;
      System.out.println(name + &amp;quot; &amp;quot; + price);&lt;br /&gt;
  }&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The printout will look similar to this:&lt;br /&gt;
&lt;br /&gt;
  Linux           32&lt;br /&gt;
  Beef            15.78&lt;br /&gt;
  Orange juice    1.50&lt;br /&gt;
&lt;br /&gt;
To process the rows going backward, the cursor must start out after the last row. The cursor is moved to the position after the last row with the method &amp;lt;code&amp;gt;afterLast()&amp;lt;/code&amp;gt;. Then &amp;lt;code&amp;gt;previous()&amp;lt;/code&amp;gt; moves the cursor from the position after the last row to the last row, and then up to the first row with each iteration through the while loop. The loop ends when the cursor reaches the position before the first row, where &amp;lt;code&amp;gt;previous()&amp;lt;/code&amp;gt; returns false. &lt;br /&gt;
&amp;lt;!--[SOURCE:Database/Sales.java]--&amp;gt;&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  XStatement stmt = con.createStatement();&lt;br /&gt;
  &lt;br /&gt;
  XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,stmt);&lt;br /&gt;
  xProp.setPropertyValue(&amp;quot;ResultSetType&amp;quot;, new java.lang.Integer(ResultSetType.SCROLL_INSENSITIVE));&lt;br /&gt;
  xProp.setPropertyValue(&amp;quot;ResultSetConcurrency&amp;quot;, new java.lang.Integer(ResultSetConcurrency.READ_ONLY));&lt;br /&gt;
  &lt;br /&gt;
  XResultSet srs = stmt.executeQuery(&amp;quot;SELECT NAME, PRICE FROM SALES&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
  XRow row = (XRow)UnoRuntime.queryInterface(XRow.class, srs);&lt;br /&gt;
  &lt;br /&gt;
  srs.afterLast();&lt;br /&gt;
  while (srs.previous()) {&lt;br /&gt;
      String name = row.getString(1);&lt;br /&gt;
      float price = row.getFloat(2);&lt;br /&gt;
      System.out.println(name + &amp;quot; &amp;quot; + price);&lt;br /&gt;
  }&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The printout will look similar to this:&lt;br /&gt;
&lt;br /&gt;
  Orange juice    1.50&lt;br /&gt;
  Beef            15.78&lt;br /&gt;
  Linux           32&lt;br /&gt;
&lt;br /&gt;
The column values are the same, but the rows are in the reverse order.&lt;br /&gt;
&lt;br /&gt;
The cursor can be moved to a specific row in a ResultSet object. The methods &amp;lt;code&amp;gt;first()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;last()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beforeFirst()&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;afterLast()&amp;lt;/code&amp;gt; move the cursor to the row indicated by the method names.&lt;br /&gt;
&lt;br /&gt;
The method &amp;lt;code&amp;gt;absolute()&amp;lt;/code&amp;gt; moves the cursor to the row number indicated in the argument passed. If the number is positive, the cursor moves the given number from the beginning. Calling &amp;lt;code&amp;gt;absolute(1)&amp;lt;/code&amp;gt; moves the cursor to the first row. If the number is negative, the cursor moves the given number of rows from the end. Calling &amp;lt;code&amp;gt;absolute(-1)&amp;lt;/code&amp;gt; sets the cursor to the last row. The following line of code moves the cursor to the fourth row of srs:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  srs.absolute(4);&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
If srs has 500 rows, the following line of code moves the cursor to row 497:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  srs.absolute(-4);&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The method &amp;lt;code&amp;gt;relative()&amp;lt;/code&amp;gt; moves the cursor by an arbitrary number of rows from the current row. A positive number moves the cursor forward, and a negative number moves the cursor backwards. For example, in the following code fragment, the cursor moves to the fourth row, then to the first row, and finally to the third row:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  srs.absolute(4); // cursor is on the fourth row&lt;br /&gt;
  ... &lt;br /&gt;
  srs.relative(-3); // cursor is on the first row&lt;br /&gt;
  ... &lt;br /&gt;
  srs.relative(2); // cursor is on the third row&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The method &amp;lt;code&amp;gt;getRow()&amp;lt;/code&amp;gt; returns the number of the current row. For example, use &amp;lt;code&amp;gt;getRow()&amp;lt;/code&amp;gt; to verify the current position of the cursor in the previous example using the following code: &lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  srs.absolute(4); &lt;br /&gt;
  int rowNum = srs.getRow(); // rowNum should be 4&lt;br /&gt;
  srs.relative(-3); &lt;br /&gt;
  rowNum = srs.getRow(); // rowNum should be 1&lt;br /&gt;
  srs.relative(2); &lt;br /&gt;
  rowNum = srs.getRow(); // rowNum should be 3&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
Note that some drivers do not support the getRow method. They always return 0.&lt;br /&gt;
&lt;br /&gt;
There are four methods to verify if the cursor is at a particular position. The position is stated in their names: &amp;lt;code&amp;gt;isFirst()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;isLast()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;isBeforeFirst()&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;isAfterLast()&amp;lt;/code&amp;gt;. These methods return a boolean that can be used in a conditional statement. For example, the following code fragment tests if the cursor is after the last row before invoking the method &amp;lt;code&amp;gt;previous()&amp;lt;/code&amp;gt; in a while loop. If the method &amp;lt;code&amp;gt;isAfterLast()&amp;lt;/code&amp;gt; returns false, the cursor is not after the last row, so the method afterLast can be invoked. This guarantees that the cursor is after the last row and that using the method &amp;lt;code&amp;gt;previous()&amp;lt;/code&amp;gt; in the while loop stop at every row in srs.&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  if (srs.isAfterLast() == false) {&lt;br /&gt;
      srs.afterLast(); &lt;br /&gt;
  }&lt;br /&gt;
  while (srs.previous()) {&lt;br /&gt;
      String name = row.getString(1);&lt;br /&gt;
      float price = row.getFloat(2);&lt;br /&gt;
      System.out.println(name + &amp;quot; &amp;quot; + price);&lt;br /&gt;
  }&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
How to use the two methods from the &amp;lt;code&amp;gt;XResultSetUpdate&amp;lt;/code&amp;gt; interface to move the cursor: &amp;lt;code&amp;gt;moveToInsertRow()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;moveToCurrentRow()&amp;lt;/code&amp;gt; are discussed in the next section. There are examples illustrating why moving the cursor to certain positions may be required.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
[[Category: Database Access]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Using_the_getXXX_Methods&amp;diff=79185</id>
		<title>Documentation/DevGuide/Database/Using the getXXX Methods</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Using_the_getXXX_Methods&amp;diff=79185"/>
		<updated>2008-05-31T15:25:02Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/DatabaseTOC&lt;br /&gt;
|Database2c=block&lt;br /&gt;
|DatabaseResult=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Database/Moving the Result Set Cursor&lt;br /&gt;
|NextPage=Documentation/DevGuide/Database/Scrollable Result Sets&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Using the getXXX Methods}}&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.sdbc.XRow&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
To get column values from the current row, use the interface &amp;lt;idl&amp;gt;com.sun.star.sdbc.XRow&amp;lt;/idl&amp;gt;. It offers a large number of get methods for all SDBC data types, or rather getXXX methods. The XXX stands for the type retrieved by the method.&lt;br /&gt;
&lt;br /&gt;
Usually, the getXXX method is used for the appropriate type to retrieve the value in each column. For example, the first column in each row of &amp;lt;code&amp;gt;xResult&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;FIRSTNAME&amp;lt;/code&amp;gt;. It is the first column and contains a value of SQL type &amp;lt;code&amp;gt;VARCHAR&amp;lt;/code&amp;gt;. The appropriate method to retrieve a &amp;lt;code&amp;gt;VARCHAR&amp;lt;/code&amp;gt; value is &amp;lt;code&amp;gt;getString()&amp;lt;/code&amp;gt;. It should be used for the second column, as well. The third column &amp;lt;code&amp;gt;BIRTHDATE&amp;lt;/code&amp;gt; stores DATE values, the method for date types is &amp;lt;code&amp;gt;getDate()&amp;lt;/code&amp;gt;. SDBC is flexible and allows a number of type conversions through getXXX. See the table below for details.&lt;br /&gt;
&lt;br /&gt;
The following code accesses the values stored in the current row of &amp;lt;code&amp;gt;xResult&amp;lt;/code&amp;gt; and prints a line with the column values separated by tabs. Each time &amp;lt;code&amp;gt;next()&amp;lt;/code&amp;gt; is invoked, the next row becomes the current row, and the loop continues until there are no more rows in &amp;lt;code&amp;gt;xResult&amp;lt;/code&amp;gt;. &lt;br /&gt;
&amp;lt;!--[SOURCE:Database/SalesMan.java]--&amp;gt;&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  public static void selectSalespersons(XMultiServiceFactory _rMSF) throws com.sun.star.uno.Exception {&lt;br /&gt;
      // retrieve the DatabaseContext and get its com.sun.star.container.XNameAccess interface&lt;br /&gt;
      XNameAccess xNameAccess = (XNameAccess)UnoRuntime.queryInterface(&lt;br /&gt;
          XNameAccess.class, _rMSF.createInstance(&amp;quot;com.sun.star.sdb.DatabaseContext&amp;quot;));&lt;br /&gt;
      &lt;br /&gt;
      //connect&lt;br /&gt;
      Object dataSource = xNameAccess.getByName(&amp;quot;Ada01&amp;quot;);&lt;br /&gt;
      XDataSource xDataSource = (XDataSource)UnoRuntime.queryInterface(XDataSource.class, dataSource);&lt;br /&gt;
      Object interactionHandler = _rMSF.createInstance(&amp;quot;com.sun.star.sdb.InteractionHandler&amp;quot;);&lt;br /&gt;
      XInteractionHandler xInteractionHandler = (XInteractionHandler)UnoRuntime.queryInterface(&lt;br /&gt;
          XInteractionHandler.class, interactionHandler);&lt;br /&gt;
      XCompletedConnection xCompletedConnection = (XCompletedConnection)UnoRuntime.queryInterface(&lt;br /&gt;
          XCompletedConnection.class, dataSource);&lt;br /&gt;
      XConnection xConnection = xCompletedConnection.connectWithCompletion(xInteractionHandler);&lt;br /&gt;
      &lt;br /&gt;
      // create statement and execute query&lt;br /&gt;
      XStatement xStatement = xConnection.createStatement();&lt;br /&gt;
      XResultSet xResult = xStatement.executeQuery(&amp;quot;SELECT FIRSTNAME, LASTNAME, BIRTHDATE FROM SALESMAN&amp;quot;);&lt;br /&gt;
      &lt;br /&gt;
      // process result&lt;br /&gt;
      XRow xRow = (XRow)UnoRuntime.queryInterface(XRow.class, xResult);&lt;br /&gt;
      while (xResult != null &amp;amp;&amp;amp; xResult.next()) {&lt;br /&gt;
          String firstName = xRow.getString(1);&lt;br /&gt;
          String lastName = xRow.getString(2);&lt;br /&gt;
          com.sun.star.util.Date birthDate = xRow.getDate(3);&lt;br /&gt;
          System.out.println(firstName + &amp;quot;\t&amp;quot; + lastName + &amp;quot;\t\t&amp;quot; +&lt;br /&gt;
              birthDate.Month + &amp;quot;/&amp;quot; + birthDate.Day + &amp;quot;/&amp;quot; + birthDate.Year);&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The output looks like this:&lt;br /&gt;
&lt;br /&gt;
  Joseph    Smith        7/2/1946&lt;br /&gt;
  Frank     Jones        12/24/1963&lt;br /&gt;
  Jane      Esperanza    4/1/1972&lt;br /&gt;
  George    Flint        2/13/1953&lt;br /&gt;
  Bob       Meyers       9/7/1949&lt;br /&gt;
&lt;br /&gt;
In this code, how the &amp;lt;code&amp;gt;getXXX&amp;lt;/code&amp;gt; methods work are shown and the two &amp;lt;code&amp;gt;getXXX&amp;lt;/code&amp;gt; calls are examined. &lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  String firstName = xRow.getString(1);&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The method &amp;lt;code&amp;gt;getString()&amp;lt;/code&amp;gt; is invoked on &amp;lt;code&amp;gt;xRow&amp;lt;/code&amp;gt;, that is, &amp;lt;code&amp;gt;getString()&amp;lt;/code&amp;gt; gets the value stored in column no. 1 in the current row of &amp;lt;code&amp;gt;xResult&amp;lt;/code&amp;gt;, which is &amp;lt;code&amp;gt;FIRSTNAME&amp;lt;/code&amp;gt;. The value retrieved by &amp;lt;code&amp;gt;getString()&amp;lt;/code&amp;gt; has been converted from a &amp;lt;code&amp;gt;VARCHAR&amp;lt;/code&amp;gt; to a &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; in the Java programming language, and assigned to the &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; object &amp;lt;code&amp;gt;firstname&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
The situation is similar with the method &amp;lt;code&amp;gt;getDate()&amp;lt;/code&amp;gt;. It retrieves the value stored in column no. 3 (BIRTHDATE), which is an SQL &amp;lt;code&amp;gt;DATE&amp;lt;/code&amp;gt;, and converts it to a &amp;lt;idl&amp;gt;com.sun.star.util.Date&amp;lt;/idl&amp;gt; before assigning it to the variable &amp;lt;code&amp;gt;birthDate&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that the column number refers to the column number in the result set, not in the original table.&lt;br /&gt;
&lt;br /&gt;
SDBC is flexible as to which &amp;lt;code&amp;gt;getXXX&amp;lt;/code&amp;gt; methods can be used to retrieve the various SQL types. For example, the method &amp;lt;code&amp;gt;getInt()&amp;lt;/code&amp;gt; can be used to retrieve any of the numeric or character types. The data it retrieves is converted to an int; that is, if the SQL type is &amp;lt;code&amp;gt;VARCHAR&amp;lt;/code&amp;gt;, SDBC attempts to parse an integer out of the &amp;lt;code&amp;gt;VARCHAR&amp;lt;/code&amp;gt;. To be sure that no information is lost, the method &amp;lt;code&amp;gt;getInt()&amp;lt;/code&amp;gt; is only recommended for SQL &amp;lt;code&amp;gt;INTEGER&amp;lt;/code&amp;gt; types, and it cannot be used for the SQL types &amp;lt;code&amp;gt;BINARY&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;VARBINARY&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;LONGVARBINARY&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;DATE&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TIME&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;TIMESTAMP&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Although &amp;lt;code&amp;gt;getString()&amp;lt;/code&amp;gt; is recommended for the SQL types &amp;lt;code&amp;gt;CHAR&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;VARCHAR&amp;lt;/code&amp;gt;, it is possible to retrieve any of the basic SQL types with it. The new SQL3 data types can not be retrieved with it. Getting values with &amp;lt;code&amp;gt;getString()&amp;lt;/code&amp;gt; can be useful, but has its limitations. For instance, if it is used to retrieve a numeric type, &amp;lt;code&amp;gt;getString()&amp;lt;/code&amp;gt; converts the numeric value to a Java String object, and the value has to be converted back to a numeric type before it can be used for numeric operations. &lt;br /&gt;
&lt;br /&gt;
The value will be treated as a string, so if an application is to retrieve and display arbitrary column values of any standard SQL type other than SQL3 types, use &amp;lt;code&amp;gt;getString()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The illustration below shows all &amp;lt;code&amp;gt;getXXX()&amp;lt;/code&amp;gt; methods and the corresponding SDBC data types defined in &amp;lt;idl&amp;gt;com.sun.star.sdbc.DataType&amp;lt;/idl&amp;gt;. The illustration above shows which methods can legally be used to retrieve SQL types, and which methods are recommended for retrieving the various SQL types. &lt;br /&gt;
&lt;br /&gt;
[[Image:DataTypesGetXXX.png|none|thumb|500px|Methods to Retrieve SQL Types]]&lt;br /&gt;
&lt;br /&gt;
* x with grey background indicates that the &amp;lt;code&amp;gt;getXXX()&amp;lt;/code&amp;gt; method is the recommended method to retrieve an SDBC data type. No data will be lost due to type conversion.&lt;br /&gt;
* x indicates that the &amp;lt;code&amp;gt;getXXX()&amp;lt;/code&amp;gt; method may legally be used to retrieve the given SDBC type. However, type conversion will take place and affect the values you obtain.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
[[Category: Database Access]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Moving_the_Result_Set_Cursor&amp;diff=79183</id>
		<title>Documentation/DevGuide/Database/Moving the Result Set Cursor</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Moving_the_Result_Set_Cursor&amp;diff=79183"/>
		<updated>2008-05-31T15:23:36Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/DatabaseTOC&lt;br /&gt;
|Database2c=block&lt;br /&gt;
|DatabaseResult=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Database/Retrieving Values from Result Sets&lt;br /&gt;
|NextPage=Documentation/DevGuide/Database/Using the getXXX Methods&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Moving the Result Set Cursor}}&lt;br /&gt;
The &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; stored in the variable &amp;lt;code&amp;gt;xResult&amp;lt;/code&amp;gt; contains the following data after the call above:&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;
!FIRSTNAME &lt;br /&gt;
!LASTNAME &lt;br /&gt;
!BIRTHDATE &lt;br /&gt;
|-&lt;br /&gt;
|Joseph &lt;br /&gt;
|Smith &lt;br /&gt;
|02/07/46 &lt;br /&gt;
|-&lt;br /&gt;
|Bob &lt;br /&gt;
|Meyers &lt;br /&gt;
|09/07/49 &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To access the data, go to each row and retrieve the values according to their types. The method &amp;lt;code&amp;gt;next()&amp;lt;/code&amp;gt; is used to move the row cursor from row to row. Since the cursor is initially positioned just above the first row of a &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; object, the first call to &amp;lt;code&amp;gt;next()&amp;lt;/code&amp;gt; moves the cursor to the first row and makes it the current row. For the same reason, use the method &amp;lt;code&amp;gt;next()&amp;lt;/code&amp;gt; to access the first row even if there is only one row in a result set. Subsequent invocations of &amp;lt;code&amp;gt;next()&amp;lt;/code&amp;gt; move the cursor down one row at a time.&lt;br /&gt;
&lt;br /&gt;
The interface &amp;lt;idl&amp;gt;com.sun.star.sdbc.XResultSet&amp;lt;/idl&amp;gt; offers methods to move to specific row numbers, and to positions relative to the current row, in addition to moving the cursor back and forth one row at a time:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  // move one row at a time&lt;br /&gt;
  boolean next()&lt;br /&gt;
  boolean previous()&lt;br /&gt;
  &lt;br /&gt;
  // move a number of rows&lt;br /&gt;
  boolean absolute( [in] long row )&lt;br /&gt;
  boolean relative( [in] long rows )&lt;br /&gt;
  &lt;br /&gt;
  // move to result set borders and beyond&lt;br /&gt;
  boolean first()&lt;br /&gt;
  boolean last()&lt;br /&gt;
  void beforeFirst()&lt;br /&gt;
  void afterLast()&lt;br /&gt;
  &lt;br /&gt;
  //detect position&lt;br /&gt;
  boolean isBeforeFirst()&lt;br /&gt;
  boolean isAfterLast()&lt;br /&gt;
  boolean isFirst()&lt;br /&gt;
  boolean isLast()&lt;br /&gt;
  long getRow()&lt;br /&gt;
  &lt;br /&gt;
  // refetch row from the database&lt;br /&gt;
  void refreshRow()&lt;br /&gt;
  &lt;br /&gt;
  // row has been updated, inserted or deleted&lt;br /&gt;
  boolean rowUpdated()&lt;br /&gt;
  boolean rowInserted()&lt;br /&gt;
  boolean rowDeleted()&lt;br /&gt;
  &lt;br /&gt;
  // get the statement which created the result set&lt;br /&gt;
  com::sun::star::uno::XInterface getStatement()&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
{{Documentation/Note|Note that you can only move the cursor backwards if you set the statement property &amp;lt;tt&amp;gt;ResultSetType&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;SCROLL_INSENSITIVE&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;SCROLL_SENSITIVE&amp;lt;/tt&amp;gt;. For details, refer to chapter [[Documentation/DevGuide/Database/Scrollable Result Sets|Scrollable Result Sets]].}}&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
[[Category: Database Access]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Retrieving_Values_from_Result_Sets&amp;diff=79182</id>
		<title>Documentation/DevGuide/Database/Retrieving Values from Result Sets</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Retrieving_Values_from_Result_Sets&amp;diff=79182"/>
		<updated>2008-05-31T15:22:24Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/DatabaseTOC&lt;br /&gt;
|Database2c=block&lt;br /&gt;
|DatabaseResult=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Database/Result Sets&lt;br /&gt;
|NextPage=Documentation/DevGuide/Database/Moving the Result Set Cursor&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Retrieving Values from Result Sets}}&lt;br /&gt;
A call to &amp;lt;code&amp;gt;execute()&amp;lt;/code&amp;gt; on a &amp;lt;idl&amp;gt;com.sun.star.sdb.RowSet&amp;lt;/idl&amp;gt; or a call to &amp;lt;code&amp;gt;executeQuery()&amp;lt;/code&amp;gt; on a Statement produces a &amp;lt;idl&amp;gt;com.sun.star.sdb.ResultSet&amp;lt;/idl&amp;gt;. &lt;br /&gt;
&amp;lt;!--[SOURCE:Database/Sales.java]--&amp;gt;&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  com.sun.star.sdbc.XResultSet xResult = xStatement.executeQuery(&amp;quot;SELECT FIRSTNAME, LASTNAME, STREET &amp;quot; + &lt;br /&gt;
      &amp;quot;FROM SALESMAN &amp;quot; + &lt;br /&gt;
      &amp;quot;VWHERE BIRTHDATE &amp;lt; &amp;#039;1950-01-01&amp;#039;&amp;quot;);&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
[[Category: Database Access]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Inserting_and_Updating_Data&amp;diff=79181</id>
		<title>Documentation/DevGuide/Database/Inserting and Updating Data</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Inserting_and_Updating_Data&amp;diff=79181"/>
		<updated>2008-05-31T15:18:58Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/DatabaseTOC&lt;br /&gt;
|Database2c=block&lt;br /&gt;
|DatabaseStmt=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Database/Creating Statements&lt;br /&gt;
|NextPage=Documentation/DevGuide/Database/Getting Data from a Table&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Inserting and Updating Data}}&lt;br /&gt;
The following examples use a sample Adabas D database. Generate an Adabas D database in the {{PRODUCTNAME}} API installation and define a new table named SALESMAN. &lt;br /&gt;
&lt;br /&gt;
[[Image:SalesmanDefinition.png|none|thumb|400px|SALESMAN Table Design]]&lt;br /&gt;
&lt;br /&gt;
The illustration above shows the definition of the SALESMAN table in the {{PRODUCTNAME}} API data source administrator. The description column shows the lengths defined for the text fields of the table. After all the fields are defined, right-click the row header of the column SNR and choose &amp;#039;&amp;#039;&amp;#039;Primary Key&amp;#039;&amp;#039;&amp;#039; to make SNR the primary key. Afterwards a small key icon in the row header shows that SNR is the primary key of the table SALESMAN. When completed, save the table as SALESMAN. It is important to use uppercase letters for the table name, otherwise the example SQL code will not work.&lt;br /&gt;
&lt;br /&gt;
The table does not contain any data. Use the following &amp;lt;code&amp;gt;INSERT&amp;lt;/code&amp;gt; command to insert data into the table one row at a time:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
  INSERT INTO SALESMAN (&lt;br /&gt;
    SNR,&lt;br /&gt;
    FIRSTNAME,&lt;br /&gt;
    LASTNAME,&lt;br /&gt;
    STREET,&lt;br /&gt;
    STATE,&lt;br /&gt;
    ZIP,&lt;br /&gt;
    BIRTHDATE&lt;br /&gt;
    )&lt;br /&gt;
  VALUES (&lt;br /&gt;
    1, &lt;br /&gt;
    &amp;#039;Joseph&amp;#039;, &lt;br /&gt;
    &amp;#039;Smith&amp;#039;,&lt;br /&gt;
    &amp;#039;Bond Street&amp;#039;,&lt;br /&gt;
    &amp;#039;CA&amp;#039;,&lt;br /&gt;
    &amp;#039;95460&amp;#039;,&lt;br /&gt;
    &amp;#039;1946-07-02&amp;#039;&lt;br /&gt;
    )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|Note the single quotes around the values for the text fields. Single quotes denote character strings in SQL, while double quotes are used for case-sensitive identifiers,such as table and column names.}}&lt;br /&gt;
&lt;br /&gt;
The following code sample inserts one row of data with the value &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; in the column &amp;lt;code&amp;gt;SNR&amp;lt;/code&amp;gt;, &amp;#039;&amp;lt;code&amp;gt;Joseph&amp;lt;/code&amp;gt;&amp;#039; in &amp;lt;code&amp;gt;FIRSTNAME&amp;lt;/code&amp;gt;, &amp;#039;&amp;lt;code&amp;gt;Smith&amp;lt;/code&amp;gt;&amp;#039; in &amp;lt;code&amp;gt;LASTNAME&amp;lt;/code&amp;gt;, with other information in the following columns of the table SALESMAN. To issue the command against the database, create a &amp;lt;code&amp;gt;Statement&amp;lt;/code&amp;gt; object and then execute it using the method &amp;lt;code&amp;gt;executeUpdate()&amp;lt;/code&amp;gt;:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  XStatement xStatement = xConnection.createStatement();&lt;br /&gt;
  &lt;br /&gt;
  xStatement.executeUpdate(&amp;quot;INSERT INTO SALESMAN (&amp;quot; + &lt;br /&gt;
      &amp;quot;SNR, FIRSTNAME, LASTNAME, STREET, STATE, ZIP, BIRTHDATE) &amp;quot; + &lt;br /&gt;
      &amp;quot;VALUES (1, &amp;#039;Joseph&amp;#039;, &amp;#039;Smith&amp;#039;,&amp;#039;Bond Street&amp;#039;,&amp;#039;CA&amp;#039;,&amp;#039;95460&amp;#039;,&amp;#039;1946-07-02&amp;#039;)&amp;quot;);&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The next call to &amp;lt;code&amp;gt;executeUpdate()&amp;lt;/code&amp;gt; inserts more rows into the table &amp;lt;code&amp;gt;SALESMAN&amp;lt;/code&amp;gt;. Note the Statement object &amp;lt;code&amp;gt;stmt&amp;lt;/code&amp;gt; is reused, rather than creating a new one for each update.&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  xStatement.executeUpdate(&amp;quot;INSERT INTO SALESMAN (&amp;quot; + &lt;br /&gt;
      &amp;quot;SNR, FIRSTNAME, LASTNAME, STREET, STATE, ZIP, BIRTHDATE) &amp;quot; + &lt;br /&gt;
      &amp;quot;VALUES (2, &amp;#039;Frank&amp;#039;, &amp;#039;Jones&amp;#039;, &amp;#039;Lake Silver&amp;#039;, &amp;#039;CA&amp;#039;, &amp;#039;95460&amp;#039;, &amp;#039;1963-12-24&amp;#039;)&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
  xStatement.executeUpdate(&amp;quot;INSERT INTO SALESMAN (&amp;quot; + &lt;br /&gt;
      &amp;quot;SNR, FIRSTNAME, LASTNAME, STREET, STATE, ZIP, BIRTHDATE) &amp;quot; + &lt;br /&gt;
      &amp;quot;VALUES (3, &amp;#039;Jane&amp;#039;, &amp;#039;Esperanza&amp;#039;, &amp;#039;23 Hollywood drive&amp;#039;, &amp;#039;CA&amp;#039;, &amp;#039;95460&amp;#039;, &amp;#039;1972-01-04&amp;#039;)&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
  xStatement.executeUpdate(&amp;quot;INSERT INTO SALESMAN (&amp;quot; + &lt;br /&gt;
      &amp;quot;SNR, FIRSTNAME, LASTNAME, STREET, STATE, ZIP, BIRTHDATE) &amp;quot; + &lt;br /&gt;
      &amp;quot;VALUES (4, &amp;#039;George&amp;#039;, &amp;#039;Flint&amp;#039;, &amp;#039;12 Washington street&amp;#039;, &amp;#039;CA&amp;#039;, &amp;#039;95460&amp;#039;, &amp;#039;1953-02-13&amp;#039;)&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
  xStatement.executeUpdate(&amp;quot;INSERT INTO SALESMAN (&amp;quot; + &lt;br /&gt;
      &amp;quot;SNR, FIRSTNAME, LASTNAME, STREET, STATE, ZIP, BIRTHDATE) &amp;quot; + &lt;br /&gt;
      &amp;quot;VALUES (5, &amp;#039;Bob&amp;#039;, &amp;#039;Meyers&amp;#039;, &amp;#039;2 Moon way&amp;#039;, &amp;#039;CA&amp;#039;, &amp;#039;95460&amp;#039;, &amp;#039;1949-09-07&amp;#039;)&amp;quot;);&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
Updating tables is basically the same process. The SQL command:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
  UPDATE SALESMAN&lt;br /&gt;
  SET STREET=&amp;#039;Grant Street&amp;#039;, STATE=&amp;#039;FL&amp;#039;&lt;br /&gt;
  WHERE SNR=2&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
writes a new street and state entry for Frank Jones who has SNR=2. The corresponding &amp;lt;code&amp;gt;executeUpdate()&amp;lt;/code&amp;gt; call looks like this:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  int n = xStatement.executeUpdate(&amp;quot;UPDATE SALESMAN &amp;quot; + &lt;br /&gt;
      &amp;quot;SET STREET=&amp;#039;Grant Street&amp;#039;, STATE=&amp;#039;FL&amp;#039; &amp;quot; + &lt;br /&gt;
      &amp;quot;WHERE SNR=2&amp;quot;);&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The return value of &amp;lt;code&amp;gt;executeUpdate()&amp;lt;/code&amp;gt; is an int that indicates how many rows of a table were updated. Our update command affected one row, so n is equal to 1. &lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|Note that it depends on the database and the driver,if the return value of &amp;lt;tt&amp;gt;executeUpdate()&amp;lt;/tt&amp;gt; reflects the actual changes.}}&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
[[Category: Database Access]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Getting_Data_from_a_Table&amp;diff=79180</id>
		<title>Documentation/DevGuide/Database/Getting Data from a Table</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Getting_Data_from_a_Table&amp;diff=79180"/>
		<updated>2008-05-31T15:18:08Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/DatabaseTOC&lt;br /&gt;
|Database2c=block&lt;br /&gt;
|DatabaseStmt=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Database/Inserting and Updating Data&lt;br /&gt;
|NextPage=Documentation/DevGuide/Database/Result Sets&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Getting Data from a Table}}&lt;br /&gt;
Now that the table &amp;lt;code&amp;gt;SALESMAN&amp;lt;/code&amp;gt; has values in it, write a &amp;lt;code&amp;gt;SELECT&amp;lt;/code&amp;gt; statement to access those values. The asterisk &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; in the following SQL statement indicates that all columns should be selected. Since there is no &amp;lt;code&amp;gt;WHERE&amp;lt;/code&amp;gt; clause to select less rows, the following SQL statement selects the whole table:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
  SELECT * FROM SALESMAN&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The result contains the following data:&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;
!SNR &lt;br /&gt;
!FIRSTNAME &lt;br /&gt;
!LASTNAME &lt;br /&gt;
!STREET &lt;br /&gt;
!STATE &lt;br /&gt;
!ZIP &lt;br /&gt;
!BIRTHDATE &lt;br /&gt;
|-&lt;br /&gt;
|1 &lt;br /&gt;
|Joseph &lt;br /&gt;
|Smith &lt;br /&gt;
|Bond Street &lt;br /&gt;
|CA &lt;br /&gt;
|95460 &lt;br /&gt;
|02/07/46 &lt;br /&gt;
|-&lt;br /&gt;
|2 &lt;br /&gt;
|Frank &lt;br /&gt;
|Jones &lt;br /&gt;
|Lake silver &lt;br /&gt;
|CA &lt;br /&gt;
|95460 &lt;br /&gt;
|12/24/63 &lt;br /&gt;
|-&lt;br /&gt;
|3 &lt;br /&gt;
|Jane &lt;br /&gt;
|Esperanza &lt;br /&gt;
|23 Hollywood drive &lt;br /&gt;
|CA &lt;br /&gt;
|95460 &lt;br /&gt;
|04/01/72 &lt;br /&gt;
|-&lt;br /&gt;
|4 &lt;br /&gt;
|George &lt;br /&gt;
|Flint &lt;br /&gt;
|12 Washington street &lt;br /&gt;
|CA &lt;br /&gt;
|95460 &lt;br /&gt;
|02/13/53 &lt;br /&gt;
|-&lt;br /&gt;
|5 &lt;br /&gt;
|Bob &lt;br /&gt;
|Meyers &lt;br /&gt;
|2 Moon way &lt;br /&gt;
|CA &lt;br /&gt;
|95460 &lt;br /&gt;
|09/07/49 &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following is another example of a &amp;lt;code&amp;gt;SELECT&amp;lt;/code&amp;gt; statement. This statement gets a list with the names and addresses of all the salespersons. Only the columns &amp;lt;code&amp;gt;FIRSTNAME&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;LASTNAME&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;STREET&amp;lt;/code&amp;gt; were selected.&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
  SELECT FIRSTNAME, LASTNAME, STREET FROM SALESMAN&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The result of this query only contains three columns:&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;
!FIRSTNAME &lt;br /&gt;
!LASTNAME &lt;br /&gt;
!STREET &lt;br /&gt;
|-&lt;br /&gt;
|Joseph &lt;br /&gt;
|Smith &lt;br /&gt;
|Bond Street &lt;br /&gt;
|-&lt;br /&gt;
|Frank &lt;br /&gt;
|Jones &lt;br /&gt;
|Lake silver &lt;br /&gt;
|-&lt;br /&gt;
|Jane &lt;br /&gt;
|Esperansa &lt;br /&gt;
|23 Hollywood drive &lt;br /&gt;
|-&lt;br /&gt;
|George &lt;br /&gt;
|Flint &lt;br /&gt;
|12 Washington street &lt;br /&gt;
|-&lt;br /&gt;
|Bob &lt;br /&gt;
|Meyers &lt;br /&gt;
|2 Moon way &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SELECT&amp;lt;/code&amp;gt; statement above extracts all salespersons in the table. The following SQL statement limits the SALESMAN &amp;lt;code&amp;gt;SELECT&amp;lt;/code&amp;gt; to salespersons who were born before 01/01/1950: &lt;br /&gt;
 &amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
  SELECT FIRSTNAME, LASTNAME, BIRTHDATE&lt;br /&gt;
  FROM SALESMAN&lt;br /&gt;
  WHERE BIRTHDATE &amp;lt; &amp;#039;1950-01-01&amp;#039;&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The resulting data is:&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;
!FIRSTNAME &lt;br /&gt;
!LASTNAME &lt;br /&gt;
!BIRTHDATE &lt;br /&gt;
|-&lt;br /&gt;
|Joseph &lt;br /&gt;
|Smith &lt;br /&gt;
|02/07/46 &lt;br /&gt;
|-&lt;br /&gt;
|Bob &lt;br /&gt;
|Meyers &lt;br /&gt;
|09/07/49 &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
When a database is accessed through the {{PRODUCTNAME}} API database integration, the results are retrieved through &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; objects. The next section discusses how to use result sets. The following &amp;lt;code&amp;gt;executeQuery()&amp;lt;/code&amp;gt; call executes the SQL command above. Note that the Statement is used again: &lt;br /&gt;
&amp;lt;!--[SOURCE:Database/Sales.java]--&amp;gt;&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  com.sun.star.sdbc.XResultSet xResult = xStatement.executeQuery(&amp;quot;SELECT FIRSTNAME, LASTNAME, BIRTHDATE &amp;quot; + &lt;br /&gt;
      &amp;quot;FROM SALESMAN &amp;quot; + &lt;br /&gt;
      &amp;quot;WHERE BIRTHDATE &amp;lt; &amp;#039;1950-01-01&amp;#039;&amp;quot;);&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
[[Category: Database Access]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Inserting_and_Updating_Data&amp;diff=79179</id>
		<title>Documentation/DevGuide/Database/Inserting and Updating Data</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Inserting_and_Updating_Data&amp;diff=79179"/>
		<updated>2008-05-31T15:15:17Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/DatabaseTOC&lt;br /&gt;
|Database2c=block&lt;br /&gt;
|DatabaseStmt=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Database/Creating Statements&lt;br /&gt;
|NextPage=Documentation/DevGuide/Database/Getting Data from a Table&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Inserting and }}&lt;br /&gt;
The following examples use a sample Adabas D database. Generate an Adabas D database in the {{PRODUCTNAME}} API installation and define a new table named SALESMAN. &lt;br /&gt;
&lt;br /&gt;
[[Image:SalesmanDefinition.png|none|thumb|400px|SALESMAN Table Design]]&lt;br /&gt;
&lt;br /&gt;
The illustration above shows the definition of the SALESMAN table in the {{PRODUCTNAME}} API data source administrator. The description column shows the lengths defined for the text fields of the table. After all the fields are defined, right-click the row header of the column SNR and choose &amp;#039;&amp;#039;&amp;#039;Primary Key&amp;#039;&amp;#039;&amp;#039; to make SNR the primary key. Afterwards a small key icon in the row header shows that SNR is the primary key of the table SALESMAN. When completed, save the table as SALESMAN. It is important to use uppercase letters for the table name, otherwise the example SQL code will not work.&lt;br /&gt;
&lt;br /&gt;
The table does not contain any data. Use the following &amp;lt;code&amp;gt;INSERT&amp;lt;/code&amp;gt; command to insert data into the table one row at a time:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
  INSERT INTO SALESMAN (&lt;br /&gt;
    SNR,&lt;br /&gt;
    FIRSTNAME,&lt;br /&gt;
    LASTNAME,&lt;br /&gt;
    STREET,&lt;br /&gt;
    STATE,&lt;br /&gt;
    ZIP,&lt;br /&gt;
    BIRTHDATE&lt;br /&gt;
    )&lt;br /&gt;
  VALUES (&lt;br /&gt;
    1, &lt;br /&gt;
    &amp;#039;Joseph&amp;#039;, &lt;br /&gt;
    &amp;#039;Smith&amp;#039;,&lt;br /&gt;
    &amp;#039;Bond Street&amp;#039;,&lt;br /&gt;
    &amp;#039;CA&amp;#039;,&lt;br /&gt;
    &amp;#039;95460&amp;#039;,&lt;br /&gt;
    &amp;#039;1946-07-02&amp;#039;&lt;br /&gt;
    )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|Note the single quotes around the values for the text fields. Single quotes denote character strings in SQL, while double quotes are used for case-sensitive identifiers,such as table and column names.}}&lt;br /&gt;
&lt;br /&gt;
The following code sample inserts one row of data with the value &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; in the column &amp;lt;code&amp;gt;SNR&amp;lt;/code&amp;gt;, &amp;#039;&amp;lt;code&amp;gt;Joseph&amp;lt;/code&amp;gt;&amp;#039; in &amp;lt;code&amp;gt;FIRSTNAME&amp;lt;/code&amp;gt;, &amp;#039;&amp;lt;code&amp;gt;Smith&amp;lt;/code&amp;gt;&amp;#039; in &amp;lt;code&amp;gt;LASTNAME&amp;lt;/code&amp;gt;, with other information in the following columns of the table SALESMAN. To issue the command against the database, create a &amp;lt;code&amp;gt;Statement&amp;lt;/code&amp;gt; object and then execute it using the method &amp;lt;code&amp;gt;executeUpdate()&amp;lt;/code&amp;gt;:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  XStatement xStatement = xConnection.createStatement();&lt;br /&gt;
  &lt;br /&gt;
  xStatement.executeUpdate(&amp;quot;INSERT INTO SALESMAN (&amp;quot; + &lt;br /&gt;
      &amp;quot;SNR, FIRSTNAME, LASTNAME, STREET, STATE, ZIP, BIRTHDATE) &amp;quot; + &lt;br /&gt;
      &amp;quot;VALUES (1, &amp;#039;Joseph&amp;#039;, &amp;#039;Smith&amp;#039;,&amp;#039;Bond Street&amp;#039;,&amp;#039;CA&amp;#039;,&amp;#039;95460&amp;#039;,&amp;#039;1946-07-02&amp;#039;)&amp;quot;);&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The next call to &amp;lt;code&amp;gt;executeUpdate()&amp;lt;/code&amp;gt; inserts more rows into the table &amp;lt;code&amp;gt;SALESMAN&amp;lt;/code&amp;gt;. Note the Statement object &amp;lt;code&amp;gt;stmt&amp;lt;/code&amp;gt; is reused, rather than creating a new one for each update.&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  xStatement.executeUpdate(&amp;quot;INSERT INTO SALESMAN (&amp;quot; + &lt;br /&gt;
      &amp;quot;SNR, FIRSTNAME, LASTNAME, STREET, STATE, ZIP, BIRTHDATE) &amp;quot; + &lt;br /&gt;
      &amp;quot;VALUES (2, &amp;#039;Frank&amp;#039;, &amp;#039;Jones&amp;#039;, &amp;#039;Lake Silver&amp;#039;, &amp;#039;CA&amp;#039;, &amp;#039;95460&amp;#039;, &amp;#039;1963-12-24&amp;#039;)&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
  xStatement.executeUpdate(&amp;quot;INSERT INTO SALESMAN (&amp;quot; + &lt;br /&gt;
      &amp;quot;SNR, FIRSTNAME, LASTNAME, STREET, STATE, ZIP, BIRTHDATE) &amp;quot; + &lt;br /&gt;
      &amp;quot;VALUES (3, &amp;#039;Jane&amp;#039;, &amp;#039;Esperanza&amp;#039;, &amp;#039;23 Hollywood drive&amp;#039;, &amp;#039;CA&amp;#039;, &amp;#039;95460&amp;#039;, &amp;#039;1972-01-04&amp;#039;)&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
  xStatement.executeUpdate(&amp;quot;INSERT INTO SALESMAN (&amp;quot; + &lt;br /&gt;
      &amp;quot;SNR, FIRSTNAME, LASTNAME, STREET, STATE, ZIP, BIRTHDATE) &amp;quot; + &lt;br /&gt;
      &amp;quot;VALUES (4, &amp;#039;George&amp;#039;, &amp;#039;Flint&amp;#039;, &amp;#039;12 Washington street&amp;#039;, &amp;#039;CA&amp;#039;, &amp;#039;95460&amp;#039;, &amp;#039;1953-02-13&amp;#039;)&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
  xStatement.executeUpdate(&amp;quot;INSERT INTO SALESMAN (&amp;quot; + &lt;br /&gt;
      &amp;quot;SNR, FIRSTNAME, LASTNAME, STREET, STATE, ZIP, BIRTHDATE) &amp;quot; + &lt;br /&gt;
      &amp;quot;VALUES (5, &amp;#039;Bob&amp;#039;, &amp;#039;Meyers&amp;#039;, &amp;#039;2 Moon way&amp;#039;, &amp;#039;CA&amp;#039;, &amp;#039;95460&amp;#039;, &amp;#039;1949-09-07&amp;#039;)&amp;quot;);&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
Updating tables is basically the same process. The SQL command:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
  UPDATE SALESMAN&lt;br /&gt;
  SET STREET=&amp;#039;Grant Street&amp;#039;, STATE=&amp;#039;FL&amp;#039;&lt;br /&gt;
  WHERE SNR=2&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
writes a new street and state entry for Frank Jones who has SNR=2. The corresponding &amp;lt;code&amp;gt;executeUpdate()&amp;lt;/code&amp;gt; call looks like this:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  int n = xStatement.executeUpdate(&amp;quot;UPDATE SALESMAN &amp;quot; + &lt;br /&gt;
      &amp;quot;SET STREET=&amp;#039;Grant Street&amp;#039;, STATE=&amp;#039;FL&amp;#039; &amp;quot; + &lt;br /&gt;
      &amp;quot;WHERE SNR=2&amp;quot;);&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The return value of &amp;lt;code&amp;gt;executeUpdate()&amp;lt;/code&amp;gt; is an int that indicates how many rows of a table were updated. Our update command affected one row, so n is equal to 1. &lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|Note that it depends on the database and the driver,if the return value of &amp;lt;tt&amp;gt;executeUpdate()&amp;lt;/tt&amp;gt; reflects the actual changes.}}&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
[[Category: Database Access]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Creating_Statements&amp;diff=79178</id>
		<title>Documentation/DevGuide/Database/Creating Statements</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Creating_Statements&amp;diff=79178"/>
		<updated>2008-05-31T15:12:14Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/DatabaseTOC&lt;br /&gt;
|Database2c=block&lt;br /&gt;
|DatabaseStmt=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Database/Statements&lt;br /&gt;
|NextPage=Documentation/DevGuide/Database/Inserting and Updating Data&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Creating Statements}}&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.sdbc.Statement&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
A Statement object is required to send SQL statements to the Database Management System (DBMS). A Statement object is created using &amp;lt;code&amp;gt;createStatement()&amp;lt;/code&amp;gt; at the &amp;lt;idl&amp;gt;com.sun.star.sdbc.XConnection&amp;lt;/idl&amp;gt; interface of the connection. It returns a &amp;lt;idl&amp;gt;com.sun.star.sdbc.Statement&amp;lt;/idl&amp;gt; service. This &amp;lt;code&amp;gt;Statement&amp;lt;/code&amp;gt; is generic, that is, it does not contain any SQL command. It can be used for all kinds of SQL commands. Its main interface is &amp;lt;idl&amp;gt;com.sun.star.sdbc.XStatement&amp;lt;/idl&amp;gt;:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  com::sun::star::sdbc::XResultSet executeQuery( [in] string sql)&lt;br /&gt;
  long executeUpdate( [in] string sql)&lt;br /&gt;
  boolean execute( [in] string sql)&lt;br /&gt;
  com::sun::star::sdbc::XConnection getConnection()&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
Once a &amp;lt;code&amp;gt;Statement&amp;lt;/code&amp;gt; is obtained, choose the appropriate execution method for the SQL command. For a &amp;lt;code&amp;gt;SELECT&amp;lt;/code&amp;gt; statement, use the method &amp;lt;code&amp;gt;executeQuery()&amp;lt;/code&amp;gt;. For &amp;lt;code&amp;gt;UPDATE&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;DELETE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;INSERT&amp;lt;/code&amp;gt; statements, the proper method is &amp;lt;code&amp;gt;executeUpdate()&amp;lt;/code&amp;gt;. To have multiple result sets returned, use &amp;lt;code&amp;gt;execute()&amp;lt;/code&amp;gt; together with the interface &amp;lt;idl&amp;gt;com.sun.star.sdbc.XMultipleResults&amp;lt;/idl&amp;gt; of the statement.&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Tip|Data definition commands, such as &amp;lt;tt&amp;gt;CREATE&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;DROP&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ALTER&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;GRANT&amp;lt;/tt&amp;gt;, can be issued with &amp;lt;tt&amp;gt;executeUpdate()&amp;lt;/tt&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
Consider how an &amp;lt;code&amp;gt;XConnection&amp;lt;/code&amp;gt; is used to create an &amp;lt;code&amp;gt;XStatement&amp;lt;/code&amp;gt; in the following example:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  public static void executeSelect(XMultiServiceFactory _rMSF) throws com.sun.star.uno.Exception {&lt;br /&gt;
          // retrieve the DatabaseContext and get its com.sun.star.container.XNameAccess interface&lt;br /&gt;
      XNameAccess xNameAccess = (XNameAccess)UnoRuntime.queryInterface(&lt;br /&gt;
          XNameAccess.class, _rMSF.createInstance(&amp;quot;com.sun.star.sdb.DatabaseContext&amp;quot;));&lt;br /&gt;
  &lt;br /&gt;
      // connect&lt;br /&gt;
      Object dataSource = xNameAccess.getByName(&amp;quot;Ada01&amp;quot;);&lt;br /&gt;
      XDataSource xDataSource = (XDataSource)UnoRuntime.queryInterface(XDataSource.class, dataSource);&lt;br /&gt;
      Object interactionHandler = _rMSF.createInstance(&amp;quot;com.sun.star.sdb.InteractionHandler&amp;quot;);&lt;br /&gt;
      XInteractionHandler xInteractionHandler = (XInteractionHandler)UnoRuntime.queryInterface(&lt;br /&gt;
      XInteractionHandler.class, interactionHandler);&lt;br /&gt;
      XCompletedConnection xCompletedConnection = (XCompletedConnection)UnoRuntime.queryInterface(&lt;br /&gt;
          XCompletedConnection.class, dataSource);&lt;br /&gt;
      XConnection xConnection = xCompletedConnection.connectWithCompletion(xInteractionHandler);&lt;br /&gt;
      &lt;br /&gt;
      // the connection creates a statement&lt;br /&gt;
      XStatement xStatement = xConnection.createStatement();&lt;br /&gt;
      &lt;br /&gt;
      // The XStatement interface is used to execute a SELECT command&lt;br /&gt;
      // Double quotes for identifiers in the SELECT string must be escaped in Java&lt;br /&gt;
      XResultSet xResult = xStatement.executeQuery(&amp;quot;Select * from \&amp;quot;Table1\&amp;quot;&amp;quot;);&lt;br /&gt;
      &lt;br /&gt;
      // process the result ...&lt;br /&gt;
      XRow xRow = (XRow)UnoRuntime.queryInterface(XRow.class, xResult);&lt;br /&gt;
      while (xResult != null &amp;amp;&amp;amp; xResult.next()) {&lt;br /&gt;
          System.out.println(xRow.getString(1));&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The remainder of this section discusses how to enter data into a table and retrieving the data later, using &amp;lt;code&amp;gt;INSERT&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SELECT&amp;lt;/code&amp;gt; commands with a &amp;lt;idl&amp;gt;com.sun.star.sdbc.Statement&amp;lt;/idl&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
[[Category: Database Access]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Events_and_Other_Notifications&amp;diff=79177</id>
		<title>Documentation/DevGuide/Database/Events and Other Notifications</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Events_and_Other_Notifications&amp;diff=79177"/>
		<updated>2008-05-31T15:04:20Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/DatabaseTOC&lt;br /&gt;
|Database2c=block&lt;br /&gt;
|DatabaseRowSet=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Database/Usage&lt;br /&gt;
|NextPage=Documentation/DevGuide/Database/Clones of the RowSet Service&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Events and Other Notifications}}&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.sdb.XRowSetApproveBroadcaster;com.sun.star.sdb.XRowSetApproveListener;com.sun.star.sdbc.XRowSetListener;com.sun.star.lang.EventObject&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt; supports a number of events and notifications. First, there is the &amp;lt;idl&amp;gt;com.sun.star.sdb.XRowSetApproveBroadcaster&amp;lt;/idl&amp;gt; interface of the &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt; that allows the user to add or remove objects derived from the interface &amp;lt;idl&amp;gt;com.sun.star.sdb.XRowSetApproveListener&amp;lt;/idl&amp;gt;. The interface &amp;lt;idl&amp;gt;com.sun.star.sdb.XRowSetApproveListener&amp;lt;/idl&amp;gt; defines the following 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;
!colspan=&amp;quot;2&amp;quot;|Methods of &amp;lt;idl&amp;gt;com.sun.star.sdb.XRowSetApproveListener&amp;lt;/idl&amp;gt;  &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdb.XRowSetApproveListener:approveCursorMove&amp;lt;/idlm&amp;gt;() &lt;br /&gt;
|Called before a &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt;&amp;#039;s cursor is moved. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdb.XRowSetApproveListener:approveRowChange&amp;lt;/idlm&amp;gt;() &lt;br /&gt;
|Called before a row is inserted, updated, or deleted. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdb.XRowSetApproveListener:approveRowSetChange&amp;lt;/idlm&amp;gt;() &lt;br /&gt;
|Called before a &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt; is changed or before a &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt; is re-executed. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
All three methods return a boolean value that allows the &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt; to continue when it is true, otherwise the current action is stopped.&lt;br /&gt;
&lt;br /&gt;
Additionally, the &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt; supports &amp;lt;idl&amp;gt;com.sun.star.sdbc.XRowSet&amp;lt;/idl&amp;gt; that allows the user to add objects which are notified when the &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt; has changed. This has to be a &amp;lt;idl&amp;gt;com.sun.star.sdbc.XRowSetListener&amp;lt;/idl&amp;gt;. The methods are:&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;
!colspan=&amp;quot;2&amp;quot;|Methods of &amp;lt;idl&amp;gt;com.sun.star.sdbc.XRowSetListener&amp;lt;/idl&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdbc.XRowSetListener:cursorMoved&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|Called when a &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt;&amp;#039;s cursor has been moved. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdbc.XRowSetListener:rowChanged&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|Called when a row has been inserted, updated, or deleted. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdbc.XRowSetListener:rowSetChanged&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|Called when the entire row set has changed, or when the row set has been re-executed. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
When an event occurs, the appropriate listener method is called to notify the registered listener(s). If a listener is not interested in a particular kind of event, it implements the method for that event as no-op. All listener methods take a &amp;lt;idl&amp;gt;com.sun.star.lang.EventObject&amp;lt;/idl&amp;gt; struct that contains the &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt; object which is the source of the event.&lt;br /&gt;
&lt;br /&gt;
The following table lists the order of events after a specific method call on the RowSet. First the movements.&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;
!Method Call &lt;br /&gt;
!Event Call (before) &lt;br /&gt;
!Event Call (after) &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;beforeFirst()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;first()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;next()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;previous()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;last()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;afterLast()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;absolute()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;relative()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;moveToBookmark()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;moveRelativeToBookmark()&amp;lt;/code&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;approveCursorMove()&amp;lt;/code&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;cursorMoved()&amp;lt;/code&amp;gt;, only when the movement was successful&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;modified()&amp;lt;/code&amp;gt; event from &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idl&amp;gt; of property &amp;lt;code&amp;gt;RowCount&amp;lt;/code&amp;gt;, only when changed&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;modified()&amp;lt;/code&amp;gt; event from &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idl&amp;gt; of property &amp;lt;code&amp;gt;RowCountFinal&amp;lt;/code&amp;gt;, only when changed &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;updateRow()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;deleteRow()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;insertRow()&amp;lt;/code&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;approveRowChange()&amp;lt;/code&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;rowChanged()&amp;lt;/code&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;execute()&amp;lt;/code&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;approveRowSetChange()&amp;lt;/code&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;rowSetChanged()&amp;lt;/code&amp;gt; &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Consider a simple class which implements the two listener interfaces described above. &lt;br /&gt;
&amp;lt;!--[SOURCE:Database/RowSetEventListener.java]--&amp;gt;&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  import com.sun.star.sdb.XRowSetApproveListener;&lt;br /&gt;
  import com.sun.star.sdbc.XRowSetListener;&lt;br /&gt;
  import com.sun.star.sdb.RowChangeEvent;&lt;br /&gt;
  import com.sun.star.lang.EventObject;&lt;br /&gt;
  &lt;br /&gt;
  public class RowSetEventListener implements XRowSetApproveListener,XRowSetListener {&lt;br /&gt;
      // XEventListener&lt;br /&gt;
      public void disposing(com.sun.star.lang.EventObject event) {&lt;br /&gt;
          System.out.println(&amp;quot;RowSet will be destroyed!&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      // XRowSetApproveBroadcaster&lt;br /&gt;
      public boolean approveCursorMove(EventObject event) {&lt;br /&gt;
          System.out.println(&amp;quot;Before CursorMove!&amp;quot;);&lt;br /&gt;
          return true;&lt;br /&gt;
      }&lt;br /&gt;
      public boolean approveRowChange(RowChangeEvent event) {&lt;br /&gt;
          System.out.println(&amp;quot;Before row change!&amp;quot;);&lt;br /&gt;
          return true;&lt;br /&gt;
      }&lt;br /&gt;
      public boolean approveRowSetChange(EventObject event) {&lt;br /&gt;
          System.out.println(&amp;quot;Before RowSet change!&amp;quot;);&lt;br /&gt;
          return true;&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      // XRowSetListener&lt;br /&gt;
      public void cursorMoved(com.sun.star.lang.EventObject event) {&lt;br /&gt;
          System.out.println(&amp;quot;Cursor moved!&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      public void rowChanged(com.sun.star.lang.EventObject event) {&lt;br /&gt;
          System.out.println(&amp;quot;Row changed!&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      public void rowSetChanged(com.sun.star.lang.EventObject event) {&lt;br /&gt;
          System.out.println(&amp;quot;RowSet changed!&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The following method uses the listener implementation above. &lt;br /&gt;
&amp;lt;!--[SOURCE:Database/RowSet.java]--&amp;gt;&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  public static void showRowSetEvents(XMultiServiceFactory _rMSF) throws com.sun.star.uno.Exception {&lt;br /&gt;
      // first we create our RowSet object&lt;br /&gt;
      XRowSet xRowRes = (XRowSet)UnoRuntime.queryInterface(&lt;br /&gt;
          XRowSet.class, _rMSF.createInstance(&amp;quot;com.sun.star.sdb.RowSet&amp;quot;));&lt;br /&gt;
      &lt;br /&gt;
      System.out.println(&amp;quot;RowSet created!&amp;quot;);&lt;br /&gt;
      // add our Listener&lt;br /&gt;
      System.out.println(&amp;quot;Append our Listener!&amp;quot;);&lt;br /&gt;
      RowSetEventListener pRow = new RowSetEventListener();&lt;br /&gt;
      XRowSetApproveBroadcaster xApBroad = (XRowSetApproveBroadcaster)UnoRuntime.queryInterface(&lt;br /&gt;
          XRowSetApproveBroadcaster.class, xRowRes);&lt;br /&gt;
      xApBroad.addRowSetApproveListener(pRow);&lt;br /&gt;
      xRowRes.addRowSetListener(pRow);&lt;br /&gt;
      &lt;br /&gt;
      // set the properties needed to connect to a database&lt;br /&gt;
      XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xRowRes);&lt;br /&gt;
      xProp.setPropertyValue(&amp;quot;DataSourceName&amp;quot;, &amp;quot;Bibliography&amp;quot;);&lt;br /&gt;
      xProp.setPropertyValue(&amp;quot;Command&amp;quot;, &amp;quot;biblio&amp;quot;);&lt;br /&gt;
      xProp.setPropertyValue(&amp;quot;CommandType&amp;quot;, new Integer(com.sun.star.sdb.CommandType.TABLE));&lt;br /&gt;
      &lt;br /&gt;
      xRowRes.execute();&lt;br /&gt;
      System.out.println(&amp;quot;RowSet executed!&amp;quot;);&lt;br /&gt;
      &lt;br /&gt;
      // do some movements to check if we got all notifications&lt;br /&gt;
      XResultSet xRes = (XResultSet)UnoRuntime.queryInterface(XResultSet.class, xRowRes);&lt;br /&gt;
      System.out.println(&amp;quot;beforeFirst&amp;quot;);&lt;br /&gt;
      xRes.beforeFirst();&lt;br /&gt;
      // this should lead to no notifications because &lt;br /&gt;
      // we should stand before the first row at the beginning&lt;br /&gt;
      System.out.println(&amp;quot;We stand before the first row: &amp;quot; + xRes.isBeforeFirst());&lt;br /&gt;
      &lt;br /&gt;
      System.out.println(&amp;quot;next&amp;quot;);&lt;br /&gt;
      xRes.next();&lt;br /&gt;
      System.out.println(&amp;quot;next&amp;quot;);&lt;br /&gt;
      xRes.next();&lt;br /&gt;
      System.out.println(&amp;quot;last&amp;quot;);&lt;br /&gt;
      xRes.last();&lt;br /&gt;
      System.out.println(&amp;quot;next&amp;quot;);&lt;br /&gt;
      xRes.next();&lt;br /&gt;
      System.out.println(&amp;quot;We stand after the last row: &amp;quot; + xRes.isAfterLast());&lt;br /&gt;
      System.out.println(&amp;quot;first&amp;quot;);&lt;br /&gt;
      xRes.first();&lt;br /&gt;
      System.out.println(&amp;quot;previous&amp;quot;);&lt;br /&gt;
      xRes.previous();&lt;br /&gt;
      System.out.println(&amp;quot;We stand before the first row: &amp;quot; + xRes.isBeforeFirst());&lt;br /&gt;
      System.out.println(&amp;quot;afterLast&amp;quot;);&lt;br /&gt;
      xRes.afterLast();&lt;br /&gt;
      System.out.println(&amp;quot;We stand after the last row: &amp;quot; + xRes.isAfterLast());&lt;br /&gt;
      &lt;br /&gt;
      // now destroy the RowSet&lt;br /&gt;
      XComponent xComp = (XComponent)UnoRuntime.queryInterface(XComponent.class, xRowRes);&lt;br /&gt;
      xComp.dispose();&lt;br /&gt;
      System.out.println(&amp;quot;RowSet destroyed!&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
[[Category: Database Access]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Usage&amp;diff=79176</id>
		<title>Documentation/DevGuide/Database/Usage</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Usage&amp;diff=79176"/>
		<updated>2008-05-31T15:02:51Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/DatabaseTOC&lt;br /&gt;
|Database2c=block&lt;br /&gt;
|DatabaseRowSet=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Database/The RowSet Service&lt;br /&gt;
|NextPage=Documentation/DevGuide/Database/Events and Other Notifications&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Usage}}&lt;br /&gt;
To use a row set, create a &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt; instance at the global service manager through the service name &amp;lt;idl&amp;gt;com.sun.star.sdb.RowSet&amp;lt;/idl&amp;gt;. Next, the &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt; needs a &amp;#039;&amp;#039;connection&amp;#039;&amp;#039; and a command before it can be executed. These have to be configured through &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt; properties.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Connection&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
:There are three different ways to establish a connection:&lt;br /&gt;
&lt;br /&gt;
:* Setting &amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:DataSourceName&amp;lt;/idlm&amp;gt; to a data source from the database context. If the &amp;lt;code&amp;gt;DataSourceName&amp;lt;/code&amp;gt; is not a URL, then the &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt; uses the name to get the &amp;lt;code&amp;gt;DataSource&amp;lt;/code&amp;gt; from the &amp;lt;code&amp;gt;DatabaseContext&amp;lt;/code&amp;gt; to create a connection to that data source.&lt;br /&gt;
:* Setting &amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:DataSourceName&amp;lt;/idlm&amp;gt; to a database URL. The row set tries to use this URL to establish a connection. Database URLs are described in [[Documentation/DevGuide/Database/Connecting Using the DriverManager and a Database URL|Connecting Using the DriverManager and a Database URL]].&lt;br /&gt;
:* Setting &amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:ActiveConnection&amp;lt;/idlm&amp;gt; makes a row set ready for immediate use. The row set uses this connection. &lt;br /&gt;
&lt;br /&gt;
:The difference between the two properties is that in the first case the &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt; owns the connection. The &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt; disposes the connection when it is disposed. In the second case, the &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt; only uses the connection. The user of a &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt; is responsible for the disposition of the connection. For a simple &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt;, use &amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:DataSourceName&amp;lt;/idlm&amp;gt;, but when sharing the connection between different row sets, then use &amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:ActiveConnection&amp;lt;/idlm&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
:If there is already a connection, for example, the user opened a database form, open another row set based upon the property &amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:ActiveConnection&amp;lt;/idlm&amp;gt; of the form. Put the &amp;lt;code&amp;gt;ActiveConnection&amp;lt;/code&amp;gt; of the form into the &amp;lt;code&amp;gt;ActiveConnection&amp;lt;/code&amp;gt; property of the new row set.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Command&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
:With a connection and a command, the row set is ready to be executed calling &amp;lt;code&amp;gt;execute()&amp;lt;/code&amp;gt; on the &amp;lt;idl&amp;gt;com.sun.star.sdbc.XRowSet&amp;lt;/idl&amp;gt; interface of the row set. For interactive logon, use &amp;lt;code&amp;gt;executeWithCompletion()&amp;lt;/code&amp;gt;, see [[Documentation/DevGuide/Database/Connecting Through a DataSource|Connecting Through a DataSource]]. If interactive logon is not feasible for your application, the properties &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Password&amp;lt;/code&amp;gt; can be used to connect to a database that requires logon.&lt;br /&gt;
&lt;br /&gt;
:Once the method for how &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt; creates it connections has been determined, the properties &amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:Command&amp;lt;/idlm&amp;gt; and &amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:CommandType&amp;lt;/idlm&amp;gt; have to be set. The &amp;lt;code&amp;gt;CommandType&amp;lt;/code&amp;gt; can be &amp;lt;code&amp;gt;TABLE&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;QUERY&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;COMMAND&amp;lt;/code&amp;gt; where the &amp;lt;code&amp;gt;Command&amp;lt;/code&amp;gt; can be a table or query name, or an SQL command.&lt;br /&gt;
&lt;br /&gt;
The following table shows the properties supported by &amp;lt;idl&amp;gt;com.sun.star.sdb.RowSet&amp;lt;/idl&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;
!colspan=&amp;quot;2&amp;quot;|Properties of &amp;lt;idl&amp;gt;com.sun.star.sdb.RowSet&amp;lt;/idl&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:ActiveConnection&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;idl&amp;gt;com.sun.star.sdbc.XConnection&amp;lt;/idl&amp;gt;. The active connection is generated by a &amp;lt;code&amp;gt;DataSource&amp;lt;/code&amp;gt; or by a URL. It could also be set from the outside. If set from outside, the &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt; is not responsible for disposition of the connection. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:DataSourceName&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; - The name of the &amp;lt;code&amp;gt;DataSource&amp;lt;/code&amp;gt; to use. This could be a named &amp;lt;code&amp;gt;DataSource&amp;lt;/code&amp;gt; or the URL of a data access component. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:Command&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; - The &amp;lt;code&amp;gt;Command&amp;lt;/code&amp;gt; is the command that should be executed. The type of command depends on the &amp;lt;idl&amp;gt;com.sun.star.sdb.CommandType&amp;lt;/idl&amp;gt;. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:CommandType&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;idl&amp;gt;com.sun.star.sdb.CommandType&amp;lt;/idl&amp;gt; Command type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;TABLE&amp;lt;/code&amp;gt;: indicates the command contains a table name that results in a command like &amp;quot;&amp;lt;code&amp;gt;select * from tablename&amp;lt;/code&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;QUERY&amp;lt;/code&amp;gt;: indicates the command contains a name of a query component that contains a certain statement.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;COMMAND&amp;lt;/code&amp;gt;: indicates the command is an SQL-Statement. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:ActiveCommand&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;[readonly] string&amp;lt;/code&amp;gt; - The command which is currently used. &amp;lt;idl&amp;gt;com.sun.star.sdb.CommandType&amp;lt;/idl&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:IgnoreResult&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; - Indicates if all results should be discarded. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:Filter&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; - Contains a additional filter for a &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt;. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:ApplyFilter&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; - Indicates if the filter should be applied. The default is false. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:Order&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|An additional sort order definition for a &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt;. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:Privileges&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;[readonly] long&amp;lt;/code&amp;gt;, constants group &amp;lt;idl&amp;gt;com.sun.star.sdbcx.Privilege&amp;lt;/idl&amp;gt;. Indicates the privileges for insert, update, and delete. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:IsModified&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;[readonly] boolean&amp;lt;/code&amp;gt; - Indicates if the current row is modified. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:IsNew&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;[readonly]&amp;lt;/code&amp;gt; boolean - Indicates if the current row is the &amp;lt;code&amp;gt;InsertRow&amp;lt;/code&amp;gt; and can be inserted into the database. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:RowCount&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;[readonly] boolean&amp;lt;/code&amp;gt; - Contains the number of rows accessed in a the data source. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:IsRowCountFinal&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;[readonly] boolean&amp;lt;/code&amp;gt; - Indicates if all rows of the &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt; have been counted. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:UpdateTableName&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; - The name of the table that should be updated. This is used for queries that relate to more than one table.  &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:UpdateSchemaName&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; - The name of the table schema. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdb.RowSet:UpdateCatalogName&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; - The name of the table catalog. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;idl&amp;gt;com.sun.star.sdb.RowSet&amp;lt;/idl&amp;gt; includes the service &amp;lt;idl&amp;gt;com.sun.star.sdbc.RowSet&amp;lt;/idl&amp;gt; and its properties. Important settings such as &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Password&amp;lt;/code&amp;gt; come from this service:&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;
!colspan=&amp;quot;2&amp;quot;|Properties of &amp;lt;idl&amp;gt;com.sun.star.sdbc.RowSet&amp;lt;/idl&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdbc.RowSet:DataSourceName&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; - Is the name of a named datasource to use. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdbc.RowSet:URL&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; - The connection URL. Can be used instead of the &amp;lt;code&amp;gt;DataSourceName&amp;lt;/code&amp;gt;.  &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdbc.RowSet:Command&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; - The command that should be executed.  &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdbc.RowSet:TransactionIsolation&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;long&amp;lt;/code&amp;gt; - Indicates the transaction isolation level that should be used for the connection, according to &amp;lt;idl&amp;gt;com.sun.star.sdbc.TransactionIsolation&amp;lt;/idl&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdbc.RowSet:TypeMap&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;com::sun::star::container::XNameAccess&amp;lt;/code&amp;gt;. The type map that is used for the custom mapping of SQL structured types and distinct types. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdbc.RowSet:EscapeProcessing&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|boolean - Determines if escape processing is on or off. If escape scanning is on (the default), the driver does the escape substitution before sending the SQL to the database. This is only evaluated if the &amp;lt;code&amp;gt;CommandType&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;COMMAND&amp;lt;/code&amp;gt;.  &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdbc.RowSet:QueryTimeOut&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;long&amp;lt;/code&amp;gt; - Retrieves the number of seconds the driver waits for a Statement to execute. If the limit is exceeded, a SQLException is thrown. There is no limitation if set to zero.  &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdbc.RowSet:MaxFieldSize&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;long&amp;lt;/code&amp;gt; - Returns the maximum number of bytes allowed for any column value. This limit is the maximum number of bytes that can be returned for any column value. The limit applies only to &amp;lt;code&amp;gt;DataType::BINARY&amp;lt;ode&amp;gt;, &amp;lt;code&amp;gt;DataType::VARBINARY&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;DataType::LONGVARBINARY&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;DataType::CHAR&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;DataType::VARCHAR&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;DataType::LONGVARCHAR&amp;lt;/code&amp;gt; columns. If the limit is exceeded, the excess data is silently discarded. There is no limitation if set to zero. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdbc.RowSet:MaxRows&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;long&amp;lt;/code&amp;gt; - Retrieves the maximum number of rows that a &amp;lt;code&amp;gt;ResultSet&amp;lt;/code&amp;gt; can contain. If the limit is exceeded, the excess rows are silently dropped. There is no limitation if set to zero. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdbc.RowSet:User&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; - Determines the user to open the connection for. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdbc.RowSet:Password&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; - Determines the user to open the connection for.  &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.sdbc.RowSet:ResultSetType&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;long&amp;lt;/code&amp;gt; - Determine the result set type according to &amp;lt;idl&amp;gt;com.sun.star.sdbc.ResultSetType&amp;lt;/idl&amp;gt; &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If the command returns results, that is, it selects data, use &amp;lt;code&amp;gt;XRowSet&amp;lt;/code&amp;gt; to manipulate the data, because &amp;lt;code&amp;gt;XRowSet&amp;lt;/code&amp;gt; is derived from &amp;lt;code&amp;gt;XResultSet&amp;lt;/code&amp;gt;. For details on manipulating a &amp;lt;idl&amp;gt;com.sun.star.sdb.ResultSet&amp;lt;/idl&amp;gt;, see [[Documentation/DevGuide/Database/Result Sets|Result Sets]].&lt;br /&gt;
&lt;br /&gt;
The code fragment below shows how to create a &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt;. &lt;br /&gt;
&amp;lt;!--[SOURCE:Database/RowSet.java]--&amp;gt;&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  public static void useRowSet(XMultiServiceFactory _rMSF) throws com.sun.star.uno.Exception {&lt;br /&gt;
      // first we create our RowSet object&lt;br /&gt;
      XRowSet xRowRes = (XRowSet)UnoRuntime.queryInterface(XRowSet.class,&lt;br /&gt;
          _rMSF.createInstance(&amp;quot;com.sun.star.sdb.RowSet&amp;quot;));&lt;br /&gt;
      System.out.println(&amp;quot;RowSet created!&amp;quot;);&lt;br /&gt;
      &lt;br /&gt;
      // set the properties needed to connect to a database&lt;br /&gt;
      XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xRowRes);&lt;br /&gt;
      xProp.setPropertyValue(&amp;quot;DataSourceName&amp;quot;, &amp;quot;Bibliography&amp;quot;);&lt;br /&gt;
      xProp.setPropertyValue(&amp;quot;Command&amp;quot;, &amp;quot;biblio&amp;quot;);&lt;br /&gt;
      xProp.setPropertyValue(&amp;quot;CommandType&amp;quot;, new Integer(com.sun.star.sdb.CommandType.TABLE));&lt;br /&gt;
      xRowRes.execute();&lt;br /&gt;
      System.out.println(&amp;quot;RowSet executed!&amp;quot;);&lt;br /&gt;
      XComponent xComp = (XComponent)UnoRuntime.queryInterface(XComponent.class, xRowRes);&lt;br /&gt;
      xComp.dispose();&lt;br /&gt;
      System.out.println(&amp;quot;RowSet destroyed!&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The value of the read-only &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt; properties is only valid after the first call to &amp;lt;code&amp;gt;execute()&amp;lt;/code&amp;gt; on the &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt;. This snippet shows how to read the privileges out of the &amp;lt;code&amp;gt;RowSet&amp;lt;/code&amp;gt;: &lt;br /&gt;
&amp;lt;!--[SOURCE:Database/RowSet.java]--&amp;gt;&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  public static void showRowSetReadOnlyProps(XMultiServiceFactory _rMSF) throws com.sun.star.uno.Exception {&lt;br /&gt;
      // first we create our RowSet object&lt;br /&gt;
      XRowSet xRowRes =&lt;br /&gt;
          (XRowSet)UnoRuntime.queryInterface(XRowSet.class_rMSF.createInstance(&lt;br /&gt;
              &amp;quot;com.sun.star.sdb.RowSet&amp;quot;));&lt;br /&gt;
      System.out.println(&amp;quot;RowSet created!&amp;quot;);&lt;br /&gt;
      &lt;br /&gt;
      // set the properties needed to connect to a database&lt;br /&gt;
      XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xRowRes);&lt;br /&gt;
      xProp.setPropertyValue(&amp;quot;DataSourceName&amp;quot;, &amp;quot;Bibliography&amp;quot;);&lt;br /&gt;
      xProp.setPropertyValue(&amp;quot;Command&amp;quot;, &amp;quot;biblio&amp;quot;);&lt;br /&gt;
      xProp.setPropertyValue(&amp;quot;CommandType&amp;quot;, new Integer(com.sun.star.sdb.CommandType.TABLE));&lt;br /&gt;
      xRowRes.execute();&lt;br /&gt;
      System.out.println(&amp;quot;RowSet executed!&amp;quot;);&lt;br /&gt;
      Integer aPriv = (Integer)xProp.getPropertyValue(&amp;quot;Privileges&amp;quot;);&lt;br /&gt;
      int nPriv = aPriv.intValue();&lt;br /&gt;
      &lt;br /&gt;
      if ((nPriv &amp;amp; Privilege.SELECT) == Privilege.SELECT) System.out.println(&amp;quot;SELECT&amp;quot;);&lt;br /&gt;
      if ((nPriv &amp;amp; Privilege.INSERT) == Privilege.INSERT) System.out.println(&amp;quot;INSERT&amp;quot;);&lt;br /&gt;
      if ((nPriv &amp;amp; Privilege.UPDATE) == Privilege.UPDATE) System.out.println(&amp;quot;UPDATE&amp;quot;);&lt;br /&gt;
      if ((nPriv &amp;amp; Privilege.DELETE) == Privilege.DELETE) System.out.println(&amp;quot;DELETE&amp;quot;);&lt;br /&gt;
      &lt;br /&gt;
      XComponent xComp = (XComponent)UnoRuntime.queryInterface(XComponent.class, xRowRes);&lt;br /&gt;
      xComp.dispose();&lt;br /&gt;
      System.out.println(&amp;quot;RowSet destroyed!&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The next example reads the properties &amp;lt;code&amp;gt;IsRowCountFinal&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RowCount&amp;lt;/code&amp;gt;. &lt;br /&gt;
&amp;lt;!--[SOURCE:Database/RowSet.java]--&amp;gt;&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  public static void showRowSetRowCount(XMultiServiceFactory _rMSF) throws com.sun.star.uno.Exception {&lt;br /&gt;
      // first we create our RowSet object&lt;br /&gt;
      XRowSet xRowRes = (XRowSet)UnoRuntime.queryInterface(XRowSet.class,&lt;br /&gt;
          _rMSF.createInstance(&amp;quot;com.sun.star.sdb.RowSet&amp;quot;));&lt;br /&gt;
      System.out.println(&amp;quot;RowSet created!&amp;quot;);&lt;br /&gt;
      &lt;br /&gt;
      // set the properties needed to connect to a database&lt;br /&gt;
      XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xRowRes);&lt;br /&gt;
      xProp.setPropertyValue(&amp;quot;DataSourceName&amp;quot;,&amp;quot;Bibliography&amp;quot;);&lt;br /&gt;
      xProp.setPropertyValue(&amp;quot;Command&amp;quot;,&amp;quot;biblio&amp;quot;);&lt;br /&gt;
      xProp.setPropertyValue(&amp;quot;CommandType&amp;quot;,new Integer(com.sun.star.sdb.CommandType.TABLE));&lt;br /&gt;
      xRowRes.execute();&lt;br /&gt;
      System.out.println(&amp;quot;RowSet executed!&amp;quot;);&lt;br /&gt;
      &lt;br /&gt;
      // now look if the RowCount is already final&lt;br /&gt;
      System.out.println(&amp;quot;The RowCount is final: &amp;quot; + xProp.getPropertyValue(&amp;quot;IsRowCountFinal&amp;quot;));&lt;br /&gt;
      XResultSet xRes = (XResultSet)UnoRuntime.queryInterface(XResultSet.class,xRowRes);&lt;br /&gt;
      xRes.last();&lt;br /&gt;
      &lt;br /&gt;
      System.out.println(&amp;quot;The RowCount is final: &amp;quot; + xProp.getPropertyValue(&amp;quot;IsRowCountFinal&amp;quot;));&lt;br /&gt;
      System.out.println(&amp;quot;There are &amp;quot; + xProp.getPropertyValue(&amp;quot;RowCount&amp;quot;) + &amp;quot; rows!&amp;quot;);&lt;br /&gt;
      &lt;br /&gt;
      // now destroy the RowSet&lt;br /&gt;
      XComponent xComp = (XComponent)UnoRuntime.queryInterface(XComponent.class,xRowRes);&lt;br /&gt;
      xComp.dispose();&lt;br /&gt;
      System.out.println(&amp;quot;RowSet destroyed!&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
Occasionally, it is useful for the user to be notified when the &amp;lt;code&amp;gt;RowCount&amp;lt;/code&amp;gt; is final. That is accomplished by adding a &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertyChangeListener&amp;lt;/idl&amp;gt; for the property &amp;lt;code&amp;gt;IsRowCountFinal&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
[[Category: Database Access]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Template:Documentation/DevGuide/DatabaseTOC&amp;diff=79175</id>
		<title>Template:Documentation/DevGuide/DatabaseTOC</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Template:Documentation/DevGuide/DatabaseTOC&amp;diff=79175"/>
		<updated>2008-05-31T14:58:48Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/MasterTOC&lt;br /&gt;
|ShowPrevPage={{{ShowPrevPage}}}&lt;br /&gt;
|PrevPage={{{PrevPage}}}&lt;br /&gt;
|ShowNextPage={{{ShowNextPage}}}&lt;br /&gt;
|NextPage={{{NextPage}}}&lt;br /&gt;
|bookid=DevGuide&lt;br /&gt;
|booktitle=[[Documentation/DevGuide/OpenOffice.org Developers Guide|OpenOffice.org Developer&amp;#039;s Guide]]&lt;br /&gt;
|ShowParttitle=block&lt;br /&gt;
|parttitle=[[Documentation/DevGuide/Database/Database Access|Database Access]]&lt;br /&gt;
|ShowPrevPart=block&lt;br /&gt;
|PrevPart=Documentation/DevGuide/Basic/OpenOffice.org Basic and Dialogs&lt;br /&gt;
|ShowNextPart=block&lt;br /&gt;
|NextPart=Documentation/DevGuide/Forms/Forms&lt;br /&gt;
|toccontent=&lt;br /&gt;
&amp;lt;div id=Database2a&amp;quot; style=&amp;quot;display:{{{Database2a|none}}};margin-left: 12px;&amp;quot;&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/Architecture|Architecture]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Example: Querying the Bibliography Database|Example: Querying the Bibliography Database]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/Data Sources in OpenOffice.org API|Data Sources in OpenOffice.org API]]&lt;br /&gt;
&amp;lt;div id=Database2b&amp;quot; style=&amp;quot;display:{{{Database2b|none}}};margin-left: 12px;&amp;quot;&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/DataSources|DataSources]]&lt;br /&gt;
&amp;lt;div id=DatabaseSources&amp;quot; style=&amp;quot;display:{{{DatabaseSources|none}}};margin-left: 12px;&amp;quot;&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/The DataSource Service|The DataSource Service]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Queries|Queries]]&lt;br /&gt;
&amp;lt;div id=DatabaseQueries&amp;quot; style=&amp;quot;display:{{{DatabaseQueries|none}}};margin-left: 12px;&amp;quot;&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/Adding and Editing Predefined Queries|Adding and Editing Predefined Queries]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Runtime Settings For Predefined Queries|Runtime Settings For Predefined Queries]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/The SingleSelectQueryComposer|The SingleSelectQueryComposer]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/The SQLQueryComposer|The SQLQueryComposer]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/Forms and Reports|Forms and Reports]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Document Links|Document Links]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Tables and Columns|Tables and Columns]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/Connections|Connections]]&lt;br /&gt;
&amp;lt;div id=DatabaseConnections&amp;quot; style=&amp;quot;display:{{{DatabaseConnections|none}}};margin-left: 12px;&amp;quot;&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/Connecting Through a DataSource|Connecting Through a DataSource]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Connecting Using the DriverManager and a Database URL|Connecting Using the DriverManager and a Database URL]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Connecting Through a Specific Driver|Connecting Through a Specific Driver]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Driver Specifics|Driver Specifics]]&lt;br /&gt;
&amp;lt;div id=DatabaseDrv&amp;quot; style=&amp;quot;display:{{{DatabaseDrv|none}}};margin-left: 12px;&amp;quot;&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/The SDBC Driver for JDBC|The SDBC Driver for JDBC]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/The SDBC Driver for ODBC|The SDBC Driver for ODBC]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/The SDBC Driver for Adabas D|The SDBC Driver for Adabas D]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/The SDBC Driver for ADO|The SDBC Driver for ADO]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/The SDBC Driver for dBase|The SDBC Driver for dBase]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/The SDBC Driver for Flat File Formats|The SDBC Driver for Flat File Formats]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/The SDBC Driver for OpenOffice.org Calc Files|The SDBC Driver for OpenOffice.org Calc Files]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/The SDBC Driver for address books|The SDBC Driver for address books]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/The SDBC Driver for embedded HSQL databases|The SDBC Driver for embedded HSQL databases]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/Connection Pooling|Connection Pooling]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Piggyback Connections|Piggyback Connections]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/Manipulating the Data|Manipulating the Data]]&lt;br /&gt;
&amp;lt;div id=Database2c&amp;quot; style=&amp;quot;display:{{{Database2c|none}}};margin-left: 12px;&amp;quot;&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/The RowSet Service|The RowSet Service]]&lt;br /&gt;
&amp;lt;div id=DatabaseRowSet&amp;quot; style=&amp;quot;display:{{{DatabaseRowSet|none}}};margin-left: 12px;&amp;quot;&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/Usage|Usage]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Events and Other Notifications|Events and Other Notifications]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Clones of the RowSet Service|Clones of the RowSet Service]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/Statements|Statements]]&lt;br /&gt;
&amp;lt;div id=DatabaseStmt&amp;quot; style=&amp;quot;display:{{{DatabaseStmt|none}}};margin-left: 12px;&amp;quot;&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/Creating Statements|Creating Statements]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Inserting and Updating Data|Inserting and Updating Data]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Getting Data from a Table|Getting Data from a Table]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/Result Sets|Result Sets]]&lt;br /&gt;
&amp;lt;div id=DatabaseResult&amp;quot; style=&amp;quot;display:{{{DatabaseResult|none}}};margin-left: 12px;&amp;quot;&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/Retrieving Values from Result Sets|Retrieving Values from Result Sets]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Moving the Result Set Cursor|Moving the Result Set Cursor]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Using the getXXX Methods|Using the getXXX Methods]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Scrollable Result Sets|Scrollable Result Sets]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Modifiable Result Sets|Modifiable Result Sets]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Update|Update]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Insert|Insert]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Delete|Delete]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Seeing Changes in Result Sets|Seeing Changes in Result Sets]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/ResultSetMetaData|ResultSetMetaData]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Using Prepared Statements|Using Prepared Statements]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/PreparedStatement From DataSource Queries|PreparedStatement From DataSource Queries]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/Database Design|Database Design]]&lt;br /&gt;
&amp;lt;div id=Database2d&amp;quot; style=&amp;quot;display:{{{Database2d|none}}};margin-left: 12px;&amp;quot;&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/Using DDL to Change the Database Design|Using DDL to Change the Database Design]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Using SDBCX to Access the Database Design|Using SDBCX to Access the Database Design]]&lt;br /&gt;
&amp;lt;div id=DatabaseSDBCX&amp;quot; style=&amp;quot;display:{{{DatabaseSDBCX|none}}};margin-left: 12px;&amp;quot;&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/Catalog Service|Catalog Service]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Table Service|Table Service]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Column Service|Column Service]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Index Service|Index Service]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Key Service|Key Service]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/View Service|View Service]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Group Service|Group Service]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/User Service|User Service]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/The Descriptor Pattern|The Descriptor Pattern]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Adding an Index|Adding an Index]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Creating a User|Creating a User]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Adding a Group|Adding a Group]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/Using DBMS Features|Using DBMS Features]]&lt;br /&gt;
&amp;lt;div id=Database2e&amp;quot; style=&amp;quot;display:{{{Database2e|none}}};margin-left: 12px;&amp;quot;&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/Stored Procedures|Stored Procedures]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/Writing Database Drivers|Writing Database Drivers]]&lt;br /&gt;
&amp;lt;div id=Database2f&amp;quot; style=&amp;quot;display:{{{Database2f|none}}};margin-left: 12px;&amp;quot;&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/SDBC Driver|SDBC Driver]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Driver Service|Driver Service]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Connection Service|Connection Service]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/XDatabaseMetaData Interface|XDatabaseMetaData Interface]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Driver Statements|Statements]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Support Scalar Functions|Support Scalar Functions]]&lt;br /&gt;
&amp;lt;div id=DatabaseScalar&amp;quot; style=&amp;quot;display:{{{DatabaseScalar|none}}};margin-left: 12px;&amp;quot;&amp;gt;&lt;br /&gt;
* [[Documentation/DevGuide/Database/Open Group CLI Numeric Functions|Open Group CLI Numeric Functions]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Open Group CLI String Functions|Open Group CLI String Functions]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Open Group CLI Time and Date Functions|Open Group CLI Time and Date Functions]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Open Group CLI System Functions|Open Group CLI System Functions]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Open Group CLI Conversion Functions|Open Group CLI Conversion Functions]]&lt;br /&gt;
* [[Documentation/DevGuide/Database/Handling Unsupported Functionality|Handling Unsupported Functionality]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/The_SDBC_Driver_for_JDBC&amp;diff=79173</id>
		<title>Documentation/DevGuide/Database/The SDBC Driver for JDBC</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/The_SDBC_Driver_for_JDBC&amp;diff=79173"/>
		<updated>2008-05-31T14:48:04Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/DatabaseTOC&lt;br /&gt;
|Database2b=block&lt;br /&gt;
|DatabaseConnections=block&lt;br /&gt;
|DatabaseDrv=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Database/Driver Specifics&lt;br /&gt;
|NextPage=Documentation/DevGuide/Database/The SDBC Driver for ODBC&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:The SDBC Driver for JDBC}}&lt;br /&gt;
The SDBC driver for JDBC is a mapping from SDBC API calls to the JDBC API, and vice versa. Basically, this driver is a direct bridge to JDBC. The SDBC driver for JDBC requires a special property called &amp;lt;code&amp;gt;JavaDriverClass&amp;lt;/code&amp;gt; to know which JDBC driver should be used. The expected value of this property should be the complete class name of the JDBC driver. The following code snippet uses a MySQL JDBC driver to connect.&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // first create the needed url&lt;br /&gt;
  String url = &amp;quot;jdbc:mysql://localhost:3306/TestTables&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  // second create the necessary properties&lt;br /&gt;
  com.sun.star.beans.PropertyValue [] props = new com.sun.star.beans.PropertyValue[] {&lt;br /&gt;
      new [ com.sun.star.beans.PropertyValue](&amp;quot;user&amp;quot;, 0, &amp;quot;test1&amp;quot;, &lt;br /&gt;
          com.sun.star.beans.PropertyState.DIRECT_VALUE),&lt;br /&gt;
      new com.sun.star.beans.PropertyValue(&amp;quot;password&amp;quot;, 0, &amp;quot;test1&amp;quot;,&lt;br /&gt;
          com.sun.star.beans.PropertyState.DIRECT_VALUE),&lt;br /&gt;
      new com.sun.star.beans.PropertyValue(&amp;quot;JavaDriverClass&amp;quot;, 0, &amp;quot;org.gjt.mm.mysql.Driver&amp;quot;,&lt;br /&gt;
          com.sun.star.beans.PropertyState.DIRECT_VALUE)&lt;br /&gt;
  };&lt;br /&gt;
  &lt;br /&gt;
  // now create a connection to adabas&lt;br /&gt;
  xConnection = xDriverManager.getConnectionWithInfo(url, props);&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
Other properties that require setting during the connect process depend on the JDBC driver that is used.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
[[Category: Database Access]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Connecting_Through_a_Specific_Driver&amp;diff=79172</id>
		<title>Documentation/DevGuide/Database/Connecting Through a Specific Driver</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Connecting_Through_a_Specific_Driver&amp;diff=79172"/>
		<updated>2008-05-31T14:46:20Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/DatabaseTOC&lt;br /&gt;
|Database2b=block&lt;br /&gt;
|DatabaseConnections=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Database/Connecting Using the DriverManager and a Database URL&lt;br /&gt;
|NextPage=Documentation/DevGuide/Database/Driver Specifics&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Connecting Through a Specific Driver}}&lt;br /&gt;
The second method to create an independent, data-source connection is to use a particular driver implementation, such as writing a driver. There are also several implementations. Create an instance of the driver and ask it for a connection to decide what driver is used: &lt;br /&gt;
&amp;lt;!--[SOURCE:Database/CodeSamples.java]--&amp;gt;&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // create the Driver using the implementation name&lt;br /&gt;
  Object aDriver = xMultiServiceFactory.createInstance(&amp;quot;com.sun.star.comp.sdbcx.adabas.ODriver&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
  // query for the XDriver interface&lt;br /&gt;
  com.sun.star.sdbc.XDriver xDriver;&lt;br /&gt;
  xDriver = (XDriver)UnoRuntime.queryInterface(XDriver.class, aDriver);&lt;br /&gt;
  &lt;br /&gt;
  if (xDriver != null) {&lt;br /&gt;
      // first create the needed url&lt;br /&gt;
      String adabasURL = &amp;quot;sdbc:adabas::MYDB0&amp;quot;;&lt;br /&gt;
      &lt;br /&gt;
      // second create the necessary properties&lt;br /&gt;
      com.sun.star.beans.PropertyValue [] adabasProps = new com.sun.star.beans.PropertyValue[] {&lt;br /&gt;
          new com.sun.star.beans.PropertyValue(&amp;quot;user&amp;quot;, 0, &amp;quot;test1&amp;quot;,&lt;br /&gt;
              com.sun.star.beans.PropertyState.DIRECT_VALUE),&lt;br /&gt;
          new com.sun.star.beans.PropertyValue(&amp;quot;password&amp;quot;, 0, &amp;quot;test1&amp;quot;,&lt;br /&gt;
              com.sun.star.beans.PropertyState.DIRECT_VALUE)&lt;br /&gt;
      };&lt;br /&gt;
  &lt;br /&gt;
      // now create a connection to adabas&lt;br /&gt;
      XConnection adabasConnection = xDriver.connect(adabasURL,adabasProps);&lt;br /&gt;
      &lt;br /&gt;
      if (xConnection != null) {&lt;br /&gt;
          System.out.println(&amp;quot;Connection was created!&amp;quot;);&lt;br /&gt;
          // now we dispose the connection to close it&lt;br /&gt;
          XComponent xComponent = (XComponent)UnoRuntime.queryInterface(XComponent.class, xConnection);&lt;br /&gt;
          if (xComponent != null) {&lt;br /&gt;
              xComponent.dispose();&lt;br /&gt;
              System.out.println(&amp;quot;Connection disposed!&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
      } else {&lt;br /&gt;
          System.out.println(&amp;quot;Connection could not be created!&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
[[Category: Database Access]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Connecting_Using_the_DriverManager_and_a_Database_URL&amp;diff=79171</id>
		<title>Documentation/DevGuide/Database/Connecting Using the DriverManager and a Database URL</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Connecting_Using_the_DriverManager_and_a_Database_URL&amp;diff=79171"/>
		<updated>2008-05-31T14:44:52Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/DatabaseTOC&lt;br /&gt;
|Database2b=block&lt;br /&gt;
|DatabaseConnections=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Database/Connecting Through a DataSource&lt;br /&gt;
|NextPage=Documentation/DevGuide/Database/Connecting Through a Specific Driver&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Connecting Using the DriverManager and a Database URL}}&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.sdbc.DriverManager&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The database context and establishing connections to a database even if there is no data source for it in {{PRODUCTNAME}} API can be avoided. &lt;br /&gt;
&lt;br /&gt;
To create a connection ask the driver manager for it. The &amp;lt;idl&amp;gt;com.sun.star.sdbc.DriverManager&amp;lt;/idl&amp;gt; manages database drivers. The methods of its interface &amp;lt;idl&amp;gt;com.sun.star.sdbc.XDriverManager&amp;lt;/idl&amp;gt; are used to connect to a database using a database URL:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  // establish connection&lt;br /&gt;
  com::sun::star::sdbc::XConnection getConnection( [in] string url)&lt;br /&gt;
  com::sun::star::sdbc::XConnection getConnectionWithInfo( [in] string url, &lt;br /&gt;
          [in] sequence &amp;lt; com::sun::star::beans::PropertyValue &amp;gt; info)&lt;br /&gt;
  &lt;br /&gt;
  // timeout for connection failure&lt;br /&gt;
  void setLoginTimeout( [in] long seconds)&lt;br /&gt;
  long getLoginTimeout()&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
Additionally, the driver manager enumerates all available drivers, and is used to register and deregister drivers. A URL that identifies a driver and contains information about the database to connect to must be known. The DriverManager chooses the first registered driver that accepts this URL. The following line of code illustrates it generally:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  Connection xConnection = DriverManager.getConnection(url);&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The structure of the URL consists of a protocol name, followed by the driver specific sub-protocol. The data source administration dialog shows the latest supported protocols. Some protocols are platform dependent. For example, ADO is only supported on Windows. &lt;br /&gt;
&lt;br /&gt;
The URLs and conditions for the various drivers are explained in section [[Documentation/DevGuide/Database/Driver Specifics|Driver Specifics]] below.&lt;br /&gt;
&lt;br /&gt;
Frequently a connection needs additional information, such as a user name, password or character set. Use the method &amp;lt;code&amp;gt;getConnectionWithInfo()&amp;lt;/code&amp;gt; to provide this information. The method &amp;lt;code&amp;gt;getConnectionWithInfo()&amp;lt;/code&amp;gt; takes a sequence of &amp;lt;idl&amp;gt;com.sun.star.beans.PropertyValue&amp;lt;/idl&amp;gt; structs. Usually user and password are supported. For other connection info properties, refer to the section [[Documentation/DevGuide/Database/Driver Specifics|Driver Specifics]]. &lt;br /&gt;
&amp;lt;!--[SOURCE:Database/CodeSamples.java]--&amp;gt;&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // create the DriverManager&lt;br /&gt;
  Object driverManager = xMultiServiceFactory.createInstance(&amp;quot;com.sun.star.sdbc.DriverManager&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
  // query for the interface XDriverManager&lt;br /&gt;
  com.sun.star.sdbc.XDriverManager xDriverManager;&lt;br /&gt;
  &lt;br /&gt;
  xDriverManager = (XDriverManager)UnoRuntime.queryInterface(&lt;br /&gt;
      XDriverManager.class, driverManager);&lt;br /&gt;
  &lt;br /&gt;
  if (xDriverManager != null) {&lt;br /&gt;
      // first create the database URL&lt;br /&gt;
      String adabasURL = &amp;quot;sdbc:adabas::MYDB0&amp;quot;;&lt;br /&gt;
    &lt;br /&gt;
      // create the necessary sequence of PropertyValue structs for user and password&lt;br /&gt;
      com.sun.star.beans.PropertyValue [] adabasProps = new com.sun.star.beans.PropertyValue[] { &lt;br /&gt;
          new com.sun.star.beans.PropertyValue(&amp;quot;user&amp;quot;, 0, &amp;quot;Scott&amp;quot;,&lt;br /&gt;
              com.sun.star.beans.PropertyState.DIRECT_VALUE),&lt;br /&gt;
          new com.sun.star.beans.PropertyValue(&amp;quot;password&amp;quot;, 0, &amp;quot;huutsch&amp;quot;,&lt;br /&gt;
              com.sun.star.beans.PropertyState.DIRECT_VALUE)&lt;br /&gt;
          };&lt;br /&gt;
  &lt;br /&gt;
      // now create a connection to Adabas&lt;br /&gt;
      XConnection xConnection = xDriverManager.getConnectionWithInfo(adabasURL, adabasProps);&lt;br /&gt;
      &lt;br /&gt;
      if (adabasConnection != null) {&lt;br /&gt;
          System.out.println(&amp;quot;Connection was created!&amp;quot;);&lt;br /&gt;
      &lt;br /&gt;
          // now we dispose the connection to close it&lt;br /&gt;
          XComponent xComponent = (XComponent)UnoRuntime.queryInterface(&lt;br /&gt;
              XComponent.class, xConnection );&lt;br /&gt;
      &lt;br /&gt;
          if (xComponent != null) {&lt;br /&gt;
              // connection must be disposed to avoid memory leaks&lt;br /&gt;
              xComponent.dispose();&lt;br /&gt;
              System.out.println(&amp;quot;Connection disposed!&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
      } else {&lt;br /&gt;
          System.out.println(&amp;quot;Connection could not be created!&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
[[Category: Database Access]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/ProUNO/Starting_OpenOffice.org_in_Listening_Mode&amp;diff=76966</id>
		<title>Documentation/DevGuide/ProUNO/Starting OpenOffice.org in Listening Mode</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/ProUNO/Starting_OpenOffice.org_in_Listening_Mode&amp;diff=76966"/>
		<updated>2008-05-12T07:53:21Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/ProUNOTOC&lt;br /&gt;
|ProUNO2b=block&lt;br /&gt;
|ProUNO2bUNOIC=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/ProUNO/UNO Interprocess Connections&lt;br /&gt;
|NextPage=Documentation/DevGuide/ProUNO/Importing a UNO Object&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Starting OpenOffice.org in Listening Mode}}&lt;br /&gt;
Most examples in this developers guide connect to a running {{PRODUCTNAME}} and perform API calls, which are then executed in {{PRODUCTNAME}}. By default, the office does not listen on a resource for security reasons. This makes it necessary to make {{PRODUCTNAME}} listen on an interprocess connection resource, for example, a socket. Currently this can be done in two ways: &lt;br /&gt;
&lt;br /&gt;
* Start the office with an additional parameter:&lt;br /&gt;
 &lt;br /&gt;
  soffice -accept=socket,host=0,port=2002;urp;&lt;br /&gt;
&lt;br /&gt;
This string has to be quoted on unix shells, because the semicolon &amp;#039;&amp;lt;code&amp;gt;;&amp;lt;/code&amp;gt;&amp;#039; is interpreted by the shells&lt;br /&gt;
&lt;br /&gt;
* Place the same string without &amp;lt;code&amp;gt;&amp;#039;-accept=&amp;#039;&amp;lt;/code&amp;gt; into a configuration file. You can edit the file &lt;br /&gt;
:&amp;#039;&amp;#039;&amp;lt;OfficePath&amp;gt;/share/registry/data/org/openoffice/Setup.xcu&amp;#039;&amp;#039;&lt;br /&gt;
:and replace the tag &lt;br /&gt;
  &amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;prop oor:name=&amp;quot;ooSetupConnectionURL&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
with &lt;br /&gt;
  &amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;prop oor:name=&amp;quot;ooSetupConnectionURL&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;value&amp;gt;socket,host=localhost,port=2002;urp;StarOffice.ServiceManager&lt;br /&gt;
  &amp;lt;/value&amp;gt;&lt;br /&gt;
  &amp;lt;/prop&amp;gt;&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
If the tag is not present, add it within the tag&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;node oor:name=&amp;quot;Office&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
This change affects the whole installation. If you want to configure it for a certain user in a network installation, add the same tag within the node &amp;lt;code&amp;gt;&amp;lt;node oor:name=&amp;quot;Office/&amp;gt;&amp;lt;/code&amp;gt; to the file &amp;#039;&amp;#039;Setup.xcu&amp;#039;&amp;#039; in the user dependent configuration directory &amp;#039;&amp;#039;&amp;lt;OfficePath&amp;gt;/user/registry/data/org/openoffice/&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Choose the procedure that suits your requirements and launch {{PRODUCTNAME}} in listening mode now. Check if it is listening by calling &amp;#039;&amp;#039;netstat -a&amp;#039;&amp;#039; or &amp;#039;&amp;#039;-na&amp;#039;&amp;#039; on the command-line. An output similar to the following shows that the office is listening:&lt;br /&gt;
&lt;br /&gt;
  TCP &amp;lt;Hostname&amp;gt;:8100 &amp;lt;Fully qualified hostname&amp;gt;: 0 Listening&lt;br /&gt;
&lt;br /&gt;
If you use the &amp;#039;&amp;#039;-n&amp;#039;&amp;#039; option, &amp;#039;&amp;#039;netstat&amp;#039;&amp;#039; displays addresses and port numbers in numerical form. This is sometimes useful on UNIX systems where it is possible to assign logical names to ports.&lt;br /&gt;
&lt;br /&gt;
If the office is not listening, it probably was not started with the proper connection URL parameter. Check the Setup.xcu file or your command-line for typing errors and try again. &lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|Note: In versions before {{PRODUCTNAME}} {{OOo1.x}}, there are several differences.&lt;br /&gt;
&lt;br /&gt;
The configuration setting that makes the office listen every time is located elsewhere. Open the file &amp;#039;&amp;#039;&amp;lt;OfficePath&amp;gt;/share/config/registry/instance/org/openoffice/Setup.xml&amp;#039;&amp;#039; in an editor, and look for the element:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;ooSetupConnectionURL cfg:type=&amp;quot;string&amp;quot;/&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Extend it with the following code:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;ooSetupConnectionURL cfg:type=&amp;quot;string&amp;quot;&amp;gt;&lt;br /&gt;
  socket,port=2083;urp;&lt;br /&gt;
  &amp;lt;/ooSetupConnectionURL&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The commandline option -accept is ignored when there is a running instance of the office, including the quick starter and the online help. If you use it, make sure that no soffice process runs on your system.}}&lt;br /&gt;
&lt;br /&gt;
The various parts of the connection URL will be discussed in the next section.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developers Guide/Professional UNO]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Connecting_Through_a_DataSource&amp;diff=76945</id>
		<title>Documentation/DevGuide/Database/Connecting Through a DataSource</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Connecting_Through_a_DataSource&amp;diff=76945"/>
		<updated>2008-05-10T19:08:43Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/DatabaseTOC&lt;br /&gt;
|Database2b=block&lt;br /&gt;
|DatabaseConnections=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Database/Connections&lt;br /&gt;
|NextPage=Documentation/DevGuide/Database/Connecting Using the DriverManager and a Database URL&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Connecting Through a DataSource}}&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.sdbc.XDataSource&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
Data sources in the database context of {{PRODUCTNAME}} API offer two methods to establish a connection, a non-interactive and an interactive procedure. Use the &amp;lt;idl&amp;gt;com.sun.star.sdbc.XDataSource&amp;lt;/idl&amp;gt; interface to connect. It consists of:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  // establish connection&lt;br /&gt;
  com::sun::star::sdbc::XConnection getConnection( &lt;br /&gt;
                  [in] string user, [in] string password)&lt;br /&gt;
  &lt;br /&gt;
  // timeout for connection failure&lt;br /&gt;
  void setLoginTimeout( [in] long seconds)&lt;br /&gt;
  long getLoginTimeout()&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
If a database does not support logins, pass empty strings to &amp;lt;code&amp;gt;getConnection()&amp;lt;/code&amp;gt;. For instance, use &amp;lt;code&amp;gt;getConnection()&amp;lt;/code&amp;gt; against dBase data sources like Bibliography:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  XNameAccess xNameAccess = (XNameAccess)UnoRuntime.queryInterface(&lt;br /&gt;
      XNameAccess.class, _rMSF.createInstance(&amp;quot;com.sun.star.sdb.DatabaseContext&amp;quot;));&lt;br /&gt;
  &lt;br /&gt;
  // we use the Bibliography data source&lt;br /&gt;
  XDataSource xDS = (XDataSource)UnoRuntime.queryInterface(&lt;br /&gt;
      XDataSource.class, xNameAccess.getByName(&amp;quot;Bibliography&amp;quot;));&lt;br /&gt;
  &lt;br /&gt;
  // simple way to connect&lt;br /&gt;
  XConnection xConnection = xDS.getConnection(&amp;quot;&amp;quot;, &amp;quot;&amp;quot;);&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
However if the database expects a login procedure, hard code the user and password, although this is not advisable. Data sources support an advanced login concept. Their interface &amp;lt;idl&amp;gt;com.sun.star.sdb.XCompletedConnection&amp;lt;/idl&amp;gt; starts an interactive login, if necessary:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  com::sun::star::sdbc::XConnection connectWithCompletion(&lt;br /&gt;
                  [in] com::sun::star::task::XInteractionHandler handler)&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
When you call &amp;lt;code&amp;gt;connectWithCompletion()&amp;lt;/code&amp;gt;, {{PRODUCTNAME}} API shows the common login dialog to the user if the data source property &amp;lt;code&amp;gt;IsPasswordRequired&amp;lt;/code&amp;gt; is true. The login dialog is part of the &amp;lt;idl&amp;gt;com.sun.star.sdb.InteractionHandler&amp;lt;/idl&amp;gt; provided by the global service factory.&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // logs into a database and returns a connection&lt;br /&gt;
  // expects a reference to the global service manager&lt;br /&gt;
  com.sun.star.sdbc.XConnection logon(XMultiServiceFactory _rMSF) throws com.sun.star.uno.Exception {&lt;br /&gt;
  &lt;br /&gt;
      // retrieve the DatabaseContext and get its com.sun.star.container.XNameAccess interface&lt;br /&gt;
      XNameAccess xNameAccess = (XNameAccess)UnoRuntime.queryInterface(&lt;br /&gt;
          XNameAccess.class, _rMSF.createInstance(&amp;quot;com.sun.star.sdb.DatabaseContext&amp;quot;));&lt;br /&gt;
      &lt;br /&gt;
      // get an Adabas D data source Ada01 generated in the GUI&lt;br /&gt;
      Object dataSource = xNameAccess.getByName(&amp;quot;Ada01&amp;quot;);&lt;br /&gt;
      &lt;br /&gt;
      // create a com.sun.star.sdb.InteractionHandler and get its XInteractionHandler interface&lt;br /&gt;
      Object interactionHandler = _rMSF.createInstance(&amp;quot;com.sun.star.sdb.InteractionHandler&amp;quot;);&lt;br /&gt;
      XInteractionHandler xInteractionHandler = (XInteractionHandler)UnoRuntime.queryInterface(&lt;br /&gt;
          XInteractionHandler.class, interactionHandler);&lt;br /&gt;
      &lt;br /&gt;
      // query for the XCompletedConnection interface of the data source&lt;br /&gt;
      XCompletedConnection xCompletedConnection = (XCompletedConnection)UnoRuntime.queryInterface(&lt;br /&gt;
          XCompletedConnection.class, dataSource);&lt;br /&gt;
      &lt;br /&gt;
      // connect with interactive login&lt;br /&gt;
      XConnection xConnection = xCompletedConnection.connectWithCompletion(xInteractionHandler);&lt;br /&gt;
      &lt;br /&gt;
      return XConnection;&lt;br /&gt;
  }&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
[[Category: Database Access]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Connections&amp;diff=76944</id>
		<title>Documentation/DevGuide/Database/Connections</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Connections&amp;diff=76944"/>
		<updated>2008-05-10T19:06:05Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/DatabaseTOC&lt;br /&gt;
|Database2b=block&lt;br /&gt;
|DatabaseConnections=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Database/Tables and Columns&lt;br /&gt;
|NextPage=Documentation/DevGuide/Database/Connecting Through a DataSource&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Connections}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
=== Understanding Connections ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.sdb.Connection&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
A &amp;#039;&amp;#039;connection&amp;#039;&amp;#039; is an open communication channel to a database. A connection is required to work with data in a database or with a database definition. Connections are encapsulated in Connection objects in the {{PRODUCTNAME}} API. There are several possibilities to get a Connection:&lt;br /&gt;
&lt;br /&gt;
* Connect to a data source that has already been set up in the database context of {{PRODUCTNAME}} API.&lt;br /&gt;
* Use the driver manager or a specific driver to connect to a database without using an existing data source from the database context.&lt;br /&gt;
* Get a connection from the connection pool maintained by {{PRODUCTNAME}} API.&lt;br /&gt;
* Reuse the connection of a database form which is currently open in the GUI.&lt;br /&gt;
&lt;br /&gt;
With the above possibilities, a &amp;lt;idl&amp;gt;com.sun.star.sdb.Connection&amp;lt;/idl&amp;gt; is made or at least a &amp;lt;idl&amp;gt;com.sun.star.sdbc.Connection&amp;lt;/idl&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
[[Image:Sdb_Connection.png|none|thumb|400px|&amp;lt;idl&amp;gt;com.sun.star.sdb.Connection&amp;lt;/idl&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
The service &amp;lt;idl&amp;gt;com.sun.star.sdb.Connection&amp;lt;/idl&amp;gt; has three main functions: communication, data definition and operation on the {{PRODUCTNAME}} API application level. The service:&lt;br /&gt;
&lt;br /&gt;
* Handles the communication with a database including statement execution, transactions, database metadata and warnings through the simple connection service of the SDBC layer &amp;lt;idl&amp;gt;com.sun.star.sdbc.Connection&amp;lt;/idl&amp;gt;. &lt;br /&gt;
* Handles database definition tasks, primarily table definitions, through the service &amp;lt;idl&amp;gt;com.sun.star.sdbcx.DatabaseDefinition&amp;lt;/idl&amp;gt;. Optionally, it manages views, users and groups.&lt;br /&gt;
* Organizes query definitions on the application level and provides a method to open queries and tables defined in {{PRODUCTNAME}} API. Query definitions are organized by the interfaces &amp;lt;idl&amp;gt;com.sun.star.sdb.XQueriesSupplier&amp;lt;/idl&amp;gt; and &amp;lt;idl&amp;gt;com.sun.star.sdb.XSQLQueryComposerFactory&amp;lt;/idl&amp;gt;. Queries and tables can be opened using &amp;lt;idl&amp;gt;com.sun.star.sdb.XCommandPreparation&amp;lt;/idl&amp;gt;. In case the underlying data source is needed, &amp;lt;idl&amp;gt;com.sun.star.container.XChild&amp;lt;/idl&amp;gt; provides the parent data source. This is useful when using an existing connection, for instance, of a database form, to act upon its data source.&lt;br /&gt;
Connections are central to all database activities. The connection interfaces are discussed later.&lt;br /&gt;
&lt;br /&gt;
==== Communication ====&lt;br /&gt;
&lt;br /&gt;
The main interface of &amp;lt;idl&amp;gt;com.sun.star.sdbc.Connection&amp;lt;/idl&amp;gt; is &amp;lt;idl&amp;gt;com.sun.star.sdbc.XConnection&amp;lt;/idl&amp;gt;. Its methods control almost every aspect of communication with a database management system:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  // general connection control&lt;br /&gt;
  void close()&lt;br /&gt;
  boolean isClosed()&lt;br /&gt;
  void setReadOnly( [in] boolean readOnly)&lt;br /&gt;
  boolean isReadOnly()&lt;br /&gt;
  &lt;br /&gt;
  // commands and statements&lt;br /&gt;
  // - generic SQL statement&lt;br /&gt;
  // - prepared statement&lt;br /&gt;
  // - stored procedure call&lt;br /&gt;
  com::sun::star::sdbc::XStatement createStatement()&lt;br /&gt;
  com::sun::star::sdbc::XPreparedStatement prepareStatement( [in] string sql)&lt;br /&gt;
  com::sun::star::sdbc::XPreparedStatement prepareCall( [in] string sql)&lt;br /&gt;
  string nativeSQL( [in] string sql)&lt;br /&gt;
  &lt;br /&gt;
  // transactions&lt;br /&gt;
  void setTransactionIsolation( [in] long level)&lt;br /&gt;
  long getTransactionIsolation()&lt;br /&gt;
  void setAutoCommit( [in] boolean autoCommit)&lt;br /&gt;
  boolean getAutoCommit()&lt;br /&gt;
  void commit()&lt;br /&gt;
  void rollback()&lt;br /&gt;
  &lt;br /&gt;
  // database metadata&lt;br /&gt;
  com::sun::star::sdbc::XDatabaseMetaData getMetaData()&lt;br /&gt;
  &lt;br /&gt;
  // data type mapping (driver dependent)&lt;br /&gt;
  com::sun::star::container::XNameAccess getTypeMap()&lt;br /&gt;
  void setTypeMap( [in] com::sun::star::container::XNameAccess typeMap)&lt;br /&gt;
  &lt;br /&gt;
  // catalog (subspace in a database)&lt;br /&gt;
  void setCatalog( [in] string catalog)&lt;br /&gt;
  string getCatalog()&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The use of commands and statements are explained in the sections [[Documentation/DevGuide/Database/Manipulating the Data|Manipulating Data]] and [[Documentation/DevGuide/Database/Using DDL to Change the Database Design|Using DDL to Change the Database Design]]. Transactions are discussed in [[Documentation/DevGuide/Database/Using DBMS Features|Using DBMS Features]]. Database metadata are covered in [[Documentation/DevGuide/Database/Database Design#Retrieving Information about a Database|Retrieving Information about a Database]].&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;idl&amp;gt;com.sun.star.sdbc.XWarningsSupplier&amp;lt;/idl&amp;gt; is a simple interface to handle SQL warnings:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  any getWarnings()&lt;br /&gt;
  void clearWarnings()&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The exception &amp;lt;idl&amp;gt;com.sun.star.sdbc.SQLWarning&amp;lt;/idl&amp;gt; is usually not thrown, rather it is transported silently to objects supporting &amp;lt;idl&amp;gt;com.sun.star.sdbc.XWarningsSupplier&amp;lt;/idl&amp;gt;. Refer to the API reference for more information about SQL warnings.&lt;br /&gt;
&lt;br /&gt;
==== Data Definition ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.sdbcx.DatabaseDefinition&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The interfaces of &amp;lt;idl&amp;gt;com.sun.star.sdbcx.DatabaseDefinition&amp;lt;/idl&amp;gt; are explained in the section [[Documentation/DevGuide/Database/Using SDBCX to Access the Database Design|Using SDBCX to Access the Database Design]].&lt;br /&gt;
&lt;br /&gt;
==== Operation on Application Level ====&lt;br /&gt;
&lt;br /&gt;
Handling of query definitions through &amp;lt;idl&amp;gt;com.sun.star.sdb.XQueriesSupplier&amp;lt;/idl&amp;gt; and &amp;lt;idl&amp;gt;com.sun.star.sdb.XSQLQueryComposerFactory&amp;lt;/idl&amp;gt; is discussed in the section [[Documentation/DevGuide/Database/Queries|Queries]] .&lt;br /&gt;
&lt;br /&gt;
Through &amp;lt;idl&amp;gt;com.sun.star.sdb.XCommandPreparation&amp;lt;/idl&amp;gt; get the necessary statement objects to open predefined queries and tables in a data source, and execute arbitrary SQL statements. &lt;br /&gt;
 &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  com::sun::star::sdbc::XPreparedStatement prepareCommand( [in] string command, [in] long commandType)&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
If the value of the parameter &amp;lt;idl&amp;gt;com.sun.star.sdb.CommandType&amp;lt;/idl&amp;gt; is &amp;lt;code&amp;gt;TABLE&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;QUERY&amp;lt;/code&amp;gt;, pass a table name or query name that exists in the &amp;lt;idl&amp;gt;com.sun.star.sdb.DataSource&amp;lt;/idl&amp;gt; of the connection. The value &amp;lt;code&amp;gt;COMMAND&amp;lt;/code&amp;gt; makes &amp;lt;code&amp;gt;prepareCommand()&amp;lt;/code&amp;gt; expect an SQL string. The result is a prepared statement object that can be parameterized and executed. For details and an example, refer to section [[Documentation/DevGuide/Database/PreparedStatement From DataSource Queries|PreparedStatement From DataSource Queries]].&lt;br /&gt;
&lt;br /&gt;
The interface &amp;lt;idl&amp;gt;com.sun.star.container.XChild&amp;lt;/idl&amp;gt; accesses the parent &amp;lt;idl&amp;gt;com.sun.star.sdb.DataSource&amp;lt;/idl&amp;gt; of the connection, if available.&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  com::sun::star::uno::XInterface getParent()&lt;br /&gt;
  void setParent( [in] com::sun::star::uno::XInterface Parent)&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
[[Category: Database Access]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Config/Connecting_to_a_Data_Source&amp;diff=76943</id>
		<title>Documentation/DevGuide/Config/Connecting to a Data Source</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Config/Connecting_to_a_Data_Source&amp;diff=76943"/>
		<updated>2008-05-10T19:01:37Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/ConfigTOC&lt;br /&gt;
|Config2a=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Config/Configuration Data Sources&lt;br /&gt;
|NextPage=Documentation/DevGuide/Config/Using a Data Source&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Connecting to a Data Source}}&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.configuration.ConfigurationProvider;com.sun.star.configuration.AdministrationProvider&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The first step to access the configuration database is to connect to a configuration data source. &lt;br /&gt;
&lt;br /&gt;
To obtain a provider instance ask the global &amp;lt;idl&amp;gt;com.sun.star.lang.ServiceManager&amp;lt;/idl&amp;gt; for a &amp;lt;idl&amp;gt;com.sun.star.configuration.ConfigurationProvider&amp;lt;/idl&amp;gt;. Typically the first lines of code to get access to configuration data look similar to the following: &lt;br /&gt;
&amp;lt;!--[SOURCE:Config/ConfigExamples.java]--&amp;gt;&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // get my global service manager &lt;br /&gt;
  XMultiServiceFactory xServiceManager = (XMultiServiceFactory)UnoRuntime.queryInterface(&lt;br /&gt;
  XMultiServiceFactory.class, this.getRemoteServiceManager(&lt;br /&gt;
      &amp;quot;uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager&amp;quot;)); &lt;br /&gt;
  &lt;br /&gt;
  final String sProviderService = &amp;quot;com.sun.star.configuration.ConfigurationProvider&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  // create the provider and remember it as a XMultiServiceFactory&lt;br /&gt;
  XMultiServiceFactory xProvider = (XMultiServiceFactory)&lt;br /&gt;
      UnoRuntime.queryInterface(XMultiServiceFactory.class, &lt;br /&gt;
          xServiceManager.createInstance(sProviderService));&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
This code creates a default &amp;lt;idl&amp;gt;com.sun.star.configuration.ConfigurationProvider&amp;lt;/idl&amp;gt;. The most important interface a &amp;lt;idl&amp;gt;com.sun.star.configuration.ConfigurationProvider&amp;lt;/idl&amp;gt; implements is &amp;lt;idl&amp;gt;com.sun.star.lang.XMultiServiceFactory&amp;lt;/idl&amp;gt; that is used to create further configuration objects.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;idl&amp;gt;com.sun.star.configuration.ConfigurationProvider&amp;lt;/idl&amp;gt; always operates in the user mode, accessing data on behalf of the current user and directing updates to the user&amp;#039;s personal layer.&lt;br /&gt;
&lt;br /&gt;
For administrative access to manipulate the default layers the &amp;lt;idl&amp;gt;com.sun.star.configuration.AdministrationProvider&amp;lt;/idl&amp;gt; is used. When creating this service, additional parameters can be used that select the layer for updates or that contain credentials used to authorize administrative access. The backend that is used determines which default layers exist, how they are addressed and how administrative access is authorized. &lt;br /&gt;
&lt;br /&gt;
The standard file-based backend has several shared layers. One of these layers is used to store shared default data. The files for this layer are located in the share directory of the {{PRODUCTNAME}} installation. To gain administrative access to this layer, no additional parameters are needed. An &amp;lt;idl&amp;gt;com.sun.star.configuration.AdministrationProvider&amp;lt;/idl&amp;gt; for this backend automatically tries to read and write this shared layer. Additionally there are special layers that are used by the Extension Manager for deploying configuration data associated with extensions. For details, see [[Documentation/DevGuide/Extensions/Extensions|Extensions]]. &lt;br /&gt;
&lt;br /&gt;
Authorization for the file-based backend is done by the operating system based upon file access privileges. The current user requires write privileges in the shared configuration directory if an &amp;lt;code&amp;gt;AdministrationProvider&amp;lt;/code&amp;gt; is suppose to update configuration data.&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;idl&amp;gt;com.sun.star.configuration.AdministrationProvider&amp;lt;/idl&amp;gt; is created in the same way as a &amp;lt;idl&amp;gt;com.sun.star.configuration.ConfigurationProvider&amp;lt;/idl&amp;gt;.&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // get my global service manager&lt;br /&gt;
  XMultiServiceFactory xServiceManager = getServiceManager();&lt;br /&gt;
  &lt;br /&gt;
  // get the arguments to use &lt;br /&gt;
  com.sun.star.beans.PropertyValue aReinitialize = new com.sun.star.beans.PropertyValue()&lt;br /&gt;
  aReinitialize.Name = &amp;quot;reinitialize&amp;quot;&lt;br /&gt;
  aReinitialize.Value = new Boolean(true);&lt;br /&gt;
  &lt;br /&gt;
  Object[] aProviderArguments = new Object[1];&lt;br /&gt;
  aProviderArguments[0] = aReinitialize;&lt;br /&gt;
  &lt;br /&gt;
  final String sAdminService = &amp;quot;com.sun.star.configuration.AdministrationProvider&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  // create the provider and remember it as a XMultiServiceFactory&lt;br /&gt;
  XMultiServiceFactory xAdminProvider = (XMultiServiceFactory)&lt;br /&gt;
      UnoRuntime.queryInterface(XMultiServiceFactory.class,&lt;br /&gt;
          xServiceManager.createInstanceWithArguments(sAdminService,aProviderArguments));&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
As you see in the example above, the default &amp;lt;idl&amp;gt;com.sun.star.configuration.AdministrationProvider&amp;lt;/idl&amp;gt; supports a special parameter for reinitialization:&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;
!Parameter Name &lt;br /&gt;
!Type &lt;br /&gt;
!Default &lt;br /&gt;
!Comments &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;reinitialize&amp;lt;/code&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt;&lt;br /&gt;
|&amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;&lt;br /&gt;
|Discard any cached information from previous runs and regenerate from scratch. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some backend implementations use cached data to speed up access. If the &amp;lt;code&amp;gt;reinitialize&amp;lt;/code&amp;gt; parameter is &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;, this cache will be recreated from the XML data when the &amp;lt;code&amp;gt;AdministrationProvider&amp;lt;/code&amp;gt; is created. With the current implementation, the parameter has no effect.&lt;br /&gt;
&lt;br /&gt;
When establishing the connection, specify the parameters that select the backend to use and additional backend-specific parameters to select the data source. When there are no parameters given, the standard configuration backend and data source of the {{PRODUCTNAME}} installation is used.&lt;br /&gt;
&lt;br /&gt;
The standard values for these parameters may be found in the configuration file&amp;#039;&amp;#039; configmgr(.ini|rc)&amp;#039;&amp;#039; (&amp;#039;&amp;#039;.ini&amp;#039;&amp;#039; on Windows, &amp;#039;&amp;#039;rc&amp;#039;&amp;#039; on Unix) in the program directory of the {{PRODUCTNAME}} installation. The INI entries have a prefix &amp;quot;CFG_&amp;quot; before the parameter name. &lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|The list of available backends and the parameters they support may change in a future release. Using these parameters is normally not necessary and therefore is not recommended.}}&lt;br /&gt;
&lt;br /&gt;
The following parameters are supported to select the backend component to use:&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;
!Parameter Name &lt;br /&gt;
!Type &lt;br /&gt;
!Default &lt;br /&gt;
!Comments &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;BackendService&amp;lt;/code&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; &lt;br /&gt;
|&amp;quot;&amp;lt;idl&amp;gt;com.sun.star.configuration.backend.LocalSingleBackend&amp;lt;/idl&amp;gt;&amp;quot; &lt;br /&gt;
|This must be a UNO service or implementation name that can be used to create a service instance. The instance created must support either service &amp;lt;idl&amp;gt;com.sun.star.configuration.backend.Backend&amp;lt;/idl&amp;gt; or service &amp;lt;idl&amp;gt;com.sun.star.configuration.backend.SingleBackend&amp;lt;/idl&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;BackendWrapper&amp;lt;/code&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; &lt;br /&gt;
|&amp;quot;&amp;lt;idl&amp;gt;com.sun.star.configuration.backend.SingleBackendAdapter&amp;lt;/idl&amp;gt;&amp;quot; &lt;br /&gt;
|This parameter is used only, if the service specified by parameter &amp;quot;BackendService&amp;quot; only implements service [IDLS:com.sun.star.configuration.backend.SingleBackend, but does not support service &amp;lt;idls&amp;gt;com.sun.star.configuration.backend.Backend&amp;lt;/idls&amp;gt;. It must be a UNO service or implementation name that can be used to create a service instance. The instance created must support service &amp;lt;idl&amp;gt;com.sun.star.configuration.backend.BackendAdapter&amp;lt;/idl&amp;gt;. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following parameter was formerly supported to select the type of backend to use:&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;
!Parameter Name &lt;br /&gt;
!Type &lt;br /&gt;
!Default &lt;br /&gt;
!Comments &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;servertype&amp;lt;/code&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;&amp;quot;uno&amp;quot;&amp;lt;/code&amp;gt; &lt;br /&gt;
|Other values are not supported any more in {{PRODUCTNAME}}. This setting formerly was used to select between several internal backend implementations. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For the &amp;quot;&amp;lt;idl&amp;gt;com.sun.star.configuration.backend.LocalSingleBackend&amp;lt;/idl&amp;gt;&amp;quot; backend, the following parameters are used to select the location of data:&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;
!Parameter Name &lt;br /&gt;
!Type &lt;br /&gt;
!Default &lt;br /&gt;
!Comments &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;SchemaDataUrl&amp;lt;/code&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;string[]&amp;lt;/code&amp;gt; &lt;br /&gt;
|$(installurl)/share/registry/schema &lt;br /&gt;
&lt;br /&gt;
+ locations used for extensions &lt;br /&gt;
|This must be a file URL pointing to a directory, a whitespace-separated list of such URLs or a sequence of such URLs. &lt;br /&gt;
&lt;br /&gt;
The locations are searched in the given order until a schema is found. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;DefaultLayerUrls&amp;lt;/code&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;string[]&amp;lt;/code&amp;gt; &lt;br /&gt;
|$(installurl)/share/registry &lt;br /&gt;
&lt;br /&gt;
+ locations used for extensions &lt;br /&gt;
|This must be a file URL pointing to a directory, a whitespace-separated list of such URLs or a sequence of such URLs. &lt;br /&gt;
&lt;br /&gt;
The layers are merged in the given order.&lt;br /&gt;
&lt;br /&gt;
The data is located in subdirectory data of each location. Additionally locale-specific data can be placed in subdirectory res. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;UserLayerUrl&amp;lt;/code&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; &lt;br /&gt;
|$(userurl)/user/registry &lt;br /&gt;
|This must be a file URL pointing to a directory.&lt;br /&gt;
&lt;br /&gt;
If this is one of the entries of parameter &amp;quot;&amp;lt;code&amp;gt;DefaultLayerUrls&amp;lt;/code&amp;gt;&amp;quot;, then only the entries before it will be used as default layers.&lt;br /&gt;
&lt;br /&gt;
The data is located in the subdirectory data of the given location. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Arguments can be provided that determine the default behavior of views created through this &amp;lt;idl&amp;gt;com.sun.star.configuration.ConfigurationProvider&amp;lt;/idl&amp;gt;. The following parameters may be used for this purpose:&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;
!Parameter Name &lt;br /&gt;
!Type &lt;br /&gt;
!Default &lt;br /&gt;
!Comments &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;Locale&amp;lt;/code&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; &lt;br /&gt;
|The user&amp;#039;s locale. &lt;br /&gt;
|This parameter was called &amp;quot;&amp;lt;code&amp;gt;locale&amp;lt;/code&amp;gt;&amp;quot; in a former version. The old name is still supported for compatibility. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;EnableAsync&amp;lt;/code&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; &lt;br /&gt;
|This parameter was called &amp;quot;&amp;lt;code&amp;gt;lazywrite&amp;lt;/code&amp;gt;&amp;quot; in a former version. The old name is still supported for compatibility. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Caution|The default configuration provider obtained when no arguments are given will always be the same object. Be careful not to call &amp;lt;idlml&amp;gt;com.sun.star.lang.XComponent:dispose&amp;lt;/idlml&amp;gt;() on this shared &amp;lt;idl&amp;gt;com.sun.star.configuration.ConfigurationProvider&amp;lt;/idl&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
If you provide any arguments, then a new instance is created. You must then call &amp;lt;idlml&amp;gt;com.sun.star.lang.XComponent:dispose&amp;lt;/idlml&amp;gt;() on this &amp;lt;idl&amp;gt;com.sun.star.configuration.ConfigurationProvider&amp;lt;/idl&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
[[Category: Configuration Management]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Config/Configuration_Management&amp;diff=76942</id>
		<title>Documentation/DevGuide/Config/Configuration Management</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Config/Configuration_Management&amp;diff=76942"/>
		<updated>2008-05-10T18:57:18Z</updated>

		<summary type="html">&lt;p&gt;Beppec56: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/ConfigTOC&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/UCB/Content Provider Proxies&lt;br /&gt;
|NextPage=Documentation/DevGuide/Config/Object Model&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Configuration Management}}&lt;br /&gt;
=== Capabilities ===&lt;br /&gt;
The {{PRODUCTNAME}} configuration management component provides a uniform interface to get and set {{PRODUCTNAME}} configuration data in an organized manner, independent of the physical data store used for the data.&lt;br /&gt;
&lt;br /&gt;
The configuration API can be used to get and set existing configuration options. Additionally you can extend the configuration with new settings for your own purposes. For details, see [[Documentation/DevGuide/Config/Customizing Configuration Data|Customizing Configuration Data]].&lt;br /&gt;
&lt;br /&gt;
=== Architecture ===&lt;br /&gt;
&lt;br /&gt;
{{PRODUCTNAME}} configuration data describes the state or environment of a UNO component or the {{PRODUCTNAME}} application. There are different kinds of configuration data:&lt;br /&gt;
&lt;br /&gt;
* Static configuration: This is data that describes the configuration of the software and hardware environment. This data is set by a setup tool and does not change at runtime. An example of static configuration data is information about installed filters.&lt;br /&gt;
* Explicit settings: This is preference data that can be controlled by the user explicitly. There is a dedicated UI to change these settings. An example explicit settings are the settings controlled through the &amp;#039;&amp;#039;&amp;#039;Tools - Options&amp;#039;&amp;#039;&amp;#039; dialogs in {{PRODUCTNAME}}.&lt;br /&gt;
* Implicit settings: This is status information that is also controlled by the user, but the user does not change explicitly. The application tracks this state in the background, making it persistent across application sessions. An example implicit settings are window positions and states, or a list of the recently used documents.&lt;br /&gt;
&lt;br /&gt;
This list is not comprehensive, but indicates the range of data characteristically stored by configuration management.&lt;br /&gt;
&lt;br /&gt;
The configuration management component organizes the configuration data in a hierarchical structure. The hierarchical structure and the names and data types of entries in this database are described by a schema. Only data that conforms to one of the installed schemas is stored in the database. &lt;br /&gt;
&lt;br /&gt;
The hierarchical database stores any hierarchical information that can be described as a configuration schema, but it is optimized to work with the data needed for application configuration and preferences. Small data items having a well-defined data type are supported efficiently, whereas large, unspecific binary objects should not be stored in the configuration database. These objects should be stored in separate files so that the configuration keeps the URLs of these files only.&lt;br /&gt;
&lt;br /&gt;
Configuration schemas are provided by the authors of applications and components that use the data. When a component is installed, the corresponding configuration schemas are installed into the configuration management system.&lt;br /&gt;
&lt;br /&gt;
Configuration data is stored in a backend data store. In {{PRODUCTNAME}}, the standard backend consists of XML files stored in a directory hierarchy. You can add another backend component to be used instead. Support for combining data from multiple backends is planned for a future release.&lt;br /&gt;
&lt;br /&gt;
[[Image:Config_layering.png|none|thumb|400px|Configuration layers]]&lt;br /&gt;
&lt;br /&gt;
For a given schema, multiple layers of data may exist that are merged together at runtime. One or more of these layers define default settings, possibly shared by several users. Additionally, there is a layer specific to a single user that contains personal preferences overriding the shared settings. In normal operations all changes to data affect only this user-specific layer.&lt;br /&gt;
&lt;br /&gt;
Access to the merged configuration data for a user is managed by a &amp;lt;idl&amp;gt;com.sun.star.configuration.ConfigurationProvider&amp;lt;/idl&amp;gt; object to connect to a data source, fetch and store data, and merge layers.&lt;br /&gt;
&lt;br /&gt;
This provider provides views on the configuration data. A view is a subset of the entire configuration that can be navigated as an object hierarchy. The objects in this hierarchy represent nodes of the configuration hierarchy to navigate to other nodes and access values of data items.&lt;br /&gt;
&lt;br /&gt;
All configuration items have a fixed type and a name.&lt;br /&gt;
&lt;br /&gt;
The type is prescribed by the schema. The following kinds of items are available:&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;Properties&amp;#039; are &amp;#039;&amp;#039;data&amp;#039;&amp;#039; items that contain a single data value or an array of values from a limited set of basic types.&lt;br /&gt;
* &amp;#039;Groups&amp;#039; are &amp;#039;&amp;#039;structural&amp;#039;&amp;#039; nodes that contain a collection of child items of various types. The number and names of children, as well as their types, are &amp;#039;&amp;#039;fixed&amp;#039;&amp;#039; by the schema. Structural and data items can be mixed within one group.&lt;br /&gt;
* &amp;#039;Sets&amp;#039; are &amp;#039;&amp;#039;structural&amp;#039;&amp;#039; nodes that serve as dynamic containers for a variable number of elements. These elements must be all data or all structural items, and they must all be uniform. In the first case, all values have the same basic type, and in the latter case, all the sub-trees have the same structure. The schema contains templates for container elements, which are prototypes of the element structure.&lt;br /&gt;
&lt;br /&gt;
Properties hold the actual data. Group nodes form the structural skeleton defined in the schema. Set nodes are used to dynamically add and remove configuration data within the confines of the schema. Taken together, they can be used to build hierarchical structures of arbitrary complexity. &lt;br /&gt;
&lt;br /&gt;
Each configuration item has a name that uniquely identifies the item within its parent, that is, the node in the hierarchical tree that immediately contains the item under consideration. Paths spanning multiple levels of the hierarchy are built similarly to UNIX file system paths. The separator for individual name components in paths is a forward slash (&amp;#039;/&amp;#039;). Paths that begin with a slash are considered &amp;#039;absolute paths&amp;#039; and must completely specify the location of an item within the hierarchy. Paths that start directly with a name are relative paths and describe the location of an item within one of its ancestors in the hierarchy.&lt;br /&gt;
&lt;br /&gt;
The top-level subdivisions of the configuration hierarchy are called configuration modules. Each configuration module has a schema that describes the data items available within that module. Modules are the unit of schema installation. The name of a configuration module must be globally unique. The names of configuration modules have an internal hierarchical structure using a dot (&amp;#039;.&amp;#039;) as a separator, similar to Java package names. The predefined configuration modules of {{PRODUCTNAME}} use package names from the super-package &amp;quot;org.openoffice.*&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The names of container elements are specified when data items are added to a container. Data item names in the schema are limited to ASCII letters, digits and a few punctuation marks, but there are no restrictions applied to the names of container elements. This requires special handling when referring to a container element in a path. A path component addressing a container element takes the form &amp;lt;code&amp;gt;&amp;lt;template-pattern&amp;gt;[&amp;#039;&amp;lt;escaped-name&amp;gt;&amp;#039;]&amp;lt;/code&amp;gt;. Here &amp;lt;code&amp;gt;&amp;lt;template-pattern&amp;gt;&amp;lt;/code&amp;gt; can be the name of the template describing the element or an asterisk &amp;quot;&amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt;&amp;quot; to match any template. The &amp;lt;code&amp;gt;&amp;lt;escaped-name&amp;gt;&amp;lt;/code&amp;gt; is a representation of the name of the element where a few forbidden characters are represented in an escaped form borrowed from XML. The quotes delimiting the &amp;lt;code&amp;gt;&amp;lt;escaped-name&amp;gt;&amp;lt;/code&amp;gt; may alternatively be double quote characters &amp;lt;code&amp;gt;&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;. The following character escapes are used: &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;
!Character &lt;br /&gt;
!Escape &lt;br /&gt;
|-&lt;br /&gt;
|&amp;amp; &lt;br /&gt;
|&amp;amp;amp; &lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot; &lt;br /&gt;
|&amp;amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|&amp;#039; &lt;br /&gt;
|&amp;amp;apos; &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the table below, are some escaped forms for invented entries in the Set node &amp;lt;code&amp;gt;/org.openoffice.Office.TypeDetection/Filters&amp;lt;/code&amp;gt; for (fictitious) filters:&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;
!Filter Name &lt;br /&gt;
!Path Component  &lt;br /&gt;
|-&lt;br /&gt;
|Plain Text  &lt;br /&gt;
|Filter[&amp;#039;Plain Text&amp;#039;] &lt;br /&gt;
|-&lt;br /&gt;
|Q &amp;amp; A Book &lt;br /&gt;
|*[&amp;quot;Q &amp;amp;amp; A Book&amp;quot;] &lt;br /&gt;
|-&lt;br /&gt;
|Bob&amp;#039;s Filter &lt;br /&gt;
|*[&amp;#039;Bob&amp;amp;apos;s Filter&amp;#039;] &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The UIName value of the last example filter would have an absolute path of &amp;lt;code&amp;gt;/org.openoffice.Office.TypeDetection/Filters/Filter[&amp;#039;Bob&amp;amp;apos;s Filter&amp;#039;]/UIName&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In several places in the configuration management, API arguments are passed to a newly created object instance as Sequence, for example, in the argument to &amp;lt;idlml&amp;gt;com.sun.star.lang.XMultiServiceFactory:createInstanceWithArguments&amp;lt;/idlml&amp;gt;. Such arguments are type &amp;lt;idl&amp;gt;com.sun.star.beans.NamedValue&amp;lt;/idl&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|For compatibility with older versions, arguments of type &amp;lt;idl&amp;gt;com.sun.star.beans.PropertyValue&amp;lt;/idl&amp;gt; are accepted as well. Only the &amp;lt;idlm&amp;gt;com.sun.star.beans.PropertyValue:Name&amp;lt;/idlm&amp;gt; and &amp;lt;idlm&amp;gt;com.sun.star.beans.PropertyValue:Value&amp;lt;/idlm&amp;gt; fields need to be filled.}}&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
[[Category: Configuration Management]]&lt;/div&gt;</summary>
		<author><name>Beppec56</name></author>
	</entry>
</feed>