POI-HPBF - A Guide to the Publisher File Format(POI-HPBF - 发布者文件格式指南)
Overview(概述)
Document Streams(文档流)
The file is made up of a number of POIFS streams. A typical file will be made up as follows:(该文件由许多 POIFS 流组成。一个典型的文件将组成如下:)
Changing Text(更改文本)
If you make a change to the text of a file, but not change how much text there is, then the CONTENTS stream will undergo a small change, and the Contents stream will undergo a large change.(如果您对文件的文本进行了更改,但没有更改文本的数量,那么 CONTENTS 流将发生小的变化,而 Contents 流将发生很大的变化。)
If you make a change to the text of a file, and change the amount of text there is, then both the Contents and the CONTENTS streams change.(如果您更改文件的文本并更改文本的数量,那么 Contents 和 CONTENTS 流都会更改。)
Changing Shapes(改变形状)
If you alter the size of a textbox, but make no text changes, then both Contents and CONTENTS streams change. There are no changes to the Escher streams.(如果您更改文本框的大小,但不更改文本,则 Contents 和 CONTENTS 流都会更改。 Escher 流没有变化。)
If you set the background colour of a textbox, but make no changes to the text, (to finish off)(如果您设置文本框的背景颜色,但不更改文本,(结束))
Structure of CONTENTS(内容结构)
First we have "CHNKINK ", followed by 24 bytes.(首先我们有“CHNKINK”,然后是 24 个字节。)
Next we have 20 sequences of 24 bytes each. If the first two bytes at 0x1800, then that sequence entry exists, but if it's 0x0000 then the entry doesn't exist. If it does exist, we then have 4 bytes of upper case ASCII text, followed by three little endian shorts. The first of these seems to be the count of that type, the second is usually 1, the third is usually zero. The we have another 4 bytes of upper case ASCII text, normally but not always the same as the first text. Finally, we have an unsigned little endian 32 bit offset to the start of the data for this, then an unsigned little endian 32 bit offset of the length of this section.(接下来我们有 20 个序列,每个序列 24 个字节。如果前两个字节位于 0x1800,则该序列条目存在,但如果它是 0x0000,则该条目不存在。如果确实存在,那么我们有 4 个字节的大写 ASCII 文本,后跟三个 little endian short。其中第一个似乎是该类型的计数,第二个通常是 1,第三个通常是零。我们还有另外 4 个字节的大写 ASCII 文本,通常但并不总是与第一个文本相同。最后,我们有一个到数据开头的无符号小端 32 位偏移量,然后是本节长度的无符号小端 32 位偏移量。)
Normally, the first sequence entry is for TEXT, and the text data will start at 0x200. After that is normally two or three STSH entries (so the first short has values 0, then 1, then 2). After that it seems to vary.(通常,第一个序列条目用于 TEXT,文本数据将从 0x200 开始。之后通常是两个或三个 STSH 条目(所以第一个 short 的值是 0,然后是 1,然后是 2)。在那之后,它似乎有所不同。)
At 0x200 we have the text, stored as little endian 16 bit unicode.(在 0x200 我们有文本,存储为 little endian 16 位 unicode。)
After the text comes all sorts of other stuff, presumably as described by the sequences.(在文本之后是各种其他的东西,大概如序列所描述的那样。)
For a contents stream of length 7168 / 0x1c00 bytes, the start looks something like:(对于长度为 7168 / 0x1c00 字节的内容流,开始看起来像:)
We think that the first 4 bytes of text describes the the function of the data at the offset. The first short is then the count of that type, eg the 2nd will have 1. We think that the second 4 bytes of text describes the format of data block at the offset. The format of the text block is easy, but we're still trying to figure out the others.(我们认为前 4 个字节的文本描述了数据在偏移处的作用。第一个short 是该类型的计数,例如第二个将有1。我们认为第二个4 字节的文本描述了偏移处数据块的格式。文本块的格式很简单,但我们仍在尝试找出其他格式。)
Structure of TEXT bit(TEXT 位的结构)
This is very simple. All the text for the document is stored in a single bit of the Quill CONTENTS. The text is stored as little endian 16 bit unicode strings.(这很简单。文档的所有文本都存储在 Quill CONTENTS 的一个位中。文本存储为 little endian 16 位 unicode 字符串。)
Structure of PLC bit(PLC位的结构)
The first four bytes seem to hold the count of the entries in the bit, and the second four bytes seem to hold the type. There is then some pre-data, and then data for each of the entries, the exact format dependant on the type.(前四个字节似乎保存了位中条目的计数,后四个字节似乎保存了类型。然后是一些预数据,然后是每个条目的数据,确切的格式取决于类型。)
Type 0 has 4 2 byte unsigned ints, then a pair of 2 byte unsigned ints for each entry.(类型 0 有 4 个 2 字节无符号整数,然后每个条目有一对 2 字节无符号整数。)
Type 4 has 4 2 byte unsigned ints, then a pair of 4 byte unsigned ints for each entry.(类型 4 有 4 个 2 字节无符号整数,然后每个条目有一对 4 字节无符号整数。)
Type 8 has 7 2 byte unsigned ints, then a pair of 4 byte unsigned ints for each entry.(类型 8 有 7 个 2 字节无符号整数,然后每个条目有一对 4 字节无符号整数。)
Type 12 holds hyperlinks, and is very much more complex. See org.apache.poi.hpbf.model.qcbits.QCPLCBit for our best guess as to how the contents match up.(类型 12 包含超链接,并且非常复杂。有关内容如何匹配的最佳猜测,请参见 org.apache.poi.hpbf.model.qcbits.QCPLCBit。)
by Nick Burch(通过尼克伯奇)