<?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=Newacct</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=Newacct"/>
	<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/wiki/Special:Contributions/Newacct"/>
	<updated>2026-05-16T14:15:14Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.14</generator>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/WritingUNO/Implementing_without_Helpers&amp;diff=195307</id>
		<title>Documentation/DevGuide/WritingUNO/Implementing without Helpers</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/WritingUNO/Implementing_without_Helpers&amp;diff=195307"/>
		<updated>2011-03-23T01:22:35Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/WritingUNOTOC&lt;br /&gt;
|WritingUNO2c=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/WritingUNO/Write Registration Info Using a Helper Method&lt;br /&gt;
|NextPage=Documentation/DevGuide/WritingUNO/Storing the Service Manager for Further Use&lt;br /&gt;
}}&lt;br /&gt;
{{Documentation/DevGuideLanguages|Documentation/DevGuide/WritingUNO/{{SUBPAGENAME}}}}&lt;br /&gt;
{{DISPLAYTITLE:Implementing without Helpers}}&lt;br /&gt;
=== XInterface ===&lt;br /&gt;
&lt;br /&gt;
As soon as the component implements any UNO interface, &amp;lt;idl&amp;gt;com.sun.star.uno.XInterface&amp;lt;/idl&amp;gt; is included automatically. The Java interface definition generated by javamaker for &amp;lt;idl&amp;gt;com.sun.star.uno.XInterface&amp;lt;/idl&amp;gt; only contains a &amp;lt;code&amp;gt;TypeInfo&amp;lt;/code&amp;gt; member used by Java UNO internally to store certain UNO type information:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // source file com/sun/star/uno/XInterface.java corresponding to the class generated by&lt;br /&gt;
  &lt;br /&gt;
  package com.sun.star.uno;&lt;br /&gt;
  &lt;br /&gt;
  public interface XInterface&lt;br /&gt;
  {&lt;br /&gt;
      // static Member&lt;br /&gt;
      public static final com.sun.star.lib.uno.typeinfo.TypeInfo UNOTYPEINFO[] = null;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note that &amp;lt;code&amp;gt;XInterface&amp;lt;/code&amp;gt; does not have any methods, in contrast to its IDL description. That means, if &amp;lt;code&amp;gt;implements com.sun.star.uno.XInterface&amp;lt;/code&amp;gt; is added to a class definition, there is nothing to implement. &lt;br /&gt;
&lt;br /&gt;
The method &amp;lt;code&amp;gt;queryInterface()&amp;lt;/code&amp;gt; is unnecessary in the implementation of a UNO object, because the Java UNO runtime environment obtains interface references without support from the UNO objects themselves. Within Java, the method &amp;lt;code&amp;gt;UnoRuntime.queryInterface()&amp;lt;/code&amp;gt; is used to obtain interfaces instead of calling &amp;lt;idlml&amp;gt;com.sun.star.uno.XInterface:queryInterface&amp;lt;/idlml&amp;gt;(), and the Java UNO language binding hands out interfaces for UNO objects to other processes on its own as well.&lt;br /&gt;
&lt;br /&gt;
The methods &amp;lt;code&amp;gt;acquire()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;release()&amp;lt;/code&amp;gt; are used for reference counting and control the lifetime of an object, because the Java garbage collector does this, there is no reference counting in Java components.&lt;br /&gt;
&lt;br /&gt;
=== XTypeProvider ===&lt;br /&gt;
&lt;br /&gt;
Helper classes with default &amp;lt;idl&amp;gt;com.sun.star.lang.XTypeProvider&amp;lt;/idl&amp;gt; implementations are still under development for Java. Meanwhile, every Java UNO object implementation can implement the &amp;lt;code&amp;gt;XTypeProvider&amp;lt;/code&amp;gt; interface as shown in the following code. In your implementation, adjust &amp;lt;code&amp;gt;getTypes()&amp;lt;/code&amp;gt;: &amp;lt;!--[SOURCE:Components/Thumbs/org/openoffice/comp/test/ImageShrink.java]--&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  ...&lt;br /&gt;
  &lt;br /&gt;
  // XTypeProvider implementation&lt;br /&gt;
    &lt;br /&gt;
  // maintain a static implementation id for all instances of ImageShrink&lt;br /&gt;
  // initialized by the first call to getImplementationId()&lt;br /&gt;
  protected static byte[] _implementationId;&lt;br /&gt;
  &lt;br /&gt;
  public com.sun.star.uno.Type[] getTypes() {&lt;br /&gt;
  &lt;br /&gt;
      // instantiate Type instances for each interface you support and place them in a Type[] array&lt;br /&gt;
      // (this object supports XServiceInfo, XTypeProvider, and XImageShrinkFilter)&lt;br /&gt;
      return new com.sun.star.uno.Type[] {&lt;br /&gt;
          new com.sun.star.uno.Type(com.sun.star.lang.XServiceInfo.class),&lt;br /&gt;
          new com.sun.star.uno.Type(com.sun.star.lang.XTypeProvider.class),&lt;br /&gt;
          new com.sun.star.uno.Type(org.openoffice.test.XImageShrinkFilter.class) };&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  synchronized public byte[] getImplementationId() {&lt;br /&gt;
      if (_implementationId == null) {&lt;br /&gt;
          _implementationId= new byte[16];&lt;br /&gt;
          int hash = hashCode(); // hashCode of this object&lt;br /&gt;
          _implementationId[0] = (byte)(hash &amp;amp; 0xff);&lt;br /&gt;
          _implementationId[1] = (byte)((hash &amp;gt;&amp;gt;&amp;gt; 8) &amp;amp; 0xff);&lt;br /&gt;
          _implementationId[2] = (byte)((hash &amp;gt;&amp;gt;&amp;gt; 16) &amp;amp; 0xff);&lt;br /&gt;
          _implementationId[3] = (byte)((hash &amp;gt;&amp;gt;&amp;gt;24) &amp;amp; 0xff);&lt;br /&gt;
      }&lt;br /&gt;
      return _implementationId;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The suggested implementation of the &amp;lt;code&amp;gt;getImplementationId()&amp;lt;/code&amp;gt; method is not optimal, it uses the &amp;lt;code&amp;gt;hashCode()&amp;lt;/code&amp;gt; of the first instance that initializes the static field. The future UNO helper class will improve this.&lt;br /&gt;
&lt;br /&gt;
=== XComponent ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;XComponent&amp;lt;/code&amp;gt; is an optional interface that is useful when other objects hold references to the component. The notification mechanism of &amp;lt;code&amp;gt;XComponent&amp;lt;/code&amp;gt; enables listener objects to learn when the component stops to provide its services, so that the objects drop their references to the component. This enables the component to delete itself when its reference count drops to zero. From section [[Documentation/DevGuide/WritingUNO/Core Interfaces to Implement|Core Interfaces to Implement]], there must be three things done when &amp;lt;code&amp;gt;dispose()&amp;lt;/code&amp;gt; is called at an &amp;lt;code&amp;gt;XComponent&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* Inform registered &amp;lt;code&amp;gt;XEventListener&amp;lt;/code&amp;gt;s that the object is being disposed of by calling their method &amp;lt;code&amp;gt;disposing()&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Release all references the object holds, including all &amp;lt;code&amp;gt;XEvenListener&amp;lt;/code&amp;gt; objects.&lt;br /&gt;
* On further calls to the component, throw an &amp;lt;idl&amp;gt;com.sun.star.lang.DisposedException&amp;lt;/idl&amp;gt; in case the required task can not be fulfilled anymore, because the component was disposed.&lt;br /&gt;
In Java, the object cannot be deleted, but the garbage collector will do this. It is sufficient to release all references that are currently being held to break the cyclic reference, and to call &amp;lt;code&amp;gt;disposing()&amp;lt;/code&amp;gt; on all &amp;lt;idl&amp;gt;com.sun.star.lang.XEventListener&amp;lt;/idl&amp;gt;s.&lt;br /&gt;
&lt;br /&gt;
The registration and removal of listener interfaces is a standard procedure in Java. Some IDEs even create the necessary methods automatically. The following example could be written: &amp;lt;!--[SOURCE:Components/Thumbs/org/openoffice/comp/test/ImageShrink.java]--&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  ...&lt;br /&gt;
  &lt;br /&gt;
  //XComponent implementation&lt;br /&gt;
  &lt;br /&gt;
  // hold a list of eventListeners&lt;br /&gt;
  private java.util.ArrayList eventListeners = new java.util.ArrayList();&lt;br /&gt;
  &lt;br /&gt;
  public void dispose {&lt;br /&gt;
      java.util.ArrayList listeners;&lt;br /&gt;
      synchronized (this) {&lt;br /&gt;
          listeners = eventListeners;&lt;br /&gt;
          eventListeners = null;&lt;br /&gt;
      }&lt;br /&gt;
      for (java.util.Iterator i = listeners.iterator(); i.hasNext();) {&lt;br /&gt;
          fireDisposing((XEventListener) i.next());&lt;br /&gt;
      }&lt;br /&gt;
      releaseReferences();&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  public void addEventListener(XEventListener listener) {&lt;br /&gt;
      bool fire = false;&lt;br /&gt;
      synchronized (this) {&lt;br /&gt;
          if (eventListeners == null) {&lt;br /&gt;
              fire = true;&lt;br /&gt;
          } else {&lt;br /&gt;
              eventListeners.add(listener);&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
      if (fire) {&lt;br /&gt;
          fireDisposing(listener);&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  public synchronized void removeEventListener(XEventListener listener) {&lt;br /&gt;
      if (eventListeners != null) {&lt;br /&gt;
          eventListeners.remove(listener);&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  private void fireDisposing(XEventListener listener) {&lt;br /&gt;
      com.sun.star.uno.EventObject event = new com.sun.star.uno.EventObject(this);&lt;br /&gt;
      try {&lt;br /&gt;
          listener.disposing(event);&lt;br /&gt;
      } catch (com.sun.star.uno.DisposedException e) {&lt;br /&gt;
          // it is not an error if some listener is disposed simultaneously&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  private void releaseReferences() {&lt;br /&gt;
      xComponentContext = null;&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>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Writing_warning-free_code&amp;diff=193461</id>
		<title>Writing warning-free code</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Writing_warning-free_code&amp;diff=193461"/>
		<updated>2011-02-08T05:23:18Z</updated>

		<summary type="html">&lt;p&gt;Newacct: /* Invalid enum case values */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We are currently on the way towards a completely warning-free OOo C/C++ code base.  And once we have reached that, we want to keep the code clean!&lt;br /&gt;
&lt;br /&gt;
We reached a first milestone by integrating CWS [http://eis.services.openoffice.org/EIS2/servlet/cws.showCWS?Id=2903&amp;amp;Path=SRC680%2Fwarnings01 warnings01] into SRC680m173.  Since then, and at least on the &amp;lt;code&amp;gt;unxlngi6&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unxsoli4&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unxsols4&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;wntmsci10&amp;lt;/code&amp;gt; platforms, the C/C++ compilers are used with rather aggressive warning levels, and in most CVS modules warnings are treated as errors that break the build.  Some CVS modules have not yet been made warning-free.&lt;br /&gt;
&lt;br /&gt;
==What changed?==&lt;br /&gt;
&lt;br /&gt;
Since SRC680m173, any new or modified C/C++ code that produces warnings will break the build.  (Unless, of course, you fail to pass &amp;lt;code&amp;gt;--enable-werror&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt;.)  Ideally, to be sure that integrating a CWS will not break the build, the CWS should now be built on every warning-free platform (i.e., at least &amp;lt;code&amp;gt;unxlngi6&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unxsoli4&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unxsols4&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;wntmsci10&amp;lt;/code&amp;gt;), with all supported compiler versions, in both product and non-product variants, and with and without the &amp;lt;code&amp;gt;debug=x&amp;lt;/code&amp;gt; build switch before nominating it for integration.  Practically, a reasonable subset of these will have to suffice.&lt;br /&gt;
&lt;br /&gt;
For &amp;lt;code&amp;gt;unxlngi6&amp;lt;/code&amp;gt;, we concentrated on GCC&amp;amp;nbsp;3.4.1, GCC 4.0.2/4.0.3, and GCC&amp;amp;nbsp;4.1.1, while other GCC versions probably produce slightly different warnings (that could break the build now on those GCC versions).&lt;br /&gt;
&lt;br /&gt;
Porters are encouraged to make additional platforms warning-free.  Since most ports are using GCC, there should not be too many surprises.  Any necessary changes to the platform-specific &amp;lt;code&amp;gt;.mk&amp;lt;/code&amp;gt; file in &amp;lt;code&amp;gt;solenv/inc&amp;lt;/code&amp;gt; can be modelled after &amp;lt;code&amp;gt;solenv/inc/unxlngi6.mk&amp;lt;/code&amp;gt;.  In short, you need a bunch of &amp;lt;code&amp;gt;CFLAGSxxx&amp;lt;/code&amp;gt; (see [http://www.openoffice.org/servlets/ReadMsg?list=interface-announce&amp;amp;msgNo=758 interface-announce C/C++ compiler warnings]) and &amp;lt;code&amp;gt;MODULES_WITH_WARNINGS&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;COMPILER_WARN_ERRORS&amp;lt;/code&amp;gt; (see [http://www.openoffice.org/servlets/ReadMsg?list=interface-announce&amp;amp;msgNo=942 interface-announce MODULES_WITH_WARNINGS]).&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;wall=x&amp;lt;/code&amp;gt; build switch no longer has any effect on the warning-free platforms.  Once all platforms are warning-free, we can remove it completely.&lt;br /&gt;
&lt;br /&gt;
==The missing modules==&lt;br /&gt;
&lt;br /&gt;
If your job is to clean up a given CVS module, here are some practical guidelines:&lt;br /&gt;
* Remove the module from the &amp;lt;code&amp;gt;MODULES_WITH_WARNINGS&amp;lt;/code&amp;gt; list in the platform-specific &amp;lt;code&amp;gt;.mk&amp;lt;/code&amp;gt; files in &amp;lt;code&amp;gt;solenv/inc&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Make sure your module builds and delivers successfully with &amp;lt;code&amp;gt;build &amp;amp;&amp;amp; deliver&amp;lt;/code&amp;gt; (and all the variants mentioned above).&lt;br /&gt;
* If your module contains external code which we do not want to clean up, set &amp;lt;code&amp;gt;EXTERNAL_WARNINGS_NOT_ERRORS := TRUE&amp;lt;/code&amp;gt; at the beginning of the corresponding &amp;lt;code&amp;gt;makefile.mk&amp;lt;/code&amp;gt;, so that warnings do not lead to errors there.&lt;br /&gt;
* In any case, for any header file delivered from your module, make sure that &amp;lt;code&amp;gt;testhxx&amp;lt;/code&amp;gt; on the delivered header file is successful.  (Note that &amp;lt;code&amp;gt;testhxx&amp;lt;/code&amp;gt; only works for headers delivered to the solver, not for local headers within a CVS module, as it calls the compiler with only a fixed set of include directories.)&lt;br /&gt;
* If you encounter a warning that cannot reasonably be worked around, discuss that problem on &amp;lt;code&amp;gt;dev@openoffice.org&amp;lt;/code&amp;gt;.  One outcome of that discussion can be that we globally disable that particular warning.  To see which warnings are already globally disabled on a given platform, look at the settings for &amp;lt;code&amp;gt;CFLAGSWARNCC&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CFLAGSWARNCXX&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CFLAGSWALLCC&amp;lt;/code&amp;gt;, and/or &amp;lt;code&amp;gt;CFLAGSWALLCXX&amp;lt;/code&amp;gt; in the platform-specific &amp;lt;code&amp;gt;.mk&amp;lt;/code&amp;gt; file in &amp;lt;code&amp;gt;solenv/inc&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;unxlngi6.mk&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unxsoli4.mk&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unxsols4.mk&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;wntmsci10.mk&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
See the current [[Warning-free_code_status|warning-free code status]].&lt;br /&gt;
&lt;br /&gt;
==Tips for Warning-free code==&lt;br /&gt;
&lt;br /&gt;
The following is a list of issues you might come across when making existing&lt;br /&gt;
code warning-free, or when writing new, warning-free code:&lt;br /&gt;
&lt;br /&gt;
===Integral conversions===&lt;br /&gt;
&lt;br /&gt;
Sometimes, a cast between integral types is needed to avoid a warning.  In such a case, use &amp;lt;code&amp;gt;sal::static_int_cast&amp;lt;/code&amp;gt;&amp;amp;nbsp;(C++) or &amp;lt;code&amp;gt;SAL_INT_CAST&amp;lt;/code&amp;gt;&amp;amp;nbsp;(C) to make that cast stick out&amp;amp;mdash;it will need to be adapted when the type of any of the involved expressions changes later on:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
sal_Int32 n;&lt;br /&gt;
std::vector&amp;lt;char&amp;gt; v;&lt;br /&gt;
if (n &amp;gt;= 0 &amp;amp;&amp;amp; sal::static_int_cast&amp;lt;sal_uInt32&amp;gt;(n) == v.size()) ...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that you might get the warning C4244 (possible loss of data) on Windows also for the following situation:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
short a = 0, b = 0;&lt;br /&gt;
a += b;  // warning C4244 on Windows&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This is because &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt; are converted to &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;, then added and the result is then again cast back to &amp;lt;code&amp;gt;short&amp;lt;/code&amp;gt;. This is especially nasty, as it also happens when you use &amp;lt;code&amp;gt;xub_StrLen&amp;lt;/code&amp;gt;, but only if it is a typedf to &amp;lt;code&amp;gt;USHORT&amp;lt;/code&amp;gt; and not to &amp;lt;code&amp;gt;sal_uInt32&amp;lt;/code&amp;gt;, i.e. only as long as &amp;lt;code&amp;gt;STRING32&amp;lt;/code&amp;gt; is not defined in solar.h.&lt;br /&gt;
The warning does not occur when you use &amp;lt;code&amp;gt;operator+&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;operator+=&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
short a = 0, b = 0;&lt;br /&gt;
a = a + b;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Invalid enum case values===&lt;br /&gt;
&lt;br /&gt;
Code like&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
enum E { A=1, B=2, C=4 } e;&lt;br /&gt;
switch (e) {&lt;br /&gt;
case A: ...&lt;br /&gt;
case B|C: ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
will cause &amp;lt;code&amp;gt;wntmsci11&amp;lt;/code&amp;gt; to complain with &amp;lt;code&amp;gt;warning C4063: case &amp;#039;6&amp;#039; is not a valid value for switch of enum &amp;#039;E&amp;#039;&amp;lt;/code&amp;gt;. The cause of the warning is that &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; is not meant be an enumerated type, but a bit field type. &amp;lt;code&amp;gt;enum&amp;lt;/code&amp;gt; is commonly used in C and C++ to initialize constants; in this case, constants for individual bits.&lt;br /&gt;
&lt;br /&gt;
A better way to write this would be to typedef &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; to be an unsigned int (a better type for bit fields); and then define the constants for the individual bits using an anonymous &amp;lt;code&amp;gt;enum&amp;lt;/code&amp;gt;. (A downside is that the documentation for the type &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; will not contain the constants the user needs to use.)&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
typedef unsigned int E;&lt;br /&gt;
E e;&lt;br /&gt;
enum { A=1, B=2, C=4 };&lt;br /&gt;
switch (e) {&lt;br /&gt;
case A: ...&lt;br /&gt;
case B|C: ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you do not have access to the definition of the type &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt;, it can still be worked around by promoting &amp;lt;code&amp;gt;e&amp;lt;/code&amp;gt; to its underlying integral type:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
switch (+e) {&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Casting between pointer and integer types===&lt;br /&gt;
&lt;br /&gt;
====C++====&lt;br /&gt;
&lt;br /&gt;
* From pointer-to-(possibly-cv-qualified-)void-or-object type&amp;amp;nbsp;&amp;lt;code&amp;gt;P&amp;lt;/code&amp;gt; to unsigned integral type&amp;amp;nbsp;&amp;lt;code&amp;gt;U&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
P p;&lt;br /&gt;
U u = sal::static_int_cast&amp;lt;U&amp;gt;(reinterpret_cast&amp;lt;sal_uIntPtr&amp;gt;(p));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* From unsigned integral type&amp;amp;nbsp;&amp;lt;code&amp;gt;U&amp;lt;/code&amp;gt; to pointer-to-(possibly-cv-qualified-)void-or-object type&amp;amp;nbsp;&amp;lt;code&amp;gt;P&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
U u;&lt;br /&gt;
P p = reinterpret_cast&amp;lt;P&amp;gt;(sal::static_int_cast&amp;lt;sal_uIntPtr&amp;gt;(u));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* From pointer-to-(possibly-cv-qualified-)void-or-object type&amp;amp;nbsp;&amp;lt;code&amp;gt;P&amp;lt;/code&amp;gt; to signed integral type&amp;amp;nbsp;&amp;lt;code&amp;gt;S&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
P p;&lt;br /&gt;
S s = sal::static_int_cast&amp;lt;S&amp;gt;(reinterpret_cast&amp;lt;sal_IntPtr&amp;gt;(p));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* From signed integral type&amp;amp;nbsp;&amp;lt;code&amp;gt;S&amp;lt;/code&amp;gt; to pointer-to-(possibly-cv-qualified-)void-or-object type&amp;amp;nbsp;&amp;lt;code&amp;gt;P&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
S s;&lt;br /&gt;
P p = reinterpret_cast&amp;lt;P&amp;gt;(sal::static_int_cast&amp;lt;sal_IntPtr&amp;gt;(s));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====C====&lt;br /&gt;
&lt;br /&gt;
* From pointer-to-(possibly-qualified-)void-or-object type&amp;amp;nbsp;&amp;lt;code&amp;gt;P&amp;lt;/code&amp;gt; to unsigned integer type&amp;amp;nbsp;&amp;lt;code&amp;gt;U&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
P p;&lt;br /&gt;
U u = SAL_INT_CAST(U, (sal_uIntPtr) p);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* From unsigned integer type&amp;amp;nbsp;&amp;lt;code&amp;gt;U&amp;lt;/code&amp;gt; to pointer-to-(possibly-qualified-)void-or-object type&amp;amp;nbsp;&amp;lt;code&amp;gt;P&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
U u;&lt;br /&gt;
P p = (P) SAL_INT_CAST(sal_uIntPtr, u);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* From pointer-to-(possibly-qualified-)void-or-object type&amp;amp;nbsp;&amp;lt;code&amp;gt;P&amp;lt;/code&amp;gt; to signed integer type&amp;amp;nbsp;&amp;lt;code&amp;gt;S&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
P p;&lt;br /&gt;
S s = SAL_INT_CAST(S, (sal_IntPtr) p);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* From signed integer type&amp;amp;nbsp;&amp;lt;code&amp;gt;S&amp;lt;/code&amp;gt; to pointer-to-(possibly-qualified-)void-or-object type&amp;amp;nbsp;&amp;lt;code&amp;gt;P&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
S s;&lt;br /&gt;
P p = (P) SAL_INT_CAST(sal_IntPtr, s);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Pointer to function===&lt;br /&gt;
&lt;br /&gt;
A pointer to function is not compatible with a pointer to object, so code like&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void * osl::Module::getSymbol(rtl::OUString const &amp;amp;);&lt;br /&gt;
typedef void (* MyFunc)();&lt;br /&gt;
MyFunc f = module.getSymbol(&amp;quot;myFunc&amp;quot;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
will not compile.  The only places were converting between pointer to function and pointer to object (typically &amp;lt;code&amp;gt;void *&amp;lt;/code&amp;gt;) should be necessary are &amp;lt;code&amp;gt;osl::Module::getSymbol&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;osl::Module::getUrlFromAddress&amp;lt;/code&amp;gt;, and in both cases there are additional functions (&amp;lt;code&amp;gt;osl::Module::getFunctionSymbol&amp;lt;/code&amp;gt; and an overload with &amp;lt;code&amp;gt;oslGenericFunction&amp;lt;/code&amp;gt; of &amp;lt;code&amp;gt;osl::Module::getUrlFromAddress&amp;lt;/code&amp;gt;) that handle the problem internally.  Use them!&lt;br /&gt;
&lt;br /&gt;
===Name hiding===&lt;br /&gt;
&lt;br /&gt;
In C++, use a &amp;lt;code&amp;gt;using&amp;lt;/code&amp;gt; declaration to make visible (virtual) function declarations from a base clase that would be hidden by a function declaration in a derived class:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
class Base {&lt;br /&gt;
public:&lt;br /&gt;
  virtual void f(int);&lt;br /&gt;
  virtual void f(double);&lt;br /&gt;
};&lt;br /&gt;
class Derived: public Base {&lt;br /&gt;
public:&lt;br /&gt;
  using Base::f;&lt;br /&gt;
  virtual void f(int);&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure to apply the correct access control to the &amp;lt;code&amp;gt;using&amp;lt;/code&amp;gt; declaration:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
class Base {&lt;br /&gt;
protected:&lt;br /&gt;
  void f();&lt;br /&gt;
};&lt;br /&gt;
class Derived: public Base {&lt;br /&gt;
public:&lt;br /&gt;
  void f(int);&lt;br /&gt;
protected:&lt;br /&gt;
  using Base::f;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you can, avoid such constructs as in the above example, by chosing different names for the two functions &amp;lt;code&amp;gt;f&amp;lt;/code&amp;gt;. If on the other hand the function f is clearly meant to be overloaded, then make all instances of &amp;lt;code&amp;gt;f&amp;lt;/code&amp;gt; virtual in the base class.&lt;br /&gt;
&lt;br /&gt;
===Unused parameters===&lt;br /&gt;
&lt;br /&gt;
There are three cases where a parameter of a function is not actually used in the definition of the function:&lt;br /&gt;
&lt;br /&gt;
* The function has to have a certain signature (it is a virtual function, shall be used with a certain function pointer type, or is part of a stable API that cannot be changed).  In those cases, leave out the paramter name in the function definition (C++) or use&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
(void) paramName; /* avoid warning about unused parameter */&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
at the start of the function body (C).&lt;br /&gt;
&lt;br /&gt;
* The function is created by the Macro IMPL_LINK( Class, Method, ArgType, ArgName ) from tools/inc/link.hxx or similar. Use EMPTYARG as Parametername as in&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
IMPL_LINK( Class, Method, ArgType, EMPTYARG )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
EMPTYARG is defined empty, so this will result in leaving out the parameter name as suggested above.&lt;br /&gt;
&lt;br /&gt;
* The function uses the paramter only in an &amp;lt;code&amp;gt;#ifdef&amp;lt;/code&amp;gt;-block, or only in &amp;lt;code&amp;gt;OSL_ASSERT&amp;lt;/code&amp;gt; etc. debug code.  If the first case occurs in C++ code, fix it by using the same &amp;lt;code&amp;gt;#ifdef&amp;lt;/code&amp;gt; around the parameter name in the function header.  In all other cases, fix it by using&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
(void) paramName; /* avoid warning about unused parameter */&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
at the start of the function body.&lt;br /&gt;
&lt;br /&gt;
* The function once used the parameter, but does no longer do so.  In that case, clean up the function declaration and all uses of the function.&lt;br /&gt;
&lt;br /&gt;
===When all else fails===&lt;br /&gt;
&lt;br /&gt;
There are cases where the only sensible solution is to suppress warnings for a given chunk of code:&lt;br /&gt;
&lt;br /&gt;
* As explained above, in external code which we do not want to clean up, use &amp;lt;code&amp;gt;EXTERNAL_WARNINGS_NOT_ERRORS := TRUE&amp;lt;/code&amp;gt; so that warnings do not lead to errors there.&lt;br /&gt;
&lt;br /&gt;
* Header files included directly from the system, or header files delivered from external code included in the OOo code base but which we cannot reasonably make &amp;lt;code&amp;gt;testhxx&amp;lt;/code&amp;gt;-clean:  Surround that code (e.g., the &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt;-directives for those headers) by&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#if defined __GNUC__&lt;br /&gt;
#pragma GCC system_header&lt;br /&gt;
#elif defined __SUNPRO_CC&lt;br /&gt;
#pragma disable_warn&lt;br /&gt;
#elif defined _MSC_VER&lt;br /&gt;
#pragma warning(push, 1)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#if defined __SUNPRO_CC&lt;br /&gt;
#pragma enable_warn&lt;br /&gt;
#elif defined _MSC_VER&lt;br /&gt;
#pragma warning(pop)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
(probably together with an explanatory comment).  &amp;lt;em&amp;gt;Due to the nature of the GCC solution, this does not work directly within the compilation unit&amp;#039;s main (&amp;lt;code&amp;gt;.c&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.cxx&amp;lt;/code&amp;gt;) file, only within a (&amp;lt;code&amp;gt;.h&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.hxx&amp;lt;/code&amp;gt;) file included directly or indirectly.&amp;lt;/em&amp;gt; Even more important, because the &amp;lt;code&amp;gt;system_header&amp;lt;/code&amp;gt; pragma affects the &amp;#039;&amp;#039;rest of the current header&amp;#039;&amp;#039;, the entire warnings guard mechanism should be separated into a &amp;#039;&amp;#039;header file on its own&amp;#039;&amp;#039;, including just the file in question. From the original file then include that wrapper file.&lt;br /&gt;
&lt;br /&gt;
* Code generated by &amp;lt;code&amp;gt;flex&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bison&amp;lt;/code&amp;gt;:  The solution here is similar to the solution in the previous item&amp;amp;mdash;disable all warnings in the generated code.  However, this has two implications:  For one, it means that also all warnings from our client code integrated into the &amp;lt;code&amp;gt;flex&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;bison&amp;lt;/code&amp;gt; output are suppressed; this is not really that large an issue, given the relatively small number of &amp;lt;code&amp;gt;flex&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;bison&amp;lt;/code&amp;gt; files we use.  For another, due to the nature of the GCC solution, it means that you need to introduce a wrapper file.  The individual steps for a given &amp;lt;code&amp;gt;flex&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;bison&amp;lt;/code&amp;gt; file named &amp;lt;code&amp;gt;example.ly&amp;lt;/code&amp;gt;, translated to &amp;lt;code&amp;gt;$(MISC)$/example.cxx&amp;lt;/code&amp;gt;, are as follows:  First, change &amp;lt;code&amp;gt;example.ly&amp;lt;/code&amp;gt; by adding&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#if defined __GNUC__&lt;br /&gt;
#pragma GCC system_header&lt;br /&gt;
#elif defined __SUNPRO_CC&lt;br /&gt;
#pragma disable_warn&lt;br /&gt;
#elif defined _MSC_VER&lt;br /&gt;
#pragma warning(push, 1)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
(probably together with an explanatory comment) at the very end of the initial &amp;lt;code&amp;gt;%{...%}&amp;lt;/code&amp;gt; section (for &amp;lt;code&amp;gt;_MSC_VER&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;#pragma warning(push, 1)&amp;lt;/code&amp;gt; might not disable all the warnings that occur; in that case, add &amp;lt;code&amp;gt;#pragma warning(disable: NNN1 NNN2 ...)&amp;lt;/code&amp;gt; after it to disable specific warnings &amp;lt;code&amp;gt;NNN1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;NNN2&amp;lt;/code&amp;gt;, etc.).  Second, create a new file named &amp;lt;code&amp;gt;wrap_example.cxx&amp;lt;/code&amp;gt; in the same source directory as &amp;lt;code&amp;gt;exmaple.ly&amp;lt;/code&amp;gt;, containing&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;example.cxx&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Third, change the corresponding &amp;lt;code&amp;gt;makefile.mk&amp;lt;/code&amp;gt; by adding&lt;br /&gt;
&amp;lt;code&amp;gt;[]&lt;br /&gt;
INCPRE=$(MISC)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
to the top, by changing occurences of &amp;lt;code&amp;gt;example.obj&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;wrap_example.obj&amp;lt;/code&amp;gt;, and by adding&lt;br /&gt;
&amp;lt;code&amp;gt;[]&lt;br /&gt;
$(OBJ)$/wrap_example.obj: $(MISC)$/example.cxx&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
and/or&lt;br /&gt;
&amp;lt;code&amp;gt;[]&lt;br /&gt;
$(SLO)$/wrap_example.obj: $(MISC)$/example.cxx&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
at the bottom.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Coding Standards]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Writing_warning-free_code&amp;diff=193460</id>
		<title>Writing warning-free code</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Writing_warning-free_code&amp;diff=193460"/>
		<updated>2011-02-08T05:22:32Z</updated>

		<summary type="html">&lt;p&gt;Newacct: /* Invalid enum case values */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We are currently on the way towards a completely warning-free OOo C/C++ code base.  And once we have reached that, we want to keep the code clean!&lt;br /&gt;
&lt;br /&gt;
We reached a first milestone by integrating CWS [http://eis.services.openoffice.org/EIS2/servlet/cws.showCWS?Id=2903&amp;amp;Path=SRC680%2Fwarnings01 warnings01] into SRC680m173.  Since then, and at least on the &amp;lt;code&amp;gt;unxlngi6&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unxsoli4&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unxsols4&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;wntmsci10&amp;lt;/code&amp;gt; platforms, the C/C++ compilers are used with rather aggressive warning levels, and in most CVS modules warnings are treated as errors that break the build.  Some CVS modules have not yet been made warning-free.&lt;br /&gt;
&lt;br /&gt;
==What changed?==&lt;br /&gt;
&lt;br /&gt;
Since SRC680m173, any new or modified C/C++ code that produces warnings will break the build.  (Unless, of course, you fail to pass &amp;lt;code&amp;gt;--enable-werror&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt;.)  Ideally, to be sure that integrating a CWS will not break the build, the CWS should now be built on every warning-free platform (i.e., at least &amp;lt;code&amp;gt;unxlngi6&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unxsoli4&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unxsols4&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;wntmsci10&amp;lt;/code&amp;gt;), with all supported compiler versions, in both product and non-product variants, and with and without the &amp;lt;code&amp;gt;debug=x&amp;lt;/code&amp;gt; build switch before nominating it for integration.  Practically, a reasonable subset of these will have to suffice.&lt;br /&gt;
&lt;br /&gt;
For &amp;lt;code&amp;gt;unxlngi6&amp;lt;/code&amp;gt;, we concentrated on GCC&amp;amp;nbsp;3.4.1, GCC 4.0.2/4.0.3, and GCC&amp;amp;nbsp;4.1.1, while other GCC versions probably produce slightly different warnings (that could break the build now on those GCC versions).&lt;br /&gt;
&lt;br /&gt;
Porters are encouraged to make additional platforms warning-free.  Since most ports are using GCC, there should not be too many surprises.  Any necessary changes to the platform-specific &amp;lt;code&amp;gt;.mk&amp;lt;/code&amp;gt; file in &amp;lt;code&amp;gt;solenv/inc&amp;lt;/code&amp;gt; can be modelled after &amp;lt;code&amp;gt;solenv/inc/unxlngi6.mk&amp;lt;/code&amp;gt;.  In short, you need a bunch of &amp;lt;code&amp;gt;CFLAGSxxx&amp;lt;/code&amp;gt; (see [http://www.openoffice.org/servlets/ReadMsg?list=interface-announce&amp;amp;msgNo=758 interface-announce C/C++ compiler warnings]) and &amp;lt;code&amp;gt;MODULES_WITH_WARNINGS&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;COMPILER_WARN_ERRORS&amp;lt;/code&amp;gt; (see [http://www.openoffice.org/servlets/ReadMsg?list=interface-announce&amp;amp;msgNo=942 interface-announce MODULES_WITH_WARNINGS]).&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;wall=x&amp;lt;/code&amp;gt; build switch no longer has any effect on the warning-free platforms.  Once all platforms are warning-free, we can remove it completely.&lt;br /&gt;
&lt;br /&gt;
==The missing modules==&lt;br /&gt;
&lt;br /&gt;
If your job is to clean up a given CVS module, here are some practical guidelines:&lt;br /&gt;
* Remove the module from the &amp;lt;code&amp;gt;MODULES_WITH_WARNINGS&amp;lt;/code&amp;gt; list in the platform-specific &amp;lt;code&amp;gt;.mk&amp;lt;/code&amp;gt; files in &amp;lt;code&amp;gt;solenv/inc&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Make sure your module builds and delivers successfully with &amp;lt;code&amp;gt;build &amp;amp;&amp;amp; deliver&amp;lt;/code&amp;gt; (and all the variants mentioned above).&lt;br /&gt;
* If your module contains external code which we do not want to clean up, set &amp;lt;code&amp;gt;EXTERNAL_WARNINGS_NOT_ERRORS := TRUE&amp;lt;/code&amp;gt; at the beginning of the corresponding &amp;lt;code&amp;gt;makefile.mk&amp;lt;/code&amp;gt;, so that warnings do not lead to errors there.&lt;br /&gt;
* In any case, for any header file delivered from your module, make sure that &amp;lt;code&amp;gt;testhxx&amp;lt;/code&amp;gt; on the delivered header file is successful.  (Note that &amp;lt;code&amp;gt;testhxx&amp;lt;/code&amp;gt; only works for headers delivered to the solver, not for local headers within a CVS module, as it calls the compiler with only a fixed set of include directories.)&lt;br /&gt;
* If you encounter a warning that cannot reasonably be worked around, discuss that problem on &amp;lt;code&amp;gt;dev@openoffice.org&amp;lt;/code&amp;gt;.  One outcome of that discussion can be that we globally disable that particular warning.  To see which warnings are already globally disabled on a given platform, look at the settings for &amp;lt;code&amp;gt;CFLAGSWARNCC&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CFLAGSWARNCXX&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CFLAGSWALLCC&amp;lt;/code&amp;gt;, and/or &amp;lt;code&amp;gt;CFLAGSWALLCXX&amp;lt;/code&amp;gt; in the platform-specific &amp;lt;code&amp;gt;.mk&amp;lt;/code&amp;gt; file in &amp;lt;code&amp;gt;solenv/inc&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;unxlngi6.mk&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unxsoli4.mk&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unxsols4.mk&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;wntmsci10.mk&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
See the current [[Warning-free_code_status|warning-free code status]].&lt;br /&gt;
&lt;br /&gt;
==Tips for Warning-free code==&lt;br /&gt;
&lt;br /&gt;
The following is a list of issues you might come across when making existing&lt;br /&gt;
code warning-free, or when writing new, warning-free code:&lt;br /&gt;
&lt;br /&gt;
===Integral conversions===&lt;br /&gt;
&lt;br /&gt;
Sometimes, a cast between integral types is needed to avoid a warning.  In such a case, use &amp;lt;code&amp;gt;sal::static_int_cast&amp;lt;/code&amp;gt;&amp;amp;nbsp;(C++) or &amp;lt;code&amp;gt;SAL_INT_CAST&amp;lt;/code&amp;gt;&amp;amp;nbsp;(C) to make that cast stick out&amp;amp;mdash;it will need to be adapted when the type of any of the involved expressions changes later on:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
sal_Int32 n;&lt;br /&gt;
std::vector&amp;lt;char&amp;gt; v;&lt;br /&gt;
if (n &amp;gt;= 0 &amp;amp;&amp;amp; sal::static_int_cast&amp;lt;sal_uInt32&amp;gt;(n) == v.size()) ...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that you might get the warning C4244 (possible loss of data) on Windows also for the following situation:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
short a = 0, b = 0;&lt;br /&gt;
a += b;  // warning C4244 on Windows&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This is because &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt; are converted to &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;, then added and the result is then again cast back to &amp;lt;code&amp;gt;short&amp;lt;/code&amp;gt;. This is especially nasty, as it also happens when you use &amp;lt;code&amp;gt;xub_StrLen&amp;lt;/code&amp;gt;, but only if it is a typedf to &amp;lt;code&amp;gt;USHORT&amp;lt;/code&amp;gt; and not to &amp;lt;code&amp;gt;sal_uInt32&amp;lt;/code&amp;gt;, i.e. only as long as &amp;lt;code&amp;gt;STRING32&amp;lt;/code&amp;gt; is not defined in solar.h.&lt;br /&gt;
The warning does not occur when you use &amp;lt;code&amp;gt;operator+&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;operator+=&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
short a = 0, b = 0;&lt;br /&gt;
a = a + b;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Invalid enum case values===&lt;br /&gt;
&lt;br /&gt;
Code like&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
enum E { A=1, B=2, C=4 } e;&lt;br /&gt;
switch (e) {&lt;br /&gt;
case A: ...&lt;br /&gt;
case B|C: ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
will cause &amp;lt;code&amp;gt;wntmsci11&amp;lt;/code&amp;gt; to complain with &amp;lt;code&amp;gt;warning C4063: case &amp;#039;6&amp;#039; is not a valid value for switch of enum &amp;#039;E&amp;#039;&amp;lt;/code&amp;gt;. The cause of the warning is that &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; is not meant be an enumerated type, but a bit field type. &amp;lt;code&amp;gt;enum&amp;lt;/code&amp;gt; is commonly used in C and C++ to initialize constants; in this case, constants for individual bits.&lt;br /&gt;
&lt;br /&gt;
A better way to write this would be to typedef &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; to be an unsigned int (a better type for bit fields); and then define the constants for the individual bits using an anonymous &amp;lt;code&amp;gt;enum&amp;lt;/code&amp;gt;. (A downside is that the documentation for the type &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; will not contain the constants the user needs to use.)&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
typedef unsigned int E;&lt;br /&gt;
E e;&lt;br /&gt;
enum { A=1, B=2, C=4 };&lt;br /&gt;
switch (e) {&lt;br /&gt;
case A: ...&lt;br /&gt;
case B|C: ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you do not have access to the definition of the type &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt;, it can still be worked around by promoting &amp;lt;code&amp;gt;e&amp;lt;/code&amp;gt; to is underlying integral type:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
switch (+e) {&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Casting between pointer and integer types===&lt;br /&gt;
&lt;br /&gt;
====C++====&lt;br /&gt;
&lt;br /&gt;
* From pointer-to-(possibly-cv-qualified-)void-or-object type&amp;amp;nbsp;&amp;lt;code&amp;gt;P&amp;lt;/code&amp;gt; to unsigned integral type&amp;amp;nbsp;&amp;lt;code&amp;gt;U&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
P p;&lt;br /&gt;
U u = sal::static_int_cast&amp;lt;U&amp;gt;(reinterpret_cast&amp;lt;sal_uIntPtr&amp;gt;(p));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* From unsigned integral type&amp;amp;nbsp;&amp;lt;code&amp;gt;U&amp;lt;/code&amp;gt; to pointer-to-(possibly-cv-qualified-)void-or-object type&amp;amp;nbsp;&amp;lt;code&amp;gt;P&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
U u;&lt;br /&gt;
P p = reinterpret_cast&amp;lt;P&amp;gt;(sal::static_int_cast&amp;lt;sal_uIntPtr&amp;gt;(u));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* From pointer-to-(possibly-cv-qualified-)void-or-object type&amp;amp;nbsp;&amp;lt;code&amp;gt;P&amp;lt;/code&amp;gt; to signed integral type&amp;amp;nbsp;&amp;lt;code&amp;gt;S&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
P p;&lt;br /&gt;
S s = sal::static_int_cast&amp;lt;S&amp;gt;(reinterpret_cast&amp;lt;sal_IntPtr&amp;gt;(p));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* From signed integral type&amp;amp;nbsp;&amp;lt;code&amp;gt;S&amp;lt;/code&amp;gt; to pointer-to-(possibly-cv-qualified-)void-or-object type&amp;amp;nbsp;&amp;lt;code&amp;gt;P&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
S s;&lt;br /&gt;
P p = reinterpret_cast&amp;lt;P&amp;gt;(sal::static_int_cast&amp;lt;sal_IntPtr&amp;gt;(s));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====C====&lt;br /&gt;
&lt;br /&gt;
* From pointer-to-(possibly-qualified-)void-or-object type&amp;amp;nbsp;&amp;lt;code&amp;gt;P&amp;lt;/code&amp;gt; to unsigned integer type&amp;amp;nbsp;&amp;lt;code&amp;gt;U&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
P p;&lt;br /&gt;
U u = SAL_INT_CAST(U, (sal_uIntPtr) p);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* From unsigned integer type&amp;amp;nbsp;&amp;lt;code&amp;gt;U&amp;lt;/code&amp;gt; to pointer-to-(possibly-qualified-)void-or-object type&amp;amp;nbsp;&amp;lt;code&amp;gt;P&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
U u;&lt;br /&gt;
P p = (P) SAL_INT_CAST(sal_uIntPtr, u);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* From pointer-to-(possibly-qualified-)void-or-object type&amp;amp;nbsp;&amp;lt;code&amp;gt;P&amp;lt;/code&amp;gt; to signed integer type&amp;amp;nbsp;&amp;lt;code&amp;gt;S&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
P p;&lt;br /&gt;
S s = SAL_INT_CAST(S, (sal_IntPtr) p);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* From signed integer type&amp;amp;nbsp;&amp;lt;code&amp;gt;S&amp;lt;/code&amp;gt; to pointer-to-(possibly-qualified-)void-or-object type&amp;amp;nbsp;&amp;lt;code&amp;gt;P&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
S s;&lt;br /&gt;
P p = (P) SAL_INT_CAST(sal_IntPtr, s);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Pointer to function===&lt;br /&gt;
&lt;br /&gt;
A pointer to function is not compatible with a pointer to object, so code like&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void * osl::Module::getSymbol(rtl::OUString const &amp;amp;);&lt;br /&gt;
typedef void (* MyFunc)();&lt;br /&gt;
MyFunc f = module.getSymbol(&amp;quot;myFunc&amp;quot;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
will not compile.  The only places were converting between pointer to function and pointer to object (typically &amp;lt;code&amp;gt;void *&amp;lt;/code&amp;gt;) should be necessary are &amp;lt;code&amp;gt;osl::Module::getSymbol&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;osl::Module::getUrlFromAddress&amp;lt;/code&amp;gt;, and in both cases there are additional functions (&amp;lt;code&amp;gt;osl::Module::getFunctionSymbol&amp;lt;/code&amp;gt; and an overload with &amp;lt;code&amp;gt;oslGenericFunction&amp;lt;/code&amp;gt; of &amp;lt;code&amp;gt;osl::Module::getUrlFromAddress&amp;lt;/code&amp;gt;) that handle the problem internally.  Use them!&lt;br /&gt;
&lt;br /&gt;
===Name hiding===&lt;br /&gt;
&lt;br /&gt;
In C++, use a &amp;lt;code&amp;gt;using&amp;lt;/code&amp;gt; declaration to make visible (virtual) function declarations from a base clase that would be hidden by a function declaration in a derived class:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
class Base {&lt;br /&gt;
public:&lt;br /&gt;
  virtual void f(int);&lt;br /&gt;
  virtual void f(double);&lt;br /&gt;
};&lt;br /&gt;
class Derived: public Base {&lt;br /&gt;
public:&lt;br /&gt;
  using Base::f;&lt;br /&gt;
  virtual void f(int);&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure to apply the correct access control to the &amp;lt;code&amp;gt;using&amp;lt;/code&amp;gt; declaration:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
class Base {&lt;br /&gt;
protected:&lt;br /&gt;
  void f();&lt;br /&gt;
};&lt;br /&gt;
class Derived: public Base {&lt;br /&gt;
public:&lt;br /&gt;
  void f(int);&lt;br /&gt;
protected:&lt;br /&gt;
  using Base::f;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you can, avoid such constructs as in the above example, by chosing different names for the two functions &amp;lt;code&amp;gt;f&amp;lt;/code&amp;gt;. If on the other hand the function f is clearly meant to be overloaded, then make all instances of &amp;lt;code&amp;gt;f&amp;lt;/code&amp;gt; virtual in the base class.&lt;br /&gt;
&lt;br /&gt;
===Unused parameters===&lt;br /&gt;
&lt;br /&gt;
There are three cases where a parameter of a function is not actually used in the definition of the function:&lt;br /&gt;
&lt;br /&gt;
* The function has to have a certain signature (it is a virtual function, shall be used with a certain function pointer type, or is part of a stable API that cannot be changed).  In those cases, leave out the paramter name in the function definition (C++) or use&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
(void) paramName; /* avoid warning about unused parameter */&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
at the start of the function body (C).&lt;br /&gt;
&lt;br /&gt;
* The function is created by the Macro IMPL_LINK( Class, Method, ArgType, ArgName ) from tools/inc/link.hxx or similar. Use EMPTYARG as Parametername as in&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
IMPL_LINK( Class, Method, ArgType, EMPTYARG )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
EMPTYARG is defined empty, so this will result in leaving out the parameter name as suggested above.&lt;br /&gt;
&lt;br /&gt;
* The function uses the paramter only in an &amp;lt;code&amp;gt;#ifdef&amp;lt;/code&amp;gt;-block, or only in &amp;lt;code&amp;gt;OSL_ASSERT&amp;lt;/code&amp;gt; etc. debug code.  If the first case occurs in C++ code, fix it by using the same &amp;lt;code&amp;gt;#ifdef&amp;lt;/code&amp;gt; around the parameter name in the function header.  In all other cases, fix it by using&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
(void) paramName; /* avoid warning about unused parameter */&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
at the start of the function body.&lt;br /&gt;
&lt;br /&gt;
* The function once used the parameter, but does no longer do so.  In that case, clean up the function declaration and all uses of the function.&lt;br /&gt;
&lt;br /&gt;
===When all else fails===&lt;br /&gt;
&lt;br /&gt;
There are cases where the only sensible solution is to suppress warnings for a given chunk of code:&lt;br /&gt;
&lt;br /&gt;
* As explained above, in external code which we do not want to clean up, use &amp;lt;code&amp;gt;EXTERNAL_WARNINGS_NOT_ERRORS := TRUE&amp;lt;/code&amp;gt; so that warnings do not lead to errors there.&lt;br /&gt;
&lt;br /&gt;
* Header files included directly from the system, or header files delivered from external code included in the OOo code base but which we cannot reasonably make &amp;lt;code&amp;gt;testhxx&amp;lt;/code&amp;gt;-clean:  Surround that code (e.g., the &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt;-directives for those headers) by&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#if defined __GNUC__&lt;br /&gt;
#pragma GCC system_header&lt;br /&gt;
#elif defined __SUNPRO_CC&lt;br /&gt;
#pragma disable_warn&lt;br /&gt;
#elif defined _MSC_VER&lt;br /&gt;
#pragma warning(push, 1)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#if defined __SUNPRO_CC&lt;br /&gt;
#pragma enable_warn&lt;br /&gt;
#elif defined _MSC_VER&lt;br /&gt;
#pragma warning(pop)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
(probably together with an explanatory comment).  &amp;lt;em&amp;gt;Due to the nature of the GCC solution, this does not work directly within the compilation unit&amp;#039;s main (&amp;lt;code&amp;gt;.c&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.cxx&amp;lt;/code&amp;gt;) file, only within a (&amp;lt;code&amp;gt;.h&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.hxx&amp;lt;/code&amp;gt;) file included directly or indirectly.&amp;lt;/em&amp;gt; Even more important, because the &amp;lt;code&amp;gt;system_header&amp;lt;/code&amp;gt; pragma affects the &amp;#039;&amp;#039;rest of the current header&amp;#039;&amp;#039;, the entire warnings guard mechanism should be separated into a &amp;#039;&amp;#039;header file on its own&amp;#039;&amp;#039;, including just the file in question. From the original file then include that wrapper file.&lt;br /&gt;
&lt;br /&gt;
* Code generated by &amp;lt;code&amp;gt;flex&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bison&amp;lt;/code&amp;gt;:  The solution here is similar to the solution in the previous item&amp;amp;mdash;disable all warnings in the generated code.  However, this has two implications:  For one, it means that also all warnings from our client code integrated into the &amp;lt;code&amp;gt;flex&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;bison&amp;lt;/code&amp;gt; output are suppressed; this is not really that large an issue, given the relatively small number of &amp;lt;code&amp;gt;flex&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;bison&amp;lt;/code&amp;gt; files we use.  For another, due to the nature of the GCC solution, it means that you need to introduce a wrapper file.  The individual steps for a given &amp;lt;code&amp;gt;flex&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;bison&amp;lt;/code&amp;gt; file named &amp;lt;code&amp;gt;example.ly&amp;lt;/code&amp;gt;, translated to &amp;lt;code&amp;gt;$(MISC)$/example.cxx&amp;lt;/code&amp;gt;, are as follows:  First, change &amp;lt;code&amp;gt;example.ly&amp;lt;/code&amp;gt; by adding&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#if defined __GNUC__&lt;br /&gt;
#pragma GCC system_header&lt;br /&gt;
#elif defined __SUNPRO_CC&lt;br /&gt;
#pragma disable_warn&lt;br /&gt;
#elif defined _MSC_VER&lt;br /&gt;
#pragma warning(push, 1)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
(probably together with an explanatory comment) at the very end of the initial &amp;lt;code&amp;gt;%{...%}&amp;lt;/code&amp;gt; section (for &amp;lt;code&amp;gt;_MSC_VER&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;#pragma warning(push, 1)&amp;lt;/code&amp;gt; might not disable all the warnings that occur; in that case, add &amp;lt;code&amp;gt;#pragma warning(disable: NNN1 NNN2 ...)&amp;lt;/code&amp;gt; after it to disable specific warnings &amp;lt;code&amp;gt;NNN1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;NNN2&amp;lt;/code&amp;gt;, etc.).  Second, create a new file named &amp;lt;code&amp;gt;wrap_example.cxx&amp;lt;/code&amp;gt; in the same source directory as &amp;lt;code&amp;gt;exmaple.ly&amp;lt;/code&amp;gt;, containing&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;example.cxx&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Third, change the corresponding &amp;lt;code&amp;gt;makefile.mk&amp;lt;/code&amp;gt; by adding&lt;br /&gt;
&amp;lt;code&amp;gt;[]&lt;br /&gt;
INCPRE=$(MISC)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
to the top, by changing occurences of &amp;lt;code&amp;gt;example.obj&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;wrap_example.obj&amp;lt;/code&amp;gt;, and by adding&lt;br /&gt;
&amp;lt;code&amp;gt;[]&lt;br /&gt;
$(OBJ)$/wrap_example.obj: $(MISC)$/example.cxx&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
and/or&lt;br /&gt;
&amp;lt;code&amp;gt;[]&lt;br /&gt;
$(SLO)$/wrap_example.obj: $(MISC)$/example.cxx&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
at the bottom.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Coding Standards]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=XFastTokenHandler&amp;diff=174636</id>
		<title>XFastTokenHandler</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=XFastTokenHandler&amp;diff=174636"/>
		<updated>2010-07-10T17:08:25Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;DRAFT&lt;br /&gt;
&lt;br /&gt;
See [[FastParser]]&lt;br /&gt;
&lt;br /&gt;
= Abstract =&lt;br /&gt;
&lt;br /&gt;
An instance of this interface is used by a [[FastParser]] to convert xml names from utf8&lt;br /&gt;
to integer tokens used by [[XFastContextHandler]] and [[XFastAttributeList]]&lt;br /&gt;
&lt;br /&gt;
= IDL =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
module com {  module sun {  module star {  module xml {  module sax {  &lt;br /&gt;
&lt;br /&gt;
/** a container for the attributes of an xml element. &lt;br /&gt;
&lt;br /&gt;
	&amp;lt;br&amp;gt;Attributes are seperated into known attributes and unknown attributes.&lt;br /&gt;
	&amp;lt;p&amp;gt;Known attributes have a local name that is known to the &amp;lt;type&amp;gt;XFastTokenHandler&amp;lt;/token&amp;gt;&lt;br /&gt;
	registered at the &amp;lt;type&amp;gt;XFastParser&amp;lt;/type&amp;gt; which created the sax event containing&lt;br /&gt;
	this attributes. If an attribute also has a namespace, that must be registered&lt;br /&gt;
	at the &amp;lt;type&amp;gt;XFastParser&amp;lt;/type&amp;gt;, else this attribute is also unknown even if&lt;br /&gt;
	the local name is known.&lt;br /&gt;
 */&lt;br /&gt;
interface XFastAttributeList: com::sun::star::uno::XInterface&lt;br /&gt;
{&lt;br /&gt;
	/** checks if an attribute is available.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		@param Token&lt;br /&gt;
			contains the integer token from the &amp;lt;type&amp;gt;XFastTokenHandler&amp;lt;/type&amp;gt;&lt;br /&gt;
			registered at the &amp;lt;type&amp;gt;XFastParser&amp;lt;/type&amp;gt;.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
			If the attribute name has a namespace that was registered with the&lt;br /&gt;
			&amp;lt;type&amp;gt;XFastParser&amp;lt;/type&amp;gt;, Token contains the integer token of the&lt;br /&gt;
			attributes local name from the &amp;lt;type&amp;gt;XFastTokenHandler&amp;lt;/type&amp;gt; and&lt;br /&gt;
			the integer token of the namespace combined with an arithmetic&lt;br /&gt;
			&amp;lt;b&amp;gt;or&amp;lt;/b&amp;gt; operation.&lt;br /&gt;
&lt;br /&gt;
		@returns&lt;br /&gt;
			&amp;lt;TRUE/&amp;gt;, if the attribute is available&lt;br /&gt;
	*/&lt;br /&gt;
	boolean hasAttribute( [in] long Token );&lt;br /&gt;
&lt;br /&gt;
	/** retrieves the token of an attributes value.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		@param Token&lt;br /&gt;
			contains the integer token from the &amp;lt;type&amp;gt;XFastTokenHandler&amp;lt;/type&amp;gt;&lt;br /&gt;
			registered at the &amp;lt;type&amp;gt;XFastParser&amp;lt;/type&amp;gt;.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
			If the attribute name has a namespace that was registered with the&lt;br /&gt;
			&amp;lt;type&amp;gt;XFastParser&amp;lt;/type&amp;gt;, Token contains the integer token of the&lt;br /&gt;
			attributes local name from the &amp;lt;type&amp;gt;XFastTokenHandler&amp;lt;/type&amp;gt; and&lt;br /&gt;
			the integer token of the namespace combined with an arithmetic&lt;br /&gt;
			&amp;lt;b&amp;gt;or&amp;lt;/b&amp;gt; operation.&lt;br /&gt;
&lt;br /&gt;
		@returns&lt;br /&gt;
			The integer token of the value from the attribute or &amp;lt;const&amp;gt;FastToken::Invalid&amp;lt;/const&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		@raises SAXEXception&lt;br /&gt;
			if the attribute is not available&lt;br /&gt;
&lt;br /&gt;
	*/&lt;br /&gt;
	long getValueToken( [in] long Token )&lt;br /&gt;
		raises( SAXException );&lt;br /&gt;
&lt;br /&gt;
	/**retrieves the token of an attributes value.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		@param Token&lt;br /&gt;
			contains the integer token from the &amp;lt;type&amp;gt;XFastTokenHandler&amp;lt;/type&amp;gt;&lt;br /&gt;
			registered at the &amp;lt;type&amp;gt;XFastParser&amp;lt;/type&amp;gt;.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
			If the attribute name has a namespace that was registered with the&lt;br /&gt;
			&amp;lt;type&amp;gt;XFastParser&amp;lt;/type&amp;gt;, Token contains the integer token of the&lt;br /&gt;
			attributes local name from the &amp;lt;type&amp;gt;XFastTokenHandler&amp;lt;/type&amp;gt; and&lt;br /&gt;
			the integer token of the namespace combined with an arithmetic&lt;br /&gt;
			&amp;lt;b&amp;gt;or&amp;lt;/b&amp;gt; operation.&lt;br /&gt;
&lt;br /&gt;
		@param Default&lt;br /&gt;
			This value will be returned if the attribute is not available&lt;br /&gt;
&lt;br /&gt;
		@returns&lt;br /&gt;
			If the attribute is available it returns the integer token of the value&lt;br /&gt;
			from the attribute or &amp;lt;const&amp;gt;FastToken::Invalid&amp;lt;/const&amp;gt;.&lt;br /&gt;
			If not the value of &amp;lt;param&amp;gt;Default&amp;lt;/param&amp;gt; is returned.&lt;br /&gt;
&lt;br /&gt;
	*/&lt;br /&gt;
	long getOptionalValueToken( [in] long Token, [in] long Default );&lt;br /&gt;
&lt;br /&gt;
	/** retrieves the value of an attributes.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		@param Token&lt;br /&gt;
			contains the integer token from the &amp;lt;type&amp;gt;XFastTokenHandler&amp;lt;/type&amp;gt;&lt;br /&gt;
			registered at the &amp;lt;type&amp;gt;XFastParser&amp;lt;/type&amp;gt;.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
			If the attribute name has a namespace that was registered with the&lt;br /&gt;
			&amp;lt;type&amp;gt;XFastParser&amp;lt;/type&amp;gt;, Token contains the integer token of the&lt;br /&gt;
			attributes local name from the &amp;lt;type&amp;gt;XFastTokenHandler&amp;lt;/type&amp;gt; and&lt;br /&gt;
			the integer token of the namespace combined with an arithmetic&lt;br /&gt;
			&amp;lt;b&amp;gt;or&amp;lt;/b&amp;gt; operation.&lt;br /&gt;
&lt;br /&gt;
		@returns&lt;br /&gt;
			The string value from the attribute.&lt;br /&gt;
&lt;br /&gt;
		@raises SAXEXception&lt;br /&gt;
			if the attribute is not available&lt;br /&gt;
&lt;br /&gt;
	*/&lt;br /&gt;
	string getValue( [in] long Token )&lt;br /&gt;
		raises( SAXException );&lt;br /&gt;
&lt;br /&gt;
	/** retrieves the value of an attributes.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		@param Token&lt;br /&gt;
			contains the integer token from the &amp;lt;type&amp;gt;XFastTokenHandler&amp;lt;/type&amp;gt;&lt;br /&gt;
			registered at the &amp;lt;type&amp;gt;XFastParser&amp;lt;/type&amp;gt;.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
			If the attribute name has a namespace that was registered with the&lt;br /&gt;
			&amp;lt;type&amp;gt;XFastParser&amp;lt;/type&amp;gt;, Token contains the integer token of the&lt;br /&gt;
			attributes local name from the &amp;lt;type&amp;gt;XFastTokenHandler&amp;lt;/type&amp;gt; and&lt;br /&gt;
			the integer token of the namespace combined with an arithmetic&lt;br /&gt;
			&amp;lt;b&amp;gt;or&amp;lt;/b&amp;gt; operation.&lt;br /&gt;
&lt;br /&gt;
		@returns&lt;br /&gt;
			The string value from the attribute or an empty string if the&lt;br /&gt;
			attribute is not available.&lt;br /&gt;
	*/&lt;br /&gt;
	string getOptionalValue( [in] long Token );&lt;br /&gt;
&lt;br /&gt;
	/** returns a sequence of attributes which names and or namespaces URLS&lt;br /&gt;
		can not be translated to tokens.&lt;br /&gt;
	*/&lt;br /&gt;
	sequence&amp;lt; ::com::sun::star::xml::Attribute &amp;gt; getUnknownAttributes();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
}; }; }; }; };  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Sample implementation using gperf =&lt;br /&gt;
&lt;br /&gt;
[http://www.gnu.org/software/gperf/gperf.html gperf] is a cool little tool to generate a perfect&lt;br /&gt;
hash algorithm at compile time for a fixed set of strings.&lt;br /&gt;
&lt;br /&gt;
When writing a filter to import an xml format you usually have a list of valid xml names.&lt;br /&gt;
They can be easily extracted from a schema. Lets assume you already have a list&lt;br /&gt;
of valid xml names in the file &amp;#039;&amp;#039;tokens.txt&amp;#039;&amp;#039;, for example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
User&lt;br /&gt;
Admin&lt;br /&gt;
Name&lt;br /&gt;
Login&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following pearl script can convert that file to an input file for gperf and&lt;br /&gt;
also a header file with one const sal_Int32 identifier for each xml name.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
my $ARGV0 = shift;&lt;br /&gt;
my $ARGV1 = shift;&lt;br /&gt;
my $ARGV2 = shift;&lt;br /&gt;
&lt;br /&gt;
open ( TOKENS, $ARGV0 ) || die &amp;quot;can&amp;#039;t open token file: $!&amp;quot;;&lt;br /&gt;
my %tokens;&lt;br /&gt;
&lt;br /&gt;
while ( defined (my $line = &amp;lt;TOKENS&amp;gt;) )&lt;br /&gt;
{&lt;br /&gt;
	chomp($line);&lt;br /&gt;
	my @token = split(&amp;#039; &amp;#039;,$line);&lt;br /&gt;
	unless ( defined ($token[1]) )&lt;br /&gt;
	{&lt;br /&gt;
		$token[1] = &amp;quot;XML_&amp;quot;.$token[0];&lt;br /&gt;
		$token[1] =~ tr/\-\.\:/___/;&lt;br /&gt;
		$token[1] =~ s/\+/PLUS/g;&lt;br /&gt;
		$token[1] =~ s/\-/MINUS/g;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	$tokens{$token[0]} = $token[1];&lt;br /&gt;
}&lt;br /&gt;
close ( TOKENS );&lt;br /&gt;
&lt;br /&gt;
open ( HXX, &amp;quot;&amp;gt;$ARGV1&amp;quot; ) or die &amp;quot;can&amp;#039;t open tokens.hxx file: $!&amp;quot;;&lt;br /&gt;
open ( GPERF, &amp;quot;&amp;gt;$ARGV2&amp;quot; ) or die &amp;quot;can&amp;#039;t open tokens.gperf file: $!&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
print ( GPERF &amp;quot;%language=C++\n&amp;quot; );&lt;br /&gt;
print ( GPERF &amp;quot;%global-table\n&amp;quot; );&lt;br /&gt;
print ( GPERF &amp;quot;%null-strings\n&amp;quot; );&lt;br /&gt;
print ( GPERF &amp;quot;%struct-type\n&amp;quot; );&lt;br /&gt;
print ( GPERF &amp;quot;struct xmltoken\n&amp;quot; );&lt;br /&gt;
print ( GPERF &amp;quot;{\n&amp;quot; );&lt;br /&gt;
print ( GPERF &amp;quot;  const sal_Char *name; sal_Int32 nToken; \n&amp;quot; );&lt;br /&gt;
print ( GPERF &amp;quot;};\n&amp;quot; );&lt;br /&gt;
print ( GPERF &amp;quot;%%\n&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
print ( HXX &amp;quot;#ifndef _TOKEN_HXX_\n&amp;quot; );&lt;br /&gt;
print ( HXX &amp;quot;#define _TOKEN_HXX_\n\n&amp;quot; );&lt;br /&gt;
print ( HXX &amp;quot;#ifndef _SAL_TYPES_H_\n&amp;quot; );&lt;br /&gt;
print ( HXX &amp;quot;#include &amp;lt;sal/types.h&amp;gt;\n&amp;quot; );&lt;br /&gt;
print ( HXX &amp;quot;#endif\n\n&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
$i = 0;&lt;br /&gt;
foreach( sort(keys(%tokens)) )&lt;br /&gt;
{&lt;br /&gt;
	print( HXX &amp;quot;const sal_Int32 $tokens{$_} = $i;\n&amp;quot; );&lt;br /&gt;
	print( GPERF &amp;quot;$_,$tokens{$_}\n&amp;quot; );&lt;br /&gt;
	$i++;&lt;br /&gt;
}&lt;br /&gt;
print ( GPERF &amp;quot;%%\n&amp;quot; );&lt;br /&gt;
print ( HXX &amp;quot;const sal_Int32 XML_TOKEN_COUNT = $i;\n&amp;quot; );&lt;br /&gt;
print ( HXX &amp;quot;#endif\n&amp;quot; );&lt;br /&gt;
close ( HXX );&lt;br /&gt;
close ( GPERF );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The generated .hxx file has the following format&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#ifndef _TOKEN_HXX_&lt;br /&gt;
#define _TOKEN_HXX_&lt;br /&gt;
&lt;br /&gt;
#ifndef _SAL_TYPES_H_&lt;br /&gt;
#include &amp;lt;sal/types.h&amp;gt;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
const sal_Int32 User = 0:&lt;br /&gt;
const sal_Int32 Admin = 1;&lt;br /&gt;
const sal_Int32 Name = 2;&lt;br /&gt;
const sal_Int32 Login = 3;&lt;br /&gt;
const sal_Int32 XML_TOKEN_COUNT = 4;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be automated by adding the following at the end of your makefile.mk&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$(INCCOM)$/tokens.hxx $(MISC)$/tokens.gperf : tokens.txt gentoken.pl&lt;br /&gt;
		$(PERL) gentoken.pl tokens.txt $(INCCOM)$/tokens.hxx $(MISC)$/tokens.gperf&lt;br /&gt;
&lt;br /&gt;
$(INCCOM)$/tokens.cxx : $(MISC)$/tokens.gperf&lt;br /&gt;
		gperf --compare-strncmp --output-file=$(MISC)$/_tokens.cxx $(MISC)$/tokens.gperf&lt;br /&gt;
		$(TYPE) $(MISC)$/_tokens.cxx | $(SED) -e &amp;quot;s/(char\*)0/(char\*)0, 0/g&amp;quot; &amp;gt;$(INCCOM)$/tokens.cxx&lt;br /&gt;
&lt;br /&gt;
$(SLO)$/tokenmap.obj : $(INCCOM)$/tokens.cxx $(INCCOM)$/tokens.hxx&lt;br /&gt;
&lt;br /&gt;
$(INCCOM)$/tokens.gperf : $(INCCOM)$/tokens.hxx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This automatically creates the tokens.hxx and a tokens.cxx in your platforms include folder of your project.&lt;br /&gt;
&lt;br /&gt;
The following code uses the tokens.cxx generated by gperf to implement a XFastTokenHandler&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;com/sun/star/xml/sax/XFastTokenHandler.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/xml/sax/FastToken.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;cppuhelper/implbase1.hxx&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;tokens.hxx&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;tokens.cxx&amp;quot; // this also includes the c++ code created from gperf&lt;br /&gt;
&lt;br /&gt;
using ::rtl::OUString;&lt;br /&gt;
using ::osl::Mutex;&lt;br /&gt;
using ::osl::MutexGuard;&lt;br /&gt;
using namespace ::com::sun::star::xml::sax;&lt;br /&gt;
using namespace ::com::sun::star::uno;&lt;br /&gt;
&lt;br /&gt;
class FastTokenHandler : public ::cppu::WeakImplHelper1&amp;lt; XFastTokenHandler &amp;gt;&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
  virtual sal_Int32 SAL_CALL getToken( const OUString&amp;amp; Identifier ) throw (RuntimeException);&lt;br /&gt;
  virtual OUString SAL_CALL getIdentifier( sal_Int32 Token ) throw (RuntimeException);&lt;br /&gt;
  virtual sal_Int32 SAL_CALL getTokenFromUTF8( const Sequence&amp;lt; sal_Int8 &amp;gt;&amp;amp; Identifier ) throw (RuntimeException);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
Mutex&amp;amp; getTokenMutex()&lt;br /&gt;
{&lt;br /&gt;
  static Mutex aMutex;&lt;br /&gt;
  return aMutex;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
sal_Int32 FastTokenHandler::getToken( const OUString&amp;amp; Identifier ) throw (RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
  MutexGuard guard( getTokenMutex() );&lt;br /&gt;
&lt;br /&gt;
  OString aUTF8( Identifier.getStr(), Identifier.getLength(), RTL_TEXTENCODING_UTF8 );&lt;br /&gt;
&lt;br /&gt;
  struct xmltoken * t = Perfect_Hash::in_word_set( aUTF8, aUTF8.getLength() );&lt;br /&gt;
  if( t )&lt;br /&gt;
    return t-&amp;gt;nToken;&lt;br /&gt;
  else&lt;br /&gt;
    return FastToken::DONTKNOW;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
OUString FastTokenHandler::getIdentifier( sal_Int32 nToken ) throw (RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
  MutexGuard guard( getTokenMutex() );&lt;br /&gt;
&lt;br /&gt;
  if( nToken &amp;gt;= XML_TOKEN_COUNT )&lt;br /&gt;
    return OUString();&lt;br /&gt;
&lt;br /&gt;
  static OUString aTokens[XML_TOKEN_COUNT];&lt;br /&gt;
&lt;br /&gt;
  if( aTokens[nToken].getLength() == 0 )&lt;br /&gt;
    aTokens[nToken] = OUString::createFromAscii(wordlist[nToken].name);&lt;br /&gt;
&lt;br /&gt;
  return aTokens[nToken];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
sal_Int32 FastTokenHandler::getTokenFromUTF8( const Sequence&amp;lt; sal_Int8 &amp;gt;&amp;amp; Identifier ) throw (RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
  MutexGuard guard( getTokenMutex() );&lt;br /&gt;
&lt;br /&gt;
  struct xmltoken * t = Perfect_Hash::in_word_set((const char*)Identifier.getConstArray(), Identifier.getLength());&lt;br /&gt;
  if( t )&lt;br /&gt;
    return t-&amp;gt;nToken;&lt;br /&gt;
  else&lt;br /&gt;
    return FastToken::DONTKNOW;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
[[Category:API]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Mac_OS_X_Implementing_HIView&amp;diff=169357</id>
		<title>Mac OS X Implementing HIView</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Mac_OS_X_Implementing_HIView&amp;diff=169357"/>
		<updated>2010-05-28T00:07:53Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Contributors ==&lt;br /&gt;
&lt;br /&gt;
Eric Bachard[[http://wiki.services.openoffice.org/wiki/User:Ericb ericb]]&lt;br /&gt;
&lt;br /&gt;
Sébastien Plisson [[http://wiki.services.openoffice.org/wiki/User:Plipli plipli]]&lt;br /&gt;
&lt;br /&gt;
== Introduction == &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;[DRAFT]  : means,  not yet working, work in progress ... &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
HIObject is a common base class for all user interface objects and all menus, windows, controls, toolbars, and so on, are subclasses of HIObject.&lt;br /&gt;
&lt;br /&gt;
HIView is an object-oriented view system subclassed from HIObject. All controls are implemented as HIView objects (&amp;quot;views&amp;quot;). You can easily subclass HIView classes, making it easy to implement custom controls. Over time the HIView API will replace the current Control Manager. See [[http://developer.apple.com/documentation/Carbon/Conceptual/HandlingWindowsControls/hitb-wind_cont_tasks/chapter_3_section_9.html HIView intro]]&lt;br /&gt;
&lt;br /&gt;
The main idea behind HIView is to superpose plans, to create any view, using compositing possibilities of Quartz Graphical Engine. &lt;br /&gt;
&lt;br /&gt;
The final result is the superposition of all plans, following simple rules like :&lt;br /&gt;
&lt;br /&gt;
 - The last plan is always drawn on the previous one ;&lt;br /&gt;
 - Some plans can  be declared visible, or not, very easily.&lt;br /&gt;
&lt;br /&gt;
This page is part of [[http://wiki.services.openoffice.org/wiki/Mac_OS_X_Porting_-_Native_Controls Native Controls Implementation]] and the objective is to use HIView for HIComboboxes or other HI*  controls. &lt;br /&gt;
&lt;br /&gt;
Our objective is to bind vcl controls with HI* controls, from Carbon API. &lt;br /&gt;
&lt;br /&gt;
e.g.  :  implement HICombobox as one control only.&lt;br /&gt;
&lt;br /&gt;
The generic implementation, under tests (and not fully working), uses : &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;In progress :&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
- plipli : &amp;#039;&amp;#039;&amp;#039;HIFramework&amp;#039;&amp;#039;&amp;#039; integration : compiled, to be cleaned up before testing delivery to mac@porting ;&lt;br /&gt;
- ericb/ismael : salnativewidget - create and bind &amp;#039;&amp;#039;&amp;#039;native controls&amp;#039;&amp;#039;&amp;#039; (HIViews) (ericb) and &amp;#039;&amp;#039;&amp;#039;HIWindow&amp;#039;&amp;#039;&amp;#039; (ismael);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note : we &amp;quot;or&amp;quot;- ed kWindowCompositingAttribute in nWindowAttributes, to see compositing effects. &lt;br /&gt;
[FIXME] : investigate, because use this attribute causes refresh issues&lt;br /&gt;
&lt;br /&gt;
== HIFramework integration and benefits ==&lt;br /&gt;
--[[User:Plipli|Plipli]] 15:00, 25 April 2007 (CEST)&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;Origin&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039; : Issued from Apple samples&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;Pros&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039; : &lt;br /&gt;
- use recent API code, &amp;lt;br&amp;gt;&lt;br /&gt;
- given with many helpers and set/getters to manage data and events&amp;lt;br&amp;gt;&lt;br /&gt;
- easily adaptable to use new services coming with Leopard (MacOSX 0.5)&amp;lt;br&amp;gt;&lt;br /&gt;
- up/down compatibility with different MacOSX versions&amp;lt;br&amp;gt;&lt;br /&gt;
- hiobject registering system : low couplage with the utility classes of HIFramework&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;Cons&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039; :&lt;br /&gt;
- ?? too nice to be true :-)&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;Step by step&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039; :&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;1&amp;#039;&amp;#039;&amp;#039; - When any HIObject is created in salframe/salnativewidget (AquaSalFrame / AquaSalGraphics) it will be &lt;br /&gt;
registered to HIFramework base classes ;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;2a&amp;#039;&amp;#039;&amp;#039; - Being registered gives this instance of HIView/HIWindow access to helpers/setters/getters methods ;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;2b&amp;#039;&amp;#039;&amp;#039; - Event handling is highly centralized/factored : create, initialize, draw... ;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;3&amp;#039;&amp;#039;&amp;#039; - Almost all possible data / events is covered by HIFramework and will be easily used, as new controls are implemented in salnativewidget ;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;Conclusion&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039; :&lt;br /&gt;
- Let&amp;#039;s clean it, test it and enjoy fastest implementation of Aqua native controls !! (GsoC fun ;-)&lt;br /&gt;
&lt;br /&gt;
== Technical principles ==&lt;br /&gt;
&lt;br /&gt;
1) OO ask to VCL / native implementation code to draw controls (ie DrawNativeControl) or images or text&lt;br /&gt;
&lt;br /&gt;
2) For controls, native implementation code create objects but do not draw them&lt;br /&gt;
For images and text, native code draw objects to context (from QDBegin) or context from HiView event&lt;br /&gt;
&lt;br /&gt;
3) When HIView events are received by event handler, especially kEventControlDraw, native code should draw controls to context given by the event&lt;br /&gt;
&lt;br /&gt;
4) Native code call needsDisplay functions to tell Quartz which zone to update&lt;br /&gt;
&lt;br /&gt;
== Current code implementation==&lt;br /&gt;
&lt;br /&gt;
===Events for HIView ===&lt;br /&gt;
&lt;br /&gt;
Two sorts of events are needed: &lt;br /&gt;
&lt;br /&gt;
*for objects (ClasskEventClassHIObject )  :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;kEventHIObjectConstruct&lt;br /&gt;
&lt;br /&gt;
kEventHIObjectInitialize&lt;br /&gt;
&lt;br /&gt;
kEventHIObjectDestruct&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*for controls themselves ( Class kEventClassControl ) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;kEventControlDraw &lt;br /&gt;
&lt;br /&gt;
kEventControlInitialize&lt;br /&gt;
&lt;br /&gt;
kEventControlHitTest&lt;br /&gt;
&lt;br /&gt;
kEventControlGetPartRegion&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Current implementation : see vcl/aqua/aquavclevents.hxx for more informations about the syntax.&lt;br /&gt;
&lt;br /&gt;
===Install Event Handler ===&lt;br /&gt;
&lt;br /&gt;
Now we have to install event Handler, inside AquaSalFrame::CreateNewSystemWindow() :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
InstallEventHandler (&lt;br /&gt;
                           GetControlEventTarget (mhView),&lt;br /&gt;
                           NewEventHandlerUPP (HandleHIViewEvent),&lt;br /&gt;
                           GetEventTypeCount (cHIViewEvent),&lt;br /&gt;
                           cHIViewEvent,&lt;br /&gt;
                           (void*)mhView, // note the use of the pointer &lt;br /&gt;
                           NULL&lt;br /&gt;
                           );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The HI* Event Handler ===&lt;br /&gt;
&lt;br /&gt;
The Handler is OSStatus type, and is used when events are detected.&lt;br /&gt;
&lt;br /&gt;
e.g.  : we created HandleHIViewEvent() &lt;br /&gt;
&lt;br /&gt;
using GetEventParameter, itself using the parameters described in Apple documentation. &lt;br /&gt;
&lt;br /&gt;
Code sample :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
OSStatus HandleHIViewEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void* inUserData)&lt;br /&gt;
{ &lt;br /&gt;
    //lock&lt;br /&gt;
    ImplSalYieldMutexAcquire();&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    OSStatus status = noErr;&lt;br /&gt;
    &lt;br /&gt;
    // we use mrContext, global and seen from everywhere &lt;br /&gt;
    CGContextRef mrContext; &lt;br /&gt;
    &lt;br /&gt;
    // create HIRect, containing the control bounds ( in local coordinates) &lt;br /&gt;
    HIRect bounds;  &lt;br /&gt;
&lt;br /&gt;
    status = GetEventParameter (inEvent, &lt;br /&gt;
                                kEventParamCGContextRef, &lt;br /&gt;
                                typeCGContextRef, &lt;br /&gt;
                                NULL, &lt;br /&gt;
                                sizeof (CGContextRef), &lt;br /&gt;
                                NULL, &lt;br /&gt;
                                &amp;amp;mrContext); &lt;br /&gt;
&lt;br /&gt;
    // not used, but useful&lt;br /&gt;
    //require_noerr(status, CantGetGraphicsContext); // 2&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
    // We need to know the bounds containing the current control &lt;br /&gt;
    HIViewGetBounds ((HIViewRef) inUserData, &amp;amp;bounds); &lt;br /&gt;
&lt;br /&gt;
    // not used, but useful&lt;br /&gt;
    //require_noerr(status, CantGetBoundingRectangle);&lt;br /&gt;
&lt;br /&gt;
    // unlock &lt;br /&gt;
    ImplSalYieldMutexRelease();&lt;br /&gt;
    &lt;br /&gt;
    return status;  &lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===HIView use in AquaSalFrame::CreateNewSystemWindow()  ===&lt;br /&gt;
&lt;br /&gt;
Code sample : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    //  TEST HIVIew part &lt;br /&gt;
    // Set mrContentView with HIView Content ViewRef&lt;br /&gt;
  &lt;br /&gt;
        HIRect myViewRect;&lt;br /&gt;
        myViewRect.origin.x = aContentRect.left; &lt;br /&gt;
        myViewRect.origin.y = aContentRect.right; &lt;br /&gt;
        myViewRect.size.width = aContentRect.right-aContentRect.left; &lt;br /&gt;
        myViewRect.size.height = aContentRect.bottom-aContentRect.top; &lt;br /&gt;
        OSStatus errval;&lt;br /&gt;
        errval = HIViewFindByID(HIViewGetRoot(mrWindow), kHIViewWindowContentID, &amp;amp;mrContentView); &lt;br /&gt;
&lt;br /&gt;
        // make the view visible                        &lt;br /&gt;
        HIViewSetVisible (mrContentView, true); &lt;br /&gt;
        &lt;br /&gt;
        // set the frame&lt;br /&gt;
        HIViewSetFrame (mrContentView, &amp;amp;myViewRect);&lt;br /&gt;
&lt;br /&gt;
        // Activate content view and children&lt;br /&gt;
        HIViewSetActivated (mrContentView,true);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Controls ===&lt;br /&gt;
&lt;br /&gt;
[FIXME]&lt;br /&gt;
&lt;br /&gt;
Example : HICombobox&lt;br /&gt;
&lt;br /&gt;
-&amp;gt; code located in vcl/aqua/source/gdi/salnativewidgets.cxx  , where all NWF are defined &lt;br /&gt;
&lt;br /&gt;
1) declare CTRL_COMBOBOX control as &amp;quot;true&amp;quot; in isNativeControlSupported() &lt;br /&gt;
&lt;br /&gt;
2) get the control region in getNativeControlRegion() &lt;br /&gt;
&lt;br /&gt;
3) add CTRL_COMBOBOX case in drawNativeControl()&lt;br /&gt;
&lt;br /&gt;
Code sample for the last part (Warning : not yet working !! ) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 switch( nType )&lt;br /&gt;
    {&lt;br /&gt;
            &lt;br /&gt;
        case CTRL_COMBOBOX:&lt;br /&gt;
        if ( ( nPart==PART_BUTTON_DOWN) ||  (nPart==PART_SUB_EDIT) || (nPart==PART_ENTIRE_CONTROL) || (nPart==HAS_BACKGROUND_TEXTURE))&lt;br /&gt;
&lt;br /&gt;
        .... (other code ) &lt;br /&gt;
&lt;br /&gt;
                    HIViewRef myCombo;&lt;br /&gt;
                                        &lt;br /&gt;
                    HIRect rc2;&lt;br /&gt;
                    &lt;br /&gt;
                    rc2.origin.x = rControlRegion.GetBoundRect().Left();&lt;br /&gt;
                    rc2.origin.y = rControlRegion.GetBoundRect().Top();&lt;br /&gt;
                    rc2.size.width = rControlRegion.GetBoundRect().GetWidth();&lt;br /&gt;
                    rc2.size.height = rControlRegion.GetBoundRect().GetHeight();&lt;br /&gt;
                    &lt;br /&gt;
                    HIComboBoxCreate ( &amp;amp;rc2 , NULL, NULL, NULL, kHIComboBoxStandardAttributes, &amp;amp;myCombo);&lt;br /&gt;
                    &lt;br /&gt;
                    HIViewSetVisible ( myCombo, true);&lt;br /&gt;
                    HIViewAddSubview (mrView, myCombo); &lt;br /&gt;
                    &lt;br /&gt;
                    HIViewSetNeedsDisplay (myCombo, true);                   &lt;br /&gt;
                    &lt;br /&gt;
                    printf (&amp;quot;rc2.origin.x %.0f  \n rc2.origin.y %.0f \n rc2.size.width %.0f \n rc2.size.height %.0f \n&amp;quot;, &lt;br /&gt;
                    rc2.origin.x, rc2.origin.y, rc2.size.width , rc2.size.height );&lt;br /&gt;
                                        &lt;br /&gt;
                    //HIViewSetActivated (myCombo,true);&lt;br /&gt;
&lt;br /&gt;
                     .....  (other code )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Usefull Links ==  &lt;br /&gt;
&lt;br /&gt;
=== References ===&lt;br /&gt;
&lt;br /&gt;
[[http://developer.apple.com/documentation/Carbon/Conceptual/HandlingWindowsControls/hitb-wind_cont_tasks/chapter_3_section_9.html Introducing HIView]]&lt;br /&gt;
&lt;br /&gt;
OverView : [[http://developer.apple.com/carbon/HIToolbox_feature.html HIToolbox]] &lt;br /&gt;
&lt;br /&gt;
HIVIew  : [[http://developer.apple.com/documentation/Carbon/Reference/HIViewReference/Reference/reference.html reference]] [[http://developer.apple.com/documentation/Carbon/Reference/HIViewReference/HIViewReference.pdf or .pdf format]]&lt;br /&gt;
&lt;br /&gt;
[[http://developer.apple.com/documentation/Carbon/Conceptual/Upgrading_HIToolbox/index.html Upgrading to HIToolbox]]&lt;br /&gt;
&lt;br /&gt;
===Code sample ===&lt;br /&gt;
&lt;br /&gt;
Build a big toy with all controls included : [http://developer.apple.com/samplecode/AppearanceSampleUpdated/listing575.html All controls + code around]&lt;br /&gt;
&lt;br /&gt;
High Level Toolbox, HIServices Release Notes : [http://developer.apple.com/releasenotes/Carbon/RN-HIToolbox/ HIToolbox]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Porting]]&lt;br /&gt;
[[Category:MacOSX]]&lt;br /&gt;
[[Category:Aqua]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Qa/Testtool_WinXP&amp;diff=169327</id>
		<title>Qa/Testtool WinXP</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Qa/Testtool_WinXP&amp;diff=169327"/>
		<updated>2010-05-27T09:46:42Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Quality Assurance]]&lt;br /&gt;
&lt;br /&gt;
This page is intended to help the Windows users to use the Testtool. The info on this page is for Windows XP, but it&amp;#039;s useful for most Windows versions.&lt;br /&gt;
Please, change &amp;#039;ja&amp;#039; for your ISO language code when needed.&lt;br /&gt;
Also take into account this info is up to version 2.1.&lt;br /&gt;
&lt;br /&gt;
= How to obtain OS =&lt;br /&gt;
You&amp;#039;ve to have an Windows license, a install disc and ensure the your license allows you to install it on a virtual machine.&lt;br /&gt;
&lt;br /&gt;
= Setup =&lt;br /&gt;
&lt;br /&gt;
As the releases tests takes about 15 hours and use the mouse, keyboard or an OpenOffice.org instance can&amp;#039;t be used, most people would prefer an alternative way to running the tests in the main box. The common method for Windows is:&lt;br /&gt;
* Install the OS inside a virtual machine&lt;br /&gt;
&lt;br /&gt;
== Installation of OS inside the Vmware player ==&lt;br /&gt;
You can use the virtual machine you want, but Vmware player is free and is a lot faster than Qemu, so we recommend using Qemu to setup the virtual machine and Vmware player to running it.&lt;br /&gt;
&lt;br /&gt;
The basic steps are:&lt;br /&gt;
* creation of HDD image&lt;br /&gt;
 qemu-img create -f vmdk winXPja.vmdk 10G&lt;br /&gt;
:You should have qemu-img on your OS path or run this command in the directory where Qemu is installed.&lt;br /&gt;
&lt;br /&gt;
* creation of winXPja.vmx &lt;br /&gt;
:Save the following section as the FC6.vmx file in the same folder in which the image file is located.&lt;br /&gt;
 config.version = &amp;quot;8&amp;quot;&lt;br /&gt;
 virtualHW.version = &amp;quot;3&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 displayName = &amp;quot;Windows XP SP2 Japanese&amp;quot;&lt;br /&gt;
 guestOS = &amp;quot;winXPPro&amp;quot;&lt;br /&gt;
 memsize = &amp;quot;256&amp;quot;&lt;br /&gt;
 usb.present = &amp;quot;FALSE&amp;quot;&lt;br /&gt;
 floppy0.present = &amp;quot;FALSE&amp;quot;&lt;br /&gt;
 sound.present = &amp;quot;TRUE&amp;quot;&lt;br /&gt;
 sound.virtualdev = &amp;quot;es1371&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 ethernet0.present = &amp;quot;TRUE&amp;quot;&lt;br /&gt;
 ethernet0.addressType = &amp;quot;generated&amp;quot;&lt;br /&gt;
 ethernet0.generatedAddress = &amp;quot;&amp;quot;&lt;br /&gt;
 ethernet0.generatedAddressOffset = &amp;quot;0&amp;quot;&lt;br /&gt;
 ethernet0.connectionType = &amp;quot;bridged&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 ide0:0.present = &amp;quot;TRUE&amp;quot;&lt;br /&gt;
 ide0:0.fileName = &amp;quot;winXPja.vmdk&amp;quot;&lt;br /&gt;
 ide0:0.deviceType = &amp;quot;disk&amp;quot;&lt;br /&gt;
 ide0:0.startConnected = &amp;quot;TRUE&amp;quot;&lt;br /&gt;
 ide0:0.redo = &amp;quot;&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 ide1:0.present = &amp;quot;TRUE&amp;quot;&lt;br /&gt;
 ide1:0.fileName = &amp;quot;auto detect&amp;quot;&lt;br /&gt;
 ide1:0.deviceType = &amp;quot;cdrom-raw&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 ide1:1.present = &amp;quot;TRUE&amp;quot;&lt;br /&gt;
 ide1:1.fileName = &amp;quot;auto detect&amp;quot;&lt;br /&gt;
 ide1:1.deviceType = &amp;quot;cdrom-raw&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
* follow instruction of p.37 of Guest OS installation guide&lt;br /&gt;
 http://www.vmware.com/pdf/GuestOS_guide.pdf&lt;br /&gt;
 http://www.vmware.com/support/pubs/player_pubs.html&lt;br /&gt;
 I allocated Y: for iso image mount drive at the host OS, thus this is 2nd CD/DVD-ROM drive.&lt;br /&gt;
 So, to boot Win XP Pro install program from CD-ROM image via daemon tool,&lt;br /&gt;
 I disconnected 1st CD-ROM at boot time when the vmware player started. Otherwise&lt;br /&gt;
 winXP Pro installation program doesn&amp;#039;t boot.&lt;br /&gt;
&lt;br /&gt;
* installation of vmware tools&lt;br /&gt;
 Get windows.iso from vmware server, mount windows.iso via daemon tool,&lt;br /&gt;
 and install.&lt;br /&gt;
&lt;br /&gt;
= Update the OS =&lt;br /&gt;
* Activation.&lt;br /&gt;
* via Windows update, updated to up to date Windows XP SP2.&lt;br /&gt;
&lt;br /&gt;
= Some miscellaneous settings =&lt;br /&gt;
We should not move mouse during this test. Screensaver is also harmful, activate sleep mode is very harmful.&lt;br /&gt;
&lt;br /&gt;
* Show all files and folders.&lt;br /&gt;
 o Translated from Japanese (may be wrong :)&lt;br /&gt;
  Explorer-&amp;gt;Tool-&amp;gt;Folder option -&amp;gt;show -&amp;gt;files and folders-&amp;gt;&lt;br /&gt;
  Not show extension that is registered.&lt;br /&gt;
* Show the extensions even they are registered&lt;br /&gt;
 o Translated from Japanese (may be wrong :)&lt;br /&gt;
  Explorer-&amp;gt;Tool-&amp;gt;Folder option -&amp;gt;show -&amp;gt;files and folders-&amp;gt;&lt;br /&gt;
  check Show All files and folders&lt;br /&gt;
* Screen saver has been disabled.&lt;br /&gt;
 o Translated from Japanese (may be wrong :)&lt;br /&gt;
  Control Panel -&amp;gt; Display -&amp;gt; Choose Screen saver-&amp;gt;&lt;br /&gt;
  -&amp;gt;Screen saver -&amp;gt;(none)&lt;br /&gt;
* Energy saving&lt;br /&gt;
 All set to (none)&lt;br /&gt;
* Disable the error report&lt;br /&gt;
   Control Panel -&amp;gt; System -&amp;gt; Advanced -&amp;gt; Error report&lt;br /&gt;
   You might to &amp;quot;Enable error report&amp;quot; and uncheck &amp;quot;Programs&amp;quot;, or to&lt;br /&gt;
&amp;quot;Disable error report&amp;quot;.&lt;br /&gt;
   Remember to enable later if you like it.&lt;br /&gt;
&lt;br /&gt;
= Download and install =&lt;br /&gt;
* OOo 2.1RC2&lt;br /&gt;
http://oootranslation.services.openoffice.org/pub/OpenOffice.org/2.1.0rc2/OOo_2.1.0rc2_20061130_Win32Intel_install_ja_wJRE.exe&lt;br /&gt;
* QA tool&lt;br /&gt;
ftp://ftp.ooodev.org/pub/qa/qatesttool_ooo201_20062311.tgz&lt;br /&gt;
&lt;br /&gt;
== Verification of MD5 sums ==&lt;br /&gt;
You might to download a MD5 sum checktool from [http://www.etree.org/md5com.html] and to install it.&lt;br /&gt;
* run a MD5 check against the downloaded file&lt;br /&gt;
 md5sum OOo_2.1.0rc2_20061130_Win32Intel_install_ja_wJRE.exe&lt;br /&gt;
* check the MD5 sum&lt;br /&gt;
:compare with the one from [http://www.openoffice.org/servlets/ReadMsg?list=releases&amp;amp;msgNo=10261]&lt;br /&gt;
* Check the qatesttool_ooo201_20062311.tgz MD5 sum&lt;br /&gt;
:compare with the one from [http://qa.openoffice.org/servlets/ReadMsg?list=dev&amp;amp;msgNo=7328]&lt;br /&gt;
&lt;br /&gt;
 % md5sum qatesttool_ooo201_20062311.tgz&lt;br /&gt;
 d43d1ed59ea7bd10330be1276d79c6b1  qatesttool_ooo201_20062311.tgz&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
It&amp;#039;s done as usual. You may want to follow instruction from official installation guide.&amp;lt;br&amp;gt;&lt;br /&gt;
(If wrong, raise an issue!)&amp;lt;br&amp;gt;&lt;br /&gt;
[http://documentation.openoffice.org/setup_guide2/2.x/en/SETUP_GUIDE_A4.pdf English]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://documentation.openoffice.org/setup_guide2/2.x/ja/SETUP_GUIDE_A4J.pdf Japanese]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== QA tools ==&lt;br /&gt;
* C:\Document and Settings\&amp;lt;User Name&amp;gt;\Application Data\testtool.ini has been created like following:&lt;br /&gt;
 [Misc]&lt;br /&gt;
 ServerTimeout=100000&lt;br /&gt;
 StopOnSyntaxError=0&lt;br /&gt;
 AutoReload=0&lt;br /&gt;
 AutoSave=0&lt;br /&gt;
 CurrentProfile=_profile_testtool&lt;br /&gt;
 ScriptFontName=Courier&lt;br /&gt;
 ScriptFontStyle=normal&lt;br /&gt;
 ScriptFontSize=12&lt;br /&gt;
 &lt;br /&gt;
 [Path]&lt;br /&gt;
 BaseDir=&lt;br /&gt;
 LogBaseDir=&lt;br /&gt;
 HIDDir=&lt;br /&gt;
 &lt;br /&gt;
 [GUI Platform]&lt;br /&gt;
 Current=501&lt;br /&gt;
 All=501&lt;br /&gt;
 &lt;br /&gt;
 [WinGeom]&lt;br /&gt;
 WinParams=228,124,802,620;1;0,0,0,0;&lt;br /&gt;
 &lt;br /&gt;
 [OooProgramDir]&lt;br /&gt;
 Current=C:\Program Files\OpenOffice.org 2.1&lt;br /&gt;
 All=C:\Program Files\OpenOffice.org 2.1&lt;br /&gt;
 &lt;br /&gt;
 [_profile_testtool]&lt;br /&gt;
 LogBaseDir=C:\work\qa\qatesttool\errorlog&lt;br /&gt;
 BaseDir=C:\work\qa\qatesttool&lt;br /&gt;
 HIDDir=C:\work\qa\qatesttool\global\hid&lt;br /&gt;
 AutoReload=0&lt;br /&gt;
 AutoSave=0&lt;br /&gt;
 StopOnSyntaxError=0&lt;br /&gt;
 *.bas=C:\work\qa\qatesttool\framework\first&lt;br /&gt;
 &lt;br /&gt;
 [LRU]&lt;br /&gt;
 MaxLRU=4&lt;br /&gt;
 LRU1=C:\work\qa\qatesttool\framework\first\first.bas&lt;br /&gt;
 &lt;br /&gt;
 [Communication]&lt;br /&gt;
 Host=localhost&lt;br /&gt;
 TTPort=12479&lt;br /&gt;
 UnoPort=10241&lt;br /&gt;
 &lt;br /&gt;
 [Crashreporter]&lt;br /&gt;
 UseProxy=false&lt;br /&gt;
 ProxyServer=none&lt;br /&gt;
 ProxyPort=8080&lt;br /&gt;
 AllowContact=false&lt;br /&gt;
 ReturnAddress=&lt;br /&gt;
 &lt;br /&gt;
 [Misc]&lt;br /&gt;
 ServerTimeout=4500&lt;br /&gt;
 StopOnSyntaxError=0&lt;br /&gt;
 AutoReload=0&lt;br /&gt;
 AutoSave=0&lt;br /&gt;
 CurrentProfile=_profile_testtool&lt;br /&gt;
 ScriptFontName=Courier&lt;br /&gt;
 ScriptFontStyle=normal&lt;br /&gt;
 ScriptFontSize=12&lt;br /&gt;
&lt;br /&gt;
* Extract qatesttool_ooo201_20062311.tgz at C:\work\qa so that tree become:&lt;br /&gt;
 C:\work\work\qa\testtool ... &lt;br /&gt;
&lt;br /&gt;
* Apply following patch for ooo_releasetests.bat&lt;br /&gt;
&lt;br /&gt;
C:\work\qa\qatesttool\script\win32\ooo_relesetests.bat&lt;br /&gt;
 --- qa/qatesttool/script/win32/ooo_releasetests.bat        Mon Oct 16 20:22:45 2006&lt;br /&gt;
 +++ qa/qatesttool/script/win32/ooo_releasetests.bat        Sun May 28 19:34:33 2006&lt;br /&gt;
 @@ -59,10 +59,10 @@&lt;br /&gt;
 &lt;br /&gt;
  rem set location of TestTool&lt;br /&gt;
  rem (full path including executable &amp;#039;testtool&amp;#039;)&lt;br /&gt;
 -set tool=&amp;quot;C:\qatesttool\bin\win32\testtool.exe&amp;quot;&lt;br /&gt;
 +set tool=&amp;quot;C:\Program Files\OpenOffice.org 2.1\program\testtool.exe&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
  rem set path to directory which contains directory &amp;#039;qatesttool&amp;#039;&lt;br /&gt;
 -set work=&amp;quot;C:\qatesttool\scripts&amp;quot;&lt;br /&gt;
 +set work=&amp;quot;C:\work\qa&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
  %tool% -run %work%\qatesttool\framework\first\first.bas&lt;br /&gt;
  %tool% -run %work%\qatesttool\global\tools\closeoffice.bas&lt;br /&gt;
&lt;br /&gt;
= QAtest =&lt;br /&gt;
&lt;br /&gt;
* Make sure that quick start is not active (you can verify by no seagull small icon at the right bottom of your screen)&lt;br /&gt;
* removed C:\work\qa\qatesttool\errorlogs\*res (if present)&lt;br /&gt;
* removed C:\Document and Settings\&amp;lt;UserName&amp;gt;\Application Data\OpenOffice.org2 (if present)&lt;br /&gt;
* Double click C:\work\qa\qatesttool\script\win32\ooo_releasetests.bat&lt;br /&gt;
&lt;br /&gt;
I recived following message from Windows XP:&lt;br /&gt;
 Important warning of Windows Security.&lt;br /&gt;
 To protect this computer, Windows firewall blocks some&lt;br /&gt;
 functions. Do you block this program?&amp;#039;&amp;#039;&lt;br /&gt;
 Name(N): OpenOffice.org 2.1&lt;br /&gt;
 Producer(P): OpenOffice.org&lt;br /&gt;
&lt;br /&gt;
I ignored this massage...during test.&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Check the result files for errors and upload the *res files to the IssueTracker.&lt;br /&gt;
If any found, try to reproduce manually and file bugs if needed.&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=SDKCppLanguage&amp;diff=168308</id>
		<title>SDKCppLanguage</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=SDKCppLanguage&amp;diff=168308"/>
		<updated>2010-05-17T21:49:59Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/Banner}}&lt;br /&gt;
{{Documentation/NeedsRework}}&lt;br /&gt;
=The UNO C++ Language=&lt;br /&gt;
The aim of this chapter is to explain peculiarities of the C++ language in the UNO environment and not to provide skills on traditional C++. To put it differently, I want to give here the UNO/C++ background, quite helpful in getting us started.&lt;br /&gt;
You can find e-Books on C++ [http://www.smart2help.com/e-books/ here].&lt;br /&gt;
&lt;br /&gt;
See also [[Uno/Article/Understanding_Uno|Understanding Uno]], [[Documentation/DevGuide/FirstSteps/Objects%2C_Interfaces%2C_and_Services|Objects, Interfaces, and Services]] and [[Documentation/BASIC_Guide/UNO|OOoBasic UNO Guide]] for a start with UNO.&lt;br /&gt;
&lt;br /&gt;
== Our starting Example : Simple Binaries (Executable) ==&lt;br /&gt;
&lt;br /&gt;
We want now to start with a SDK example. The purpose of the  example presented is to create an executable which interacts with OpenOffice.org. We can imagine two kind of interactions : direct interaction with OpenOffice.org or interaction with one of OOo&amp;#039;s shared library. We focus on this second case where the makefile is simpler. The shared library involved is then cppuhelper.uno.so (cppuhelper.uno.dll under Windows). Former case will be examined later.&lt;br /&gt;
I assume (I know nobody of the SDK team) this example is given to provide the simplest example we can do with the SDK. This is the Lifetime example: see at “&amp;lt;OpenOffice.org1.1_SDK&amp;gt;/examples/DevelopersGuide/ProfUNO/Lifetime”&lt;br /&gt;
&lt;br /&gt;
Before diving into the examples, you will need to set up your programming environment so you can create UNO programs. What&amp;#039;s required depends on what platform you&amp;#039;re working. This is shown in the first example with LINUX platform.&lt;br /&gt;
To check this example you only have to launch the makefile :&lt;br /&gt;
{{Documentation/Linux|&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd &amp;lt;OpenOffice.org1.1_SDK&amp;gt;&lt;br /&gt;
./setsdkenv_unix&lt;br /&gt;
cd examples/DevelopersGuide/ProfUNO/Lifetime&lt;br /&gt;
make&lt;br /&gt;
make ProfUnoLifetime.runexe&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
The last command line only launch the binary executable “ProfUnoLifetime” which interact with cpphelper.uno.so (cppuhelper.uno.dll under Windows) even if  OpenOffice.org is not running.&lt;br /&gt;
This example creates and releases an object, nothing more. The constructor and destructor of the object only write out a message. Its little size allows us to give its code here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 1 First Example (from SDK)&lt;br /&gt;
// C++&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;cppuhelper/weak.hxx&amp;gt;&lt;br /&gt;
&lt;br /&gt;
class MyOWeakObject : public ::cppu::OWeakObject&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
    MyOWeakObject() { printf( &amp;quot;constructed\n&amp;quot; ); }&lt;br /&gt;
    ~MyOWeakObject() { printf( &amp;quot;destructed\n&amp;quot; ); }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void simple_object_creation_and_destruction()&lt;br /&gt;
{&lt;br /&gt;
    // create the UNO object&lt;br /&gt;
    com::sun::star::uno::XInterface * p = new MyOWeakObject();&lt;br /&gt;
&lt;br /&gt;
    // acquire it, refcount becomes one&lt;br /&gt;
    p-&amp;gt;acquire();&lt;br /&gt;
&lt;br /&gt;
    printf( &amp;quot;before release\n&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    // release it, refcount drops to zero&lt;br /&gt;
    p-&amp;gt;release();&lt;br /&gt;
&lt;br /&gt;
    printf( &amp;quot;after release\n&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int main( char * argv[] )&lt;br /&gt;
{&lt;br /&gt;
    simple_object_creation_and_destruction();&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The two methods acquire and release will be encountered later. What exactly they do is not important for the moment. This example shows us how to write a class which inherits from an other class, how to write and call methods and how to instantiate the class.&lt;br /&gt;
All the listings given below only need to modify this C++ code  compile it and run it. You can therefore use the same makefile by possibly changing the name of the source file  (tackled in next section).&lt;br /&gt;
&lt;br /&gt;
== Types ==&lt;br /&gt;
The [[Documentation/DevGuide/FirstSteps/Common_Types|UNO types]] are given in the table below :&lt;br /&gt;
; UNO Types&lt;br /&gt;
{| border cellspacing=&amp;quot;0&amp;quot; width=&amp;quot;550&amp;quot;&lt;br /&gt;
|- style = &amp;quot;background:#b3e2d1;text-align:center&amp;quot;&lt;br /&gt;
| |UNO||Type description||Java||C++||Basic&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
| char||16-bit unicode character type||char||sal_Unicode || -&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|boolean ||boolean type; true and false ||boolean ||sal_Bool||Boolean&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|byte ||8-bit ordinal type||byte ||sal_Int8 ||Integer&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|short ||signed 16-bit ordinal type||short ||sal_Int16 ||Integer &lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|unsigned short||unsigned 16-bit ordinal type||- ||sal_uInt16 ||-&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|long ||signed 32-bit ordinal type||int ||sal_Int32 ||Long&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|unsigned long ||unsigned 32-bit type ||- ||sal_uInt32  ||-&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|hyper||signed 64-bit ordinal type||long  ||sal_Int64  ||-&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|unsigned hyper ||unsigned 64-bit ordinal type||- ||sal_uInt64  ||-&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|float  ||processor dependent float||float  ||float (IEEE float) ||Single&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|double  ||processor dependent double||double||double (IEEE double)||Double&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The UNO&amp;#039;s column represents all the types you can find in the specifications files : IDL files. We describe IDL files later (see chapter 10). The C++ column is what we are interested in when we program with this language. If you want to check the different programs given in this chapter, you can use the &amp;lt;OpenOffice.org1.1_SDK&amp;gt;/examples/DevelopersGuide/ProfUNO/Lifetime &lt;br /&gt;
example. Replace object_lifetime.cxx completely with the listing below (don&amp;#039;t forget to save the old file)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 2 A short UNO Program &lt;br /&gt;
// C++&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;cppuhelper/bootstrap.hxx&amp;gt;&lt;br /&gt;
&lt;br /&gt;
main( ) {&lt;br /&gt;
	sal_Int32 var1;&lt;br /&gt;
	var1 = 34;&lt;br /&gt;
	printf(&amp;quot;The var1 value is : %d\n&amp;quot;,var1);&lt;br /&gt;
   	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then launch &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make ALL&lt;br /&gt;
make ProfUnoLifetime.runexe&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and it works. Don&amp;#039;t forget ./setsdkenv_unix (only one time) on Linux and the corresponding command (setsdkenv_windows.bat) on Windows.&lt;br /&gt;
&lt;br /&gt;
==[[Uno/Cpp/Tutorials/Introduction_to_Cpp_Uno#Sequence|Sequences]]==&lt;br /&gt;
We can find also good materials in Developer&amp;#039;s guide on [[Documentation/DevGuide/FirstSteps/Sequence|Sequence]].&lt;br /&gt;
A sequence is an abstract view of a set of UNO types with a variable number of elements. As first example, we give a very simple program:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 3  UNO Sequences&lt;br /&gt;
// C++&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;cppuhelper/bootstrap.hxx&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/uno/Sequence.hxx&amp;gt;&lt;br /&gt;
using namespace com::sun::star::uno;&lt;br /&gt;
&lt;br /&gt;
main( ) {&lt;br /&gt;
	Sequence &amp;lt; sal_Int32 &amp;gt; SetOfInt(5);&lt;br /&gt;
	//var1 = 34;&lt;br /&gt;
	SetOfInt[2]=44;&lt;br /&gt;
	printf(&amp;quot;The value is : %d\n&amp;quot;,SetOfInt[2]);&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The important things to notice are as follows:&lt;br /&gt;
* the type of each element of the set is put between angular brackets: &amp;quot;&amp;lt;&amp;quot; and &amp;quot;&amp;gt;&amp;quot;. In the example above sal_int32 is the type.&lt;br /&gt;
* declaration of sequence is done with parentheses &amp;quot;(&amp;quot; and &amp;quot;)&amp;quot; and the number of elements of the sequence between them.  In the example above a sequence of five sal_Int32 elements is declared.&lt;br /&gt;
* accessing elements of the sequence is done with &amp;quot;[&amp;quot; and &amp;quot;]&amp;quot; and an index between them (generaly called subscript operator). This allows us to say that sequences are referenced like arrays. But they are different in some way, for instance they don&amp;#039;t have a fixed size. &lt;br /&gt;
* We have to include Sequence.hxx file in a program when using Sequence. Note that this file is provided with the SDK and this not always the case for all hxx files (some of them have to be reconstructed).&lt;br /&gt;
We have to use the correct namespace with adding &amp;quot;using namespace ...&amp;quot; If you don&amp;#039;t use this statement you have to write com::sun::star::uno::Sequence instead of Sequence.&lt;br /&gt;
A Sequence can be created with arbitrary UNO type but not with other types. &lt;br /&gt;
The object SetOfInt has many methods. We give an example to show some of them:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 4 Examples of using Sequence Methods&lt;br /&gt;
// C++&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;cppuhelper/bootstrap.hxx&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/uno/Sequence.hxx&amp;gt;&lt;br /&gt;
using namespace com::sun::star::uno;&lt;br /&gt;
&lt;br /&gt;
main( ) {&lt;br /&gt;
	Sequence &amp;lt; sal_Int32 &amp;gt; SetOfInt(5);&lt;br /&gt;
	sal_Int32 *table;&lt;br /&gt;
	SetOfInt[2]=44;&lt;br /&gt;
	printf(&amp;quot;The value is : %d\n&amp;quot;,SetOfInt[2]);&lt;br /&gt;
	// Tests whether the sequence has elements, i.e. elements count is greater than zero&lt;br /&gt;
	if (SetOfInt.hasElements()) printf(&amp;quot;Set not empty\n&amp;quot;);&lt;br /&gt;
	// Gets a pointer to elements array for reading and writing. If the sequence &lt;br /&gt;
	//  has a length of 0, then the returned pointer is undefined&lt;br /&gt;
	table = SetOfInt.getArray();&lt;br /&gt;
	table[4]=78;&lt;br /&gt;
	printf(&amp;quot;The value is : %d\n&amp;quot;,SetOfInt[4]); // prints out 78&lt;br /&gt;
	SetOfInt.realloc(7);&lt;br /&gt;
	printf(&amp;quot;New length : %d\n&amp;quot;,SetOfInt.getLength()); // prints out 7&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The comments explain what is printed out when executing this example. The method realloc is particularly important: it allows the size of set to change.&lt;br /&gt;
&lt;br /&gt;
Let us focus on using sequences in function or as parameter. An example is again more descriptive than a long text:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 5 Sequence and Parameters &lt;br /&gt;
// C++&lt;br /&gt;
// function&lt;br /&gt;
Sequence &amp;lt; sal_Int32 &amp;gt; initSequence(){&lt;br /&gt;
	sal_Int32 sourceArray[5]={1,2,3,4,5};&lt;br /&gt;
	Sequence &amp;lt; sal_Int32 &amp;gt; SeqOfInt(sourceArray,5);&lt;br /&gt;
	return SeqOfInt;&lt;br /&gt;
}&lt;br /&gt;
// reference parameter&lt;br /&gt;
void initSequence2(Sequence &amp;lt; sal_Int32 &amp;gt; &amp;amp;SeqOfInt ) {&lt;br /&gt;
	sal_Int32 sourceArray[4]={1,2,3,4};&lt;br /&gt;
	Sequence &amp;lt; sal_Int32 &amp;gt; SeqOfInt2(sourceArray,4);&lt;br /&gt;
	SeqOfInt=SeqOfInt2;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
An obvious call could be :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 6 Sequence and Parameters (following) &lt;br /&gt;
// C++&lt;br /&gt;
	SetOfInt = initSequence();&lt;br /&gt;
	printf(&amp;quot;New length : %d\n&amp;quot;,SetOfInt.getLength()); // prints out 5&lt;br /&gt;
	initSequence2(SetOfInt);&lt;br /&gt;
	printf(&amp;quot;New length : %d\n&amp;quot;,SetOfInt.getLength()); // prints out 4&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We cannot leave this section without adding that operators == and != are available with sequences. Note also that &amp;quot;toUnoSequence()&amp;quot;, &amp;quot;getCppuSequenceType()&amp;quot; and &amp;quot;getCharSequenceCppuType()&amp;quot; are also member functions.&lt;br /&gt;
&lt;br /&gt;
Passing a sequence into a function by value is, like a vector, somewhat inefficient because the function must make a copy of all elements. It&amp;#039;s better to use a constant reference as shown below:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 7 The Constant Reference method&lt;br /&gt;
//C++&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;cppuhelper/bootstrap.hxx&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/uno/Sequence.hxx&amp;gt;&lt;br /&gt;
using namespace com::sun::star::uno;&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
// Passing a Sequence by value using the Constant Reference method&lt;br /&gt;
void avoidCopy(const Sequence&amp;lt; double &amp;gt; &amp;amp;ConstRef){&lt;br /&gt;
	// ConstRef[2]=6.7; would fail here&lt;br /&gt;
	for(int i=0;i&amp;lt;ConstRef.getLength();i++)&lt;br /&gt;
           cout&amp;lt;&amp;lt;ConstRef[i]&amp;lt;&amp;lt;&amp;quot; &amp;quot;;&lt;br /&gt;
	cout&amp;lt;&amp;lt;endl;&lt;br /&gt;
	&lt;br /&gt;
}&lt;br /&gt;
	&lt;br /&gt;
main( ) {&lt;br /&gt;
    Sequence &amp;lt; double &amp;gt; demo(5);&lt;br /&gt;
    demo[0]=1.1;&lt;br /&gt;
    demo[1]=2.1;&lt;br /&gt;
    demo[2]=3.1;&lt;br /&gt;
    demo[3]=4.1;&lt;br /&gt;
    demo[4]=5.1;&lt;br /&gt;
    avoidCopy(demo);&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See other material in Developer&amp;#039;s Guide (UNO C++ Binding).&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
&lt;br /&gt;
In C, a string is simply an array of characters that always includes a binary zero (often called the null terminator) as its final array element. UNO/C++ API manages strings with two classes: OUString and OString. The former uses Unicode characters.&lt;br /&gt;
&lt;br /&gt;
; STRING UNO Type&lt;br /&gt;
{| border cellspacing=&amp;quot;0&amp;quot; width=&amp;quot;550&amp;quot;&lt;br /&gt;
|- style = &amp;quot;background:#b3e2d1;text-align:center&amp;quot;&lt;br /&gt;
| |UNO||Type description||Java||C++||Basic&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
| string||String of 16-bit unicode characters ||Java.lang.string||::rtl::OUString || String&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
But, if you want to use ASCII characters the latter class is for you.&lt;br /&gt;
===OUString and OString===&lt;br /&gt;
OUString and OString classes are designed for UNO programmers. Only OString can be used with a standard C printf. To put it differently OString is nearer to the common C ASCII strings (array of characters) than OUString (which is an array of Unicode).&lt;br /&gt;
But all strings managed by UNO API are OUString. That means, if you want to see something in the console, you have to convert OUString to OString. If you ask something to the user and want to pass it to UNO API, you have to convert OString to OUString. Then if you want to use the console (in general for testing) you have to learn first both conversions.&lt;br /&gt;
&lt;br /&gt;
==== OUString to OString ====&lt;br /&gt;
&lt;br /&gt;
If OUStr is a OUString object, we give this example for conversion:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 8 Converting OUString into OString&lt;br /&gt;
// C++&lt;br /&gt;
#include &amp;lt;rtl/string.hxx&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	OString o = OUStringToOString( OUStr, RTL_TEXTENCODING_ASCII_US );&lt;br /&gt;
	printf( &amp;quot;Conversion result : %s\n&amp;quot;, o.pData-&amp;gt;buffer );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== OString to OUString ====&lt;br /&gt;
The inverse conversion is easy too :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 9 Converting OString into OUString&lt;br /&gt;
// C++&lt;br /&gt;
	OUString foo;&lt;br /&gt;
	foo = OUString::createFromAscii(&amp;quot;Hi every body&amp;quot;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a complete conversion example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 10 A complete Example&lt;br /&gt;
// C++&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;cppuhelper/bootstrap.hxx&amp;gt;&lt;br /&gt;
#include &amp;lt;rtl/string.hxx&amp;gt;&lt;br /&gt;
using namespace rtl;&lt;br /&gt;
&lt;br /&gt;
main( ) {&lt;br /&gt;
	OUString OUStr;&lt;br /&gt;
	OUStr = OUString::createFromAscii(&amp;quot;Hi every body&amp;quot;);&lt;br /&gt;
	OString OStr = OUStringToOString( OUStr, RTL_TEXTENCODING_ASCII_US );&lt;br /&gt;
	printf( &amp;quot;OUStr was : %s\n&amp;quot;, OStr.pData-&amp;gt;buffer );&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We see that a rtl namespace has to be used. If not, please replace OUString by ::rtl::OUString.&lt;br /&gt;
OUString and OString objects are class type variables, and then the operations that can be performed on O(U)Strings take the form&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
        O(U)StringVariable.operation(argumentList)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For example, if string1 and string2 are variables of type OUString, then&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
        string1.compareTo(string2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
can be used to compare both strings. A function like compareTo(), which is part of the O(U)String-class is called a member function. The O(U)String class offers a large number of these member functions, as well as extensions of some well-known operators, like the assignment (=) and the comparison operator (==). These operators and functions are discussed in the following sections.&lt;br /&gt;
The OUString and OString methods are similar: we give a complete example which shows some of them:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 11 A more complete Example&lt;br /&gt;
// C++&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;cppuhelper/bootstrap.hxx&amp;gt;&lt;br /&gt;
#include &amp;lt;rtl/string.hxx&amp;gt;&lt;br /&gt;
using rtl::OUString;&lt;br /&gt;
using rtl::OString;&lt;br /&gt;
&lt;br /&gt;
main( ) {&lt;br /&gt;
	OUString OUStr1,OUStr2;&lt;br /&gt;
	OString OStr1, OStr2;&lt;br /&gt;
	OStr1=&amp;quot;Hi every body&amp;quot;;&lt;br /&gt;
	OStr2=&amp;quot;every body&amp;quot;;&lt;br /&gt;
	OUStr1 = OUString::createFromAscii(&amp;quot;Hi every body&amp;quot;);&lt;br /&gt;
	OUStr2 = OUString::createFromAscii(&amp;quot;Hi every body&amp;quot;);&lt;br /&gt;
	// Returns the length of this string&lt;br /&gt;
	printf(&amp;quot;Length : %d\n&amp;quot;,OUStr1.getLength()); // prints out 13&lt;br /&gt;
	// Compares two strings&lt;br /&gt;
	printf(&amp;quot;CompareTo : %d\n&amp;quot;,OUStr1.compareTo(OUStr2)); // prints out 0&lt;br /&gt;
	// Compares two strings&lt;br /&gt;
        // serviceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(&amp;quot;my_module.MyService2&amp;quot;) );&lt;br /&gt;
	printf(&amp;quot;equals : %d\n&amp;quot;,OUStr1.equals(OUStr2)); // prints out 1&lt;br /&gt;
	if (OUStr1.equals(OUStr2)) printf(&amp;quot;OK\n&amp;quot;);// prints out OK&lt;br /&gt;
	// Compares two strings&lt;br /&gt;
	printf(&amp;quot;CompareToAscii : %d\n&amp;quot;,OUStr1.compareToAscii(OStr1)); // prints out 0&lt;br /&gt;
	// Compares two strings with a maximum count of characters&lt;br /&gt;
	printf(&amp;quot;CompareToAscii : %d\n&amp;quot;,OUStr1.compareToAscii(OStr1),10); // prints out 0&lt;br /&gt;
	// Perform a comparison of a substring in this string&lt;br /&gt;
	// is &amp;quot;every body&amp;quot; in position 3 of OUStr1 ?&lt;br /&gt;
	if (OUStr1.match(OUString::createFromAscii(&amp;quot;every body&amp;quot;),3))&lt;br /&gt;
		printf(&amp;quot;match : OK\n&amp;quot;); //prints out match : OK&lt;br /&gt;
	// Perform a comparison of a substring in this string&lt;br /&gt;
	if (OUStr1.matchAsciiL(OStr2,OStr2.getLength(),3))&lt;br /&gt;
		printf(&amp;quot;matchAsciiL: OK\n&amp;quot;);&lt;br /&gt;
	// Returns the float value from this string&lt;br /&gt;
	OUStr2 = OUString::createFromAscii(&amp;quot;1.675&amp;quot;);&lt;br /&gt;
	printf(&amp;quot;toFloat : %f\n&amp;quot;,OUStr2.toFloat()); // prints out 1.675000&lt;br /&gt;
	// Value Of :&lt;br /&gt;
	OUStr1 = OUStr1.valueOf((float)1.56);&lt;br /&gt;
	OStr1 = OUStringToOString( OUStr1, RTL_TEXTENCODING_ASCII_US );&lt;br /&gt;
	printf( &amp;quot;Value of : %s\n&amp;quot;, OStr1.pData-&amp;gt;buffer );&lt;br /&gt;
	// concat&lt;br /&gt;
	OUStr2=OUStr2.concat(OUString::createFromAscii(&amp;quot; ...&amp;quot;));&lt;br /&gt;
	OStr1 = OUStringToOString( OUStr2, RTL_TEXTENCODING_ASCII_US );&lt;br /&gt;
	printf( &amp;quot;concat is : %s\n&amp;quot;, OStr1.pData-&amp;gt;buffer );&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We can also see in this program how the concat method (three last lines) is used. The toFloat() conversion method is not alone: toBoolean(), toChar(), toInt32(), toInt64() , toDouble(), toAsciiLowerCase() and toAsciiUpperCase() exist also. Now we terminate with presenting some other methods (see C++ material):&lt;br /&gt;
&lt;br /&gt;
; String methods&lt;br /&gt;
{| border cellspacing=&amp;quot;0&amp;quot; width=&amp;quot;850&amp;quot;&lt;br /&gt;
|- style = &amp;quot;background:#b3e2d1;text-align:center&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|Methods&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) ||Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|sal_Int32 hashCode()||Returns a hashcode for this string&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|sal_int32 lastIndexOf(sal_Unicode ch )||Returns the index within this string of the last occurrence of the specified character, searching backward starting at the end&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|sal_Int32 lastIndexOf(sal_Unicode ch, sal_Int32 fromIndex ) ||Returns the index within this string of the last occurrence of the specified character, searching backward starting at the specified index&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|sal_Int32 lastIndexOf(const OUString &amp;amp; str ) || Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the end&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|OUString copy(sal_Int32 beginIndex, sal_Int32 count ) OUString copy(sal_Int32 beginIndex ) ||Returns a new string that is a substring of this string&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|OUString replaceAt(sal_Int32 index, sal_Int32 count, const OUString &amp;amp; newStr ) ||Returns a new string resulting from replacing n = count characters from position index in this string with newStr&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|OUString replace(sal_Unicode oldChar, sal_Unicode newChar ) ||Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|OUString trim() ||Returns a new string resulting from removing white space from both ends of the string&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &amp;amp; index )  ||Returns a token in the string&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
I cannot close this section without giving a code found in OOo source /OOB680_m5/registry/source/regimpl.cxx&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 11-b Printing out an OUString&lt;br /&gt;
// C++&lt;br /&gt;
void printString(rtl::OUString const &amp;amp; s) {&lt;br /&gt;
    printf(&amp;quot;\&amp;quot;&amp;quot;);&lt;br /&gt;
    for (sal_Int32 i = 0; i &amp;lt; s.getLength(); ++i) {&lt;br /&gt;
        sal_Unicode c = s[i];&lt;br /&gt;
        if (c == &amp;#039;&amp;quot;&amp;#039; || c == &amp;#039;\\&amp;#039;) {&lt;br /&gt;
            printf(&amp;quot;\\%c&amp;quot;, static_cast&amp;lt; char &amp;gt;(c));&lt;br /&gt;
        } else if (s[i] &amp;gt;= &amp;#039; &amp;#039; &amp;amp;&amp;amp; s[i] &amp;lt;= &amp;#039;~&amp;#039;) {&lt;br /&gt;
            printf(&amp;quot;%c&amp;quot;, static_cast&amp;lt; char &amp;gt;(c));&lt;br /&gt;
        } else {&lt;br /&gt;
            printf(&amp;quot;\\u%04X&amp;quot;, static_cast&amp;lt; unsigned int &amp;gt;(c));&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    printf(&amp;quot;\&amp;quot;&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If you want to see the content of an OUString with standard output, you have only to convert it in OString :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 11-c Printing out an OUString with standard C++ output&lt;br /&gt;
// C++&lt;br /&gt;
  OUString OUStr  = OUString::createFromAscii( &amp;quot;Hello&amp;quot; );&lt;br /&gt;
  OString   OStr  = OUStringToOString ( OUStr,RTL_TEXTENCODING_UTF8);&lt;br /&gt;
  cout &amp;lt;&amp;lt;  Ostr &amp;lt;&amp;lt; endl;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===File Path ===&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Linux|Linux related content : the file paths are OS-dependent. To remove this dependency, UNO use URL and a way to transform a file path to an URL. We show an example now&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 12 UNO URL&lt;br /&gt;
// C++&lt;br /&gt;
// Don&amp;#039;t forget #include &amp;lt;osl/file.hxx&amp;gt;&lt;br /&gt;
	OUString sDocUrl;&lt;br /&gt;
    osl::FileBase::getFileURLFromSystemPath(&lt;br /&gt;
                 OUString::createFromAscii(&amp;quot;/home/smoutou/edt.sxd&amp;quot;),sDocUrl);&lt;br /&gt;
// Windows C++ to check&lt;br /&gt;
//	osl::FileBase::getFileURLFromSystemPath(&lt;br /&gt;
//			  OUString::createFromAscii(&amp;quot;\&amp;quot;C:\\My Documents\\tata.sxc\&amp;quot;&amp;quot;),sDocUrl);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A complete example is given in the below listing :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 13 Using URL&lt;br /&gt;
// C++&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;cppuhelper/bootstrap.hxx&amp;gt;&lt;br /&gt;
#include &amp;lt;osl/file.hxx&amp;gt;&lt;br /&gt;
using rtl::OUString;&lt;br /&gt;
using rtl::OString;&lt;br /&gt;
using namespace osl;&lt;br /&gt;
&lt;br /&gt;
main( ) {&lt;br /&gt;
	OUString sDocUrl;&lt;br /&gt;
	OString toPrintOut;&lt;br /&gt;
   	osl::FileBase::getFileURLFromSystemPath(&lt;br /&gt;
                 OUString::createFromAscii(&amp;quot;/home/smoutou/edt.sxd&amp;quot;),sDocUrl);&lt;br /&gt;
	toPrintOut = OUStringToOString( sDocUrl, RTL_TEXTENCODING_ASCII_US );&lt;br /&gt;
	printf( &amp;quot;URL is : %s\n&amp;quot;, toPrintOut.pData-&amp;gt;buffer );&lt;br /&gt;
	// prints out URL is : file:///home/smoutou/edt.sxd&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which shows how to use the conversion. Remember that we work with UNO and therefore the URL is an OUString.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Windows|Only file paths have to be changed to transform these programs into Windows programs}}&lt;br /&gt;
&lt;br /&gt;
=== SDK Example ===&lt;br /&gt;
Here is some code provided by SDK :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 14 SDK Example&lt;br /&gt;
// C++&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;rtl/ustrbuf.hxx&amp;gt;&lt;br /&gt;
#include &amp;lt;rtl/string.hxx&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using rtl::OUString;&lt;br /&gt;
using rtl::OUStringBuffer;&lt;br /&gt;
using rtl::OString;&lt;br /&gt;
&lt;br /&gt;
int main( int argc, char * argv [] )&lt;br /&gt;
{&lt;br /&gt;
    // string concatination&lt;br /&gt;
&lt;br /&gt;
    sal_Int32 n = 42;&lt;br /&gt;
    double pi = 3.14159;&lt;br /&gt;
&lt;br /&gt;
    // give it an initial size, should be a good guess.&lt;br /&gt;
    // stringbuffer extends if necessary&lt;br /&gt;
    OUStringBuffer buf( 128 );&lt;br /&gt;
&lt;br /&gt;
    // append an ascii string&lt;br /&gt;
    buf.appendAscii( &amp;quot;pi ( here &amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    // numbers can be simply appended&lt;br /&gt;
    buf.append( pi );&lt;br /&gt;
&lt;br /&gt;
    // lets the compiler count the stringlength, so this is more efficient than&lt;br /&gt;
    // the above appendAscii call, where length of the string must be calculated at&lt;br /&gt;
    // runtime&lt;br /&gt;
    buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(&amp;quot; ) multiplied with &amp;quot; ) );&lt;br /&gt;
    buf.append( n );&lt;br /&gt;
    buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(&amp;quot; gives &amp;quot;) );&lt;br /&gt;
    buf.append( (double)( n * pi ) );&lt;br /&gt;
    buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( &amp;quot;.&amp;quot; ) );&lt;br /&gt;
&lt;br /&gt;
    // now transfer the buffer into the string.&lt;br /&gt;
    // afterwards buffer is empty and may be reused again !&lt;br /&gt;
    OUString string = buf.makeStringAndClear();&lt;br /&gt;
&lt;br /&gt;
    // I could of course also used the OStringBuffer directly&lt;br /&gt;
    OString oString = rtl::OUStringToOString( string , RTL_TEXTENCODING_ASCII_US );&lt;br /&gt;
&lt;br /&gt;
    // just to print something&lt;br /&gt;
    printf( &amp;quot;%s\n&amp;quot; ,oString.getStr() );&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This example shows an other way to use OUString, OString and buffer.&lt;br /&gt;
 &lt;br /&gt;
For performance analysis see &lt;br /&gt;
[http://udk.openoffice.org/common/man/concept/string_invest.html Some String Performance Thoughts]&lt;br /&gt;
&lt;br /&gt;
===Sequence of Strings===&lt;br /&gt;
Sequence has been tackled in a previous [[SDKCppLanguage#Sequences|section]]. If you want to construct a Sequence of string (useful in list box ...) have a look on this piece of code :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 15 An Example of Sequence of Strings&lt;br /&gt;
// C++&lt;br /&gt;
// Sequence of string&lt;br /&gt;
#include &amp;lt;rtl/string.hxx&amp;gt;&lt;br /&gt;
// Don&amp;#039;t forget to add #include &amp;lt;com/sun/star/uno/Sequence.hxx&amp;gt;&lt;br /&gt;
// Don&amp;#039;t forget to add using namespace com::sun::star::uno;&lt;br /&gt;
	Sequence&amp;lt;OUString&amp;gt;seqStrlistItems(2);&lt;br /&gt;
	seqStrlistItems[0]=OUString::createFromAscii(&amp;quot;Item1&amp;quot;);&lt;br /&gt;
	seqStrlistItems[1]=OUString::createFromAscii(&amp;quot;Item2&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// retrieve them and prints out&lt;br /&gt;
	for (int i=0;i&amp;lt;seqStrlistItems.getLength();i++){&lt;br /&gt;
		OString toPrintOut = OUStringToOString(seqStrlistItems[i],RTL_TEXTENCODING_ASCII_US);&lt;br /&gt;
		printf(&amp;quot;-- %s\n&amp;quot;,toPrintOut.pData-&amp;gt;buffer);&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This code prints out in the shell console :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-- Item1&lt;br /&gt;
-- Item2&lt;br /&gt;
[smoutou@p3 Lifetime]$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is easy to understand and therefore I have nothing more to say about it.&lt;br /&gt;
&lt;br /&gt;
===Exercise on  Sequence of Strings===&lt;br /&gt;
Write and test the following &amp;quot;convert2SeqOUStrInDEBUGMODE&amp;quot; function with a sequence of &amp;quot;sal_Int8&amp;quot; as parameter and which returns a sequence of Strings in a format like the dump method of the old &amp;quot;debug&amp;quot; of DOS. This format  [[UNO_registery_and_Bootstrapping#C.2B.2B_Code_to_recover_Information_in_a_Binary_Sequence|will be used here]], but without this function.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution&amp;#039;&amp;#039;&amp;#039; : here is the corresponng function code&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Sequence&amp;lt; OUString &amp;gt; convert2SeqOUStrInDEBUGMODE(Sequence &amp;lt; sal_Int8 &amp;gt; seqBytes){&lt;br /&gt;
  sal_Int8 Hexa[16]={&amp;#039;0&amp;#039;,&amp;#039;1&amp;#039;,&amp;#039;2&amp;#039;,&amp;#039;3&amp;#039;,&amp;#039;4&amp;#039;,&amp;#039;5&amp;#039;,&amp;#039;6&amp;#039;,&amp;#039;7&amp;#039;,&amp;#039;8&amp;#039;,&amp;#039;9&amp;#039;,&amp;#039;A&amp;#039;,&amp;#039;B&amp;#039;,&amp;#039;C&amp;#039;,&amp;#039;D&amp;#039;,&amp;#039;E&amp;#039;,&amp;#039;F&amp;#039;};&lt;br /&gt;
  sal_Int32 lin,col;&lt;br /&gt;
  sal_Char line[80];&lt;br /&gt;
  sal_Int32 len,sequenceSize,index;&lt;br /&gt;
  len=seqBytes.getLength();&lt;br /&gt;
  sequenceSize=(len&amp;gt;&amp;gt;4)+2;&lt;br /&gt;
  if ((len&amp;amp;0XFFF0)==len) sequenceSize--; //if len%16==0&lt;br /&gt;
  Sequence&amp;lt; OUString &amp;gt; SeqOUStr(sequenceSize);&lt;br /&gt;
  // First line with length &lt;br /&gt;
  SeqOUStr[0] = OUString::createFromAscii(&amp;quot;Length:&amp;quot;)+&lt;br /&gt;
                OUString::valueOf((sal_Int32) seqBytes.getLength());&lt;br /&gt;
  len = len&amp;amp;0XFFF0; // remove the modulo 16&lt;br /&gt;
  for(lin=0;lin&amp;lt;len;lin=lin+16){&lt;br /&gt;
      for(col=0;col&amp;lt;16;col++){&lt;br /&gt;
        line[3*col]=Hexa[((unsigned char)seqBytes[lin+col])&amp;gt;&amp;gt;4];&lt;br /&gt;
	line[3*col+1]=Hexa[seqBytes[lin+col]&amp;amp;0x0F];&lt;br /&gt;
	line[3*col+2]=&amp;#039; &amp;#039;;&lt;br /&gt;
        if ((seqBytes[lin+col]&amp;lt;128)&amp;amp;&amp;amp;(seqBytes[lin+col]&amp;gt;20)) line[50+col]=seqBytes[lin+col];&lt;br /&gt;
        else line[50+col]=&amp;#039;.&amp;#039;;&lt;br /&gt;
      } /* end of for */&lt;br /&gt;
      line[66]=0; /* end of cstring...*/&lt;br /&gt;
      line[48]=&amp;#039; &amp;#039;;line[49]=&amp;#039; &amp;#039;;&lt;br /&gt;
  // ready to add the OUString in Sequence&lt;br /&gt;
      if ((lin%16)==0) index = lin/16+1; else index=lin/16+2;&lt;br /&gt;
      SeqOUStr[index]=OUString::createFromAscii(line);&lt;br /&gt;
  } /* end of for */ &lt;br /&gt;
  // the last line is more complicated because not complete&lt;br /&gt;
  // we only keep modulo&lt;br /&gt;
  len=seqBytes.getLength()&amp;amp;0x000F;&lt;br /&gt;
  if (len&amp;gt;0) { // only a line here if non-empty&lt;br /&gt;
  for (lin=0;lin&amp;lt;len;lin++){&lt;br /&gt;
    col=lin;&lt;br /&gt;
    line[3*col]=Hexa[((unsigned char)seqBytes[lin])&amp;gt;&amp;gt;4];&lt;br /&gt;
    line[3*col+1]=Hexa[seqBytes[lin]&amp;amp;0x0F];&lt;br /&gt;
    line[3*col+2]=&amp;#039; &amp;#039;;&lt;br /&gt;
    if ((seqBytes[lin]&amp;lt;128)&amp;amp;&amp;amp;(seqBytes[lin]&amp;gt;20)) line[50+col]=seqBytes[lin];&lt;br /&gt;
    else line[50+col]=&amp;#039;.&amp;#039;;&lt;br /&gt;
  }&lt;br /&gt;
  // we complete the line&lt;br /&gt;
  for (++col;col&amp;lt;16;col++){&lt;br /&gt;
	line[3*col]=&amp;#039; &amp;#039;;line[3*col+1]=&amp;#039; &amp;#039;;line[3*col+2]=&amp;#039; &amp;#039;;line[50+col]=&amp;#039; &amp;#039;;&lt;br /&gt;
  }&lt;br /&gt;
  line[66]=0; /* end of string...*/&lt;br /&gt;
  line[48]=&amp;#039; &amp;#039;;line[49]=&amp;#039; &amp;#039;;&lt;br /&gt;
  // ready to add the OUString in Sequence&lt;br /&gt;
  SeqOUStr[lin/16+2]=OUString::createFromAscii(line);&lt;br /&gt;
  } //end if&lt;br /&gt;
  return SeqOUStr;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
and now how this function can be used :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
sal_Int8 sourceArray[32]={1,22,23,24,55,56,57,8,9,10,11,12,13,14,15,16,17,18,19,61,62,-32,-33,-34,-35,26,127,-31,29,56,23,67};&lt;br /&gt;
        Sequence &amp;lt; sal_Int8 &amp;gt; seqBytes(sourceArray,32);&lt;br /&gt;
	Sequence &amp;lt; OUString &amp;gt; seqOUStr=convert2SeqOUStrInDEBUGMODE(seqBytes);&lt;br /&gt;
	printf(&amp;quot;%s\n&amp;quot;,OUStringToOString( seqOUStr[0], RTL_TEXTENCODING_ASCII_US ).pData-&amp;gt;buffer);&lt;br /&gt;
	printf(&amp;quot;%s\n&amp;quot;,OUStringToOString( seqOUStr[1], RTL_TEXTENCODING_ASCII_US ).pData-&amp;gt;buffer);&lt;br /&gt;
	printf(&amp;quot;%s\n&amp;quot;,OUStringToOString( seqOUStr[2], RTL_TEXTENCODING_ASCII_US ).pData-&amp;gt;buffer);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
In our [[Constructing_Helpers#Reflection_Helper|introspection tool]] we need also this format but in one string. It&amp;#039;s easy to write the corresponding code :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
OUString convert2OUStrInDEBUGMODE(Sequence &amp;lt; sal_Int8 &amp;gt; seqBytes){&lt;br /&gt;
  Sequence &amp;lt;OUString&amp;gt; SeqOUStr = convert2SeqOUStrInDEBUGMODE(seqBytes);&lt;br /&gt;
  OUString OUStr;&lt;br /&gt;
  for(sal_Int32 i=0;i&amp;lt;SeqOUStr.getLength();i++)&lt;br /&gt;
    OUStr = OUStr+SeqOUStr[i]+OUString::createFromAscii(&amp;quot;\n&amp;quot;);&lt;br /&gt;
  return OUStr;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
which can be used with :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
sal_Int8 sourceArray[32]={1,22,23,24,55,56,57,8,9,10,11,12,13,14,15,16,17,18,19,61,62,-32,-33,-34,-35,26,127,-31,29,56,23,67};&lt;br /&gt;
        Sequence &amp;lt; sal_Int8 &amp;gt; seqBytes(sourceArray,32);&lt;br /&gt;
&lt;br /&gt;
        OUString OUStr=convert2OUStrInDEBUGMODE(seqBytes);&lt;br /&gt;
        printf(&amp;quot;%s\n&amp;quot;,OUStringToOString( OUStr, RTL_TEXTENCODING_ASCII_US ).pData-&amp;gt;buffer);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== [[Uno/Cpp/Tutorials/Introduction_to_Cpp_Uno#Any|Any]] ==&lt;br /&gt;
We can find also good materials in Developer&amp;#039;s guide on [[Documentation/DevGuide/FirstSteps/Any|Any type]]. [[Uno/Cpp/Tutorials/Introduction_to_Cpp_Uno#Any|Any]] is easy to use only with &amp;lt;&amp;lt;= and &amp;gt;&amp;gt;= operators and we then often use intermediate variables. We can use also the build-in “makeAny” function :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 16 makeAny Example&lt;br /&gt;
// C++&lt;br /&gt;
Any any = makeAny((long) 1000);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We give first an example above :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;]&lt;br /&gt;
//Listing 17 Any Example&lt;br /&gt;
// C++&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;cppuhelper/bootstrap.hxx&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/uno/Any.hxx&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/uno/Sequence.hxx&amp;gt;&lt;br /&gt;
using rtl::OUString;&lt;br /&gt;
using rtl::OString;&lt;br /&gt;
using com::sun::star::uno::Any;&lt;br /&gt;
using namespace com::sun::star::uno;&lt;br /&gt;
using namespace rtl;&lt;br /&gt;
&lt;br /&gt;
main( ) {&lt;br /&gt;
	Any any,any2;&lt;br /&gt;
	sal_Int32 n=5,n2=18;&lt;br /&gt;
	any &amp;lt;&amp;lt;= n;&lt;br /&gt;
	// Gets the type name of the set value&lt;br /&gt;
	OUString OUStr = any.getValueTypeName();&lt;br /&gt;
	OString OStr = OUStringToOString( OUStr, RTL_TEXTENCODING_ASCII_US );&lt;br /&gt;
	printf( &amp;quot;Any type : %s\n&amp;quot;, OStr.pData-&amp;gt;buffer );// prints out Any type : long&lt;br /&gt;
	// Tests if any contains a value&lt;br /&gt;
	if (any.hasValue()) printf(&amp;quot;Any has a value\n&amp;quot;);// prints out Any has a value&lt;br /&gt;
	// Clears this any. If the any already contains a value, that value will be destructed and&lt;br /&gt;
	// its memory freed. After this has been called, the any does not contain a value.&lt;br /&gt;
	any.clear();&lt;br /&gt;
	if (any.hasValue()) printf(&amp;quot;Any has a value\n&amp;quot;);// prints out nothing&lt;br /&gt;
	any &amp;lt;&amp;lt;= n2;&lt;br /&gt;
	any2 &amp;lt;&amp;lt;= OUStr;&lt;br /&gt;
	// Unequality operator: compares two anys. The values need not be of equal type,&lt;br /&gt;
	// e.g. a short integer is compared to a long integer&lt;br /&gt;
	if (any != any2) printf(&amp;quot;Two different any\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	Sequence&amp;lt; Any&amp;gt; aValues(2);&lt;br /&gt;
	aValues[0] &amp;lt;&amp;lt;= (float) 1.1; aValues[1] &amp;lt;&amp;lt;= OUString::createFromAscii(&amp;quot;Text&amp;quot;);&lt;br /&gt;
	aValues[1] &amp;gt;&amp;gt;= OUStr;&lt;br /&gt;
	OStr = OUStringToOString( OUStr, RTL_TEXTENCODING_ASCII_US );&lt;br /&gt;
	float real;&lt;br /&gt;
	aValues[0] &amp;gt;&amp;gt;= real;&lt;br /&gt;
	printf(&amp;quot;Seq - length : %d val : %f val %s\n&amp;quot;,aValues.getLength(),real,OStr.pData-&amp;gt;buffer);&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This program prints out :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Any type : long&lt;br /&gt;
Any has a value&lt;br /&gt;
Two different any&lt;br /&gt;
Seq - length : 2 val : 1.100000 val Text&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Another important problem is a sequence of sequence of Any : we give now a piece of code without explanation :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 18 Sequence of Sequence of Any&lt;br /&gt;
// C++&lt;br /&gt;
Sequence&amp;lt; Sequence&amp;lt; Any &amp;gt; &amp;gt; aValues(2); &lt;br /&gt;
Sequence&amp;lt; Any &amp;gt; aValues2(2);&lt;br /&gt;
aValues2[0] &amp;lt;&amp;lt;=  (double) 1.1; aValues2[1] &amp;lt;&amp;lt;= OUString::createFromAscii(&amp;quot;Hello&amp;quot;);&lt;br /&gt;
aValues[0] = aValues2;&lt;br /&gt;
aValues2[0] &amp;lt;&amp;lt;=  (double)2.2; aValues2[1] &amp;lt;&amp;lt;= OUString::createFromAscii(&amp;quot;Hi&amp;quot;);&lt;br /&gt;
aValues[1] = aValues2;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This code uses two sequences. I have not found an other simpler way to do that. If anybody has a more straightforward solution, I would be happy learn about it. &lt;br /&gt;
If it is possible to access directely a value in a 2D array but I found only one means using an intermediate sequence (avalues2) in the case of sequence of sequence.&lt;br /&gt;
&lt;br /&gt;
== Files ==&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Linux|&lt;br /&gt;
&lt;br /&gt;
We want now create a text file named &amp;quot;demo.txt&amp;quot;. Here is the code to do this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 19 A little Example manipulating Files&lt;br /&gt;
// C++&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;cppuhelper/bootstrap.hxx&amp;gt;&lt;br /&gt;
#include &amp;lt;osl/file.hxx&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using rtl::OUString;&lt;br /&gt;
using rtl::OString;&lt;br /&gt;
using namespace osl;&lt;br /&gt;
&lt;br /&gt;
main( ) {&lt;br /&gt;
	OUString FileName;&lt;br /&gt;
	sal_Int8 tab[25]=&amp;quot;Hi every body\n&amp;quot;;&lt;br /&gt;
	sal_uInt64 nb;&lt;br /&gt;
	osl::FileBase::getFileURLFromSystemPath(&lt;br /&gt;
                 OUString::createFromAscii(&amp;quot;/home/smoutou/demo.txt&amp;quot;),FileName);&lt;br /&gt;
	File myfile(FileName);&lt;br /&gt;
	myfile.open(OpenFlag_Write);&lt;br /&gt;
	myfile.write(tab,(sal_uInt64)16,nb);&lt;br /&gt;
	printf(&amp;quot;%d bytes are written\n&amp;quot;,nb);&lt;br /&gt;
	myfile.close();&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
{{Documentation/Note|The method open is not described in C++ documentation !!! I have found it while reading the “file.hxx” header file.}} &lt;br /&gt;
&lt;br /&gt;
The flag you can pass to the &amp;quot;open&amp;quot; method are :  OpenFlag_Write,  OpenFlag_Read,  OpenFlag_Create. The &amp;quot; using namespace osl;&amp;quot; is obligatory even if the compiler doesn&amp;#039;t complain without.&lt;br /&gt;
When a file is open, you can use the  methods above : &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// C++&lt;br /&gt;
// Write a number of bytes to a file&lt;br /&gt;
write( const void * pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64 &amp;amp; rBytesWritten );&lt;br /&gt;
&lt;br /&gt;
// Read a number of bytes from a file&lt;br /&gt;
read( void * pBuffer, sal_uInt64 uBytesRequested, sal_uInt64 &amp;amp; rBytesRead );&lt;br /&gt;
&lt;br /&gt;
// Read a line from a file&lt;br /&gt;
ReadLine( ::rtl::ByteSequence &amp;amp; aSeq );&lt;br /&gt;
&lt;br /&gt;
// Test if the end of a file is reached&lt;br /&gt;
isEndOfFile( sal_Bool * pIsEOF );&lt;br /&gt;
&lt;br /&gt;
// Retrieve the current position of the internal pointer of an open file&lt;br /&gt;
getPos( sal_uInt64 &amp;amp; uPos );&lt;br /&gt;
&lt;br /&gt;
// Set the internal position pointer of an open file. &lt;br /&gt;
setPos( sal_uInt32 uHow, sal_Int64 uPos );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
There are other possibilities : move, remove, copy... See the documentation or read the file.hxx file.&lt;br /&gt;
&lt;br /&gt;
See [http://udk.openoffice.org/common/man/concept/streams.html « Streaming interfaces »]&lt;br /&gt;
for an other way to use files.&lt;br /&gt;
&lt;br /&gt;
== Threads ==&lt;br /&gt;
&lt;br /&gt;
It would be great to use the Thread Class but it&amp;#039;s  so badly documented that we begin with process instead thread.&lt;br /&gt;
Starting from an example posted in the forum Working with a Spreadsheet Document in C++ (by lirincy). This example gives a working code to start OOo if not started when launching a binary executable. We remove what was not usefull for us and give two examples.&lt;br /&gt;
{{Documentation/Linux|&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 20 A Process Example&lt;br /&gt;
// C++&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;cppuhelper/bootstrap.hxx&amp;gt;&lt;br /&gt;
#include &amp;lt;osl/process.h&amp;gt;&lt;br /&gt;
#include &amp;lt;osl/file.hxx&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using rtl::OUString;&lt;br /&gt;
using rtl::OString;&lt;br /&gt;
&lt;br /&gt;
main( ) {&lt;br /&gt;
// Don&amp;#039;t forget to add #include &amp;lt;osl/process.h&amp;gt;&lt;br /&gt;
	oslProcess hProcess = NULL;&lt;br /&gt;
// Don&amp;#039;t forget to add #include &amp;lt;osl/file.hxx&amp;gt;&lt;br /&gt;
	OUString FileURL;&lt;br /&gt;
	osl::FileBase::getFileURLFromSystemPath(&lt;br /&gt;
	OUString::createFromAscii(&amp;quot;/home/smoutou/demo&amp;quot;),&lt;br /&gt;
		FileURL&lt;br /&gt;
	);&lt;br /&gt;
	oslProcessError osl_error = osl_executeProcess(&lt;br /&gt;
	 FileURL.pData,&lt;br /&gt;
	 NULL,&lt;br /&gt;
	 0,&lt;br /&gt;
	 osl_Process_DETACHED,&lt;br /&gt;
	 0, /* osl_getCurrentSecurity() */&lt;br /&gt;
	 NULL,&lt;br /&gt;
	 NULL,&lt;br /&gt;
	 0,&lt;br /&gt;
	 &amp;amp;hProcess );&lt;br /&gt;
	osl_error = osl_joinProcess(hProcess);&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
{{Documentation/Note|Note that the demo file is an existing binary in /home/smoutou.}}&lt;br /&gt;
If you want to pass something to the launched program see AppArgs variable in the second example :&lt;br /&gt;
{{Documentation/Linux|&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 21 A second Process Example&lt;br /&gt;
// C++&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;cppuhelper/bootstrap.hxx&amp;gt;&lt;br /&gt;
#include &amp;lt;osl/process.h&amp;gt;&lt;br /&gt;
#include &amp;lt;osl/file.hxx&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using rtl::OUString;&lt;br /&gt;
using rtl::OString;&lt;br /&gt;
&lt;br /&gt;
main( ) {&lt;br /&gt;
// Don&amp;#039;t forget to add #include &amp;lt;osl/process.h&amp;gt;&lt;br /&gt;
	oslProcess hProcess = NULL;&lt;br /&gt;
// Don&amp;#039;t forget to add #include &amp;lt;osl/file.hxx&amp;gt;&lt;br /&gt;
	OUString FileURL;&lt;br /&gt;
	osl::FileBase::getFileURLFromSystemPath(&lt;br /&gt;
	OUString::createFromAscii(&amp;quot;/home/smoutou/demo&amp;quot;),&lt;br /&gt;
		FileURL&lt;br /&gt;
	);&lt;br /&gt;
	OUString AppArgs = OUString::createFromAscii(&amp;quot;Arg1&amp;quot;);&lt;br /&gt;
	oslProcessError osl_error = osl_executeProcess(&lt;br /&gt;
	 FileURL.pData,&lt;br /&gt;
	 &amp;amp;AppArgs.pData,&lt;br /&gt;
	 1,&lt;br /&gt;
	 osl_Process_DETACHED,&lt;br /&gt;
	 0, /* osl_getCurrentSecurity() */&lt;br /&gt;
	 NULL,&lt;br /&gt;
	 NULL,&lt;br /&gt;
	 0,&lt;br /&gt;
	 &amp;amp;hProcess );&lt;br /&gt;
	osl_error = osl_joinProcess(hProcess);&lt;br /&gt;
&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
I have tried working with thread but only with C style at the moment (not with using the thread class). Here is my first example code :&lt;br /&gt;
{{Documentation/Linux|&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 22 A working Thread Example&lt;br /&gt;
// C++&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;cppuhelper/bootstrap.hxx&amp;gt;&lt;br /&gt;
#include &amp;lt;osl/thread.h&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt; // LINUX&lt;br /&gt;
&lt;br /&gt;
using rtl::OUString;&lt;br /&gt;
using rtl::OString;&lt;br /&gt;
&lt;br /&gt;
/** wait _nSec seconds.&lt;br /&gt;
*/&lt;br /&gt;
void thread_sleep( sal_Int32 _nSec )&lt;br /&gt;
{&lt;br /&gt;
/// print statement in thread process must use fflush() to force display.&lt;br /&gt;
	printf(&amp;quot;# wait %d seconds. &amp;quot;, _nSec );&lt;br /&gt;
	fflush( stdout );&lt;br /&gt;
	sleep( _nSec );&lt;br /&gt;
	printf(&amp;quot;# done\n&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void SAL_CALL thread1(void *) {&lt;br /&gt;
  while(1) &lt;br /&gt;
	printf(&amp;quot;\n thread running&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void SAL_CALL thread2(int *nb){&lt;br /&gt;
  while(1) &lt;br /&gt;
	printf(&amp;quot;\n thread nb=%d running&amp;quot;,*nb);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
main( ) {&lt;br /&gt;
// Don&amp;#039;t forget to add #include &amp;lt;osl/thread.h&amp;gt;&lt;br /&gt;
	oslThread hThread = NULL;&lt;br /&gt;
//oslWorkerFunction type : void (SAL_CALL *oslWorkerFunction)(void*); in osl/thread.h&lt;br /&gt;
	oslWorkerFunction pFunction = (void (SAL_CALL *)(void*)) thread2;&lt;br /&gt;
	int pthreaddata=2;&lt;br /&gt;
// create and start the thread2 with 2 as a parameter value&lt;br /&gt;
	oslThread hThread2 = osl_createThread(pFunction,(void *) &amp;amp;pthreaddata);&lt;br /&gt;
// create and start the thread1 &lt;br /&gt;
	hThread = osl_createThread(thread1,NULL);&lt;br /&gt;
					&lt;br /&gt;
	thread_sleep(2);&lt;br /&gt;
	osl_suspendThread(hThread);&lt;br /&gt;
	osl_suspendThread(hThread2);&lt;br /&gt;
&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
What is printed out is depending on how screen is managed by your OS. Under Linux I obtained something like :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
 thread running&lt;br /&gt;
 thread running&lt;br /&gt;
 thread running&lt;br /&gt;
 thread running# done&lt;br /&gt;
 &lt;br /&gt;
 thread nb=2 running&lt;br /&gt;
 thread nb=2 running&lt;br /&gt;
 thread nb=2 running&lt;br /&gt;
 thread nb=2 running&lt;br /&gt;
 ....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here you can see the second thread launched writes at first and only when the main sleeping is terminated thread two is writing out. The other thread primitives can be found in osl/thread.h :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/** Create the thread, using the function-ptr pWorker as&lt;br /&gt;
	its main (worker) function. This functions receives in&lt;br /&gt;
	its void* parameter the value supplied by pThreadData.&lt;br /&gt;
	Once the OS-structures are initialized,the thread starts&lt;br /&gt;
	running.&lt;br /&gt;
	@return 0 if creation failed, otherwise a handle to the thread&lt;br /&gt;
*/&lt;br /&gt;
oslThread SAL_CALL osl_createThread(oslWorkerFunction pWorker, void* pThreadData);&lt;br /&gt;
&lt;br /&gt;
/** Create the thread, using the function-ptr pWorker as&lt;br /&gt;
	its main (worker) function. This functions receives in&lt;br /&gt;
	its void* parameter the value supplied by pThreadData.&lt;br /&gt;
	The thread will be created, but it won&amp;#039;t start running.&lt;br /&gt;
	To wake-up the thread, use resume().&lt;br /&gt;
	@return 0 if creation failed, otherwise a handle to the thread&lt;br /&gt;
*/&lt;br /&gt;
oslThread SAL_CALL osl_createSuspendedThread(oslWorkerFunction pWorker, void* pThreadData);&lt;br /&gt;
&lt;br /&gt;
/** Release the thread handle.&lt;br /&gt;
	If Thread is NULL, the function won&amp;#039;t do anything.&lt;br /&gt;
	Note that we do not interfere with the actual running of&lt;br /&gt;
	the thread, we just free up the memory needed by the handle.&lt;br /&gt;
*/&lt;br /&gt;
void SAL_CALL osl_destroyThread(oslThread Thread);&lt;br /&gt;
&lt;br /&gt;
/** Wake-up a thread that was suspended with suspend() or&lt;br /&gt;
	createSuspended(). The oslThread must be valid!&lt;br /&gt;
*/&lt;br /&gt;
void SAL_CALL osl_resumeThread(oslThread Thread);&lt;br /&gt;
&lt;br /&gt;
/** Suspend the execution of the thread. If you want the thread&lt;br /&gt;
	to continue, call resume(). The oslThread must be valid!&lt;br /&gt;
*/&lt;br /&gt;
void SAL_CALL osl_suspendThread(oslThread Thread);&lt;br /&gt;
/** Returns True if the thread was created and has not terminated yet.&lt;br /&gt;
	Note that according to this definition a &amp;quot;running&amp;quot; thread might be&lt;br /&gt;
	suspended! Also returns False is Thread is NULL.&lt;br /&gt;
*/&lt;br /&gt;
sal_Bool SAL_CALL osl_isThreadRunning(const oslThread Thread);&lt;br /&gt;
&lt;br /&gt;
/** Blocks the calling thread until Thread has terminated.&lt;br /&gt;
	Returns immediately if Thread is NULL.&lt;br /&gt;
*/&lt;br /&gt;
void SAL_CALL osl_joinWithThread(oslThread Thread);&lt;br /&gt;
&lt;br /&gt;
/** Blocks the calling thread at least for the given number&lt;br /&gt;
    of time.&lt;br /&gt;
*/&lt;br /&gt;
void SAL_CALL osl_waitThread(const TimeValue* pDelay);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information you can read [[Uno/Article/Multi-Thread_Programming|Multi-Thread Programming]].&lt;br /&gt;
&lt;br /&gt;
== To go further : the Enumeration Type Problem ==&lt;br /&gt;
Sometimes we will encounter enumeration values. We have to learn how to resolve the problem. An example will be discussed later but we give it without its context here. The Cell content in OOoCalc is described by an enumeration. How can I know that, is not easy with the previous material, but I want to tackle the problem even if too soon to understand for a first reading.&lt;br /&gt;
&lt;br /&gt;
All types used in programming are described in IDL files. Sometimes these IDL files are used to create hpp/hxx files.&lt;br /&gt;
&lt;br /&gt;
This example is around CellContentType.idl file. Here is the summary of this file where we remove comments :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 23  CellContentType Enumeration type (IDL File)&lt;br /&gt;
// IDL&lt;br /&gt;
namespace com{&lt;br /&gt;
namespace sun{&lt;br /&gt;
namespace star{&lt;br /&gt;
namespace table{&lt;br /&gt;
enum CellContentType&lt;br /&gt;
{&lt;br /&gt;
    CellContentType_EMPTY = 0,&lt;br /&gt;
    CellContentType_VALUE = 1,&lt;br /&gt;
    CellContentType_TEXT = 2,&lt;br /&gt;
    CellContentType_FORMULA = 3,&lt;br /&gt;
    CellContentType_MAKE_FIXED_SIZE = SAL_MAX_ENUM&lt;br /&gt;
};&lt;br /&gt;
} // table&lt;br /&gt;
} // star&lt;br /&gt;
} // sun&lt;br /&gt;
} // com&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Three tips can be used when using this kind of enumeration :&lt;br /&gt;
* In C++ a corresponding using namespace is necessary&lt;br /&gt;
using namespace com::sun::star::table&lt;br /&gt;
This line can be drawn from the IDL file.&lt;br /&gt;
* In C++ an include directive is necessary&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/table/CellContentType.hpp&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The  name of the file to include and the path is easy to draw from IDL file.&lt;br /&gt;
* We have to construct the previous hpp file. This is done with adding the red line above in the makefile :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
TYPES := \&lt;br /&gt;
	com.sun.star.uno.XNamingService \&lt;br /&gt;
	com.sun.star.uno.XComponentContext \&lt;br /&gt;
	com.sun.star.uno.XWeak \&lt;br /&gt;
	com.sun.star.uno.XAggregation \&lt;br /&gt;
	com.sun.star.lang.XMain \&lt;br /&gt;
	com.sun.star.lang.XMultiServiceFactory \&lt;br /&gt;
	com.sun.star.lang.XSingleComponentFactory \&lt;br /&gt;
	com.sun.star.lang.XTypeProvider \&lt;br /&gt;
	com.sun.star.lang.XComponent \&lt;br /&gt;
	com.sun.star.registry.XSimpleRegistry \&lt;br /&gt;
	com.sun.star.registry.XImplementationRegistration \&lt;br /&gt;
	com.sun.star.bridge.XBridgeFactory \&lt;br /&gt;
	com.sun.star.bridge.XUnoUrlResolver \&lt;br /&gt;
	com.sun.star.table.CellContentType \&lt;br /&gt;
	com.sun.star.container.XHierarchicalNameAccess&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After you can use this enumeration without problem like this :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 24 Enumeration type : an Example&lt;br /&gt;
//C++&lt;br /&gt;
// To check&lt;br /&gt;
// Don&amp;#039;t forget to add #include &amp;lt;com/sun/star/table/CellContentType.hpp&amp;gt;&lt;br /&gt;
// Don&amp;#039;t forget to add &amp;quot;com.sun.star.table.CellContentType \&amp;quot; in the makefile&lt;br /&gt;
&lt;br /&gt;
	using namespace com::sun::star::table&lt;br /&gt;
	short enumval;&lt;br /&gt;
	enumval =  CellContentType_EMPTY;&lt;br /&gt;
	switch (enumval){&lt;br /&gt;
		case CellContentType_EMPTY : printf(&amp;quot;Empty\n&amp;quot;);break;&lt;br /&gt;
		case CellContentType_VALUE : printf(&amp;quot;Numerical Value\n&amp;quot;);break;&lt;br /&gt;
		case CellContentType_TEXT : printf(&amp;quot;Text\n&amp;quot;);break;&lt;br /&gt;
		case CellContentType_FORMULA : printf(&amp;quot;Formula\n&amp;quot;);break;&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What is shown here is a general SDK&amp;#039;s feature : we construct a hpp file starting from an IDL file. This is so important and unexpected for beginners that I will repeat many times these explanations [[UNO_automation_with_a_binary_%28executable%29#Introduction_to_Bootstrapping|later]] and more deeply [[IDL_Files_and_Cpp#Getting_an_interface_in_C.2B.2B|here]].&lt;br /&gt;
&lt;br /&gt;
== To go further : the Constant Type Problem ==&lt;br /&gt;
Values are not always defined with enumeration types as shown in previous section. Sometimes constants are used when programming with UNO. One example is again tackled [[OpenOffice_Calc#The_Compute_Function__Example|later]] but we want again writes on it now. We first present the corresponding IDL file (as an example)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 25 CellFlags Constants type : IDL File &lt;br /&gt;
//IDL&lt;br /&gt;
module com {  module sun {  module star {  module sheet {&lt;br /&gt;
constants CellFlags&lt;br /&gt;
{&lt;br /&gt;
	const long VALUE = 1;&lt;br /&gt;
	const long DATETIME = 2;&lt;br /&gt;
	const long STRING = 4;&lt;br /&gt;
	const long ANNOTATION = 8;&lt;br /&gt;
	const long FORMULA = 16;&lt;br /&gt;
	const long HARDATTR = 32;&lt;br /&gt;
	const long STYLES = 64;&lt;br /&gt;
	const long OBJECTS = 128;&lt;br /&gt;
	const long EDITATTR = 256;&lt;br /&gt;
};&lt;br /&gt;
}; }; }; };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Compare this listing with Listing 23 to see the differences.&lt;br /&gt;
If you want to use the constants above you first generate the corresponding hpp file with modifying the makefile as in previous section, and then add the corresponding include directive :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// C++&lt;br /&gt;
#include &amp;lt;com/sun/star/sheet/CellFlags.hpp&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
in your C++ code. Note that with this include directive you can directly write something like &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// C++&lt;br /&gt;
VALUE | DATETIME&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
instead of &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// C++&lt;br /&gt;
CellFlags_VALUE | CellFlags_DATETIME&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
as seen previously.&lt;br /&gt;
&lt;br /&gt;
==Going further with Sequences==&lt;br /&gt;
We want to give any utilities used later in this document.&lt;br /&gt;
===Converting Sequences into Array===&lt;br /&gt;
Because it exists a correponding member function this conversion is very easy :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 27 Conversion Example&lt;br /&gt;
// C++&lt;br /&gt;
Sequence &amp;lt; sal_Int32 &amp;gt; SetOfInt(5);&lt;br /&gt;
sal_Int32 *table;&lt;br /&gt;
table = SetOfInt.getArray();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If you read carefully to this point, this code is familiar for you : it&amp;#039;s drawn from Listing 4 and then already explained.&lt;br /&gt;
===Converting Sequence of Sequence into Array===&lt;br /&gt;
This problem has to be solved. We will use this kind of conversion later (see chapter 14). We first give two subprograms, to print out and to convert :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 28 Sequence of Sequence into 1D array&lt;br /&gt;
//C+&lt;br /&gt;
// Sequence of Sequence is printed out like that :&lt;br /&gt;
// toPrint[0][0] toPrint[0][1] toPrint[0][2]...&lt;br /&gt;
// toPrint[1][0] toPrint[1][1] toPrint[1][2]...&lt;br /&gt;
// ...&lt;br /&gt;
// Note that i denotes the first index&lt;br /&gt;
void printOutSeqSeq(const Sequence &amp;lt; Sequence &amp;lt; double &amp;gt; &amp;gt; &amp;amp;toPrint){&lt;br /&gt;
	cout &amp;lt;&amp;lt; &amp;quot;Prints out SeqSeq&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
        for(int i=0;i&amp;lt;toPrint.getLength();i++){&lt;br /&gt;
                Sequence &amp;lt; double &amp;gt; rLine = toPrint[i];&lt;br /&gt;
		double *line= rLine.getArray();&lt;br /&gt;
		for(int j=0;j&amp;lt;rLine.getLength();j++)&lt;br /&gt;
			cout &amp;lt;&amp;lt; &amp;quot; &amp;quot; &amp;lt;&amp;lt; line[j] &amp;lt;&amp;lt; &amp;quot; &amp;quot;;&lt;br /&gt;
		cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
double *SeqSeqToArray1D(const Sequence &amp;lt; Sequence &amp;lt; double&amp;gt; &amp;gt; &amp;amp;seqseq){&lt;br /&gt;
	sal_Int32 iMax=seqseq.getLength(),jMax;&lt;br /&gt;
	Sequence &amp;lt; double &amp;gt; rLine = seqseq[0];&lt;br /&gt;
	jMax=rLine.getLength();	&lt;br /&gt;
	double *table1D = new double[iMax*jMax];&lt;br /&gt;
	for (sal_Int32 i = 0 ; i &amp;lt; iMax; i++ )&lt;br /&gt;
		for(sal_Int32 j = 0 ; j &amp;lt; jMax; j++ )&lt;br /&gt;
			table1D[i*jMax+j]= seqseq[i][j];&lt;br /&gt;
	return table1D;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Using these sub is easy : it can be done like that :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 29 Using the conversion&lt;br /&gt;
//C+&lt;br /&gt;
// We first construct a sequence&lt;br /&gt;
	Sequence &amp;lt; double &amp;gt; demo(5);&lt;br /&gt;
	demo[0]=1.1;&lt;br /&gt;
    demo[1]=2.1;&lt;br /&gt;
	demo[2]=3.1;&lt;br /&gt;
	demo[3]=4.1;&lt;br /&gt;
	demo[4]=5.1;&lt;br /&gt;
// We then construct the sequence of sequence&lt;br /&gt;
	Sequence &amp;lt; Sequence &amp;lt; double &amp;gt; &amp;gt; seqseq(3);&lt;br /&gt;
	for (int i=0; i&amp;lt;seqseq.getLength();i++)&lt;br /&gt;
            seqseq[i]=demo;&lt;br /&gt;
// We print out the result of the construction	&lt;br /&gt;
	printOutSeqSeq(seqseq);&lt;br /&gt;
// Here is the conversion&lt;br /&gt;
	double *table = SeqSeqToArray1D(seqseq);&lt;br /&gt;
// We finish wit printing out the result &lt;br /&gt;
	cout &amp;lt;&amp;lt; &amp;quot;Array1D -&amp;gt; 2D : &amp;quot;&amp;lt;&amp;lt; endl;&lt;br /&gt;
	for (int i=0; i&amp;lt; 3; i++){&lt;br /&gt;
		for (int j=0;j&amp;lt;5;j++)&lt;br /&gt;
			cout&amp;lt;&amp;lt;&amp;quot; &amp;quot;&amp;lt;&amp;lt;table[i*5+j]&amp;lt;&amp;lt;&amp;quot; &amp;quot;;&lt;br /&gt;
		cout&amp;lt;&amp;lt;endl;&lt;br /&gt;
	}&lt;br /&gt;
	....&lt;br /&gt;
	delete table;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
which gives us :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Prints out SeqSeq&lt;br /&gt;
 1.1  2.1  3.1  4.1  5.1&lt;br /&gt;
 1.1  2.1  3.1  4.1  5.1&lt;br /&gt;
 1.1  2.1  3.1  4.1  5.1&lt;br /&gt;
Array1D -&amp;gt; 2D :&lt;br /&gt;
 1.1  2.1  3.1  4.1  5.1&lt;br /&gt;
 1.1  2.1  3.1  4.1  5.1&lt;br /&gt;
 1.1  2.1  3.1  4.1  5.1&lt;br /&gt;
[smoutou@p3 Lifetime]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Converting a sequence of sequence directly in an 2D array is not an easy task because the compiler has to know the size of the second index before compiling. At first something like &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 30 Array2D conversion&lt;br /&gt;
// C++&lt;br /&gt;
double **SeqSeqToArray2D(const Sequence &amp;lt; Sequence &amp;lt; double&amp;gt; &amp;gt; &amp;amp;seqseq){&lt;br /&gt;
	double **table2D; &lt;br /&gt;
	double *table1D;&lt;br /&gt;
	table1D = SeqSeqToArray1D(seqseq);&lt;br /&gt;
	table2D = &amp;amp;table1D;&lt;br /&gt;
	return table2D;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
seems interesting but let&amp;#039;s see if that works out. A first idea is to write something like :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 31 Wrong code for  conversion&lt;br /&gt;
// C++&lt;br /&gt;
	double **table2= SeqSeqToArray2D(seqseq);&lt;br /&gt;
	for (int i=0; i&amp;lt; 3; i++){&lt;br /&gt;
		for (int j=0;j&amp;lt;5;j++)&lt;br /&gt;
			cout&amp;lt;&amp;lt;&amp;quot; &amp;quot;&amp;lt;&amp;lt; table2[i][j]&amp;lt;&amp;lt;&amp;quot; &amp;quot;;&lt;br /&gt;
		cout&amp;lt;&amp;lt;endl;&lt;br /&gt;
	}&lt;br /&gt;
	delete table2;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
but the compiler is unable to calculate table2[i][j] here. For that it has to evaluate the expression i*jMax+j but has no knowledge on jMax !!&lt;br /&gt;
&lt;br /&gt;
===More Abstractions with STL===&lt;br /&gt;
If you plan to use C++ you will certainly use the STL extensively. We begin first by conversions. Here is the easier one :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 32 Converting a Sequence of Sequence into a vector&lt;br /&gt;
// C++&lt;br /&gt;
// Inspired by Eric Ehlers&amp;#039;s code but using template&lt;br /&gt;
// See chapter 14&lt;br /&gt;
template&amp;lt; typename T&amp;gt;&lt;br /&gt;
vector &amp;lt; T &amp;gt;SeqSeqToVectorTemplate(const Sequence&amp;lt; Sequence &amp;lt; T &amp;gt; &amp;gt;&amp;amp; ss) {&lt;br /&gt;
    vector &amp;lt; T &amp;gt;v;&lt;br /&gt;
    for (int i=0; i&amp;lt;ss.getLength(); i++)&lt;br /&gt;
        for (int j=0; j&amp;lt;ss[i].getLength(); j++)&lt;br /&gt;
            v.push_back(ss[i][j]);&lt;br /&gt;
    return v;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
My start point for achieving this code was Eric Ethler&amp;#039;s code presented [[CompleteAddIn#Transforming_an_Array_into_Sequence_of_Sequence|here]]. This code is again easy to use :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 33 Using the previous Convertion&lt;br /&gt;
// C++&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include&amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;cppuhelper/bootstrap.hxx&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/uno/Sequence.hxx&amp;gt;&lt;br /&gt;
using namespace com::sun::star::uno;&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
template&amp;lt; typename T&amp;gt;&lt;br /&gt;
vector &amp;lt; T &amp;gt;SeqSeqToVectorTemplate(const Sequence&amp;lt; Sequence &amp;lt; T &amp;gt; &amp;gt;&amp;amp; ss);&lt;br /&gt;
main( ) {&lt;br /&gt;
	Sequence &amp;lt; double &amp;gt; demo(5);&lt;br /&gt;
	demo[0]=1.1;&lt;br /&gt;
    demo[1]=2.1;&lt;br /&gt;
	demo[2]=3.1;&lt;br /&gt;
	demo[3]=4.1;&lt;br /&gt;
	demo[4]=5.1;&lt;br /&gt;
	Sequence &amp;lt; Sequence &amp;lt; double &amp;gt; &amp;gt; seqseq(3);&lt;br /&gt;
// simply use the same sequence&lt;br /&gt;
	for (int i=0; i&amp;lt;seqseq.getLength();i++)&lt;br /&gt;
            seqseq[i]=demo;&lt;br /&gt;
// template&lt;br /&gt;
	vector &amp;lt;double&amp;gt; v=SeqSeqToVectorTemplate(seqseq);&lt;br /&gt;
	cout &amp;lt;&amp;lt; &amp;quot;vector1D -&amp;gt; 2D : &amp;quot;&amp;lt;&amp;lt; endl;&lt;br /&gt;
	for (int i=0; i&amp;lt; 3; i++){&lt;br /&gt;
		for (int j=0;j&amp;lt;5;j++)&lt;br /&gt;
			cout&amp;lt;&amp;lt;&amp;quot; &amp;quot;&amp;lt;&amp;lt;v[i*5+j]&amp;lt;&amp;lt;&amp;quot; &amp;quot;;&lt;br /&gt;
		cout&amp;lt;&amp;lt;endl;&lt;br /&gt;
	}&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We give now three other conversions (see also [[CompleteAddIn#Transforming_an_Array_into_Sequence_of_Sequence|here]])&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 34 Converting Utilities with Template&lt;br /&gt;
// C++&lt;br /&gt;
// Inspired by Eric Ethler&amp;#039;s code but using template&lt;br /&gt;
// See chapter 14&lt;br /&gt;
template&amp;lt; typename T&amp;gt;&lt;br /&gt;
Sequence&amp;lt; Sequence&amp;lt; T &amp;gt; &amp;gt; VectorTemplateToSeqSeq(const vector &amp;lt; T &amp;gt; &amp;amp;v) {&lt;br /&gt;
    Sequence&amp;lt; Sequence&amp;lt; double &amp;gt; &amp;gt; ss(v.size());&lt;br /&gt;
    for (unsigned int i=0; i&amp;lt;v.size(); i++) {&lt;br /&gt;
        Sequence&amp;lt; T &amp;gt; s(1);&lt;br /&gt;
        s[0] = v[i];&lt;br /&gt;
        ss[i] = s;&lt;br /&gt;
    }&lt;br /&gt;
    return ss;&lt;br /&gt;
}&lt;br /&gt;
template&amp;lt; typename T&amp;gt;&lt;br /&gt;
vector &amp;lt; vector &amp;lt; T &amp;gt; &amp;gt;SeqSeqToMatrixTemplate(const Sequence&amp;lt; Sequence &amp;lt; T &amp;gt; &amp;gt;&amp;amp; ss) {&lt;br /&gt;
    vector &amp;lt; vector &amp;lt; T &amp;gt; &amp;gt;vv;&lt;br /&gt;
    for (int i=0; i&amp;lt;ss.getLength(); i++) {&lt;br /&gt;
        vector &amp;lt; T &amp;gt;v;&lt;br /&gt;
        for (int j=0; j&amp;lt;ss[i].getLength(); j++)&lt;br /&gt;
            v.push_back(ss[i][j]);&lt;br /&gt;
        vv.push_back(v);&lt;br /&gt;
    }&lt;br /&gt;
    return vv;&lt;br /&gt;
}&lt;br /&gt;
template&amp;lt; typename T&amp;gt;&lt;br /&gt;
Sequence&amp;lt; Sequence&amp;lt; T &amp;gt; &amp;gt; MatrixTemplateToSeqSeq(&lt;br /&gt;
			const std::vector &amp;lt; std::vector &amp;lt; T &amp;gt; &amp;gt;&amp;amp;vv) {&lt;br /&gt;
    Sequence&amp;lt; Sequence&amp;lt; T &amp;gt; &amp;gt; ss(vv.size());&lt;br /&gt;
    for (unsigned int i=0; i&amp;lt;vv.size(); i++) {&lt;br /&gt;
        std::vector &amp;lt; T &amp;gt; v = vv[i];&lt;br /&gt;
        Sequence&amp;lt; T &amp;gt; s(v.size());&lt;br /&gt;
        for (unsigned int j=0; j&amp;lt;v.size(); j++)&lt;br /&gt;
            s[j] = v[j];&lt;br /&gt;
        ss[i] = s;&lt;br /&gt;
    }&lt;br /&gt;
    return ss;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
One way to use it is for instance :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 35 Converting Utilities with Template&lt;br /&gt;
//C++&lt;br /&gt;
	...&lt;br /&gt;
// seqseq must be initialized	&lt;br /&gt;
	vector &amp;lt;vector &amp;lt;double&amp;gt; &amp;gt; v2=SeqSeqToMatrixTemplate(seqseq);&lt;br /&gt;
	cout &amp;lt;&amp;lt; &amp;quot;vector2D : &amp;quot;&amp;lt;&amp;lt; endl;&lt;br /&gt;
	for (int i=0; i&amp;lt; 3; i++){&lt;br /&gt;
		for (int j=0;j&amp;lt;5;j++)&lt;br /&gt;
			cout&amp;lt;&amp;lt;&amp;quot; &amp;quot;&amp;lt;&amp;lt;v2[i][j]&amp;lt;&amp;lt;&amp;quot; &amp;quot;;&lt;br /&gt;
		cout&amp;lt;&amp;lt;endl;&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Because there is a lot of algorithms based on STL I think these utilities will be very helpfull.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Template:Home_Page}}&lt;br /&gt;
&lt;br /&gt;
= See also =&lt;br /&gt;
* [[FR/Documentation/Cpp_Guide|French version of this chapter]].&lt;br /&gt;
* [[Uno/Article/Understanding_Uno|Understanding Uno]]&lt;br /&gt;
* [[Uno/Cpp/Tutorials/Introduction_to_Cpp_Uno|C++ and UNO tutorial]]&lt;br /&gt;
* [[Uno/Article/Multi-Thread Programming | Multi-Thread Programming]]&lt;br /&gt;
* To learn C++ : [http://www.smart2help.com/e-books/ C++ e-books]&lt;br /&gt;
* [http://en.wikibooks.org/wiki/Programming:Data_Structures Wiki on C++ Data Structures]&lt;br /&gt;
* [[Uno/Binary/Analysis/String_Performance|String Performance]]&lt;br /&gt;
* Writing a Program to Control OpenOffice.org, by Franco Pingiori — [http://www.linuxjournal.com/article/8550 Part 1] and [http://www.linuxjournal.com/article/8608 Part 2], Linux Journal&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorial]]&lt;br /&gt;
[[Category:Cpp]]&lt;br /&gt;
[[Category:Uno]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=PyUNOServer&amp;diff=167502</id>
		<title>PyUNOServer</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=PyUNOServer&amp;diff=167502"/>
		<updated>2010-05-15T05:49:10Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:Py-uno_128.png|right|PyUNO Logo]]&lt;br /&gt;
The PyUNOServer is a script that works as an XML server for OpenOffice.org Calc where it can exchange data through XML calls. This means that can get data from other apps that are XML compliant. You can download the script from [http://es.openoffice.org/files/documents/73/2929/pyUnoServer.tar.gz this mirror] since the original site seems to be down.&lt;br /&gt;
&lt;br /&gt;
The zip file contains 3 files: &lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;PyUNOServerV2.py&amp;#039;&amp;#039;&amp;#039; - The Python Script&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;PyUNOServerV2.pyc&amp;#039;&amp;#039;&amp;#039; - compiled version&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;PyUNOServer.sh2&amp;#039;&amp;#039;&amp;#039; - the script to conect to the service&lt;br /&gt;
&lt;br /&gt;
The script have just 1 script called &amp;#039;&amp;#039;&amp;#039;PyUNOServerV2.py&amp;#039;&amp;#039;&amp;#039; however there is a faster, bytecode-compiled script. It also includes a bash script which loads the path to the openoffice.org application.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;NOTE: This script will work on just certain distros since the location of OpenOffice.org might vary. We recomend to load the path manually.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This script uses the following libraries:&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;OS&amp;#039;&amp;#039;&amp;#039; - This module provides a more portable way of using operating system dependent functionality than importing a operating system dependent built-in module like posix or nt.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;UNO&amp;#039;&amp;#039;&amp;#039; - Python UNO implementation module, this can used by python 2.3.4 &amp;#039;&amp;#039;&amp;#039;only&amp;#039;&amp;#039;&amp;#039; which is the python provided within openoffice.org. It provides all the interfaces from OpenOffice.org into python.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;SYS&amp;#039;&amp;#039;&amp;#039; - This module provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter. It is always available.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;time&amp;#039;&amp;#039;&amp;#039; - This module provides various time-related functions. It is always available, but not all functions are available on all platforms. Most of the functions defined in this module call platform C library functions with the same name. It may sometimes be helpful to consult the platform documentation, because the semantics of these functions varies among platforms.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;logging&amp;#039;&amp;#039;&amp;#039; - Logging is performed by calling methods on instances of the Logger class (hereafter called loggers). Each instance has a name, and they are conceptually arranged in a name space hierarchy using dots (periods) as separators.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;urllib&amp;#039;&amp;#039;&amp;#039; - This module provides a high-level interface for fetching data across the World Wide Web. In particular, the urlopen() function is similar to the built-in function open(), but accepts Universal Resource Locators (URLs) instead of filenames. Some restrictions apply -- it can only open URLs for reading, and no seek operations are available.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;SimpleXMLRPCServer&amp;#039;&amp;#039;&amp;#039; - The SimpleXMLRPCServer module provides a basic server framework for XML-RPC servers written in Python. Servers can either be free standing, using SimpleXMLRPCServer, or embedded in a CGI environment, using CGIXMLRPCRequestHandler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
# -*- coding: iso-8859-1 -*-&lt;br /&gt;
#&lt;br /&gt;
# pyUnoServer - version 2.0&lt;br /&gt;
from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler&lt;br /&gt;
import os&lt;br /&gt;
import uno&lt;br /&gt;
import sys&lt;br /&gt;
import time&lt;br /&gt;
import logging&lt;br /&gt;
import urllib&lt;br /&gt;
&lt;br /&gt;
class PyUNOServer(SimpleXMLRPCServer):&lt;br /&gt;
&lt;br /&gt;
	def _dispatch(self, method, params):&lt;br /&gt;
&lt;br /&gt;
		try:&lt;br /&gt;
			func = getattr(self, &amp;#039;&amp;#039; + method)&lt;br /&gt;
		except:&lt;br /&gt;
			self.logger.error(&amp;quot;El Metodo &amp;#039;&amp;quot;+method+&amp;quot;&amp;#039; no esta soportado!&amp;quot;)&lt;br /&gt;
			raise Exception(&amp;#039;method &amp;quot;%s&amp;quot; is not supported&amp;#039; % method)&lt;br /&gt;
		else:&lt;br /&gt;
			try:&lt;br /&gt;
				ret = func(*params)&lt;br /&gt;
				self.logger.info(&amp;quot;Llamada: %s%s | Retorno: %s&amp;quot; % (method, params, ret))&lt;br /&gt;
				return ret&lt;br /&gt;
			except:&lt;br /&gt;
				self.logger.info(&amp;quot;Llamada: %s%s&amp;quot; % (method, params))&lt;br /&gt;
				self.logger.error(&amp;quot;Error: %s:%s&amp;quot; % sys.exc_info()[:2])&lt;br /&gt;
&lt;br /&gt;
	def init(self):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		This method	starts an Openoffice session and initializes the XMLRPC server&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	&lt;br /&gt;
		# Generate some useful constants&lt;br /&gt;
		self.EMPTY = uno.Enum(&amp;quot;com.sun.star.table.CellContentType&amp;quot;, &amp;quot;EMPTY&amp;quot;)&lt;br /&gt;
		self.TEXT = uno.Enum(&amp;quot;com.sun.star.table.CellContentType&amp;quot;, &amp;quot;TEXT&amp;quot;)&lt;br /&gt;
		self.FORMULA = uno.Enum(&amp;quot;com.sun.star.table.CellContentType&amp;quot;, &amp;quot;FORMULA&amp;quot;)&lt;br /&gt;
		self.VALUE = uno.Enum(&amp;quot;com.sun.star.table.CellContentType&amp;quot;, &amp;quot;VALUE&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
		# Generate a Logger&lt;br /&gt;
		self.logger = logging.getLogger(&amp;#039;pyUnoServer&amp;#039;)&lt;br /&gt;
		hdlr = logging.FileHandler(&amp;#039;./pyUnoServer.log&amp;#039;)&lt;br /&gt;
		formatter = logging.Formatter(&amp;#039;%(asctime)s %(levelname)s -- %(message)s&amp;#039;)&lt;br /&gt;
		hdlr.setFormatter(formatter)&lt;br /&gt;
		self.logger.addHandler(hdlr) &lt;br /&gt;
		self.logger.setLevel(logging.INFO)&lt;br /&gt;
&lt;br /&gt;
		self.sessions = []&lt;br /&gt;
		self.sessionSerial = 0&lt;br /&gt;
&lt;br /&gt;
		# Start Calc and grep the PID&lt;br /&gt;
		self.PID = os.spawnlp(os.P_NOWAIT,&amp;quot;/usr/bin/oocalc&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;-accept=socket,host=localhost,port=2002;urp;&amp;quot;)&lt;br /&gt;
		&lt;br /&gt;
		self.logger.info(&amp;quot;OOCalc Iniciado con el PID %d&amp;quot; % self.PID)&lt;br /&gt;
&lt;br /&gt;
		while 1:&lt;br /&gt;
			try: &lt;br /&gt;
				localContext = uno.getComponentContext()&lt;br /&gt;
				resolver = localContext.ServiceManager.createInstanceWithContext(&amp;quot;com.sun.star.bridge.UnoUrlResolver&amp;quot;, localContext )&lt;br /&gt;
				smgr = resolver.resolve( &amp;quot;uno:socket,host=localhost,port=2002;urp;StarOffice.ServiceManager&amp;quot; )&lt;br /&gt;
				remoteContext = smgr.getPropertyValue( &amp;quot;DefaultContext&amp;quot; )&lt;br /&gt;
				self.desktop = smgr.createInstanceWithContext( &amp;quot;com.sun.star.frame.Desktop&amp;quot;,remoteContext)&lt;br /&gt;
				self.logger.info(&amp;quot;Sistema conectado al socket de UNO&amp;quot;)&lt;br /&gt;
				break&lt;br /&gt;
			except:&lt;br /&gt;
				time.sleep(0.5)&lt;br /&gt;
&lt;br /&gt;
	def openSession(self, session):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		This method opens a new session.&lt;br /&gt;
		Sample usage from PHP:&lt;br /&gt;
		 - $sessionString is your a session ID provided by your program):&lt;br /&gt;
&lt;br /&gt;
			$openSession = array( new XML_RPC_VALUE($sessionString, &amp;quot;string&amp;quot;));&lt;br /&gt;
			$sessionID = queryXMLRPC($client, &amp;quot;openSession&amp;quot;, $openSession);&lt;br /&gt;
			return $sessionID;&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
		for i,x in enumerate(self.sessions):&lt;br /&gt;
			if x[0] == session:&lt;br /&gt;
				currentSerial = i&lt;br /&gt;
				break&lt;br /&gt;
		else:&lt;br /&gt;
			self.sessions.append([session,[]])&lt;br /&gt;
			currentSerial = len(self.sessions)-1&lt;br /&gt;
&lt;br /&gt;
		return currentSerial&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	def getSessions(self):&lt;br /&gt;
		return self.sessions&lt;br /&gt;
&lt;br /&gt;
	def openBook(self, session, bookPath):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		This method opens a new Openoffice spreadsheet book.&lt;br /&gt;
		Sample usage from PHP:&lt;br /&gt;
		 - $sessionID is the session&amp;#039;s ID returned by openSession()&lt;br /&gt;
		 - $path is the path to the book in the server&amp;#039;s filesystem&lt;br /&gt;
&lt;br /&gt;
		$openBookQuery = array( new XML_RPC_VALUE($sessionID, &amp;quot;int&amp;quot;), new XML_RPC_VALUE($path,&amp;quot;string&amp;quot;) );&lt;br /&gt;
		$bookID = queryXMLRPC($client, &amp;quot;openBook&amp;quot;, $openBookQuery);&lt;br /&gt;
		return $bookID;&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
		currentSerial = session&lt;br /&gt;
		bookPath = bookPath.strip()&lt;br /&gt;
		print bookPath&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
		exists = os.path.exists(bookPath)&lt;br /&gt;
		if exists == False:&lt;br /&gt;
			raise Exception(&amp;#039;El libro %s no existe&amp;#039;, bookPath)&lt;br /&gt;
		else:&lt;br /&gt;
			self.logger.info(&amp;quot;se ha encontrado el libro!&amp;quot;)&lt;br /&gt;
		&lt;br /&gt;
		currentBook = -1&lt;br /&gt;
		&lt;br /&gt;
		for i, book in enumerate(self.sessions[currentSerial][1]):&lt;br /&gt;
			try:&lt;br /&gt;
			&lt;br /&gt;
				bookname = book[0]&lt;br /&gt;
				bookhandler = book[1]&lt;br /&gt;
				bookmodtime = book[2]&lt;br /&gt;
			&lt;br /&gt;
				if bookname == bookPath:&lt;br /&gt;
					modtime = os.path.getmtime(bookPath)&lt;br /&gt;
					if modtime &amp;gt; bookmodtime:&lt;br /&gt;
						book[1].dispose()&lt;br /&gt;
						self.sessions[currentSerial][1].remove(book)&lt;br /&gt;
					else:&lt;br /&gt;
						currentBook = i&lt;br /&gt;
					break&lt;br /&gt;
			except:&lt;br /&gt;
				self.logger.error(&amp;quot;El libro &amp;quot;+currentBook+&amp;quot; no existe!&amp;quot;)&lt;br /&gt;
				&lt;br /&gt;
&lt;br /&gt;
		if currentBook &amp;lt; 0:&lt;br /&gt;
			handler = self.desktop.loadComponentFromURL( &amp;quot;file://&amp;quot; + bookPath ,&amp;quot;_blank&amp;quot;,0,())&lt;br /&gt;
&lt;br /&gt;
			if handler == None:&lt;br /&gt;
				raise Exception(&amp;#039;El libro no existe o tiene caracteres extraños...&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
			modtime = os.path.getmtime(bookPath)&lt;br /&gt;
			&lt;br /&gt;
			estruct = [bookPath,handler,modtime]&lt;br /&gt;
			self.sessions[currentSerial][1].append(estruct)&lt;br /&gt;
			currentBook = len(self.sessions[currentSerial][1])-1&lt;br /&gt;
			&lt;br /&gt;
		return currentBook&lt;br /&gt;
&lt;br /&gt;
	def closeBook(self, sessionID, bookID):&lt;br /&gt;
		&lt;br /&gt;
		books = self.sessions[sessionID][1]&lt;br /&gt;
		&lt;br /&gt;
		# Close the document. It doesn&amp;#039;t look very elegant but thats the way is documented.&lt;br /&gt;
		books[bookID][1].dispose()&lt;br /&gt;
		self.sessions[sessionID][1].remove(books[bookID])&lt;br /&gt;
		&lt;br /&gt;
		return 1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	def getBookSheets(self, sessionID, bookID):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		This method return an array with the book&amp;#039;s worksheets.&lt;br /&gt;
		Sample usage from PHP:&lt;br /&gt;
		 - $sessionID is the session&amp;#039;s ID returned by openSession()&lt;br /&gt;
		 - $bookID is the book&amp;#039;s ID returned by openBook()&lt;br /&gt;
&lt;br /&gt;
		$sheetsQuery = array( new XML_RPC_VALUE($sessionID, &amp;quot;int&amp;quot;), new XML_RPC_VALUE($bookID, &amp;quot;int&amp;quot;) );&lt;br /&gt;
		$sheets = queryXMLRPC($client, &amp;quot;getBookSheets&amp;quot; , $sheetsQuery);&lt;br /&gt;
		return $sheets;&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		sheets = self.sessions[sessionID][1][bookID][1].getSheets().createEnumeration()&lt;br /&gt;
		&lt;br /&gt;
		container = []&lt;br /&gt;
		while sheets.hasMoreElements():&lt;br /&gt;
			currentSheet = sheets.nextElement()&lt;br /&gt;
			container.append(currentSheet.getName().encode(&amp;quot;UTF-8&amp;quot;))&lt;br /&gt;
			&lt;br /&gt;
		return container&lt;br /&gt;
&lt;br /&gt;
	def getCellValue (self,sheet,x,y):&lt;br /&gt;
&lt;br /&gt;
		cell = sheet.getCellByPosition(x,y)&lt;br /&gt;
		cellType  = cell.getType()&lt;br /&gt;
&lt;br /&gt;
		if cellType == self.TEXT :&lt;br /&gt;
			data = cell.getString().encode(&amp;quot;UTF-8&amp;quot;)&lt;br /&gt;
			if data == None:&lt;br /&gt;
				return &amp;quot;&amp;quot;&lt;br /&gt;
			return data.encode(&amp;quot;UTF-8&amp;quot;)&lt;br /&gt;
			&lt;br /&gt;
		if cellType == self.FORMULA or cellType == self.VALUE :&lt;br /&gt;
			data = cell.getValue()&lt;br /&gt;
			if data == None:&lt;br /&gt;
				return 0&lt;br /&gt;
			return cell.getValue()&lt;br /&gt;
&lt;br /&gt;
		if cellType == self.EMPTY :&lt;br /&gt;
			return &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	def getCell(self, session, book, sheet, x, y):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		This method returns the content of a cell.&lt;br /&gt;
		Sample usage from PHP:&lt;br /&gt;
		 - $sessionID is the session&amp;#039;s ID returned by openSession()&lt;br /&gt;
		 - $bookID is the book&amp;#039;s ID returned by openBook()&lt;br /&gt;
		 - $sheet is the sheet&amp;#039;s ID as returned by getBookSheets()&lt;br /&gt;
&lt;br /&gt;
		$query = array(	&lt;br /&gt;
						new XML_RPC_Value($sessionID, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_VALUE($bookID, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_VALUE($sheet, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_Value($x, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_Value($y, &amp;quot;string&amp;quot;)&lt;br /&gt;
					);&lt;br /&gt;
&lt;br /&gt;
		$result = queryXMLRPC($client, &amp;quot;getCell&amp;quot;, $query);&lt;br /&gt;
		return $result;&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
		sheetref = self.sessions[session][1][book][1].getSheets().getByIndex(sheet)&lt;br /&gt;
		valor = self.getCellValue(sheetref,x,y)&lt;br /&gt;
		return valor&lt;br /&gt;
		&lt;br /&gt;
	def setCell(self,session,book,sheet,x,y,value):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		This method sets the content of a cell.&lt;br /&gt;
		Sample usage from PHP:&lt;br /&gt;
		 - $sessionID is the session&amp;#039;s ID returned by openSession()&lt;br /&gt;
		 - $bookID is the book&amp;#039;s ID returned by openBook()&lt;br /&gt;
		 - $sheet is the sheet&amp;#039;s ID as returned by getBookSheets()&lt;br /&gt;
&lt;br /&gt;
		$query = array(&lt;br /&gt;
						new XML_RPC_Value($sessionID, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_VALUE($bookID, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_VALUE($sheet, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_Value($x, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_Value($y, &amp;quot;int&amp;quot;),&lt;br /&gt;
						new XML_RPC_Value($value, &amp;quot;string&amp;quot;)&lt;br /&gt;
					);&lt;br /&gt;
&lt;br /&gt;
		$result = queryXMLRPC($client, &amp;quot;setCell&amp;quot;, $query);&lt;br /&gt;
		return $result;&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		bookObject = self.sessions[session][1][book][1]&lt;br /&gt;
		cell = bookObject.getSheets().getByIndex(sheet).getCellByPosition(x,y)&lt;br /&gt;
		cell.setValue(value)&lt;br /&gt;
		return 1&lt;br /&gt;
&lt;br /&gt;
	#what will change? mmm...&lt;br /&gt;
	def massiveSetCell(self, data):&lt;br /&gt;
			for valores in data:&lt;br /&gt;
				session,sheetid,x,y,valor = valores.split(&amp;quot;|&amp;quot;)&lt;br /&gt;
				code = self.setCell(self.trim(session),self.trim(sheetid),self.trim(x),self.trim(y),valor)&lt;br /&gt;
				if code &amp;lt; 0:&lt;br /&gt;
					return code&lt;br /&gt;
			return 1&lt;br /&gt;
&lt;br /&gt;
	def getSheetPreview(self,session,book,sheet):&lt;br /&gt;
&lt;br /&gt;
		sheet = self.sessions[session][1][book][1].getSheets().getByIndex(sheet)&lt;br /&gt;
		range = sheet.getCellRangeByPosition(0,0,8,23).getDataArray()&lt;br /&gt;
		return range&lt;br /&gt;
		&lt;br /&gt;
&lt;br /&gt;
	def trim(self, cadena):&lt;br /&gt;
		return cadena.strip()&lt;br /&gt;
	&lt;br /&gt;
server = PyUNOServer((&amp;quot;localhost&amp;quot;, 8000))&lt;br /&gt;
&lt;br /&gt;
server.init()&lt;br /&gt;
server.logger.info(&amp;quot;Servicio Inicializado...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
	server.serve_forever()&lt;br /&gt;
except KeyboardInterrupt:&lt;br /&gt;
	server.logger.info(&amp;quot;Cerrando el socket...&amp;quot;)&lt;br /&gt;
	server.server_close()&lt;br /&gt;
	os.kill(server.PID,1)&lt;br /&gt;
	server.logger.info(&amp;quot;Socket cerrado.&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==startPyUnoServer.sh2==&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/openoffice/program/&lt;br /&gt;
export PYTHONPATH=$PYTHONPATH:/usr/lib/openoffice/program&lt;br /&gt;
export DISPLAY=localhost:1&lt;br /&gt;
echo &amp;quot;Logging en pyUnoServer.log&amp;quot;&lt;br /&gt;
python pyUnoServerV2.py&lt;br /&gt;
echo &amp;quot;Ciao!&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Python]][[Category:Uno]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Python_container_components&amp;diff=167138</id>
		<title>Python container components</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Python_container_components&amp;diff=167138"/>
		<updated>2010-05-12T07:15:52Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Python container components=== &lt;br /&gt;
&lt;br /&gt;
I have been dabbling with creating components in Python. This message is intended as an update on what I have learned and am experimenting with. &lt;br /&gt;
&lt;br /&gt;
As a first experiment, here is a single python component program which implements two services. &lt;br /&gt;
&lt;br /&gt;
The two new services are.... &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;name.dannyBrewer.util.IndexContainer &lt;br /&gt;
name.dannyBrewer.util.NameContainer &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is how you install the new component. &lt;br /&gt;
* Copy the text of the following python source code. &lt;br /&gt;
* Put it into a file named &amp;quot;DannyComponentTest2004052217.py&amp;quot; &lt;br /&gt;
* Put the file DannyComponentTest2004052217.py into the uno_components folder of your &amp;quot;user&amp;quot; folder. &lt;br /&gt;
&lt;br /&gt;
The user folder on Windows is probably the folder named &amp;quot;user&amp;quot; under your OOo installation. &lt;br /&gt;
The user folder on Linux is contained within a folder in your home directory with a name like OpenOffice.org1.1.1. &lt;br /&gt;
(Note on Linux, be sure that when you copy the python program that it has no carriage returns, but instead has unix linefeeds. Otherwise the component will not install properly!) &lt;br /&gt;
&lt;br /&gt;
(New edit 2005-03-28: It may in fact be important now on ALL platforms to make sure that the &amp;quot;.py&amp;quot; file of python source has its line endings separated by linefeeds only with NO carriage returns!) &lt;br /&gt;
&lt;br /&gt;
* Be sure that OOo is NOT running. &lt;br /&gt;
* Run the command &amp;quot;pkgchk&amp;quot; in your OOo\programs folder.&lt;br /&gt;
&lt;br /&gt;
To uninstall do this.... &lt;br /&gt;
* Remove the DannyComponentTest2004052217.py file from your uno_components folder. &lt;br /&gt;
* Be sure that OOo is NOT running. &lt;br /&gt;
* Run the pkgchk command. &lt;br /&gt;
&lt;br /&gt;
After installing the component, you have two new data structure services that can be instantiated from any language which can access UNO components. For instance, in OOo Basic, you can simply do...&lt;br /&gt;
  oItems = createUnoService( &amp;quot;name.dannyBrewer.util.IndexContainer&amp;quot; )&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;import unohelper &lt;br /&gt;
&lt;br /&gt;
g_ImplementationHelper = unohelper.ImplementationHelper() &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
################################################################## &lt;br /&gt;
class DannysUnoBaseClass: &lt;br /&gt;
    cServiceName = &amp;quot;&amp;quot; &lt;br /&gt;
    tServiceNames = ( cServiceName, ) &lt;br /&gt;
    # stuff to support the XTypeProvider interface. &lt;br /&gt;
    tInterfaceTypes = ( &lt;br /&gt;
                    uno.getTypeByName( &amp;quot;com.sun.star.lang.XServiceName&amp;quot; ), &lt;br /&gt;
                    uno.getTypeByName( &amp;quot;com.sun.star.lang.XServiceInfo&amp;quot; ), &lt;br /&gt;
                    uno.getTypeByName( &amp;quot;com.sun.star.lang.XTypeProvider&amp;quot; ), &lt;br /&gt;
                    ) &lt;br /&gt;
    uuid = uno.generateUuid() &lt;br /&gt;
    &lt;br /&gt;
    # The component must have a ctor with the component context as argument. &lt;br /&gt;
    def __init__( self, oContext ): &lt;br /&gt;
        self.DannysUnoBaseClass_init( oContext ) &lt;br /&gt;
&lt;br /&gt;
    def DannysUnoBaseClass_init( self, oContext ): &lt;br /&gt;
        self.oContext = oContext &lt;br /&gt;
&lt;br /&gt;
        self.oCoreReflection = None &lt;br /&gt;
        self.StarDesktop = None &lt;br /&gt;
        self.getDesktop() &lt;br /&gt;
&lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
    #   Danny&amp;#039;s stuff to make programming less convenient. &lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
&lt;br /&gt;
    def getServiceManager( self ): &lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;Get the ServiceManager from the running OpenOffice.org. &lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot; &lt;br /&gt;
        return self.oContext.ServiceManager &lt;br /&gt;
    &lt;br /&gt;
    def createUnoService( self, cClass ): &lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;A handy way to create a global objects within the running OOo. &lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot; &lt;br /&gt;
        oServiceManager = self.getServiceManager() &lt;br /&gt;
        oObj = oServiceManager.createInstance( cClass ) &lt;br /&gt;
        return oObj &lt;br /&gt;
    &lt;br /&gt;
    def getDesktop( self ): &lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;An easy way to obtain the Desktop object from a running OOo. &lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot; &lt;br /&gt;
        if self.StarDesktop == None: &lt;br /&gt;
            self.StarDesktop = self.createUnoService( &amp;quot;com.sun.star.frame.Desktop&amp;quot; ) &lt;br /&gt;
        return self.StarDesktop &lt;br /&gt;
&lt;br /&gt;
    def getCoreReflection( self ): &lt;br /&gt;
        if self.oCoreReflection == None: &lt;br /&gt;
            self.oCoreReflection = self.createUnoService( &amp;quot;com.sun.star.reflection.CoreReflection&amp;quot; ) &lt;br /&gt;
        return oCoreReflection &lt;br /&gt;
    &lt;br /&gt;
    def createUnoStruct( self, cTypeName ): &lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;Create a UNO struct and return it. &lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot; &lt;br /&gt;
        oCoreReflection = self.getCoreReflection() &lt;br /&gt;
&lt;br /&gt;
        # Get the IDL class for the type name &lt;br /&gt;
        oXIdlClass = oCoreReflection.forName( cTypeName ) &lt;br /&gt;
&lt;br /&gt;
        # Create the struct. &lt;br /&gt;
        oReturnValue, oStruct = oXIdlClass.createObject( None ) &lt;br /&gt;
&lt;br /&gt;
        return oStruct &lt;br /&gt;
&lt;br /&gt;
    def makePropertyValue( self, cName=None, uValue=None, nHandle=None, nState=None ): &lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;Create a com.sun.star.beans.PropertyValue struct and return it. &lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot; &lt;br /&gt;
        oPropertyValue = self.createUnoStruct( &amp;quot;com.sun.star.beans.PropertyValue&amp;quot; ) &lt;br /&gt;
&lt;br /&gt;
        if cName != None: &lt;br /&gt;
            oPropertyValue.Name = cName &lt;br /&gt;
        if uValue != None: &lt;br /&gt;
            oPropertyValue.Value = uValue &lt;br /&gt;
        if nHandle != None: &lt;br /&gt;
            oPropertyValue.Handle = nHandle &lt;br /&gt;
        if nState != None: &lt;br /&gt;
            oPropertyValue.State = nState &lt;br /&gt;
&lt;br /&gt;
        return oPropertyValue &lt;br /&gt;
&lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
    #   Interface: XServiceName &lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
&lt;br /&gt;
    # string &lt;br /&gt;
    # getServiceName(); &lt;br /&gt;
    def getServiceName( self ): &lt;br /&gt;
        return self.cServiceName &lt;br /&gt;
&lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
    #   Interface: XServiceInfo &lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
&lt;br /&gt;
    # string &lt;br /&gt;
    # getImplementationName(); &lt;br /&gt;
    def getImplementationName( self ): &lt;br /&gt;
        return self.cServiceName &lt;br /&gt;
&lt;br /&gt;
    # boolean &lt;br /&gt;
    # supportsService( [in] string ServiceName ); &lt;br /&gt;
    def supportsService( self, cServiceName ): &lt;br /&gt;
        return cServiceName in self.getSupportedServiceNames() &lt;br /&gt;
&lt;br /&gt;
    # sequence&amp;lt; string &amp;gt; &lt;br /&gt;
    # getSupportedServiceNames(); &lt;br /&gt;
    def getSupportedServiceNames( self ): &lt;br /&gt;
        return self.tServiceNames &lt;br /&gt;
&lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
    #   Interface: XTypeProvider &lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
&lt;br /&gt;
    # sequence&amp;lt; type &amp;gt; &lt;br /&gt;
    # getTypes(); &lt;br /&gt;
    def getTypes( self ): &lt;br /&gt;
        #if self.tInterfaceTypes == None: &lt;br /&gt;
        #    self.tInterfaceTypes = () &lt;br /&gt;
        #    for cTypeName in self.tInterfaces: &lt;br /&gt;
        #        self.tInterfaceTypes += ( uno.getTypeByName( cTypeName ), ) &lt;br /&gt;
        return self.tInterfaceTypes &lt;br /&gt;
&lt;br /&gt;
    # sequence&amp;lt; byte &amp;gt; &lt;br /&gt;
    # getImplementationId(); &lt;br /&gt;
    def getImplementationId( self ): &lt;br /&gt;
        return self.uuid &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
################################################################## &lt;br /&gt;
from com.sun.star.lang import IndexOutOfBoundsException &lt;br /&gt;
&lt;br /&gt;
class IndexContainer( DannysUnoBaseClass ): &lt;br /&gt;
    cServiceName = &amp;quot;name.dannyBrewer.util.IndexContainer&amp;quot; &lt;br /&gt;
    tServiceNames = ( cServiceName, ) &lt;br /&gt;
    tInterfaceTypes = DannysUnoBaseClass.tInterfaceTypes + ( &lt;br /&gt;
                    uno.getTypeByName( &amp;quot;com.sun.star.container.XIndexContainer&amp;quot; ), &lt;br /&gt;
                    uno.getTypeByName( &amp;quot;com.sun.star.container.XIndexReplace&amp;quot; ), &lt;br /&gt;
                    uno.getTypeByName( &amp;quot;com.sun.star.container.XIndexAccess&amp;quot; ), &lt;br /&gt;
                    uno.getTypeByName( &amp;quot;com.sun.star.container.XElementAccess&amp;quot; ), &lt;br /&gt;
                    ) &lt;br /&gt;
    &lt;br /&gt;
    # The component must have a ctor with the component context as argument. &lt;br /&gt;
    def __init__( self, oContext ): &lt;br /&gt;
        # Initialize the base class! &lt;br /&gt;
        self.DannysUnoBaseClass_init( oContext ) &lt;br /&gt;
        # This is the list of items in the IndexContainer. &lt;br /&gt;
        self.items = [] &lt;br /&gt;
&lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
    #   Interface: com.sun.star.container.XIndexContainer &lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
&lt;br /&gt;
    # void &lt;br /&gt;
    # insertByIndex( [in] long nIndex, &lt;br /&gt;
    #                [in] any uElement ); &lt;br /&gt;
    def insertByIndex( self, nIndex, uElement ): &lt;br /&gt;
        if nIndex &amp;lt; 0: &lt;br /&gt;
            raise IndexOutOfBoundsException( &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;You specified an index that was less than zero. &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;, self ) &lt;br /&gt;
        nItems = len( self.items ) &lt;br /&gt;
        if nIndex &amp;gt; nItems: &lt;br /&gt;
            raise IndexOutOfBoundsException( &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;You specified an index that was greater than the last item in the container. &lt;br /&gt;
                Since there are &amp;quot;&amp;quot;&amp;quot; + str( nItems ) + &amp;quot;&amp;quot;&amp;quot; items in the container, you must specify an &lt;br /&gt;
                insert index that is from zero to &amp;quot;&amp;quot;&amp;quot; + str( nItems ) + &amp;quot;&amp;quot;&amp;quot;. &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;, self ) &lt;br /&gt;
        if nIndex == nItems: &lt;br /&gt;
            self.items += [uElement] &lt;br /&gt;
            return &lt;br /&gt;
        self.items = self.items[:nIndex] + [uElement] + self.items[nIndex:] &lt;br /&gt;
&lt;br /&gt;
    # void &lt;br /&gt;
    # removeByIndex( [in] long nIndex ); &lt;br /&gt;
    def removeByIndex( self, nIndex ): &lt;br /&gt;
        if nIndex &amp;lt; 0: &lt;br /&gt;
            raise IndexOutOfBoundsException( &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;You specified an index that was less than zero. &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;, self ) &lt;br /&gt;
        nItems = len( self.items ) &lt;br /&gt;
        if nIndex &amp;gt; nItems: &lt;br /&gt;
            raise IndexOutOfBoundsException( &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;You specified an index that was greater than or equal to the last item in the container. &lt;br /&gt;
                Since there are &amp;quot;&amp;quot;&amp;quot; + str( nItems ) + &amp;quot;&amp;quot;&amp;quot; items in the container, you must specify an &lt;br /&gt;
                insert index that is from zero to &amp;quot;&amp;quot;&amp;quot; + str( nItems-1 ) + &amp;quot;&amp;quot;&amp;quot;. &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;, self ) &lt;br /&gt;
        self.items = self.items[:nIndex] + self.items[nIndex+1:] &lt;br /&gt;
        &lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
    #   Interface: com.sun.star.container.XIndexReplace &lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
&lt;br /&gt;
    # void &lt;br /&gt;
    # replaceByIndex( [in] long nIndes, &lt;br /&gt;
    #                 [in] any uElement ); &lt;br /&gt;
    def replaceByIndex( self, nIndex, uElement ): &lt;br /&gt;
        if nIndex &amp;lt; 0: &lt;br /&gt;
            raise IndexOutOfBoundsException( &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;You specified an index that was less than zero. &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;, self ) &lt;br /&gt;
        nItems = len( self.items ) &lt;br /&gt;
        if nIndex &amp;gt; nItems: &lt;br /&gt;
            raise IndexOutOfBoundsException( &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;You specified an index that was greater than or equal to the last item in the container. &lt;br /&gt;
                Since there are &amp;quot;&amp;quot;&amp;quot; + str( nItems ) + &amp;quot;&amp;quot;&amp;quot; items in the container, you must specify an &lt;br /&gt;
                insert index that is from zero to &amp;quot;&amp;quot;&amp;quot; + str( nItems-1 ) + &amp;quot;&amp;quot;&amp;quot;. &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;, self ) &lt;br /&gt;
        self.items = self.items[:nIndex] + [uElement] + self.items[nIndex+1:] &lt;br /&gt;
    &lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
    #   Interface: com.sun.star.container.XIndexAccess &lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
&lt;br /&gt;
    # long &lt;br /&gt;
    # getCount(); &lt;br /&gt;
    def getCount( self ): &lt;br /&gt;
        return len( self.items ) &lt;br /&gt;
&lt;br /&gt;
    # any &lt;br /&gt;
    # getByIndex( [in] long nIndex ); &lt;br /&gt;
    def getByIndex( self, nIndex ): &lt;br /&gt;
        if nIndex &amp;lt; 0: &lt;br /&gt;
            raise IndexOutOfBoundsException( &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;You specified an index that was less than zero. &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;, self ) &lt;br /&gt;
        nItems = len( self.items ) &lt;br /&gt;
        if nIndex &amp;gt; nItems: &lt;br /&gt;
            raise IndexOutOfBoundsException( &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;You specified an index that was greater than or equal to the last item in the container. &lt;br /&gt;
                Since there are &amp;quot;&amp;quot;&amp;quot; + str( nItems ) + &amp;quot;&amp;quot;&amp;quot; items in the container, you must specify an &lt;br /&gt;
                insert index that is from zero to &amp;quot;&amp;quot;&amp;quot; + str( nItems-1 ) + &amp;quot;&amp;quot;&amp;quot;. &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;, self ) &lt;br /&gt;
        return self.items[ nIndex ] &lt;br /&gt;
    &lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
    #   Interface: com.sun.star.container.XElementAccess &lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
&lt;br /&gt;
    # type &lt;br /&gt;
    # getElementType(); &lt;br /&gt;
    def getElementType( self ): &lt;br /&gt;
        return None &lt;br /&gt;
&lt;br /&gt;
    # boolean &lt;br /&gt;
    # hasElements(); &lt;br /&gt;
    def hasElements( self ): &lt;br /&gt;
        return len( self.items ) &amp;gt; 0 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Add the class to the implementation container, &lt;br /&gt;
#  which the loader uses to register/instantiate the component. &lt;br /&gt;
g_ImplementationHelper.addImplementation( &lt;br /&gt;
        # The class &lt;br /&gt;
   IndexContainer, &lt;br /&gt;
        # The implementation name. &lt;br /&gt;
        # Change this name for your own service. &lt;br /&gt;
        IndexContainer.cServiceName, &lt;br /&gt;
        # A list of services that that are implemented. &lt;br /&gt;
   IndexContainer.tServiceNames, &lt;br /&gt;
        ) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
################################################################## &lt;br /&gt;
from com.sun.star.lang import IndexOutOfBoundsException &lt;br /&gt;
from com.sun.star.container import ElementExistException &lt;br /&gt;
from com.sun.star.container import NoSuchElementException &lt;br /&gt;
&lt;br /&gt;
class NameContainer( DannysUnoBaseClass ): &lt;br /&gt;
    cServiceName = &amp;quot;name.dannyBrewer.util.NameContainer&amp;quot; &lt;br /&gt;
    tServiceNames = ( cServiceName, ) &lt;br /&gt;
    tInterfaceTypes = DannysUnoBaseClass.tInterfaceTypes + ( &lt;br /&gt;
                    uno.getTypeByName( &amp;quot;com.sun.star.container.XNameContainer&amp;quot; ), &lt;br /&gt;
                    uno.getTypeByName( &amp;quot;com.sun.star.container.XNameReplace&amp;quot; ), &lt;br /&gt;
                    uno.getTypeByName( &amp;quot;com.sun.star.container.XNameAccess&amp;quot; ), &lt;br /&gt;
                    uno.getTypeByName( &amp;quot;com.sun.star.container.XIndexAccess&amp;quot; ), &lt;br /&gt;
                    uno.getTypeByName( &amp;quot;com.sun.star.container.XElementAccess&amp;quot; ), &lt;br /&gt;
                    ) &lt;br /&gt;
    &lt;br /&gt;
    # The component must have a ctor with the component context as argument. &lt;br /&gt;
    def __init__( self, oContext ): &lt;br /&gt;
        # Initialize the base class! &lt;br /&gt;
        self.DannysUnoBaseClass_init( oContext ) &lt;br /&gt;
        # This is the dictionary of items in the NameContainer. &lt;br /&gt;
        self.items = {} &lt;br /&gt;
&lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
    #   Interface: com.sun.star.container.XNameContainer &lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
&lt;br /&gt;
    # void &lt;br /&gt;
    # insertByName( [in] string cName, &lt;br /&gt;
    #               [in] any uElement ); &lt;br /&gt;
    def insertByName( self, cName, uElement ): &lt;br /&gt;
        if cName in self.items: &lt;br /&gt;
            raise ElementExistException( &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;You specified an element name of \&amp;quot;&amp;quot;&amp;quot;&amp;quot; + cName + &amp;quot;&amp;quot;&amp;quot;\&amp;quot; &lt;br /&gt;
                which is already present in the container. &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;, self ) &lt;br /&gt;
        self.items[ cName ] = uElement &lt;br /&gt;
&lt;br /&gt;
    # void &lt;br /&gt;
    # removeByName( [in] string cName ); &lt;br /&gt;
    def removeByName( self, cName ): &lt;br /&gt;
        if cName not in self.items: &lt;br /&gt;
            raise NoSuchElementException( &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;You specified an element name of \&amp;quot;&amp;quot;&amp;quot;&amp;quot; + cName + &amp;quot;&amp;quot;&amp;quot;\&amp;quot; &lt;br /&gt;
                which does not exist in the container. &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;, self ) &lt;br /&gt;
        del self.items[ cName ] &lt;br /&gt;
        &lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
    #   Interface: com.sun.star.container.XNameReplace &lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
&lt;br /&gt;
    # void &lt;br /&gt;
    # replaceByName( [in] string cName, &lt;br /&gt;
    #                [in] any uElement ); &lt;br /&gt;
    def replaceByName( self, cName, uElement ): &lt;br /&gt;
        if cName not in self.items: &lt;br /&gt;
            raise NoSuchElementException( &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;You specified an element name of \&amp;quot;&amp;quot;&amp;quot;&amp;quot; + cName + &amp;quot;&amp;quot;&amp;quot;\&amp;quot; &lt;br /&gt;
                which does not exist in the container. &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;, self ) &lt;br /&gt;
        self.items[ cName ] = uElement &lt;br /&gt;
    &lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
    #   Interface: com.sun.star.container.XNameAccess &lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
&lt;br /&gt;
    # any &lt;br /&gt;
    # getByName( [in] string cName ); &lt;br /&gt;
    def getByName( self, cName ): &lt;br /&gt;
        if cName not in self.items: &lt;br /&gt;
            raise NoSuchElementException( &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;You specified an element name of \&amp;quot;&amp;quot;&amp;quot;&amp;quot; + cName + &amp;quot;&amp;quot;&amp;quot;\&amp;quot; &lt;br /&gt;
                which does not exist in the container. &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;, self ) &lt;br /&gt;
        return self.items[ cName ] &lt;br /&gt;
    &lt;br /&gt;
    # boolean &lt;br /&gt;
    # hasByName( [in] string cName ); &lt;br /&gt;
    def hasByName( self, cName ): &lt;br /&gt;
        return cName in self.items &lt;br /&gt;
&lt;br /&gt;
    # sequence&amp;lt; string &amp;gt; &lt;br /&gt;
    # getElementNames(); &lt;br /&gt;
    def getElementNames( self ): &lt;br /&gt;
        return tuple( self.items.keys() ) &lt;br /&gt;
    &lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
    #   Interface: com.sun.star.container.XIndexAccess &lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
&lt;br /&gt;
    # long &lt;br /&gt;
    # getCount(); &lt;br /&gt;
    def getCount( self ): &lt;br /&gt;
        return len( self.items ) &lt;br /&gt;
&lt;br /&gt;
    # any &lt;br /&gt;
    # getByIndex( [in] long nIndex ); &lt;br /&gt;
    def getByIndex( self, nIndex ): &lt;br /&gt;
        if nIndex &amp;lt; 0: &lt;br /&gt;
            raise IndexOutOfBoundsException( &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;You specified an index that was less than zero. &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;, self ) &lt;br /&gt;
        nItems = len( self.items ) &lt;br /&gt;
        if nIndex &amp;gt; nItems: &lt;br /&gt;
            raise IndexOutOfBoundsException( &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;You specified an index that was greater than or equal to the last item in the container. &lt;br /&gt;
                Since there are &amp;quot;&amp;quot;&amp;quot; + str( nItems ) + &amp;quot;&amp;quot;&amp;quot; items in the container, you must specify an &lt;br /&gt;
                insert index that is from zero to &amp;quot;&amp;quot;&amp;quot; + str( nItems-1 ) + &amp;quot;&amp;quot;&amp;quot;. &lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;, self ) &lt;br /&gt;
        return self.items.values()[ nIndex ] &lt;br /&gt;
    &lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
    #   Interface: com.sun.star.container.XElementAccess &lt;br /&gt;
    #---------------------------------------- &lt;br /&gt;
&lt;br /&gt;
    # type &lt;br /&gt;
    # getElementType(); &lt;br /&gt;
    def getElementType( self ): &lt;br /&gt;
        return None &lt;br /&gt;
&lt;br /&gt;
    # boolean &lt;br /&gt;
    # hasElements(); &lt;br /&gt;
    def hasElements( self ): &lt;br /&gt;
        return len( self.items ) &amp;gt; 0 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Add the class to the implementation container, &lt;br /&gt;
#  which the loader uses to register/instantiate the component. &lt;br /&gt;
g_ImplementationHelper.addImplementation( &lt;br /&gt;
        # The class &lt;br /&gt;
   NameContainer, &lt;br /&gt;
        # The implementation name. &lt;br /&gt;
        # Change this name for your own service. &lt;br /&gt;
        NameContainer.cServiceName, &lt;br /&gt;
        # A list of services that that are implemented. &lt;br /&gt;
   NameContainer.tServiceNames, &lt;br /&gt;
        )&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are still some issues I am working out. I just want other interested people to be able to take my experimentation further or in different directions. &lt;br /&gt;
&lt;br /&gt;
The above demonstrates several useful features. &lt;br /&gt;
* Component code written in pure python. &lt;br /&gt;
* Two services in one component. &lt;br /&gt;
* Two components which inherit from a base class which implements some of the underlying &amp;quot;plumbing&amp;quot; machinery. &lt;br /&gt;
* A way to inherit from multiple interfaces.&lt;br /&gt;
&lt;br /&gt;
So why don&amp;#039;t I just&lt;br /&gt;
    from com.sun.star.container import XIndexAccess&lt;br /&gt;
and then just make my class do.... &lt;br /&gt;
    class IndexContainer( unohelper.Base, XIndexAccess )&lt;br /&gt;
[[Category:Python]][[Category:Uno]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Text/Inserting_Tables&amp;diff=165613</id>
		<title>Documentation/DevGuide/Text/Inserting Tables</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Text/Inserting_Tables&amp;diff=165613"/>
		<updated>2010-04-30T05:55:17Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/TextTOC&lt;br /&gt;
|Text2b=block&lt;br /&gt;
|TextTables=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Text/Text Table Properties&lt;br /&gt;
|NextPage=Documentation/DevGuide/Text/Accessing Existing Tables&lt;br /&gt;
}}&lt;br /&gt;
{{Documentation/DevGuideLanguages|Documentation/DevGuide/Text/{{SUBPAGENAME}}}} &lt;br /&gt;
 {{DISPLAYTITLE:Inserting Tables}}&lt;br /&gt;
To create and insert a new text table, a five-step procedure must be followed:&lt;br /&gt;
&lt;br /&gt;
# Get the service manager of the text document, querying the document&amp;#039;s factory interface &amp;lt;idl&amp;gt;com.sun.star.lang.XMultiServiceFactory&amp;lt;/idl&amp;gt;.&lt;br /&gt;
# Order a new text table from the factory by its service name &amp;quot;&amp;lt;code&amp;gt;com.sun.star.text.TextTable&amp;lt;/code&amp;gt;&amp;quot;, using the factory method &amp;lt;code&amp;gt;createInstance()&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the object received, query the &amp;lt;idl&amp;gt;com.sun.star.text.XTextTable&amp;lt;/idl&amp;gt; interface that inherits from &amp;lt;idl&amp;gt;com.sun.star.text.XTextContent&amp;lt;/idl&amp;gt;.&lt;br /&gt;
# If necessary, initialize the table with the number of rows and columns. For this purpose, &amp;lt;code&amp;gt;XTextTable&amp;lt;/code&amp;gt; offers the &amp;lt;code&amp;gt;initialize()&amp;lt;/code&amp;gt; method.&lt;br /&gt;
# Insert the table into the text using the &amp;lt;code&amp;gt;insertTextContent()&amp;lt;/code&amp;gt; method at its &amp;lt;idl&amp;gt;com.sun.star.text.XText&amp;lt;/idl&amp;gt; interface. The method &amp;lt;code&amp;gt;insertTextContent()&amp;lt;/code&amp;gt; expects an &amp;lt;code&amp;gt;XTextContent&amp;lt;/code&amp;gt; to insert. Since &amp;lt;code&amp;gt;XTextTable&amp;lt;/code&amp;gt; inherits from &amp;lt;code&amp;gt;XTextContent&amp;lt;/code&amp;gt;, pass the &amp;lt;code&amp;gt;XTextTable&amp;lt;/code&amp;gt; interface retrieved previously.&lt;br /&gt;
&lt;br /&gt;
You are now ready to get cells, fill in text, values and formulas and set the table and cell properties as needed.&lt;br /&gt;
&lt;br /&gt;
In the following code sample, there is a small helper function to put random numbers between -1000 and 1000 into the table to demonstrate formulas: &lt;br /&gt;
&amp;lt;!--[SOURCE:Text/TextDocuments.java]--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /** This method returns a random double which isn&amp;#039;t too high or too low&lt;br /&gt;
   */&lt;br /&gt;
  protected double getRandomDouble()&lt;br /&gt;
  {&lt;br /&gt;
      return (maRandom.nextInt(1000) * maRandom.nextDouble());&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
The following helper function inserts a string into a cell known by its name and sets its text color to white: &lt;br /&gt;
&amp;lt;!--[SOURCE:Text/TextDocuments.java]--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /** This method sets the text colour of the cell refered to by sCellName to white and inserts&lt;br /&gt;
      the string sText in it&lt;br /&gt;
   */&lt;br /&gt;
  public static void insertIntoCell(String sCellName, String sText, XTextTable xTable) {&lt;br /&gt;
      // Access the XText interface of the cell referred to by sCellName&lt;br /&gt;
      XText xCellText = (XText) UnoRuntime.queryInterface(&lt;br /&gt;
          XText.class, xTable.getCellByName(sCellName));&lt;br /&gt;
  &lt;br /&gt;
      // create a text cursor from the cells XText interface&lt;br /&gt;
      XTextCursor xCellCursor = xCellText.createTextCursor();&lt;br /&gt;
  &lt;br /&gt;
      // Get the property set of the cell&amp;#039;s TextCursor&lt;br /&gt;
      XPropertySet xCellCursorProps = (XPropertySet)UnoRuntime.queryInterface(&lt;br /&gt;
          XPropertySet.class, xCellCursor);&lt;br /&gt;
  &lt;br /&gt;
      try {&lt;br /&gt;
          // Set the colour of the text to white&lt;br /&gt;
          xCellCursorProps.setPropertyValue(&amp;quot;CharColor&amp;quot;, new Integer(16777215));&lt;br /&gt;
      } catch (Exception e) {&lt;br /&gt;
          e.printStackTrace(System.out);&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
      // Set the text in the cell to sText&lt;br /&gt;
      xCellText.setString(sText);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Using the above helper functions, create a text table and insert it into the text document. &lt;br /&gt;
&amp;lt;!--[SOURCE:Text/TextDocuments.java]--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /** This method shows how to create and insert a text table, as well as insert text and formulae&lt;br /&gt;
      into the cells of the table&lt;br /&gt;
   */&lt;br /&gt;
  protected void TextTableExample ()&lt;br /&gt;
  {&lt;br /&gt;
      try &lt;br /&gt;
      {&lt;br /&gt;
          // Create a new table from the document&amp;#039;s factory&lt;br /&gt;
          XTextTable xTable = (XTextTable) UnoRuntime.queryInterface( &lt;br /&gt;
              XTextTable.class, mxDocFactory .createInstance(&lt;br /&gt;
                  &amp;quot;com.sun.star.text.TextTable&amp;quot; ) );&lt;br /&gt;
          &lt;br /&gt;
          // Specify that we want the table to have 4 rows and 4 columns&lt;br /&gt;
          xTable.initialize( 4, 4 );&lt;br /&gt;
          &lt;br /&gt;
          // Insert the table into the document&lt;br /&gt;
          mxDocText.insertTextContent( mxDocCursor, xTable, false);&lt;br /&gt;
          // Get an XIndexAccess of the table rows&lt;br /&gt;
          XIndexAccess xRows = xTable.getRows();&lt;br /&gt;
          &lt;br /&gt;
          // Access the property set of the first row (properties listed in service description:&lt;br /&gt;
          // com.sun.star.text.TextTableRow)&lt;br /&gt;
          XPropertySet xRow = (XPropertySet) UnoRuntime.queryInterface( &lt;br /&gt;
              XPropertySet.class, xRows.getByIndex ( 0 ) );&lt;br /&gt;
          // If BackTransparant is false, then the background color is visible&lt;br /&gt;
          xRow.setPropertyValue( &amp;quot;BackTransparent&amp;quot;, Boolean.FALSE);&lt;br /&gt;
          // Specify the color of the background to be dark blue&lt;br /&gt;
          xRow.setPropertyValue( &amp;quot;BackColor&amp;quot;, new Integer(6710932));&lt;br /&gt;
          &lt;br /&gt;
          // Access the property set of the whole table&lt;br /&gt;
          XPropertySet xTableProps = (XPropertySet)UnoRuntime.queryInterface( &lt;br /&gt;
              XPropertySet.class, xTable );&lt;br /&gt;
          // We want visible background colors&lt;br /&gt;
          xTableProps.setPropertyValue( &amp;quot;BackTransparent&amp;quot;, Boolean.FALSE);&lt;br /&gt;
          // Set the background colour to light blue&lt;br /&gt;
          xTableProps.setPropertyValue( &amp;quot;BackColor&amp;quot;, new Integer(13421823));&lt;br /&gt;
          &lt;br /&gt;
          // set the text (and text colour) of all the cells in the first row of the table&lt;br /&gt;
          insertIntoCell( &amp;quot;A1&amp;quot;, &amp;quot;First Column&amp;quot;, xTable );&lt;br /&gt;
          insertIntoCell( &amp;quot;B1&amp;quot;, &amp;quot;Second Column&amp;quot;, xTable );&lt;br /&gt;
          insertIntoCell( &amp;quot;C1&amp;quot;, &amp;quot;Third Column&amp;quot;, xTable );&lt;br /&gt;
          insertIntoCell( &amp;quot;D1&amp;quot;, &amp;quot;Results&amp;quot;, xTable );&lt;br /&gt;
          &lt;br /&gt;
          // Insert random numbers into the first this three cells of each&lt;br /&gt;
          // remaining row&lt;br /&gt;
          xTable.getCellByName( &amp;quot;A2&amp;quot; ).setValue( getRandomDouble() );&lt;br /&gt;
          xTable.getCellByName( &amp;quot;B2&amp;quot; ).setValue( getRandomDouble() );&lt;br /&gt;
          xTable.getCellByName( &amp;quot;C2&amp;quot; ).setValue( getRandomDouble() );&lt;br /&gt;
          &lt;br /&gt;
          xTable.getCellByName( &amp;quot;A3&amp;quot; ).setValue( getRandomDouble() );&lt;br /&gt;
          xTable.getCellByName( &amp;quot;B3&amp;quot; ).setValue( getRandomDouble() );&lt;br /&gt;
          xTable.getCellByName( &amp;quot;C3&amp;quot; ).setValue( getRandomDouble() );&lt;br /&gt;
          &lt;br /&gt;
          xTable.getCellByName( &amp;quot;A4&amp;quot; ).setValue( getRandomDouble() );&lt;br /&gt;
          xTable.getCellByName( &amp;quot;B4&amp;quot; ).setValue( getRandomDouble() );&lt;br /&gt;
          xTable.getCellByName( &amp;quot;C4&amp;quot; ).setValue( getRandomDouble() );&lt;br /&gt;
          &lt;br /&gt;
          // Set the last cell in each row to be a formula that calculates&lt;br /&gt;
          // the sum of the first three cells&lt;br /&gt;
          xTable.getCellByName( &amp;quot;D2&amp;quot; ).setFormula( &amp;quot;sum &amp;lt;A2:C2&amp;gt;&amp;quot; );&lt;br /&gt;
          xTable.getCellByName( &amp;quot;D3&amp;quot; ).setFormula( &amp;quot;sum &amp;lt;A3:C3&amp;gt;&amp;quot; );&lt;br /&gt;
          xTable.getCellByName( &amp;quot;D4&amp;quot; ).setFormula( &amp;quot;sum &amp;lt;A4:C4&amp;gt;&amp;quot; );&lt;br /&gt;
      } &lt;br /&gt;
      catch (Exception e) &lt;br /&gt;
      {&lt;br /&gt;
          e.printStackTrace ( System.out );&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
The next sample inserts auto text entries into a table, splitting cells during its course. &lt;br /&gt;
&amp;lt;!--[SOURCE:Text/TextDocuments.java]--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /** This example demonstrates the use of the AutoTextContainer, AutoTextGroup and AutoTextEntry services&lt;br /&gt;
      and shows how to create, insert and modify auto text blocks&lt;br /&gt;
   */&lt;br /&gt;
  protected void AutoTextExample ()&lt;br /&gt;
  {&lt;br /&gt;
      try&lt;br /&gt;
      {&lt;br /&gt;
          // Go to the end of the document&lt;br /&gt;
          mxDocCursor.gotoEnd( false );&lt;br /&gt;
          // Insert two paragraphs&lt;br /&gt;
          mxDocText.insertControlCharacter ( mxDocCursor, &lt;br /&gt;
              ControlCharacter.PARAGRAPH_BREAK, false );&lt;br /&gt;
          mxDocText.insertControlCharacter ( mxDocCursor, &lt;br /&gt;
              ControlCharacter.PARAGRAPH_BREAK, false );&lt;br /&gt;
          // Position the cursor in the second paragraph&lt;br /&gt;
          XParagraphCursor xParaCursor = (XParagraphCursor) UnoRuntime.queryInterface(&lt;br /&gt;
              XParagraphCursor.class, mxDocCursor );&lt;br /&gt;
          xParaCursor.gotoPreviousParagraph ( false );&lt;br /&gt;
          &lt;br /&gt;
          // Get an XNameAccess interface to all auto text groups from the document factory&lt;br /&gt;
          XNameAccess xContainer = (XNameAccess) UnoRuntime.queryInterface( &lt;br /&gt;
              XNameAccess.class, mxFactory.createInstance (&lt;br /&gt;
                  &amp;quot;com.sun.star.text.AutoTextContainer&amp;quot; ) );&lt;br /&gt;
          &lt;br /&gt;
          // Create a new table at the document factory&lt;br /&gt;
          XTextTable xTable = (XTextTable) UnoRuntime.queryInterface( &lt;br /&gt;
              XTextTable.class, mxDocFactory .createInstance( &lt;br /&gt;
                  &amp;quot;com.sun.star.text.TextTable&amp;quot; ) );&lt;br /&gt;
          &lt;br /&gt;
          // Store the names of all auto text groups in an array of strings&lt;br /&gt;
          String[] aGroupNames = xContainer.getElementNames();&lt;br /&gt;
          &lt;br /&gt;
          // Make sure we have at least one group name&lt;br /&gt;
          if ( aGroupNames.length &amp;gt; 0 ) &lt;br /&gt;
          {&lt;br /&gt;
              // initialise the table to have a row for every autotext group &lt;br /&gt;
              //in a single column + one&lt;br /&gt;
              // additional row for a header&lt;br /&gt;
              xTable.initialize( aGroupNames.length+1,1);&lt;br /&gt;
              &lt;br /&gt;
              // Access the XPropertySet of the table&lt;br /&gt;
              XPropertySet xTableProps = (XPropertySet)UnoRuntime.queryInterface(&lt;br /&gt;
                  XPropertySet.class, xTable );&lt;br /&gt;
              &lt;br /&gt;
              // We want a visible background&lt;br /&gt;
              xTableProps.setPropertyValue( &amp;quot;BackTransparent&amp;quot;, Boolean.FALSE);&lt;br /&gt;
              &lt;br /&gt;
              // We want the background to be light blue&lt;br /&gt;
              xTableProps.setPropertyValue( &amp;quot;BackColor&amp;quot;, new Integer(13421823));&lt;br /&gt;
              &lt;br /&gt;
              // Insert the table into the document&lt;br /&gt;
              mxDocText.insertTextContent( mxDocCursor, xTable, false);&lt;br /&gt;
              &lt;br /&gt;
              // Get an XIndexAccess to all table rows&lt;br /&gt;
              XIndexAccess xRows = xTable.getRows();&lt;br /&gt;
              &lt;br /&gt;
              // Get the first row in the table&lt;br /&gt;
              XPropertySet xRow = (XPropertySet) UnoRuntime.queryInterface(&lt;br /&gt;
                  XPropertySet.class, xRows.getByIndex ( 0 ) );&lt;br /&gt;
              &lt;br /&gt;
              // We want the background of the first row to be visible too&lt;br /&gt;
              xRow.setPropertyValue( &amp;quot;BackTransparent&amp;quot;, Boolean.FALSE);&lt;br /&gt;
              &lt;br /&gt;
              // And let&amp;#039;s make it dark blue&lt;br /&gt;
              xRow.setPropertyValue( &amp;quot;BackColor&amp;quot;, new Integer(6710932));&lt;br /&gt;
              &lt;br /&gt;
              // Put a description of the table contents into the first cell&lt;br /&gt;
              insertIntoCell( &amp;quot;A1&amp;quot;, &amp;quot;AutoText Groups&amp;quot;, xTable);&lt;br /&gt;
              &lt;br /&gt;
              // Create a table cursor pointing at the second cell in the first column&lt;br /&gt;
              XTextTableCursor xTableCursor = xTable.createCursorByCellName ( &amp;quot;A2&amp;quot; );&lt;br /&gt;
              &lt;br /&gt;
              // Loop over the group names&lt;br /&gt;
              for ( int i = 0 ; i &amp;lt; aGroupNames.length ; i ++ )&lt;br /&gt;
              {&lt;br /&gt;
                  // Get the name of the current cell&lt;br /&gt;
                  String sCellName = xTableCursor.getRangeName ();&lt;br /&gt;
                  &lt;br /&gt;
                  // Get the XText interface of the current cell&lt;br /&gt;
                  XText xCellText = (XText) UnoRuntime.queryInterface ( &lt;br /&gt;
                      XText.class, xTable.getCellByName ( sCellName ) );&lt;br /&gt;
                  &lt;br /&gt;
                  // Set the cell contents of the current cell to be &lt;br /&gt;
                  //the name of the of an autotext group&lt;br /&gt;
                  xCellText.setString ( aGroupNames[i] );&lt;br /&gt;
                  &lt;br /&gt;
                  // Access the autotext gruop with this name&lt;br /&gt;
                  XAutoTextGroup xGroup = ( XAutoTextGroup ) UnoRuntime.queryInterface (&lt;br /&gt;
                      XAutoTextGroup.class,xContainer.getByName(aGroupNames[i]));&lt;br /&gt;
                  &lt;br /&gt;
                  // Get the titles of each autotext block in this group&lt;br /&gt;
                  String [] aBlockNames = xGroup.getTitles();&lt;br /&gt;
                  &lt;br /&gt;
                  // Make sure that the autotext group contains at least one block&lt;br /&gt;
                  if ( aBlockNames.length &amp;gt; 0 )&lt;br /&gt;
                  {&lt;br /&gt;
                      // Split the current cell vertically into two seperate cells&lt;br /&gt;
                      xTableCursor.splitRange ( (short) 1, false );&lt;br /&gt;
                      &lt;br /&gt;
                      // Put the cursor in the newly created right hand cell &lt;br /&gt;
                      // and select it&lt;br /&gt;
                      xTableCursor.goRight ( (short) 1, false );&lt;br /&gt;
                      &lt;br /&gt;
                      // Split this cell horizontally to make a seperate cell &lt;br /&gt;
                      // for each Autotext block&lt;br /&gt;
                      if ( ( aBlockNames.length -1 ) &amp;gt; 0 )&lt;br /&gt;
                          xTableCursor.splitRange ( &lt;br /&gt;
                              (short) (aBlockNames.length - 1), true );&lt;br /&gt;
                      &lt;br /&gt;
                      // loop over the block names&lt;br /&gt;
                      for ( int j = 0 ; j &amp;lt; aBlockNames.length ; j ++ )&lt;br /&gt;
                      {&lt;br /&gt;
                          // Get the XText interface of the current cell&lt;br /&gt;
                          xCellText = (XText) UnoRuntime.queryInterface (&lt;br /&gt;
                              XText.class, xTable.getCellByName (&lt;br /&gt;
                              xTableCursor.getRangeName() ) );&lt;br /&gt;
                      &lt;br /&gt;
                          // Set the text contents of the current cell to the&lt;br /&gt;
                          // title of an Autotext block&lt;br /&gt;
                          xCellText.setString ( aBlockNames[j] );&lt;br /&gt;
                      &lt;br /&gt;
                          // Move the cursor down one cell&lt;br /&gt;
                          xTableCursor.goDown( (short)1, false);&lt;br /&gt;
                      }&lt;br /&gt;
                  }&lt;br /&gt;
                  // Go back to the cell we originally split&lt;br /&gt;
                  xTableCursor.gotoCellByName ( sCellName, false );&lt;br /&gt;
                  &lt;br /&gt;
                  // Go down one cell&lt;br /&gt;
                  xTableCursor.goDown( (short)1, false);&lt;br /&gt;
              }&lt;br /&gt;
              &lt;br /&gt;
              XAutoTextGroup xGroup;&lt;br /&gt;
              String [] aBlockNames;&lt;br /&gt;
              &lt;br /&gt;
              // Add a depth so that we only generate 200 numbers before &lt;br /&gt;
              // giving up on finding a random autotext group that contains autotext blocks&lt;br /&gt;
              int nDepth = 0;&lt;br /&gt;
              do&lt;br /&gt;
              {&lt;br /&gt;
                  // Generate a random, positive number which is lower than &lt;br /&gt;
                  // the number of autotext groups&lt;br /&gt;
                  int nRandom = maRandom.nextInt( aGroupNames.length );&lt;br /&gt;
                  &lt;br /&gt;
                  // Get the autotext group at this name&lt;br /&gt;
                  xGroup = ( XAutoTextGroup ) UnoRuntime.queryInterface (&lt;br /&gt;
                      XAutoTextGroup.class, xContainer.getByName (&lt;br /&gt;
                          aGroupNames[ nRandom ] ) );&lt;br /&gt;
                  &lt;br /&gt;
                  // Fill our string array with the names of all the blocks in this&lt;br /&gt;
                  // group&lt;br /&gt;
                  aBlockNames = xGroup.getElementNames();&lt;br /&gt;
                  &lt;br /&gt;
                  // increment our depth counter&lt;br /&gt;
                  ++nDepth;&lt;br /&gt;
              }                  &lt;br /&gt;
              while ( nDepth &amp;lt; 200 &amp;amp;&amp;amp; aBlockNames.length == 0 );&lt;br /&gt;
              // If we managed to find a group containg blocks...&lt;br /&gt;
              if ( aBlockNames.length &amp;gt; 0 )&lt;br /&gt;
              {&lt;br /&gt;
                  // Pick a random block in this group and get it&amp;#039;s&lt;br /&gt;
                  // XAutoTextEntry interface&lt;br /&gt;
                  int nRandom = maRandom.nextInt( aBlockNames.length );&lt;br /&gt;
                  XAutoTextEntry xEntry = ( XAutoTextEntry )&lt;br /&gt;
                      UnoRuntime.queryInterface ( &lt;br /&gt;
                          XAutoTextEntry.class, xGroup.getByName (&lt;br /&gt;
                              aBlockNames[ nRandom ] ) );&lt;br /&gt;
                  // insert the modified autotext block at the end of the document&lt;br /&gt;
                  xEntry.applyTo ( mxDocCursor );&lt;br /&gt;
                  &lt;br /&gt;
                  // Get the titles of all text blocks in this AutoText group&lt;br /&gt;
                  String [] aBlockTitles = xGroup.getTitles();&lt;br /&gt;
                  &lt;br /&gt;
                  // Get the XNamed interface of the autotext group&lt;br /&gt;
                  XNamed xGroupNamed = ( XNamed ) UnoRuntime.queryInterface (&lt;br /&gt;
                      XNamed.class, xGroup );&lt;br /&gt;
                  &lt;br /&gt;
                  // Output the short cut and title of the random block &lt;br /&gt;
                  //and the name of the group it&amp;#039;s from&lt;br /&gt;
                  System.out.println ( &amp;quot;Inserted the Autotext &amp;#039;&amp;quot; + aBlockTitles[nRandom] &lt;br /&gt;
                      + &amp;quot;&amp;#039;, shortcut &amp;#039;&amp;quot; + aBlockNames[nRandom] + &amp;quot;&amp;#039; from group &amp;#039;&amp;quot; &lt;br /&gt;
                          + xGroupNamed.getName() );&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          &lt;br /&gt;
          // Go to the end of the document&lt;br /&gt;
          mxDocCursor.gotoEnd( false );&lt;br /&gt;
          // Insert new paragraph&lt;br /&gt;
          mxDocText.insertControlCharacter ( &lt;br /&gt;
              mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );&lt;br /&gt;
          &lt;br /&gt;
          // Position cursor in new paragraph&lt;br /&gt;
          xParaCursor.gotoPreviousParagraph ( false );&lt;br /&gt;
          &lt;br /&gt;
          // Insert a string in the new paragraph&lt;br /&gt;
          mxDocText.insertString ( mxDocCursor, &amp;quot;Some text for a new autotext block&amp;quot;, false );&lt;br /&gt;
          &lt;br /&gt;
          // Go to the end of the document&lt;br /&gt;
          mxDocCursor.gotoEnd( false );&lt;br /&gt;
      }&lt;br /&gt;
      catch (Exception e) &lt;br /&gt;
      {&lt;br /&gt;
          e.printStackTrace ( System.out );&lt;br /&gt;
      }&lt;br /&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>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=ES/Desarrollo/Syndication&amp;diff=165524</id>
		<title>ES/Desarrollo/Syndication</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=ES/Desarrollo/Syndication&amp;diff=165524"/>
		<updated>2010-04-28T19:27:16Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
{{DISPLAYTITLE:Syndicating the OOo Website}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;This script will parse and syndicate [[OOoES|OOoES]] Announcement section and then register it to a Database Backend. This is still a simple script and has no other functionality than parse the annoucment page you can change the project subdomain and you will be able to parse your announcments.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;TODO:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Loop over multiple urls&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Parse other documents such as Documentation&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
# -*- coding: utf-8 -*-&lt;br /&gt;
&lt;br /&gt;
###########################################################################&lt;br /&gt;
#	 Copyright (C) 2005 by Alexandro Colorado &amp;amp;&amp;amp; Luis Cabrera&lt;br /&gt;
#&lt;br /&gt;
#	 Author:&lt;br /&gt;
#		  Alexandro Colorado &amp;lt;jza@openoffice.org&amp;gt;&lt;br /&gt;
#		  Luis Cabrera &amp;lt;lcabrera@sauco.org&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Copyright: See COPYING file that comes with this distribution&lt;br /&gt;
#&lt;br /&gt;
###########################################################################&lt;br /&gt;
&lt;br /&gt;
__shell_usage__ = &amp;#039;&amp;#039;&amp;#039;Este programa esta pensado para recoger automaticamente&lt;br /&gt;
		  los enlaces localizados en una determinada pagina, compararlos con los ya&lt;br /&gt;
		  existentes en una bbdd, y, si hay nuevos enlaces, insertarlos en la bbdd y&lt;br /&gt;
		  posteriormente, mandar un correo a las listas de usuarios predeterminadas&lt;br /&gt;
		  con los enlaces a las nuevas noticias.&lt;br /&gt;
		  Si no hubieran noticias nuevas, el programa no debera hacer absolutamente&lt;br /&gt;
		  nada.&lt;br /&gt;
		  &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
__version__ = &amp;#039;20051024&amp;#039;&lt;br /&gt;
__author__=&amp;#039;Luis Cabrera Sauco &amp;amp;&amp;amp; Alexandro Colorado&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import HTMLParser&lt;br /&gt;
import urllib2&lt;br /&gt;
import MySQLdb&lt;br /&gt;
import smtplib&lt;br /&gt;
&lt;br /&gt;
############ CONFIGURATION VARIABLES ###############&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Pagina de la que recoger los enlaces iniciales&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
headlines_url = &amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Datos para la configuracia de la bbdd&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
myhost= &amp;quot;&amp;quot;&lt;br /&gt;
myuser=&amp;quot;&amp;quot;&lt;br /&gt;
mypassword=&amp;quot;&amp;quot;&lt;br /&gt;
mydb=&amp;quot;&amp;quot;&lt;br /&gt;
mytb=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Datos para el envio de correos de avisos&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
enviar_correo=1&lt;br /&gt;
remitente=&amp;quot;&amp;quot;&lt;br /&gt;
destinatario=&amp;quot;&amp;quot;&lt;br /&gt;
subject=&amp;quot;&amp;quot;&lt;br /&gt;
##&lt;br /&gt;
###################################&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class HeadlinesParser(HTMLParser.HTMLParser):&lt;br /&gt;
	 def __init__(self):&lt;br /&gt;
		  HTMLParser.HTMLParser.__init__(self)&lt;br /&gt;
		  self.headlines = {}&lt;br /&gt;
		  self.while_anchor = False&lt;br /&gt;
		  self.last_href = None&lt;br /&gt;
&lt;br /&gt;
	 def handle_starttag(self, name, attrs):&lt;br /&gt;
		  attrs = dict(attrs)&lt;br /&gt;
		  if name == &amp;quot;a&amp;quot;:&lt;br /&gt;
				if &amp;quot;href&amp;quot; in attrs:&lt;br /&gt;
					 current_href = attrs[&amp;quot;href&amp;quot;]&lt;br /&gt;
					 if &amp;quot;newsItemID&amp;quot; in current_href:&lt;br /&gt;
						  self.while_anchor = True&lt;br /&gt;
						  self.last_href = current_href&lt;br /&gt;
&lt;br /&gt;
	 def handle_data(self, content):&lt;br /&gt;
		  content = content.strip()&lt;br /&gt;
		  if self.while_anchor:&lt;br /&gt;
				self.headlines[content] = self.last_href&lt;br /&gt;
&lt;br /&gt;
	 def handle_endtag(self, name):&lt;br /&gt;
		  if name == &amp;quot;a&amp;quot;:&lt;br /&gt;
				self.while_anchor = False&lt;br /&gt;
&lt;br /&gt;
def sendMessage(de, para=[], cc=[], asunto=&amp;#039;Asunto&amp;#039;,texto=&amp;#039;Cuerpo.&amp;#039;, archivos=[],&lt;br /&gt;
host=&amp;#039;&amp;#039;, charsettexto=&amp;#039;iso-8859-1&amp;#039;, loginUsername=&amp;#039;&amp;#039;, loginPassword=&amp;#039;&amp;#039;):&lt;br /&gt;
	 &amp;quot;&amp;quot;&amp;quot; Mandar mensaje por correo electronico. &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	 from email.MIMEBase import MIMEBase&lt;br /&gt;
	 from email.MIMEText import MIMEText&lt;br /&gt;
	 from email import Encoders&lt;br /&gt;
	 import mimetypes&lt;br /&gt;
	 from smtplib import SMTP&lt;br /&gt;
	 import os&lt;br /&gt;
&lt;br /&gt;
	 msg=MIMEText(texto, _charset=charsettexto)&lt;br /&gt;
	 if archivos:&lt;br /&gt;
		  msg2=MIMEBase(&amp;quot;multipart&amp;quot;,&amp;quot;mixed&amp;quot;)  # crear contenedor&lt;br /&gt;
		  msg2.preamble=&amp;quot;Este es un mensaje MIME con varias partes.&amp;quot;	 &lt;br /&gt;
&lt;br /&gt;
                  # es muy importante!!! (de lo contrario no reconoce primer anexo.)&lt;br /&gt;
		  msg2.epilogue=&amp;#039;&amp;#039;&lt;br /&gt;
		  msg2.add_payload(msg)&lt;br /&gt;
		  msg=msg2&lt;br /&gt;
&lt;br /&gt;
	 # Cabeceras primero&lt;br /&gt;
	 msg[&amp;#039;From&amp;#039;]=de&lt;br /&gt;
	 if isinstance(para,basestring): para=[para]&lt;br /&gt;
	 msg[&amp;#039;To&amp;#039;]=&amp;quot;, &amp;quot;.join(para)&lt;br /&gt;
	 if cc:&lt;br /&gt;
		  if isinstance(cc,basestring): cc=[cc]&lt;br /&gt;
		  msg[&amp;#039;Cc&amp;#039;]=&amp;quot;, &amp;quot;.join(cc)&lt;br /&gt;
		  para.extend(cc)&lt;br /&gt;
	 msg[&amp;#039;Subject&amp;#039;]=asunto&lt;br /&gt;
&lt;br /&gt;
	 for archivo in archivos:&lt;br /&gt;
		  ctype, encoding = mimetypes.guess_type(archivo)&lt;br /&gt;
		  if ctype is None or encoding is not None:&lt;br /&gt;
				ctype = &amp;#039;application/octet-stream&amp;#039;&lt;br /&gt;
		  maintype, subtype = ctype.split(&amp;#039;/&amp;#039;, 1)&lt;br /&gt;
		  if maintype == &amp;#039;text&amp;#039;:&lt;br /&gt;
				msgparte = MIMEText(file(archivo).read(), _subtype=subtype)&lt;br /&gt;
		  else:&lt;br /&gt;
				msgparte = MIMEBase(maintype, subtype)&lt;br /&gt;
				msgparte.add_payload(file(archivo,&amp;quot;rb&amp;quot;).read())&lt;br /&gt;
				# Encode the payload using Base64&lt;br /&gt;
				Encoders.encode_base64(msgparte)&lt;br /&gt;
		  msgparte.add_header(&amp;#039;Content-Disposition&amp;#039;, &amp;#039;attachment&amp;#039;, &lt;br /&gt;
		  filename=os.path.basename(archivo))&lt;br /&gt;
		  msg.attach(msgparte)&lt;br /&gt;
&lt;br /&gt;
	 if not host:&lt;br /&gt;
		  return msg.as_string(0)&lt;br /&gt;
	 s=SMTP(host)&lt;br /&gt;
	 if loginUsername and loginPassword:&lt;br /&gt;
		  s.login(loginUserName,loginPassword)&lt;br /&gt;
	 x=s.sendmail(de,para, msg.as_string(0))&lt;br /&gt;
	 s.quit()&lt;br /&gt;
	 return x&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def conectarBD():&lt;br /&gt;
	 &amp;quot;&amp;quot;&amp;quot;Rutina de conexion a la BBDD&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	 try:&lt;br /&gt;
		  db = MySQLdb.Connect(host=myhost,user=myuser,passwd=mypassword,db=mydb)&lt;br /&gt;
		  return db&lt;br /&gt;
	 except:&lt;br /&gt;
		  print u&amp;quot;Error en la conexion a la Base de Datos&amp;quot;&lt;br /&gt;
		  return -1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def insertarHeadLines(datos):&lt;br /&gt;
	 &amp;quot;&amp;quot;&amp;quot;Funcion para insertar los enlaces en mysql&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	 conn = conectarBD()&lt;br /&gt;
	 c	 = conn.cursor()&lt;br /&gt;
&lt;br /&gt;
	 if (conn != -1):&lt;br /&gt;
		  try:&lt;br /&gt;
			&amp;quot;&amp;quot;&amp;quot;Insertamos los links&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
			for headline in datos:&lt;br /&gt;
				 try:&lt;br /&gt;
					  titulo_noticia = headline[0].decode(&amp;#039;utf8&amp;#039;).encode(&amp;#039;latin1&amp;#039;)&lt;br /&gt;
					  enlace_noticia = headline[1]&lt;br /&gt;
					  c.execute(&amp;#039;&amp;#039;&amp;#039;INSERT INTO mytb (headline, url) VALUES (&amp;#039;s&amp;#039;)&amp;#039;&amp;#039;&amp;#039; % ( titulo_noticia, enlace_noticia ))&lt;br /&gt;
						  referencia_noticia = &amp;#039;Acaba de ser a adida la siguiente noticia:&lt;br /&gt;
							&amp;#039;+titulo_noticia+&amp;#039;&lt;br /&gt;
&lt;br /&gt;
							Pueden leer la noticia completa en el siguiente enlace:&lt;br /&gt;
							&amp;#039;+enlace_noticia&lt;br /&gt;
							referencia_noticia = referencia_noticia.decode(&amp;#039;utf8&amp;#039;).encode(&amp;#039;latin1&amp;#039;)&lt;br /&gt;
						  if enviar_correo == 1:&lt;br /&gt;
								sendMessage(de=remitente,para=destinatario,asunto=subject,&lt;br /&gt;
								texto=referencia_noticia,host=&amp;quot;localhost&amp;quot;)&lt;br /&gt;
				except:&lt;br /&gt;
					  pass&lt;br /&gt;
					  ## print u&amp;#039;Enlace repetido&amp;#039;&lt;br /&gt;
		  		except:&lt;br /&gt;
					  print u&amp;#039;Problemas al realizar los INSERT&amp;#039;&lt;br /&gt;
					  return -1&lt;br /&gt;
def main():&lt;br /&gt;
	 &amp;quot;&amp;quot;&amp;quot;LLamada a las distintas funciones para conseguir los objetivos del programa&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	 source = urllib2.urlopen(headlines_url).read()&lt;br /&gt;
	 parser = [[Main_HeadlinesParser|HeadlinesParser]]()&lt;br /&gt;
	 parser.feed(source)&lt;br /&gt;
&lt;br /&gt;
	 lineas = parser.headlines.items()&lt;br /&gt;
&lt;br /&gt;
	 try:&lt;br /&gt;
		  insertar[[Main_HeadLines|HeadLines]](lineas)&lt;br /&gt;
	 except:&lt;br /&gt;
		  print u&amp;#039;Problemas al insertar los enlaces.&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
	 main()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;hr /&amp;gt;&lt;br /&gt;
Second script: Parse Documentation Page&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
# -*- coding: latin1 -*-&lt;br /&gt;
&lt;br /&gt;
###########################################################################&lt;br /&gt;
#	 Copyright (C) 2005 by Alexandro Colorado &amp;amp;&amp;amp; Luis Cabrera&lt;br /&gt;
#&lt;br /&gt;
#	 Author:&lt;br /&gt;
#		  Alexandro Colorado &amp;lt;jza@openoffice.org&amp;gt;&lt;br /&gt;
#		  Luis Cabrera &amp;lt;lcabrera@sauco.org&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Copyright: See COPYING file that comes with this distribution&lt;br /&gt;
#&lt;br /&gt;
###########################################################################&lt;br /&gt;
&lt;br /&gt;
__shell_usage__ = &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
__version__ = &amp;#039;20051030&amp;#039;&lt;br /&gt;
__author__=&amp;#039;Luis Cabrera Sauco&amp;#039;&lt;br /&gt;
&lt;br /&gt;
import HTMLParser&lt;br /&gt;
import urllib2&lt;br /&gt;
&lt;br /&gt;
headlines_url = &amp;#039;http://es.openoffice.org/servlets/ProjectDocumentList?folderID=276&amp;amp;expandFolder=276&amp;amp;folderID=0&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class HeadlinesParser(HTMLParser.HTMLParser):&lt;br /&gt;
	 def __init__(self):&lt;br /&gt;
		  HTMLParser.HTMLParser.__init__(self)&lt;br /&gt;
		  self.headlines = {}&lt;br /&gt;
		  self.while_anchor = False&lt;br /&gt;
		  self.last_href = None&lt;br /&gt;
		  self.mysearch = &amp;#039;ProjectDocumentList&amp;#039;&lt;br /&gt;
&lt;br /&gt;
	 def handle_starttag(self, name, attrs):&lt;br /&gt;
		  attrs = dict(attrs)&lt;br /&gt;
		  if name == &amp;quot;a&amp;quot;:&lt;br /&gt;
				if &amp;quot;href&amp;quot; in attrs:&lt;br /&gt;
					 current_href = attrs[&amp;quot;href&amp;quot;]&lt;br /&gt;
					 if self.mysearch in current_href:&lt;br /&gt;
						  self.while_anchor = True&lt;br /&gt;
						  self.last_href = current_href&lt;br /&gt;
&lt;br /&gt;
	 def handle_data(self, content):&lt;br /&gt;
		  content = content.strip()&lt;br /&gt;
		  if self.while_anchor:&lt;br /&gt;
				self.headlines[content] = self.last_href&lt;br /&gt;
&lt;br /&gt;
	 def handle_endtag(self, name):&lt;br /&gt;
		  if name == &amp;quot;a&amp;quot;:&lt;br /&gt;
				self.while_anchor = False&lt;br /&gt;
&lt;br /&gt;
def main():&lt;br /&gt;
	 source = urllib2.urlopen(headlines_url).read()&lt;br /&gt;
	 parser = HeadlinesParser()&lt;br /&gt;
	 parser.feed(source)&lt;br /&gt;
&lt;br /&gt;
	 for headline in parser.headlines.items():&lt;br /&gt;
		  # print &amp;#039;&amp;#039;&amp;#039;insert into &amp;quot;Headlines&amp;quot; values (&amp;#039;s&amp;#039;);&amp;#039;&amp;#039;&amp;#039; % headline&lt;br /&gt;
		  urldoc = headline[1].decode(&amp;#039;utf8&amp;#039;).encode(&amp;#039;latin1&amp;#039;)&lt;br /&gt;
		  docsource = urllib2.urlopen(urldoc).read()&lt;br /&gt;
		  docparser = HeadlinesParser()&lt;br /&gt;
		  docparser.mysearch = &amp;#039;documents&amp;#039;&lt;br /&gt;
		  docparser.feed(docsource)&lt;br /&gt;
&lt;br /&gt;
		  for datos in docparser.headlines.items():&lt;br /&gt;
				print &amp;#039;&amp;#039;&amp;#039;insert into &amp;quot;Headlines&amp;quot; values (&amp;#039;s&amp;#039;,&amp;#039; (headline[0],datos[0].decode(&amp;#039;utf8&amp;#039;).encode(&amp;#039;latin1&amp;#039;),datos[1].decode(&amp;#039;utf8&amp;#039;).encode(&amp;#039;latin1&amp;#039;))&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
	 main()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- AlexandroColorado - 23 Oct 2005&amp;lt;br /&amp;gt;&lt;br /&gt;
-- LuisCabreraSauco - 02 Nov 2005&lt;br /&gt;
[[Category:NLC]] [[Category:OOoES]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/WritingUNO/Disable_Commands&amp;diff=164395</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=164395"/>
		<updated>2010-04-17T00:32:39Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &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;
{{Documentation/DevGuideLanguages|Documentation/DevGuide/WritingUNO/{{SUBPAGENAME}}}}&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;
          &amp;quot;Open&amp;quot;,&lt;br /&gt;
          &amp;quot;About&amp;quot;,&lt;br /&gt;
          &amp;quot;SelectAll&amp;quot;,&lt;br /&gt;
          &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 = &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 = &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 = { };&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 = &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>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Spreadsheets/Function_Handling&amp;diff=164394</id>
		<title>Documentation/DevGuide/Spreadsheets/Function Handling</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Spreadsheets/Function_Handling&amp;diff=164394"/>
		<updated>2010-04-17T00:31:54Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/SpreadsheetsTOC&lt;br /&gt;
|SpreadsheetDocs2d=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Spreadsheets/Overall Document Features&lt;br /&gt;
|NextPage=Documentation/DevGuide/Spreadsheets/Settings&lt;br /&gt;
}}&lt;br /&gt;
{{Documentation/DevGuideLanguages|Documentation/DevGuide/Spreadsheets/{{SUBPAGENAME}}}} &lt;br /&gt;
 {{DISPLAYTITLE:Function Handling}}&lt;br /&gt;
This section describes the services which handle spreadsheet functions.&lt;br /&gt;
&lt;br /&gt;
=== Calculating Function Results ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.sheet.FunctionAccess&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The &amp;lt;idl&amp;gt;com.sun.star.sheet.FunctionAccess&amp;lt;/idl&amp;gt; service calls any spreadsheet function and gets its result without having to insert a formula into a spreadsheet document.&lt;br /&gt;
&lt;br /&gt;
[[Image:FunctionHandlingUML1.png|none|thumb|400px|FunctionAccess]]&lt;br /&gt;
&lt;br /&gt;
The service can be instantiated through the service manager. The &amp;lt;idl&amp;gt;com.sun.star.sheet.XFunctionAccess&amp;lt;/idl&amp;gt; interface contains only one method, &amp;lt;code&amp;gt;callFunction()&amp;lt;/code&amp;gt;. The first parameter is the name of the function to call. The name has to be the function&amp;#039;s programmatic name.&lt;br /&gt;
&lt;br /&gt;
* For a built-in function, the English name is always used, regardless of the application&amp;#039;s UI language.&lt;br /&gt;
* For an add-in function, the complete internal name that is the add-in component&amp;#039;s service name, followed by a dot and the function&amp;#039;s name as defined in the interface. For the &amp;lt;code&amp;gt;getIncremented&amp;lt;/code&amp;gt; function in the example from the add-in section, this would be: &amp;quot;&amp;lt;code&amp;gt;com.sun.star.sheet.addin.ExampleAddIn.getIncremented&amp;lt;/code&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The second parameter to &amp;lt;code&amp;gt;callFunction()&amp;lt;/code&amp;gt; is a sequence containing the function arguments. The supported types for each argument are described in the &amp;lt;idl&amp;gt;com.sun.star.sheet.XFunctionAccess&amp;lt;/idl&amp;gt; interface description, and are similar to the argument types for add-in functions. The following example passes two arguments to the &amp;lt;code&amp;gt;ZTEST&amp;lt;/code&amp;gt; function, an array of values and a single value. &lt;br /&gt;
&amp;lt;!--[SOURCE:Spreadsheet/SpreadsheetSample.java]--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;// --- Calculate a function ---&lt;br /&gt;
  Object aFuncInst = xServiceManager.createInstance(&amp;quot;com.sun.star.sheet.FunctionAccess&amp;quot;);&lt;br /&gt;
  com.sun.star.sheet.XFunctionAccess xFuncAcc = (com.sun.star.sheet.XFunctionAccess)&lt;br /&gt;
      UnoRuntime.queryInterface(com.sun.star.sheet.XFunctionAccess.class, aFuncInst);&lt;br /&gt;
  // put the data into a two-dimensional array&lt;br /&gt;
  double[][] aData = {{1.0, 2.0, 3.0}};&lt;br /&gt;
  // construct the array of function arguments&lt;br /&gt;
  Object[] aArgs = { aData, new Double( 2.0 ) };&lt;br /&gt;
  Object aResult = xFuncAcc.callFunction(&amp;quot;ZTEST&amp;quot;, aArgs);&lt;br /&gt;
  System.out.println(&amp;quot;ZTEST result for data {1,2,3} and value 2 is &amp;quot;&lt;br /&gt;
      + ((Double)aResult).doubleValue()); &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Calc, an argument of the function may accept a range of cells, e.g &amp;lt;code&amp;gt;=SUM(B12:G55)&amp;lt;/code&amp;gt;. When calling a spreadsheet function, a range argument is transmitted as an array with two dimensions. The first corresponds to the row, the second corresponds to the column, indexes are zero-based.&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|The implementation of &amp;lt;idl&amp;gt;com.sun.star.sheet.FunctionAccess&amp;lt;/idl&amp;gt; uses the same internal structures as a spreadsheet document, therefore it is bound by the same limitations, such as the limit of 65536 rows and 1024 columns for the function arguments.}}&lt;br /&gt;
&lt;br /&gt;
=== Information about Functions ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.sheet.FunctionDescription;com.sun.star.sheet.FunctionDescriptions&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The services &amp;lt;idl&amp;gt;com.sun.star.sheet.FunctionDescriptions&amp;lt;/idl&amp;gt; and &amp;lt;idl&amp;gt;com.sun.star.sheet.FunctionDescription&amp;lt;/idl&amp;gt; provide help texts about the available spreadsheet cell functions, including add-in functions and their arguments. This is the same information that {{PRODUCTNAME}} API Calc displays in the function AutoPilot.&lt;br /&gt;
&lt;br /&gt;
[[Image:FunctionHandlingUML2.png|none|thumb|400px|FunctionDescriptions]]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;idl&amp;gt;com.sun.star.sheet.FunctionDescriptions&amp;lt;/idl&amp;gt; service is instantiated through the service manager. It provides three different methods to access the information for the different functions:&lt;br /&gt;
&lt;br /&gt;
* By name through the &amp;lt;idl&amp;gt;com.sun.star.container.XNameAccess&amp;lt;/idl&amp;gt; interface.&lt;br /&gt;
* By index through the &amp;lt;idl&amp;gt;com.sun.star.container.XIndexAccess&amp;lt;/idl&amp;gt; interface.&lt;br /&gt;
* By function identifier through the &amp;lt;idl&amp;gt;com.sun.star.sheet.XFunctionDescriptions&amp;lt;/idl&amp;gt; interface&amp;#039;s &amp;lt;code&amp;gt;getById()&amp;lt;/code&amp;gt; method. The function identifier is the same used in the &amp;lt;idl&amp;gt;com.sun.star.sheet.RecentFunctions&amp;lt;/idl&amp;gt; service.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;idl&amp;gt;com.sun.star.sheet.FunctionDescription&amp;lt;/idl&amp;gt; that is returned by any of these calls is a sequence of &amp;lt;idl&amp;gt;com.sun.star.beans.PropertyValue&amp;lt;/idl&amp;gt; structs. To access one of these properties, loop through the sequence, looking for the desired property&amp;#039;s name in the Name member. The Arguments property contains a sequence of &amp;lt;idl&amp;gt;com.sun.star.sheet.FunctionArgument&amp;lt;/idl&amp;gt; structs, one for each argument that the function accepts. The struct contains the name and description of the argument, as well as a boolean flag showing if the argument is optional.&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|All of the strings contained in the &amp;lt;idl&amp;gt;com.sun.star.sheet.FunctionDescription&amp;lt;/idl&amp;gt; service are to be used in user interaction, and therefore translated to the application&amp;#039;s UI language. They cannot be used where programmatic function names are expected, for example, the &amp;lt;idl&amp;gt;com.sun.star.sheet.FunctionAccess&amp;lt;/idl&amp;gt; service.}}&lt;br /&gt;
&lt;br /&gt;
The Recently Used Functions section below provides an example on how to use the &amp;lt;idl&amp;gt;com.sun.star.sheet.FunctionDescriptions&amp;lt;/idl&amp;gt; service.&lt;br /&gt;
&lt;br /&gt;
=== Recently Used Functions ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.sheet.RecentFunctions&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
The &amp;lt;idl&amp;gt;com.sun.star.sheet.RecentFunctions&amp;lt;/idl&amp;gt; service provides access to the list of recently used functions of the spreadsheet application, that is displayed in the &amp;#039;&amp;#039;&amp;#039;AutoPilot:Functions&amp;#039;&amp;#039;&amp;#039; and the &amp;#039;&amp;#039;&amp;#039;Function List&amp;#039;&amp;#039;&amp;#039; window for example.&lt;br /&gt;
&lt;br /&gt;
[[Image:FunctionHandlingUML3.png|none|thumb|400px|RecentFunctions]]&lt;br /&gt;
&lt;br /&gt;
The service can be instantiated through the service manager. The &amp;lt;idl&amp;gt;com.sun.star.sheet.XRecentFunctions&amp;lt;/idl&amp;gt; interface&amp;#039;s &amp;lt;code&amp;gt;getRecentFunctionIds()&amp;lt;/code&amp;gt; method returns a sequence of function identifiers that are used with the &amp;lt;idl&amp;gt;com.sun.star.sheet.FunctionDescriptions&amp;lt;/idl&amp;gt; service. The &amp;lt;code&amp;gt;setRecentFunctionIds()&amp;lt;/code&amp;gt; method changes the list. If the parameter to the &amp;lt;code&amp;gt;setRecentFunctionIds()&amp;lt;/code&amp;gt; call contains more entries than the application handles, only the first entries are used. The maximum size of the list of recently used functions, currently 10, can be queried with the &amp;lt;code&amp;gt;getMaxRecentFunctions()&amp;lt;/code&amp;gt; method.&lt;br /&gt;
&lt;br /&gt;
The following example demonstrates the use of the &amp;lt;idl&amp;gt;com.sun.star.sheet.RecentFunctions&amp;lt;/idl&amp;gt; and &amp;lt;idl&amp;gt;com.sun.star.sheet.FunctionDescriptions&amp;lt;/idl&amp;gt; services. &lt;br /&gt;
&amp;lt;!--[SOURCE:Spreadsheet/SpreadsheetSample.java]--&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  // --- Get the list of recently used functions ---&lt;br /&gt;
  Object aRecInst = xServiceManager.createInstance(&amp;quot;com.sun.star.sheet.RecentFunctions&amp;quot;);&lt;br /&gt;
  com.sun.star.sheet.XRecentFunctions xRecFunc = (com.sun.star.sheet.XRecentFunctions)&lt;br /&gt;
      UnoRuntime.queryInterface(com.sun.star.sheet.XRecentFunctions.class, aRecInst);&lt;br /&gt;
  int[] nRecentIds = xRecFunc.getRecentFunctionIds();&lt;br /&gt;
  &lt;br /&gt;
  // --- Get the names for these functions ---&lt;br /&gt;
  Object aDescInst = xServiceManager.createInstance(&amp;quot;com.sun.star.sheet.FunctionDescriptions&amp;quot;);&lt;br /&gt;
  com.sun.star.sheet.XFunctionDescriptions xFuncDesc = (com.sun.star.sheet.XFunctionDescriptions)&lt;br /&gt;
      UnoRuntime.queryInterface(com.sun.star.sheet.XFunctionDescriptions.class, aDescInst);&lt;br /&gt;
  System.out.print(&amp;quot;Recently used functions: &amp;quot;);&lt;br /&gt;
  for (int nFunction=0; nFunction&amp;lt;nRecentIds.length; nFunction++) {&lt;br /&gt;
      com.sun.star.beans.PropertyValue[] aProperties = xFuncDesc.getById(nRecentIds[nFunction]);&lt;br /&gt;
      for (int nProp=0; nProp&amp;lt;aProperties.length; nProp++)&lt;br /&gt;
          if (aProperties[nProp].Name.equals(&amp;quot;Name&amp;quot;))&lt;br /&gt;
              System.out.print(aProperties[nProp].Value + &amp;quot; &amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  System.out.println(); &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/Spreadsheet Documents]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=General_UNO_Component_Project_Type&amp;diff=160758</id>
		<title>General UNO Component Project Type</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=General_UNO_Component_Project_Type&amp;diff=160758"/>
		<updated>2010-03-28T04:25:10Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[OpenOffice_NetBeans_Integration|OpenOffice.org NetBeans Integration]]&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The OpenOffice.org Component wizard creates a new project based on a J2SE class library project and supports additional targets to create a complete OpenOffice.org extension package and to deploy this package into the configured OpenOffice.org installation.&amp;lt;br&amp;gt;&lt;br /&gt;
The wizard collects all necessary information and allows you to select the existing services and interfaces that should be implemented. In the same wizard step you can also define completely new services and interfaces (and additional data types based on IDL) to design abstract interfaces for completely new functionality.&amp;lt;br&amp;gt;&lt;br /&gt;
After finishing the wizard you can directly build the project and can create and deploy the OpenOffice.org extension package. All interface methods are implemented by default, and do nothing. In a second step you can insert your implementation in the generated skeleton, rebuild the extension and deploy it again to see the effect.&lt;br /&gt;
&lt;br /&gt;
= Project Wizard =&lt;br /&gt;
The project wizard is quite simple to use, you simply choose&lt;br /&gt;
*&amp;#039;&amp;#039; &amp;#039;&amp;#039;&amp;#039;File -&amp;gt; New Project -&amp;gt; OpenOffice.org -&amp;gt; OpenOffice.org Component&amp;#039;&amp;#039;&amp;#039; &amp;#039;&amp;#039;&lt;br /&gt;
and follow the wizard.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Step 1&amp;#039;&amp;#039;&amp;#039;: Select the project type&lt;br /&gt;
&amp;lt;br&amp;gt;[[Image:Component1.png|center]]&amp;lt;br&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Step 2&amp;#039;&amp;#039;&amp;#039;: Define the project name, implementation class name, an package and the project location &lt;br /&gt;
&amp;lt;br&amp;gt;[[Image:Component2.png|center]]&amp;lt;br&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Step 4&amp;#039;&amp;#039;&amp;#039;: Specifiy or define the UNO IDL services and interfaces which should be implemented.&lt;br /&gt;
** To provide an own defined interface, choose the &amp;#039;&amp;#039;&amp;#039;Interface&amp;#039;&amp;#039;&amp;#039; node and click on &amp;#039;&amp;#039;&amp;#039;Define New Data Type&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[Image:Component_Interface1.png|center]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
** Create the interface as shown in this picture&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[Image:Component_Interface.png|center]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
** Back at the New Project window, select the &amp;#039;&amp;#039;&amp;#039;Service&amp;#039;&amp;#039;&amp;#039; node and click again on &amp;#039;&amp;#039;&amp;#039;Define New Data Type&amp;#039;&amp;#039;&amp;#039;. Create the service as follows:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[Image:Component_Service.png|center]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
** Back at the New Project window, click on &amp;#039;&amp;#039;&amp;#039;Add Service/Interface&amp;#039;&amp;#039;&amp;#039;. Select the new created service. The interface will be added automatically:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[Image:Component_TypeBrowser.png|center]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
** When everything looks like this, click &amp;#039;&amp;#039;&amp;#039;OK&amp;#039;&amp;#039;&amp;#039;:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[Image:Component3.png|center]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can simply create or deploy the &amp;#039;&amp;#039;&amp;#039;oxt&amp;#039;&amp;#039;&amp;#039; extension package by choosing:&amp;lt;br&amp;gt;&lt;br /&gt;
::&amp;#039;&amp;#039;&amp;#039;Project View -&amp;gt; Project Node -&amp;gt; Context Menu -&amp;gt; Deploy and Run Extension in OpenOffice.org&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you have deployed the package, the usage of the new UNO component in OpenOffice.org is straight forward. Either you have implemented a special service provider interface (SPI) and can use it in the same way as any other implementations of this SPI can be used, or you have defined some new service and/or interfaces and can instantiate your component as a normal service over the global service manager.&lt;br /&gt;
&lt;br /&gt;
= Generated Code =&lt;br /&gt;
The wizard generates more code for a UNO component, but it depends on the selected UNO IDL types. If only existing types are selected and no new UNO IDL types are defined, the wizard will not generate any UNO IDL files.  For the example shown above, the following files are generated:&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;uno-extension-manifest.xml&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt;the package descriptor, will be packed as &amp;amp;quot;META-INF/manifest.xml&amp;amp;quot;. The content of the uno-extension-manifest.xml depends on the selection or definition of the IDL types. If no new types are defined, no type library is specified. Own IDL types are packed in an additional jar referenced here. Without new IDL types, this jar will also not exist.&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;manifest:manifest xmlns:manifest=&amp;quot;http://openoffice.org/2001/manifest&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;application/vnd.sun.star.uno-typelibrary;type=RDB&amp;quot;&lt;br /&gt;
                       manifest:full-path=&amp;quot;types.rdb&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;application/vnd.sun.star.uno-component;type=Java&amp;quot;&lt;br /&gt;
                       manifest:full-path=&amp;quot;TestComponent.jar&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;application/vnd.sun.star.uno-typelibrary;type=Java&amp;quot;&lt;br /&gt;
                       manifest:full-path=&amp;quot;TestComponent_IDL_types.jar&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/manifest:manifest&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;org/openoffice/test/MyTestService.idl&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt;the test service definition&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * MyTestService.idl&lt;br /&gt;
 *&lt;br /&gt;
 * Created on 11.09.2006 - 17:42:17&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
#ifndef _org_openoffice_test_MyTestService_&lt;br /&gt;
#define _org_openoffice_test_MyTestService_&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;XMyTest.idl&amp;quot;&lt;br /&gt;
&lt;br /&gt;
module org { module openoffice { module test {&lt;br /&gt;
    service MyTestService : XMyTest;&lt;br /&gt;
}; }; };&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;org/openoffice/test/XMyTest.idl&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt;the test interface definition&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * XMyTest.idl&lt;br /&gt;
 *&lt;br /&gt;
 * Created on 11.09.2006 - 17:42:17&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
#ifndef _org_openoffice_test_XMyTest_&lt;br /&gt;
#define _org_openoffice_test_XMyTest_&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;com/sun/star/uno/XInterface.idl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
module org { module openoffice { module test {&lt;br /&gt;
    interface XMyTest {&lt;br /&gt;
&lt;br /&gt;
        string helloWorld([in] string sMessage);&lt;br /&gt;
            raises ( com::sun::star::lang::IllegalArgumentException );&lt;br /&gt;
    };&lt;br /&gt;
}; }; };&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;org/openoffice/test/TestComponentImpl.java&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt;the generated code skeleton where all selected services and interface are implemented by defualt plus some UNO component base interfaces, so that the newly generated project can be built and the extension can be deployed directly.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
package org.openoffice.test;&lt;br /&gt;
&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.lib.uno.helper.Factory;&lt;br /&gt;
import com.sun.star.lang.XSingleComponentFactory;&lt;br /&gt;
import com.sun.star.registry.XRegistryKey;&lt;br /&gt;
import com.sun.star.lib.uno.helper.WeakBase;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public final class TestComponentImpl extends WeakBase&lt;br /&gt;
   implements com.sun.star.lang.XServiceInfo,&lt;br /&gt;
              org.openoffice.test.XMyTest&lt;br /&gt;
{&lt;br /&gt;
    private final XComponentContext m_xContext;&lt;br /&gt;
    private static final String m_implementationName = TestComponentImpl.class.getName();&lt;br /&gt;
    private static final String[] m_serviceNames = {&lt;br /&gt;
        &amp;quot;org.openoffice.test.MyTestService&amp;quot; };&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    public TestComponentImpl( XComponentContext context )&lt;br /&gt;
    {&lt;br /&gt;
        m_xContext = context;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public static XSingleComponentFactory __getComponentFactory(String sImplementationName ) {&lt;br /&gt;
        XSingleComponentFactory xFactory = null;&lt;br /&gt;
&lt;br /&gt;
        if ( sImplementationName.equals( m_implementationName ) )&lt;br /&gt;
            xFactory = Factory.createComponentFactory(TestComponentImpl.class, m_serviceNames);&lt;br /&gt;
        return xFactory;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public static boolean __writeRegistryServiceInfo(XRegistryKey xRegistryKey ) {&lt;br /&gt;
        return Factory.writeRegistryServiceInfo(m_implementationName,&lt;br /&gt;
                                                m_serviceNames,&lt;br /&gt;
                                                xRegistryKey);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // com.sun.star.lang.XServiceInfo:&lt;br /&gt;
    public String getImplementationName() {&lt;br /&gt;
         return m_implementationName;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public boolean supportsService( String sService ) {&lt;br /&gt;
        int len = m_serviceNames.length;&lt;br /&gt;
&lt;br /&gt;
        for( int i=0; i &amp;lt; len; i++) {&lt;br /&gt;
            if (sService.equals(m_serviceNames[i]))&lt;br /&gt;
                return true;&lt;br /&gt;
        }&lt;br /&gt;
        return false;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public String[] getSupportedServiceNames() {&lt;br /&gt;
        return m_serviceNames;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // org.openoffice.test.XMyTest:&lt;br /&gt;
    public String helloWorld(String sMessage) throws com.sun.star.lang.IllegalArgumentException&lt;br /&gt;
    {&lt;br /&gt;
        // TODO !!!&lt;br /&gt;
        // Exchange the default return implementation.&lt;br /&gt;
        // NOTE: Default initialized polymorphic structs can cause problems&lt;br /&gt;
        // because of missing default initialization of primitive types of&lt;br /&gt;
        // some C++ compilers or different Any initialization in Java and C++&lt;br /&gt;
        // polymorphic structs.&lt;br /&gt;
        return &amp;quot;&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Result Use Example : OOoBasic Macro Call =&lt;br /&gt;
&lt;br /&gt;
For using the previous skeleton for an OOoBasic service call, we only have to alter the last method helloWorld and redeploy the oxt extension&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
    // org.openoffice.test.XMyTest:&lt;br /&gt;
    public String helloWorld(String message)&lt;br /&gt;
    {&lt;br /&gt;
        String response = &amp;quot;Hello &amp;quot; + message;   &lt;br /&gt;
        return response;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, opening a new OpenOffice.org, your component is available for any macro you may need. It is seen as any legacy service and is manipulated the same way. Even introspection is available, letting you verify that all your properties and methods are available, as the xRay call can show.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
sub TestHelloWorld()&lt;br /&gt;
	&amp;#039; Create the new UNO service&lt;br /&gt;
	myService = createUNOService(&amp;quot;org.openoffice.test.MyTestService&amp;quot;)&lt;br /&gt;
	&amp;#039; The new service with its properties &amp;amp; methods is available&lt;br /&gt;
	msgbox myService.helloWorld (&amp;quot;Laurent&amp;quot;)&lt;br /&gt;
	&amp;#039; It is also available through Xray introspection&lt;br /&gt;
	xRay myService&lt;br /&gt;
end sub&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:hello_testing_netbeans.png|center]]&lt;br /&gt;
| [[Image:xray_helloworld_netbeans.png|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= See also =&lt;br /&gt;
* Daniel Bölzle&amp;#039;s tutorial : [[Uno/Cpp/Tutorials/component_tutorial|Writing a simple UNO component]]&lt;br /&gt;
* [[Documentation/DevGuide/WritingUNO/Writing_UNO_Components|Writing UNO Components]] in Developer&amp;#039;s Guide&lt;br /&gt;
* [[Constructing_Components|Constructing Components in C++]]&lt;br /&gt;
* [[Extensions_Packager|Extensions Packager]] (BasicAddonBuilder from [mailto:paolomantovani@openoffice.org Paolo Mantovani])&lt;br /&gt;
* [[BASIC/UNO_Object_Browser|BASIC UNO Object Browser]] : You can see the corresponding code as a complex component.&lt;br /&gt;
* [[API/Samples/Java/Office/MinimalComponent|Minimal Java Component]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Uno]]&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Extensions]]&lt;br /&gt;
[[Category:API]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Scripting/Writing_Macros&amp;diff=160670</id>
		<title>Documentation/DevGuide/Scripting/Writing Macros</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Scripting/Writing_Macros&amp;diff=160670"/>
		<updated>2010-03-27T06:09:39Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/ScriptingTOC&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Scripting/Macro Recording&lt;br /&gt;
|NextPage=Documentation/DevGuide/Scripting/How the Scripting Framework Works&lt;br /&gt;
}}&lt;br /&gt;
{{Documentation/DevGuideLanguages|Documentation/DevGuide/Scripting/{{SUBPAGENAME}}}} &lt;br /&gt;
 {{DISPLAYTITLE:Writing Macros}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
=== The HelloWorld macro ===&lt;br /&gt;
&lt;br /&gt;
When the user creates a new macro in BeanShell or JavaScript, the default content of the macro is the HelloWorld. Here is what the code looks like for BeanShell:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  import com.sun.star.uno.UnoRuntime;&lt;br /&gt;
  &lt;br /&gt;
  import com.sun.star.text.XTextDocument;&lt;br /&gt;
  import com.sun.star.text.XText;&lt;br /&gt;
  import com.sun.star.text.XTextRange;&lt;br /&gt;
  &lt;br /&gt;
  oDoc = XSCRIPTCONTEXT.getDocument();&lt;br /&gt;
  xTextDoc = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class,oDoc);&lt;br /&gt;
  xText = xTextDoc.getText();&lt;br /&gt;
  xTextRange = xText.getEnd();&lt;br /&gt;
  xTextRange.setString( &amp;quot;Hello World (in BeanShell)&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
  // BeanShell OpenOffice.org scripts should always return 0&lt;br /&gt;
  return 0;&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As BeanShell accepts typeless variables, the queryInterface instructions can be simplified.&lt;br /&gt;
&lt;br /&gt;
Like OpenOffice.org Basic, BeanShell interprets pairs of get and set methods at UNO objects as object properties if they follow this pattern:&lt;br /&gt;
&lt;br /&gt;
  SomeType getSomeProperty()&lt;br /&gt;
  void setSomeProperty(SomeType aValue)&lt;br /&gt;
&lt;br /&gt;
Using these facilities the above example can be simplified:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  import com.sun.star.uno.UnoRuntime;&lt;br /&gt;
  &lt;br /&gt;
  import com.sun.star.text.XTextDocument;&lt;br /&gt;
  import com.sun.star.text.XText;&lt;br /&gt;
  import com.sun.star.text.XTextRange;&lt;br /&gt;
  &lt;br /&gt;
  oDoc = XSCRIPTCONTEXT.Document;&lt;br /&gt;
  xTextDoc = UnoRuntime.queryInterface(XTextDocument.class,oDoc);&lt;br /&gt;
  xText = xTextDoc.Text;&lt;br /&gt;
  xTextRange = xText.End;&lt;br /&gt;
  xTextRange.String = &amp;quot;Hello World (in BeanShell)&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  // BeanShell OpenOffice.org scripts should always return 0&lt;br /&gt;
  return 0;&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is the same code in JavaScript:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  importClass(Packages.com.sun.star.uno.UnoRuntime);&lt;br /&gt;
  importClass(Packages.com.sun.star.text.XTextDocument);&lt;br /&gt;
  importClass(Packages.com.sun.star.text.XText);&lt;br /&gt;
  importClass(Packages.com.sun.star.text.XTextRange);&lt;br /&gt;
  &lt;br /&gt;
  oDoc = XSCRIPTCONTEXT.getDocument();&lt;br /&gt;
  xTextDoc = UnoRuntime.queryInterface(XTextDocument,oDoc);&lt;br /&gt;
  xText = xTextDoc.getText();&lt;br /&gt;
  xTextRange = xText.getEnd();&lt;br /&gt;
  xTextRange.setString( &amp;quot;Hello World (in JavaScript)&amp;quot; );&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
Here is the code for HelloWorld in Java:&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.frame.XModel;&lt;br /&gt;
  import com.sun.star.text.XTextDocument;&lt;br /&gt;
  import com.sun.star.text.XTextRange;&lt;br /&gt;
  import com.sun.star.text.XText;&lt;br /&gt;
  import com.sun.star.script.provider.XScriptContext;&lt;br /&gt;
  &lt;br /&gt;
  public class HelloWorld {&lt;br /&gt;
      public static void printHW(XScriptContext xScriptContext)&lt;br /&gt;
      {&lt;br /&gt;
          XModel xDocModel = xScriptContext.getDocument();&lt;br /&gt;
    &lt;br /&gt;
          // getting the text document object&lt;br /&gt;
          XTextDocument xtextdocument = (XTextDocument) UnoRuntime.queryInterface(&lt;br /&gt;
              XTextDocument.class, xDocModel);&lt;br /&gt;
      &lt;br /&gt;
          XText xText = xtextdocument.getText();&lt;br /&gt;
          XTextRange xTextRange = xText.getEnd();&lt;br /&gt;
          xTextRange.setString( &amp;quot;Hello World (in Java)&amp;quot; );&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The table below outlines some of the features of macro development in the different languages:&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;
!Language &lt;br /&gt;
!Interpreted &lt;br /&gt;
!Typeless &lt;br /&gt;
!Editor &lt;br /&gt;
!Debugger &lt;br /&gt;
|-&lt;br /&gt;
|BeanShell &lt;br /&gt;
|Yes &lt;br /&gt;
|Yes &lt;br /&gt;
|Yes &lt;br /&gt;
|No &lt;br /&gt;
|-&lt;br /&gt;
|JavaScript &lt;br /&gt;
|Yes &lt;br /&gt;
|Yes &lt;br /&gt;
|Yes &lt;br /&gt;
|Yes &lt;br /&gt;
|-&lt;br /&gt;
|Java &lt;br /&gt;
|No &lt;br /&gt;
|No &lt;br /&gt;
|No &lt;br /&gt;
|No &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|Instructions on compiling and deploying Java macros can be found later in this chapter.}}&lt;br /&gt;
&lt;br /&gt;
=== Using the {{PRODUCTNAME}} API from macros ===&lt;br /&gt;
&lt;br /&gt;
All BeanShell, JavaScript and Java macros are supplied with a variable of type &amp;lt;idl&amp;gt;com.sun.star.script.provider.XScriptContext&amp;lt;/idl&amp;gt; which can be used to access the {{PRODUCTNAME}} API. This type has three methods:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;idl&amp;gt;com.sun.star.frame.XModel&amp;lt;/idl&amp;gt; &amp;lt;code&amp;gt;getDocument( )&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the &amp;lt;code&amp;gt;XModel&amp;lt;/code&amp;gt; interface of the document for which the macro was invoked (see [[Documentation/DevGuide/OfficeDev/Using the Component Framework|Using the Component Framework]])&lt;br /&gt;
* &amp;lt;idl&amp;gt;com.sun.star.frame.XDesktop&amp;lt;/idl&amp;gt; &amp;lt;code&amp;gt;getDesktop( )&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the &amp;lt;code&amp;gt;XDesktop&amp;lt;/code&amp;gt; interface for the application which can be used to access open document, and load documents (see [[Documentation/DevGuide/OfficeDev/Using the Desktop|Using the Desktop]])&lt;br /&gt;
* &amp;lt;idl&amp;gt;com.sun.star.uno.XComponentContext&amp;lt;/idl&amp;gt; &amp;lt;code&amp;gt;getComponentContext( )&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the &amp;lt;code&amp;gt;XComponentContext&amp;lt;/code&amp;gt; interface which is used to create instances of services (see [[Documentation/DevGuide/ProUNO/Service Manager and Component Context|Service Manager and Component Context]])&lt;br /&gt;
&lt;br /&gt;
Depending on the language the macro accesses the &amp;lt;code&amp;gt;XScriptContext&amp;lt;/code&amp;gt; type in different ways:&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;BeanShell&amp;#039;&amp;#039;&amp;#039;: Using the global variable &amp;lt;code&amp;gt;XSCRIPTCONTEXT&amp;lt;/code&amp;gt;&lt;br /&gt;
  oDoc = XSCRIPTCONTEXT.getDocument();&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;JavaScript&amp;#039;&amp;#039;&amp;#039;: Using the global variable &amp;lt;code&amp;gt;XSCRIPTCONTEXT&amp;lt;/code&amp;gt;&lt;br /&gt;
  oDoc = XSCRIPTCONTEXT.getDocument();&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Java&amp;#039;&amp;#039;&amp;#039;: The first parameter passed to the macro method is always of type &amp;lt;code&amp;gt;XScriptContext&amp;lt;/code&amp;gt;&lt;br /&gt;
  Xmodel xDocModel = xScriptContext.getDocument();&lt;br /&gt;
&lt;br /&gt;
=== Handling arguments passed to macros ===&lt;br /&gt;
&lt;br /&gt;
In certain cases arguments may be passed to macros, for example, when a macro is assigned to a button in a document. In this case the arguments are passed to the macro as follows:&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;BeanShell&amp;#039;&amp;#039;&amp;#039;: In the global &amp;lt;code&amp;gt;Object[]&amp;lt;/code&amp;gt; variable &amp;lt;code&amp;gt;ARGUMENTS&amp;lt;/code&amp;gt;&lt;br /&gt;
  event = (ActionEvent) ARGUMENTS[0];&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;JavaScript&amp;#039;&amp;#039;&amp;#039;: In the global &amp;lt;code&amp;gt;Object[]&amp;lt;/code&amp;gt; variable &amp;lt;code&amp;gt;ARGUMENTS&amp;lt;/code&amp;gt;&lt;br /&gt;
  event = ARGUMENTS[0];&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Java&amp;#039;&amp;#039;&amp;#039;: The arguments are passed as an &amp;lt;code&amp;gt;Object[]&amp;lt;/code&amp;gt; in the second parameter to the macro method&lt;br /&gt;
  public void handleButtonPress(&lt;br /&gt;
      XScriptContext xScriptContext, Object[] args)&lt;br /&gt;
&lt;br /&gt;
Each of the arguments in the &amp;lt;code&amp;gt;Object[]&amp;lt;/code&amp;gt; are of the UNO type Any. For more information on how the Any type is used in Java see [[Documentation/DevGuide/ProUNO/Java/Type Mappings|Type Mappings]].&lt;br /&gt;
&lt;br /&gt;
The ButtonPressHandler macros in the Highlight library of a {{PRODUCTNAME}} installation show how a macro can handle arguments.&lt;br /&gt;
&lt;br /&gt;
=== Creating dialogs from macros ===&lt;br /&gt;
&lt;br /&gt;
Dialogs which have been built in the Dialog Editor can be loaded by macros using the &amp;lt;idl&amp;gt;com.sun.star.awt.XDialogProvider&amp;lt;/idl&amp;gt; API. The &amp;lt;code&amp;gt;XDialogProvider&amp;lt;/code&amp;gt; interface has one method &amp;lt;code&amp;gt;createDialog()&amp;lt;/code&amp;gt; which takes a string as a parameter. This string is the URL to the dialog. The URL is formed as follows:&lt;br /&gt;
&lt;br /&gt;
  vnd.sun.star.script:DIALOGREF?location=[application|document]&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;code&amp;gt;DIALOGREF&amp;lt;/code&amp;gt; is the name of the dialog that you want to create, and location is either application or document depending on where the dialog is stored.&lt;br /&gt;
&lt;br /&gt;
For example if you wanted to load dialog called MyDialog, which is in a Dialog Library called MyDialogLibrary in the {{PRODUCTNAME}} dialogs area of your installation then the URL would be:&lt;br /&gt;
&lt;br /&gt;
  vnd.sun.star.script:MyDialogLibrary.MyDialog?location=application&lt;br /&gt;
&lt;br /&gt;
If you wanted to load a dialog called MyDocumentDialog which in a library called MyDocumentLibrary which is located in a document then the URL would be:&lt;br /&gt;
&lt;br /&gt;
  vnd.sun.star.script:MyDocumentLibrary.MyDocumentDialog?location=document&lt;br /&gt;
&lt;br /&gt;
The following code shows how to create a dialog from a Java macro:&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  public XDialog getDialog(XScriptContext context)&lt;br /&gt;
  {&lt;br /&gt;
      XDialog theDialog;&lt;br /&gt;
  &lt;br /&gt;
      // We must pass the XModel of the current document when creating a DialogProvider object&lt;br /&gt;
      Object[] args = { context.getDocument() };&lt;br /&gt;
    &lt;br /&gt;
      Object obj;&lt;br /&gt;
      try {&lt;br /&gt;
          obj = xmcf.createInstanceWithArgumentsAndContext(&lt;br /&gt;
              &amp;quot;com.sun.star.awt.DialogProvider&amp;quot;, args, context.getComponentContext());&lt;br /&gt;
      }&lt;br /&gt;
      catch (com.sun.star.uno.Exception e) {&lt;br /&gt;
          System.err.println(&amp;quot;Error getting DialogProvider object&amp;quot;);&lt;br /&gt;
          return null;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
      XDialogProvider xDialogProvider = (XDialogProvider)&lt;br /&gt;
          UnoRuntime.queryInterface(XDialogProvider.class, obj);&lt;br /&gt;
      &lt;br /&gt;
      // Got DialogProvider, now get dialog &lt;br /&gt;
      try {&lt;br /&gt;
          theDialog = xDialogProvider.createDialog(&lt;br /&gt;
              &amp;quot;vnd.sun.star.script:MyDialogLibrary.MyDialog?location=application&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      catch (java.lang.Exception e) {&lt;br /&gt;
          System.err.println(&amp;quot;Got exception on first creating dialog: &amp;quot; + e.getMessage());&lt;br /&gt;
      }&lt;br /&gt;
      return theDialog;&lt;br /&gt;
  }&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
=== Compiling and Deploying Java macros ===&lt;br /&gt;
&lt;br /&gt;
Because Java is a compiled language it is not possible to execute Java source code as a macro directly from within {{PRODUCTNAME}}. The code must first be compiled and then deployed within a {{PRODUCTNAME}} installation or document. The following steps show how to create a Java macro using the HelloWorld example code:&lt;br /&gt;
&lt;br /&gt;
* Create a &amp;#039;&amp;#039;HelloWorld&amp;#039;&amp;#039; directory for your macro&lt;br /&gt;
* Create a &amp;#039;&amp;#039;HelloWorld.java&amp;#039;&amp;#039; file using the HelloWorld source code&lt;br /&gt;
* Compile the &amp;#039;&amp;#039;HelloWorld.java&amp;#039;&amp;#039; file. The following jar files from the &amp;#039;&amp;#039;program/classes&amp;#039;&amp;#039; directory of a {{PRODUCTNAME}} installation must be in the classpath: &amp;#039;&amp;#039;ridl.jar&amp;#039;&amp;#039;, &amp;#039;&amp;#039;unoil.jar&amp;#039;&amp;#039;, &amp;#039;&amp;#039;jurt.jar&amp;#039;&amp;#039;&lt;br /&gt;
* Create a &amp;#039;&amp;#039;HelloWorld.jar&amp;#039;&amp;#039; file containing the &amp;#039;&amp;#039;HelloWorld.class&amp;#039;&amp;#039; file&lt;br /&gt;
* Create a &amp;#039;&amp;#039;parcel-descriptor.xml&amp;#039;&amp;#039; file for your macro&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;
  &lt;br /&gt;
  &amp;lt;parcel language=&amp;quot;Java&amp;quot; xmlns:parcel=&amp;quot;scripting.dtd&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script language=&amp;quot;Java&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;locale lang=&amp;quot;en&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;displayname value=&amp;quot;HelloWorld&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;description&amp;gt;&lt;br /&gt;
          Prints &amp;quot;Hello World&amp;quot;.&lt;br /&gt;
        &amp;lt;/description&amp;gt;&lt;br /&gt;
      &amp;lt;/locale&amp;gt;&lt;br /&gt;
      &amp;lt;functionname value=&amp;quot;HelloWorld.printHW&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;logicalname value=&amp;quot;HelloWorld.printHW&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;languagedepprops&amp;gt;&lt;br /&gt;
          &amp;lt;prop name=&amp;quot;classpath&amp;quot; value=&amp;quot;HelloWorld.jar&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/languagedepprops&amp;gt;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/parcel&amp;gt;&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
The &amp;#039;&amp;#039;parcel-descriptor.xml&amp;#039;&amp;#039; file is used by the Scripting Framework to find macros. The functionname element indicates the name of the Java method which should be executed as a macro. The classpath element can be used to indicate any jar or class files which are used by the macro. If the classpath element is not included, then the directory in which the &amp;#039;&amp;#039;parcel-desciptor.xml&amp;#039;&amp;#039; file is found and any jar files in that directory will be used as the classpath. The necessary Java UNO classes are available automatically.&lt;br /&gt;
&lt;br /&gt;
* Copy the HelloWorld directory into the &amp;#039;&amp;#039;share/Scripts/java&amp;#039;&amp;#039; directory of a {{PRODUCTNAME}} installation or into the &amp;#039;&amp;#039;user/Scripts/java&amp;#039;&amp;#039; directory of a user installation. If you want to deploy the macro to a document you need to place it in a &amp;#039;&amp;#039;Scripts/java&amp;#039;&amp;#039; directory within the document zip file.&lt;br /&gt;
* If {{PRODUCTNAME}} is running, you will need to restart it in order for the macro to appear in the Macro Selector dialog.&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|The &amp;#039;&amp;#039;parcel-descriptor.xml&amp;#039;&amp;#039; file is also used to detect BeanShell and JavaScript macros. It is created automatically when creating macros using the Organizer dialogs for BeanShell and JavaScript.}}&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Scripting]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=ES_PyUNOServer&amp;diff=158872</id>
		<title>ES PyUNOServer</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=ES_PyUNOServer&amp;diff=158872"/>
		<updated>2010-03-14T07:39:23Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;El PyUNOServer es un script el cual pretende funcionar como un servidor para OpenOffice.org donde este pueda emitir y recibir llamadas usando XMLRPC. Esto quiere decir que puede obtener informacion desde otras aplicacion en una arquitectura usada por Webservices. &lt;br /&gt;
&lt;br /&gt;
El zip contiene tres archivos: &lt;br /&gt;
* PyUNOServerV2.py - es el script de Python&lt;br /&gt;
* PyUNOServerV2.pyc - version compilada&lt;br /&gt;
* PyUNOServer.sh2 - script para conectar al servicio&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;[python]&lt;br /&gt;
 # -*- coding: iso-8859-1 -*-&lt;br /&gt;
 #&lt;br /&gt;
 # pyUnoServer - version 2.0&lt;br /&gt;
 #&lt;br /&gt;
 # (C) 2005 ECWeb Ingenieria y Desarrollo - http://www.ecweb.cl/&lt;br /&gt;
 # Written by:&lt;br /&gt;
 # - Jose Antonio Akel &amp;lt;jakel@NOSPAMecweb.cl&amp;gt;&lt;br /&gt;
 # - Hector Vergara &amp;lt;hector@NOSPAMecweb.cl&amp;gt;&lt;br /&gt;
 # - Luis Gonzalez Miranda &amp;lt;lgm@NOSPAMecweb.cl&amp;gt;&lt;br /&gt;
 #&lt;br /&gt;
 # This program is freely distributable per the following license:&lt;br /&gt;
 #&lt;br /&gt;
 # Permission to use, copy, modify, and distribute this software and its&lt;br /&gt;
 # documentation for any purpose and without fee is hereby granted,&lt;br /&gt;
 # provided that the above copyright notice appears in all copies and that&lt;br /&gt;
 # both that copyright notice and this permission notice appear in&lt;br /&gt;
 # supporting documentation.&lt;br /&gt;
 #&lt;br /&gt;
 # I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL&lt;br /&gt;
 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I&lt;br /&gt;
 # BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY&lt;br /&gt;
 # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,&lt;br /&gt;
 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,&lt;br /&gt;
 # ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS&lt;br /&gt;
 # SOFTWARE.&lt;br /&gt;
&lt;br /&gt;
“&amp;quot;” &lt;br /&gt;
 This program implements a XMLRPC gateway to Openoffice&amp;#039;s Spreadsheet Calculator,&lt;br /&gt;
 allowing external programs to exchange data with spreadsheets.&lt;br /&gt;
“&amp;quot;”&lt;br /&gt;
&lt;br /&gt;
 from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler&lt;br /&gt;
 import os&lt;br /&gt;
 import uno&lt;br /&gt;
 import sys&lt;br /&gt;
 import time&lt;br /&gt;
 import logging&lt;br /&gt;
 import urllib&lt;br /&gt;
 &lt;br /&gt;
 class PyUNOServer(SimpleXMLRPCServer):&lt;br /&gt;
 &lt;br /&gt;
 	def _dispatch(self, method, params):&lt;br /&gt;
try:&lt;br /&gt;
	func = getattr(self, &amp;#039;&amp;#039; + method)&lt;br /&gt;
except:&lt;br /&gt;
	self.logger.error(&amp;quot;El Metodo &amp;#039;&amp;quot;+method+&amp;quot;&amp;#039; no esta soportado!&amp;quot;)&lt;br /&gt;
	raise Exception(&amp;#039;method &amp;quot;%s&amp;quot; is not supported&amp;#039; % method)&lt;br /&gt;
else:&lt;br /&gt;
	try:&lt;br /&gt;
		ret = func(*params)&lt;br /&gt;
		self.logger.info(&amp;quot;Llamada: &amp;quot;+str(method)+str(params)+&amp;quot; | Retorno: &amp;quot;+str(ret))&lt;br /&gt;
		return ret&lt;br /&gt;
	except:&lt;br /&gt;
		self.logger.info(&amp;quot;Llamada: &amp;quot;+str(method)+str(params))&lt;br /&gt;
		self.logger.error(&amp;quot;Error: &amp;quot;+str(sys.exc_type)+&amp;quot;:&amp;quot;+str(sys.exc_value))&lt;br /&gt;
ef init(self):&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
This method	starts an Openoffice session and initializes the XMLRPC server&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#Creo algunas constantes de utilidad&lt;br /&gt;
self.EMPTY = uno.Enum(&amp;quot;com.sun.star.table.CellContentType&amp;quot;, &amp;quot;EMPTY&amp;quot;)&lt;br /&gt;
self.TEXT = uno.Enum(&amp;quot;com.sun.star.table.CellContentType&amp;quot;, &amp;quot;TEXT&amp;quot;)&lt;br /&gt;
self.FORMULA = uno.Enum(&amp;quot;com.sun.star.table.CellContentType&amp;quot;, &amp;quot;FORMULA&amp;quot;)&lt;br /&gt;
self.VALUE = uno.Enum(&amp;quot;com.sun.star.table.CellContentType&amp;quot;, &amp;quot;VALUE&amp;quot;)&lt;br /&gt;
# Creo un Logger&lt;br /&gt;
self.logger = logging.getLogger(&amp;#039;pyUnoServer&amp;#039;)&lt;br /&gt;
hdlr = logging.FileHandler(&amp;#039;./pyUnoServer.log&amp;#039;)&lt;br /&gt;
formatter = logging.Formatter(&amp;#039;%(asctime)s %(levelname)s -- %(message)s&amp;#039;)&lt;br /&gt;
hdlr.setFormatter(formatter)&lt;br /&gt;
self.logger.addHandler(hdlr) &lt;br /&gt;
self.logger.setLevel(logging.INFO)&lt;br /&gt;
self.sessions = []&lt;br /&gt;
self.sessionSerial = 0&lt;br /&gt;
# Echo a correr el OpenOffice Calc obteniendo su PID&lt;br /&gt;
self.PID = os.spawnlp(os.P_NOWAIT,&amp;quot;/usr/bin/oocalc&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;-accept=socket,host=localhost,port=2002;urp;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
self.logger.info(&amp;quot;OOCalc Iniciado con el PID &amp;quot;+str(self.PID))&lt;br /&gt;
while 1:&lt;br /&gt;
	try: &lt;br /&gt;
		localContext = uno.getComponentContext()&lt;br /&gt;
		resolver = localContext.ServiceManager.createInstanceWithContext(&amp;quot;com.sun.star.bridge.UnoUrlResolver&amp;quot;, localContext )&lt;br /&gt;
		smgr = resolver.resolve( &amp;quot;uno:socket,host=localhost,port=2002;urp;StarOffice.ServiceManager&amp;quot; )&lt;br /&gt;
		remoteContext = smgr.getPropertyValue( &amp;quot;DefaultContext&amp;quot; )&lt;br /&gt;
		self.desktop = smgr.createInstanceWithContext( &amp;quot;com.sun.star.frame.Desktop&amp;quot;,remoteContext)&lt;br /&gt;
		self.logger.info(&amp;quot;Sistema conectado al socket de UNO&amp;quot;)&lt;br /&gt;
		break&lt;br /&gt;
	except:&lt;br /&gt;
		time.sleep(0.5)&lt;br /&gt;
ef openSession(self, session):&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
This method opens a new session.&lt;br /&gt;
Sample usage from PHP:&lt;br /&gt;
 - $sessionString is your a session ID provided by your program):&lt;br /&gt;
	$openSession = array( new XML_RPC_VALUE($sessionString, &amp;quot;string&amp;quot;));&lt;br /&gt;
	$sessionID = queryXMLRPC($client, &amp;quot;openSession&amp;quot;, $openSession);&lt;br /&gt;
	return $sessionID;&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
currentSerial = -1&lt;br /&gt;
for i in range(0,len(self.sessions)):&lt;br /&gt;
	if self.sessions[i][0] == session:&lt;br /&gt;
		currentSerial = i&lt;br /&gt;
		break&lt;br /&gt;
&lt;br /&gt;
if currentSerial == -1:&lt;br /&gt;
	self.sessions.append([session,[]])&lt;br /&gt;
	currentSerial = len(self.sessions)-1&lt;br /&gt;
return currentSerial&lt;br /&gt;
&lt;br /&gt;
ef getSessions(self):&lt;br /&gt;
return self.sessions&lt;br /&gt;
ef openBook(self, session, bookPath):&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
This method opens a new Openoffice spreadsheet book.&lt;br /&gt;
Sample usage from PHP:&lt;br /&gt;
 - $sessionID is the session&amp;#039;s ID returned by openSession()&lt;br /&gt;
 - $path is the path to the book in the server&amp;#039;s filesystem&lt;br /&gt;
$openBookQuery = array( new XML_RPC_VALUE($sessionID, &amp;quot;int&amp;quot;), new XML_RPC_VALUE($path,&amp;quot;string&amp;quot;) );&lt;br /&gt;
$bookID = queryXMLRPC($client, &amp;quot;openBook&amp;quot;, $openBookQuery);&lt;br /&gt;
return $bookID;&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
currentSerial = session&lt;br /&gt;
bookPath = bookPath.strip()&lt;br /&gt;
print bookPath&lt;br /&gt;
exists = os.path.exists(bookPath)&lt;br /&gt;
if exists == False:&lt;br /&gt;
	raise Exception(&amp;#039;El libro %s no existe&amp;#039;, bookPath)&lt;br /&gt;
else:&lt;br /&gt;
	self.logger.info(&amp;quot;se ha encontrado el libro!&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
currentBook = -1&lt;br /&gt;
&lt;br /&gt;
for i in range(0, len(self.sessions[currentSerial][1])):&lt;br /&gt;
	try:&lt;br /&gt;
		book = self.sessions[currentSerial][1][i]&lt;br /&gt;
	&lt;br /&gt;
		bookname = book[0]&lt;br /&gt;
		bookhandler = book[1]&lt;br /&gt;
		bookmodtime = book[2]&lt;br /&gt;
	&lt;br /&gt;
		if bookname == bookPath:&lt;br /&gt;
			modtime = os.path.getmtime(bookPath)&lt;br /&gt;
			if (modtime &amp;gt; bookmodtime):&lt;br /&gt;
				book[1].dispose()&lt;br /&gt;
				self.sessions[currentSerial][1].remove(book)&lt;br /&gt;
			else:&lt;br /&gt;
				currentBook = i&lt;br /&gt;
			break&lt;br /&gt;
	except:&lt;br /&gt;
		self.logger.error(&amp;quot;El libro &amp;quot;+currentBook+&amp;quot; no existe!&amp;quot;)&lt;br /&gt;
		&lt;br /&gt;
if (currentBook &amp;lt; 0 ):&lt;br /&gt;
	handler = self.desktop.loadComponentFromURL( &amp;quot;file://&amp;quot; + bookPath ,&amp;quot;_blank&amp;quot;,0,())&lt;br /&gt;
	if(handler == None):&lt;br /&gt;
		raise Exception(&amp;#039;El libro no existe o tiene caracteres extraños...&amp;#039;)&lt;br /&gt;
	modtime = os.path.getmtime(bookPath)&lt;br /&gt;
	&lt;br /&gt;
	estruct = [bookPath,handler,modtime]&lt;br /&gt;
	self.sessions[currentSerial][1].append(estruct)&lt;br /&gt;
	currentBook = len(self.sessions[currentSerial][1])-1&lt;br /&gt;
	&lt;br /&gt;
return currentBook&lt;br /&gt;
ef closeBook(self, sessionID, bookID):&lt;br /&gt;
&lt;br /&gt;
books = self.sessions[sessionID][1]&lt;br /&gt;
&lt;br /&gt;
#esto cierra el documento. Parece Cerdo, pero segun la documentcion, asi es&lt;br /&gt;
books[bookID][1].dispose()&lt;br /&gt;
self.sessions[sessionID][1].remove(books[bookID])&lt;br /&gt;
&lt;br /&gt;
return 1&lt;br /&gt;
ef getBookSheets(self, sessionID, bookID):&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
This method return an array with the book&amp;#039;s worksheets.&lt;br /&gt;
Sample usage from PHP:&lt;br /&gt;
 - $sessionID is the session&amp;#039;s ID returned by openSession()&lt;br /&gt;
 - $bookID is the book&amp;#039;s ID returned by openBook()&lt;br /&gt;
$sheetsQuery = array( new XML_RPC_VALUE($sessionID, &amp;quot;int&amp;quot;), new XML_RPC_VALUE($bookID, &amp;quot;int&amp;quot;) );&lt;br /&gt;
$sheets = queryXMLRPC($client, &amp;quot;getBookSheets&amp;quot; , $sheetsQuery);&lt;br /&gt;
return $sheets;&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
sheets = self.sessions[sessionID][1][bookID][1].getSheets().createEnumeration()&lt;br /&gt;
&lt;br /&gt;
container = []&lt;br /&gt;
while(sheets.hasMoreElements()):&lt;br /&gt;
	currentSheet = sheets.nextElement()&lt;br /&gt;
	container.append(currentSheet.getName().encode(&amp;quot;UTF-8&amp;quot;))&lt;br /&gt;
	&lt;br /&gt;
return container&lt;br /&gt;
ef getCellValue (self,sheet,x,y):&lt;br /&gt;
cell = sheet.getCellByPosition(x,y)&lt;br /&gt;
cellType  = cell.getType()&lt;br /&gt;
if cellType == self.TEXT :&lt;br /&gt;
	data = cell.getString().encode(&amp;quot;UTF-8&amp;quot;)&lt;br /&gt;
	if data == None:&lt;br /&gt;
		return &amp;quot;&amp;quot;&lt;br /&gt;
	return data.encode(&amp;quot;UTF-8&amp;quot;)&lt;br /&gt;
	&lt;br /&gt;
if cellType == self.FORMULA or cellType == self.VALUE :&lt;br /&gt;
	data = cell.getValue()&lt;br /&gt;
	if data == None:&lt;br /&gt;
		return 0&lt;br /&gt;
	return cell.getValue()&lt;br /&gt;
if cellType == self.EMPTY :&lt;br /&gt;
	return &amp;quot;&amp;quot;&lt;br /&gt;
ef getCell(self, session, book, sheet, x, y):&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
This method returns the content of a cell.&lt;br /&gt;
Sample usage from PHP:&lt;br /&gt;
 - $sessionID is the session&amp;#039;s ID returned by openSession()&lt;br /&gt;
 - $bookID is the book&amp;#039;s ID returned by openBook()&lt;br /&gt;
 - $sheet is the sheet&amp;#039;s ID as returned by getBookSheets()&lt;br /&gt;
$query = array(	&lt;br /&gt;
				new XML_RPC_Value($sessionID, &amp;quot;int&amp;quot;), &lt;br /&gt;
				new XML_RPC_VALUE($bookID, &amp;quot;int&amp;quot;), &lt;br /&gt;
				new XML_RPC_VALUE($sheet, &amp;quot;int&amp;quot;), &lt;br /&gt;
				new XML_RPC_Value($x, &amp;quot;int&amp;quot;), &lt;br /&gt;
				new XML_RPC_Value($y, &amp;quot;string&amp;quot;)&lt;br /&gt;
			);&lt;br /&gt;
$result = queryXMLRPC($client, &amp;quot;getCell&amp;quot;, $query);&lt;br /&gt;
return $result;&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
sheetref = self.sessions[session][1][book][1].getSheets().getByIndex(sheet)&lt;br /&gt;
valor = self.getCellValue(sheetref,x,y)&lt;br /&gt;
return valor&lt;br /&gt;
&lt;br /&gt;
ef setCell(self,session,book,sheet,x,y,value):&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
This method sets the content of a cell.&lt;br /&gt;
Sample usage from PHP:&lt;br /&gt;
 - $sessionID is the session&amp;#039;s ID returned by openSession()&lt;br /&gt;
 - $bookID is the book&amp;#039;s ID returned by openBook()&lt;br /&gt;
 - $sheet is the sheet&amp;#039;s ID as returned by getBookSheets()&lt;br /&gt;
$query = array(&lt;br /&gt;
				new XML_RPC_Value($sessionID, &amp;quot;int&amp;quot;), &lt;br /&gt;
				new XML_RPC_VALUE($bookID, &amp;quot;int&amp;quot;), &lt;br /&gt;
				new XML_RPC_VALUE($sheet, &amp;quot;int&amp;quot;), &lt;br /&gt;
				new XML_RPC_Value($x, &amp;quot;int&amp;quot;), &lt;br /&gt;
				new XML_RPC_Value($y, &amp;quot;int&amp;quot;),&lt;br /&gt;
				new XML_RPC_Value($value, &amp;quot;string&amp;quot;)&lt;br /&gt;
			);&lt;br /&gt;
$result = queryXMLRPC($client, &amp;quot;setCell&amp;quot;, $query);&lt;br /&gt;
return $result;&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
bookObject = self.sessions[session][1][book][1]&lt;br /&gt;
cell = bookObject.getSheets().getByIndex(sheet).getCellByPosition(x,y)&lt;br /&gt;
cell.setValue(value)&lt;br /&gt;
return 1&lt;br /&gt;
en que cambiara todo? mmm...&lt;br /&gt;
ef massiveSetCell(self, data):&lt;br /&gt;
	for valores in data:&lt;br /&gt;
		session,sheetid,x,y,valor = valores.split(&amp;quot;|&amp;quot;)&lt;br /&gt;
		code = self.setCell(self.trim(session),self.trim(sheetid),self.trim(x),self.trim(y),valor)&lt;br /&gt;
		if code &amp;lt; 0:&lt;br /&gt;
			return code&lt;br /&gt;
	return 1&lt;br /&gt;
ef getSheetPreview(self,session,book,sheet):&lt;br /&gt;
sheet = self.sessions[session][1][book][1].getSheets().getByIndex(sheet)&lt;br /&gt;
range = sheet.getCellRangeByPosition(0,0,8,23).getDataArray()&lt;br /&gt;
return range&lt;br /&gt;
&lt;br /&gt;
ef trim(self, cadena):&lt;br /&gt;
return cadena.strip()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
server = PyUNOServer2) &lt;br /&gt;
&lt;br /&gt;
server.init() server.logger.info(“Servicio Inicializado…”) &lt;br /&gt;
&lt;br /&gt;
try: &lt;br /&gt;
erver.serve_forever()&lt;br /&gt;
&lt;br /&gt;
except KeyboardInterrupt: &lt;br /&gt;
erver.logger.info(&amp;quot;Cerrando el socket...&amp;quot;)&lt;br /&gt;
erver.server_close()&lt;br /&gt;
s.kill(server.PID,1)&lt;br /&gt;
erver.logger.info(&amp;quot;Socket cerrado.&amp;quot;)&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==startPyUnoServer.sh2==&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;[bash]&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/openoffice/program/&lt;br /&gt;
export PYTHONPATH=$PYTHONPATH:/usr/lib/openoffice/program&lt;br /&gt;
export DISPLAY=localhost:1&lt;br /&gt;
echo &amp;quot;Logging en pyUnoServer.log&amp;quot;&lt;br /&gt;
python pyUnoServerV2.py&lt;br /&gt;
echo &amp;quot;CHAO!&amp;quot;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
[[Category:ES]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=AODL_wishlist&amp;diff=158084</id>
		<title>AODL wishlist</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=AODL_wishlist&amp;diff=158084"/>
		<updated>2010-02-26T23:09:13Z</updated>

		<summary type="html">&lt;p&gt;Newacct: /* Bugfix */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this article, you can add descriptions of features you would like to see in [[AODL|AODL]]. This can serve as a source of inspiration for developers and contributers.  Hopefully, these might be implemented during the [[Summer of Code 2007#ODF_Toolkit|Summer of Code 2007]] work on this project&lt;br /&gt;
&lt;br /&gt;
==Bugfix==&lt;br /&gt;
I have fixed a bug on loading a existing table who have some empty cells (OpenOffice creates here a attribute &amp;quot;table:number-columns-repeated&amp;quot; who declares the number of copies of this cell.&lt;br /&gt;
&lt;br /&gt;
Here is the sourcecode to fix the problem:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Add this to the Cell data object:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/// &lt;br /&gt;
/// Gets or sets the number of columns repeated.&lt;br /&gt;
/// &lt;br /&gt;
/// The number of columns repeated.&lt;br /&gt;
public int NumberOfColumnsRepeated { get; set; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;The method CreateTableCell()&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
//Create a new Cel&lt;br /&gt;
Cell cell					= new Cell(this._document, node);&lt;br /&gt;
IContentCollection iColl	= new IContentCollection();&lt;br /&gt;
//Recieve CellStyle&lt;br /&gt;
IStyle cellStyle			= this._document.Styles.GetStyleByName(cell.StyleName);&lt;br /&gt;
&lt;br /&gt;
if(cellStyle != null)&lt;br /&gt;
{&lt;br /&gt;
	int i=0;&lt;br /&gt;
	cell.Style				= cellStyle;&lt;br /&gt;
	if(cellStyle.StyleName == &amp;quot;ce244&amp;quot;)&lt;br /&gt;
		i=1;&lt;br /&gt;
}&lt;br /&gt;
//No need for a warning&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// this is the new code:::&lt;br /&gt;
&lt;br /&gt;
// check for thew &amp;quot;table:number-columns-repeated&amp;quot; attribute&lt;br /&gt;
int repeating = 0;&lt;br /&gt;
&lt;br /&gt;
foreach(XmlAttribute attr in node.Attributes) {&lt;br /&gt;
	if(attr.Name == &amp;quot;table:number-columns-repeated&amp;quot;) {&lt;br /&gt;
		int.TryParse(attr.Value, out repeating);&lt;br /&gt;
		cell.NumberOfColumnsRepeated = repeating;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// :::end of new code&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//Create the cells content&lt;br /&gt;
foreach(XmlNode nodeChild in cell.Node.ChildNodes)&lt;br /&gt;
{&lt;br /&gt;
	IContent iContent		= this.CreateContent(nodeChild);&lt;br /&gt;
&lt;br /&gt;
	if(iContent != null)&lt;br /&gt;
	{&lt;br /&gt;
		iColl.Add(iContent);&lt;br /&gt;
	}&lt;br /&gt;
	else if(this.OnWarning != null)&lt;br /&gt;
	{&lt;br /&gt;
		AODLWarning warning			= new AODLWarning(&amp;quot;Couldn&amp;#039;t create IContent from a table cell.&amp;quot;);&lt;br /&gt;
		warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));&lt;br /&gt;
		warning.Node				= nodeChild;&lt;br /&gt;
		this.OnWarning(warning);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
cell.Node.InnerXml			= &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
foreach(IContent iContent in iColl)&lt;br /&gt;
	cell.Content.Add(iContent);&lt;br /&gt;
return cell;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;The method CreateTableRow()&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
foreach(IContent iContent in iColl)&lt;br /&gt;
{&lt;br /&gt;
if(iContent is Cell)&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// this is the new code:::&lt;br /&gt;
	// new way&lt;br /&gt;
	Cell cell = (Cell)iContent;&lt;br /&gt;
	cell.Row = row;&lt;br /&gt;
&lt;br /&gt;
	row.CellCollection.Add(cell);&lt;br /&gt;
&lt;br /&gt;
	for(int i = 1; i &amp;lt; cell.NumberOfColumnsRepeated; i++) {&lt;br /&gt;
		XmlNode copyNode = cell.Node.CloneNode(true);&lt;br /&gt;
		copyNode.Attributes.RemoveAll();&lt;br /&gt;
		row.CellCollection.Add(this.CreateTableCell(copyNode));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
// :::end of new code&lt;br /&gt;
&lt;br /&gt;
	// old way ...&lt;br /&gt;
	//( (Cell)iContent ).Row = row;&lt;br /&gt;
	//row.CellCollection.Add(cell);&lt;br /&gt;
}&lt;br /&gt;
else if(iContent is CellSpan)&lt;br /&gt;
{&lt;br /&gt;
	((CellSpan)iContent).Row	= row;&lt;br /&gt;
	row.CellSpanCollection.Add(iContent as CellSpan);&lt;br /&gt;
}&lt;br /&gt;
else if(this.OnWarning != null)&lt;br /&gt;
{&lt;br /&gt;
	AODLWarning warning			= new AODLWarning(&amp;quot;Couldn&amp;#039;t create IContent from a row node. Content is unknown table row content!&amp;quot;);&lt;br /&gt;
	warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));&lt;br /&gt;
	warning.Node				= iContent.Node;&lt;br /&gt;
	this.OnWarning(warning);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Bugfix==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;include bugfix posted on sourceforge.net&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
several month ago i had a problem with aodl and large tables.. i posted the bug, testcode and the bugfix a few days later on the sourceforge bugtracker. please fix this big bug! &lt;br /&gt;
&lt;br /&gt;
i haven&amp;#039;t found a email-adress to which i could direct mail this request, but i hope someone will read this text and fix the bug! THX! [[User:Artemis1121|Artemis1121]] 09:49, 17 October 2007 (CEST)&lt;br /&gt;
&lt;br /&gt;
==Styles==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Font by String&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Allow indicating and using fonts by string, such as &amp;quot;Broadway BT&amp;quot;, rather than FontFamilies.BroadwayBT;&lt;br /&gt;
&lt;br /&gt;
Otherwise, when I would try to use a typeface not included in the standard installations, such as &amp;quot;Gentium&amp;quot; or &amp;quot;DejaVu Sans&amp;quot;, these would never be available under the hardcoded system.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Table Cell Widths&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Allow define of cell widths for individual cells or columns.&lt;br /&gt;
&lt;br /&gt;
==Graphics==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Captions&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Is there a way to add a caption to a Frame that has a graphic in it? I can simply add text below a figure, but I would like the captions to be sequences so that I could then build a table of contents. Below is a snippet of xml from an ODT content.xml file that shows what I need (written from OpenOffice). A little bit from the end is a text: sequence element. How do I add this using AODL? The graphics are no problem it&amp;#039;s just the sequence that I&amp;#039;m lost on.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;SVG&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Work with SVG Import to allow runtime SVG insertion.&lt;br /&gt;
&lt;br /&gt;
==AutoText==&lt;br /&gt;
My document assembly strategy relies heavily upon use of AutoText entries. Please implement Autotext features.&lt;br /&gt;
&lt;br /&gt;
==Master Documents==&lt;br /&gt;
Easy insertion of smaller documents into Master documents without XmlDoc.ImportNode&lt;br /&gt;
[[category:Summer of Code 2007]][[category:AODL]]&lt;br /&gt;
&lt;br /&gt;
==Temporary Files==&lt;br /&gt;
Please insert a possibility to change the path whitch is used for the temporary extraction of the ODF-Files. Maybe it can be set to the systemwide Temp-Directory.&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=API/Tutorials/PDF_export&amp;diff=158083</id>
		<title>API/Tutorials/PDF export</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=API/Tutorials/PDF_export&amp;diff=158083"/>
		<updated>2010-02-26T20:24:07Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PDF export is an important and useful feature of OpenOffice.org that can completely be automatized using OpenOffice.org API, quite every aspect of exporting to PDF in the graphical user interface is also available for programming: documents can be exported directly with default settings just passing the proper filter name and an URL, every option the user can set in the GUI can also be set programmatically in the filter options, also these settings are configurable via the API (they can be accessed, changed, or reset to their default values), and even the options dialog for exporting to PDF can be used through pure API calls.&lt;br /&gt;
&lt;br /&gt;
This tutorial will show how to use OpenOffice.org API to export documents to PDF. The  reader should have at least a basic knowledge about handling office documents (how to load and store a document), and should also know how to access OpenOffice.org configuration.&lt;br /&gt;
&lt;br /&gt;
This tutorial also aims to provide a full up-to-date documentation about the PDF export filter options, as these specific properties are usually not documented and only available in the core OpenOffice.org source code (thus not accessible for developers aiming to work only with its API).&lt;br /&gt;
&lt;br /&gt;
The sources for this tutorial can be found [http://api.openoffice.org  here]. They are not intended to provide a ready-to-use PDF export application, but to give you a tool for doing your own experiments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= PDF Export basics =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A document can be exported by saving it to a different location and using a special filter capable to write the document to the desired format. In the API, documents are storable through their interface &amp;lt;idl&amp;gt;com.sun.star.frame.XStorable&amp;lt;/idl&amp;gt;, as discussed in detail in [[Documentation/DevGuide/OfficeDev/Storing Documents|Developer&amp;#039;s Guide - Office Development - Storing Documents]].&lt;br /&gt;
&lt;br /&gt;
For exporting, besides the location (in URL notation) where the exported document is to be stored, a filter name must be passed to &amp;lt;code&amp;gt;XStorable.storeAsURL()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;XStorable.storeToURL()&amp;lt;/code&amp;gt;. The property needed for this purpose is the string argument &amp;lt;idlm&amp;gt;com.sun.star.document.MediaDescriptor:FilterName&amp;lt;/idlm&amp;gt; that takes the name of a filter already known by OpenOffice.org.&lt;br /&gt;
&lt;br /&gt;
In the simplest case, all you need for exporting to PDF is the URL where you want to export the document and the filter name; this way, the document will be exported using the current PDF export settings (the ones used the last time, or the default values stipulated by the filter configuration, if this is first time).&lt;br /&gt;
&lt;br /&gt;
The following code shows the basic procedure:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XComponent xComponent = null;&lt;br /&gt;
// create a new Writer document using a helper&lt;br /&gt;
xComponent = Helper.createNewDoc(m_xContext, &amp;quot;swriter&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// access its XTextDocument interface&lt;br /&gt;
XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(&lt;br /&gt;
        XTextDocument.class, xComponent);&lt;br /&gt;
&lt;br /&gt;
// access the text body and set a string&lt;br /&gt;
XText xText = xTextDocument.getText();&lt;br /&gt;
xText.setString(&amp;quot;Simple PDF export demo.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// XStorable to store the document&lt;br /&gt;
XStorable xStorable = (XStorable) UnoRuntime.queryInterface(&lt;br /&gt;
        XStorable.class, xComponent);&lt;br /&gt;
&lt;br /&gt;
// XStorable.storeToURL() expects an URL telling where to store the document&lt;br /&gt;
// and an array of PropertyValue indicating how to store it&lt;br /&gt;
&lt;br /&gt;
// URL = use helper method to get the home directory&lt;br /&gt;
String sURL = Helper.getHomeDir(m_xContext) + &amp;quot;/Simple_PDF_EXPORT_demo.pdf&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Exporting to PDF consists of giving the proper&lt;br /&gt;
// filter name in the property &amp;quot;FilterName&amp;quot;&lt;br /&gt;
// With only this, the document will be exported&lt;br /&gt;
// using the existing PDF export settings&lt;br /&gt;
// (the one used the last time, or the default if the first time)&lt;br /&gt;
PropertyValue[] aMediaDescriptor = new PropertyValue[1];&lt;br /&gt;
aMediaDescriptor[0] = new PropertyValue();&lt;br /&gt;
aMediaDescriptor[0].Name = &amp;quot;FilterName&amp;quot;;&lt;br /&gt;
aMediaDescriptor[0].Value = &amp;quot;writer_pdf_Export&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
xStorable.storeToURL(sURL, aMediaDescriptor);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As the code shows, &amp;lt;code&amp;gt;XStorable.storeToURL()&amp;lt;/code&amp;gt; expects an URL as first parameter, and an array of &amp;lt;idl&amp;gt;com.sun.star.beans.PropertyValue&amp;lt;/idl&amp;gt; structs as second parameter, which implements the &amp;lt;idl&amp;gt;com.sun.star.document.MediaDescriptor&amp;lt;/idl&amp;gt; service, consisting of property definitions. The media descriptor is used for loading/importing and saving/exporting  documents, please refer to the [[Documentation/DevGuide/OfficeDev/Handling_Documents#MediaDescriptor|Developer&amp;#039;s Guide]] for a detailed explanation. In this case, it includes only the struct for the &amp;lt;idlm&amp;gt;com.sun.star.document.MediaDescriptor:FilterName&amp;lt;/idlm&amp;gt;, indicating the name of the filter for exporting Writer documents to PDF.&lt;br /&gt;
&lt;br /&gt;
You can fully customize the PDF export process by adding another &amp;lt;code&amp;gt;PropertyValue&amp;lt;/code&amp;gt; struct to the MediaDescriptor array: &amp;lt;idlm&amp;gt;com.sun.star.document.MediaDescriptor:FilterData&amp;lt;/idlm&amp;gt;. This parameter is used to pass properties specific for a special filter type. In the case of the PDF export filter, another array of &amp;lt;code&amp;gt;PropertyValue&amp;lt;/code&amp;gt; structs is expected.&lt;br /&gt;
&lt;br /&gt;
In the next section, we will describe the complete list of specific properties available at the present for the PDF export filter.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= PDF Export filter data =&lt;br /&gt;
&lt;br /&gt;
The following tables contain all the properties available in the PDF export filter implementation in OpenOffice.org 2.4. You must be aware of the fact that they are &amp;#039;&amp;#039;implementation specific&amp;#039;&amp;#039;, so you may not find all of them in previous versions (nor expect that they remain the same in the future).&lt;br /&gt;
&lt;br /&gt;
The tables follow the order of the PDF Export dialog tab pages, so that you can easily understand their meaning just comparing them with this dialog.&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* The &amp;#039;&amp;#039;&amp;#039;Description&amp;#039;&amp;#039;&amp;#039; column contains descriptions taken mainly from the PDF Export Dialog configuration, found in &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;&amp;lt;/nowiki&amp;gt;opt/openoffice.org2.4&amp;lt;nowiki&amp;gt;&amp;gt;&amp;lt;/nowiki&amp;gt;/share/registry/schema/org/openoffice/Office/Common.xcs&amp;lt;/code&amp;gt; &lt;br /&gt;
* The &amp;#039;&amp;#039;&amp;#039;Type&amp;#039;&amp;#039;&amp;#039; column refers to the UNO IDL data types (see [[Documentation/DevGuide/ProUNO/Simple Types | Developer&amp;#039;s Guide - Professional UNO - Simple Types]]), not the OpenOffice.org Registry data types (see [[Documentation/DevGuide/Config/Object Model | Developer&amp;#039;s Guide - Configuration Management - Object Model]] and [http://util.openoffice.org/common/configuration/oor-document-format.html#RegistryOM OpenOffice.org Registry Format - Registry Object Model]). For the &amp;#039;&amp;#039;&amp;#039;mapping&amp;#039;&amp;#039;&amp;#039; refer to [http://util.openoffice.org/common/configuration/api_spec.html#Types%20Objects%20and%20Values   Configuration API Overview - Types, Objects and Values].&lt;br /&gt;
* The &amp;#039;&amp;#039;&amp;#039;Default value&amp;#039;&amp;#039;&amp;#039; column contains the default value as indicated in the PDF Export Dialog configuration mentioned above.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== General properties ==&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;
| &amp;lt;center&amp;gt;&amp;#039;&amp;#039;&amp;#039;Property Name&amp;#039;&amp;#039;&amp;#039;&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;&amp;#039;&amp;#039;&amp;#039;Description&amp;#039;&amp;#039;&amp;#039;&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;&amp;#039;&amp;#039;&amp;#039;Type&amp;#039;&amp;#039;&amp;#039;&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;&amp;#039;&amp;#039;&amp;#039;Default value&amp;#039;&amp;#039;&amp;#039;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;PageRange&amp;lt;/code&amp;gt;&lt;br /&gt;
| If this property is set, it indicates the range of pages to be printed.&lt;br /&gt;
&lt;br /&gt;
If you want to print all the pages, leave this property unset.&lt;br /&gt;
&lt;br /&gt;
If you want to export a selection, leave this property unset, setting only the property &amp;#039;&amp;#039;&amp;#039;Selection&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
| &amp;lt;center&amp;gt;string&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;empty&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;(all pages are printed)&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Selection&amp;lt;/code&amp;gt;&lt;br /&gt;
| An &amp;#039;&amp;#039;&amp;#039;any&amp;#039;&amp;#039;&amp;#039; corresponding to the current selection in the document.&lt;br /&gt;
| &amp;lt;center&amp;gt;any&amp;lt;/center&amp;gt;&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;UseLosslessCompression&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies if graphics are exported to PDF using a lossless compression eg. &amp;#039;&amp;#039;&amp;#039;PNG&amp;#039;&amp;#039;&amp;#039; or if they are compressed using the &amp;#039;&amp;#039;&amp;#039;JPEG&amp;#039;&amp;#039;&amp;#039; format.&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;false&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Quality&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies quality of the JPG export. A higher value results in higher quality and file.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Minimum inclusive value&amp;#039;&amp;#039;: 1. Represents lowest value that can be used. The lower the value, the less good is the compression quality and the bigger is be the file size.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Maximum inclusive value&amp;#039;&amp;#039;:100. Represents highest value that can be used. The higher the value, the better is the compression quality and the smaller is the file size.&lt;br /&gt;
| &amp;lt;center&amp;gt;long&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;90&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ReduceImageResolution&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies if the resolution of each image is reduced to the resolution specified by the property MaxImageResolution.&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;false&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;MaxImageResolution&amp;lt;/code&amp;gt;&lt;br /&gt;
| If the property ReduceImageResolution is set to true all images will be reduced to the given value in DPI.&lt;br /&gt;
&lt;br /&gt;
Posible values:&lt;br /&gt;
&lt;br /&gt;
* 75&lt;br /&gt;
* 150&lt;br /&gt;
* 300&lt;br /&gt;
* 600&lt;br /&gt;
* 1200&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| &amp;lt;center&amp;gt;long&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;300&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;SelectPdfVersion&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies the version of PDF to emit.&lt;br /&gt;
&lt;br /&gt;
Possible values:&lt;br /&gt;
&lt;br /&gt;
* 0 = PDF 1.4 (default selection).&lt;br /&gt;
* 1 = PDF/A-1 (ISO 19005-1:2005)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| &amp;lt;center&amp;gt;long&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;0&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;UseTaggedPDF&amp;lt;/code&amp;gt;&lt;br /&gt;
| Determines if PDF are created by using special tags also known as Tagged PDF.&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;false&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ExportFormFields&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies whether form fields are exported as widgets or only their fixed print representation is exported.&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;true&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;FormsType&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies the submitted format of a PDF form.&lt;br /&gt;
&lt;br /&gt;
Possible values:&lt;br /&gt;
&lt;br /&gt;
* 0= Specifies that forms type &amp;#039;&amp;#039;&amp;#039;FDF&amp;#039;&amp;#039;&amp;#039; is used.&lt;br /&gt;
* 1= Specifies that forms type &amp;#039;&amp;#039;&amp;#039;PDF&amp;#039;&amp;#039;&amp;#039; is used.&lt;br /&gt;
* 2= Specifies that forms type &amp;#039;&amp;#039;&amp;#039;HTML&amp;#039;&amp;#039;&amp;#039; is used.&lt;br /&gt;
* 3= Specifies that forms type &amp;#039;&amp;#039;&amp;#039;XML&amp;#039;&amp;#039;&amp;#039; is used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| &amp;lt;center&amp;gt;long&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;0&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ExportBookmarks&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies if bookmarks are exported to PDF.&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;true&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ExportNotes&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies if notes are exported to PDF.&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;false&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ExportNotesPages&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies if notes pages are exported to PDF. (Notes pages are available in &amp;#039;&amp;#039;&amp;#039;Impress&amp;#039;&amp;#039;&amp;#039; documents only).&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;false&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;IsSkipEmptyPages&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies that automatically inserted empty pages are suppressed. This option is active only if storing Writer documents.&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;false&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;IsAddStream&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies that a stream is inserted to the PDF file which contains the original document for archiving purposes.&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;false&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Initial view ==&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;
! &amp;lt;center&amp;gt;Property Name&amp;lt;/center&amp;gt;&lt;br /&gt;
! &amp;lt;center&amp;gt;Description&amp;lt;/center&amp;gt;&lt;br /&gt;
! &amp;lt;center&amp;gt;Type&amp;lt;/center&amp;gt;&lt;br /&gt;
! &amp;lt;center&amp;gt;Default value&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;InitialView&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies how the PDF document should be displayed when opened.&lt;br /&gt;
&lt;br /&gt;
Possible values:&lt;br /&gt;
&lt;br /&gt;
* 0= Select the default viewer mode, neither outlines or thumbnails.&lt;br /&gt;
* 1= The document is opened with outline pane opened&lt;br /&gt;
* 2= The document is opened with thumbnail pane opened&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| &amp;lt;center&amp;gt;long&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;0&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;InitialPage&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies the page on which a PDF document should be opened in the viewer application.&lt;br /&gt;
| &amp;lt;center&amp;gt;long&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;1&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Magnification&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies the action to be performed when the PDF document is opened.&lt;br /&gt;
&lt;br /&gt;
Possible values:&lt;br /&gt;
&lt;br /&gt;
* 0= Opens with &amp;#039;&amp;#039;&amp;#039;default&amp;#039;&amp;#039;&amp;#039; zoom magnification.&lt;br /&gt;
* 1= Opens magnified to &amp;#039;&amp;#039;&amp;#039;fit&amp;#039;&amp;#039;&amp;#039; the entire page &amp;#039;&amp;#039;&amp;#039;within&amp;#039;&amp;#039;&amp;#039; the &amp;#039;&amp;#039;&amp;#039;window&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
* 2= Opens magnified to &amp;#039;&amp;#039;&amp;#039;fit&amp;#039;&amp;#039;&amp;#039; the entire &amp;#039;&amp;#039;&amp;#039;page&amp;#039;&amp;#039;&amp;#039; &amp;#039;&amp;#039;&amp;#039;width&amp;#039;&amp;#039;&amp;#039; within the window.&lt;br /&gt;
* 3= Opens magnified to fit the entire width of its &amp;#039;&amp;#039;&amp;#039;boundig&amp;#039;&amp;#039;&amp;#039; &amp;#039;&amp;#039;&amp;#039;box&amp;#039;&amp;#039;&amp;#039; within the window (cuts out margins).&lt;br /&gt;
* 4= Opens with the &amp;#039;&amp;#039;&amp;#039;zoom&amp;#039;&amp;#039;&amp;#039; &amp;#039;&amp;#039;&amp;#039;level&amp;#039;&amp;#039;&amp;#039; specified in the Zoom property.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| &amp;lt;center&amp;gt;long&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;0&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Zoom&amp;lt;/code&amp;gt;&lt;br /&gt;
| specifies the zoom level a PDF document is opened with. Only valid if &amp;quot;Magnification&amp;quot; is set to &amp;quot;4&amp;quot;.&lt;br /&gt;
| &amp;lt;center&amp;gt;long&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;100&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;PageLayout&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies the page layout to be used when the document is opened.&lt;br /&gt;
&lt;br /&gt;
Possible values:&lt;br /&gt;
&lt;br /&gt;
* 0= Display the pages according to the reader configuration.&lt;br /&gt;
* 1= Display one page at a time.&lt;br /&gt;
* 2= Display the pages in one column.&lt;br /&gt;
* 3= Display the pages in two columns odd pages on the right, to have the odd pages on the left the FirstPageOnLeft property should be used as well.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| &amp;lt;center&amp;gt;long&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;0&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;FirstPageOnLeft&amp;lt;/code&amp;gt;&lt;br /&gt;
| Used with the value 3 of the PageLayout property above, true if the first page (odd) should be on the left side of the screen.&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;false&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User interface ==&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;
! &amp;lt;center&amp;gt;Property Name&amp;lt;/center&amp;gt;&lt;br /&gt;
! &amp;lt;center&amp;gt;Description&amp;lt;/center&amp;gt;&lt;br /&gt;
! &amp;lt;center&amp;gt;Type&amp;lt;/center&amp;gt;&lt;br /&gt;
! &amp;lt;center&amp;gt;Default value&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ResizeWindowToInitialPage&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies that the PDF viewer window is opened &amp;#039;&amp;#039;&amp;#039;full screen&amp;#039;&amp;#039;&amp;#039; when the document is opened.&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;false&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CenterWindow&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies that the PDF viewer window is centered to the screen when the PDF document is opened.&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;false&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;OpenInFullScreenMode&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies that the PDF viewer window is opened full screen, on top of all windows.&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;false&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;DisplayPDFDocumentTitle&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies that the title of the document, if present in the document properties, is displayed in the PDF viewer window title bar.&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;true&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;HideViewerMenubar&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies whether to hide the PDF viewer menubar when the document is active.&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;false&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;HideViewerToolbar&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies whether to hide the PDF viewer toolbar when the document is active.&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;false&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;HideViewerWindowControls&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies whether to hide the PDF viewer controls when the document is active.&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;false&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;UseTransitionEffects&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies slide transitions are exported to PDF. This option is active only if storing &amp;#039;&amp;#039;&amp;#039;Impress&amp;#039;&amp;#039;&amp;#039; documents.&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;true&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;OpenBookmarkLevels&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies how many bookmark levels should be opened in the reader application when the PDF gets opened.&lt;br /&gt;
&lt;br /&gt;
Possible values:&lt;br /&gt;
&lt;br /&gt;
* -1: all bookmark levels are opened&lt;br /&gt;
* 1 – 10: indicate a bookmark level (from 1 to 10)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| &amp;lt;center&amp;gt;long&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-1&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&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;
! &amp;lt;center&amp;gt;Property Name&amp;lt;/center&amp;gt;&lt;br /&gt;
! &amp;lt;center&amp;gt;Description&amp;lt;/center&amp;gt;&lt;br /&gt;
! &amp;lt;center&amp;gt;Type&amp;lt;/center&amp;gt;&lt;br /&gt;
! &amp;lt;center&amp;gt;Default value&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ExportBookmarksToPDFDestination&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies that the bookmarks contained in the source OpenOffice.org file should be exported to the PDF file as Named Destination (see PDF 1.4 section 8.2.1).&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;false&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ConvertOOoTargetToPDFTarget&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;nowiki&amp;gt;Specifies that the target documents with .od[tpgs] extension, will have that extension changed to .pdf when the link is exported to PDF. The source document remains untouched.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;false&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ExportLinksRelativeFsys&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies that the file system related hyperlinks (file:// protocol) present in the document will be exported as relative to the source document location.&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;false&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;PDFViewSelection&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies the way the exported PDF will be viewed (experienced) by the user.&lt;br /&gt;
&lt;br /&gt;
Possible values:&lt;br /&gt;
&lt;br /&gt;
* 0 = Specifies that the PDF will be exported with all the links external to the document treated as URI. This is the Default&lt;br /&gt;
* 1 = Specifies that the PDF will be exported in order to be viewed through a PDF reader application only. Valid only if not exporting to PDF/A-1 (e.g. SelectPdfVersion not set to 1).&lt;br /&gt;
* 2 = Specifies that the PDF will be exported in order to be viewed through an Internet browser, using the PDF plug-in provided with it. The bookmark of the URI will be rendered compatible with the target bookmark generated with OOo PDF Export feature (see ExportBookmarksToPDFDestination, below).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| &amp;lt;center&amp;gt;long&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;0&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Security ==&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;
! &amp;lt;center&amp;gt;Property Name&amp;lt;/center&amp;gt;&lt;br /&gt;
! &amp;lt;center&amp;gt;Description&amp;lt;/center&amp;gt;&lt;br /&gt;
! &amp;lt;center&amp;gt;Type&amp;lt;/center&amp;gt;&lt;br /&gt;
! &amp;lt;center&amp;gt;Default value&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;EncryptFile&amp;lt;/code&amp;gt;&lt;br /&gt;
| If true, selects to encrypt the PDF document with a password. The PDF file can be opened only when the user enters the correct password.&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;false&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;DocumentOpenPassword&amp;lt;/code&amp;gt;&lt;br /&gt;
| This is the password that allows the user to open the PDF file is &amp;quot;EncryptFile&amp;quot; is set to true.&lt;br /&gt;
| &amp;lt;center&amp;gt;string&amp;lt;/center&amp;gt;&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;RestrictPermissions&amp;lt;/code&amp;gt;&lt;br /&gt;
| If true, selects to restrict some permissions. The permissions can be changed only when the user enters the correct password.&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;false&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;PermissionPassword&amp;lt;/code&amp;gt;&lt;br /&gt;
| This is the password that allows the user to access some permissions restricted if &amp;quot;RestrictPermissions&amp;quot; is set to true.&lt;br /&gt;
| &amp;lt;center&amp;gt;string&amp;lt;/center&amp;gt;&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Printing&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies what printing is allowed.&lt;br /&gt;
&lt;br /&gt;
Possible values:&lt;br /&gt;
&lt;br /&gt;
* 0 = The document cannot be printed.&lt;br /&gt;
* 1 = The document can be printed at low resolution only.&lt;br /&gt;
* 2 = The document can be printed at maximum resolution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| &amp;lt;center&amp;gt;long&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;2&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Changes&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies the change allowed to the document.&lt;br /&gt;
&lt;br /&gt;
Possible values:&lt;br /&gt;
&lt;br /&gt;
* 0 = The document cannot be changed.&lt;br /&gt;
* 1 = Inserting deleting and rotating pages is allowed.&lt;br /&gt;
* 2 = Filling of form field is allowed.&lt;br /&gt;
* 3 = Both filling of form field and commenting is allowed.&lt;br /&gt;
* 4 = All the changes of the previous selections are permitted, with the only exclusion of page extraction (copy).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| &amp;lt;center&amp;gt;long&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;4&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;EnableCopyingOfContent&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies that the pages and the document content can be extracted to be used in other documents (copy and paste).&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;true&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;EnableTextAccessForAccessibilityTools&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies that the document content can be extracted to be used in accessibility applications.&lt;br /&gt;
| &amp;lt;center&amp;gt;boolean&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;true&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Filter data demo =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sample shows how to use the filer data to set some PDF export filter options.&lt;br /&gt;
&lt;br /&gt;
We will create a new Writer document, insert some text in it and draw two shapes. Then we will show how to export only these two shapes, setting also some view preferences (the PDF will open in full screen mode).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    // create a new Writer document using a helper&lt;br /&gt;
    xComponent = Helper.createNewDoc(m_xContext, &amp;quot;swriter&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    // access its XTextDocument interface&lt;br /&gt;
    XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(&lt;br /&gt;
            XTextDocument.class, xComponent);&lt;br /&gt;
&lt;br /&gt;
    // draw a group of shapes&lt;br /&gt;
    // so that then we can select them and export ONLY them to PDF&lt;br /&gt;
    XShapeGroup xShapes = drawShapeGroup(xTextDocument);&lt;br /&gt;
&lt;br /&gt;
    // XStorable to store the document&lt;br /&gt;
    XStorable xStorable = (XStorable) UnoRuntime.queryInterface(&lt;br /&gt;
        XStorable.class, xComponent);&lt;br /&gt;
&lt;br /&gt;
    // XStorable.storeToURL() expects an URL telling where to store the document&lt;br /&gt;
    // and an array of PropertyValue indicating how to store it&lt;br /&gt;
&lt;br /&gt;
    // URL = use helper method to get the home directory&lt;br /&gt;
    String sURL = Helper.getHomeDir(m_xContext) + &amp;quot;/PDF_EXPORT_FilterData_demo.pdf&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
    // Exporting to PDF consists of giving the proper&lt;br /&gt;
    // filter name in the property &amp;quot;FilterName&amp;quot;&lt;br /&gt;
    // With only this, the WHOLE document will be exported&lt;br /&gt;
    // using the existing PDF export settings&lt;br /&gt;
    // (the one used the last time, or the default if the first time)&lt;br /&gt;
    PropertyValue[] aMediaDescriptor = new PropertyValue[2];&lt;br /&gt;
    aMediaDescriptor[0] = new PropertyValue();&lt;br /&gt;
    aMediaDescriptor[0].Name = &amp;quot;FilterName&amp;quot;;&lt;br /&gt;
    aMediaDescriptor[0].Value = &amp;quot;writer_pdf_Export&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
    // By adding the &amp;quot;FilterData&amp;quot; we can control what is exported and how&lt;br /&gt;
    // For example, we will export ONLY the current selection&lt;br /&gt;
&lt;br /&gt;
    PropertyValue[] aFilterData = new PropertyValue[3];&lt;br /&gt;
    aFilterData[0] = new PropertyValue();&lt;br /&gt;
    aFilterData[0].Name = &amp;quot;Selection&amp;quot;;&lt;br /&gt;
    aFilterData[0].Value = select(xTextDocument, xShapes);&lt;br /&gt;
    // there was really no need to retrieve the selection&lt;br /&gt;
    // we could have used the XShapeGroup reference&lt;br /&gt;
&lt;br /&gt;
    aFilterData[1] = new PropertyValue();&lt;br /&gt;
    aFilterData[1].Name = &amp;quot;DisplayPDFDocumentTitle&amp;quot;;&lt;br /&gt;
    aFilterData[1].Value = Boolean.FALSE;&lt;br /&gt;
&lt;br /&gt;
    aFilterData[2] = new PropertyValue();&lt;br /&gt;
    aFilterData[2].Name = &amp;quot;OpenInFullScreenMode&amp;quot;;&lt;br /&gt;
    aFilterData[2].Value = Boolean.TRUE;&lt;br /&gt;
&lt;br /&gt;
    aMediaDescriptor[1] = new PropertyValue();&lt;br /&gt;
    aMediaDescriptor[1].Name = &amp;quot;FilterData&amp;quot;;&lt;br /&gt;
    aMediaDescriptor[1].Value = aFilterData;&lt;br /&gt;
&lt;br /&gt;
    xStorable.storeToURL(sURL, aMediaDescriptor);            &lt;br /&gt;
&lt;br /&gt;
    // open the PDF with your default PDF viewer&lt;br /&gt;
    // to check how it worked!&lt;br /&gt;
    Helper.executeSystemCommand(m_xContext, sURL);&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To export the selection, there must be something currently selected in the document&amp;#039;s &amp;#039;&amp;#039;view&amp;#039;&amp;#039;; that is, if you &amp;quot;select&amp;quot; for example a text range by means of expanding a text cursor &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
    XTextCursor xCursor = xTextDocument.getText().createTextCursor();&lt;br /&gt;
&lt;br /&gt;
    // The text cursor can travel through the text&lt;br /&gt;
    // as a &amp;quot;collapsed&amp;quot; text range&lt;br /&gt;
    // with identical start and end as a point in text,&lt;br /&gt;
    // or it can expand while it moves to contain a target string.&lt;br /&gt;
    // This is controlled with the XTextCursor methods&lt;br /&gt;
    // having a boolean parameter, for example XTextCursor.gotoEnd(bExpand)&lt;br /&gt;
    // If bExpand is true, the cursor expands while it travels&lt;br /&gt;
&lt;br /&gt;
    xCursor.gotoStart(false); // go to the start&lt;br /&gt;
    xCursor.gotoEnd(true);    // go to the end, expanding the cursor&amp;#039;s text range&lt;br /&gt;
&lt;br /&gt;
    // now the cursor&amp;#039;s text range covers all the document&amp;#039;s text&lt;br /&gt;
&lt;br /&gt;
    //...&lt;br /&gt;
&lt;br /&gt;
    aFilterData[0] = new PropertyValue();&lt;br /&gt;
    aFilterData[0].Name = &amp;quot;Selection&amp;quot;;&lt;br /&gt;
    aFilterData[0].Value = xCursor;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
the PDF export filter will not recognize this as a selection: the text cursor is not collapsed (start and end are not the same), but nothing is selected in the document&amp;#039;s view.&lt;br /&gt;
&lt;br /&gt;
To select an object in the document&amp;#039;s view is really simple: just get the current &amp;lt;idl&amp;gt;com.sun.star.frame.XController&amp;lt;/idl&amp;gt; from the document &amp;lt;idl&amp;gt;com.sun.star.frame.XModel&amp;lt;/idl&amp;gt;, query for the &amp;lt;code&amp;gt;XController&amp;lt;/code&amp;gt;&amp;#039;s &amp;lt;idl&amp;gt;com.sun.star.view.XSelectionSupplier&amp;lt;/idl&amp;gt;,and select the object (a cursor&amp;#039;s text, a group of shapes, etc.):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
private Object select(XInterface xInterface, Object aAny){&lt;br /&gt;
        Object oSelection = null;&lt;br /&gt;
        try {&lt;br /&gt;
            XModel xModel = (XModel) UnoRuntime.queryInterface(&lt;br /&gt;
                    XModel.class, xInterface);&lt;br /&gt;
            if (xModel != null){&lt;br /&gt;
                XController xController = xModel.getCurrentController();&lt;br /&gt;
                XSelectionSupplier xSelectionSupplier = &lt;br /&gt;
                        (XSelectionSupplier) UnoRuntime.queryInterface(&lt;br /&gt;
                        XSelectionSupplier.class, xController);&lt;br /&gt;
                xSelectionSupplier.select(aAny);&lt;br /&gt;
                // there is really no need to retrieve the selection&lt;br /&gt;
                oSelection = xSelectionSupplier.getSelection();&lt;br /&gt;
            }&lt;br /&gt;
        } finally {&lt;br /&gt;
            return oSelection;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= PDF Export Configuration =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Most of the PDF export filter properties seen in the tables above are stored in the OpenOffice.org configuration. &lt;br /&gt;
&lt;br /&gt;
When the user clicks the toolbar icon to export the current document (command &amp;lt;code&amp;gt;&amp;quot;.uno:ExportDirectToPDF&amp;quot;&amp;lt;/code&amp;gt;), s/he  will only see the &amp;quot;Export&amp;quot; dialog, not the &amp;quot;PDF Options&amp;quot; dialog. In this case, the filter will export reading the settings the user defined the last time in the PDF Options dialog (or the default settings if the dialog has never been used before).&lt;br /&gt;
&lt;br /&gt;
If the user chooses the command in the &amp;quot;File&amp;quot; menu (&amp;lt;code&amp;gt;&amp;quot;.uno:ExportToPDF&amp;quot;&amp;lt;/code&amp;gt;), s/he will see two dialogs in succession: first the PDF Options dialog, where s/he chooses the export settings; then the &amp;quot;Export&amp;quot; dialog, where s/he enters a file name. The settings entered int the PDF Options dialog are made persistent.&lt;br /&gt;
&lt;br /&gt;
The PDF export filter configuration is stored in the path &amp;lt;code&amp;gt;org.openoffice.Office/Common/PDF/Export&amp;lt;/code&amp;gt;, its schema can be found in the office installation inside  &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;opt/openoffice.org2.4&amp;gt;&amp;lt;/nowiki&amp;gt;/share/registry/schema/org/openoffice/Office/Common.xcs&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Not all properties passed to the PDF filter are stored in the registry (as it makes no sense, for example to make persistent the page range to be exported, or the passwords for protecting the document). The following is a list of the properties not stored in the OpenOffice.org registry:&lt;br /&gt;
&lt;br /&gt;
# &amp;lt;code&amp;gt;DocumentOpenPassword&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;EncryptFile&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;PageRange&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;PermissionPassword&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;RestrictPermissions&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;Selection&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following property is present, but deprecated (that&amp;#039;s why we didn&amp;#039;t include in the tables above):&lt;br /&gt;
&lt;br /&gt;
# &amp;lt;code&amp;gt;CompressMode&amp;lt;/code&amp;gt; &amp;lt;nowiki&amp;gt;[deprecated]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the next sections, we will show how to access this configuration, change it, and restore it to its default values. The reader should be familiar with OpenOffice.org configuration API, as explained in [[Documentation/DevGuide/Config/Configuration Management|Developer&amp;#039;s Guide – Configuration Management]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Accessing the configuration==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To access the PDF export configuration, we must follow two steps, as explained in  [[Documentation/DevGuide/Config/Configuration_Data_Sources|Developer&amp;#039;s Guide – Configuration Management - Configuration Data Sources]]:&lt;br /&gt;
&lt;br /&gt;
# connect to the OpenOffice.org registry that stores the user configuration data by creating an instance of a &amp;lt;idl&amp;gt;com.sun.star.configuration.ConfigurationProvider&amp;lt;/idl&amp;gt; at the global service manager&lt;br /&gt;
# ask the &amp;lt;code&amp;gt;ConfigurationProvider&amp;lt;/code&amp;gt; to create an access object for the nodepath &amp;lt;code&amp;gt;&amp;quot;/org.openoffice.Office/Common/PDF/Export&amp;quot;&amp;lt;/code&amp;gt;, using &amp;lt;idlml&amp;gt;com.sun.star.lang.XMultiServiceFactory:createInstanceWithArguments&amp;lt;/idlml&amp;gt;. Depending on if we want a read-only view of the configuration data, or we want it to be modifiable, we must pass to &amp;lt;code&amp;gt;createInstanceWithArguments()&amp;lt;/code&amp;gt; the name of the service &amp;lt;idl&amp;gt;com.sun.star.configuration.ConfigurationAccess&amp;lt;/idl&amp;gt;, for read-only access, or &amp;lt;idl&amp;gt;com.sun.star.configuration.ConfigurationUpdateAccess&amp;lt;/idl&amp;gt;, for updatable access.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To create a &amp;#039;&amp;#039;&amp;#039;read-only&amp;#039;&amp;#039;&amp;#039; view on the PDF export filter configuration data in the user layer, the service &amp;lt;idl&amp;gt;com.sun.star.configuration.ConfigurationAccess&amp;lt;/idl&amp;gt; is requested to the &amp;lt;idls&amp;gt;com.sun.star.configuration.ConfigurationProvider&amp;lt;/idls&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   public static Object getPDFConfigAccess(XComponentContext xContext){&lt;br /&gt;
        &lt;br /&gt;
        Object oPDFExportConfig = null;&lt;br /&gt;
        try {&lt;br /&gt;
            XMultiComponentFactory xMCF = xContext.getServiceManager();&lt;br /&gt;
&lt;br /&gt;
            // instantiate the ConfigurationProvider at the ServiceManager&lt;br /&gt;
            Object oConfigProvider = xMCF.createInstanceWithContext(&lt;br /&gt;
                    &amp;quot;com.sun.star.configuration.ConfigurationProvider&amp;quot;, xContext);&lt;br /&gt;
&lt;br /&gt;
            // query its XMultiServiceFactory: &lt;br /&gt;
            // the ConfigurationProvider serves as a FACTORY for objects &lt;br /&gt;
            // that provide access to a subset of the configuration.&lt;br /&gt;
            XMultiServiceFactory oConfigProvMSF = &lt;br /&gt;
                    (XMultiServiceFactory) UnoRuntime.queryInterface(&lt;br /&gt;
                XMultiServiceFactory.class, oConfigProvider);&lt;br /&gt;
            &lt;br /&gt;
            // createInstanceWithArguments(sServiceSpecifier, aArguments) &lt;br /&gt;
            // first parameter is the service specifier, in this case for read-only access:&lt;br /&gt;
            String sServiceName = &amp;quot;com.sun.star.configuration.ConfigurationAccess&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
            // createInstanceWithArguments(sServiceSpecifier, aArguments)&lt;br /&gt;
            // second parameter takes a sequence&amp;lt; any &amp;gt; for the arguments, &lt;br /&gt;
            // mapped in Java to Object[]&lt;br /&gt;
            Object[] args = new Object[1];&lt;br /&gt;
&lt;br /&gt;
            // The arguments passed to createInstanceWithArguments() &lt;br /&gt;
            // in parameter aArguments specify the view of the configuration &lt;br /&gt;
            // that should be created.&lt;br /&gt;
            // Each element of the argument sequence should be a &lt;br /&gt;
            // PropertyValue or a NamedValue.&lt;br /&gt;
            &lt;br /&gt;
            // The &amp;quot;nodepath&amp;quot; argument contains the absolute path to &lt;br /&gt;
            // the element of the configuration we want to create a view for.&lt;br /&gt;
            NamedValue  aNodepath= new NamedValue();&lt;br /&gt;
            aNodepath.Name = &amp;quot;nodepath&amp;quot;;&lt;br /&gt;
            aNodepath.Value = &amp;quot;/org.openoffice.Office.Common/Filter/PDF/Export/&amp;quot;;&lt;br /&gt;
            &lt;br /&gt;
            args[0] = aNodepath;&lt;br /&gt;
&lt;br /&gt;
            // create the view&lt;br /&gt;
            oPDFExportConfig = oConfigProvMSF.createInstanceWithArguments(&lt;br /&gt;
                    sServiceName, args);&lt;br /&gt;
            &lt;br /&gt;
        } catch (Exception ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        } finally {&lt;br /&gt;
            return oPDFExportConfig;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The method for creating an &amp;#039;&amp;#039;&amp;#039;updatable&amp;#039;&amp;#039;&amp;#039; view is quite the same as the above, we only have to change the service specifier, so that &amp;lt;idl&amp;gt;com.sun.star.configuration.ConfigurationUpdateAccess&amp;lt;/idl&amp;gt; is requested. In this case, there are other additional creation parameters available that control the caching behavior of the configuration management component, refer to [[Documentation/DevGuide/Config/Using_a_Data_Source|Developer&amp;#039;s Guide - Configuration Mamagement - Using a Data Source]]. In the following sample, we use the defaults:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
    public static Object getPDFConfigUpdateAccess(XComponentContext xContext){&lt;br /&gt;
        &lt;br /&gt;
        Object oPDFExportConfig = null;&lt;br /&gt;
        try {&lt;br /&gt;
            XMultiComponentFactory xMCF = xContext.getServiceManager();&lt;br /&gt;
&lt;br /&gt;
            // instantiate the ConfigurationProvider at the ServiceManager&lt;br /&gt;
            Object oConfigProvider = xMCF.createInstanceWithContext(&lt;br /&gt;
                    &amp;quot;com.sun.star.configuration.ConfigurationProvider&amp;quot;, xContext);&lt;br /&gt;
&lt;br /&gt;
            // query its XMultiServiceFactory: &lt;br /&gt;
            // the ConfigurationProvider serves as a FACTORY for objects &lt;br /&gt;
            // that provide access to a subset of the configuration.&lt;br /&gt;
            XMultiServiceFactory oConfigProvMSF = &lt;br /&gt;
                    (XMultiServiceFactory) UnoRuntime.queryInterface(&lt;br /&gt;
                XMultiServiceFactory.class, oConfigProvider);&lt;br /&gt;
            &lt;br /&gt;
            // createInstanceWithArguments(sServiceSpecifier, aArguments) &lt;br /&gt;
            // first parameter is the service specifier, in this case for UPDATE access:&lt;br /&gt;
            String sServiceName = &amp;quot;com.sun.star.configuration.ConfigurationUpdateAccess&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
            // createInstanceWithArguments(sServiceSpecifier, aArguments)&lt;br /&gt;
            // second parameter takes a sequence&amp;lt; any &amp;gt; for the arguments, &lt;br /&gt;
            // mapped in Java to Object[]&lt;br /&gt;
            Object[] args = new Object[1];&lt;br /&gt;
            &lt;br /&gt;
            // The &amp;quot;nodepath&amp;quot; argument contains the absolute path to &lt;br /&gt;
            // the element of the configuration we want to create a view for.&lt;br /&gt;
            NamedValue  aNodepath= new NamedValue();&lt;br /&gt;
            aNodepath.Name = &amp;quot;nodepath&amp;quot;;&lt;br /&gt;
            aNodepath.Value = &amp;quot;/org.openoffice.Office.Common/Filter/PDF/Export/&amp;quot;;&lt;br /&gt;
            &lt;br /&gt;
            args[0] = aNodepath;&lt;br /&gt;
&lt;br /&gt;
            // create the view&lt;br /&gt;
            oPDFExportConfig = oConfigProvMSF.createInstanceWithArguments(&lt;br /&gt;
                    sServiceName, args);&lt;br /&gt;
            &lt;br /&gt;
        } catch (Exception ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        } finally {&lt;br /&gt;
            return oPDFExportConfig;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Both methods return in the Java sample a &amp;lt;code&amp;gt;java.lang.Object&amp;lt;/code&amp;gt; (use &amp;lt;idl&amp;gt;com.sun.star.uno.XInterface&amp;lt;/idl&amp;gt; in C++, and &amp;lt;code&amp;gt;Object&amp;lt;/code&amp;gt; in OpenOffice.org Basic), as the view implements different interfaces you must query according to your needs.&lt;br /&gt;
&lt;br /&gt;
==Read-only access==&lt;br /&gt;
&lt;br /&gt;
The read-only view of the PDF export filter configuration we accessed with our method, supports the following services:&lt;br /&gt;
&lt;br /&gt;
# &amp;lt;idl&amp;gt;com.sun.star.configuration.ConfigurationAccess&amp;lt;/idl&amp;gt;&lt;br /&gt;
# &amp;lt;idl&amp;gt;com.sun.star.configuration.AccessRootElement&amp;lt;/idl&amp;gt;&lt;br /&gt;
# &amp;lt;idl&amp;gt;com.sun.star.configuration.GroupAccess&amp;lt;/idl&amp;gt;&lt;br /&gt;
# &amp;lt;idl&amp;gt;com.sun.star.configuration.HierarchyAccess&amp;lt;/idl&amp;gt;&lt;br /&gt;
# &amp;lt;idl&amp;gt;com.sun.star.configuration.HierarchyElement&amp;lt;/idl&amp;gt;&lt;br /&gt;
# &amp;lt;idl&amp;gt;com.sun.star.configuration.PropertyHierarchy&amp;lt;/idl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To access the PDF export filter properties we will query &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idl&amp;gt;, and use its methods &amp;lt;idlm&amp;gt;com.sun.star.beans.XPropertySet:getPropertyValue&amp;lt;/idlm&amp;gt; and &amp;lt;idlm&amp;gt;com.sun.star.beans.XPropertySet:getPropertySetInfo&amp;lt;/idlm&amp;gt;. Notice that any attempt to invoke &amp;lt;idlm&amp;gt;com.sun.star.beans.XPropertySet:setPropertyValue&amp;lt;/idlm&amp;gt; will throw an exception, as this is a read-only view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
    public void run(){&lt;br /&gt;
        &lt;br /&gt;
        Object oConfig = getPDFConfigAccess(m_xContext);&lt;br /&gt;
        &lt;br /&gt;
        if (oConfig == null ) {&lt;br /&gt;
            System.out.println(&amp;quot;Impossible to access the PDF configuration&amp;quot;);&lt;br /&gt;
            return;&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(&lt;br /&gt;
                XPropertySet.class, oConfig);&lt;br /&gt;
        &lt;br /&gt;
        XPropertySetInfo xPropertySetInfo = xPropertySet.getPropertySetInfo();&lt;br /&gt;
        &lt;br /&gt;
        Property[] properties = xPropertySetInfo.getProperties();&lt;br /&gt;
        &lt;br /&gt;
        System.out.println(&amp;quot;\nProperties and values\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        for (Property property : properties) {&lt;br /&gt;
            String sValue = &amp;quot;&amp;quot;;&lt;br /&gt;
            try {&lt;br /&gt;
                Object aValue = xPropertySet.getPropertyValue( property.Name );&lt;br /&gt;
                sValue = String.valueOf( aValue );&lt;br /&gt;
            } catch (Exception ex) {&lt;br /&gt;
                ex.printStackTrace();&lt;br /&gt;
            }&lt;br /&gt;
            System.out.println(property.Name + &amp;quot; =\t&amp;quot; + sValue);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Update access==&lt;br /&gt;
&lt;br /&gt;
The &amp;#039;&amp;#039;&amp;#039;updatable&amp;#039;&amp;#039;&amp;#039; view of the PDF export filter configuration we accessed with our method, supports the following services:&lt;br /&gt;
&lt;br /&gt;
# &amp;lt;idl&amp;gt;com.sun.star.configuration.ConfigurationAccess&amp;lt;/idl&amp;gt;&lt;br /&gt;
# &amp;lt;idl&amp;gt;com.sun.star.configuration.ConfigurationUpdateAccess&amp;lt;/idl&amp;gt;&lt;br /&gt;
# &amp;lt;idl&amp;gt;com.sun.star.configuration.AccessRootElement&amp;lt;/idl&amp;gt;&lt;br /&gt;
# &amp;lt;idl&amp;gt;com.sun.star.configuration.UpdateRootElement&amp;lt;/idl&amp;gt;&lt;br /&gt;
# &amp;lt;idl&amp;gt;com.sun.star.configuration.GroupAccess&amp;lt;/idl&amp;gt;&lt;br /&gt;
# &amp;lt;idl&amp;gt;com.sun.star.configuration.GroupUpdate&amp;lt;/idl&amp;gt;&lt;br /&gt;
# &amp;lt;idl&amp;gt;com.sun.star.configuration.HierarchyAccess&amp;lt;/idl&amp;gt;&lt;br /&gt;
# &amp;lt;idl&amp;gt;com.sun.star.configuration.HierarchyElement&amp;lt;/idl&amp;gt;&lt;br /&gt;
# &amp;lt;idl&amp;gt;com.sun.star.configuration.PropertyHierarchy&amp;lt;/idl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To change the configuration properties we proceed as above: query &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idl&amp;gt;, but in this case we are able to invoke &amp;lt;idlm&amp;gt;com.sun.star.beans.XPropertySet:setPropertyValue&amp;lt;/idlm&amp;gt;. Note that for better performance, you should try to use &amp;lt;idlml&amp;gt;com.sun.star.beans.XMultiPropertySet:setPropertyValues&amp;lt;/idlml&amp;gt; instead.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
    public void run() {&lt;br /&gt;
        &lt;br /&gt;
        Object oConfig = getPDFConfigUpdateAccess(m_xContext);&lt;br /&gt;
&lt;br /&gt;
        if (oConfig == null) {&lt;br /&gt;
            System.out.println(&amp;quot;Impossible to access the PDF configuration&amp;quot;);&lt;br /&gt;
            return;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(&lt;br /&gt;
                XPropertySet.class, oConfig);&lt;br /&gt;
        &lt;br /&gt;
        // for better performance use XMultiPropertySet&lt;br /&gt;
        XMultiPropertySet xMultiPropertySet = &lt;br /&gt;
                (XMultiPropertySet) UnoRuntime.queryInterface(&lt;br /&gt;
                    XMultiPropertySet.class, oConfig);&lt;br /&gt;
        &lt;br /&gt;
        try {&lt;br /&gt;
            // change some properties&lt;br /&gt;
            &lt;br /&gt;
            /**&lt;br /&gt;
             * The first property specifies that the resolution of each image&lt;br /&gt;
             * must be reduced to the resolution specified by the second property&lt;br /&gt;
             * The value is given in DPI.&lt;br /&gt;
             */&lt;br /&gt;
            xPropertySet.setPropertyValue(&amp;quot;ReduceImageResolution&amp;quot;, Boolean.TRUE);&lt;br /&gt;
            xPropertySet.setPropertyValue(&amp;quot;MaxImageResolution&amp;quot;, new Integer(600));&lt;br /&gt;
            &lt;br /&gt;
            /**&lt;br /&gt;
             * When exporting a document to PDF, the default is PDF 1.4&lt;br /&gt;
             * Since OOo 2.4 the PDF/A-1a is also supported.&lt;br /&gt;
             * PDF/A-1a is an ISO 19005-1:2005 International Standard.&lt;br /&gt;
             * &lt;br /&gt;
             * NOTE that some other options WILL NOT be available if this format&lt;br /&gt;
             * is selected (UseTaggedPDF, ExportFormFileds, FormsType,&lt;br /&gt;
             * all security options)&lt;br /&gt;
             */&lt;br /&gt;
            xPropertySet.setPropertyValue(&amp;quot;SelectPdfVersion&amp;quot;, new Integer(1));&lt;br /&gt;
            &lt;br /&gt;
            /**&lt;br /&gt;
             * &amp;quot;Magnification&amp;quot; specifies the action to be performed &lt;br /&gt;
             * when the PDF document is opened.&lt;br /&gt;
             * A value of 4 opens with the zoom level specified in the &lt;br /&gt;
             * &amp;quot;Zoom&amp;quot; property.&lt;br /&gt;
             */&lt;br /&gt;
            xPropertySet.setPropertyValue(&amp;quot;Magnification&amp;quot;, new Integer(4));&lt;br /&gt;
            xPropertySet.setPropertyValue(&amp;quot;Zoom&amp;quot;, new Integer(60));&lt;br /&gt;
            &lt;br /&gt;
            // When using XMultiPropertySet:setPropertyValues(),&lt;br /&gt;
            // properties must be alphabetically sorted!&lt;br /&gt;
            String[] aProperties = { &amp;quot;CenterWindow&amp;quot;, &amp;quot;DisplayPDFDocumentTitle&amp;quot;, &lt;br /&gt;
                    &amp;quot;InitialView&amp;quot;, &amp;quot;PageLayout&amp;quot; };&lt;br /&gt;
            Object[] aValues = { Boolean.TRUE, Boolean.FALSE, &lt;br /&gt;
                    new Integer(2), new Integer(1)};&lt;br /&gt;
            &lt;br /&gt;
            xMultiPropertySet.setPropertyValues(aProperties, aValues);&lt;br /&gt;
            &lt;br /&gt;
            // commit the changes, otherwise they will be lost!&lt;br /&gt;
            XChangesBatch xChangesBatch = (XChangesBatch) UnoRuntime.queryInterface(&lt;br /&gt;
                    XChangesBatch.class, oConfig);&lt;br /&gt;
            &lt;br /&gt;
            xChangesBatch.commitChanges();&lt;br /&gt;
            &lt;br /&gt;
        } catch (UnknownPropertyException ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        } catch (PropertyVetoException ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        } catch (IllegalArgumentException ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        } catch (WrappedTargetException ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resetting the configuration==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Setting the configuration to its default values is very simple, just query the &amp;lt;idls&amp;gt;com.sun.star.configuration.ConfigurationUpdateAccess&amp;lt;/idls&amp;gt;&amp;#039;s &amp;lt;idl&amp;gt;com.sun.star.beans.XMultiPropertyStates&amp;lt;/idl&amp;gt;, and use its method &amp;lt;idlm&amp;gt;com.sun.star.beans.XMultiPropertyStates:setAllPropertiesToDefault&amp;lt;/idlm&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
        // get an updatable view&lt;br /&gt;
        Object oConfig = ConfigUpdateAccess.getPDFConfigUpdateAccess(m_xContext);&lt;br /&gt;
&lt;br /&gt;
        if (oConfig == null) {&lt;br /&gt;
            System.out.println(&amp;quot;Impossible to access the PDF configuration&amp;quot;);&lt;br /&gt;
            return;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        XMultiPropertyStates xMultiPropertyStates = &lt;br /&gt;
                (XMultiPropertyStates) UnoRuntime.queryInterface(&lt;br /&gt;
                XMultiPropertyStates.class, oConfig);&lt;br /&gt;
        try {&lt;br /&gt;
            // set all the properties to default values&lt;br /&gt;
            xMultiPropertyStates.setAllPropertiesToDefault();&lt;br /&gt;
&lt;br /&gt;
            //you must commit the changes, if not they will be lost&lt;br /&gt;
            XChangesBatch xChangesBatch = (XChangesBatch) UnoRuntime.queryInterface(&lt;br /&gt;
                    XChangesBatch.class, xMultiPropertyStates);&lt;br /&gt;
&lt;br /&gt;
            xChangesBatch.commitChanges();&lt;br /&gt;
            &lt;br /&gt;
        } catch (WrappedTargetException ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=PDF Export Dialog=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How to use it from Java==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import com.sun.star.beans.PropertyValue;&lt;br /&gt;
import com.sun.star.beans.XPropertyAccess;&lt;br /&gt;
import com.sun.star.io.IOException;&lt;br /&gt;
import com.sun.star.uno.XComponentContext;&lt;br /&gt;
import com.sun.star.comp.helper.Bootstrap;&lt;br /&gt;
import com.sun.star.document.XExporter;&lt;br /&gt;
import com.sun.star.frame.XComponentLoader;&lt;br /&gt;
import com.sun.star.frame.XStorable;&lt;br /&gt;
import com.sun.star.lang.XComponent;&lt;br /&gt;
import com.sun.star.lang.XMultiComponentFactory;&lt;br /&gt;
import com.sun.star.ui.dialogs.ExecutableDialogResults;&lt;br /&gt;
import com.sun.star.ui.dialogs.XExecutableDialog;&lt;br /&gt;
import com.sun.star.uno.AnyConverter;&lt;br /&gt;
import com.sun.star.uno.UnoRuntime;&lt;br /&gt;
import com.sun.star.util.CloseVetoException;&lt;br /&gt;
import com.sun.star.util.XCloseable;&lt;br /&gt;
import com.sun.star.util.XStringSubstitution;&lt;br /&gt;
&lt;br /&gt;
public class PDFExportDialog {&lt;br /&gt;
&lt;br /&gt;
    private final XComponentContext m_xContext;&lt;br /&gt;
    &lt;br /&gt;
    public PDFExportDialog(XComponentContext xContext){&lt;br /&gt;
        m_xContext = xContext;        &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static void main(String[] args) {&lt;br /&gt;
        try {&lt;br /&gt;
            // get the remote office component context&lt;br /&gt;
            XComponentContext xContext = Bootstrap.bootstrap();&lt;br /&gt;
            &lt;br /&gt;
            PDFExportDialog demo = new PDFExportDialog(xContext);&lt;br /&gt;
            demo.run();&lt;br /&gt;
            &lt;br /&gt;
        } catch (java.lang.Exception e){&lt;br /&gt;
            e.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
        finally {&lt;br /&gt;
            System.exit( 0 );&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void run() {&lt;br /&gt;
&lt;br /&gt;
        XMultiComponentFactory xMCF = m_xContext.getServiceManager();&lt;br /&gt;
&lt;br /&gt;
        Object oPDFDialog = null;&lt;br /&gt;
&lt;br /&gt;
        try {&lt;br /&gt;
            oPDFDialog = xMCF.createInstanceWithContext(&lt;br /&gt;
                    &amp;quot;com.sun.star.document.PDFDialog&amp;quot;, m_xContext);&lt;br /&gt;
        } catch (com.sun.star.uno.Exception ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        // get all interface references&lt;br /&gt;
        XExecutableDialog xExecutableDialog = &lt;br /&gt;
                (XExecutableDialog) UnoRuntime.queryInterface(&lt;br /&gt;
                    XExecutableDialog.class, oPDFDialog);&lt;br /&gt;
&lt;br /&gt;
        XExporter xExporter = (XExporter) UnoRuntime.queryInterface(&lt;br /&gt;
                XExporter.class, xExecutableDialog);&lt;br /&gt;
&lt;br /&gt;
        XPropertyAccess xPropertyAccess = &lt;br /&gt;
                (XPropertyAccess) UnoRuntime.queryInterface(&lt;br /&gt;
                    XPropertyAccess.class, xExporter);&lt;br /&gt;
        &lt;br /&gt;
        // check them all&lt;br /&gt;
        if (xExecutableDialog == null || &lt;br /&gt;
                xExporter == null || xPropertyAccess == null) {&lt;br /&gt;
            System.out.println(&amp;quot;something went wrong with the PDFDialog!&amp;quot;);&lt;br /&gt;
            return;&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        XComponent xComponent = null;&lt;br /&gt;
        try {&lt;br /&gt;
            // change the following to test with different doc. types&lt;br /&gt;
            // but remember to change the filter name below&lt;br /&gt;
            xComponent = createNewDoc(m_xContext, &amp;quot;swriter&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            // set the source document&lt;br /&gt;
            xExporter.setSourceDocument(xComponent);&lt;br /&gt;
&lt;br /&gt;
            // set the title&lt;br /&gt;
            xExecutableDialog.setTitle(&amp;quot;Demo Export PDF Dialog OOo API&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            // execute the dialog&lt;br /&gt;
            int nResult = xExecutableDialog.execute();&lt;br /&gt;
&lt;br /&gt;
            if (nResult != ExecutableDialogResults.OK) {&lt;br /&gt;
                System.out.println(&amp;quot;you didn&amp;#039;t press OK! so do nothing...&amp;quot;);&lt;br /&gt;
                return;&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            // get the options the user has choosen&lt;br /&gt;
            PropertyValue[] aFilterData = null;&lt;br /&gt;
&lt;br /&gt;
            PropertyValue[] aPropertyValues = xPropertyAccess.getPropertyValues();&lt;br /&gt;
            for (int i = 0; i &amp;lt; aPropertyValues.length; i++) {&lt;br /&gt;
                PropertyValue propertyValue = aPropertyValues[i];&lt;br /&gt;
                if (propertyValue.Name.equals(&amp;quot;FilterData&amp;quot;)) {&lt;br /&gt;
                    try {&lt;br /&gt;
                        aFilterData = (PropertyValue[]) AnyConverter.toObject(&lt;br /&gt;
                                PropertyValue[].class, propertyValue.Value);&lt;br /&gt;
&lt;br /&gt;
                    } catch (com.sun.star.lang.IllegalArgumentException ex) {&lt;br /&gt;
                        ex.printStackTrace();&lt;br /&gt;
                    }&lt;br /&gt;
                    break;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            if (aFilterData != null) {&lt;br /&gt;
                // print the properties and their values&lt;br /&gt;
                printPropertyValues(aFilterData);&lt;br /&gt;
                &lt;br /&gt;
                // finally export!                &lt;br /&gt;
                // location where to export the doc.&lt;br /&gt;
                String sURL = getHomeDir(m_xContext) + &amp;quot;/PDF_EXPORT_DIALOG_demo.pdf&amp;quot;;                &lt;br /&gt;
                // choose the proper filter            &lt;br /&gt;
                String sFilter = &amp;quot;writer_pdf_Export&amp;quot;;&lt;br /&gt;
                &lt;br /&gt;
                boolean bExport = doExport(xComponent, sURL, sFilter, aFilterData);&lt;br /&gt;
                &lt;br /&gt;
                System.out.println( (bExport) ? &amp;quot;\nExported!&amp;quot; : &lt;br /&gt;
                    &amp;quot;\nCouldn&amp;#039;t export the document!&amp;quot; );&lt;br /&gt;
            }&lt;br /&gt;
            &lt;br /&gt;
        } catch (java.lang.Exception ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        } finally {&lt;br /&gt;
            if (xComponent != null) {&lt;br /&gt;
                try {&lt;br /&gt;
                    XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(&lt;br /&gt;
                            XCloseable.class, xComponent);&lt;br /&gt;
                    xCloseable.close(true);&lt;br /&gt;
                } catch (CloseVetoException ex) {&lt;br /&gt;
                    ex.printStackTrace();&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    private boolean doExport(&lt;br /&gt;
                                XComponent xComponent,&lt;br /&gt;
                                String aURL,&lt;br /&gt;
                                String sFilterName,&lt;br /&gt;
                                PropertyValue[] aFilterData)&lt;br /&gt;
    {&lt;br /&gt;
        XStorable xStorable = (XStorable) UnoRuntime.queryInterface(&lt;br /&gt;
                XStorable.class, xComponent);&lt;br /&gt;
        if (xStorable == null) {&lt;br /&gt;
            return false;&lt;br /&gt;
        } else {&lt;br /&gt;
            try {&lt;br /&gt;
                PropertyValue[] aMediaDescriptor = new PropertyValue[2];&lt;br /&gt;
&lt;br /&gt;
                aMediaDescriptor[0] = new PropertyValue();&lt;br /&gt;
                aMediaDescriptor[0].Name = &amp;quot;FilterName&amp;quot;;&lt;br /&gt;
                aMediaDescriptor[0].Value = sFilterName;&lt;br /&gt;
&lt;br /&gt;
                aMediaDescriptor[1] = new PropertyValue();&lt;br /&gt;
                aMediaDescriptor[1].Name = &amp;quot;FilterData&amp;quot;;&lt;br /&gt;
                aMediaDescriptor[1].Value = aFilterData;&lt;br /&gt;
&lt;br /&gt;
                xStorable.storeToURL(aURL, aMediaDescriptor);                &lt;br /&gt;
                return true;&lt;br /&gt;
                &lt;br /&gt;
            } catch (IOException ex) {&lt;br /&gt;
                ex.printStackTrace();&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return false;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static void printPropertyValues(PropertyValue[] aPropertyValues) &lt;br /&gt;
    {&lt;br /&gt;
        System.out.println(&amp;quot;\nProperties and values\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        for (PropertyValue property : aPropertyValues) {&lt;br /&gt;
            String sValue = &amp;quot;&amp;quot;;&lt;br /&gt;
            try {&lt;br /&gt;
                sValue = String.valueOf(property.Value);&lt;br /&gt;
            } catch (Exception ex) {&lt;br /&gt;
                ex.printStackTrace();&lt;br /&gt;
            }&lt;br /&gt;
            System.out.println(property.Name + &amp;quot; = &amp;quot; + sValue);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    //*************************************************************************&lt;br /&gt;
    &lt;br /&gt;
    public static XComponent loadComponent(&lt;br /&gt;
                                    XComponentContext xContext, &lt;br /&gt;
                                    String sURL, &lt;br /&gt;
                                    PropertyValue[] aMediaDescriptor)&lt;br /&gt;
    {&lt;br /&gt;
        XComponent xComp = null;&lt;br /&gt;
        try {&lt;br /&gt;
            XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface(&lt;br /&gt;
                    XComponentLoader.class, &lt;br /&gt;
                    xContext.getServiceManager().createInstanceWithContext(&lt;br /&gt;
                    &amp;quot;com.sun.star.frame.Desktop&amp;quot;, xContext));&lt;br /&gt;
            xComp = xComponentLoader.loadComponentFromURL(&lt;br /&gt;
                    sURL, &amp;quot;_default&amp;quot;, 0, aMediaDescriptor);&lt;br /&gt;
        } catch (Exception ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
        return xComp;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static XComponent createNewDoc(&lt;br /&gt;
                                    XComponentContext xContext, &lt;br /&gt;
                                    String sDocType, &lt;br /&gt;
                                    PropertyValue[] aMediaDescriptor)&lt;br /&gt;
    {&lt;br /&gt;
        XComponent xComp = null;&lt;br /&gt;
        try {&lt;br /&gt;
            xComp = loadComponent(xContext, &amp;quot;private:factory/&amp;quot; + &lt;br /&gt;
                    sDocType, aMediaDescriptor);&lt;br /&gt;
        } catch (Exception ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
        return xComp;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static XComponent createNewDoc(&lt;br /&gt;
                                    XComponentContext xContext, &lt;br /&gt;
                                    String sDocType)&lt;br /&gt;
    {&lt;br /&gt;
        XComponent xComp = null;&lt;br /&gt;
        try {&lt;br /&gt;
            xComp = createNewDoc(xContext, sDocType, new PropertyValue[0]);&lt;br /&gt;
        } catch (Exception ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
        return xComp;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static XComponent createNewHiddenDoc(&lt;br /&gt;
                                    XComponentContext xContext, &lt;br /&gt;
                                    String sDocType)&lt;br /&gt;
    {&lt;br /&gt;
        XComponent xComp = null;&lt;br /&gt;
        try {&lt;br /&gt;
            PropertyValue[] aMediaDescriptor = new PropertyValue[1];&lt;br /&gt;
            aMediaDescriptor[0] = new PropertyValue();&lt;br /&gt;
            aMediaDescriptor[0].Name = &amp;quot;Hidden&amp;quot;;&lt;br /&gt;
            aMediaDescriptor[0].Value = Boolean.TRUE;&lt;br /&gt;
            &lt;br /&gt;
            xComp = createNewDoc(xContext, sDocType, aMediaDescriptor);&lt;br /&gt;
            &lt;br /&gt;
        } catch (Exception ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
        return xComp;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //************************************************************************&lt;br /&gt;
    //*************************************************************************&lt;br /&gt;
    &lt;br /&gt;
    public static String getHomeDir(XComponentContext xContext) {&lt;br /&gt;
        return getPathSubstitution(xContext, &amp;quot;$(home)&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public static String getWorkDir(XComponentContext xContext) {&lt;br /&gt;
        return getPathSubstitution(xContext, &amp;quot;$(work)&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public static String getUserDir(XComponentContext xContext) {&lt;br /&gt;
        return getPathSubstitution(xContext, &amp;quot;$(user)&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     *&lt;br /&gt;
     *      com.sun.star.util.PathSubstitution&lt;br /&gt;
     *&lt;br /&gt;
     *      $(inst)     Installation path of the Office. &lt;br /&gt;
     *      $(prog)     Program path of the Office. &lt;br /&gt;
     *      $(user)     The user installation directory. &lt;br /&gt;
     *      $(work)     The work directory of the user. &lt;br /&gt;
     *                      Under Windows this would be the &amp;quot;MyDocuments&amp;quot; subdirectory. &lt;br /&gt;
     *                      Under Unix this would be the home-directory&lt;br /&gt;
     *      $(home)     The home directory of the user.&lt;br /&gt;
     *                      Under Unix this would be the home- directory. &lt;br /&gt;
     *                      Under Windows this would be the &amp;quot;Documents and Settings\ &amp;quot; subdirectory.&lt;br /&gt;
     *      $(temp)     The current temporary directory. &lt;br /&gt;
     *      $(path)     The value of PATH environment variable.&lt;br /&gt;
     *      $(lang)     The country code used by the Office, like &lt;br /&gt;
     *                      01=english, &lt;br /&gt;
     *                      49=german.&lt;br /&gt;
     *      $(langid)   The language code used by the Office, like &lt;br /&gt;
     *                      0x0009=english, &lt;br /&gt;
     *                      0x0409=english us.&lt;br /&gt;
     *      $(vlang)    The language used by the Office as a string. Like &lt;br /&gt;
     *                      &amp;quot;german&amp;quot; for a german Office.&lt;br /&gt;
     *&lt;br /&gt;
     */    &lt;br /&gt;
    public static String getPathSubstitution(&lt;br /&gt;
            XComponentContext xContext, String aVariable)&lt;br /&gt;
    {&lt;br /&gt;
        String variableSubst = null;&lt;br /&gt;
        try {&lt;br /&gt;
            XStringSubstitution xStringSubstitution = getPathSubstitution(xContext);&lt;br /&gt;
            variableSubst = xStringSubstitution.getSubstituteVariableValue(aVariable);                &lt;br /&gt;
            &lt;br /&gt;
        } catch (com.sun.star.container.NoSuchElementException e) {&lt;br /&gt;
            e.printStackTrace();&lt;br /&gt;
        } catch (com.sun.star.uno.Exception ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        } finally {&lt;br /&gt;
            return variableSubst;&lt;br /&gt;
        }        &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static String getPathSubstitution(&lt;br /&gt;
            XComponentContext xContext, String aText, boolean bSubstRequired)&lt;br /&gt;
    {&lt;br /&gt;
        String variableSubst = null;&lt;br /&gt;
        try {&lt;br /&gt;
            XStringSubstitution xStringSubstitution = getPathSubstitution(xContext);&lt;br /&gt;
            variableSubst = xStringSubstitution.substituteVariables(&lt;br /&gt;
                    aText, bSubstRequired);                &lt;br /&gt;
            &lt;br /&gt;
        } catch (com.sun.star.container.NoSuchElementException e) {&lt;br /&gt;
            e.printStackTrace();&lt;br /&gt;
        } catch (Exception ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        } finally {&lt;br /&gt;
            return variableSubst;&lt;br /&gt;
        }        &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static XStringSubstitution getPathSubstitution(&lt;br /&gt;
                                                XComponentContext xContext)&lt;br /&gt;
    {&lt;br /&gt;
        XStringSubstitution xPathSubstitution = null;        &lt;br /&gt;
        XMultiComponentFactory xMCF = xContext.getServiceManager();        &lt;br /&gt;
        try {&lt;br /&gt;
            xPathSubstitution = (XStringSubstitution) UnoRuntime.queryInterface(&lt;br /&gt;
                    XStringSubstitution.class, &lt;br /&gt;
                    xMCF.createInstanceWithContext(&lt;br /&gt;
                        &amp;quot;com.sun.star.util.PathSubstitution&amp;quot;, xContext));            &lt;br /&gt;
        } catch (com.sun.star.uno.Exception ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        } finally {&lt;br /&gt;
            return xPathSubstitution;&lt;br /&gt;
        }        &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==How to use it from C++==&lt;br /&gt;
&lt;br /&gt;
ToDo&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How to use it from OOo Basic==&lt;br /&gt;
&lt;br /&gt;
ToDo&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
[[Category:API]]&lt;br /&gt;
[[Category:Tutorial]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/Filter&amp;diff=158068</id>
		<title>Documentation/DevGuide/OfficeDev/Filter</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/Filter&amp;diff=158068"/>
		<updated>2010-02-26T06:22:50Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/OfficeDevTOC&lt;br /&gt;
|OfficeDev2b=block&lt;br /&gt;
|OfficeDevInteg=block&lt;br /&gt;
|OfficeDevDocFilter=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/OfficeDev/Filtering Process&lt;br /&gt;
|NextPage=Documentation/DevGuide/OfficeDev/Configuring a Filter in OpenOffice.org&lt;br /&gt;
}}&lt;br /&gt;
{{Documentation/DevGuideLanguages|Documentation/DevGuide/OfficeDev/{{SUBPAGENAME}}}} &lt;br /&gt;
 {{DISPLAYTITLE:Filters}}&lt;br /&gt;
&lt;br /&gt;
As described in the previous chapter, filters are objects that can be used to import or export content into or from {{PRODUCTNAME}} documents. The API defines the two services &amp;lt;idl&amp;gt;com.sun.star.document.ImportFilter&amp;lt;/idl&amp;gt; and &amp;lt;idl&amp;gt;com.sun.star.document.ExportFilter&amp;lt;/idl&amp;gt;. A filter implementation can support one or both of them. If a particular filter that only supports import is used, the imported document is modified by the user and then the user presses the &amp;quot;Save&amp;quot; button, a &amp;quot;Save As&amp;quot; operation will be carried out instead as {{PRODUCTNAME}} must assume that the filter component is &amp;quot;import only&amp;quot; and so storing must be done in a different format. It doesn&amp;#039;t help to have a different export filter for the same content. If a direct &amp;quot;Save&amp;quot; operation should be possible, both filter services must be supported at the same filter object.&lt;br /&gt;
&lt;br /&gt;
A filter is created from the factory service &amp;lt;idl&amp;gt;com.sun.star.document.FilterFactory&amp;lt;/idl&amp;gt;. This service also provides a low-level access to the configuration that knows all registered filters of {{PRODUCTNAME}} and their properties, supports search and query functionality, and creates and initializes filter components. As an example, if the type name of a content is known, a query at the FilterFactory can be used to retrieve one or more internal filter names of possible filters and after chosing one of them the filter can be created using this name.&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|Many existing filters are legacy filters. The component loader or &amp;lt;code&amp;gt;XStorable&amp;lt;/code&amp;gt; implementation does not use the &amp;lt;code&amp;gt;FilterFactory&amp;lt;/code&amp;gt; to create them, but triggers filtering by internal C++ calls. So asking the FilterFactory to create such filter is not possible.}}&lt;br /&gt;
&lt;br /&gt;
Filters can be initialized if they implement the interface &amp;lt;idl&amp;gt;com.sun.star.lang.XInitialization&amp;lt;/idl&amp;gt;. The method &amp;lt;code&amp;gt;initialize()&amp;lt;/code&amp;gt; is used by the filter factory service directly after creation of the filter object, before the filter is returned to the code that requested the filter. It passes the configuration data of the filter and all parameters and options that have been specified by the creation request to the factory. These properties usually originate from the &amp;quot;FilterOptions&amp;quot; property of the MediaDescriptor and have been put there either by the code requesting the loading or storing or by user input in a filter options dialog. How such filter dialog can be implemented is explained in the chapter about [[Documentation/DevGuide/OfficeDev/Filter_Options|filter options]].&lt;br /&gt;
&lt;br /&gt;
The parameter list of &amp;lt;code&amp;gt;initialize()&amp;lt;/code&amp;gt; uses the following protocol: &lt;br /&gt;
&lt;br /&gt;
* The first item in the list is a sequence of &amp;lt;idl&amp;gt;com.sun.star.beans.PropertyValue&amp;lt;/idl&amp;gt; structs, that describe the configuration properties of the filter.&lt;br /&gt;
* All other items are directly copied from the parameter Arguments of the factory interface method &amp;lt;idlml&amp;gt;com.sun.star.lang.XMultiServiceFactory:createInstanceWithArguments&amp;lt;/idlml&amp;gt;().&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Caution|The interface provides functionality for reading and writing of this name. It is not allowed to change an internal filter name during runtime of {{PRODUCTNAME}}, because all filter names must be unique and it is not possible for a filter instance to alter its name. Calls to &amp;lt;idlml&amp;gt;com.sun.star.container.XNamed:setName&amp;lt;/idlml&amp;gt;() should be ignored or forwarded to the &amp;lt;tt&amp;gt;FilterFactory&amp;lt;/tt&amp;gt; service, which knows all unique names and can solve ambiguities!}}&lt;br /&gt;
&lt;br /&gt;
The fact that a filter gets its own name passed as an argument can be used to use one filter implementation to act as several filters in the configuration. This is shown in the following code snippet of the implementation of a filter initialization:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  private String m_sInternalName;&lt;br /&gt;
  public void initialize( Object[] lArguments )  &lt;br /&gt;
          throws com.sun.star.uno.Exception &lt;br /&gt;
  {  &lt;br /&gt;
          // no arguments - no initialization  &lt;br /&gt;
          if (lArguments.length&amp;lt;1)&lt;br /&gt;
                  return;&lt;br /&gt;
          // Arguments[0] = own configuration data&lt;br /&gt;
          com.sun.star.beans.PropertyValue[] lConfig =&lt;br /&gt;
                  (com.sun.star.beans.PropertyValue[])lArguments[0];&lt;br /&gt;
          &lt;br /&gt;
          // Arguments[1..n] = optional arguments of create request &lt;br /&gt;
          for (int n=1; n&amp;lt;lArguments.length; ++n)&lt;br /&gt;
          {&lt;br /&gt;
                  ...&lt;br /&gt;
          }  &lt;br /&gt;
          &lt;br /&gt;
          // analyze own configuration data for our own internal  &lt;br /&gt;
          // filter name! Important for generic filter services,  &lt;br /&gt;
          // which are registered more then once. They can use this  &lt;br /&gt;
          // information to find out, which specialization of it  &lt;br /&gt;
          // is required.  &lt;br /&gt;
          for (int i=0; i&amp;lt;lConfig.length; ++i)  &lt;br /&gt;
          {   &lt;br /&gt;
                  if (lConfig[i].Name.equals(&amp;quot;Name&amp;quot;))   &lt;br /&gt;
                  {    &lt;br /&gt;
                          m_sInternalName =     &lt;br /&gt;
                                  AnyConverter.toString(lConfig[i].Value);&lt;br /&gt;
          &lt;br /&gt;
                          // Tip: A generic filter implementation can use this internal    &lt;br /&gt;
                          // name at runtime, to detect which specialization of it is required.&lt;br /&gt;
                          if (m_sInternalName==&amp;quot;filter_format_1&amp;quot;)     &lt;br /&gt;
                                  m_eHandle = E_FORMAT_1;    &lt;br /&gt;
                          else     &lt;br /&gt;
                          if (m_sInternalName==&amp;quot;filter_format_2&amp;quot;)&lt;br /&gt;
                                  ...   &lt;br /&gt;
                  }  &lt;br /&gt;
          } &lt;br /&gt;
  }&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In one single workflow filters can act as an import or an export filter. If content is loaded, the creator of the filter will use the &amp;lt;idl&amp;gt;com.sun.star.document.XImporter&amp;lt;/idl&amp;gt; interface and its method &amp;lt;code&amp;gt;setTargetDocument()&amp;lt;/code&amp;gt; to bind the filter to the document it should import into. If content is stored, the interface &amp;lt;idl&amp;gt;com.sun.star.document.XExporter&amp;lt;/idl&amp;gt; and its method &amp;lt;code&amp;gt;setSourceDocument()&amp;lt;/code&amp;gt; will bind the filter to the document it shall get data from. The filtering process is done by the same method in both cases: it&amp;#039;s the &amp;lt;code&amp;gt;filter()&amp;lt;/code&amp;gt; method of the &amp;lt;idl&amp;gt;com.sun.star.document.XFilter&amp;lt;/idl&amp;gt; interface that both kinds of filters must support. Here the &amp;lt;code&amp;gt;MediaDescriptor&amp;lt;/code&amp;gt; is passed to the filter.&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Tip|In an object that implements both import and export it is necessary to decide whether importing or exporting is asked for when the &amp;lt;tt&amp;gt;filter()&amp;lt;/tt&amp;gt; method is called. The differentiator is whether setTargetDocument or setSourceDocument has been called before (see sample code below). The user of a filter is responsible to make this call in a valid order.}}&lt;br /&gt;
&lt;br /&gt;
This example code shows how the required filter operation can be tracked inside the filter implementation easily: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--[SOURCE:OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java]--&amp;gt;&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  private boolean m_bImport;&lt;br /&gt;
  &lt;br /&gt;
  // used to tell us: &amp;quot;you will be used for import&amp;quot; &lt;br /&gt;
  public void setTargetDocument( &lt;br /&gt;
    com.sun.star.lang.XComponent xDocument ) &lt;br /&gt;
      throws com.sun.star.lang.IllegalArgumentException &lt;br /&gt;
  { &lt;br /&gt;
      m_bImport = true;&lt;br /&gt;
  }&lt;br /&gt;
    &lt;br /&gt;
  // used to tell us: &amp;quot;you will be used for export&amp;quot; &lt;br /&gt;
  public void setSourceDocument( &lt;br /&gt;
    com.sun.star.lang.XComponent xDocument ) &lt;br /&gt;
      throws com.sun.star.lang.IllegalArgumentException &lt;br /&gt;
  { &lt;br /&gt;
      m_bImport = false; &lt;br /&gt;
  }  &lt;br /&gt;
  &lt;br /&gt;
  // detect required type of filter operation &lt;br /&gt;
  public boolean filter( &lt;br /&gt;
    com.sun.star.beans.PropertyValue[] lDescriptor ) &lt;br /&gt;
  { &lt;br /&gt;
       boolean bState; &lt;br /&gt;
       if (m_bImport) &lt;br /&gt;
         bState = impl_import( lDescriptor ); &lt;br /&gt;
       else &lt;br /&gt;
         bState = impl_export( lDescriptor ); &lt;br /&gt;
       return bState; &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/Office Development]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=PyUNO_samples&amp;diff=158042</id>
		<title>PyUNO samples</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=PyUNO_samples&amp;diff=158042"/>
		<updated>2010-02-25T09:24:50Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/Candidate}}&lt;br /&gt;
OpenOffice.org comes with a set of scripts that work as a sample on how to programmatically generate certain tasks using PyUNO.&lt;br /&gt;
&lt;br /&gt;
=== Hello World.py ===&lt;br /&gt;
This script print a Hello World in an Writer document. This uses the [http://api.openoffice.org/docs/common/ref/com/sun/star/text/XText.html XText] interface, the actual content is on the String value of the [http://api.openoffice.org/docs/common/ref/com/sun/star/text/XTextRange.html XTextRange]. &lt;br /&gt;
&lt;br /&gt;
First step we define the HelloWorldPython() class, then we call the XSCRIPTCONTEXT which will let us work within a sub-environment from UNO. Notice we didn&amp;#039;t import uno and we don&amp;#039;t need to connect to OOo through the socket. Also we have the uno environment by calling getDocument(). &lt;br /&gt;
&lt;br /&gt;
Then we call the XText interface to call on the END and STRING methods to write up the &amp;quot;Hello World (in Python)&amp;quot;.&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
# HelloWorld python script for the scripting framework&lt;br /&gt;
&lt;br /&gt;
def HelloWorldPython( ):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Prints the string &amp;#039;Hello World(in Python)&amp;#039; into the current document&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
#get the doc from the scripting context which is made available to all scripts&lt;br /&gt;
    model = XSCRIPTCONTEXT.getDocument()&lt;br /&gt;
#get the XText interface&lt;br /&gt;
    text = model.Text&lt;br /&gt;
#create an XTextRange at the end of the document&lt;br /&gt;
    tRange = text.End&lt;br /&gt;
#and set the string&lt;br /&gt;
    tRange.String = &amp;quot;Hello World (in Python)&amp;quot;&lt;br /&gt;
    return None&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Capitalize.py ===&lt;br /&gt;
This script will show how to modify existing content in a document. More specifically manipulate the format values from the text. We use common python string methods like &amp;#039;&amp;#039;&amp;#039;isupper, upper, len and lower&amp;#039;&amp;#039;&amp;#039;. And we use XSCRIPTCONTEXT (Learn about the [http://api.openoffice.org/docs/DevelopersGuide/ScriptingFramework/ScriptingFramework.xhtml XSCRIPTCONTEXT]) for the positioning of the text ([http://api.openoffice.org/docs/common/ref/com/sun/star/text/XText.html XText] and [http://api.openoffice.org/docs/common/ref/com/sun/star/text/XTextRange.html XTextRange] ), the control of the cursor ([http://api.openoffice.org/docs/common/ref/com/sun/star/text/XWordCursor.html xWordCursor]).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
# helper function&lt;br /&gt;
def getNewString( theString ) :&lt;br /&gt;
    if not theString or len(theString) ==0 :&lt;br /&gt;
        return &amp;quot;&amp;quot;&lt;br /&gt;
    # should we tokenize on &amp;quot;.&amp;quot;?&lt;br /&gt;
    if theString[0].isupper() and len(theString)&amp;gt;=2 and theString[1].isupper() :&lt;br /&gt;
	# first two chars are UC =&amp;gt; first UC, rest LC&lt;br /&gt;
        newString=theString.capitalize();&lt;br /&gt;
    elif theString[0].isupper():&lt;br /&gt;
	# first char UC =&amp;gt; all to LC&lt;br /&gt;
        newString=theString.lower()&lt;br /&gt;
    else: # all to UC.&lt;br /&gt;
        newString=theString.upper()&lt;br /&gt;
    return newString;&lt;br /&gt;
&lt;br /&gt;
def capitalisePython( ): &lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Change the case of a selection, or current word from upper case, to first char upper case, to all lower case to upper case...&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    # The context variable is of type XScriptContext and is available to&lt;br /&gt;
    # all BeanShell scripts executed by the Script Framework&lt;br /&gt;
    xModel = XSCRIPTCONTEXT.getDocument()&lt;br /&gt;
&lt;br /&gt;
    #the writer controller impl supports the css.view.XSelectionSupplier interface&lt;br /&gt;
    xSelectionSupplier = xModel.getCurrentController()&lt;br /&gt;
&lt;br /&gt;
    #see section 7.5.1 of developers&amp;#039; guide&lt;br /&gt;
    xIndexAccess = xSelectionSupplier.getSelection()&lt;br /&gt;
    count = xIndexAccess.getCount();&lt;br /&gt;
    for i in range(count) :&lt;br /&gt;
        xTextRange = xIndexAccess.getByIndex(i);&lt;br /&gt;
        #print &amp;quot;string: &amp;quot; + xTextRange.getString();&lt;br /&gt;
        theString = xTextRange.getString();&lt;br /&gt;
        if len(theString)==0 :&lt;br /&gt;
            # sadly we can have a selection where nothing is selected&lt;br /&gt;
            # in this case we get the XWordCursor and make a selection!&lt;br /&gt;
            xText = xTextRange.getText();&lt;br /&gt;
            xWordCursor = xText.createTextCursorByRange(xTextRange);&lt;br /&gt;
            if not xWordCursor.isStartOfWord():&lt;br /&gt;
                xWordCursor.gotoStartOfWord(False);&lt;br /&gt;
            xWordCursor.gotoNextWord(True);&lt;br /&gt;
            theString = xWordCursor.getString();&lt;br /&gt;
            newString = getNewString(theString);&lt;br /&gt;
            if newString :&lt;br /&gt;
                xWordCursor.setString(newString);&lt;br /&gt;
                xSelectionSupplier.select(xWordCursor);&lt;br /&gt;
        else :&lt;br /&gt;
            newString = getNewString( theString );&lt;br /&gt;
            if newString:&lt;br /&gt;
                xTextRange.setString(newString);&lt;br /&gt;
                xSelectionSupplier.select(xTextRange);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# lists the scripts, that shall be visible inside OOo. Can be omitted, if&lt;br /&gt;
# all functions shall be visible, however here getNewString shall be suppressed&lt;br /&gt;
g_exportedScripts = capitalisePython,&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== TableSample.py ===&lt;br /&gt;
&lt;br /&gt;
On this script we abandon the XSCRIPTCONTEXT and use the UNO module. We also use nested modules from Text, AWT, and LANG. Since we using the UNO module we have to import what we need straight from the com.sun.star path. &lt;br /&gt;
&lt;br /&gt;
The first step is to get the functions for generating the document, and the other for manipulating the content. The document and content is under the &amp;#039;&amp;#039;&amp;#039;createTable()&amp;#039;&amp;#039;&amp;#039;, while &amp;#039;&amp;#039;&amp;#039;insertTextIntoCell()&amp;#039;&amp;#039;&amp;#039; will handle the positioning within the table.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
import uno&lt;br /&gt;
&lt;br /&gt;
# a UNO struct later needed to create a document&lt;br /&gt;
from com.sun.star.text.ControlCharacter import PARAGRAPH_BREAK&lt;br /&gt;
from com.sun.star.text.TextContentAnchorType import AS_CHARACTER&lt;br /&gt;
from com.sun.star.awt import Size&lt;br /&gt;
&lt;br /&gt;
from com.sun.star.lang import XMain&lt;br /&gt;
&lt;br /&gt;
def insertTextIntoCell( table, cellName, text, color ):&lt;br /&gt;
    tableText = table.getCellByName( cellName )&lt;br /&gt;
    cursor = tableText.createTextCursor()&lt;br /&gt;
    cursor.setPropertyValue( &amp;quot;CharColor&amp;quot;, color )&lt;br /&gt;
    tableText.setString( text )&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def createTable():&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;creates a new writer document and inserts a table with some data (also known as the SWriter sample)&amp;quot;&amp;quot;&amp;quot; &lt;br /&gt;
    ctx = uno.getComponentContext()&lt;br /&gt;
    smgr = ctx.ServiceManager&lt;br /&gt;
    desktop = smgr.createInstanceWithContext( &amp;quot;com.sun.star.frame.Desktop&amp;quot;,ctx)&lt;br /&gt;
    &lt;br /&gt;
    # open a writer document&lt;br /&gt;
    doc = desktop.loadComponentFromURL( &amp;quot;private:factory/swriter&amp;quot;,&amp;quot;_blank&amp;quot;, 0, () )&lt;br /&gt;
    &lt;br /&gt;
    text = doc.Text&lt;br /&gt;
    cursor = text.createTextCursor()&lt;br /&gt;
    text.insertString( cursor, &amp;quot;The first line in the newly created text document.\n&amp;quot;, 0 )&lt;br /&gt;
    text.insertString( cursor, &amp;quot;Now we are in the second line\n&amp;quot; , 0 )&lt;br /&gt;
    &lt;br /&gt;
    # create a text table&lt;br /&gt;
    table = doc.createInstance( &amp;quot;com.sun.star.text.TextTable&amp;quot; )&lt;br /&gt;
&lt;br /&gt;
    # with 4 rows and 4 columns&lt;br /&gt;
    table.initialize( 4,4)&lt;br /&gt;
&lt;br /&gt;
    text.insertTextContent( cursor, table, 0 )&lt;br /&gt;
    rows = table.Rows&lt;br /&gt;
&lt;br /&gt;
    table.setPropertyValue( &amp;quot;BackTransparent&amp;quot;, uno.Bool(0) )&lt;br /&gt;
    table.setPropertyValue( &amp;quot;BackColor&amp;quot;, 13421823 )&lt;br /&gt;
    row = rows.getByIndex(0)&lt;br /&gt;
    row.setPropertyValue( &amp;quot;BackTransparent&amp;quot;, uno.Bool(0) )&lt;br /&gt;
    row.setPropertyValue( &amp;quot;BackColor&amp;quot;, 6710932 )&lt;br /&gt;
&lt;br /&gt;
    textColor = 16777215&lt;br /&gt;
&lt;br /&gt;
    insertTextIntoCell( table, &amp;quot;A1&amp;quot;, &amp;quot;FirstColumn&amp;quot;, textColor )&lt;br /&gt;
    insertTextIntoCell( table, &amp;quot;B1&amp;quot;, &amp;quot;SecondColumn&amp;quot;, textColor )&lt;br /&gt;
    insertTextIntoCell( table, &amp;quot;C1&amp;quot;, &amp;quot;ThirdColumn&amp;quot;, textColor )&lt;br /&gt;
    insertTextIntoCell( table, &amp;quot;D1&amp;quot;, &amp;quot;SUM&amp;quot;, textColor )&lt;br /&gt;
&lt;br /&gt;
    values = ( (22.5,21.5,121.5),&lt;br /&gt;
              (5615.3,615.3,-615.3),&lt;br /&gt;
              (-2315.7,315.7,415.7) )&lt;br /&gt;
    table.getCellByName(&amp;quot;A2&amp;quot;).setValue(22.5)&lt;br /&gt;
    table.getCellByName(&amp;quot;B2&amp;quot;).setValue(5615.3)&lt;br /&gt;
    table.getCellByName(&amp;quot;C2&amp;quot;).setValue(-2315.7)&lt;br /&gt;
    table.getCellByName(&amp;quot;D2&amp;quot;).setFormula(&amp;quot;sum &amp;lt;A2:C2&amp;gt;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    table.getCellByName(&amp;quot;A3&amp;quot;).setValue(21.5)&lt;br /&gt;
    table.getCellByName(&amp;quot;B3&amp;quot;).setValue(615.3)&lt;br /&gt;
    table.getCellByName(&amp;quot;C3&amp;quot;).setValue(-315.7)&lt;br /&gt;
    table.getCellByName(&amp;quot;D3&amp;quot;).setFormula(&amp;quot;sum &amp;lt;A3:C3&amp;gt;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    table.getCellByName(&amp;quot;A4&amp;quot;).setValue(121.5)&lt;br /&gt;
    table.getCellByName(&amp;quot;B4&amp;quot;).setValue(-615.3)&lt;br /&gt;
    table.getCellByName(&amp;quot;C4&amp;quot;).setValue(415.7)&lt;br /&gt;
    table.getCellByName(&amp;quot;D4&amp;quot;).setFormula(&amp;quot;sum &amp;lt;A4:C4&amp;gt;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    cursor.setPropertyValue( &amp;quot;CharColor&amp;quot;, 255 )&lt;br /&gt;
    cursor.setPropertyValue( &amp;quot;CharShadowed&amp;quot;, uno.Bool(1) )&lt;br /&gt;
&lt;br /&gt;
    text.insertControlCharacter( cursor, PARAGRAPH_BREAK, 0 )&lt;br /&gt;
    text.insertString( cursor, &amp;quot; This is a colored Text - blue with shadow\n&amp;quot; , 0 )&lt;br /&gt;
    text.insertControlCharacter( cursor, PARAGRAPH_BREAK, 0 )&lt;br /&gt;
&lt;br /&gt;
    textFrame = doc.createInstance( &amp;quot;com.sun.star.text.TextFrame&amp;quot; )&lt;br /&gt;
    textFrame.setSize( Size(15000,400))&lt;br /&gt;
    textFrame.setPropertyValue( &amp;quot;AnchorType&amp;quot; , AS_CHARACTER )&lt;br /&gt;
&lt;br /&gt;
    text.insertTextContent( cursor, textFrame, 0 )&lt;br /&gt;
&lt;br /&gt;
    textInTextFrame = textFrame.getText()&lt;br /&gt;
    cursorInTextFrame = textInTextFrame.createTextCursor()&lt;br /&gt;
    textInTextFrame.insertString( cursorInTextFrame, &amp;quot;The first line in the newly created text frame.&amp;quot;, 0 )&lt;br /&gt;
    textInTextFrame.insertString( cursorInTextFrame, &amp;quot;\nWith this second line the height of the rame raises.&amp;quot;,0)&lt;br /&gt;
    text.insertControlCharacter( cursor, PARAGRAPH_BREAK, 0 )&lt;br /&gt;
&lt;br /&gt;
    cursor.setPropertyValue( &amp;quot;CharColor&amp;quot;, 65536 )&lt;br /&gt;
    cursor.setPropertyValue( &amp;quot;CharShadowed&amp;quot;, uno.Bool(0) )&lt;br /&gt;
&lt;br /&gt;
    text.insertString( cursor, &amp;quot; That&amp;#039;s all for now !!&amp;quot; , 0 )&lt;br /&gt;
&lt;br /&gt;
g_exportedScripts = createTable,&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First step to understand is that the UNO module will give us the IDL binding from the API. We will then import specific things from the UNO module. For that we need to specify the path from com.sun.star and import the interfaces and services. &lt;br /&gt;
&lt;br /&gt;
The nested modules [http://api.openoffice.org/docs/common/ref/com/sun/star/text/module-ix.html text] we had: [http://api.openoffice.org/docs/common/ref/com/sun/star/text/ControlCharacter.html ControlCharacter], [http://api.openoffice.org/docs/common/ref/com/sun/star/text/TextContentAnchorType.html TextContentAnchorType] and import [http://api.openoffice.org/docs/common/ref/com/sun/star/text/ControlCharacter.html#PARAGRAPH_BREAK PARAGRAPH_BREAK], [http://api.openoffice.org/docs/common/ref/com/sun/star/text/TextContentAnchorType.html#AS_CHARACTER AS_CHARACTER].&lt;br /&gt;
&lt;br /&gt;
From [http://api.openoffice.org/docs/common/ref/com/sun/star/awt/module-ix.html awt] which is a user interface toolkit had: [http://api.openoffice.org/docs/common/ref/com/sun/star/awt/Size.html Size]&lt;br /&gt;
&lt;br /&gt;
Finally [http://api.openoffice.org/docs/common/ref/com/sun/star/lang/module-ix.html lang] nested module which is about , we import [http://api.openoffice.org/docs/common/ref/com/sun/star/lang/XMain.html XMain].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
import uno&lt;br /&gt;
&lt;br /&gt;
# a UNO struct later needed to create a document&lt;br /&gt;
from com.sun.star.text.ControlCharacter import PARAGRAPH_BREAK&lt;br /&gt;
from com.sun.star.text.TextContentAnchorType import AS_CHARACTER&lt;br /&gt;
from com.sun.star.awt import Size&lt;br /&gt;
&lt;br /&gt;
from com.sun.star.lang import XMain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== createTable() ====&lt;br /&gt;
&lt;br /&gt;
We can divide this class into the process of:&lt;br /&gt;
* creating a new window&lt;br /&gt;
* creating a writer document &lt;br /&gt;
* inserting text (previously seen on the Hello World Script).&lt;br /&gt;
* Creating a table within the writer document &lt;br /&gt;
* manipulate the format and finally the content &lt;br /&gt;
* Then we insert a frame with text in it&lt;br /&gt;
* insert a string&lt;br /&gt;
&lt;br /&gt;
This let us analyze in more detail the interfaces and methods from the cursor, table, text, textFrame and textInTextFrame. All this documentation can be found on the IDL reference. Following this script will allow us to use the IDL to our benefit and explore other nested modules for different purpose.&lt;br /&gt;
&lt;br /&gt;
The following values goes extract from the following:&lt;br /&gt;
&lt;br /&gt;
* doc = desktop.&amp;#039;&amp;#039;&amp;#039;loadComponentFromURL( &amp;quot;private:factory/swriter&amp;quot;,&amp;quot;_blank&amp;quot;, 0, () )&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* text = doc.Text&lt;br /&gt;
* cursor = text.&amp;#039;&amp;#039;&amp;#039;createTextCursor()&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* table = doc.&amp;#039;&amp;#039;&amp;#039;createInstance( &amp;quot;com.sun.star.text.TextTable&amp;quot; )&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The &amp;#039;&amp;#039;&amp;#039;loadcomponentFromURL()&amp;#039;&amp;#039;&amp;#039; creates and load the Writer document by generating the variable. Text is a variable that will get the document object with the module of Text. The function of &amp;#039;&amp;#039;&amp;#039;createTextCursor()&amp;#039;&amp;#039;&amp;#039; according with the IDL &amp;#039;&amp;#039;a new instance of a TextCursor service which can be used to travel in the given text context&amp;#039;&amp;#039;.&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;creates a new writer document and inserts a table with some data (also known as the SWriter sample)&amp;quot;&amp;quot;&amp;quot; &lt;br /&gt;
    ctx = uno.getComponentContext()&lt;br /&gt;
    smgr = ctx.ServiceManager&lt;br /&gt;
    desktop = smgr.createInstanceWithContext( &amp;quot;com.sun.star.frame.Desktop&amp;quot;,ctx)&lt;br /&gt;
    &lt;br /&gt;
    # open a writer document&lt;br /&gt;
    doc = desktop.loadComponentFromURL( &amp;quot;private:factory/swriter&amp;quot;,&amp;quot;_blank&amp;quot;, 0, () )&lt;br /&gt;
    &lt;br /&gt;
    text = doc.Text&lt;br /&gt;
    cursor = text.createTextCursor()&lt;br /&gt;
    text.insertString( cursor, &amp;quot;The first line in the newly created text document.\n&amp;quot;, 0 )&lt;br /&gt;
    text.insertString( cursor, &amp;quot;Now we are in the second line\n&amp;quot; , 0 )&amp;lt;/source&amp;gt;&lt;br /&gt;
The next instance is the creation of the table instance within the table variable. We use the function of &amp;#039;&amp;#039;&amp;#039;createTextCursor()&amp;#039;&amp;#039;&amp;#039;, the path to the module is &amp;#039;&amp;#039;&amp;#039;com.sun.star.text.TextTable&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
    # create a text table&lt;br /&gt;
    table = doc.createInstance( &amp;quot;com.sun.star.text.TextTable&amp;quot; )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We create our table by using the method &amp;#039;&amp;#039;&amp;#039;initialize&amp;#039;&amp;#039;&amp;#039; on the line 35 of the code &amp;#039;&amp;#039;&amp;#039;table.initialize( 4,4)&amp;#039;&amp;#039;&amp;#039;. Now we will deal with the properties of the table as well as the methods and objects from the table like rows, cursor and values. First step after initialize the table, we use the function &amp;#039;&amp;#039;&amp;#039;insertTextContent( cursor, table, 0 )&amp;#039;&amp;#039;&amp;#039;, if you think that this will put a cursor in the table, then you are RIGHT. TextContent is basically an object which can be anchored in a text, like instances of TextFrame or TextFields. In our case we will deal with Cells rather than Frames or Fields.&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    # with 4 rows and 4 columns&lt;br /&gt;
    table.initialize( 4,4)&lt;br /&gt;
&lt;br /&gt;
    text.insertTextContent( cursor, table, 0 )&lt;br /&gt;
    rows = table.Rows&amp;lt;/source&amp;gt;&lt;br /&gt;
The next point is we will focus on the &amp;#039;&amp;#039;&amp;#039;styles&amp;#039;&amp;#039;&amp;#039; of the table and have methods such as &amp;#039;&amp;#039;&amp;#039;setPropertyValue&amp;#039;&amp;#039;&amp;#039; which could might as well be setStyleValue being implemented to the text, for example &amp;#039;&amp;#039;&amp;#039;setPropertyValue( &amp;quot;BackTransparent&amp;quot;, uno.Bool(0) )&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;setPropertyValue( &amp;quot;BackColor&amp;quot;, 6710932 )&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
    table.setPropertyValue( &amp;quot;BackTransparent&amp;quot;, uno.Bool(0) )&lt;br /&gt;
    table.setPropertyValue( &amp;quot;BackColor&amp;quot;, 13421823 )&lt;br /&gt;
    row = rows.getByIndex(0)&lt;br /&gt;
    row.setPropertyValue( &amp;quot;BackTransparent&amp;quot;, uno.Bool(0) )&lt;br /&gt;
    row.setPropertyValue( &amp;quot;BackColor&amp;quot;, 6710932 )&amp;lt;/source&amp;gt;&lt;br /&gt;
The next step is to get the header of the table which will use the other class and will insert the values that we need, we get &amp;#039;&amp;#039;&amp;#039;insertTextIntoCell( table, &amp;quot;A1&amp;quot;, &amp;quot;FirstColumn&amp;quot;, textColor )&amp;#039;&amp;#039;&amp;#039; put color and content into the specific cells from the table object. The syntax is rather straight forward by stating object, cell position, text content and finally text color value which in this case is a variable of the hex color 16777215.&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
    textColor = 16777215&lt;br /&gt;
&lt;br /&gt;
    insertTextIntoCell( table, &amp;quot;A1&amp;quot;, &amp;quot;FirstColumn&amp;quot;, textColor )&lt;br /&gt;
    insertTextIntoCell( table, &amp;quot;B1&amp;quot;, &amp;quot;SecondColumn&amp;quot;, textColor )&lt;br /&gt;
    insertTextIntoCell( table, &amp;quot;C1&amp;quot;, &amp;quot;ThirdColumn&amp;quot;, textColor )&lt;br /&gt;
    insertTextIntoCell( table, &amp;quot;D1&amp;quot;, &amp;quot;SUM&amp;quot;, textColor )&amp;lt;/source&amp;gt;&lt;br /&gt;
Now we will insert the content of our table including the numerical value and &amp;#039;&amp;#039;&amp;#039;formula&amp;#039;&amp;#039;&amp;#039;. We use an array of values and then generate a series of inserting the &amp;#039;&amp;#039;&amp;#039;values()&amp;#039;&amp;#039;&amp;#039; within the the &amp;#039;&amp;#039;&amp;#039;getCellByName()&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;setValue()&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;setFormula&amp;#039;&amp;#039;&amp;#039;. &lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
    values = ( (22.5,21.5,121.5),&lt;br /&gt;
              (5615.3,615.3,-615.3),&lt;br /&gt;
              (-2315.7,315.7,415.7) )&lt;br /&gt;
    table.getCellByName(&amp;quot;A2&amp;quot;).setValue(22.5)&lt;br /&gt;
    table.getCellByName(&amp;quot;B2&amp;quot;).setValue(5615.3)&lt;br /&gt;
    table.getCellByName(&amp;quot;C2&amp;quot;).setValue(-2315.7)&lt;br /&gt;
    table.getCellByName(&amp;quot;D2&amp;quot;).setFormula(&amp;quot;sum &amp;lt;A2:C2&amp;gt;&amp;quot;)&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== insertTextIntoCell() ====&lt;br /&gt;
This is a sub-process class which brings the services and methods for the table manipulation. The function uses the method getCellbyName, createTextCursor and createPropertyValue.&lt;br /&gt;
&lt;br /&gt;
This insertTextIntoCell() function will bring a structure to format the header of the table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Python]]&lt;br /&gt;
[[Category:Uno]]&lt;br /&gt;
[[Category:Tutorial]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/WritingUNO/Class_Definition_with_Helper_Class&amp;diff=156461</id>
		<title>Documentation/DevGuide/WritingUNO/Class Definition with Helper Class</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/WritingUNO/Class_Definition_with_Helper_Class&amp;diff=156461"/>
		<updated>2010-02-07T06:02:32Z</updated>

		<summary type="html">&lt;p&gt;Newacct: /* XServiceInfo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/WritingUNOTOC&lt;br /&gt;
|WritingUNO2c=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/WritingUNO/Simple Component in Java&lt;br /&gt;
|NextPage=Documentation/DevGuide/WritingUNO/Implementing Your Own Interfaces&lt;br /&gt;
}}&lt;br /&gt;
{{Documentation/DevGuideLanguages|Documentation/DevGuide/WritingUNO/{{SUBPAGENAME}}}}&lt;br /&gt;
{{DISPLAYTITLE:Class Definition with Helper Class}}&lt;br /&gt;
=== XInterface, XTypeProvider and XWeak ===&lt;br /&gt;
&lt;br /&gt;
The {{PRODUCTNAME}} Java UNO environment contains Java helper classes that implement the majority of the core interfaces that are implemented by UNO components. There are two helper classes:&lt;br /&gt;
&lt;br /&gt;
* The helper &amp;lt;code&amp;gt;com.sun.star.lib.uno.helper.WeakBase&amp;lt;/code&amp;gt; is the minimal base class and implements &amp;lt;code&amp;gt;XInterface&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;XTypeProvider&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Xweak&amp;lt;/code&amp;gt;.&lt;br /&gt;
* The helper &amp;lt;code&amp;gt;com.sun.star.lib.uno.helper.ComponentBase&amp;lt;/code&amp;gt; that extends &amp;lt;code&amp;gt;WeakBase&amp;lt;/code&amp;gt; and implements &amp;lt;code&amp;gt;XComponent&amp;lt;/code&amp;gt;.&lt;br /&gt;
The &amp;lt;idl&amp;gt;com.sun.star.lang.XServiceInfo&amp;lt;/idl&amp;gt; is the only interface that should be implemented, but it is not part of the helpers.&lt;br /&gt;
&lt;br /&gt;
Use the naming conventions described in section [[Documentation/DevGuide/WritingUNO/XServiceInfo|XServiceInfo]] for the service implementation. Following the rules, a service &amp;lt;code&amp;gt;org.openoffice.test.ImageShrink&amp;lt;/code&amp;gt; should be implemented in &amp;lt;code&amp;gt;org.openoffice.&amp;#039;&amp;#039;comp&amp;#039;&amp;#039;.test.ImageShrink&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A possible class definition that uses &amp;lt;code&amp;gt;WeakBase&amp;lt;/code&amp;gt; could look like this: &amp;lt;!--[SOURCE:Components/Thumbs/org/openoffice/comp/test/ImageShrink.java]--&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  package org.openoffice.comp.test;&lt;br /&gt;
  &lt;br /&gt;
  public class ImageShrink extends com.sun.star.lib.uno.helper.WeakBase &lt;br /&gt;
        implements com.sun.star.lang.XServiceInfo,&lt;br /&gt;
          org.openoffice.test.XImageShrinkFilter {&lt;br /&gt;
  &lt;br /&gt;
      com.sun.star.uno.XComponentContext xComponentContext = null;&lt;br /&gt;
  &lt;br /&gt;
      /** Creates a new instance of ImageShrink */&lt;br /&gt;
      public ImageShrink(com.sun.star.uno.XComponentContext XComponentContext xContext) {&lt;br /&gt;
          this.xComponentContext = xContext;&lt;br /&gt;
      }&lt;br /&gt;
      ...&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
=== XServiceInfo ===&lt;br /&gt;
&lt;br /&gt;
If the implementation only supports one service, use the following code to implement &amp;lt;code&amp;gt;XServiceInfo&amp;lt;/code&amp;gt;: &lt;br /&gt;
&amp;lt;!--[SOURCE:Components/Thumbs/org/openoffice/comp/test/ImageShrink.java]--&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  ...&lt;br /&gt;
  &lt;br /&gt;
  //XServiceInfo implementation&lt;br /&gt;
  &lt;br /&gt;
  // hold the service name in a private static member variable of the class&lt;br /&gt;
  protected static final String __serviceName = &amp;quot;org.openoffice.test.ImageShrink&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  public String getImplementationName( ) {&lt;br /&gt;
      return getClass().getName();&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  public boolean supportsService(String serviceName) {&lt;br /&gt;
      return serviceName.equals( __serviceName);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  public String[] getSupportedServiceNames( ) {&lt;br /&gt;
      return new String[] { __serviceName };&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
An implementation of more than one service in one UNO object is more complex. It has to return all supported service names in &amp;lt;code&amp;gt;getSupportedServiceNames()&amp;lt;/code&amp;gt;, furthermore it must check all supported service names in &amp;lt;code&amp;gt;supportsService()&amp;lt;/code&amp;gt;. Note that several services packaged in one component file are not discussed here, but objects supporting more than one service. Refer to [[:Image:ComponentOverview2.png|A Component implementing three UNO objects]] for the implementation of srv3_4.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Writing UNO Components]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Counter_Example&amp;diff=156442</id>
		<title>Counter Example</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Counter_Example&amp;diff=156442"/>
		<updated>2010-02-06T09:48:07Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This example given with the SDK contains two files : counter.cxx and countermain.cxx. These files show differencies with [[Constructing_Components#A_very_simple_Counter|Listing 3 and Listing 4]] previously tackled because they have to run with OpenOffice.org now. But they do the same work !&lt;br /&gt;
 &lt;br /&gt;
The generated counter, like ProfUnoLifeTime, is able to run even if OpenOffice isn&amp;#039;t running. &lt;br /&gt;
MainCounter in the Figure below is the binary program file to run to test the example. There is no direct arrow between MainCounter and Counter.uno.so, indicating that they are independent of each other : if MainCounter want something from Counter.uno.so, it has to ask to cppuhelper (in other words to Openoffice). &lt;br /&gt;
&lt;br /&gt;
== Compilation Chain ==&lt;br /&gt;
&lt;br /&gt;
This little example uses a registered external module (counter.uno.so build from counter.cxx) and a main program (countermain.cxx) which uses it.&lt;br /&gt;
We shows with the figure below what tools are involved in the construction of the counter :&lt;br /&gt;
&lt;br /&gt;
[[Image:MakefileCounterEx.png|center|thumb|800px|Counter Example : the Compilation Chain]]&lt;br /&gt;
&lt;br /&gt;
The compilation chain for this example (see Figure above) is more complicated than [[Constructing_Components#Make_dependency_of_a_Component|previously]], because of the two cpp source files : counter.cxx and countermain.cxx. Please note we have to create a third file in this example : XCounter.idl.&lt;br /&gt;
&lt;br /&gt;
== IDL File ==&lt;br /&gt;
The listing of this IDL file is now comprehensive by a reader who have studied [[IDL_Files_and_Cpp|IDL Files and Cpp]] section :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 6 The IDL Counter File&lt;br /&gt;
// IDL&lt;br /&gt;
#include &amp;lt;com/sun/star/uno/XInterface.idl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
module foo&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Interface to count things. &lt;br /&gt;
	 */&lt;br /&gt;
	interface XCountable : com::sun::star::uno::XInterface&lt;br /&gt;
	{&lt;br /&gt;
		long getCount();&lt;br /&gt;
		void setCount( [in] long nCount );&lt;br /&gt;
		long increment();&lt;br /&gt;
		long decrement();&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	service Counter&lt;br /&gt;
	{&lt;br /&gt;
		// exported interface:&lt;br /&gt;
		interface XCountable;&lt;br /&gt;
	};&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This IDL file describe the interface of counter.cxx which will become counter.uno.so (counter.uno.dll under Windows), a library file after compilation. But again you call one of the four method not directly but through cppuhelper. We give a schematic representation of this IDL file.&lt;br /&gt;
&lt;br /&gt;
[[Image:ServiceCounter.png|center|thumb|600px|Counter Service and Interface]]&lt;br /&gt;
&lt;br /&gt;
== The Counter Class ==&lt;br /&gt;
We give the listing of the counter class :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 7&lt;br /&gt;
// C++&lt;br /&gt;
//==================================================================================================&lt;br /&gt;
class MyCounterImpl&lt;br /&gt;
	: public XCountable&lt;br /&gt;
	, public XServiceInfo&lt;br /&gt;
{&lt;br /&gt;
	// to obtain other services if needed&lt;br /&gt;
	Reference&amp;lt; XMultiServiceFactory &amp;gt; m_xServiceManager;&lt;br /&gt;
	&lt;br /&gt;
	sal_Int32 m_nRefCount;&lt;br /&gt;
	sal_Int32 m_nCount;&lt;br /&gt;
	&lt;br /&gt;
public:&lt;br /&gt;
	MyCounterImpl( const Reference&amp;lt; XMultiServiceFactory &amp;gt; &amp;amp; xServiceManager )&lt;br /&gt;
		: m_xServiceManager( xServiceManager ), m_nRefCount( 0 )&lt;br /&gt;
		{ printf( &amp;quot;&amp;lt; MyCounterImpl ctor called &amp;gt;\n&amp;quot; ); }&lt;br /&gt;
	~MyCounterImpl()&lt;br /&gt;
		{ printf( &amp;quot;&amp;lt; MyCounterImpl dtor called &amp;gt;\n&amp;quot; ); }&lt;br /&gt;
&lt;br /&gt;
// XInterface implementation&lt;br /&gt;
	virtual void SAL_CALL acquire() throw ()&lt;br /&gt;
		{ ++m_nRefCount; }&lt;br /&gt;
	virtual void SAL_CALL release() throw ()&lt;br /&gt;
		{ if (! --m_nRefCount) delete this; }&lt;br /&gt;
	virtual Any SAL_CALL queryInterface( const Type &amp;amp; rType ) throw (RuntimeException)&lt;br /&gt;
		{ return cppu::queryInterface(rType, &lt;br /&gt;
        		static_cast&amp;lt; XInterface* &amp;gt;( static_cast&amp;lt; XServiceInfo* &amp;gt;( this ) ),&lt;br /&gt;
        		static_cast&amp;lt; XCountable* &amp;gt;( this ),&lt;br /&gt;
                        static_cast&amp;lt; XServiceInfo* &amp;gt;( this ) ); }&lt;br /&gt;
&lt;br /&gt;
// XServiceInfo	implementation&lt;br /&gt;
    virtual OUString SAL_CALL getImplementationName(  ) throw(RuntimeException);&lt;br /&gt;
    virtual sal_Bool SAL_CALL supportsService( const OUString&amp;amp; ServiceName ) throw(RuntimeException);&lt;br /&gt;
    virtual Sequence&amp;lt; OUString &amp;gt; SAL_CALL getSupportedServiceNames(  ) throw(RuntimeException);&lt;br /&gt;
    static Sequence&amp;lt; OUString &amp;gt; SAL_CALL getSupportedServiceNames_Static(  );&lt;br /&gt;
&lt;br /&gt;
// XCountable implementation&lt;br /&gt;
	virtual sal_Int32 SAL_CALL getCount() throw (RuntimeException)&lt;br /&gt;
		{ return m_nCount; }&lt;br /&gt;
	virtual void SAL_CALL setCount( sal_Int32 nCount ) throw (RuntimeException)&lt;br /&gt;
		{ m_nCount = nCount; }&lt;br /&gt;
	virtual sal_Int32 SAL_CALL increment() throw (RuntimeException)&lt;br /&gt;
		{ return (++m_nCount); }&lt;br /&gt;
	virtual sal_Int32 SAL_CALL decrement() throw (RuntimeException)&lt;br /&gt;
		{ return (--m_nCount); }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
//*************************************************************************&lt;br /&gt;
OUString SAL_CALL MyCounterImpl::getImplementationName(  ) &lt;br /&gt;
	throw(RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
	return OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) );&lt;br /&gt;
}	&lt;br /&gt;
&lt;br /&gt;
//*************************************************************************&lt;br /&gt;
sal_Bool SAL_CALL MyCounterImpl::supportsService( const OUString&amp;amp; ServiceName ) &lt;br /&gt;
	throw(RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
	Sequence&amp;lt; OUString &amp;gt; aSNL = getSupportedServiceNames();&lt;br /&gt;
	const OUString * pArray = aSNL.getArray();&lt;br /&gt;
	for( sal_Int32 i = 0; i &amp;lt; aSNL.getLength(); i++ )&lt;br /&gt;
		if( pArray[i] == ServiceName )&lt;br /&gt;
			return sal_True;&lt;br /&gt;
	return sal_False;&lt;br /&gt;
}	&lt;br /&gt;
&lt;br /&gt;
//*************************************************************************&lt;br /&gt;
Sequence&amp;lt;OUString&amp;gt; SAL_CALL MyCounterImpl::getSupportedServiceNames(  ) &lt;br /&gt;
	throw(RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
	return getSupportedServiceNames_Static();&lt;br /&gt;
}	&lt;br /&gt;
&lt;br /&gt;
//*************************************************************************&lt;br /&gt;
Sequence&amp;lt;OUString&amp;gt; SAL_CALL MyCounterImpl::getSupportedServiceNames_Static(  ) &lt;br /&gt;
{&lt;br /&gt;
	OUString aName( RTL_CONSTASCII_USTRINGPARAM(SERVICENAME) );&lt;br /&gt;
	return Sequence&amp;lt; OUString &amp;gt;( &amp;amp;aName, 1 );&lt;br /&gt;
}	&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Function to create a new component instance; is needed by factory helper implementation.&lt;br /&gt;
 * @param xMgr service manager to if the components needs other component instances&lt;br /&gt;
 */&lt;br /&gt;
Reference&amp;lt; XInterface &amp;gt; SAL_CALL MyCounterImpl_create(&lt;br /&gt;
	const Reference&amp;lt; XMultiServiceFactory &amp;gt; &amp;amp; xMgr )&lt;br /&gt;
{&lt;br /&gt;
	return Reference&amp;lt; XCountable &amp;gt;( new MyCounterImpl( xMgr ) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//##################################################################################################&lt;br /&gt;
//#### EXPORTED ####################################################################################&lt;br /&gt;
//##################################################################################################&lt;br /&gt;
/**&lt;br /&gt;
 * Gives the environment this component belongs to.&lt;br /&gt;
 */&lt;br /&gt;
extern &amp;quot;C&amp;quot; void SAL_CALL component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv)&lt;br /&gt;
{&lt;br /&gt;
	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;&lt;br /&gt;
}&lt;br /&gt;
/**&lt;br /&gt;
 * This function creates an implementation section in the registry and another subkey&lt;br /&gt;
 *&lt;br /&gt;
 * for each supported service.&lt;br /&gt;
 * @param pServiceManager   the service manager&lt;br /&gt;
 * @param pRegistryKey      the registry key&lt;br /&gt;
 */&lt;br /&gt;
extern &amp;quot;C&amp;quot; sal_Bool SAL_CALL component_writeInfo(void * pServiceManager, void * pRegistryKey)&lt;br /&gt;
{&lt;br /&gt;
	sal_Bool result = sal_False;&lt;br /&gt;
&lt;br /&gt;
	if (pRegistryKey)&lt;br /&gt;
	{&lt;br /&gt;
		try&lt;br /&gt;
		{&lt;br /&gt;
			Reference&amp;lt; XRegistryKey &amp;gt; xNewKey(&lt;br /&gt;
				reinterpret_cast&amp;lt; XRegistryKey * &amp;gt;( pRegistryKey )-&amp;gt;createKey(&lt;br /&gt;
					OUString( RTL_CONSTASCII_USTRINGPARAM(&amp;quot;/&amp;quot; IMPLNAME &amp;quot;/UNO/SERVICES&amp;quot;) ) ) );&lt;br /&gt;
			&lt;br /&gt;
			const Sequence&amp;lt; OUString &amp;gt; &amp;amp; rSNL =&lt;br /&gt;
				MyCounterImpl::getSupportedServiceNames_Static();&lt;br /&gt;
			const OUString * pArray = rSNL.getConstArray();&lt;br /&gt;
			for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )&lt;br /&gt;
				xNewKey-&amp;gt;createKey( pArray[nPos] );&lt;br /&gt;
			&lt;br /&gt;
			return sal_True;&lt;br /&gt;
		}&lt;br /&gt;
		catch (InvalidRegistryException &amp;amp;)&lt;br /&gt;
		{&lt;br /&gt;
			// we should not ignore exceptions&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	return result;&lt;br /&gt;
}&lt;br /&gt;
/**&lt;br /&gt;
 * This function is called to get service factories for an implementation.&lt;br /&gt;
 *&lt;br /&gt;
 * @param pImplName       name of implementation&lt;br /&gt;
 * @param pServiceManager a service manager, need for component creation&lt;br /&gt;
 * @param pRegistryKey    the registry key for this component, need for persistent data&lt;br /&gt;
 * @return a component factory &lt;br /&gt;
 */&lt;br /&gt;
extern &amp;quot;C&amp;quot; void * SAL_CALL component_getFactory(const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey)&lt;br /&gt;
{&lt;br /&gt;
	void * pRet = 0;&lt;br /&gt;
	&lt;br /&gt;
	if (rtl_str_compare( pImplName, IMPLNAME ) == 0)&lt;br /&gt;
	{&lt;br /&gt;
		Reference&amp;lt; XSingleServiceFactory &amp;gt; xFactory( createSingleFactory(&lt;br /&gt;
			reinterpret_cast&amp;lt; XMultiServiceFactory * &amp;gt;( pServiceManager ),&lt;br /&gt;
			OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) ),&lt;br /&gt;
			MyCounterImpl_create,&lt;br /&gt;
			MyCounterImpl::getSupportedServiceNames_Static() ) );&lt;br /&gt;
		&lt;br /&gt;
		if (xFactory.is())&lt;br /&gt;
		{&lt;br /&gt;
			xFactory-&amp;gt;acquire();&lt;br /&gt;
			pRet = xFactory.get();&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	return pRet;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This is a lot of code compared with [[Constructing_Components#A_very_simple_Counter|Listing 3]]. This class will be compiled as a dynamic library and to be registered (see [[Constructing_Components#Making_the_Counter_registerable|Making the Counter registerable]]).&lt;br /&gt;
&lt;br /&gt;
== The countermain program ==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Listing 8&lt;br /&gt;
// C++ countermain.cxx&lt;br /&gt;
int SAL_CALL main(int argc, char **argv)&lt;br /&gt;
{&lt;br /&gt;
	Reference&amp;lt; XSimpleRegistry &amp;gt; xReg = createSimpleRegistry(); &lt;br /&gt;
	OSL_ENSURE( xReg.is(), &amp;quot;### cannot get service instance of \&amp;quot;com.sun.star.regiystry.SimpleRegistry\&amp;quot;!&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
	xReg-&amp;gt;open(OUString::createFromAscii(&amp;quot;counter.uno.rdb&amp;quot;), sal_False, sal_False);&lt;br /&gt;
	OSL_ENSURE( xReg-&amp;gt;isValid(), &amp;quot;### cannot open test registry \&amp;quot;counter.uno.rdb\&amp;quot;!&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
	Reference&amp;lt; XComponentContext &amp;gt; xContext = bootstrap_InitialComponentContext(xReg);&lt;br /&gt;
	OSL_ENSURE( xContext.is(), &amp;quot;### cannot creage intial component context!&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
	Reference&amp;lt; XMultiComponentFactory &amp;gt; xMgr = xContext-&amp;gt;getServiceManager();&lt;br /&gt;
	OSL_ENSURE( xMgr.is(), &amp;quot;### cannot get initial service manager!&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
	// register my counter component&lt;br /&gt;
	Reference&amp;lt; XImplementationRegistration &amp;gt; xImplReg(&lt;br /&gt;
		xMgr-&amp;gt;createInstanceWithContext(OUString::createFromAscii(&amp;quot;com.sun.star.registry.ImplementationRegistration&amp;quot;), xContext), UNO_QUERY);&lt;br /&gt;
	OSL_ENSURE( xImplReg.is(), &amp;quot;### cannot get service instance of \&amp;quot;com.sun.star.registry.ImplementationRegistration\&amp;quot;!&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
	if (xImplReg.is())&lt;br /&gt;
	{&lt;br /&gt;
		xImplReg-&amp;gt;registerImplementation(&lt;br /&gt;
			OUString::createFromAscii(&amp;quot;com.sun.star.loader.SharedLibrary&amp;quot;), // loader for component&lt;br /&gt;
#ifdef UNX&lt;br /&gt;
#ifdef MACOSX&lt;br /&gt;
			OUString::createFromAscii(&amp;quot;counter.uno.dylib&amp;quot;),		// component location&lt;br /&gt;
#else&lt;br /&gt;
			OUString::createFromAscii(&amp;quot;counter.uno.so&amp;quot;),		// component location&lt;br /&gt;
#endif&lt;br /&gt;
#else&lt;br /&gt;
			OUString::createFromAscii(&amp;quot;counter.uno.dll&amp;quot;),		// component location&lt;br /&gt;
#endif&lt;br /&gt;
			Reference&amp;lt; XSimpleRegistry &amp;gt;()	 // registry omitted,&lt;br /&gt;
						 // defaulting to service manager registry used&lt;br /&gt;
			);&lt;br /&gt;
		&lt;br /&gt;
		// get a counter instance&lt;br /&gt;
		Reference&amp;lt; XInterface &amp;gt; xx ;&lt;br /&gt;
		xx = xMgr-&amp;gt;createInstanceWithContext(OUString::createFromAscii(&amp;quot;foo.Counter&amp;quot;), xContext);&lt;br /&gt;
		Reference&amp;lt; XCountable &amp;gt; xCount( xx, UNO_QUERY );&lt;br /&gt;
		OSL_ENSURE( xCount.is(), &amp;quot;### cannot get service instance of \&amp;quot;foo.Counter\&amp;quot;!&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
		if (xCount.is())&lt;br /&gt;
		{&lt;br /&gt;
			xCount-&amp;gt;setCount( 42 );&lt;br /&gt;
			printf( &amp;quot;%d,&amp;quot; , xCount-&amp;gt;getCount() );&lt;br /&gt;
			printf( &amp;quot;%d,&amp;quot; , xCount-&amp;gt;increment() );&lt;br /&gt;
			printf( &amp;quot;%d\n&amp;quot; , xCount-&amp;gt;decrement() );&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	Reference&amp;lt; XComponent &amp;gt;::query( xContext )-&amp;gt;dispose();&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a lot of code compared with [[Constructing_Components#A_very_simple_Counter|Listing 4]]. One reason is because we have to register now the previous counter class : this is done in this program between lines 16 and 36.&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Tip|&amp;#039;&amp;#039;&amp;#039;Please note&amp;#039;&amp;#039;&amp;#039; this example doesn&amp;#039;t require an OpenOffice running.}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Return to [[Constructing_Components |Constructing Component]] or to &amp;quot;Using C++ with OOo SDK&amp;quot; [[Using_Cpp_with_the_OOo_SDK|main page]]&lt;br /&gt;
&lt;br /&gt;
[[Category:MacOSX]]&lt;br /&gt;
[[Category:Cpp]]&lt;br /&gt;
[[Category:Uno]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/ProUNO/Differences_Between_the_Lifetime_of_C%2B%2B_and_Java_Objects&amp;diff=156441</id>
		<title>Documentation/DevGuide/ProUNO/Differences Between the Lifetime of C++ and Java Objects</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/ProUNO/Differences_Between_the_Lifetime_of_C%2B%2B_and_Java_Objects&amp;diff=156441"/>
		<updated>2010-02-06T09:47:29Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/ProUNOTOC&lt;br /&gt;
|ProUNO2b=block&lt;br /&gt;
|ProUNO2bLife=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/ProUNO/Weak Objects and References&lt;br /&gt;
|NextPage=Documentation/DevGuide/ProUNO/Object Identity&lt;br /&gt;
}}&lt;br /&gt;
{{Documentation/DevGuideLanguages|Documentation/DevGuide/ProUNO/{{SUBPAGENAME}}}}&lt;br /&gt;
{{DISPLAYTITLE:Differences Between the Lifetime of C++ and Java Objects}}&lt;br /&gt;
{{Documentation/Note|Read [[Documentation/DevGuide/ProUNO/C++/C++ Language Binding|C++ Language Binding]] and [[Documentation/DevGuide/ProUNO/Java/Java Language Binding|Java Language Binding]] for information on language bindings, and [[Documentation/DevGuide/WritingUNO/C++/C++ Component|C++ Component]] and [[Documentation/DevGuide/WritingUNO/Storing the Service Manager for Further Use|Storing the Service Manager for Further Use]] about component implementation before beginning this section.}}&lt;br /&gt;
&lt;br /&gt;
The implementation of the reference count specification is different in Java UNO and C++ UNO. In C++ UNO, every object maintains its own reference counter. When you implement a C++ UNO object, instantiate it, acquire it and afterwards release it, the destructor of the object is called immediately. The following example uses the standard helper class &amp;lt;code&amp;gt;::cppu::OWeakObject&amp;lt;/code&amp;gt; and prints a message when the destructor is called. &amp;lt;!--[SOURCE:ProfUNO/Lifetime/object_lifetime.cxx]--&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  class MyOWeakObject : public ::cppu::OWeakObject&lt;br /&gt;
  {&lt;br /&gt;
  public:&lt;br /&gt;
      MyOWeakObject() { printf( &amp;quot;constructed\n&amp;quot; ); }&lt;br /&gt;
      ~MyOWeakObject() { printf( &amp;quot;destroyed\n&amp;quot; ); }&lt;br /&gt;
  };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The following method creates a new &amp;lt;code&amp;gt;MyOWeakObject&amp;lt;/code&amp;gt;, acquires it and releases it for demonstration purposes. The call to release() immediately leads to the destruction of &amp;lt;code&amp;gt;MyOWeakObject&amp;lt;/code&amp;gt;. If the &amp;lt;code&amp;gt;Reference&amp;lt;&amp;gt;&amp;lt;/code&amp;gt; template is used, you do not need to care about &amp;lt;code&amp;gt;acquire()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;release()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  void simple_object_creation_and_destruction()&lt;br /&gt;
  {&lt;br /&gt;
      // create the UNO object&lt;br /&gt;
      com::sun::star::uno::XInterface * p = new MyOWeakObject();&lt;br /&gt;
  &lt;br /&gt;
      // acquire it &lt;br /&gt;
      p-&amp;gt;acquire();&lt;br /&gt;
  &lt;br /&gt;
      // release it&lt;br /&gt;
      printf( &amp;quot;before release\n&amp;quot; );&lt;br /&gt;
      p-&amp;gt;release();&lt;br /&gt;
      printf( &amp;quot;after release\n&amp;quot; );&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This piece of code produces the following output:&lt;br /&gt;
&lt;br /&gt;
  constructed&lt;br /&gt;
  before release&lt;br /&gt;
  destroyed&lt;br /&gt;
  after release&lt;br /&gt;
&lt;br /&gt;
Java UNO objects behave differently, because they are finalized by the garbage collector at a time of its choosing. &amp;lt;idl&amp;gt;com.sun.star.uno.XInterface&amp;lt;/idl&amp;gt; has no methods in the Java UNO language binding, therefore no methods need to be implemented, although MyUnoObject implements XInterface: &lt;br /&gt;
&amp;lt;!--[SOURCE:ProfUNO/Lifetime/MyUnoObject.java]--&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  class MyUnoObject implements com.sun.star.uno.XInterface {&lt;br /&gt;
  &lt;br /&gt;
      public MyUnoObject() {&lt;br /&gt;
      }&lt;br /&gt;
   &lt;br /&gt;
      void finalize() {&lt;br /&gt;
          System.out.println(&amp;quot;finalizer called&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
   &lt;br /&gt;
      static void main(String args[]) throws java.lang.InterruptedException {&lt;br /&gt;
          com.sun.star.uno.XInterface a = new MyUnoObject();&lt;br /&gt;
          a = null;&lt;br /&gt;
  &lt;br /&gt;
          // ask the garbage collector politely &lt;br /&gt;
          System.gc();&lt;br /&gt;
          System.runFinalization();&lt;br /&gt;
      &lt;br /&gt;
          System.out.println(&amp;quot;leaving&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
          // It is java VM dependent, whether or not the finalizer was called&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The output of this code depends on the Java VM implementation. The output &amp;quot;finalizer called&amp;quot; is not a usual result. Be aware of the side effects when UNO brings Java and C++ together.&lt;br /&gt;
&lt;br /&gt;
When a UNO C++ object is mapped to Java, a Java proxy object is created that keeps a hard UNO reference to the C++ object. The UNO core takes care of this. The Java proxy only clears the reference when it enters the &amp;lt;code&amp;gt;finalize()&amp;lt;/code&amp;gt; method, thus the destruction of the C++ object is delayed until the Java VM collects some garbage.&lt;br /&gt;
&lt;br /&gt;
When a UNO Java object is mapped to C++, a C++ proxy object is created that keeps a hard UNO reference to the Java object. Internally, the Java UNO bridge keeps a Java reference to the original Java object. When the C++ proxy is no longer used, it is destroyed immediately. The Java UNO bridge is notified and immediately frees the Java reference to the original Java object. When the Java object is finalized is dependent on the garbage collector.&lt;br /&gt;
&lt;br /&gt;
When a Java program is connected to a running {{PRODUCTNAME}}, the UNO objects in the office process are not destroyed until the garbage collector finalizes the Java proxies or until the interprocess connection is closed (see [[Documentation/DevGuide/ProUNO/UNO Interprocess Connections|UNO Interprocess Connections]]).&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Professional UNO]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Text/Inserting_Tables&amp;diff=156410</id>
		<title>Documentation/DevGuide/Text/Inserting Tables</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Text/Inserting_Tables&amp;diff=156410"/>
		<updated>2010-02-06T02:55:04Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/TextTOC&lt;br /&gt;
|Text2b=block&lt;br /&gt;
|TextTables=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Text/Text Table Properties&lt;br /&gt;
|NextPage=Documentation/DevGuide/Text/Accessing Existing Tables&lt;br /&gt;
}}&lt;br /&gt;
{{Documentation/DevGuideLanguages|Documentation/DevGuide/Text/{{SUBPAGENAME}}}} &lt;br /&gt;
 {{DISPLAYTITLE:Inserting Tables}}&lt;br /&gt;
To create and insert a new text table, a five-step procedure must be followed:&lt;br /&gt;
&lt;br /&gt;
# Get the service manager of the text document, querying the document&amp;#039;s factory interface &amp;lt;idl&amp;gt;com.sun.star.lang.XMultiServiceFactory&amp;lt;/idl&amp;gt;.&lt;br /&gt;
# Order a new text table from the factory by its service name &amp;quot;&amp;lt;code&amp;gt;com.sun.star.text.TextTable&amp;lt;/code&amp;gt;&amp;quot;, using the factory method &amp;lt;code&amp;gt;createInstance()&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the object received, query the &amp;lt;idl&amp;gt;com.sun.star.text.XTextTable&amp;lt;/idl&amp;gt; interface that inherits from &amp;lt;idl&amp;gt;com.sun.star.text.XTextContent&amp;lt;/idl&amp;gt;.&lt;br /&gt;
# If necessary, initialize the table with the number of rows and columns. For this purpose, &amp;lt;code&amp;gt;XTextTable&amp;lt;/code&amp;gt; offers the &amp;lt;code&amp;gt;initialize()&amp;lt;/code&amp;gt; method.&lt;br /&gt;
# Insert the table into the text using the &amp;lt;code&amp;gt;insertTextContent()&amp;lt;/code&amp;gt; method at its &amp;lt;idl&amp;gt;com.sun.star.text.XText&amp;lt;/idl&amp;gt; interface. The method &amp;lt;code&amp;gt;insertTextContent()&amp;lt;/code&amp;gt; expects an &amp;lt;code&amp;gt;XTextContent&amp;lt;/code&amp;gt; to insert. Since &amp;lt;code&amp;gt;XTextTable&amp;lt;/code&amp;gt; inherits from &amp;lt;code&amp;gt;XTextContent&amp;lt;/code&amp;gt;, pass the &amp;lt;code&amp;gt;XTextTable&amp;lt;/code&amp;gt; interface retrieved previously.&lt;br /&gt;
&lt;br /&gt;
You are now ready to get cells, fill in text, values and formulas and set the table and cell properties as needed.&lt;br /&gt;
&lt;br /&gt;
In the following code sample, there is a small helper function to put random numbers between -1000 and 1000 into the table to demonstrate formulas: &lt;br /&gt;
&amp;lt;!--[SOURCE:Text/TextDocuments.java]--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /** This method returns a random double which isn&amp;#039;t too high or too low&lt;br /&gt;
   */&lt;br /&gt;
  protected double getRandomDouble()&lt;br /&gt;
  {&lt;br /&gt;
      return ((maRandom.nextInt() % 1000) * maRandom.nextDouble());&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
The following helper function inserts a string into a cell known by its name and sets its text color to white: &lt;br /&gt;
&amp;lt;!--[SOURCE:Text/TextDocuments.java]--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /** This method sets the text colour of the cell refered to by sCellName to white and inserts&lt;br /&gt;
      the string sText in it&lt;br /&gt;
   */&lt;br /&gt;
  public static void insertIntoCell(String sCellName, String sText, XTextTable xTable) {&lt;br /&gt;
      // Access the XText interface of the cell referred to by sCellName&lt;br /&gt;
      XText xCellText = (XText) UnoRuntime.queryInterface(&lt;br /&gt;
          XText.class, xTable.getCellByName(sCellName));&lt;br /&gt;
  &lt;br /&gt;
      // create a text cursor from the cells XText interface&lt;br /&gt;
      XTextCursor xCellCursor = xCellText.createTextCursor();&lt;br /&gt;
  &lt;br /&gt;
      // Get the property set of the cell&amp;#039;s TextCursor&lt;br /&gt;
      XPropertySet xCellCursorProps = (XPropertySet)UnoRuntime.queryInterface(&lt;br /&gt;
          XPropertySet.class, xCellCursor);&lt;br /&gt;
  &lt;br /&gt;
      try {&lt;br /&gt;
          // Set the colour of the text to white&lt;br /&gt;
          xCellCursorProps.setPropertyValue(&amp;quot;CharColor&amp;quot;, new Integer(16777215));&lt;br /&gt;
      } catch (Exception e) {&lt;br /&gt;
          e.printStackTrace(System.out);&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
      // Set the text in the cell to sText&lt;br /&gt;
      xCellText.setString(sText);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Using the above helper functions, create a text table and insert it into the text document. &lt;br /&gt;
&amp;lt;!--[SOURCE:Text/TextDocuments.java]--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /** This method shows how to create and insert a text table, as well as insert text and formulae&lt;br /&gt;
      into the cells of the table&lt;br /&gt;
   */&lt;br /&gt;
  protected void TextTableExample ()&lt;br /&gt;
  {&lt;br /&gt;
      try &lt;br /&gt;
      {&lt;br /&gt;
          // Create a new table from the document&amp;#039;s factory&lt;br /&gt;
          XTextTable xTable = (XTextTable) UnoRuntime.queryInterface( &lt;br /&gt;
              XTextTable.class, mxDocFactory .createInstance(&lt;br /&gt;
                  &amp;quot;com.sun.star.text.TextTable&amp;quot; ) );&lt;br /&gt;
          &lt;br /&gt;
          // Specify that we want the table to have 4 rows and 4 columns&lt;br /&gt;
          xTable.initialize( 4, 4 );&lt;br /&gt;
          &lt;br /&gt;
          // Insert the table into the document&lt;br /&gt;
          mxDocText.insertTextContent( mxDocCursor, xTable, false);&lt;br /&gt;
          // Get an XIndexAccess of the table rows&lt;br /&gt;
          XIndexAccess xRows = xTable.getRows();&lt;br /&gt;
          &lt;br /&gt;
          // Access the property set of the first row (properties listed in service description:&lt;br /&gt;
          // com.sun.star.text.TextTableRow)&lt;br /&gt;
          XPropertySet xRow = (XPropertySet) UnoRuntime.queryInterface( &lt;br /&gt;
              XPropertySet.class, xRows.getByIndex ( 0 ) );&lt;br /&gt;
          // If BackTransparant is false, then the background color is visible&lt;br /&gt;
          xRow.setPropertyValue( &amp;quot;BackTransparent&amp;quot;, Boolean.FALSE);&lt;br /&gt;
          // Specify the color of the background to be dark blue&lt;br /&gt;
          xRow.setPropertyValue( &amp;quot;BackColor&amp;quot;, new Integer(6710932));&lt;br /&gt;
          &lt;br /&gt;
          // Access the property set of the whole table&lt;br /&gt;
          XPropertySet xTableProps = (XPropertySet)UnoRuntime.queryInterface( &lt;br /&gt;
              XPropertySet.class, xTable );&lt;br /&gt;
          // We want visible background colors&lt;br /&gt;
          xTableProps.setPropertyValue( &amp;quot;BackTransparent&amp;quot;, Boolean.FALSE);&lt;br /&gt;
          // Set the background colour to light blue&lt;br /&gt;
          xTableProps.setPropertyValue( &amp;quot;BackColor&amp;quot;, new Integer(13421823));&lt;br /&gt;
          &lt;br /&gt;
          // set the text (and text colour) of all the cells in the first row of the table&lt;br /&gt;
          insertIntoCell( &amp;quot;A1&amp;quot;, &amp;quot;First Column&amp;quot;, xTable );&lt;br /&gt;
          insertIntoCell( &amp;quot;B1&amp;quot;, &amp;quot;Second Column&amp;quot;, xTable );&lt;br /&gt;
          insertIntoCell( &amp;quot;C1&amp;quot;, &amp;quot;Third Column&amp;quot;, xTable );&lt;br /&gt;
          insertIntoCell( &amp;quot;D1&amp;quot;, &amp;quot;Results&amp;quot;, xTable );&lt;br /&gt;
          &lt;br /&gt;
          // Insert random numbers into the first this three cells of each&lt;br /&gt;
          // remaining row&lt;br /&gt;
          xTable.getCellByName( &amp;quot;A2&amp;quot; ).setValue( getRandomDouble() );&lt;br /&gt;
          xTable.getCellByName( &amp;quot;B2&amp;quot; ).setValue( getRandomDouble() );&lt;br /&gt;
          xTable.getCellByName( &amp;quot;C2&amp;quot; ).setValue( getRandomDouble() );&lt;br /&gt;
          &lt;br /&gt;
          xTable.getCellByName( &amp;quot;A3&amp;quot; ).setValue( getRandomDouble() );&lt;br /&gt;
          xTable.getCellByName( &amp;quot;B3&amp;quot; ).setValue( getRandomDouble() );&lt;br /&gt;
          xTable.getCellByName( &amp;quot;C3&amp;quot; ).setValue( getRandomDouble() );&lt;br /&gt;
          &lt;br /&gt;
          xTable.getCellByName( &amp;quot;A4&amp;quot; ).setValue( getRandomDouble() );&lt;br /&gt;
          xTable.getCellByName( &amp;quot;B4&amp;quot; ).setValue( getRandomDouble() );&lt;br /&gt;
          xTable.getCellByName( &amp;quot;C4&amp;quot; ).setValue( getRandomDouble() );&lt;br /&gt;
          &lt;br /&gt;
          // Set the last cell in each row to be a formula that calculates&lt;br /&gt;
          // the sum of the first three cells&lt;br /&gt;
          xTable.getCellByName( &amp;quot;D2&amp;quot; ).setFormula( &amp;quot;sum &amp;lt;A2:C2&amp;gt;&amp;quot; );&lt;br /&gt;
          xTable.getCellByName( &amp;quot;D3&amp;quot; ).setFormula( &amp;quot;sum &amp;lt;A3:C3&amp;gt;&amp;quot; );&lt;br /&gt;
          xTable.getCellByName( &amp;quot;D4&amp;quot; ).setFormula( &amp;quot;sum &amp;lt;A4:C4&amp;gt;&amp;quot; );&lt;br /&gt;
      } &lt;br /&gt;
      catch (Exception e) &lt;br /&gt;
      {&lt;br /&gt;
          e.printStackTrace ( System.out );&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
The next sample inserts auto text entries into a table, splitting cells during its course. &lt;br /&gt;
&amp;lt;!--[SOURCE:Text/TextDocuments.java]--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /** This example demonstrates the use of the AutoTextContainer, AutoTextGroup and AutoTextEntry services&lt;br /&gt;
      and shows how to create, insert and modify auto text blocks&lt;br /&gt;
   */&lt;br /&gt;
  protected void AutoTextExample ()&lt;br /&gt;
  {&lt;br /&gt;
      try&lt;br /&gt;
      {&lt;br /&gt;
          // Go to the end of the document&lt;br /&gt;
          mxDocCursor.gotoEnd( false );&lt;br /&gt;
          // Insert two paragraphs&lt;br /&gt;
          mxDocText.insertControlCharacter ( mxDocCursor, &lt;br /&gt;
              ControlCharacter.PARAGRAPH_BREAK, false );&lt;br /&gt;
          mxDocText.insertControlCharacter ( mxDocCursor, &lt;br /&gt;
              ControlCharacter.PARAGRAPH_BREAK, false );&lt;br /&gt;
          // Position the cursor in the second paragraph&lt;br /&gt;
          XParagraphCursor xParaCursor = (XParagraphCursor) UnoRuntime.queryInterface(&lt;br /&gt;
              XParagraphCursor.class, mxDocCursor );&lt;br /&gt;
          xParaCursor.gotoPreviousParagraph ( false );&lt;br /&gt;
          &lt;br /&gt;
          // Get an XNameAccess interface to all auto text groups from the document factory&lt;br /&gt;
          XNameAccess xContainer = (XNameAccess) UnoRuntime.queryInterface( &lt;br /&gt;
              XNameAccess.class, mxFactory.createInstance (&lt;br /&gt;
                  &amp;quot;com.sun.star.text.AutoTextContainer&amp;quot; ) );&lt;br /&gt;
          &lt;br /&gt;
          // Create a new table at the document factory&lt;br /&gt;
          XTextTable xTable = (XTextTable) UnoRuntime.queryInterface( &lt;br /&gt;
              XTextTable.class, mxDocFactory .createInstance( &lt;br /&gt;
                  &amp;quot;com.sun.star.text.TextTable&amp;quot; ) );&lt;br /&gt;
          &lt;br /&gt;
          // Store the names of all auto text groups in an array of strings&lt;br /&gt;
          String[] aGroupNames = xContainer.getElementNames();&lt;br /&gt;
          &lt;br /&gt;
          // Make sure we have at least one group name&lt;br /&gt;
          if ( aGroupNames.length &amp;gt; 0 ) &lt;br /&gt;
          {&lt;br /&gt;
              // initialise the table to have a row for every autotext group &lt;br /&gt;
              //in a single column + one&lt;br /&gt;
              // additional row for a header&lt;br /&gt;
              xTable.initialize( aGroupNames.length+1,1);&lt;br /&gt;
              &lt;br /&gt;
              // Access the XPropertySet of the table&lt;br /&gt;
              XPropertySet xTableProps = (XPropertySet)UnoRuntime.queryInterface(&lt;br /&gt;
                  XPropertySet.class, xTable );&lt;br /&gt;
              &lt;br /&gt;
              // We want a visible background&lt;br /&gt;
              xTableProps.setPropertyValue( &amp;quot;BackTransparent&amp;quot;, Boolean.FALSE);&lt;br /&gt;
              &lt;br /&gt;
              // We want the background to be light blue&lt;br /&gt;
              xTableProps.setPropertyValue( &amp;quot;BackColor&amp;quot;, new Integer(13421823));&lt;br /&gt;
              &lt;br /&gt;
              // Insert the table into the document&lt;br /&gt;
              mxDocText.insertTextContent( mxDocCursor, xTable, false);&lt;br /&gt;
              &lt;br /&gt;
              // Get an XIndexAccess to all table rows&lt;br /&gt;
              XIndexAccess xRows = xTable.getRows();&lt;br /&gt;
              &lt;br /&gt;
              // Get the first row in the table&lt;br /&gt;
              XPropertySet xRow = (XPropertySet) UnoRuntime.queryInterface(&lt;br /&gt;
                  XPropertySet.class, xRows.getByIndex ( 0 ) );&lt;br /&gt;
              &lt;br /&gt;
              // We want the background of the first row to be visible too&lt;br /&gt;
              xRow.setPropertyValue( &amp;quot;BackTransparent&amp;quot;, Boolean.FALSE);&lt;br /&gt;
              &lt;br /&gt;
              // And let&amp;#039;s make it dark blue&lt;br /&gt;
              xRow.setPropertyValue( &amp;quot;BackColor&amp;quot;, new Integer(6710932));&lt;br /&gt;
              &lt;br /&gt;
              // Put a description of the table contents into the first cell&lt;br /&gt;
              insertIntoCell( &amp;quot;A1&amp;quot;, &amp;quot;AutoText Groups&amp;quot;, xTable);&lt;br /&gt;
              &lt;br /&gt;
              // Create a table cursor pointing at the second cell in the first column&lt;br /&gt;
              XTextTableCursor xTableCursor = xTable.createCursorByCellName ( &amp;quot;A2&amp;quot; );&lt;br /&gt;
              &lt;br /&gt;
              // Loop over the group names&lt;br /&gt;
              for ( int i = 0 ; i &amp;lt; aGroupNames.length ; i ++ )&lt;br /&gt;
              {&lt;br /&gt;
                  // Get the name of the current cell&lt;br /&gt;
                  String sCellName = xTableCursor.getRangeName ();&lt;br /&gt;
                  &lt;br /&gt;
                  // Get the XText interface of the current cell&lt;br /&gt;
                  XText xCellText = (XText) UnoRuntime.queryInterface ( &lt;br /&gt;
                      XText.class, xTable.getCellByName ( sCellName ) );&lt;br /&gt;
                  &lt;br /&gt;
                  // Set the cell contents of the current cell to be &lt;br /&gt;
                  //the name of the of an autotext group&lt;br /&gt;
                  xCellText.setString ( aGroupNames[i] );&lt;br /&gt;
                  &lt;br /&gt;
                  // Access the autotext gruop with this name&lt;br /&gt;
                  XAutoTextGroup xGroup = ( XAutoTextGroup ) UnoRuntime.queryInterface (&lt;br /&gt;
                      XAutoTextGroup.class,xContainer.getByName(aGroupNames[i]));&lt;br /&gt;
                  &lt;br /&gt;
                  // Get the titles of each autotext block in this group&lt;br /&gt;
                  String [] aBlockNames = xGroup.getTitles();&lt;br /&gt;
                  &lt;br /&gt;
                  // Make sure that the autotext group contains at least one block&lt;br /&gt;
                  if ( aBlockNames.length &amp;gt; 0 )&lt;br /&gt;
                  {&lt;br /&gt;
                      // Split the current cell vertically into two seperate cells&lt;br /&gt;
                      xTableCursor.splitRange ( (short) 1, false );&lt;br /&gt;
                      &lt;br /&gt;
                      // Put the cursor in the newly created right hand cell &lt;br /&gt;
                      // and select it&lt;br /&gt;
                      xTableCursor.goRight ( (short) 1, false );&lt;br /&gt;
                      &lt;br /&gt;
                      // Split this cell horizontally to make a seperate cell &lt;br /&gt;
                      // for each Autotext block&lt;br /&gt;
                      if ( ( aBlockNames.length -1 ) &amp;gt; 0 )&lt;br /&gt;
                          xTableCursor.splitRange ( &lt;br /&gt;
                              (short) (aBlockNames.length - 1), true );&lt;br /&gt;
                      &lt;br /&gt;
                      // loop over the block names&lt;br /&gt;
                      for ( int j = 0 ; j &amp;lt; aBlockNames.length ; j ++ )&lt;br /&gt;
                      {&lt;br /&gt;
                          // Get the XText interface of the current cell&lt;br /&gt;
                          xCellText = (XText) UnoRuntime.queryInterface (&lt;br /&gt;
                              XText.class, xTable.getCellByName (&lt;br /&gt;
                              xTableCursor.getRangeName() ) );&lt;br /&gt;
                      &lt;br /&gt;
                          // Set the text contents of the current cell to the&lt;br /&gt;
                          // title of an Autotext block&lt;br /&gt;
                          xCellText.setString ( aBlockNames[j] );&lt;br /&gt;
                      &lt;br /&gt;
                          // Move the cursor down one cell&lt;br /&gt;
                          xTableCursor.goDown( (short)1, false);&lt;br /&gt;
                      }&lt;br /&gt;
                  }&lt;br /&gt;
                  // Go back to the cell we originally split&lt;br /&gt;
                  xTableCursor.gotoCellByName ( sCellName, false );&lt;br /&gt;
                  &lt;br /&gt;
                  // Go down one cell&lt;br /&gt;
                  xTableCursor.goDown( (short)1, false);&lt;br /&gt;
              }&lt;br /&gt;
              &lt;br /&gt;
              XAutoTextGroup xGroup;&lt;br /&gt;
              String [] aBlockNames;&lt;br /&gt;
              &lt;br /&gt;
              // Add a depth so that we only generate 200 numbers before &lt;br /&gt;
              // giving up on finding a random autotext group that contains autotext blocks&lt;br /&gt;
              int nDepth = 0;&lt;br /&gt;
              do&lt;br /&gt;
              {&lt;br /&gt;
                  // Generate a random, positive number which is lower than &lt;br /&gt;
                  // the number of autotext groups&lt;br /&gt;
                  int nRandom = Math.abs ( maRandom.nextInt() % aGroupNames.length );&lt;br /&gt;
                  &lt;br /&gt;
                  // Get the autotext group at this name&lt;br /&gt;
                  xGroup = ( XAutoTextGroup ) UnoRuntime.queryInterface (&lt;br /&gt;
                      XAutoTextGroup.class, xContainer.getByName (&lt;br /&gt;
                          aGroupNames[ nRandom ] ) );&lt;br /&gt;
                  &lt;br /&gt;
                  // Fill our string array with the names of all the blocks in this&lt;br /&gt;
                  // group&lt;br /&gt;
                  aBlockNames = xGroup.getElementNames();&lt;br /&gt;
                  &lt;br /&gt;
                  // increment our depth counter&lt;br /&gt;
                  ++nDepth;&lt;br /&gt;
              }                  &lt;br /&gt;
              while ( nDepth &amp;lt; 200 &amp;amp;&amp;amp; aBlockNames.length == 0 );&lt;br /&gt;
              // If we managed to find a group containg blocks...&lt;br /&gt;
              if ( aBlockNames.length &amp;gt; 0 )&lt;br /&gt;
              {&lt;br /&gt;
                  // Pick a random block in this group and get it&amp;#039;s&lt;br /&gt;
                  // XAutoTextEntry interface&lt;br /&gt;
                  int nRandom = Math.abs ( maRandom.nextInt() &lt;br /&gt;
                      % aBlockNames.length );&lt;br /&gt;
                  XAutoTextEntry xEntry = ( XAutoTextEntry )&lt;br /&gt;
                      UnoRuntime.queryInterface ( &lt;br /&gt;
                          XAutoTextEntry.class, xGroup.getByName (&lt;br /&gt;
                              aBlockNames[ nRandom ] ) );&lt;br /&gt;
                  // insert the modified autotext block at the end of the document&lt;br /&gt;
                  xEntry.applyTo ( mxDocCursor );&lt;br /&gt;
                  &lt;br /&gt;
                  // Get the titles of all text blocks in this AutoText group&lt;br /&gt;
                  String [] aBlockTitles = xGroup.getTitles();&lt;br /&gt;
                  &lt;br /&gt;
                  // Get the XNamed interface of the autotext group&lt;br /&gt;
                  XNamed xGroupNamed = ( XNamed ) UnoRuntime.queryInterface (&lt;br /&gt;
                      XNamed.class, xGroup );&lt;br /&gt;
                  &lt;br /&gt;
                  // Output the short cut and title of the random block &lt;br /&gt;
                  //and the name of the group it&amp;#039;s from&lt;br /&gt;
                  System.out.println ( &amp;quot;Inserted the Autotext &amp;#039;&amp;quot; + aBlockTitles[nRandom] &lt;br /&gt;
                      + &amp;quot;&amp;#039;, shortcut &amp;#039;&amp;quot; + aBlockNames[nRandom] + &amp;quot;&amp;#039; from group &amp;#039;&amp;quot; &lt;br /&gt;
                          + xGroupNamed.getName() );&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          &lt;br /&gt;
          // Go to the end of the document&lt;br /&gt;
          mxDocCursor.gotoEnd( false );&lt;br /&gt;
          // Insert new paragraph&lt;br /&gt;
          mxDocText.insertControlCharacter ( &lt;br /&gt;
              mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );&lt;br /&gt;
          &lt;br /&gt;
          // Position cursor in new paragraph&lt;br /&gt;
          xParaCursor.gotoPreviousParagraph ( false );&lt;br /&gt;
          &lt;br /&gt;
          // Insert a string in the new paragraph&lt;br /&gt;
          mxDocText.insertString ( mxDocCursor, &amp;quot;Some text for a new autotext block&amp;quot;, false );&lt;br /&gt;
          &lt;br /&gt;
          // Go to the end of the document&lt;br /&gt;
          mxDocCursor.gotoEnd( false );&lt;br /&gt;
      }&lt;br /&gt;
      catch (Exception e) &lt;br /&gt;
      {&lt;br /&gt;
          e.printStackTrace ( System.out );&lt;br /&gt;
      }&lt;br /&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>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Drawings/Presentation_Settings&amp;diff=156406</id>
		<title>Documentation/DevGuide/Drawings/Presentation Settings</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Drawings/Presentation_Settings&amp;diff=156406"/>
		<updated>2010-02-06T02:44:32Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/DrawingsTOC&lt;br /&gt;
|Drawing2e=block&lt;br /&gt;
|DrawingPresSetting=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Drawings/Working with Presentation Documents&lt;br /&gt;
|NextPage=Documentation/DevGuide/Drawings/Custom Slide Show&lt;br /&gt;
}}&lt;br /&gt;
{{Documentation/DevGuideLanguages|Documentation/DevGuide/Drawings/{{SUBPAGENAME}}}} &lt;br /&gt;
 {{DISPLAYTITLE:Presentation Settings}}&lt;br /&gt;
&amp;lt;!--&amp;lt;idltopic&amp;gt;com.sun.star.presentation.XPresentation&amp;lt;/idltopic&amp;gt;--&amp;gt;&lt;br /&gt;
Impress documents contain a Presentation service that controls a running presentation. This &amp;lt;idl&amp;gt;com.sun.star.presentation.Presentation&amp;lt;/idl&amp;gt; service can be accessed through the &amp;lt;idl&amp;gt;com.sun.star.presentation.XPresentationSupplier&amp;lt;/idl&amp;gt; interface through the method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  com::sun::star::presentation::XPresentation getPresentation()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method &amp;lt;code&amp;gt;getPresentation()&amp;lt;/code&amp;gt; returns a &amp;lt;idl&amp;gt;com.sun.star.presentation.Presentation&amp;lt;/idl&amp;gt; service. It contains properties for presentation settings and the interface &amp;lt;idl&amp;gt;com.sun.star.presentation.XPresentation&amp;lt;/idl&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The presentation settings define the slide range, which custom show is used, and how the presentation is executed. These settings are provided as properties of the service &amp;lt;idl&amp;gt;com.sun.star.presentation.Presentation&amp;lt;/idl&amp;gt;. This service also exports the &amp;lt;idl&amp;gt;com.sun.star.presentation.XPresentation&amp;lt;/idl&amp;gt; interface that starts and ends a presentation.&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.presentation.XPresentation&amp;lt;/idl&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.presentation.XPresentation:start&amp;lt;/idlm&amp;gt;() &lt;br /&gt;
|Starts the presentation in full-screen mode. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.presentation.XPresentation:end&amp;lt;/idlm&amp;gt;() &lt;br /&gt;
|Stops the presentation. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.presentation.XPresentation:rehearseTimings&amp;lt;/idlm&amp;gt;() &lt;br /&gt;
|Starts the presentation from the beginning and shows the actual running time to the user. &lt;br /&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;
!colspan=&amp;quot;2&amp;quot;|Properties of &amp;lt;idl&amp;gt;com.sun.star.presentation.Presentation&amp;lt;/idl&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.presentation.Presentation:AllowAnimations&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; - Enables/disables the shape animations. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.presentation.Presentation:CustomShow&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; - Contains the name of a customized show that is used for the presentation. &lt;br /&gt;
|-&lt;br /&gt;
|[http://api.openoffice.org/docs/common/ref/com/sun/star/presentation/Presentation.html#FirstPage Presentation:FirstPage] &lt;br /&gt;
|&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; - Contains the name of the page where the presentation is started. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.presentation.Presentation:IsAlwaysOnTop&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; - If true, the window of the presentation is always on top of all the other windows. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.presentation.Presentation:IsAutomatic&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; - If true, all pages are changed automatically. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.presentation.Presentation:IsEndless&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; - If true, the presentation is repeated endlessly. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.presentation.Presentation:IsFullScreen&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; - If true, the presentation runs in full-screen mode. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.presentation.Presentation:IsLivePresentation&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; - With this property, the presentation is set to live mode. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.presentation.Presentation:IsMouseVisible&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; - If true, the mouse is visible during the presentation. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.presentation.Presentation:Pause&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;long&amp;lt;/code&amp;gt; - Duration of the black screen after the presentation has finished. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.presentation.Presentation:StartWithNavigator&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; - If true, the Navigator is opened at the start of the presentation. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.presentation.Presentation:UsePen&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; - If true, a pen is shown during presentation. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.presentation.Presentation:IsShowAll&amp;lt;/idlm&amp;gt;&lt;br /&gt;
|&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; - Show all slides. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.presentation.Presentation:IsShowLogo&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; - Show {{PRODUCTNAME}} logo on pause page in automatic mode. &lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;idlm&amp;gt;com.sun.star.presentation.Presentation:IsTransitionOnClick&amp;lt;/idlm&amp;gt; &lt;br /&gt;
|&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; - Slide change on mouse click, in addition to pressing cursor right. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--[BUG641+]--&amp;gt;&lt;br /&gt;
The properties &amp;lt;code&amp;gt;IsShowAll&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;IsShowLogo&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;IsTransitionOnClick&amp;lt;/code&amp;gt; are currently not documented in the API reference.&lt;br /&gt;
&lt;br /&gt;
The next example demonstrates how to start a presentation that is automatically repeated and plays in full-screen mode by modifying the presentation settings. &lt;br /&gt;
&amp;lt;!--[SOURCE:Drawing/PresentationDemo.java]--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  XPresentationSupplier xPresSupplier = (XPresentationSupplier)UnoRuntime.queryInterface( &lt;br /&gt;
      XPresentationSupplier.class, xComponent);&lt;br /&gt;
  XPresentation xPresentation = xPresSupplier.getPresentation();&lt;br /&gt;
  XPropertySet xPresPropSet = (XPropertySet)UnoRuntime.queryInterface(&lt;br /&gt;
      XPropertySet.class, xPresentation);&lt;br /&gt;
  xPresPropSet.setPropertyValue(&amp;quot;IsEndless&amp;quot;, Boolean.TRUE);&lt;br /&gt;
  xPresPropSet.setPropertyValue(&amp;quot;IsFullScreen&amp;quot;, Boolean.TRUE);&lt;br /&gt;
  xPresPropSet.setPropertyValue(&amp;quot;Pause&amp;quot;, new Integer(0));&lt;br /&gt;
  xPresentation.start();&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/Drawing Documents and Presentation Documents]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/WritingUNO/Disable_Commands&amp;diff=156336</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=156336"/>
		<updated>2010-02-05T09:03:05Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &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;
{{Documentation/DevGuideLanguages|Documentation/DevGuide/WritingUNO/{{SUBPAGENAME}}}}&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;
          &amp;quot;Open&amp;quot;,&lt;br /&gt;
          &amp;quot;About&amp;quot;,&lt;br /&gt;
          &amp;quot;SelectAll&amp;quot;,&lt;br /&gt;
          &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 = &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 = &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 = &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>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/WritingUNO/Possible_Structures_for_Java_Components&amp;diff=156332</id>
		<title>Documentation/DevGuide/WritingUNO/Possible Structures for Java Components</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/WritingUNO/Possible_Structures_for_Java_Components&amp;diff=156332"/>
		<updated>2010-02-05T06:27:49Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/WritingUNOTOC&lt;br /&gt;
|WritingUNO2c=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/WritingUNO/Create Instance with Arguments&lt;br /&gt;
|NextPage=Documentation/DevGuide/WritingUNO/Running and Debugging Java Components&lt;br /&gt;
}}&lt;br /&gt;
{{Documentation/DevGuideLanguages|Documentation/DevGuide/WritingUNO/{{SUBPAGENAME}}}}&lt;br /&gt;
{{DISPLAYTITLE:Possible Structures for Java Components}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
The implementation of a component depends on the needs of the implementer. The following examples show some possible ways to assemble a component. There can be one implemented object or several implemented objects per component file.&lt;br /&gt;
&lt;br /&gt;
=== One Implementation per Component File ===&lt;br /&gt;
&lt;br /&gt;
There are additional options if implementing one service per component file:&lt;br /&gt;
&lt;br /&gt;
* Use a flat structure with the static component operations added to the service implementation class directly.&lt;br /&gt;
* Reserve the class with the implementation name for the static component operation and use an inner class to implement the service.&lt;br /&gt;
&lt;br /&gt;
==== Implementation Class with Component Operations ====&lt;br /&gt;
&lt;br /&gt;
An implementation class contains the static component operations. The following sample implements an interface &amp;lt;code&amp;gt;com.sun.star.test.XSomething&amp;lt;/code&amp;gt; in an implementation class &amp;lt;code&amp;gt;JavaComp.TestComponent&amp;lt;/code&amp;gt;: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  // UNOIDL: interface example specification&lt;br /&gt;
  module com { module sun { module star { module test { &lt;br /&gt;
  &lt;br /&gt;
  interface XSomething: com::sun::star::uno::XInterface&lt;br /&gt;
  { &lt;br /&gt;
      string methodOne([in]string val);&lt;br /&gt;
  }; &lt;br /&gt;
  }; }; }; }; &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
A component that implements only one service supporting &amp;lt;code&amp;gt;XSomething&amp;lt;/code&amp;gt; can be assembled in one class as follows: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  package JavaComp;&lt;br /&gt;
  &lt;br /&gt;
  ...&lt;br /&gt;
  &lt;br /&gt;
  public class TestComponent implements XSomething, XTypeProvider, XServiceInfo {&lt;br /&gt;
  &lt;br /&gt;
      public static final String __serviceName=&amp;quot;com.sun.star.test.JavaTestComponent&amp;quot;; &lt;br /&gt;
    &lt;br /&gt;
      public static XSingleServiceFactory __getServiceFactory(String implName,&lt;br /&gt;
                                XMultiServiceFactory multiFactory, XRegistryKey regKey) {&lt;br /&gt;
      XSingleServiceFactory xSingleServiceFactory = null;&lt;br /&gt;
  &lt;br /&gt;
      if (implName.equals( TestComponent.class.getName()) )&lt;br /&gt;
          xSingleServiceFactory = FactoryHelper.getServiceFactory( TestComponent.class,&lt;br /&gt;
                                TestComponent.__serviceName, multiFactory, regKey); &lt;br /&gt;
          return xSingleServiceFactory;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
      public static boolean __writeRegistryServiceInfo(XRegistryKey regKey){&lt;br /&gt;
          return FactoryHelper.writeRegistryServiceInfo( TestComponent.class.getName(),&lt;br /&gt;
                      TestComponent.__serviceName, regKey);&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      // XSomething&lt;br /&gt;
      string methodOne(String val) {&lt;br /&gt;
          return val;&lt;br /&gt;
      }&lt;br /&gt;
      //XTypeProvider&lt;br /&gt;
      public com.sun.star.uno.Type[] getTypes( ) {&lt;br /&gt;
          ...&lt;br /&gt;
      } &lt;br /&gt;
      // XTypeProvider&lt;br /&gt;
      public byte[] getImplementationId( ) {&lt;br /&gt;
          ...&lt;br /&gt;
      }&lt;br /&gt;
      //XServiceInfo&lt;br /&gt;
      public String getImplementationName( ) {&lt;br /&gt;
          ...&lt;br /&gt;
      }&lt;br /&gt;
      // XServiceInfo&lt;br /&gt;
      public boolean supportsService( /*IN*/String serviceName ) {&lt;br /&gt;
          ...&lt;br /&gt;
      }&lt;br /&gt;
      //XServiceInfo&lt;br /&gt;
      public String[] getSupportedServiceNames( ) {&lt;br /&gt;
          ...&lt;br /&gt;
      } &lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The class implements the &amp;lt;code&amp;gt;XSomething&amp;lt;/code&amp;gt; interface. The IDL description and documentation provides information about its functionality. The class also contains the functions for factory creation and registration, therefore the manifest entry must read as follows:&lt;br /&gt;
&lt;br /&gt;
  RegistrationClassName: JavaComp.TestComponent&lt;br /&gt;
&lt;br /&gt;
==== Implementation Class with Component Operations and Inner Implementation Class ====&lt;br /&gt;
To implement the component as inner class of the one that provides the service factory through &amp;lt;code&amp;gt;__getServiceFactory()&amp;lt;/code&amp;gt;, it must be a &amp;#039;&amp;#039;static&amp;#039;&amp;#039; inner class, otherwise the factory provided by the &amp;lt;code&amp;gt;FactoryHelper&amp;lt;/code&amp;gt; cannot create the component. An example for an inner implementation class is located in the sample &amp;lt;code&amp;gt;com.sun.star.comp.demo.DemoComponent.java&amp;lt;/code&amp;gt; provided with the SDK. The implementation of &amp;lt;code&amp;gt;__getServiceFactory()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;__writeRegistryServiceInfo()&amp;lt;/code&amp;gt; is omitted here, because they act the same as in the implementation class with component operations above.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  package com.sun.star.comp.demo;&lt;br /&gt;
  &lt;br /&gt;
  public class DemoComponent {&lt;br /&gt;
  &lt;br /&gt;
      ...&lt;br /&gt;
      // static inner class implements service com.sun.star.demo.DemoComponent&lt;br /&gt;
      static public class _Implementation implements XTypeProvider, &lt;br /&gt;
                      XServiceInfo, XInitialization, XWindowListener, &lt;br /&gt;
                      XActionListener, XTopWindowListener {&lt;br /&gt;
  &lt;br /&gt;
      static private final String __serviceName = &amp;quot;com.sun.star.demo.DemoComponent&amp;quot;;&lt;br /&gt;
      private XMultiServiceFactory _xMultiServiceFactory;&lt;br /&gt;
  &lt;br /&gt;
      // Constructor&lt;br /&gt;
      public _Implementation(XMultiServiceFactory xMultiServiceFactory) {&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  // static method to get a single factory creating the given service from the factory helper&lt;br /&gt;
  public static XSingleServiceFactory __getServiceFactory(String implName,&lt;br /&gt;
                                          XMultiServiceFactory multiFactory, &lt;br /&gt;
                                          XRegistryKey regKey) {&lt;br /&gt;
              ...&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
      // static method to write the service information into the given registry key&lt;br /&gt;
      public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {&lt;br /&gt;
          ...&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The manifest entry for this implementation structure again has to point to the class with the static component operations:&lt;br /&gt;
&lt;br /&gt;
  RegistrationClassName: com.sun.star.comp.demo.DemoComponent&lt;br /&gt;
&lt;br /&gt;
=== Multiple Implementations per Component File ===&lt;br /&gt;
&lt;br /&gt;
To assemble several service implementations in one component file, implement each service in its own class and add a separate class containing the static component operations. The following code sample features two services: &amp;lt;code&amp;gt;TestComponentA&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;TestComponentB&amp;lt;/code&amp;gt; implementing the interfaces &amp;lt;code&amp;gt;XSomethingA&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;XSomethingB&amp;lt;/code&amp;gt; with a separate static class &amp;lt;code&amp;gt;TestServiceProvider&amp;lt;/code&amp;gt; containing the component operations.&lt;br /&gt;
&lt;br /&gt;
The following are the UNOIDL specifications for &amp;lt;code&amp;gt;XSomethingA&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;XSomethingB&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
  module com { module sun { module star { module test {&lt;br /&gt;
  interface XSomethingA: com::sun::star::uno::XInterface&lt;br /&gt;
  { &lt;br /&gt;
      string methodOne([in]string value);&lt;br /&gt;
  }; &lt;br /&gt;
  }; }; }; }; &lt;br /&gt;
  &lt;br /&gt;
  module com { module sun { module star { module test {&lt;br /&gt;
  interface XSomethingB: com::sun::star::uno::XInterface&lt;br /&gt;
  { &lt;br /&gt;
      string methodTwo([in]string value);&lt;br /&gt;
  }; &lt;br /&gt;
  }; }; }; }; &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;TestComponentA&amp;lt;/code&amp;gt; implements &amp;lt;code&amp;gt;XSomethingA&amp;lt;/code&amp;gt;: &amp;lt;!--[SOURCE:Components/JavaComponent/TestComponentA.java]:--&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  package JavaComp;&lt;br /&gt;
  &lt;br /&gt;
  public class TestComponentA implements XTypeProvider, XServiceInfo, XSomethingA {&lt;br /&gt;
      static final String __serviceName= &amp;quot;JavaTestComponentA&amp;quot;; &lt;br /&gt;
      &lt;br /&gt;
      static byte[] _implementationId;&lt;br /&gt;
      &lt;br /&gt;
      public TestComponentA() {&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      // XSomethingA&lt;br /&gt;
      public String methodOne(String val) {&lt;br /&gt;
          return val;&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      //XTypeProvider&lt;br /&gt;
      public com.sun.star.uno.Type[] getTypes( ) {&lt;br /&gt;
          Type[] retValue= new Type[3];&lt;br /&gt;
          retValue[0]= new Type( XServiceInfo.class);&lt;br /&gt;
          retValue[1]= new Type( XTypeProvider.class);&lt;br /&gt;
          retValue[2]= new Type( XSomethingA.class);&lt;br /&gt;
          return retValue;&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      //XTypeProvider&lt;br /&gt;
      synchronized public byte[] getImplementationId( ) {&lt;br /&gt;
          if (_implementationId == null) {&lt;br /&gt;
              _implementationId= new byte[16];&lt;br /&gt;
              int hash = hashCode();&lt;br /&gt;
              _implementationId[0] = (byte)(hash &amp;amp; 0xff);&lt;br /&gt;
              _implementationId[1] = (byte)((hash &amp;gt;&amp;gt;&amp;gt; 8) &amp;amp; 0xff);&lt;br /&gt;
              _implementationId[2] = (byte)((hash &amp;gt;&amp;gt;&amp;gt; 16) &amp;amp; 0xff);&lt;br /&gt;
              _implementationId[3] = (byte)((hash &amp;gt;&amp;gt;&amp;gt;24) &amp;amp; 0xff);&lt;br /&gt;
          }&lt;br /&gt;
          return _implementationId;&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      //XServiceInfo&lt;br /&gt;
      public String getImplementationName( ) {&lt;br /&gt;
          return getClass().getName();&lt;br /&gt;
      }&lt;br /&gt;
      // XServiceInfo&lt;br /&gt;
      public boolean supportsService( /*IN*/String serviceName ) {&lt;br /&gt;
          return serviceName.equals( __serviceName);&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      //XServiceInfo&lt;br /&gt;
      public String[] getSupportedServiceNames( ) {&lt;br /&gt;
          String[] retValue= new String[0];&lt;br /&gt;
          retValue[0]= __serviceName;&lt;br /&gt;
          return retValue;&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;TestComponentB&amp;lt;/code&amp;gt; implements &amp;lt;code&amp;gt;XSomethingB&amp;lt;/code&amp;gt;. Note that it receives the component context and initialization arguments in its constructor. &amp;lt;!--[SOURCE:Components/JavaComponent/TestComponentB.java]--&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  package JavaComp;&lt;br /&gt;
  &lt;br /&gt;
  public class TestComponentB implements XTypeProvider, XServiceInfo, XSomethingB {&lt;br /&gt;
      static final String __serviceName= &amp;quot;JavaTestComponentB&amp;quot;; &lt;br /&gt;
  &lt;br /&gt;
      static byte[] _implementationId;&lt;br /&gt;
      private XComponentContext context; &lt;br /&gt;
      private Object[] args; &lt;br /&gt;
      &lt;br /&gt;
      public TestComponentB(XComponentContext context, Object[] args) {&lt;br /&gt;
          this.context= context; &lt;br /&gt;
          this.args= args;&lt;br /&gt;
      }&lt;br /&gt;
       &lt;br /&gt;
      // XSomethingB&lt;br /&gt;
      public String methodTwo(String val) {&lt;br /&gt;
          if (args.length &amp;gt; 0 &amp;amp;&amp;amp; args[0] instanceof String )&lt;br /&gt;
          return (String) args[0];&lt;br /&gt;
          return val;&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      //XTypeProvider&lt;br /&gt;
      public com.sun.star.uno.Type[] getTypes( ) {&lt;br /&gt;
          Type[] retValue= new Type[3];&lt;br /&gt;
          retValue[0]= new Type( XServiceInfo.class);&lt;br /&gt;
          retValue[1]= new Type( XTypeProvider.class);&lt;br /&gt;
          retValue[2]= new Type( XSomethingB.class);&lt;br /&gt;
          return retValue;&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      //XTypeProvider&lt;br /&gt;
      synchronized public byte[] getImplementationId( ) {&lt;br /&gt;
          if (_implementationId == null) {&lt;br /&gt;
              _implementationId= new byte[16];&lt;br /&gt;
              int hash = hashCode();&lt;br /&gt;
              _implementationId[0] = (byte)(hash &amp;amp; 0xff);&lt;br /&gt;
              _implementationId[1] = (byte)((hash &amp;gt;&amp;gt;&amp;gt; 8) &amp;amp; 0xff);&lt;br /&gt;
              _implementationId[2] = (byte)((hash &amp;gt;&amp;gt;&amp;gt; 16) &amp;amp; 0xff);&lt;br /&gt;
              _implementationId[3] = (byte)((hash &amp;gt;&amp;gt;&amp;gt;24) &amp;amp; 0xff);&lt;br /&gt;
          }&lt;br /&gt;
          return _implementationId;&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      //XServiceInfo&lt;br /&gt;
      public String getImplementationName( ) {&lt;br /&gt;
          return getClass().getName();&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      // XServiceInfo&lt;br /&gt;
      public boolean supportsService( /*IN*/String serviceName ) {&lt;br /&gt;
          return serviceName.equals( __serviceName);&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      //XServiceInfo&lt;br /&gt;
      public String[] getSupportedServiceNames( ) {&lt;br /&gt;
          String[] retValue= new String[0];&lt;br /&gt;
          retValue[0]= __serviceName;&lt;br /&gt;
          return retValue;&lt;br /&gt;
      } &lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;TestServiceProvider&amp;lt;/code&amp;gt; implements &amp;lt;code&amp;gt;__getServiceFactory()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;__writeRegistryServiceInfo()&amp;lt;/code&amp;gt;: &lt;br /&gt;
&amp;lt;!--[SOURCE:Components/JavaComponent/TestServiceProvider.java]--&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  package JavaComp;&lt;br /&gt;
  ...&lt;br /&gt;
  public class TestServiceProvider&lt;br /&gt;
  {&lt;br /&gt;
      public static XSingleServiceFactory __getServiceFactory(String implName,&lt;br /&gt;
                                               XMultiServiceFactory multiFactory,&lt;br /&gt;
                                               XRegistryKey regKey) {&lt;br /&gt;
          XSingleServiceFactory xSingleServiceFactory = null;&lt;br /&gt;
  &lt;br /&gt;
          if (implName.equals( TestComponentA.class.getName()) )&lt;br /&gt;
              xSingleServiceFactory = FactoryHelper.getServiceFactory( TestComponentA.class,&lt;br /&gt;
                                          TestComponentA.__serviceName, multiFactory, regKey); &lt;br /&gt;
          else if (implName.equals(TestComponentB.class.getName()))&lt;br /&gt;
              xSingleServiceFactory= FactoryHelper.getServiceFactory( TestComponentB.class,&lt;br /&gt;
                                          TestComponentB.__serviceName, multiFactory, regKey);&lt;br /&gt;
          return xSingleServiceFactory;&lt;br /&gt;
      }&lt;br /&gt;
          &lt;br /&gt;
      public static boolean __writeRegistryServiceInfo(XRegistryKey regKey){&lt;br /&gt;
          boolean bregA= FactoryHelper.writeRegistryServiceInfo( TestComponentA.class.getName(),&lt;br /&gt;
                                          TestComponentA.__serviceName, regKey);&lt;br /&gt;
          boolean bregB= FactoryHelper.writeRegistryServiceInfo( TestComponentB.class.getName(),&lt;br /&gt;
                                          TestComponentB.__serviceName, regKey);&lt;br /&gt;
          return bregA &amp;amp;&amp;amp; bregB;&lt;br /&gt;
      } &lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The corresponding manifest entry must point to the static class with the component operations, in this case &amp;lt;code&amp;gt;JavaComp.TestServiceProvider&amp;lt;/code&amp;gt;: &lt;br /&gt;
&lt;br /&gt;
  RegistrationClassName: JavaComp.TestServiceProvider&lt;br /&gt;
&lt;br /&gt;
=== Additional UNO Types ===&lt;br /&gt;
&lt;br /&gt;
To make the Java UNO runtime more robust and efficient, each component is loaded with its own class loader, with one &amp;lt;code&amp;gt;UnoClassLoader&amp;lt;/code&amp;gt; at the root that takes care of loading all Java classes&lt;br /&gt;
representing UNO types in such a way that they are available across the whole Java UNO runtime environment.&lt;br /&gt;
&lt;br /&gt;
If a Java UNO component requires additional UNO types, it must use a &amp;lt;code&amp;gt;UNO-Type-Path&amp;lt;/code&amp;gt; manifest entry to specify the location of the UNO types.  The &amp;lt;code&amp;gt;UNO-Type-Path&amp;lt;/code&amp;gt; is similar to the &amp;lt;code&amp;gt;Class-Path&amp;lt;/code&amp;gt; manifest entry and can contain URLs of jars and directories that contain the Java classes that represent additional UNO types.  The &amp;lt;code&amp;gt;UnoClassLoader&amp;lt;/code&amp;gt; evaluates the &amp;lt;code&amp;gt;UNO-Type-Path&amp;lt;/code&amp;gt; manifest entry to ensure that the additional UNO types are available to the Java UNO environment.  The &amp;lt;code&amp;gt;UNO-Type-Path&amp;lt;/code&amp;gt; can have one of the following formats.&lt;br /&gt;
* Current jar does not contain UNO types:&amp;lt;pre&amp;gt;UNO-Type-Path: &amp;lt;/pre&amp;gt;(Note the final space character.)&lt;br /&gt;
* Current jar contains UNO types:&amp;lt;pre&amp;gt;UNO-Type-Path: &amp;lt;&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Current jar brings other jars that contain UNO types:&amp;lt;pre&amp;gt;UNO-Type-Path: any/other/jar.jar yet/another/jar.jar&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Current jar and other jars that the current jar uses contain UNO types:&amp;lt;pre&amp;gt;UNO-Type-Path: any/other/jar.jar &amp;lt;&amp;gt; yet/another/jar.jar&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|Note: For backwards compatibility, if you do not include the &amp;lt;tt&amp;gt;UNO-Type-Path&amp;lt;/tt&amp;gt; manifest entry at all, the UNO runtime assumes that the current jar does contain UNO types.}}&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Writing UNO Components]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Add-In/CompleteAddIn&amp;diff=156331</id>
		<title>Calc/Add-In/CompleteAddIn</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Add-In/CompleteAddIn&amp;diff=156331"/>
		<updated>2010-02-05T05:20:06Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/Candidate}}&lt;br /&gt;
=An other C++ add-in example=&lt;br /&gt;
In this article under construction, a complete and simple add-in in C++ is presented.&lt;br /&gt;
==Introduction==&lt;br /&gt;
Before reading this article, please read [[Constructing_Components|Constructing Components]] and [[SimpleCalcAddIn]]. In SimpleCalcAddin you will learn most of important things like the tools involved in constructing an addin, the services involved and also the corresponding references to read in the devlopper&amp;#039;s guide. &lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s recall here how different files are created and what are the corresponding tools involved ? A drawing is beter than a long discussion :&lt;br /&gt;
&lt;br /&gt;
[[Image:ComponentTools.png]]&lt;br /&gt;
&lt;br /&gt;
As you can see idlc is used to transform a .IDL-suffix file into a .urd-suffix file, regmerge to transform the previous .urd-suffix file into a .rdb-suffix file and so on... (see the corresponding [[SimpleCalcAddIn#Other_Files|SimpleCalcAddin]] compilation script and also [[Constructing_Components#Compilation_Chain_of_a_Component|Compilation Chain of a Component]]. The action done by the red arrow is not a file transformation but what is usually called registery. Before going further let&amp;#039;s note that starting from an idl file, we will generate an hpp file : this file automatically defines a C++ class that we will use in the cxx file.&lt;br /&gt;
&lt;br /&gt;
You can go further with component and Java [[JavaEclipseTuto|here]]. &lt;br /&gt;
&lt;br /&gt;
We choose here an other way : starting  from an example of SDK slightly modified :&lt;br /&gt;
&amp;lt;OpenOffice.org1.1_SDK&amp;gt;/examples/DevelopersGuide/Components/CppComponent&lt;br /&gt;
&lt;br /&gt;
I mean I will use this example makefile only modified to take into account the fact I only use one file instead the two provided by the example. The makefile compiles the component and installs it.&lt;br /&gt;
&lt;br /&gt;
==IDL File==&lt;br /&gt;
We begin with a simple IDL file with four methods. Here is the corresponding IDL file :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
// IDL&lt;br /&gt;
#include &amp;lt;com/sun/star/uno/XInterface.idl&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/lang/XInitialization.idl&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/lang/XServiceName.idl&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/lang/XLocalizable.idl&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/sheet/XAddIn.idl&amp;gt;&lt;br /&gt;
module my_module&lt;br /&gt;
{&lt;br /&gt;
  interface XSomething : com::sun::star::uno::XInterface&lt;br /&gt;
{ // our four methods&lt;br /&gt;
  string methodOne( [in] string val );&lt;br /&gt;
  string methodTwo( [in] string val );&lt;br /&gt;
  long methodThree( [in] sequence&amp;lt; sequence&amp;lt; long &amp;gt; &amp;gt; aValList );&lt;br /&gt;
  sequence&amp;lt; sequence&amp;lt; long &amp;gt; &amp;gt; methodFour( [in] sequence&amp;lt; sequence&amp;lt; long &amp;gt; &amp;gt; aValList );&lt;br /&gt;
};&lt;br /&gt;
service MyService2&lt;br /&gt;
{&lt;br /&gt;
interface XSomething;&lt;br /&gt;
interface com::sun::star::lang::XInitialization;&lt;br /&gt;
interface com::sun::star::lang::XServiceName;&lt;br /&gt;
interface com::sun::star::sheet::XAddIn;&lt;br /&gt;
};&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Four methods named methodOne, methodTwo, methodThree and methodFour can be seen in this IDL file and then will be implemented.&lt;br /&gt;
&lt;br /&gt;
We give the automatically generated C++ class with the cppumaker tool.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
class SAL_NO_VTABLE XSomething : public ::com::sun::star::uno::XInterface&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
&lt;br /&gt;
    // Methods&lt;br /&gt;
    virtual ::rtl::OUString SAL_CALL methodOne( const ::rtl::OUString&amp;amp; val ) throw&lt;br /&gt;
                     (::com::sun::star::uno::RuntimeException) = 0; &lt;br /&gt;
    virtual ::rtl::OUString SAL_CALL methodTwo( const ::rtl::OUString&amp;amp; val ) throw &lt;br /&gt;
                     (::com::sun::star::uno::RuntimeException) = 0;&lt;br /&gt;
    virtual sal_Int32 SAL_CALL methodThree( const ::com::sun::star::uno::Sequence&amp;lt; &lt;br /&gt;
                     ::com::sun::star::uno::Sequence&amp;lt; sal_Int32 &amp;gt; &amp;gt;&amp;amp; aValList ) throw&lt;br /&gt;
                           (::com::sun::star::uno::RuntimeException) = 0;&lt;br /&gt;
    virtual ::com::sun::star::uno::Sequence&amp;lt; ::com::sun::star::uno::Sequence&amp;lt; &lt;br /&gt;
                      sal_Int32 &amp;gt; &amp;gt; SAL_CALL methodFour( const ::com::sun::star::uno::Sequence&amp;lt;&lt;br /&gt;
                           ::com::sun::star::uno::Sequence&amp;lt; sal_Int32 &amp;gt; &amp;gt;&amp;amp; aValList ) throw &lt;br /&gt;
                               (::com::sun::star::uno::RuntimeException) = 0;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where again the four methods are seen but in C++ language. Note before going further that parameters of the methods  are always marked as const but passed by reference (in C++ style with &amp;amp; operator). It&amp;#039;s time to give the corresponding code.&lt;br /&gt;
&lt;br /&gt;
==Implementing in C++ the corresponding four member Functions==&lt;br /&gt;
We first give the C++ code of the four methods presented in the previous IDL file.&lt;br /&gt;
&lt;br /&gt;
===The two first member functions===&lt;br /&gt;
The two first methods are similar :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// C++&lt;br /&gt;
OUString MyService2Impl::methodOne( OUString const &amp;amp; str )&lt;br /&gt;
throw (RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
  return OUString( RTL_CONSTASCII_USTRINGPARAM(&lt;br /&gt;
    &amp;quot;called methodOne() of MyService2 implementation: &amp;quot;) ) + m_arg + str;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
OUString MyService2Impl::methodTwo( OUString const &amp;amp; str )throw (RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
  return OUString( RTL_CONSTASCII_USTRINGPARAM(&lt;br /&gt;
    &amp;quot;called methodTwo() of MyService2 implementation: &amp;quot;) ) + m_arg + str;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
They only take a string (from a OOoCalc Cell) and add a message and put all the message+string in the result cell.&lt;br /&gt;
&lt;br /&gt;
===The third member Function===&lt;br /&gt;
The third member function is more complicated : it returns a value calculed from a cell range (the sum).&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// C++&lt;br /&gt;
sal_Int32 MyService2Impl::methodThree(const Sequence&amp;lt; Sequence&amp;lt; sal_Int32 &amp;gt; &amp;gt; &amp;amp;aValList )&lt;br /&gt;
throw (RuntimeException)&lt;br /&gt;
{ &lt;br /&gt;
  sal_Int32 n1 = 0;&lt;br /&gt;
  sal_Int32 n2 = 0;&lt;br /&gt;
  sal_Int32 nE1 = aValList.getLength();&lt;br /&gt;
  sal_Int32 nE2 = 0;&lt;br /&gt;
  sal_Int32 temp=0;&lt;br /&gt;
  for( n1 = 0 ; n1 &amp;lt; nE1 ; n1++ )&lt;br /&gt;
  {&lt;br /&gt;
    const Sequence&amp;lt; sal_Int32 &amp;gt; rList = aValList[ n1 ];&lt;br /&gt;
    nE2 = rList.getLength();&lt;br /&gt;
    const sal_Int32* pList = rList.getConstArray();&lt;br /&gt;
    for( n2 = 0 ; n2 &amp;lt; nE2 ; n2++ )&lt;br /&gt;
    {&lt;br /&gt;
      temp += pList[ n2 ];&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  return temp;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===The fourth member Function===&lt;br /&gt;
The goal of the fourth member function is to show how we can implement a matrix function : starting from a cell range and obtaining a cell range.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//C++&lt;br /&gt;
//It&amp;#039;s a matrix operation should be called like : {=METHODFOUR(A1:B4)}&lt;br /&gt;
Sequence&amp;lt; Sequence&amp;lt; sal_Int32 &amp;gt; &amp;gt; MyService2Impl::methodFour(const Sequence&amp;lt; Sequence&amp;lt; sal_Int32 &amp;gt; &amp;gt; &amp;amp;aValList )&lt;br /&gt;
throw (RuntimeException)&lt;br /&gt;
{ sal_Int32 n1, n2;&lt;br /&gt;
  sal_Int32 nE1 = aValList.getLength();&lt;br /&gt;
  sal_Int32 nE2;&lt;br /&gt;
  Sequence&amp;lt; Sequence&amp;lt; sal_Int32 &amp;gt; &amp;gt; temp = aValList;&lt;br /&gt;
  for( n1 = 0 ; n1 &amp;lt; nE1 ; n1++ )&lt;br /&gt;
  {&lt;br /&gt;
    Sequence&amp;lt; sal_Int32 &amp;gt; rList = temp[ n1 ];&lt;br /&gt;
    nE2 = rList.getLength();&lt;br /&gt;
    for( n2 = 0 ; n2 &amp;lt; nE2 ; n2++ )&lt;br /&gt;
    {&lt;br /&gt;
      rList[ n2 ] += 4;&lt;br /&gt;
    }&lt;br /&gt;
    temp[n1]=rList;&lt;br /&gt;
  }&lt;br /&gt;
  return temp;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What is done by this example is not great : only add four to every cells of the cell range and put the result in an other cell range.&lt;br /&gt;
&lt;br /&gt;
Every method are related to a C++ class named MyService2Impl. Let&amp;#039;s now give the corresponding class definition.&lt;br /&gt;
&lt;br /&gt;
===The C++ Class===&lt;br /&gt;
We use an helper to implement our class and then we don&amp;#039;t need to implement all the interfaces : no need to implement XInterface, XTypeProvider, XWeak for instance. We give now the corresponding C++ code.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//C++&lt;br /&gt;
class MyService2Impl : public ::cppu::WeakImplHelper5&amp;lt;&lt;br /&gt;
      ::my_module::XSomething, lang::XServiceInfo, lang::XInitialization, lang::XServiceName,&lt;br /&gt;
	XAddIn&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    OUString m_arg;&lt;br /&gt;
public:&lt;br /&gt;
    // no need to implement XInterface, XTypeProvider, XWeak&lt;br /&gt;
    &lt;br /&gt;
    // XInitialization will be called upon createInstanceWithArguments[AndContext]()&lt;br /&gt;
    virtual void SAL_CALL initialize( Sequence&amp;lt; Any &amp;gt; const &amp;amp; args )&lt;br /&gt;
        throw (Exception);&lt;br /&gt;
    // XSomething&lt;br /&gt;
    virtual OUString SAL_CALL methodOne( OUString const &amp;amp; str )&lt;br /&gt;
        throw (RuntimeException);&lt;br /&gt;
    virtual OUString SAL_CALL methodTwo( OUString const &amp;amp; str )&lt;br /&gt;
        throw (RuntimeException);&lt;br /&gt;
    virtual sal_Int32 SAL_CALL methodThree(const Sequence&amp;lt; Sequence&amp;lt; sal_Int32 &amp;gt; &amp;gt; &amp;amp;aValList )&lt;br /&gt;
        throw (RuntimeException);&lt;br /&gt;
    virtual Sequence&amp;lt; Sequence&amp;lt; sal_Int32 &amp;gt; &amp;gt; SAL_CALL methodFour(&lt;br /&gt;
				const Sequence&amp;lt; Sequence&amp;lt; sal_Int32 &amp;gt; &amp;gt; &amp;amp;aValList )&lt;br /&gt;
	throw (RuntimeException);&lt;br /&gt;
&lt;br /&gt;
    // XServiceName&lt;br /&gt;
    virtual OUString SAL_CALL getServiceName() throw( uno::RuntimeException );&lt;br /&gt;
    // XServiceInfo&lt;br /&gt;
    virtual OUString SAL_CALL getImplementationName()&lt;br /&gt;
        throw (RuntimeException);&lt;br /&gt;
    virtual sal_Bool SAL_CALL supportsService( OUString const &amp;amp; serviceName )&lt;br /&gt;
        throw (RuntimeException);&lt;br /&gt;
    virtual Sequence&amp;lt; OUString &amp;gt; SAL_CALL getSupportedServiceNames()&lt;br /&gt;
        throw (RuntimeException);&lt;br /&gt;
    // XAddIn&lt;br /&gt;
    virtual OUString SAL_CALL getProgrammaticFuntionName( const OUString&amp;amp; aDisplayName ) &lt;br /&gt;
                throw( uno::RuntimeException );&lt;br /&gt;
    virtual OUString SAL_CALL getDisplayFunctionName( const OUString&amp;amp; aProgrammaticName ) &lt;br /&gt;
                throw( uno::RuntimeException );&lt;br /&gt;
    virtual OUString SAL_CALL getFunctionDescription( const OUString&amp;amp; aProgrammaticName ) &lt;br /&gt;
                throw( uno::RuntimeException );&lt;br /&gt;
    virtual OUString SAL_CALL getDisplayArgumentName(&lt;br /&gt;
        const OUString&amp;amp; aProgrammaticName, sal_Int32 nArgument ) throw( uno::RuntimeException );&lt;br /&gt;
    virtual OUString SAL_CALL getArgumentDescription(&lt;br /&gt;
        const OUString&amp;amp; aProgrammaticName, sal_Int32 nArgument ) throw( uno::RuntimeException );&lt;br /&gt;
    virtual OUString SAL_CALL getProgrammaticCategoryName(&lt;br /&gt;
        const OUString&amp;amp; aProgrammaticName ) throw( uno::RuntimeException );&lt;br /&gt;
    virtual OUString SAL_CALL getDisplayCategoryName(&lt;br /&gt;
        const OUString&amp;amp; aProgrammaticName ) throw( uno::RuntimeException );&lt;br /&gt;
    // XLocalizable&lt;br /&gt;
    virtual void SAL_CALL setLocale( const lang::Locale&amp;amp; eLocale ) throw( uno::RuntimeException );&lt;br /&gt;
    virtual lang::Locale SAL_CALL getLocale() throw( uno::RuntimeException );&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code is not complete with the four methods as you can see in the class declaration. Only your own XSomething interface is already implemented (see [[CompleteAddIn#Implementing_in_C.2B.2B_the_corresponding_four_Methods|above]]). You can wonder how is it possible to find all the methods in the class ? As you will learn below, the IDL files corresponding to interfaces have to be read for that. The number of interfaces you have to implement is dependant of your goal. If you want to create a component you have to implement XInterface interface and add more code, if you want to make a scriptable component you still add more code (and more interfaces : XTypeprovider, XServiceInfo and XWeak) and if you want to create an AddIn you have to add more (XAddin, XServiceName). This is explained in Developper&amp;#039;s Guide. We first begin with a typical addin interface : XAddin.&lt;br /&gt;
&lt;br /&gt;
==The XAddIn Interface==&lt;br /&gt;
Every add-in have to implement the &amp;lt;idl&amp;gt;com.sun.star.sheet.XAddIn&amp;lt;/idl&amp;gt; interface. As usual what you have to do is described by an IDL file (or you can read the previous C++ class definition) :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
// IDL&lt;br /&gt;
module com { module sun { module star { module sheet {&lt;br /&gt;
interface XAddIn: com::sun::star::lang::XLocalizable&lt;br /&gt;
{&lt;br /&gt;
  string getProgrammaticFuntionName( [in] string aDisplayName );&lt;br /&gt;
  string getDisplayFunctionName( [in] string aProgrammaticName );&lt;br /&gt;
  string getFunctionDescription( [in] string aProgrammaticName );&lt;br /&gt;
  string getDisplayArgumentName(&lt;br /&gt;
  [in] string aProgrammaticFunctionName,&lt;br /&gt;
  [in] long nArgument );&lt;br /&gt;
  string getArgumentDescription(&lt;br /&gt;
  [in] string aProgrammaticFunctionName,&lt;br /&gt;
  [in] long nArgument );&lt;br /&gt;
  string getProgrammaticCategoryName( [in] string aProgrammaticFunctionName );&lt;br /&gt;
  string getDisplayCategoryName( [in] string aProgrammaticFunctionName );&lt;br /&gt;
};&lt;br /&gt;
}; }; }; };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The corresponding C++ code is given now without explanation (for the moment)&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// C++&lt;br /&gt;
// XAddIn&lt;br /&gt;
OUString SAL_CALL MyService2Impl::getProgrammaticFuntionName( const OUString&amp;amp; aDisplayName ) throw(&lt;br /&gt;
                uno::RuntimeException )&lt;br /&gt;
{&lt;br /&gt;
// not used by calc&lt;br /&gt;
// (but should be implemented for other uses of the AddIn service)&lt;br /&gt;
  return OUString();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
OUString SAL_CALL MyService2Impl::getDisplayFunctionName( const OUString&amp;amp; aProgrammaticName ) throw(&lt;br /&gt;
                uno::RuntimeException )&lt;br /&gt;
{ // a nested if implementation would be better&lt;br /&gt;
  OUString aProgName, aRet;&lt;br /&gt;
  aProgName = aProgrammaticName;&lt;br /&gt;
  if (aProgName.equalsAscii(&amp;quot;methodOne&amp;quot;)) aRet = OUString::createFromAscii(&amp;quot;method1&amp;quot;);&lt;br /&gt;
  if (aProgName.equalsAscii(&amp;quot;methodTwo&amp;quot;)) aRet = OUString::createFromAscii(&amp;quot;method2&amp;quot;);&lt;br /&gt;
  if (aProgName.equalsAscii(&amp;quot;methodThree&amp;quot;)) aRet = OUString::createFromAscii(&amp;quot;method3&amp;quot;);&lt;br /&gt;
  if (aProgName.equalsAscii(&amp;quot;methodFour&amp;quot;)) aRet = OUString::createFromAscii(&amp;quot;method4&amp;quot;);&lt;br /&gt;
  return aRet;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
OUString SAL_CALL MyService2Impl::getFunctionDescription( const OUString&amp;amp; aProgrammaticName ) throw(&lt;br /&gt;
                uno::RuntimeException )&lt;br /&gt;
{ // a nested if implementation would be better&lt;br /&gt;
  OUString aRet;&lt;br /&gt;
  if (aProgrammaticName.equalsAscii(&amp;quot;methodOne&amp;quot;))&lt;br /&gt;
    aRet = OUString::createFromAscii(&amp;quot;methodOne() : 1st try&amp;quot;);&lt;br /&gt;
  if (aProgrammaticName.equalsAscii(&amp;quot;methodTwo&amp;quot;))&lt;br /&gt;
    aRet = OUString::createFromAscii(&amp;quot;methodTwo() : 1st try&amp;quot;);&lt;br /&gt;
  if (aProgrammaticName.equalsAscii(&amp;quot;methodThree&amp;quot;))&lt;br /&gt;
    aRet = OUString::createFromAscii(&amp;quot;methodThree() : 1st try&amp;quot;);&lt;br /&gt;
  if (aProgrammaticName.equalsAscii(&amp;quot;methodFour&amp;quot;)) &lt;br /&gt;
    aRet = OUString::createFromAscii(&amp;quot;methodFour() : 1st try&amp;quot;);&lt;br /&gt;
  return aRet;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
OUString SAL_CALL MyService2Impl::getDisplayArgumentName(&lt;br /&gt;
const OUString&amp;amp; aProgrammaticName, sal_Int32 nArgument ) throw( uno::RuntimeException )&lt;br /&gt;
{ // (requis) is added in French and probably (required) in English (see the snapshot below)&lt;br /&gt;
  OUString aRet;&lt;br /&gt;
  if (aProgrammaticName.equalsAscii(&amp;quot;methodOne&amp;quot;)||aProgrammaticName.equalsAscii(&amp;quot;methodTwo&amp;quot;))&lt;br /&gt;
    aRet = OUString::createFromAscii(&amp;quot;a string&amp;quot;);&lt;br /&gt;
  if (aProgrammaticName.equalsAscii(&amp;quot;methodThree&amp;quot;)||aProgrammaticName.equalsAscii(&amp;quot;methodFour&amp;quot;))&lt;br /&gt;
    aRet = OUString::createFromAscii(&amp;quot;a Cell Range&amp;quot;);&lt;br /&gt;
  return aRet;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
OUString SAL_CALL MyService2Impl::getArgumentDescription(&lt;br /&gt;
const OUString&amp;amp; aProgrammaticName, sal_Int32 nArgument ) throw( uno::RuntimeException )&lt;br /&gt;
{&lt;br /&gt;
  OUString aRet;&lt;br /&gt;
  if (aProgrammaticName.equalsAscii(&amp;quot;methodOne&amp;quot;)||aProgrammaticName.equalsAscii(&amp;quot;methodTwo&amp;quot;))&lt;br /&gt;
    aRet = OUString::createFromAscii(&amp;quot;method1/2:a string or a cell with a string is required&amp;quot;);&lt;br /&gt;
  if (aProgrammaticName.equalsAscii(&amp;quot;methodThree&amp;quot;)||aProgrammaticName.equalsAscii(&amp;quot;methodFour&amp;quot;))&lt;br /&gt;
    aRet = OUString::createFromAscii(&amp;quot;method3/4:a cell range is required&amp;quot;);&lt;br /&gt;
  return aRet;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
OUString SAL_CALL MyService2Impl::getProgrammaticCategoryName(const OUString&amp;amp; aProgrammaticName ) throw(&lt;br /&gt;
                 uno::RuntimeException )&lt;br /&gt;
{&lt;br /&gt;
  OUString aRet( RTL_CONSTASCII_USTRINGPARAM(&amp;quot;Add-In&amp;quot;));&lt;br /&gt;
  return aRet;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
OUString SAL_CALL MyService2Impl::getDisplayCategoryName(const OUString&amp;amp; aProgrammaticName ) throw(&lt;br /&gt;
                  uno::RuntimeException )&lt;br /&gt;
{&lt;br /&gt;
  return getProgrammaticCategoryName( aProgrammaticName );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To understand what is this code related to, we provide a snapshot : read it carefully to see where the code works and provides the strings to print out in the autopilot frame :&lt;br /&gt;
&lt;br /&gt;
[[Image:Addin2.png]]&lt;br /&gt;
&lt;br /&gt;
I have used the method one as you can see above the autopilot frame, and I am ready to use  the method two. What you can read in the autopilot comes directly from the C++ code except the French word &amp;quot;requis&amp;quot; which is probably translated by &amp;quot;required&amp;quot; in an English OpenOffice version.&lt;br /&gt;
&lt;br /&gt;
== The XServiceName Interface==&lt;br /&gt;
&lt;br /&gt;
Again the corresponding IDL file indicates what we have to do :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
// IDL&lt;br /&gt;
module com { module sun { module star { module lang {&lt;br /&gt;
interface XServiceName: com::sun::star::uno::XInterface&lt;br /&gt;
{&lt;br /&gt;
  string getServiceName();&lt;br /&gt;
};&lt;br /&gt;
}; }; }; };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This interface is simple : one method :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//C++&lt;br /&gt;
// XServiceName&lt;br /&gt;
OUString SAL_CALL MyService2Impl::getServiceName() throw( uno::RuntimeException )&lt;br /&gt;
{&lt;br /&gt;
// name of specific AddIn service&lt;br /&gt;
  return OUString::createFromAscii( &amp;quot;my_module.MyService2&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
See &amp;lt;idl&amp;gt;com.sun.star.lang.XServiceName&amp;lt;/idl&amp;gt; for the complete documentation.&lt;br /&gt;
&lt;br /&gt;
==The XServiceInfo Interface==&lt;br /&gt;
This &amp;lt;idl&amp;gt;com.sun.star.lang.XServiceInfo&amp;lt;/idl&amp;gt; interface may be avoided. You have to implement it only if you want that your add-in is also scriptable : you can call it from OOoBasic for instance. It&amp;#039;s time to present the corresponding IDL file :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
// IDL&lt;br /&gt;
module com {  module sun {  module star {  module lang {&lt;br /&gt;
interface XServiceInfo: com::sun::star::uno::XInterface&lt;br /&gt;
{&lt;br /&gt;
	string getImplementationName();&lt;br /&gt;
	boolean supportsService( [in] string ServiceName );&lt;br /&gt;
	sequence&amp;lt;string&amp;gt; getSupportedServiceNames();&lt;br /&gt;
};&lt;br /&gt;
}; }; }; }; &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is the corresponding C++ code :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// C++&lt;br /&gt;
// XServiceInfo implementation&lt;br /&gt;
OUString MyService2Impl::getImplementationName()&lt;br /&gt;
throw (RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
// unique implementation name&lt;br /&gt;
  return OUString( RTL_CONSTASCII_USTRINGPARAM(&amp;quot;my_module.my_sc_impl.MyService2&amp;quot;) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
sal_Bool MyService2Impl::supportsService( OUString const &amp;amp; serviceName )&lt;br /&gt;
throw (RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
// this object only supports one service, so the test is simple&lt;br /&gt;
  return serviceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(&amp;quot;my_module.MyService2&amp;quot;) ) ||&lt;br /&gt;
         serviceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(&amp;quot;com.sun.star.sheet.AddIn&amp;quot;) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Sequence&amp;lt; OUString &amp;gt; MyService2Impl::getSupportedServiceNames()&lt;br /&gt;
throw (RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
  return getSupportedServiceNames_MyService2Impl();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Reference&amp;lt; XInterface &amp;gt; SAL_CALL create_MyService2Impl(Reference&amp;lt; XComponentContext &amp;gt; const &amp;amp; xContext)&lt;br /&gt;
SAL_THROW( () )&lt;br /&gt;
{&lt;br /&gt;
  return static_cast&amp;lt; lang::XTypeProvider * &amp;gt;( new MyService2Impl() );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==XInitialisation Interface==&lt;br /&gt;
This &amp;lt;idl&amp;gt;com.sun.star.lang.XInitialization&amp;lt;/idl&amp;gt; interface could be removed without problem. I will remove it completely in the futur.&lt;br /&gt;
Here is the corresponding C++ code.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// C++&lt;br /&gt;
// XInitialization implemention&lt;br /&gt;
void MyService2Impl::initialize( Sequence&amp;lt; Any &amp;gt; const &amp;amp; args )&lt;br /&gt;
    throw (Exception)&lt;br /&gt;
{&lt;br /&gt;
    if (1 != args.getLength())&lt;br /&gt;
    {&lt;br /&gt;
        throw lang::IllegalArgumentException(&lt;br /&gt;
            OUString( RTL_CONSTASCII_USTRINGPARAM(&amp;quot;give a string instanciating this component!&amp;quot;) ),&lt;br /&gt;
            (::cppu::OWeakObject *)this, // resolve to XInterface reference&lt;br /&gt;
            0 ); // argument pos&lt;br /&gt;
    }&lt;br /&gt;
    if (! (args[ 0 ] &amp;gt;&amp;gt;= m_arg))&lt;br /&gt;
    {&lt;br /&gt;
        throw lang::IllegalArgumentException(&lt;br /&gt;
            OUString( RTL_CONSTASCII_USTRINGPARAM(&amp;quot;no string given as argument!&amp;quot;) ),&lt;br /&gt;
            (::cppu::OWeakObject *)this, // resolve to XInterface reference&lt;br /&gt;
            0 ); // argument pos&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==XLocalizable Interface==&lt;br /&gt;
&lt;br /&gt;
This &amp;lt;idl&amp;gt;com.sun.star.lang.XLocalizable&amp;lt;/idl&amp;gt; interface is particular : we have let it in the class definition and give now the corresponding code but because the code do nothing, we don&amp;#039;t add it as sixth interface when using the helper.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// C++&lt;br /&gt;
// XLocalizable&lt;br /&gt;
void SAL_CALL MyService2Impl::setLocale( const lang::Locale&amp;amp; eLocale ) throw( uno::RuntimeException )&lt;br /&gt;
{&lt;br /&gt;
//    aFuncLoc = eLocale;&lt;br /&gt;
//    InitData();     // change of locale invalidates resources!&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
lang::Locale SAL_CALL MyService2Impl::getLocale() throw( uno::RuntimeException )&lt;br /&gt;
{&lt;br /&gt;
//    return aFuncLoc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Making a registerable component==&lt;br /&gt;
An add-in has to be registered. In fact if you want to use external code, you have to work with a registry. If you use your external code with OOoBasic you call it a component and if you use it with OOoCalc you call it an add-in. But both are very similar. In my knowledge the only exception to this registry rule is OOoBasic (under Windows) which can call directly an external DLL.&lt;br /&gt;
&lt;br /&gt;
To supplement the above code we have to add :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// C++&lt;br /&gt;
/* shared lib exports implemented without helpers in service_impl1.cxx */&lt;br /&gt;
namespace my_sc_impl&lt;br /&gt;
{&lt;br /&gt;
static struct ::cppu::ImplementationEntry s_component_entries [] =&lt;br /&gt;
{&lt;br /&gt;
    {&lt;br /&gt;
        create_MyService2Impl, getImplementationName_MyService2Impl,&lt;br /&gt;
        getSupportedServiceNames_MyService2Impl, ::cppu::createSingleComponentFactory,&lt;br /&gt;
        0, 0&lt;br /&gt;
    },&lt;br /&gt;
    { 0, 0, 0, 0, 0, 0 }&lt;br /&gt;
};&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
extern &amp;quot;C&amp;quot;&lt;br /&gt;
{&lt;br /&gt;
void SAL_CALL component_getImplementationEnvironment(&lt;br /&gt;
    sal_Char const ** ppEnvTypeName, uno_Environment ** ppEnv )&lt;br /&gt;
{&lt;br /&gt;
    *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;&lt;br /&gt;
}&lt;br /&gt;
sal_Bool SAL_CALL component_writeInfo(&lt;br /&gt;
    lang::XMultiServiceFactory * xMgr, registry::XRegistryKey * xRegistry )&lt;br /&gt;
{&lt;br /&gt;
    return ::cppu::component_writeInfoHelper(&lt;br /&gt;
        xMgr, xRegistry, ::my_sc_impl::s_component_entries );&lt;br /&gt;
}&lt;br /&gt;
void * SAL_CALL component_getFactory(&lt;br /&gt;
    sal_Char const * implName, lang::XMultiServiceFactory * xMgr,&lt;br /&gt;
    registry::XRegistryKey * xRegistry )&lt;br /&gt;
{&lt;br /&gt;
    return ::cppu::component_getFactoryHelper(&lt;br /&gt;
        implName, xMgr, xRegistry, ::my_sc_impl::s_component_entries );&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The complete Code ==&lt;br /&gt;
It&amp;#039;s time to give  the C++ complete code :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 9 My first Add-In&lt;br /&gt;
//C++&lt;br /&gt;
#include &amp;lt;cppuhelper/implbase5.hxx&amp;gt; // &amp;quot;5&amp;quot; implementing five interfaces&lt;br /&gt;
#include &amp;lt;cppuhelper/factory.hxx&amp;gt;&lt;br /&gt;
#include &amp;lt;cppuhelper/implementationentry.hxx&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;com/sun/star/lang/XServiceInfo.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/lang/XInitialization.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/lang/XServiceName.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/lang/IllegalArgumentException.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/sheet/XAddIn.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/lang/XLocalizable.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;my_module/XSomething.hpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
using namespace ::rtl; // for OUString&lt;br /&gt;
using namespace ::com::sun::star; // for odk interfaces&lt;br /&gt;
using namespace ::com::sun::star::uno; // for basic types&lt;br /&gt;
using namespace ::com::sun::star::sheet;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
namespace my_sc_impl&lt;br /&gt;
{&lt;br /&gt;
 &lt;br /&gt;
static Sequence&amp;lt; OUString &amp;gt; getSupportedServiceNames_MyService2Impl()&lt;br /&gt;
{&lt;br /&gt;
	static Sequence &amp;lt; OUString &amp;gt; *pNames = 0;&lt;br /&gt;
	if( ! pNames )&lt;br /&gt;
	{&lt;br /&gt;
//		MutexGuard guard( Mutex::getGlobalMutex() );&lt;br /&gt;
		if( !pNames )&lt;br /&gt;
		{&lt;br /&gt;
			static Sequence&amp;lt; OUString &amp;gt; seqNames(2);&lt;br /&gt;
			seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(&amp;quot;my_module.MyService2&amp;quot;));&lt;br /&gt;
                        seqNames.getArray()[1] = OUString(RTL_CONSTASCII_USTRINGPARAM(&amp;quot;com.sun.star.sheet.AddIn&amp;quot;));&lt;br /&gt;
			pNames = &amp;amp;seqNames;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	return *pNames;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static OUString getImplementationName_MyService2Impl()&lt;br /&gt;
{&lt;br /&gt;
	static OUString *pImplName = 0;&lt;br /&gt;
	if( ! pImplName )&lt;br /&gt;
	{&lt;br /&gt;
//		MutexGuard guard( Mutex::getGlobalMutex() );&lt;br /&gt;
		if( ! pImplName )&lt;br /&gt;
		{&lt;br /&gt;
			static OUString implName( RTL_CONSTASCII_USTRINGPARAM(&amp;quot;my_module.my_sc_implementation.MyService2&amp;quot;) );&lt;br /&gt;
			pImplName = &amp;amp;implName;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	return *pImplName;&lt;br /&gt;
}&lt;br /&gt;
    &lt;br /&gt;
class MyService2Impl : public ::cppu::WeakImplHelper5&amp;lt;&lt;br /&gt;
      ::my_module::XSomething, lang::XServiceInfo, lang::XInitialization, lang::XServiceName,&lt;br /&gt;
	/*lang::XLocalizable, */XAddIn&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    OUString m_arg;&lt;br /&gt;
public:&lt;br /&gt;
    // focus on three given interfaces,&lt;br /&gt;
    // no need to implement XInterface, XTypeProvider, XWeak&lt;br /&gt;
    &lt;br /&gt;
    // XInitialization will be called upon createInstanceWithArguments[AndContext]()&lt;br /&gt;
    virtual void SAL_CALL initialize( Sequence&amp;lt; Any &amp;gt; const &amp;amp; args )&lt;br /&gt;
        throw (Exception);&lt;br /&gt;
    // XSomething&lt;br /&gt;
    virtual OUString SAL_CALL methodOne( OUString const &amp;amp; str )&lt;br /&gt;
        throw (RuntimeException);&lt;br /&gt;
    // **********************ADDED&lt;br /&gt;
    virtual OUString SAL_CALL methodTwo( OUString const &amp;amp; str )&lt;br /&gt;
        throw (RuntimeException);&lt;br /&gt;
    virtual sal_Int32 SAL_CALL methodThree(const Sequence&amp;lt; Sequence&amp;lt; sal_Int32 &amp;gt; &amp;gt; &amp;amp;aValList )&lt;br /&gt;
        throw (RuntimeException);&lt;br /&gt;
    virtual Sequence&amp;lt; Sequence&amp;lt; sal_Int32 &amp;gt; &amp;gt; SAL_CALL methodFour(&lt;br /&gt;
				const Sequence&amp;lt; Sequence&amp;lt; sal_Int32 &amp;gt; &amp;gt; &amp;amp;aValList )&lt;br /&gt;
	throw (RuntimeException);&lt;br /&gt;
    // ********************** END ADDED&lt;br /&gt;
    // XServiceName&lt;br /&gt;
    virtual OUString SAL_CALL getServiceName() throw( uno::RuntimeException );&lt;br /&gt;
    // XServiceInfo&lt;br /&gt;
    virtual OUString SAL_CALL getImplementationName()&lt;br /&gt;
        throw (RuntimeException);&lt;br /&gt;
    virtual sal_Bool SAL_CALL supportsService( OUString const &amp;amp; serviceName )&lt;br /&gt;
        throw (RuntimeException);&lt;br /&gt;
    virtual Sequence&amp;lt; OUString &amp;gt; SAL_CALL getSupportedServiceNames()&lt;br /&gt;
        throw (RuntimeException);&lt;br /&gt;
    // XAddIn&lt;br /&gt;
    virtual OUString SAL_CALL getProgrammaticFuntionName( const OUString&amp;amp; aDisplayName ) throw( uno::RuntimeException );&lt;br /&gt;
    virtual OUString SAL_CALL getDisplayFunctionName( const OUString&amp;amp; aProgrammaticName ) throw( uno::RuntimeException );&lt;br /&gt;
    virtual OUString SAL_CALL getFunctionDescription( const OUString&amp;amp; aProgrammaticName ) throw( uno::RuntimeException );&lt;br /&gt;
    virtual OUString SAL_CALL getDisplayArgumentName(&lt;br /&gt;
        const OUString&amp;amp; aProgrammaticName, sal_Int32 nArgument ) throw( uno::RuntimeException );&lt;br /&gt;
    virtual OUString SAL_CALL getArgumentDescription(&lt;br /&gt;
        const OUString&amp;amp; aProgrammaticName, sal_Int32 nArgument ) throw( uno::RuntimeException );&lt;br /&gt;
    virtual OUString SAL_CALL getProgrammaticCategoryName(&lt;br /&gt;
        const OUString&amp;amp; aProgrammaticName ) throw( uno::RuntimeException );&lt;br /&gt;
    virtual OUString SAL_CALL getDisplayCategoryName(&lt;br /&gt;
        const OUString&amp;amp; aProgrammaticName ) throw( uno::RuntimeException );&lt;br /&gt;
    // XLocalizable&lt;br /&gt;
    virtual void SAL_CALL MyService2Impl::setLocale( const lang::Locale&amp;amp; eLocale ) throw( uno::RuntimeException );&lt;br /&gt;
    virtual lang::Locale SAL_CALL MyService2Impl::getLocale() throw( uno::RuntimeException );&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
// XInitialization implemention&lt;br /&gt;
void MyService2Impl::initialize( Sequence&amp;lt; Any &amp;gt; const &amp;amp; args )&lt;br /&gt;
    throw (Exception)&lt;br /&gt;
{&lt;br /&gt;
    if (1 != args.getLength())&lt;br /&gt;
    {&lt;br /&gt;
        throw lang::IllegalArgumentException(&lt;br /&gt;
            OUString( RTL_CONSTASCII_USTRINGPARAM(&amp;quot;give a string instanciating this component!&amp;quot;) ),&lt;br /&gt;
            (::cppu::OWeakObject *)this, // resolve to XInterface reference&lt;br /&gt;
            0 ); // argument pos&lt;br /&gt;
    }&lt;br /&gt;
    if (! (args[ 0 ] &amp;gt;&amp;gt;= m_arg))&lt;br /&gt;
    {&lt;br /&gt;
        throw lang::IllegalArgumentException(&lt;br /&gt;
            OUString( RTL_CONSTASCII_USTRINGPARAM(&amp;quot;no string given as argument!&amp;quot;) ),&lt;br /&gt;
            (::cppu::OWeakObject *)this, // resolve to XInterface reference&lt;br /&gt;
            0 ); // argument pos&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// XServiceName&lt;br /&gt;
OUString SAL_CALL MyService2Impl::getServiceName() throw( uno::RuntimeException )&lt;br /&gt;
{&lt;br /&gt;
    // name of specific AddIn service&lt;br /&gt;
    return OUString::createFromAscii( &amp;quot;my_module.MyService2&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
// XSomething implementation&lt;br /&gt;
OUString MyService2Impl::methodOne( OUString const &amp;amp; str )&lt;br /&gt;
    throw (RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
    return OUString( RTL_CONSTASCII_USTRINGPARAM(&lt;br /&gt;
        &amp;quot;called methodOne() of MyService2 implementation: &amp;quot;) ) + m_arg + str;&lt;br /&gt;
}&lt;br /&gt;
// **********************ADDED &lt;br /&gt;
&lt;br /&gt;
OUString MyService2Impl::methodTwo( OUString const &amp;amp; str )&lt;br /&gt;
    throw (RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
    return OUString( RTL_CONSTASCII_USTRINGPARAM(&lt;br /&gt;
        &amp;quot;called methodTwo() of MyService2 implementation: &amp;quot;) ) + m_arg + str;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
sal_Int32 MyService2Impl::methodThree(const Sequence&amp;lt; Sequence&amp;lt; sal_Int32 &amp;gt; &amp;gt; &amp;amp;aValList )&lt;br /&gt;
    throw (RuntimeException)&lt;br /&gt;
{ 	sal_Int32		n1, n2;&lt;br /&gt;
	sal_Int32		nE1 = aValList.getLength();&lt;br /&gt;
	sal_Int32		nE2;&lt;br /&gt;
	sal_Int32 temp=0;&lt;br /&gt;
	for( n1 = 0 ; n1 &amp;lt; nE1 ; n1++ )&lt;br /&gt;
	{&lt;br /&gt;
		const Sequence&amp;lt; sal_Int32 &amp;gt;	rList = aValList[ n1 ];&lt;br /&gt;
		nE2 = rList.getLength();&lt;br /&gt;
		const sal_Int32*	pList = rList.getConstArray();&lt;br /&gt;
		for( n2 = 0 ; n2 &amp;lt; nE2 ; n2++ )&lt;br /&gt;
		{&lt;br /&gt;
			temp += pList[ n2 ];&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	return temp;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//It&amp;#039;s a matrix operation  should be called like : {=METHODFOUR(A1:B4)}&lt;br /&gt;
Sequence&amp;lt; Sequence&amp;lt; sal_Int32 &amp;gt; &amp;gt; MyService2Impl::methodFour(&lt;br /&gt;
		const Sequence&amp;lt; Sequence&amp;lt; sal_Int32 &amp;gt; &amp;gt; &amp;amp;aValList )throw (RuntimeException)&lt;br /&gt;
{ 	sal_Int32		n1, n2;&lt;br /&gt;
	sal_Int32		nE1 = aValList.getLength();&lt;br /&gt;
	sal_Int32		nE2;&lt;br /&gt;
	Sequence&amp;lt; Sequence&amp;lt; sal_Int32 &amp;gt; &amp;gt; temp = aValList;&lt;br /&gt;
	for( n1 = 0 ; n1 &amp;lt; nE1 ; n1++ )&lt;br /&gt;
	{&lt;br /&gt;
		Sequence&amp;lt; sal_Int32 &amp;gt;	rList = temp[ n1 ];&lt;br /&gt;
		nE2 = rList.getLength();&lt;br /&gt;
		for( n2 = 0 ; n2 &amp;lt; nE2 ; n2++ )&lt;br /&gt;
		{&lt;br /&gt;
			rList[ n2 ] += 4;&lt;br /&gt;
		}&lt;br /&gt;
		temp[n1]=rList;&lt;br /&gt;
	}&lt;br /&gt;
	return temp;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// ********************** END ADDED &lt;br /&gt;
&lt;br /&gt;
// XAddIn&lt;br /&gt;
&lt;br /&gt;
OUString SAL_CALL MyService2Impl::getProgrammaticFuntionName( const OUString&amp;amp; aDisplayName ) throw( uno::RuntimeException )&lt;br /&gt;
{&lt;br /&gt;
    //  not used by calc&lt;br /&gt;
    //  (but should be implemented for other uses of the AddIn service)&lt;br /&gt;
    return OUString();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
OUString SAL_CALL MyService2Impl::getDisplayFunctionName( const OUString&amp;amp; aProgrammaticName ) throw( uno::RuntimeException )&lt;br /&gt;
{&lt;br /&gt;
    OUString aProgName, aRet;&lt;br /&gt;
    aProgName = aProgrammaticName;&lt;br /&gt;
    if (aProgName.equalsAscii(&amp;quot;methodOne&amp;quot;)) aRet = OUString::createFromAscii(&amp;quot;method1&amp;quot;);&lt;br /&gt;
    if (aProgName.equalsAscii(&amp;quot;methodTwo&amp;quot;)) aRet = OUString::createFromAscii(&amp;quot;method2&amp;quot;);&lt;br /&gt;
    if (aProgName.equalsAscii(&amp;quot;methodThree&amp;quot;)) aRet = OUString::createFromAscii(&amp;quot;method3&amp;quot;);&lt;br /&gt;
    if (aProgName.equalsAscii(&amp;quot;methodFour&amp;quot;)) aRet = OUString::createFromAscii(&amp;quot;method4&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
    return aRet;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
OUString SAL_CALL MyService2Impl::getFunctionDescription( const OUString&amp;amp; aProgrammaticName ) throw( uno::RuntimeException )&lt;br /&gt;
{&lt;br /&gt;
    OUString aRet;&lt;br /&gt;
    if (aProgrammaticName.equalsAscii(&amp;quot;methodOne&amp;quot;)) &lt;br /&gt;
	aRet = OUString::createFromAscii(&amp;quot;methodOne() : 1st try&amp;quot;);&lt;br /&gt;
    if (aProgrammaticName.equalsAscii(&amp;quot;methodTwo&amp;quot;)) &lt;br /&gt;
	aRet = OUString::createFromAscii(&amp;quot;methodTwo() : 1st try&amp;quot;);&lt;br /&gt;
    if (aProgrammaticName.equalsAscii(&amp;quot;methodThree&amp;quot;)) &lt;br /&gt;
	aRet = OUString::createFromAscii(&amp;quot;methodThree() : 1st try&amp;quot;);&lt;br /&gt;
    return aRet;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
OUString SAL_CALL MyService2Impl::getDisplayArgumentName(&lt;br /&gt;
        const OUString&amp;amp; aProgrammaticName, sal_Int32 nArgument ) throw( uno::RuntimeException )&lt;br /&gt;
{   &lt;br /&gt;
    OUString aRet;&lt;br /&gt;
    if (aProgrammaticName.equalsAscii(&amp;quot;methodOne&amp;quot;)||aProgrammaticName.equalsAscii(&amp;quot;methodTwo&amp;quot;)) &lt;br /&gt;
	aRet = OUString::createFromAscii(&amp;quot;a string&amp;quot;);&lt;br /&gt;
    if (aProgrammaticName.equalsAscii(&amp;quot;methodThree&amp;quot;)||aProgrammaticName.equalsAscii(&amp;quot;methodFour&amp;quot;)) &lt;br /&gt;
	aRet = OUString::createFromAscii(&amp;quot;a Cell Range&amp;quot;);&lt;br /&gt;
    return aRet;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
OUString SAL_CALL MyService2Impl::getArgumentDescription(&lt;br /&gt;
        const OUString&amp;amp; aProgrammaticName, sal_Int32 nArgument ) throw( uno::RuntimeException )&lt;br /&gt;
{&lt;br /&gt;
    OUString aRet;&lt;br /&gt;
    if (aProgrammaticName.equalsAscii(&amp;quot;methodOne&amp;quot;)||aProgrammaticName.equalsAscii(&amp;quot;methodTwo&amp;quot;)) &lt;br /&gt;
	aRet = OUString::createFromAscii(&amp;quot;method1/2:a string or a cell with a string is required&amp;quot;);&lt;br /&gt;
    if (aProgrammaticName.equalsAscii(&amp;quot;methodThree&amp;quot;)||aProgrammaticName.equalsAscii(&amp;quot;methodFour&amp;quot;)) &lt;br /&gt;
	aRet = OUString::createFromAscii(&amp;quot;method3/4:a cell range is required&amp;quot;);&lt;br /&gt;
    return aRet;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
OUString SAL_CALL MyService2Impl::getProgrammaticCategoryName(&lt;br /&gt;
        const OUString&amp;amp; aProgrammaticName ) throw( uno::RuntimeException )&lt;br /&gt;
{&lt;br /&gt;
    OUString aRet( RTL_CONSTASCII_USTRINGPARAM(&amp;quot;Add-In&amp;quot;));&lt;br /&gt;
    return aRet;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
OUString SAL_CALL MyService2Impl::getDisplayCategoryName(&lt;br /&gt;
        const OUString&amp;amp; aProgrammaticName ) throw( uno::RuntimeException )&lt;br /&gt;
{&lt;br /&gt;
    return getProgrammaticCategoryName( aProgrammaticName );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// XServiceInfo implementation&lt;br /&gt;
OUString MyService2Impl::getImplementationName()&lt;br /&gt;
    throw (RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
    // unique implementation name&lt;br /&gt;
    return OUString( RTL_CONSTASCII_USTRINGPARAM(&amp;quot;my_module.my_sc_impl.MyService2&amp;quot;) );&lt;br /&gt;
}&lt;br /&gt;
sal_Bool MyService2Impl::supportsService( OUString const &amp;amp; serviceName )&lt;br /&gt;
    throw (RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
    // this object only supports one service, so the test is simple&lt;br /&gt;
    // modified *********&lt;br /&gt;
    return serviceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(&amp;quot;my_module.MyService2&amp;quot;) ) ||&lt;br /&gt;
           serviceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(&amp;quot;com.sun.star.sheet.AddIn&amp;quot;) );&lt;br /&gt;
}&lt;br /&gt;
Sequence&amp;lt; OUString &amp;gt; MyService2Impl::getSupportedServiceNames()&lt;br /&gt;
    throw (RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
	return getSupportedServiceNames_MyService2Impl();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Reference&amp;lt; XInterface &amp;gt; SAL_CALL create_MyService2Impl(&lt;br /&gt;
    Reference&amp;lt; XComponentContext &amp;gt; const &amp;amp; xContext )&lt;br /&gt;
    SAL_THROW( () )&lt;br /&gt;
{&lt;br /&gt;
    return static_cast&amp;lt; lang::XTypeProvider * &amp;gt;( new MyService2Impl() );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// XLocalizable&lt;br /&gt;
void SAL_CALL MyService2Impl::setLocale( const lang::Locale&amp;amp; eLocale ) throw( uno::RuntimeException )&lt;br /&gt;
{&lt;br /&gt;
//    aFuncLoc = eLocale;&lt;br /&gt;
//    InitData();     // change of locale invalidates resources!&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
lang::Locale SAL_CALL MyService2Impl::getLocale() throw( uno::RuntimeException )&lt;br /&gt;
{&lt;br /&gt;
//    return aFuncLoc;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* shared lib exports implemented without helpers in service_impl1.cxx */&lt;br /&gt;
namespace my_sc_impl&lt;br /&gt;
{&lt;br /&gt;
static struct ::cppu::ImplementationEntry s_component_entries [] =&lt;br /&gt;
{&lt;br /&gt;
    {&lt;br /&gt;
        create_MyService2Impl, getImplementationName_MyService2Impl,&lt;br /&gt;
        getSupportedServiceNames_MyService2Impl, ::cppu::createSingleComponentFactory,&lt;br /&gt;
        0, 0&lt;br /&gt;
    },&lt;br /&gt;
    { 0, 0, 0, 0, 0, 0 }&lt;br /&gt;
};&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
extern &amp;quot;C&amp;quot;&lt;br /&gt;
{&lt;br /&gt;
void SAL_CALL component_getImplementationEnvironment(&lt;br /&gt;
    sal_Char const ** ppEnvTypeName, uno_Environment ** ppEnv )&lt;br /&gt;
{&lt;br /&gt;
    *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;&lt;br /&gt;
}&lt;br /&gt;
sal_Bool SAL_CALL component_writeInfo(&lt;br /&gt;
    lang::XMultiServiceFactory * xMgr, registry::XRegistryKey * xRegistry )&lt;br /&gt;
{&lt;br /&gt;
    return ::cppu::component_writeInfoHelper(&lt;br /&gt;
        xMgr, xRegistry, ::my_sc_impl::s_component_entries );&lt;br /&gt;
}&lt;br /&gt;
void * SAL_CALL component_getFactory(&lt;br /&gt;
    sal_Char const * implName, lang::XMultiServiceFactory * xMgr,&lt;br /&gt;
    registry::XRegistryKey * xRegistry )&lt;br /&gt;
{&lt;br /&gt;
    return ::cppu::component_getFactoryHelper(&lt;br /&gt;
        implName, xMgr, xRegistry, ::my_sc_impl::s_component_entries );&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We have learnt now how things works and particularly how to manage sequence of sequence parameters or returned value.&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|This code is to set in &amp;lt;OpenOffice.org1.1_SDK&amp;gt;/examples/DevelopersGuide/Components/CppComponent path because there is no add-in exemple in the SDK. You have to slightly modify the corresponding makefile remove a source file to check this example.}}&lt;br /&gt;
&lt;br /&gt;
=Utilities=&lt;br /&gt;
In order to provide utilities to interface OOo to other external libraries, we will provide in this section any utilities to transform classical variables into UNO variables.&lt;br /&gt;
&lt;br /&gt;
==Transforming sequence of sequence into  array==&lt;br /&gt;
&lt;br /&gt;
If you plan to extend OOoCalc in any way, you will probably use an external library, for instance a C library like GSL. You will notice that the variables are in general arrays of double and not sequence. &lt;br /&gt;
Have a look to the case of Listing below where you see an imaginary method « foo ». The point is we use a sequence of sequence as parameter and we want to transform it into 2D array.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//C+&lt;br /&gt;
Sequence&amp;lt; Sequence&amp;lt; double &amp;gt; &amp;gt; MyService2Impl::foo(&lt;br /&gt;
		const Sequence&amp;lt; Sequence&amp;lt; double &amp;gt; &amp;gt; &amp;amp;aValList )throw (RuntimeException)&lt;br /&gt;
{ 		sal_Int32		nE1 = aValList.getLength();&lt;br /&gt;
	sal_Int32		nE2;&lt;br /&gt;
&lt;br /&gt;
	Sequence&amp;lt; double &amp;gt;	rList = aValList[ 0 ];&lt;br /&gt;
	nE2 = rList.getLength();&lt;br /&gt;
	double table[nE1][nE2];&lt;br /&gt;
	for( sal_Int32 n1 = 0 ; n1 &amp;lt; nE1; n1++ )&lt;br /&gt;
	{&lt;br /&gt;
		for (sal_Int32 n2=0;n2&amp;lt;nE2;n2++)&lt;br /&gt;
			table[n1][n2]=aValList[n1][n2];&lt;br /&gt;
	}&lt;br /&gt;
// we have a 2D array now&lt;br /&gt;
//!!!!!!!! This code is wrong : double table[nE1][nE2]; with nE1 and nE2 &lt;br /&gt;
//!!!!!!!! unknown at the compilation time. !!!!!!!!&lt;br /&gt;
// I have used this code with success but I don&amp;#039;t know why ? &lt;br /&gt;
// Perhaps the compiler use a constructor in this case ?&lt;br /&gt;
// I will have a look as sooner as possible&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
At the end of this program we have a 2D array named « table » and we show how to construct it. (I have tried a way using getArray() but without success).&lt;br /&gt;
&lt;br /&gt;
As mentioned in the comments, this code has a poor quality in my knowledge. At the moment, I provide other code [[SDKCppLanguage#More_Abstractions_with_STL|here]]&lt;br /&gt;
&lt;br /&gt;
==Transforming an Array into Sequence of Sequence==&lt;br /&gt;
&lt;br /&gt;
Imagine your calculus provides a 1D array named « z » and you want to construct a sequence of sequence before returning it. Here is what you could do :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//C+&lt;br /&gt;
...&lt;br /&gt;
// here a line is constructed with size (nE2-1)*2&lt;br /&gt;
	Sequence&amp;lt; double &amp;gt;	solList1D(z,(nE2-1)*2);&lt;br /&gt;
	Sequence&amp;lt; Sequence&amp;lt; double &amp;gt; &amp;gt; solList2D(1);&lt;br /&gt;
	solList2D[0]=solList1D;&lt;br /&gt;
	return solList2D;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A similar problem encountered later has to be solved differently : I start from an 1D array but this array contains, real part and imaginary part « The n-1 roots are returned in the packed complex array z of length 2(n-1), alternating real and imaginary parts » I want to show the result in Calc but with two rows (real part and imaginary part) with as many lines as necessary. Here is the way :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//C+&lt;br /&gt;
...&lt;br /&gt;
// two rows and nE2-1 lines starting from an array &amp;quot;z&amp;quot; with (nE2-1)*2 lements&lt;br /&gt;
	Sequence&amp;lt; double &amp;gt;	solList1D(2);&lt;br /&gt;
		Sequence&amp;lt; Sequence&amp;lt; double &amp;gt; &amp;gt; solList2D(nE2-1);&lt;br /&gt;
		for( int j=0;j&amp;lt;((nE2-1)&amp;lt;&amp;lt;1);j+=2){ // (nE2-1)&amp;lt;&amp;lt;1 is faster than (nE2-1)*2&lt;br /&gt;
			for( int i=0; i&amp;lt;2 ; i++){&lt;br /&gt;
				solList1D[i]=z[i+j];&lt;br /&gt;
			}&lt;br /&gt;
			solList2D[j&amp;gt;&amp;gt;1]=solList1D;//j &amp;gt;&amp;gt; 2 is faster than j/2&lt;br /&gt;
		}&lt;br /&gt;
		return solList2D;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sometimes we have to use Standard Template Library because the library we want to interface is in C++. Eric Ehlers has interfaced a C++ library (QuantLib project) and then provide any interesting code [http://www.quantlibaddin.org here]. See particularly the file calcutils.cpp. I have reproduct part of the code [[SDKCppLanguage#More_Abstractions_with_STL|here]] but with using template.&lt;br /&gt;
&lt;br /&gt;
=Interfacing the GSL (GNU Scientific Library)=&lt;br /&gt;
&lt;br /&gt;
Our goal is now to provide an example of intarfacing OOo with a scientific library. To give the possibility of accessing all the library is an enormous task that I cannot realize. I only want to show the way.&lt;br /&gt;
&lt;br /&gt;
==First step==&lt;br /&gt;
&lt;br /&gt;
The first step is to install the GSL. See the GSL documentation&lt;br /&gt;
&lt;br /&gt;
==Second step==&lt;br /&gt;
&lt;br /&gt;
Find what gsl function do you want to wrapp and write the corresponding IDL file. For this example I am interested in finding the complex roots of a polynom. The corresponding function is « gsl_poly_complex_solve ».&lt;br /&gt;
&lt;br /&gt;
The corresponding IDL file is (keeping all the old methods of the previous sections) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 14.14 My SDL interfacing Add-In : the IDL File&lt;br /&gt;
// IDL&lt;br /&gt;
module my_module&lt;br /&gt;
{&lt;br /&gt;
interface XSomething : com::sun::star::uno::XInterface&lt;br /&gt;
{&lt;br /&gt;
  string methodOne( [in] string val );&lt;br /&gt;
  string methodTwo( [in] string val );&lt;br /&gt;
  long methodThree( [in] sequence&amp;lt; sequence&amp;lt; long &amp;gt; &amp;gt; aValList );&lt;br /&gt;
  sequence&amp;lt; sequence&amp;lt; long &amp;gt; &amp;gt; methodFour( [in] sequence&amp;lt; sequence&amp;lt; long &amp;gt; &amp;gt; aValList );&lt;br /&gt;
  sequence&amp;lt; sequence&amp;lt; double &amp;gt; &amp;gt; poly_complex_solve([in] sequence&amp;lt; sequence&amp;lt; double &amp;gt; &amp;gt; aValList );&lt;br /&gt;
};&lt;br /&gt;
service MyService2&lt;br /&gt;
{&lt;br /&gt;
  interface XSomething;&lt;br /&gt;
  interface com::sun::star::lang::XInitialization;&lt;br /&gt;
  interface com::sun::star::lang::XServiceName;&lt;br /&gt;
  interface com::sun::star::sheet::XAddIn;&lt;br /&gt;
};&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The name of the new method will be « poly_complex_solve »&lt;br /&gt;
&lt;br /&gt;
==Third Step==&lt;br /&gt;
&lt;br /&gt;
You have to modify the makefile to link your addin with the GSL libraries :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Listing 14.15 New MakeFile&lt;br /&gt;
....&lt;br /&gt;
ifeq &amp;quot;$(OS)&amp;quot; &amp;quot;WIN&amp;quot;&lt;br /&gt;
$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) $(OUT_COMP_GEN)/%.def&lt;br /&gt;
-$(MKDIR) $(subst /,$(PS),$(@D))&lt;br /&gt;
$(LINK) $(LIBRARY_LINK_FLAGS) /OUT:$@ /MAP:$(OUT_COMP_GEN)/$(subst $(SHAREDLIB_EXT),map,$(@F)) \&lt;br /&gt;
/DEF:$(OUT_COMP_GEN)/$(subst $(SHAREDLIB_EXT),def,$(@F)) $(SLOFILES) \&lt;br /&gt;
$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) msvcrt.lib kernel32.lib&lt;br /&gt;
else&lt;br /&gt;
$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)&lt;br /&gt;
-$(MKDIR) $(subst /,$(PS),$(@D))&lt;br /&gt;
$(LINK) $(LIBRARY_LINK_FLAGS) $(LINK_LIBS) -o $@ $^\&lt;br /&gt;
$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) -lgsl -lgslcblas -lm&lt;br /&gt;
# $(CPPUHELPERLIB)&lt;br /&gt;
endif&lt;br /&gt;
....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Step Four==&lt;br /&gt;
&lt;br /&gt;
Write the code and compile. The code given below only works when the polynomial coefficients are given in a line. In all the other cases it returns the same values as given in entry.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 14.16 New Code&lt;br /&gt;
// C++&lt;br /&gt;
....&lt;br /&gt;
#include &amp;lt;gsl/gsl_poly.h&amp;gt;&lt;br /&gt;
....&lt;br /&gt;
Sequence&amp;lt; Sequence&amp;lt; double &amp;gt; &amp;gt; MyService2Impl::poly_complex_solve(&lt;br /&gt;
const Sequence&amp;lt; Sequence&amp;lt; double &amp;gt; &amp;gt; &amp;amp;aValList )throw (RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
  sal_Int32 nE1 = aValList.getLength();&lt;br /&gt;
  sal_Int32 nE2;&lt;br /&gt;
  Sequence&amp;lt; double &amp;gt; rList = aValList[ 0 ];&lt;br /&gt;
  nE2 = rList.getLength();&lt;br /&gt;
  double table[nE1][nE2];&lt;br /&gt;
  for( sal_Int32 n1 = 0 ; n1 &amp;lt; nE1; n1++ )&lt;br /&gt;
  {&lt;br /&gt;
   for (sal_Int32 n2=0;n2&amp;lt;nE2;n2++)&lt;br /&gt;
     table[n1][n2]=aValList[n1][n2];&lt;br /&gt;
  }&lt;br /&gt;
// I have a 2D nE1xnE2 table here&lt;br /&gt;
  if (nE1==1){ // real coefficients horizontally disposed&lt;br /&gt;
    double z[(nE2-1)*2];&lt;br /&gt;
    gsl_poly_complex_workspace * w = gsl_poly_complex_workspace_alloc(nE2);&lt;br /&gt;
    gsl_poly_complex_solve(table[0],nE2,w,z);&lt;br /&gt;
    gsl_poly_complex_workspace_free(w);&lt;br /&gt;
    Sequence&amp;lt; double &amp;gt; solList1D(2);&lt;br /&gt;
    Sequence&amp;lt; Sequence&amp;lt; double &amp;gt; &amp;gt; solList2D(nE2-1);&lt;br /&gt;
    for( int j=0;j&amp;lt;((nE2-1)&amp;lt;&amp;lt;1);j+=2){&lt;br /&gt;
      for( int i=0; i&amp;lt;2 ; i++){&lt;br /&gt;
         solList1D[i]=z[i+j]; &lt;br /&gt;
      }&lt;br /&gt;
      solList2D[j&amp;gt;&amp;gt;1]=solList1D;&lt;br /&gt;
    }&lt;br /&gt;
    return solList2D;&lt;br /&gt;
  } else&lt;br /&gt;
  if (nE2==1){ // real coefficients vertically disposed : doesn&amp;#039;t work at the moment&lt;br /&gt;
    Sequence&amp;lt; Sequence&amp;lt; double &amp;gt; &amp;gt; temp = aValList; // return the coefficients&lt;br /&gt;
   return temp;&lt;br /&gt;
  } else {&lt;br /&gt;
// If here : error&lt;br /&gt;
    Sequence&amp;lt; Sequence&amp;lt; double &amp;gt; &amp;gt; temp = aValList; // return the coefficients&lt;br /&gt;
    return temp;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here is the result :&lt;br /&gt;
; Résults &lt;br /&gt;
{| border cellspacing=&amp;quot;0&amp;quot; width=&amp;quot;550&amp;quot;&lt;br /&gt;
|- style = &amp;quot;background:#b3e2d1;text-align:center&amp;quot;&lt;br /&gt;
| |x°||x¹||x²||x³||x^4||x^5&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
| -1||0||0||0||0||1&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
| || || ||  || ||&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
| ||-0.81||0.59 || || ||&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
| ||-0.81||-0.59|| || ||&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
| ||0.31||0.95|| || || &lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
| ||0.31||-0.95|| || ||&lt;br /&gt;
|- style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
| ||1||0|| || ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where you see horizontally the polynomial coefficients and vertically the five roots with real part (left) and imaginary part (right).&lt;br /&gt;
=Notes=&lt;br /&gt;
{{Documentation/Caution|If you are installing an external addin under linux and encounter a problem verify the dynamic library dependance with ldd command : &amp;lt;code&amp;gt;ldd your_addin.so&amp;lt;/code&amp;gt; to see if a dynamic library fails.}}&lt;br /&gt;
{{Documentation/Note|Instead of going further with interfacing the GSL, bear in mind there is an advanced project of interfacing the giac library (giac is a Computer Algebra System used in [http://www-fourier.ujf-grenoble.fr/~parisse/giac/doc/en/casref_en/casref_en.html XCas]) which is already working. Here is the [http://cdeval.free.fr/spip.php?article132 French Documentation] of the corresponding addin. You can download [http://cdeval.free.fr/CmathOOoUpdate/CmathOOoCAS.oxt the version 1.0] for Linux or M$ Windows (same file for both version).}}&lt;br /&gt;
&lt;br /&gt;
=Home Page=&lt;br /&gt;
[[Image:HomePageCpp.png]] [[Using_Cpp_with_the_OOo_SDK|Return to Document Home page]]&lt;br /&gt;
&lt;br /&gt;
=See also=&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;This article is under construction&amp;#039;&amp;#039;&amp;#039; and if you want to go further, for the moment have a look to the following references :&lt;br /&gt;
* [[Uno/Cpp/Tutorials/Introduction_to_Cpp_Uno|C++ and UNO tutorial]]&lt;br /&gt;
*[[Tutorial_UNO_Library|UNO tutorial]]&lt;br /&gt;
*[[Tutorial_UNO_IDL|UNO IDL]]&lt;br /&gt;
* [[Uno/Article/Types%26Reflection]]&lt;br /&gt;
* [[Extensions_Packager|Extensions Packager]] (BasicAddonBuilder from [mailto:paolomantovani@openoffice.org Paolo Mantovani])&lt;br /&gt;
* [[Calc/Add-In/Project_Type|Java Calc Add-in]]&lt;br /&gt;
* [[API/Samples/Java/CalcAddin|An other Java Calc Add-in example]]&lt;br /&gt;
* [http://www.oooforum.org/forum/viewtopic.phtml?t=29552 Add-In in C++]&lt;br /&gt;
* [http://sc.openoffice.org/addin_howto.html How to add-in in OpenOffice.org Calc]&lt;br /&gt;
* [http://api.openoffice.org/docs/common/ref/com/sun/star/sheet/AddIn.html Service AddIn Documentation]&lt;br /&gt;
* [http://perso.wanadoo.fr/moutou/MyUNODoc_HTML/UNOCppAPI13.html Constructing Components]&lt;br /&gt;
* Writing a Program to Control OpenOffice.org, by Franco Pingiori — [http://www.linuxjournal.com/article/8550 Part 1] and [http://www.linuxjournal.com/article/8608 Part 2], Linux Journal&lt;br /&gt;
* [[SDKInstallation | How to install the SDK and compile the C++ examples]]&lt;br /&gt;
* [[SDKCppLanguage | The UNO C++ Language]]&lt;br /&gt;
* QuantLibAddin exports the functionality of the QuantLib analytics library as Addins on a variety of platforms including OpenOffice.org Calc and can be found here : http://quantlib.org/quantlibaddin/&lt;br /&gt;
&lt;br /&gt;
[[Category:Calc|Add-Ins 10 Complete]]&lt;br /&gt;
[[Category:API|Calc]]&lt;br /&gt;
[[Category:Add-In|Calc]]&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Cpp]]&lt;br /&gt;
[[Category:Uno]]&lt;br /&gt;
[[Category:Tutorial]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Database/Scrollable_Result_Sets&amp;diff=156329</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=156329"/>
		<updated>2010-02-05T03:33:19Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &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;
{{Documentation/DevGuideLanguages|Documentation/DevGuide/Database/{{SUBPAGENAME}}}} &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()) {&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;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Database Access]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/Using_the_Desktop&amp;diff=156325</id>
		<title>Documentation/DevGuide/OfficeDev/Using the Desktop</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/OfficeDev/Using_the_Desktop&amp;diff=156325"/>
		<updated>2010-02-05T03:23:48Z</updated>

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

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/DrawingsTOC&lt;br /&gt;
|Drawing2c=block&lt;br /&gt;
|DrawingShapes=block&lt;br /&gt;
|DrawingOp=block&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Drawings/Rotating and Shearing&lt;br /&gt;
|NextPage=Documentation/DevGuide/Drawings/Ordering&lt;br /&gt;
}}&lt;br /&gt;
{{Documentation/DevGuideLanguages|Documentation/DevGuide/Drawings/{{SUBPAGENAME}}}} &lt;br /&gt;
 {{DISPLAYTITLE:Transforming}}&lt;br /&gt;
Changing the size, rotation and shearing of an object can be done by using the transformation mechanism provided by {{PRODUCTNAME}}. The matrix of our API is a standard homogenous 3x3 matrix that may be used together with the java.awt.geom.AffineTransform class from Java. The transformation received describes the actual values of the transformations as a linear combination of the single matrices. The basic object without transformation has a size of (1, 1) and a position of (0, 0), and is not rotated or sheared. Thus, to transform an object get its matrix and multiply from the left side to influence the current appearance. To set the whole transformation directly, build a combined matrix of the single values mentioned above and apply it to the object. &lt;br /&gt;
&amp;lt;!--[SOURCE:Drawing/ObjectTransformationDemo.java]--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  XPropertySet xPropSet = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, xShape );&lt;br /&gt;
  // take the current tranformation matrix&lt;br /&gt;
  HomogenMatrix3 aHomogenMatrix3 = (HomogenMatrix3)xPropSet.getPropertyValue(&amp;quot;Transformation&amp;quot;);&lt;br /&gt;
  java.awt.geom.AffineTransform aOriginalMatrix = new java.awt.geom.AffineTransform(aHomogenMatrix3.Line1.Column1, aHomogenMatrix3.Line2.Column1,&lt;br /&gt;
      aHomogenMatrix3.Line1.Column2, aHomogenMatrix3.Line2.Column2,&lt;br /&gt;
      aHomogenMatrix3.Line1.Column3, aHomogenMatrix3.Line2.Column3 );&lt;br /&gt;
  // rotate the object by 15 degrees&lt;br /&gt;
  AffineTransform aNewMatrix1 = new AffineTransform();&lt;br /&gt;
  aNewMatrix1.setToRotation(Math.toRadians(15));&lt;br /&gt;
  aNewMatrix1.concatenate(aOriginalMatrix);&lt;br /&gt;
  // and translate the object by 2cm on the x-axis&lt;br /&gt;
  AffineTransform aNewMatrix2 = new AffineTransform();&lt;br /&gt;
  aNewMatrix2.setToTranslation(2000, 0);&lt;br /&gt;
  aNewMatrix2.concatenate(aNewMatrix1);&lt;br /&gt;
  double aFlatMatrix[] = new double[6];aNewMatrix2.getMatrix(aFlatMatrix);&lt;br /&gt;
  // convert the flatMatrix to our HomogenMatrix3 structure&lt;br /&gt;
  aHomogenMatrix3.Line1.Column1 = aFlatMatrix[0];&lt;br /&gt;
  aHomogenMatrix3.Line2.Column1 = aFlatMatrix[1];&lt;br /&gt;
  aHomogenMatrix3.Line1.Column2 = aFlatMatrix[2];&lt;br /&gt;
  aHomogenMatrix3.Line2.Column2 = aFlatMatrix[3];&lt;br /&gt;
  aHomogenMatrix3.Line1.Column3 = aFlatMatrix[4];&lt;br /&gt;
  aHomogenMatrix3.Line2.Column3 = aFlatMatrix[5];&lt;br /&gt;
  xPropSet.setPropertyValue(&amp;quot;Transformation&amp;quot;, aHomogenMatrix3);&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Drawing Documents and Presentation Documents]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Charts/3-D_Charts&amp;diff=155880</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=155880"/>
		<updated>2010-01-29T06:00:29Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &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;
{{Documentation/DevGuideLanguages|Documentation/DevGuide/Charts/{{SUBPAGENAME}}}} &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 = Math.cos(Math.toRadians(fAngle));&lt;br /&gt;
  double fSinX = Math.sin(Math.toRadians(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 = Math.cos(Math.toRadians(fAngle));&lt;br /&gt;
  double fSinY = Math.sin(Math.toRadians(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 = Math.cos(Math.toRadians(fAngle));&lt;br /&gt;
  double fSinZ = Math.sin(Math.toRadians(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>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=BuildSpeedup&amp;diff=155706</id>
		<title>BuildSpeedup</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=BuildSpeedup&amp;diff=155706"/>
		<updated>2010-01-26T01:18:55Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Make the OO.o build system the coolest on the planet! OpenOffice.org is one of the largest and most interesting open source projects that exists. The target of the BuildSpeedup project is to make the build system the coolest one around. A reliable and fast build system has several direct and indirect impacts, maybe most importantly it is the first thing a new contributor comes across when they pick up the project. Main main target audience is an contributor running a high-mid level desktop. Secondary target is people running build farms (notably Sun). Specification for Jam build prototype [[SpecJamBuild]].&lt;br /&gt;
&lt;br /&gt;
* Simple test harness to figure out the speed of different build tools: [http://wiki.services.openoffice.org/mwiki/images/1/11/Buildtest.tgz Buildtest.tgz]&lt;br /&gt;
* Paper on prototype for setting up and building OO.o on large compilation cluster: [http://wiki.services.openoffice.org/wiki/Image:Build_j50.tgz Build_j50.tgz]&lt;br /&gt;
&lt;br /&gt;
== How to report build profile logs ==&lt;br /&gt;
&lt;br /&gt;
Thank you for sending in a build profile log. The more logs we have, the easier it is to focus our effort correctly. Here are the steps to producing a build log:&lt;br /&gt;
&lt;br /&gt;
# Apply the latest patch from {{Bug|60948}} to your source tree&lt;br /&gt;
# in the dmake directory type &amp;quot;make clean; make&amp;quot;. In the root directory type &amp;quot;./bootstrap&amp;quot;&lt;br /&gt;
# When building redirect stderr and stdout to the logfile. In tcsh &amp;quot;build --all |&amp;amp; tee myconfigdesc_build.log&amp;quot; will do the trick. You can alternatively use cat instead of tee to speed up the build slightly. You need to build in a single go and in a single process (no parallel building)&lt;br /&gt;
# Check that the log contains markers like &amp;quot;s target 1234 foo.obj&amp;quot;. If not, then report&lt;br /&gt;
# Compress the log with zip/gz&lt;br /&gt;
# When you send in your log URL to mailto:kaib@openoffice.org please provide a short description of the build type:&lt;br /&gt;
#* Important configure options (like --with-lang=?)&lt;br /&gt;
#* OS/compiler/generic hardware description&lt;br /&gt;
#* No-change, partial or full build (we are especially looking for full builds)&lt;br /&gt;
#* External accelerators like [[wikipedia:ccache|ccache]]&lt;br /&gt;
&lt;br /&gt;
Thank you again for contributing! --[[User:KaiB|KaiB]] 16:25, 25 January 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
== Profile results ==&lt;br /&gt;
&lt;br /&gt;
Here are some initial profile results. These were done on a HP development desktop with 4GB of RAM. Due to various reasons there is a margin of error in all results, but the largest culprits are pretty clear.&lt;br /&gt;
&lt;br /&gt;
=== Full rebuild from scratch ===&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;5&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Time spent&lt;br /&gt;
! Target type (file extension)&lt;br /&gt;
|- &lt;br /&gt;
| 33.2%&lt;br /&gt;
| C/C++ compilation (obj)&lt;br /&gt;
|- &lt;br /&gt;
| 27%&lt;br /&gt;
| dmake/build.pl (time not attributed to any target)&lt;br /&gt;
|-&lt;br /&gt;
| 22.0%&lt;br /&gt;
| Dependency generation (dpcc)&lt;br /&gt;
|-&lt;br /&gt;
| 3.7%&lt;br /&gt;
| SDK installer (sdkoo_en-US)&lt;br /&gt;
|-&lt;br /&gt;
| 1.3%&lt;br /&gt;
| Unknown, build related (last_target)&lt;br /&gt;
|-&lt;br /&gt;
| 1.2%&lt;br /&gt;
| Linking (dll)&lt;br /&gt;
|-&lt;br /&gt;
| 1.1%&lt;br /&gt;
| OpenOffice.org installer (openoffice_en-US)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running time: 62296 s targets: 45927 s 73%&lt;br /&gt;
&lt;br /&gt;
As a benchmark, a Mozilla Firefox build corrected for differences in source code size takes about 25% of the OO.o build time.&lt;br /&gt;
&lt;br /&gt;
=== Nothing changed rebuild ===&lt;br /&gt;
&lt;br /&gt;
Basically profiling the build in a non-changed source tree.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;5&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Time spent&lt;br /&gt;
! Target type (file extension)&lt;br /&gt;
|- &lt;br /&gt;
| 54.8%&lt;br /&gt;
| SDK installer (sdkoo_en-US)&lt;br /&gt;
|-&lt;br /&gt;
| 19%&lt;br /&gt;
| dmake/build.pl (time not attributed to any target)&lt;br /&gt;
|-&lt;br /&gt;
| 16.2%&lt;br /&gt;
| OpenOffice installer (openoffice_en-US)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running time: 4209 s targets: 3431 s 81%&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
This is a workarea for ideas and notes regarding the speeding up of the build process. --[[User:KaiB|KaiB]] 12:50, 16 January 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* Newest dmake version: cws_src680_dmake43p01)&lt;br /&gt;
* solenv/inc define global targets&lt;br /&gt;
* potential modules: KaiB: transex3, tools, svx, binfilter - small to huge :)&lt;br /&gt;
* helpcontent2 --with-lang=ALL (there are open issues on this already)&lt;br /&gt;
* batched compiles&lt;br /&gt;
* Interix instead of cygwin&lt;br /&gt;
* dependency generation&lt;br /&gt;
&lt;br /&gt;
Existing possibly useful Build Speed related tweaks:&lt;br /&gt;
* export nodep=true&lt;br /&gt;
* export NO_HIDS=true&lt;br /&gt;
* build.pl -P parallel flag&lt;br /&gt;
* dmake -P parallel flag and/or MAXPROCESS (cws_src680_dmake43p01 has fixes for some problems there)&lt;br /&gt;
* dmake -s flag for less verbose output&lt;br /&gt;
* for gcj users targetedaot workspace to ahead of time compile (only) HelpLinker and FCFGMerge java build tools&lt;br /&gt;
&lt;br /&gt;
=== transex3 ===&lt;br /&gt;
&lt;br /&gt;
Started by tackling this small module. Initial full compile time was 137 sec.&lt;br /&gt;
&lt;br /&gt;
== build_profile_analyzer.py ==&lt;br /&gt;
&lt;br /&gt;
(NB. Move this to an attachment once the Wiki accepts .py files)&lt;br /&gt;
&lt;br /&gt;
 # Copyright 2006 Google Inc.&lt;br /&gt;
 #&lt;br /&gt;
 # Licensed under the Apache License, Version 2.0 (the &amp;quot;License&amp;quot;);&lt;br /&gt;
 # you may not use this file except in compliance with the License.&lt;br /&gt;
 # You may obtain a copy of the License at&lt;br /&gt;
 #&lt;br /&gt;
 #     http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 #&lt;br /&gt;
 # Unless required by applicable law or agreed to in writing, software&lt;br /&gt;
 # distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS,&lt;br /&gt;
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;br /&gt;
 # See the License for the specific language governing permissions and&lt;br /&gt;
 # limitations under the License.&lt;br /&gt;
 &lt;br /&gt;
 # OO.o build profile analyzer. To get the required patches look at:&lt;br /&gt;
 # http://wiki.services.openoffice.org/wiki/BuildSpeedup&lt;br /&gt;
 # Author: Kai Backman, kaib@google.com&lt;br /&gt;
 &lt;br /&gt;
 import os&lt;br /&gt;
 import re&lt;br /&gt;
 import sys&lt;br /&gt;
 &lt;br /&gt;
 def SortProfileTimes(lhs, rhs):&lt;br /&gt;
   if lhs[1] &amp;lt; rhs[1] : return 1&lt;br /&gt;
   elif rhs[1] &amp;lt; lhs[1] : return -1&lt;br /&gt;
   else : return 0&lt;br /&gt;
 &lt;br /&gt;
 def ProcessLogFile(file_name, target_durations):&lt;br /&gt;
 #  print &amp;quot;Processing file: &amp;quot; + file_name&lt;br /&gt;
   file = open(file_name)&lt;br /&gt;
   start_time = 0&lt;br /&gt;
   end_time = 0&lt;br /&gt;
 &lt;br /&gt;
   target_start = 0&lt;br /&gt;
   target_name = &amp;quot;&amp;quot;&lt;br /&gt;
   line = file.readline()&lt;br /&gt;
   while line != &amp;quot;&amp;quot; :&lt;br /&gt;
     tokens = line[:-1].split(&amp;quot; &amp;quot;)&lt;br /&gt;
     line = file.readline()&lt;br /&gt;
 &lt;br /&gt;
     if len(tokens) &amp;lt; 2 : continue&lt;br /&gt;
     if tokens[1] == &amp;quot;build&amp;quot; :&lt;br /&gt;
       if tokens[0] == &amp;quot;s&amp;quot; :&lt;br /&gt;
         start_time = int(tokens[2]) * 1000&lt;br /&gt;
       elif tokens[0] == &amp;quot;e&amp;quot; :&lt;br /&gt;
         end_time = int(tokens[2]) * 1000&lt;br /&gt;
     elif tokens[1] == &amp;quot;target&amp;quot; :&lt;br /&gt;
       if tokens[0] == &amp;quot;s&amp;quot;:&lt;br /&gt;
         target_start = int(tokens[2])&lt;br /&gt;
         target_name = tokens[3]&lt;br /&gt;
       elif tokens[0] == &amp;quot;e&amp;quot; and target_name == tokens[3]:&lt;br /&gt;
         target_duration = int(tokens[2]) - target_start&lt;br /&gt;
         target_tokens = tokens[3].split(&amp;quot;.&amp;quot;)&lt;br /&gt;
         target_class = target_tokens[-1]&lt;br /&gt;
         if target_class in target_durations :&lt;br /&gt;
           target_durations[target_class] += target_duration&lt;br /&gt;
         else :&lt;br /&gt;
           target_durations[target_class] = target_duration&lt;br /&gt;
   file.close()&lt;br /&gt;
   return end_time - start_time&lt;br /&gt;
   return &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
   target_durations = {}&lt;br /&gt;
   total_time = 0&lt;br /&gt;
   for file_name in sys.argv[1:] :&lt;br /&gt;
     total_time += ProcessLogFile(file_name, target_durations)&lt;br /&gt;
 &lt;br /&gt;
   profile = target_durations.items()&lt;br /&gt;
   profile.sort(SortProfileTimes)&lt;br /&gt;
   total_target_time = 0&lt;br /&gt;
   for target_iter in profile :&lt;br /&gt;
     target_promille = target_iter[1] * 1000 / total_time&lt;br /&gt;
     if target_promille &amp;gt; 0 :&lt;br /&gt;
       print &amp;quot;%6.ds %3.d.%1.d%% %s&amp;quot; % (target_iter[1] / 1000, target_promille/10,&lt;br /&gt;
                                       target_promille % 10, target_iter[0])&lt;br /&gt;
     total_target_time += target_iter[1]&lt;br /&gt;
   print &amp;quot;Running time: %d s targets: %d s %d%%&amp;quot; % (total_time / 1000, total_target_time / 1000,&lt;br /&gt;
                                                    total_target_time * 100 / total_time)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Build_System]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=OpenOffice_Add-On_Project_Type&amp;diff=155569</id>
		<title>OpenOffice Add-On Project Type</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=OpenOffice_Add-On_Project_Type&amp;diff=155569"/>
		<updated>2010-01-24T12:23:37Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[OpenOffice_NetBeans_Integration|OpenOffice.org NetBeans Integration]]&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The Add-On wizard will enable users to create an OpenOffice.org component that including support of UI extensions. The component is based on a on a J2SE class library project and supports additional targets to create and deploy the package into the office installation.&lt;br /&gt;
All interface methods are default implemented and do nothing. In a second step you can insert your implementation in the generated skeleton, rebuild the extension and deploy it again to see the effect in your office.&lt;br /&gt;
&lt;br /&gt;
= Project Wizard =&lt;br /&gt;
The project wizard  is quite simple to use, you simply choose&lt;br /&gt;
*&amp;#039;&amp;#039; &amp;#039;&amp;#039;&amp;#039;File -&amp;gt; New Project -&amp;gt; OpenOffice.org -&amp;gt; OpenOffice.org Add-On&amp;#039;&amp;#039;&amp;#039; &amp;#039;&amp;#039;&lt;br /&gt;
and follow the wizard.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Step 1&amp;#039;&amp;#039;&amp;#039;: Select the project type&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[Image:AddOn1.png|center]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Step 2&amp;#039;&amp;#039;&amp;#039;: Define the project name, Add-On name, an optional package and the project location&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[Image:AddOn2.png|center]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;The necessary xcu files are generated and become part of the final &amp;#039;&amp;#039;&amp;#039;oxt&amp;#039;&amp;#039;&amp;#039; package. These xcu files can be easily adapted later to extend the initial project to a more complex Add-On example. The generated Add-On skeleton implements a simple [http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/Protocol_Handler com.sun.star.frame.ProtocolHandler] Add-On.&amp;lt;br&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Step 3&amp;#039;&amp;#039;&amp;#039;: Defining the new commands, including icons.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[Image:AddOn3-1.png|center]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Step 4&amp;#039;&amp;#039;&amp;#039;: Defining the top level menu&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[Image:AddOn3.png|center]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;On this panel you can define the top level menus with sub-menus on a higher abstraction level. You will not have to deal with xcu files directly. You can modify the default menu, add new menus and commands, and you can define the context in which the command should appear. When you have deployed the package, the newly defined menus are visible in the specified context. For example, if you choose the context &amp;#039;&amp;#039;&amp;#039;Writer&amp;#039;&amp;#039;&amp;#039;, the menu is visible when you open or create a text document. Not selecting a context means all contexts, even the back-end window. For more detailed descriptions of the different fields simply press the help button or read the appropriate chapter in the [http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/Protocol_Handler Protocol Handler]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[Image:AddOn4.png|center]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Step 5&amp;#039;&amp;#039;&amp;#039;: Definig the toolbar is similar to the menu. There is no top level toolbar, of course.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[Image:AddOn5.png|center]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Step 6&amp;#039;&amp;#039;&amp;#039;: Deploying the extension package&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[Image:Calc_AddIn4.png|center]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;You can simply create or deploy the &amp;#039;&amp;#039;&amp;#039;oxt&amp;#039;&amp;#039;&amp;#039; extension package by choosing:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;&amp;#039;Project View -&amp;gt; Project Node -&amp;gt; Context Menu -&amp;gt; Deploy and Run Extension in OpenOffice.org&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The AddOn deployed in OpenOffice.org is visible in the back-end window.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[Image:AddOn6.png|center]]&lt;br /&gt;
&lt;br /&gt;
= Generated Code =&lt;br /&gt;
Two (.xcu) files for the Add-On are created that describe the Add-On commands with descriptions, displaynames etc., (Addons.xcu) and the protocol that is used to access these commands (ProtocolHandler.xcu). For the example shown above, the following files are generated:&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Addons.xcu&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt;xcu file defining the new menus with submenus and commands. This file can be easily extended to support toolbars as well (toolbar support will be added later to the wizard).&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;
&lt;br /&gt;
&amp;lt;oor:component-data xmlns:oor=&amp;quot;http://openoffice.org/2001/registry&amp;quot; xmlns:xs=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; oor:name=&amp;quot;Addons&amp;quot; oor:package=&amp;quot;org.openoffice.Office&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;node oor:name=&amp;quot;AddonUI&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;node oor:name=&amp;quot;OfficeMenuBar&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;node oor:name=&amp;quot;org.openoffice.testaddon.testaddon&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;prop oor:name=&amp;quot;Title&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;value/&amp;gt;&lt;br /&gt;
          &amp;lt;value xml:lang=&amp;quot;en&amp;quot;&amp;gt;My Menu&amp;lt;/value&amp;gt;&lt;br /&gt;
        &amp;lt;/prop&amp;gt;&lt;br /&gt;
        &amp;lt;prop oor:name=&amp;quot;Target&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;value&amp;gt;_self&amp;lt;/value&amp;gt;&lt;br /&gt;
        &amp;lt;/prop&amp;gt;&lt;br /&gt;
        &amp;lt;prop oor:name=&amp;quot;ImageIdentifier&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;value/&amp;gt;&lt;br /&gt;
        &amp;lt;/prop&amp;gt;&lt;br /&gt;
        &amp;lt;node oor:name=&amp;quot;Submenu&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;URL&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;value&amp;gt;org.openoffice.testaddon.testaddon:HelloWorld&amp;lt;/value&amp;gt;&lt;br /&gt;
            &amp;lt;/prop&amp;gt;&lt;br /&gt;
            &amp;lt;prop oor:name=&amp;quot;ImageIdentifier&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;value/&amp;gt;&lt;br /&gt;
            &amp;lt;/prop&amp;gt;&lt;br /&gt;
            &amp;lt;prop oor:name=&amp;quot;Target&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;value&amp;gt;_self&amp;lt;/value&amp;gt;&lt;br /&gt;
            &amp;lt;/prop&amp;gt;&lt;br /&gt;
            &amp;lt;prop oor:name=&amp;quot;Context&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;value/&amp;gt;&lt;br /&gt;
            &amp;lt;/prop&amp;gt;&lt;br /&gt;
            &amp;lt;prop oor:name=&amp;quot;Title&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;value/&amp;gt;&lt;br /&gt;
              &amp;lt;value xml:lang=&amp;quot;en&amp;quot;&amp;gt;Hello World&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;/node&amp;gt;&lt;br /&gt;
    &amp;lt;node oor:name=&amp;quot;OfficeToolBar&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;node oor:name=&amp;quot;org.openoffice.testaddon.testaddon&amp;quot; oor:op=&amp;quot;replace&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;URL&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;value&amp;gt;org.openoffice.testaddon.testaddon:HelloWorld&amp;lt;/value&amp;gt;&lt;br /&gt;
        &amp;lt;/prop&amp;gt;&lt;br /&gt;
        &amp;lt;prop oor:name=&amp;quot;ImageIdentifier&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;value/&amp;gt;&lt;br /&gt;
        &amp;lt;/prop&amp;gt;&lt;br /&gt;
        &amp;lt;prop oor:name=&amp;quot;Target&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;value&amp;gt;_self&amp;lt;/value&amp;gt;&lt;br /&gt;
        &amp;lt;/prop&amp;gt;&lt;br /&gt;
        &amp;lt;prop oor:name=&amp;quot;Context&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;value/&amp;gt;&lt;br /&gt;
        &amp;lt;/prop&amp;gt;&lt;br /&gt;
        &amp;lt;prop oor:name=&amp;quot;Title&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;value/&amp;gt;&lt;br /&gt;
          &amp;lt;value xml:lang=&amp;quot;en&amp;quot;&amp;gt;Hello World&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;node oor:name=&amp;quot;Images&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;node oor:name=&amp;quot;org.openoffice.testaddon.testaddon.helloworld.images&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;prop oor:name=&amp;quot;URL&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;value&amp;gt;org.openoffice.testaddon.testaddon:HelloWorld&amp;lt;/value&amp;gt;&lt;br /&gt;
        &amp;lt;/prop&amp;gt;&lt;br /&gt;
        &amp;lt;node oor:name=&amp;quot;UserDefinedImages&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;prop oor:name=&amp;quot;ImageSmallURL&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;value&amp;gt;%origin%/idlfile.png&amp;lt;/value&amp;gt;&lt;br /&gt;
          &amp;lt;/prop&amp;gt;&lt;br /&gt;
          &amp;lt;prop oor:name=&amp;quot;ImageBigURL&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;value&amp;gt;%origin%/idlfile.png&amp;lt;/value&amp;gt;&lt;br /&gt;
          &amp;lt;/prop&amp;gt;&lt;br /&gt;
          &amp;lt;prop oor:name=&amp;quot;ImageSmallHCURL&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;value&amp;gt;%origin%/idlfile.png&amp;lt;/value&amp;gt;&lt;br /&gt;
          &amp;lt;/prop&amp;gt;&lt;br /&gt;
          &amp;lt;prop oor:name=&amp;quot;ImageBigHCURL&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;value&amp;gt;%origin%/idlfile.png&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;/node&amp;gt;&lt;br /&gt;
&amp;lt;/oor:component-data&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;uno-extension-manifest.xml&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt;the package descriptor, will be packed as &amp;amp;quot;META-INF/manifest.xml&amp;amp;quot;&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;manifest:manifest xmlns:manifest=&amp;quot;http://openoffice.org/2001/manifest&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;application/vnd.sun.star.uno-component;type=Java&amp;quot;&lt;br /&gt;
                       manifest:full-path=&amp;quot;TestAddOn.jar&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;application/vnd.sun.star.configuration-data&amp;quot;&lt;br /&gt;
                       manifest:full-path=&amp;quot;registry/data/org/openoffice/Office/Addons.xcu&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;application/vnd.sun.star.configuration-data&amp;quot;&lt;br /&gt;
                       manifest:full-path=&amp;quot;registry/data/org/openoffice/Office/ProtocolHandler.xcu&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/manifest:manifest&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;org/openoffice/testaddon/TestAddOn.java&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt;the generated Add-On code skeleton where the generated class acts itself as the dispatch object (can be easily changed to support more complex Add-Ons). Most of the methods are already implemented and you simply have to add your own code in the dispatch method in the right place for each specified command.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;Java&amp;quot;&amp;gt;&lt;br /&gt;
package org.openoffice.testaddon;&lt;br /&gt;
&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.lib.uno.helper.Factory;&lt;br /&gt;
import com.sun.star.lang.XSingleComponentFactory;&lt;br /&gt;
import com.sun.star.registry.XRegistryKey;&lt;br /&gt;
import com.sun.star.lib.uno.helper.WeakBase;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public final class TestAddOn extends WeakBase&lt;br /&gt;
   implements com.sun.star.lang.XServiceInfo,&lt;br /&gt;
              com.sun.star.frame.XDispatchProvider,&lt;br /&gt;
              com.sun.star.lang.XInitialization,&lt;br /&gt;
              com.sun.star.frame.XDispatch&lt;br /&gt;
{&lt;br /&gt;
    private final XComponentContext m_xContext;&lt;br /&gt;
    private com.sun.star.frame.XFrame m_xFrame;&lt;br /&gt;
    private static final String m_implementationName = TestAddOn.class.getName();&lt;br /&gt;
    private static final String[] m_serviceNames = {&lt;br /&gt;
        &amp;quot;com.sun.star.frame.ProtocolHandler&amp;quot; };&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    public TestAddOn( XComponentContext context )&lt;br /&gt;
    {&lt;br /&gt;
        m_xContext = context;&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    public static XSingleComponentFactory __getComponentFactory( String sImplementationName ) {&lt;br /&gt;
        XSingleComponentFactory xFactory = null;&lt;br /&gt;
&lt;br /&gt;
        if ( sImplementationName.equals( m_implementationName ) )&lt;br /&gt;
            xFactory = Factory.createComponentFactory(TestAddOn.class, m_serviceNames);&lt;br /&gt;
        return xFactory;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public static boolean __writeRegistryServiceInfo( XRegistryKey xRegistryKey ) {&lt;br /&gt;
        return Factory.writeRegistryServiceInfo(m_implementationName,&lt;br /&gt;
                                                m_serviceNames,&lt;br /&gt;
                                                xRegistryKey);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // com.sun.star.lang.XServiceInfo:&lt;br /&gt;
    public String getImplementationName() {&lt;br /&gt;
         return m_implementationName;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public boolean supportsService( String sService ) {&lt;br /&gt;
        int len = m_serviceNames.length;&lt;br /&gt;
&lt;br /&gt;
        for( int i=0; i &amp;lt; len; i++) {&lt;br /&gt;
            if (sService.equals(m_serviceNames[i]))&lt;br /&gt;
                return true;&lt;br /&gt;
        }&lt;br /&gt;
        return false;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public String[] getSupportedServiceNames() {&lt;br /&gt;
        return m_serviceNames;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // com.sun.star.frame.XDispatchProvider:&lt;br /&gt;
    public com.sun.star.frame.XDispatch queryDispatch( com.sun.star.util.URL aURL,&lt;br /&gt;
                                                       String sTargetFrameName,&lt;br /&gt;
                                                       int iSearchFlags )&lt;br /&gt;
    {&lt;br /&gt;
        if ( aURL.Protocol.equals(&amp;quot;org.openoffice.testaddon.testaddon:&amp;quot;) )&lt;br /&gt;
        {&lt;br /&gt;
            if ( aURL.Path.equals(&amp;quot;mycommands&amp;quot;) )&lt;br /&gt;
                return this;&lt;br /&gt;
        }&lt;br /&gt;
        return null;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // com.sun.star.frame.XDispatchProvider:&lt;br /&gt;
    public com.sun.star.frame.XDispatch[] queryDispatches(&lt;br /&gt;
         com.sun.star.frame.DispatchDescriptor[] seqDescriptors )&lt;br /&gt;
    {&lt;br /&gt;
        int nCount = seqDescriptors.length;&lt;br /&gt;
        com.sun.star.frame.XDispatch[] seqDispatcher =&lt;br /&gt;
            new com.sun.star.frame.XDispatch[seqDescriptors.length];&lt;br /&gt;
&lt;br /&gt;
        for( int i=0; i &amp;lt; nCount; ++i )&lt;br /&gt;
        {&lt;br /&gt;
            seqDispatcher[i] = queryDispatch(seqDescriptors[i].FeatureURL,&lt;br /&gt;
                                             seqDescriptors[i].FrameName,&lt;br /&gt;
                                             seqDescriptors[i].SearchFlags );&lt;br /&gt;
        }&lt;br /&gt;
        return seqDispatcher;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // com.sun.star.lang.XInitialization:&lt;br /&gt;
    public void initialize( Object[] object )&lt;br /&gt;
        throws com.sun.star.uno.Exception&lt;br /&gt;
    {&lt;br /&gt;
        if ( object.length &amp;gt; 0 )&lt;br /&gt;
        {&lt;br /&gt;
            m_xFrame = (com.sun.star.frame.XFrame)UnoRuntime.queryInterface(&lt;br /&gt;
                com.sun.star.frame.XFrame.class, object[0]);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // com.sun.star.frame.XDispatch:&lt;br /&gt;
     public void dispatch( com.sun.star.util.URL aURL,&lt;br /&gt;
                           com.sun.star.beans.PropertyValue[] aArguments )&lt;br /&gt;
    {&lt;br /&gt;
         if ( aURL.Protocol.equals(&amp;quot;org.openoffice.testaddon.testaddon:&amp;quot;) )&lt;br /&gt;
        {&lt;br /&gt;
            if ( aURL.Path.equals(&amp;quot;mycommands&amp;quot;) )&lt;br /&gt;
            {&lt;br /&gt;
                // add your own code here&lt;br /&gt;
                return;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void addStatusListener( com.sun.star.frame.XStatusListener xControl,&lt;br /&gt;
                                    com.sun.star.util.URL aURL )&lt;br /&gt;
    {&lt;br /&gt;
        // add your own code here&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void removeStatusListener( com.sun.star.frame.XStatusListener xControl,&lt;br /&gt;
                                       com.sun.star.util.URL aURL )&lt;br /&gt;
    {&lt;br /&gt;
        // add your own code here&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Uno]]&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Add-On]]&lt;br /&gt;
[[Category:API]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Basic/Creating_Dialogs_at_Runtime&amp;diff=155443</id>
		<title>Documentation/DevGuide/Basic/Creating Dialogs at Runtime</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Basic/Creating_Dialogs_at_Runtime&amp;diff=155443"/>
		<updated>2010-01-22T09:11:33Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/DevGuide/BasicTOC&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|PrevPage=Documentation/DevGuide/Basic/File Control&lt;br /&gt;
|NextPage=Documentation/DevGuide/Basic/Library File Structure&lt;br /&gt;
}}&lt;br /&gt;
{{Documentation/DevGuideLanguages|Documentation/DevGuide/Basic/{{SUBPAGENAME}}}} &lt;br /&gt;
 {{DISPLAYTITLE:Creating Dialogs at Runtime}}&lt;br /&gt;
When using {{PRODUCTNAME}} Basic, the dialog editor is a tool for designing dialogs. Refer to [[Documentation/DevGuide/Basic/OpenOffice.org Basic IDE|OpenOffice.org Basic IDE]] for additional information. Since {{PRODUCTNAME}} {{OO2.0.0}}, dialogs that have been built with the dialog editor can be loaded by a macro written in any of the supported scripting framework languages (BeanShell, JavaScript, Java, {{PRODUCTNAME}} Basic) by using the &amp;lt;idl&amp;gt;com.sun.star.awt.XDialogProvider&amp;lt;/idl&amp;gt; API. See section [[Documentation/DevGuide/Scripting/Using the Scripting Framework|Using the Scripting Framework]] for more details.&lt;br /&gt;
&lt;br /&gt;
In addition, it is also possible to create dialogs at runtime in a similar way as Java Swing components are created. Also, the event listeners are registered at runtime at the appropriate controls.&lt;br /&gt;
&lt;br /&gt;
[[Image:CreatingDialogs_SampleDialog.png|none|thumb|295px|An example dialog]]&lt;br /&gt;
&lt;br /&gt;
In the Java example described in this section, a simple modal dialog is created at runtime containing a command button and label field. Each time the user clicks on the button, the label field is updated and the total number of button clicks is displayed.&lt;br /&gt;
&lt;br /&gt;
The dialog is implemented as a UNO component in Java that is instantiated with the service name &amp;lt;code&amp;gt;com.sun.star.examples.SampleDialog&amp;lt;/code&amp;gt;. For details about writing a Java component and the implementation of the UNO core interfaces, refer to [[Documentation/DevGuide/WritingUNO/Storing the Service Manager for Further Use|Storing the Service Manager for Further Use]]. The method that creates and executes the dialog is shown below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  /** method for creating a dialog at runtime&lt;br /&gt;
   */&lt;br /&gt;
  private void createDialog() throws com.sun.star.uno.Exception {&lt;br /&gt;
      // get the service manager from the component context&lt;br /&gt;
      XMultiComponentFactory xMultiComponentFactory = _xComponentContext.getServiceManager();&lt;br /&gt;
      // create the dialog model and set the properties&lt;br /&gt;
      Object dialogModel = xMultiComponentFactory.createInstanceWithContext(&lt;br /&gt;
          &amp;quot;com.sun.star.awt.UnoControlDialogModel&amp;quot;, _xComponentContext);&lt;br /&gt;
      XPropertySet xPSetDialog = (XPropertySet)UnoRuntime.queryInterface(&lt;br /&gt;
          XPropertySet.class, dialogModel); &lt;br /&gt;
      xPSetDialog.setPropertyValue(&amp;quot;PositionX&amp;quot;, new Integer(100));&lt;br /&gt;
      xPSetDialog.setPropertyValue(&amp;quot;PositionY&amp;quot;, new Integer(100));&lt;br /&gt;
      xPSetDialog.setPropertyValue(&amp;quot;Width&amp;quot;, new Integer(150));&lt;br /&gt;
      xPSetDialog.setPropertyValue(&amp;quot;Height&amp;quot;, new Integer(100));&lt;br /&gt;
      xPSetDialog.setPropertyValue(&amp;quot;Title&amp;quot;, new String(&amp;quot;Runtime Dialog Demo&amp;quot;));&lt;br /&gt;
      // get the service manager from the dialog model&lt;br /&gt;
      XMultiServiceFactory xMultiServiceFactory = (XMultiServiceFactory)UnoRuntime.queryInterface(&lt;br /&gt;
          XMultiServiceFactory.class, dialogModel);&lt;br /&gt;
      // create the button model and set the properties&lt;br /&gt;
      Object buttonModel = xMultiServiceFactory.createInstance(&lt;br /&gt;
          &amp;quot;com.sun.star.awt.UnoControlButtonModel&amp;quot; );&lt;br /&gt;
      XPropertySet xPSetButton = (XPropertySet)UnoRuntime.queryInterface(&lt;br /&gt;
          XPropertySet.class, buttonModel);&lt;br /&gt;
      xPSetButton.setPropertyValue(&amp;quot;PositionX&amp;quot;, new Integer(50));&lt;br /&gt;
      xPSetButton.setPropertyValue(&amp;quot;PositionY&amp;quot;, new Integer(30));&lt;br /&gt;
      xPSetButton.setPropertyValue(&amp;quot;Width&amp;quot;, new Integer(50));&lt;br /&gt;
      xPSetButton.setPropertyValue(&amp;quot;Height&amp;quot;, new Integer(14));&lt;br /&gt;
      xPSetButton.setPropertyValue(&amp;quot;Name&amp;quot;, _buttonName);&lt;br /&gt;
      xPSetButton.setPropertyValue(&amp;quot;TabIndex&amp;quot;, new Short((short)0)); &lt;br /&gt;
      xPSetButton.setPropertyValue(&amp;quot;Label&amp;quot;, new String(&amp;quot;Click Me&amp;quot;));&lt;br /&gt;
      // create the label model and set the properties&lt;br /&gt;
      Object labelModel = xMultiServiceFactory.createInstance(&lt;br /&gt;
          &amp;quot;com.sun.star.awt.UnoControlFixedTextModel&amp;quot; );&lt;br /&gt;
      XPropertySet xPSetLabel = ( XPropertySet )UnoRuntime.queryInterface(&lt;br /&gt;
          XPropertySet.class, labelModel );&lt;br /&gt;
      xPSetLabel.setPropertyValue(&amp;quot;PositionX&amp;quot;, new Integer(40));&lt;br /&gt;
      xPSetLabel.setPropertyValue(&amp;quot;PositionY&amp;quot;, new Integer(60));&lt;br /&gt;
      xPSetLabel.setPropertyValue(&amp;quot;Width&amp;quot;, new Integer(100));&lt;br /&gt;
      xPSetLabel.setPropertyValue(&amp;quot;Height&amp;quot;, new Integer(14));&lt;br /&gt;
      xPSetLabel.setPropertyValue(&amp;quot;Name&amp;quot;, _labelName);&lt;br /&gt;
      xPSetLabel.setPropertyValue(&amp;quot;TabIndex&amp;quot;, new Short((short)1)); &lt;br /&gt;
      xPSetLabel.setPropertyValue(&amp;quot;Label&amp;quot;, _labelPrefix);&lt;br /&gt;
      // insert the control models into the dialog model&lt;br /&gt;
      XNameContainer xNameCont = (XNameContainer)UnoRuntime.queryInterface(&lt;br /&gt;
          XNameContainer.class, dialogModel);&lt;br /&gt;
      xNameCont.insertByName(_buttonName, buttonModel);&lt;br /&gt;
      xNameCont.insertByName(_labelName, labelModel);&lt;br /&gt;
      // create the dialog control and set the model&lt;br /&gt;
      Object dialog = xMultiComponentFactory.createInstanceWithContext(&lt;br /&gt;
          &amp;quot;com.sun.star.awt.UnoControlDialog&amp;quot;, _xComponentContext);&lt;br /&gt;
      XControl xControl = (XControl)UnoRuntime.queryInterface(&lt;br /&gt;
          XControl.class, dialog );&lt;br /&gt;
      XControlModel xControlModel = (XControlModel)UnoRuntime.queryInterface(&lt;br /&gt;
          XControlModel.class, dialogModel); &lt;br /&gt;
      xControl.setModel(xControlModel);&lt;br /&gt;
      // add an action listener to the button control&lt;br /&gt;
      XControlContainer xControlCont = (XControlContainer)UnoRuntime.queryInterface(&lt;br /&gt;
          XControlContainer.class, dialog); &lt;br /&gt;
      Object objectButton = xControlCont.getControl(&amp;quot;Button1&amp;quot;);&lt;br /&gt;
      XButton xButton = (XButton)UnoRuntime.queryInterface(XButton.class, objectButton);&lt;br /&gt;
      xButton.addActionListener(new ActionListenerImpl(xControlCont));&lt;br /&gt;
      // create a peer&lt;br /&gt;
      Object toolkit = xMultiComponentFactory.createInstanceWithContext(&lt;br /&gt;
          &amp;quot;com.sun.star.awt.Toolkit&amp;quot;, _xComponentContext); &lt;br /&gt;
      XToolkit xToolkit = (XToolkit)UnoRuntime.queryInterface(XToolkit.class, toolkit);&lt;br /&gt;
      XWindow xWindow = (XWindow)UnoRuntime.queryInterface(XWindow.class, xControl);&lt;br /&gt;
      xWindow.setVisible(false); &lt;br /&gt;
      xControl.createPeer(xToolkit, null);&lt;br /&gt;
      // execute the dialog&lt;br /&gt;
      XDialog xDialog = (XDialog)UnoRuntime.queryInterface(XDialog.class, dialog);&lt;br /&gt;
      xDialog.execute();&lt;br /&gt;
      // dispose the dialog&lt;br /&gt;
      XComponent xComponent = (XComponent)UnoRuntime.queryInterface(XComponent.class, dialog);&lt;br /&gt;
      xComponent.dispose();&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
First, a dialog model is created by prompting the &amp;lt;code&amp;gt;ServiceManager&amp;lt;/code&amp;gt; for the &amp;lt;idl&amp;gt;com.sun.star.awt.UnoControlDialogModel&amp;lt;/idl&amp;gt; service. Then, the position, size and title of the dialog are set using the &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idl&amp;gt; interface. In performance critical applications, the use of the &amp;lt;idl&amp;gt;com.sun.star.beans.XMultiPropertySet&amp;lt;/idl&amp;gt; interface is recommended. At this point, the dialog model describes an empty dialog, which does not contain any control models. &lt;br /&gt;
&lt;br /&gt;
All control models in a dialog container have the common properties &amp;quot;PositionX&amp;quot;, &amp;quot;PositionY&amp;quot;, &amp;quot;Width&amp;quot;, &amp;quot;Height&amp;quot;, &amp;quot;Name&amp;quot;, &amp;quot;TabIndex&amp;quot;, &amp;quot;Step&amp;quot; and &amp;quot;Tag&amp;quot;. These properties are optional and only added if the control model is created by a special object factory, namely the dialog model. Therefore, a dialog model also supports the &amp;lt;idl&amp;gt;com.sun.star.lang.XMultiServiceFactory&amp;lt;/idl&amp;gt; interface. If the control model is created by the &amp;lt;code&amp;gt;ServiceManager&amp;lt;/code&amp;gt;, these common properties are missing.&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|Note that control models have the common properties &amp;quot;PositionX&amp;quot;, &amp;quot;PositionY&amp;quot;, &amp;quot;Width&amp;quot;, &amp;quot;Height&amp;quot;, &amp;quot;Name&amp;quot;, &amp;quot;TabIndex&amp;quot;, &amp;quot;Step&amp;quot; and &amp;quot;Tag&amp;quot; only if they were created by the dialog model that they belong to.}}&lt;br /&gt;
&lt;br /&gt;
After the control models for the command button and label field are created, their position, size, name, tab index and label are set. Then, the control models are inserted into the dialog model using the &amp;lt;idl&amp;gt;com.sun.star.container.XNameContainer&amp;lt;/idl&amp;gt; interface. The model of the dialog has been fully described.&lt;br /&gt;
&lt;br /&gt;
To display the dialog on the screen, a dialog control &amp;lt;idl&amp;gt;com.sun.star.awt.UnoControlDialog&amp;lt;/idl&amp;gt; is created and the corresponding model is set. An action listener is added to the button control, because the label field is updated whenever the user clicks on the command button. The listener is explained below. Before the dialog is shown, a window or a peer is created on the screen. Finally, the dialog is displayed on the screen using the execute method of the &amp;lt;idl&amp;gt;com.sun.star.awt.XDialog&amp;lt;/idl&amp;gt; interface.&lt;br /&gt;
&lt;br /&gt;
The implementation of the action listener is shown in the following example.&lt;br /&gt;
&lt;br /&gt;
  /** action listener&lt;br /&gt;
   */&lt;br /&gt;
  public class ActionListenerImpl implements com.sun.star.awt.XActionListener {&lt;br /&gt;
      private int _nCounts = 0;&lt;br /&gt;
      private XControlContainer _xControlCont;&lt;br /&gt;
      &lt;br /&gt;
      public ActionListenerImpl(XControlContainer xControlCont) {&lt;br /&gt;
          _xControlCont = xControlCont;&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      // XEventListener&lt;br /&gt;
      public void disposing(EventObject eventObject) {&lt;br /&gt;
          _xControlCont = null;&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      // XActionListener&lt;br /&gt;
      public void actionPerformed(ActionEvent actionEvent) {&lt;br /&gt;
          // increase click counter&lt;br /&gt;
          _nCounts++;&lt;br /&gt;
      &lt;br /&gt;
          // set label text&lt;br /&gt;
          Object label = _xControlCont.getControl(&amp;quot;Label1&amp;quot;);&lt;br /&gt;
          XFixedText xLabel = (XFixedText)UnoRuntime.queryInterface(XFixedText.class, label); &lt;br /&gt;
          xLabel.setText(_labelPrefix + _nCounts);&lt;br /&gt;
      } &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
The action listener is fired each time the user clicks on the command button. In the &amp;lt;code&amp;gt;actionPerformed&amp;lt;/code&amp;gt; method of the &amp;lt;idl&amp;gt;com.sun.star.awt.XActionListener&amp;lt;/idl&amp;gt; interface, an internal counter for the number of button clicks is increased. Then, this number is updated in the label field. In addition, the disposing method of the parent interface &amp;lt;idl&amp;gt;com.sun.star.lang.XEventListener&amp;lt;/idl&amp;gt; is implemented.&lt;br /&gt;
&lt;br /&gt;
Our sample component executes the dialog from within the office by implementing the trigger method of the &amp;lt;idl&amp;gt;com.sun.star.task.XJobExecutor&amp;lt;/idl&amp;gt; interface:&lt;br /&gt;
&lt;br /&gt;
  public void trigger(String sEvent) {&lt;br /&gt;
      if (sEvent.equals(&amp;quot;execute&amp;quot;)) {&lt;br /&gt;
          try {&lt;br /&gt;
              createDialog();&lt;br /&gt;
          }&lt;br /&gt;
          catch (Exception e) {&lt;br /&gt;
              throw new com.sun.star.lang.WrappedTargetRuntimeException(e.getMessage(), this, e);&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
A simple {{PRODUCTNAME}} Basic macro that instantiates the service of our sample component and executes the dialog is shown below.&lt;br /&gt;
&lt;br /&gt;
  Sub Main&lt;br /&gt;
      Dim oJobExecutor&lt;br /&gt;
      oJobExecutor = CreateUnoService(&amp;quot;com.sun.star.examples.SampleDialog&amp;quot;)&lt;br /&gt;
      oJobExecutor.trigger(&amp;quot;execute&amp;quot;)&lt;br /&gt;
  End Sub&lt;br /&gt;
&lt;br /&gt;
In future versions of {{PRODUCTNAME}}, a method for executing dialogs created at runtime will be provided.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation/Developer&amp;#039;s Guide/Basic and Dialogs]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Performance/Startup&amp;diff=152664</id>
		<title>Performance/Startup</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Performance/Startup&amp;diff=152664"/>
		<updated>2009-12-14T19:14:49Z</updated>

		<summary type="html">&lt;p&gt;Newacct: /* callgrind */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Performance}}&lt;br /&gt;
= Issues =&lt;br /&gt;
&lt;br /&gt;
* [http://eis.services.openoffice.org/EIS2/cws.ShowCWS?Path=DEV300%2Fsb103 CWS sb103], integrated in OOO310_m1 and DEV300_m42:&lt;br /&gt;
** [http://qa.openoffice.org/issues/show_bug.cgi?id=96284 Issue 96284] &amp;amp;ldquo;registry symlink foo ...&amp;amp;rdquo;&lt;br /&gt;
** [http://qa.openoffice.org/issues/show_bug.cgi?id=97424 Issue 97424] &amp;amp;ldquo;improve ImplImageTree performance&amp;amp;rdquo;&lt;br /&gt;
* [http://eis.services.openoffice.org/EIS2/cws.ShowCWS?Path=DEV300%2Fsb107 CWS sb107], integrated in DEV300_m47:&lt;br /&gt;
** [http://qa.openoffice.org/issues/show_bug.cgi?id=85679 Issue 85679] &amp;amp;ldquo;Link with -Wl,-Bsymbolic-functions -Wl,--dynamic-list-cpp-new -Wl,--dynamic-list-cpp-typeinfo when supported&amp;amp;rdquo;&lt;br /&gt;
** [http://qa.openoffice.org/issues/show_bug.cgi?id=99519 Issue 99519] &amp;amp;ldquo;Remove unnecessary library dependencies&amp;amp;rdquo; (&amp;amp;ldquo;[t]his cleanup has no positive impact on OOo startup performance though&amp;amp;rdquo;&amp;amp;mdash;[https://so-web.germany.sun.com/iBIS/servlet/edit.ControlPanel?tid=i99519#desc3])&lt;br /&gt;
** [http://qa.openoffice.org/issues/show_bug.cgi?id=100348 Issue 100348] &amp;amp;ldquo;svt, bf_svt export symbols from jpeg archive&amp;amp;rdquo;&lt;br /&gt;
** [http://qa.openoffice.org/issues/show_bug.cgi?id=100396 Issue 100396] &amp;amp;ldquo;svtools: costly external data symbols sHTML_xxx/sRTF_xxx&amp;amp;rdquo;&lt;br /&gt;
** [http://qa.openoffice.org/issues/show_bug.cgi?id=100576 Issue 100576] &amp;amp;ldquo;enable HAVE_LD_HASH_STYLE in sdev300.ini&amp;amp;rdquo;&lt;br /&gt;
* analyzing startup to identify performance problems (ongoing)&lt;br /&gt;
&lt;br /&gt;
= Details =&lt;br /&gt;
&lt;br /&gt;
== Additional processes during startup ==&lt;br /&gt;
&lt;br /&gt;
Starting OOo &amp;lt;code&amp;gt;DEV300m39&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;unxlngi6.pro&amp;lt;/code&amp;gt; on &amp;lt;code&amp;gt;v20z-so3&amp;lt;/code&amp;gt; (some old Ubuntu machine), &amp;lt;code&amp;gt;soffice.bin&amp;lt;/code&amp;gt; spawns additional processes during start up:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ strace -fF opt/openoffice.org3/program/soffice.bin 2&amp;gt;&amp;amp;1 | grep &amp;#039;exec.*(&amp;#039;&lt;br /&gt;
execve(&amp;quot;ooo/opt/openoffice.org3/program/soffice.bin&amp;quot;, [&amp;quot;ooo/opt/openoffice.org3/program/&amp;quot;...], [/* 17 vars */]) = 0&lt;br /&gt;
[pid 19800] execve(&amp;quot;/usr/lib/libgconf2-4/gconfd-2&amp;quot;, [&amp;quot;/usr/lib/libgconf2-4/gconfd-2&amp;quot;, &amp;quot;17&amp;quot;], [/* 18 vars */] &amp;lt;unfinished ...&amp;gt;&lt;br /&gt;
[pid 19802] execve(&amp;quot;/bin/sh&amp;quot;, [&amp;quot;sh&amp;quot;, &amp;quot;-c&amp;quot;, &amp;quot;sh -c paperconf 2&amp;gt;/dev/null&amp;quot;], [/* 18 vars */]) = 0&lt;br /&gt;
[pid 19803] execve(&amp;quot;/bin/sh&amp;quot;, [&amp;quot;sh&amp;quot;, &amp;quot;-c&amp;quot;, &amp;quot;paperconf&amp;quot;], [/* 17 vars */]) = 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It turns out only the first additional process (&amp;lt;code&amp;gt;/usr/lib/libgconf2-4/gconfd-2&amp;lt;/code&amp;gt;) is spawned directly from &amp;lt;code&amp;gt;soffice.bin&amp;lt;/code&amp;gt; (and the following ones are in turn spawned from that process), and it is spawned during a call to &amp;lt;code&amp;gt;gconf_client_preload&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ gdb opt/openoffice.org3/program/soffice.bin&lt;br /&gt;
(gdb) break fork&lt;br /&gt;
Breakpoint 2 at 0xb7c6f584&lt;br /&gt;
(gdb) run&lt;br /&gt;
Breakpoint 2, 0xb7c6f584 in fork () from /lib/tls/i686/cmov/libpthread.so.0&lt;br /&gt;
(gdb) info threads&lt;br /&gt;
  4 Thread -1296356432 (LWP 19893)  0xffffe410 in __kernel_vsyscall ()&lt;br /&gt;
  3 Thread -1287963728 (LWP 19892)  0xffffe410 in __kernel_vsyscall ()&lt;br /&gt;
  2 Thread -1251386448 (LWP 19889)  0xffffe410 in __kernel_vsyscall ()&lt;br /&gt;
* 1 Thread -1251252000 (LWP 19887)  0xb7c6f584 in fork ()&lt;br /&gt;
   from /lib/tls/i686/cmov/libpthread.so.0&lt;br /&gt;
(gdb) where&lt;br /&gt;
#0  0xb7c6f584 in fork () from /lib/tls/i686/cmov/libpthread.so.0&lt;br /&gt;
#1  0xb496593a in g_spawn_error_quark () from /usr/lib/libglib-2.0.so.0&lt;br /&gt;
#2  0xb49660fe in g_spawn_async_with_pipes () from /usr/lib/libglib-2.0.so.0&lt;br /&gt;
#3  0xb496617b in g_spawn_async () from /usr/lib/libglib-2.0.so.0&lt;br /&gt;
#4  0xb34a4ec6 in gconf_activate_server () from /usr/lib/libgconf-2.so.4&lt;br /&gt;
#5  0xb34afc29 in gconf_debug_shutdown () from /usr/lib/libgconf-2.so.4&lt;br /&gt;
#6  0xb34b06e1 in gconf_spawn_daemon () from /usr/lib/libgconf-2.so.4&lt;br /&gt;
#7  0xb34b091a in gconf_spawn_daemon () from /usr/lib/libgconf-2.so.4&lt;br /&gt;
#8  0xb34b148c in gconf_engine_all_entries () from /usr/lib/libgconf-2.so.4&lt;br /&gt;
#9  0xb34b7540 in gconf_client_all_entries () from /usr/lib/libgconf-2.so.4&lt;br /&gt;
#10 0xb34e0f9c in GconfLayer::getTimestamp (this=0xb342dc1c)&lt;br /&gt;
    at /so/ws/DEV300/ooo/shell/source/backends/gconfbe/gconflayer.cxx:528&lt;br /&gt;
#11 0xb35dc4c3 in configmgr::backend::BinaryReadHandler::validateHeader (&lt;br /&gt;
    this=0xbffcf42c, pLayers=0xb33c2020, nNumLayers=6,&lt;br /&gt;
    _aSchemaVersion=@0xbffcf550, aRequestedLocale=@0xbffcf530,&lt;br /&gt;
    outKnownLocales=@0xbffcf540) at Reference.h:366&lt;br /&gt;
#12 0xb35dd151 in configmgr::backend::BinaryCache::readComponentData (&lt;br /&gt;
    this=0xb33bca1c, aComponentData=@0xbffcf698, aFactory=@0xbffcf510,&lt;br /&gt;
    aComponent=@0xbffcf6c8, aSchemaVersion=@0xbffcf550, aEntity=@0xbffcf520,&lt;br /&gt;
    aRequestedLocale=@0xbffcf530, outKnownLocales=@0xbffcf540,&lt;br /&gt;
    pLayers=0xb33c2020, nNumLayers=6, bIncludeTemplates=true)&lt;br /&gt;
    at /so/ws/DEV300/ooo/configmgr/source/backend/binarycache.cxx:200&lt;br /&gt;
#13 0xb35cc7bd in configmgr::backend::BackendAccess::readDefaultData (&lt;br /&gt;
    this=0xb4584d5c, aComponentData=@0xbffcf698, aComponent=@0xbffcf6c8,&lt;br /&gt;
    aOptions=@0xbffcf83c, bIncludeTemplates=true, pLayers=0xb33c2020,&lt;br /&gt;
    nNumLayers=6, aTemplateProvider=0xb352d60c, pLayersMerged=0xbffcf644)&lt;br /&gt;
    at /so/ws/DEV300/ooo/configmgr/source/backend/backendaccess.cxx:84&lt;br /&gt;
#14 0xb35cd9bd in configmgr::backend::BackendAccess::getNodeData (&lt;br /&gt;
    this=0xb4584d5c, aRequest=@0xbffcf838, _aTemplateProvider=0xb352d60c,&lt;br /&gt;
    aListener=0xb352d610) at request.hxx:75&lt;br /&gt;
#15 0xb35934e5 in configmgr::backend::CacheController::loadDirectly (&lt;br /&gt;
    this=0xb352d604, _aRequest=@0xbffcf838, _bAddListenter=true) at ref.hxx:167&lt;br /&gt;
#16 0xb3597198 in configmgr::backend::CacheController::loadComponent (&lt;br /&gt;
    this=0xb352d604, _aRequest=@0xbffcf838)&lt;br /&gt;
    at /so/ws/DEV300/ooo/configmgr/source/treecache/cachecontroller.cxx:376&lt;br /&gt;
#17 0xb359b6d4 in configmgr::TreeManager::requestSubtree (this=0xb4584eac,&lt;br /&gt;
    aSubtreePath=@0xbffcf960, _aOptions=@0xbffcf83c) at ref.hxx:99&lt;br /&gt;
#18 0xb36517e9 in configmgr::OProviderImpl::requestSubtree (this=0xb458b31c,&lt;br /&gt;
    aSubtreePath=@0xbffcf960, _aOptions=@0xbffcf9a0) at ref.hxx:167&lt;br /&gt;
#19 0xb3652f6b in configmgr::OProviderImpl::buildReadAccess (this=0xb458b31c,&lt;br /&gt;
    _rAccessor=@0xbffcf9c0, _aOptions=@0xbffcf9a0, nMinLevels=-1)&lt;br /&gt;
    at /so/ws/DEV300/ooo/configmgr/source/api2/providerimpl.cxx:490&lt;br /&gt;
#20 0xb36532b5 in configmgr::OProviderImpl::createReadAccess (this=0xb458b31c,&lt;br /&gt;
    aArgs=@0xbffcfb80)&lt;br /&gt;
    at /so/ws/DEV300/ooo/configmgr/source/api2/providerimpl.cxx:860&lt;br /&gt;
#21 0xb364b799 in configmgr::OProvider::createInstanceWithArguments (&lt;br /&gt;
    this=0xb376a554, aServiceSpecifier=@0xbffcfb20, aArguments=@0xbffcfb80)&lt;br /&gt;
    at Reference.h:359&lt;br /&gt;
#22 0xb690b180 in DefaultFontConfiguration (this=0xb33c3394) at Reference.h:366&lt;br /&gt;
#23 0xb690ba5f in vcl::DefaultFontConfiguration::get ()&lt;br /&gt;
    at /so/ws/DEV300/ooo/vcl/source/gdi/fontcfg.cxx:107&lt;br /&gt;
#24 0xb684818d in ImplStyleData::SetStandardStyles (this=0xb33df618)&lt;br /&gt;
    at ustring.hxx:111&lt;br /&gt;
#25 0xb6848945 in ImplStyleData (this=0xb33df618)&lt;br /&gt;
    at /so/ws/DEV300/ooo/vcl/source/app/settings.cxx:438&lt;br /&gt;
#26 0xb6848eef in StyleSettings (this=0x0)&lt;br /&gt;
    at /so/ws/DEV300/ooo/vcl/source/app/settings.cxx:640&lt;br /&gt;
#27 0xb684aa98 in ImplAllSettingsData (this=0xb33b71c8)&lt;br /&gt;
    at /so/ws/DEV300/ooo/vcl/source/app/settings.cxx:1523&lt;br /&gt;
#28 0xb684b244 in AllSettings (this=0x0)&lt;br /&gt;
    at /so/ws/DEV300/ooo/vcl/source/app/settings.cxx:1590&lt;br /&gt;
#29 0xb684ce12 in Application::GetSettings ()&lt;br /&gt;
    at /so/ws/DEV300/ooo/vcl/source/app/svapp.cxx:814&lt;br /&gt;
#30 0xb68c699c in OutputDevice (this=0xb458e924)&lt;br /&gt;
    at /so/ws/DEV300/ooo/vcl/source/gdi/outdev.cxx:427&lt;br /&gt;
#31 0xb6a18618 in Window (this=0xb458e924, nType=383)&lt;br /&gt;
    at /so/ws/DEV300/ooo/vcl/source/window/window.cxx:4288&lt;br /&gt;
#32 0xb69ee0b7 in SystemWindow (this=0xb458e924, nType=0)&lt;br /&gt;
    at /so/ws/DEV300/ooo/vcl/source/window/syswin.cxx:83&lt;br /&gt;
#33 0xb6a28a72 in WorkWindow (this=0xb458e924, nType=0)&lt;br /&gt;
    at /so/ws/DEV300/ooo/vcl/source/window/wrkwin.cxx:114&lt;br /&gt;
#34 0xb69c8151 in IntroWindow (this=0xb458e924)&lt;br /&gt;
    at /so/ws/DEV300/ooo/vcl/source/window/introwin.cxx:61&lt;br /&gt;
#35 0xb239185d in SplashScreen (this=0xb458e908, rSMgr=@0x0)&lt;br /&gt;
    at /so/ws/DEV300/ooo/desktop/source/splash/splash.cxx:83&lt;br /&gt;
#36 0xb2391b10 in desktop::SplashScreen::getInstance (rSMgr=@0xbffcfdec)&lt;br /&gt;
    at weak.hxx:91&lt;br /&gt;
#37 0xb77d9206 in cppu::OSingleFactoryHelper::createInstanceEveryTime (&lt;br /&gt;
    this=0xb33b726c, xContext=@0x1) at Reference.h:359&lt;br /&gt;
#38 0xb77d88be in cppu::OSingleFactoryHelper::createInstanceWithContext (&lt;br /&gt;
    this=0x0, xContext=@0xb4e41ad8) at Reference.h:359&lt;br /&gt;
#39 0xb77d8cb1 in cppu::OFactoryComponentHelper::createInstanceWithContext (&lt;br /&gt;
    this=0xb33b7238, xContext=@0xb4e41ad8) at Reference.h:359&lt;br /&gt;
#40 0xb77d9988 in cppu::OSingleFactoryHelper::createInstanceWithArgumentsAndContext (this=0x0, rArguments=@0xbffd0160, xContext=@0xb4e41ad8) at Reference.h:359&lt;br /&gt;
#41 0xb77da48e in cppu::OFactoryComponentHelper::createInstanceWithArgumentsAndContext (this=0xb33b7238, rArguments=@0xbffd0160, xContext=@0xb4e41ad8)&lt;br /&gt;
    at Reference.h:359&lt;br /&gt;
#42 0xb77dadce in cppu::ORegistryFactoryHelper::createInstanceWithArgumentsAndContext (this=0xb33b4264, rArguments=@0xbffd0160, xContext=@0xb4e41ad8)&lt;br /&gt;
    at Reference.h:366&lt;br /&gt;
#43 0xb45f68e9 in stoc_smgr::OServiceManager::createInstanceWithArgumentsAndContext (this=0xb33b42a0, rServiceSpecifier=@0xbffd0130, rArguments=@0xbffd0160,&lt;br /&gt;
    xContext=@0xb4e41ad8) at Reference.h:366&lt;br /&gt;
#44 0xb45f61a8 in stoc_smgr::OServiceManager::createInstanceWithArguments (&lt;br /&gt;
    this=0x1, rServiceSpecifier=@0xbffd0130, rArguments=@0xbffd0160)&lt;br /&gt;
    at Reference.h:359&lt;br /&gt;
#45 0xb7dbcc21 in desktop::Desktop::OpenSplashScreen (this=0xbffd04a4)&lt;br /&gt;
    at Reference.h:121&lt;br /&gt;
#46 0xb7dbd296 in desktop::Desktop::Main (this=0xbffd04a4)&lt;br /&gt;
    at /so/ws/DEV300/ooo/desktop/source/app/app.cxx:1232&lt;br /&gt;
#47 0xb6852372 in ImplSVMain ()&lt;br /&gt;
    at /so/ws/DEV300/ooo/vcl/source/app/svmain.cxx:194&lt;br /&gt;
#48 0xb68524fd in SVMain () at /so/ws/DEV300/ooo/vcl/source/app/svmain.cxx:235&lt;br /&gt;
#49 0xb7de6e23 in soffice_main ()&lt;br /&gt;
    at /so/ws/DEV300/ooo/desktop/source/app/sofficemain.cxx:52&lt;br /&gt;
#50 0x08048dea in main (argc=1, argv=0xbffd0584) at main.c:38&lt;br /&gt;
(gdb) cont&lt;br /&gt;
Program exited normally.&lt;br /&gt;
(gdb) quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first call to &amp;lt;code&amp;gt;gconf_client_preload&amp;lt;/code&amp;gt; (that presumably does the spawning) accounts for 0.05&amp;amp;nbsp;seconds of real time during start up:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ patch -p 0 &amp;lt;&amp;lt;-\EOF&lt;br /&gt;
	Index: tags/DEV300_m39/shell/source/backends/gconfbe/gconflayer.cxx&lt;br /&gt;
	===================================================================&lt;br /&gt;
	--- tags/DEV300_m39/shell/source/backends/gconfbe/gconflayer.cxx        (revision 266425)&lt;br /&gt;
	+++ tags/DEV300_m39/shell/source/backends/gconfbe/gconflayer.cxx        (working copy)&lt;br /&gt;
	@@ -1,3 +1,6 @@&lt;br /&gt;
	+/*SB*/#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
	+/*SB*/#include&amp;lt;sys/times.h&amp;gt;&lt;br /&gt;
	+/*SB*/#include&amp;lt;unistd.h&amp;gt;&lt;br /&gt;
	 /*************************************************************************&lt;br /&gt;
	  *&lt;br /&gt;
	  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.&lt;br /&gt;
	@@ -524,8 +527,10 @@&lt;br /&gt;
	     GConfValue* aGconfValue;&lt;br /&gt;
	     int i = 0;&lt;br /&gt;
	&lt;br /&gt;
	+/*SB*/tms TMS;clock_t TIME=times(&amp;amp;TMS);&lt;br /&gt;
	     while( m_pPreloadValuesList[i] != NULL )&lt;br /&gt;
	         gconf_client_preload( aClient, m_pPreloadValuesList[i++], GCONF_CLIENT_PRELOAD_ONELEVEL, NULL );&lt;br /&gt;
	+/*SB*/TIME=times(&amp;amp;TMS)-TIME;fprintf(stderr,&amp;quot;time %f\n&amp;quot;,double(TIME)/sysconf(_SC_CLK_TCK));for(int N=0;N&amp;lt;i;++N)fprintf(stderr,&amp;quot; preload %d &amp;lt;%s&amp;gt;\n&amp;quot;,N,m_pPreloadValuesList[N]);&lt;br /&gt;
	&lt;br /&gt;
	     for( i = 0; i &amp;lt; m_nConfigurationValues; i++ )&lt;br /&gt;
	     {&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ opt/openoffice.org3/program/soffice.bin&lt;br /&gt;
time 0.050000&lt;br /&gt;
 preload 0 &amp;lt;/desktop/gnome/interface&amp;gt;&lt;br /&gt;
time 0.010000&lt;br /&gt;
 preload 0 &amp;lt;/desktop/gnome/url-handlers/mailto&amp;gt;&lt;br /&gt;
time 0.000000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The overhead of the &amp;lt;code&amp;gt;soffice&amp;lt;/code&amp;gt; wrapper script around &amp;lt;code&amp;gt;soffice.bin&amp;lt;/code&amp;gt; is roughly as follows (see [http://qa.openoffice.org/issues/show_bug.cgi?id=97491 issue 97491] &amp;amp;ldquo;&amp;quot;soffice&amp;quot; now being binary instead of shellscript&amp;amp;rdquo; for temporary problems with the &amp;lt;code&amp;gt;soffice&amp;lt;/code&amp;gt; wrapper script), where &amp;lt;code&amp;gt;javaldx&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;pagein&amp;lt;/code&amp;gt; are among the executables called from the script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm opt/openoffice.org3/program/soffice.bin&lt;br /&gt;
$ ln -s /bin/true opt/openoffice.org3/program/soffice.bin&lt;br /&gt;
$ time opt/openoffice.org3/program/soffice&lt;br /&gt;
real    0m0.170s&lt;br /&gt;
user    0m0.060s&lt;br /&gt;
sys     0m0.110s&lt;br /&gt;
$ time opt/openoffice.org3/program/../basis-link/ure-link/bin/javaldx &amp;quot;-env:INIFILENAME=vnd.sun.star.pathname:${PWD?}/opt/openoffice.org3/program/redirectrc&amp;quot;&lt;br /&gt;
/usr/java/jdk1.6.0_03/jre/lib/i386/client:/usr/java/jdk1.6.0_03/jre/lib/i386/native_threads:/usr/java/jdk1.6.0_03/jre/lib/i386&lt;br /&gt;
real    0m0.024s&lt;br /&gt;
user    0m0.020s&lt;br /&gt;
sys     0m0.000s&lt;br /&gt;
$ time opt/openoffice.org3/program/../basis-link/program/pagein &amp;quot;-L${PWD?}/opt/openoffice.org3/program/../basis-link/program&amp;quot; @pagein-common&lt;br /&gt;
real    0m0.102s&lt;br /&gt;
user    0m0.020s&lt;br /&gt;
sys     0m0.080s&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ELF Dynamic Objects ==&lt;br /&gt;
&lt;br /&gt;
At least on ELF based systems, one factor that controls how much of a dynamic library needs to be loaded in initially are the relocations in the &amp;lt;code&amp;gt;.rel.dyn&amp;lt;/code&amp;gt; section (the &amp;lt;code&amp;gt;.rel.plt&amp;lt;/code&amp;gt; section is not relevant directly at load time unless you force &amp;lt;code&amp;gt;LD_BIND_NOW&amp;lt;/code&amp;gt;).  The following gives the number of relocations per ELF dynamic object in a &amp;lt;code&amp;gt;DEV300m41&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;unxlngi6.pro&amp;lt;/code&amp;gt; OOo installation (&amp;lt;code&amp;gt;libicudata.so.40.0&amp;lt;/code&amp;gt; has no relocations), for some rough guiding numbers:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd DEV300m41-unxlngi6.pro-en_US &amp;amp;&amp;amp; find opt -type f -exec bash -c &amp;#039;file &amp;quot;$0&amp;quot; | fgrep -q &amp;quot; ELF &amp;quot; &amp;amp;&amp;amp; echo $(readelf -r &amp;quot;$0&amp;quot; | grep &amp;quot;^Relocation section .*rel.dyn&amp;quot; | cut -d &amp;quot; &amp;quot; -f 8) &amp;quot;$0&amp;quot;&amp;#039; {} \; | sort -n&lt;br /&gt;
opt/openoffice.org/basis3.0/program/libicudata.so.40.0&lt;br /&gt;
1 opt/openoffice.org/basis3.0/program/python.bin&lt;br /&gt;
2 opt/openoffice.org/basis3.0/program/gnome-open-url.bin&lt;br /&gt;
2 opt/openoffice.org/basis3.0/program/pagein&lt;br /&gt;
2 opt/openoffice.org/basis3.0/program/uri-encode&lt;br /&gt;
3 opt/openoffice.org3/program/crash_report.bin&lt;br /&gt;
3 opt/openoffice.org/basis3.0/program/msfontextract&lt;br /&gt;
6 opt/openoffice.org/basis3.0/program/pyuno.so&lt;br /&gt;
7 opt/openoffice.org/basis3.0/program/libprldap50.so&lt;br /&gt;
7 opt/openoffice.org/basis3.0/program/libtextcat.so&lt;br /&gt;
8 opt/openoffice.org3/program/soffice.bin&lt;br /&gt;
8 opt/openoffice.org3/program/unopkg.bin&lt;br /&gt;
8 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/crypt.so&lt;br /&gt;
10 opt/openoffice.org/ure/bin/regmerge&lt;br /&gt;
10 opt/openoffice.org/ure/bin/regview&lt;br /&gt;
10 opt/openoffice.org/ure/lib/libgcc_s.so.1&lt;br /&gt;
11 opt/openoffice.org/basis3.0/program/libcollator_data.so&lt;br /&gt;
11 opt/openoffice.org/basis3.0/program/libdict_ja.so&lt;br /&gt;
11 opt/openoffice.org/basis3.0/program/libdict_zh.so&lt;br /&gt;
11 opt/openoffice.org/basis3.0/program/liberali.so&lt;br /&gt;
11 opt/openoffice.org/basis3.0/program/libetili.so&lt;br /&gt;
11 opt/openoffice.org/basis3.0/program/libexpli.so&lt;br /&gt;
11 opt/openoffice.org/basis3.0/program/libicdli.so&lt;br /&gt;
11 opt/openoffice.org/basis3.0/program/libimeli.so&lt;br /&gt;
11 opt/openoffice.org/basis3.0/program/libipbli.so&lt;br /&gt;
11 opt/openoffice.org/basis3.0/program/libipdli.so&lt;br /&gt;
11 opt/openoffice.org/basis3.0/program/libipsli.so&lt;br /&gt;
11 opt/openoffice.org/basis3.0/program/libiptli.so&lt;br /&gt;
11 opt/openoffice.org/basis3.0/program/libipxli.so&lt;br /&gt;
11 opt/openoffice.org/basis3.0/program/libirali.so&lt;br /&gt;
11 opt/openoffice.org/basis3.0/program/libitgli.so&lt;br /&gt;
11 opt/openoffice.org/basis3.0/program/libofficebean.so&lt;br /&gt;
11 opt/openoffice.org/basis3.0/program/libtextconv_dict.so&lt;br /&gt;
11 opt/openoffice.org/ure/bin/javaldx&lt;br /&gt;
11 opt/openoffice.org/ure/lib/libjpipe.so&lt;br /&gt;
12 opt/openoffice.org/ure/bin/regcomp.bin&lt;br /&gt;
13 opt/openoffice.org/basis3.0/program/gengal.bin&lt;br /&gt;
13 opt/openoffice.org/basis3.0/program/libaggli.so&lt;br /&gt;
13 opt/openoffice.org/basis3.0/program/nsplugin&lt;br /&gt;
14 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/rgbimg.so&lt;br /&gt;
14 opt/openoffice.org/ure/bin/uno.bin&lt;br /&gt;
15 opt/openoffice.org/basis3.0/program/libitili.so&lt;br /&gt;
15 opt/openoffice.org/basis3.0/program/pluginapp.bin&lt;br /&gt;
15 opt/openoffice.org/basis3.0/program/spadmin.bin&lt;br /&gt;
16 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/timing.so&lt;br /&gt;
16 opt/openoffice.org/ure/lib/libjuh.so&lt;br /&gt;
17 opt/openoffice.org/basis3.0/program/libplds4.so&lt;br /&gt;
18 opt/openoffice.org/basis3.0/program/libi18nregexpgcc3.so&lt;br /&gt;
18 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/syslog.so&lt;br /&gt;
19 opt/openoffice.org/ure/lib/librmcxt.so.3&lt;br /&gt;
20 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/_weakref.so&lt;br /&gt;
21 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/fcntl.so&lt;br /&gt;
22 opt/openoffice.org/basis3.0/program/libi18nisolang1gcc3.so&lt;br /&gt;
22 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/dl.so&lt;br /&gt;
23 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/rotor.so&lt;br /&gt;
24 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/xreadlines.so&lt;br /&gt;
27 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/grp.so&lt;br /&gt;
27 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/nis.so&lt;br /&gt;
27 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/pcre.so&lt;br /&gt;
28 opt/openoffice.org3/program/libnpsoplugin.so&lt;br /&gt;
29 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/md5.so&lt;br /&gt;
29 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/sha.so&lt;br /&gt;
30 opt/openoffice.org/basis3.0/program/fpicker.uno.so&lt;br /&gt;
30 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/select.so&lt;br /&gt;
32 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/_random.so&lt;br /&gt;
33 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/pwd.so&lt;br /&gt;
33 opt/openoffice.org/basis3.0/program/pythonloader.uno.so&lt;br /&gt;
34 opt/openoffice.org/basis3.0/program/desktopbe1.uno.so&lt;br /&gt;
34 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/_ssl.so&lt;br /&gt;
35 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/dbm.so&lt;br /&gt;
35 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/imageop.so&lt;br /&gt;
37 opt/openoffice.org/basis3.0/program/libindex_data.so&lt;br /&gt;
38 opt/openoffice.org/basis3.0/program/libjli_g.so&lt;br /&gt;
38 opt/openoffice.org/basis3.0/program/libmozz.so&lt;br /&gt;
40 opt/openoffice.org/ure/lib/libuno_salhelpergcc3.so.3&lt;br /&gt;
41 opt/openoffice.org/basis3.0/program/libi18nutilgcc3.so&lt;br /&gt;
42 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/gdbm.so&lt;br /&gt;
42 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/linuxaudiodev.so&lt;br /&gt;
42 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/regex.so&lt;br /&gt;
44 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/zlib.so&lt;br /&gt;
45 opt/openoffice.org/basis3.0/program/libbf_ofali.so&lt;br /&gt;
46 opt/openoffice.org/ure/lib/libunsafe_uno_uno.so&lt;br /&gt;
47 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/_testcapi.so&lt;br /&gt;
47 opt/openoffice.org/ure/lib/libuno_cppu.so.3&lt;br /&gt;
51 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/resource.so&lt;br /&gt;
52 opt/openoffice.org/ure/lib/libjvmfwk.so.3&lt;br /&gt;
54 opt/openoffice.org/basis3.0/program/components/libvcard.so&lt;br /&gt;
54 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/time.so&lt;br /&gt;
54 opt/openoffice.org/ure/lib/libuno_purpenvhelpergcc3.so.3&lt;br /&gt;
55 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/audioop.so&lt;br /&gt;
55 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/cmath.so&lt;br /&gt;
55 opt/openoffice.org/basis3.0/program/testtool.bin&lt;br /&gt;
58 opt/openoffice.org/ure/lib/libgcc3_uno.so&lt;br /&gt;
60 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/mmap.so&lt;br /&gt;
62 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/binascii.so&lt;br /&gt;
63 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/mpz.so&lt;br /&gt;
66 opt/openoffice.org/basis3.0/program/libbf_goli.so&lt;br /&gt;
66 opt/openoffice.org/ure/lib/libjava_uno.so&lt;br /&gt;
69 opt/openoffice.org/ure/lib/libjvmaccessgcc3.so.3&lt;br /&gt;
76 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/strop.so&lt;br /&gt;
81 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/_csv.so&lt;br /&gt;
86 opt/openoffice.org/basis3.0/program/librdf.so.0.0.0&lt;br /&gt;
86 opt/openoffice.org/ure/lib/libaffine_uno_uno.so&lt;br /&gt;
87 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/_hotshot.so&lt;br /&gt;
89 opt/openoffice.org/basis3.0/program/libplc4.so&lt;br /&gt;
91 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/parser.so&lt;br /&gt;
97 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/cPickle.so&lt;br /&gt;
97 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/_locale.so&lt;br /&gt;
97 opt/openoffice.org/ure/lib/libreg.so.3&lt;br /&gt;
98 opt/openoffice.org/basis3.0/program/libxslt.so.1.1.24&lt;br /&gt;
100 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/struct.so&lt;br /&gt;
103 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/math.so&lt;br /&gt;
116 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/bz2.so&lt;br /&gt;
116 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/cStringIO.so&lt;br /&gt;
125 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/ossaudiodev.so&lt;br /&gt;
128 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/itertools.so&lt;br /&gt;
132 opt/openoffice.org/basis3.0/program/libcurl.so.3.0.0&lt;br /&gt;
133 opt/openoffice.org/basis3.0/program/libldap50.so&lt;br /&gt;
145 opt/openoffice.org/basis3.0/program/libicgli.so&lt;br /&gt;
151 opt/openoffice.org/ure/lib/liburp_uno.so&lt;br /&gt;
152 opt/openoffice.org/basis3.0/program/libtfuli.so&lt;br /&gt;
152 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/array.so&lt;br /&gt;
153 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/_socket.so&lt;br /&gt;
161 opt/openoffice.org/ure/lib/namingservice.uno.so&lt;br /&gt;
163 opt/openoffice.org/basis3.0/program/libepbli.so&lt;br /&gt;
163 opt/openoffice.org/basis3.0/program/libepgli.so&lt;br /&gt;
163 opt/openoffice.org/basis3.0/program/libeppli.so&lt;br /&gt;
164 opt/openoffice.org/basis3.0/program/libegili.so&lt;br /&gt;
164 opt/openoffice.org/ure/lib/remotebridge.uno.so&lt;br /&gt;
166 opt/openoffice.org/basis3.0/program/libemeli.so&lt;br /&gt;
166 opt/openoffice.org/basis3.0/program/libeptli.so&lt;br /&gt;
168 opt/openoffice.org/ure/lib/uuresolver.uno.so&lt;br /&gt;
169 opt/openoffice.org/basis3.0/program/libsmdli.so&lt;br /&gt;
170 opt/openoffice.org/basis3.0/program/i18nsearch.uno.so&lt;br /&gt;
170 opt/openoffice.org/basis3.0/program/libswdli.so&lt;br /&gt;
171 opt/openoffice.org/basis3.0/program/libsddli.so&lt;br /&gt;
171 opt/openoffice.org/basis3.0/program/syssh.uno.so&lt;br /&gt;
173 opt/openoffice.org/ure/lib/javaloader.uno.so&lt;br /&gt;
175 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/unicodedata.so&lt;br /&gt;
182 opt/openoffice.org/basis3.0/program/ucpexpand1.uno.so&lt;br /&gt;
185 opt/openoffice.org/basis3.0/program/libmozabli.so&lt;br /&gt;
187 opt/openoffice.org/basis3.0/program/libxmlfdli.so&lt;br /&gt;
188 opt/openoffice.org/ure/lib/invocadapt.uno.so&lt;br /&gt;
189 opt/openoffice.org/ure/lib/proxyfac.uno.so&lt;br /&gt;
191 opt/openoffice.org/basis3.0/program/libscdli.so&lt;br /&gt;
198 opt/openoffice.org/basis3.0/program/canvasfactory.uno.so&lt;br /&gt;
199 opt/openoffice.org/basis3.0/program/behelper.uno.so&lt;br /&gt;
199 opt/openoffice.org/basis3.0/program/libsimplecmli.so&lt;br /&gt;
201 opt/openoffice.org/basis3.0/program/libodbcli.so&lt;br /&gt;
208 opt/openoffice.org/ure/lib/textoutstream.uno.so&lt;br /&gt;
210 opt/openoffice.org/basis3.0/program/libcommunili.so&lt;br /&gt;
212 opt/openoffice.org/basis3.0/program/libguesslangli.so&lt;br /&gt;
214 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/_bsddb.so&lt;br /&gt;
218 opt/openoffice.org/ure/lib/bridgefac.uno.so&lt;br /&gt;
220 opt/openoffice.org/basis3.0/program/components/libxpcom_compat_c.so&lt;br /&gt;
221 opt/openoffice.org/basis3.0/program/libidxli.so&lt;br /&gt;
221 opt/openoffice.org/ure/lib/libjuhx.so&lt;br /&gt;
227 opt/openoffice.org/basis3.0/program/libplacewareli.so&lt;br /&gt;
233 opt/openoffice.org/ure/lib/sunjavaplugin.so&lt;br /&gt;
237 opt/openoffice.org/basis3.0/program/liboffaccli.so&lt;br /&gt;
238 opt/openoffice.org/basis3.0/program/libxmxli.so&lt;br /&gt;
240 opt/openoffice.org/basis3.0/program/libepsli.so&lt;br /&gt;
241 opt/openoffice.org/ure/lib/textinstream.uno.so&lt;br /&gt;
242 opt/openoffice.org/basis3.0/program/libkab1.so&lt;br /&gt;
242 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/operator.so&lt;br /&gt;
245 opt/openoffice.org/basis3.0/program/components/libprofile.so&lt;br /&gt;
245 opt/openoffice.org/basis3.0/program/libmcnttype.so&lt;br /&gt;
246 opt/openoffice.org/basis3.0/program/libprotocolhandlerli.so&lt;br /&gt;
249 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/termios.so&lt;br /&gt;
251 opt/openoffice.org/basis3.0/program/libsmime3.so&lt;br /&gt;
252 opt/openoffice.org/basis3.0/program/localebe1.uno.so&lt;br /&gt;
253 opt/openoffice.org/basis3.0/program/sysmgr1.uno.so&lt;br /&gt;
257 opt/openoffice.org/basis3.0/program/libbf_migratefilterli.so&lt;br /&gt;
262 opt/openoffice.org/basis3.0/program/libssl3.so&lt;br /&gt;
266 opt/openoffice.org/basis3.0/program/librecentfile.so&lt;br /&gt;
284 opt/openoffice.org/basis3.0/program/liboooimprovecoreli.so&lt;br /&gt;
284 opt/openoffice.org/basis3.0/program/libvclplug_kdeli.so&lt;br /&gt;
297 opt/openoffice.org/basis3.0/program/libsaxli.so&lt;br /&gt;
303 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/datetime.so&lt;br /&gt;
310 opt/openoffice.org/basis3.0/program/libbindetli.so&lt;br /&gt;
318 opt/openoffice.org/basis3.0/program/libxmlfali.so&lt;br /&gt;
323 opt/openoffice.org/basis3.0/program/libpyuno.so&lt;br /&gt;
323 opt/openoffice.org/basis3.0/program/libsolverli.so&lt;br /&gt;
337 opt/openoffice.org/basis3.0/program/libxsltfilterli.so&lt;br /&gt;
347 opt/openoffice.org/basis3.0/program/libdb-4.2.so&lt;br /&gt;
348 opt/openoffice.org/ure/lib/connector.uno.so&lt;br /&gt;
352 opt/openoffice.org/basis3.0/program/cmdmail.uno.so&lt;br /&gt;
354 opt/openoffice.org/basis3.0/program/gconfbe1.uno.so&lt;br /&gt;
356 opt/openoffice.org/ure/lib/acceptor.uno.so&lt;br /&gt;
357 opt/openoffice.org/basis3.0/program/libbasegfxli.so&lt;br /&gt;
361 opt/openoffice.org/basis3.0/program/libsdbc2.so&lt;br /&gt;
373 opt/openoffice.org/basis3.0/program/libfwlli.so&lt;br /&gt;
375 opt/openoffice.org/basis3.0/program/passwordcontainer.uno.so&lt;br /&gt;
376 opt/openoffice.org/basis3.0/program/libbf_wrapperli.so&lt;br /&gt;
386 opt/openoffice.org/basis3.0/program/libdeploymentmiscli.so&lt;br /&gt;
388 opt/openoffice.org/basis3.0/program/libupdchkli.so&lt;br /&gt;
389 opt/openoffice.org/basis3.0/program/kdebe1.uno.so&lt;br /&gt;
393 opt/openoffice.org/basis3.0/program/libt602filterli.so&lt;br /&gt;
394 opt/openoffice.org/basis3.0/program/libhelplinkerli.so&lt;br /&gt;
395 opt/openoffice.org/basis3.0/program/libevtatt.so&lt;br /&gt;
408 opt/openoffice.org/basis3.0/program/productregistration.uno.so&lt;br /&gt;
410 opt/openoffice.org/basis3.0/program/libunopkgapp.so&lt;br /&gt;
415 opt/openoffice.org/basis3.0/program/libsvgfilterli.so&lt;br /&gt;
419 opt/openoffice.org/basis3.0/program/components/libmozldap.so&lt;br /&gt;
419 opt/openoffice.org/basis3.0/program/librasqal.so.0.0.0&lt;br /&gt;
422 opt/openoffice.org/basis3.0/program/libhyphenli.so&lt;br /&gt;
429 opt/openoffice.org/basis3.0/program/libdateli.so&lt;br /&gt;
432 opt/openoffice.org/basis3.0/program/libxpcom_compat.so&lt;br /&gt;
438 opt/openoffice.org/basis3.0/program/libucppkg1.so&lt;br /&gt;
461 opt/openoffice.org/basis3.0/program/simplecanvas.uno.so&lt;br /&gt;
465 opt/openoffice.org/basis3.0/program/liblnthli.so&lt;br /&gt;
468 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/pyexpat.so&lt;br /&gt;
472 opt/openoffice.org/basis3.0/program/libresli.so&lt;br /&gt;
478 opt/openoffice.org/ure/lib/invocation.uno.so&lt;br /&gt;
493 opt/openoffice.org/basis3.0/program/libpreloadli.so&lt;br /&gt;
496 opt/openoffice.org/basis3.0/program/ucpgvfs1.uno.so&lt;br /&gt;
497 opt/openoffice.org/basis3.0/program/libraptor.so.1.1.0&lt;br /&gt;
499 opt/openoffice.org/basis3.0/program/migrationoo2.uno.so&lt;br /&gt;
502 opt/openoffice.org/basis3.0/program/libicule.so.40.0&lt;br /&gt;
502 opt/openoffice.org/basis3.0/program/libspellli.so&lt;br /&gt;
503 opt/openoffice.org/basis3.0/program/components/libpref.so&lt;br /&gt;
507 opt/openoffice.org/ure/lib/libstore.so.3&lt;br /&gt;
524 opt/openoffice.org/basis3.0/program/fastsax.uno.so&lt;br /&gt;
543 opt/openoffice.org/basis3.0/program/ldapbe2.uno.so&lt;br /&gt;
547 opt/openoffice.org/basis3.0/program/libfileacc.so&lt;br /&gt;
553 opt/openoffice.org/basis3.0/program/updatefeed.uno.so&lt;br /&gt;
557 opt/openoffice.org/basis3.0/program/libnspr4.so&lt;br /&gt;
571 opt/openoffice.org/basis3.0/program/liblpsolve55.so&lt;br /&gt;
574 opt/openoffice.org/basis3.0/program/libdbacfgli.so&lt;br /&gt;
586 opt/openoffice.org/basis3.0/program/libtvhlp1.so&lt;br /&gt;
590 opt/openoffice.org/ure/lib/javavm.uno.so&lt;br /&gt;
592 opt/openoffice.org/basis3.0/program/libforli.so&lt;br /&gt;
593 opt/openoffice.org/basis3.0/program/basprovli.uno.so&lt;br /&gt;
597 opt/openoffice.org/basis3.0/program/libsrtrs1.so&lt;br /&gt;
599 opt/openoffice.org/ure/lib/introspection.uno.so&lt;br /&gt;
615 opt/openoffice.org/basis3.0/program/libfwmli.so&lt;br /&gt;
623 opt/openoffice.org/basis3.0/program/hatchwindowfactory.uno.so&lt;br /&gt;
624 opt/openoffice.org/basis3.0/program/libvos3gcc3.so&lt;br /&gt;
627 opt/openoffice.org/basis3.0/program/libvclplug_svpli.so&lt;br /&gt;
630 opt/openoffice.org/basis3.0/program/libadabasuili.so&lt;br /&gt;
644 opt/openoffice.org/basis3.0/program/libscnli.so&lt;br /&gt;
664 opt/openoffice.org/basis3.0/program/libbasebmpli.so&lt;br /&gt;
681 opt/openoffice.org/basis3.0/program/libvclplug_gtkli.so&lt;br /&gt;
685 opt/openoffice.org/basis3.0/program/libfwili.so&lt;br /&gt;
687 opt/openoffice.org/basis3.0/program/dlgprovli.uno.so&lt;br /&gt;
697 opt/openoffice.org/basis3.0/program/libucphier1.so&lt;br /&gt;
713 opt/openoffice.org/basis3.0/program/libflashli.so&lt;br /&gt;
725 opt/openoffice.org/basis3.0/program/fsstorage.uno.so&lt;br /&gt;
752 opt/openoffice.org/basis3.0/program/libdbpool2.so&lt;br /&gt;
752 opt/openoffice.org/basis3.0/program/sax.uno.so&lt;br /&gt;
780 opt/openoffice.org/basis3.0/program/libempli.so&lt;br /&gt;
784 opt/openoffice.org/basis3.0/program/fps_gnome.uno.so&lt;br /&gt;
790 opt/openoffice.org/basis3.0/program/libtextconversiondlgsli.so&lt;br /&gt;
833 opt/openoffice.org/basis3.0/program/updchk.uno.so&lt;br /&gt;
837 opt/openoffice.org/basis3.0/program/libcanvastoolsli.so&lt;br /&gt;
843 opt/openoffice.org/basis3.0/program/libsdbtli.so&lt;br /&gt;
850 opt/openoffice.org/basis3.0/program/libgoli.so&lt;br /&gt;
880 opt/openoffice.org/basis3.0/program/svtmisc.uno.so&lt;br /&gt;
886 opt/openoffice.org/basis3.0/program/libscriptframe.so&lt;br /&gt;
902 opt/openoffice.org/basis3.0/program/liblogli.so&lt;br /&gt;
906 opt/openoffice.org/ure/lib/reflection.uno.so&lt;br /&gt;
925 opt/openoffice.org/basis3.0/program/libanalysisli.so&lt;br /&gt;
971 opt/openoffice.org/basis3.0/program/libsoftokn3.so&lt;br /&gt;
979 opt/openoffice.org/basis3.0/program/libpdffilterli.so&lt;br /&gt;
984 opt/openoffice.org/basis3.0/program/libemboleobj.so&lt;br /&gt;
999 opt/openoffice.org/basis3.0/program/libabpli.so&lt;br /&gt;
999 opt/openoffice.org/basis3.0/program/libnss3.so&lt;br /&gt;
1006 opt/openoffice.org/basis3.0/program/libtlli.so&lt;br /&gt;
1018 opt/openoffice.org/basis3.0/program/liblegacy_binfiltersli.so&lt;br /&gt;
1046 opt/openoffice.org/basis3.0/program/stocservices.uno.so&lt;br /&gt;
1046 opt/openoffice.org/ure/lib/stocservices.uno.so&lt;br /&gt;
1068 opt/openoffice.org/basis3.0/program/libavmediali.so&lt;br /&gt;
1076 opt/openoffice.org/basis3.0/program/libucpftp1.so&lt;br /&gt;
1134 opt/openoffice.org/basis3.0/program/components/librdf.so&lt;br /&gt;
1134 opt/openoffice.org/basis3.0/program/libunordfli.so&lt;br /&gt;
1139 opt/openoffice.org/basis3.0/program/libfilterconfig1.so&lt;br /&gt;
1179 opt/openoffice.org/basis3.0/program/libdtransX11li.so&lt;br /&gt;
1193 opt/openoffice.org/basis3.0/program/libdbaxmlli.so&lt;br /&gt;
1229 opt/openoffice.org/basis3.0/program/libdbmmli.so&lt;br /&gt;
1249 opt/openoffice.org/basis3.0/program/ucptdoc1.uno.so&lt;br /&gt;
1287 opt/openoffice.org/basis3.0/program/libforuili.so&lt;br /&gt;
1305 opt/openoffice.org/basis3.0/program/libcached1.so&lt;br /&gt;
1310 opt/openoffice.org/basis3.0/program/libsplli.so&lt;br /&gt;
1318 opt/openoffice.org/basis3.0/program/stringresourceli.uno.so&lt;br /&gt;
1362 opt/openoffice.org/basis3.0/program/libstsli.so&lt;br /&gt;
1363 opt/openoffice.org/basis3.0/program/libmozjs.so&lt;br /&gt;
1368 opt/openoffice.org/basis3.0/program/libucpchelp1.so&lt;br /&gt;
1381 opt/openoffice.org/basis3.0/program/components/libi18n.so&lt;br /&gt;
1400 opt/openoffice.org/basis3.0/program/libucb1.so&lt;br /&gt;
1435 opt/openoffice.org/basis3.0/program/libucpfile1.so&lt;br /&gt;
1447 opt/openoffice.org/basis3.0/program/libpspli.so&lt;br /&gt;
1483 opt/openoffice.org/basis3.0/program/libxstor.so&lt;br /&gt;
1484 opt/openoffice.org/ure/lib/streams.uno.so&lt;br /&gt;
1499 opt/openoffice.org/basis3.0/program/libmysqlli.so&lt;br /&gt;
1510 opt/openoffice.org/basis3.0/program/libchartviewli.so&lt;br /&gt;
1546 opt/openoffice.org/basis3.0/program/libembobj.so&lt;br /&gt;
1586 opt/openoffice.org/basis3.0/program/components/libpipnss.so&lt;br /&gt;
1589 opt/openoffice.org/basis3.0/program/libcppcanvasli.so&lt;br /&gt;
1644 opt/openoffice.org/basis3.0/program/libplli.so&lt;br /&gt;
1669 opt/openoffice.org/basis3.0/program/libsotli.so&lt;br /&gt;
1669 opt/openoffice.org/basis3.0/program/libxsltdlgli.so&lt;br /&gt;
1697 opt/openoffice.org/basis3.0/program/libhwp.so&lt;br /&gt;
1697 opt/openoffice.org/basis3.0/program/libsofficeapp.so&lt;br /&gt;
1699 opt/openoffice.org/ure/lib/libstlport_gcc.so&lt;br /&gt;
1717 opt/openoffice.org/basis3.0/program/libxofli.so&lt;br /&gt;
1721 opt/openoffice.org/basis3.0/program/libxsec_fw.so&lt;br /&gt;
1726 opt/openoffice.org/basis3.0/program/components/libmork.so&lt;br /&gt;
1798 opt/openoffice.org/basis3.0/program/libctlli.so&lt;br /&gt;
1806 opt/openoffice.org/ure/lib/libuno_cppuhelpergcc3.so.3&lt;br /&gt;
1820 opt/openoffice.org/basis3.0/program/libvclplug_genli.so&lt;br /&gt;
1828 opt/openoffice.org/basis3.0/program/libuuili.so&lt;br /&gt;
1837 opt/openoffice.org/basis3.0/program/fps_office.uno.so&lt;br /&gt;
1869 opt/openoffice.org/basis3.0/program/libmsgbaseutil.so&lt;br /&gt;
1926 opt/openoffice.org/basis3.0/program/libxsec_xmlsec.so&lt;br /&gt;
1941 opt/openoffice.org/basis3.0/program/libfweli.so&lt;br /&gt;
1960 opt/openoffice.org/basis3.0/program/libflatli.so&lt;br /&gt;
1995 opt/openoffice.org/basis3.0/program/libevoabli.so&lt;br /&gt;
1996 opt/openoffice.org/basis3.0/program/libcalcli.so&lt;br /&gt;
2010 opt/openoffice.org/basis3.0/program/libdbpli.so&lt;br /&gt;
2011 opt/openoffice.org/basis3.0/program/libxmlsecurity.so&lt;br /&gt;
2057 opt/openoffice.org/basis3.0/program/libucbhelper4gcc3.so&lt;br /&gt;
2062 opt/openoffice.org/basis3.0/program/components/libxpconnect.so&lt;br /&gt;
2064 opt/openoffice.org/basis3.0/program/libpackage2.so&lt;br /&gt;
2129 opt/openoffice.org/basis3.0/program/libhsqldb.so&lt;br /&gt;
2168 opt/openoffice.org/basis3.0/program/libanimcore.so&lt;br /&gt;
2276 opt/openoffice.org/basis3.0/program/components/libuconv.so&lt;br /&gt;
2311 opt/openoffice.org/basis3.0/program/libspali.so&lt;br /&gt;
2327 opt/openoffice.org/basis3.0/program/libmswordli.so&lt;br /&gt;
2408 opt/openoffice.org/basis3.0/program/deploymentguili.uno.so&lt;br /&gt;
2432 opt/openoffice.org/basis3.0/program/libdbaseli.so&lt;br /&gt;
2457 opt/openoffice.org/basis3.0/program/libbibli.so&lt;br /&gt;
2460 opt/openoffice.org/ure/lib/libstdc++.so.6&lt;br /&gt;
2694 opt/openoffice.org/basis3.0/program/libutlli.so&lt;br /&gt;
2865 opt/openoffice.org/basis3.0/program/libodbcbaseli.so&lt;br /&gt;
2928 opt/openoffice.org/basis3.0/program/libwpftli.so&lt;br /&gt;
3029 opt/openoffice.org/basis3.0/program/libbf_smli.so&lt;br /&gt;
3104 opt/openoffice.org/basis3.0/program/libxcrli.so&lt;br /&gt;
3198 opt/openoffice.org/ure/lib/libxml2.so.2&lt;br /&gt;
3233 opt/openoffice.org/basis3.0/program/libsvlli.so&lt;br /&gt;
3245 opt/openoffice.org/basis3.0/program/components/libaddrbook.so&lt;br /&gt;
3287 opt/openoffice.org/basis3.0/program/libkabdrv1.so&lt;br /&gt;
3337 opt/openoffice.org/basis3.0/program/liblngli.so&lt;br /&gt;
3357 opt/openoffice.org/basis3.0/program/libmozabdrvli.so&lt;br /&gt;
3432 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/_curses_panel.so&lt;br /&gt;
3445 opt/openoffice.org/basis3.0/program/libadabasli.so&lt;br /&gt;
3730 opt/openoffice.org/basis3.0/program/libjdbcli.so&lt;br /&gt;
3784 opt/openoffice.org/basis3.0/program/libicui18n.so.40.0&lt;br /&gt;
3821 opt/openoffice.org/basis3.0/program/libdrawinglayerli.so&lt;br /&gt;
3906 opt/openoffice.org/basis3.0/program/libfileli.so&lt;br /&gt;
3970 opt/openoffice.org/basis3.0/program/libsduili.so&lt;br /&gt;
4075 opt/openoffice.org/basis3.0/program/libpython2.3.so.1.0&lt;br /&gt;
4097 opt/openoffice.org/basis3.0/program/deploymentli.uno.so&lt;br /&gt;
4150 opt/openoffice.org/basis3.0/program/libicuuc.so.40.0&lt;br /&gt;
4302 opt/openoffice.org/basis3.0/program/libxpcom.so&lt;br /&gt;
4319 opt/openoffice.org/basis3.0/program/liblocaledata_es.so&lt;br /&gt;
4502 opt/openoffice.org/basis3.0/program/liblocaledata_en.so&lt;br /&gt;
4663 opt/openoffice.org/ure/lib/libuno_sal.so.3&lt;br /&gt;
4676 opt/openoffice.org/ure/lib/bootstrap.uno.so&lt;br /&gt;
4722 opt/openoffice.org/basis3.0/program/components/libnecko.so&lt;br /&gt;
4982 opt/openoffice.org/basis3.0/program/libbf_soli.so&lt;br /&gt;
5013 opt/openoffice.org/basis3.0/program/libcharttoolsli.so&lt;br /&gt;
5256 opt/openoffice.org/basis3.0/program/libsmli.so&lt;br /&gt;
5374 opt/openoffice.org/basis3.0/program/python-core-2.3.4/lib/lib-dynload/_curses.so&lt;br /&gt;
5540 opt/openoffice.org/basis3.0/program/libbf_sbli.so&lt;br /&gt;
5811 opt/openoffice.org/basis3.0/program/slideshow.uno.so&lt;br /&gt;
6012 opt/openoffice.org/basis3.0/program/libbf_schli.so&lt;br /&gt;
6353 opt/openoffice.org/basis3.0/program/vclcanvas.uno.so&lt;br /&gt;
6481 opt/openoffice.org/basis3.0/program/libunoxmlli.so&lt;br /&gt;
6551 opt/openoffice.org/basis3.0/program/libscuili.so&lt;br /&gt;
6667 opt/openoffice.org/basis3.0/program/libscfiltli.so&lt;br /&gt;
6725 opt/openoffice.org/basis3.0/program/libcomphelp4gcc3.so&lt;br /&gt;
6730 opt/openoffice.org/basis3.0/program/libbf_sdli.so&lt;br /&gt;
6982 opt/openoffice.org/basis3.0/program/libbf_svtli.so&lt;br /&gt;
7116 opt/openoffice.org/basis3.0/program/libdbtoolsli.so&lt;br /&gt;
7671 opt/openoffice.org/basis3.0/program/libbasctlli.so&lt;br /&gt;
8414 opt/openoffice.org/basis3.0/program/libchartmodelli.so&lt;br /&gt;
9782 opt/openoffice.org/basis3.0/program/libpcrli.so&lt;br /&gt;
10042 opt/openoffice.org/basis3.0/program/libsbli.so&lt;br /&gt;
10240 opt/openoffice.org/basis3.0/program/libucpdav1.so&lt;br /&gt;
11268 opt/openoffice.org/basis3.0/program/i18npool.uno.so&lt;br /&gt;
11559 opt/openoffice.org/basis3.0/program/libvclli.so&lt;br /&gt;
11657 opt/openoffice.org/basis3.0/program/libfwkli.so&lt;br /&gt;
11915 opt/openoffice.org/basis3.0/program/libaccli.so&lt;br /&gt;
11976 opt/openoffice.org/basis3.0/program/libbf_xoli.so&lt;br /&gt;
12568 opt/openoffice.org/basis3.0/program/libchartcontrollerli.so&lt;br /&gt;
13352 opt/openoffice.org/basis3.0/program/configmgr2.uno.so&lt;br /&gt;
14279 opt/openoffice.org/basis3.0/program/libbf_frmli.so&lt;br /&gt;
15504 opt/openoffice.org/basis3.0/program/libxoli.so&lt;br /&gt;
16083 opt/openoffice.org/basis3.0/program/libdbali.so&lt;br /&gt;
16440 opt/openoffice.org/basis3.0/program/libswuili.so&lt;br /&gt;
18793 opt/openoffice.org/basis3.0/program/libvbaobjli.uno.so&lt;br /&gt;
19218 opt/openoffice.org/basis3.0/program/libcuili.so&lt;br /&gt;
19950 opt/openoffice.org/basis3.0/program/libsfxli.so&lt;br /&gt;
21368 opt/openoffice.org/basis3.0/program/libbf_scli.so&lt;br /&gt;
24233 opt/openoffice.org/basis3.0/program/libsvtli.so&lt;br /&gt;
25860 opt/openoffice.org/basis3.0/program/libfrmli.so&lt;br /&gt;
26811 opt/openoffice.org/basis3.0/program/libbf_swli.so&lt;br /&gt;
27025 opt/openoffice.org/basis3.0/program/libdbuli.so&lt;br /&gt;
31017 opt/openoffice.org/basis3.0/program/liblocaledata_euro.so&lt;br /&gt;
31950 opt/openoffice.org/basis3.0/program/libooxli.so&lt;br /&gt;
32073 opt/openoffice.org/basis3.0/program/libbf_svxli.so&lt;br /&gt;
35190 opt/openoffice.org/basis3.0/program/liblocaledata_others.so&lt;br /&gt;
40816 opt/openoffice.org/basis3.0/program/libtkli.so&lt;br /&gt;
46714 opt/openoffice.org/basis3.0/program/libsdli.so&lt;br /&gt;
49694 opt/openoffice.org/basis3.0/program/libscli.so&lt;br /&gt;
61034 opt/openoffice.org/basis3.0/program/libwriterfilterli.so&lt;br /&gt;
61287 opt/openoffice.org/basis3.0/program/libswli.so&lt;br /&gt;
84341 opt/openoffice.org/basis3.0/program/libsvxli.so&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Measurements =&lt;br /&gt;
&lt;br /&gt;
Measurements are done on a Sun Ultra&amp;amp;nbsp;20 with a recent (as of February 25, 2009) Debian Unstable i386.  The OOo is a &amp;lt;code&amp;gt;sb107/DEV300/src.m41/instsetoo_native/unxlngi6.pro/OpenOffice/archive/install/en-US/OOo_3.0.0_090219_unxlngi6_install.tar.gz&amp;lt;/code&amp;gt; (i.e., [http://eis.services.openoffice.org/EIS2/cws.ShowCWS?Path=DEV300%2Fsb107 CWS sb107] as based on &amp;lt;code&amp;gt;DEV300m41&amp;lt;/code&amp;gt; with just a fix for [http://qa.openoffice.org/issues/show_bug.cgi?id=99519 Issue 99519] included), installed to &amp;lt;code&amp;gt;/sb-tree1/ooo-m107&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;UserInstallation=file:///sb-tree2/ooo-m107/.openoffice.org/3&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;/sb-tree1/ooo-m107/openoffice.org3/program/bootstraprc&amp;lt;/code&amp;gt;, &amp;amp;ldquo;Check for updates automatically&amp;amp;rdquo; disabled, &amp;amp;ldquo;I do not want to register&amp;amp;rdquo; selected (both during first &amp;lt;code&amp;gt;soffice&amp;lt;/code&amp;gt; start), and &amp;amp;ldquo;No, I do not wish to participate&amp;amp;rdquo; selected (during second &amp;lt;code&amp;gt;soffice&amp;lt;/code&amp;gt; start); the working directory is &amp;lt;code&amp;gt;/sb-tree3&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
During &amp;lt;code&amp;gt;soffice.bin&amp;lt;/code&amp;gt; start up, [http://svn.services.openoffice.org/ooo/tags/DEV300_m44/vcl/unx/source/fontmanager/fontconfig.cxx &amp;lt;code&amp;gt;vcl/unx/source/fontmanager/fontconfig.cxx&amp;lt;/code&amp;gt;] l.&amp;amp;nbsp;791 calls [http://fontconfig.org/fontconfig-devel/r2744.html &amp;lt;code&amp;gt;FcConfigAppFontAddDir&amp;lt;/code&amp;gt;] three times (with existing directory &amp;lt;code&amp;gt;/opt/openoffice.org/basis3.2/share/fonts/truetype&amp;lt;/code&amp;gt; and non-existing directories &amp;lt;code&amp;gt;/opt/openoffice.org3/program/../basis-link/share/fonts/type1&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;~/.openoffice.org/3/user/fonts&amp;lt;/code&amp;gt;).  Apparently, during the first &amp;lt;code&amp;gt;soffice&amp;lt;/code&amp;gt; start those directories are actually accessed and data about them stored at &amp;lt;code&amp;gt;~/.fontconfig&amp;lt;/code&amp;gt; (resulting in heavy use of the &amp;lt;code&amp;gt;freetype&amp;lt;/code&amp;gt; dynamic library), while during subsequent starts the cached data is used.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;time&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Just after system start up run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /sb-tree3&lt;br /&gt;
$ time /sb-tree1/ooo-sb107/openoffice.org3/program/soffice -swriter # press Ctrl-Q as soon as the text cursor starts to blink&lt;br /&gt;
$ time /sb-tree1/ooo-sb107/openoffice.org3/program/soffice -swriter # press Ctrl-Q as soon as the text cursor starts to blink&lt;br /&gt;
$ time /sb-tree1/ooo-sb107/openoffice.org3/program/soffice -swriter # press Ctrl-Q as soon as the text cursor starts to blink&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
to get one cold and two warm start-up (plus shut-down) times.  Repeat three times.  The average of the three cold start ups is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
real 0m11.584s&lt;br /&gt;
user 0m2.335s&lt;br /&gt;
sys  0m0.237s&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and the average of the six warm start ups is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
real 0m3.528s&lt;br /&gt;
user 0m2.069s&lt;br /&gt;
sys  0m0.173s&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;strace&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Just after system start up run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /sb-tree3&lt;br /&gt;
$ strace -ff -T -o ~/cold /sb-tree1/ooo-sb107/openoffice.org3/program/soffice -swriter # press Ctrl-Q as soon as the text cursor starts to blink&lt;br /&gt;
$ strace -ff -T -o ~/warma /sb-tree1/ooo-sb107/openoffice.org3/program/soffice -swriter # press Ctrl-Q as soon as the text cursor starts to blink&lt;br /&gt;
$ strace -ff -T -o ~/warmb /sb-tree1/ooo-sb107/openoffice.org3/program/soffice -swriter # press Ctrl-Q as soon as the text cursor starts to blink&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
to get one cold and two warm start-up (plus shut-down) times.  Repeat three times (&amp;lt;code&amp;gt;cold1&amp;lt;/code&amp;gt;&amp;amp;ndash;&amp;lt;code&amp;gt;cold3&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;warm1a&amp;lt;/code&amp;gt;&amp;amp;ndash;&amp;lt;code&amp;gt;warm3b&amp;lt;/code&amp;gt;).  Use&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ for i in cold1.*; do sed &amp;quot;s/^/${i#cold1.} /&amp;quot; &amp;quot;$i&amp;quot;; done | strace-eval &amp;gt; cold1-all&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
(and similarly for the other measurements) with the following &amp;lt;code&amp;gt;strace-eval&amp;lt;/code&amp;gt; Haskell script&lt;br /&gt;
&amp;lt;source lang=&amp;quot;haskell&amp;quot;&amp;gt;&lt;br /&gt;
-- Makefile:&lt;br /&gt;
--  .PHONY: strace-eval&lt;br /&gt;
--  strace-eval:&lt;br /&gt;
--   ghc-6.10.1 --make -o $@ Main.hs&lt;br /&gt;
--&lt;br /&gt;
-- Group strace output system calls by files they operate on:&lt;br /&gt;
--&lt;br /&gt;
-- $ strace -T -o log1 soffice.bin &amp;amp;&amp;amp; strace-eval &amp;lt; log1 &amp;gt; log2&lt;br /&gt;
--&lt;br /&gt;
-- or&lt;br /&gt;
--&lt;br /&gt;
-- $ strace -ff -T -o log1 soffice &amp;amp;&amp;amp; \&lt;br /&gt;
--    for i in log1.*; do sed &amp;quot;s/^/${i#log1.} /&amp;quot; &amp;quot;$i&amp;quot;; done | strace-eval &amp;gt; log2&lt;br /&gt;
&lt;br /&gt;
{-# LANGUAGE ScopedTypeVariables #-}&lt;br /&gt;
&lt;br /&gt;
module Main (main) where&lt;br /&gt;
&lt;br /&gt;
import Data.Map as M&lt;br /&gt;
import GHC.Exts (sortWith)&lt;br /&gt;
import Text.Regex.Posix ((=~))&lt;br /&gt;
&lt;br /&gt;
main :: IO ()&lt;br /&gt;
main = do c &amp;lt;- getContents&lt;br /&gt;
          let cs = lines c&lt;br /&gt;
          let m = process M.empty M.empty cs&lt;br /&gt;
          mapM_ displayFileData $ reverse $ sortWith (fst . snd) $ M.toList m&lt;br /&gt;
&lt;br /&gt;
type FdMap = M.Map (String, Integer) String -- (pid, fd) -&amp;gt; filepath&lt;br /&gt;
&lt;br /&gt;
type FileMap = M.Map FileSpec FileData&lt;br /&gt;
&lt;br /&gt;
data FileSpec = File String&lt;br /&gt;
              | Fd String Integer -- pid, fd&lt;br /&gt;
              | Unknown deriving (Eq, Ord)&lt;br /&gt;
&lt;br /&gt;
type FileData = (Integer, [String]) -- (time, [lines])&lt;br /&gt;
&lt;br /&gt;
process :: FdMap -&amp;gt; FileMap -&amp;gt; [String] -&amp;gt; FileMap&lt;br /&gt;
process _ fm [] = fm&lt;br /&gt;
process fdm fm (c:cs) = process fdm&amp;#039; fm&amp;#039; cs&lt;br /&gt;
    where (fdm&amp;#039;, fm&amp;#039;) = processOne fdm fm c&lt;br /&gt;
&lt;br /&gt;
processOne :: FdMap -&amp;gt; FileMap -&amp;gt; String -&amp;gt; (FdMap, FileMap)&lt;br /&gt;
processOne fdm fm c = case splitLine c of&lt;br /&gt;
                        Just (pid, s, a, r, n) -&amp;gt;&lt;br /&gt;
                            (fdm&amp;#039;, M.insertWith merge fs (n, [c]) fm)&lt;br /&gt;
                            where (fdm&amp;#039;, fs) = parse fdm pid s a r&lt;br /&gt;
                        _ -&amp;gt;&lt;br /&gt;
                            (fdm, M.insertWith merge Unknown (0, [c]) fm)&lt;br /&gt;
    where merge (n&amp;#039;, cs&amp;#039;) (n, cs) = (n + n&amp;#039;, cs ++ cs&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
splitLine :: String -&amp;gt; Maybe (String, String, String, String, Integer)&lt;br /&gt;
splitLine c = case pts of&lt;br /&gt;
                [pid, s, a, r, n1, n2] -&amp;gt;&lt;br /&gt;
                    Just (pid, s, a, r, 1000000 * read n1 + read n2)&lt;br /&gt;
                _ -&amp;gt; Nothing&lt;br /&gt;
    where pts = c =~~~ &amp;quot;^([0-9]+)? *([0-9A-Z_a-z]+)\\((.*)\\) += (.+) &amp;lt;([0-9]+)\\.([0-9][0-9][0-9][0-9][0-9][0-9])&amp;gt;$&amp;quot;&lt;br /&gt;
&lt;br /&gt;
parse :: FdMap -&amp;gt; String -&amp;gt; String -&amp;gt; String -&amp;gt; String -&amp;gt; (FdMap, FileSpec)&lt;br /&gt;
parse fdm pid &amp;quot;_llseek&amp;quot; a _ =&lt;br /&gt;
    (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;accept&amp;quot; a r = case (a&amp;#039;, r&amp;#039;) of&lt;br /&gt;
                           (_, [fd]) -&amp;gt; (fdm, Fd pid $ read fd)&lt;br /&gt;
                           ([fd], _) -&amp;gt; (fdm, findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
          r&amp;#039; = r =~~~ &amp;quot;^([0-9]+)$&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;access&amp;quot; a _ = (fdm, case a&amp;#039; of { (f:_) -&amp;gt; File f; _ -&amp;gt; Unknown })&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^\&amp;quot;(([^\&amp;quot;\\]|\\\\.)*)\&amp;quot;&amp;quot; -- or &amp;quot;^NULL&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;bind&amp;quot; a _ = (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;chdir&amp;quot; a _ = (fdm, case a&amp;#039; of (f:_) -&amp;gt; File f)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^\&amp;quot;(([^\&amp;quot;\\]|\\\\.)*)\&amp;quot;$&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;chmod&amp;quot; a _ = (fdm, case a&amp;#039; of (f:_) -&amp;gt; File f)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^\&amp;quot;(([^\&amp;quot;\\]|\\\\.)*)\&amp;quot;,&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;chown32&amp;quot; a _ = (fdm, case a&amp;#039; of (f:_) -&amp;gt; File f)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^\&amp;quot;(([^\&amp;quot;\\]|\\\\.)*)\&amp;quot;,&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;close&amp;quot; a r =&lt;br /&gt;
    case (a&amp;#039;, r&amp;#039;) of&lt;br /&gt;
      ([fd], [&amp;quot;0&amp;quot;]) -&amp;gt; (M.delete (pid, read fd) fdm, findFile fdm pid $ read fd)&lt;br /&gt;
      ([fd], _) -&amp;gt; (fdm, findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+)$&amp;quot;&lt;br /&gt;
          r&amp;#039; = r =~~~ &amp;quot;^([0-9]+)$&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;connect&amp;quot; a _ =&lt;br /&gt;
    (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;execve&amp;quot; a _ = (fdm, case a&amp;#039; of (f:_) -&amp;gt; File f)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^\&amp;quot;(([^\&amp;quot;\\]|\\\\.)*)\&amp;quot;&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;fcntl64&amp;quot; a _ =&lt;br /&gt;
    (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;fstat64&amp;quot; a _ =&lt;br /&gt;
    (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;fsync&amp;quot; a _ = (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+)$&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;ftruncate&amp;quot; a _ =&lt;br /&gt;
    (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;ftruncate64&amp;quot; a _ =&lt;br /&gt;
    (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;getcwd&amp;quot; a _ = (fdm, case a&amp;#039; of { (f:_) -&amp;gt; File f; _ -&amp;gt; Unknown })&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^\&amp;quot;(([^\&amp;quot;\\]|\\\\.)*)\&amp;quot;&amp;quot; -- or &amp;quot;^NULL&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;getdents64&amp;quot; a _ =&lt;br /&gt;
    (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;getpeername&amp;quot; a _ =&lt;br /&gt;
    (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;getsockname&amp;quot; a _ =&lt;br /&gt;
    (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;ioctl&amp;quot; a _ = (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;link&amp;quot; a _ = (fdm, case a&amp;#039; of (f:_) -&amp;gt; File f)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^\&amp;quot;(([^\&amp;quot;\\]|\\\\.)*)\&amp;quot;&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;listen&amp;quot; a _ =&lt;br /&gt;
    (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;lseek&amp;quot; a _ = (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;lstat64&amp;quot; a _ = (fdm, case a&amp;#039; of (f:_) -&amp;gt; File f)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^\&amp;quot;(([^\&amp;quot;\\]|\\\\.)*)\&amp;quot;&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;mkdir&amp;quot; a _ = (fdm, case a&amp;#039; of (f:_) -&amp;gt; File f)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^\&amp;quot;(([^\&amp;quot;\\]|\\\\.)*)\&amp;quot;&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;mmap2&amp;quot; a _ =&lt;br /&gt;
    (fdm,&lt;br /&gt;
     case a&amp;#039; of [&amp;quot;-1&amp;quot;] -&amp;gt; Unknown&lt;br /&gt;
                [fd] -&amp;gt; findFile fdm pid $ read fd&lt;br /&gt;
                _ -&amp;gt; error a)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;, (-?[0-9]+), -?[0-9a-fx]+$&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;old_mmap&amp;quot; a _ =&lt;br /&gt;
    (fdm,&lt;br /&gt;
     case a&amp;#039; of [&amp;quot;-1&amp;quot;] -&amp;gt; Unknown&lt;br /&gt;
                [fd] -&amp;gt; findFile fdm pid $ read fd&lt;br /&gt;
                _ -&amp;gt; error a)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;, (-?[0-9]+), -?[0-9a-fx]+$&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;open&amp;quot; a r =&lt;br /&gt;
    case (a&amp;#039;, r&amp;#039;) of&lt;br /&gt;
      (f:_, [fd]) -&amp;gt; (M.insertWith (error (&amp;quot;not empty &amp;lt;&amp;quot;++pid++&amp;quot;/&amp;quot;++fd++&amp;quot;, &amp;quot;++a++&amp;quot;, &amp;quot;++r++&amp;quot;&amp;gt;&amp;quot;) . const) (pid, read fd) f&lt;br /&gt;
                       fdm,&lt;br /&gt;
                      File f)&lt;br /&gt;
      (f:_, _) -&amp;gt; (fdm, File f)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^\&amp;quot;(([^\&amp;quot;\\]|\\\\.)*)\&amp;quot;&amp;quot;&lt;br /&gt;
          r&amp;#039; = r =~~~ &amp;quot;^([0-9]+)$&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;pipe&amp;quot; a r =&lt;br /&gt;
    (fdm,&lt;br /&gt;
     case (a&amp;#039;, r) of ([fd, _], &amp;quot;0&amp;quot;) -&amp;gt; findFile fdm pid $ read fd&lt;br /&gt;
                     _ -&amp;gt; Unknown)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^\\[([0-9]+), ([0-9]+)\\]$&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;poll&amp;quot; a _ =&lt;br /&gt;
    (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd) --TODO&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^\\[\\{fd=([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;pread64&amp;quot; a _ =&lt;br /&gt;
    (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;pwrite64&amp;quot; a _ =&lt;br /&gt;
    (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;read&amp;quot; a _ = (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;readlink&amp;quot; a _ = (fdm, case a&amp;#039; of (f:_) -&amp;gt; File f)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^\&amp;quot;(([^\&amp;quot;\\]|\\\\.)*)\&amp;quot;&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;readv&amp;quot; a _ = (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;recv&amp;quot; a _ =&lt;br /&gt;
    (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;recvmsg&amp;quot; a _ =&lt;br /&gt;
    (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;rename&amp;quot; a _ = (fdm, case a&amp;#039; of (f:_) -&amp;gt; File f)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^\&amp;quot;(([^\&amp;quot;\\]|\\\\.)*)\&amp;quot;&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;rmdir&amp;quot; a _ = (fdm, case a&amp;#039; of (f:_) -&amp;gt; File f)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^\&amp;quot;(([^\&amp;quot;\\]|\\\\.)*)\&amp;quot;&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;send&amp;quot; a _ = (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;setsockopt&amp;quot; a _ =&lt;br /&gt;
    (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;shutdown&amp;quot; a _ =&lt;br /&gt;
    (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;socket&amp;quot; a r =&lt;br /&gt;
    case r&amp;#039; of&lt;br /&gt;
      [fd] -&amp;gt; (fdm, Fd pid $ read fd)&lt;br /&gt;
      _ -&amp;gt; (fdm, Unknown)&lt;br /&gt;
    where r&amp;#039; = r =~~~ &amp;quot;^([0-9]+)$&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;stat64&amp;quot; a _ = (fdm, case a&amp;#039; of (f:_) -&amp;gt; File f)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^\&amp;quot;(([^\&amp;quot;\\]|\\\\.)*)\&amp;quot;&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;unlink&amp;quot; a _ = (fdm, case a&amp;#039; of (f:_) -&amp;gt; File f)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^\&amp;quot;(([^\&amp;quot;\\]|\\\\.)*)\&amp;quot;&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;utime&amp;quot; a _ = (fdm, case a&amp;#039; of (f:_) -&amp;gt; File f)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^\&amp;quot;(([^\&amp;quot;\\]|\\\\.)*)\&amp;quot;&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;write&amp;quot; a _ = (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid &amp;quot;writev&amp;quot; a _ =&lt;br /&gt;
    (fdm, case a&amp;#039; of [fd] -&amp;gt; findFile fdm pid $ read fd)&lt;br /&gt;
    where a&amp;#039; = a =~~~ &amp;quot;^([0-9]+),&amp;quot;&lt;br /&gt;
parse fdm pid _ _ _ = (fdm, Unknown)&lt;br /&gt;
&lt;br /&gt;
(=~~~) :: String -&amp;gt; String -&amp;gt; [String]&lt;br /&gt;
a =~~~ b = c&lt;br /&gt;
    where (_::String, _::String, _::String, c) = a =~ b&lt;br /&gt;
&lt;br /&gt;
displayFileData :: (FileSpec, FileData) -&amp;gt; IO ()&lt;br /&gt;
displayFileData (_, (0, [])) = return ()&lt;br /&gt;
displayFileData (s, (n, cs)) = do&lt;br /&gt;
  putStrLn $ showSpec s ++ &amp;quot;: &amp;quot; ++ show n ++ &amp;quot;mu&amp;quot;&lt;br /&gt;
  mapM_ (putStrLn . (&amp;quot;  &amp;quot; ++)) $ cs&lt;br /&gt;
&lt;br /&gt;
showSpec :: FileSpec -&amp;gt; String&lt;br /&gt;
showSpec Unknown = &amp;quot;???&amp;quot;&lt;br /&gt;
showSpec (Fd pid fd) = (if pid == &amp;quot;&amp;quot; then &amp;quot;&amp;quot; else pid ++ &amp;quot;/&amp;quot;) ++ show fd&lt;br /&gt;
showSpec (File f) = &amp;quot;\&amp;quot;&amp;quot; ++ f ++ &amp;quot;\&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
findFile :: FdMap -&amp;gt; String -&amp;gt; Integer -&amp;gt; FileSpec&lt;br /&gt;
findFile fdm pid fd = case M.lookup (pid, fd) fdm of&lt;br /&gt;
                        Just f -&amp;gt; File f&lt;br /&gt;
                        Nothing -&amp;gt; Fd pid fd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to group system calls by the files or file descriptors they work on.  The output is a list of blocks, sorted descending on time spent.  Each block consists of a start line consisting of a file tag, a colon, a space, and an accumulated time, followed by one or more lines (pertaining to the given file tag) from the (combined, in the case of &amp;lt;code&amp;gt;strace -ff -o&amp;lt;/code&amp;gt;) original &amp;lt;code&amp;gt;strace&amp;lt;/code&amp;gt; output (in original order), each prefixed with a space.  A file tag is either a filepath in double quotes, or a &amp;lt;code&amp;gt;&amp;lt;var&amp;gt;pid&amp;lt;/var&amp;gt;/&amp;lt;var&amp;gt;fd&amp;lt;/var&amp;gt;&amp;lt;/code&amp;gt; combination of numeric &amp;lt;code&amp;gt;&amp;lt;var&amp;gt;pid&amp;lt;/var&amp;gt;&amp;lt;/code&amp;gt; and&amp;amp;nbsp;&amp;lt;code&amp;gt;&amp;lt;var&amp;gt;fd&amp;lt;/var&amp;gt;&amp;lt;/code&amp;gt; (for uses of file descriptors that cannot be associated with a filepath; the &amp;amp;ldquo;&amp;lt;code&amp;gt;&amp;lt;var&amp;gt;pid&amp;lt;/var&amp;gt;/&amp;lt;/code&amp;gt;&amp;amp;rdquo; part is left out for &amp;lt;code&amp;gt;strace&amp;lt;/code&amp;gt; calls without&amp;amp;nbsp;&amp;lt;code&amp;gt;-ff&amp;lt;/code&amp;gt;), or &amp;lt;code&amp;gt;???&amp;lt;/code&amp;gt; for all system calls that are not associated with a filepath or file descriptor at all.  The accumulated time is the sum of the times given by &amp;lt;code&amp;gt;strace -T&amp;lt;/code&amp;gt; for the individual lines, measured in microseconds.&lt;br /&gt;
&lt;br /&gt;
For the measured times, take the following into account:&lt;br /&gt;
* The description of the &amp;lt;code&amp;gt;-O&amp;lt;/code&amp;gt; option on the man page of &amp;lt;code&amp;gt;strace&amp;lt;/code&amp;gt;(1) makes you assume that the given numbers are not too accurate.&lt;br /&gt;
* In multi-threaded scenarios, large times for certain system calls naturally need not imply delays in start up (if those delays are compensated for by other threads making progress).&lt;br /&gt;
* Similarly, in multi-process scenarios, large times for certain system calls naturally need not imply delays in start up either (if those delays are compensated for by other processes making progress; this is especially true for large times given for &amp;lt;code&amp;gt;wait&amp;lt;/code&amp;gt;-family system calls that are accumulated under the &amp;lt;code&amp;gt;???&amp;lt;/code&amp;gt; file tag).&lt;br /&gt;
&lt;br /&gt;
The resulting measurements do exhibit some variance, but concentrating on the top listed files (i.e., filtering out mere file descriptors and &amp;lt;code&amp;gt;???&amp;lt;/code&amp;gt;) across cold and warm starts does show trends:&lt;br /&gt;
&lt;br /&gt;
* Accessing the four Berkeley&amp;amp;nbsp;DB files of the extension manager is costly due to &amp;lt;code&amp;gt;fsync&amp;lt;/code&amp;gt; system calls.  However, the costly &amp;lt;code&amp;gt;flush&amp;lt;/code&amp;gt; calls are only made during OOo shut-down, not during start-up.  Typical numbers are for example&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;/sb-tree2/ooo-sb107/.openoffice.org/3/user/uno_packages/cache/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/registered_packages.db&amp;quot;: 167833mu&lt;br /&gt;
&amp;quot;/sb-tree1/ooo-sb107/openoffice.org3/program/../share/uno_packages/cache/uno_packages.db&amp;quot;: 58392mu&lt;br /&gt;
&amp;quot;/sb-tree1/ooo-sb107/openoffice.org3/program/../share/uno_packages/cache/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/registered_packages.db&amp;quot;: 49750mu&lt;br /&gt;
&amp;quot;/sb-tree2/ooo-sb107/.openoffice.org/3/user/uno_packages/cache/uno_packages.db&amp;quot;: 41407mu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Accessing &amp;lt;code&amp;gt;images_tango.zip&amp;lt;/code&amp;gt; is costly due to many small &amp;lt;code&amp;gt;read&amp;lt;/code&amp;gt; system calls.  Typical numbers are for example&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;/sb-tree1/ooo-sb107/openoffice.org3/program/../basis-link/share/config/images_tango.zip&amp;quot;: 119944mu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
for cold start and&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;/sb-tree1/ooo-sb107/openoffice.org3/program/../basis-link/share/config/images_tango.zip&amp;quot;: 18541mu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
for warm start.&lt;br /&gt;
&lt;br /&gt;
* Accessing the directories of the OOo installation is costyl due to many repeated &amp;lt;code&amp;gt;stat&amp;lt;/code&amp;gt;-family system calls.  Typical numbers are for example&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;/sb-tree1&amp;quot;: 21751mu&lt;br /&gt;
&amp;quot;/sb-tree1/ooo-sb107&amp;quot;: 18782mu&lt;br /&gt;
&amp;quot;/sb-tree1/ooo-sb107/openoffice.org3&amp;quot;: 9481mu&lt;br /&gt;
&amp;quot;/sb-tree1/ooo-sb107/openoffice.org3/basis-link&amp;quot;: 2640mu&lt;br /&gt;
&amp;quot;/sb-tree1/ooo-sb107/openoffice.org3/program&amp;quot;: 5238mu&lt;br /&gt;
&amp;quot;/sb-tree1/ooo-sb107/openoffice.org3/program/../basis-link/program&amp;quot;: 29mu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
for cold start and&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;/sb-tree1&amp;quot;: 22727mu&lt;br /&gt;
&amp;quot;/sb-tree1/ooo-sb107&amp;quot;: 19496mu&lt;br /&gt;
&amp;quot;/sb-tree1/ooo-sb107/openoffice.org3&amp;quot;: 9811mu&lt;br /&gt;
&amp;quot;/sb-tree1/ooo-sb107/openoffice.org3/basis-link&amp;quot;: 2742mu&lt;br /&gt;
&amp;quot;/sb-tree1/ooo-sb107/openoffice.org3/program&amp;quot;: 5413mu&lt;br /&gt;
&amp;quot;/sb-tree1/ooo-sb107/openoffice.org3/program/../basis-link/program&amp;quot;: 15mu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
for warm start.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;callgrind&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -a /sb-tree1 /sb-tree1f&lt;br /&gt;
$ unstr /cws/so-cwsserv02/sb107/DEV300/scr.m41 /cws/so-cwsserv02/sb107/DEV300/unxlngi6.pro/inc.m41 /sb-tree1f/ooo-sb107&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
once to get an unstripped OOo installation, using the following &amp;lt;code&amp;gt;unstr&amp;lt;/code&amp;gt; Haskell script:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;haskell&amp;quot;&amp;gt;&lt;br /&gt;
-- Makefile:&lt;br /&gt;
--  .PHONY: unstr&lt;br /&gt;
--  unstr:&lt;br /&gt;
--   ghc-6.10.1 --make -o $@ Main.hs&lt;br /&gt;
--&lt;br /&gt;
-- Replace ELF objects in an OOo installation with unstripped ones from a build&lt;br /&gt;
-- tree:&lt;br /&gt;
--&lt;br /&gt;
-- $ unstr &amp;lt;build-tree-root&amp;gt; &amp;lt;solver-inc-dir&amp;gt; &amp;lt;installation-root&amp;gt;&lt;br /&gt;
&lt;br /&gt;
module Main (main) where&lt;br /&gt;
&lt;br /&gt;
import Control.Monad (filterM, foldM, join, zipWithM_)&lt;br /&gt;
import Data.List (isPrefixOf)&lt;br /&gt;
import Data.Map (Map, empty, foldWithKey, insertWith)&lt;br /&gt;
import qualified Data.Map (lookup)&lt;br /&gt;
import System.Directory (copyFile, doesFileExist, getDirectoryContents)&lt;br /&gt;
import System.Environment (getArgs)&lt;br /&gt;
import System.Exit (ExitCode(ExitSuccess))&lt;br /&gt;
import System.FilePath (combine, dropFileName, joinPath, takeFileName)&lt;br /&gt;
import System.Posix.Files (getSymbolicLinkStatus, isDirectory, isRegularFile)&lt;br /&gt;
import System.Process (readProcessWithExitCode)&lt;br /&gt;
&lt;br /&gt;
filterSystemDirs :: [FilePath] -&amp;gt; [FilePath]&lt;br /&gt;
filterSystemDirs = filter (\f -&amp;gt; f /= &amp;quot;.&amp;quot; &amp;amp;&amp;amp; f /= &amp;quot;..&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
data Entry = Copy FilePath -- source&lt;br /&gt;
           | Link FilePath -- resolved target&lt;br /&gt;
&lt;br /&gt;
type EntryMap = Map FilePath (Maybe Entry)&lt;br /&gt;
&lt;br /&gt;
parseLog :: EntryMap -&amp;gt; FilePath -&amp;gt; IO EntryMap&lt;br /&gt;
parseLog m f = do c &amp;lt;- readFile f&lt;br /&gt;
                  return $ foldr (parse . words) m $ lines c&lt;br /&gt;
    where parse [&amp;quot;COPY&amp;quot;, o, d] m&amp;#039; = insert m&amp;#039; d $ Copy o&lt;br /&gt;
          parse [&amp;quot;LINK&amp;quot;, t, l] m&amp;#039; = insert m&amp;#039; l $ Link $&lt;br /&gt;
                                    combine (dropFileName l) t&lt;br /&gt;
          insert m f e = insertWith (const $ const Nothing) f (Just e) m&lt;br /&gt;
&lt;br /&gt;
type FileMap = Map FilePath (Maybe FilePath)&lt;br /&gt;
&lt;br /&gt;
resolve :: FilePath -&amp;gt; EntryMap -&amp;gt; FileMap&lt;br /&gt;
resolve srcDir em = foldWithKey resolve&amp;#039; empty em&lt;br /&gt;
    where resolve&amp;#039; kf Nothing fm = fm&lt;br /&gt;
          resolve&amp;#039; kf (Just (Copy f)) fm = insert fm kf f&lt;br /&gt;
          resolve&amp;#039; kf (Just (Link f)) fm =&lt;br /&gt;
              resolve&amp;#039; kf (join $ Data.Map.lookup f em) fm&lt;br /&gt;
          insert fm kf f = insertWith (const $ const Nothing) (takeFileName kf)&lt;br /&gt;
                           (Just $ combine srcDir f) fm&lt;br /&gt;
&lt;br /&gt;
findBin :: FilePath -&amp;gt; IO [FilePath]&lt;br /&gt;
findBin = findBin&amp;#039; []&lt;br /&gt;
    where findBin&amp;#039; l f = do&lt;br /&gt;
            s &amp;lt;- getSymbolicLinkStatus f&lt;br /&gt;
            case (isDirectory s, isRegularFile s) of&lt;br /&gt;
              (True, _) -&amp;gt; do dirs &amp;lt;- getDirectoryContents f&lt;br /&gt;
                              let files = map (combine f) $&lt;br /&gt;
                                          filterSystemDirs dirs&lt;br /&gt;
                              foldM findBin&amp;#039; l files&lt;br /&gt;
              (_, True) -&amp;gt; isBinary f &amp;gt;&amp;gt;= return . choose (f : l) l&lt;br /&gt;
                               where choose a b c = if c then a else b&lt;br /&gt;
              _ -&amp;gt; return l&lt;br /&gt;
&lt;br /&gt;
isBinary :: FilePath -&amp;gt; IO Bool&lt;br /&gt;
isBinary f = do (e, o, _) &amp;lt;-&lt;br /&gt;
                    readProcessWithExitCode &amp;quot;/usr/bin/file&amp;quot; [&amp;quot;-h&amp;quot;, f] &amp;quot;&amp;quot;&lt;br /&gt;
                return $ e == ExitSuccess &amp;amp;&amp;amp; (f ++ &amp;quot;: ELF &amp;quot;) `isPrefixOf` o&lt;br /&gt;
&lt;br /&gt;
findSource :: FileMap -&amp;gt; FilePath -&amp;gt; Maybe FilePath&lt;br /&gt;
findSource m f = join $ Data.Map.lookup (takeFileName f) m&lt;br /&gt;
&lt;br /&gt;
execute :: Integer -&amp;gt; (FilePath, Maybe FilePath) -&amp;gt; IO Integer&lt;br /&gt;
execute n (f, Nothing) = do putStrLn $ &amp;quot;No (unambiguous) source for &amp;quot; ++ f&lt;br /&gt;
                            return n&lt;br /&gt;
execute n (f, Just f&amp;#039;) = do copyFile f&amp;#039; f&lt;br /&gt;
                            return $ n + 1&lt;br /&gt;
&lt;br /&gt;
main :: IO ()&lt;br /&gt;
main = do [srcDir, logDir, instDir] &amp;lt;- getArgs&lt;br /&gt;
          dirs &amp;lt;- getDirectoryContents logDir&lt;br /&gt;
          let files = map (\x -&amp;gt; joinPath [logDir, x, &amp;quot;deliver.log&amp;quot;]) $&lt;br /&gt;
                      filterSystemDirs dirs&lt;br /&gt;
          files&amp;#039; &amp;lt;- filterM doesFileExist files&lt;br /&gt;
          em &amp;lt;- foldM parseLog empty files&amp;#039;&lt;br /&gt;
          bins &amp;lt;- findBin instDir&lt;br /&gt;
          n &amp;lt;- foldM execute 0&lt;br /&gt;
               (zip bins $ map (findSource $ resolve srcDir em) bins)&lt;br /&gt;
          putStrLn $&lt;br /&gt;
              show n ++ &amp;quot; file&amp;quot; ++ (if n == 1 then &amp;quot;&amp;quot; else &amp;quot;s&amp;quot;) ++ &amp;quot; copied&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Just after system start up run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /sb-tree3 &amp;amp;&amp;amp; valgrind --tool=callgrind --compress-strings=no /sb-tree1f/ooo-sb107/openoffice3/program/soffice.bin -swriter # press Ctrl-Q as soon as the text cursor starts to blink&lt;br /&gt;
$ cd /sb-tree3 &amp;amp;&amp;amp; valgrind --tool=callgrind --compress-strings=no /sb-tree1f/ooo-sb107/openoffice3/program/soffice.bin -swriter # press Ctrl-Q as soon as the text cursor starts to blink&lt;br /&gt;
$ cd /sb-tree3 &amp;amp;&amp;amp; valgrind --tool=callgrind --compress-strings=no /sb-tree1f/ooo-sb107/openoffice3/program/soffice.bin -swriter # press Ctrl-Q as soon as the text cursor starts to blink&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
to get one cold and two warm start-up (plus shut-down) measurements.  The variance, even across cold and warm start ups, appears to be minimal.&lt;br /&gt;
&lt;br /&gt;
Interesting first results, using grouping by ELF object in &amp;lt;code&amp;gt;kcachegrind&amp;lt;/code&amp;gt;, are the instruction reads spent directly within the top scoring ELF objects:&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! ELF object&lt;br /&gt;
! absolute instruction reads&lt;br /&gt;
! relative instruction reads&lt;br /&gt;
|-&lt;br /&gt;
| total &amp;amp;sum;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2,597,556,857&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 100.00%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;libuno_sal.so.3&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 731,982,997&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 28.18%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ld-2.7.so&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 551,561,186&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 21.23%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;libpthread-2.7.so&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 259,698,813&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 10.00%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;libstore.so.3&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 165,350,190&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 6.37%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;configmgr2.uno.so&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 161,273,959&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 6.21%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;libc-2.7.so&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 132,961,163&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 5.12%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;libuno_cppu.so.3&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 111,161,292&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 4.28%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;libfontconfig.so.1.3.0&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 91,777,652&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 3.53%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;libuno_cppuhelpergcc3.so.3&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 43,931,839&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.69%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;libtlli.so&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 43,326,910&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.67%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;libgcc_s.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 25,236,175&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.97%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;libfilterconfig1.so&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 23,319,326&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.90%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;LD_DEBUG&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Run&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cd /sb-tree3&lt;br /&gt;
LD_DEBUG=bindings LD_DEBUG_OUTPUT=~/lddebug /sb-tree1/opt/openoffice.org3/program/soffice -swriter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
and from the generated &amp;lt;code&amp;gt;~/lddebug.&amp;lt;var&amp;gt;pid&amp;lt;/var&amp;gt;&amp;lt;/code&amp;gt; files pick the one corresponding to &amp;lt;code&amp;gt;soffice.bin&amp;lt;/code&amp;gt; (usually the largest one).  Pass it through the below Haskell script to dress it up.  This gives information about all the symbolic relocations actually done at start-up (plus shut-down).  Note that this includes all symbolic relocations from the data segments (as they cannot be postponed until needed).&lt;br /&gt;
&amp;lt;source lang=&amp;quot;haskell&amp;quot;&amp;gt;&lt;br /&gt;
-- Makefile:&lt;br /&gt;
--  .PHONY: lddebug-eval&lt;br /&gt;
--  lddebug-eval:&lt;br /&gt;
--   ghc-6.10.1 --make -o $@ Main.hs&lt;br /&gt;
--&lt;br /&gt;
-- For every dynamic object, list:&lt;br /&gt;
--  number of symbol bindings made by that object to itself&lt;br /&gt;
--  number of symbol bindings made by that object to other objects&lt;br /&gt;
--  number of symbol bindings made by that object (sum of above two)&lt;br /&gt;
--  number of symbol bindings made by other objects to that object&lt;br /&gt;
-- (Descending) sorting by any of those four columns is controlled by -1, -2,&lt;br /&gt;
-- -3, or -4, respectively.&lt;br /&gt;
-- Listing the symbols belonging to the different columns is controlled by +1,&lt;br /&gt;
-- +2, or +4, respectively.&lt;br /&gt;
--&lt;br /&gt;
-- $ LD_DEBUG=bindings LD_DEBUG_OUTPUT=lddebug soffice.bin &amp;amp;&amp;amp; \&lt;br /&gt;
--    lddebug-eval -3 +1 +2 &amp;lt; lddebug &amp;gt; lddebug-a&lt;br /&gt;
&lt;br /&gt;
{-# LANGUAGE ScopedTypeVariables #-}&lt;br /&gt;
&lt;br /&gt;
module Main (main) where&lt;br /&gt;
&lt;br /&gt;
import Control.Monad (when)&lt;br /&gt;
import Data.List (sort, sortBy)&lt;br /&gt;
import qualified Data.Map as M&lt;br /&gt;
import System.Environment (getArgs)&lt;br /&gt;
import Text.Regex.Posix ((=~))&lt;br /&gt;
&lt;br /&gt;
main :: IO ()&lt;br /&gt;
main = do&lt;br /&gt;
  (so, lb) &amp;lt;- handleArgs&lt;br /&gt;
  c &amp;lt;- getContents&lt;br /&gt;
  let m = foldr process M.empty $ lines c&lt;br /&gt;
  reportTotal m&lt;br /&gt;
  mapM_ (report lb) $ sortObjs so $ M.toList m&lt;br /&gt;
&lt;br /&gt;
newtype SortColumn = SortColumn Int&lt;br /&gt;
data ListBindings = ListBindings { listToSelf :: Bool, listToOther :: Bool,&lt;br /&gt;
                                   listFromOther :: Bool }&lt;br /&gt;
&lt;br /&gt;
handleArgs :: IO (SortColumn, ListBindings)&lt;br /&gt;
handleArgs =&lt;br /&gt;
    return . foldl handleArg (SortColumn 0, ListBindings False False False)&lt;br /&gt;
        =&amp;lt;&amp;lt; getArgs&lt;br /&gt;
    where handleArg (_, lb) &amp;quot;-1&amp;quot; = (SortColumn 1, lb)&lt;br /&gt;
          handleArg (_, lb) &amp;quot;-2&amp;quot; = (SortColumn 2, lb)&lt;br /&gt;
          handleArg (_, lb) &amp;quot;-3&amp;quot; = (SortColumn 3, lb)&lt;br /&gt;
          handleArg (_, lb) &amp;quot;-4&amp;quot; = (SortColumn 4, lb)&lt;br /&gt;
          handleArg (so, ListBindings _ b2 b4) &amp;quot;+1&amp;quot; =&lt;br /&gt;
              (so, ListBindings True b2 b4)&lt;br /&gt;
          handleArg (so, ListBindings b1 _ b4) &amp;quot;+2&amp;quot; =&lt;br /&gt;
              (so, ListBindings b1 True b4)&lt;br /&gt;
          handleArg (so, ListBindings b1 b2 _) &amp;quot;+4&amp;quot; =&lt;br /&gt;
              (so, ListBindings b1 b2 True)&lt;br /&gt;
&lt;br /&gt;
data Binding = Binding FilePath String deriving (Eq, Ord)&lt;br /&gt;
instance Show Binding where show (Binding fp sym) = fp ++ &amp;quot; &amp;quot; ++ sym&lt;br /&gt;
&lt;br /&gt;
data Bindings = Bindings { toSelf :: [String], toOther :: [Binding],&lt;br /&gt;
                           fromOther :: [Binding] }&lt;br /&gt;
type Map = M.Map FilePath Bindings&lt;br /&gt;
&lt;br /&gt;
process :: String -&amp;gt; Map -&amp;gt; Map&lt;br /&gt;
process l m =&lt;br /&gt;
    case l =~~~ &amp;quot;binding file ([^ ]+) (.* )?to ([^ :]+)( .*): .* `(.+)&amp;#039;&amp;quot; of&lt;br /&gt;
      [f1, _, f2, _, s] -&amp;gt; add f1 updateTo $&lt;br /&gt;
                           if f1 == f2 then m else add f2 updateFrom m&lt;br /&gt;
          where updateTo = if f1 == f2 then Bindings [s] [] []&lt;br /&gt;
                                       else Bindings [] [Binding f2 s] []&lt;br /&gt;
                updateFrom = Bindings [] [] [Binding f1 s]&lt;br /&gt;
                add = M.insertWith (+:+)&lt;br /&gt;
                Bindings x1 y1 z1 +:+ Bindings x2 y2 z2 =&lt;br /&gt;
                    Bindings (x1 +::+ x2) (y1 +::+ y2) (z1 +::+ z2)&lt;br /&gt;
                [] +::+ xs = xs&lt;br /&gt;
                [x] +::+ xs = x : xs&lt;br /&gt;
      _ -&amp;gt; m&lt;br /&gt;
&lt;br /&gt;
reportTotal :: Map -&amp;gt; IO ()&lt;br /&gt;
reportTotal m = putStrLn $ &amp;quot;Total &amp;quot; ++ show s1 ++ &amp;quot; &amp;quot; ++ show s2 ++ &amp;quot; &amp;quot; ++&lt;br /&gt;
                show (s1 + s2) ++ &amp;quot; &amp;quot; ++ show s4&lt;br /&gt;
    where (s1, s2, s4) = M.fold sum (0, 0, 0) m&lt;br /&gt;
          sum (Bindings x y z) (a1, a2, a3) = (a1 + length x, a2 + length y,&lt;br /&gt;
                                               a3 + length z)&lt;br /&gt;
&lt;br /&gt;
report :: ListBindings -&amp;gt; (FilePath, Bindings) -&amp;gt; IO ()&lt;br /&gt;
report lb (f, c) = do&lt;br /&gt;
    putStrLn $ f ++ &amp;quot; &amp;quot; ++ show (len toSelf) ++ &amp;quot; &amp;quot; ++ show (len toOther) ++&lt;br /&gt;
                 &amp;quot; &amp;quot; ++ show (len toSelf + len toOther) ++ &amp;quot; &amp;quot; ++&lt;br /&gt;
                 show (len fromOther)&lt;br /&gt;
    when (listToSelf lb) $ mapM_ (putStrLn . (&amp;quot; &amp;gt;&amp;lt; &amp;quot; ++)) $ sort $ toSelf c&lt;br /&gt;
    when (listToOther lb) $&lt;br /&gt;
         mapM_ (putStrLn . (&amp;quot; -&amp;gt; &amp;quot; ++) . show) $ sort $ toOther c&lt;br /&gt;
    when (listFromOther lb) $&lt;br /&gt;
         mapM_ (putStrLn . (&amp;quot; &amp;lt;- &amp;quot; ++) . show) $ sort $ fromOther c&lt;br /&gt;
    where len x = length $ x c&lt;br /&gt;
&lt;br /&gt;
sortObjs :: SortColumn -&amp;gt; [(FilePath, Bindings)] -&amp;gt; [(FilePath, Bindings)]&lt;br /&gt;
sortObjs (SortColumn 0) = id&lt;br /&gt;
sortObjs (SortColumn 1) = sortBy (\(_, Bindings x _ _) (_, Bindings y _ _) -&amp;gt; compare (length y) (length x))&lt;br /&gt;
sortObjs (SortColumn 2) = sortBy (\(_, Bindings _ x _) (_, Bindings _ y _) -&amp;gt;&lt;br /&gt;
                                  compare (length y) (length x))&lt;br /&gt;
sortObjs (SortColumn 3) = sortBy (\(_, Bindings x1 x2 _) (_, Bindings y1 y2 _) -&amp;gt;&lt;br /&gt;
                                  compare (length y1 + length y2) (length x1 + length x2))&lt;br /&gt;
sortObjs (SortColumn 4) = sortBy (\(_, Bindings _ _ x) (_, Bindings _ _ y) -&amp;gt;&lt;br /&gt;
                                  compare (length y) (length x))&lt;br /&gt;
&lt;br /&gt;
(=~~~) :: String -&amp;gt; String -&amp;gt; [String]&lt;br /&gt;
a =~~~ b = c&lt;br /&gt;
    where (_::String, _::String, _::String, c) = a =~ b&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that &amp;lt;code&amp;gt;ld-linux.so.2&amp;lt;/code&amp;gt; on the used machine sometimes garbles lines of &amp;lt;code&amp;gt;LD_DEBUG&amp;lt;/code&amp;gt; output (maybe a multi-threading issue), so the data produced by the above Haskell script need not be totally accurate.&lt;br /&gt;
&lt;br /&gt;
= Symbolic Linking =&lt;br /&gt;
&lt;br /&gt;
[http://qa.openoffice.org/issues/show_bug.cgi?id=85679 Issue&amp;amp;nbsp;85679] &amp;amp;ldquo;Link with -Wl,-Bsymbolic-functions -Wl,--dynamic-list-cpp-new -Wl,--dynamic-list-cpp-typeinfo when supported&amp;amp;rdquo; suggest a performance boost on Linux through symbolic linking.  This requires a fairly recent GNU&amp;amp;nbsp;&amp;lt;code&amp;gt;ld&amp;lt;/code&amp;gt;.  Experimenting with combining the existing (GCC&amp;amp;nbsp;3.4.1 based) Hamburg &amp;lt;code&amp;gt;unxlngi6.pro&amp;lt;/code&amp;gt; tool chain with (latest, as of March&amp;amp;nbsp;2009) &amp;lt;code&amp;gt;ld&amp;lt;/code&amp;gt;&amp;amp;nbsp;2.19.1 failed, so I set up an environment using GNU binutils&amp;amp;nbsp;2.19.1 and GNU GCC&amp;amp;nbsp;4.3.3 (again, latest as of March&amp;amp;nbsp;2009) on &amp;lt;code&amp;gt;v20z-so3&amp;lt;/code&amp;gt; (see above).&lt;br /&gt;
&lt;br /&gt;
* Build the new tool chain with &amp;lt;code&amp;gt;~/newgcc.sh ~/newgcc &amp;amp;&amp;amp; rm -rf build&amp;lt;/code&amp;gt;, where &amp;lt;code&amp;gt;~/newgcc.sh&amp;lt;/code&amp;gt; is&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
set -e&lt;br /&gt;
&lt;br /&gt;
mkdir ${1?}&lt;br /&gt;
mkdir build&lt;br /&gt;
cd build&lt;br /&gt;
&lt;br /&gt;
wget http://ftp.gnu.org/gnu/binutils/binutils-2.19.1.tar.bz2&lt;br /&gt;
tar xfj binutils-2.19.1.tar.bz2&lt;br /&gt;
mkdir binutils-build&lt;br /&gt;
(cd binutils-build; \&lt;br /&gt;
 ../binutils-2.19.1/configure --prefix=${1?}; \&lt;br /&gt;
 make; make install)&lt;br /&gt;
&lt;br /&gt;
wget http://ftp.gnu.org/gnu/gmp/gmp-4.2.4.tar.bz2&lt;br /&gt;
tar xfj gmp-4.2.4.tar.bz2&lt;br /&gt;
&lt;br /&gt;
wget http://www.mpfr.org/mpfr-2.4.1/mpfr-2.4.1.tar.bz2&lt;br /&gt;
tar xfj mpfr-2.4.1.tar.bz2&lt;br /&gt;
wget http://www.mpfr.org/mpfr-2.4.1/patches&lt;br /&gt;
(cd mpfr-2.4.1; patch -N -Z -p1 &amp;lt; ../patches)&lt;br /&gt;
&lt;br /&gt;
wget http://ftp.gnu.org/gnu/gcc/gcc-4.3.3/gcc-4.3.3.tar.bz2&lt;br /&gt;
tar xfj gcc-4.3.3.tar.bz2&lt;br /&gt;
ln -s ../gmp-4.2.4 gcc-4.3.3/gmp&lt;br /&gt;
ln -s ../mpfr-2.4.1 gcc-4.3.3/mpfr&lt;br /&gt;
mkdir gcc-build&lt;br /&gt;
(cd gcc-build; \&lt;br /&gt;
 export PATH=${1?}${PATH+:$PATH}; \&lt;br /&gt;
 ../gcc-4.3.3/configure --prefix=${1?} --enable-languages=c,c++; \&lt;br /&gt;
 make; make install)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Again using [http://eis.services.openoffice.org/EIS2/cws.ShowCWS?Path=DEV300%2Fsb107 CWS&amp;amp;nbsp;sb107] (see above), by now based on &amp;lt;code&amp;gt;DEV300m42&amp;lt;/code&amp;gt;, replace the (Hamburg-internal) compiler-support libraries at &amp;lt;code&amp;gt;$SRC_ROOT/so_prereq/baseline/unxlngi6&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;libgcc_s.so.1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;libstdc++.a&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;libstdc++.la&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;libstdc++.so.6.0.1&amp;lt;/code&amp;gt;) with the ones from the new tool chain (&amp;lt;code&amp;gt;libgcc_s.so.1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;libstdc++.a&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;libstdc++.la&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;libstdc++.so.6.0.10&amp;lt;/code&amp;gt;) and in &amp;lt;code&amp;gt;$SRC_ROOT/solenv/bin/rpm-wrapper&amp;lt;/code&amp;gt; replace &amp;amp;ldquo;&amp;lt;code&amp;gt;${COMPATH?}&amp;lt;/code&amp;gt;&amp;amp;rdquo; with &amp;amp;ldquo;&amp;lt;code&amp;gt;/so/env/gcc_3.4.1_p_linux_libc2.24&amp;lt;/code&amp;gt;&amp;amp;rdquo;.&lt;br /&gt;
&lt;br /&gt;
* Merge in the relevant changes from [http://qa.openoffice.org/issues/show_bug.cgi?id=85679 Issue&amp;amp;nbsp;85679] to support &amp;lt;code&amp;gt;HAVE_LD_BSYMBOLIC_FUNCTIONS&amp;lt;/code&amp;gt; (ignoring the configure changes that are not relevant for a &amp;lt;code&amp;gt;setsolar&amp;lt;/code&amp;gt; environment):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cd $SOURCE_ROOT/DEV300/ooo &amp;amp;&amp;amp; svn merge --ignore-ancestry svn://svn.services.openoffice.org/ooo/cws/buildporting31b -r 264159:264162&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Remove &amp;amp;ldquo;&amp;lt;code&amp;gt;SO:b_server&amp;lt;/code&amp;gt;&amp;amp;rdquo; from &amp;lt;code&amp;gt;$SRC_ROOT/top/prj/build.lst&amp;lt;/code&amp;gt;, to avoid an error later on when building (irrelevant, for OOo installation sets) &amp;lt;code&amp;gt;$SRC_ROOT/soldep/bootstrp&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* Unfortunately, I did not manage to combine the standard Hamburg build environment (setting a specific &amp;lt;code&amp;gt;sysbaseroot&amp;lt;/code&amp;gt;) with the new toolchain, so had to go with a null &amp;lt;code&amp;gt;sysbaseroot&amp;lt;/code&amp;gt; (i.e., using stuff directly from the &amp;lt;code&amp;gt;v20z-so3&amp;lt;/code&amp;gt; build machine).  This means that results might be slightly different between the vanilla reference build and the builds checking the effects of symbolic linking.&lt;br /&gt;
&lt;br /&gt;
* I did three builds:&lt;br /&gt;
&lt;br /&gt;
** Build&amp;amp;nbsp;&amp;lt;var&amp;gt;N&amp;lt;/var&amp;gt; using just the new tool chain (&amp;lt;code&amp;gt;EXTERNAL_WARNINGS_NOT_ERRORS=TRUE&amp;lt;/code&amp;gt; is necessary as OOo is not yet completely warning-free for GCC&amp;amp;nbsp;4.3.3):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
SYSBASE_ROOT= setcws -pro sb107 -- -compath ~/newgcc -sysbaseroot&lt;br /&gt;
cd $SRC_ROOT/finalize &amp;amp;&amp;amp; EXTERNAL_WARNINGS_NOT_ERRORS=TRUE build --all&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
** Build&amp;amp;nbsp;&amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt; actually enabling symbolic linking:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
SYSBASE_ROOT= setcws -pro sb107 -- -compath ~/newgcc -sysbaseroot&lt;br /&gt;
cd $SRC_ROOT/finalize &amp;amp;&amp;amp; EXTERNAL_WARNINGS_NOT_ERRORS=TRUE HAVE_LD_BSYMBOLIC_FUNCTIONS=TRUE build --all&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
** Build&amp;amp;nbsp;&amp;lt;var&amp;gt;F&amp;lt;/var&amp;gt; using full symbolic linking (for functions and data) instead of symbolic linking for functions only, see [http://qa.openoffice.org/issues/show_bug.cgi?id=85679#desc7 issue&amp;amp;nbsp;85679 additional comment&amp;amp;nbsp;7].  For that, I changed from &amp;amp;ldquo;&amp;lt;code&amp;gt;-Wl,-Bsymbolic-functions&amp;lt;/code&amp;gt;&amp;amp;rdquo; to &amp;amp;ldquo;&amp;lt;code&amp;gt;-Wl,-Bsymbolic&amp;lt;/code&amp;gt;&amp;amp;rdquo; in &amp;lt;code&amp;gt;$SRC_ROOT/solenv/inc/unxlngi6.mk&amp;lt;/code&amp;gt; (and forgot to adapt &amp;lt;code&amp;gt;$SRC_ROOT/icu/makefile.mk&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$SRC_ROOT/stlport/makefile.mk&amp;lt;/code&amp;gt; accordingly, which, however, should only have a minor effect on the resulting numbers).&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
SYSBASE_ROOT= setcws -pro sb107 -- -compath ~/newgcc -sysbaseroot&lt;br /&gt;
cd $SRC_ROOT/finalize &amp;amp;&amp;amp; EXTERNAL_WARNINGS_NOT_ERRORS=TRUE HAVE_LD_BSYMBOLIC_FUNCTIONS=TRUE build --all&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This gave me four OOo installation sets (the original &amp;lt;var&amp;gt;O&amp;lt;/var&amp;gt; one built with the standard Hamburg build environment, and the three new &amp;lt;var&amp;gt;N&amp;lt;/var&amp;gt;, &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt;, and &amp;lt;var&amp;gt;F&amp;lt;/var&amp;gt; ones), which were measured on the dedicated machine (see above).&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;time&amp;lt;/code&amp;gt; numbers (in each case, the average of three cold and six warm starts):&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&lt;br /&gt;
!&lt;br /&gt;
! &amp;lt;var&amp;gt;O&amp;lt;/var&amp;gt;&lt;br /&gt;
! &amp;lt;var&amp;gt;N&amp;lt;/var&amp;gt;&lt;br /&gt;
! &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt;&lt;br /&gt;
! &amp;lt;var&amp;gt;F&amp;lt;/var&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;3&amp;quot; | cold&lt;br /&gt;
! real&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 11.16s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 9.48s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 10.53s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 9.54s&lt;br /&gt;
|-&lt;br /&gt;
! user&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.09s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.91s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.71s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.69s&lt;br /&gt;
|-&lt;br /&gt;
! sys&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.25s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.24s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.26s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.26s&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;3&amp;quot; | warm&lt;br /&gt;
! real&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 3.17s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 3.02s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.83s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.70s&lt;br /&gt;
|-&lt;br /&gt;
! user&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.02s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.68s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.48s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.41s&lt;br /&gt;
|-&lt;br /&gt;
! sys&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.16s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.15s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.14s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.15s&lt;br /&gt;
|}&lt;br /&gt;
Remarks:&lt;br /&gt;
* The &amp;lt;var&amp;gt;N&amp;lt;/var&amp;gt; cold-start real time looks somewhat too small (probably due to the overall small number of measurements taken).&lt;br /&gt;
* The user times decrease as expected (as time spent in the run-time loader decreases).&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;callgrind&amp;lt;/code&amp;gt; numbers (in each case, the second warm start in a row):&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; | &amp;lt;var&amp;gt;O&amp;lt;/var&amp;gt;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; | &amp;lt;var&amp;gt;N&amp;lt;/var&amp;gt;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; | &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; | &amp;lt;var&amp;gt;F&amp;lt;/var&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;sum;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2,283,122,716&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 100.00%&lt;br /&gt;
| &amp;amp;sum;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2,334,805,645&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 100.00%&lt;br /&gt;
| &amp;amp;sum;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2,038,552,787&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 100.00%&lt;br /&gt;
| &amp;amp;sum;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2,003,854,857&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 100.00%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;sal&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 647,373,539&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 28.35%&lt;br /&gt;
| &amp;lt;code&amp;gt;sal&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 691,393,484&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 29,61%&lt;br /&gt;
| &amp;lt;code&amp;gt;sal&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 634,256,193&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 31.11%&lt;br /&gt;
| &amp;lt;code&amp;gt;sal&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 634,307,373&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 31.65%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ld&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 553,872,166&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 24.26%&lt;br /&gt;
| &amp;lt;code&amp;gt;ld&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 546,564,974&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 23.41%&lt;br /&gt;
| &amp;lt;code&amp;gt;ld&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 305,756,844&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 15.00%&lt;br /&gt;
| &amp;lt;code&amp;gt;ld&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 271,385,866&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 13.54%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;pthread&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 201,802,573&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 8.84%&lt;br /&gt;
| &amp;lt;code&amp;gt;pthread&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 201,363,821&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 8.62%&lt;br /&gt;
| &amp;lt;code&amp;gt;pthread&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 204,557,648&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 10.03%&lt;br /&gt;
| &amp;lt;code&amp;gt;pthread&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 204,573,303&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 10.21%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;configmgr&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 161,661,066&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 7.08%&lt;br /&gt;
| &amp;lt;code&amp;gt;configmgr&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 180,214,766&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 7.72%&lt;br /&gt;
| &amp;lt;code&amp;gt;configmgr&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 180,278,175&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 8.84%&lt;br /&gt;
| &amp;lt;code&amp;gt;configmgr&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 180,278,731&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 9.00%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 121,552,893&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 5.32%&lt;br /&gt;
| &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 111,557,687&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 4.78%&lt;br /&gt;
| &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 109,967,449&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 5.39%&lt;br /&gt;
| &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 109,791,414&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 5.48%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;cppu&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 111,123,581&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 4.87%&lt;br /&gt;
| &amp;lt;code&amp;gt;cppu&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 99,323,254&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 4.25%&lt;br /&gt;
| &amp;lt;code&amp;gt;cppu&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 99,387,817&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 4.88%&lt;br /&gt;
| &amp;lt;code&amp;gt;cppu&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 99,377,448&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 4.96%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;fontconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 62,609,949&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.74%&lt;br /&gt;
| &amp;lt;code&amp;gt;fontconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 62,704,639&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.69%&lt;br /&gt;
| &amp;lt;code&amp;gt;fontconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 62,592,873&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 3.07%&lt;br /&gt;
| &amp;lt;code&amp;gt;fontconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 62,423,589&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 3.12%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;cppuhelper&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 43,994,951&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.93%&lt;br /&gt;
| &amp;lt;code&amp;gt;store&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 56,053,961&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.40%&lt;br /&gt;
| &amp;lt;code&amp;gt;store&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 56,053,990&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.75%&lt;br /&gt;
| &amp;lt;code&amp;gt;store&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 56,053,990&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.80%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;tl&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 43,389,333&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.90%&lt;br /&gt;
| &amp;lt;code&amp;gt;cppuhelper&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 49,022,128&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.10%&lt;br /&gt;
| &amp;lt;code&amp;gt;cppuhelper&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 49,146,109&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.41%&lt;br /&gt;
| &amp;lt;code&amp;gt;cppuhelper&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 49,096,875&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.45%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;store&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 39,787,117&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.74%&lt;br /&gt;
| &amp;lt;code&amp;gt;tl&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 40,778,608&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.75%&lt;br /&gt;
| &amp;lt;code&amp;gt;tl&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 40,778,745&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.00%&lt;br /&gt;
| &amp;lt;code&amp;gt;tl&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 40,778,944&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.04%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;comphelp&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 27,750,228&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.22%&lt;br /&gt;
| &amp;lt;code&amp;gt;comphelp&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 25,798,266&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.10%&lt;br /&gt;
| &amp;lt;code&amp;gt;comphelp&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 25,797,960&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.27%&lt;br /&gt;
| &amp;lt;code&amp;gt;comphelp&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 25,797,960&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.29%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;gcc_s&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 24,964,856&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.09%&lt;br /&gt;
| &amp;lt;code&amp;gt;filterconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 23,233,003&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.00%&lt;br /&gt;
| &amp;lt;code&amp;gt;filterconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 23,233,003&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.14%&lt;br /&gt;
| &amp;lt;code&amp;gt;filterconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 23,233,003&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.16%&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
|}&lt;br /&gt;
Remarks:&lt;br /&gt;
* &amp;lt;code&amp;gt;callgrind&amp;lt;/code&amp;gt;-instrumented runs of the various OOo instances often terminated with unexpected C++ exceptions, see [http://www.openoffice.org/issues/show_bug.cgi?id=100159 issue&amp;amp;nbsp;100159] &amp;amp;ldquo;unexpected exception from oooimprovement during shut down&amp;amp;rdquo;.  I could not get good runs for neither &amp;lt;var&amp;gt;O&amp;lt;/var&amp;gt; nor&amp;amp;nbsp;&amp;lt;var&amp;gt;N&amp;lt;/var&amp;gt;, so used ones crashing with &amp;lt;code&amp;gt;com::sun::star::lang::DisposedException&amp;lt;/code&amp;gt; there; I did get good runs for both &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt; and&amp;amp;nbsp;&amp;lt;var&amp;gt;F&amp;lt;/var&amp;gt;, though.  This probably makes the numbers for &amp;lt;var&amp;gt;O&amp;lt;/var&amp;gt; and&amp;amp;nbsp;&amp;lt;var&amp;gt;N&amp;lt;/var&amp;gt; somewhat different from what they would correctly be.&lt;br /&gt;
* Overall numbers apparently dropped from &amp;lt;code&amp;gt;DEV300m41&amp;lt;/code&amp;gt; (see [[#callgrind]] above) to &amp;lt;code&amp;gt;DEV300m42&amp;lt;/code&amp;gt;&amp;amp;nbsp;(&amp;lt;var&amp;gt;O&amp;lt;/var&amp;gt;), mostly in &amp;lt;code&amp;gt;sal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;store&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;fontconfig&amp;lt;/code&amp;gt;.&lt;br /&gt;
* The number of instruction reads appears to be generally higher for the new tool chain.  This need not imply higher execution times, however.  It might be caused by padding &amp;lt;code&amp;gt;nop&amp;lt;/code&amp;gt;s or choices of multiple simple (and in sum fast) instructions instead of fewer (and in sum slower) complex ones.&lt;br /&gt;
* Numbers decreased significantly for &amp;lt;code&amp;gt;gcc_s&amp;lt;/code&amp;gt; with the new tool chain.  This is probably due to better support for C++ exception handling.&lt;br /&gt;
* As expected, for &amp;lt;code&amp;gt;ld&amp;lt;/code&amp;gt; numbers decreased significantly from &amp;lt;var&amp;gt;N&amp;lt;/var&amp;gt; to&amp;amp;nbsp;&amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt;, and then yet some more from &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt; to&amp;amp;nbsp;&amp;lt;var&amp;gt;F&amp;lt;/var&amp;gt; (while numbers remained the same for all other objects).&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;LD_DEBUG&amp;lt;/code&amp;gt; numbers:&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Relocations&lt;br /&gt;
! &amp;lt;var&amp;gt;O&amp;lt;/var&amp;gt;&lt;br /&gt;
! &amp;lt;var&amp;gt;N&amp;lt;/var&amp;gt;&lt;br /&gt;
! &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt;&lt;br /&gt;
! &amp;lt;var&amp;gt;F&amp;lt;/var&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! intra-object&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 45,698&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 44,480&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 16,520&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 11,623&lt;br /&gt;
|-&lt;br /&gt;
! inter-object&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 22,927&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 22,705&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 22,547&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 22,270&lt;br /&gt;
|-&lt;br /&gt;
! &amp;amp;sum;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 68,625&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 67,185&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 39,067&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 33,893&lt;br /&gt;
|}&lt;br /&gt;
Remarks:&lt;br /&gt;
* As expected, intra-object numbers go down while inter-object numbers stay almost the same.&lt;br /&gt;
&lt;br /&gt;
Using &amp;lt;code&amp;gt;-Bsymbolic&amp;lt;/code&amp;gt; is in general unsound, however (and thus variant&amp;amp;nbsp;&amp;lt;var&amp;gt;F&amp;lt;/var&amp;gt; subtly broken).  If an executable references data from a shared library, the instance of data used at runtime will not be the instance in the shared library memory but a copy residing in the executable memory (using &amp;lt;code&amp;gt;R_386_COPY&amp;lt;/code&amp;gt; relocation to copy data from the shared library memory to the executable memory).  This will obviously fail if the shared library &amp;amp;ldquo;short circuits&amp;amp;rdquo; to use its own instance.  (It might work if all executables were built as PIC, but it appears too fragile and cumbersome to enforce this, especially for all the third-party code built as part of OOo.)  Therefore, other mechanisms need to be sought to reduce the number of intra-object (and inter-object!) references past the &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt; numbers.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;DEV300m44&amp;lt;/code&amp;gt;  ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;DEV300m44&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;unxlngi6.pro&amp;lt;/code&amp;gt; is now routinely built with a new tool chain in the Hamburg &amp;lt;code&amp;gt;setsolar&amp;lt;/code&amp;gt; environment, using GNU binutils&amp;amp;nbsp;2.19 and  GCC&amp;amp;nbsp;4.2.3, which is close to the tool chain I used above.  Below are measurements for five &amp;lt;code&amp;gt;unxlngi6.pro&amp;lt;/code&amp;gt; OOo versions:&lt;br /&gt;
* &amp;lt;var&amp;gt;B&amp;lt;/var&amp;gt; is the plain &amp;lt;code&amp;gt;OOO300m9&amp;lt;/code&amp;gt; (i.e., OOo&amp;amp;nbsp;3.0.0) version built by Hamburg Release Engineering (using the old tool chain based on GCC&amp;amp;nbsp;3.4.1), for reference.&lt;br /&gt;
* &amp;lt;var&amp;gt;O&amp;lt;/var&amp;gt; is the plain &amp;lt;code&amp;gt;DEV300m44&amp;lt;/code&amp;gt; version built by Hamburg Release Engineering, using GCC&amp;amp;nbsp;4.2.3 and binutils&amp;amp;nbsp;2.19.&lt;br /&gt;
* &amp;lt;var&amp;gt;C&amp;lt;/var&amp;gt; is a Hamburg &amp;lt;code&amp;gt;setsolar&amp;lt;/code&amp;gt;-based build of CWS [http://eis.services.openoffice.org/EIS2/cws.ShowCWS?Path=DEV300%2Fsb107 CWS sb107] with fixes for [http://qa.openoffice.org/issues/show_bug.cgi?id=85679 issue&amp;amp;nbsp;85679], [http://qa.openoffice.org/issues/show_bug.cgi?id=99519 issue&amp;amp;nbsp;99519], [http://qa.openoffice.org/issues/show_bug.cgi?id=100348 issue&amp;amp;nbsp;100348], [http://qa.openoffice.org/issues/show_bug.cgi?id=100396 issue&amp;amp;nbsp;100396], and [http://qa.openoffice.org/issues/show_bug.cgi?id=100576 issue&amp;amp;nbsp;100576] (and some additional issues that are not performance relevant), also using GCC&amp;amp;nbsp;4.2.3 and binutils&amp;amp;nbsp;2.19.  Especially [http://qa.openoffice.org/issues/show_bug.cgi?id=100576 issue&amp;amp;nbsp;100576] &amp;amp;ldquo;enable HAVE_LD_HASH_STYLE in sdev300.ini&amp;amp;rdquo; seems to make a difference.&lt;br /&gt;
* &amp;lt;var&amp;gt;N&amp;lt;/var&amp;gt; is the same as&amp;amp;nbsp;&amp;lt;var&amp;gt;C&amp;lt;/var&amp;gt;, but using my above tool chain (GCC&amp;amp;nbsp;4.3.3 and binutils&amp;amp;nbsp;2.19.1) instead&amp;amp;mdash;and again without the Hamburg &amp;lt;code&amp;gt;SYSBASE_ROOT&amp;lt;/code&amp;gt; to be able to compile at all:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
SYSBASE_ROOT= setcws -pro sb107 -- -compath ~/newgcc -sysbaseroot&lt;br /&gt;
cd $SRC_ROOT/finalize &amp;amp;&amp;amp; EXTERNAL_WARNINGS_NOT_ERRORS=TRUE build --all&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
* &amp;lt;var&amp;gt;F&amp;lt;/var&amp;gt; is the same as&amp;amp;nbsp;&amp;lt;var&amp;gt;N&amp;lt;/var&amp;gt;, only chainging &amp;lt;code&amp;gt;CFLAGSOPT=-Os -fno-strict-aliasing&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;CFLAGSOPT=-O3 -fno-strict-aliasing&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;solenv/inc/unxlngi6.mk&amp;lt;/code&amp;gt; (and including a necessary fix for [http://qa.openoffice.org/issues/show_bug.cgi?id=100668 issue&amp;amp;nbsp;100668] &amp;amp;ldquo;explicit template instantiation: correct syntax&amp;amp;rdquo;).&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;time&amp;lt;/code&amp;gt; numbers (in each case, the average of three cold and six warm starts):&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&lt;br /&gt;
!&lt;br /&gt;
! &amp;lt;var&amp;gt;B&amp;lt;/var&amp;gt;&lt;br /&gt;
! &amp;lt;var&amp;gt;O&amp;lt;/var&amp;gt;&lt;br /&gt;
! &amp;lt;var&amp;gt;C&amp;lt;/var&amp;gt;&lt;br /&gt;
! &amp;lt;var&amp;gt;C&amp;lt;/var&amp;gt;&amp;amp;prime;&lt;br /&gt;
! &amp;lt;var&amp;gt;N&amp;lt;/var&amp;gt;&lt;br /&gt;
! &amp;lt;var&amp;gt;F&amp;lt;/var&amp;gt;&lt;br /&gt;
! &amp;lt;var&amp;gt;F&amp;lt;/var&amp;gt;&amp;amp;prime;&lt;br /&gt;
! &amp;lt;var&amp;gt;F&amp;lt;/var&amp;gt;&amp;amp;prime;&amp;amp;prime;&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;4&amp;quot; | cold&lt;br /&gt;
! real&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 10.39s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 10.04s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 8.29s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 6.91s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 8.54s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 9.56s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 7.63s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 11.08s&lt;br /&gt;
|-&lt;br /&gt;
! user&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.03s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.05s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.59s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.42s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.53s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.47s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.19s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.55s&lt;br /&gt;
|-&lt;br /&gt;
! sys&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.25s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.26s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.24s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.27s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.26s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.28s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.32s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.31s&lt;br /&gt;
|-&lt;br /&gt;
! pgflts&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 542&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 548&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 549&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 241&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 550&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 607&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 241&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1007&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;4&amp;quot; | warm&lt;br /&gt;
! real&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 3.07s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 3.23s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.62s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 3.15s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.61s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.40s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.48s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.45s&lt;br /&gt;
|-&lt;br /&gt;
! user&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.79s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.87s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.45s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.46s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.24s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.16s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.22s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.22s&lt;br /&gt;
|-&lt;br /&gt;
! sys&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.15s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.16s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.16s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.18s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.18s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.17s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.19s&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0.14s&lt;br /&gt;
|-&lt;br /&gt;
! pgflts&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 0&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 7&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 7&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 7&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 7&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 7&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 7&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 7&lt;br /&gt;
|}&lt;br /&gt;
* &amp;lt;var&amp;gt;C&amp;lt;/var&amp;gt;&amp;amp;prime; and &amp;lt;var&amp;gt;F&amp;lt;/var&amp;gt;&amp;amp;prime; are like &amp;lt;var&amp;gt;C&amp;lt;/var&amp;gt; resp.&amp;amp;nbsp;&amp;lt;var&amp;gt;F&amp;lt;/var&amp;gt; but with [http://qa.openoffice.org/issues/show_bug.cgi?id=100884 issue&amp;amp;nbsp;100884] fixed and &amp;lt;code&amp;gt;pagein-common&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;pagein-writer&amp;lt;/code&amp;gt; modified to contain all libraries from the &amp;lt;code&amp;gt;OOo&amp;lt;/code&amp;gt; installation that are loaded during start-up.&lt;br /&gt;
* &amp;lt;var&amp;gt;F&amp;lt;/var&amp;gt;&amp;amp;prime;&amp;amp;prime; is like &amp;lt;var&amp;gt;F&amp;lt;/var&amp;gt; but with the call to &amp;lt;code&amp;gt;pagein&amp;lt;/code&amp;gt; commented out in the &amp;lt;code&amp;gt;soffice&amp;lt;/code&amp;gt; wrapper script.&lt;br /&gt;
* &amp;amp;ldquo;pgflts&amp;amp;rdquo; is the number of &amp;amp;ldquo;major (requiring I/O) page faults&amp;amp;rdquo; as reported by &amp;lt;code&amp;gt;/usr/bin/time&amp;amp;nbsp;-v&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;callgrind&amp;lt;/code&amp;gt; numbers:&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; | &amp;lt;var&amp;gt;B&amp;lt;/var&amp;gt;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; | &amp;lt;var&amp;gt;O&amp;lt;/var&amp;gt;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; | &amp;lt;var&amp;gt;C&amp;lt;/var&amp;gt;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; | &amp;lt;var&amp;gt;N&amp;lt;/var&amp;gt;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; | &amp;lt;var&amp;gt;F&amp;lt;/var&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;sum;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2,343,921,428&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 100.00%&lt;br /&gt;
| &amp;amp;sum;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2,480,626,988&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 100.00%&lt;br /&gt;
| &amp;amp;sum;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2,154,221,636&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 100.00%&lt;br /&gt;
| &amp;amp;sum;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1,941,254,692&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 100.00%&lt;br /&gt;
| &amp;amp;sum;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1,784,892,501&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 100.00%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;sal&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 613,760,471&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 26.19%&lt;br /&gt;
| &amp;lt;code&amp;gt;sal&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 618,714,642&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 24.94%&lt;br /&gt;
| &amp;lt;code&amp;gt;sal&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 618,363,619&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 28.70%&lt;br /&gt;
| &amp;lt;code&amp;gt;sal&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 642,648,488&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 33.10%&lt;br /&gt;
| &amp;lt;code&amp;gt;sal&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 583,727,656&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 32.70%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ld&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 520,524,128&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 22.21%&lt;br /&gt;
| &amp;lt;code&amp;gt;ld&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 549,307,081&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 22.14%&lt;br /&gt;
| &amp;lt;code&amp;gt;configmgr&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 267,645,553&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 12.42%&lt;br /&gt;
| &amp;lt;code&amp;gt;ld&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 219,943,725&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 11.33%&lt;br /&gt;
| &amp;lt;code&amp;gt;ld&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 219,918,343&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 12.32%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;pthread&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 216,174,061&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 9.22%&lt;br /&gt;
| &amp;lt;code&amp;gt;configmgr&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 267,677,829&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 10.79%&lt;br /&gt;
| &amp;lt;code&amp;gt;ld&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 223,705,486&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 10.38%&lt;br /&gt;
| &amp;lt;code&amp;gt;pthread&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 204,639,671&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 10.54%&lt;br /&gt;
| &amp;lt;code&amp;gt;pthread&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 204,929,641&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 11.48%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;configmgr&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 151,420,129&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 6.46%&lt;br /&gt;
| &amp;lt;code&amp;gt;pthread&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 205,754,007&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 8.29%&lt;br /&gt;
| &amp;lt;code&amp;gt;pthread&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 205,541,731&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 9.54%&lt;br /&gt;
| &amp;lt;code&amp;gt;configmgr&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 180,332,775&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 9.29%&lt;br /&gt;
| &amp;lt;code&amp;gt;configmgr&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 133,123,244&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 7.46%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 136,653,675&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 5.83%&lt;br /&gt;
| &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 115,297,223&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 4.65%&lt;br /&gt;
| &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 115,251,998&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 5.35%&lt;br /&gt;
| &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 110,134,686&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 5.67%&lt;br /&gt;
| &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 110,172,575&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 6.17%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;store&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 133,941,126&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 5.71%&lt;br /&gt;
| &amp;lt;code&amp;gt;cppu&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 104,329,278&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 4.21%&lt;br /&gt;
| &amp;lt;code&amp;gt;cppu&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 104,274,668&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 4.84%&lt;br /&gt;
| &amp;lt;code&amp;gt;cppu&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 99,445,552&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 5.12%&lt;br /&gt;
| &amp;lt;code&amp;gt;cppu&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 99,404,356&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 5.57%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;cppu&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 101,645,154&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 4.34%&lt;br /&gt;
| &amp;lt;code&amp;gt;cppuhelper&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 69,983,048&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.82%&lt;br /&gt;
| &amp;lt;code&amp;gt;cppuhelper&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 69,869,741&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 3.24%&lt;br /&gt;
| &amp;lt;code&amp;gt;fontconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 62,572,767&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 3.22%&lt;br /&gt;
| &amp;lt;code&amp;gt;fontconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 62,470,938&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 3.50%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;fontconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 91,592,358&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 3.91%&lt;br /&gt;
| &amp;lt;code&amp;gt;fontconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 62,635,949&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.53%&lt;br /&gt;
| &amp;lt;code&amp;gt;fontconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 62,579,720&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.90%&lt;br /&gt;
| &amp;lt;code&amp;gt;cppuhelper&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 49,302,429&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.54%&lt;br /&gt;
| &amp;lt;code&amp;gt;tl&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 39,124,806&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.19%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;tl&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 44,621,672&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.90%&lt;br /&gt;
| &amp;lt;code&amp;gt;store&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 49,663,092&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.00%&lt;br /&gt;
| &amp;lt;code&amp;gt;store&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 49,663,469&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.31%&lt;br /&gt;
| &amp;lt;code&amp;gt;tl&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 40,230,939&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.07%&lt;br /&gt;
| &amp;lt;code&amp;gt;cppuhelper&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 37,836,248&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.12%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;cppuhelper&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 38,147,061&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.63%&lt;br /&gt;
| &amp;lt;code&amp;gt;tl&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 46,338,109&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.87%&lt;br /&gt;
| &amp;lt;code&amp;gt;tl&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 46,338,474&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 2.15%&lt;br /&gt;
| &amp;lt;code&amp;gt;store&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 35,294,336&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.82%&lt;br /&gt;
| &amp;lt;code&amp;gt;comphelp&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 28,243,242&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.58%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;gcc_s&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 25,960,226&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.11%&lt;br /&gt;
| &amp;lt;code&amp;gt;vcl&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 37,507,044&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.51%&lt;br /&gt;
| &amp;lt;code&amp;gt;vcl&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 37,508,119&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.74%&lt;br /&gt;
| &amp;lt;code&amp;gt;comphelp&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 25,799,196&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.33%&lt;br /&gt;
| &amp;lt;code&amp;gt;store&amp;lt;/code&amp;gt;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 27,574,934&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 1.54%&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &amp;amp;hellip;&lt;br /&gt;
|}&lt;br /&gt;
* While the reductions from &amp;lt;var&amp;gt;O&amp;lt;/var&amp;gt; to&amp;amp;nbsp;&amp;lt;var&amp;gt;C&amp;lt;/var&amp;gt; are exactly as expected, the reductions from &amp;lt;var&amp;gt;C&amp;lt;/var&amp;gt; to&amp;amp;nbsp;&amp;lt;var&amp;gt;N&amp;lt;/var&amp;gt; seem over-optimistic (especially the extreme reduction for &amp;lt;code&amp;gt;cofnigmgr&amp;lt;/code&amp;gt;).  However, I could not find any mistakes (the set of dynamic libraries involved is exactly the same, high-level &amp;lt;code&amp;gt;callgrind&amp;lt;/code&amp;gt; call numbers appear comparable).  It appears that GCC&amp;amp;nbsp;4.3.3 more aggressively inlines functions, which might explain some of the impact on C++ libraries that might contain lots of small functions (like &amp;lt;code&amp;gt;configmgr&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cppuhelper&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;LD_DEBUG&amp;lt;/code&amp;gt; numbers:&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Relocations&lt;br /&gt;
! &amp;lt;var&amp;gt;B&amp;lt;/var&amp;gt;&lt;br /&gt;
! &amp;lt;var&amp;gt;O&amp;lt;/var&amp;gt;&lt;br /&gt;
! &amp;lt;var&amp;gt;C&amp;lt;/var&amp;gt;&lt;br /&gt;
! &amp;lt;var&amp;gt;N&amp;lt;/var&amp;gt;&lt;br /&gt;
! &amp;lt;var&amp;gt;F&amp;lt;/var&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! intra-object&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 44,088&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 45,226&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 15,110&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 14,793&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 14,790&lt;br /&gt;
|-&lt;br /&gt;
! inter-object&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 23,062&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 22,825&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 22,265&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 22,162&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 22,118&lt;br /&gt;
|-&lt;br /&gt;
! &amp;amp;sum;&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 67,150&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 68,051&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 37,375&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 36,955&lt;br /&gt;
| align=&amp;quot;right&amp;quot; | 36,908&lt;br /&gt;
|}&lt;br /&gt;
* The reductions from &amp;lt;var&amp;gt;C&amp;lt;/var&amp;gt; to &amp;lt;var&amp;gt;N&amp;lt;/var&amp;gt; appear to be due to&lt;br /&gt;
** inter-object resolutions of &amp;lt;code&amp;gt;_ZTI&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;_ZTS&amp;lt;/code&amp;gt; (i.e., RTTI) symbols for types in anonymous namespaces being done directly rather than via symbol lookup;&lt;br /&gt;
** inter- and intra-object resolutions of truly vague &amp;lt;code&amp;gt;_ZTV&amp;lt;/code&amp;gt; (i.e., vtable) symbols (i.e., belonging to types without &amp;lt;em&amp;gt;key functions&amp;lt;/em&amp;gt;, see [http://www.codesourcery.com/public/cxx-abi/abi.html#vague Itanium C++ ABI]) being done directly (i.e., always intra-object) rather than via symbol lookup;&lt;br /&gt;
** to a small degree, calls to functions like &amp;lt;code&amp;gt;memcpy&amp;lt;/code&amp;gt; being inlined instead of referring to &amp;lt;code&amp;gt;libc&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[Category:Performance]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Playing_with_Window_Toolkit_AWT&amp;diff=151763</id>
		<title>Playing with Window Toolkit AWT</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Playing_with_Window_Toolkit_AWT&amp;diff=151763"/>
		<updated>2009-12-03T06:04:27Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/NeedsRework}}&lt;br /&gt;
{{Documentation/Note|This chapter is old : written long before discovering the new Dialog for components in [[Documentation/DevGuide/WritingUNO/Accessing_Dialogs|Developer&amp;#039;s Guide]]. At the moment I have only managed such [[Component_and_Dialog|Dialogs in components]] but I hope to work and see if it is not possible to use them in binaries executable.}}&lt;br /&gt;
==Danny Brewer&amp;#039;s Explanations==&lt;br /&gt;
There are two different things here. Actually three. &lt;br /&gt;
# Dialogs &lt;br /&gt;
# AWT &lt;br /&gt;
# Forms &lt;br /&gt;
&lt;br /&gt;
Forms are much higher level than the other two. &lt;br /&gt;
&lt;br /&gt;
Of the first two, Dialogs are something using the UnoDialogControl and its model. You can also create AWT windows with controls. &lt;br /&gt;
&lt;br /&gt;
AWT windows are modeless, and are not tied to any other window. &lt;br /&gt;
&lt;br /&gt;
AWT windows are not the same thing as dialogs. &lt;br /&gt;
&lt;br /&gt;
Generally, dialogs are operated modally by calling execute() on the dialog. &lt;br /&gt;
&lt;br /&gt;
I have also had some success with operating dialogs modelessly. Just unhide the dialog, and it can be used modelessly. One drawback is that the modeless dialog seems to be tied to some concept of a &amp;quot;parent&amp;quot; window. I&amp;#039;m not sure, but I think that tends to be whatever window was in front when you created the dialog. So for example, you could create a modeless dialog that allows you to work with your document, but that modeless dialog&amp;#039;s behavior appears to be tied to that document. Bring the modeless dialog to the front, and its document also comes to the front.&lt;br /&gt;
&lt;br /&gt;
==The MessageBox Windows==&lt;br /&gt;
The starting code is roughly the same as previously (examples/DevelopersGuide/ProfUNO/CppBinding/). We examine also the “&amp;lt;OpenOffice.org1.1_SDK&amp;gt;/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp” example where we find a MessageBox window.  The corresponding code is given here (see also &amp;lt;idl&amp;gt;com.sun.star.awt.XWindowPeer&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.awt.XMessageBox&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.frame.XFrame&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.awt.XToolkit&amp;lt;/idl&amp;gt; interfaces and &amp;lt;idl&amp;gt;com.sun.star.awt.WindowDescriptor&amp;lt;/idl&amp;gt; structure and &amp;lt;idl&amp;gt;com.sun.star.awt.WindowAttribute&amp;lt;/idl&amp;gt; constants ) :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 1 MessageBox Windows (deprecated)&lt;br /&gt;
// C++&lt;br /&gt;
// Don&amp;#039;t forget to add : #include &amp;lt;com/sun/star/awt/WindowDescriptor.hpp&amp;gt;&lt;br /&gt;
// Don&amp;#039;t forget to add &amp;quot;com.sun.star.awt.WindowDescriptor \&amp;quot; in the makefile&lt;br /&gt;
// Don&amp;#039;t forget to add : #include &amp;lt;com/sun/star/awt/WindowAttribute.hpp&amp;gt;&lt;br /&gt;
// Don&amp;#039;t forget to add &amp;quot;com.sun.star.awt.WindowAttribute \&amp;quot; in the makefile&lt;br /&gt;
// Don&amp;#039;t forget to add : #include &amp;lt;com/sun/star/awt/XWindowPeer.hpp&amp;gt;&lt;br /&gt;
// Don&amp;#039;t forget to add &amp;quot;com.sun.star.awt.XWindowPeer \&amp;quot; in the makefile&lt;br /&gt;
// Don&amp;#039;t forget to add : #include &amp;lt;com/sun/star/awt/XMessageBox.hpp&amp;gt;&lt;br /&gt;
// Don&amp;#039;t forget to add &amp;quot;com.sun.star.awt.XMessageBox \&amp;quot; in the makefile&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
  * Show a message box with the UNO based toolkit&lt;br /&gt;
  */&lt;br /&gt;
static void ShowMessageBox( const Reference&amp;lt; XToolkit &amp;gt;&amp;amp; rToolkit, &lt;br /&gt;
               const Reference&amp;lt; XFrame &amp;gt;&amp;amp; rFrame, const OUString&amp;amp; aTitle, const OUString&amp;amp; aMsgText )&lt;br /&gt;
{&lt;br /&gt;
    if ( rFrame.is() &amp;amp;&amp;amp; rToolkit.is() )&lt;br /&gt;
    {&lt;br /&gt;
        // describe window properties.&lt;br /&gt;
        WindowDescriptor                aDescriptor;&lt;br /&gt;
        aDescriptor.Type              = WindowClass_MODALTOP;&lt;br /&gt;
        aDescriptor.WindowServiceName = OUString( RTL_CONSTASCII_USTRINGPARAM( &amp;quot;infobox&amp;quot; ));&lt;br /&gt;
        aDescriptor.ParentIndex       = -1;&lt;br /&gt;
        aDescriptor.Parent            = Reference&amp;lt; XWindowPeer &amp;gt;&lt;br /&gt;
						( rFrame-&amp;gt;getContainerWindow(), UNO_QUERY );&lt;br /&gt;
        aDescriptor.Bounds            = Rectangle(300,200,300,200);&lt;br /&gt;
        aDescriptor.WindowAttributes  = WindowAttribute::BORDER | &lt;br /&gt;
                                          WindowAttribute::MOVEABLE | WindowAttribute::CLOSEABLE;&lt;br /&gt;
&lt;br /&gt;
        Reference&amp;lt; XWindowPeer &amp;gt; xPeer = rToolkit-&amp;gt;createWindow( aDescriptor );&lt;br /&gt;
        if ( xPeer.is() )&lt;br /&gt;
        {&lt;br /&gt;
            Reference&amp;lt; XMessageBox &amp;gt; xMsgBox( xPeer, UNO_QUERY );&lt;br /&gt;
            if ( xMsgBox.is() )&lt;br /&gt;
            {&lt;br /&gt;
                xMsgBox-&amp;gt;setCaptionText( aTitle );&lt;br /&gt;
                xMsgBox-&amp;gt;setMessageText( aMsgText );&lt;br /&gt;
                xMsgBox-&amp;gt;execute();&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similar script in [[Python|PyUNO]] from the Python Samples included in &amp;lt;openoffice.org version&amp;gt;/share/Scripts/python/MsgBox.py:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from com.sun.star.awt import Rectangle&lt;br /&gt;
from com.sun.star.awt import WindowDescriptor&lt;br /&gt;
&lt;br /&gt;
from com.sun.star.awt.WindowClass import MODALTOP&lt;br /&gt;
from com.sun.star.awt.VclWindowPeerAttribute import OK, OK_CANCEL, YES_NO, YES_NO_CANCEL, \&lt;br /&gt;
                              RETRY_CANCEL, DEF_OK, DEF_CANCEL, DEF_RETRY, DEF_YES, DEF_NO&lt;br /&gt;
&lt;br /&gt;
def TestMessageBox():&lt;br /&gt;
	doc = XSCRIPTCONTEXT.getDocument()&lt;br /&gt;
	parentwin = doc.CurrentController.Frame.ContainerWindow&lt;br /&gt;
	&lt;br /&gt;
	s = &amp;quot;This is a test&amp;quot;&lt;br /&gt;
	t = &amp;quot;Test&amp;quot;&lt;br /&gt;
	res = MessageBox(parentwin, s, t, &amp;quot;querybox&amp;quot;, YES_NO_CANCEL + DEF_NO)&lt;br /&gt;
	&lt;br /&gt;
	s = res&lt;br /&gt;
	MessageBox(parentwin, s, t, &amp;quot;infobox&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Show a message box with the UNO based toolkit&lt;br /&gt;
def MessageBox(ParentWin, MsgText, MsgTitle, MsgType=&amp;quot;messbox&amp;quot;, MsgButtons=OK):&lt;br /&gt;
	&lt;br /&gt;
	MsgType = MsgType.lower()&lt;br /&gt;
	&lt;br /&gt;
	#available msg types&lt;br /&gt;
	MsgTypes = (&amp;quot;messbox&amp;quot;, &amp;quot;infobox&amp;quot;, &amp;quot;errorbox&amp;quot;, &amp;quot;warningbox&amp;quot;, &amp;quot;querybox&amp;quot;)&lt;br /&gt;
	&lt;br /&gt;
	if MsgType not in MsgTypes:&lt;br /&gt;
		MsgType = &amp;quot;messbox&amp;quot;&lt;br /&gt;
	&lt;br /&gt;
	#describe window properties.&lt;br /&gt;
	aDescriptor = WindowDescriptor()&lt;br /&gt;
	aDescriptor.Type = MODALTOP&lt;br /&gt;
	aDescriptor.WindowServiceName = MsgType&lt;br /&gt;
	aDescriptor.ParentIndex = -1&lt;br /&gt;
	aDescriptor.Parent = ParentWin&lt;br /&gt;
	#aDescriptor.Bounds = Rectangle()&lt;br /&gt;
	aDescriptor.WindowAttributes = MsgButtons&lt;br /&gt;
	&lt;br /&gt;
	tk = ParentWin.getToolkit()&lt;br /&gt;
	msgbox = tk.createWindow(aDescriptor)&lt;br /&gt;
	&lt;br /&gt;
	msgbox.setMessageText(MsgText)&lt;br /&gt;
	if MsgTitle :&lt;br /&gt;
		msgbox.setCaptionText(MsgTitle)&lt;br /&gt;
		&lt;br /&gt;
	return msgbox.execute()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
g_exportedScripts = TestMessageBox,&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To understand the WindowAttribute::BORDER and other constants, we first have a look at the IDL file “WindowAttribute.idl” describing the windows&amp;#039; attributes (&amp;lt;idl&amp;gt;com.sun.star.awt.WindowAttribute&amp;lt;/idl&amp;gt;) :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 2 WindowAttribute IDL File &lt;br /&gt;
// IDL&lt;br /&gt;
module com {  module sun {  module star {  module awt {&lt;br /&gt;
constants WindowAttribute&lt;br /&gt;
{&lt;br /&gt;
	const long SHOW = 1; &lt;br /&gt;
	const long FULLSIZE = 2; &lt;br /&gt;
	const long OPTIMUMSIZE = 4; &lt;br /&gt;
	const long MINSIZE = 8; &lt;br /&gt;
	const long BORDER = 16; &lt;br /&gt;
	const long SIZEABLE = 32; &lt;br /&gt;
	const long MOVEABLE = 64; &lt;br /&gt;
	const long CLOSEABLE = 128; &lt;br /&gt;
	const long SYSTEMDEPENDENT = 256;  &lt;br /&gt;
};&lt;br /&gt;
}; }; }; };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We have a look at &amp;lt;idl&amp;gt;com.sun.star.awt.XMessageBox&amp;lt;/idl&amp;gt; IDL file :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 3 XMessageBox Interface : IDL File &lt;br /&gt;
// IDL&lt;br /&gt;
module com {  module sun {  module star {  module awt {&lt;br /&gt;
/** gives access to a message box.&lt;br /&gt;
    @deprecated&lt;br /&gt;
 */&lt;br /&gt;
interface XMessageBox: com::sun::star::uno::XInterface&lt;br /&gt;
{&lt;br /&gt;
	[oneway] void setCaptionText( [in] string aText );&lt;br /&gt;
	string getCaptionText();&lt;br /&gt;
	[oneway] void setMessageText( [in] string aText );&lt;br /&gt;
	string getMessageText();&lt;br /&gt;
	short execute();&lt;br /&gt;
};&lt;br /&gt;
}; }; }; };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
where we learn this interface is deprecated.&lt;br /&gt;
We give now a complete main in a listing to learn how to use the previous ShowMessageBox procedure :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 4 Complete Program showing a Message Box Window&lt;br /&gt;
//C++&lt;br /&gt;
int main( ) {&lt;br /&gt;
//retrieve an instance of the remote service manager&lt;br /&gt;
    Reference&amp;lt; XMultiServiceFactory &amp;gt; rOfficeServiceManager;&lt;br /&gt;
    rOfficeServiceManager = ooConnect();&lt;br /&gt;
    if( rOfficeServiceManager.is() ){&lt;br /&gt;
        printf( &amp;quot;Connected sucessfully to the office\n&amp;quot; );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
//get the desktop service using createInstance returns an XInterface type&lt;br /&gt;
    Reference&amp;lt; XInterface  &amp;gt; Desktop = rOfficeServiceManager-&amp;gt;createInstance(&lt;br /&gt;
    OUString::createFromAscii( &amp;quot;com.sun.star.frame.Desktop&amp;quot; ));&lt;br /&gt;
&lt;br /&gt;
//query for the XComponentLoader interface&lt;br /&gt;
    Reference&amp;lt; XComponentLoader &amp;gt; rComponentLoader (Desktop, UNO_QUERY);&lt;br /&gt;
    if( rComponentLoader.is() ){&lt;br /&gt;
        	printf( &amp;quot;XComponentloader successfully instanciated\n&amp;quot; );&lt;br /&gt;
    	}&lt;br /&gt;
// Don&amp;#039;t forget to add : #include &amp;lt;com/sun/star/awt/XToolkit.hpp&amp;gt;&lt;br /&gt;
// Don&amp;#039;t forget to add &amp;quot;com.sun.star.awt.XToolkit \&amp;quot; in the makefile&lt;br /&gt;
// Query the XTollkit Interface&lt;br /&gt;
	Reference&amp;lt; XToolkit &amp;gt;rToolkit = Reference&amp;lt; XToolkit &amp;gt;&lt;br /&gt;
		( rOfficeServiceManager-&amp;gt;createInstance(&lt;br /&gt;
                                        OUString( RTL_CONSTASCII_USTRINGPARAM(&lt;br /&gt;
                                            &amp;quot;com.sun.star.awt.Toolkit&amp;quot; ))), UNO_QUERY );&lt;br /&gt;
&lt;br /&gt;
	if (rToolkit.is()) {&lt;br /&gt;
	  printf (&amp;quot;OK...\n&amp;quot;);&lt;br /&gt;
	} else printf(&amp;quot;Toolkit Error\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	Reference&amp;lt; XDesktop &amp;gt; rDesktop(Desktop,UNO_QUERY);&lt;br /&gt;
	Reference&amp;lt; XFrame &amp;gt; rFrame=rDesktop-&amp;gt;getCurrentFrame();&lt;br /&gt;
	if (rFrame.is()) printf(&amp;quot;rFrame ... OK\n&amp;quot;); else printf(&amp;quot;rFrame Error\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	ShowMessageBox( rToolkit, rFrame,OUString::createFromAscii(&amp;quot;Hello&amp;quot;) ,&lt;br /&gt;
				OUString::createFromAscii(&amp;quot;Your First Message\n OK ?&amp;quot;)  );&lt;br /&gt;
&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
(See also &amp;lt;idl&amp;gt;com.sun.star.awt.XToolkit&amp;lt;/idl&amp;gt; interface and &amp;lt;idl&amp;gt;com.sun.star.awt.Toolkit&amp;lt;/idl&amp;gt; service).&lt;br /&gt;
We can draw three important things from this code :&lt;br /&gt;
*the way we can use such an IDL file (given above) [[SDKCppLanguage#To_go_further_:_the_Constant_Type_Problem|with constants in C++]] : it&amp;#039;s not the first time we encounter this kind of IDL file,&lt;br /&gt;
*the way we can access an interface through a service with a createInstance and UNO_QUERY simultaneously (see how do we obtain rToolkit)&lt;br /&gt;
*we see also how we obtain a frame from a &amp;lt;idl&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idl&amp;gt; service.&lt;br /&gt;
We will present later a Desktop Helper using this message box code. (See [[Constructing_Helpers#Desktop_Helper_with_message_box|here]])&lt;br /&gt;
&lt;br /&gt;
==A very simple Window==&lt;br /&gt;
We give now a listing to construct a very simple windows using UNO toolkit (See also &amp;lt;idl&amp;gt;com.sun.star.awt.XToolkit&amp;lt;/idl&amp;gt; , &amp;lt;idl&amp;gt;com.sun.star.frame.XFrame&amp;lt;/idl&amp;gt; and &amp;lt;idl&amp;gt;com.sun.star.frame.XDesktop&amp;lt;/idl&amp;gt; interfaces) :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 5 Constructing a simple Window&lt;br /&gt;
// C++&lt;br /&gt;
main( ) {&lt;br /&gt;
    Reference&amp;lt; XMultiServiceFactory &amp;gt; rOfficeServiceManager;&lt;br /&gt;
    rOfficeServiceManager = ooConnect();&lt;br /&gt;
&lt;br /&gt;
    if( rOfficeServiceManager.is() ){&lt;br /&gt;
        printf( &amp;quot;Connected sucessfully to the office\n&amp;quot; );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
//get the desktop service using createInstance returns an XInterface type&lt;br /&gt;
    Reference&amp;lt; XInterface  &amp;gt; Desktop = rOfficeServiceManager-&amp;gt;createInstance(&lt;br /&gt;
    OUString::createFromAscii( &amp;quot;com.sun.star.frame.Desktop&amp;quot; ));&lt;br /&gt;
&lt;br /&gt;
//query for the XComponentLoader interface&lt;br /&gt;
    Reference&amp;lt; XComponentLoader &amp;gt; rComponentLoader (Desktop, UNO_QUERY);&lt;br /&gt;
    if( rComponentLoader.is() ){&lt;br /&gt;
        	printf( &amp;quot;XComponentloader successfully instanciated\n&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    	}&lt;br /&gt;
&lt;br /&gt;
// Don&amp;#039;t forget to add : #include &amp;lt;com/sun/star/awt/XToolkit.hpp&amp;gt;&lt;br /&gt;
// Don&amp;#039;t forget to add &amp;quot;com.sun.star.awt.XToolkit \&amp;quot; in the makefile&lt;br /&gt;
// Query the XTollkit Interface&lt;br /&gt;
	Reference&amp;lt; XToolkit &amp;gt;rToolkit = Reference&amp;lt; XToolkit &amp;gt;( rOfficeServiceManager-&amp;gt;createInstance(&lt;br /&gt;
                                        OUString( RTL_CONSTASCII_USTRINGPARAM(&lt;br /&gt;
                                            &amp;quot;com.sun.star.awt.Toolkit&amp;quot; ))), UNO_QUERY );&lt;br /&gt;
&lt;br /&gt;
	if (rToolkit.is()) {&lt;br /&gt;
	  printf (&amp;quot;OK...\n&amp;quot;);&lt;br /&gt;
	} else printf(&amp;quot;Toolkit Error\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	Reference&amp;lt; XDesktop &amp;gt; rDesktop(Desktop,UNO_QUERY);&lt;br /&gt;
&lt;br /&gt;
// *** essai fenetre&lt;br /&gt;
	if ( rToolkit.is() )&lt;br /&gt;
    	{&lt;br /&gt;
        // describe window properties.&lt;br /&gt;
        WindowDescriptor                aDescriptor;&lt;br /&gt;
        aDescriptor.Type              = WindowClass_TOP;&lt;br /&gt;
        aDescriptor.WindowServiceName = OUString( RTL_CONSTASCII_USTRINGPARAM(&amp;quot;&amp;quot;));&lt;br /&gt;
        aDescriptor.ParentIndex       = -1;&lt;br /&gt;
		aDescriptor.Parent            = rToolkit-&amp;gt;getDesktopWindow();&lt;br /&gt;
        aDescriptor.Bounds            = Rectangle(100,200,300,400);&lt;br /&gt;
        aDescriptor.WindowAttributes  = WindowAttribute::BORDER | WindowAttribute::MOVEABLE 						| WindowAttribute::SHOW	| WindowAttribute::CLOSEABLE &lt;br /&gt;
						| WindowAttribute::SIZEABLE;&lt;br /&gt;
	Reference&amp;lt; XWindowPeer &amp;gt; xWindowPeer  = rToolkit-&amp;gt;createWindow( aDescriptor );&lt;br /&gt;
	Reference&amp;lt; XWindow &amp;gt; xWindow(xWindowPeer,UNO_QUERY);&lt;br /&gt;
	xWindowPeer-&amp;gt;setBackground(0xFF00FF);&lt;br /&gt;
&lt;br /&gt;
// At this point, if you stop the program, you will have a new OOo window on the screen, &lt;br /&gt;
//but you cannot do anything  with it.  You cannot even close it!&lt;br /&gt;
	// create a new frame&lt;br /&gt;
	Reference&amp;lt; XFrame &amp;gt; xFrame =Reference&amp;lt; XFrame &amp;gt;( rOfficeServiceManager-&amp;gt;createInstance(&lt;br /&gt;
                                        OUString( RTL_CONSTASCII_USTRINGPARAM(&lt;br /&gt;
                                            &amp;quot;com.sun.star.frame.Frame&amp;quot; ))), UNO_QUERY );&lt;br /&gt;
	xFrame-&amp;gt;initialize(xWindow);&lt;br /&gt;
	Reference &amp;lt; XFramesSupplier &amp;gt; xFramesSupplier(Desktop,UNO_QUERY);&lt;br /&gt;
	xFrame-&amp;gt;setCreator(xFramesSupplier);&lt;br /&gt;
	xFrame-&amp;gt;setName(OUString::createFromAscii(&amp;quot;Window 1&amp;quot;));&lt;br /&gt;
	getchar();&lt;br /&gt;
	}&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==The file picker dialog==&lt;br /&gt;
We want provide a dialog box for searching a file and returning its name. We start from a Bernard Marcelly&amp;#039;s book example. When working with file picker dialog, we are concerned with three IDL files. Here is the first one (&amp;lt;idl&amp;gt;com.sun.star.ui.dialogs.XFilePicker&amp;lt;/idl&amp;gt;) :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 6 XFilePicker Interface : IDL File &lt;br /&gt;
// IDL&lt;br /&gt;
module com { module sun { module star { module ui { module dialogs {&lt;br /&gt;
interface XFilePicker: com::sun::star::ui::dialogs::XExecutableDialog&lt;br /&gt;
{&lt;br /&gt;
	void setMultiSelectionMode( [in] boolean bMode );&lt;br /&gt;
	void setDefaultName( [in] string aName );&lt;br /&gt;
	void setDisplayDirectory( [in] string aDirectory )&lt;br /&gt;
		raises( ::com::sun::star::lang::IllegalArgumentException );&lt;br /&gt;
	string getDisplayDirectory();&lt;br /&gt;
	sequence&amp;lt; string &amp;gt; getFiles();&lt;br /&gt;
};&lt;br /&gt;
}; }; }; }; };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The beginning of this file indicates we are concerned with &amp;lt;idl&amp;gt;com.sun.star.ui.dialogs.XExecutableDialog&amp;lt;/idl&amp;gt; too  because of inheritance :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 7 XExecutableDialog Interface : IDL File &lt;br /&gt;
// IDL&lt;br /&gt;
module com { module sun { module star { module ui { module dialogs {&lt;br /&gt;
interface XExecutableDialog: com::sun::star::uno::XInterface&lt;br /&gt;
{&lt;br /&gt;
	void setTitle( [in] string aTitle );&lt;br /&gt;
	short execute();&lt;br /&gt;
};&lt;br /&gt;
}; }; }; }; };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
and what is more difficult to see is we are also concerned with &amp;lt;idl&amp;gt;com.sun.star.ui.dialogs.ExecutableDialogresults&amp;lt;/idl&amp;gt; [[SDKCppLanguage#To_go_further_:_the_Constant_Type_Problem|IDL constants]]:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 8 ExecutableDialogresults values : IDL File &lt;br /&gt;
// IDL&lt;br /&gt;
module com { module sun { module star { module ui { module dialogs {&lt;br /&gt;
constants ExecutableDialogResults&lt;br /&gt;
{&lt;br /&gt;
	const short CANCEL = 0;&lt;br /&gt;
	const short OK     = 1;&lt;br /&gt;
};&lt;br /&gt;
}; }; }; }; };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The way to obtain the FilePicker dialog can be explained as follow. First you have to obtain a &amp;lt;idl&amp;gt;com.sun.star.ui.dialogs.XFilePicker&amp;lt;/idl&amp;gt; interface. After we use a setDisplayDirectory for an example, then execute the dialog box and finally get the first of chosen files.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 9 a File Picker Dialog&lt;br /&gt;
// LINUX C++ (Only the file path is LINUX-like)&lt;br /&gt;
// based on Bernard Marcelly&amp;#039;s  Example (Book p512)&lt;br /&gt;
// Don&amp;#039;t forget #include &amp;lt;osl/file.hxx&amp;gt;&lt;br /&gt;
	OUString sDocUrl;&lt;br /&gt;
	osl::FileBase::getFileURLFromSystemPath(&lt;br /&gt;
				OUString::createFromAscii(&amp;quot;/home/smoutou/&amp;quot;),sDocUrl);&lt;br /&gt;
&lt;br /&gt;
// Don&amp;#039;t forget to add : using namespace com::sun::star::ui::dialogs;&lt;br /&gt;
// Don&amp;#039;t forget to add : #include &amp;lt;com/sun/star/ui/dialogs/XFilePicker.hpp&amp;gt;&lt;br /&gt;
// Don&amp;#039;t forget to add &amp;quot;com.sun.star.ui.dialogs.XFilePicker \&amp;quot; in the makefile&lt;br /&gt;
// Query the XFilePicker interface&lt;br /&gt;
&lt;br /&gt;
	Reference&amp;lt; XFilePicker &amp;gt; rFilePicker = Reference&amp;lt; XFilePicker &amp;gt;&lt;br /&gt;
					( rOfficeServiceManager-&amp;gt;createInstance(&lt;br /&gt;
                          OUString( RTL_CONSTASCII_USTRINGPARAM(&lt;br /&gt;
                          &amp;quot;com.sun.star.ui.dialogs.FilePicker&amp;quot; ))), UNO_QUERY );&lt;br /&gt;
&lt;br /&gt;
	rFilePicker-&amp;gt;setDisplayDirectory( sDocUrl);&lt;br /&gt;
	short result=rFilePicker-&amp;gt;execute();&lt;br /&gt;
&lt;br /&gt;
// Don&amp;#039;t forget to add : #include &amp;lt;com/sun/star/ui/dialogs/ExecutableDialogResults.hpp&amp;gt;&lt;br /&gt;
// Don&amp;#039;t forget to add &amp;quot;com.sun.star.ui.dialogs.ExecutableDialogResults \&amp;quot; in the makefile&lt;br /&gt;
	if (result == ExecutableDialogResults::OK)&lt;br /&gt;
	  ShowMessageBox( rToolkit, rFrame,OUString::createFromAscii(&amp;quot;Result&amp;quot;) ,&lt;br /&gt;
			rFilePicker-&amp;gt;getFiles()[0]  );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
It is possible to modify the filter names with the &amp;lt;idl&amp;gt;com.sun.star.ui.dialogs.XFilterManager&amp;lt;/idl&amp;gt; interface. Here is the corresponding IDL file :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 10 XFilterManager Interface : IDL File &lt;br /&gt;
// IDL&lt;br /&gt;
module com { module sun { module star { module ui { module dialogs {&lt;br /&gt;
interface XFilterManager: com::sun::star::uno::XInterface&lt;br /&gt;
{&lt;br /&gt;
	void appendFilter( [in] string aTitle, [in] string aFilter )&lt;br /&gt;
		raises( ::com::sun::star::lang::IllegalArgumentException );&lt;br /&gt;
	void setCurrentFilter( [in] string aTitle )&lt;br /&gt;
		raises( ::com::sun::star::lang::IllegalArgumentException );&lt;br /&gt;
	string getCurrentFilter( );&lt;br /&gt;
};&lt;br /&gt;
}; }; }; }; };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
and now a C++ example which use this interface :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 11 Using the File Picker&lt;br /&gt;
// LINUX C++&lt;br /&gt;
// Don&amp;#039;t forget #include &amp;lt;osl/file.hxx&amp;gt;&lt;br /&gt;
	OUString sDocUrl;&lt;br /&gt;
	osl::FileBase::getFileURLFromSystemPath(&lt;br /&gt;
						OUString::createFromAscii(&amp;quot;/home/smoutou/&amp;quot;),sDocUrl);&lt;br /&gt;
// Don&amp;#039;t forget to add : using namespace com::sun::star::ui::dialogs;&lt;br /&gt;
// Don&amp;#039;t forget to add : #include &amp;lt;com/sun/star/ui/dialogs/XFilePicker.hpp&amp;gt;&lt;br /&gt;
// Don&amp;#039;t forget to add &amp;quot;com.sun.star.ui.dialogs.XFilePicker \&amp;quot; in the makefile&lt;br /&gt;
//	Reference&amp;lt; XFilePicker &amp;gt; rFilePicker(rDesktop,UNO_QUERY);&lt;br /&gt;
	Reference&amp;lt; XFilePicker &amp;gt; rFilePicker = Reference&amp;lt; XFilePicker &amp;gt;&lt;br /&gt;
					( rOfficeServiceManager-&amp;gt;createInstance(&lt;br /&gt;
                                 OUString( RTL_CONSTASCII_USTRINGPARAM(&lt;br /&gt;
                                 &amp;quot;com.sun.star.ui.dialogs.FilePicker&amp;quot; ))), UNO_QUERY );&lt;br /&gt;
&lt;br /&gt;
	rFilePicker-&amp;gt;setDisplayDirectory( sDocUrl);&lt;br /&gt;
&lt;br /&gt;
// Don&amp;#039;t forget to add : #include &amp;lt;com/sun/star/ui/dialogs/XFilterManager.hpp&amp;gt;&lt;br /&gt;
// Don&amp;#039;t forget to add &amp;quot;com.sun.star.ui.dialogs.XFilterManager \&amp;quot; in the makefile&lt;br /&gt;
	Reference&amp;lt; XFilterManager &amp;gt; rFilterManager (rFilePicker, UNO_QUERY);&lt;br /&gt;
	rFilterManager-&amp;gt;appendFilter(OUString::createFromAscii(&amp;quot;Texts&amp;quot;),&lt;br /&gt;
					OUString::createFromAscii(&amp;quot;*.txt&amp;quot;));&lt;br /&gt;
	rFilterManager-&amp;gt;appendFilter(OUString::createFromAscii(&amp;quot;Docs OpenOffice&amp;quot;),&lt;br /&gt;
					OUString::createFromAscii(&amp;quot;*.sxw;*.sxc&amp;quot;));&lt;br /&gt;
	rFilterManager-&amp;gt;setCurrentFilter(OUString::createFromAscii(&amp;quot;Docs OpenOffice&amp;quot;));&lt;br /&gt;
	short result=rFilePicker-&amp;gt;execute();&lt;br /&gt;
&lt;br /&gt;
// Don&amp;#039;t forget to add : #include &amp;lt;com/sun/star/ui/dialogs/ExecutableDialogResults.hpp&amp;gt;&lt;br /&gt;
// Don&amp;#039;t forget to add &amp;quot;com.sun.star.ui.dialogs.ExecutableDialogResults \&amp;quot; in the makefile&lt;br /&gt;
	if (result == ExecutableDialogResults::OK)&lt;br /&gt;
	  ShowMessageBox( rToolkit, rFrame,OUString::createFromAscii(&amp;quot;Result&amp;quot;) ,&lt;br /&gt;
			rFilePicker-&amp;gt;getFiles()[0]  );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
See also &amp;lt;idl&amp;gt;com.sun.star.ui.dialogs.XFilePicker&amp;lt;/idl&amp;gt; and &amp;lt;idl&amp;gt;com.sun.star.ui.dialogs.XFilterManager&amp;lt;/idl&amp;gt; interfaces and &amp;lt;idl&amp;gt;com.sun.star.ui.dialogs.ExecutableDialogResults&amp;lt;/idl&amp;gt; constants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It&amp;#039;s time to show how to construct a save as Dialog.&lt;br /&gt;
&lt;br /&gt;
==Save as Dialog==&lt;br /&gt;
We again start from a Bernard Marcelly&amp;#039;s example. Our problem is to translate these OOoBasic lines :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
&amp;#039;Listing 12 Save Dialog&lt;br /&gt;
REM  *****  BASIC  *****&lt;br /&gt;
FP=CreateUnoService(&amp;quot;com.sun.star.ui.dialogs.FilePicker&amp;quot;)&lt;br /&gt;
Dim FPtype(0) As Integer&lt;br /&gt;
FPtype(0)=com.sun.star.ui.dialogs.TemplateDescription.FILESAVE_SIMPLE&lt;br /&gt;
With FP&lt;br /&gt;
	.initialize(FPtype())&lt;br /&gt;
....&lt;br /&gt;
End With&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
particularly the « initialize » method.&lt;br /&gt;
At first, we look for the constant to  transform the previous FilePicker dialog. The constants are defined in the &amp;lt;idl&amp;gt;com.sun.star.ui.dialogs.TemplateDescription&amp;lt;/idl&amp;gt; file as descibed below ([[SDKCppLanguage#To_go_further_:_the_Constant_Type_Problem|see how to use UNO constants with C++]]) :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 13 TemplateDescription Constants : IDL File &lt;br /&gt;
// IDL&lt;br /&gt;
module com { module sun { module star { module ui { module dialogs {&lt;br /&gt;
constants TemplateDescription&lt;br /&gt;
{&lt;br /&gt;
	const short FILEOPEN_SIMPLE                                = 0;&lt;br /&gt;
	const short FILESAVE_SIMPLE                                = 1;&lt;br /&gt;
	const short FILESAVE_AUTOEXTENSION_PASSWORD                = 2;&lt;br /&gt;
	const short FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS  = 3;&lt;br /&gt;
	const short FILESAVE_AUTOEXTENSION_SELECTION               = 4;&lt;br /&gt;
	const short FILESAVE_AUTOEXTENSION_TEMPLATE                = 5;&lt;br /&gt;
	const short FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE           = 6;&lt;br /&gt;
	const short FILEOPEN_PLAY                                  = 7;&lt;br /&gt;
	const short FILEOPEN_READONLY_VERSION                      = 8;&lt;br /&gt;
	const short FILEOPEN_LINK_PREVIEW				           = 9;&lt;br /&gt;
	const short FILESAVE_AUTOEXTENSION			               = 10;&lt;br /&gt;
};&lt;br /&gt;
}; }; }; }; };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Looking for initialize method, we have a look in &amp;lt;idl&amp;gt;com.sun.star.ui.dialogs.FilePicker&amp;lt;/idl&amp;gt; service :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 14 FilePiker service : IDL File &lt;br /&gt;
// IDL&lt;br /&gt;
module com { module sun { module star { module ui { module dialogs {&lt;br /&gt;
interface XFilePicker;&lt;br /&gt;
interface XFilePickerNotifier;&lt;br /&gt;
interface XFilePickerControlAccess;&lt;br /&gt;
interface XFilterManager;&lt;br /&gt;
interface XFilePreview;&lt;br /&gt;
interface XFilterGroupManager;&lt;br /&gt;
&lt;br /&gt;
service FilePicker&lt;br /&gt;
{&lt;br /&gt;
	[optional, property] string HelpURL;&lt;br /&gt;
	interface XFilePicker;&lt;br /&gt;
	interface XFilePickerNotifier;&lt;br /&gt;
	interface XFilterManager;&lt;br /&gt;
	[optional] interface XFilePreview;&lt;br /&gt;
	[optional] interface XFilePickerControlAccess;&lt;br /&gt;
	[optional] interface XFilterGroupManager;&lt;br /&gt;
	[optional] interface com::sun::star::lang::XInitialization;&lt;br /&gt;
	[optional] interface com::sun::star::util::XCancellable;&lt;br /&gt;
	interface com::sun::star::lang::XComponent;&lt;br /&gt;
	interface com::sun::star::lang::XServiceInfo;&lt;br /&gt;
	interface com::sun::star::lang::XTypeProvider;&lt;br /&gt;
};&lt;br /&gt;
}; }; }; }; };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
where you see an &amp;lt;idl&amp;gt;com.sun.star.lang.XInitialization&amp;lt;/idl&amp;gt; interface. Therefore we give the XInitialization.idl file :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 15 XInitialisation Interface : IDL File &lt;br /&gt;
// IDL&lt;br /&gt;
module com {  module sun {  module star {  module lang {&lt;br /&gt;
interface XInitialization: com::sun::star::uno::XInterface&lt;br /&gt;
{ &lt;br /&gt;
	void initialize( [in] sequence&amp;lt;any&amp;gt; aArguments ) &lt;br /&gt;
			raises( com::sun::star::uno::Exception ); &lt;br /&gt;
 &lt;br /&gt;
}; &lt;br /&gt;
}; }; }; };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
It&amp;#039;s OK, we get it. We see we have to pass an any sequence to the initialize procedure. It&amp;#039;s time to write the C++ corresponding code.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 16 Invoking the Save Dialog&lt;br /&gt;
	// LINUX C++&lt;br /&gt;
	// inspired by Bernard Marcelly&amp;#039;s Example p515&lt;br /&gt;
// Don&amp;#039;t forget #include &amp;lt;osl/file.hxx&amp;gt;&lt;br /&gt;
	OUString sDocUrl;&lt;br /&gt;
	osl::FileBase::getFileURLFromSystemPath(&lt;br /&gt;
						OUString::createFromAscii(&amp;quot;/home/smoutou/&amp;quot;),sDocUrl);&lt;br /&gt;
// Don&amp;#039;t forget to add : using namespace com::sun::star::ui::dialogs;&lt;br /&gt;
// Don&amp;#039;t forget to add : #include &amp;lt;com/sun/star/ui/dialogs/XFilePicker.hpp&amp;gt;&lt;br /&gt;
// Don&amp;#039;t forget to add &amp;quot;com.sun.star.ui.dialogs.XFilePicker \&amp;quot; in the makefile&lt;br /&gt;
//	Reference&amp;lt; XFilePicker &amp;gt; rFilePicker(rDesktop,UNO_QUERY);&lt;br /&gt;
	Reference&amp;lt; XFilePicker &amp;gt; rFilePicker = Reference&amp;lt; XFilePicker &amp;gt;&lt;br /&gt;
					( rOfficeServiceManager-&amp;gt;createInstance(&lt;br /&gt;
                               OUString( RTL_CONSTASCII_USTRINGPARAM(&lt;br /&gt;
                               &amp;quot;com.sun.star.ui.dialogs.FilePicker&amp;quot; ))), UNO_QUERY );&lt;br /&gt;
&lt;br /&gt;
	rFilePicker-&amp;gt;setDisplayDirectory( sDocUrl);&lt;br /&gt;
&lt;br /&gt;
// Don&amp;#039;t forget to add : #include &amp;lt;com/sun/star/ui/dialogs/XFilterManager.hpp&amp;gt;&lt;br /&gt;
// Don&amp;#039;t forget to add &amp;quot;com.sun.star.ui.dialogs.XFilterManager \&amp;quot; in the makefile&lt;br /&gt;
	Reference&amp;lt; XFilterManager &amp;gt; rFilterManager (rFilePicker, UNO_QUERY);&lt;br /&gt;
&lt;br /&gt;
// Don&amp;#039;t forget to add : #include &amp;lt;com/sun/star/lang/XInitialization.hpp&amp;gt;&lt;br /&gt;
// Don&amp;#039;t forget to add &amp;quot;com.sun.star.lang.XInitialization \&amp;quot; in the makefile&lt;br /&gt;
	Reference&amp;lt; XInitialization &amp;gt; rInitialize (rFilePicker, UNO_QUERY);&lt;br /&gt;
	Sequence &amp;lt; Any &amp;gt; info(1);&lt;br /&gt;
&lt;br /&gt;
// Don&amp;#039;t forget to add : #include &amp;lt;com/sun/star/ui/dialogs/TemplateDescription.hpp&amp;gt;&lt;br /&gt;
// Don&amp;#039;t forget to add &amp;quot;com.sun.star.ui.dialogs.TemplateDescription \&amp;quot; in the makefile&lt;br /&gt;
	info[0] &amp;lt;&amp;lt;=  (short) TemplateDescription::FILESAVE_SIMPLE;&lt;br /&gt;
	rInitialize-&amp;gt; initialize(info);&lt;br /&gt;
&lt;br /&gt;
	rFilterManager-&amp;gt;appendFilter(OUString::createFromAscii(&amp;quot;Texts&amp;quot;),&lt;br /&gt;
					OUString::createFromAscii(&amp;quot;*.txt&amp;quot;));&lt;br /&gt;
	rFilterManager-&amp;gt;appendFilter(OUString::createFromAscii(&amp;quot;Docs OpenOffice&amp;quot;),&lt;br /&gt;
					OUString::createFromAscii(&amp;quot;*.sxw;*.sxc&amp;quot;));&lt;br /&gt;
	rFilterManager-&amp;gt;setCurrentFilter(OUString::createFromAscii(&amp;quot;Docs OpenOffice&amp;quot;));&lt;br /&gt;
	short result=rFilePicker-&amp;gt;execute();&lt;br /&gt;
&lt;br /&gt;
// Don&amp;#039;t forget to add : #include &amp;lt;com/sun/star/ui/dialogs/ExecutableDialogResults.hpp&amp;gt;&lt;br /&gt;
// Don&amp;#039;t forget to add &amp;quot;com.sun.star.ui.dialogs.ExecutableDialogResults \&amp;quot; in the makefile&lt;br /&gt;
	if (result == ExecutableDialogResults::OK)&lt;br /&gt;
	  ShowMessageBox( rToolkit, rFrame,OUString::createFromAscii(&amp;quot;Result&amp;quot;) ,&lt;br /&gt;
			rFilePicker-&amp;gt;getFiles()[0]  );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This code uses &amp;lt;idl&amp;gt;com.sun.star.ui.dialogs.XFilePicker&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.ui.dialogs.XFilterManager&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.lang.XInitialization&amp;lt;/idl&amp;gt; interfaces and &amp;lt;idl&amp;gt;com.sun.star.ui.dialogs.ExecutableDialogResults&amp;lt;/idl&amp;gt; UNO constants.&lt;br /&gt;
&lt;br /&gt;
We are interesting now with generalising our previous work with Dialog Box.&lt;br /&gt;
&lt;br /&gt;
== Run Time Dialog Box ==&lt;br /&gt;
Read also [[Documentation/DevGuide/Basic/Creating_Dialogs_at_Runtime|Developer&amp;#039;s Guide]] and [[Documentation/BASIC_Guide/Dialogs|OOoBasic and Dialogs]].&lt;br /&gt;
&lt;br /&gt;
After the previous examples inspired by Bernard Marcelly&amp;#039;s book, it&amp;#039;s time to start with an example inspired from Andrew Pitonyak&amp;#039;s book. OOoBasic is particulary difficult to translate in these situations. We then choose to start from a Java example in :&lt;br /&gt;
&amp;lt;OpenOffice.org1.1_SDK&amp;gt;/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs&lt;br /&gt;
with the file SampleDialog.java&lt;br /&gt;
For this example we use [[CppSDKAuthors|GAP&amp;#039;s]] helper provided [[Constructing_Helpers#The_GAP.27s_Helper|here]]. &lt;br /&gt;
{{Documentation/Note|Dialogs tackled in this section are runtime dialogs. Since recent evolution of OpenOffice, it is possible to run OOoBasic Dialog (I mean conceived with Basic IDE) with all programming language. But the [[Documentation/DevGuide/WritingUNO/Using_Dialogs_in_Components|only SDK&amp;#039;s examples available]] are for components and in Java, and at the moment, I have no time to explore if it is possible with C++ automation examples and in C++.}}&lt;br /&gt;
&lt;br /&gt;
We give now the complete code. Because it&amp;#039;s a lot of code you have to look at  &amp;lt;idl&amp;gt;com.sun.star.awt.XActionListener&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.awt.XControlContainer&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.lang.XMultiServiceFactory&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.uno.XInterface&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.frame.XComponentLoader&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.uno.XComponentContext&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.lang.XMultiComponentFactory&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.beans.XPropertySet&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.container.XNameContainer&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.awt.XButton&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.awt.XToolkit&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.awt.XWindow&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.ui.dialogs.XDialog&amp;lt;/idl&amp;gt; interfaces, and &amp;lt;idl&amp;gt;com.sun.star.awt.ActionEvent&amp;lt;/idl&amp;gt; event, and also &amp;lt;idl&amp;gt;com.sun.star.frame.Desktop&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.awt.UnoControlDialogModel&amp;lt;/idl&amp;gt;, &amp;lt;idl&amp;gt;com.sun.star.awt.UnoControlButtonModel&amp;lt;/idl&amp;gt; services) :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 17 Our first Run Time Dialog Box&lt;br /&gt;
// C++ (GAP example)&lt;br /&gt;
#include &amp;quot;SimpleOOConnection.cpp&amp;quot;&lt;br /&gt;
...&lt;br /&gt;
// First an event listener for the Button&lt;br /&gt;
// Don&amp;#039;t forget the #include &amp;lt;cppuhelper/implbase1.hxx&amp;gt;&lt;br /&gt;
typedef ::cppu::WeakImplHelper1&amp;lt; ::com::sun::star::awt::XActionListener &amp;gt; ActionListenerHelper;&lt;br /&gt;
/** action listener&lt;br /&gt;
*/&lt;br /&gt;
class ActionListenerImpl : public ActionListenerHelper&lt;br /&gt;
{&lt;br /&gt;
private :&lt;br /&gt;
	int _nCounts;&lt;br /&gt;
	Reference&amp;lt; XControlContainer &amp;gt; _xControlCont;&lt;br /&gt;
	//XControlContainer _xControlCont;&lt;br /&gt;
&lt;br /&gt;
public :&lt;br /&gt;
ActionListenerImpl(const Reference&amp;lt; XControlContainer &amp;gt;&amp;amp; xControlCont) {&lt;br /&gt;
	_xControlCont = xControlCont;&lt;br /&gt;
	_nCounts = 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// XEventListener&lt;br /&gt;
virtual void SAL_CALL disposing (const com::sun::star::lang::EventObject&amp;amp; aEventObj )&lt;br /&gt;
                                            throw(::com::sun::star::uno::RuntimeException) {&lt;br /&gt;
//	_xControlCont = NULL;&lt;br /&gt;
	cout &amp;lt;&amp;lt; &amp;quot;object listened to will be disposed&amp;quot;&amp;lt;&amp;lt;endl;&lt;br /&gt;
}&lt;br /&gt;
              &lt;br /&gt;
// XActionListener&lt;br /&gt;
virtual void SAL_CALL actionPerformed (const ::com::sun::star::awt::ActionEvent&amp;amp; rEvent ) &lt;br /&gt;
                                                                   throw ( RuntimeException) {&lt;br /&gt;
// increase click counter&lt;br /&gt;
	_nCounts++;&lt;br /&gt;
	cout &amp;lt;&amp;lt; &amp;quot;OK : &amp;quot; &amp;lt;&amp;lt; _nCounts &amp;lt;&amp;lt; endl;&lt;br /&gt;
 }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
SimpleOOConnection sOOConnection1;&lt;br /&gt;
&lt;br /&gt;
//instantiating connection to Remote Service Manager&lt;br /&gt;
	Reference&amp;lt; XMultiServiceFactory &amp;gt; xRemoteServiceManager=sOOConnection1.connect_ooffice&lt;br /&gt;
		(&amp;quot;uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager&amp;quot;);&lt;br /&gt;
//checks whether getting Remote Service Manager or Not&lt;br /&gt;
	if(!xRemoteServiceManager.is())&lt;br /&gt;
	{&lt;br /&gt;
	cout&amp;lt;&amp;lt;&amp;quot;Error in connection&amp;quot;&amp;lt;&amp;lt;endl;&lt;br /&gt;
	return 1;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
// setting Desktop reference to desktop&lt;br /&gt;
	Reference&amp;lt; XInterface &amp;gt; desktop =xRemoteServiceManager-&amp;gt;createInstance&lt;br /&gt;
		(OUString::createFromAscii(&amp;quot;com.sun.star.frame.Desktop&amp;quot; ));&lt;br /&gt;
&lt;br /&gt;
// Query for the XUnoUrlResolver interface for loading Desktop&lt;br /&gt;
	Reference&amp;lt; XComponentLoader &amp;gt; xComponentLoader( desktop, UNO_QUERY );&lt;br /&gt;
&lt;br /&gt;
//////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
	Any any;&lt;br /&gt;
	sal_Int32 value;&lt;br /&gt;
&lt;br /&gt;
	Reference&amp;lt; XComponentContext &amp;gt; xComponentContext =&lt;br /&gt;
	defaultBootstrap_InitialComponentContext();&lt;br /&gt;
&lt;br /&gt;
// retrieve the servicemanager from the context&lt;br /&gt;
	Reference&amp;lt; XMultiComponentFactory &amp;gt; xMultiComponentFactory =&lt;br /&gt;
	xComponentContext-&amp;gt;getServiceManager();&lt;br /&gt;
/************************************************************************************&lt;br /&gt;
Reference&amp;lt;XInterface&amp;gt; dialogModel = xMultiComponentFactory-&amp;gt;createInstanceWithContext(&lt;br /&gt;
                                      OUString::createFromAscii(&amp;quot;com.sun.star.awt.UnoControlDialogModel&amp;quot;),&lt;br /&gt;
                                      xComponentContext );&lt;br /&gt;
************************************************************************************/&lt;br /&gt;
/////////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
	Reference&amp;lt;XInterface&amp;gt; dialogModel = xRemoteServiceManager-&amp;gt;createInstance&lt;br /&gt;
		(OUString::createFromAscii(&amp;quot;com.sun.star.awt.UnoControlDialogModel&amp;quot;));&lt;br /&gt;
	cout&amp;lt;&amp;lt;&amp;quot;hi&amp;quot;&amp;lt;&amp;lt;endl;&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
	Reference&amp;lt; XPropertySet &amp;gt;xPSetDialog(dialogModel,UNO_QUERY );&lt;br /&gt;
&lt;br /&gt;
	value=150;&lt;br /&gt;
	any&amp;lt;&amp;lt;=value;&lt;br /&gt;
	xPSetDialog-&amp;gt;setPropertyValue( OUString::createFromAscii(&amp;quot;PositionX&amp;quot;), any );&lt;br /&gt;
	xPSetDialog-&amp;gt;setPropertyValue( OUString::createFromAscii(&amp;quot;PositionY&amp;quot;), any );&lt;br /&gt;
	xPSetDialog-&amp;gt;setPropertyValue( OUString::createFromAscii(&amp;quot;Width&amp;quot;), any );&lt;br /&gt;
	xPSetDialog-&amp;gt;setPropertyValue( OUString::createFromAscii(&amp;quot;Height&amp;quot;), any );&lt;br /&gt;
	any&amp;lt;&amp;lt;=OUString::createFromAscii( &amp;quot;Runtime Dialog Demo&amp;quot; );&lt;br /&gt;
	xPSetDialog-&amp;gt;setPropertyValue( OUString::createFromAscii(&amp;quot;Title&amp;quot;), any );&lt;br /&gt;
&lt;br /&gt;
	Reference&amp;lt;XMultiServiceFactory&amp;gt; xMultiServiceFactory(dialogModel,UNO_QUERY );&lt;br /&gt;
&lt;br /&gt;
	Reference&amp;lt; XInterface &amp;gt; buttonModel = xMultiServiceFactory-&amp;gt;createInstance&lt;br /&gt;
		(OUString::createFromAscii(&amp;quot;com.sun.star.awt.UnoControlButtonModel&amp;quot;) );&lt;br /&gt;
&lt;br /&gt;
	Reference&amp;lt; XPropertySet &amp;gt;xPSetButton(buttonModel,UNO_QUERY );&lt;br /&gt;
&lt;br /&gt;
	value=20;&lt;br /&gt;
	any&amp;lt;&amp;lt;=value;&lt;br /&gt;
	xPSetButton-&amp;gt;setPropertyValue( OUString::createFromAscii(&amp;quot;PositionX&amp;quot;), any );&lt;br /&gt;
&lt;br /&gt;
	value=70;&lt;br /&gt;
	any&amp;lt;&amp;lt;=value;&lt;br /&gt;
	xPSetButton-&amp;gt;setPropertyValue( OUString::createFromAscii(&amp;quot;PositionY&amp;quot;), any );&lt;br /&gt;
	value=50;&lt;br /&gt;
	any&amp;lt;&amp;lt;=value;&lt;br /&gt;
	xPSetButton-&amp;gt;setPropertyValue( OUString::createFromAscii(&amp;quot;Width&amp;quot;), any );&lt;br /&gt;
	value=14;&lt;br /&gt;
	any&amp;lt;&amp;lt;=value;&lt;br /&gt;
	xPSetButton-&amp;gt;setPropertyValue( OUString::createFromAscii(&amp;quot;Height&amp;quot;), any );&lt;br /&gt;
	any&amp;lt;&amp;lt;=OUString::createFromAscii(&amp;quot;Button1&amp;quot;);&lt;br /&gt;
	xPSetButton-&amp;gt;setPropertyValue( OUString::createFromAscii(&amp;quot;Name&amp;quot;), any );&lt;br /&gt;
	value=1;&lt;br /&gt;
	any&amp;lt;&amp;lt;=value;&lt;br /&gt;
&lt;br /&gt;
//xPSetButton-&amp;gt;setPropertyValue( OUString::createFromAscii(&amp;quot;TabIndex&amp;quot;), any );&lt;br /&gt;
	any&amp;lt;&amp;lt;=OUString::createFromAscii( &amp;quot;Click Me&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
	xPSetButton-&amp;gt;setPropertyValue( OUString::createFromAscii(&amp;quot;Label&amp;quot;), any );&lt;br /&gt;
&lt;br /&gt;
// insert the control models into the dialog model&lt;br /&gt;
	Reference&amp;lt; XNameContainer &amp;gt;xNameCont(dialogModel,UNO_QUERY );&lt;br /&gt;
	any&amp;lt;&amp;lt;=buttonModel;&lt;br /&gt;
&lt;br /&gt;
	xNameCont-&amp;gt;insertByName( OUString::createFromAscii(&amp;quot;Button1&amp;quot;), any );&lt;br /&gt;
&lt;br /&gt;
// create the dialog control and set the model&lt;br /&gt;
	Reference&amp;lt;XInterface&amp;gt; dialog = xRemoteServiceManager-&amp;gt;createInstance(&lt;br /&gt;
			OUString::createFromAscii(&amp;quot;com.sun.star.awt.UnoControlDialog&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
	Reference&amp;lt;XControl&amp;gt; xControl(dialog,UNO_QUERY );&lt;br /&gt;
	Reference&amp;lt;XControlModel &amp;gt;xControlModel(dialogModel,UNO_QUERY );&lt;br /&gt;
	xControl-&amp;gt;setModel( xControlModel );&lt;br /&gt;
&lt;br /&gt;
 // add an action listener to the button control&lt;br /&gt;
	Reference&amp;lt; XControlContainer &amp;gt;xControlCont(dialog ,UNO_QUERY );&lt;br /&gt;
	Reference&amp;lt; XInterface &amp;gt; objectButton = xControlCont-&amp;gt;getControl( &lt;br /&gt;
							OUString::createFromAscii(&amp;quot;Button1&amp;quot;) );&lt;br /&gt;
	Reference&amp;lt; XButton &amp;gt;xButton(objectButton ,UNO_QUERY);&lt;br /&gt;
&lt;br /&gt;
	ActionListenerImpl *xListener = new ActionListenerImpl( xControlCont );&lt;br /&gt;
	Reference&amp;lt; XActionListener &amp;gt; xActionListener = &lt;br /&gt;
			static_cast&amp;lt; XActionListener* &amp;gt; ( xListener );&lt;br /&gt;
&lt;br /&gt;
	xButton-&amp;gt;addActionListener( xActionListener );&lt;br /&gt;
&lt;br /&gt;
// create a peer&lt;br /&gt;
	Reference&amp;lt;XInterface&amp;gt; toolkit = xRemoteServiceManager-&amp;gt;createInstance(&lt;br /&gt;
	OUString::createFromAscii(&amp;quot;com.sun.star.awt.ExtToolkit&amp;quot;));&lt;br /&gt;
	Reference&amp;lt; XToolkit &amp;gt;xToolkit(toolkit , UNO_QUERY );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	Reference&amp;lt; XWindow &amp;gt;xWindow(xControl , UNO_QUERY );&lt;br /&gt;
	xWindow-&amp;gt;setVisible( true );&lt;br /&gt;
	xControl-&amp;gt;createPeer( xToolkit,&amp;#039;\0&amp;#039; );//create instance of XWindowPeer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// execute the dialog&lt;br /&gt;
	Reference&amp;lt; XDialog &amp;gt;xDialog(dialog , UNO_QUERY );&lt;br /&gt;
	xDialog-&amp;gt;execute();&lt;br /&gt;
&lt;br /&gt;
// dispose the dialog&lt;br /&gt;
	Reference&amp;lt; XComponent &amp;gt; xComponent(dialog,UNO_QUERY );&lt;br /&gt;
	xComponent-&amp;gt;dispose();&lt;br /&gt;
&lt;br /&gt;
/////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This code will print out :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
hi&lt;br /&gt;
OK : 1&lt;br /&gt;
OK : 2&lt;br /&gt;
OK : 3&lt;br /&gt;
OK : 4&lt;br /&gt;
OK : 5&lt;br /&gt;
OK : 6&lt;br /&gt;
OK : 7&lt;br /&gt;
OK : 8&lt;br /&gt;
object listened to will be disposed&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
When clicking on the button it increment and prints out the new value.&lt;br /&gt;
From this code any tips to manage a dialog box can be hired :&lt;br /&gt;
# create a dialog model service, dialogModel variable in the above code&lt;br /&gt;
# query a XPropertySet interface to set any properties (x y positions, size, title, ..)&lt;br /&gt;
# create all controls with the same previous both rules : query a control model first, and then query a XPropertySet interface to set any properties&lt;br /&gt;
# query a XNameContainer from the dialog model&lt;br /&gt;
# insert every control model into the dialog model with this container&lt;br /&gt;
# create the dialog control and query first aXControl interface and second a XControlModedl interface to set the model&lt;br /&gt;
# add action listener if needed&lt;br /&gt;
# after creating a peer run the dialog&lt;br /&gt;
&lt;br /&gt;
== Complete Translation of a Java example ==&lt;br /&gt;
&lt;br /&gt;
{{:First Dialog}}&lt;br /&gt;
&lt;br /&gt;
== Text Control example ==&lt;br /&gt;
We want now to construct a more complex [[dialog_box_with_an_edit_control|dialog box with a text control]].&lt;br /&gt;
&lt;br /&gt;
== List Box example ==&lt;br /&gt;
We want now to construct a [[dialog_box_with_an_List_Box|dialog box with a list box]].&lt;br /&gt;
&lt;br /&gt;
== Radio button example ==&lt;br /&gt;
&lt;br /&gt;
We want now to construct a [[dialog_box_with_an_Radio_Button|dialog box with a radio button]].&lt;br /&gt;
&lt;br /&gt;
== TO DO ==&lt;br /&gt;
&lt;br /&gt;
[http://api.openoffice.org/docs/DevelopersGuide/Components/Components.xhtml Developer&amp;#039;s Guide] states it is possible to construct a component with a dialog that have been created with the Dialog Editor integrated in the OpenOffice.org Basic IDE. I think the same is possible with a binary executable and I have to work around this subject.&lt;br /&gt;
&lt;br /&gt;
{{Template:Home_Page}}&lt;br /&gt;
&lt;br /&gt;
=See also=&lt;br /&gt;
* [[Documentation/DevGuide/Basic/Creating_Dialogs_at_Runtime|Creating Dialogs at Runtime]] in Developer&amp;#039;s Guide&lt;br /&gt;
* [[Framework/Article/Easy_To_Use_Message_Boxes|Easy To Use Message Boxes]] in OOoBasic&lt;br /&gt;
* [[Documentation/BASIC_Guide/Dialogs|OOoBasic and Dialogs]]&lt;br /&gt;
* [[Uno/Cpp/Tutorials/Introduction_to_Cpp_Uno|C++ and UNO tutorial]]&lt;br /&gt;
*[[Tutorial_UNO_Library|UNO tutorial]]&lt;br /&gt;
*[[Tutorial_UNO_IDL|UNO IDL]]&lt;br /&gt;
* [[Uno/Article/Types%26Reflection]]&lt;br /&gt;
* [[Framework/Tutorial/Popup_Menu_Controller|Popup Menu Controller]] and C++&lt;br /&gt;
* [[Framework/Tutorial/Statusbar_Controller|Statusbar Controler]] and C++&lt;br /&gt;
* [[Treecontrol|The New Tree Contol]]&lt;br /&gt;
* [[Framework/Article/Generic_UNO_Interfaces_for_complex_toolbar_controls|Generic UNO Interfaces for complex toolbar controls]]&lt;br /&gt;
* Writing a Program to Control OpenOffice.org, by Franco Pingiori — [http://www.linuxjournal.com/article/8550 Part 1] and [http://www.linuxjournal.com/article/8608 Part 2], Linux Journal&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Cpp]]&lt;br /&gt;
[[Category:Uno]]&lt;br /&gt;
[[Category:Tutorial]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=PrinttoWriter.py&amp;diff=151762</id>
		<title>PrinttoWriter.py</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=PrinttoWriter.py&amp;diff=151762"/>
		<updated>2009-12-03T06:02:27Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Danny.OOo.PrintToWriter.py ==&lt;br /&gt;
&lt;br /&gt;
This makes it easy and convenient to &amp;#039;&amp;#039;&amp;#039;print&amp;#039;&amp;#039;&amp;#039; a bunch of text into a Writer document. &lt;br /&gt;
&lt;br /&gt;
See the example routine in the module that shows how easy this module is to use, and how useful it can be. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
#********************************************************************** &lt;br /&gt;
#   If you make changes, please append to the change log below. &lt;br /&gt;
# &lt;br /&gt;
#   Change Log &lt;br /&gt;
#   Danny Brewer         Revised 2004-06-05-01 &lt;br /&gt;
# &lt;br /&gt;
#********************************************************************** &lt;br /&gt;
&lt;br /&gt;
# OOo&amp;#039;s libraries &lt;br /&gt;
import uno &lt;br /&gt;
&lt;br /&gt;
# Danny&amp;#039;s libraries &lt;br /&gt;
from Danny.OOo.OOoLib import StarDesktop &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
com_sun_star_text_ControlCharacter_PARAGRAPH_BREAK  = uno.getConstantByName( &amp;quot;com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK&amp;quot; ) &lt;br /&gt;
com_sun_star_text_ControlCharacter_LINE_BREAK       = uno.getConstantByName( &amp;quot;com.sun.star.text.ControlCharacter.LINE_BREAK&amp;quot; ) &lt;br /&gt;
com_sun_star_text_ControlCharacter_HARD_HYPHEN      = uno.getConstantByName( &amp;quot;com.sun.star.text.ControlCharacter.HARD_HYPHEN&amp;quot; ) &lt;br /&gt;
com_sun_star_text_ControlCharacter_SOFT_HYPHEN      = uno.getConstantByName( &amp;quot;com.sun.star.text.ControlCharacter.SOFT_HYPHEN&amp;quot; ) &lt;br /&gt;
com_sun_star_text_ControlCharacter_HARD_SPACE       = uno.getConstantByName( &amp;quot;com.sun.star.text.ControlCharacter.HARD_SPACE&amp;quot; ) &lt;br /&gt;
com_sun_star_text_ControlCharacter_APPEND_PARAGRAPH = uno.getConstantByName( &amp;quot;com.sun.star.text.ControlCharacter.APPEND_PARAGRAPH&amp;quot; ) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class PrintToWriter: &lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;A class which allows conveniently printing stuff into a Writer document. &lt;br /&gt;
    Very useful for debugging, general output purposes, or even for creating reports.&amp;quot;&amp;quot;&amp;quot; &lt;br /&gt;
    def __init__( self ): &lt;br /&gt;
        self.oWriterDoc = StarDesktop.loadComponentFromURL( &amp;quot;private:factory/swriter&amp;quot;, &amp;quot;_blank&amp;quot;, 0, () ) &lt;br /&gt;
        self.oWriterText = self.oWriterDoc.getText() &lt;br /&gt;
        self.oWriterCursor = self.oWriterText.createTextCursor() &lt;br /&gt;
&lt;br /&gt;
    def writeLn( self, *args ): &lt;br /&gt;
        if len( args ) &amp;gt; 0: &lt;br /&gt;
            self.write( *args ) &lt;br /&gt;
        self.writeParagraphBreak() &lt;br /&gt;
&lt;br /&gt;
    def write( self, arg1, *argsRest ): &lt;br /&gt;
        self.writeOne( arg1 ) &lt;br /&gt;
        for arg in argsRest: &lt;br /&gt;
            self.writeTab() &lt;br /&gt;
            self.writeOne( arg ) &lt;br /&gt;
&lt;br /&gt;
    def writeOne( self, arg, bAbsorb=False ): &lt;br /&gt;
        self.writeString( str( arg ), bAbsorb ) &lt;br /&gt;
&lt;br /&gt;
    def writeTab( self, bAbsorb=False ): &lt;br /&gt;
        self.writeString( &amp;quot;\t&amp;quot;, bAbsorb ) &lt;br /&gt;
&lt;br /&gt;
    def writeParagraphBreak( self, bAbsorb=False ): &lt;br /&gt;
        self.writeControlCharacter( com_sun_star_text_ControlCharacter_PARAGRAPH_BREAK, bAbsorb ) &lt;br /&gt;
&lt;br /&gt;
    def writeString( self, cString, bAbsorb=False ): &lt;br /&gt;
        self.oWriterText.insertString( self.oWriterCursor, cString, bAbsorb ) &lt;br /&gt;
&lt;br /&gt;
    def writeControlCharacter( self, nCtrlChar, bAbsorb=False ): &lt;br /&gt;
        self.oWriterText.insertControlCharacter( self.oWriterCursor, nCtrlChar, bAbsorb ) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def example_PrintToWriter(): &lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;An example of how to use the PrintToWriter class to trivially create &lt;br /&gt;
    a new Writer document, and write out text into it.&amp;quot;&amp;quot;&amp;quot; &lt;br /&gt;
    oOutput = PrintToWriter() &lt;br /&gt;
    oOutput.writeLn( &amp;quot;Hello World&amp;quot; ) &lt;br /&gt;
    oOutput.write( &amp;quot;String&amp;quot;, 123, 456.23, True ) &lt;br /&gt;
    oOutput.writeLn() &lt;br /&gt;
    oOutput.writeLn() &lt;br /&gt;
&lt;br /&gt;
    oOutput.writeLn( &amp;quot;Tab delimited values...&amp;quot; ) &lt;br /&gt;
    &lt;br /&gt;
    oOutput.write( 123 ) &lt;br /&gt;
    oOutput.writeTab() &lt;br /&gt;
    oOutput.write( 456 ) &lt;br /&gt;
    oOutput.writeTab() &lt;br /&gt;
    oOutput.write( 789 ) &lt;br /&gt;
    oOutput.writeLn() &lt;br /&gt;
    &lt;br /&gt;
    oOutput.write( 465 ) &lt;br /&gt;
    oOutput.writeTab() &lt;br /&gt;
    oOutput.write( 522 ) &lt;br /&gt;
    oOutput.writeTab() &lt;br /&gt;
    oOutput.write( 835 ) &lt;br /&gt;
    oOutput.writeLn() &lt;br /&gt;
    &lt;br /&gt;
    oOutput.write( 886 ) &lt;br /&gt;
    oOutput.writeTab() &lt;br /&gt;
    oOutput.write( 164 ) &lt;br /&gt;
    oOutput.writeTab() &lt;br /&gt;
    oOutput.write( 741 ) &lt;br /&gt;
    oOutput.writeLn()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
== How it Works ==&lt;br /&gt;
PrintToWriter.py code is really just a way to:&lt;br /&gt;
* create the enviroment&lt;br /&gt;
* create a document&lt;br /&gt;
* generate the content&lt;br /&gt;
* insert it within a document&lt;br /&gt;
&lt;br /&gt;
So first we need to create the &amp;#039;&amp;#039;&amp;#039;enviroment&amp;#039;&amp;#039;&amp;#039; so that we don&amp;#039;t generate a verbose code, we need to insert it into variable.&lt;br /&gt;
&lt;br /&gt;
To create the enviroment we need a couple of things, first we import a library, which already save us a bunch of code in order to reference to UNO. The next step is to choose the fomat element we will need to input. For tha we use the uno.getConstantByName and point to the [http://api.openoffice.org/docs/common/ref/com/sun/star/text/ControlCharacter.html ControlCharacter] component which includes all the format we need. &lt;br /&gt;
&lt;br /&gt;
* Paragraph Break - Insert a paragraph break&lt;br /&gt;
* Line Break - Inserts a line break inside of the paragraph&lt;br /&gt;
* Hard Hyphen - A character that appears like a dash, but prevents hyphenation at its position&lt;br /&gt;
* Soft Hyphen - Marks a preferred position for hyphenation&lt;br /&gt;
* Hard Space - A character that appears like a space, but prevents hyphenation at this point&lt;br /&gt;
* Append Paragraph - A new paragraph is appended &lt;br /&gt;
&lt;br /&gt;
The next step is to generate the class for &amp;#039;&amp;#039;&amp;#039;PrintToWriter&amp;#039;&amp;#039;&amp;#039;, this is the class that this file is about. Then we need to load the writer component, on like 59. We use the &amp;#039;&amp;#039;&amp;#039;getText()&amp;#039;&amp;#039;&amp;#039; function so we can access the text area from the writer&amp;#039;s component. Once we are there, we explicity activate the Cursor.&lt;br /&gt;
&lt;br /&gt;
We go on using the following functions:&lt;br /&gt;
&lt;br /&gt;
* writeLn = Insert a break on end of Line&lt;br /&gt;
* write = &lt;br /&gt;
* writeOne = Write String&lt;br /&gt;
* writeTab = Insert a &amp;#039;&amp;#039;&amp;#039;\t&amp;#039;&amp;#039;&amp;#039; value as a string&lt;br /&gt;
* writeParagraphBreak =  we call on the PARAGRAPH_BREAK component&lt;br /&gt;
* writeString = We use cString after the Cursor&lt;br /&gt;
* writeControlCharacter = nCtrlChar&lt;br /&gt;
&lt;br /&gt;
The example_PrinterToWrite is basically we execute the functtons we create under the &amp;#039;&amp;#039;&amp;#039;PrintToWriter class&amp;#039;&amp;#039;&amp;#039;. This will be enough for you to see how we can use the functions to insert content and how it works the different funmction.&lt;br /&gt;
&lt;br /&gt;
[[Category:Python]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=UNO_component_packaging_ja&amp;diff=151761</id>
		<title>UNO component packaging ja</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=UNO_component_packaging_ja&amp;diff=151761"/>
		<updated>2009-12-03T06:01:23Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Python UNO コンポーネント =&lt;br /&gt;
このページでは作成済みの UNO コンポーネントのパッケージ化および配布方法を説明します。非常に簡単な例として私が作成した &amp;#039;&amp;#039;Wavelet&amp;#039;&amp;#039; クラスを使用します。 &lt;br /&gt;
&lt;br /&gt;
より詳細が必要なら [[http://api.openoffice.org/docs/DevelopersGuide/Components/Components.htm Developers Guide]] を参照してください。 &lt;br /&gt;
&lt;br /&gt;
=Python ローダー=&lt;br /&gt;
Python ローダーは自身があるパスにないクラスを読み込むことができません。そのため、使用する全てのクラスおよびモジュールを OpenOffice.org Python ライブラリのディレクトリにコピーしなければいけません。さらに、実行前に OOo を再起動する必要があるかもしれません。&lt;br /&gt;
訳注: OOo 2.4 以降ではユーザー独自の Python モジュールをインポートする方法が実装されています。 &lt;br /&gt;
&lt;br /&gt;
=Python コンポーネント例=&lt;br /&gt;
&lt;br /&gt;
==Wavelet クラス==&lt;br /&gt;
私が作成した &amp;#039;&amp;#039;Wavelet&amp;#039;&amp;#039; クラスを使用します。このクラスはチェコ語の前置詞の前のスペースを改行されないスペースで置換します。次のコードを &amp;#039;&amp;#039;Wavelet.py&amp;#039;&amp;#039; ファイルに保存してください。 &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import uno&lt;br /&gt;
import unohelper&lt;br /&gt;
from com.sun.star.task import XJobExecutor&lt;br /&gt;
&lt;br /&gt;
class Wavelet( unohelper.Base, XJobExecutor ):&lt;br /&gt;
    def __init__( self, ctx ):&lt;br /&gt;
        self.ctx = ctx&lt;br /&gt;
 &lt;br /&gt;
    def trigger( self, args ):&lt;br /&gt;
        desktop = self.ctx.ServiceManager.createInstanceWithContext(&lt;br /&gt;
            &amp;quot;com.sun.star.frame.Desktop&amp;quot;, self.ctx )&lt;br /&gt;
 &lt;br /&gt;
        doc = desktop.getCurrentComponent()&lt;br /&gt;
 &lt;br /&gt;
        try:&lt;br /&gt;
            search = doc.createSearchDescriptor()&lt;br /&gt;
            search.SearchRegularExpression = True&lt;br /&gt;
            search.SearchString = &amp;quot;\\&amp;lt;(k|s|v|z|o|u|i|a) &amp;quot;&lt;br /&gt;
            &lt;br /&gt;
            found = doc.findFirst( search )&lt;br /&gt;
            while found:&lt;br /&gt;
                found.String = found.String.replace( &amp;quot; &amp;quot;, u&amp;quot;\xa0&amp;quot; )&lt;br /&gt;
                found = doc.findNext( found.End, search)&lt;br /&gt;
 &lt;br /&gt;
        except:&lt;br /&gt;
            pass&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Wavelet クラスの登録 ==&lt;br /&gt;
OpenOffice.org にコンポーネントのメインクラスを伝えなければいけません。次のコードを &amp;#039;&amp;#039;Wavelet.py&amp;#039;&amp;#039; ファイルの最後に追加してください。 &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
g_ImplementationHelper = unohelper.ImplementationHelper()&lt;br /&gt;
g_ImplementationHelper.addImplementation(&lt;br /&gt;
        Wavelet,&lt;br /&gt;
        &amp;quot;name.vojta.openoffice.Wavelet&amp;quot;,&lt;br /&gt;
        (&amp;quot;com.sun.star.task.Job&amp;quot;,),)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= コンポーネントの統合 =&lt;br /&gt;
&lt;br /&gt;
==アイコン==&lt;br /&gt;
あなた独自のメニューの項目やツールバーのボタンのアイコンを作成できます。最も簡単なのは TrueColor の BMP ファイルを二つ作成することです。一つ目は 26 x 26 pixel に、もう一つは 16x16 pixel サイズにしておきます。 &lt;br /&gt;
&lt;br /&gt;
アルファ (透過) を利用したいのであれば &amp;#039;&amp;#039;#FF00FF&amp;#039;&amp;#039; (RGB) (マゼンタ) を使いましょう。 &lt;br /&gt;
&lt;br /&gt;
このアイコンは任意で作成します。無理に作成する必要はありません。 &lt;br /&gt;
&lt;br /&gt;
==Addons.xcu==&lt;br /&gt;
コンポーネント統合のためのコンフィグレーションを &amp;#039;&amp;#039;Addons.xcu&amp;#039;&amp;#039; ファイルに記述します。 &lt;br /&gt;
&lt;br /&gt;
===ヘッダ===&lt;br /&gt;
このファイルのヘッダは次のようにしなければいけません。 &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=xml&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 xmlns:oor=&amp;quot;http://openoffice.org/2001/registry&amp;quot;&lt;br /&gt;
  xmlns:xs=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; oor:name=&amp;quot;Addons&amp;quot;&lt;br /&gt;
  oor:package=&amp;quot;org.openoffice.Office&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
    &amp;lt;node oor:name=&amp;quot;AddonUI&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===オフィースメニューバー===&lt;br /&gt;
次のパートでは &amp;#039;&amp;#039;Czech&amp;#039;&amp;#039; (または &amp;#039;&amp;#039;Cestina&amp;#039;&amp;#039;、ユーザーインターフェースの言語設定により違います) という新規メニュー項目をおよび &amp;quot;Wavelet&amp;quot; メニュー項目を作成します。 &lt;br /&gt;
&lt;br /&gt;
このメニュー項目は &amp;#039;&amp;#039;name.vojta.openoffice.Wavelet?execute&amp;#039;&amp;#039; &amp;#039;&amp;#039;URL&amp;#039;&amp;#039; に関連付けます。これはメニューをクリックしたときに &amp;#039;&amp;#039;Wavelet.trigger&amp;#039;&amp;#039; メソッドが &amp;#039;&amp;#039;execute&amp;#039;&amp;#039; という引数と共に呼ばれるということです。 &lt;br /&gt;
&lt;br /&gt;
このメニューは OpenOffice.org Writer にのみ表示されます。 &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=xml&amp;gt;&lt;br /&gt;
        &amp;lt;node oor:name=&amp;quot;OfficeMenuBar&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;node oor:name=&amp;quot;name.vojta.openoffice.Wavelet&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;prop oor:name=&amp;quot;Title&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;value/&amp;gt;&lt;br /&gt;
                    &amp;lt;value xml:lang=&amp;quot;en-US&amp;quot;&amp;gt;Czech&amp;lt;/value&amp;gt;&lt;br /&gt;
                    &amp;lt;value xml:lang=&amp;quot;cs&amp;quot;&amp;gt;Cestina&amp;lt;/value&amp;gt;&lt;br /&gt;
                &amp;lt;/prop&amp;gt;&lt;br /&gt;
                &amp;lt;prop oor:name=&amp;quot;Target&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;value&amp;gt;_self&amp;lt;/value&amp;gt;&lt;br /&gt;
                &amp;lt;/prop&amp;gt;&lt;br /&gt;
                &amp;lt;prop oor:name=&amp;quot;ImageIdentifier&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;value/&amp;gt;&lt;br /&gt;
                &amp;lt;/prop&amp;gt;&lt;br /&gt;
                &amp;lt;node oor:name=&amp;quot;Submenu&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;URL&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                            &amp;lt;value&amp;gt;service:name.vojta.openoffice.Wavelet?execute&amp;lt;/value&amp;gt;&lt;br /&gt;
                        &amp;lt;/prop&amp;gt;&lt;br /&gt;
                        &amp;lt;prop oor:name=&amp;quot;Title&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                            &amp;lt;value/&amp;gt;&lt;br /&gt;
                            &amp;lt;value xml:lang=&amp;quot;en-US&amp;quot;&amp;gt;Wavelet&amp;lt;/value&amp;gt;&lt;br /&gt;
                            &amp;lt;value xml:lang=&amp;quot;cs&amp;quot;&amp;gt;Vlnka&amp;lt;/value&amp;gt;&lt;br /&gt;
                        &amp;lt;/prop&amp;gt;&lt;br /&gt;
                        &amp;lt;prop oor:name=&amp;quot;Target&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                            &amp;lt;value&amp;gt;_self&amp;lt;/value&amp;gt;&lt;br /&gt;
                        &amp;lt;/prop&amp;gt;&lt;br /&gt;
                        &amp;lt;prop oor:name=&amp;quot;Context&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                            &amp;lt;value&amp;gt;com.sun.star.text.TextDocument&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;/node&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===オフィースツールバー===&lt;br /&gt;
次のパートでは一つのボタンを持った新規ツールバー (&amp;#039;&amp;#039;Add-on 1&amp;#039;&amp;#039; や &amp;#039;&amp;#039;Add-on 2&amp;#039;&amp;#039;, ... というツールバー名を持ったもの) を作成します。このボタンは &amp;#039;&amp;#039;name.vojta.openoffice.Wavelet?execute&amp;#039;&amp;#039; &amp;#039;&amp;#039;URL&amp;#039;&amp;#039; に関連付けます。これは、ツールバーのこのボタンが押されたときに &amp;quot;Wabelet.trigger&amp;quot; メソッドが実行されるということです。&amp;#039;&amp;#039;execute&amp;#039;&amp;#039; が引数として渡されます。 &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;注&amp;#039;&amp;#039;&amp;#039;: ツールバー名を変更することができません。これは旧バージョン 1.1.x 系との互換性のためです。 &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=xml&amp;gt;&lt;br /&gt;
        &amp;lt;node oor:name=&amp;quot;OfficeToolBar&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;node oor:name=&amp;quot;name.vojta.openoffice.Wavelet&amp;quot; oor:op=&amp;quot;replace&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;URL&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;value&amp;gt;service:name.vojta.openoffice.Wavelet?execute&amp;lt;/value&amp;gt;&lt;br /&gt;
                    &amp;lt;/prop&amp;gt;&lt;br /&gt;
                    &amp;lt;prop oor:name=&amp;quot;ImageIdentifier&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;value/&amp;gt;&lt;br /&gt;
                    &amp;lt;/prop&amp;gt;&lt;br /&gt;
                    &amp;lt;prop oor:name=&amp;quot;Title&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;value/&amp;gt;&lt;br /&gt;
                        &amp;lt;value xml:lang=&amp;quot;en-US&amp;quot;&amp;gt;Wavelet&amp;lt;/value&amp;gt;&lt;br /&gt;
                        &amp;lt;value xml:lang=&amp;quot;cs&amp;quot;&amp;gt;Vlnka&amp;lt;/value&amp;gt;&lt;br /&gt;
                    &amp;lt;/prop&amp;gt;&lt;br /&gt;
                    &amp;lt;prop oor:name=&amp;quot;Target&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;value&amp;gt;_self&amp;lt;/value&amp;gt;&lt;br /&gt;
                    &amp;lt;/prop&amp;gt;&lt;br /&gt;
                    &amp;lt;prop oor:name=&amp;quot;Context&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;value&amp;gt;com.sun.star.text.TextDocument&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;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===アイコン===&lt;br /&gt;
アイコンをすべての &amp;#039;&amp;#039;URL&amp;#039;&amp;#039; と関連付けることができます。アイコンを &amp;#039;&amp;#039;name.vojta.openoffice.Wavelet?execute&amp;#039;&amp;#039; &amp;#039;&amp;#039;URL&amp;#039;&amp;#039; と関連付けることにします。これは、同じ &amp;quot;URL&amp;quot; に関連付けられたすべてのコントロール (メニュー項目、ボタンなど) がこれらのアイコンを使用するということです。 &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;注:&amp;#039;&amp;#039;&amp;#039; %origin% は UNO コンポーネントパッケージです。これについては後述します。 &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=xml&amp;gt;&lt;br /&gt;
        &amp;lt;node oor:name=&amp;quot;Images&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;node oor:name=&amp;quot;name.vojta.openoffice.Wavelet.image1&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;prop oor:name=&amp;quot;URL&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;value&amp;gt;service:name.vojta.openoffice.Wavelet?execute&amp;lt;/value&amp;gt;&lt;br /&gt;
                &amp;lt;/prop&amp;gt;&lt;br /&gt;
                &amp;lt;node oor:name=&amp;quot;UserDefinedImages&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;prop oor:name=&amp;quot;ImageSmallURL&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;value&amp;gt;%origin%/images/WaveletSmall.bmp&amp;lt;/value&amp;gt;&lt;br /&gt;
                    &amp;lt;/prop&amp;gt;&lt;br /&gt;
                    &amp;lt;prop oor:name=&amp;quot;ImageBigURL&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;value&amp;gt;%origin%/images/WaveletBig.bmp&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;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===フッタ===&lt;br /&gt;
開いているセクションをすべて閉じます。 &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=xml&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;
=UNO コンポーネントパッケージ=&lt;br /&gt;
UNO コンポーネントパッケージは単純な ZIP ファイルです。パッケージは &amp;#039;&amp;#039;Addons.xcu&amp;#039;&amp;#039; ファイル、アイコンを入れた &amp;#039;&amp;#039;images&amp;#039;&amp;#039; ディレクトリおよび Python コンポーネントの実装を含んでいることは言うまでもありません。 &lt;br /&gt;
&lt;br /&gt;
==パッケージ作成==&lt;br /&gt;
次のコマンドでサンプルパッケージを作成できます。 &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
zip -r Wavelet.uno.zip Addons.xcu Wavelet.py images&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
最終的に &amp;#039;&amp;#039;Wavelet.uno.zip&amp;#039;&amp;#039; パッケージに次のファイルが含まれているはずです。 &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
Wavelet.uno.zip&lt;br /&gt;
  Addons.xcu&lt;br /&gt;
  Wavelet.py&lt;br /&gt;
  images/WaveletBig.bmp&lt;br /&gt;
  images/WaveletSmall.bmp&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;注:&amp;#039;&amp;#039;&amp;#039; &amp;#039;&amp;#039;%origin%&amp;#039;&amp;#039; は &amp;#039;&amp;#039;Wavelet.uno.zip&amp;#039;&amp;#039; になります。従って、 &amp;#039;&amp;#039;%origin%/images/WaveletBig.bmp&amp;#039;&amp;#039; は &amp;#039;&amp;#039;Wavelet.uno.zip&amp;#039;&amp;#039; ファイル中の &amp;#039;&amp;#039;WaveletBig.bmp&amp;#039;&amp;#039; ファイルを指します。 &lt;br /&gt;
訳注: 現在の実装では %origin% はコンフィグレーションファイルの位置を指します。 &lt;br /&gt;
&lt;br /&gt;
==インストール==&lt;br /&gt;
UNO コンポーネントを拡張機能マネージャ (ツールメニューにあると思われます) または &amp;#039;&amp;#039;unopkg&amp;#039;&amp;#039; ツールでインストールできます。 &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
/opt/openoffice.org1.9.103/program/unopkg add Wavelet.uno.zip&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==アンインストール==&lt;br /&gt;
UNO コンポーネントを拡張機能マネージャ (ツールメニューにあるでしょう) または &amp;#039;&amp;#039;unopkg&amp;#039;&amp;#039; ツールでアンインストールできます。 &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
/opt/openoffice.org1.9.103/program/unopkg remove Wavelet.uno.zip&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Python コンポーネントのテスト=&lt;br /&gt;
Python UNO コンポーネントをテストするためにそのコンポーネントをインストールする必要はありません。実行されている OpenOffice.org のインスタンスに接続して UNO コンポーネントをテストできます。 &lt;br /&gt;
&lt;br /&gt;
==コード==&lt;br /&gt;
次のコードを &amp;#039;&amp;#039;Wavelet.py&amp;#039;&amp;#039; ファイルの最後に追加してください。 &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    import os&lt;br /&gt;
 &lt;br /&gt;
    # Start OpenOffice.org, listen for connections and open testing document&lt;br /&gt;
    os.system( &amp;quot;/etc/openoffice.org-1.9/program/soffice &amp;#039;-accept=socket,host=localhost,port=2002;urp;&amp;#039; -writer ./WaveletTest.odt &amp;amp;&amp;quot; )&lt;br /&gt;
 &lt;br /&gt;
    # Get local context info&lt;br /&gt;
    localContext = uno.getComponentContext()&lt;br /&gt;
    resolver = localContext.ServiceManager.createInstanceWithContext(&lt;br /&gt;
        &amp;quot;com.sun.star.bridge.UnoUrlResolver&amp;quot;, localContext )&lt;br /&gt;
 &lt;br /&gt;
    ctx = None&lt;br /&gt;
 &lt;br /&gt;
    # Wait until the OO.o starts and connection is established&lt;br /&gt;
    while ctx == None:&lt;br /&gt;
        try:&lt;br /&gt;
            ctx = resolver.resolve(&lt;br /&gt;
                &amp;quot;uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext&amp;quot; )&lt;br /&gt;
        except:&lt;br /&gt;
            pass&lt;br /&gt;
 &lt;br /&gt;
    # Trigger our job&lt;br /&gt;
    wavelet = Wavelet( ctx )&lt;br /&gt;
    wavelet.trigger( () )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==テスト==&lt;br /&gt;
UNO コンポーネントをテストするには、&amp;#039;&amp;#039;Wavelet.py&amp;#039;&amp;#039; ファイルを Python インタープレタからただ実行してください。 &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
/opt/openoffice.org1.9.103/program/python ./Wavelet.py&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==概要==&lt;br /&gt;
このパートでは次のことを行います。 &lt;br /&gt;
&lt;br /&gt;
OpenOffice.org を開始して &amp;#039;&amp;#039;WaveletTest.odt&amp;#039;&amp;#039; ファイルを開きます。 &lt;br /&gt;
&lt;br /&gt;
接続が確立するまでループします。 &lt;br /&gt;
&lt;br /&gt;
コンポーネントを 実行中の OpenOffice.org context で開始します。 &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;注:&amp;#039;&amp;#039;&amp;#039; 実際の UNO コンポーネントパッケージを作成するときにこのパートを削除するのを忘れないでください。もしくはコメントにしてください。&lt;br /&gt;
訳注: 実際には削除する必要はありません。パッケージ内で実行されるときにはモジュールが __main__ でないので実行されません。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=参照=&lt;br /&gt;
* [http://api.openoffice.org/docs/DevelopersGuide/Extensions/Extensions.xhtml Extensions] chapter of the Developers Guide&lt;br /&gt;
* Using C++ with OOo SDK : [[Constructing_Components| Constructing Component in C++]]&lt;br /&gt;
*[[Tutorial_UNO_Library|UNO tutorial]]&lt;br /&gt;
*[[Tutorial_UNO_IDL|UNO IDL]]&lt;br /&gt;
* [[Uno/Article/Types%26Reflection]]&lt;br /&gt;
* Daniel Bolzle&amp;#039;s [http://udk.openoffice.org/cpp/man/component_tutorial.html tutorial] : Writing a simple UNO component.&lt;br /&gt;
* [[UNO_component_packaging|Component with Python]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Uno]]&lt;br /&gt;
[[Category:Extensions]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=UNO_component_packaging&amp;diff=151760</id>
		<title>UNO component packaging</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=UNO_component_packaging&amp;diff=151760"/>
		<updated>2009-12-03T06:01:03Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Python UNO component=&lt;br /&gt;
This page shows you how to pack and deploy already written UNO component. I&amp;#039;m using my &amp;#039;&amp;#039;Wavelet&amp;#039;&amp;#039; class as an example of a very simple component. &lt;br /&gt;
&lt;br /&gt;
More detailed info is in the [[http://api.openoffice.org/docs/DevelopersGuide/Components/Components.htm Developers Guide]]. &lt;br /&gt;
&lt;br /&gt;
=Python loader=&lt;br /&gt;
The Python loader is not able load classes that are not it its own path. Thus it&amp;#039;s necessary to copy any classes or modules you will use into the OPenOffice Python lib directory, and it may be necessary to restart OOo before they are picked up. &lt;br /&gt;
&lt;br /&gt;
=Sample Python component=&lt;br /&gt;
&lt;br /&gt;
==Wavelet class==&lt;br /&gt;
We will use my sample &amp;#039;&amp;#039;Wavelet&amp;#039;&amp;#039; class which replaces space with non breaking space before the Czech prepositions. Put the following code in the &amp;#039;&amp;#039;Wavelet.py&amp;#039;&amp;#039; file. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import uno&lt;br /&gt;
import unohelper&lt;br /&gt;
from com.sun.star.task import XJobExecutor&lt;br /&gt;
&lt;br /&gt;
class Wavelet( unohelper.Base, XJobExecutor ):&lt;br /&gt;
    def __init__( self, ctx ):&lt;br /&gt;
        self.ctx = ctx&lt;br /&gt;
 &lt;br /&gt;
    def trigger( self, args ):&lt;br /&gt;
        desktop = self.ctx.ServiceManager.createInstanceWithContext(&lt;br /&gt;
            &amp;quot;com.sun.star.frame.Desktop&amp;quot;, self.ctx )&lt;br /&gt;
 &lt;br /&gt;
        doc = desktop.getCurrentComponent()&lt;br /&gt;
 &lt;br /&gt;
        try:&lt;br /&gt;
            search = doc.createSearchDescriptor()&lt;br /&gt;
            search.SearchRegularExpression = True&lt;br /&gt;
            search.SearchString = &amp;quot;\\&amp;lt;(k|s|v|z|o|u|i|a) &amp;quot;&lt;br /&gt;
            &lt;br /&gt;
            found = doc.findFirst( search )&lt;br /&gt;
            while found:&lt;br /&gt;
                found.String = found.String.replace( &amp;quot; &amp;quot;, u&amp;quot;\xa0&amp;quot; )&lt;br /&gt;
                found = doc.findNext( found.End, search)&lt;br /&gt;
 &lt;br /&gt;
        except:&lt;br /&gt;
            pass&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Wavelet class registration==&lt;br /&gt;
You have to tell the OpenOffice.org what is the main class of your component. Put the following code at the end of your &amp;#039;&amp;#039;Wavelet.py&amp;#039;&amp;#039; file. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
g_ImplementationHelper = unohelper.ImplementationHelper()&lt;br /&gt;
g_ImplementationHelper.addImplementation(&lt;br /&gt;
        Wavelet,&lt;br /&gt;
        &amp;quot;name.vojta.openoffice.Wavelet&amp;quot;,&lt;br /&gt;
        (&amp;quot;com.sun.star.task.Job&amp;quot;,),)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Component integration=&lt;br /&gt;
&lt;br /&gt;
==Icons==&lt;br /&gt;
You can create your own icons for the Menu item or the Toolbar button. The easiest way is to create two true color BMP files - the first one should be 26×26 and the second one should be 16×16. &lt;br /&gt;
&lt;br /&gt;
If you want to use alpha (transparent color), use &amp;#039;&amp;#039;#FF00FF&amp;#039;&amp;#039; (RGB) color. &lt;br /&gt;
&lt;br /&gt;
This possibility is optional and you&amp;#039;re not forced to create icons. &lt;br /&gt;
&lt;br /&gt;
==Addons.xcu==&lt;br /&gt;
Component integration configuration is in the &amp;#039;&amp;#039;Addons.xcu&amp;#039;&amp;#039; file. &lt;br /&gt;
&lt;br /&gt;
===Header===&lt;br /&gt;
The header of this file should contain: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=xml&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 xmlns:oor=&amp;quot;http://openoffice.org/2001/registry&amp;quot;&lt;br /&gt;
  xmlns:xs=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; oor:name=&amp;quot;Addons&amp;quot;&lt;br /&gt;
  oor:package=&amp;quot;org.openoffice.Office&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
    &amp;lt;node oor:name=&amp;quot;AddonUI&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Office Menu Bar===&lt;br /&gt;
Following part creates new menu item &amp;#039;&amp;#039;Czech&amp;#039;&amp;#039; (or &amp;#039;&amp;#039;Cestina&amp;#039;&amp;#039;, depends on the UI language) and the &amp;#039;&amp;#039;Wavelet&amp;#039;&amp;#039; menu item. &lt;br /&gt;
&lt;br /&gt;
This menu item is associated with the &amp;#039;&amp;#039;name.vojta.openoffice.Wavelet?execute&amp;#039;&amp;#039; &amp;#039;&amp;#039;URL&amp;#039;&amp;#039;. It means, that when you click on the menuitem, &amp;#039;&amp;#039;Wavelet.trigger&amp;#039;&amp;#039; method will be executed with the &amp;#039;&amp;#039;execute&amp;#039;&amp;#039; as an argument. &lt;br /&gt;
&lt;br /&gt;
This menu will be visible in the OpenOffice.org Writer only. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=xml&amp;gt;&lt;br /&gt;
        &amp;lt;node oor:name=&amp;quot;OfficeMenuBar&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;node oor:name=&amp;quot;name.vojta.openoffice.Wavelet&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;prop oor:name=&amp;quot;Title&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;value/&amp;gt;&lt;br /&gt;
                    &amp;lt;value xml:lang=&amp;quot;en-US&amp;quot;&amp;gt;Czech&amp;lt;/value&amp;gt;&lt;br /&gt;
                    &amp;lt;value xml:lang=&amp;quot;cs&amp;quot;&amp;gt;Cestina&amp;lt;/value&amp;gt;&lt;br /&gt;
                &amp;lt;/prop&amp;gt;&lt;br /&gt;
                &amp;lt;prop oor:name=&amp;quot;Target&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;value&amp;gt;_self&amp;lt;/value&amp;gt;&lt;br /&gt;
                &amp;lt;/prop&amp;gt;&lt;br /&gt;
                &amp;lt;prop oor:name=&amp;quot;ImageIdentifier&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;value/&amp;gt;&lt;br /&gt;
                &amp;lt;/prop&amp;gt;&lt;br /&gt;
                &amp;lt;node oor:name=&amp;quot;Submenu&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;URL&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                            &amp;lt;value&amp;gt;service:name.vojta.openoffice.Wavelet?execute&amp;lt;/value&amp;gt;&lt;br /&gt;
                        &amp;lt;/prop&amp;gt;&lt;br /&gt;
                        &amp;lt;prop oor:name=&amp;quot;Title&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                            &amp;lt;value/&amp;gt;&lt;br /&gt;
                            &amp;lt;value xml:lang=&amp;quot;en-US&amp;quot;&amp;gt;Wavelet&amp;lt;/value&amp;gt;&lt;br /&gt;
                            &amp;lt;value xml:lang=&amp;quot;cs&amp;quot;&amp;gt;Vlnka&amp;lt;/value&amp;gt;&lt;br /&gt;
                        &amp;lt;/prop&amp;gt;&lt;br /&gt;
                        &amp;lt;prop oor:name=&amp;quot;Target&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                            &amp;lt;value&amp;gt;_self&amp;lt;/value&amp;gt;&lt;br /&gt;
                        &amp;lt;/prop&amp;gt;&lt;br /&gt;
                        &amp;lt;prop oor:name=&amp;quot;Context&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                            &amp;lt;value&amp;gt;com.sun.star.text.TextDocument&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;/node&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Office Toolbar===&lt;br /&gt;
Following part creates new toolbar (with name &amp;#039;&amp;#039;Add-on 1&amp;#039;&amp;#039;, &amp;#039;&amp;#039;Add-on 2&amp;#039;&amp;#039;, …) and one button. This button is associated with the &amp;#039;&amp;#039;name.vojta.openoffice.Wavelet?execute&amp;#039;&amp;#039; &amp;#039;&amp;#039;URL&amp;#039;&amp;#039;. It means that the &amp;#039;&amp;#039;Wavelet.trigger&amp;#039;&amp;#039; method will be executed when you click on the button on the toolbar. &amp;#039;&amp;#039;execute&amp;#039;&amp;#039; will be passed as an argument. &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Note:&amp;#039;&amp;#039;&amp;#039; You can&amp;#039;t rename the toolbar. It&amp;#039;s due to the backwards compatibility with the 1.1.x version. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=xml&amp;gt;&lt;br /&gt;
        &amp;lt;node oor:name=&amp;quot;OfficeToolBar&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;node oor:name=&amp;quot;name.vojta.openoffice.Wavelet&amp;quot; oor:op=&amp;quot;replace&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;URL&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;value&amp;gt;service:name.vojta.openoffice.Wavelet?execute&amp;lt;/value&amp;gt;&lt;br /&gt;
                    &amp;lt;/prop&amp;gt;&lt;br /&gt;
                    &amp;lt;prop oor:name=&amp;quot;ImageIdentifier&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;value/&amp;gt;&lt;br /&gt;
                    &amp;lt;/prop&amp;gt;&lt;br /&gt;
                    &amp;lt;prop oor:name=&amp;quot;Title&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;value/&amp;gt;&lt;br /&gt;
                        &amp;lt;value xml:lang=&amp;quot;en-US&amp;quot;&amp;gt;Wavelet&amp;lt;/value&amp;gt;&lt;br /&gt;
                        &amp;lt;value xml:lang=&amp;quot;cs&amp;quot;&amp;gt;Vlnka&amp;lt;/value&amp;gt;&lt;br /&gt;
                    &amp;lt;/prop&amp;gt;&lt;br /&gt;
                    &amp;lt;prop oor:name=&amp;quot;Target&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;value&amp;gt;_self&amp;lt;/value&amp;gt;&lt;br /&gt;
                    &amp;lt;/prop&amp;gt;&lt;br /&gt;
                    &amp;lt;prop oor:name=&amp;quot;Context&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;value&amp;gt;com.sun.star.text.TextDocument&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;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Icons===&lt;br /&gt;
You can associate your icons with any &amp;#039;&amp;#039;URL&amp;#039;&amp;#039;. We will associate our icons with &amp;#039;&amp;#039;name.vojta.openoffice.Wavelet?execute&amp;#039;&amp;#039; &amp;#039;&amp;#039;URL&amp;#039;&amp;#039;. It means that all controls (menu item, button, …) associated with the same &amp;#039;&amp;#039;URL&amp;#039;&amp;#039; will use these icons. &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Note:&amp;#039;&amp;#039;&amp;#039; %origin% is the UNO component package. We will explain it later. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=xml&amp;gt;&lt;br /&gt;
        &amp;lt;node oor:name=&amp;quot;Images&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;node oor:name=&amp;quot;name.vojta.openoffice.Wavelet.image1&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;prop oor:name=&amp;quot;URL&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;value&amp;gt;service:name.vojta.openoffice.Wavelet?execute&amp;lt;/value&amp;gt;&lt;br /&gt;
                &amp;lt;/prop&amp;gt;&lt;br /&gt;
                &amp;lt;node oor:name=&amp;quot;UserDefinedImages&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;prop oor:name=&amp;quot;ImageSmallURL&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;value&amp;gt;%origin%/images/WaveletSmall.bmp&amp;lt;/value&amp;gt;&lt;br /&gt;
                    &amp;lt;/prop&amp;gt;&lt;br /&gt;
                    &amp;lt;prop oor:name=&amp;quot;ImageBigURL&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;value&amp;gt;%origin%/images/WaveletBig.bmp&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;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Footer===&lt;br /&gt;
Close all opened sections. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=xml&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;
=UNO component package=&lt;br /&gt;
UNO component package is a simple ZIP file. Obviously it contains the &amp;#039;&amp;#039;Addons.xcu&amp;#039;&amp;#039; file, &amp;#039;&amp;#039;images&amp;#039;&amp;#039; directory with icons and the Python component implementation. &lt;br /&gt;
&lt;br /&gt;
==Packing==&lt;br /&gt;
You can pack our sample package with the following command: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
zip -r Wavelet.uno.zip Addons.xcu Wavelet.py images&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The final &amp;#039;&amp;#039;Wavelet.uno.zip&amp;#039;&amp;#039; package should contain these files: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
Wavelet.uno.zip&lt;br /&gt;
  Addons.xcu&lt;br /&gt;
  Wavelet.py&lt;br /&gt;
  images/WaveletBig.bmp&lt;br /&gt;
  images/WaveletSmall.bmp&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Note:&amp;#039;&amp;#039;&amp;#039; The &amp;#039;&amp;#039;%origin%&amp;#039;&amp;#039; is &amp;#039;&amp;#039;Wavelet.uno.zip&amp;#039;&amp;#039;, thus the &amp;#039;&amp;#039;%origin%/images/WaveletBig.bmp&amp;#039;&amp;#039; points to the &amp;#039;&amp;#039;WaveletBig.bmp&amp;#039;&amp;#039; file in your &amp;#039;&amp;#039;Wavelet.uno.zip&amp;#039;&amp;#039; file. &lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
You can install your UNO component with the Extension manager (somewhere in the &amp;#039;&amp;#039;Tools&amp;#039;&amp;#039; menu) or with the &amp;#039;&amp;#039;unopkg&amp;#039;&amp;#039; tool. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
/opt/openoffice.org1.9.103/program/unopkg add Wavelet.uno.zip&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Uninstallation==&lt;br /&gt;
You can uninstall your UNO component with the Extension manager (somewhere in the &amp;#039;&amp;#039;Tools&amp;#039;&amp;#039; menu) or with the &amp;#039;&amp;#039;unopkg&amp;#039;&amp;#039; tool. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
/opt/openoffice.org1.9.103/program/unopkg remove Wavelet.uno.zip&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Python component testing=&lt;br /&gt;
It&amp;#039;s not necessary to install the Python UNO component to test it. You can connect to the running OpenOffice.org instance and test your UNO component directly. &lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
Append the following code at the end of the &amp;#039;&amp;#039;Wavelet.py&amp;#039;&amp;#039; file. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    import os&lt;br /&gt;
 &lt;br /&gt;
    # Start OpenOffice.org, listen for connections and open testing document&lt;br /&gt;
    os.system( &amp;quot;/etc/openoffice.org-1.9/program/soffice &amp;#039;-accept=socket,host=localhost,port=2002;urp;&amp;#039; -writer ./WaveletTest.odt &amp;amp;&amp;quot; )&lt;br /&gt;
 &lt;br /&gt;
    # Get local context info&lt;br /&gt;
    localContext = uno.getComponentContext()&lt;br /&gt;
    resolver = localContext.ServiceManager.createInstanceWithContext(&lt;br /&gt;
        &amp;quot;com.sun.star.bridge.UnoUrlResolver&amp;quot;, localContext )&lt;br /&gt;
 &lt;br /&gt;
    ctx = None&lt;br /&gt;
 &lt;br /&gt;
    # Wait until the OO.o starts and connection is established&lt;br /&gt;
    while ctx == None:&lt;br /&gt;
        try:&lt;br /&gt;
            ctx = resolver.resolve(&lt;br /&gt;
                &amp;quot;uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext&amp;quot; )&lt;br /&gt;
        except:&lt;br /&gt;
            pass&lt;br /&gt;
 &lt;br /&gt;
    # Trigger our job&lt;br /&gt;
    wavelet = Wavelet( ctx )&lt;br /&gt;
    wavelet.trigger( () )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
To test your UNO component, just run your &amp;#039;&amp;#039;Wavelet.py&amp;#039;&amp;#039; in the Python interpreter. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
/opt/openoffice.org1.9.103/program/python ./Wavelet.py&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resume==&lt;br /&gt;
This part does this: &lt;br /&gt;
&lt;br /&gt;
starts OpenOffice.org and opens the &amp;#039;&amp;#039;WaveletTest.odt&amp;#039;&amp;#039; file &lt;br /&gt;
&lt;br /&gt;
loop until the connection will be established &lt;br /&gt;
&lt;br /&gt;
start your component in the running OpenOffice.org context &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Note:&amp;#039;&amp;#039;&amp;#039; Do not forget to remove this part before real UNO component packaging. Or comment it out.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See also=&lt;br /&gt;
* [http://api.openoffice.org/docs/DevelopersGuide/Extensions/Extensions.xhtml Extensions] chapter of the Developers Guide&lt;br /&gt;
* Using C++ with OOo SDK : [[Constructing_Components| Constructing Component in C++]]&lt;br /&gt;
*[[Tutorial_UNO_Library|UNO tutorial]]&lt;br /&gt;
*[[Tutorial_UNO_IDL|UNO IDL]]&lt;br /&gt;
* [[Uno/Article/Types%26Reflection]]&lt;br /&gt;
* Daniel Bölzle&amp;#039;s [http://udk.openoffice.org/cpp/man/component_tutorial.html tutorial] : Writing a simple UNO component.&lt;br /&gt;
* [[UNO_component_packaging|Component with Python]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Uno]]&lt;br /&gt;
[[Category:Extensions]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=PyUNOServer&amp;diff=151759</id>
		<title>PyUNOServer</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=PyUNOServer&amp;diff=151759"/>
		<updated>2009-12-03T06:00:00Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:Py-uno_128.png|right|PyUNO Logo]]&lt;br /&gt;
The PyUNOServer is a script that works as an XML server for OpenOffice.org Calc where it can exchange data through XML calls. This means that can get data from other apps that are XML compliant. You can download the script from [http://es.openoffice.org/files/documents/73/2929/pyUnoServer.tar.gz this mirror] since the original site seems to be down.&lt;br /&gt;
&lt;br /&gt;
The zip file contains 3 files: &lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;PyUNOServerV2.py&amp;#039;&amp;#039;&amp;#039; - The Python Script&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;PyUNOServerV2.pyc&amp;#039;&amp;#039;&amp;#039; - compiled version&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;PyUNOServer.sh2&amp;#039;&amp;#039;&amp;#039; - the script to conect to the service&lt;br /&gt;
&lt;br /&gt;
The script have just 1 script called &amp;#039;&amp;#039;&amp;#039;PyUNOServerV2.py&amp;#039;&amp;#039;&amp;#039; however there is a faster, bytecode-compiled script. It also includes a bash script which loads the path to the openoffice.org application.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;NOTE: This script will work on just certain distros since the location of OpenOffice.org might vary. We recomend to load the path manually.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This script uses the following libraries:&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;OS&amp;#039;&amp;#039;&amp;#039; - This module provides a more portable way of using operating system dependent functionality than importing a operating system dependent built-in module like posix or nt.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;UNO&amp;#039;&amp;#039;&amp;#039; - Python UNO implementation module, this can used by python 2.3.4 &amp;#039;&amp;#039;&amp;#039;only&amp;#039;&amp;#039;&amp;#039; which is the python provided within openoffice.org. It provides all the interfaces from OpenOffice.org into python.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;SYS&amp;#039;&amp;#039;&amp;#039; - This module provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter. It is always available.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;time&amp;#039;&amp;#039;&amp;#039; - This module provides various time-related functions. It is always available, but not all functions are available on all platforms. Most of the functions defined in this module call platform C library functions with the same name. It may sometimes be helpful to consult the platform documentation, because the semantics of these functions varies among platforms.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;logging&amp;#039;&amp;#039;&amp;#039; - Logging is performed by calling methods on instances of the Logger class (hereafter called loggers). Each instance has a name, and they are conceptually arranged in a name space hierarchy using dots (periods) as separators.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;urllib&amp;#039;&amp;#039;&amp;#039; - This module provides a high-level interface for fetching data across the World Wide Web. In particular, the urlopen() function is similar to the built-in function open(), but accepts Universal Resource Locators (URLs) instead of filenames. Some restrictions apply -- it can only open URLs for reading, and no seek operations are available.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;SimpleXMLRPCServer&amp;#039;&amp;#039;&amp;#039; - The SimpleXMLRPCServer module provides a basic server framework for XML-RPC servers written in Python. Servers can either be free standing, using SimpleXMLRPCServer, or embedded in a CGI environment, using CGIXMLRPCRequestHandler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
# -*- coding: iso-8859-1 -*-&lt;br /&gt;
#&lt;br /&gt;
# pyUnoServer - version 2.0&lt;br /&gt;
from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler&lt;br /&gt;
import os&lt;br /&gt;
import uno&lt;br /&gt;
import sys&lt;br /&gt;
import time&lt;br /&gt;
import logging&lt;br /&gt;
import urllib&lt;br /&gt;
&lt;br /&gt;
class PyUNOServer(SimpleXMLRPCServer):&lt;br /&gt;
&lt;br /&gt;
	def _dispatch(self, method, params):&lt;br /&gt;
&lt;br /&gt;
		try:&lt;br /&gt;
			func = getattr(self, &amp;#039;&amp;#039; + method)&lt;br /&gt;
		except:&lt;br /&gt;
			self.logger.error(&amp;quot;El Metodo &amp;#039;&amp;quot;+method+&amp;quot;&amp;#039; no esta soportado!&amp;quot;)&lt;br /&gt;
			raise Exception(&amp;#039;method &amp;quot;%s&amp;quot; is not supported&amp;#039; % method)&lt;br /&gt;
		else:&lt;br /&gt;
			try:&lt;br /&gt;
				ret = func(*params)&lt;br /&gt;
				self.logger.info(&amp;quot;Llamada: %s%s | Retorno: %s&amp;quot; % (method, params, ret))&lt;br /&gt;
				return ret&lt;br /&gt;
			except:&lt;br /&gt;
				self.logger.info(&amp;quot;Llamada: %s%s&amp;quot; % (method, params))&lt;br /&gt;
				self.logger.error(&amp;quot;Error: %s:%s&amp;quot; % sys.exc_info()[:2])&lt;br /&gt;
&lt;br /&gt;
	def init(self):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		This method	starts an Openoffice session and initializes the XMLRPC server&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	&lt;br /&gt;
		# Generate some useful constants&lt;br /&gt;
		self.EMPTY = uno.Enum(&amp;quot;com.sun.star.table.CellContentType&amp;quot;, &amp;quot;EMPTY&amp;quot;)&lt;br /&gt;
		self.TEXT = uno.Enum(&amp;quot;com.sun.star.table.CellContentType&amp;quot;, &amp;quot;TEXT&amp;quot;)&lt;br /&gt;
		self.FORMULA = uno.Enum(&amp;quot;com.sun.star.table.CellContentType&amp;quot;, &amp;quot;FORMULA&amp;quot;)&lt;br /&gt;
		self.VALUE = uno.Enum(&amp;quot;com.sun.star.table.CellContentType&amp;quot;, &amp;quot;VALUE&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
		# Generate a Logger&lt;br /&gt;
		self.logger = logging.getLogger(&amp;#039;pyUnoServer&amp;#039;)&lt;br /&gt;
		hdlr = logging.FileHandler(&amp;#039;./pyUnoServer.log&amp;#039;)&lt;br /&gt;
		formatter = logging.Formatter(&amp;#039;%(asctime)s %(levelname)s -- %(message)s&amp;#039;)&lt;br /&gt;
		hdlr.setFormatter(formatter)&lt;br /&gt;
		self.logger.addHandler(hdlr) &lt;br /&gt;
		self.logger.setLevel(logging.INFO)&lt;br /&gt;
&lt;br /&gt;
		self.sessions = []&lt;br /&gt;
		self.sessionSerial = 0&lt;br /&gt;
&lt;br /&gt;
		# Start Calc and grep the PID&lt;br /&gt;
		self.PID = os.spawnlp(os.P_NOWAIT,&amp;quot;/usr/bin/oocalc&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;-accept=socket,host=localhost,port=2002;urp;&amp;quot;)&lt;br /&gt;
		&lt;br /&gt;
		self.logger.info(&amp;quot;OOCalc Iniciado con el PID %d&amp;quot; % self.PID)&lt;br /&gt;
&lt;br /&gt;
		while 1:&lt;br /&gt;
			try: &lt;br /&gt;
				localContext = uno.getComponentContext()&lt;br /&gt;
				resolver = localContext.ServiceManager.createInstanceWithContext(&amp;quot;com.sun.star.bridge.UnoUrlResolver&amp;quot;, localContext )&lt;br /&gt;
				smgr = resolver.resolve( &amp;quot;uno:socket,host=localhost,port=2002;urp;StarOffice.ServiceManager&amp;quot; )&lt;br /&gt;
				remoteContext = smgr.getPropertyValue( &amp;quot;DefaultContext&amp;quot; )&lt;br /&gt;
				self.desktop = smgr.createInstanceWithContext( &amp;quot;com.sun.star.frame.Desktop&amp;quot;,remoteContext)&lt;br /&gt;
				self.logger.info(&amp;quot;Sistema conectado al socket de UNO&amp;quot;)&lt;br /&gt;
				break&lt;br /&gt;
			except:&lt;br /&gt;
				time.sleep(0.5)&lt;br /&gt;
&lt;br /&gt;
	def openSession(self, session):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		This method opens a new session.&lt;br /&gt;
		Sample usage from PHP:&lt;br /&gt;
		 - $sessionString is your a session ID provided by your program):&lt;br /&gt;
&lt;br /&gt;
			$openSession = array( new XML_RPC_VALUE($sessionString, &amp;quot;string&amp;quot;));&lt;br /&gt;
			$sessionID = queryXMLRPC($client, &amp;quot;openSession&amp;quot;, $openSession);&lt;br /&gt;
			return $sessionID;&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
		currentSerial = -1&lt;br /&gt;
&lt;br /&gt;
		for i in range(len(self.sessions)):&lt;br /&gt;
			if self.sessions[i][0] == session:&lt;br /&gt;
				currentSerial = i&lt;br /&gt;
				break&lt;br /&gt;
		&lt;br /&gt;
		if currentSerial == -1:&lt;br /&gt;
			self.sessions.append([session,[]])&lt;br /&gt;
			currentSerial = len(self.sessions)-1&lt;br /&gt;
&lt;br /&gt;
		return currentSerial&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	def getSessions(self):&lt;br /&gt;
		return self.sessions&lt;br /&gt;
&lt;br /&gt;
	def openBook(self, session, bookPath):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		This method opens a new Openoffice spreadsheet book.&lt;br /&gt;
		Sample usage from PHP:&lt;br /&gt;
		 - $sessionID is the session&amp;#039;s ID returned by openSession()&lt;br /&gt;
		 - $path is the path to the book in the server&amp;#039;s filesystem&lt;br /&gt;
&lt;br /&gt;
		$openBookQuery = array( new XML_RPC_VALUE($sessionID, &amp;quot;int&amp;quot;), new XML_RPC_VALUE($path,&amp;quot;string&amp;quot;) );&lt;br /&gt;
		$bookID = queryXMLRPC($client, &amp;quot;openBook&amp;quot;, $openBookQuery);&lt;br /&gt;
		return $bookID;&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
		currentSerial = session&lt;br /&gt;
		bookPath = bookPath.strip()&lt;br /&gt;
		print bookPath&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
		exists = os.path.exists(bookPath)&lt;br /&gt;
		if exists == False:&lt;br /&gt;
			raise Exception(&amp;#039;El libro %s no existe&amp;#039;, bookPath)&lt;br /&gt;
		else:&lt;br /&gt;
			self.logger.info(&amp;quot;se ha encontrado el libro!&amp;quot;)&lt;br /&gt;
		&lt;br /&gt;
		currentBook = -1&lt;br /&gt;
		&lt;br /&gt;
		for i in range(len(self.sessions[currentSerial][1])):&lt;br /&gt;
			try:&lt;br /&gt;
&lt;br /&gt;
				book = self.sessions[currentSerial][1][i]&lt;br /&gt;
			&lt;br /&gt;
				bookname = book[0]&lt;br /&gt;
				bookhandler = book[1]&lt;br /&gt;
				bookmodtime = book[2]&lt;br /&gt;
			&lt;br /&gt;
				if bookname == bookPath:&lt;br /&gt;
					modtime = os.path.getmtime(bookPath)&lt;br /&gt;
					if modtime &amp;gt; bookmodtime:&lt;br /&gt;
						book[1].dispose()&lt;br /&gt;
						self.sessions[currentSerial][1].remove(book)&lt;br /&gt;
					else:&lt;br /&gt;
						currentBook = i&lt;br /&gt;
					break&lt;br /&gt;
			except:&lt;br /&gt;
				self.logger.error(&amp;quot;El libro &amp;quot;+currentBook+&amp;quot; no existe!&amp;quot;)&lt;br /&gt;
				&lt;br /&gt;
&lt;br /&gt;
		if currentBook &amp;lt; 0:&lt;br /&gt;
			handler = self.desktop.loadComponentFromURL( &amp;quot;file://&amp;quot; + bookPath ,&amp;quot;_blank&amp;quot;,0,())&lt;br /&gt;
&lt;br /&gt;
			if handler == None:&lt;br /&gt;
				raise Exception(&amp;#039;El libro no existe o tiene caracteres extraños...&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
			modtime = os.path.getmtime(bookPath)&lt;br /&gt;
			&lt;br /&gt;
			estruct = [bookPath,handler,modtime]&lt;br /&gt;
			self.sessions[currentSerial][1].append(estruct)&lt;br /&gt;
			currentBook = len(self.sessions[currentSerial][1])-1&lt;br /&gt;
			&lt;br /&gt;
		return currentBook&lt;br /&gt;
&lt;br /&gt;
	def closeBook(self, sessionID, bookID):&lt;br /&gt;
		&lt;br /&gt;
		books = self.sessions[sessionID][1]&lt;br /&gt;
		&lt;br /&gt;
		# Close the document. It doesn&amp;#039;t look very elegant but thats the way is documented.&lt;br /&gt;
		books[bookID][1].dispose()&lt;br /&gt;
		self.sessions[sessionID][1].remove(books[bookID])&lt;br /&gt;
		&lt;br /&gt;
		return 1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	def getBookSheets(self, sessionID, bookID):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		This method return an array with the book&amp;#039;s worksheets.&lt;br /&gt;
		Sample usage from PHP:&lt;br /&gt;
		 - $sessionID is the session&amp;#039;s ID returned by openSession()&lt;br /&gt;
		 - $bookID is the book&amp;#039;s ID returned by openBook()&lt;br /&gt;
&lt;br /&gt;
		$sheetsQuery = array( new XML_RPC_VALUE($sessionID, &amp;quot;int&amp;quot;), new XML_RPC_VALUE($bookID, &amp;quot;int&amp;quot;) );&lt;br /&gt;
		$sheets = queryXMLRPC($client, &amp;quot;getBookSheets&amp;quot; , $sheetsQuery);&lt;br /&gt;
		return $sheets;&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		sheets = self.sessions[sessionID][1][bookID][1].getSheets().createEnumeration()&lt;br /&gt;
		&lt;br /&gt;
		container = []&lt;br /&gt;
		while sheets.hasMoreElements():&lt;br /&gt;
			currentSheet = sheets.nextElement()&lt;br /&gt;
			container.append(currentSheet.getName().encode(&amp;quot;UTF-8&amp;quot;))&lt;br /&gt;
			&lt;br /&gt;
		return container&lt;br /&gt;
&lt;br /&gt;
	def getCellValue (self,sheet,x,y):&lt;br /&gt;
&lt;br /&gt;
		cell = sheet.getCellByPosition(x,y)&lt;br /&gt;
		cellType  = cell.getType()&lt;br /&gt;
&lt;br /&gt;
		if cellType == self.TEXT :&lt;br /&gt;
			data = cell.getString().encode(&amp;quot;UTF-8&amp;quot;)&lt;br /&gt;
			if data == None:&lt;br /&gt;
				return &amp;quot;&amp;quot;&lt;br /&gt;
			return data.encode(&amp;quot;UTF-8&amp;quot;)&lt;br /&gt;
			&lt;br /&gt;
		if cellType == self.FORMULA or cellType == self.VALUE :&lt;br /&gt;
			data = cell.getValue()&lt;br /&gt;
			if data == None:&lt;br /&gt;
				return 0&lt;br /&gt;
			return cell.getValue()&lt;br /&gt;
&lt;br /&gt;
		if cellType == self.EMPTY :&lt;br /&gt;
			return &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	def getCell(self, session, book, sheet, x, y):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		This method returns the content of a cell.&lt;br /&gt;
		Sample usage from PHP:&lt;br /&gt;
		 - $sessionID is the session&amp;#039;s ID returned by openSession()&lt;br /&gt;
		 - $bookID is the book&amp;#039;s ID returned by openBook()&lt;br /&gt;
		 - $sheet is the sheet&amp;#039;s ID as returned by getBookSheets()&lt;br /&gt;
&lt;br /&gt;
		$query = array(	&lt;br /&gt;
						new XML_RPC_Value($sessionID, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_VALUE($bookID, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_VALUE($sheet, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_Value($x, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_Value($y, &amp;quot;string&amp;quot;)&lt;br /&gt;
					);&lt;br /&gt;
&lt;br /&gt;
		$result = queryXMLRPC($client, &amp;quot;getCell&amp;quot;, $query);&lt;br /&gt;
		return $result;&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
		sheetref = self.sessions[session][1][book][1].getSheets().getByIndex(sheet)&lt;br /&gt;
		valor = self.getCellValue(sheetref,x,y)&lt;br /&gt;
		return valor&lt;br /&gt;
		&lt;br /&gt;
	def setCell(self,session,book,sheet,x,y,value):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		This method sets the content of a cell.&lt;br /&gt;
		Sample usage from PHP:&lt;br /&gt;
		 - $sessionID is the session&amp;#039;s ID returned by openSession()&lt;br /&gt;
		 - $bookID is the book&amp;#039;s ID returned by openBook()&lt;br /&gt;
		 - $sheet is the sheet&amp;#039;s ID as returned by getBookSheets()&lt;br /&gt;
&lt;br /&gt;
		$query = array(&lt;br /&gt;
						new XML_RPC_Value($sessionID, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_VALUE($bookID, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_VALUE($sheet, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_Value($x, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_Value($y, &amp;quot;int&amp;quot;),&lt;br /&gt;
						new XML_RPC_Value($value, &amp;quot;string&amp;quot;)&lt;br /&gt;
					);&lt;br /&gt;
&lt;br /&gt;
		$result = queryXMLRPC($client, &amp;quot;setCell&amp;quot;, $query);&lt;br /&gt;
		return $result;&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		bookObject = self.sessions[session][1][book][1]&lt;br /&gt;
		cell = bookObject.getSheets().getByIndex(sheet).getCellByPosition(x,y)&lt;br /&gt;
		cell.setValue(value)&lt;br /&gt;
		return 1&lt;br /&gt;
&lt;br /&gt;
	#what will change? mmm...&lt;br /&gt;
	def massiveSetCell(self, data):&lt;br /&gt;
			for valores in data:&lt;br /&gt;
				session,sheetid,x,y,valor = valores.split(&amp;quot;|&amp;quot;)&lt;br /&gt;
				code = self.setCell(self.trim(session),self.trim(sheetid),self.trim(x),self.trim(y),valor)&lt;br /&gt;
				if code &amp;lt; 0:&lt;br /&gt;
					return code&lt;br /&gt;
			return 1&lt;br /&gt;
&lt;br /&gt;
	def getSheetPreview(self,session,book,sheet):&lt;br /&gt;
&lt;br /&gt;
		sheet = self.sessions[session][1][book][1].getSheets().getByIndex(sheet)&lt;br /&gt;
		range = sheet.getCellRangeByPosition(0,0,8,23).getDataArray()&lt;br /&gt;
		return range&lt;br /&gt;
		&lt;br /&gt;
&lt;br /&gt;
	def trim(self, cadena):&lt;br /&gt;
		return cadena.strip()&lt;br /&gt;
	&lt;br /&gt;
server = PyUNOServer((&amp;quot;localhost&amp;quot;, 8000))&lt;br /&gt;
&lt;br /&gt;
server.init()&lt;br /&gt;
server.logger.info(&amp;quot;Servicio Inicializado...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
	server.serve_forever()&lt;br /&gt;
except KeyboardInterrupt:&lt;br /&gt;
	server.logger.info(&amp;quot;Cerrando el socket...&amp;quot;)&lt;br /&gt;
	server.server_close()&lt;br /&gt;
	os.kill(server.PID,1)&lt;br /&gt;
	server.logger.info(&amp;quot;Socket cerrado.&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==startPyUnoServer.sh2==&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/openoffice/program/&lt;br /&gt;
export PYTHONPATH=$PYTHONPATH:/usr/lib/openoffice/program&lt;br /&gt;
export DISPLAY=localhost:1&lt;br /&gt;
echo &amp;quot;Logging en pyUnoServer.log&amp;quot;&lt;br /&gt;
python pyUnoServerV2.py&lt;br /&gt;
echo &amp;quot;Ciao!&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Python]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
</feed>