Tutorial Locate Misc

From Apache OpenOffice Wiki
Jump to: navigation, search
Locate! :-) Tutorial_Help

Assumptions :-) we have an installation in /opt/ooinstall/ which we link to a build tree in ~/ooo-build/build/*680*/ and when run this creates a user configuration dataset in ~/.ooo-2.0*

Whatever could not go into the other two locate sections is what goes in here :-)

The usual locations of the code at the top-level projects is

  • sw/ for Writer
  • sd/ for Impress
  • sc/ for Calc
  • dbaccess/ for Base and
  • desktop/ for the base application/framework without any of the others

Where code is common across all the applications, it is usually part of the sfx2/, svx/, svtools and framework/ projects.

Another aspect of locating code is the UNO componentization - while most of the code is C++, the UNO part is particular to OOo, so if you're reading code and it suddenly goes:

            Reference < XURLTransformer >   xParser     (
OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.URLTransformer")) ),
::com::sun::star::uno::UNO_QUERY );

that's UNO for you :-)

Very simply put, a component is termed as a UNO service and before you can use a UNO service, you query for the service, as shown above. If the component is available and is instantiated, a UNO Reference to the service is obtained. This reference is used to invoke the methods that the service makes available. A query can fail, which can be detected by calling the .is() method on the Reference, so for the above code, where the reference to the service is successfully obtained, xParser.is() would return true :-)

Further, the service registry of all available UNO components is at /opt/install/program/services.rdb and this is a binary file that can be viewed using ~/ooo-build/build/*680*/solver/680/unxlngi6.pro/bin/regview from an OOo build. So to see where the above code goes, we run regview on services.rdb to find:

   / com.sun.star.comp.framework.URLTransformer
     / UNO
       / ACTIVATOR
         Value: Type = RG_VALUETYPE_STRING
                Size = 34
                Data = "com.sun.star.loader.SharedLibrary"
       / SERVICES
         / com.sun.star.util.URLTransformer
       / LOCATION
         Value: Type = RG_VALUETYPE_STRING
                Size = 15
                Data = "libfwk680li.so"


   / com.sun.star.util.URLTransformer
            Size = 51
            Len  = 1
            Data = 0 = "com.sun.star.comp.framework.URLTransformer"

What that effectively means is that the interface com.sun.star.util.URLTransformer is implemented by com.sun.star.comp.framework.URLTransformer which in turn is in the shared library libfwk680li.so.

Now what we can do is run a locate on the disk to find where the so comes from, so "locate libfwk680li.so" returns for every build tree two results minimum:


One result is the actual location where it is built and the second is its copy in the solver, so now we know that the library comes from the top-level framework/ project, next a search for the implementation name:

grep -rHn "com.sun.star.comp.framework.URLTransformer" framework/

gives us:

framework/inc/services.h:166:#define    IMPLEMENTATIONNAME_URLTRANSFORMER  DECLARE_ASCII("com.sun.star.comp.framework.URLTransformer"

which tells us what to look for next and since we are usually interested in the cxx where the action is:



framework/source/services/urltransformer.cxx:174:                                IMPLEMENTATIONNAME_URLTRANSFORMER

which is what we would probably be most interested in! :-)

So the line of code executed after the UNO query would be the component instantiation function, in this case, somewhat complicated by the macro DEFINE_INIT_SERVICE which is defined in framework/inc/macros/xserviceinfo.hxx. The exact methods invoked would be the impl_createFactory and impl_createInstance methods which would in turn instantiate the class that implements the service.

A UNO service implements a UNO interface. For instance, the service above implements the service com::sun::star::util::XURLTransformer. To find more details on the interface, the easiest method would probably be googling for it and we find:


which details the different methods that implementers of the service need to implement. Another way is to look up the original idl file specifying the interface in offapi at offapi/com/sun/star/util/XURLTransformer.idl or the generated associated header file that would be generated in offuh at /offuh/unxlngi6.pro/inc/com/sun/star/util/XURLTransformer.hpp, and can look in to see the methods that are part of this interface.

Personal tools