Accessing code for Calc functions

Kaganski Mike mikekaganski at hotmail.com
Tue Nov 26 14:37:43 UTC 2019


Hi Steve,

On 26.11.2019 17:15, Steve Fanning wrote:
> I am currently working as a member of the Documentation Team, updating 
> Chapter 18 of the Calc Guide (Description of Functions). From time to 
> time during this task, I would benefit from viewing the code that 
> implements individual functions but have not been able to find that 
> code. Could somebody give me some hints please?

E.g., given the function CHITEST [1]:

1. I git grep for the function's name:
     https://opengrok.libreoffice.org/search?project=core&full=CHITEST
2. I see opcode, like "{ "CHITEST" , SC_OPCODE_CHI_TEST },", and grep 
for the opcode:
 
https://opengrok.libreoffice.org/search?project=core&full=SC_OPCODE_CHI_TEST
3. I see "ocChiTest = SC_OPCODE_CHI_TEST," in opcode.hxx, and grep gain 
for it:
     https://opengrok.libreoffice.org/search?project=core&full=ocChiTest
4. In an interprN.cxx, I see "case ocChiTest :", and go there to see the 
name of function called when that opcode arrives:
 
https://opengrok.libreoffice.org/xref/core/sc/source/core/tool/interpr4.cxx?r=0ef5c475#4392
5. So I see the function name is ScChiTest:
 
https://opengrok.libreoffice.org/xref/core/sc/source/core/tool/interpr3.cxx?r=f853ec31#2797

This is possibly too long, but that's from the PoV of not knowing where 
to look initially. Of course, you could also try shortcut searching for 
ScFoo when looking for FOO function... (not always helpful). Anyway, 
this shows the relevant pieces.

> It would also help if I could view the code for the Function Wizard.

For any dialog, you look into its English UI, and grep for the strings 
in it (choose specific enough):
 
https://opengrok.libreoffice.org/search?project=core&full=%22Function+result%22

Find the .ui file, and then grep for its name in .cxx files - you will 
find the constructor creating the dialog or one of its tabs:
 
https://opengrok.libreoffice.org/search?project=core&full=%22formuladialog.ui%22

So likely you need to look in formula/source/ui/dlg/formula.cxx

That's how I do that. HTH.

[1] 
https://help.libreoffice.org/latest/en-US/text/scalc/01/04060181.html?DbPAR=CALC#bm_id3154260

-- 
Best regards,
Mike Kaganski


More information about the LibreOffice mailing list