OpenOffice.org 拡張機能 その3

テンプレートパッケージ

テンプレートをまとめて配布するパッケージを作成してみます。

テンプレートのみを配布する拡張機能パッケージは次のような構造になります。

  • META-INF/
  • description.xml
  • Paths.xcu テンプレートファイルを配置した場所を指定する設定ファイル
  • template/
    • groupuinames.xml テンプレートを入れたディレクトリのテーマを指定
    • theme/
      • template.odt
manifest.xml

インストール時に登録が必要なファイルは Paths.xcu のみです。エントリーは次のようになります。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE manifest:manifest PUBLIC "-//OpenOffice.org//DTD Manifest 1.0//EN" "Manifest.dtd">
<manifest:manifest xmlns:manifest="http://openoffice.org/2001/manifest">
    <manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-data"
                         manifest:full-path ="Paths.xcu"/>
</manifest:manifest>

設定ファイルのため media-type は application/vnd.sun.star.configuration-data になります。

Paths.xcu

テンプレートを配置した template ディレクトリを指定する設定ファイルです。

<?xml version='1.0' encoding='UTF-8'?>
<oor:component-data oor:package="org.openoffice.Office" oor:name="Paths" 
xmlns:install="http://openoffice.org/2004/installation" 
xmlns:oor="http://openoffice.org/2001/registry" 
xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <node oor:name="Paths">
    <node oor:name="Template" oor:op="fuse">
      <node oor:name="InternalPaths">
        <node oor:name="%origin%/template" oor:op="fuse"/>
      </node>
    </node>
  </node>
</oor:component-data>

InternalPaths ノードの子ノードの oor:name 属性にテンプレートディレクトリを指定します。このとき %origin% はインストール時に、この設定ファイルのあるパスに置換されます。
ここでは、Paths.xcu ファイルと同じディレクトリにある template ディレクトリを指定しています。

groupuinames.xml

このファイルではファイル - 新規 - テンプレートとドキュメントなどに表示されるテンプレートのグループの表示名を指定します。

<?xml version="1.0" encoding="UTF-8"?>
<groupuinames:template-group-list xmlns:groupuinames="http://openoffice.org/2006/groupuinames">
 <groupuinames:template-group groupuinames:name="theme"
groupuinames:default-ui-name="独自のテンプレート" />
</groupuinames:template-group-list>

theme ディレクトリに配置されたテンプレートを「独自のテンプレート」として表示させます。

日本語を含む場合にはファイルを UTF-8 エンコーディングで保存しておく必要があります。

descriptiom.xml

拡張機能マネージャで表示される項目などを指定します。

<?xml version="1.0" encoding="UTF-8"?>
<description xmlns="http://openoffice.org/extensions/description/2006"
	xmlns:xlink="http://www.w3.org/1999/xlink"
	xmlns:d="http://openoffice.org/extensions/description/2006">
	<identifier value="org.templates.MyTemplates" />
	<version value="0.1.0" />
	<display-name>
		<name lang="en">Original Templates</name>
		<name lang="ja">独自のテンプレート</name>
	</display-name>
</description>