<?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=Jcn</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=Jcn"/>
	<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/wiki/Special:Contributions/Jcn"/>
	<updated>2026-12-05T05:12:15Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.14</generator>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Uno/FAQ&amp;diff=120022</id>
		<title>Uno/FAQ</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Uno/FAQ&amp;diff=120022"/>
		<updated>2009-04-16T10:17:05Z</updated>

		<summary type="html">&lt;p&gt;Jcn: New entry about .MAP file and std_UNO_lib_file (): What if recomp does not find your C++ service&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Uno/FAQ zh|中]]&lt;br /&gt;
&lt;br /&gt;
Frequently Asked Questions about Uno, UDK, URE etc. Based on questions and answers posted to the dev@udk.openoffice.org mailing list. Any comments or questions will also be answered there.&lt;br /&gt;
&lt;br /&gt;
==General==&lt;br /&gt;
===Hey, the OpenOffice.org component technology is great. How do I contribute?===&lt;br /&gt;
Great, you&amp;#039;re always welcome. To find some ideas on where to help please browse the [[Uno/To-Dos|open task list]]. If you&amp;#039;ve got any questions about any of these tasks don&amp;#039;t hesitate to ask them. Please post them to the [http://udk.openoffice.org/servlets/SummarizeList?listName=dev dev@udk.openoffice.org] mailing list.&lt;br /&gt;
&lt;br /&gt;
===Does UNO depend on OpenOffice.org?===&lt;br /&gt;
In the near future, there will be an Office Development Kit available for download beside the openoffice.org-setup-set. This development kit contains all files (include-files, libraries, tools, etc.) that are necessary to build components. The development kit will also contain samples. These samples are built with makefiles, that only require gnumake (not the whole openoffice.org build environment). These makefiles can be used as a template to integrate the build of your UNO-components into your build environment.&lt;br /&gt;
&lt;br /&gt;
===Is UNO analogous to MS COM?===&lt;br /&gt;
Yes, UNO can be seen as an component model completely independent from the office itself. It is in direct competition to COM. You can find a feature list [http://udk.openoffice.org/common/man/uno.html here].&lt;br /&gt;
&lt;br /&gt;
===What is the ODK?===&lt;br /&gt;
The Office Development Kit (ODK) extends the UDK with additional documentation, API&amp;#039;s (more IDL&amp;#039;s), and examples. The UDK is a subset of the ODK. If you want to extend the OpenOffice.org, or write solutions with OpenOffice.org, then the ODK fits your needs. The UDK is a stand alone object model, that can be used without OpenOffice.org. The UDK will be the main target of integration discussions with Gnome and XPCOM, for achieving the long term goal of having only one Open Source Object Model. In the future, it should be possible to write components which depend on the ODK and components which are independent from OpenOffice.org.&lt;br /&gt;
&lt;br /&gt;
The Office Development Kit enables software engineers to develop components for OpenOffice.org without the need of the bulky OpenOffice.org build environment. Thus, the ODK includes the binaries of the base libraries (+ im&lt;br /&gt;
port libraries), C++ header files, all idl-files, .jar files, and development tools (code generators, tools to register components, etc.) The ODK, additionally, includes some source examples and makefiles, that only require gnumake and a C++-compiler, you can take the makefiles, as an example, to integrate them into your build environment. The development kit will be provided in the future alongside every OpenOffice.org build and will be available as an separate [http://download.openoffice.org/index.html#sdk download].&lt;br /&gt;
&lt;br /&gt;
===Why didn&amp;#039;t you use Java or CORBA as middleware?===&lt;br /&gt;
We wanted a middleware which can be used for components with a fine granularity, at least, in-process. If you use different UNO components in the same language than there is no overhead (e.g., in C++ a call is only a virtual method call). Unfortunately, CORBA has no in-process specification of interfaces and structures. The only way to communicate is through the IIOP protocol. The overhead is too high for in-process communication. We wanted to be programming language independent: let UNO be a mediator between different languages like Java, C++, C and other languages, this isn&amp;#039;t the goal of CORBA. Another goal of UNO is to be the mediator between different object models like COM/DCOM, CORBA, Java, and XPCOM which does not appear to be a goal of other object models.&lt;br /&gt;
&lt;br /&gt;
===What are the differences between UNO and CORBA?===&lt;br /&gt;
UNO does not generate stub code. We did this in the former UNO2 implementation. One problem was, that the generated stub code was quite a heavy load (about 12 MB at former times, even though the API had less types as compared to now!). With UNO3 (the current version), we decided to generically call implementations, without having generated stub code, just by providing bridging code that knows the specific compiler that compiled the implementation. The only thing that is generated for C++, besides the pure virtual classes, are the getCppuType() functions to reflect types. The full type description is read at runtime from a binary storage. This approach has the advantage that on increasing numbers of types, less space is used. To see more the differences between UNO and CORBA, please have a look on the following [http://udk.openoffice.org/common/man/comparison_uno_corba.html comparison].&lt;br /&gt;
&lt;br /&gt;
===What are the differences between UNO IDL and CORBA IDL?===&lt;br /&gt;
UNO IDL has:&lt;br /&gt;
* inheritance of structures and exceptions&lt;br /&gt;
* a stereotype &amp;quot;service&amp;quot; (an abstract class which combines interfaces and properties)&lt;br /&gt;
* can assign specific values to enumeration values&lt;br /&gt;
* no stereotype array (but ad-hoc sequences)&lt;br /&gt;
* no union stereotype &lt;br /&gt;
&lt;br /&gt;
===Can I use OpenOffice.org components as JavaBeans?===&lt;br /&gt;
Yes, the OpenOffice.org bean (OOBean) project enables the use of OpenOffice.org components in Java applications. Please visit  [[OOoBean]] for information, source code, and binary downloads.&lt;br /&gt;
&lt;br /&gt;
The OOo Bean features&lt;br /&gt;
* Embedding OpenOffice.org components into Java application or applets.&lt;br /&gt;
* Accessing the whole StarOffice API from Java, to implement your own applications. &lt;br /&gt;
The project is just starting, so please be aware there may be bugs, incomplete documentation, install problems, etc. We would like everyone with interest in OpenOffice.org and Java to contribute to this project, or just use the bean in their Java application.&lt;br /&gt;
&lt;br /&gt;
==Development==&lt;br /&gt;
===Can you give me some example code?===&lt;br /&gt;
====C++ Examples====&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#efefef;&amp;quot; &lt;br /&gt;
| Where || What&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.openoffice.org/source/browse/udk/remotebridges/examples/officeclient.cxx udk/remotebridges/examples/officeclient.cxx] || The example shows how to build up an interprocess bridge to an OpenOffice.org document. There are no differences if you write a component for Windows or Linux.&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.openoffice.org/source/browse/udk/product/examples/ udk/product/examples/] || More examples. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====HTML Documentation====&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#efefef;&amp;quot; &lt;br /&gt;
| Where || What&lt;br /&gt;
|-&lt;br /&gt;
| http://udk.openoffice.org/cpp/man/tutorial/remotedemo.html || Remote demo tutorial&lt;br /&gt;
|-&lt;br /&gt;
| http://udk.openoffice.org/cpp/man/component_tutorial.html || Component writing in UNO space&lt;br /&gt;
|-&lt;br /&gt;
| http://udk.openoffice.org/cpp/man/tutorial/unointro.html || C++ specific guide to UNO&lt;br /&gt;
|-&lt;br /&gt;
| http://udk.openoffice.org/common/man/concept/unointro.html || Language independent guide to UNO&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Java Examples====&lt;br /&gt;
We lack a good document on how to start developing using Java. You have a look at the source directly. There are also some examples in the jurt project, which you can check out using&lt;br /&gt;
&lt;br /&gt;
  $ cvs -d :pserver:anoncvs@anoncvs.services.openoffice.org:/cvs co udk/jurt&lt;br /&gt;
&lt;br /&gt;
You&amp;#039;ll find some examples in the source code demo-tree: &lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#efefef;&amp;quot; &lt;br /&gt;
| Where || What&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.openoffice.org/source/browse/udk/jurt/demo/com/sun/star/demo/TestOffice.java jurt/demo/com/sun/star/demo/TestOffice.java] || Starts up an interprocess bridge and creates several documents in the office.&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.openoffice.org/source/browse/udk/jurt/demo/com/sun/star/comp/demo/ jurt/demo/com/sun/star/comp/demo/] || Here some sample code can be found on how to setup a JavaComponent. The sample can be registered with an office and thus runs within the same process as the office.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
We also suggest having a look at the sun-developer-connection (http://developers.sun.com/), when you click on Download SDK, you can download the StarOffice Programmers Tutorial. It contains some examples on certain API-topics. Please use the [http://api.openoffice.org/servlets/ProjectMailingListList dev@api.openoffice.org] mailing list for asking high level office API questions.&lt;br /&gt;
&lt;br /&gt;
===How do I generate C++ type definitions?===&lt;br /&gt;
#. create .idl files describing the interface&lt;br /&gt;
#. generate .urd file using unoidl&lt;br /&gt;
#. merge the new type(s) into the system registry with regmerge&lt;br /&gt;
#. create the C++ types using cppumaker (for Java: use javamaker)&lt;br /&gt;
#. for Java: compile the generated interfaces and add them to your CLASSPATH&lt;br /&gt;
&lt;br /&gt;
===What&amp;#039;s the purpose of regcomp?===&lt;br /&gt;
The unoidl converts the IDL description into a binary type library format; this type information is needed for every IDL type at runtime. The generated output file of unoidl contains only the type information of the specified IDL file. It does not contain the complete type descriptions of all types. So, it is necessary to install the new types in the type library applicat.rdb using regmerge. If somebody has developed a UNO component, he must support/export some administration functions (e.g., component_writeInfo). In the component_writeInfo function the developer gives some information about the supported services and the implementation name. This information is later used by the service manager to instantiate the component. So, if you developed your own component, you must install your component to the runtime. This could be done with regcomp. regcomp reads the component_writeInfo function and does some administration work with that information. For example, all supported services of the component are inserted in a global SERVICES section, which is used by the service manager. In this section a relation between the service name and the implementation name is established. Under the reserved area IMPLEMENTATIONS you&amp;#039;ll find the appropriate section for your own component, which is equal to the key defined in the component_writeInfo function. Please have a look at the installed applicat.rdb in your office directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ regview applicat.rdb /SERVICES&lt;br /&gt;
$ regview applicat.rdb /SERVICES/&amp;lt;service_name&amp;gt;&lt;br /&gt;
$ regview applicat.rdb /IMPLEMENTATIONS&lt;br /&gt;
$ regview applicat.rdb /IMPLEMENTATIONS/&amp;lt;implementation_name&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
So regcomp is always needed if you want to install a new component. regmerge is needed to install new types in the type library. &lt;br /&gt;
&lt;br /&gt;
Where is the OpenOffice.org API?&lt;br /&gt;
&lt;br /&gt;
Please visit the http://api.openoffice.org project site.&lt;br /&gt;
&lt;br /&gt;
===How do I test my components?===&lt;br /&gt;
If you develop a new component it&amp;#039;ll end up in a shared library or dynamic link library (DLL). The DLL will be loaded on demand if the implemented service is requested. To make the component visible and usable in the OpenOffice.org, you&amp;#039;ll have to register your service as a external component. To achieve this you&amp;#039;ll need to follow these steps:&lt;br /&gt;
&lt;br /&gt;
#. copy your DLL into the .../program directory&lt;br /&gt;
#. copy the tool regcomp into the .../program directory. You will find this tool in the UDK module cpputools&lt;br /&gt;
#. use the regcomp tool &amp;lt;pre&amp;gt;$ regcomp -register -r applicat.rdb -c foo.dll&amp;lt;/pre&amp;gt;&lt;br /&gt;
#. If you develop your own interfaces or new types, then you have to register these new types in the UNO type library. For doing that you need the tool regmerge which you find in the UDK module registry. The unoidl tool generated a foo.urd file which contains the new types. You&amp;#039;ll find this file in the output directory of your component.&lt;br /&gt;
#. use the regmerge tool &amp;lt;pre&amp;gt;$ regmerge applicat.rdb /UCR foo.urd&amp;lt;/pre&amp;gt; All type descriptions of IDL types are stored in the registry under the reserved key UCR (UNO core reflection)&lt;br /&gt;
#. After registration of the component and the new types you are able to instantiate your service via the service manager.&lt;br /&gt;
&lt;br /&gt;
A very easy and fast way to instantiate a new service is by using basic. Start a new basic script and type in the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Sub Main&lt;br /&gt;
  s = createUnoService(&amp;quot;YourSerivceName&amp;quot;)&lt;br /&gt;
  msgbox(s.dbg_supportedinterfaces)&lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the instantiation is successful, the message box will show all supported interfaces of the object.&lt;br /&gt;
&lt;br /&gt;
More information can be found in the README files in the directory http://www.openoffice.org/source/browse/udk/product/examples/.&lt;br /&gt;
&lt;br /&gt;
===How many bridges exist?===&lt;br /&gt;
Currently there exist 4 bridges: the C++ bridge, the Java bridge, the [http://udk.openoffice.org/common/man/spec/urp.html UNO Remote Protocol (URP) bridge], and the [http://api.openoffice.org/ IIOP bridge].&lt;br /&gt;
&lt;br /&gt;
===When is a bridge involved?===&lt;br /&gt;
If you develop your components in C++, remember that for in process calling of components compiled by the same compiler, there is no need to bridge any interface. The component loader recognizes this fact and uses the implemented C++ interface directly. But if you use scripting (e.g., basic) to call a Java component or to do remote UNO to some other process, bridging is indeed involved.&lt;br /&gt;
&lt;br /&gt;
===How do I specify default values for structs?===&lt;br /&gt;
It is not possible to specify default values for structs because these defaults cannot be used in other object models (e.g., CORBA). It is also impossible to emulate default values for member variables by modifying the unoidl-generated default constructors for structs. The default constructors set enums to the first enum value, numbers to 0, and the other types use their default constructors. The generated inline default constructor can be found in the .hpp file. The constructor sets the members to known initial values only.&lt;br /&gt;
&lt;br /&gt;
===Hey, my component just dumps core. What&amp;#039;s going wrong?===&lt;br /&gt;
Since it&amp;#039;s hard to tell from a stack trace only, what is going wrong, please send as much information as possible. If you&amp;#039;re lucky, you&amp;#039;re the writer of the service and you can send the component implementation code and the code which instantiates the object as well. If you are not the component developer then you&amp;#039;re forced to contact the component developer.&lt;br /&gt;
&lt;br /&gt;
===Why is it so annoying to write a compiler version dependent C++ bridge?===&lt;br /&gt;
The goal behind UNO is to provide the simplest language binding for the UNO component writer and user, the least amount of generated code, and a maximum of execution speed. With the current technique, the goals are reached. For example, in C++ there is no call overhead, because a C++ to C++ call is only a virtual method call. There is no compile time code generation, it is done by the bridge on the fly. The UNO C++ language binding is smarter than all other (CORBA, COM) bindings. On the other hand, writing a C++ bridge is a hard thing to do, but this has to be done only once for each compiler, operating system, and processor. There are simpler ways to achieve language bindings, but they aren&amp;#039;t better ways. A bridge from cpp to uno is very compiler and abi dependent, and at first glance, it seems that it isn&amp;#039;t portable at all. But it must be noted that the bridge code is pretty similar for most compilers. The main differences are the generated vtables, performing C++ virtual calls, and handling exceptions.&lt;br /&gt;
&lt;br /&gt;
===How do I implement a C++ bridge for a RISC CPU?===&lt;br /&gt;
On RISC machines parameters to functions are passed in registers, whereas, the C++ bridge code manipulates a stack between the C++ layout and the required uno layout. For an example of how this is solved, please see the sunpro5 solaris sparc bridge. Registers are pushed right to stack (extending non-register parameters on the stack [if more than 6]). &lt;br /&gt;
&lt;br /&gt;
===Which PropertyValue should I use when loading an existing document?===&lt;br /&gt;
A document is always opened through a loader with an empty property argument&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PropertyValue [] szEmptyArgs = new PropertyValue [0];&lt;br /&gt;
String doc = &amp;quot;private:factory/swriter&amp;quot;;&lt;br /&gt;
aDoc = oCLoader.loadComponentFromURL(doc, &amp;quot;_blank&amp;quot;, 0, szEmptyArgs );&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
Using these arguments, you can force OpenOffice.org to use a certain filter, open the document read-only, and set a password for password protected documents. The csv-filter for spreadsheet documents has some additional options which are the same as the pick list from the UI,the options are stored in the soffice.ini/sofficerc.&lt;br /&gt;
&lt;br /&gt;
===How do I open an existing document and then save it into HTML format?===&lt;br /&gt;
Here&amp;#039;s some sample code for that:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PropertyValue [] mypv = new PropertyValue[1];&lt;br /&gt;
mypv[0] = new PropertyValue();&lt;br /&gt;
mypv[0].Name = new String(&amp;quot;FilterName&amp;quot;);&lt;br /&gt;
mypv[0].Value = new String(&amp;quot;scalc: Text - txt&amp;quot;);&lt;br /&gt;
mypv[0].Handle = -1;&lt;br /&gt;
mypv[0].State = PropertyState.DEFAULT_VALUE;&lt;br /&gt;
aStore.storeAsURL(doc, mypv);  //aStore is a XStorable object, and doc is url string&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===How do I save a OpenOffice.org document as XML?===&lt;br /&gt;
Here&amp;#039;s some sample code for that:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sub SaveXML&lt;br /&gt;
  dim mProps(0) as new com.sun.star.beans.PropertyValue&lt;br /&gt;
  mProps(0).Name = &amp;quot;FilterName&amp;quot;&lt;br /&gt;
  &amp;#039;This works with 614&lt;br /&gt;
  mProps(0).Value = &amp;quot;swriter: StarOffice XML (Writer)&amp;quot; &lt;br /&gt;
  oDesk = createUNOService(&amp;quot;com.sun.star.frame.Desktop&amp;quot;)&lt;br /&gt;
  &amp;#039;For some reason, ActiveComponent no longer works:&lt;br /&gt;
  oComponent = oDesk.CurrentComponent()&lt;br /&gt;
  oComponent.storeAsUrl(&amp;quot;file:///C|/Tmp/startemp.xml&amp;quot;,_&lt;br /&gt;
  mProps())&lt;br /&gt;
end sub &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Should I always use queryInterface?===&lt;br /&gt;
You don&amp;#039;t need to call queryInterface directly. A more comfortable way is to use a special reference constructor for this. Instead of&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  ::com::sun::star::uno::Any x = xI-&amp;gt;queryInterface(&lt;br /&gt;
    ::getCppuType((const ::com::sun::star::uno::Reference&amp;lt; &lt;br /&gt;
      ::com::sun::star::i18n::XTransliteration&amp;gt;*)0));&lt;br /&gt;
  x &amp;gt;&amp;gt;= transRef;&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
you should use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
transRef = Reference&amp;lt; XTransliteration &amp;gt;( xI, UNO_QUERY );&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===What does cannot dump type &amp;#039;com/star/uno/RuntimeException&amp;#039; mean?===&lt;br /&gt;
First, make sure that you followed the FAQ entry [[Uno/FAQ#How_do_I_generate_C.2B.2B_type_definitions.3F|&amp;#039;How do I generate C++ type definitions?&amp;#039;]]. That means: you created a .idl file that &amp;quot;describes&amp;quot; or &amp;quot;defines&amp;quot; the component. You use the unoidl tool to compile the idl file. Run the cppumaker on the resulting .urd file. The cppumaker generates a C++ representation for idl types and it works on a type library which is generated by the unoidl. If you followed these steps and get the error: cppumaker ERROR: cannot dump type &amp;#039;com/star/uno/RuntimeException&amp;#039;, you must integrate your new type into the system type library because the type information is needed at runtime and also for generating the C++ code. For doing that, the easiest way is to merge your &amp;#039;XXX.urd&amp;#039; files into the system type library. The system type library is called applicat.rdb and can be found in the program directory. To merge the type library, you must use the tool regmerge which you should find in the build environment. All type information in the applicat.rdb are saved under a reserved area &amp;#039;UCR&amp;#039;. You must merge your own types also in this reserved area. Using regmerge:&lt;br /&gt;
 $ regmerge applicat.rdb /UCR yourtypes.urd&lt;br /&gt;
There exists another nice tool to view the contents of a registry file (= type library):&lt;br /&gt;
 $ regview applicat.rdb /UCR/com/sun/star/uno&lt;br /&gt;
This shows all types of the module com.sun.star.uno or&lt;br /&gt;
 $ regview  applicat.rdb /UCR/com/sun/star/uno/XInterface&lt;br /&gt;
shows the type information of com.sun.star.uno.XInterface&lt;br /&gt;
&lt;br /&gt;
Additional info about generating code: The cppumaker needs all type information because the cppumaker generates the specified type and all the dependencies. The depent types will be generated recursively, so that you get all the necessary C++ type declarations you need to build your component.&lt;br /&gt;
&lt;br /&gt;
After the regmerge the applicat.rdb contains all types, the ones that comes with Openoffice.org and your new one. Note the regmerge command only modifies the first file, the others are opened read only.&lt;br /&gt;
&lt;br /&gt;
You should now check with regview, that the regmerge really worked and that it now contains your new type. For example:&lt;br /&gt;
 $ regview applicat.rdb /UCR/com/sun/star/uno/RuntimeException&lt;br /&gt;
should give output about the normal RuntimeException.&lt;br /&gt;
 $ regview applicat.rdb /UCR/your/new/types&lt;br /&gt;
should give output about your new type (of course replace your/new/types with the module and typename of the new type in idl).&lt;br /&gt;
&lt;br /&gt;
Then the following command should generate C++ headers below your current working directory:&lt;br /&gt;
 $ cppumaker -O. -Tyour/new/types -BUCR applicat.rdb&lt;br /&gt;
If this doesn&amp;#039;t work, at least the following command should work:&lt;br /&gt;
 $ cppumaker -O. -Tcom/sun/star/uno/RuntimeException -BUCR applicat.rdb&lt;br /&gt;
&lt;br /&gt;
===What does symbol &amp;quot;component_getImplementationEnvironment&amp;quot; could not be found mean?===&lt;br /&gt;
If you try to register your DLL with regcomp like this:&lt;br /&gt;
 $ regcomp -register -r applicat.rdb -c foo.dll&lt;br /&gt;
and get the following error:&lt;br /&gt;
 register component &amp;quot;foo.dll&amp;quot; in registry &amp;quot;applicat.rdb&amp;quot; failed!&lt;br /&gt;
 ERROR: component could not be registered: symbol &amp;quot;component_getImplementationEnvironment&amp;quot; &lt;br /&gt;
 could not be found in &amp;quot;foo.dll&amp;quot;&lt;br /&gt;
Make sure that you defined the function outside any classes in a .cxx file like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
extern &amp;quot;C&amp;quot; &lt;br /&gt;
void SAL_CALL component_getImplementationEnvironment( &lt;br /&gt;
                 const sal_Char ** ppEnvTypeName, &lt;br /&gt;
                 uno_Environment ** ppEnv ) &lt;br /&gt;
{ &lt;br /&gt;
        *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you are not using a module definition file (DEF file), then you can use a SAL_DLLEXPORT macro in front of your function definition, which expands to __declspec(dllexport). On Win32 platforms check your exports using&lt;br /&gt;
 $ dumpbin /EXPORTS foo.dll&lt;br /&gt;
If this still doesn&amp;#039;t work while registering your DLL, make sure that your path is correct and that all libraries foo.dll is linked against are accessible via your path. On Win32 platforms you can use a tool which is delivered with Developer Studio 6. It&amp;#039;s called depend and shows library imports and missing libraries (marked red). If this still doesn&amp;#039;t help you should debug the function writeRegistryInfo() of the shared library component loader. The loader is located in the CVS module stoc which checks out the directory oo/udk/stoc. Inside the stoc directory the loader is built in the directory source/loader. The built library is called cpld.dll.&lt;br /&gt;
&lt;br /&gt;
===What if regcomp does not find your C++ service===&lt;br /&gt;
If you are testing C++ library registration of your Calc.XlsxExport&lt;br /&gt;
service with regcomp like this:&lt;br /&gt;
&amp;lt;source lang=cpp&amp;gt;&lt;br /&gt;
SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo (void*, void* key)&lt;br /&gt;
{&lt;br /&gt;
    OSL_TRACE (&amp;quot;%s: Xlsx HELLO&amp;quot;, __PRETTY_FUNCTION__);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
but&lt;br /&gt;
 $ regcomp -register -r foo.rdb -c unxlngx6.pro/lib/libscfilt.so&lt;br /&gt;
 register component &amp;#039;unxlngx6.pro/lib/libscfiltlx.so&amp;#039; in registry &amp;#039;foe.rdb&amp;#039; succesful!&lt;br /&gt;
fails to print HELLO and&lt;br /&gt;
 $ regview foo.rdb | grep Xlsx&lt;br /&gt;
fails to print something like&lt;br /&gt;
   / com.sun.star.comp.Calc.XlsxExport&lt;br /&gt;
            Data = 0 = &amp;quot;com.sun.star.comp.Calc.XlsxExport&amp;quot;&lt;br /&gt;
you can assume safely assume that component_writeInfo is not found.&lt;br /&gt;
&lt;br /&gt;
Make sure to add these functions to the util/NAME.map file, eg&lt;br /&gt;
when adding the first UNO service to calc&amp;#039;s scfilt library, do &lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
--- sc/util/scfilt.map&lt;br /&gt;
+++ sc/util/scfilt.map&lt;br /&gt;
@@ -1,6 +1,9 @@&lt;br /&gt;
 SCFILT_1_0 {&lt;br /&gt;
   global:&lt;br /&gt;
     ScFilterCreate;&lt;br /&gt;
+    component_getImplementationEnvironment;&lt;br /&gt;
+    component_writeInfo;&lt;br /&gt;
+    component_getFactory;&lt;br /&gt;
   local:&lt;br /&gt;
     *;&lt;br /&gt;
 };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and that you tell scp2 the library is a UNO library, in the case of scfilt, do&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
--- scp2/source/calc/file_calc.scp&lt;br /&gt;
+++ scp2/source/calc/file_calc.scp&lt;br /&gt;
@@ -49,7 +49,7 @@ STD_UNO_LIB_FILE_PATCH( gid_File_Lib_Sc, sc)&lt;br /&gt;
 &lt;br /&gt;
 STD_LIB_FILE_PATCH( gid_File_Lib_Scui, scui)&lt;br /&gt;
 &lt;br /&gt;
-STD_LIB_FILE( gid_File_Lib_Scfilt, scfilt)&lt;br /&gt;
+STD_UNO_LIB_FILE( gid_File_Lib_Scfilt, scfilt)&lt;br /&gt;
 &lt;br /&gt;
 STD_UNO_LIB_FILE( gid_File_Lib_Scd, scd)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===How do I unmerge what I added to type library with regmerge?===&lt;br /&gt;
regmerge overwrites existing keys. However, a tool to delete existing keys would be nice to have, but there currently is none.&lt;br /&gt;
&lt;br /&gt;
===Where do I find service descriptions in the type library?===&lt;br /&gt;
Service descriptions are not stored in the type library because reflective information about services aren&amp;#039;t needed at runtime. A service description exists only for modeling purposes.&lt;br /&gt;
&lt;br /&gt;
You can start the IDL compiler with a special option ( -C ) to generate a type library including service descriptions and comments, it is not used in a normal office build, as it approximately doubles the file size.&lt;br /&gt;
&lt;br /&gt;
===How do I create a unique uik number?===&lt;br /&gt;
Some people do it by just copying an existing one and modifying it a little. This is, of course, disapproved of, but it works for now. We currently don&amp;#039;t have our own tool, but you can use the guidgen.exe that comes with the Microsoft compiler.&lt;br /&gt;
&lt;br /&gt;
However, the guides are currently not used. They are there for historical reasons (the former UNO component model needed it) and we left it in for a future bridge, maybe UNO-COM, which would require unique identifiers.&lt;br /&gt;
How can I configure the office to be started in listening mode ?&lt;br /&gt;
There are two ways.&lt;br /&gt;
#. Start the office with an additional parameter :&amp;lt;pre&amp;gt;soffice -accept=socket,host=0,port=2002;urp;StarOffice.ServiceManager&amp;lt;/pre&amp;gt;(Please ensure to quote the ; on a Unix shell).&lt;br /&gt;
#. Place the same string without &amp;#039;-accept=&amp;#039; into a configuration file. You can edit the file &amp;lt;pre&amp;gt;&amp;lt;office-install&amp;gt;/share/config/registry/instance/org/openoffice/Setup.xml&amp;lt;/pre&amp;gt;and replace the tag&amp;lt;pre&amp;gt;&amp;lt;ooSetupConnectionURL cfg:type=&amp;quot;string&amp;quot;/&amp;gt;&amp;lt;/pre&amp;gt;with &amp;lt;pre&amp;gt;&amp;lt;ooSetupConnectionURL cfg:type=&amp;quot;string&amp;quot;&amp;gt;socket,host=0,port=2002;urp;StarOffice.ServiceManager&amp;lt;/ooSetupConnectionURL&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this change has effect on the whole network installation, which can easily become a very serious security problem. Please also note, that using the host=0 phrase will make the office listen on every network interface, in case you only want to script your office from the same machine, it is definitely better, more secure, to replace the 0 with localhost.&lt;br /&gt;
&lt;br /&gt;
If you want to configure remote connect only for a certain user (in a network installation), you need to do the modification into the user dependent configuration directory in Setup.xml, above. &lt;br /&gt;
&lt;br /&gt;
===How do I start the TestOffice.java?===&lt;br /&gt;
As parameters, please use, for example: uno:socket,host=localhost,port=2002;urp;StarOffice.NamingService&lt;br /&gt;
&lt;br /&gt;
===How do I remotely connect to an OpenOffice.org running on a different machine?===&lt;br /&gt;
When connecting to an OpenOffice.org you supply an Uno URL, which allows to locate a named Uno object in a different process. A Uno URL consists of four parts:&lt;br /&gt;
* The constant string &amp;quot;uno&amp;quot;.&lt;br /&gt;
* A connection specification with optional parameters as key/value pairs.&lt;br /&gt;
* A protocol specification with optional parameters as key/value pairs.&lt;br /&gt;
* The name of the object to be located.&lt;br /&gt;
&lt;br /&gt;
Those four parts are concatenated to a string&lt;br /&gt;
 uno:[connection],params;[protocol],params;[objectname]&lt;br /&gt;
&lt;br /&gt;
An example Uno URL looks like:&lt;br /&gt;
 uno:socket,host=localhost,port=2002;urp;StarOffice.ServiceManager&lt;br /&gt;
&lt;br /&gt;
For more information about Uno URLs please consult http://udk.openoffice.org/common/man/spec/uno-url.html&lt;br /&gt;
&lt;br /&gt;
A string similar to the uno-url is used to configure the accepting process, for instance the office. . You can start the office with&lt;br /&gt;
 soffice &amp;quot;-accept=socket,host=0,port=2002;urp;&amp;quot;&lt;br /&gt;
Note that this string is not specified as strong as the uno-url and other programs may define there own format (e.g. the uno tool coming with the ODK expects a different format). One speciality of the socket connection part is, that you can use &amp;quot;host=0&amp;quot;, which means accept on every network interface available on the current machine including localhost. The &amp;quot;host=0&amp;quot; part cannot be used for connecting to a resource.&lt;br /&gt;
&lt;br /&gt;
Additionally, you don&amp;#039;t need to specify the object name, as the office either way exports multiple objects (StarOffice.NamingService, StarOffice.ServiceManager and [new] StarOffice.ComponentContext).&lt;br /&gt;
&lt;br /&gt;
===What&amp;#039;s the purpose of the UnoUrlResolver?===&lt;br /&gt;
The UnoUrlResolver gets a remote object for a service name specified in an uno-url, especially a StarOffice.ServiceManager. Then, you use the the service managers XNamingService interface in order to retrieve the service manager &amp;#039;registeredObject&amp;#039; via getRegisteredObject in order to be able to queryInterface() for a XMultiServiceFactory. Remember, that the remote OpenOffice.org process has fulfilled its startup phase before the naming service reference is returned. This is necessary to guarantee the availability of all services. As you can see, the naming service is only a container for the service manager. This is done for flexibility reasons, because future versions may export more objects than only the service manager. Understand the uno-url as an entry point into another process; after that, everything else should be handled via normal UNO calls. Perhaps future versions also will remove the naming service&amp;#039;s ability to remove and add objects, which obviously doesn&amp;#039;t make any sense for remote processes.&lt;br /&gt;
How can I be event notified when a remote bridge is being disposed?&lt;br /&gt;
&lt;br /&gt;
A XComponent notifies its event listeners when it is being disposed. Unfortunately a reference to a UnoUrlResolver object is not sufficient to receive a dispose event notification. You&amp;#039;ll need at least a connector and a bridge factory service (see com.sun.star.comp.urlresolver.UnoUrlResolver in the jurt directory for more details) which you can query for a XComponent interface. This queried reference can be used to add a dispose event listener like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
String connection = &amp;quot;socket,host=localhost,port=2002&amp;quot;;&lt;br /&gt;
String protocol = &amp;quot;urp&amp;quot;;&lt;br /&gt;
Object connector = _xMultiServiceFactory.createInstance(&amp;quot;com.sun.star.connection.Connector&amp;quot;);&lt;br /&gt;
XConnector connector_xConnector = (XConnector)UnoRuntime.queryInterface(XConnector.class, connector);&lt;br /&gt;
XConnection xConnection = connector_xConnector.connect(connection);&lt;br /&gt;
xBridge = xBridgeFactory.createBridge(connection + &amp;quot;;&amp;quot; + protocol, protocol, xConnection, null);&lt;br /&gt;
XComponent component = (XComponent)UnoRuntime.queryInterface(XComponent.class, component);&lt;br /&gt;
component.addEventListener(...);     &lt;br /&gt;
&amp;lt;/pre&amp;gt;   &lt;br /&gt;
&lt;br /&gt;
==Documentation==&lt;br /&gt;
===How can I check out the UDK WWW documentation?===&lt;br /&gt;
The documentation for the UDK project, which can be viewed via http://udk.openoffice.org, can be checked out using the following CVS command&lt;br /&gt;
 $ cvs -d :pserver:anoncvs@anoncvs.services.openoffice.org:/cvs -z3 co udk/www &lt;br /&gt;
&lt;br /&gt;
If you don&amp;#039;t want the generated C++ module reference documents you might want to save these commands into a script or batch file and run it from the command shell:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cvs -d :pserver:anoncvs@anoncvs.services.openoffice.org:/cvs -z3 co udk/www/common&lt;br /&gt;
cvs -d :pserver:anoncvs@anoncvs.services.openoffice.org:/cvs -z3 co udk/www/cpp/man&lt;br /&gt;
cvs -d :pserver:anoncvs@anoncvs.services.openoffice.org:/cvs -z3 co udk/www/java&lt;br /&gt;
cvs -d :pserver:anoncvs@anoncvs.services.openoffice.org:/cvs -z3 co udk/www/images &lt;br /&gt;
cvs -d :pserver:anoncvs@anoncvs.services.openoffice.org:/cvs -z3 co udk/www/documentation_structure.html&lt;br /&gt;
cvs -d :pserver:anoncvs@anoncvs.services.openoffice.org:/cvs -z3 co udk/www/faq.html&lt;br /&gt;
cvs -d :pserver:anoncvs@anoncvs.services.openoffice.org:/cvs -z3 co udk/www/index.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Where can I find more information about the UNO security model?===&lt;br /&gt;
Please look at http://udk.openoffice.org/common/man/concept/uno_security.html. The main goal of this draft is to provide a generic API to wrap existing security implementations, this draft is based on Java security and semantics and may change. There are details being discussed, marked in red, for example remote transparency.&lt;br /&gt;
&lt;br /&gt;
===Where can I find more information about the UNO CORBA bridge?===&lt;br /&gt;
Bridging UNO and CORBA is no trivial task, as both component models are based on different fundamental concepts. Therefore, we want to write down the ideas about how to deal with these fundamental differences, before beginning implementation. Please look at http://udk.openoffice.org/common/man/concept/uno_corba.html for more information.&lt;br /&gt;
&lt;br /&gt;
This document currently contains only part that we will have to deal with during development of the bridge. The document is supposed to grow rapidly during the next weeks. Any input on UNO CORBA bridge from the community is very welcome, discussions take place on dev@udk.openoffice.org.&lt;br /&gt;
&lt;br /&gt;
The main goal is to get a CORBA-bridge that supports all features necessary to communicate with the GNOME desktop (http://www.gnome.org). The component model used in GNOME is Bonobo, which is built on top of [http://www.gnome.org/projects/ORBit2/ ORBIT], an open source CORBA ORB (Object Request Broker). A CORBA-UNO bridge would allow to script OpenOffice.org with a GNOME scripting language, for example.&lt;br /&gt;
&lt;br /&gt;
The secondary goal is to develop a &amp;#039;generic&amp;#039; CORBA-UNO-bridge, that allows communication with an arbitrary ORB. This would allow OpenOffice.org to seamlessly integrate into any CORBA environment.&lt;br /&gt;
&lt;br /&gt;
===Where can I find more information about the SOAP-UNO integration?===&lt;br /&gt;
Please have a look at http://udk.openoffice.org/common/man/draft/soap.html.&lt;br /&gt;
&lt;br /&gt;
===Where can I find more information about the OpenOffice.org Bonobo integration?===&lt;br /&gt;
A brief overview about the project OpenOffice.org - Bonobo Integration can be found at http://whiteboard.openoffice.org/bonobo/. Something about motivation and goals of this project is written there. We have checked in some code into CVS, enabling OpenOffice.org to be a Bonobo server for containers like Nautilus. Everyone is welcome to contribute ideas or code, on how to bring OpenOffice.org and GNOME closer together on the level of component technology.&lt;br /&gt;
&lt;br /&gt;
[[Category:Uno]] [[Category:FAQ]]&lt;/div&gt;</summary>
		<author><name>Jcn</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Constructing_Components&amp;diff=120021</id>
		<title>Constructing Components</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Constructing_Components&amp;diff=120021"/>
		<updated>2009-04-16T09:47:23Z</updated>

		<summary type="html">&lt;p&gt;Jcn: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/Candidate}}&lt;br /&gt;
Our purpose is to extend OpenOffice.org in any way. All the possibilities of extensions come not in spirit at the first time you ask yourself how is it possible ? But at first, if I say you : realize first a (shared/not shared) library and second says OpenOffice.org you have to use this library, are you shocked ? Not at all I suppose. Then we have to produce a shared library with suffix uno.so under Linux or uno.dll under Windows. To indicate OpenOffice.org to use this new library and where to find it, we use a rdb file and an operation called registry. Registry has been already tackled in [[UNO_registery_and_Bootstrapping|UNO registery and Bootstrapping]], but we have to go further in this chapter.&lt;br /&gt;
=Danny Brewer&amp;#039;s Terminology=&lt;br /&gt;
&lt;br /&gt;
You can read first in this wiki [[Extensions|the extensions terminology]].&lt;br /&gt;
We can also read [http://www.oooforum.org/forum/viewtopic.php?t=13335&amp;amp;postdays=0&amp;amp;postorder=asc&amp;amp;start=0 here] :&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s clarify (and perhaps even invent) some terminology. &lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Add On&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
A menu item on the Tools menu, and an icon on the toolbar. &lt;br /&gt;
By modifying the Configuration sub node for AddOn, you can add new menu items and toolbar icon items to the AddOn menu or toolbar icon. &lt;br /&gt;
Basic programs can modify the Configuration to add some Add On items to the menu. It is not necessary to use pkgchk. &lt;br /&gt;
Components (see below) can also add things to the AddOn menu or toolbar when the component is installed using pkgchk. &lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Add In&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
A component (see below) which provides new Calc spreadsheet functions. &lt;br /&gt;
These functions show up on the Function List and Insert --&amp;gt; Function... dialog box. The dialog box can then fully describe your functions, their parameters, provide tooltips, etc. &lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;[[Uno/Cpp/Tutorials/Introduction_to_Cpp_Uno#C.2B.2B_components|Component]]&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
An UNO [[Uno/Cpp/Tutorials/Introduction_to_Cpp_Uno#C.2B.2B_components|Component]], written in any supported programming language, which must be installed using the pkgchk command. (This would be &amp;quot;pkgchk.exe&amp;quot; for Windows users.) &lt;br /&gt;
A component provides one or more new Services which are registered in the OOo registry. These services can be instantiated just like the factory installed services in OOo. For instance, in Basic, you can just call createUnoService( &amp;quot;name.DannyBrewer.magic.SomeService&amp;quot; ) to get an instance of the service, and then immediately call its methods or properties. Similarly, Python or Java, or Visual Basic, or any other language can use the newly installed service. &lt;br /&gt;
&lt;br /&gt;
A component provides one or more services. See for instance [[IDL_Files_and_Cpp#Using_Java_Inspector|Using Java Inspector]] component.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Service&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
An UNO abstraction for an Object. A service may not actually represent a single underlying object. A service may have many different interfaces which it implements. A service has properties. What methods are callable on the service are determined purely by what interfaces the service implements. &lt;br /&gt;
&lt;br /&gt;
Since a Calc Add-In is just a component, which implements certain particular interfaces and services, the Calc AddIn is installed and registered in the same way as any other component. That is, a Calc AddIn is installed or removed by using pkgchk. &lt;br /&gt;
Making a Calc Add-In is just like making any other service. You must be a particular com.sun.star.sheet.AddIn service, and must properly implement all of its interfaces, of which there are several. But once you do this, your service magically provides new functions to the spreadsheet. Calc Add-In are tackled the next [[CompleteAddIn|chapter]]. You can find an introduction on addIn also [[SimpleCalcAddIn|here]].&lt;br /&gt;
&lt;br /&gt;
= Compilation Chain of a Component=&lt;br /&gt;
To create a UNO component, you require an IDL file and a cpp file. The entire process is illustrated in the figure below. The final goal is to create a uno.so and a rdb file.&lt;br /&gt;
&lt;br /&gt;
[[Image:ComponentTools.png]]&lt;br /&gt;
&lt;br /&gt;
The black arrows in the figure above indicate how to create one file type from another. For example, use idlc to create some.urd starting from some.idl. The red arrow indicates that regcomp is used to place the name of the library done into the rdb file rather than create the rdb file. Finally, the blue arrows indicate a dependency.&lt;br /&gt;
The entire process is as follows :&lt;br /&gt;
# Create the idl and cpp files. Figure above shows these files as some.idl and some.cpp.&lt;br /&gt;
# Use idlc to compile the idl file to a urd file.&lt;br /&gt;
# Transform the urd file to the rdb file using regmerge. The rdb file is not yet complete because it must contain the name of the uno.so file, which is added at the end using regcomp.&lt;br /&gt;
# Use cppumaker to create the hpp and hdl header files.&lt;br /&gt;
# Use gcc to compile the cpp file.&lt;br /&gt;
# The final registry step has been discussed previously and is not shown in Figure above.&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|&amp;#039;&amp;#039;&amp;#039;Service Managers&amp;#039;&amp;#039;&amp;#039; UNO uses a factory concept to instantiate components in a target environment. This factory is called the service manager. The service manager maintains a database of registered components. Your application can instantiate and communicate with any component known by the service manager, no matter what language it was implemented in. Communication takes place through interface calls specified by the UNO IDL. See &amp;#039;&amp;#039;&amp;#039; Creating a ServiceManager from a Given Registry File&amp;#039;&amp;#039;&amp;#039; in [[Documentation/DevGuide/WritingUNO/Special_Service_Manager_Configurations|Developer&amp;#039;s Guide]].}}&lt;br /&gt;
&lt;br /&gt;
To create a component, you must first create an idl file. The IDL file describes the interface. The goal of the following examples, is to create a component, visible to OpenOffice.org more specifically, visible from OOoBasic. The SDK contains an example in: “&amp;lt;OpenOffice.org1.1_SDK&amp;gt;/examples/DevelopersGuide/Components/CppComponent”. &lt;br /&gt;
The view described above is only important when you wonder how a component is constructed. If you want to know what you have to do when writing a component an other view is needed ; it is described in chapter 1.3.2 with the corresponding three rules.&lt;br /&gt;
&lt;br /&gt;
=First Example : accessing a Counter from OOoBasic=&lt;br /&gt;
&lt;br /&gt;
Our first goal is to transform  a counter into a component. A counter is perhaps not great but a good start. The inspiration comes to me with the following two SDK&amp;#039;s examples :&lt;br /&gt;
&amp;lt;OpenOffice.org1.1_SDK&amp;gt;/examples/DevelopersGuide/Components/CppComponent (used in previous chapter)&lt;br /&gt;
&amp;lt;OpenOffice.org1.1_SDK&amp;gt;/examples/cpp/counter&lt;br /&gt;
The problem with the counter example given above with the SDK is its inaccessibility from OOoBasic. We begin describing it.&lt;br /&gt;
&lt;br /&gt;
== A very simple Counter==&lt;br /&gt;
We give in this section our start : a counter.cxx file and a countermain.cxx file working all together. Please note that this example would be simpler if not constructed for OpenOffice.org It&amp;#039;s only given here to present  our start. From this start we will wonder a lot of questions showing I hope how components work. I will use sometimes UML notations in this chapter.&lt;br /&gt;
So we start with this code :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 1 The Counter&lt;br /&gt;
//c++&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;quot;counter.hxx&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	MyCounterImpl::MyCounterImpl()&lt;br /&gt;
		: m_nCount( 0 )&lt;br /&gt;
		{ printf( &amp;quot;&amp;lt; MyCounterImpl ctor called &amp;gt;\n&amp;quot; ); }&lt;br /&gt;
	MyCounterImpl::~MyCounterImpl()&lt;br /&gt;
		{ printf( &amp;quot;&amp;lt; MyCounterImpl dtor called &amp;gt;\n&amp;quot; ); }&lt;br /&gt;
	int MyCounterImpl::getCount() &lt;br /&gt;
		{ return m_nCount; }&lt;br /&gt;
	void MyCounterImpl::setCount( int nCount ) &lt;br /&gt;
		{ m_nCount = nCount; }&lt;br /&gt;
	int MyCounterImpl::increment() &lt;br /&gt;
		{ return (++m_nCount); }&lt;br /&gt;
	int MyCounterImpl::decrement() &lt;br /&gt;
		{ return (--m_nCount); }&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char **argv)&lt;br /&gt;
{&lt;br /&gt;
	MyCounterImpl Cnt;&lt;br /&gt;
	Cnt.setCount(50);&lt;br /&gt;
	printf(&amp;quot;-- %d\n&amp;quot;,Cnt.getCount());&lt;br /&gt;
	Cnt.increment();&lt;br /&gt;
	printf(&amp;quot;-- %d\n&amp;quot;,Cnt.getCount());&lt;br /&gt;
	Cnt.decrement();&lt;br /&gt;
	printf(&amp;quot;-- %d\n&amp;quot;,Cnt.getCount());&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with the header file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 2 The header File of the Counter&lt;br /&gt;
// C++&lt;br /&gt;
// counter.hxx&lt;br /&gt;
class MyCounterImpl {&lt;br /&gt;
	int m_nCount;&lt;br /&gt;
public:&lt;br /&gt;
	MyCounterImpl();&lt;br /&gt;
	~MyCounterImpl();&lt;br /&gt;
	int getCount();&lt;br /&gt;
	void setCount( int nCount ); &lt;br /&gt;
	int increment(); &lt;br /&gt;
	int decrement() ;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What we want is to separate the code in two files : one for the class : counter.cxx and a second for the utilisation of the class countermain.cxx. The counter.cxx will be compiled in counter.so file and countermain will use this dynamic library.&lt;br /&gt;
The corresponding way in C++ is again illustrated. First the dynamic library :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 3 Dynamic library&lt;br /&gt;
//c++&lt;br /&gt;
//counter.cxx&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;quot;counter.hxx&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MyCounterImpl::MyCounterImpl()&lt;br /&gt;
	: m_nCount( 0 )&lt;br /&gt;
	{ printf( &amp;quot;&amp;lt; MyCounterImpl ctor called &amp;gt;\n&amp;quot; ); }&lt;br /&gt;
MyCounterImpl::~MyCounterImpl()&lt;br /&gt;
	{ printf( &amp;quot;&amp;lt; MyCounterImpl dtor called &amp;gt;\n&amp;quot; ); }&lt;br /&gt;
int MyCounterImpl::getCount() &lt;br /&gt;
	{ return m_nCount; }&lt;br /&gt;
void MyCounterImpl::setCount( int nCount ) &lt;br /&gt;
	{ m_nCount = nCount; }&lt;br /&gt;
int MyCounterImpl::increment() &lt;br /&gt;
	{ return (++m_nCount); }&lt;br /&gt;
int MyCounterImpl::decrement() &lt;br /&gt;
	{ return (--m_nCount); }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file is compiled with :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 gcc -shared -fPIC -o counter.uno.so counter.cxx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To use it I write this code :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 4 Main executable&lt;br /&gt;
//c++&lt;br /&gt;
//countermain.cxx&lt;br /&gt;
#include &amp;quot;counter.hxx&amp;quot;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
int main(int argc, char **argv)&lt;br /&gt;
{&lt;br /&gt;
	MyCounterImpl Cnt;&lt;br /&gt;
	Cnt.setCount(50);&lt;br /&gt;
	printf(&amp;quot;-- %d\n&amp;quot;,Cnt.getCount());&lt;br /&gt;
	Cnt.increment();&lt;br /&gt;
	printf(&amp;quot;-- %d\n&amp;quot;,Cnt.getCount());&lt;br /&gt;
	Cnt.decrement();&lt;br /&gt;
	printf(&amp;quot;-- %d\n&amp;quot;,Cnt.getCount());&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The compilation is then done with&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 gcc -o test1 countermain.cxx -L ./ counter.uno.so -lstdc++&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running this example gives :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[smoutou@p3 component]$ ./test1&lt;br /&gt;
&amp;lt; MyCounterImpl ctor called &amp;gt;&lt;br /&gt;
-- 50&lt;br /&gt;
-- 51&lt;br /&gt;
-- 50&lt;br /&gt;
&amp;lt; MyCounterImpl dtor called &amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example is done without Openoffice.org. In the contrary the example given in the SDK make exacly the same but needs OpenOffice.org. Problems with shared library and C++ are examined [[Uno/Cpp/Tutorials/Global_References|here]].&lt;br /&gt;
&lt;br /&gt;
==Making the Counter registerable==&lt;br /&gt;
All dynamic libraries are not registrable. Taking the one constructed in previous section and give it to register, what&amp;#039;s happening ?&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[smoutou@p3 bin]$ regcomp -register -r counter.uno.rdb -c counter.uno.so&lt;br /&gt;
Aborted&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Regcomp is completely unable to do correctly its job. Why ? &lt;br /&gt;
If you want to be able to registry something you have to follow strict rules.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Rule 1&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
You have to construct first an IDL file. This IDL file allow you to construct an urd file and add it in a rdb file. This has already been discussed above.&lt;br /&gt;
See the figure below.&lt;br /&gt;
&lt;br /&gt;
[[Image:Registery.png]]&lt;br /&gt;
&lt;br /&gt;
When examining this figure you see that a some.idl file is required (and naturally a uno.so file).&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Rule 2&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Your dynamic library have to contain extern C subprograms. Their names are :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// C++&lt;br /&gt;
extern &amp;quot;C&amp;quot; void SAL_CALL component_getImplementationEnvironment(&lt;br /&gt;
    sal_Char const ** ppEnvTypeName, uno_Environment ** ppEnv );&lt;br /&gt;
&lt;br /&gt;
extern &amp;quot;C&amp;quot; sal_Bool SAL_CALL component_writeInfo(&lt;br /&gt;
    lang::XMultiServiceFactory * xMgr, registry::XRegistryKey * xRegistry );&lt;br /&gt;
&lt;br /&gt;
extern &amp;quot;C&amp;quot; void * SAL_CALL component_getFactory(&lt;br /&gt;
    sal_Char const * implName, lang::XMultiServiceFactory * xMgr, void * );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
First and second subroutines are for registry and third is for allowing UNO_QUERY calls. More information [[Uno/Cpp/Tutorials/Introduction_to_Cpp_Uno#Exported_symbols|here]] where a fourth optional extern C subprogram is presented : getDescription.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Rule 3 (provisional rule)&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Your component has to provide some other interfaces that those described in your IDL file : XInterface, XServiceInfo. The counter example provide these interfaces as shown in the listing below :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 5 The counter interfaces&lt;br /&gt;
// C++&lt;br /&gt;
class MyCounterImpl&lt;br /&gt;
	: public XCountable&lt;br /&gt;
	, public XServiceInfo&lt;br /&gt;
{&lt;br /&gt;
....&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
I suppose XCountable is an inheritance from XInterface.  &lt;br /&gt;
The figure above shows us a component in a schematic view.&lt;br /&gt;
&lt;br /&gt;
[[Image:ComponentInterface.png]]&lt;br /&gt;
&lt;br /&gt;
The external rectangle in Figure above represents the component. In this component, we see a XCountable interface inheriting from XInterface and XServiceInfo and the three extern C callable functions.&lt;br /&gt;
&lt;br /&gt;
== The Counter Example (from SDK) ==&lt;br /&gt;
&lt;br /&gt;
The Counter is provided with SDK here : &amp;lt;OpenOffice.org_SDK&amp;gt;/examples/cpp/counter. See a description of the [[Counter_Example|SDK counter example]].&lt;br /&gt;
&lt;br /&gt;
=== Modifying the simple Counter to see registry at Work===&lt;br /&gt;
Again, we start with the counter example included in the SDK at &amp;lt;OpenOffice.org1.1_SDK&amp;gt;/examples/cpp/counter.&lt;br /&gt;
We modify it to see in the console how registry works and particularly the necessity of the rule 2 described in [[Constructing_Components#Making_the_Counter_registerable|a previous section]]. The modification only consists of adding printf as shown in the listing below. The goal is to help us to see how it works.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 7 Modified Counter Component (extract)&lt;br /&gt;
// C++&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;
	printf(&amp;quot;MyCounterImpl::getImplementationName(  ) called \n&amp;quot;);&lt;br /&gt;
	return OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) );&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;
	printf(&amp;quot;MyCounterImpl::supportsService called\n&amp;quot;);&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;
	printf(&amp;quot;MyCounterImpl::getSupportedServiceNames(  ) called \n&amp;quot;);&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;
	printf(&amp;quot;MyCounterImpl::getSupportedServiceNames_Static(  ) called with &lt;br /&gt;
                                         %s\n&amp;quot;,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;
{	printf(&amp;quot;MyCounterImpl_create called\n&amp;quot;);&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, &lt;br /&gt;
                                                                  uno_Environment ** ppEnv) {&lt;br /&gt;
	printf(&amp;quot;getImplementationEnvironnement return %s\n&amp;quot;,CPPU_CURRENT_LANGUAGE_BINDING_NAME);&lt;br /&gt;
	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;&lt;br /&gt;
}&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;
	printf(&amp;quot;component_writeInfo called\n&amp;quot;);&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;
		printf(&amp;quot;New key : %s\n&amp;quot;,RTL_CONSTASCII_USTRINGPARAM(&amp;quot;/&amp;quot; IMPLNAME &amp;quot;/UNO/SERVICES&amp;quot;));&lt;br /&gt;
		printf(&amp;quot;--component_writeInfo calls MyCounterImpl::getSupportedServiceNames_Static()\n&amp;quot;);&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;
			printf(&amp;quot;----Sub-Key : %s build\n&amp;quot;,OUStringToOString(pArray[nPos],&lt;br /&gt;
									RTL_TEXTENCODING_ASCII_US)&lt;br /&gt;
			.pData-&amp;gt;buffer);&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;
/**&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;
/**/&lt;br /&gt;
extern &amp;quot;C&amp;quot; void * SAL_CALL component_getFactory(const sal_Char * pImplName, &lt;br /&gt;
                                              void * pServiceManager, void * pRegistryKey){&lt;br /&gt;
	void * pRet = 0;&lt;br /&gt;
	printf(&amp;quot;component_getFactory called\n&amp;quot;);&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;
	return pRet;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When working in the OpenOffice build framework, make sure to add these functions to the util/NAME.map file, eg&lt;br /&gt;
when adding the first UNO service to calc&amp;#039;s scfilt library, do &lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
--- sc/util/scfilt.map&lt;br /&gt;
+++ sc/util/scfilt.map&lt;br /&gt;
@@ -1,6 +1,9 @@&lt;br /&gt;
 SCFILT_1_0 {&lt;br /&gt;
   global:&lt;br /&gt;
     ScFilterCreate;&lt;br /&gt;
+    component_getImplementationEnvironment;&lt;br /&gt;
+    component_writeInfo;&lt;br /&gt;
+    component_getFactory;&lt;br /&gt;
   local:&lt;br /&gt;
     *;&lt;br /&gt;
 };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and that you tell scp2 the library is a UNO library, in the case of scfilt, do&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
--- scp2/source/calc/file_calc.scp&lt;br /&gt;
+++ scp2/source/calc/file_calc.scp&lt;br /&gt;
@@ -49,7 +49,7 @@ STD_UNO_LIB_FILE_PATCH( gid_File_Lib_Sc, sc)&lt;br /&gt;
 &lt;br /&gt;
 STD_LIB_FILE_PATCH( gid_File_Lib_Scui, scui)&lt;br /&gt;
 &lt;br /&gt;
-STD_LIB_FILE( gid_File_Lib_Scfilt, scfilt)&lt;br /&gt;
+STD_UNO_LIB_FILE( gid_File_Lib_Scfilt, scfilt)&lt;br /&gt;
 &lt;br /&gt;
 STD_UNO_LIB_FILE( gid_File_Lib_Scd, scd)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With countermain slightly modified to know where the registry begins, this piece of code produces the following output :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[smoutou@p3 counter]$ make countermain.run&lt;br /&gt;
cd ../../../LINUXexample.out/bin &amp;amp;&amp;amp; countermain&lt;br /&gt;
Here begin registry&lt;br /&gt;
getImplementationEnvironnement return gcc3&lt;br /&gt;
component_writeInfo called&lt;br /&gt;
New key : /com.sun.star.comp.example.cpp.Counter/UNO/SERVICES&lt;br /&gt;
--component_writeInfo calls MyCounterImpl::getSupportedServiceNames_Static()&lt;br /&gt;
MyCounterImpl::getSupportedServiceNames_Static(  ) called with foo.Counter&lt;br /&gt;
----Sub-Key : foo.Counter build&lt;br /&gt;
Here ends registry and begin instanciation&lt;br /&gt;
getImplementationEnvironnement return gcc3&lt;br /&gt;
component_getFactory called&lt;br /&gt;
MyCounterImpl::getSupportedServiceNames_Static(  ) called with foo.Counter&lt;br /&gt;
MyCounterImpl_create called&lt;br /&gt;
&amp;lt; MyCounterImpl2 ctor called &amp;gt;&lt;br /&gt;
42,43,42&lt;br /&gt;
Another registry use : getImplementations&lt;br /&gt;
-- com.sun.star.comp.bridge.UnoUrlResolver&lt;br /&gt;
&amp;lt; MyCounterImpl2 dtor called &amp;gt;&lt;br /&gt;
[smoutou@p3 counter]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
while a direct regcomp call produces this following output :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[smoutou@p3 bin]$ regcomp -register -r counter.uno.rdb -c counter.uno.so&lt;br /&gt;
getImplementationEnvironnement return gcc3&lt;br /&gt;
component_writeInfo called&lt;br /&gt;
New key : /com.sun.star.comp.example.cpp.Counter/UNO/SERVICES&lt;br /&gt;
--component_writeInfo calls MyCounterImpl::getSupportedServiceNames_Static()&lt;br /&gt;
MyCounterImpl::getSupportedServiceNames_Static(  ) called with foo.Counter&lt;br /&gt;
----Sub-Key : foo.Counter build&lt;br /&gt;
register component &amp;#039;counter.uno.so&amp;#039; in registry &amp;#039;counter.uno.rdb&amp;#039; succesful!&lt;br /&gt;
[smoutou@p3 bin]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We can draw from both shell ouputs that registry works the same way, in the both case as expected. The first call is asking for Environment which return “gcc3” here, and after componentwriteinfo which is responsible of registry itself.&lt;br /&gt;
A question : how do we see our counter with OOoBasic at this step ? Because our counter is registered we see it (partially) but we cannot use it. (Note you have to stop countermain with a getchar to have time launch a OOoBasic program.)&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
&amp;#039;Listing 8  Little OOoBasic Program to see our Counter.&lt;br /&gt;
&lt;br /&gt;
REM  *****  BASIC  *****&lt;br /&gt;
&lt;br /&gt;
Sub Main&lt;br /&gt;
	ocmpt = createUnoService(&amp;quot;foo.Counter&amp;quot;)&lt;br /&gt;
	XRay.XRay oCmpt&lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Results ===&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;XRay&amp;#039;&amp;#039;&amp;#039; is a OOoBasic tool very easy to use for introspection. Bernard Marcelly&amp;#039;s [[Extensions_development_basic#X-Ray_tool|XRay tool description]] can be found in this Wiki or you can download it &lt;br /&gt;
[http://www.ooomacros.org/dev.php#101416 here] &lt;br /&gt;
&lt;br /&gt;
XRaying this object as shown in the above listing, gives us :&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;properties&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- Object internal name : ( no name )&lt;br /&gt;
Dbg_Methods &lt;br /&gt;
        string &amp;lt;...&amp;gt; basic prop, read-only&lt;br /&gt;
Dbg_Properties            &lt;br /&gt;
        string &amp;lt;...&amp;gt; basic prop, read-only&lt;br /&gt;
Dbg_SupportedInterfaces&lt;br /&gt;
        string &amp;lt;...&amp;gt; basic prop, read-only&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;methods&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- Object internal name : ( no name )&lt;br /&gt;
queryInterface  ( aType as type )  AS variant&lt;br /&gt;
acquire         (  )&lt;br /&gt;
release         (  )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;supported interfaces&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- List of supported interfaces ---&lt;br /&gt;
com.sun.star.uno.XInterface&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As shown above, only the XInterface can bee seen : not great ! We can therefore instantiate it but not call one of its own method. The next step is to use the counter with OOoBasic : in other words, to make it scriptable.&lt;br /&gt;
&lt;br /&gt;
== Using an Helper to construct the scriptable Counter ==&lt;br /&gt;
&lt;br /&gt;
Starting from the [[Counter_Example| Counter example]] we hope to modify the [[Counter_Example#The_Counter_Class|counter class]] and make it scriptable.&lt;br /&gt;
&lt;br /&gt;
If you want to make your component scriptable you have to modify the previous rule 3 as this new one :&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Rule 3&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Your component has to provide some interfaces : XInterface, XServiceInfo, and XTypeProvider. The last one is then a characteristic of scriptable component.&lt;br /&gt;
&lt;br /&gt;
[[Image:ScripComponent.png]]&lt;br /&gt;
&lt;br /&gt;
The Figure above shows us a  &amp;#039;&amp;#039;&amp;#039;scriptable component&amp;#039;&amp;#039;&amp;#039; with a schematic view. As we will show later in fact we are using an helper and this means we haven&amp;#039;t to implement all Interfaces : only XServiceInfo is needed : both other are implemented automatically with the helper.&lt;br /&gt;
What about our makefile ? We are no more interested in calling this counter with countermain.cxx but using it in OOoBasic that means we have to register our dynamic library. Two solutions : we let again countermain to register itself and we stop it after registered and then try the OOoBasic program, or we look for an example which correctly registers. One is provided with the SDK as mentioned above :&amp;lt;OpenOffice.org1.1_SDK&amp;gt;/examples/DevelopersGuide/Components/CppComponent&lt;br /&gt;
and we can use the makefile of this component. &lt;br /&gt;
For a try I use the first solution but it doesn&amp;#039;t work : there is probably a problem with registery. If a second program manage registry it doesn&amp;#039;t work. There is perhaps an other problem. &lt;br /&gt;
It works when using the makefile of CppComponent renaming the IDL file and cxx file in MakeFile.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;To do : to go further with the registery problem !!!To have a look on that problem : when I use the CppComponent makefile, registry doesn&amp;#039;t print out all I was expecting !!!&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
To access the counter interface in Basic, you require the same IDL names as in [[Counter_Example#IDL_File|Listing 6]] ; we give now the complete C++ counter program.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 9 The complete Counter Program&lt;br /&gt;
// C++&lt;br /&gt;
// counter.cxx&lt;br /&gt;
/**** old&lt;br /&gt;
class MyCounterImpl&lt;br /&gt;
	: public XCountable&lt;br /&gt;
	, public XServiceInfo&lt;br /&gt;
*** old*/&lt;br /&gt;
&lt;br /&gt;
namespace my_sc_impl&lt;br /&gt;
{&lt;br /&gt;
static Sequence&amp;lt; OUString &amp;gt; getSupportedServiceNames_MyCounterImpl()&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(1);&lt;br /&gt;
			seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME));&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_MyCounterImpl()&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(IMPLNAME) );&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;
// New&lt;br /&gt;
class MyCounterImpl : public ::cppu::WeakImplHelper2&amp;lt;&lt;br /&gt;
      XCountable, XServiceInfo &amp;gt;&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;
    // 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;
	printf(&amp;quot;MyCounterImpl::getImplementationName(  ) called \n&amp;quot;);&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;
	printf(&amp;quot;MyCounterImpl::supportsService called\n&amp;quot;);&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;
	printf(&amp;quot;MyCounterImpl::getSupportedServiceNames(  ) called \n&amp;quot;);&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;
	printf(&amp;quot;MyCounterImpl::getSupportedServiceNames_Static(  ) called with %s\n&amp;quot;,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;
/******* OLD&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;
{	printf(&amp;quot;MyCounterImpl_create called\n&amp;quot;);&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;
******** OLD*/&lt;br /&gt;
//***********NEW&lt;br /&gt;
Reference&amp;lt; XInterface &amp;gt; SAL_CALL MyCounterImpl_create(&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; XTypeProvider * &amp;gt;( new MyCounterImpl() );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
//##################################################################################################&lt;br /&gt;
//#### EXPORTED ####################################################################################&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_MyService1Impl, getImplementationName_MyService1Impl,&lt;br /&gt;
    //    getSupportedServiceNames_MyService1Impl, ::cppu::createSingleComponentFactory,&lt;br /&gt;
    //    0, 0&lt;br /&gt;
    //},&lt;br /&gt;
    {&lt;br /&gt;
        MyCounterImpl_create, getImplementationName_MyCounterImpl,&lt;br /&gt;
        getSupportedServiceNames_MyCounterImpl, ::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;
    XMultiServiceFactory * xMgr, 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, XMultiServiceFactory * xMgr,&lt;br /&gt;
    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;
The makeFile is the same as in the previous example.&lt;br /&gt;
{{Documentation/Note|The use of helper (::cppu::WeakImplHelper2) provide a default class constructor. If you need a constructor managing a service manager you have rewrite a corresponding constructor. See also the [[helperNotHelper|difference between helper and not helper]] and also [[Uno/Cpp/Tutorials/component_tutorial| Daniel Bölzle&amp;#039;s tutorial]] where helper is used with explicit constructor.}} &lt;br /&gt;
&lt;br /&gt;
=== Results===&lt;br /&gt;
The OOoBasic program to test this example is as follows:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
&amp;#039;Listing 10 OOoBasic test Program&lt;br /&gt;
REM  *****  BASIC  *****&lt;br /&gt;
Sub Main&lt;br /&gt;
	Dim oSimpleComponent&lt;br /&gt;
	oSimpleComponent = CreateUnoService( &amp;quot;foo.Counter&amp;quot; )&lt;br /&gt;
	oSimpleComponent.setCount(5)&lt;br /&gt;
	print oSimpleComponent.getCount()&lt;br /&gt;
	oSimpleComponent.increment()&lt;br /&gt;
	print oSimpleComponent.getCount()&lt;br /&gt;
	XRay.XRay oSimpleComponent&lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Inspecting the new created service with [http://www.ooomacros.org/dev.php#101416 XRay] shows :&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;properties&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---- Object internal name : com.sun.star.comp.example.cpp.Counter&lt;br /&gt;
Count                     long          &lt;br /&gt;
ImplementationName        string &lt;br /&gt;
SupportedServiceNames  ]  string               &lt;br /&gt;
Types                     []type                 &lt;br /&gt;
ImplementationId          []byte                 &lt;br /&gt;
Dbg_Methods               string       &lt;br /&gt;
Dbg_Properties            string       &lt;br /&gt;
Dbg_SupportedInterfaces   string       &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;methods&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- Object internal name : com.sun.star.comp.example.cpp.Counter&lt;br /&gt;
queryInterface            ( aType as type )                &lt;br /&gt;
acquire                   (  ) &lt;br /&gt;
release                   (  ) &lt;br /&gt;
getCount                  (  )                             &lt;br /&gt;
setCount                  ( nCount as long ) &lt;br /&gt;
increment                 (  )                             &lt;br /&gt;
decrement                 (  )                             &lt;br /&gt;
getImplementationName     (  )                             &lt;br /&gt;
supportsService           ( ServiceName as string )        &lt;br /&gt;
getSupportedServiceNames  (  )                             &lt;br /&gt;
getTypes                  (  )                             &lt;br /&gt;
getImplementationId       (  )                             &lt;br /&gt;
queryAdapter              (  )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You see now the counter methods in OOoBasic (XRay is a OOoBasic tool)&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Note|Please note that the tutorial (from Daniel Bölzle) [[Uno/Cpp/Tutorials/component_tutorial| here]] presents a scriptable counter too but using less interfaces (cppu::WeakImplHelper1&amp;lt; XCountable &amp;gt; instead of cppu::WeakImplHelper2&amp;lt; XCountable, XServiceInfo &amp;gt;) :}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// C++ Daniel Bölzle&lt;br /&gt;
....&lt;br /&gt;
class MyCounterImpl : public cppu::WeakImplHelper1&amp;lt; XCountable &amp;gt;&lt;br /&gt;
{&lt;br /&gt;
	// to obtain other services if needed&lt;br /&gt;
	Reference&amp;lt; XMultiServiceFactory &amp;gt; _xServiceManager;&lt;br /&gt;
	&lt;br /&gt;
	sal_Int32 _nCount;&lt;br /&gt;
	&lt;br /&gt;
	Reference&amp;lt; XText &amp;gt; _xText;&lt;br /&gt;
	void dump( sal_Int32 nValue ) const;&lt;br /&gt;
	&lt;br /&gt;
public:&lt;br /&gt;
	MyCounterImpl( const Reference&amp;lt; XMultiServiceFactory &amp;gt; &amp;amp; xServiceManager );&lt;br /&gt;
	virtual ~MyCounterImpl();&lt;br /&gt;
	&lt;br /&gt;
	// XCountable implementation&lt;br /&gt;
	virtual sal_Int32 SAL_CALL getCount() throw (RuntimeException);&lt;br /&gt;
	virtual void SAL_CALL setCount( sal_Int32 nCount ) throw (RuntimeException);&lt;br /&gt;
	virtual sal_Int32 SAL_CALL increment() throw (RuntimeException);&lt;br /&gt;
	virtual sal_Int32 SAL_CALL decrement() throw (RuntimeException);&lt;br /&gt;
};&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== First Variation : a Counter with Attribute==&lt;br /&gt;
A little variation on the counter component. I decide to use the attribute possibility  in an IDL file. Bear in mind an attribute is automatically accessed with set/get methods. These methods are automatically created. We have then to remove the corresponding methods from the IDL file. My Counter IDL file becomes then :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
//Listing 11 Our new IDL File&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;
&lt;br /&gt;
module my_module&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
interface XSomething : com::sun::star::uno::XInterface&lt;br /&gt;
{&lt;br /&gt;
	// long getCount(); **************automaticaly generated&lt;br /&gt;
	// void setCount( [in] long nCount ); **************automaticaly generated&lt;br /&gt;
    [attribute] long Count;&lt;br /&gt;
	long increment();&lt;br /&gt;
	long decrement();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
service MyService&lt;br /&gt;
{&lt;br /&gt;
    interface XSomething;&lt;br /&gt;
};&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
How is this new counter seen with OooBasic ? We don&amp;#039;t see getCount and setCount anymore ! That doesn&amp;#039;t mean they don&amp;#039;t exist anymore. To prove their existence we program this OooBasic program and run it successfully.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
&amp;#039;Listing 12 &lt;br /&gt;
REM  *****  BASIC  *****&lt;br /&gt;
&lt;br /&gt;
Sub Main&lt;br /&gt;
	Dim oSimpleComponent&lt;br /&gt;
	oSimpleComponent = CreateUnoService( &amp;quot;foo.counter&amp;quot; )&lt;br /&gt;
	oSimpleComponent.Count = 5&lt;br /&gt;
	print oSimpleComponent.Count&lt;br /&gt;
	oSimpleComponent.increment()&lt;br /&gt;
	print oSimpleComponent.Count&lt;br /&gt;
	XRay.XRay oSimpleComponent&lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
XRaying this object gives us :&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;properties&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Properties of object &amp;quot;my_module.MyService&amp;quot;:&lt;br /&gt;
SbxSTRING        ImplementationName&lt;br /&gt;
SbxARRAY         SupportedServiceNames&lt;br /&gt;
SbxARRAY         Types&lt;br /&gt;
SbxARRAY         ImplementationId&lt;br /&gt;
SbxSTRING        Dbg_SupportedInterfaces&lt;br /&gt;
SbxSTRING        Dbg_Properties&lt;br /&gt;
SbxSTRING        Dbg_Methods    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;methods&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Methods of object &amp;quot;my_module.MyService&amp;quot;:&lt;br /&gt;
SbxEMPTY         queryInterface ( SbxOBJECT )&lt;br /&gt;
SbxLONG          addFive ( SbxLONG )&lt;br /&gt;
SbxLONG          addSix ( SbxLONG )&lt;br /&gt;
SbxSTRING        getImplementationName ( void )&lt;br /&gt;
SbxBOOL          supportsService ( SbxSTRING )&lt;br /&gt;
SbxARRAY         getSupportedServiceNames ( void )&lt;br /&gt;
SbxVOID          initialize ( SbxARRAY )&lt;br /&gt;
SbxARRAY         getTypes ( void )&lt;br /&gt;
SbxARRAY         getImplementationId ( void )&lt;br /&gt;
SbxOBJECT        queryAdapter ( void )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Second Variation : using the Service Manager in the Counter ==&lt;br /&gt;
&lt;br /&gt;
You can find a tutorial describing a scriptable counter example (from Daniel Bölzle) [[Uno/Cpp/Tutorials/component_tutorial| here]] where the counter is opening a OOoCalc document, that means it uses OOo services and interfaces.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;I can see all the Interfaces with XRay, all is working with OOoBasic except the main thing : using the Service Manager&amp;#039;&amp;#039;&amp;#039; :&lt;br /&gt;
&lt;br /&gt;
{{TODO|todonote=&lt;br /&gt;
make this example working&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Constructing the scriptable Counter without Helper==&lt;br /&gt;
We have seen how using helper avoid any interfaces coding. We want construct the counter but without helper, that means we will write everything we need. At the moment see the Developper&amp;#039;s Guide&lt;br /&gt;
&lt;br /&gt;
== TO DO : going further with components and dialog ==&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Tip|It is probably possible to create dialog at run time in a component. Installing Event listener for buttons is probably possible with [[Uno/Cpp/Tutorials/Introduction_to_Cpp_Uno#The_Component_helper | the Component helper]].}} &lt;br /&gt;
&lt;br /&gt;
[[Documentation/DevGuide/WritingUNO/Accessing_Dialogs | 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. This is an other way, probably simpler and I have to work around the [[BASIC/UNO_Object_Browser|BASIC UNO Object Browser component]] , the only C++ example I know. Developer&amp;#039;s Guide gives only a Java example. See also [[Framework/Article/Generic_UNO_Interfaces_for_complex_toolbar_controls|Generic UNO Interfaces for complex toolbar controls]].&lt;br /&gt;
&lt;br /&gt;
{{TODO|todonote=&lt;br /&gt;
make this example working&lt;br /&gt;
}}&lt;br /&gt;
&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;
* Daniel Bölzle&amp;#039;s tutorial : [[Uno/Cpp/Tutorials/component_tutorial|Writing a simple UNO component]]&lt;br /&gt;
* Old Service Manager and new Context passing when instanciating a component [[Documentation/DevGuide/ProUNO/Service_Manager_and_Component_Context|(see Developer&amp;#039;s Guide)]]&lt;br /&gt;
* [[Documentation/DevGuide/WritingUNO/Writing_UNO_Components|Writing UNO Components]] in Developer&amp;#039;s Guide&lt;br /&gt;
* [[Framework/Article/Generic_UNO_Interfaces_for_complex_toolbar_controls|Generic UNO Interfaces for complex toolbar controls]]&lt;br /&gt;
* [[HelperNotHelper|Helper Not Helper]]&lt;br /&gt;
* [[Uno/Cpp/Tutorials/Introduction_to_Cpp_Uno|C++ and UNO tutorial]]&lt;br /&gt;
* [http://cedric.bosdonnat.free.fr/wordpress/?p=19 Creating an URE application in C++]&lt;br /&gt;
* [[Development/Cpp/Helper/ServiceDecl|Service Declaration]]&lt;br /&gt;
* [[Development/Cpp/Helper/OPropertyContainerHelper|Registering properties]]&lt;br /&gt;
*[[Tutorial_UNO_Library|UNO tutorial]]&lt;br /&gt;
*[[Tutorial_UNO_IDL|UNO IDL]]&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;
* [[General_UNO_Component_Project_Type|General UNO Component project Type in Java]]&lt;br /&gt;
* [[OpenOffice_Add-On_Project_Type|Office Add-on Projet Type in Java]]&lt;br /&gt;
* [[Uno/Article/Types%26Reflection]]&lt;br /&gt;
* [[UNO_component_packaging|Component with Python]]&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;
* Bernard Marcelly&amp;#039;s [http://www.ooomacros.org/dev.php#101416 XRay OOoBasic tool] and a [[Extensions_development_basic#X-Ray_tool|XRay tool description]] in this wiki&lt;br /&gt;
* See also [[Extension Deployement|Extension Deployement]]&lt;br /&gt;
* [[UNO component packaging|(Python) UNO component packaging]]&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;br /&gt;
[[Category:Extensions]]&lt;br /&gt;
[[Category:Add-In]]&lt;br /&gt;
[[Category:Add-On]]&lt;/div&gt;</summary>
		<author><name>Jcn</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Uno/Cpp/Tutorials/component_tutorial&amp;diff=120020</id>
		<title>Uno/Cpp/Tutorials/component tutorial</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Uno/Cpp/Tutorials/component_tutorial&amp;diff=120020"/>
		<updated>2009-04-16T09:39:24Z</updated>

		<summary type="html">&lt;p&gt;Jcn: describe necessary oo.o build infrastucture snippets&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
&lt;br /&gt;
This tutorial is a general example of how to write a UNO component and how to use it in applications, for example StarOffice or OpenOffice.org. This example is written in C++, however differences for implementing the component in Java will be mentioned.&lt;br /&gt;
&lt;br /&gt;
The component is a basic counter, whose value can be set, read, incremented and decremented.&lt;br /&gt;
&lt;br /&gt;
= Interfaces =&lt;br /&gt;
&lt;br /&gt;
The first step, in writing any component (in almost any language environment) is to specify one or more interfaces that the component must implement.&lt;br /&gt;
&lt;br /&gt;
Interfaces are the key to hiding implementation details in any modern development environment. They are contracts between a client that wants to use a components&amp;#039; functionality and the component (serving this functionality). In UNO terminology, UNO components are called services.&lt;br /&gt;
&lt;br /&gt;
Interfaces separate the specific implementation (there can more than one for a service) from the usage. The client using the component does not have any insight how the component is implemented.&lt;br /&gt;
&lt;br /&gt;
Interfaces are specified using an Interface definition language (IDL). UNO uses UNO-IDL as the interface definition language. An interface for a Counter might look like this:&lt;br /&gt;
&lt;br /&gt;
file counter.idl:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/uno/XInterface.idl&amp;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;
    [ uik(3806AFF0-75A0-11d3-87B300A0-24494732), ident(&amp;quot;XCountable&amp;quot;, 1.0) ]&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;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Any interface that is specified is derived from XInterface, the basic interface in UNO. The XInterface has methods for lifetime control of the interface (acquire() and release()) and the ability to query for further interfaces of the UNO object (queryInterface()). Once you have an interface of an object, you can query for any others the object provides. If there are no acquired interfaces (references) left on an UNO object, the object might disappear. Interfaces (and services) can be grouped in modules to avoid pollution of the global namespace.&lt;br /&gt;
&lt;br /&gt;
= Services =&lt;br /&gt;
&lt;br /&gt;
Any UNO component (service) exports one or more interfaces that the clients are using. All services are specified using the service directive in an IDL file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
module foo &lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
    service Counter&lt;br /&gt;
    {&lt;br /&gt;
        // exported interfaces:&lt;br /&gt;
        interface XCountable;&lt;br /&gt;
    };&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The service declaration introduces a service called foo.Counter which supports the XCountable interface.&lt;br /&gt;
&lt;br /&gt;
There are some more IDL features, e.g. attributes, structs, enums, that are omitted at this time. All IDL declarations are put into a typelibrary file (rdb file). This speeds up the back end generation of the language specific files.&lt;br /&gt;
&lt;br /&gt;
To implement the interfaces, the appropriate interface code for the implementation language has to be generated from the rdb file.&lt;br /&gt;
&lt;br /&gt;
In C++ a tool called cppumaker generates pure abstract classes that the component has to implement. This is a common way to describe interfaces in C++. The Java language directly supports interfaces as a language feature (javamaker will generate Java interfaces).&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
A component that is implemented in C++ is normally packaged in a shared library. This shared lib exports two symbols, which are explained further below. Java implementations are normally packaged in a JAR file. In this case the manifest file identifies a class implementing two methods with similar semantics.&lt;br /&gt;
&lt;br /&gt;
A simple implementation of the counting UNO service foo.Counter might be:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//file foo.cxx:&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;rtl/ustring.hxx&amp;gt;&lt;br /&gt;
#include &amp;lt;cppuhelper/implbase1.hxx&amp;gt;&lt;br /&gt;
#include &amp;lt;cppuhelper/factory.hxx&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/lang/XSingleServiceFactory.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/lang/XMultiServiceFactory.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/registry/XRegistryKey.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;foo/XCountable.hpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using namespace rtl;&lt;br /&gt;
using namespace com::sun::star::uno;&lt;br /&gt;
using namespace com::sun::star::lang;&lt;br /&gt;
using namespace com::sun::star::registry;&lt;br /&gt;
using namespace foo;&lt;br /&gt;
&lt;br /&gt;
//==================================================================================================&lt;br /&gt;
class MyCounterImpl : public cppu::WeakImplHelper1&amp;lt; XCountable &amp;gt;&lt;br /&gt;
{&lt;br /&gt;
	// to obtain other services if needed&lt;br /&gt;
	Reference&amp;lt; XMultiServiceFactory &amp;gt; _xServiceManager;&lt;br /&gt;
	&lt;br /&gt;
	sal_Int32 _nCount;&lt;br /&gt;
	&lt;br /&gt;
	Reference&amp;lt; XText &amp;gt; _xText;&lt;br /&gt;
	void dump( sal_Int32 nValue ) const;&lt;br /&gt;
	&lt;br /&gt;
public:&lt;br /&gt;
	MyCounterImpl( const Reference&amp;lt; XMultiServiceFactory &amp;gt; &amp;amp; xServiceManager );&lt;br /&gt;
	virtual ~MyCounterImpl();&lt;br /&gt;
	&lt;br /&gt;
	// XCountable implementation&lt;br /&gt;
	virtual sal_Int32 SAL_CALL getCount() throw (RuntimeException);&lt;br /&gt;
	virtual void SAL_CALL setCount( sal_Int32 nCount ) throw (RuntimeException);&lt;br /&gt;
	virtual sal_Int32 SAL_CALL increment() throw (RuntimeException);&lt;br /&gt;
	virtual sal_Int32 SAL_CALL decrement() throw (RuntimeException);&lt;br /&gt;
};&lt;br /&gt;
//__________________________________________________________________________________________________&lt;br /&gt;
MyCounterImpl::MyCounterImpl( const Reference&amp;lt; XMultiServiceFactory &amp;gt; &amp;amp; xServiceManager )&lt;br /&gt;
	: _xServiceManager( xServiceManager )&lt;br /&gt;
{&lt;br /&gt;
	cerr &amp;lt;&amp;lt; &amp;quot;&amp;lt; MyCounterImpl ctor called &amp;gt;&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
	if (_xServiceManager.is())&lt;br /&gt;
	{&lt;br /&gt;
		Reference&amp;lt; XComponentLoader &amp;gt; xLoader( _xServiceManager-&amp;gt;createInstance(&lt;br /&gt;
			L&amp;quot;com.sun.star.frame.Desktop&amp;quot; ), UNO_QUERY );&lt;br /&gt;
		if (xLoader.is())&lt;br /&gt;
		{&lt;br /&gt;
			Reference&amp;lt; XTextDocument &amp;gt; xDoc( xLoader-&amp;gt;loadComponentFromURL(&lt;br /&gt;
				L&amp;quot;private:scalc/factory&amp;quot;, L&amp;quot;_blank&amp;quot;, 0, Sequence&amp;lt; PropertyValue &amp;gt;() ), UNO_QUERY );&lt;br /&gt;
			if (xDoc.is())&lt;br /&gt;
				_xText = xTextDoc-&amp;gt;getText();&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//__________________________________________________________________________________________________&lt;br /&gt;
MyCounterImpl::~MyCounterImpl()&lt;br /&gt;
{&lt;br /&gt;
	cerr &amp;lt;&amp;lt; &amp;quot;&amp;lt; MyCounterImpl dtor called &amp;gt;&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&lt;br /&gt;
//__________________________________________________________________________________________________&lt;br /&gt;
void MyCounterImpl::dump( sal_Int32 nValue ) const&lt;br /&gt;
{&lt;br /&gt;
	if (_xText.is())&lt;br /&gt;
		_xText-&amp;gt;setValue( nValue );&lt;br /&gt;
	else&lt;br /&gt;
		cerr &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; nValue;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// XCountable implementation&lt;br /&gt;
//__________________________________________________________________________________________________&lt;br /&gt;
sal_Int32 MyCounterImpl::getCount() throw (RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
	return _nCount;&lt;br /&gt;
}&lt;br /&gt;
//__________________________________________________________________________________________________&lt;br /&gt;
void MyCounterImpl::setCount( sal_Int32 nCount ) throw (RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
	_nCount = nCount;&lt;br /&gt;
	dump( _nCount );&lt;br /&gt;
}&lt;br /&gt;
//__________________________________________________________________________________________________&lt;br /&gt;
sal_Int32 MyCounterImpl::increment() throw (RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
	++_nCount;&lt;br /&gt;
	dump( _nCount );&lt;br /&gt;
	return _nCount;&lt;br /&gt;
}&lt;br /&gt;
//__________________________________________________________________________________________________&lt;br /&gt;
sal_Int32 MyCounterImpl::decrement() throw (RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
	--_nCount;&lt;br /&gt;
	dump( _nCount );&lt;br /&gt;
	return _nCount;&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; 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; XInterface &amp;gt;( new MyCounterImpl( xMgr ) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Caution|The instanciation of a component has changed since this article has been written. The constructor has to use a context instead of a service manager [[Documentation/DevGuide/ProUNO/Service_Manager_and_Component_Context|(see Developer&amp;#039;s Guide)]].}}&lt;br /&gt;
&lt;br /&gt;
The generated header file declares an abstract C++ class and a function called getCppuType(). Any generated type has its getCppuType() describing the type, for example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
const com::sun::star::uno::Type &amp;amp; SAL_CALL getCppuType( const com::sun::star::uno::Reference&amp;lt; foo::XCountable &amp;gt; * );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
describes the XCountable interface. Only the type of the parameter is of importance. By using overloaded getCppuType() functions for any type, it is possible to get runtime type information. It is also possible to use little helpers like a template queryInterface() function used for the implementation of XInterface::queryInterface().&lt;br /&gt;
&lt;br /&gt;
So how is the UNO component instantiated? As mentioned above, four symbols are exported by the shared library, providing four functions: component_getDescriptionFunc(), component_getImplementationEnvironment(), component_writeInfo() and component_getFactory().&lt;br /&gt;
&lt;br /&gt;
The first is called to get a description of the component. This function returns a XML formatted string which describes the component. This function could be generated from the XML description with the xml2cmp tool. Each component should provide such a XML description. The second is called from a loader service to get information about the used environment of the component. The third is called whenever the component is registered in some registry file and the latter is called to obtain a factory to get instances of the component.&lt;br /&gt;
&lt;br /&gt;
They are typically implemented as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * This function returns the name of the used environment.&lt;br /&gt;
 * @param ppEnvTypeName name of the environment&lt;br /&gt;
 * @param ppEnv could be point to a special environment, this parameter is normally set to null&lt;br /&gt;
 */&lt;br /&gt;
extern &amp;quot;C&amp;quot; void SAL_CALL component_getImplementationEnvironment(&lt;br /&gt;
    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;
/**&lt;br /&gt;
 * This function creates an implementation section in the registry and another subkey&lt;br /&gt;
 * for each supported service.&lt;br /&gt;
 * @param pServiceManager generic uno interface providing a service manager&lt;br /&gt;
 * @param pRegistryKey generic uno interface providing registry key to write&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;
    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;/foo.MyCounterImpl/UNO/SERVICES&amp;quot;) ) ) );&lt;br /&gt;
           xNewKey-&amp;gt;createKey( OUString( RTL_CONSTASCII_USTRINGPARAM(&amp;quot;foo.Counter&amp;quot;) ) );&lt;br /&gt;
           return sal_True;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    return sal_False;&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
component_writeInfo() will write information about all service implementations that are in the shared library. Each service implementation is registered under its implementation name in the implementation section, followed by its service name. The hierarchical structure of the registry is as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/IMPLEMENTATIONS/&lt;br /&gt;
    /foo.MyCounterImpl                    // implementation name&lt;br /&gt;
        /UNO&lt;br /&gt;
            /SERVICES&lt;br /&gt;
                /foo.Counter        // service name&lt;br /&gt;
    /bar.AnotherCounterImpl           // implementation name&lt;br /&gt;
       /UNO&lt;br /&gt;
           /SERVICES&lt;br /&gt;
               /foo.Counter        // service name&lt;br /&gt;
    ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;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; MyCounterImpl_create( const Reference&amp;lt; XMultiServiceFactory &amp;gt; &amp;amp; xMgr )&lt;br /&gt;
{&lt;br /&gt;
    return Reference&amp;lt; XInterface &amp;gt;( new MyCounterImpl( xMgr ) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * This function is called to get service factories for an implementation.&lt;br /&gt;
 * @param pImplName name of implementation&lt;br /&gt;
 * @param pServiceManager generic uno interface providing a service manager to instantiate components&lt;br /&gt;
 * @param pRegistryKey registry data key to read and write component persistent data&lt;br /&gt;
 * @return a component factory (generic uno interface)&lt;br /&gt;
 */&lt;br /&gt;
extern &amp;quot;C&amp;quot; void * SAL_CALL component_getFactory(&lt;br /&gt;
    const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )&lt;br /&gt;
{&lt;br /&gt;
    void * pRet = 0;&lt;br /&gt;
    // which implementation is required?&lt;br /&gt;
    if (pServiceManager &amp;amp;&amp;amp; rtl_str_compare( pImplName, &amp;quot;foo.MyCounterImpl&amp;quot; ))&lt;br /&gt;
    {&lt;br /&gt;
        rtl::OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM(&amp;quot;foo.Counter&amp;quot;) );&lt;br /&gt;
        Reference&amp;lt; XSingleServiceFactory &amp;gt; xFactory(&lt;br /&gt;
           cppu::createSingleFactory( // helper function from cppuhelper lib&lt;br /&gt;
           reinterpret_cast&amp;lt; XMultiServiceFactory * &amp;gt;( pServiceManager ),&lt;br /&gt;
           OUString( RTL_CONSTASCII_USTRINGPARAM(&amp;quot;foo.MyCounterImpl&amp;quot;) ),&lt;br /&gt;
           MyCounterImpl_create,&lt;br /&gt;
           Sequence&amp;lt; rtl::OUString &amp;gt;( &amp;amp;aServiceName, 1 ) ) );&lt;br /&gt;
        if (xFactory.is())&lt;br /&gt;
        {&lt;br /&gt;
           xFactory.acquire();&lt;br /&gt;
           pRet = xFactory.get();&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;
component_getFactory() demands a certain implementation from the shared library. The returned uno interface is a component factory that is used to produce service instances of the component implementation. The first parameter identifies the name of the required implementation. This name must correspond to the registered one from component_writeInfo(). The second parameter provides a service manager instance, components can use this for getting further components. The last parameter provides a registry key to the implementation section of the component, so it can read and write persistent data to the registry, e.g. for booting.&lt;br /&gt;
&lt;br /&gt;
When working in the OpenOffice build framework, make sure to add these functions to the util/NAME.map file, eg&lt;br /&gt;
when adding the first UNO service to calc&amp;#039;s scfilt library, do &lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
--- sc/util/scfilt.map&lt;br /&gt;
+++ sc/util/scfilt.map&lt;br /&gt;
@@ -1,6 +1,9 @@&lt;br /&gt;
 SCFILT_1_0 {&lt;br /&gt;
   global:&lt;br /&gt;
     ScFilterCreate;&lt;br /&gt;
+    component_getImplementationEnvironment;&lt;br /&gt;
+    component_writeInfo;&lt;br /&gt;
+    component_getFactory;&lt;br /&gt;
   local:&lt;br /&gt;
     *;&lt;br /&gt;
 };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and that you tell scp2 the library is a UNO library, in the case of scfilt, do&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
--- scp2/source/calc/file_calc.scp&lt;br /&gt;
+++ scp2/source/calc/file_calc.scp&lt;br /&gt;
@@ -49,7 +49,7 @@ STD_UNO_LIB_FILE_PATCH( gid_File_Lib_Sc, sc)&lt;br /&gt;
 &lt;br /&gt;
 STD_LIB_FILE_PATCH( gid_File_Lib_Scui, scui)&lt;br /&gt;
 &lt;br /&gt;
-STD_LIB_FILE( gid_File_Lib_Scfilt, scfilt)&lt;br /&gt;
+STD_UNO_LIB_FILE( gid_File_Lib_Scfilt, scfilt)&lt;br /&gt;
 &lt;br /&gt;
 STD_UNO_LIB_FILE( gid_File_Lib_Scd, scd)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Author: Daniel Bölzle ($Date: 2004/11/17 12:41:00 $)&lt;br /&gt;
Copyright 2001 Sun Microsystems, Inc., 901 San Antonio Road, Palo Alto, CA 94303 USA.&lt;br /&gt;
&lt;br /&gt;
[[Category:Uno]]&lt;br /&gt;
[[Category:Uno:Cpp]]&lt;br /&gt;
[[Category:Tutorial]]&lt;br /&gt;
[[Category:Cpp]]&lt;/div&gt;</summary>
		<author><name>Jcn</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Uno/Cpp/Tutorials/component_tutorial&amp;diff=120019</id>
		<title>Uno/Cpp/Tutorials/component tutorial</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Uno/Cpp/Tutorials/component_tutorial&amp;diff=120019"/>
		<updated>2009-04-16T09:36:03Z</updated>

		<summary type="html">&lt;p&gt;Jcn: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
&lt;br /&gt;
This tutorial is a general example of how to write a UNO component and how to use it in applications, for example StarOffice or OpenOffice.org. This example is written in C++, however differences for implementing the component in Java will be mentioned.&lt;br /&gt;
&lt;br /&gt;
The component is a basic counter, whose value can be set, read, incremented and decremented.&lt;br /&gt;
&lt;br /&gt;
= Interfaces =&lt;br /&gt;
&lt;br /&gt;
The first step, in writing any component (in almost any language environment) is to specify one or more interfaces that the component must implement.&lt;br /&gt;
&lt;br /&gt;
Interfaces are the key to hiding implementation details in any modern development environment. They are contracts between a client that wants to use a components&amp;#039; functionality and the component (serving this functionality). In UNO terminology, UNO components are called services.&lt;br /&gt;
&lt;br /&gt;
Interfaces separate the specific implementation (there can more than one for a service) from the usage. The client using the component does not have any insight how the component is implemented.&lt;br /&gt;
&lt;br /&gt;
Interfaces are specified using an Interface definition language (IDL). UNO uses UNO-IDL as the interface definition language. An interface for a Counter might look like this:&lt;br /&gt;
&lt;br /&gt;
file counter.idl:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/uno/XInterface.idl&amp;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;
    [ uik(3806AFF0-75A0-11d3-87B300A0-24494732), ident(&amp;quot;XCountable&amp;quot;, 1.0) ]&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;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Any interface that is specified is derived from XInterface, the basic interface in UNO. The XInterface has methods for lifetime control of the interface (acquire() and release()) and the ability to query for further interfaces of the UNO object (queryInterface()). Once you have an interface of an object, you can query for any others the object provides. If there are no acquired interfaces (references) left on an UNO object, the object might disappear. Interfaces (and services) can be grouped in modules to avoid pollution of the global namespace.&lt;br /&gt;
&lt;br /&gt;
= Services =&lt;br /&gt;
&lt;br /&gt;
Any UNO component (service) exports one or more interfaces that the clients are using. All services are specified using the service directive in an IDL file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;idl&amp;quot;&amp;gt;&lt;br /&gt;
module foo &lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
    service Counter&lt;br /&gt;
    {&lt;br /&gt;
        // exported interfaces:&lt;br /&gt;
        interface XCountable;&lt;br /&gt;
    };&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The service declaration introduces a service called foo.Counter which supports the XCountable interface.&lt;br /&gt;
&lt;br /&gt;
There are some more IDL features, e.g. attributes, structs, enums, that are omitted at this time. All IDL declarations are put into a typelibrary file (rdb file). This speeds up the back end generation of the language specific files.&lt;br /&gt;
&lt;br /&gt;
To implement the interfaces, the appropriate interface code for the implementation language has to be generated from the rdb file.&lt;br /&gt;
&lt;br /&gt;
In C++ a tool called cppumaker generates pure abstract classes that the component has to implement. This is a common way to describe interfaces in C++. The Java language directly supports interfaces as a language feature (javamaker will generate Java interfaces).&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
A component that is implemented in C++ is normally packaged in a shared library. This shared lib exports two symbols, which are explained further below. Java implementations are normally packaged in a JAR file. In this case the manifest file identifies a class implementing two methods with similar semantics.&lt;br /&gt;
&lt;br /&gt;
A simple implementation of the counting UNO service foo.Counter might be:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//file foo.cxx:&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;rtl/ustring.hxx&amp;gt;&lt;br /&gt;
#include &amp;lt;cppuhelper/implbase1.hxx&amp;gt;&lt;br /&gt;
#include &amp;lt;cppuhelper/factory.hxx&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/lang/XSingleServiceFactory.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/lang/XMultiServiceFactory.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;com/sun/star/registry/XRegistryKey.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;foo/XCountable.hpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using namespace rtl;&lt;br /&gt;
using namespace com::sun::star::uno;&lt;br /&gt;
using namespace com::sun::star::lang;&lt;br /&gt;
using namespace com::sun::star::registry;&lt;br /&gt;
using namespace foo;&lt;br /&gt;
&lt;br /&gt;
//==================================================================================================&lt;br /&gt;
class MyCounterImpl : public cppu::WeakImplHelper1&amp;lt; XCountable &amp;gt;&lt;br /&gt;
{&lt;br /&gt;
	// to obtain other services if needed&lt;br /&gt;
	Reference&amp;lt; XMultiServiceFactory &amp;gt; _xServiceManager;&lt;br /&gt;
	&lt;br /&gt;
	sal_Int32 _nCount;&lt;br /&gt;
	&lt;br /&gt;
	Reference&amp;lt; XText &amp;gt; _xText;&lt;br /&gt;
	void dump( sal_Int32 nValue ) const;&lt;br /&gt;
	&lt;br /&gt;
public:&lt;br /&gt;
	MyCounterImpl( const Reference&amp;lt; XMultiServiceFactory &amp;gt; &amp;amp; xServiceManager );&lt;br /&gt;
	virtual ~MyCounterImpl();&lt;br /&gt;
	&lt;br /&gt;
	// XCountable implementation&lt;br /&gt;
	virtual sal_Int32 SAL_CALL getCount() throw (RuntimeException);&lt;br /&gt;
	virtual void SAL_CALL setCount( sal_Int32 nCount ) throw (RuntimeException);&lt;br /&gt;
	virtual sal_Int32 SAL_CALL increment() throw (RuntimeException);&lt;br /&gt;
	virtual sal_Int32 SAL_CALL decrement() throw (RuntimeException);&lt;br /&gt;
};&lt;br /&gt;
//__________________________________________________________________________________________________&lt;br /&gt;
MyCounterImpl::MyCounterImpl( const Reference&amp;lt; XMultiServiceFactory &amp;gt; &amp;amp; xServiceManager )&lt;br /&gt;
	: _xServiceManager( xServiceManager )&lt;br /&gt;
{&lt;br /&gt;
	cerr &amp;lt;&amp;lt; &amp;quot;&amp;lt; MyCounterImpl ctor called &amp;gt;&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
	if (_xServiceManager.is())&lt;br /&gt;
	{&lt;br /&gt;
		Reference&amp;lt; XComponentLoader &amp;gt; xLoader( _xServiceManager-&amp;gt;createInstance(&lt;br /&gt;
			L&amp;quot;com.sun.star.frame.Desktop&amp;quot; ), UNO_QUERY );&lt;br /&gt;
		if (xLoader.is())&lt;br /&gt;
		{&lt;br /&gt;
			Reference&amp;lt; XTextDocument &amp;gt; xDoc( xLoader-&amp;gt;loadComponentFromURL(&lt;br /&gt;
				L&amp;quot;private:scalc/factory&amp;quot;, L&amp;quot;_blank&amp;quot;, 0, Sequence&amp;lt; PropertyValue &amp;gt;() ), UNO_QUERY );&lt;br /&gt;
			if (xDoc.is())&lt;br /&gt;
				_xText = xTextDoc-&amp;gt;getText();&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//__________________________________________________________________________________________________&lt;br /&gt;
MyCounterImpl::~MyCounterImpl()&lt;br /&gt;
{&lt;br /&gt;
	cerr &amp;lt;&amp;lt; &amp;quot;&amp;lt; MyCounterImpl dtor called &amp;gt;&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&lt;br /&gt;
//__________________________________________________________________________________________________&lt;br /&gt;
void MyCounterImpl::dump( sal_Int32 nValue ) const&lt;br /&gt;
{&lt;br /&gt;
	if (_xText.is())&lt;br /&gt;
		_xText-&amp;gt;setValue( nValue );&lt;br /&gt;
	else&lt;br /&gt;
		cerr &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; nValue;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// XCountable implementation&lt;br /&gt;
//__________________________________________________________________________________________________&lt;br /&gt;
sal_Int32 MyCounterImpl::getCount() throw (RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
	return _nCount;&lt;br /&gt;
}&lt;br /&gt;
//__________________________________________________________________________________________________&lt;br /&gt;
void MyCounterImpl::setCount( sal_Int32 nCount ) throw (RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
	_nCount = nCount;&lt;br /&gt;
	dump( _nCount );&lt;br /&gt;
}&lt;br /&gt;
//__________________________________________________________________________________________________&lt;br /&gt;
sal_Int32 MyCounterImpl::increment() throw (RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
	++_nCount;&lt;br /&gt;
	dump( _nCount );&lt;br /&gt;
	return _nCount;&lt;br /&gt;
}&lt;br /&gt;
//__________________________________________________________________________________________________&lt;br /&gt;
sal_Int32 MyCounterImpl::decrement() throw (RuntimeException)&lt;br /&gt;
{&lt;br /&gt;
	--_nCount;&lt;br /&gt;
	dump( _nCount );&lt;br /&gt;
	return _nCount;&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; 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; XInterface &amp;gt;( new MyCounterImpl( xMgr ) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Documentation/Caution|The instanciation of a component has changed since this article has been written. The constructor has to use a context instead of a service manager [[Documentation/DevGuide/ProUNO/Service_Manager_and_Component_Context|(see Developer&amp;#039;s Guide)]].}}&lt;br /&gt;
&lt;br /&gt;
The generated header file declares an abstract C++ class and a function called getCppuType(). Any generated type has its getCppuType() describing the type, for example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
const com::sun::star::uno::Type &amp;amp; SAL_CALL getCppuType( const com::sun::star::uno::Reference&amp;lt; foo::XCountable &amp;gt; * );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
describes the XCountable interface. Only the type of the parameter is of importance. By using overloaded getCppuType() functions for any type, it is possible to get runtime type information. It is also possible to use little helpers like a template queryInterface() function used for the implementation of XInterface::queryInterface().&lt;br /&gt;
&lt;br /&gt;
So how is the UNO component instantiated? As mentioned above, four symbols are exported by the shared library, providing four functions: component_getDescriptionFunc(), component_getImplementationEnvironment(), component_writeInfo() and component_getFactory().&lt;br /&gt;
&lt;br /&gt;
The first is called to get a description of the component. This function returns a XML formatted string which describes the component. This function could be generated from the XML description with the xml2cmp tool. Each component should provide such a XML description. The second is called from a loader service to get information about the used environment of the component. The third is called whenever the component is registered in some registry file and the latter is called to obtain a factory to get instances of the component.&lt;br /&gt;
&lt;br /&gt;
They are typically implemented as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * This function returns the name of the used environment.&lt;br /&gt;
 * @param ppEnvTypeName name of the environment&lt;br /&gt;
 * @param ppEnv could be point to a special environment, this parameter is normally set to null&lt;br /&gt;
 */&lt;br /&gt;
extern &amp;quot;C&amp;quot; void SAL_CALL component_getImplementationEnvironment(&lt;br /&gt;
    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;
/**&lt;br /&gt;
 * This function creates an implementation section in the registry and another subkey&lt;br /&gt;
 * for each supported service.&lt;br /&gt;
 * @param pServiceManager generic uno interface providing a service manager&lt;br /&gt;
 * @param pRegistryKey generic uno interface providing registry key to write&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;
    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;/foo.MyCounterImpl/UNO/SERVICES&amp;quot;) ) ) );&lt;br /&gt;
           xNewKey-&amp;gt;createKey( OUString( RTL_CONSTASCII_USTRINGPARAM(&amp;quot;foo.Counter&amp;quot;) ) );&lt;br /&gt;
           return sal_True;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    return sal_False;&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
component_writeInfo() will write information about all service implementations that are in the shared library. Each service implementation is registered under its implementation name in the implementation section, followed by its service name. The hierarchical structure of the registry is as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/IMPLEMENTATIONS/&lt;br /&gt;
    /foo.MyCounterImpl                    // implementation name&lt;br /&gt;
        /UNO&lt;br /&gt;
            /SERVICES&lt;br /&gt;
                /foo.Counter        // service name&lt;br /&gt;
    /bar.AnotherCounterImpl           // implementation name&lt;br /&gt;
       /UNO&lt;br /&gt;
           /SERVICES&lt;br /&gt;
               /foo.Counter        // service name&lt;br /&gt;
    ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;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; MyCounterImpl_create( const Reference&amp;lt; XMultiServiceFactory &amp;gt; &amp;amp; xMgr )&lt;br /&gt;
{&lt;br /&gt;
    return Reference&amp;lt; XInterface &amp;gt;( new MyCounterImpl( xMgr ) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * This function is called to get service factories for an implementation.&lt;br /&gt;
 * @param pImplName name of implementation&lt;br /&gt;
 * @param pServiceManager generic uno interface providing a service manager to instantiate components&lt;br /&gt;
 * @param pRegistryKey registry data key to read and write component persistent data&lt;br /&gt;
 * @return a component factory (generic uno interface)&lt;br /&gt;
 */&lt;br /&gt;
extern &amp;quot;C&amp;quot; void * SAL_CALL component_getFactory(&lt;br /&gt;
    const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )&lt;br /&gt;
{&lt;br /&gt;
    void * pRet = 0;&lt;br /&gt;
    // which implementation is required?&lt;br /&gt;
    if (pServiceManager &amp;amp;&amp;amp; rtl_str_compare( pImplName, &amp;quot;foo.MyCounterImpl&amp;quot; ))&lt;br /&gt;
    {&lt;br /&gt;
        rtl::OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM(&amp;quot;foo.Counter&amp;quot;) );&lt;br /&gt;
        Reference&amp;lt; XSingleServiceFactory &amp;gt; xFactory(&lt;br /&gt;
           cppu::createSingleFactory( // helper function from cppuhelper lib&lt;br /&gt;
           reinterpret_cast&amp;lt; XMultiServiceFactory * &amp;gt;( pServiceManager ),&lt;br /&gt;
           OUString( RTL_CONSTASCII_USTRINGPARAM(&amp;quot;foo.MyCounterImpl&amp;quot;) ),&lt;br /&gt;
           MyCounterImpl_create,&lt;br /&gt;
           Sequence&amp;lt; rtl::OUString &amp;gt;( &amp;amp;aServiceName, 1 ) ) );&lt;br /&gt;
        if (xFactory.is())&lt;br /&gt;
        {&lt;br /&gt;
           xFactory.acquire();&lt;br /&gt;
           pRet = xFactory.get();&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;
component_getFactory() demands a certain implementation from the shared library. The returned uno interface is a component factory that is used to produce service instances of the component implementation. The first parameter identifies the name of the required implementation. This name must correspond to the registered one from component_writeInfo(). The second parameter provides a service manager instance, components can use this for getting further components. The last parameter provides a registry key to the implementation section of the component, so it can read and write persistent data to the registry, e.g. for booting.&lt;br /&gt;
&lt;br /&gt;
When working in the OpenOffice build framework, make sure to add these functions to the util/NAME.map file, eg&lt;br /&gt;
when adding the first UNO service to calc&amp;#039;s scfilt library, do &lt;br /&gt;
&amp;lt;source lang=whitespace&amp;gt;&lt;br /&gt;
--- sc/util/scfilt.map&lt;br /&gt;
+++ sc/util/scfilt.map&lt;br /&gt;
@@ -1,6 +1,9 @@&lt;br /&gt;
 SCFILT_1_0 {&lt;br /&gt;
   global:&lt;br /&gt;
     ScFilterCreate;&lt;br /&gt;
+    component_getImplementationEnvironment;&lt;br /&gt;
+    component_writeInfo;&lt;br /&gt;
+    component_getFactory;&lt;br /&gt;
   local:&lt;br /&gt;
     *;&lt;br /&gt;
 };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and that you tell scp2 the library is a UNO library, in the case of scfilt, do&lt;br /&gt;
&amp;lt;source lang=whitespace&amp;gt;&lt;br /&gt;
--- scp2/source/calc/file_calc.scp&lt;br /&gt;
+++ scp2/source/calc/file_calc.scp&lt;br /&gt;
@@ -49,7 +49,7 @@ STD_UNO_LIB_FILE_PATCH( gid_File_Lib_Sc, sc)&lt;br /&gt;
 &lt;br /&gt;
 STD_LIB_FILE_PATCH( gid_File_Lib_Scui, scui)&lt;br /&gt;
 &lt;br /&gt;
-STD_LIB_FILE( gid_File_Lib_Scfilt, scfilt)&lt;br /&gt;
+STD_UNO_LIB_FILE( gid_File_Lib_Scfilt, scfilt)&lt;br /&gt;
 &lt;br /&gt;
 STD_UNO_LIB_FILE( gid_File_Lib_Scd, scd)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Author: Daniel Bölzle ($Date: 2004/11/17 12:41:00 $)&lt;br /&gt;
Copyright 2001 Sun Microsystems, Inc., 901 San Antonio Road, Palo Alto, CA 94303 USA.&lt;br /&gt;
&lt;br /&gt;
[[Category:Uno]]&lt;br /&gt;
[[Category:Uno:Cpp]]&lt;br /&gt;
[[Category:Tutorial]]&lt;br /&gt;
[[Category:Cpp]]&lt;/div&gt;</summary>
		<author><name>Jcn</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=VCL_UI_Rework&amp;diff=72207</id>
		<title>VCL UI Rework</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=VCL_UI_Rework&amp;diff=72207"/>
		<updated>2008-04-01T13:51:54Z</updated>

		<summary type="html">&lt;p&gt;Jcn: Fix history&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Rational ==&lt;br /&gt;
&lt;br /&gt;
Currently all dialogs (along with most translated strings) are stored in a rather unusual binary resource file format, that has not had much love in the last decade. We need to write some new code that separates the process of designing &amp;amp; laying out the UI from the code - to allow UE to make our UI more beautiful, and allow future re-factoring. The existing Basic GUI dialog editor and it&amp;#039;s XML format should be re-used, a simple C++ compatibility API created, and a number of dialogs converted to the new format.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
There have already been several attempts at adding features to VCL, and of course people have different requirements, an initial synthesis of requirements is perhaps helpful. Please do add subsequent constraints, or comments thereof.&lt;br /&gt;
&lt;br /&gt;
=== Simple code changes (Mandatory) ===&lt;br /&gt;
&lt;br /&gt;
Of course, we want to remove lots of code - all the immediate construction of non-core widgets that do not require special handling for a start. However - given the scope of the problem, it does not seem sensible to require some vast re-writing of each &amp;amp;amp; every dialog from day 1. ie. re-implementing all callbacks using a UNO Listener type interface would kill the task, we should stick with existing callback mechanisms and signatures.&lt;br /&gt;
&lt;br /&gt;
=== QA Test tool (Mandatory) ===&lt;br /&gt;
&lt;br /&gt;
We need to ensure either, that relevant qa testtool tests are updated to use the new UI code, or that we have a strong back-compat story here.&lt;br /&gt;
&lt;br /&gt;
=== Re-use of existing code (Desirable) ===&lt;br /&gt;
&lt;br /&gt;
Clearly the existing form code has not only a working XML serialization, but code to (re)store from that, re-using that where at all possible is important. Unfortunately this code is rather complex and difficult to work with. A life-boat approach to creating a new cleaner, smaller structure and moving dialogs across would perhaps be better.&lt;br /&gt;
&lt;br /&gt;
=== Simple new APIs (Important) ===&lt;br /&gt;
&lt;br /&gt;
The existing &amp;amp;amp; successful [[http://svn.gnome.org/viewcvs/libglade/trunk/glade/glade-xml.h?view=markup libglade API]] is a good model to build from. Identifying widgets and signals by strings seems to scale well and be more extensible than the SID based system.&lt;br /&gt;
&lt;br /&gt;
=== I18n (Important) ===&lt;br /&gt;
&lt;br /&gt;
The i18n story is important, quite possibly we&amp;#039;ll want to process any Form XML to introduce integer IDs to identify strings, feature creep into re-writing i18n might kill this project.&lt;br /&gt;
&lt;br /&gt;
=== Layout (Mandatory) ===&lt;br /&gt;
&lt;br /&gt;
Adding automatic layout, as modern toolkits do, would substantially help improve the look of the UI, it&amp;#039;s portability to other platforms, and also it&amp;#039;s look when translated.&lt;br /&gt;
&lt;br /&gt;
==== Support for platform specific layout and HIG ====&lt;br /&gt;
The UI layouting mechanism should (where possible) &amp;#039;&amp;#039;&amp;#039;automatically adapt the XML UI description to the conventions of the platform&amp;#039;&amp;#039;&amp;#039;. &lt;br /&gt;
&lt;br /&gt;
For changes that are beyond possibilities of automatic layout, there should be a possibility to add &amp;#039;&amp;#039;&amp;#039;conditional UI layout&amp;#039;&amp;#039;&amp;#039; that allows to use different XML descriptions for different platforms (only specific sub-areas of a dialog/whatever, preferably not the whole dialog).&lt;br /&gt;
&lt;br /&gt;
* Example 1: The typical &amp;quot;OK&amp;quot; and &amp;quot;Cancel&amp;quot; -buttons in a dialog are&lt;br /&gt;
** WINDOWS: &amp;quot;OK&amp;quot; (first), &amp;quot;Cancel&amp;quot; (second), both aligned to the right bottom edge of the dialog.&lt;br /&gt;
** LINUX (QT): same as Windows&lt;br /&gt;
** MAC OS X: &amp;#039;&amp;#039;&amp;#039;The OK button sits in the lower right corner&amp;#039;&amp;#039;&amp;#039;, the cancel button left to it and then all other buttons. An optional HelpButton follows a completely different look (it is a small icon with a questionmark basically). &amp;#039;&amp;#039;For more Mac OS X examples, see [[Mac OS Porter Team at WWDC 2007]]&amp;#039;&amp;#039;&lt;br /&gt;
** LINUX (GTK): same as Mac OS X&lt;br /&gt;
&lt;br /&gt;
* Example 2: Preferences dialogs&lt;br /&gt;
** WINDOWS: This type of dialogs are called &amp;quot;Settings&amp;quot; or &amp;quot;Options&amp;quot;. There is typically &amp;quot;OK&amp;quot; and &amp;quot;Cancel&amp;quot; -buttons, in that order.&lt;br /&gt;
** LINUX (GTK): This type of dialogs are called &amp;quot;Properties&amp;quot; or &amp;quot;Preferences&amp;quot;. There is typically &amp;quot;Help&amp;quot; (optional) and &amp;quot;Close&amp;quot; -buttons, in that order.&lt;br /&gt;
** MAC OS X: This type of dialogs are called &amp;quot;Preferences&amp;quot;, there are no regular buttons, optionally just a circular &amp;quot;?&amp;quot; -button for help. The dialog is instantly applies any changes, and can be closed from the window border&amp;#039;s red circular button (upper left corner). &lt;br /&gt;
&lt;br /&gt;
* Example 3: Changing values related to currently selected object in document&lt;br /&gt;
** WINDOWS: Relatively many icons/widgets in several toolbars, some context sensitive toolbars exist, but they are specific to certain object types.&lt;br /&gt;
** LINUX (GTK): similar to Windows(?).&lt;br /&gt;
** MAC OS X: In addition to one main toolbar with about 6-12 user-configurable (drag-n-drop) icons (= big buttons with text underneath), there is a separate &amp;quot;Inspector&amp;quot; widget for changing values related to the currently selected object in the document. Selecting a different object, changes the contents of the inspector widget, it does not open a new toolbar. If there are many settings, they can be divided into tab-pages within the inspector.&lt;br /&gt;
&lt;br /&gt;
=== Reduced Inheritance (Desirable) ===&lt;br /&gt;
&lt;br /&gt;
Currently all dialogs inherit (somehow) from VCL&amp;#039;s Window class. Such inheritance from virtual bases generates large vtables, and substantial inefficiency across the code-base. Wherever possible we should have a child instance of the relevant window &amp;amp;amp; use an aggregating pattern. In other cases, we may want to have a simple base class to inherit from with &amp;#039;Show&amp;#039; / &amp;#039;Hide&amp;#039; type methods that chain to the aggregated instance, and in more complex situations stick with an inherited approach.&lt;br /&gt;
&lt;br /&gt;
It would also be good to do some code size profiles of the resulting code, to optimise for reduced code size.&lt;br /&gt;
&lt;br /&gt;
=== New file format (Desirable) ===&lt;br /&gt;
&lt;br /&gt;
Deprecating the rsc code, and preferably removing it is a good goal.&lt;br /&gt;
There is a decision to be made whether the layout information is mangled with the widgets or defined alongside.&lt;br /&gt;
&lt;br /&gt;
* Having layout information and widgets mixed like in XUL&lt;br /&gt;
** pro: format is more human readable in an XML editor&lt;br /&gt;
** con: current implementation to read/store the widgets from/to XML must be altered &lt;br /&gt;
&lt;br /&gt;
* Having layout information and widgets separated in one or more XML files&lt;br /&gt;
** pro: format may be easier to use by a dialog editor (see [http://www.netbeans.org/kb/55/quickstart-gui.html NetBeans GUI Editor] using [http://java.sun.com/javase/6/docs/api/javax/swing/GroupLayout.html javax.swing.GroupLayout]&lt;br /&gt;
** pro: implementation is faster as it must not be implemented inside the existing XML code for widgets (better compatibility, lower risk of regressions)&lt;br /&gt;
** con: not as easy to edit for humans in an XML editor&lt;br /&gt;
&lt;br /&gt;
=== Easy to use Dialog Editor (Desirable) ===&lt;br /&gt;
&lt;br /&gt;
To allow User Experience to tweak the UI easily, it is necessary to implement an easy-to-use GUI editor that allows the UI to be tweaked simply.&lt;br /&gt;
&lt;br /&gt;
* NetBeans has an interactive GUI editor that also supports layouts. [http://www.netbeans.org/kb/55/quickstart-gui.html Quickstart Guide]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Ongoing work ==&lt;br /&gt;
&lt;br /&gt;
Phases of the work:&lt;br /&gt;
&lt;br /&gt;
* Implement layout / container implementations&lt;br /&gt;
* Implement new, simple, hierarchical XML serialization of widgets &amp;amp; layout&lt;br /&gt;
* Implement helper API &amp;amp; port sample dialogs&lt;br /&gt;
* Implement resource file encapsulation&lt;br /&gt;
* Implement support in dialog editor in basctl (optional)&lt;br /&gt;
* Commence porting dialogs&lt;br /&gt;
&lt;br /&gt;
=== layout / container implementations *prototype complete* ===&lt;br /&gt;
&lt;br /&gt;
Several prototypes out there to choose from. Various decisions&lt;br /&gt;
* as little new API as possible - use introspectable / self describing &amp;#039;child&amp;#039; properties&lt;br /&gt;
* only the basic box, table and alignment primitives necessary to start with&lt;br /&gt;
&lt;br /&gt;
=== new XML format *skeleton complete* ===&lt;br /&gt;
&lt;br /&gt;
This is based on the widget hierarchy, property and child property&lt;br /&gt;
names, suitable mangled. The layout information is included in-line&lt;br /&gt;
with the widgets, to avoid indirection related complexity.&lt;br /&gt;
&lt;br /&gt;
=== helper API *commenced* ===&lt;br /&gt;
&lt;br /&gt;
In order to reduce code impact, we should incrementally create thin wrapper api around the AWT UNO APIs, providing VCL-like back-compatibility logic, to substantially limit the scope of the code changes. We should provide &amp;#039;placeholders&amp;#039; whereby complex widgets can easily be inserted into the layout &amp;amp;amp; used as-before.&lt;br /&gt;
&lt;br /&gt;
We should port at least 3 sample dialogs (~1 done so far)&lt;br /&gt;
&lt;br /&gt;
=== resource file ===&lt;br /&gt;
&lt;br /&gt;
The resource file format can re-use the package code for a .zip encapsulation, though some tweaks will be necessary to populate an existing dialog parent with widgets, for those widgets that are re-used elsewhere.&lt;br /&gt;
&lt;br /&gt;
=== support in dialog editor ===&lt;br /&gt;
&lt;br /&gt;
This will require more GUI work, extending the palette and adding properties specific to layout containers.&lt;br /&gt;
&lt;br /&gt;
=== i18n ===&lt;br /&gt;
* mark i18n attributes by prepending an underscore: &amp;lt;radiobutton id=&amp;quot;RB1&amp;quot; _label=&amp;quot;One&amp;quot;/&amp;gt;&lt;br /&gt;
* implement new transex3 tool to extract strings from template XML into ubiquitous localize.sdf files and produce i18n tree of translated XMLs at compile time&lt;br /&gt;
* use simple read-right translation&lt;br /&gt;
* eventually read XMLs from per-language zip files: share/layout/de.zip, share/layout/nl.zip etc. &lt;br /&gt;
&lt;br /&gt;
=== .src converter ===&lt;br /&gt;
&lt;br /&gt;
The process of converting 360,000+ lines of .src file to XML is a fairly daunting one.&lt;br /&gt;
This is where Kohei&amp;#039;s src2xml converter can help.&lt;br /&gt;
&lt;br /&gt;
The src2xml tool currently will convert:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    ModalDialog RID_SVXDLG_ZOOM&lt;br /&gt;
    {&lt;br /&gt;
	HelpId = SID_ATTR_ZOOM ;&lt;br /&gt;
	OutputSize = TRUE ;&lt;br /&gt;
	SvLook = TRUE ;&lt;br /&gt;
	Size = MAP_APPFONT ( 202 , 116 ) ;&lt;br /&gt;
	Moveable = TRUE ;&lt;br /&gt;
&lt;br /&gt;
	FixedLine FL_ZOOM&lt;br /&gt;
	{&lt;br /&gt;
	    Pos = MAP_APPFONT ( 6 , 3 ) ;&lt;br /&gt;
	    Size = MAP_APPFONT ( 92 , 8 ) ;&lt;br /&gt;
	    Text [ en-US ] = &amp;quot;Zoom factor&amp;quot;;&lt;br /&gt;
	};&lt;br /&gt;
	RadioButton BTN_OPTIMAL&lt;br /&gt;
	{&lt;br /&gt;
	    Pos = MAP_APPFONT ( 12 , 15 ) ;&lt;br /&gt;
	    Size = MAP_APPFONT ( 80 , 10 ) ;&lt;br /&gt;
	    Text [ en-US ] = &amp;quot;~Optimal&amp;quot; ;&lt;br /&gt;
	};&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
into:&lt;br /&gt;
&amp;lt;pre&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;modaldialog &amp;quot;sizeable=true&amp;quot; help-id=&amp;quot;SID_ATTR_ZOOM&amp;quot; moveable=&amp;quot;true&amp;quot; output-size=&amp;quot;true&amp;quot;&lt;br /&gt;
		 id=&amp;quot;RID_SVXDLG_ZOOM&amp;quot; sv-look=&amp;quot;true&amp;quot;&lt;br /&gt;
		 xmlns=&amp;quot;http://openoffice.org/2007/layout&amp;quot;&lt;br /&gt;
		 xmlns:cnt=&amp;quot;http://openoffice.org/2007/layout/container&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;vbox&amp;gt;&lt;br /&gt;
	    &amp;lt;fixedline id=&amp;quot;FL_ZOOM&amp;quot; _text=&amp;quot;Zoom factor&amp;quot;/&amp;gt;&lt;br /&gt;
	    &amp;lt;radiobutton id=&amp;quot;BTN_OPTIMAL&amp;quot; _text=&amp;quot;~Optimal&amp;quot;/&amp;gt;&lt;br /&gt;
	&amp;lt;/vbox&amp;gt;&lt;br /&gt;
    &amp;lt;/modaldialog&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ie. just whacks all the widgets into a single vbox, to allow later layout work to be done by hand / in the GUI editor.&lt;br /&gt;
&lt;br /&gt;
=== Dialog Editor ===&lt;br /&gt;
&lt;br /&gt;
This should be written using our VCL-like wrapper API wherever possible - as a means to extend &amp;amp;amp; mature the wrapper API itself. The code should be hosted in our &amp;#039;test&amp;#039; application initially (due to evil UNO bootstrapping problems to horrible to detail).&lt;br /&gt;
Steps:&lt;br /&gt;
* introspect the layout hierarchy, and write out the containers and all their properties as XML. This would currently be stymied by the lack of interface capabilities to introspect children; thus adding a method &amp;lt;code&amp;gt;sequence&amp;lt;XLayoutConstrains&amp;gt; getChildren()&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;layout/source/api/com/sun/star/awt/XInterfaceContainer&amp;lt;/code&amp;gt; would be rather helpful.&lt;br /&gt;
* a palette should be created added, and widget selection &amp;amp;amp; creation allowed&lt;br /&gt;
** requires construction of a &amp;#039;placeholder&amp;#039; widget to reserve space for adding new widgets.&lt;br /&gt;
** icons can be re-used from existing OO.o toolbars for this.&lt;br /&gt;
** we should present properties (initially) generically&lt;br /&gt;
*** ie. by introspection determine a properties&amp;#039; type and hence what kind of control to present.&lt;br /&gt;
*** partitioning of child properties &amp;amp;amp; widget properties would also be useful perhaps.&lt;br /&gt;
glade2, or stetic gives a good model of how this can be done. A high level of polish is not required.&lt;br /&gt;
&lt;br /&gt;
=== toolkit/ fixing ===&lt;br /&gt;
&lt;br /&gt;
The toolkit code is fairly incomplete &amp;amp;amp; curious in it&amp;#039;s implementation; we need to extend it where necessary to provide a high behavioral fidelity as we switch from wrapper API to UNO awt to VCL and back.&lt;br /&gt;
&lt;br /&gt;
=== QA test tool ===&lt;br /&gt;
&lt;br /&gt;
An audit of qatesttool interaction with dialogs needs to be done, to identify entry points, and resource identification. If necessary the wrapper API &amp;amp;amp; awt needs to propagate &amp;#039;SmartIds&amp;#039; (or some other identifiers) through to the VCL widgets.&lt;br /&gt;
&lt;br /&gt;
[[Category:VCL]]&lt;br /&gt;
[[Category:GUI]]&lt;/div&gt;</summary>
		<author><name>Jcn</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=VCL_UI_Rework&amp;diff=72204</id>
		<title>VCL UI Rework</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=VCL_UI_Rework&amp;diff=72204"/>
		<updated>2008-04-01T13:49:34Z</updated>

		<summary type="html">&lt;p&gt;Jcn: fix verbatim snippets&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Rational ==&lt;br /&gt;
&lt;br /&gt;
Currently all dialogs (along with most translated strings) are stored in a rather unusual binary resource file format, that has not had much love in the last decade. We need to write some new code that separates the process of designing &amp;amp; laying out the UI from the code - to allow UE to make our UI more beautiful, and allow future re-factoring. The existing Basic GUI dialog editor and it&amp;#039;s XML format should be re-used, a simple C++ compatibility API created, and a number of dialogs converted to the new format.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
There have already been several attempts at adding features to VCL, and of course people have different requirements, an initial synthesis of requirements is perhaps helpful. Please do add subsequent constraints, or comments thereof.&lt;br /&gt;
&lt;br /&gt;
=== Simple code changes (Mandatory) ===&lt;br /&gt;
&lt;br /&gt;
Of course, we want to remove lots of code - all the immediate construction of non-core widgets that do not require special handling for a start. However - given the scope of the problem, it does not seem sensible to require some vast re-writing of each &amp;amp;amp; every dialog from day 1. ie. re-implementing all callbacks using a UNO Listener type interface would kill the task, we should stick with existing callback mechanisms and signatures.&lt;br /&gt;
&lt;br /&gt;
=== QA Test tool (Mandatory) ===&lt;br /&gt;
&lt;br /&gt;
We need to ensure either, that relevant qa testtool tests are updated to use the new UI code, or that we have a strong back-compat story here.&lt;br /&gt;
&lt;br /&gt;
=== Re-use of existing code (Desirable) ===&lt;br /&gt;
&lt;br /&gt;
Clearly the existing form code has not only a working XML serialization, but code to (re)store from that, re-using that where at all possible is important. Unfortunately this code is rather complex and difficult to work with. A life-boat approach to creating a new cleaner, smaller structure and moving dialogs across would perhaps be better.&lt;br /&gt;
&lt;br /&gt;
=== Simple new APIs (Important) ===&lt;br /&gt;
&lt;br /&gt;
The existing &amp;amp;amp; successful [[http://svn.gnome.org/viewcvs/libglade/trunk/glade/glade-xml.h?view=markup libglade API]] is a good model to build from. Identifying widgets and signals by strings seems to scale well and be more extensible than the SID based system.&lt;br /&gt;
&lt;br /&gt;
=== I18n (Important) ===&lt;br /&gt;
&lt;br /&gt;
The i18n story is important, quite possibly we&amp;#039;ll want to process any Form XML to introduce integer IDs to identify strings, feature creep into re-writing i18n might kill this project.&lt;br /&gt;
&lt;br /&gt;
=== Layout (Mandatory) ===&lt;br /&gt;
&lt;br /&gt;
Adding automatic layout, as modern toolkits do, would substantially help improve the look of the UI, it&amp;#039;s portability to other platforms, and also it&amp;#039;s look when translated.&lt;br /&gt;
&lt;br /&gt;
==== Support for platform specific layout and HIG ====&lt;br /&gt;
The UI layouting mechanism should (where possible) &amp;#039;&amp;#039;&amp;#039;automatically adapt the XML UI description to the conventions of the platform&amp;#039;&amp;#039;&amp;#039;. &lt;br /&gt;
&lt;br /&gt;
For changes that are beyond possibilities of automatic layout, there should be a possibility to add &amp;#039;&amp;#039;&amp;#039;conditional UI layout&amp;#039;&amp;#039;&amp;#039; that allows to use different XML descriptions for different platforms (only specific sub-areas of a dialog/whatever, preferably not the whole dialog).&lt;br /&gt;
&lt;br /&gt;
* Example 1: The typical &amp;quot;OK&amp;quot; and &amp;quot;Cancel&amp;quot; -buttons in a dialog are&lt;br /&gt;
** WINDOWS: &amp;quot;OK&amp;quot; (first), &amp;quot;Cancel&amp;quot; (second), both aligned to the right bottom edge of the dialog.&lt;br /&gt;
** LINUX (QT): same as Windows&lt;br /&gt;
** MAC OS X: &amp;#039;&amp;#039;&amp;#039;The OK button sits in the lower right corner&amp;#039;&amp;#039;&amp;#039;, the cancel button left to it and then all other buttons. An optional HelpButton follows a completely different look (it is a small icon with a questionmark basically). &amp;#039;&amp;#039;For more Mac OS X examples, see [[Mac OS Porter Team at WWDC 2007]]&amp;#039;&amp;#039;&lt;br /&gt;
** LINUX (GTK): same as Mac OS X&lt;br /&gt;
&lt;br /&gt;
* Example 2: Preferences dialogs&lt;br /&gt;
** WINDOWS: This type of dialogs are called &amp;quot;Settings&amp;quot; or &amp;quot;Options&amp;quot;. There is typically &amp;quot;OK&amp;quot; and &amp;quot;Cancel&amp;quot; -buttons, in that order.&lt;br /&gt;
** LINUX (GTK): This type of dialogs are called &amp;quot;Properties&amp;quot; or &amp;quot;Preferences&amp;quot;. There is typically &amp;quot;Help&amp;quot; (optional) and &amp;quot;Close&amp;quot; -buttons, in that order.&lt;br /&gt;
** MAC OS X: This type of dialogs are called &amp;quot;Preferences&amp;quot;, there are no regular buttons, optionally just a circular &amp;quot;?&amp;quot; -button for help. The dialog is instantly applies any changes, and can be closed from the window border&amp;#039;s red circular button (upper left corner). &lt;br /&gt;
&lt;br /&gt;
* Example 3: Changing values related to currently selected object in document&lt;br /&gt;
** WINDOWS: Relatively many icons/widgets in several toolbars, some context sensitive toolbars exist, but they are specific to certain object types.&lt;br /&gt;
** LINUX (GTK): similar to Windows(?).&lt;br /&gt;
** MAC OS X: In addition to one main toolbar with about 6-12 user-configurable (drag-n-drop) icons (= big buttons with text underneath), there is a separate &amp;quot;Inspector&amp;quot; widget for changing values related to the currently selected object in the document. Selecting a different object, changes the contents of the inspector widget, it does not open a new toolbar. If there are many settings, they can be divided into tab-pages within the inspector.&lt;br /&gt;
&lt;br /&gt;
=== Reduced Inheritance (Desirable) ===&lt;br /&gt;
&lt;br /&gt;
Currently all dialogs inherit (somehow) from VCL&amp;#039;s Window class. Such inheritance from virtual bases generates large vtables, and substantial inefficiency across the code-base. Wherever possible we should have a child instance of the relevant window &amp;amp;amp; use an aggregating pattern. In other cases, we may want to have a simple base class to inherit from with &amp;#039;Show&amp;#039; / &amp;#039;Hide&amp;#039; type methods that chain to the aggregated instance, and in more complex situations stick with an inherited approach.&lt;br /&gt;
&lt;br /&gt;
It would also be good to do some code size profiles of the resulting code, to optimise for reduced code size.&lt;br /&gt;
&lt;br /&gt;
=== New file format (Desirable) ===&lt;br /&gt;
&lt;br /&gt;
Deprecating the rsc code, and preferably removing it is a good goal.&lt;br /&gt;
There is a decision to be made whether the layout information is mangled with the widgets or defined alongside.&lt;br /&gt;
&lt;br /&gt;
* Having layout information and widgets mixed like in XUL&lt;br /&gt;
** pro: format is more human readable in an XML editor&lt;br /&gt;
** con: current implementation to read/store the widgets from/to XML must be altered &lt;br /&gt;
&lt;br /&gt;
* Having layout information and widgets separated in one or more XML files&lt;br /&gt;
** pro: format may be easier to use by a dialog editor (see [http://www.netbeans.org/kb/55/quickstart-gui.html NetBeans GUI Editor] using [http://java.sun.com/javase/6/docs/api/javax/swing/GroupLayout.html javax.swing.GroupLayout]&lt;br /&gt;
** pro: implementation is faster as it must not be implemented inside the existing XML code for widgets (better compatibility, lower risk of regressions)&lt;br /&gt;
** con: not as easy to edit for humans in an XML editor&lt;br /&gt;
&lt;br /&gt;
=== Easy to use Dialog Editor (Desirable) ===&lt;br /&gt;
&lt;br /&gt;
To allow User Experience to tweak the UI easily, it is necessary to implement an easy-to-use GUI editor that allows the UI to be tweaked simply.&lt;br /&gt;
&lt;br /&gt;
* NetBeans has an interactive GUI editor that also supports layouts. [http://www.netbeans.org/kb/55/quickstart-gui.html Quickstart Guide]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Ongoing work ==&lt;br /&gt;
&lt;br /&gt;
Phases of the work:&lt;br /&gt;
&lt;br /&gt;
* Implement layout / container implementations&lt;br /&gt;
* Implement new, simple, hierarchical XML serialization of widgets &amp;amp; layout&lt;br /&gt;
* Implement helper API &amp;amp; port sample dialogs&lt;br /&gt;
* Implement resource file encapsulation&lt;br /&gt;
* Implement support in dialog editor in basctl (optional)&lt;br /&gt;
* Commence porting dialogs&lt;br /&gt;
&lt;br /&gt;
=== layout / container implementations *prototype complete* ===&lt;br /&gt;
&lt;br /&gt;
Several prototypes out there to choose from. Various decisions&lt;br /&gt;
* as little new API as possible - use introspectable / self describing &amp;#039;child&amp;#039; properties&lt;br /&gt;
* only the basic box, table and alignment primitives necessary to start with&lt;br /&gt;
&lt;br /&gt;
=== new XML format *skeleton complete* ===&lt;br /&gt;
&lt;br /&gt;
This is based on the widget hierarchy, property and child property&lt;br /&gt;
names, suitable mangled. The layout information is included in-line&lt;br /&gt;
with the widgets, to avoid indirection related complexity.&lt;br /&gt;
&lt;br /&gt;
=== helper API *commenced* ===&lt;br /&gt;
&lt;br /&gt;
In order to reduce code impact, we should incrementally create thin wrapper api around the AWT UNO APIs, providing VCL-like back-compatibility logic, to substantially limit the scope of the code changes. We should provide &amp;#039;placeholders&amp;#039; whereby complex widgets can easily be inserted into the layout &amp;amp;amp; used as-before.&lt;br /&gt;
&lt;br /&gt;
We should port at least 3 sample dialogs (~1 done so far)&lt;br /&gt;
&lt;br /&gt;
=== resource file ===&lt;br /&gt;
&lt;br /&gt;
The resource file format can re-use the package code for a .zip encapsulation, though some tweaks will be necessary to populate an existing dialog parent with widgets, for those widgets that are re-used elsewhere.&lt;br /&gt;
&lt;br /&gt;
=== support in dialog editor ===&lt;br /&gt;
&lt;br /&gt;
This will require more GUI work, extending the palette and adding properties specific to layout containers.&lt;br /&gt;
&lt;br /&gt;
=== i18n ===&lt;br /&gt;
&lt;br /&gt;
* should use Java Properties files &amp;#039;ab&amp;#039; implemented this for 2.2&lt;br /&gt;
* see scripting/source/stringresource.cxx, &amp;quot;com.sun.star.comp.scripting.StringResource&amp;quot; service, and com::sun::star::resource::XStringResourceResolver.&lt;br /&gt;
* docs see &amp;quot;Technical Details&amp;quot;: near [http://api.openoffice.org/docs/DevelopersGuide/BasicAndDialogs/BasicAndDialogs.xhtml#Frame34]&lt;br /&gt;
** we should use a -far- less complex flat naming scheme for strings (IMHO etc.) perhaps &amp;#039;id&amp;#039;.property eg.&lt;br /&gt;
    &amp;lt;pushbutton id=&amp;quot;foo&amp;quot; title=&amp;quot;baa&amp;quot; message=&amp;quot;bendy&amp;quot;/&amp;gt;&lt;br /&gt;
maps to: dialog-en_US.Properties&lt;br /&gt;
    foo.title = baa&lt;br /&gt;
    foo.message = bendy&lt;br /&gt;
and: dialog-de_DE.Properties&lt;br /&gt;
    foo.title = DeutschenBaa&lt;br /&gt;
    foo.message = Kendy&lt;br /&gt;
* should also provide a simple API to fetch i18n strings on the wrapper &amp;#039;Context&amp;#039; to further deprecated .src files.&lt;br /&gt;
* we should (eventually) aggregate these many-little-files into a single .zip file per language, and a UI .zip file with the raw xml.&lt;br /&gt;
&lt;br /&gt;
=== .src converter ===&lt;br /&gt;
&lt;br /&gt;
The process of converting 360,000+ lines of .src file to XML is a fairly daunting one.&lt;br /&gt;
This is where Kohei&amp;#039;s src2xml converter can help.&lt;br /&gt;
&lt;br /&gt;
The src2xml tool currently will convert:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    ModalDialog RID_SVXDLG_ZOOM&lt;br /&gt;
    {&lt;br /&gt;
	HelpId = SID_ATTR_ZOOM ;&lt;br /&gt;
	OutputSize = TRUE ;&lt;br /&gt;
	SvLook = TRUE ;&lt;br /&gt;
	Size = MAP_APPFONT ( 202 , 116 ) ;&lt;br /&gt;
	Moveable = TRUE ;&lt;br /&gt;
&lt;br /&gt;
	FixedLine FL_ZOOM&lt;br /&gt;
	{&lt;br /&gt;
	    Pos = MAP_APPFONT ( 6 , 3 ) ;&lt;br /&gt;
	    Size = MAP_APPFONT ( 92 , 8 ) ;&lt;br /&gt;
	    Text [ en-US ] = &amp;quot;Zoom factor&amp;quot;;&lt;br /&gt;
	};&lt;br /&gt;
	RadioButton BTN_OPTIMAL&lt;br /&gt;
	{&lt;br /&gt;
	    Pos = MAP_APPFONT ( 12 , 15 ) ;&lt;br /&gt;
	    Size = MAP_APPFONT ( 80 , 10 ) ;&lt;br /&gt;
	    Text [ en-US ] = &amp;quot;~Optimal&amp;quot; ;&lt;br /&gt;
	};&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
into:&lt;br /&gt;
&amp;lt;pre&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;modaldialog &amp;quot;sizeable=true&amp;quot; help-id=&amp;quot;SID_ATTR_ZOOM&amp;quot; moveable=&amp;quot;true&amp;quot; output-size=&amp;quot;true&amp;quot;&lt;br /&gt;
		 id=&amp;quot;RID_SVXDLG_ZOOM&amp;quot; sv-look=&amp;quot;true&amp;quot;&lt;br /&gt;
		 xmlns=&amp;quot;http://openoffice.org/2007/layout&amp;quot;&lt;br /&gt;
		 xmlns:cnt=&amp;quot;http://openoffice.org/2007/layout/container&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;vbox&amp;gt;&lt;br /&gt;
	    &amp;lt;fixedline id=&amp;quot;FL_ZOOM&amp;quot; _text=&amp;quot;Zoom factor&amp;quot;/&amp;gt;&lt;br /&gt;
	    &amp;lt;radiobutton id=&amp;quot;BTN_OPTIMAL&amp;quot; _text=&amp;quot;~Optimal&amp;quot;/&amp;gt;&lt;br /&gt;
	&amp;lt;/vbox&amp;gt;&lt;br /&gt;
    &amp;lt;/modaldialog&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ie. just whacks all the widgets into a single vbox, to allow later layout work to be done by hand / in the GUI editor.&lt;br /&gt;
&lt;br /&gt;
=== Dialog Editor ===&lt;br /&gt;
&lt;br /&gt;
This should be written using our VCL-like wrapper API wherever possible - as a means to extend &amp;amp;amp; mature the wrapper API itself. The code should be hosted in our &amp;#039;test&amp;#039; application initially (due to evil UNO bootstrapping problems to horrible to detail).&lt;br /&gt;
Steps:&lt;br /&gt;
* introspect the layout hierarchy, and write out the containers and all their properties as XML. This would currently be stymied by the lack of interface capabilities to introspect children; thus adding a method &amp;lt;code&amp;gt;sequence&amp;lt;XLayoutConstrains&amp;gt; getChildren()&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;layout/source/api/com/sun/star/awt/XInterfaceContainer&amp;lt;/code&amp;gt; would be rather helpful.&lt;br /&gt;
* a palette should be created added, and widget selection &amp;amp;amp; creation allowed&lt;br /&gt;
** requires construction of a &amp;#039;placeholder&amp;#039; widget to reserve space for adding new widgets.&lt;br /&gt;
** icons can be re-used from existing OO.o toolbars for this.&lt;br /&gt;
** we should present properties (initially) generically&lt;br /&gt;
*** ie. by introspection determine a properties&amp;#039; type and hence what kind of control to present.&lt;br /&gt;
*** partitioning of child properties &amp;amp;amp; widget properties would also be useful perhaps.&lt;br /&gt;
glade2, or stetic gives a good model of how this can be done. A high level of polish is not required.&lt;br /&gt;
&lt;br /&gt;
=== toolkit/ fixing ===&lt;br /&gt;
&lt;br /&gt;
The toolkit code is fairly incomplete &amp;amp;amp; curious in it&amp;#039;s implementation; we need to extend it where necessary to provide a high behavioral fidelity as we switch from wrapper API to UNO awt to VCL and back.&lt;br /&gt;
&lt;br /&gt;
=== QA test tool ===&lt;br /&gt;
&lt;br /&gt;
An audit of qatesttool interaction with dialogs needs to be done, to identify entry points, and resource identification. If necessary the wrapper API &amp;amp;amp; awt needs to propagate &amp;#039;SmartIds&amp;#039; (or some other identifiers) through to the VCL widgets.&lt;br /&gt;
&lt;br /&gt;
[[Category:VCL]]&lt;br /&gt;
[[Category:GUI]]&lt;/div&gt;</summary>
		<author><name>Jcn</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=VCL_UI_Rework&amp;diff=72196</id>
		<title>VCL UI Rework</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=VCL_UI_Rework&amp;diff=72196"/>
		<updated>2008-04-01T13:43:48Z</updated>

		<summary type="html">&lt;p&gt;Jcn: Update info about src2xml converter&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Rational ==&lt;br /&gt;
&lt;br /&gt;
Currently all dialogs (along with most translated strings) are stored in a rather unusual binary resource file format, that has not had much love in the last decade. We need to write some new code that separates the process of designing &amp;amp; laying out the UI from the code - to allow UE to make our UI more beautiful, and allow future re-factoring. The existing Basic GUI dialog editor and it&amp;#039;s XML format should be re-used, a simple C++ compatibility API created, and a number of dialogs converted to the new format.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
There have already been several attempts at adding features to VCL, and of course people have different requirements, an initial synthesis of requirements is perhaps helpful. Please do add subsequent constraints, or comments thereof.&lt;br /&gt;
&lt;br /&gt;
=== Simple code changes (Mandatory) ===&lt;br /&gt;
&lt;br /&gt;
Of course, we want to remove lots of code - all the immediate construction of non-core widgets that do not require special handling for a start. However - given the scope of the problem, it does not seem sensible to require some vast re-writing of each &amp;amp;amp; every dialog from day 1. ie. re-implementing all callbacks using a UNO Listener type interface would kill the task, we should stick with existing callback mechanisms and signatures.&lt;br /&gt;
&lt;br /&gt;
=== QA Test tool (Mandatory) ===&lt;br /&gt;
&lt;br /&gt;
We need to ensure either, that relevant qa testtool tests are updated to use the new UI code, or that we have a strong back-compat story here.&lt;br /&gt;
&lt;br /&gt;
=== Re-use of existing code (Desirable) ===&lt;br /&gt;
&lt;br /&gt;
Clearly the existing form code has not only a working XML serialization, but code to (re)store from that, re-using that where at all possible is important. Unfortunately this code is rather complex and difficult to work with. A life-boat approach to creating a new cleaner, smaller structure and moving dialogs across would perhaps be better.&lt;br /&gt;
&lt;br /&gt;
=== Simple new APIs (Important) ===&lt;br /&gt;
&lt;br /&gt;
The existing &amp;amp;amp; successful [[http://svn.gnome.org/viewcvs/libglade/trunk/glade/glade-xml.h?view=markup libglade API]] is a good model to build from. Identifying widgets and signals by strings seems to scale well and be more extensible than the SID based system.&lt;br /&gt;
&lt;br /&gt;
=== I18n (Important) ===&lt;br /&gt;
&lt;br /&gt;
The i18n story is important, quite possibly we&amp;#039;ll want to process any Form XML to introduce integer IDs to identify strings, feature creep into re-writing i18n might kill this project.&lt;br /&gt;
&lt;br /&gt;
=== Layout (Mandatory) ===&lt;br /&gt;
&lt;br /&gt;
Adding automatic layout, as modern toolkits do, would substantially help improve the look of the UI, it&amp;#039;s portability to other platforms, and also it&amp;#039;s look when translated.&lt;br /&gt;
&lt;br /&gt;
==== Support for platform specific layout and HIG ====&lt;br /&gt;
The UI layouting mechanism should (where possible) &amp;#039;&amp;#039;&amp;#039;automatically adapt the XML UI description to the conventions of the platform&amp;#039;&amp;#039;&amp;#039;. &lt;br /&gt;
&lt;br /&gt;
For changes that are beyond possibilities of automatic layout, there should be a possibility to add &amp;#039;&amp;#039;&amp;#039;conditional UI layout&amp;#039;&amp;#039;&amp;#039; that allows to use different XML descriptions for different platforms (only specific sub-areas of a dialog/whatever, preferably not the whole dialog).&lt;br /&gt;
&lt;br /&gt;
* Example 1: The typical &amp;quot;OK&amp;quot; and &amp;quot;Cancel&amp;quot; -buttons in a dialog are&lt;br /&gt;
** WINDOWS: &amp;quot;OK&amp;quot; (first), &amp;quot;Cancel&amp;quot; (second), both aligned to the right bottom edge of the dialog.&lt;br /&gt;
** LINUX (QT): same as Windows&lt;br /&gt;
** MAC OS X: &amp;#039;&amp;#039;&amp;#039;The OK button sits in the lower right corner&amp;#039;&amp;#039;&amp;#039;, the cancel button left to it and then all other buttons. An optional HelpButton follows a completely different look (it is a small icon with a questionmark basically). &amp;#039;&amp;#039;For more Mac OS X examples, see [[Mac OS Porter Team at WWDC 2007]]&amp;#039;&amp;#039;&lt;br /&gt;
** LINUX (GTK): same as Mac OS X&lt;br /&gt;
&lt;br /&gt;
* Example 2: Preferences dialogs&lt;br /&gt;
** WINDOWS: This type of dialogs are called &amp;quot;Settings&amp;quot; or &amp;quot;Options&amp;quot;. There is typically &amp;quot;OK&amp;quot; and &amp;quot;Cancel&amp;quot; -buttons, in that order.&lt;br /&gt;
** LINUX (GTK): This type of dialogs are called &amp;quot;Properties&amp;quot; or &amp;quot;Preferences&amp;quot;. There is typically &amp;quot;Help&amp;quot; (optional) and &amp;quot;Close&amp;quot; -buttons, in that order.&lt;br /&gt;
** MAC OS X: This type of dialogs are called &amp;quot;Preferences&amp;quot;, there are no regular buttons, optionally just a circular &amp;quot;?&amp;quot; -button for help. The dialog is instantly applies any changes, and can be closed from the window border&amp;#039;s red circular button (upper left corner). &lt;br /&gt;
&lt;br /&gt;
* Example 3: Changing values related to currently selected object in document&lt;br /&gt;
** WINDOWS: Relatively many icons/widgets in several toolbars, some context sensitive toolbars exist, but they are specific to certain object types.&lt;br /&gt;
** LINUX (GTK): similar to Windows(?).&lt;br /&gt;
** MAC OS X: In addition to one main toolbar with about 6-12 user-configurable (drag-n-drop) icons (= big buttons with text underneath), there is a separate &amp;quot;Inspector&amp;quot; widget for changing values related to the currently selected object in the document. Selecting a different object, changes the contents of the inspector widget, it does not open a new toolbar. If there are many settings, they can be divided into tab-pages within the inspector.&lt;br /&gt;
&lt;br /&gt;
=== Reduced Inheritance (Desirable) ===&lt;br /&gt;
&lt;br /&gt;
Currently all dialogs inherit (somehow) from VCL&amp;#039;s Window class. Such inheritance from virtual bases generates large vtables, and substantial inefficiency across the code-base. Wherever possible we should have a child instance of the relevant window &amp;amp;amp; use an aggregating pattern. In other cases, we may want to have a simple base class to inherit from with &amp;#039;Show&amp;#039; / &amp;#039;Hide&amp;#039; type methods that chain to the aggregated instance, and in more complex situations stick with an inherited approach.&lt;br /&gt;
&lt;br /&gt;
It would also be good to do some code size profiles of the resulting code, to optimise for reduced code size.&lt;br /&gt;
&lt;br /&gt;
=== New file format (Desirable) ===&lt;br /&gt;
&lt;br /&gt;
Deprecating the rsc code, and preferably removing it is a good goal.&lt;br /&gt;
There is a decision to be made whether the layout information is mangled with the widgets or defined alongside.&lt;br /&gt;
&lt;br /&gt;
* Having layout information and widgets mixed like in XUL&lt;br /&gt;
** pro: format is more human readable in an XML editor&lt;br /&gt;
** con: current implementation to read/store the widgets from/to XML must be altered &lt;br /&gt;
&lt;br /&gt;
* Having layout information and widgets separated in one or more XML files&lt;br /&gt;
** pro: format may be easier to use by a dialog editor (see [http://www.netbeans.org/kb/55/quickstart-gui.html NetBeans GUI Editor] using [http://java.sun.com/javase/6/docs/api/javax/swing/GroupLayout.html javax.swing.GroupLayout]&lt;br /&gt;
** pro: implementation is faster as it must not be implemented inside the existing XML code for widgets (better compatibility, lower risk of regressions)&lt;br /&gt;
** con: not as easy to edit for humans in an XML editor&lt;br /&gt;
&lt;br /&gt;
=== Easy to use Dialog Editor (Desirable) ===&lt;br /&gt;
&lt;br /&gt;
To allow User Experience to tweak the UI easily, it is necessary to implement an easy-to-use GUI editor that allows the UI to be tweaked simply.&lt;br /&gt;
&lt;br /&gt;
* NetBeans has an interactive GUI editor that also supports layouts. [http://www.netbeans.org/kb/55/quickstart-gui.html Quickstart Guide]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Ongoing work ==&lt;br /&gt;
&lt;br /&gt;
Phases of the work:&lt;br /&gt;
&lt;br /&gt;
* Implement layout / container implementations&lt;br /&gt;
* Implement new, simple, hierarchical XML serialization of widgets &amp;amp; layout&lt;br /&gt;
* Implement helper API &amp;amp; port sample dialogs&lt;br /&gt;
* Implement resource file encapsulation&lt;br /&gt;
* Implement support in dialog editor in basctl (optional)&lt;br /&gt;
* Commence porting dialogs&lt;br /&gt;
&lt;br /&gt;
=== layout / container implementations *prototype complete* ===&lt;br /&gt;
&lt;br /&gt;
Several prototypes out there to choose from. Various decisions&lt;br /&gt;
* as little new API as possible - use introspectable / self describing &amp;#039;child&amp;#039; properties&lt;br /&gt;
* only the basic box, table and alignment primitives necessary to start with&lt;br /&gt;
&lt;br /&gt;
=== new XML format *skeleton complete* ===&lt;br /&gt;
&lt;br /&gt;
This is based on the widget hierarchy, property and child property&lt;br /&gt;
names, suitable mangled. The layout information is included in-line&lt;br /&gt;
with the widgets, to avoid indirection related complexity.&lt;br /&gt;
&lt;br /&gt;
=== helper API *commenced* ===&lt;br /&gt;
&lt;br /&gt;
In order to reduce code impact, we should incrementally create thin wrapper api around the AWT UNO APIs, providing VCL-like back-compatibility logic, to substantially limit the scope of the code changes. We should provide &amp;#039;placeholders&amp;#039; whereby complex widgets can easily be inserted into the layout &amp;amp;amp; used as-before.&lt;br /&gt;
&lt;br /&gt;
We should port at least 3 sample dialogs (~1 done so far)&lt;br /&gt;
&lt;br /&gt;
=== resource file ===&lt;br /&gt;
&lt;br /&gt;
The resource file format can re-use the package code for a .zip encapsulation, though some tweaks will be necessary to populate an existing dialog parent with widgets, for those widgets that are re-used elsewhere.&lt;br /&gt;
&lt;br /&gt;
=== support in dialog editor ===&lt;br /&gt;
&lt;br /&gt;
This will require more GUI work, extending the palette and adding properties specific to layout containers.&lt;br /&gt;
&lt;br /&gt;
=== i18n ===&lt;br /&gt;
&lt;br /&gt;
* should use Java Properties files &amp;#039;ab&amp;#039; implemented this for 2.2&lt;br /&gt;
* see scripting/source/stringresource.cxx, &amp;quot;com.sun.star.comp.scripting.StringResource&amp;quot; service, and com::sun::star::resource::XStringResourceResolver.&lt;br /&gt;
* docs see &amp;quot;Technical Details&amp;quot;: near [http://api.openoffice.org/docs/DevelopersGuide/BasicAndDialogs/BasicAndDialogs.xhtml#Frame34]&lt;br /&gt;
** we should use a -far- less complex flat naming scheme for strings (IMHO etc.) perhaps &amp;#039;id&amp;#039;.property eg.&lt;br /&gt;
    &amp;lt;pushbutton id=&amp;quot;foo&amp;quot; title=&amp;quot;baa&amp;quot; message=&amp;quot;bendy&amp;quot;/&amp;gt;&lt;br /&gt;
maps to: dialog-en_US.Properties&lt;br /&gt;
    foo.title = baa&lt;br /&gt;
    foo.message = bendy&lt;br /&gt;
and: dialog-de_DE.Properties&lt;br /&gt;
    foo.title = DeutschenBaa&lt;br /&gt;
    foo.message = Kendy&lt;br /&gt;
* should also provide a simple API to fetch i18n strings on the wrapper &amp;#039;Context&amp;#039; to further deprecated .src files.&lt;br /&gt;
* we should (eventually) aggregate these many-little-files into a single .zip file per language, and a UI .zip file with the raw xml.&lt;br /&gt;
&lt;br /&gt;
=== .src converter ===&lt;br /&gt;
&lt;br /&gt;
The process of converting 360,000+ lines of .src file to XML is a fairly daunting one.&lt;br /&gt;
This is where Kohei&amp;#039;s src2xml converter can help.&lt;br /&gt;
&lt;br /&gt;
The src2xml tool currently will convert&lt;br /&gt;
    ModalDialog RID_SVXDLG_ZOOM&lt;br /&gt;
    {&lt;br /&gt;
	HelpId = SID_ATTR_ZOOM ;&lt;br /&gt;
	OutputSize = TRUE ;&lt;br /&gt;
	SvLook = TRUE ;&lt;br /&gt;
	Size = MAP_APPFONT ( 202 , 116 ) ;&lt;br /&gt;
	Moveable = TRUE ;&lt;br /&gt;
&lt;br /&gt;
	FixedLine FL_ZOOM&lt;br /&gt;
	{&lt;br /&gt;
	    Pos = MAP_APPFONT ( 6 , 3 ) ;&lt;br /&gt;
	    Size = MAP_APPFONT ( 92 , 8 ) ;&lt;br /&gt;
	    Text [ en-US ] = &amp;quot;Zoom factor&amp;quot;;&lt;br /&gt;
	};&lt;br /&gt;
	RadioButton BTN_OPTIMAL&lt;br /&gt;
	{&lt;br /&gt;
	    Pos = MAP_APPFONT ( 12 , 15 ) ;&lt;br /&gt;
	    Size = MAP_APPFONT ( 80 , 10 ) ;&lt;br /&gt;
	    Text [ en-US ] = &amp;quot;~Optimal&amp;quot; ;&lt;br /&gt;
	};&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
into:&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;modaldialog &amp;quot;sizeable=true&amp;quot; help-id=&amp;quot;SID_ATTR_ZOOM&amp;quot; moveable=&amp;quot;true&amp;quot; output-size=&amp;quot;true&amp;quot;&lt;br /&gt;
		 id=&amp;quot;RID_SVXDLG_ZOOM&amp;quot; sv-look=&amp;quot;true&amp;quot;&lt;br /&gt;
		 xmlns=&amp;quot;http://openoffice.org/2007/layout&amp;quot;&lt;br /&gt;
		 xmlns:cnt=&amp;quot;http://openoffice.org/2007/layout/container&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;vbox&amp;gt;&lt;br /&gt;
	    &amp;lt;fixedline id=&amp;quot;FL_ZOOM&amp;quot; _text=&amp;quot;Zoom factor&amp;quot;/&amp;gt;&lt;br /&gt;
	    &amp;lt;radiobutton id=&amp;quot;BTN_OPTIMAL&amp;quot; _text=&amp;quot;~Optimal&amp;quot;/&amp;gt;&lt;br /&gt;
	&amp;lt;/vbox&amp;gt;&lt;br /&gt;
    &amp;lt;/modaldialog&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ie. just whacks all the widgets into a single vbox, to allow later layout work to be done by hand / in the GUI editor.&lt;br /&gt;
&lt;br /&gt;
=== Dialog Editor ===&lt;br /&gt;
&lt;br /&gt;
This should be written using our VCL-like wrapper API wherever possible - as a means to extend &amp;amp;amp; mature the wrapper API itself. The code should be hosted in our &amp;#039;test&amp;#039; application initially (due to evil UNO bootstrapping problems to horrible to detail).&lt;br /&gt;
Steps:&lt;br /&gt;
* introspect the layout hierarchy, and write out the containers and all their properties as XML. This would currently be stymied by the lack of interface capabilities to introspect children; thus adding a method &amp;lt;code&amp;gt;sequence&amp;lt;XLayoutConstrains&amp;gt; getChildren()&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;layout/source/api/com/sun/star/awt/XInterfaceContainer&amp;lt;/code&amp;gt; would be rather helpful.&lt;br /&gt;
* a palette should be created added, and widget selection &amp;amp;amp; creation allowed&lt;br /&gt;
** requires construction of a &amp;#039;placeholder&amp;#039; widget to reserve space for adding new widgets.&lt;br /&gt;
** icons can be re-used from existing OO.o toolbars for this.&lt;br /&gt;
** we should present properties (initially) generically&lt;br /&gt;
*** ie. by introspection determine a properties&amp;#039; type and hence what kind of control to present.&lt;br /&gt;
*** partitioning of child properties &amp;amp;amp; widget properties would also be useful perhaps.&lt;br /&gt;
glade2, or stetic gives a good model of how this can be done. A high level of polish is not required.&lt;br /&gt;
&lt;br /&gt;
=== toolkit/ fixing ===&lt;br /&gt;
&lt;br /&gt;
The toolkit code is fairly incomplete &amp;amp;amp; curious in it&amp;#039;s implementation; we need to extend it where necessary to provide a high behavioral fidelity as we switch from wrapper API to UNO awt to VCL and back.&lt;br /&gt;
&lt;br /&gt;
=== QA test tool ===&lt;br /&gt;
&lt;br /&gt;
An audit of qatesttool interaction with dialogs needs to be done, to identify entry points, and resource identification. If necessary the wrapper API &amp;amp;amp; awt needs to propagate &amp;#039;SmartIds&amp;#039; (or some other identifiers) through to the VCL widgets.&lt;br /&gt;
&lt;br /&gt;
[[Category:VCL]]&lt;br /&gt;
[[Category:GUI]]&lt;/div&gt;</summary>
		<author><name>Jcn</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=VCL_UI_Rework&amp;diff=72142</id>
		<title>VCL UI Rework</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=VCL_UI_Rework&amp;diff=72142"/>
		<updated>2008-04-01T12:33:31Z</updated>

		<summary type="html">&lt;p&gt;Jcn: update i18n design&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Rational ==&lt;br /&gt;
&lt;br /&gt;
Currently all dialogs (along with most translated strings) are stored in a rather unusual binary resource file format, that has not had much love in the last decade. We need to write some new code that separates the process of designing &amp;amp; laying out the UI from the code - to allow UE to make our UI more beautiful, and allow future re-factoring. The existing Basic GUI dialog editor and it&amp;#039;s XML format should be re-used, a simple C++ compatibility API created, and a number of dialogs converted to the new format.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
There have already been several attempts at adding features to VCL, and of course people have different requirements, an initial synthesis of requirements is perhaps helpful. Please do add subsequent constraints, or comments thereof.&lt;br /&gt;
&lt;br /&gt;
=== Simple code changes (Mandatory) ===&lt;br /&gt;
&lt;br /&gt;
Of course, we want to remove lots of code - all the immediate construction of non-core widgets that do not require special handling for a start. However - given the scope of the problem, it does not seem sensible to require some vast re-writing of each &amp;amp;amp; every dialog from day 1. ie. re-implementing all callbacks using a UNO Listener type interface would kill the task, we should stick with existing callback mechanisms and signatures.&lt;br /&gt;
&lt;br /&gt;
=== QA Test tool (Mandatory) ===&lt;br /&gt;
&lt;br /&gt;
We need to ensure either, that relevant qa testtool tests are updated to use the new UI code, or that we have a strong back-compat story here.&lt;br /&gt;
&lt;br /&gt;
=== Re-use of existing code (Desirable) ===&lt;br /&gt;
&lt;br /&gt;
Clearly the existing form code has not only a working XML serialization, but code to (re)store from that, re-using that where at all possible is important. Unfortunately this code is rather complex and difficult to work with. A life-boat approach to creating a new cleaner, smaller structure and moving dialogs across would perhaps be better.&lt;br /&gt;
&lt;br /&gt;
=== Simple new APIs (Important) ===&lt;br /&gt;
&lt;br /&gt;
The existing &amp;amp;amp; successful [[http://svn.gnome.org/viewcvs/libglade/trunk/glade/glade-xml.h?view=markup libglade API]] is a good model to build from. Identifying widgets and signals by strings seems to scale well and be more extensible than the SID based system.&lt;br /&gt;
&lt;br /&gt;
=== I18n (Important) ===&lt;br /&gt;
&lt;br /&gt;
The i18n story is important, quite possibly we&amp;#039;ll want to process any Form XML to introduce integer IDs to identify strings, feature creep into re-writing i18n might kill this project.&lt;br /&gt;
&lt;br /&gt;
=== Layout (Mandatory) ===&lt;br /&gt;
&lt;br /&gt;
Adding automatic layout, as modern toolkits do, would substantially help improve the look of the UI, it&amp;#039;s portability to other platforms, and also it&amp;#039;s look when translated.&lt;br /&gt;
&lt;br /&gt;
==== Support for platform specific layout and HIG ====&lt;br /&gt;
The UI layouting mechanism should (where possible) &amp;#039;&amp;#039;&amp;#039;automatically adapt the XML UI description to the conventions of the platform&amp;#039;&amp;#039;&amp;#039;. &lt;br /&gt;
&lt;br /&gt;
For changes that are beyond possibilities of automatic layout, there should be a possibility to add &amp;#039;&amp;#039;&amp;#039;conditional UI layout&amp;#039;&amp;#039;&amp;#039; that allows to use different XML descriptions for different platforms (only specific sub-areas of a dialog/whatever, preferably not the whole dialog).&lt;br /&gt;
&lt;br /&gt;
* Example 1: The typical &amp;quot;OK&amp;quot; and &amp;quot;Cancel&amp;quot; -buttons in a dialog are&lt;br /&gt;
** WINDOWS: &amp;quot;OK&amp;quot; (first), &amp;quot;Cancel&amp;quot; (second), both aligned to the right bottom edge of the dialog.&lt;br /&gt;
** LINUX (QT): same as Windows&lt;br /&gt;
** MAC OS X: &amp;#039;&amp;#039;&amp;#039;The OK button sits in the lower right corner&amp;#039;&amp;#039;&amp;#039;, the cancel button left to it and then all other buttons. An optional HelpButton follows a completely different look (it is a small icon with a questionmark basically). &amp;#039;&amp;#039;For more Mac OS X examples, see [[Mac OS Porter Team at WWDC 2007]]&amp;#039;&amp;#039;&lt;br /&gt;
** LINUX (GTK): same as Mac OS X&lt;br /&gt;
&lt;br /&gt;
* Example 2: Preferences dialogs&lt;br /&gt;
** WINDOWS: This type of dialogs are called &amp;quot;Settings&amp;quot; or &amp;quot;Options&amp;quot;. There is typically &amp;quot;OK&amp;quot; and &amp;quot;Cancel&amp;quot; -buttons, in that order.&lt;br /&gt;
** LINUX (GTK): This type of dialogs are called &amp;quot;Properties&amp;quot; or &amp;quot;Preferences&amp;quot;. There is typically &amp;quot;Help&amp;quot; (optional) and &amp;quot;Close&amp;quot; -buttons, in that order.&lt;br /&gt;
** MAC OS X: This type of dialogs are called &amp;quot;Preferences&amp;quot;, there are no regular buttons, optionally just a circular &amp;quot;?&amp;quot; -button for help. The dialog is instantly applies any changes, and can be closed from the window border&amp;#039;s red circular button (upper left corner). &lt;br /&gt;
&lt;br /&gt;
* Example 3: Changing values related to currently selected object in document&lt;br /&gt;
** WINDOWS: Relatively many icons/widgets in several toolbars, some context sensitive toolbars exist, but they are specific to certain object types.&lt;br /&gt;
** LINUX (GTK): similar to Windows(?).&lt;br /&gt;
** MAC OS X: In addition to one main toolbar with about 6-12 user-configurable (drag-n-drop) icons (= big buttons with text underneath), there is a separate &amp;quot;Inspector&amp;quot; widget for changing values related to the currently selected object in the document. Selecting a different object, changes the contents of the inspector widget, it does not open a new toolbar. If there are many settings, they can be divided into tab-pages within the inspector.&lt;br /&gt;
&lt;br /&gt;
=== Reduced Inheritance (Desirable) ===&lt;br /&gt;
&lt;br /&gt;
Currently all dialogs inherit (somehow) from VCL&amp;#039;s Window class. Such inheritance from virtual bases generates large vtables, and substantial inefficiency across the code-base. Wherever possible we should have a child instance of the relevant window &amp;amp;amp; use an aggregating pattern. In other cases, we may want to have a simple base class to inherit from with &amp;#039;Show&amp;#039; / &amp;#039;Hide&amp;#039; type methods that chain to the aggregated instance, and in more complex situations stick with an inherited approach.&lt;br /&gt;
&lt;br /&gt;
It would also be good to do some code size profiles of the resulting code, to optimise for reduced code size.&lt;br /&gt;
&lt;br /&gt;
=== New file format (Desirable) ===&lt;br /&gt;
&lt;br /&gt;
Deprecating the rsc code, and preferably removing it is a good goal.&lt;br /&gt;
There is a decision to be made whether the layout information is mangled with the widgets or defined alongside.&lt;br /&gt;
&lt;br /&gt;
* Having layout information and widgets mixed like in XUL&lt;br /&gt;
** pro: format is more human readable in an XML editor&lt;br /&gt;
** con: current implementation to read/store the widgets from/to XML must be altered &lt;br /&gt;
&lt;br /&gt;
* Having layout information and widgets separated in one or more XML files&lt;br /&gt;
** pro: format may be easier to use by a dialog editor (see [http://www.netbeans.org/kb/55/quickstart-gui.html NetBeans GUI Editor] using [http://java.sun.com/javase/6/docs/api/javax/swing/GroupLayout.html javax.swing.GroupLayout]&lt;br /&gt;
** pro: implementation is faster as it must not be implemented inside the existing XML code for widgets (better compatibility, lower risk of regressions)&lt;br /&gt;
** con: not as easy to edit for humans in an XML editor&lt;br /&gt;
&lt;br /&gt;
=== Easy to use Dialog Editor (Desirable) ===&lt;br /&gt;
&lt;br /&gt;
To allow User Experience to tweak the UI easily, it is necessary to implement an easy-to-use GUI editor that allows the UI to be tweaked simply.&lt;br /&gt;
&lt;br /&gt;
* NetBeans has an interactive GUI editor that also supports layouts. [http://www.netbeans.org/kb/55/quickstart-gui.html Quickstart Guide]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Ongoing work ==&lt;br /&gt;
&lt;br /&gt;
Phases of the work:&lt;br /&gt;
&lt;br /&gt;
* Implement layout / container implementations&lt;br /&gt;
* Implement new, simple, hierarchical XML serialization of widgets &amp;amp; layout&lt;br /&gt;
* Implement helper API &amp;amp; port sample dialogs&lt;br /&gt;
* Implement resource file encapsulation&lt;br /&gt;
* Implement support in dialog editor in basctl (optional)&lt;br /&gt;
* Commence porting dialogs&lt;br /&gt;
&lt;br /&gt;
=== layout / container implementations *prototype complete* ===&lt;br /&gt;
&lt;br /&gt;
Several prototypes out there to choose from. Various decisions&lt;br /&gt;
* as little new API as possible - use introspectable / self describing &amp;#039;child&amp;#039; properties&lt;br /&gt;
* only the basic box, table and alignment primitives necessary to start with&lt;br /&gt;
&lt;br /&gt;
=== new XML format *skeleton complete* ===&lt;br /&gt;
&lt;br /&gt;
This is based on the widget hierarchy, property and child property&lt;br /&gt;
names, suitable mangled. The layout information is included in-line&lt;br /&gt;
with the widgets, to avoid indirection related complexity.&lt;br /&gt;
&lt;br /&gt;
=== helper API *commenced* ===&lt;br /&gt;
&lt;br /&gt;
In order to reduce code impact, we should incrementally create thin wrapper api around the AWT UNO APIs, providing VCL-like back-compatibility logic, to substantially limit the scope of the code changes. We should provide &amp;#039;placeholders&amp;#039; whereby complex widgets can easily be inserted into the layout &amp;amp;amp; used as-before.&lt;br /&gt;
&lt;br /&gt;
We should port at least 3 sample dialogs (~1 done so far)&lt;br /&gt;
&lt;br /&gt;
=== resource file ===&lt;br /&gt;
&lt;br /&gt;
The resource file format can re-use the package code for a .zip encapsulation, though some tweaks will be necessary to populate an existing dialog parent with widgets, for those widgets that are re-used elsewhere.&lt;br /&gt;
&lt;br /&gt;
=== support in dialog editor ===&lt;br /&gt;
&lt;br /&gt;
This will require more GUI work, extending the palette and adding properties specific to layout containers.&lt;br /&gt;
&lt;br /&gt;
=== i18n ===&lt;br /&gt;
&lt;br /&gt;
* mark i18n attributes by prepending an underscore: &amp;lt;radiobutton id=&amp;quot;RB1&amp;quot; _label=&amp;quot;One&amp;quot;/&amp;gt;&lt;br /&gt;
* implement new transex3 tool to extract strings from template XML into ubiquitous localize.sdf files and produce i18n tree of translated XMLs at compile time&lt;br /&gt;
* use simple read-right translation&lt;br /&gt;
* eventually read XMLs from per-language zip files: share/layout/de.zip, share/layout/nl.zip etc. &lt;br /&gt;
&lt;br /&gt;
=== .src converter ===&lt;br /&gt;
&lt;br /&gt;
The process of converting 360,000+ lines of .src file to XML is a fairly daunting one. This could be made substantially easier by writing a simple perl script to help convert. While it would (perhaps) be possible to re-use the existing &amp;lt;code&amp;gt;rsc/&amp;lt;/code&amp;gt; parser, that has several disadvantages:&lt;br /&gt;
* it works on pre-processed output, whereby our descriptive names have been lost &amp;amp;amp; turned into numbers&lt;br /&gt;
* it has no idea at all of hierarchy - at least &amp;#039;&amp;#039;&amp;#039;some&amp;#039;&amp;#039;&amp;#039; of that is available in the .src files&lt;br /&gt;
* the code is pretty tangled.&lt;br /&gt;
&lt;br /&gt;
We need something that will convert:&lt;br /&gt;
    ModalDialog RID_SVXDLG_ZOOM&lt;br /&gt;
    {&lt;br /&gt;
        HelpId = SID_ATTR_ZOOM ;&lt;br /&gt;
        OutputSize = TRUE ;&lt;br /&gt;
        SvLook = TRUE ;&lt;br /&gt;
        Size = MAP_APPFONT ( 160 , 142 ) ;&lt;br /&gt;
        Moveable = TRUE ;&lt;br /&gt;
        RadioButton BTN_200&lt;br /&gt;
        {&lt;br /&gt;
            Pos = MAP_APPFONT ( 12 , 53 ) ;&lt;br /&gt;
            Size = MAP_APPFONT ( 80 , 10 ) ;&lt;br /&gt;
            Text = &amp;quot;~200 %&amp;quot; ;&lt;br /&gt;
        };&lt;br /&gt;
        RadioButton BTN_150&lt;br /&gt;
        {&lt;br /&gt;
            Pos = MAP_APPFONT ( 12 , 66 ) ;&lt;br /&gt;
            Size = MAP_APPFONT ( 80 , 10 ) ;&lt;br /&gt;
            Text = &amp;quot;15~0 %&amp;quot; ;&lt;br /&gt;
        };&lt;br /&gt;
into:&lt;br /&gt;
    &amp;lt;modaldialog xmlns=&amp;quot;http://openoffice.org/2007/layout&amp;quot;&lt;br /&gt;
                 xmlns:cnt=&amp;quot;http://openoffice.org/2007/layout/container&amp;quot;&lt;br /&gt;
                 id=&amp;quot;rid-svxdlg-zoom&amp;quot; help-id=&amp;quot;sid-attr-zoome&amp;quot;&lt;br /&gt;
                 sv-look=&amp;quot;true&amp;quot; moveable=&amp;quot;true&amp;quot;&lt;br /&gt;
                 border=&amp;quot;true&amp;quot; sizeable=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;vbox&amp;gt;&lt;br /&gt;
            &amp;lt;radiobutton group=&amp;quot;zoom&amp;quot; id=&amp;quot;btn-200&amp;quot; label=&amp;quot;~200 %&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;radiobutton group=&amp;quot;zoom&amp;quot; id=&amp;quot;btn-150&amp;quot;label=&amp;quot;15~0 %&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/vbox&amp;gt;&lt;br /&gt;
    &amp;lt;/modaldialog&amp;gt;&lt;br /&gt;
ie. just whack all the widgets into a single vbox, to allow later layout work to be done by hand / in the GUI editor.&lt;br /&gt;
&lt;br /&gt;
=== Dialog Editor ===&lt;br /&gt;
&lt;br /&gt;
This should be written using our VCL-like wrapper API wherever possible - as a means to extend &amp;amp;amp; mature the wrapper API itself. The code should be hosted in our &amp;#039;test&amp;#039; application initially (due to evil UNO bootstrapping problems to horrible to detail).&lt;br /&gt;
Steps:&lt;br /&gt;
* introspect the layout hierarchy, and write out the containers and all their properties as XML. This would currently be stymied by the lack of interface capabilities to introspect children; thus adding a method &amp;lt;code&amp;gt;sequence&amp;lt;XLayoutConstrains&amp;gt; getChildren()&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;layout/source/api/com/sun/star/awt/XInterfaceContainer&amp;lt;/code&amp;gt; would be rather helpful.&lt;br /&gt;
* a palette should be created added, and widget selection &amp;amp;amp; creation allowed&lt;br /&gt;
** requires construction of a &amp;#039;placeholder&amp;#039; widget to reserve space for adding new widgets.&lt;br /&gt;
** icons can be re-used from existing OO.o toolbars for this.&lt;br /&gt;
** we should present properties (initially) generically&lt;br /&gt;
*** ie. by introspection determine a properties&amp;#039; type and hence what kind of control to present.&lt;br /&gt;
*** partitioning of child properties &amp;amp;amp; widget properties would also be useful perhaps.&lt;br /&gt;
glade2, or stetic gives a good model of how this can be done. A high level of polish is not required.&lt;br /&gt;
&lt;br /&gt;
=== toolkit/ fixing ===&lt;br /&gt;
&lt;br /&gt;
The toolkit code is fairly incomplete &amp;amp;amp; curious in it&amp;#039;s implementation; we need to extend it where necessary to provide a high behavioral fidelity as we switch from wrapper API to UNO awt to VCL and back.&lt;br /&gt;
&lt;br /&gt;
=== QA test tool ===&lt;br /&gt;
&lt;br /&gt;
An audit of qatesttool interaction with dialogs needs to be done, to identify entry points, and resource identification. If necessary the wrapper API &amp;amp;amp; awt needs to propagate &amp;#039;SmartIds&amp;#039; (or some other identifiers) through to the VCL widgets.&lt;br /&gt;
&lt;br /&gt;
[[Category:VCL]]&lt;br /&gt;
[[Category:GUI]]&lt;/div&gt;</summary>
		<author><name>Jcn</name></author>
	</entry>
</feed>