How to use / develop AddIns in Calc


I’ve installed LibreOffice from the official site on my 64bit Linux Mint machine, and the corresponding SDK, too. Compiled the example /opt/libreoffice5.3/sdk/examples/DevelopersGuide/Components/CppComponent.
I can run the the binarys in a shell (TestCppComponent _TestCppComponent), e.g.

connected to a running office…
Create new instance of MyService1
Call of XSomething.methOne at MyService1 = called methodOne() of MyService1 implementation: Hello World!

After the compile, a file named CppComponent.oxt was generated. I think this file can be added to Calc via Tools->Extension Managers.

However after that I don’t know how to find the created methods. Writing “=methodOne” and similar things does not work.
Any idea, how can the Addin be used?


With Python is very easy, I’m sorry, not use C++… if you or anybody want learn with Python, I can help you.

Do you have the document “SimpleComponent.odt” from that directory? Open it and click on the button to run it.

It looks like this component implements a service, not a Calc Add-In.

An example of a Python add-in is REVERSE() from The .idl file:

#include <com/sun/star/uno/XInterface.idl>

module name { module JimK { module LinguisticTools { module CalcFunctions {

    interface XCalcFunctions
      string reverse( [in] string s );

}; }; }; };

The .xcu file:

<?xml version="1.0" encoding="UTF-8"?>
<oor:component-data xmlns:oor=""
          oor:name="CalcAddIns" oor:package="org.openoffice.Office">
  <node oor:name="AddInInfo">
    <node oor:name="name.JimK.LinguisticTools.ReverseStringImpl" oor:op="replace">
      <node oor:name="AddInFunctions">
        <node oor:name="reverse" oor:op="replace">
          <prop oor:name="DisplayName"><value xml:lang="en">reverse</value></prop>
          <prop oor:name="Description">
            <value xml:lang="en">Flips a string backwards.  For example "apple" becomes "elppa".</value>
          <prop oor:name="Category"><value>Add-In</value></prop>
          <!-- This won't help, because there is no reverse() in Excel. -->
          <prop oor:name="CompatibilityName"><value xml:lang="en">reverse</value></prop>
          <node oor:name="Parameters">
            <node oor:name="s" oor:op="replace">
              <prop oor:name="DisplayName"><value xml:lang="en">s</value></prop>
              <prop oor:name="Description"><value xml:lang="en">The string to reverse.</value></prop>

The manifest.xml:

<!-- Files that describe the extension and its components -->
<!-- Compiled type library for the Calc addin -->

Finally, the implementation:

def reverseString(inString):
    s = unicode(inString)
    # This is extended slice syntax [begin:end:step].  With a step of -1,
    # it will traverse the string elements in descending order.
    return s[::-1]

To call it, enter the formula =REVERSE("apple").

For a C++ example, see Calc/Add-In/Simple Calc Add-In - Apache OpenOffice Wiki.

Hi Jim, thank you for your answer.

"Do you have the document “SimpleComponent.odt”
Yes, and you are right, probably it is not an addin example. Sorry for my misunderstading.

I have already found that c++ example, unfortunately it seems to be outdated.

  1. setenv and Makefile had to be updated (file structure of the sdk seems to be different)
  2. The “cppumaker -BUCR -Torg.openoffice.sheet.addin.XRNG …” line of the Makefile has to be modified. (It seems BUCR options are unknown, so I deleted them)
  1. Now the compile fails with the following error message:
    g++ -O2 -fPIC -fomit-frame-pointer -c -o RNG_impl.o -DUNX
    -DGCC -DLINUX -DCPPU_ENV=gcc3 -I. -I/opt/libreoffice5.3/sdk/include RNG_impl.cxx
    RNG_impl.cxx:175:109: error: expected initializer before ‘SAL_THROW’

Do you know a more up-to-date C++ AddIn example?

Not really; sorry. I have gotten C++ components to work in the past, but dealing with all the errors and linking problems is a big job. You will get more help asking about Python because it requires much less effort. Do you need C++ because of performance?

I don’t need C++ for performance, the reason is, it is language I know the best. I will give a try to Python. Thanks anyway!

How I can I use the Python version you recommended? I tried the followings:
Modified the .idl file not to contain the include. According to this ( it is not needed and with it I got an error “/tmp/idli_qYMTFH: line 1: file ‘com/sun/star/uno/XInterface.idl’ not found”

  1. idlc -C proba.idl
  2. regmerge proba.rdb /UCR proba.urd
  3. zipped every file and renamed to proba.oxt.
    The file is loaded, but “=reverse” not found.
    Do I miss something?

Using the original .idl and compiling it with “idlc -C -I/opt/libreoffice5.3/sdk/idl proba.idl” does not help.
I had to update the manifest file. Still not working, but with this (Calc/Add-In/Python How-To - Apache OpenOffice Wiki) I think I will solve the issue.
Thanks again for Jim and mauricio.