package org.apache.poi.hwpf.usermodel;
public final class TableCell
- extends Range
-{
+ extends Range {
private int _levelNum;
private TableCellDescriptor _tcd;
private int _leftEdge;
private int _width;
- public TableCell( int startIdxInclusive, int endIdxExclusive,
- TableRow parent, int levelNum, TableCellDescriptor tcd,
- int leftEdge, int width )
- {
- super( startIdxInclusive, endIdxExclusive, parent );
- _tcd = tcd;
- _leftEdge = leftEdge;
- _width = width;
- _levelNum = levelNum;
+ public TableCell(int startIdxInclusive, int endIdxExclusive,
+ TableRow parent, int levelNum, TableCellDescriptor tcd,
+ int leftEdge, int width) {
+ super(startIdxInclusive, endIdxExclusive, parent);
+ _tcd = tcd;
+ _leftEdge = leftEdge;
+ _width = width;
+ _levelNum = levelNum;
+ }
+
+ public boolean isFirstMerged() {
+ if (_tcd == null) {
+ return false;
}
- public boolean isFirstMerged()
- {
return _tcd.isFFirstMerged();
}
- public boolean isMerged()
- {
+ public boolean isMerged() {
+ if (_tcd == null) {
+ return false;
+ }
+
return _tcd.isFMerged();
}
- public boolean isVertical()
- {
+ public boolean isVertical() {
+ if (_tcd == null) {
+ return false;
+ }
+
return _tcd.isFVertical();
}
- public boolean isBackward()
- {
+ public boolean isBackward() {
+ if (_tcd == null) {
+ return false;
+ }
+
return _tcd.isFBackward();
}
- public boolean isRotateFont()
- {
+ public boolean isRotateFont() {
+ if (_tcd == null) {
+ return false;
+ }
+
return _tcd.isFRotateFont();
}
- public boolean isVerticallyMerged()
- {
+ public boolean isVerticallyMerged() {
+ if (_tcd == null) {
+ return false;
+ }
+
return _tcd.isFVertMerge();
}
- public boolean isFirstVerticallyMerged()
- {
+ public boolean isFirstVerticallyMerged() {
+ if (_tcd == null) {
+ return false;
+ }
+
return _tcd.isFVertRestart();
}
- public byte getVertAlign()
- {
+ public byte getVertAlign() {
+ if (_tcd == null) {
+ return 0;
+ }
+
return _tcd.getVertAlign();
}
- public BorderCode getBrcTop()
- {
+ public BorderCode getBrcTop() {
+ if (_tcd == null) {
+ return new BorderCode();
+ }
+
return _tcd.getBrcTop();
}
- public BorderCode getBrcBottom()
- {
+ public BorderCode getBrcBottom() {
+ if (_tcd == null) {
+ return new BorderCode();
+ }
+
return _tcd.getBrcBottom();
}
- public BorderCode getBrcLeft()
- {
+ public BorderCode getBrcLeft() {
+ if (_tcd == null) {
+ return new BorderCode();
+ }
+
return _tcd.getBrcLeft();
}
- public BorderCode getBrcRight()
- {
+ public BorderCode getBrcRight() {
+ if (_tcd == null) {
+ return new BorderCode();
+ }
+
return _tcd.getBrcRight();
}
- public int getLeftEdge() // twips
- {
+ // twips
+ public int getLeftEdge() {
return _leftEdge;
}
- public int getWidth() // twips
- {
+ // twips
+ public int getWidth() {
return _width;
}
- /** Returns the TableCellDescriptor for this cell.*/
- public TableCellDescriptor getDescriptor(){
- return _tcd;
+ /**
+ * Returns the TableCellDescriptor for this cell.
+ */
+ public TableCellDescriptor getDescriptor() {
+ return _tcd;
}
-
}
import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
+import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.poi.POIDataSamples;
import org.apache.poi.hwpf.HWPFDocument;
+import org.apache.poi.hwpf.HWPFDocumentCore;
import org.apache.poi.hwpf.HWPFOldDocument;
import org.apache.poi.hwpf.HWPFTestDataSamples;
import org.apache.poi.hwpf.converter.AbstractWordUtils;
+import org.apache.poi.hwpf.converter.WordToHtmlConverter;
import org.apache.poi.hwpf.converter.WordToTextConverter;
import org.apache.poi.hwpf.extractor.Word6Extractor;
import org.apache.poi.hwpf.extractor.WordExtractor;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
* Test different problems reported in the Apache Bugzilla
}
}
}
+
+ @Test
+ public void test60217() throws Exception {
+ File file = new File("/tmp/word-doc-with-revised-table.doc");
+ FileInputStream fileInputStream = new FileInputStream(file);
+ Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+ WordToHtmlConverter wordToHtmlConverter = new WordToHtmlConverter(document);
+ HWPFDocumentCore hwpfDocumentCore = new HWPFDocument(HWPFDocumentCore.verifyAndBuildPOIFS(fileInputStream));
+ wordToHtmlConverter.processDocument(hwpfDocumentCore);
+ System.out.println(document);
+
+ System.out.println(document.getNodeName() + " -> " + document.getNodeValue());
+
+ printNode(document, " ");
+
+ System.out.println("Process Complete");
+ }
+
+ private void printNode(Node rootNode, String spacer) {
+ System.out.println(spacer + rootNode.getNodeName() + " -> " + rootNode.getNodeValue());
+ NodeList nl = rootNode.getChildNodes();
+ for (int i = 0; i < nl.getLength(); i++)
+ printNode(nl.item(i), spacer + " ");
+ }
+
}