2016-12-21 14 views
0

私はLibreOffice calcで関数を実行しました。それは機能しますが、組み込みのLibreOffice関数のような円錐ヘルプ/ヒント機能が必要です。UDF /ユーザー定義関数libreofficeビルトインヘルプ/ヒント

例:。。私はタイプ "= BESSELK(" それは先端BESSELK(X appaears;関数と引数の説明も表示されない関数ウィザードを使用してN)を Besselk besselk

のは、私が持っているとしましょう

function arearect(a, b) 
FUNCTION DESCRIPTION "Compute rectangle area" 
ARGUMENT DESCRIPTION "base length" 
ARGUMENT DESCRIPTION "height" 
arearect = a * b 
end function 
:矩形領域

function arearect(a, b) 
arearect = a * b 
end function 

をcalculteする機能は、私はこのような何かを持っていると思います

だから、 "= arearect("と入力すると、引数の説明が表示され、すべての記述子が関数ウィザードに表示されます。

おかげ

答えて

0

Spreadsheet Add-Inとしてユーザー定義関数を作成します。次に、アドインを定義する.xcuファイルのDescriptionノードにヘルプテキストを入力します。

たとえば、REVERSEという関数を作成しました。ここに私のCalcAddIns.xcuファイルがあります:

<?xml version="1.0" encoding="UTF-8"?> 
<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" 
      xmlns:xs="http://www.w3.org/2001/XMLSchema" 
      oor:name="CalcAddIns" oor:package="org.openoffice.Office"> 
    <node oor:name="AddInInfo"> 
    <node oor:name="name.JimK.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> 
      <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> 
      </node> 
      </node> 
     </node> 
     </node> 
    </node> 
    </node> 
</oor:component-data> 

アドインには他のファイルも必要です。ここに私のXCalcFunctions.idlがあります。

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

module name { module JimK { module CalcFunctions { 

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

}; }; }; 

実際の実装は単純でした。私は、Pythonを使用:

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] 

結果:

calc tooltip

EDIT

私の拡張のためのComponents.pyでの別の部分があります:

class StringReverserAddIn(unohelper.Base, XCalcFunctions): 
    def __init__(self, ctx): 
     self.ctx = ctx 

    @staticmethod 
    def factory(ctx): 
     return StringReverserAddIn(ctx) 

    def reverse(self, inString): 
     from lingt.app.calcfunctions import reverseString 
     return reverseString(inString) 

g_ImplementationHelper.addImplementation(
    StringReverserAddIn.factory, 
    "name.JimK.LinguisticTools.ReverseStringImpl", 
    ("com.sun.star.sheet.AddIn",),) 

をファイルが宣言されているin manifest.xml:

<!--- The Python code --> 
<manifest:file-entry 
manifest:full-path="Components.py" 
manifest:media-type="application/vnd.sun.star.uno-component;type=Python"/> 

完全拡張子:https://extensions.libreoffice.org/extensions/lingtools

+0

こんにちは。これらのファイルは.odsファイル内にありますか?もしそうでなければ、これは難しいでしょう。私はcalcファイル内の関数を、アドインをインストールするのに十分な知識がない人たちと共有したいからです。 – Matheus

+0

ファイルは.odsファイル内ではなく、別の.oxtパッケージに入れる必要があります。 .oxtファイルをインストールするには、基本的にはダブルクリックが必要です。スプレッドシートを操作する方法を知っているほとんどの人がうまくいけばうまくいきます。または、おそらくリモートにインストールできますか? –

+0

私は.oxtのインストールに行きます。 しかし.oxtを生成するには?すべてのファイルをzipに入れてから、.oxtという名前に変更することができます。 あなたの例のように、逆のpythonコードファイルの名前は何ですか? .oxtを教えてください。拡張についてのオンラインチュートリアルはシンプルさに欠けています。 – Matheus

関連する問題