文件格式

From Apache OpenOffice Wiki
< Zh‎ | Documentation
Revision as of 09:03, 5 September 2008 by Jirong (Talk | contribs)

Jump to: navigation, search


扩展是以 .oxt 为后缀名(之前使用 .uno.pkg.zip)的 zip 文件。文件扩展名 .oxt 与 MIME 媒体类型 vnd.openofficeorg.extension 相对应。扩展可以包含 UNO 组件、类型库、配置文件、对话框或基本类库等。


扩展也需包含一个 description.xml(参阅 description.xml 和包含一个 META-INF (全大写)目录。META-INF 目录包含一个 manifest.xml,列出了所有的项目和它们的媒体类型。


Template:Documentation/Note


各种文件根据它们的媒体类型,应被分别对待。例如一个 UNO 组件被使用前必需要先要注册。所有不需要文件特殊处理的媒体类型现在都可以被忽略(实际上就是没有必要包含在 manifest.xml 文件中)。


运行时库

当不确定 OOo 是否已经带有或用户系统上已安装了这些库文件时,扩展需要自带它们的运行时库,如 C 或 C++。通常它们需要被放在包含 UNO 组件的库所在位置相同的目录。


请注意使用MS Visual Studio 2008 编译的库的一个特性。运行库(C、C++)要么应安装在系统中或要么必需置于库文件相同的位置才能找得到。运行库是否包含在 OOo 安装(<office>/OpenOffice.org/Basis/program)中没有很大关系。就是说扩展必需总是包含它们要使用的运行库。


运行库不能被 manifest.xml 引用。


共享库 UNO 组件

一个共享库 UNO 组件对应的媒体类型为 application/vnd.sun.star.uno-component;type=native。例如,

  <manifest:file-entry manifest:media-type="application/vnd.sun.star.uno-component;type=native" 
                       manifest:full-path="myComponent.uno.so"/>


特殊平台的共享库 UNO 组件

当实现一个 UNO 原生组件,例如,一个 .dll.so 文件时,这个文件只能部署在指定的平台上。为不同平台制作程序包相当方便。例如,为 x86 Linux、Solaris SPARC 和 Windows 编译组件。你需要通过媒体类型与一个平台属性来告诉扩展管理器哪个版本的组件文件对应哪个平台。例如:

  <manifest:file-entry manifest:media-type= "application/vnd.sun.star.uno-component;type=native;platform=Windows"
                      manifest:full-path="windows/mycomp.uno.dll"/>
  <manifest:file-entry manifest:media-type= "application/vnd.sun.star.uno-component;type=native;platform=Linux_x86"
                       manifest:full-path="linux/myComp.uno.so"/>
  <manifest:file-entry manifest:media-type= "application/vnd.sun.star.uno-component;type=native;platform=Solaris_SPARC"
                       manifest:full-path="solsparc/myComp.uno.so"/>


RDB 类型库

UNO RDB 类型库对应的媒体类型为application/vnd.sun.star.uno-typelibrary;type=RDB,例如:

  <manifest:file-entry manifest:media-type="application/vnd.sun.star.uno-typelibrary;type=RDB"
                       manifest:full-path="myTypes.uno.rdb"/>


Jar 类型库

UNO Jar 类型库对应的媒体类型为 application/vnd.sun.star.uno-typelibrary;type=Java,例如:

  <manifest:file-entry manifest:media-type="application/vnd.sun.star.uno-typelibrary;type=Java" 
                       manifest:full-path="myTypes.uno.jar"/>


切记此类型库的 RDB 变种也必需部署。目前来说这是必需的,因为你的 Java UNO 类型有可能引用自原生 UNO 代码。


Uno Jar 组件

UNO Jar 组件对应的媒体类型为 application/vnd.sun.star.uno-component;type=Java,例如:

  <manifest:file-entry manifest:media-type="application/vnd.sun.star.uno-component;type=Java" 
                       manifest:full-path="myComponent.uno.jar"/>


UNO Python 组件

unopkg 现在支持 Python 组件的租车(.py 文件)。这些文件使用 com.sun.star.loader.Python 载入然后注册。更多有关 Python-UNO 的信息,请参阅 http://udk.openoffice.org/python/python-bridge.html。UNO Python 组件对应的媒体类型为 application/vnd.sun.star.uno-component;type=Python,例如:

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


OpenOffice.org Basic 库

OpenOffice.org Basic 库被链接到基本库容器文件。更多信息请参阅 OpenOffice.org Basic 和对话框。OpenOffice.org Basic 库对应的媒体类型为 "application/vnd.sun.star.basic-library",例如:

  <manifest:file-entry manifest:media-type="application/vnd.sun.star.basic-library" 
                       manifest:full-path="myBasicLib/"/>


对话框库

对话框库被链接到 basic 对话框库容器文件。更多信息请参阅 OpenOffice.org Basic 和对话框。对话框库对应的媒体类型为 application/vnd.sun.star.dialog-library,例如:

  <manifest:file-entry manifest:media-type="application/vnd.sun.star.dialog-library" 
                       manifest:full-path="myDialog/"/>


配置数据文件

配置数据文件对应的媒体类型为 application/vnd.sun.star.configuration-data,例如:

  <manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-data" 
                       manifest:full-path="myData.xcu"/>


配置 schema 文件

配置规划文件对应的媒体类型为 application/vnd.sun.star.configuration-schema,例如:

  <manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-schema" 
                       manifest:full-path="mySchema.xcs"/>


注意不要安装包含相同元素(oor:packageoor:name)但有不同定义的 schemata (.xcs 文件)。


Extension Tooltip Description

Deprecated as of OOo 3.1. See Extension Description for details.

If you want to add a tooltip description (which shows up in the balloon help of a bundle node in the Extension Manager dialog), then you can do so by specifying localized UTF-8 files, for example,

  <manifest:file-entry manifest:media-type="application/vnd.sun.star.package-bundle-description;locale=en" 
                       manifest:full-path="readme.en" />
  <manifest:file-entry manifest:media-type="application/vnd.sun.star.package-bundle-description;locale=de" 
                       manifest:full-path="readme.de" />
  <manifest:file-entry manifest:media-type="application/vnd.sun.star.package-bundle-description" 
                       manifest:full-path="readme.txt" />

The best matching locale (against the current installation's locale) is taken. The locale is of the form locale=language-country-variant.

Executable Files

The media type for an executable is application/vnd.sun.star.configuration-schema. This media type is new in OOo 2.4. If an extension uses it then it should also use the dependency OpenOffice.org-minimal-version set to 2.4. This media type was introduced to work-around the problem that the executable attribute (Unix files, does not apply for Windows files) will not be preserved when OOo extracts a zipped extension. Also when an extension was zipped on Windows then the attribute is lost. Using the media type for an Windows executable does not have an effect since there is no such file attribute on Windows. On Unix the executable attribute is set when the extension is being installed. If it is installed for the current user then the user exectuable flag is set and if it is installed for all users, that is as shared extension, then the executable flag is set for user,group and other. Example:

  <manifest:file-entry manifest:media-type="application/vnd.sun.star.executable" 
                       manifest:full-path="hello"/>

All other contents of the extension are simply copied into the Extension Manager cache. You can, for instance, deploy an image for add-on menus within a package, or any other file needed by your component. The OpenOffice.org configuration is used to find out in which path this file is located in a particular installation. When you define a package containing additional files, include an .xcu configuration data file, which points to your files. Use a variable %origin% as a placeholder for the exact path where the file will be copied by the Extension Manager. When unopkg installs the data, it replaces the path with an URL containing a macro and writes into the configuration. This URL has to be expanded before it is a valid file URL. This can be done using the com.sun.star.util.MacroExpander service. The %origin% variable is, for instance, used by the ImageIdentifier property of add-on menus and toolbar items, which is described in the Configuration section.

Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages