0

有没有办法确定 a 的实例是否org.apache.poi.hwpf.model.ListData属于编号列表或项目符号列表?

我正在使用 Apache Poi 的org.apache.poi.hwpf.HWPFDocument类来读取 word 文档的内容以生成 HTML。我可以通过检查我正在使用的段落是否是org.apache.poi.hwpf.model.ListData. 我找不到确定ListData属于项目符号列表还是编号列表的方法。

4

3 回答 3

0
public class ListTest {

public static void main(String[] args) {

    String filename = "/some/path/to/ListTest.doc";

    try {

        POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(filename));
        HWPFDocument doc = new HWPFDocument(fs);
        //Get a table of all the lists in this document
        ListTables listtables = doc.getListTables();
        Paragraph para;

        Range range = doc.getRange();
        for(int x=0; x<range.numParagraphs(); x++) {
            para = range.getParagraph(x);

           //When non-zero, (1-based) index into the pllfo
           //identifying the list to which the paragraph belongs
           if( para.getIlfo()!=0 ) {
                //Get the list this paragraph belongs to
                ListData listdata = listtables.getListData(para.getIlfo());
                //Now get all the levels for this list
                ListLevel[] listlevel = listdata.getLevels();
                //Find the list level info for our paragraph
                ListLevel level = listlevel[para.getIlvl()];
                System.out.print("Text: \"" + para.text() + "\"");
                //list level for this paragraph
                System.out.print("\tListLevel: " + para.getIlvl());
                //Additional text associated with list symbols
                System.out.print("\tgetNumberText: \"" + level.getNumberText() + "\"" );
                //Format value for the style of list symbols
                System.out.println("\tgetNumberFormat: " + level.getNumberFormat() );
            } else {
                System.out.println();
            }
        }
    } catch(Exception e) {
        e.printStackTrace();
    }
 }
}

nfc值编号方案

15 个单字节字符

16 汉字编号 3 (dbnum3)。

17 汉字编号 4 (dbnum4)。

18 圆编号(circlenum)。

19 双字节阿拉伯编号

20 46 个拼音双字节片假名字符 ( aiueo dbchar)。

21 46 个拼音双字节片假名字符 ( iroha dbchar)。

22 阿拉伯语前导零 (01, 02, 03, ..., 10, 11)

23 子弹(根本没有数字)

24 韩文编号 2(加纳达)。

25 韩文编号 1 (chosung)。

26中文编号1(gb1)。

27中文编号2(gb2)。

28个中文编号3(gb3)。

29中文编号4(gb4)。

30 生肖编号 1

31 生肖编号 2

32生肖编号3

33 台湾双字节编号 1

34 台湾双字节编号 2

35 台湾双字节编号 3

36 台湾双字节编号 4

37 中文双字节编号 1

38 中文双字节编号 2

39 中文双字节编号 3

40 中文双字节编号 4

41 韩文双字节编号 1

42 韩文双字节编号 2

43 韩文双字节编号 3

44 韩文双字节编号 4

45 希伯来语非标准十进制

46 阿拉伯语 Alif Ba Tah

47 希伯来圣经标准

48 阿拉伯语 Abjad 风格

49 个印地语元音

50 个印地语辅音

51 个印地语数字

52 印地语描述(红衣主教)

53 个泰文字母

54个泰国号码

55 泰语描述(红衣主教

56 越南语描述(红衣主教)

57 页码格式 - # -

58 小写俄文字母

于 2010-05-19T09:05:35.967 回答
0

我最近发布了另一种确定列表类型的方法。不幸的是,这种方式只适用于少数测试。

我现在可以确认 leighgorys 确定列表类型的方式。

于 2010-03-05T20:52:10.177 回答
0

我想我已经找到了自己问题的答案。

ListEntry aListEntry = (ListEntry) aParagraph;
ListData listData = listTables.getListData(aListEntry.getIlfo());
int numberFormat = listData.getLevel(listData.numLevels()).getNumberFormat();

数字格式为项目符号返回 23,为编号列表返回 0。我敢说有多种格式的数字可以解释为项目符号或编号列表,但至少我现在可以识别它们!

于 2009-12-16T10:19:33.997 回答