:poi-scratchpad - fix javadocs - link to dependent/external project javadocs

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1888746 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2021-04-13 21:37:33 +00:00
parent 240b02daec
commit 088d1dd197
20 changed files with 1097 additions and 1264 deletions

View File

@ -31,6 +31,7 @@ final String VERSIONS9 = 'META-INF/versions/9'
configurations { configurations {
tests tests
javadocs
} }
sourceSets { sourceSets {
@ -56,6 +57,9 @@ dependencies {
testImplementation project(path: ':poi', configuration: 'tests') testImplementation project(path: ':poi', configuration: 'tests')
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}" testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}" testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
javadocs project(':poi')
javadocs project(':poi-ooxml')
} }
final MODULE_NAME = 'org.apache.poi.scratchpad' final MODULE_NAME = 'org.apache.poi.scratchpad'
@ -202,11 +206,20 @@ test {
} }
javadoc { javadoc {
// fails currently, need to fix the sources failOnError = true
failOnError = false doFirst {
// if(JavaVersion.current().isJava9Compatible()) { options {
// options.addBooleanOption('html5', true) if (JavaVersion.current().isJava9Compatible()) {
// } addBooleanOption('html5', true)
}
links 'https://poi.apache.org/apidocs/dev/'
links 'https://docs.oracle.com/javase/8/docs/api/'
use = true
splitIndex = true
source = "1.8"
classpath += configurations.javadocs.files
}
}
} }
publishing { publishing {

View File

@ -99,7 +99,7 @@ public final class HPBFDumper {
/** /**
* Dump out the escher parts of the file. * Dump out the escher parts of the file.
* Escher -> EscherStm and EscherDelayStm * Escher -> EscherStm and EscherDelayStm
*/ */
public void dumpEscher() throws IOException { public void dumpEscher() throws IOException {
DirectoryNode escherDir = (DirectoryNode) DirectoryNode escherDir = (DirectoryNode)

View File

@ -97,7 +97,7 @@ public final class AnimationInfoAtom extends RecordAtom {
/** /**
* Record header. * Record header.
*/ */
private byte[] _header; private final byte[] _header;
/** /**
* record data * record data
@ -246,7 +246,7 @@ public final class AnimationInfoAtom extends RecordAtom {
* A signed integer that specifies the order of the animation in the slide. * A signed integer that specifies the order of the animation in the slide.
* It MUST be greater than or equal to -2. The value -2 specifies that this animation follows the order of * It MUST be greater than or equal to -2. The value -2 specifies that this animation follows the order of
* the corresponding placeholder shape on the main master slide or title master slide. * the corresponding placeholder shape on the main master slide or title master slide.
* The value -1 SHOULD NOT <105> be used. * The value -1 SHOULD NOT be used.
*/ */
public int getOrderID(){ public int getOrderID(){
return LittleEndian.getInt(_recdata, 16); return LittleEndian.getInt(_recdata, 16);
@ -256,7 +256,7 @@ public final class AnimationInfoAtom extends RecordAtom {
* A signed integer that specifies the order of the animation in the slide. * A signed integer that specifies the order of the animation in the slide.
* It MUST be greater than or equal to -2. The value -2 specifies that this animation follows the order of * It MUST be greater than or equal to -2. The value -2 specifies that this animation follows the order of
* the corresponding placeholder shape on the main master slide or title master slide. * the corresponding placeholder shape on the main master slide or title master slide.
* The value -1 SHOULD NOT <105> be used. * The value -1 SHOULD NOT be used.
*/ */
public void setOrderID(int id){ public void setOrderID(int id){
LittleEndian.putInt(_recdata, 16, id); LittleEndian.putInt(_recdata, 16, id);

View File

@ -24,8 +24,10 @@ import java.util.Map;
* List of all known record types in a PowerPoint document, and the * List of all known record types in a PowerPoint document, and the
* classes that handle them. * classes that handle them.
* There are two categories of records: * There are two categories of records:
* <li> PowerPoint records: 0 <= info <= 10002 (will carry class info) * <ul>
* <li> Escher records: info >= 0xF000 (handled by DDF, so no class info) * <li> PowerPoint records: {@code 0 <= info <= 10002} (will carry class info)
* <li> Escher records: {@code info >= 0xF000} (handled by DDF, so no class info)
* </ul>
*/ */
public enum RecordTypes { public enum RecordTypes {
Unknown(0,null), Unknown(0,null),
@ -186,9 +188,9 @@ public enum RecordTypes {
} }
public final short typeID; public final short typeID;
public final RecordConstructor recordConstructor; public final RecordConstructor<?> recordConstructor;
RecordTypes(int typeID, RecordConstructor recordConstructor) { RecordTypes(int typeID, RecordConstructor<?> recordConstructor) {
this.typeID = (short)typeID; this.typeID = (short)typeID;
this.recordConstructor = recordConstructor; this.recordConstructor = recordConstructor;
} }

View File

@ -101,8 +101,8 @@ public class OutlookTextExtractor implements POIOLE2TextExtractor {
} }
try { try {
s.append("From: " + msg.getDisplayFrom() + "\n"); s.append("From: ").append(msg.getDisplayFrom()).append("\n");
} catch (ChunkNotFoundException e) { } catch (ChunkNotFoundException ignored) {
} }
// For To, CC and BCC, try to match the names // For To, CC and BCC, try to match the names
@ -111,15 +111,15 @@ public class OutlookTextExtractor implements POIOLE2TextExtractor {
// people in To + CC + BCC. // people in To + CC + BCC.
try { try {
handleEmails(s, "To", msg.getDisplayTo(), emails); handleEmails(s, "To", msg.getDisplayTo(), emails);
} catch (ChunkNotFoundException e) { } catch (ChunkNotFoundException ignored) {
} }
try { try {
handleEmails(s, "CC", msg.getDisplayCC(), emails); handleEmails(s, "CC", msg.getDisplayCC(), emails);
} catch (ChunkNotFoundException e) { } catch (ChunkNotFoundException ignored) {
} }
try { try {
handleEmails(s, "BCC", msg.getDisplayBCC(), emails); handleEmails(s, "BCC", msg.getDisplayBCC(), emails);
} catch (ChunkNotFoundException e) { } catch (ChunkNotFoundException ignored) {
} }
// Date - try two ways to find it // Date - try two ways to find it
@ -145,7 +145,7 @@ public class OutlookTextExtractor implements POIOLE2TextExtractor {
try { try {
s.append("Subject: ").append(msg.getSubject()).append("\n"); s.append("Subject: ").append(msg.getSubject()).append("\n");
} catch (ChunkNotFoundException e) { } catch (ChunkNotFoundException ignored) {
} }
// Display attachment names // Display attachment names
@ -164,7 +164,7 @@ public class OutlookTextExtractor implements POIOLE2TextExtractor {
try { try {
s.append("\n").append(msg.getTextBody()).append("\n"); s.append("\n").append(msg.getTextBody()).append("\n");
} catch (ChunkNotFoundException e) { } catch (ChunkNotFoundException ignored) {
} }
return s.toString(); return s.toString();
@ -173,7 +173,7 @@ public class OutlookTextExtractor implements POIOLE2TextExtractor {
/** /**
* Takes a Display focused string, eg "Nick; Jim" and an iterator * Takes a Display focused string, eg "Nick; Jim" and an iterator
* of emails, and does its best to return something like * of emails, and does its best to return something like
* "Nick <nick@example.com>; Jim <jim@example.com>" * {@code "Nick <nick@example.com>; Jim <jim@example.com>"}
*/ */
protected void handleEmails(StringBuilder s, String type, String displayText, Iterator<String> emails) { protected void handleEmails(StringBuilder s, String type, String displayText, Iterator<String> emails) {
if (displayText == null || displayText.length() == 0) { if (displayText == null || displayText.length() == 0) {

View File

@ -19,6 +19,7 @@ package org.apache.poi.hssf.converter;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.hssf.util.HSSFColor;
@ -27,17 +28,16 @@ import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.HorizontalAlignment; import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.Beta; import org.apache.poi.util.Internal;
/** /**
* Common class for {@link ExcelToFoUtils} and {@link ExcelToHtmlUtils} * Common class for {@link ExcelToFoConverter} and {@link ExcelToHtmlConverter}
* *
* @author Sergey Vladimirov (vlsergey {at} gmail {dot} com)
* @see AbstractWordUtils * @see AbstractWordUtils
* @since POI 3.8 beta 5 * @since POI 3.8 beta 5
*/ */
@Beta @Internal
public class AbstractExcelUtils { class AbstractExcelUtils {
/*package*/ static final String EMPTY = ""; /*package*/ static final String EMPTY = "";
private static final short EXCEL_COLUMN_WIDTH_FACTOR = 256; private static final short EXCEL_COLUMN_WIDTH_FACTOR = 256;
private static final int UNIT_OFFSET_LENGTH = 7; private static final int UNIT_OFFSET_LENGTH = 7;
@ -45,14 +45,11 @@ public class AbstractExcelUtils {
public static String getAlign(HorizontalAlignment alignment) { public static String getAlign(HorizontalAlignment alignment) {
switch (alignment) { switch (alignment) {
case CENTER: case CENTER:
return "center";
case CENTER_SELECTION: case CENTER_SELECTION:
return "center"; return "center";
case FILL: case FILL:
// XXX: shall we support fill? // XXX: shall we support fill?
return ""; return "";
case GENERAL:
return "";
case JUSTIFY: case JUSTIFY:
return "justify"; return "justify";
case LEFT: case LEFT:
@ -60,6 +57,7 @@ public class AbstractExcelUtils {
case RIGHT: case RIGHT:
return "right"; return "right";
default: default:
case GENERAL:
return ""; return "";
} }
} }
@ -115,24 +113,29 @@ public class AbstractExcelUtils {
StringBuilder stringBuilder = new StringBuilder(7); StringBuilder stringBuilder = new StringBuilder(7);
stringBuilder.append('#'); stringBuilder.append('#');
for (short s : color.getTriplet()) { for (short s : color.getTriplet()) {
if ( s < 10 ) if (s < 10) {
stringBuilder.append('0'); stringBuilder.append('0');
}
stringBuilder.append(Integer.toHexString(s)); stringBuilder.append(Integer.toHexString(s));
} }
String result = stringBuilder.toString(); String result = stringBuilder.toString();
if ( result.equals( "#ffffff" ) ) if (result.equals("#ffffff")) {
return "white"; return "white";
}
if ( result.equals( "#c0c0c0" ) ) if (result.equals("#c0c0c0")) {
return "silver"; return "silver";
}
if ( result.equals( "#808080" ) ) if (result.equals("#808080")) {
return "gray"; return "gray";
}
if ( result.equals( "#000000" ) ) if (result.equals("#000000")) {
return "black"; return "black";
}
return result; return result;
} }
@ -154,9 +157,8 @@ public class AbstractExcelUtils {
} }
/** /**
* @param mergedRanges * @param mergedRanges map of sheet merged ranges built with
* map of sheet merged ranges built with * {@link #buildMergedRangesMap(Sheet)}
* {@link ExcelToHtmlUtils#buildMergedRangesMap(Sheet)}
* @return {@link CellRangeAddress} from map if cell with specified row and * @return {@link CellRangeAddress} from map if cell with specified row and
* column numbers contained in found range, <tt>null</tt> otherwise * column numbers contained in found range, <tt>null</tt> otherwise
*/ */
@ -170,13 +172,11 @@ public class AbstractExcelUtils {
: null; : null;
} }
static boolean isEmpty( String str ) static boolean isEmpty(String str) {
{
return str == null || str.length() == 0; return str == null || str.length() == 0;
} }
static boolean isNotEmpty( String str ) static boolean isNotEmpty(String str) {
{
return !isEmpty(str); return !isEmpty(str);
} }
@ -185,4 +185,53 @@ public class AbstractExcelUtils {
return new HSSFWorkbook(inputStream); return new HSSFWorkbook(inputStream);
} }
} }
public static void appendAlign(StringBuilder style, HorizontalAlignment alignment) {
String cssAlign = getAlign(alignment);
if (isEmpty(cssAlign)) {
return;
}
style.append("text-align:");
style.append(cssAlign);
style.append(";");
}
/**
* Creates a map (i.e. two-dimensional array) filled with ranges. Allow fast
* retrieving {@link CellRangeAddress} of any cell, if cell is contained in
* range.
*
* @see #getMergedRange(CellRangeAddress[][], int, int)
*/
public static CellRangeAddress[][] buildMergedRangesMap(Sheet sheet) {
CellRangeAddress[][] mergedRanges = new CellRangeAddress[1][];
for (final CellRangeAddress cellRangeAddress : sheet.getMergedRegions()) {
final int requiredHeight = cellRangeAddress.getLastRow() + 1;
if (mergedRanges.length < requiredHeight) {
mergedRanges = Arrays.copyOf(mergedRanges, requiredHeight, CellRangeAddress[][].class);
}
for (int r = cellRangeAddress.getFirstRow(); r <= cellRangeAddress
.getLastRow(); r++) {
final int requiredWidth = cellRangeAddress.getLastColumn() + 1;
CellRangeAddress[] rowMerged = mergedRanges[r];
if (rowMerged == null) {
rowMerged = new CellRangeAddress[requiredWidth];
mergedRanges[r] = rowMerged;
} else {
final int rowMergedLength = rowMerged.length;
if (rowMergedLength < requiredWidth) {
rowMerged = mergedRanges[r] =
Arrays.copyOf(rowMerged, requiredWidth, CellRangeAddress[].class);
}
}
Arrays.fill(rowMerged, cellRangeAddress.getFirstColumn(),
cellRangeAddress.getLastColumn() + 1, cellRangeAddress);
}
}
return mergedRanges;
}
} }

View File

@ -16,6 +16,16 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.converter; package org.apache.poi.hssf.converter;
import static org.apache.poi.hssf.converter.AbstractExcelUtils.buildMergedRangesMap;
import static org.apache.poi.hssf.converter.AbstractExcelUtils.getAlign;
import static org.apache.poi.hssf.converter.AbstractExcelUtils.getBorderStyle;
import static org.apache.poi.hssf.converter.AbstractExcelUtils.getBorderWidth;
import static org.apache.poi.hssf.converter.AbstractExcelUtils.getColor;
import static org.apache.poi.hssf.converter.AbstractExcelUtils.getMergedRange;
import static org.apache.poi.hssf.converter.AbstractExcelUtils.isEmpty;
import static org.apache.poi.hssf.converter.AbstractExcelUtils.isNotEmpty;
import static org.apache.poi.hssf.converter.AbstractExcelUtils.loadXls;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -50,12 +60,9 @@ import org.w3c.dom.Text;
/** /**
* Converts xls files (97-2007) to XSL FO. * Converts xls files (97-2007) to XSL FO.
*
* @author Sergey Vladimirov (vlsergey {at} gmail {dot} com)
*/ */
@Beta @Beta
public class ExcelToFoConverter extends AbstractExcelConverter public class ExcelToFoConverter extends AbstractExcelConverter {
{
private static final float CM_PER_INCH = 2.54f; private static final float CM_PER_INCH = 2.54f;
private static final float DPI = 72; private static final float DPI = 72;
@ -67,11 +74,8 @@ public class ExcelToFoConverter extends AbstractExcelConverter
private static final float PAPER_A4_WIDTH_INCHES = 21.0f / CM_PER_INCH; private static final float PAPER_A4_WIDTH_INCHES = 21.0f / CM_PER_INCH;
/** /**
* Java main() interface to interact with {@link ExcelToFoConverter}
*
* <p>
* Usage: ExcelToHtmlConverter infile outfile * Usage: ExcelToHtmlConverter infile outfile
* </p> * <p>
* Where infile is an input .xls file ( Word 97-2007) which will be rendered * Where infile is an input .xls file ( Word 97-2007) which will be rendered
* as XSL FO into outfile * as XSL FO into outfile
*/ */
@ -97,13 +101,11 @@ public class ExcelToFoConverter extends AbstractExcelConverter
/** /**
* Converts Excel file (97-2007) into XSL FO file. * Converts Excel file (97-2007) into XSL FO file.
* *
* @param xlsFile * @param xlsFile file to process
* file to process
* @return DOM representation of result XSL FO * @return DOM representation of result XSL FO
*/ */
public static Document process( File xlsFile ) throws Exception public static Document process(File xlsFile) throws Exception {
{ try (HSSFWorkbook workbook = loadXls(xlsFile)) {
try (HSSFWorkbook workbook = AbstractExcelUtils.loadXls(xlsFile)) {
ExcelToFoConverter excelToHtmlConverter = new ExcelToFoConverter( ExcelToFoConverter excelToHtmlConverter = new ExcelToFoConverter(
XMLHelper.newDocumentBuilder().newDocument()); XMLHelper.newDocumentBuilder().newDocument());
excelToHtmlConverter.processWorkbook(workbook); excelToHtmlConverter.processWorkbook(workbook);
@ -115,31 +117,25 @@ public class ExcelToFoConverter extends AbstractExcelConverter
private float pageMarginInches = 0.4f; private float pageMarginInches = 0.4f;
public ExcelToFoConverter( Document document ) public ExcelToFoConverter(Document document) {
{
this.foDocumentFacade = new FoDocumentFacade(document); this.foDocumentFacade = new FoDocumentFacade(document);
} }
public ExcelToFoConverter( FoDocumentFacade foDocumentFacade ) public ExcelToFoConverter(FoDocumentFacade foDocumentFacade) {
{
this.foDocumentFacade = foDocumentFacade; this.foDocumentFacade = foDocumentFacade;
} }
protected String createPageMaster( float tableWidthIn, String pageMasterName ) protected String createPageMaster(float tableWidthIn, String pageMasterName) {
{
final float paperHeightIn; final float paperHeightIn;
final float paperWidthIn; final float paperWidthIn;
{ {
float requiredWidthIn = tableWidthIn + 2 * getPageMarginInches(); float requiredWidthIn = tableWidthIn + 2 * getPageMarginInches();
if ( requiredWidthIn < PAPER_A4_WIDTH_INCHES ) if (requiredWidthIn < PAPER_A4_WIDTH_INCHES) {
{
// portrait orientation // portrait orientation
paperWidthIn = PAPER_A4_WIDTH_INCHES; paperWidthIn = PAPER_A4_WIDTH_INCHES;
paperHeightIn = PAPER_A4_HEIGHT_INCHES; paperHeightIn = PAPER_A4_HEIGHT_INCHES;
} } else {
else
{
// landscape orientation // landscape orientation
paperWidthIn = requiredWidthIn; paperWidthIn = requiredWidthIn;
paperHeightIn = paperWidthIn paperHeightIn = paperWidthIn
@ -165,13 +161,11 @@ public class ExcelToFoConverter extends AbstractExcelConverter
} }
@Override @Override
protected Document getDocument() protected Document getDocument() {
{
return foDocumentFacade.getDocument(); return foDocumentFacade.getDocument();
} }
public float getPageMarginInches() public float getPageMarginInches() {
{
return pageMarginInches; return pageMarginInches;
} }
@ -194,28 +188,22 @@ public class ExcelToFoConverter extends AbstractExcelConverter
protected boolean processCell(HSSFWorkbook workbook, HSSFCell cell, protected boolean processCell(HSSFWorkbook workbook, HSSFCell cell,
Element tableCellElement, int normalWidthPx, int maxSpannedWidthPx, Element tableCellElement, int normalWidthPx, int maxSpannedWidthPx,
float normalHeightPt ) float normalHeightPt) {
{
final HSSFCellStyle cellStyle = cell.getCellStyle(); final HSSFCellStyle cellStyle = cell.getCellStyle();
String value; String value;
switch ( cell.getCellType() ) switch (cell.getCellType()) {
{
case STRING: case STRING:
// XXX: enrich // XXX: enrich
value = cell.getRichStringCellValue().getString(); value = cell.getRichStringCellValue().getString();
break; break;
case FORMULA: case FORMULA:
switch ( cell.getCachedFormulaResultType() ) switch (cell.getCachedFormulaResultType()) {
{
case STRING: case STRING:
HSSFRichTextString str = cell.getRichStringCellValue(); HSSFRichTextString str = cell.getRichStringCellValue();
if ( str != null && str.length() > 0 ) if (str != null && str.length() > 0) {
{
value = (str.toString()); value = (str.toString());
} } else {
else
{
value = AbstractExcelUtils.EMPTY; value = AbstractExcelUtils.EMPTY;
} }
break; break;
@ -254,7 +242,7 @@ public class ExcelToFoConverter extends AbstractExcelConverter
return true; return true;
} }
final boolean noText = AbstractExcelUtils.isEmpty( value ); final boolean noText = isEmpty(value);
final boolean wrapInDivs = !noText && !cellStyle.getWrapText(); final boolean wrapInDivs = !noText && !cellStyle.getWrapText();
final boolean emptyStyle = isEmptyStyle(cellStyle); final boolean emptyStyle = isEmptyStyle(cellStyle);
@ -267,11 +255,9 @@ public class ExcelToFoConverter extends AbstractExcelConverter
value = "\u00A0"; value = "\u00A0";
} }
if ( isOutputLeadingSpacesAsNonBreaking() && value.startsWith( " " ) ) if (isOutputLeadingSpacesAsNonBreaking() && value.startsWith(" ")) {
{
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
for ( int c = 0; c < value.length(); c++ ) for (int c = 0; c < value.length(); c++) {
{
if (value.charAt(c) != ' ') { if (value.charAt(c) != ' ') {
break; break;
} }
@ -288,16 +274,14 @@ public class ExcelToFoConverter extends AbstractExcelConverter
Text text = foDocumentFacade.createText(value); Text text = foDocumentFacade.createText(value);
Element block = foDocumentFacade.createBlock(); Element block = foDocumentFacade.createBlock();
if ( wrapInDivs ) if (wrapInDivs) {
{
block.setAttribute("absolute-position", "fixed"); block.setAttribute("absolute-position", "fixed");
block.setAttribute("left", "0px"); block.setAttribute("left", "0px");
block.setAttribute("top", "0px"); block.setAttribute("top", "0px");
block.setAttribute("bottom", "0px"); block.setAttribute("bottom", "0px");
block.setAttribute("min-width", normalWidthPx + "px"); block.setAttribute("min-width", normalWidthPx + "px");
if ( maxSpannedWidthPx != Integer.MAX_VALUE ) if (maxSpannedWidthPx != Integer.MAX_VALUE) {
{
block.setAttribute("max-width", maxSpannedWidthPx + "px"); block.setAttribute("max-width", maxSpannedWidthPx + "px");
} }
@ -313,38 +297,35 @@ public class ExcelToFoConverter extends AbstractExcelConverter
block.appendChild(text); block.appendChild(text);
tableCellElement.appendChild(block); tableCellElement.appendChild(block);
return AbstractExcelUtils.isEmpty( value ) && emptyStyle; return isEmpty(value) && emptyStyle;
} }
protected void processCellStyle(HSSFWorkbook workbook, protected void processCellStyle(HSSFWorkbook workbook,
HSSFCellStyle cellStyle, Element cellTarget, Element blockTarget ) HSSFCellStyle cellStyle, Element cellTarget, Element blockTarget) {
{
blockTarget.setAttribute("white-space-collapse", "false"); blockTarget.setAttribute("white-space-collapse", "false");
{ {
String textAlign = AbstractExcelUtils.getAlign( cellStyle.getAlignment() ); String textAlign = getAlign(cellStyle.getAlignment());
if ( AbstractExcelUtils.isNotEmpty( textAlign ) ) if (isNotEmpty(textAlign)) {
blockTarget.setAttribute("text-align", textAlign); blockTarget.setAttribute("text-align", textAlign);
} }
if ( cellStyle.getFillPattern() == FillPatternType.NO_FILL )
{
// no fill
} }
else if ( cellStyle.getFillPattern() == FillPatternType.SOLID_FOREGROUND )
{ if (cellStyle.getFillPattern() == FillPatternType.NO_FILL) {
// no fill
} else if (cellStyle.getFillPattern() == FillPatternType.SOLID_FOREGROUND) {
final HSSFColor foregroundColor = cellStyle final HSSFColor foregroundColor = cellStyle
.getFillForegroundColorColor(); .getFillForegroundColorColor();
if ( foregroundColor != null ) if (foregroundColor != null) {
cellTarget.setAttribute("background-color", cellTarget.setAttribute("background-color",
AbstractExcelUtils.getColor( foregroundColor ) ); getColor(foregroundColor));
} }
else } else {
{
final HSSFColor backgroundColor = cellStyle final HSSFColor backgroundColor = cellStyle
.getFillBackgroundColorColor(); .getFillBackgroundColorColor();
if ( backgroundColor != null ) if (backgroundColor != null) {
cellTarget.setAttribute("background-color", cellTarget.setAttribute("background-color",
AbstractExcelUtils.getColor( backgroundColor ) ); getColor(backgroundColor));
}
} }
processCellStyleBorder(workbook, cellTarget, "top", processCellStyleBorder(workbook, cellTarget, "top",
@ -362,31 +343,29 @@ public class ExcelToFoConverter extends AbstractExcelConverter
} }
protected void processCellStyleBorder(HSSFWorkbook workbook, protected void processCellStyleBorder(HSSFWorkbook workbook,
Element cellTarget, String type, BorderStyle xlsBorder, short borderColor ) Element cellTarget, String type, BorderStyle xlsBorder, short borderColor) {
{ if (xlsBorder == BorderStyle.NONE) {
if ( xlsBorder == BorderStyle.NONE )
return; return;
}
StringBuilder borderStyle = new StringBuilder(); StringBuilder borderStyle = new StringBuilder();
borderStyle.append( AbstractExcelUtils.getBorderWidth( xlsBorder ) ); borderStyle.append(getBorderWidth(xlsBorder));
final HSSFColor color = workbook.getCustomPalette().getColor( final HSSFColor color = workbook.getCustomPalette().getColor(
borderColor); borderColor);
if ( color != null ) if (color != null) {
{
borderStyle.append(' '); borderStyle.append(' ');
borderStyle.append( AbstractExcelUtils.getColor( color ) ); borderStyle.append(getColor(color));
borderStyle.append(' '); borderStyle.append(' ');
borderStyle.append( AbstractExcelUtils.getBorderStyle( xlsBorder ) ); borderStyle.append(getBorderStyle(xlsBorder));
} }
cellTarget.setAttribute("border-" + type, borderStyle.toString()); cellTarget.setAttribute("border-" + type, borderStyle.toString());
} }
protected void processCellStyleFont(HSSFWorkbook workbook, protected void processCellStyleFont(HSSFWorkbook workbook,
Element blockTarget, HSSFFont font ) Element blockTarget, HSSFFont font) {
{
Triplet triplet = new Triplet(); Triplet triplet = new Triplet();
triplet.fontName = font.getFontName(); triplet.fontName = font.getFontName();
triplet.bold = font.getBold(); triplet.bold = font.getBold();
@ -397,34 +376,34 @@ public class ExcelToFoConverter extends AbstractExcelConverter
final HSSFColor fontColor = workbook.getCustomPalette().getColor( final HSSFColor fontColor = workbook.getCustomPalette().getColor(
font.getColor()); font.getColor());
if ( fontColor != null ) if (fontColor != null) {
blockTarget.setAttribute("color", blockTarget.setAttribute("color",
AbstractExcelUtils.getColor( fontColor ) ); getColor(fontColor));
}
if ( font.getFontHeightInPoints() != 0 ) if (font.getFontHeightInPoints() != 0) {
blockTarget.setAttribute("font-size", font.getFontHeightInPoints() blockTarget.setAttribute("font-size", font.getFontHeightInPoints()
+ "pt"); + "pt");
}
} }
protected void processColumnHeaders(HSSFSheet sheet, int maxSheetColumns, protected void processColumnHeaders(HSSFSheet sheet, int maxSheetColumns,
Element table ) Element table) {
{
Element tableHeader = foDocumentFacade.createTableHeader(); Element tableHeader = foDocumentFacade.createTableHeader();
Element row = foDocumentFacade.createTableRow(); Element row = foDocumentFacade.createTableRow();
if ( isOutputRowNumbers() ) if (isOutputRowNumbers()) {
{
// empty cell at left-top corner // empty cell at left-top corner
final Element tableCellElement = foDocumentFacade.createTableCell(); final Element tableCellElement = foDocumentFacade.createTableCell();
tableCellElement.appendChild(foDocumentFacade.createBlock()); tableCellElement.appendChild(foDocumentFacade.createBlock());
row.appendChild(tableCellElement); row.appendChild(tableCellElement);
} }
for ( int c = 0; c < maxSheetColumns; c++ ) for (int c = 0; c < maxSheetColumns; c++) {
{ if (!isOutputHiddenColumns() && sheet.isColumnHidden(c)) {
if ( !isOutputHiddenColumns() && sheet.isColumnHidden( c ) )
continue; continue;
}
Element cell = foDocumentFacade.createTableCell(); Element cell = foDocumentFacade.createTableCell();
Element block = foDocumentFacade.createBlock(); Element block = foDocumentFacade.createBlock();
@ -449,12 +428,10 @@ public class ExcelToFoConverter extends AbstractExcelConverter
* @return table width in inches * @return table width in inches
*/ */
protected float processColumnWidths(HSSFSheet sheet, int maxSheetColumns, protected float processColumnWidths(HSSFSheet sheet, int maxSheetColumns,
Element table ) Element table) {
{
float tableWidth = 0; float tableWidth = 0;
if ( isOutputRowNumbers() ) if (isOutputRowNumbers()) {
{
final float columnWidthIn = getDefaultColumnWidth(sheet) / DPI; final float columnWidthIn = getDefaultColumnWidth(sheet) / DPI;
final Element rowNumberColumn = foDocumentFacade final Element rowNumberColumn = foDocumentFacade
@ -465,10 +442,10 @@ public class ExcelToFoConverter extends AbstractExcelConverter
tableWidth += columnWidthIn; tableWidth += columnWidthIn;
} }
for ( int c = 0; c < maxSheetColumns; c++ ) for (int c = 0; c < maxSheetColumns; c++) {
{ if (!isOutputHiddenColumns() && sheet.isColumnHidden(c)) {
if ( !isOutputHiddenColumns() && sheet.isColumnHidden( c ) )
continue; continue;
}
final float columnWidthIn = getColumnWidth(sheet, c) / DPI; final float columnWidthIn = getColumnWidth(sheet, c) / DPI;
@ -484,56 +461,56 @@ public class ExcelToFoConverter extends AbstractExcelConverter
} }
protected void processDocumentInformation( protected void processDocumentInformation(
SummaryInformation summaryInformation ) SummaryInformation summaryInformation) {
{ if (isNotEmpty(summaryInformation.getTitle())) {
if ( AbstractExcelUtils.isNotEmpty( summaryInformation.getTitle() ) )
foDocumentFacade.setTitle(summaryInformation.getTitle()); foDocumentFacade.setTitle(summaryInformation.getTitle());
}
if ( AbstractExcelUtils.isNotEmpty( summaryInformation.getAuthor() ) ) if (isNotEmpty(summaryInformation.getAuthor())) {
foDocumentFacade.setCreator(summaryInformation.getAuthor()); foDocumentFacade.setCreator(summaryInformation.getAuthor());
}
if ( AbstractExcelUtils.isNotEmpty( summaryInformation.getKeywords() ) ) if (isNotEmpty(summaryInformation.getKeywords())) {
foDocumentFacade.setKeywords(summaryInformation.getKeywords()); foDocumentFacade.setKeywords(summaryInformation.getKeywords());
}
if ( AbstractExcelUtils.isNotEmpty( summaryInformation.getComments() ) ) if (isNotEmpty(summaryInformation.getComments())) {
foDocumentFacade.setDescription(summaryInformation.getComments()); foDocumentFacade.setDescription(summaryInformation.getComments());
} }
}
/** /**
* @return maximum 1-base index of column that were rendered, zero if none * @return maximum 1-base index of column that were rendered, zero if none
*/ */
protected int processRow(HSSFWorkbook workbook, protected int processRow(HSSFWorkbook workbook,
CellRangeAddress[][] mergedRanges, HSSFRow row, CellRangeAddress[][] mergedRanges, HSSFRow row,
Element tableRowElement ) Element tableRowElement) {
{
final HSSFSheet sheet = row.getSheet(); final HSSFSheet sheet = row.getSheet();
final short maxColIx = row.getLastCellNum(); final short maxColIx = row.getLastCellNum();
if ( maxColIx <= 0 ) if (maxColIx <= 0) {
{
return 0; return 0;
} }
final List<Element> emptyCells = new ArrayList<>(maxColIx); final List<Element> emptyCells = new ArrayList<>(maxColIx);
if ( isOutputRowNumbers() ) if (isOutputRowNumbers()) {
{
Element tableRowNumberCellElement = processRowNumber(row); Element tableRowNumberCellElement = processRowNumber(row);
emptyCells.add(tableRowNumberCellElement); emptyCells.add(tableRowNumberCellElement);
} }
int maxRenderedColumn = 0; int maxRenderedColumn = 0;
for ( int colIx = 0; colIx < maxColIx; colIx++ ) for (int colIx = 0; colIx < maxColIx; colIx++) {
{ if (!isOutputHiddenColumns() && sheet.isColumnHidden(colIx)) {
if ( !isOutputHiddenColumns() && sheet.isColumnHidden( colIx ) )
continue; continue;
}
CellRangeAddress range = AbstractExcelUtils.getMergedRange( CellRangeAddress range = getMergedRange(mergedRanges, row.getRowNum(), colIx);
mergedRanges, row.getRowNum(), colIx );
if (range != null if (range != null
&& (range.getFirstColumn() != colIx || range.getFirstRow() != row && (range.getFirstColumn() != colIx || range.getFirstRow() != row
.getRowNum() ) ) .getRowNum())) {
continue; continue;
}
HSSFCell cell = row.getCell(colIx); HSSFCell cell = row.getCell(colIx);
@ -543,15 +520,14 @@ public class ExcelToFoConverter extends AbstractExcelConverter
divWidthPx = getColumnWidth(sheet, colIx); divWidthPx = getColumnWidth(sheet, colIx);
boolean hasBreaks = false; boolean hasBreaks = false;
for ( int nextColumnIndex = colIx + 1; nextColumnIndex < maxColIx; nextColumnIndex++ ) for (int nextColumnIndex = colIx + 1; nextColumnIndex < maxColIx; nextColumnIndex++) {
{
if (!isOutputHiddenColumns() if (!isOutputHiddenColumns()
&& sheet.isColumnHidden( nextColumnIndex ) ) && sheet.isColumnHidden(nextColumnIndex)) {
continue; continue;
}
if (row.getCell(nextColumnIndex) != null if (row.getCell(nextColumnIndex) != null
&& !isTextEmpty( row.getCell( nextColumnIndex ) ) ) && !isTextEmpty(row.getCell(nextColumnIndex))) {
{
hasBreaks = true; hasBreaks = true;
break; break;
} }
@ -559,47 +535,42 @@ public class ExcelToFoConverter extends AbstractExcelConverter
divWidthPx += getColumnWidth(sheet, nextColumnIndex); divWidthPx += getColumnWidth(sheet, nextColumnIndex);
} }
if ( !hasBreaks ) if (!hasBreaks) {
divWidthPx = Integer.MAX_VALUE; divWidthPx = Integer.MAX_VALUE;
} }
}
Element tableCellElement = foDocumentFacade.createTableCell(); Element tableCellElement = foDocumentFacade.createTableCell();
if ( range != null ) if (range != null) {
{ if (range.getFirstColumn() != range.getLastColumn()) {
if ( range.getFirstColumn() != range.getLastColumn() )
tableCellElement.setAttribute( tableCellElement.setAttribute(
"number-columns-spanned", "number-columns-spanned",
String.valueOf(range.getLastColumn() String.valueOf(range.getLastColumn()
- range.getFirstColumn() + 1)); - range.getFirstColumn() + 1));
if ( range.getFirstRow() != range.getLastRow() ) }
if (range.getFirstRow() != range.getLastRow()) {
tableCellElement.setAttribute( tableCellElement.setAttribute(
"number-rows-spanned", "number-rows-spanned",
String.valueOf(range.getLastRow() String.valueOf(range.getLastRow()
- range.getFirstRow() + 1)); - range.getFirstRow() + 1));
} }
}
boolean emptyCell; boolean emptyCell;
if ( cell != null ) if (cell != null) {
{
emptyCell = processCell(workbook, cell, tableCellElement, emptyCell = processCell(workbook, cell, tableCellElement,
getColumnWidth(sheet, colIx), divWidthPx, getColumnWidth(sheet, colIx), divWidthPx,
row.getHeight() / 20f); row.getHeight() / 20f);
} } else {
else
{
tableCellElement.appendChild(foDocumentFacade.createBlock()); tableCellElement.appendChild(foDocumentFacade.createBlock());
emptyCell = true; emptyCell = true;
} }
if ( emptyCell ) if (emptyCell) {
{
emptyCells.add(tableCellElement); emptyCells.add(tableCellElement);
} } else {
else for (Element emptyCellElement : emptyCells) {
{
for ( Element emptyCellElement : emptyCells )
{
tableRowElement.appendChild(emptyCellElement); tableRowElement.appendChild(emptyCellElement);
} }
emptyCells.clear(); emptyCells.clear();
@ -612,8 +583,7 @@ public class ExcelToFoConverter extends AbstractExcelConverter
return maxRenderedColumn + 1; return maxRenderedColumn + 1;
} }
protected Element processRowNumber( HSSFRow row ) protected Element processRowNumber(HSSFRow row) {
{
Element tableRowNumberCellElement = foDocumentFacade.createTableCell(); Element tableRowNumberCellElement = foDocumentFacade.createTableCell();
Element block = foDocumentFacade.createBlock(); Element block = foDocumentFacade.createBlock();
@ -628,11 +598,11 @@ public class ExcelToFoConverter extends AbstractExcelConverter
} }
protected float processSheet(HSSFWorkbook workbook, HSSFSheet sheet, protected float processSheet(HSSFWorkbook workbook, HSSFSheet sheet,
Element flow ) Element flow) {
{
final int physicalNumberOfRows = sheet.getPhysicalNumberOfRows(); final int physicalNumberOfRows = sheet.getPhysicalNumberOfRows();
if ( physicalNumberOfRows <= 0 ) if (physicalNumberOfRows <= 0) {
return 0; return 0;
}
processSheetName(sheet, flow); processSheetName(sheet, flow);
@ -641,21 +611,21 @@ public class ExcelToFoConverter extends AbstractExcelConverter
Element tableBody = foDocumentFacade.createTableBody(); Element tableBody = foDocumentFacade.createTableBody();
final CellRangeAddress[][] mergedRanges = ExcelToHtmlUtils final CellRangeAddress[][] mergedRanges = buildMergedRangesMap(sheet);
.buildMergedRangesMap( sheet );
final List<Element> emptyRowElements = new ArrayList<>( final List<Element> emptyRowElements = new ArrayList<>(
physicalNumberOfRows); physicalNumberOfRows);
int maxSheetColumns = 1; int maxSheetColumns = 1;
for ( int r = sheet.getFirstRowNum(); r <= sheet.getLastRowNum(); r++ ) for (int r = sheet.getFirstRowNum(); r <= sheet.getLastRowNum(); r++) {
{
HSSFRow row = sheet.getRow(r); HSSFRow row = sheet.getRow(r);
if ( row == null ) if (row == null) {
continue; continue;
}
if ( !isOutputHiddenRows() && row.getZeroHeight() ) if (!isOutputHiddenRows() && row.getZeroHeight()) {
continue; continue;
}
Element tableRowElement = foDocumentFacade.createTableRow(); Element tableRowElement = foDocumentFacade.createTableRow();
tableRowElement.setAttribute("height", row.getHeight() / 20f tableRowElement.setAttribute("height", row.getHeight() / 20f
@ -664,23 +634,17 @@ public class ExcelToFoConverter extends AbstractExcelConverter
int maxRowColumnNumber = processRow(workbook, mergedRanges, row, int maxRowColumnNumber = processRow(workbook, mergedRanges, row,
tableRowElement); tableRowElement);
if ( tableRowElement.getChildNodes().getLength() == 0 ) if (tableRowElement.getChildNodes().getLength() == 0) {
{
Element emptyCellElement = foDocumentFacade.createTableCell(); Element emptyCellElement = foDocumentFacade.createTableCell();
emptyCellElement.appendChild(foDocumentFacade.createBlock()); emptyCellElement.appendChild(foDocumentFacade.createBlock());
tableRowElement.appendChild(emptyCellElement); tableRowElement.appendChild(emptyCellElement);
} }
if ( maxRowColumnNumber == 0 ) if (maxRowColumnNumber == 0) {
{
emptyRowElements.add(tableRowElement); emptyRowElements.add(tableRowElement);
} } else {
else if (!emptyRowElements.isEmpty()) {
{ for (Element emptyRowElement : emptyRowElements) {
if ( !emptyRowElements.isEmpty() )
{
for ( Element emptyRowElement : emptyRowElements )
{
tableBody.appendChild(emptyRowElement); tableBody.appendChild(emptyRowElement);
} }
emptyRowElements.clear(); emptyRowElements.clear();
@ -693,8 +657,7 @@ public class ExcelToFoConverter extends AbstractExcelConverter
float tableWidthIn = processColumnWidths(sheet, maxSheetColumns, table); float tableWidthIn = processColumnWidths(sheet, maxSheetColumns, table);
if ( isOutputColumnHeaders() ) if (isOutputColumnHeaders()) {
{
processColumnHeaders(sheet, maxSheetColumns, table); processColumnHeaders(sheet, maxSheetColumns, table);
} }
@ -710,8 +673,7 @@ public class ExcelToFoConverter extends AbstractExcelConverter
* @return <tt>true</tt> if result were added to FO document, <tt>false</tt> * @return <tt>true</tt> if result were added to FO document, <tt>false</tt>
* otherwise * otherwise
*/ */
protected boolean processSheet( HSSFWorkbook workbook, int sheetIndex ) protected boolean processSheet(HSSFWorkbook workbook, int sheetIndex) {
{
String pageMasterName = "sheet-" + sheetIndex; String pageMasterName = "sheet-" + sheetIndex;
Element pageSequence = foDocumentFacade Element pageSequence = foDocumentFacade
@ -722,16 +684,16 @@ public class ExcelToFoConverter extends AbstractExcelConverter
HSSFSheet sheet = workbook.getSheetAt(sheetIndex); HSSFSheet sheet = workbook.getSheetAt(sheetIndex);
float tableWidthIn = processSheet(workbook, sheet, flow); float tableWidthIn = processSheet(workbook, sheet, flow);
if ( tableWidthIn == 0 ) if (tableWidthIn == 0) {
return false; return false;
}
createPageMaster(tableWidthIn, pageMasterName); createPageMaster(tableWidthIn, pageMasterName);
foDocumentFacade.addPageSequence(pageSequence); foDocumentFacade.addPageSequence(pageSequence);
return true; return true;
} }
protected void processSheetName( HSSFSheet sheet, Element flow ) protected void processSheetName(HSSFSheet sheet, Element flow) {
{
Element titleBlock = foDocumentFacade.createBlock(); Element titleBlock = foDocumentFacade.createBlock();
Triplet triplet = new Triplet(); Triplet triplet = new Triplet();
@ -755,35 +717,33 @@ public class ExcelToFoConverter extends AbstractExcelConverter
flow.appendChild(titleBlock2); flow.appendChild(titleBlock2);
} }
public void processWorkbook( HSSFWorkbook workbook ) public void processWorkbook(HSSFWorkbook workbook) {
{
final SummaryInformation summaryInformation = workbook final SummaryInformation summaryInformation = workbook
.getSummaryInformation(); .getSummaryInformation();
if ( summaryInformation != null ) if (summaryInformation != null) {
{
processDocumentInformation(summaryInformation); processDocumentInformation(summaryInformation);
} }
for ( int s = 0; s < workbook.getNumberOfSheets(); s++ ) for (int s = 0; s < workbook.getNumberOfSheets(); s++) {
{
processSheet(workbook, s); processSheet(workbook, s);
} }
} }
private void setBlockProperties( Element textBlock, Triplet triplet ) private void setBlockProperties(Element textBlock, Triplet triplet) {
{ if (triplet.bold) {
if ( triplet.bold )
textBlock.setAttribute("font-weight", "bold"); textBlock.setAttribute("font-weight", "bold");
if ( triplet.italic )
textBlock.setAttribute( "font-style", "italic" );
if ( AbstractExcelUtils.isNotEmpty( triplet.fontName ) )
textBlock.setAttribute( "font-family", triplet.fontName );
} }
public void setPageMarginInches( float pageMarginInches ) if (triplet.italic) {
{ textBlock.setAttribute("font-style", "italic");
}
if (isNotEmpty(triplet.fontName)) {
textBlock.setAttribute("font-family", triplet.fontName);
}
}
public void setPageMarginInches(float pageMarginInches) {
this.pageMarginInches = pageMarginInches; this.pageMarginInches = pageMarginInches;
} }

View File

@ -16,6 +16,16 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.converter; package org.apache.poi.hssf.converter;
import static org.apache.poi.hssf.converter.AbstractExcelUtils.appendAlign;
import static org.apache.poi.hssf.converter.AbstractExcelUtils.buildMergedRangesMap;
import static org.apache.poi.hssf.converter.AbstractExcelUtils.getBorderStyle;
import static org.apache.poi.hssf.converter.AbstractExcelUtils.getBorderWidth;
import static org.apache.poi.hssf.converter.AbstractExcelUtils.getColor;
import static org.apache.poi.hssf.converter.AbstractExcelUtils.getMergedRange;
import static org.apache.poi.hssf.converter.AbstractExcelUtils.isEmpty;
import static org.apache.poi.hssf.converter.AbstractExcelUtils.isNotEmpty;
import static org.apache.poi.hssf.converter.AbstractExcelUtils.loadXls;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -53,8 +63,6 @@ import org.w3c.dom.Text;
/** /**
* Converts xls files (97-2007) to HTML file. * Converts xls files (97-2007) to HTML file.
*
* @author Sergey Vladimirov (vlsergey {at} gmail {dot} com)
*/ */
@Beta @Beta
public class ExcelToHtmlConverter extends AbstractExcelConverter { public class ExcelToHtmlConverter extends AbstractExcelConverter {
@ -92,14 +100,13 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
/** /**
* Converts Excel file (97-2007) into HTML file. * Converts Excel file (97-2007) into HTML file.
* *
* @param xlsFile * @param xlsFile workbook file to process
* workbook file to process
* @return DOM representation of result HTML * @return DOM representation of result HTML
* @throws IOException If an error occurs reading or writing files * @throws IOException If an error occurs reading or writing files
* @throws ParserConfigurationException If configuration is incorrect * @throws ParserConfigurationException If configuration is incorrect
*/ */
public static Document process(File xlsFile) throws IOException, ParserConfigurationException { public static Document process(File xlsFile) throws IOException, ParserConfigurationException {
try (HSSFWorkbook workbook = AbstractExcelUtils.loadXls(xlsFile)) { try (HSSFWorkbook workbook = loadXls(xlsFile)) {
return ExcelToHtmlConverter.process(workbook); return ExcelToHtmlConverter.process(workbook);
} }
} }
@ -145,14 +152,13 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
private String cssClassPrefixTable = "t"; private String cssClassPrefixTable = "t";
private Map<Short, String> excelStyleToClass = new LinkedHashMap<>(); private final Map<Short, String> excelStyleToClass = new LinkedHashMap<>();
private final HtmlDocumentFacade htmlDocumentFacade; private final HtmlDocumentFacade htmlDocumentFacade;
private boolean useDivsToSpan; private boolean useDivsToSpan;
public ExcelToHtmlConverter( Document doc ) public ExcelToHtmlConverter(Document doc) {
{
htmlDocumentFacade = new HtmlDocumentFacade(doc); htmlDocumentFacade = new HtmlDocumentFacade(doc);
} }
@ -164,21 +170,26 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
StringBuilder style = new StringBuilder(); StringBuilder style = new StringBuilder();
style.append("white-space:pre-wrap;"); style.append("white-space:pre-wrap;");
ExcelToHtmlUtils.appendAlign( style, cellStyle.getAlignment() ); appendAlign(style, cellStyle.getAlignment());
switch (cellStyle.getFillPattern()) { switch (cellStyle.getFillPattern()) {
// no fill // no fill
case NO_FILL: break; case NO_FILL:
break;
case SOLID_FOREGROUND: case SOLID_FOREGROUND:
final HSSFColor foregroundColor = cellStyle.getFillForegroundColorColor(); final HSSFColor foregroundColor = cellStyle.getFillForegroundColorColor();
if ( foregroundColor == null ) break; if (foregroundColor == null) {
String fgCol = AbstractExcelUtils.getColor( foregroundColor ); break;
}
String fgCol = getColor(foregroundColor);
style.append("background-color:").append(fgCol).append(";"); style.append("background-color:").append(fgCol).append(";");
break; break;
default: default:
final HSSFColor backgroundColor = cellStyle.getFillBackgroundColorColor(); final HSSFColor backgroundColor = cellStyle.getFillBackgroundColorColor();
if ( backgroundColor == null ) break; if (backgroundColor == null) {
String bgCol = AbstractExcelUtils.getColor( backgroundColor ); break;
}
String bgCol = getColor(backgroundColor);
style.append("background-color:").append(bgCol).append(";"); style.append("background-color:").append(bgCol).append(";");
break; break;
} }
@ -205,16 +216,14 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
} }
StringBuilder borderStyle = new StringBuilder(); StringBuilder borderStyle = new StringBuilder();
borderStyle.append( AbstractExcelUtils.getBorderWidth( xlsBorder ) ); borderStyle.append(getBorderWidth(xlsBorder));
borderStyle.append(' '); borderStyle.append(' ');
borderStyle.append( AbstractExcelUtils.getBorderStyle( xlsBorder ) ); borderStyle.append(getBorderStyle(xlsBorder));
final HSSFColor color = workbook.getCustomPalette().getColor( final HSSFColor color = workbook.getCustomPalette().getColor(borderColor);
borderColor ); if (color != null) {
if ( color != null )
{
borderStyle.append(' '); borderStyle.append(' ');
borderStyle.append( AbstractExcelUtils.getColor( color ) ); borderStyle.append(getColor(color));
} }
style.append("border-").append(type).append(":").append(borderStyle).append(";"); style.append("border-").append(type).append(":").append(borderStyle).append(";");
@ -222,47 +231,42 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
void buildStyle_font(HSSFWorkbook workbook, StringBuilder style, void buildStyle_font(HSSFWorkbook workbook, StringBuilder style,
HSSFFont font) { HSSFFont font) {
if ( font.getBold() ) if (font.getBold()) {
{
style.append("font-weight:bold;"); style.append("font-weight:bold;");
} }
final HSSFColor fontColor = workbook.getCustomPalette().getColor( final HSSFColor fontColor = workbook.getCustomPalette().getColor(
font.getColor()); font.getColor());
if ( fontColor != null ) if (fontColor != null) {
style.append("color: ").append(AbstractExcelUtils.getColor(fontColor)).append("; "); style.append("color: ").append(getColor(fontColor)).append("; ");
}
if ( font.getFontHeightInPoints() != 0 ) if (font.getFontHeightInPoints() != 0) {
style.append("font-size:").append(font.getFontHeightInPoints()).append("pt;"); style.append("font-size:").append(font.getFontHeightInPoints()).append("pt;");
}
if ( font.getItalic() ) if (font.getItalic()) {
{
style.append("font-style:italic;"); style.append("font-style:italic;");
} }
} }
public String getCssClassPrefixCell() public String getCssClassPrefixCell() {
{
return cssClassPrefixCell; return cssClassPrefixCell;
} }
public String getCssClassPrefixDiv() public String getCssClassPrefixDiv() {
{
return cssClassPrefixDiv; return cssClassPrefixDiv;
} }
public String getCssClassPrefixRow() public String getCssClassPrefixRow() {
{
return cssClassPrefixRow; return cssClassPrefixRow;
} }
public String getCssClassPrefixTable() public String getCssClassPrefixTable() {
{
return cssClassPrefixTable; return cssClassPrefixTable;
} }
public Document getDocument() public Document getDocument() {
{
return htmlDocumentFacade.getDocument(); return htmlDocumentFacade.getDocument();
} }
@ -271,8 +275,9 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
final Short cellStyleKey = Short.valueOf(cellStyle.getIndex()); final Short cellStyleKey = Short.valueOf(cellStyle.getIndex());
String knownClass = excelStyleToClass.get(cellStyleKey); String knownClass = excelStyleToClass.get(cellStyleKey);
if ( knownClass != null ) if (knownClass != null) {
return knownClass; return knownClass;
}
String cssStyle = buildStyle(workbook, cellStyle); String cssStyle = buildStyle(workbook, cellStyle);
String cssClass = htmlDocumentFacade.getOrCreateCssClass( String cssClass = htmlDocumentFacade.getOrCreateCssClass(
@ -281,8 +286,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
return cssClass; return cssClass;
} }
public boolean isUseDivsToSpan() public boolean isUseDivsToSpan() {
{
return useDivsToSpan; return useDivsToSpan;
} }
@ -300,12 +304,9 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
switch (cell.getCachedFormulaResultType()) { switch (cell.getCachedFormulaResultType()) {
case STRING: case STRING:
HSSFRichTextString str = cell.getRichStringCellValue(); HSSFRichTextString str = cell.getRichStringCellValue();
if ( str != null && str.length() > 0 ) if (str != null && str.length() > 0) {
{
value = (str.toString()); value = (str.toString());
} } else {
else
{
value = AbstractExcelUtils.EMPTY; value = AbstractExcelUtils.EMPTY;
} }
break; break;
@ -344,7 +345,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
return true; return true;
} }
final boolean noText = AbstractExcelUtils.isEmpty( value ); final boolean noText = isEmpty(value);
final boolean wrapInDivs = !noText && isUseDivsToSpan() && !cellStyle.getWrapText(); final boolean wrapInDivs = !noText && isUseDivsToSpan() && !cellStyle.getWrapText();
if (cellStyle.getIndex() != 0) { if (cellStyle.getIndex() != 0) {
@ -371,15 +372,16 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
if (isOutputLeadingSpacesAsNonBreaking() && value.startsWith(" ")) { if (isOutputLeadingSpacesAsNonBreaking() && value.startsWith(" ")) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
for ( int c = 0; c < value.length(); c++ ) for (int c = 0; c < value.length(); c++) {
{ if (value.charAt(c) != ' ') {
if ( value.charAt( c ) != ' ' )
break; break;
}
builder.append('\u00a0'); builder.append('\u00a0');
} }
if ( value.length() != builder.length() ) if (value.length() != builder.length()) {
builder.append(value.substring(builder.length())); builder.append(value.substring(builder.length()));
}
value = builder.toString(); value = builder.toString();
} }
@ -403,7 +405,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
innerDivStyle.append("overflow:hidden;max-height:"); innerDivStyle.append("overflow:hidden;max-height:");
innerDivStyle.append(normalHeightPt); innerDivStyle.append(normalHeightPt);
innerDivStyle.append("pt;white-space:nowrap;"); innerDivStyle.append("pt;white-space:nowrap;");
ExcelToHtmlUtils.appendAlign( innerDivStyle, cellStyle.getAlignment() ); appendAlign(innerDivStyle, cellStyle.getAlignment());
htmlDocumentFacade.addStyleClass(outerDiv, cssClassPrefixDiv, htmlDocumentFacade.addStyleClass(outerDiv, cssClassPrefixDiv,
innerDivStyle.toString()); innerDivStyle.toString());
@ -414,7 +416,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
tableCellElement.appendChild(text); tableCellElement.appendChild(text);
} }
return AbstractExcelUtils.isEmpty( value ) && (cellStyle.getIndex() == 0); return isEmpty(value) && (cellStyle.getIndex() == 0);
} }
protected void processColumnHeaders(HSSFSheet sheet, int maxSheetColumns, protected void processColumnHeaders(HSSFSheet sheet, int maxSheetColumns,
@ -430,8 +432,9 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
} }
for (int c = 0; c < maxSheetColumns; c++) { for (int c = 0; c < maxSheetColumns; c++) {
if ( !isOutputHiddenColumns() && sheet.isColumnHidden( c ) ) if (!isOutputHiddenColumns() && sheet.isColumnHidden(c)) {
continue; continue;
}
Element th = htmlDocumentFacade.createTableHeaderCell(); Element th = htmlDocumentFacade.createTableHeaderCell();
String text = getColumnName(c); String text = getColumnName(c);
@ -449,14 +452,13 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
Element table) { Element table) {
// draw COLS after we know max column number // draw COLS after we know max column number
Element columnGroup = htmlDocumentFacade.createTableColumnGroup(); Element columnGroup = htmlDocumentFacade.createTableColumnGroup();
if ( isOutputRowNumbers() ) if (isOutputRowNumbers()) {
{
columnGroup.appendChild(htmlDocumentFacade.createTableColumn()); columnGroup.appendChild(htmlDocumentFacade.createTableColumn());
} }
for ( int c = 0; c < maxSheetColumns; c++ ) for (int c = 0; c < maxSheetColumns; c++) {
{ if (!isOutputHiddenColumns() && sheet.isColumnHidden(c)) {
if ( !isOutputHiddenColumns() && sheet.isColumnHidden( c ) )
continue; continue;
}
Element col = htmlDocumentFacade.createTableColumn(); Element col = htmlDocumentFacade.createTableColumn();
col.setAttribute("width", col.setAttribute("width",
@ -467,19 +469,23 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
} }
protected void processDocumentInformation(SummaryInformation summaryInformation) { protected void processDocumentInformation(SummaryInformation summaryInformation) {
if ( AbstractExcelUtils.isNotEmpty( summaryInformation.getTitle() ) ) if (isNotEmpty(summaryInformation.getTitle())) {
htmlDocumentFacade.setTitle(summaryInformation.getTitle()); htmlDocumentFacade.setTitle(summaryInformation.getTitle());
}
if ( AbstractExcelUtils.isNotEmpty( summaryInformation.getAuthor() ) ) if (isNotEmpty(summaryInformation.getAuthor())) {
htmlDocumentFacade.addAuthor(summaryInformation.getAuthor()); htmlDocumentFacade.addAuthor(summaryInformation.getAuthor());
}
if ( AbstractExcelUtils.isNotEmpty( summaryInformation.getKeywords() ) ) if (isNotEmpty(summaryInformation.getKeywords())) {
htmlDocumentFacade.addKeywords(summaryInformation.getKeywords()); htmlDocumentFacade.addKeywords(summaryInformation.getKeywords());
}
if ( AbstractExcelUtils.isNotEmpty( summaryInformation.getComments() ) ) if (isNotEmpty(summaryInformation.getComments())) {
htmlDocumentFacade htmlDocumentFacade
.addDescription(summaryInformation.getComments()); .addDescription(summaryInformation.getComments());
} }
}
/** /**
* @return maximum 1-base index of column that were rendered, zero if none * @return maximum 1-base index of column that were rendered, zero if none
@ -488,13 +494,13 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
Element tableRowElement) { Element tableRowElement) {
final HSSFSheet sheet = row.getSheet(); final HSSFSheet sheet = row.getSheet();
final short maxColIx = row.getLastCellNum(); final short maxColIx = row.getLastCellNum();
if ( maxColIx <= 0 ) if (maxColIx <= 0) {
return 0; return 0;
}
final List<Element> emptyCells = new ArrayList<>(maxColIx); final List<Element> emptyCells = new ArrayList<>(maxColIx);
if ( isOutputRowNumbers() ) if (isOutputRowNumbers()) {
{
Element tableRowNumberCellElement = htmlDocumentFacade Element tableRowNumberCellElement = htmlDocumentFacade
.createTableHeaderCell(); .createTableHeaderCell();
processRowNumber(row, tableRowNumberCellElement); processRowNumber(row, tableRowNumberCellElement);
@ -502,36 +508,34 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
} }
int maxRenderedColumn = 0; int maxRenderedColumn = 0;
for ( int colIx = 0; colIx < maxColIx; colIx++ ) for (int colIx = 0; colIx < maxColIx; colIx++) {
{ if (!isOutputHiddenColumns() && sheet.isColumnHidden(colIx)) {
if ( !isOutputHiddenColumns() && sheet.isColumnHidden( colIx ) )
continue; continue;
}
CellRangeAddress range = AbstractExcelUtils.getMergedRange( CellRangeAddress range = getMergedRange(mergedRanges, row.getRowNum(), colIx);
mergedRanges, row.getRowNum(), colIx );
if (range != null if (range != null
&& (range.getFirstColumn() != colIx || range.getFirstRow() != row && (range.getFirstColumn() != colIx || range.getFirstRow() != row
.getRowNum() ) ) .getRowNum())) {
continue; continue;
}
HSSFCell cell = row.getCell(colIx); HSSFCell cell = row.getCell(colIx);
int divWidthPx = 0; int divWidthPx = 0;
if ( isUseDivsToSpan() ) if (isUseDivsToSpan()) {
{
divWidthPx = getColumnWidth(sheet, colIx); divWidthPx = getColumnWidth(sheet, colIx);
boolean hasBreaks = false; boolean hasBreaks = false;
for ( int nextColumnIndex = colIx + 1; nextColumnIndex < maxColIx; nextColumnIndex++ ) for (int nextColumnIndex = colIx + 1; nextColumnIndex < maxColIx; nextColumnIndex++) {
{
if (!isOutputHiddenColumns() if (!isOutputHiddenColumns()
&& sheet.isColumnHidden( nextColumnIndex ) ) && sheet.isColumnHidden(nextColumnIndex)) {
continue; continue;
}
if (row.getCell(nextColumnIndex) != null if (row.getCell(nextColumnIndex) != null
&& !isTextEmpty( row.getCell( nextColumnIndex ) ) ) && !isTextEmpty(row.getCell(nextColumnIndex))) {
{
hasBreaks = true; hasBreaks = true;
break; break;
} }
@ -539,29 +543,30 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
divWidthPx += getColumnWidth(sheet, nextColumnIndex); divWidthPx += getColumnWidth(sheet, nextColumnIndex);
} }
if ( !hasBreaks ) if (!hasBreaks) {
divWidthPx = Integer.MAX_VALUE; divWidthPx = Integer.MAX_VALUE;
} }
}
Element tableCellElement = htmlDocumentFacade.createTableCell(); Element tableCellElement = htmlDocumentFacade.createTableCell();
if ( range != null ) if (range != null) {
{ if (range.getFirstColumn() != range.getLastColumn()) {
if ( range.getFirstColumn() != range.getLastColumn() )
tableCellElement.setAttribute( tableCellElement.setAttribute(
"colspan", "colspan",
String.valueOf(range.getLastColumn() String.valueOf(range.getLastColumn()
- range.getFirstColumn() + 1)); - range.getFirstColumn() + 1));
if ( range.getFirstRow() != range.getLastRow() ) }
if (range.getFirstRow() != range.getLastRow()) {
tableCellElement.setAttribute( tableCellElement.setAttribute(
"rowspan", "rowspan",
String.valueOf(range.getLastRow() String.valueOf(range.getLastRow()
- range.getFirstRow() + 1)); - range.getFirstRow() + 1));
} }
}
boolean emptyCell; boolean emptyCell;
if ( cell != null ) if (cell != null) {
{
emptyCell = processCell(cell, tableCellElement, emptyCell = processCell(cell, tableCellElement,
getColumnWidth(sheet, colIx), divWidthPx, getColumnWidth(sheet, colIx), divWidthPx,
row.getHeight() / 20f); row.getHeight() / 20f);
@ -572,8 +577,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
if (emptyCell) { if (emptyCell) {
emptyCells.add(tableCellElement); emptyCells.add(tableCellElement);
} else { } else {
for ( Element emptyCellElement : emptyCells ) for (Element emptyCellElement : emptyCells) {
{
tableRowElement.appendChild(emptyCellElement); tableRowElement.appendChild(emptyCellElement);
} }
emptyCells.clear(); emptyCells.clear();
@ -597,8 +601,9 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
processSheetHeader(htmlDocumentFacade.getBody(), sheet); processSheetHeader(htmlDocumentFacade.getBody(), sheet);
final int physicalNumberOfRows = sheet.getPhysicalNumberOfRows(); final int physicalNumberOfRows = sheet.getPhysicalNumberOfRows();
if ( physicalNumberOfRows <= 0 ) if (physicalNumberOfRows <= 0) {
return; return;
}
Element table = htmlDocumentFacade.createTable(); Element table = htmlDocumentFacade.createTable();
htmlDocumentFacade.addStyleClass(table, cssClassPrefixTable, htmlDocumentFacade.addStyleClass(table, cssClassPrefixTable,
@ -606,8 +611,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
Element tableBody = htmlDocumentFacade.createTableBody(); Element tableBody = htmlDocumentFacade.createTableBody();
final CellRangeAddress[][] mergedRanges = ExcelToHtmlUtils final CellRangeAddress[][] mergedRanges = buildMergedRangesMap(sheet);
.buildMergedRangesMap( sheet );
final List<Element> emptyRowElements = new ArrayList<>( final List<Element> emptyRowElements = new ArrayList<>(
physicalNumberOfRows); physicalNumberOfRows);
@ -615,11 +619,13 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
for (int r = sheet.getFirstRowNum(); r <= sheet.getLastRowNum(); r++) { for (int r = sheet.getFirstRowNum(); r <= sheet.getLastRowNum(); r++) {
HSSFRow row = sheet.getRow(r); HSSFRow row = sheet.getRow(r);
if ( row == null ) if (row == null) {
continue; continue;
}
if ( !isOutputHiddenRows() && row.getZeroHeight() ) if (!isOutputHiddenRows() && row.getZeroHeight()) {
continue; continue;
}
Element tableRowElement = htmlDocumentFacade.createTableRow(); Element tableRowElement = htmlDocumentFacade.createTableRow();
htmlDocumentFacade.addStyleClass(tableRowElement, htmlDocumentFacade.addStyleClass(tableRowElement,
@ -685,23 +691,19 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
htmlDocumentFacade.updateStylesheet(); htmlDocumentFacade.updateStylesheet();
} }
public void setCssClassPrefixCell( String cssClassPrefixCell ) public void setCssClassPrefixCell(String cssClassPrefixCell) {
{
this.cssClassPrefixCell = cssClassPrefixCell; this.cssClassPrefixCell = cssClassPrefixCell;
} }
public void setCssClassPrefixDiv( String cssClassPrefixDiv ) public void setCssClassPrefixDiv(String cssClassPrefixDiv) {
{
this.cssClassPrefixDiv = cssClassPrefixDiv; this.cssClassPrefixDiv = cssClassPrefixDiv;
} }
public void setCssClassPrefixRow( String cssClassPrefixRow ) public void setCssClassPrefixRow(String cssClassPrefixRow) {
{
this.cssClassPrefixRow = cssClassPrefixRow; this.cssClassPrefixRow = cssClassPrefixRow;
} }
public void setCssClassPrefixTable( String cssClassPrefixTable ) public void setCssClassPrefixTable(String cssClassPrefixTable) {
{
this.cssClassPrefixTable = cssClassPrefixTable; this.cssClassPrefixTable = cssClassPrefixTable;
} }
@ -713,8 +715,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
* with INDENT=YES option, because line breaks will make additional * with INDENT=YES option, because line breaks will make additional
* (unwanted) changes * (unwanted) changes
*/ */
public void setUseDivsToSpan( boolean useDivsToSpan ) public void setUseDivsToSpan(boolean useDivsToSpan) {
{
this.useDivsToSpan = useDivsToSpan; this.useDivsToSpan = useDivsToSpan;
} }
} }

View File

@ -1,75 +0,0 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hssf.converter;
import java.util.Arrays;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.Beta;
@Beta
public class ExcelToHtmlUtils extends AbstractExcelUtils {
public static void appendAlign( StringBuilder style, HorizontalAlignment alignment ) {
String cssAlign = getAlign( alignment );
if ( isEmpty( cssAlign ) )
return;
style.append( "text-align:" );
style.append( cssAlign );
style.append( ";" );
}
/**
* Creates a map (i.e. two-dimensional array) filled with ranges. Allow fast
* retrieving {@link CellRangeAddress} of any cell, if cell is contained in
* range.
*
* @see #getMergedRange(CellRangeAddress[][], int, int)
*/
public static CellRangeAddress[][] buildMergedRangesMap( Sheet sheet ) {
CellRangeAddress[][] mergedRanges = new CellRangeAddress[1][];
for ( final CellRangeAddress cellRangeAddress : sheet.getMergedRegions() ) {
final int requiredHeight = cellRangeAddress.getLastRow() + 1;
if ( mergedRanges.length < requiredHeight ) {
mergedRanges = Arrays.copyOf(mergedRanges, requiredHeight, CellRangeAddress[][].class);
}
for ( int r = cellRangeAddress.getFirstRow(); r <= cellRangeAddress
.getLastRow(); r++ ) {
final int requiredWidth = cellRangeAddress.getLastColumn() + 1;
CellRangeAddress[] rowMerged = mergedRanges[r];
if ( rowMerged == null ) {
rowMerged = new CellRangeAddress[requiredWidth];
mergedRanges[r] = rowMerged;
} else {
final int rowMergedLength = rowMerged.length;
if ( rowMergedLength < requiredWidth ) {
rowMerged = mergedRanges[r] =
Arrays.copyOf(rowMerged, requiredWidth, CellRangeAddress[].class);
}
}
Arrays.fill( rowMerged, cellRangeAddress.getFirstColumn(),
cellRangeAddress.getLastColumn() + 1, cellRangeAddress );
}
}
return mergedRanges;
}
}

View File

@ -58,7 +58,7 @@ public class HwmfBitmapDib implements GenericRecord {
public enum BitCount { public enum BitCount {
/** /**
* The image SHOULD be in either JPEG or PNG format. <6> Neither of these formats includes * The image SHOULD be in either JPEG or PNG format. Neither of these formats includes
* a color table, so this value specifies that no color table is present. See [JFIF] and [RFC2083] * a color table, so this value specifies that no color table is present. See [JFIF] and [RFC2083]
* for more information concerning JPEG and PNG compression formats. * for more information concerning JPEG and PNG compression formats.
*/ */
@ -257,7 +257,7 @@ public class HwmfBitmapDib implements GenericRecord {
headerCompression == Compression.BI_RGB || headerCompression == Compression.BI_RGB ||
headerCompression == Compression.BI_BITFIELDS || headerCompression == Compression.BI_BITFIELDS ||
headerCompression == Compression.BI_CMYK) { headerCompression == Compression.BI_CMYK) {
int fileSize = (int)Math.min(introSize+bodySize,recordSize); int fileSize = Math.min(introSize+bodySize,recordSize);
imageData = IOUtils.safelyAllocate(fileSize, MAX_RECORD_LENGTH); imageData = IOUtils.safelyAllocate(fileSize, MAX_RECORD_LENGTH);
leis.readFully(imageData, 0, introSize); leis.readFully(imageData, 0, introSize);
leis.skipFully(recordSize-fileSize); leis.skipFully(recordSize-fileSize);
@ -271,10 +271,10 @@ public class HwmfBitmapDib implements GenericRecord {
} }
} }
protected int readHeader(LittleEndianInputStream leis) throws IOException { protected int readHeader(LittleEndianInputStream leis) {
int size = 0; int size = 0;
/** /*
* DIBHeaderInfo (variable): Either a BitmapCoreHeader Object or a * DIBHeaderInfo (variable): Either a BitmapCoreHeader Object or a
* BitmapInfoHeader Object that specifies information about the image. * BitmapInfoHeader Object that specifies information about the image.
* *

View File

@ -205,7 +205,7 @@ public final class WordExtractor implements POIOLE2TextExtractor {
/** /**
* Grab the text out of the text pieces. Might also include various bits of * Grab the text out of the text pieces. Might also include various bits of
* crud, but will work in cases where the text piece -> paragraph mapping is * crud, but will work in cases where the text piece -&gt; paragraph mapping is
* broken. Fast too. * broken. Fast too.
*/ */
public String getTextFromPieces() { public String getTextFromPieces() {

View File

@ -50,7 +50,7 @@ public interface CharIndexTranslator {
boolean isIndexInTable(int bytePos); boolean isIndexInTable(int bytePos);
/** /**
* Return first index >= bytePos that is in table * Return first index &gt;= bytePos that is in table
* *
* @param bytePos * @param bytePos
* @return first index greater or equal to bytePos that is in table * @return first index greater or equal to bytePos that is in table
@ -58,7 +58,7 @@ public interface CharIndexTranslator {
int lookIndexForward(int bytePos); int lookIndexForward(int bytePos);
/** /**
* Return last index <= bytePos that is in table * Return last index &lt;= bytePos that is in table
* *
* @param bytePos * @param bytePos
* @return last index less of equal to bytePos that is in table * @return last index less of equal to bytePos that is in table

View File

@ -137,7 +137,7 @@ public final class ListTables
/** /**
* Get the ListLevel for a given lsid and level * Get the ListLevel for a given lsid and level
* @return ListLevel if found, or <code>null</code> if ListData can't be found or if level is > that available * @return ListLevel if found, or {@code null} if ListData can't be found or if level is &gt; that available
*/ */
public ListLevel getLevel(int lsid, int level) public ListLevel getLevel(int lsid, int level)
{ {

View File

@ -17,6 +17,8 @@
package org.apache.poi.hwpf.model; package org.apache.poi.hwpf.model;
import static org.apache.logging.log4j.util.Unbox.box;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -36,13 +38,11 @@ import org.apache.poi.hwpf.usermodel.Range;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import static org.apache.logging.log4j.util.Unbox.box;
/** /**
* Holds information about all pictures embedded in Word Document either via "Insert -> Picture -> From File" or via * Holds information about all pictures embedded in Word Document either via "Insert -&gt; Picture -&gt; From File" or via
* clipboard. Responsible for images extraction and determining whether some document's piece contains embedded image. * clipboard. Responsible for images extraction and determining whether some document's piece contains embedded image.
* Analyzes raw data bytestream 'Data' (where Word stores all embedded objects) provided by HWPFDocument. * Analyzes raw data bytestream 'Data' (where Word stores all embedded objects) provided by HWPFDocument.
* * <p>
* Word stores images as is within so called "Data stream" - the stream within a Word docfile containing various data * Word stores images as is within so called "Data stream" - the stream within a Word docfile containing various data
* that hang off of characters in the main stream. For example, binary data describing in-line pictures and/or * that hang off of characters in the main stream. For example, binary data describing in-line pictures and/or
* formfields an also embedded objects-native data. Word picture structures are concatenated one after the other in * formfields an also embedded objects-native data. Word picture structures are concatenated one after the other in
@ -67,26 +67,16 @@ public final class PicturesTable {
static final int BLOCK_TYPE_OFFSET = 0xE; static final int BLOCK_TYPE_OFFSET = 0xE;
static final int MM_MODE_TYPE_OFFSET = 0x6; static final int MM_MODE_TYPE_OFFSET = 0x6;
private HWPFDocument _document; private final HWPFDocument _document;
private byte[] _dataStream; private final byte[] _dataStream;
private byte[] _mainStream; private final byte[] _mainStream;
@Deprecated @Deprecated
private FSPATable _fspa; private FSPATable _fspa;
@Deprecated @Deprecated
private OfficeArtContent _dgg; private OfficeArtContent _dgg;
/** @link dependency
* @stereotype instantiate*/
/*# Picture lnkPicture; */
/**
*
* @param _document
* @param _dataStream
*/
@Deprecated @Deprecated
public PicturesTable(HWPFDocument _document, byte[] _dataStream, byte[] _mainStream, FSPATable fspa, OfficeArtContent dgg) public PicturesTable(HWPFDocument _document, byte[] _dataStream, byte[] _mainStream, FSPATable fspa, OfficeArtContent dgg) {
{
this._document = _document; this._document = _document;
this._dataStream = _dataStream; this._dataStream = _dataStream;
this._mainStream = _mainStream; this._mainStream = _mainStream;
@ -95,8 +85,7 @@ public final class PicturesTable {
} }
public PicturesTable(HWPFDocument _document, byte[] _dataStream, public PicturesTable(HWPFDocument _document, byte[] _dataStream,
byte[] _mainStream ) byte[] _mainStream) {
{
this._document = _document; this._document = _document;
this._dataStream = _dataStream; this._dataStream = _dataStream;
this._mainStream = _mainStream; this._mainStream = _mainStream;
@ -104,7 +93,6 @@ public final class PicturesTable {
/** /**
* determines whether specified CharacterRun contains reference to a picture * determines whether specified CharacterRun contains reference to a picture
* @param run
*/ */
public boolean hasPicture(CharacterRun run) { public boolean hasPicture(CharacterRun run) {
if (run == null) { if (run == null) {
@ -121,15 +109,11 @@ public final class PicturesTable {
} }
public boolean hasEscherPicture(CharacterRun run) { public boolean hasEscherPicture(CharacterRun run) {
if (run.isSpecialCharacter() && !run.isObj() && !run.isOle2() && !run.isData() && run.text().startsWith("\u0008")) { return run.isSpecialCharacter() && !run.isObj() && !run.isOle2() && !run.isData() && run.text().startsWith("\u0008");
return true;
}
return false;
} }
/** /**
* determines whether specified CharacterRun contains reference to a picture * determines whether specified CharacterRun contains reference to a picture
* @param run
*/ */
public boolean hasHorizontalLine(CharacterRun run) { public boolean hasHorizontalLine(CharacterRun run) {
if (run.isSpecialCharacter() && "\u0001".equals(run.text())) { if (run.isSpecialCharacter() && "\u0001".equals(run.text())) {
@ -139,7 +123,10 @@ public final class PicturesTable {
} }
private boolean isPictureRecognized(short blockType, short mappingModeOfMETAFILEPICT) { private boolean isPictureRecognized(short blockType, short mappingModeOfMETAFILEPICT) {
return (blockType == TYPE_IMAGE || blockType == TYPE_IMAGE_PASTED_FROM_CLIPBOARD || (blockType==TYPE_IMAGE_WORD2000 && mappingModeOfMETAFILEPICT==0x64) || (blockType==TYPE_IMAGE_PASTED_FROM_CLIPBOARD_WORD2000 && mappingModeOfMETAFILEPICT==0x64)); return blockType == TYPE_IMAGE
|| blockType == TYPE_IMAGE_PASTED_FROM_CLIPBOARD
|| blockType == TYPE_IMAGE_WORD2000 && mappingModeOfMETAFILEPICT == 0x64
|| blockType == TYPE_IMAGE_PASTED_FROM_CLIPBOARD_WORD2000 && mappingModeOfMETAFILEPICT == 0x64;
} }
private static short getBlockType(byte[] dataStream, int pictOffset) { private static short getBlockType(byte[] dataStream, int pictOffset) {
@ -152,11 +139,11 @@ public final class PicturesTable {
/** /**
* Returns picture object tied to specified CharacterRun * Returns picture object tied to specified CharacterRun
* @param run *
* @param fillBytes if true, Picture will be returned with filled byte array that represent picture's contents. If you don't want * @param fillBytes if true, Picture will be returned with filled byte array that represent picture's contents. If you don't want
* to have that byte array in memory but only write picture's contents to stream, pass false and then use Picture.writeImageContent * to have that byte array in memory but only write picture's contents to stream, pass false and then use Picture.writeImageContent
* @see Picture#writeImageContent(OutputStream)
* @return a Picture object if picture exists for specified CharacterRun, null otherwise. PicturesTable.hasPicture is used to determine this. * @return a Picture object if picture exists for specified CharacterRun, null otherwise. PicturesTable.hasPicture is used to determine this.
* @see Picture#writeImageContent(OutputStream)
* @see #hasPicture(CharacterRun) * @see #hasPicture(CharacterRun)
*/ */
public Picture extractPicture(CharacterRun run, boolean fillBytes) { public Picture extractPicture(CharacterRun run, boolean fillBytes) {
@ -172,36 +159,28 @@ public final class PicturesTable {
* @param escherRecords the escher records. * @param escherRecords the escher records.
* @param pictures the list to populate with the pictures. * @param pictures the list to populate with the pictures.
*/ */
private void searchForPictures(List<EscherRecord> escherRecords, List<Picture> pictures) private void searchForPictures(List<EscherRecord> escherRecords, List<Picture> pictures) {
{
for (EscherRecord escherRecord : escherRecords) { for (EscherRecord escherRecord : escherRecords) {
if (escherRecord instanceof EscherBSERecord) { if (escherRecord instanceof EscherBSERecord) {
EscherBSERecord bse = (EscherBSERecord) escherRecord; EscherBSERecord bse = (EscherBSERecord) escherRecord;
EscherBlipRecord blip = bse.getBlipRecord(); EscherBlipRecord blip = bse.getBlipRecord();
if (blip != null) if (blip != null) {
{
pictures.add(new Picture(blip)); pictures.add(new Picture(blip));
} } else if (bse.getOffset() > 0) {
else if ( bse.getOffset() > 0 ) try {
{
try
{
// Blip stored in delay stream, which in a word doc, is // Blip stored in delay stream, which in a word doc, is
// the main stream // the main stream
EscherRecordFactory recordFactory = new DefaultEscherRecordFactory(); EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
EscherRecord record = recordFactory.createRecord( EscherRecord record = recordFactory.createRecord(
_mainStream, bse.getOffset()); _mainStream, bse.getOffset());
if ( record instanceof EscherBlipRecord ) if (record instanceof EscherBlipRecord) {
{
record.fillFields(_mainStream, bse.getOffset(), record.fillFields(_mainStream, bse.getOffset(),
recordFactory); recordFactory);
blip = (EscherBlipRecord) record; blip = (EscherBlipRecord) record;
pictures.add(new Picture(blip)); pictures.add(new Picture(blip));
} }
} } catch (Exception exc) {
catch ( Exception exc )
{
LOG.atWarn().withThrowable(exc).log("Unable to load picture from BLIP record at offset #{}", box(bse.getOffset())); LOG.atWarn().withThrowable(exc).log("Unable to load picture from BLIP record at offset #{}", box(bse.getOffset()));
} }
} }
@ -240,13 +219,11 @@ public final class PicturesTable {
return pictures; return pictures;
} }
private boolean isBlockContainsImage(int i) private boolean isBlockContainsImage(int i) {
{
return isPictureRecognized(getBlockType(_dataStream, i), getMmMode(_dataStream, i)); return isPictureRecognized(getBlockType(_dataStream, i), getMmMode(_dataStream, i));
} }
private boolean isBlockContainsHorizontalLine(int i) private boolean isBlockContainsHorizontalLine(int i) {
{
return getBlockType(_dataStream, i) == TYPE_HORIZONTAL_LINE && getMmMode(_dataStream, i) == 0x64; return getBlockType(_dataStream, i) == TYPE_HORIZONTAL_LINE && getMmMode(_dataStream, i) == 0x64;
} }

View File

@ -56,17 +56,13 @@ public abstract class FRDAbstractType {
public String toString() public String toString()
{ {
StringBuilder builder = new StringBuilder(); return "[FRD]\n" +
builder.append( "[FRD]\n" ); " .nAuto = (" + getNAuto() + " )\n" +
builder.append( " .nAuto = " ); "[/FRD]\n";
builder.append( " (" ).append( getNAuto() ).append( " )\n" );
builder.append( "[/FRD]\n" );
return builder.toString();
} }
/** /**
* If > 0, the note is an automatically numbered note, otherwise it has a * If &gt; 0, the note is an automatically numbered note, otherwise it has a
* custom mark. * custom mark.
*/ */
public short getNAuto() public short getNAuto()
@ -75,7 +71,7 @@ public abstract class FRDAbstractType {
} }
/** /**
* If > 0, the note is an automatically numbered note, otherwise it has a * If &gt; 0, the note is an automatically numbered note, otherwise it has a
* custom mark. * custom mark.
*/ */
public void setNAuto( short field_1_nAuto ) public void setNAuto( short field_1_nAuto )
@ -83,4 +79,4 @@ public abstract class FRDAbstractType {
this.field_1_nAuto = field_1_nAuto; this.field_1_nAuto = field_1_nAuto;
} }
} // END OF CLASS }

View File

@ -81,7 +81,7 @@ public abstract class GrfhicAbstractType
*/ */
public static int getSize() public static int getSize()
{ {
return 0 + 1; return 1;
} }
@Override @Override
@ -94,9 +94,7 @@ public abstract class GrfhicAbstractType
if ( getClass() != obj.getClass() ) if ( getClass() != obj.getClass() )
return false; return false;
GrfhicAbstractType other = (GrfhicAbstractType) obj; GrfhicAbstractType other = (GrfhicAbstractType) obj;
if ( field_1_grfhic != other.field_1_grfhic ) return field_1_grfhic == other.field_1_grfhic;
return false;
return true;
} }
@Override @Override
@ -106,22 +104,19 @@ public abstract class GrfhicAbstractType
public String toString() public String toString()
{ {
StringBuilder builder = new StringBuilder(); String builder = "[Grfhic]\n" +
" .grfhic = " +
builder.append("[Grfhic]\n"); " ( " + field_1_grfhic + " )\n" +
builder.append( " .grfhic = " ); " .fHtmlChecked = " + isFHtmlChecked() + '\n' +
builder.append(" ( ").append( field_1_grfhic ).append( " )\n" ); " .fHtmlUnsupported = " + isFHtmlUnsupported() + '\n' +
builder.append(" .fHtmlChecked = ").append(isFHtmlChecked()).append('\n'); " .fHtmlListTextNotSharpDot = " + isFHtmlListTextNotSharpDot() + '\n' +
builder.append(" .fHtmlUnsupported = ").append(isFHtmlUnsupported()).append('\n'); " .fHtmlNotPeriod = " + isFHtmlNotPeriod() + '\n' +
builder.append(" .fHtmlListTextNotSharpDot = ").append(isFHtmlListTextNotSharpDot()).append('\n'); " .fHtmlFirstLineMismatch = " + isFHtmlFirstLineMismatch() + '\n' +
builder.append(" .fHtmlNotPeriod = ").append(isFHtmlNotPeriod()).append('\n'); " .fHtmlTabLeftIndentMismatch = " + isFHtmlTabLeftIndentMismatch() + '\n' +
builder.append(" .fHtmlFirstLineMismatch = ").append(isFHtmlFirstLineMismatch()).append('\n'); " .fHtmlHangingIndentBeneathNumber = " + isFHtmlHangingIndentBeneathNumber() + '\n' +
builder.append(" .fHtmlTabLeftIndentMismatch = ").append(isFHtmlTabLeftIndentMismatch()).append('\n'); " .fHtmlBuiltInBullet = " + isFHtmlBuiltInBullet() + '\n' +
builder.append(" .fHtmlHangingIndentBeneathNumber = ").append(isFHtmlHangingIndentBeneathNumber()).append('\n'); "[/Grfhic]";
builder.append(" .fHtmlBuiltInBullet = ").append(isFHtmlBuiltInBullet()).append('\n'); return builder;
builder.append("[/Grfhic]");
return builder.toString();
} }
/** /**
@ -164,7 +159,7 @@ public abstract class GrfhicAbstractType
/** /**
* Sets the fHtmlUnsupported field value. * Sets the fHtmlUnsupported field value.
* The numbering sequence or format is unsupported (includes tab & size) * The numbering sequence or format is unsupported (includes tab &amp; size)
*/ */
@Internal @Internal
public void setFHtmlUnsupported( boolean value ) public void setFHtmlUnsupported( boolean value )
@ -173,7 +168,7 @@ public abstract class GrfhicAbstractType
} }
/** /**
* The numbering sequence or format is unsupported (includes tab & size) * The numbering sequence or format is unsupported (includes tab &amp; size)
* @return the fHtmlUnsupported field value. * @return the fHtmlUnsupported field value.
*/ */
@Internal @Internal

View File

@ -247,174 +247,91 @@ public abstract class PAPAbstractType {
} }
public String toString() public String toString() {
{ return "[PAP]\n" +
StringBuilder builder = new StringBuilder(); " .istd = (" + getIstd() + " )\n" +
builder.append("[PAP]\n"); " .fSideBySide = (" + getFSideBySide() + " )\n" +
builder.append(" .istd = "); " .fKeep = (" + getFKeep() + " )\n" +
builder.append(" (").append(getIstd()).append(" )\n"); " .fKeepFollow = (" + getFKeepFollow() + " )\n" +
builder.append(" .fSideBySide = "); " .fPageBreakBefore = (" + getFPageBreakBefore() + " )\n" +
builder.append(" (").append(getFSideBySide()).append(" )\n"); " .brcl = (" + getBrcl() + " )\n" +
builder.append(" .fKeep = "); " .brcp = (" + getBrcp() + " )\n" +
builder.append(" (").append(getFKeep()).append(" )\n"); " .ilvl = (" + getIlvl() + " )\n" +
builder.append(" .fKeepFollow = "); " .ilfo = (" + getIlfo() + " )\n" +
builder.append(" (").append(getFKeepFollow()).append(" )\n"); " .fNoLnn = (" + getFNoLnn() + " )\n" +
builder.append(" .fPageBreakBefore = "); " .lspd = (" + getLspd() + " )\n" +
builder.append(" (").append(getFPageBreakBefore()).append(" )\n"); " .dyaBefore = (" + getDyaBefore() + " )\n" +
builder.append(" .brcl = "); " .dyaAfter = (" + getDyaAfter() + " )\n" +
builder.append(" (").append(getBrcl()).append(" )\n"); " .fInTable = (" + getFInTable() + " )\n" +
builder.append(" .brcp = "); " .finTableW97 = (" + getFinTableW97() + " )\n" +
builder.append(" (").append(getBrcp()).append(" )\n"); " .fTtp = (" + getFTtp() + " )\n" +
builder.append(" .ilvl = "); " .dxaAbs = (" + getDxaAbs() + " )\n" +
builder.append(" (").append(getIlvl()).append(" )\n"); " .dyaAbs = (" + getDyaAbs() + " )\n" +
builder.append(" .ilfo = "); " .dxaWidth = (" + getDxaWidth() + " )\n" +
builder.append(" (").append(getIlfo()).append(" )\n"); " .fBrLnAbove = (" + getFBrLnAbove() + " )\n" +
builder.append(" .fNoLnn = "); " .fBrLnBelow = (" + getFBrLnBelow() + " )\n" +
builder.append(" (").append(getFNoLnn()).append(" )\n"); " .pcVert = (" + getPcVert() + " )\n" +
builder.append(" .lspd = "); " .pcHorz = (" + getPcHorz() + " )\n" +
builder.append(" (").append(getLspd()).append(" )\n"); " .wr = (" + getWr() + " )\n" +
builder.append(" .dyaBefore = "); " .fNoAutoHyph = (" + getFNoAutoHyph() + " )\n" +
builder.append(" (").append(getDyaBefore()).append(" )\n"); " .dyaHeight = (" + getDyaHeight() + " )\n" +
builder.append(" .dyaAfter = "); " .fMinHeight = (" + getFMinHeight() + " )\n" +
builder.append(" (").append(getDyaAfter()).append(" )\n"); " .dcs = (" + getDcs() + " )\n" +
builder.append(" .fInTable = "); " .dyaFromText = (" + getDyaFromText() + " )\n" +
builder.append(" (").append(getFInTable()).append(" )\n"); " .dxaFromText = (" + getDxaFromText() + " )\n" +
builder.append(" .finTableW97 = "); " .fLocked = (" + getFLocked() + " )\n" +
builder.append(" (").append(getFinTableW97()).append(" )\n"); " .fWidowControl = (" + getFWidowControl() + " )\n" +
builder.append(" .fTtp = "); " .fKinsoku = (" + getFKinsoku() + " )\n" +
builder.append(" (").append(getFTtp()).append(" )\n"); " .fWordWrap = (" + getFWordWrap() + " )\n" +
builder.append(" .dxaAbs = "); " .fOverflowPunct = (" + getFOverflowPunct() + " )\n" +
builder.append(" (").append(getDxaAbs()).append(" )\n"); " .fTopLinePunct = (" + getFTopLinePunct() + " )\n" +
builder.append(" .dyaAbs = "); " .fAutoSpaceDE = (" + getFAutoSpaceDE() + " )\n" +
builder.append(" (").append(getDyaAbs()).append(" )\n"); " .fAutoSpaceDN = (" + getFAutoSpaceDN() + " )\n" +
builder.append(" .dxaWidth = "); " .wAlignFont = (" + getWAlignFont() + " )\n" +
builder.append(" (").append(getDxaWidth()).append(" )\n"); " .fontAlign = (" + getFontAlign() + " )\n" +
builder.append(" .fBrLnAbove = "); " .fVertical = " + isFVertical() + '\n' +
builder.append(" (").append(getFBrLnAbove()).append(" )\n"); " .fBackward = " + isFBackward() + '\n' +
builder.append(" .fBrLnBelow = "); " .fRotateFont = " + isFRotateFont() + '\n' +
builder.append(" (").append(getFBrLnBelow()).append(" )\n"); " .lvl = (" + getLvl() + " )\n" +
builder.append(" .pcVert = "); " .fBiDi = (" + getFBiDi() + " )\n" +
builder.append(" (").append(getPcVert()).append(" )\n"); " .fNumRMIns = (" + getFNumRMIns() + " )\n" +
builder.append(" .pcHorz = "); " .fCrLf = (" + getFCrLf() + " )\n" +
builder.append(" (").append(getPcHorz()).append(" )\n"); " .fUsePgsuSettings = (" + getFUsePgsuSettings() + " )\n" +
builder.append(" .wr = "); " .fAdjustRight = (" + getFAdjustRight() + " )\n" +
builder.append(" (").append(getWr()).append(" )\n"); " .itap = (" + getItap() + " )\n" +
builder.append(" .fNoAutoHyph = "); " .fInnerTableCell = (" + getFInnerTableCell() + " )\n" +
builder.append(" (").append(getFNoAutoHyph()).append(" )\n"); " .fOpenTch = (" + getFOpenTch() + " )\n" +
builder.append(" .dyaHeight = "); " .fTtpEmbedded = (" + getFTtpEmbedded() + " )\n" +
builder.append(" (").append(getDyaHeight()).append(" )\n"); " .dxcRight = (" + getDxcRight() + " )\n" +
builder.append(" .fMinHeight = "); " .dxcLeft = (" + getDxcLeft() + " )\n" +
builder.append(" (").append(getFMinHeight()).append(" )\n"); " .dxcLeft1 = (" + getDxcLeft1() + " )\n" +
builder.append(" .dcs = "); " .fDyaBeforeAuto = (" + getFDyaBeforeAuto() + " )\n" +
builder.append(" (").append(getDcs()).append(" )\n"); " .fDyaAfterAuto = (" + getFDyaAfterAuto() + " )\n" +
builder.append(" .dyaFromText = "); " .dxaRight = (" + getDxaRight() + " )\n" +
builder.append(" (").append(getDyaFromText()).append(" )\n"); " .dxaLeft = (" + getDxaLeft() + " )\n" +
builder.append(" .dxaFromText = "); " .dxaLeft1 = (" + getDxaLeft1() + " )\n" +
builder.append(" (").append(getDxaFromText()).append(" )\n"); " .jc = (" + getJc() + " )\n" +
builder.append(" .fLocked = "); " .brcTop = (" + getBrcTop() + " )\n" +
builder.append(" (").append(getFLocked()).append(" )\n"); " .brcLeft = (" + getBrcLeft() + " )\n" +
builder.append(" .fWidowControl = "); " .brcBottom = (" + getBrcBottom() + " )\n" +
builder.append(" (").append(getFWidowControl()).append(" )\n"); " .brcRight = (" + getBrcRight() + " )\n" +
builder.append(" .fKinsoku = "); " .brcBetween = (" + getBrcBetween() + " )\n" +
builder.append(" (").append(getFKinsoku()).append(" )\n"); " .brcBar = (" + getBrcBar() + " )\n" +
builder.append(" .fWordWrap = "); " .shd = (" + getShd() + " )\n" +
builder.append(" (").append(getFWordWrap()).append(" )\n"); " .anld = (" + Arrays.toString(getAnld()) + " )\n" +
builder.append(" .fOverflowPunct = "); " .phe = (" + Arrays.toString(getPhe()) + " )\n" +
builder.append(" (").append(getFOverflowPunct()).append(" )\n"); " .fPropRMark = (" + getFPropRMark() + " )\n" +
builder.append(" .fTopLinePunct = "); " .ibstPropRMark = (" + getIbstPropRMark() + " )\n" +
builder.append(" (").append(getFTopLinePunct()).append(" )\n"); " .dttmPropRMark = (" + getDttmPropRMark() + " )\n" +
builder.append(" .fAutoSpaceDE = "); " .itbdMac = (" + getItbdMac() + " )\n" +
builder.append(" (").append(getFAutoSpaceDE()).append(" )\n"); " .rgdxaTab = (" + Arrays.toString(getRgdxaTab()) + " )\n" +
builder.append(" .fAutoSpaceDN = "); " .rgtbd = (" + Arrays.toString(getRgtbd()) + " )\n" +
builder.append(" (").append(getFAutoSpaceDN()).append(" )\n"); " .numrm = (" + Arrays.toString(getNumrm()) + " )\n" +
builder.append(" .wAlignFont = "); " .ptap = (" + Arrays.toString(getPtap()) + " )\n" +
builder.append(" (").append(getWAlignFont()).append(" )\n"); " .fNoAllowOverlap = (" + getFNoAllowOverlap() + " )\n" +
builder.append(" .fontAlign = "); " .ipgp = (" + getIpgp() + " )\n" +
builder.append(" (").append(getFontAlign()).append(" )\n"); " .rsid = (" + getRsid() + " )\n" +
builder.append(" .fVertical = ").append(isFVertical()).append('\n'); "[/PAP]\n";
builder.append(" .fBackward = ").append(isFBackward()).append('\n');
builder.append(" .fRotateFont = ").append(isFRotateFont()).append('\n');
builder.append(" .lvl = ");
builder.append(" (").append(getLvl()).append(" )\n");
builder.append(" .fBiDi = ");
builder.append(" (").append(getFBiDi()).append(" )\n");
builder.append(" .fNumRMIns = ");
builder.append(" (").append(getFNumRMIns()).append(" )\n");
builder.append(" .fCrLf = ");
builder.append(" (").append(getFCrLf()).append(" )\n");
builder.append(" .fUsePgsuSettings = ");
builder.append(" (").append(getFUsePgsuSettings()).append(" )\n");
builder.append(" .fAdjustRight = ");
builder.append(" (").append(getFAdjustRight()).append(" )\n");
builder.append(" .itap = ");
builder.append(" (").append(getItap()).append(" )\n");
builder.append(" .fInnerTableCell = ");
builder.append(" (").append(getFInnerTableCell()).append(" )\n");
builder.append(" .fOpenTch = ");
builder.append(" (").append(getFOpenTch()).append(" )\n");
builder.append(" .fTtpEmbedded = ");
builder.append(" (").append(getFTtpEmbedded()).append(" )\n");
builder.append(" .dxcRight = ");
builder.append(" (").append(getDxcRight()).append(" )\n");
builder.append(" .dxcLeft = ");
builder.append(" (").append(getDxcLeft()).append(" )\n");
builder.append(" .dxcLeft1 = ");
builder.append(" (").append(getDxcLeft1()).append(" )\n");
builder.append(" .fDyaBeforeAuto = ");
builder.append(" (").append(getFDyaBeforeAuto()).append(" )\n");
builder.append(" .fDyaAfterAuto = ");
builder.append(" (").append(getFDyaAfterAuto()).append(" )\n");
builder.append(" .dxaRight = ");
builder.append(" (").append(getDxaRight()).append(" )\n");
builder.append(" .dxaLeft = ");
builder.append(" (").append(getDxaLeft()).append(" )\n");
builder.append(" .dxaLeft1 = ");
builder.append(" (").append(getDxaLeft1()).append(" )\n");
builder.append(" .jc = ");
builder.append(" (").append(getJc()).append(" )\n");
builder.append(" .brcTop = ");
builder.append(" (").append(getBrcTop()).append(" )\n");
builder.append(" .brcLeft = ");
builder.append(" (").append(getBrcLeft()).append(" )\n");
builder.append(" .brcBottom = ");
builder.append(" (").append(getBrcBottom()).append(" )\n");
builder.append(" .brcRight = ");
builder.append(" (").append(getBrcRight()).append(" )\n");
builder.append(" .brcBetween = ");
builder.append(" (").append(getBrcBetween()).append(" )\n");
builder.append(" .brcBar = ");
builder.append(" (").append(getBrcBar()).append(" )\n");
builder.append(" .shd = ");
builder.append(" (").append(getShd()).append(" )\n");
builder.append(" .anld = ");
builder.append(" (").append(Arrays.toString(getAnld())).append(" )\n");
builder.append(" .phe = ");
builder.append(" (").append(Arrays.toString(getPhe())).append(" )\n");
builder.append(" .fPropRMark = ");
builder.append(" (").append(getFPropRMark()).append(" )\n");
builder.append(" .ibstPropRMark = ");
builder.append(" (").append(getIbstPropRMark()).append(" )\n");
builder.append(" .dttmPropRMark = ");
builder.append(" (").append(getDttmPropRMark()).append(" )\n");
builder.append(" .itbdMac = ");
builder.append(" (").append(getItbdMac()).append(" )\n");
builder.append(" .rgdxaTab = ");
builder.append(" (").append(Arrays.toString(getRgdxaTab())).append(" )\n");
builder.append(" .rgtbd = ");
builder.append(" (").append(Arrays.toString(getRgtbd())).append(" )\n");
builder.append(" .numrm = ");
builder.append(" (").append(Arrays.toString(getNumrm())).append(" )\n");
builder.append(" .ptap = ");
builder.append(" (").append(Arrays.toString(getPtap())).append(" )\n");
builder.append(" .fNoAllowOverlap = ");
builder.append(" (").append(getFNoAllowOverlap()).append(" )\n");
builder.append(" .ipgp = ");
builder.append(" (").append(getIpgp()).append(" )\n");
builder.append(" .rsid = ");
builder.append(" (").append(getRsid()).append(" )\n");
builder.append("[/PAP]\n");
return builder.toString();
} }
/** /**
@ -1785,7 +1702,7 @@ public abstract class PAPAbstractType {
} }
/** /**
* Number of tabs stops defined for paragraph. Must be >= 0 and <= 64.. * Number of tabs stops defined for paragraph. Must be &gt;= 0 and &lt;= 64..
*/ */
@Internal @Internal
public int getItbdMac() public int getItbdMac()
@ -1794,7 +1711,7 @@ public abstract class PAPAbstractType {
} }
/** /**
* Number of tabs stops defined for paragraph. Must be >= 0 and <= 64.. * Number of tabs stops defined for paragraph. Must be &gt;= 0 and &lt;= 64..
*/ */
@Internal @Internal
public void setItbdMac( int field_72_itbdMac ) public void setItbdMac( int field_72_itbdMac )

View File

@ -895,7 +895,7 @@ public abstract class TAPAbstractType {
} }
/** /**
* Count of cells defined for this row. itcMac must be >= 0 and less than or equal to 64.. * Count of cells defined for this row. itcMac must be &gt;= 0 and less than or equal to 64..
*/ */
@Internal @Internal
public short getItcMac() public short getItcMac()
@ -904,7 +904,7 @@ public abstract class TAPAbstractType {
} }
/** /**
* Count of cells defined for this row. itcMac must be >= 0 and less than or equal to 64.. * Count of cells defined for this row. itcMac must be &gt;= 0 and less than or equal to 64..
*/ */
@Internal @Internal
public void setItcMac( short field_26_itcMac ) public void setItcMac( short field_26_itcMac )

View File

@ -547,11 +547,9 @@ public class Paragraph extends Range implements Duplicatable {
} }
/** /**
* Returns number of tabs stops defined for paragraph. Must be >= 0 and <= * Returns number of tabs stops defined for paragraph. Must be &gt;= 0 and &lt;= 64.
* 64.
* *
* @return number of tabs stops defined for paragraph. Must be >= 0 and <= * @return number of tabs stops defined for paragraph. Must be &gt;= 0 and &lt;= 64
* 64
*/ */
public int getTabStopsNumber() public int getTabStopsNumber()
{ {

View File

@ -65,7 +65,7 @@ public class TestExcelConverterSuite
{ {
HSSFWorkbook workbook; HSSFWorkbook workbook;
try { try {
workbook = ExcelToHtmlUtils.loadXls( child ); workbook = AbstractExcelUtils.loadXls( child );
} catch ( Exception exc ) { } catch ( Exception exc ) {
// unable to parse file -- not ExcelToFoConverter fault // unable to parse file -- not ExcelToFoConverter fault
return; return;
@ -91,7 +91,7 @@ public class TestExcelConverterSuite
{ {
HSSFWorkbook workbook; HSSFWorkbook workbook;
try { try {
workbook = ExcelToHtmlUtils.loadXls( child ); workbook = AbstractExcelUtils.loadXls( child );
} catch ( Exception exc ) { } catch ( Exception exc ) {
// unable to parse file -- not ExcelToFoConverter fault // unable to parse file -- not ExcelToFoConverter fault
return; return;