Tutorial Locate Functionality

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*

Another way to look for code is to start from the functionality that it affects. For instance, you want to figure out where spell checking is being done, so the first thing is to disable it from the UI to change the state of the functionality. What we take advantage of is the fact that OOo stores the configuration settings in our home directory which we can monitor.

So first we back up our existing configuration with a:

cp -a ~/.ooo-2.0 ~/.ooo-2.0.orig

and then change the state of the functionality we're looking for, in this case: Tools->Options->Lanuguage Settings->Writing Aids and uncheck "Check spelling as you type" and OK the dialog.

Once done, we do a recursive diff of the original and currect settings:

diff -upr ~/.ooo-2.0.orig ~/.ooo-2.0:
--- .ooo-2.0-pre.orig/user/registry/data/org/openoffice/Office/Linguistic.xcu   2005-10-18 19:55:24 +0530
+++ .ooo-2.0-pre/user/registry/data/org/openoffice/Office/Linguistic.xcu        2005-10-18 21:40:51 +0530
@@ -243,4 +142,9 @@
+ <node oor:name="SpellChecking">
+  <prop oor:name="IsSpellAuto" oor:type="xs:boolean">

+   <value>false</value>
+  </prop>
+ </node>

and ignore the rest and go looking for this setting, in this case it is easier to use LXR at go-oo.org and type in the text you're searching for "IsSpellAuto". More specifically, using the text search and specifying to search cxx files for the text IsSpellAuto,


or even better:


which gives us exactly one result [ lucky hit :-) ] at svtools/source/config/lingucfg.cxx, so we look in for the corresponding header file lingucfg.hxx since it has lesser code to read :-) and that gives us the class to look for - SvtLinguOptions, which we now look to find in sw/

Since what usually happens is that the configuration data is read by the code in svtools/ and fed into a structure, which is in turn invoked by different applications as and when they need it. So we can expect to find this class being invoked from the module we're interested in:

find sw/ -name "*.cxx" -exec grep -Hn SvtLinguOptions {} \;

or for the specific field we are interested in:

find sw/ -name "*.cxx" -exec grep -Hn IsSpellAuto {} \;

and find that this goes into a:

sw/source/ui/uiview/view.cxx:975:    aUsrPref.SetOnlineSpell( aLinguOpt.bIsSpellAuto );

which promptly gives us the hint to do a grep for:

find sw/ -name "*.cxx" -exec grep -Hn OnlineSpell {} \;

and we see how the different areas invoke this option as they proceed... Not simple for sure, but still quite intriguing... :-)

dummy.diff Next: Tutorial_Locate_Misc
Personal tools