Difference between revisions of "Documentation/DevGuide/WritingUNO/XUnoTunnel"

From Apache OpenOffice Wiki
Jump to: navigation, search
 
Line 9: Line 9:
 
<!--<idltopic>com.sun.star.lang.XUnoTunnel</idltopic>-->
 
<!--<idltopic>com.sun.star.lang.XUnoTunnel</idltopic>-->
 
The <idl>com.sun.star.lang.XUnoTunnel</idl> interface allows access to the <code>this</code> pointer of an object. This interface is used to cast a UNO interface that is coming back to its implementation class through a UNO method. Using this interface is a result of an unsatisfactory interface design, because it indicates that some functionality only works when non-UNO functions are used. In general, these objects cannot be replaced by a different implementation, because they undermine the general UNO interface concept. This interface can be understood as admittance to an already existing code that cannot be split into UNO components easily. If designing new services, do not use this interface.
 
The <idl>com.sun.star.lang.XUnoTunnel</idl> interface allows access to the <code>this</code> pointer of an object. This interface is used to cast a UNO interface that is coming back to its implementation class through a UNO method. Using this interface is a result of an unsatisfactory interface design, because it indicates that some functionality only works when non-UNO functions are used. In general, these objects cannot be replaced by a different implementation, because they undermine the general UNO interface concept. This interface can be understood as admittance to an already existing code that cannot be split into UNO components easily. If designing new services, do not use this interface.
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
   interface XUnoTunnel: com::sun::star::uno::XInterface
 
   interface XUnoTunnel: com::sun::star::uno::XInterface
 
   {  
 
   {  
 
       hyper getSomething( [in] sequence< byte > aIdentifier );
 
       hyper getSomething( [in] sequence< byte > aIdentifier );
 
   };  
 
   };  
</source>
+
</syntaxhighlight>
The byte sequence contains an identifier that both the caller and implementer must know. The implementer returns the this pointer of the object if the byte sequence is equal to the byte sequence previously stored in a static variable. The byte sequence is usually generated ''once per process'' per implementation.  
+
The byte sequence contains an identifier that both the caller and implementer must know. The implementer returns this pointer of the object if the byte sequence is equal to the byte sequence previously stored in a static variable. The byte sequence is usually generated ''once per process'' per implementation.  
  
 
{{Note|Note that the previously mentioned 'per process' is important because the <tt>this</tt> pointer of a class you know is useless, if the instance lives in a different process.}}
 
{{Note|Note that the previously mentioned 'per process' is important because the <tt>this</tt> pointer of a class you know is useless, if the instance lives in a different process.}}

Latest revision as of 17:27, 23 December 2020



The com.sun.star.lang.XUnoTunnel interface allows access to the this pointer of an object. This interface is used to cast a UNO interface that is coming back to its implementation class through a UNO method. Using this interface is a result of an unsatisfactory interface design, because it indicates that some functionality only works when non-UNO functions are used. In general, these objects cannot be replaced by a different implementation, because they undermine the general UNO interface concept. This interface can be understood as admittance to an already existing code that cannot be split into UNO components easily. If designing new services, do not use this interface.

  interface XUnoTunnel: com::sun::star::uno::XInterface
  { 
      hyper getSomething( [in] sequence< byte > aIdentifier );
  };

The byte sequence contains an identifier that both the caller and implementer must know. The implementer returns this pointer of the object if the byte sequence is equal to the byte sequence previously stored in a static variable. The byte sequence is usually generated once per process per implementation.

Documentation note.png Note that the previously mentioned 'per process' is important because the this pointer of a class you know is useless, if the instance lives in a different process.
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages