Difference between revisions of "Zh/Documentation/DevGuide/Extensions/File Format"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (Executable Files)
Line 161: Line 161:
  
  
=== Extension Tooltip Description===  
+
=== 扩展工具提示说明 ===  
  
'''Deprecated as of OOo 3.1.'''  See [[Documentation/DevGuide/Extensions/Extension Description|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,
+
'''OOo 3.1. 中不推荐使用'''  详见 [[Zh/Documentation/DevGuide/Extensions/Extension Description|Extension Description]]。
 +
 
 +
 
 +
如果需要添加工具提示说明( 扩展管理器对话框中捆绑节点的以便捷方式显示的帮助),那么可以通过指定本地化的 UTF-8 格式的文件来实现,例如:
 +
 
 
  <source lang="xml">
 
  <source lang="xml">
 
   <manifest:file-entry manifest:media-type="application/vnd.sun.star.package-bundle-description;locale=en"  
 
   <manifest:file-entry manifest:media-type="application/vnd.sun.star.package-bundle-description;locale=en"  
Line 174: Line 177:
 
                       manifest:full-path="readme.txt" />
 
                       manifest:full-path="readme.txt" />
 
  </source>
 
  </source>
The best matching locale (against the current installation's locale) is taken. The locale is of the form locale=language-country-variant.
+
 
 +
 
 +
将选择最匹配的地域(根据当前安装的地域设置)。地域是 locale=language-country-variant 的形式。
 +
 
 +
 
  
 
=== 可执行文件 ===
 
=== 可执行文件 ===
  
  
可执行文件对应的媒体类型为 ''application/vnd.sun.star.configuration-schema'',是 OOo 2.4 中新增的媒体类型。如果一个扩展使用了这个类型,那么它必需使用 2.4 的[[Documentation/DevGuide/Extensions/Description of XML Elements#Element /description/dependencies|OpenOffice.org-minimal-version]] 集合的依赖性。这个媒体类型的引入是为解决当 OOo  析取一个压缩的扩展时可执行属性(Unix 文档,不适用 Windows 文件)未预留而产生的问题。同样当在 Windows 上打包一个扩展时,这个属性也会丢失。在 Windows 可执行文件使用这项属性没有效果,因为在 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.
+
可执行文件对应的媒体类型为 ''application/vnd.sun.star.configuration-schema'',是 OOo 2.4 中新增的媒体类型。如果一个扩展使用了这个类型,那么它必需使用 2.4 的[[Documentation/DevGuide/Extensions/Description of XML Elements#Element /description/dependencies|OpenOffice.org-minimal-version]] 集合的依赖性。这个媒体类型的引入是为解决当 OOo  析取一个压缩的扩展时可执行属性(Unix 文档,不适用 Windows 文件)未预留而产生的问题。同样当在 Windows 上打包一个扩展时,这个属性也会丢失。在 Windows 可执行文件使用这项属性没有效果,因为在 Windows 上文件没有这样的属性。在 Unix 上可执行文件属性在扩展被安装时即被设置了。如果安装为当前用户可用那么可执行标志就设置为用户可执行。如果安装为所以用户可用即共享扩展,那么可执行标志将被设置为用户,组和其他类型用户可执行。例如:
Example:
+
 
 
  <source lang="xml">
 
  <source lang="xml">
 
   <manifest:file-entry manifest:media-type="application/vnd.sun.star.executable"  
 
   <manifest:file-entry manifest:media-type="application/vnd.sun.star.executable"  
Line 186: Line 193:
 
  </source>
 
  </source>
  
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 {{PRODUCTNAME}} 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 <idl>com.sun.star.util.MacroExpander</idl> service. The ''%origin%'' variable is, for instance, used by the <code>ImageIdentifier</code> property of add-on menus and toolbar items, which is described in the [[Documentation/DevGuide/WritingUNO/AddOns/Configuration|Configuration]] section.
+
 
 +
所有其他扩展内容可以直接复制到扩展管理器缓存中。例如,可以为软件包的 Add-on 菜单部署图片,或为组件添加其他需要文件。{{PRODUCTNAME}} 配置用于查询文件在某个特定安装所在的路径。当定义一个包含额外文件的程序包时,要包含一个指向这些文件的 ''.xcu'' 配置数据文件。使用 ''%origin%'' 变量作为的一个扩展管理器复制文件的准确路径的占位符。当 ''unopkg'' 安装数据时,它用一个包含宏的 URL 替换这个路径并写入配置。这个 URL 在作为合法文件 URL 前必需展开。可以通过
 +
<idl>com.sun.star.util.MacroExpander</idl> 服务做到。''%origin%'' 变量被 add-on 菜单和工具栏项目的 <code>ImageIdentifier</code> 属性使用(在 [[Zh/Documentation/DevGuide/WritingUNO/AddOns/Configuration|Configuration]] 中作相关说明)。
  
 
{{PDL1}}
 
{{PDL1}}
  
 
[[Category:文档/开发者指南/扩展]]
 
[[Category:文档/开发者指南/扩展]]

Revision as of 06:05, 8 September 2008


扩展是以 .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 文件)。


扩展工具提示说明

OOo 3.1. 中不推荐使用 详见 Extension Description


如果需要添加工具提示说明( 扩展管理器对话框中捆绑节点的以便捷方式显示的帮助),那么可以通过指定本地化的 UTF-8 格式的文件来实现,例如:

  <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" />


将选择最匹配的地域(根据当前安装的地域设置)。地域是 locale=language-country-variant 的形式。


可执行文件

可执行文件对应的媒体类型为 application/vnd.sun.star.configuration-schema,是 OOo 2.4 中新增的媒体类型。如果一个扩展使用了这个类型,那么它必需使用 2.4 的OpenOffice.org-minimal-version 集合的依赖性。这个媒体类型的引入是为解决当 OOo 析取一个压缩的扩展时可执行属性(Unix 文档,不适用 Windows 文件)未预留而产生的问题。同样当在 Windows 上打包一个扩展时,这个属性也会丢失。在 Windows 可执行文件使用这项属性没有效果,因为在 Windows 上文件没有这样的属性。在 Unix 上可执行文件属性在扩展被安装时即被设置了。如果安装为当前用户可用那么可执行标志就设置为用户可执行。如果安装为所以用户可用即共享扩展,那么可执行标志将被设置为用户,组和其他类型用户可执行。例如:

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


所有其他扩展内容可以直接复制到扩展管理器缓存中。例如,可以为软件包的 Add-on 菜单部署图片,或为组件添加其他需要文件。OpenOffice.org 配置用于查询文件在某个特定安装所在的路径。当定义一个包含额外文件的程序包时,要包含一个指向这些文件的 .xcu 配置数据文件。使用 %origin% 变量作为的一个扩展管理器复制文件的准确路径的占位符。当 unopkg 安装数据时,它用一个包含宏的 URL 替换这个路径并写入配置。这个 URL 在作为合法文件 URL 前必需展开。可以通过

com.sun.star.util.MacroExpander 服务做到。%origin% 变量被 add-on 菜单和工具栏项目的 ImageIdentifier 属性使用(在 Configuration 中作相关说明)。
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages