Bug 59324 - Unable to get a list within a table that is removed when 'Track Changes' is enabled
Summary: Unable to get a list within a table that is removed when 'Track Changes' is e...
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: HWPF (show other bugs)
Version: 3.13-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-14 16:06 UTC by adityagaitonde
Modified: 2016-05-17 19:37 UTC (History)
0 users



Attachments
Sample document to reproduce the issue (72.00 KB, application/msword)
2016-04-14 16:06 UTC, adityagaitonde
Details

Note You need to log in before you can comment on or make changes to this bug.
Description adityagaitonde 2016-04-14 16:06:48 UTC
Created attachment 33762 [details]
Sample document to reproduce the issue

When processing a Word Document with 'Track Changes' enabled, when trying to get a list within a table, we get the following exception.
Sample file is attached and code is as follows

CODE:

import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.HWPFDocumentCore;
import org.apache.poi.hwpf.converter.WordToHtmlConverter;
import org.apache.poi.hwpf.usermodel.HWPFList;
import org.apache.poi.hwpf.usermodel.Paragraph;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File;
import java.io.FileInputStream;

public class PoiIssues {

    public static void main(String[] args) throws Exception {
        File file = new File("C:\\word-doc-revised-with-row-removed.doc");
        FileInputStream fileInputStream = new FileInputStream(file);
        Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
        WordToHtmlConverter wordToHtmlConverter = new MyWordToHtmlConverter(document);
        HWPFDocumentCore hwpfDocumentCore = new HWPFDocument(HWPFDocumentCore.verifyAndBuildPOIFS(fileInputStream));
        wordToHtmlConverter.processDocument(hwpfDocumentCore);
        System.out.println(document.toString());
        System.out.println("Process Complete");
    }

    public static class MyWordToHtmlConverter extends WordToHtmlConverter {
        public MyWordToHtmlConverter(Document document) {
            super(document);
        }

        @Override
        protected void processParagraph( HWPFDocumentCore hwpfDocument,
                                         Element parentElement, int currentTableLevel, Paragraph paragraph,
                                         String bulletText )
        {
            super.processParagraph(hwpfDocument, parentElement, currentTableLevel, paragraph, bulletText);
            HWPFList list = paragraph.getList();
            System.out.println("List " + list);
        }
    }
}

EXCEPTION : 

Exception in thread "main" java.util.NoSuchElementException: LFO with ilfo 47 not found. lfoMac is 38
	at org.apache.poi.hwpf.model.PlfLfo.getLfo(PlfLfo.java:174)
	at org.apache.poi.hwpf.model.ListTables.getLfo(ListTables.java:125)
	at org.apache.poi.hwpf.usermodel.HWPFList.<init>(HWPFList.java:92)
	at org.apache.poi.hwpf.usermodel.Paragraph.getList(Paragraph.java:607)
	at PoiIssues$MyWordToHtmlConverter.processParagraph(PoiIssues.java:39)
	at org.apache.poi.hwpf.converter.AbstractWordConverter.processParagraphes(AbstractWordConverter.java:1111)
	at org.apache.poi.hwpf.converter.WordToHtmlConverter.processTable(WordToHtmlConverter.java:683)
	at org.apache.poi.hwpf.converter.AbstractWordConverter.processParagraphes(AbstractWordConverter.java:1073)
	at org.apache.poi.hwpf.converter.WordToHtmlConverter.processSingleSection(WordToHtmlConverter.java:608)
	at org.apache.poi.hwpf.converter.AbstractWordConverter.processDocument(AbstractWordConverter.java:721)
	at PoiIssues.main(PoiIssues.java:23)