このページはEtoJ逐語翻訳フィルタによって翻訳生成されました。

翻訳前ページへ


General Developer 指導基準s
Language

The 解放する/自由な and Open 生産性 控訴
解放(する)d: Apache OpenOffice 4.1.15

General Developer 指導基準s

令状ing Office scripts and the XScriptContext type

All Java script methods must pass in XScriptContext as their first parameter. The developer can then use accessor 機能(する)/行事s on the scripting 状況 to get at the 文書 状況, desktop and 構成要素 factory as follows: The Script must 輸入する the XScriptContext interface, using the に引き続いて 輸入する 指示的な:
    輸入する 草案s.com.sun.星/主役にする.script.枠組み.XScriptContext;
Example usage in a Java script method to 接近 a Writer 文書 and 挿入する some text:

    輸入する com.sun.星/主役にする.でっちあげる,人を罪に陥れる.XModel;
    輸入する com.sun.星/主役にする.text.*;
    輸入する com.sun.星/主役にする.uno.UnoRuntime;
    輸入する 草案s.com.sun.星/主役にする.script.枠組み.XScriptContext;

    public class MyClass {

        // The script method must be public
        // It can either be static or 非,不,無-static

        public 無効の showForm(XScriptContext xSc) {

            // getting the text 文書 反対する
            XModel xmodel = xSc.getDocument();

            XTextDocument xtextdoc = (XTextDocument)
                UnoRuntime.queryInterface(XTextDocument.class, xmodel);
            XText xtext = xtextdoc.getText();
            XTextCursor xtextcursor = xtext.createTextCursor();

            xtext.insertString(xtextcursor, "Hello World", 誤った);
        }
    }

Tips on 令状ing Office scripts

小包 Descriptor DTD and 見本 XML

Each script must 含む/封じ込める a 小包-descriptor.xml とじ込み/提出する which 供給するs all the necessary metadata for the script. The DTD for the 小包-descriptor.xml follows
<?xml 見解/翻訳/版="1.0" encoding="UTF-8"?>
<!-- DTD for 小包 Meta data for use in the OpenOffice.org Scripting 枠組み 事業/計画(する) -->
<!ELEMENT logicalname EMPTY>
<!ELEMENT description (#PCDATA)>
<!ELEMENT displayname EMPTY>
<!ELEMENT 地元の (displayname?, description?)>
<!ELEMENT functionname EMPTY>
<!ELEMENT 支え(る) EMPTY>
<!ELEMENT languagedepprops (支え(る)+)>
<!ELEMENT とじ込み/提出する (支え(る)*)>
<!ELEMENT fileset (とじ込み/提出する+)>
<!ELEMENT script (地元の+, functionname, logicalname, languagedepprops*, fileset*)>
<!ELEMENT 小包 (script+)>
<!ATTLIST logicalname
	value CDATA #REQUIRED
>
<!ATTLIST displayname
	value CDATA #REQUIRED
>
<!ATTLIST 地元の
	lang CDATA #REQUIRED
>
<!ATTLIST functionname
	value CDATA #REQUIRED
>
<!ATTLIST logicalname
	value CDATA #REQUIRED
>
<!ATTLIST 支え(る)
	指名する CDATA #REQUIRED
	value CDATA #REQUIRED
>
<!ATTLIST とじ込み/提出する
	指名する CDATA #REQUIRED
>
<!ATTLIST fileset
	指名する CDATA #IMPLIED
>
<!ATTLIST script
	language CDATA #REQUIRED
>
The に引き続いて is an example of a 小包-descriptor.xml とじ込み/提出する that defines a script, 器具/実施するd in Java. The languagedepprops element is used to 延長する the JVM's classpath.
<?xml 見解/翻訳/版="1.0" encoding="UTF-8"?>
<!--見本 Meta Data for use with the Scripting 枠組み 事業/計画(する) in OpenOffice.org -->
<!DOCTYPE 小包 SYSTEM "小包.dtd">
<小包>
	<script language="java">
		<地元の lang="english">
			<displayname value="Memory.usage"/>
			<description>
				陳列する,発揮するs the memory 現在の memory usage
			</description>
		</地元の>
		<functionname value="memoryUtils.memoryUsage"/>
		<logicalname value="MemoryUtils.MemUsage"/>
		<languagedepprops>
			<支え(る) 指名する="classpath" value="/選ぶ/foo.jar:/usr/java/src.jar"/>
		</languagedepprops>
		<fileset>
			<とじ込み/提出する 指名する="mems.txt">
				<支え(る) 指名する="type" value="資源"/>
			</とじ込み/提出する>
		</fileset>
	</script>
</小包>

How to 貯蔵所d Scripts

Binding scripts to Menu items Binding scripts to Shortcut 重要なs
  • Finally click on the 承認する button to save your new script shortcut 重要な.
  • 再開する OpenOffice.org and open a 文書
  • 圧力(をかける)ing your new script shortcut 重要な will invoke the Java script. 公式文書,認める: Menu items and Shortcut 重要なs are not updated on the 飛行機で行く, hence the need to 再開する, this will be 演説(する)/住所d in a 未来 解放(する).
    Last 修正するd: 結婚する Jan 15 16:25:01 GMT 2003
  • Apache Software Foundation

    Copyright & License | Privacy | 接触する Us | 寄付する | Thanks

    Apache, OpenOffice, OpenOffice.org and the seagull logo are 登録(する)d trademarks of The Apache ソフトウェア 創立/基礎. The Apache feather logo is a trademark of The Apache ソフトウェア 創立/基礎. Other 指名するs appearing on the 場所/位置 may be trademarks of their 各々の owners.