<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Feb 15, 2017 at 12:12 PM, Gergely Buday <span dir="ltr"><<a href="mailto:buday.gergely@uni-eszterhazy.hu" target="_blank">buday.gergely@uni-eszterhazy.<wbr>hu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="HU"><div class="m_3389623955164946460gmail-m_6571924816339958200WordSection1"><p class="MsoNormal"></p><p class="MsoNormal">Where in the Libre Office source tree I can find the glue code for various extension languages?</p></div></div></blockquote><div><br></div><div>I do not remember the code locations, but I once had a look at Java and Python bindings. For python, some (most, almost all?) classes are generated dynamically at runtime (so you get no code completion in IDE). For Java, there is some hand-written glue code and the rest are generated jar files (it directly generates jars from the IDL without intermediate Java sources; method parameter names are not specified in the jars, so you get some code completion, but it is not great.)<br><br></div><div>There are manual attempts to write nicer, more human friendly bindings, I saw something e.g. for python when I searched Pypi. Not sure how comprehensive they are; it possibly covers only what the original author needed covered...<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="HU"><br><div class="m_3389623955164946460gmail-m_6571924816339958200WordSection1"><p class="MsoNormal">Another option is to use Scala as it is possible to write extensions in Java and Scala can use Java libraries.</p><p class="MsoNormal"> </p><p class="MsoNormal">Did anybody write a Libre Office extension in Scala?<span class="m_3389623955164946460gmail-HOEnZb"></span><span class="m_3389623955164946460gmail-HOEnZb"></span></p></div></div></blockquote><div><br></div><div>I was looking into writing a macro[1] in Kotlin. It is not ML, but it has some syntactic elements borrowed from that tradition... One nice thing you can do in Kotlin (that you cannot in Java) is create extension function<br><br><span class="m_3389623955164946460gmail-pl-k">fun</span> <<span class="m_3389623955164946460gmail-pl-k">T</span>> Any.<span class="m_3389623955164946460gmail-pl-en">query</span>(<span class="m_3389623955164946460gmail-pl-smi">anInterface</span><span class="m_3389623955164946460gmail-pl-k">:</span> Class<T>)<span class="m_3389623955164946460gmail-pl-k">:</span> T {
      
      
        <table class="m_3389623955164946460gmail-highlight m_3389623955164946460gmail-tab-size m_3389623955164946460gmail-js-file-line-container"><tbody><tr><td id="m_3389623955164946460gmail-LC18" class="m_3389623955164946460gmail-blob-code m_3389623955164946460gmail-blob-code-inner m_3389623955164946460gmail-js-file-line">    <span class="m_3389623955164946460gmail-pl-c"><span class="m_3389623955164946460gmail-pl-c">//</span> TODO: taking KClass did not work for me</span></td>
      </tr>
      <tr>
        </tr></tbody></table><table class="m_3389623955164946460gmail-highlight m_3389623955164946460gmail-tab-size m_3389623955164946460gmail-js-file-line-container"><tbody><tr><td id="m_3389623955164946460gmail-LC19" class="m_3389623955164946460gmail-blob-code m_3389623955164946460gmail-blob-code-inner m_3389623955164946460gmail-js-file-line">    <span class="m_3389623955164946460gmail-pl-k">return</span> UnoRuntime<span class="m_3389623955164946460gmail-pl-k">.</span>queryInterface(<wbr>anInterface, <span class="m_3389623955164946460gmail-pl-c1">this</span>)</td>
      </tr>
      <tr>
        </tr></tbody></table>}<br><br></div><div>and then you can do<br><br><span class="m_3389623955164946460gmail-pl-k">val</span> <span class="m_3389623955164946460gmail-pl-en">sheets</span> <span class="m_3389623955164946460gmail-pl-k">=</span> xScriptContext<span class="m_3389623955164946460gmail-pl-k">.</span>document<span class="m_3389623955164946460gmail-pl-k">.</span>query(<wbr>com<span class="m_3389623955164946460gmail-pl-k">.</span>sun<span class="m_3389623955164946460gmail-pl-k">.</span>star<span class="m_3389623955164946460gmail-pl-k">.</span>sheet<span class="m_3389623955164946460gmail-pl-k">.</span>XSpreadshee<wbr>tDocument<span class="m_3389623955164946460gmail-pl-k">::</span>class<span class="m_3389623955164946460gmail-pl-k">.</span>java)<br><br></div><div>instead of<br><br><span class="m_3389623955164946460gmail-pl-k">val</span> <span class="m_3389623955164946460gmail-pl-en">sheets</span> <span class="m_3389623955164946460gmail-pl-k">=</span> UnoRuntime<span class="m_3389623955164946460gmail-pl-k">.</span>queryInterface(com<span class="m_3389623955164946460gmail-pl-k">.</span><wbr>sun<span class="m_3389623955164946460gmail-pl-k">.</span>star<span class="m_3389623955164946460gmail-pl-k">.</span>sheet<span class="m_3389623955164946460gmail-pl-k">.</span>XSpreadsheetDoc<wbr>ument<span class="m_3389623955164946460gmail-pl-k">::</span>class<span class="m_3389623955164946460gmail-pl-k">.</span>java, xScriptContext<span class="m_3389623955164946460gmail-pl-k">.</span>document<span class="m_3389623955164946460gmail-pl-k"></span>)<br><br></div><div>Neither is spectacularly readable, but choosing from the two, the first is IMO nicer.<br><br></div><div>Also, I have a gradle task to compile and push the macro to my libreoffice directory, so I can recompile and redeploy it into running Calc in about 5 seconds. Not spectacular either, but it is as good as I was able to get given I have to have a compilation step.<br></div><div><br>[1] <a href="https://github.com/msgqe/doccheck" target="_blank">https://github.com/msgqe/<wbr>doccheck</a><br></div></div>-- <br><div class="m_3389623955164946460gmail_signature"><div dir="ltr"><div>Jiří Daněk<br></div></div></div>
</div></div>