C++ Component

From Apache OpenOffice Wiki
Jump to: navigation, search
  • C++ Component



The first step for the C++ component is to define a language-independent interface, so that the UNO object can communicate with others. The IDL specification for the component defines one interface my_module.XSomething and two old-style services implementing this interface (if new-style services were used instead, the example would not be much different). In addition, the second service called my_module.MyService2 implements the com.sun.star.lang.XInitialization interface, so that MyService2 can be instantiated with arguments passed to it during runtime.

  #include <com/sun/star/uno/XInterface.idl>
  #include <com/sun/star/lang/XInitialization.idl>
 
  module my_module
  {
 
  interface XSomething : com::sun::star::uno::XInterface
  {
      string methodOne( [in] string val );
  };
 
  service MyService1
  {
      interface XSomething;
  };
 
  service MyService2
  {
      interface XSomething;
      interface com::sun::star::lang::XInitialization;
  };
 
  };

This IDL is compiled to produce a binary type library file (.urd file), by executing the following commands. The types are compiled and merged into a registry simple_component.rdb, that will be linked into the Apache OpenOffice installation later.

 $ idlc -I<SDK>/idl some.idl
 $ regmerge simple_component.rdb /UCR some.urd

The cppumaker tool must be used to map IDL to C++:

 $ cppumaker -BUCR -Tmy_module.XSomething <officepath>/program/types.rdb simple_component.rdb

For each given type, a pair of header files is generated, a .hdl and a .hpp file. To avoid conflicts, all C++ declarations of the type are in the .hdl and all definitions, such as constructors, are in the .hpp file. The .hpp is the one to include for any type used in C++.

The next step is to implement the core interfaces, and the implementation of the component operations component_getFactory(), component_writeInfo() and component_getImplementationEnvironment() with or without helper methods.

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