aboutsummaryrefslogtreecommitdiffstats
path: root/poi-scratchpad
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2021-04-13 21:37:33 +0000
committerAndreas Beeker <kiwiwings@apache.org>2021-04-13 21:37:33 +0000
commit088d1dd19728d4a49f84d718e8399974b021f0b3 (patch)
tree0e5420aec119820c4ae325979aa71a03c8196809 /poi-scratchpad
parent240b02daecdabd3e314bd662d56665cbb6cdf5fd (diff)
downloadpoi-088d1dd19728d4a49f84d718e8399974b021f0b3.tar.gz
poi-088d1dd19728d4a49f84d718e8399974b021f0b3.zip
: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
Diffstat (limited to 'poi-scratchpad')
-rw-r--r--poi-scratchpad/build.gradle23
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hpbf/dev/HPBFDumper.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/record/AnimationInfoAtom.java6
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/record/RecordTypes.java14
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hsmf/extractor/OutlookTextExtractor.java16
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hssf/converter/AbstractExcelUtils.java237
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hssf/converter/ExcelToFoConverter.java724
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java627
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hssf/converter/ExcelToHtmlUtils.java75
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfBitmapDib.java8
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/extractor/WordExtractor.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/CharIndexTranslator.java10
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/ListTables.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PicturesTable.java299
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/FRDAbstractType.java16
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/GrfhicAbstractType.java39
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/PAPAbstractType.java257
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/TAPAbstractType.java4
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/Paragraph.java6
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hssf/converter/TestExcelConverterSuite.java4
20 files changed, 1102 insertions, 1269 deletions
diff --git a/poi-scratchpad/build.gradle b/poi-scratchpad/build.gradle
index 0bf5032038..ca5c05bf4c 100644
--- a/poi-scratchpad/build.gradle
+++ b/poi-scratchpad/build.gradle
@@ -31,6 +31,7 @@ final String VERSIONS9 = 'META-INF/versions/9'
configurations {
tests
+ javadocs
}
sourceSets {
@@ -56,6 +57,9 @@ dependencies {
testImplementation project(path: ':poi', configuration: 'tests')
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
+
+ javadocs project(':poi')
+ javadocs project(':poi-ooxml')
}
final MODULE_NAME = 'org.apache.poi.scratchpad'
@@ -202,11 +206,20 @@ test {
}
javadoc {
-// fails currently, need to fix the sources
- failOnError = false
-// if(JavaVersion.current().isJava9Compatible()) {
-// options.addBooleanOption('html5', true)
-// }
+ failOnError = true
+ doFirst {
+ options {
+ 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 {
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/dev/HPBFDumper.java b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/dev/HPBFDumper.java
index a638ba9e77..4fccf48565 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/dev/HPBFDumper.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/dev/HPBFDumper.java
@@ -99,7 +99,7 @@ public final class HPBFDumper {
/**
* Dump out the escher parts of the file.
- * Escher -> EscherStm and EscherDelayStm
+ * Escher -&gt; EscherStm and EscherDelayStm
*/
public void dumpEscher() throws IOException {
DirectoryNode escherDir = (DirectoryNode)
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/AnimationInfoAtom.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/AnimationInfoAtom.java
index f89e188f14..f9ec145eac 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/AnimationInfoAtom.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/AnimationInfoAtom.java
@@ -97,7 +97,7 @@ public final class AnimationInfoAtom extends RecordAtom {
/**
* Record header.
*/
- private byte[] _header;
+ private final byte[] _header;
/**
* 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.
* 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 value -1 SHOULD NOT <105> be used.
+ * The value -1 SHOULD NOT be used.
*/
public int getOrderID(){
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.
* 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 value -1 SHOULD NOT <105> be used.
+ * The value -1 SHOULD NOT be used.
*/
public void setOrderID(int id){
LittleEndian.putInt(_recdata, 16, id);
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/RecordTypes.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/RecordTypes.java
index c57003c89b..295096da7e 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/RecordTypes.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/RecordTypes.java
@@ -24,8 +24,10 @@ import java.util.Map;
* List of all known record types in a PowerPoint document, and the
* classes that handle them.
* There are two categories of records:
- * <li> PowerPoint records: 0 <= info <= 10002 (will carry class info)
- * <li> Escher records: info >= 0xF000 (handled by DDF, so no class info)
+ * <ul>
+ * <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 {
Unknown(0,null),
@@ -183,12 +185,12 @@ public enum RecordTypes {
for(RecordTypes s : values()) {
LOOKUP.put(s.typeID, s);
}
- }
-
+ }
+
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.recordConstructor = recordConstructor;
}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hsmf/extractor/OutlookTextExtractor.java b/poi-scratchpad/src/main/java/org/apache/poi/hsmf/extractor/OutlookTextExtractor.java
index a818d03280..826b723329 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hsmf/extractor/OutlookTextExtractor.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hsmf/extractor/OutlookTextExtractor.java
@@ -101,8 +101,8 @@ public class OutlookTextExtractor implements POIOLE2TextExtractor {
}
try {
- s.append("From: " + msg.getDisplayFrom() + "\n");
- } catch (ChunkNotFoundException e) {
+ s.append("From: ").append(msg.getDisplayFrom()).append("\n");
+ } catch (ChunkNotFoundException ignored) {
}
// For To, CC and BCC, try to match the names
@@ -111,15 +111,15 @@ public class OutlookTextExtractor implements POIOLE2TextExtractor {
// people in To + CC + BCC.
try {
handleEmails(s, "To", msg.getDisplayTo(), emails);
- } catch (ChunkNotFoundException e) {
+ } catch (ChunkNotFoundException ignored) {
}
try {
handleEmails(s, "CC", msg.getDisplayCC(), emails);
- } catch (ChunkNotFoundException e) {
+ } catch (ChunkNotFoundException ignored) {
}
try {
handleEmails(s, "BCC", msg.getDisplayBCC(), emails);
- } catch (ChunkNotFoundException e) {
+ } catch (ChunkNotFoundException ignored) {
}
// Date - try two ways to find it
@@ -145,7 +145,7 @@ public class OutlookTextExtractor implements POIOLE2TextExtractor {
try {
s.append("Subject: ").append(msg.getSubject()).append("\n");
- } catch (ChunkNotFoundException e) {
+ } catch (ChunkNotFoundException ignored) {
}
// Display attachment names
@@ -164,7 +164,7 @@ public class OutlookTextExtractor implements POIOLE2TextExtractor {
try {
s.append("\n").append(msg.getTextBody()).append("\n");
- } catch (ChunkNotFoundException e) {
+ } catch (ChunkNotFoundException ignored) {
}
return s.toString();
@@ -173,7 +173,7 @@ public class OutlookTextExtractor implements POIOLE2TextExtractor {
/**
* Takes a Display focused string, eg "Nick; Jim" and an iterator
* 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) {
if (displayText == null || displayText.length() == 0) {
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hssf/converter/AbstractExcelUtils.java b/poi-scratchpad/src/main/java/org/apache/poi/hssf/converter/AbstractExcelUtils.java
index aa8863f841..744ffc9041 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hssf/converter/AbstractExcelUtils.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hssf/converter/AbstractExcelUtils.java
@@ -19,6 +19,7 @@ package org.apache.poi.hssf.converter;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.util.Arrays;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
@@ -27,112 +28,114 @@ import org.apache.poi.ss.usermodel.BorderStyle;
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;
+import org.apache.poi.util.Internal;
/**
- * Common class for {@link ExcelToFoUtils} and {@link ExcelToHtmlUtils}
- *
- * @author Sergey Vladimirov (vlsergey {at} gmail {dot} com)
+ * Common class for {@link ExcelToFoConverter} and {@link ExcelToHtmlConverter}
+ *
* @see AbstractWordUtils
* @since POI 3.8 beta 5
*/
-@Beta
-public class AbstractExcelUtils {
+@Internal
+class AbstractExcelUtils {
/*package*/ static final String EMPTY = "";
private static final short EXCEL_COLUMN_WIDTH_FACTOR = 256;
private static final int UNIT_OFFSET_LENGTH = 7;
- public static String getAlign( HorizontalAlignment alignment ) {
- switch ( alignment ) {
- case CENTER:
- return "center";
- case CENTER_SELECTION:
- return "center";
- case FILL:
- // XXX: shall we support fill?
- return "";
- case GENERAL:
- return "";
- case JUSTIFY:
- return "justify";
- case LEFT:
- return "left";
- case RIGHT:
- return "right";
- default:
- return "";
+ public static String getAlign(HorizontalAlignment alignment) {
+ switch (alignment) {
+ case CENTER:
+ case CENTER_SELECTION:
+ return "center";
+ case FILL:
+ // XXX: shall we support fill?
+ return "";
+ case JUSTIFY:
+ return "justify";
+ case LEFT:
+ return "left";
+ case RIGHT:
+ return "right";
+ default:
+ case GENERAL:
+ return "";
}
}
- public static String getBorderStyle( BorderStyle xlsBorder ) {
+ public static String getBorderStyle(BorderStyle xlsBorder) {
final String borderStyle;
- switch ( xlsBorder ) {
- case NONE:
- borderStyle = "none";
- break;
- case DASH_DOT:
- case DASH_DOT_DOT:
- case DOTTED:
- case HAIR:
- case MEDIUM_DASH_DOT:
- case MEDIUM_DASH_DOT_DOT:
- case SLANTED_DASH_DOT:
- borderStyle = "dotted";
- break;
- case DASHED:
- case MEDIUM_DASHED:
- borderStyle = "dashed";
- break;
- case DOUBLE:
- borderStyle = "double";
- break;
- default:
- borderStyle = "solid";
- break;
+ switch (xlsBorder) {
+ case NONE:
+ borderStyle = "none";
+ break;
+ case DASH_DOT:
+ case DASH_DOT_DOT:
+ case DOTTED:
+ case HAIR:
+ case MEDIUM_DASH_DOT:
+ case MEDIUM_DASH_DOT_DOT:
+ case SLANTED_DASH_DOT:
+ borderStyle = "dotted";
+ break;
+ case DASHED:
+ case MEDIUM_DASHED:
+ borderStyle = "dashed";
+ break;
+ case DOUBLE:
+ borderStyle = "double";
+ break;
+ default:
+ borderStyle = "solid";
+ break;
}
return borderStyle;
}
- public static String getBorderWidth( BorderStyle xlsBorder ) {
+ public static String getBorderWidth(BorderStyle xlsBorder) {
final String borderWidth;
- switch ( xlsBorder ) {
- case MEDIUM_DASH_DOT:
- case MEDIUM_DASH_DOT_DOT:
- case MEDIUM_DASHED:
- borderWidth = "2pt";
- break;
- case THICK:
- borderWidth = "thick";
- break;
- default:
- borderWidth = "thin";
- break;
+ switch (xlsBorder) {
+ case MEDIUM_DASH_DOT:
+ case MEDIUM_DASH_DOT_DOT:
+ case MEDIUM_DASHED:
+ borderWidth = "2pt";
+ break;
+ case THICK:
+ borderWidth = "thick";
+ break;
+ default:
+ borderWidth = "thin";
+ break;
}
return borderWidth;
}
- public static String getColor( HSSFColor color ) {
- StringBuilder stringBuilder = new StringBuilder( 7 );
- stringBuilder.append( '#' );
- for ( short s : color.getTriplet() ) {
- if ( s < 10 )
- stringBuilder.append( '0' );
+ public static String getColor(HSSFColor color) {
+ StringBuilder stringBuilder = new StringBuilder(7);
+ stringBuilder.append('#');
+ for (short s : color.getTriplet()) {
+ if (s < 10) {
+ stringBuilder.append('0');
+ }
- stringBuilder.append( Integer.toHexString( s ) );
+ stringBuilder.append(Integer.toHexString(s));
}
String result = stringBuilder.toString();
- if ( result.equals( "#ffffff" ) )
+ if (result.equals("#ffffff")) {
return "white";
+ }
- if ( result.equals( "#c0c0c0" ) )
+ if (result.equals("#c0c0c0")) {
return "silver";
+ }
- if ( result.equals( "#808080" ) )
+ if (result.equals("#808080")) {
return "gray";
+ }
- if ( result.equals( "#000000" ) )
+ if (result.equals("#000000")) {
return "black";
+ }
return result;
}
@@ -142,47 +145,93 @@ public class AbstractExcelUtils {
* "http://apache-poi.1045710.n5.nabble.com/Excel-Column-Width-Unit-Converter-pixels-excel-column-width-units-td2301481.html"
* >here</a> for Xio explanation and details
*/
- public static int getColumnWidthInPx( int widthUnits ) {
- int pixels = ( widthUnits / EXCEL_COLUMN_WIDTH_FACTOR )
- * UNIT_OFFSET_LENGTH;
+ public static int getColumnWidthInPx(int widthUnits) {
+ int pixels = (widthUnits / EXCEL_COLUMN_WIDTH_FACTOR)
+ * UNIT_OFFSET_LENGTH;
int offsetWidthUnits = widthUnits % EXCEL_COLUMN_WIDTH_FACTOR;
- pixels += Math.round( offsetWidthUnits
- / ( (float) EXCEL_COLUMN_WIDTH_FACTOR / UNIT_OFFSET_LENGTH ) );
+ pixels += Math.round(offsetWidthUnits
+ / ((float) EXCEL_COLUMN_WIDTH_FACTOR / UNIT_OFFSET_LENGTH));
return pixels;
}
/**
- * @param mergedRanges
- * map of sheet merged ranges built with
- * {@link ExcelToHtmlUtils#buildMergedRangesMap(Sheet)}
+ * @param mergedRanges map of sheet merged ranges built with
+ * {@link #buildMergedRangesMap(Sheet)}
* @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
*/
public static CellRangeAddress getMergedRange(
- CellRangeAddress[][] mergedRanges, int rowNumber, int columnNumber ) {
+ CellRangeAddress[][] mergedRanges, int rowNumber, int columnNumber) {
CellRangeAddress[] mergedRangeRowInfo = rowNumber < mergedRanges.length ? mergedRanges[rowNumber]
- : null;
+ : null;
return mergedRangeRowInfo != null
- && columnNumber < mergedRangeRowInfo.length ? mergedRangeRowInfo[columnNumber]
- : null;
+ && columnNumber < mergedRangeRowInfo.length ? mergedRangeRowInfo[columnNumber]
+ : null;
}
- static boolean isEmpty( String str )
- {
+ static boolean isEmpty(String str) {
return str == null || str.length() == 0;
}
- static boolean isNotEmpty( String str )
- {
- return !isEmpty( str );
+ static boolean isNotEmpty(String str) {
+ return !isEmpty(str);
+ }
+
+ public static HSSFWorkbook loadXls(File xlsFile) throws IOException {
+ try (final FileInputStream inputStream = new FileInputStream(xlsFile)) {
+ return new HSSFWorkbook(inputStream);
+ }
}
- public static HSSFWorkbook loadXls(File xlsFile ) throws IOException {
- try (final FileInputStream inputStream = new FileInputStream( xlsFile )) {
- 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;
}
}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hssf/converter/ExcelToFoConverter.java b/poi-scratchpad/src/main/java/org/apache/poi/hssf/converter/ExcelToFoConverter.java
index 50cf5427b2..d6938867e1 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hssf/converter/ExcelToFoConverter.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hssf/converter/ExcelToFoConverter.java
@@ -16,6 +16,16 @@
==================================================================== */
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.util.ArrayList;
import java.util.List;
@@ -50,12 +60,9 @@ import org.w3c.dom.Text;
/**
* Converts xls files (97-2007) to XSL FO.
- *
- * @author Sergey Vladimirov (vlsergey {at} gmail {dot} com)
*/
@Beta
-public class ExcelToFoConverter extends AbstractExcelConverter
-{
+public class ExcelToFoConverter extends AbstractExcelConverter {
private static final float CM_PER_INCH = 2.54f;
private static final float DPI = 72;
@@ -67,45 +74,40 @@ public class ExcelToFoConverter extends AbstractExcelConverter
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
- * </p>
+ * <p>
* Where infile is an input .xls file ( Word 97-2007) which will be rendered
* as XSL FO into outfile
*/
- public static void main( String[] args ) throws Exception {
- if ( args.length < 2 ) {
- System.err.println( "Usage: ExcelToFoConverter <inputFile.xls> <saveTo.xml>" );
+ public static void main(String[] args) throws Exception {
+ if (args.length < 2) {
+ System.err.println("Usage: ExcelToFoConverter <inputFile.xls> <saveTo.xml>");
return;
}
- System.out.println( "Converting " + args[0] );
- System.out.println( "Saving output to " + args[1] );
+ System.out.println("Converting " + args[0]);
+ System.out.println("Saving output to " + args[1]);
- Document doc = ExcelToHtmlConverter.process( new File( args[0] ) );
+ Document doc = ExcelToHtmlConverter.process(new File(args[0]));
- DOMSource domSource = new DOMSource( doc );
- StreamResult streamResult = new StreamResult( new File(args[1]) );
+ DOMSource domSource = new DOMSource(doc);
+ StreamResult streamResult = new StreamResult(new File(args[1]));
// TODO set encoding from a command argument
Transformer serializer = XMLHelper.newTransformer();
- serializer.transform( domSource, streamResult );
+ serializer.transform(domSource, streamResult);
}
/**
* Converts Excel file (97-2007) into XSL FO file.
*
- * @param xlsFile
- * file to process
+ * @param xlsFile file to process
* @return DOM representation of result XSL FO
*/
- public static Document process( File xlsFile ) throws Exception
- {
- try (HSSFWorkbook workbook = AbstractExcelUtils.loadXls(xlsFile)) {
+ public static Document process(File xlsFile) throws Exception {
+ try (HSSFWorkbook workbook = loadXls(xlsFile)) {
ExcelToFoConverter excelToHtmlConverter = new ExcelToFoConverter(
- XMLHelper.newDocumentBuilder().newDocument() );
+ XMLHelper.newDocumentBuilder().newDocument());
excelToHtmlConverter.processWorkbook(workbook);
return excelToHtmlConverter.getDocument();
}
@@ -115,35 +117,29 @@ public class ExcelToFoConverter extends AbstractExcelConverter
private float pageMarginInches = 0.4f;
- public ExcelToFoConverter( Document document )
- {
- this.foDocumentFacade = new FoDocumentFacade( document );
+ public ExcelToFoConverter(Document document) {
+ this.foDocumentFacade = new FoDocumentFacade(document);
}
- public ExcelToFoConverter( FoDocumentFacade foDocumentFacade )
- {
+ public ExcelToFoConverter(FoDocumentFacade foDocumentFacade) {
this.foDocumentFacade = foDocumentFacade;
}
- protected String createPageMaster( float tableWidthIn, String pageMasterName )
- {
+ protected String createPageMaster(float tableWidthIn, String pageMasterName) {
final float paperHeightIn;
final float paperWidthIn;
{
float requiredWidthIn = tableWidthIn + 2 * getPageMarginInches();
- if ( requiredWidthIn < PAPER_A4_WIDTH_INCHES )
- {
+ if (requiredWidthIn < PAPER_A4_WIDTH_INCHES) {
// portrait orientation
paperWidthIn = PAPER_A4_WIDTH_INCHES;
paperHeightIn = PAPER_A4_HEIGHT_INCHES;
- }
- else
- {
+ } else {
// landscape orientation
paperWidthIn = requiredWidthIn;
paperHeightIn = paperWidthIn
- * ( PAPER_A4_WIDTH_INCHES / PAPER_A4_HEIGHT_INCHES );
+ * (PAPER_A4_WIDTH_INCHES / PAPER_A4_HEIGHT_INCHES);
}
}
@@ -153,25 +149,23 @@ public class ExcelToFoConverter extends AbstractExcelConverter
final float bottomMargin = getPageMarginInches();
Element pageMaster = foDocumentFacade
- .addSimplePageMaster( pageMasterName );
- pageMaster.setAttribute( "page-height", paperHeightIn + "in" );
- pageMaster.setAttribute( "page-width", paperWidthIn + "in" );
+ .addSimplePageMaster(pageMasterName);
+ pageMaster.setAttribute("page-height", paperHeightIn + "in");
+ pageMaster.setAttribute("page-width", paperWidthIn + "in");
- Element regionBody = foDocumentFacade.addRegionBody( pageMaster );
- regionBody.setAttribute( "margin", topMargin + "in " + rightMargin
- + "in " + bottomMargin + "in " + leftMargin + "in" );
+ Element regionBody = foDocumentFacade.addRegionBody(pageMaster);
+ regionBody.setAttribute("margin", topMargin + "in " + rightMargin
+ + "in " + bottomMargin + "in " + leftMargin + "in");
return pageMasterName;
}
@Override
- protected Document getDocument()
- {
+ protected Document getDocument() {
return foDocumentFacade.getDocument();
}
- public float getPageMarginInches()
- {
+ public float getPageMarginInches() {
return pageMarginInches;
}
@@ -180,85 +174,79 @@ public class ExcelToFoConverter extends AbstractExcelConverter
* borders, fill, etc.) worth a mention, <tt>true</tt> otherwise
*
* @return <tt>false</tt> if cell style by itself (without text, i.e.
- * borders, fill, etc.) worth a mention, <tt>true</tt> otherwise
+ * borders, fill, etc.) worth a mention, <tt>true</tt> otherwise
*/
- protected boolean isEmptyStyle( CellStyle cellStyle ) {
+ protected boolean isEmptyStyle(CellStyle cellStyle) {
return cellStyle == null || (
- cellStyle.getFillPattern() == FillPatternType.NO_FILL
- && cellStyle.getBorderTop() == BorderStyle.NONE
- && cellStyle.getBorderRight() == BorderStyle.NONE
- && cellStyle.getBorderBottom() == BorderStyle.NONE
- && cellStyle.getBorderLeft() == BorderStyle.NONE
+ cellStyle.getFillPattern() == FillPatternType.NO_FILL
+ && cellStyle.getBorderTop() == BorderStyle.NONE
+ && cellStyle.getBorderRight() == BorderStyle.NONE
+ && cellStyle.getBorderBottom() == BorderStyle.NONE
+ && cellStyle.getBorderLeft() == BorderStyle.NONE
);
}
- protected boolean processCell( HSSFWorkbook workbook, HSSFCell cell,
- Element tableCellElement, int normalWidthPx, int maxSpannedWidthPx,
- float normalHeightPt )
- {
+ protected boolean processCell(HSSFWorkbook workbook, HSSFCell cell,
+ Element tableCellElement, int normalWidthPx, int maxSpannedWidthPx,
+ float normalHeightPt) {
final HSSFCellStyle cellStyle = cell.getCellStyle();
String value;
- switch ( cell.getCellType() )
- {
- case STRING:
- // XXX: enrich
- value = cell.getRichStringCellValue().getString();
- break;
- case FORMULA:
- switch ( cell.getCachedFormulaResultType() )
- {
+ switch (cell.getCellType()) {
case STRING:
- HSSFRichTextString str = cell.getRichStringCellValue();
- if ( str != null && str.length() > 0 )
- {
- value = ( str.toString() );
- }
- else
- {
- value = AbstractExcelUtils.EMPTY;
+ // XXX: enrich
+ value = cell.getRichStringCellValue().getString();
+ break;
+ case FORMULA:
+ switch (cell.getCachedFormulaResultType()) {
+ case STRING:
+ HSSFRichTextString str = cell.getRichStringCellValue();
+ if (str != null && str.length() > 0) {
+ value = (str.toString());
+ } else {
+ value = AbstractExcelUtils.EMPTY;
+ }
+ break;
+ case NUMERIC:
+ double nValue = cell.getNumericCellValue();
+ short df = cellStyle.getDataFormat();
+ String dfs = cellStyle.getDataFormatString();
+ value = _formatter.formatRawCellContents(nValue, df, dfs);
+ break;
+ case BOOLEAN:
+ value = Boolean.toString(cell.getBooleanCellValue());
+ break;
+ case ERROR:
+ value = ErrorEval.getText(cell.getErrorCellValue());
+ break;
+ default:
+ LOG.atWarn().log("Unexpected cell cachedFormulaResultType ({})", cell.getCachedFormulaResultType());
+ value = AbstractExcelUtils.EMPTY;
+ break;
}
break;
+ case BLANK:
+ value = AbstractExcelUtils.EMPTY;
+ break;
case NUMERIC:
- double nValue = cell.getNumericCellValue();
- short df = cellStyle.getDataFormat();
- String dfs = cellStyle.getDataFormatString();
- value = _formatter.formatRawCellContents(nValue, df, dfs );
+ value = _formatter.formatCellValue(cell);
break;
case BOOLEAN:
- value = Boolean.toString( cell.getBooleanCellValue() );
+ value = Boolean.toString(cell.getBooleanCellValue());
break;
case ERROR:
- value = ErrorEval.getText( cell.getErrorCellValue() );
+ value = ErrorEval.getText(cell.getErrorCellValue());
break;
default:
- LOG.atWarn().log("Unexpected cell cachedFormulaResultType ({})", cell.getCachedFormulaResultType());
- value = AbstractExcelUtils.EMPTY;
- break;
- }
- break;
- case BLANK:
- value = AbstractExcelUtils.EMPTY;
- break;
- case NUMERIC:
- value = _formatter.formatCellValue( cell );
- break;
- case BOOLEAN:
- value = Boolean.toString( cell.getBooleanCellValue() );
- break;
- case ERROR:
- value = ErrorEval.getText( cell.getErrorCellValue() );
- break;
- default:
- LOG.atWarn().log("Unexpected cell type ({})", cell.getCellType());
- return true;
- }
-
- final boolean noText = AbstractExcelUtils.isEmpty( value );
+ LOG.atWarn().log("Unexpected cell type ({})", cell.getCellType());
+ return true;
+ }
+
+ final boolean noText = isEmpty(value);
final boolean wrapInDivs = !noText && !cellStyle.getWrapText();
- final boolean emptyStyle = isEmptyStyle( cellStyle );
- if ( !emptyStyle && noText ) {
+ final boolean emptyStyle = isEmptyStyle(cellStyle);
+ if (!emptyStyle && noText) {
/*
* if cell style is defined (like borders, etc.) but cell text
* is empty, add "&nbsp;" to output, so browser won't collapse
@@ -267,179 +255,170 @@ public class ExcelToFoConverter extends AbstractExcelConverter
value = "\u00A0";
}
- if ( isOutputLeadingSpacesAsNonBreaking() && value.startsWith( " " ) )
- {
+ if (isOutputLeadingSpacesAsNonBreaking() && value.startsWith(" ")) {
StringBuilder builder = new StringBuilder();
- for ( int c = 0; c < value.length(); c++ )
- {
- if ( value.charAt( c ) != ' ' ) {
+ for (int c = 0; c < value.length(); c++) {
+ if (value.charAt(c) != ' ') {
break;
}
- builder.append( '\u00a0' );
+ builder.append('\u00a0');
}
- if ( value.length() != builder.length() ) {
- builder.append( value.substring( builder.length() ) );
+ if (value.length() != builder.length()) {
+ builder.append(value.substring(builder.length()));
}
value = builder.toString();
}
- Text text = foDocumentFacade.createText( value );
+ Text text = foDocumentFacade.createText(value);
Element block = foDocumentFacade.createBlock();
- if ( wrapInDivs )
- {
- block.setAttribute( "absolute-position", "fixed" );
- block.setAttribute( "left", "0px" );
- block.setAttribute( "top", "0px" );
- block.setAttribute( "bottom", "0px" );
- block.setAttribute( "min-width", normalWidthPx + "px" );
+ if (wrapInDivs) {
+ block.setAttribute("absolute-position", "fixed");
+ block.setAttribute("left", "0px");
+ block.setAttribute("top", "0px");
+ block.setAttribute("bottom", "0px");
+ block.setAttribute("min-width", normalWidthPx + "px");
- if ( maxSpannedWidthPx != Integer.MAX_VALUE )
- {
- block.setAttribute( "max-width", maxSpannedWidthPx + "px" );
+ if (maxSpannedWidthPx != Integer.MAX_VALUE) {
+ block.setAttribute("max-width", maxSpannedWidthPx + "px");
}
- block.setAttribute( "overflow", "hidden" );
- block.setAttribute( "height", normalHeightPt + "pt" );
- block.setAttribute( "keep-together.within-line", "always" );
- block.setAttribute( "wrap-option", "no-wrap" );
+ block.setAttribute("overflow", "hidden");
+ block.setAttribute("height", normalHeightPt + "pt");
+ block.setAttribute("keep-together.within-line", "always");
+ block.setAttribute("wrap-option", "no-wrap");
}
- processCellStyle( workbook, cell.getCellStyle(), tableCellElement,
- block );
+ processCellStyle(workbook, cell.getCellStyle(), tableCellElement,
+ block);
- block.appendChild( text );
- tableCellElement.appendChild( block );
+ block.appendChild(text);
+ tableCellElement.appendChild(block);
- return AbstractExcelUtils.isEmpty( value ) && emptyStyle;
+ return isEmpty(value) && emptyStyle;
}
- protected void processCellStyle( HSSFWorkbook workbook,
- HSSFCellStyle cellStyle, Element cellTarget, Element blockTarget )
- {
- blockTarget.setAttribute( "white-space-collapse", "false" );
+ protected void processCellStyle(HSSFWorkbook workbook,
+ HSSFCellStyle cellStyle, Element cellTarget, Element blockTarget) {
+ blockTarget.setAttribute("white-space-collapse", "false");
{
- String textAlign = AbstractExcelUtils.getAlign( cellStyle.getAlignment() );
- if ( AbstractExcelUtils.isNotEmpty( textAlign ) )
- blockTarget.setAttribute( "text-align", textAlign );
+ String textAlign = getAlign(cellStyle.getAlignment());
+ if (isNotEmpty(textAlign)) {
+ blockTarget.setAttribute("text-align", textAlign);
+ }
}
- if ( cellStyle.getFillPattern() == FillPatternType.NO_FILL )
- {
+ if (cellStyle.getFillPattern() == FillPatternType.NO_FILL) {
// no fill
- }
- else if ( cellStyle.getFillPattern() == FillPatternType.SOLID_FOREGROUND )
- {
+ } else if (cellStyle.getFillPattern() == FillPatternType.SOLID_FOREGROUND) {
final HSSFColor foregroundColor = cellStyle
- .getFillForegroundColorColor();
- if ( foregroundColor != null )
- cellTarget.setAttribute( "background-color",
- AbstractExcelUtils.getColor( foregroundColor ) );
- }
- else
- {
+ .getFillForegroundColorColor();
+ if (foregroundColor != null) {
+ cellTarget.setAttribute("background-color",
+ getColor(foregroundColor));
+ }
+ } else {
final HSSFColor backgroundColor = cellStyle
- .getFillBackgroundColorColor();
- if ( backgroundColor != null )
- cellTarget.setAttribute( "background-color",
- AbstractExcelUtils.getColor( backgroundColor ) );
+ .getFillBackgroundColorColor();
+ if (backgroundColor != null) {
+ cellTarget.setAttribute("background-color",
+ getColor(backgroundColor));
+ }
}
- processCellStyleBorder( workbook, cellTarget, "top",
- cellStyle.getBorderTop(), cellStyle.getTopBorderColor() );
- processCellStyleBorder( workbook, cellTarget, "right",
- cellStyle.getBorderRight(), cellStyle.getRightBorderColor() );
- processCellStyleBorder( workbook, cellTarget, "bottom",
- cellStyle.getBorderBottom(), cellStyle.getBottomBorderColor() );
- processCellStyleBorder( workbook, cellTarget, "left",
- cellStyle.getBorderLeft(), cellStyle.getLeftBorderColor() );
+ processCellStyleBorder(workbook, cellTarget, "top",
+ cellStyle.getBorderTop(), cellStyle.getTopBorderColor());
+ processCellStyleBorder(workbook, cellTarget, "right",
+ cellStyle.getBorderRight(), cellStyle.getRightBorderColor());
+ processCellStyleBorder(workbook, cellTarget, "bottom",
+ cellStyle.getBorderBottom(), cellStyle.getBottomBorderColor());
+ processCellStyleBorder(workbook, cellTarget, "left",
+ cellStyle.getBorderLeft(), cellStyle.getLeftBorderColor());
- HSSFFont font = cellStyle.getFont( workbook );
- processCellStyleFont( workbook, blockTarget, font );
+ HSSFFont font = cellStyle.getFont(workbook);
+ processCellStyleFont(workbook, blockTarget, font);
}
- protected void processCellStyleBorder( HSSFWorkbook workbook,
- Element cellTarget, String type, BorderStyle xlsBorder, short borderColor )
- {
- if ( xlsBorder == BorderStyle.NONE )
+ protected void processCellStyleBorder(HSSFWorkbook workbook,
+ Element cellTarget, String type, BorderStyle xlsBorder, short borderColor) {
+ if (xlsBorder == BorderStyle.NONE) {
return;
+ }
StringBuilder borderStyle = new StringBuilder();
- borderStyle.append( AbstractExcelUtils.getBorderWidth( xlsBorder ) );
+ borderStyle.append(getBorderWidth(xlsBorder));
final HSSFColor color = workbook.getCustomPalette().getColor(
- borderColor );
- if ( color != null )
- {
- borderStyle.append( ' ' );
- borderStyle.append( AbstractExcelUtils.getColor( color ) );
+ borderColor);
+ if (color != null) {
+ borderStyle.append(' ');
+ borderStyle.append(getColor(color));
- borderStyle.append( ' ' );
- borderStyle.append( AbstractExcelUtils.getBorderStyle( xlsBorder ) );
+ borderStyle.append(' ');
+ borderStyle.append(getBorderStyle(xlsBorder));
}
- cellTarget.setAttribute( "border-" + type, borderStyle.toString() );
+ cellTarget.setAttribute("border-" + type, borderStyle.toString());
}
- protected void processCellStyleFont( HSSFWorkbook workbook,
- Element blockTarget, HSSFFont font )
- {
+ protected void processCellStyleFont(HSSFWorkbook workbook,
+ Element blockTarget, HSSFFont font) {
Triplet triplet = new Triplet();
triplet.fontName = font.getFontName();
triplet.bold = font.getBold();
triplet.italic = font.getItalic();
- getFontReplacer().update( triplet );
- setBlockProperties( blockTarget, triplet );
+ getFontReplacer().update(triplet);
+ setBlockProperties(blockTarget, triplet);
final HSSFColor fontColor = workbook.getCustomPalette().getColor(
- font.getColor() );
- if ( fontColor != null )
- blockTarget.setAttribute( "color",
- AbstractExcelUtils.getColor( fontColor ) );
+ font.getColor());
+ if (fontColor != null) {
+ blockTarget.setAttribute("color",
+ getColor(fontColor));
+ }
- if ( font.getFontHeightInPoints() != 0 )
- blockTarget.setAttribute( "font-size", font.getFontHeightInPoints()
- + "pt" );
+ if (font.getFontHeightInPoints() != 0) {
+ blockTarget.setAttribute("font-size", font.getFontHeightInPoints()
+ + "pt");
+ }
}
- protected void processColumnHeaders( HSSFSheet sheet, int maxSheetColumns,
- Element table )
- {
+ protected void processColumnHeaders(HSSFSheet sheet, int maxSheetColumns,
+ Element table) {
Element tableHeader = foDocumentFacade.createTableHeader();
Element row = foDocumentFacade.createTableRow();
- if ( isOutputRowNumbers() )
- {
+ if (isOutputRowNumbers()) {
// empty cell at left-top corner
final Element tableCellElement = foDocumentFacade.createTableCell();
- tableCellElement.appendChild( foDocumentFacade.createBlock() );
- row.appendChild( tableCellElement );
+ tableCellElement.appendChild(foDocumentFacade.createBlock());
+ row.appendChild(tableCellElement);
}
- for ( int c = 0; c < maxSheetColumns; c++ )
- {
- if ( !isOutputHiddenColumns() && sheet.isColumnHidden( c ) )
+ for (int c = 0; c < maxSheetColumns; c++) {
+ if (!isOutputHiddenColumns() && sheet.isColumnHidden(c)) {
continue;
+ }
Element cell = foDocumentFacade.createTableCell();
Element block = foDocumentFacade.createBlock();
- block.setAttribute( "text-align", "center" );
- block.setAttribute( "font-weight", "bold" );
+ block.setAttribute("text-align", "center");
+ block.setAttribute("font-weight", "bold");
- String text = getColumnName( c );
- block.appendChild( foDocumentFacade.createText( text ) );
+ String text = getColumnName(c);
+ block.appendChild(foDocumentFacade.createText(text));
- cell.appendChild( block );
- row.appendChild( cell );
+ cell.appendChild(block);
+ row.appendChild(cell);
}
- tableHeader.appendChild( row );
- table.appendChild( tableHeader );
+ tableHeader.appendChild(row);
+ table.appendChild(tableHeader);
}
/**
@@ -448,163 +427,155 @@ public class ExcelToFoConverter extends AbstractExcelConverter
*
* @return table width in inches
*/
- protected float processColumnWidths( HSSFSheet sheet, int maxSheetColumns,
- Element table )
- {
+ protected float processColumnWidths(HSSFSheet sheet, int maxSheetColumns,
+ Element table) {
float tableWidth = 0;
- if ( isOutputRowNumbers() )
- {
- final float columnWidthIn = getDefaultColumnWidth( sheet ) / DPI;
+ if (isOutputRowNumbers()) {
+ final float columnWidthIn = getDefaultColumnWidth(sheet) / DPI;
final Element rowNumberColumn = foDocumentFacade
- .createTableColumn();
- rowNumberColumn.setAttribute( "column-width", columnWidthIn + "in" );
- table.appendChild( rowNumberColumn );
+ .createTableColumn();
+ rowNumberColumn.setAttribute("column-width", columnWidthIn + "in");
+ table.appendChild(rowNumberColumn);
tableWidth += columnWidthIn;
}
- for ( int c = 0; c < maxSheetColumns; c++ )
- {
- if ( !isOutputHiddenColumns() && sheet.isColumnHidden( c ) )
+ for (int c = 0; c < maxSheetColumns; c++) {
+ if (!isOutputHiddenColumns() && sheet.isColumnHidden(c)) {
continue;
+ }
- final float columnWidthIn = getColumnWidth( sheet, c ) / DPI;
+ final float columnWidthIn = getColumnWidth(sheet, c) / DPI;
Element col = foDocumentFacade.createTableColumn();
- col.setAttribute( "column-width", columnWidthIn + "in" );
- table.appendChild( col );
+ col.setAttribute("column-width", columnWidthIn + "in");
+ table.appendChild(col);
tableWidth += columnWidthIn;
}
- table.setAttribute( "width", tableWidth + "in" );
+ table.setAttribute("width", tableWidth + "in");
return tableWidth;
}
protected void processDocumentInformation(
- SummaryInformation summaryInformation )
- {
- if ( AbstractExcelUtils.isNotEmpty( summaryInformation.getTitle() ) )
- foDocumentFacade.setTitle( summaryInformation.getTitle() );
+ SummaryInformation summaryInformation) {
+ if (isNotEmpty(summaryInformation.getTitle())) {
+ foDocumentFacade.setTitle(summaryInformation.getTitle());
+ }
- if ( AbstractExcelUtils.isNotEmpty( summaryInformation.getAuthor() ) )
- foDocumentFacade.setCreator( summaryInformation.getAuthor() );
+ if (isNotEmpty(summaryInformation.getAuthor())) {
+ foDocumentFacade.setCreator(summaryInformation.getAuthor());
+ }
- if ( AbstractExcelUtils.isNotEmpty( summaryInformation.getKeywords() ) )
- foDocumentFacade.setKeywords( summaryInformation.getKeywords() );
+ if (isNotEmpty(summaryInformation.getKeywords())) {
+ foDocumentFacade.setKeywords(summaryInformation.getKeywords());
+ }
- if ( AbstractExcelUtils.isNotEmpty( summaryInformation.getComments() ) )
- foDocumentFacade.setDescription( summaryInformation.getComments() );
+ if (isNotEmpty(summaryInformation.getComments())) {
+ foDocumentFacade.setDescription(summaryInformation.getComments());
+ }
}
/**
* @return maximum 1-base index of column that were rendered, zero if none
*/
- protected int processRow( HSSFWorkbook workbook,
- CellRangeAddress[][] mergedRanges, HSSFRow row,
- Element tableRowElement )
- {
+ protected int processRow(HSSFWorkbook workbook,
+ CellRangeAddress[][] mergedRanges, HSSFRow row,
+ Element tableRowElement) {
final HSSFSheet sheet = row.getSheet();
final short maxColIx = row.getLastCellNum();
- if ( maxColIx <= 0 )
- {
+ if (maxColIx <= 0) {
return 0;
}
final List<Element> emptyCells = new ArrayList<>(maxColIx);
- if ( isOutputRowNumbers() )
- {
- Element tableRowNumberCellElement = processRowNumber( row );
- emptyCells.add( tableRowNumberCellElement );
+ if (isOutputRowNumbers()) {
+ Element tableRowNumberCellElement = processRowNumber(row);
+ emptyCells.add(tableRowNumberCellElement);
}
int maxRenderedColumn = 0;
- for ( int colIx = 0; colIx < maxColIx; colIx++ )
- {
- if ( !isOutputHiddenColumns() && sheet.isColumnHidden( colIx ) )
+ for (int colIx = 0; colIx < maxColIx; colIx++) {
+ if (!isOutputHiddenColumns() && sheet.isColumnHidden(colIx)) {
continue;
+ }
- CellRangeAddress range = AbstractExcelUtils.getMergedRange(
- mergedRanges, row.getRowNum(), colIx );
+ CellRangeAddress range = getMergedRange(mergedRanges, row.getRowNum(), colIx);
- if ( range != null
- && ( range.getFirstColumn() != colIx || range.getFirstRow() != row
- .getRowNum() ) )
+ if (range != null
+ && (range.getFirstColumn() != colIx || range.getFirstRow() != row
+ .getRowNum())) {
continue;
+ }
- HSSFCell cell = row.getCell( colIx );
+ HSSFCell cell = row.getCell(colIx);
// spanning using overlapping blocks
int divWidthPx = 0;
{
- divWidthPx = getColumnWidth( sheet, colIx );
+ divWidthPx = getColumnWidth(sheet, colIx);
boolean hasBreaks = false;
- for ( int nextColumnIndex = colIx + 1; nextColumnIndex < maxColIx; nextColumnIndex++ )
- {
- if ( !isOutputHiddenColumns()
- && sheet.isColumnHidden( nextColumnIndex ) )
+ for (int nextColumnIndex = colIx + 1; nextColumnIndex < maxColIx; nextColumnIndex++) {
+ if (!isOutputHiddenColumns()
+ && sheet.isColumnHidden(nextColumnIndex)) {
continue;
+ }
- if ( row.getCell( nextColumnIndex ) != null
- && !isTextEmpty( row.getCell( nextColumnIndex ) ) )
- {
+ if (row.getCell(nextColumnIndex) != null
+ && !isTextEmpty(row.getCell(nextColumnIndex))) {
hasBreaks = true;
break;
}
- divWidthPx += getColumnWidth( sheet, nextColumnIndex );
+ divWidthPx += getColumnWidth(sheet, nextColumnIndex);
}
- if ( !hasBreaks )
+ if (!hasBreaks) {
divWidthPx = Integer.MAX_VALUE;
+ }
}
Element tableCellElement = foDocumentFacade.createTableCell();
- if ( range != null )
- {
- if ( range.getFirstColumn() != range.getLastColumn() )
+ if (range != null) {
+ if (range.getFirstColumn() != range.getLastColumn()) {
tableCellElement.setAttribute(
- "number-columns-spanned",
- String.valueOf( range.getLastColumn()
- - range.getFirstColumn() + 1 ) );
- if ( range.getFirstRow() != range.getLastRow() )
+ "number-columns-spanned",
+ String.valueOf(range.getLastColumn()
+ - range.getFirstColumn() + 1));
+ }
+ if (range.getFirstRow() != range.getLastRow()) {
tableCellElement.setAttribute(
- "number-rows-spanned",
- String.valueOf( range.getLastRow()
- - range.getFirstRow() + 1 ) );
+ "number-rows-spanned",
+ String.valueOf(range.getLastRow()
+ - range.getFirstRow() + 1));
+ }
}
boolean emptyCell;
- if ( cell != null )
- {
- emptyCell = processCell( workbook, cell, tableCellElement,
- getColumnWidth( sheet, colIx ), divWidthPx,
- row.getHeight() / 20f );
- }
- else
- {
- tableCellElement.appendChild( foDocumentFacade.createBlock() );
+ if (cell != null) {
+ emptyCell = processCell(workbook, cell, tableCellElement,
+ getColumnWidth(sheet, colIx), divWidthPx,
+ row.getHeight() / 20f);
+ } else {
+ tableCellElement.appendChild(foDocumentFacade.createBlock());
emptyCell = true;
}
- if ( emptyCell )
- {
- emptyCells.add( tableCellElement );
- }
- else
- {
- for ( Element emptyCellElement : emptyCells )
- {
- tableRowElement.appendChild( emptyCellElement );
+ if (emptyCell) {
+ emptyCells.add(tableCellElement);
+ } else {
+ for (Element emptyCellElement : emptyCells) {
+ tableRowElement.appendChild(emptyCellElement);
}
emptyCells.clear();
- tableRowElement.appendChild( tableCellElement );
+ tableRowElement.appendChild(tableCellElement);
maxRenderedColumn = colIx;
}
}
@@ -612,94 +583,86 @@ public class ExcelToFoConverter extends AbstractExcelConverter
return maxRenderedColumn + 1;
}
- protected Element processRowNumber( HSSFRow row )
- {
+ protected Element processRowNumber(HSSFRow row) {
Element tableRowNumberCellElement = foDocumentFacade.createTableCell();
Element block = foDocumentFacade.createBlock();
- block.setAttribute( "text-align", "right" );
- block.setAttribute( "font-weight", "bold" );
+ block.setAttribute("text-align", "right");
+ block.setAttribute("font-weight", "bold");
- Text text = foDocumentFacade.createText( getRowName( row ) );
- block.appendChild( text );
+ Text text = foDocumentFacade.createText(getRowName(row));
+ block.appendChild(text);
- tableRowNumberCellElement.appendChild( block );
+ tableRowNumberCellElement.appendChild(block);
return tableRowNumberCellElement;
}
- protected float processSheet( HSSFWorkbook workbook, HSSFSheet sheet,
- Element flow )
- {
+ protected float processSheet(HSSFWorkbook workbook, HSSFSheet sheet,
+ Element flow) {
final int physicalNumberOfRows = sheet.getPhysicalNumberOfRows();
- if ( physicalNumberOfRows <= 0 )
+ if (physicalNumberOfRows <= 0) {
return 0;
+ }
- processSheetName( sheet, flow );
+ processSheetName(sheet, flow);
Element table = foDocumentFacade.createTable();
- table.setAttribute( "table-layout", "fixed" );
+ table.setAttribute("table-layout", "fixed");
Element tableBody = foDocumentFacade.createTableBody();
- final CellRangeAddress[][] mergedRanges = ExcelToHtmlUtils
- .buildMergedRangesMap( sheet );
+ final CellRangeAddress[][] mergedRanges = buildMergedRangesMap(sheet);
final List<Element> emptyRowElements = new ArrayList<>(
- physicalNumberOfRows);
+ physicalNumberOfRows);
int maxSheetColumns = 1;
- for ( int r = sheet.getFirstRowNum(); r <= sheet.getLastRowNum(); r++ )
- {
- HSSFRow row = sheet.getRow( r );
+ for (int r = sheet.getFirstRowNum(); r <= sheet.getLastRowNum(); r++) {
+ HSSFRow row = sheet.getRow(r);
- if ( row == null )
+ if (row == null) {
continue;
+ }
- if ( !isOutputHiddenRows() && row.getZeroHeight() )
+ if (!isOutputHiddenRows() && row.getZeroHeight()) {
continue;
+ }
Element tableRowElement = foDocumentFacade.createTableRow();
- tableRowElement.setAttribute( "height", row.getHeight() / 20f
- + "pt" );
+ tableRowElement.setAttribute("height", row.getHeight() / 20f
+ + "pt");
- int maxRowColumnNumber = processRow( workbook, mergedRanges, row,
- tableRowElement );
+ int maxRowColumnNumber = processRow(workbook, mergedRanges, row,
+ tableRowElement);
- if ( tableRowElement.getChildNodes().getLength() == 0 )
- {
+ if (tableRowElement.getChildNodes().getLength() == 0) {
Element emptyCellElement = foDocumentFacade.createTableCell();
- emptyCellElement.appendChild( foDocumentFacade.createBlock() );
- tableRowElement.appendChild( emptyCellElement );
+ emptyCellElement.appendChild(foDocumentFacade.createBlock());
+ tableRowElement.appendChild(emptyCellElement);
}
- if ( maxRowColumnNumber == 0 )
- {
- emptyRowElements.add( tableRowElement );
- }
- else
- {
- if ( !emptyRowElements.isEmpty() )
- {
- for ( Element emptyRowElement : emptyRowElements )
- {
- tableBody.appendChild( emptyRowElement );
+ if (maxRowColumnNumber == 0) {
+ emptyRowElements.add(tableRowElement);
+ } else {
+ if (!emptyRowElements.isEmpty()) {
+ for (Element emptyRowElement : emptyRowElements) {
+ tableBody.appendChild(emptyRowElement);
}
emptyRowElements.clear();
}
- tableBody.appendChild( tableRowElement );
+ tableBody.appendChild(tableRowElement);
}
- maxSheetColumns = Math.max( maxSheetColumns, maxRowColumnNumber );
+ maxSheetColumns = Math.max(maxSheetColumns, maxRowColumnNumber);
}
- float tableWidthIn = processColumnWidths( sheet, maxSheetColumns, table );
+ float tableWidthIn = processColumnWidths(sheet, maxSheetColumns, table);
- if ( isOutputColumnHeaders() )
- {
- processColumnHeaders( sheet, maxSheetColumns, table );
+ if (isOutputColumnHeaders()) {
+ processColumnHeaders(sheet, maxSheetColumns, table);
}
- table.appendChild( tableBody );
- flow.appendChild( table );
+ table.appendChild(tableBody);
+ flow.appendChild(table);
return tableWidthIn;
}
@@ -708,82 +671,79 @@ public class ExcelToFoConverter extends AbstractExcelConverter
* Process single sheet (as specified by 0-based sheet index)
*
* @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;
Element pageSequence = foDocumentFacade
- .createPageSequence( pageMasterName );
- Element flow = foDocumentFacade.addFlowToPageSequence( pageSequence,
- "xsl-region-body" );
+ .createPageSequence(pageMasterName);
+ Element flow = foDocumentFacade.addFlowToPageSequence(pageSequence,
+ "xsl-region-body");
- HSSFSheet sheet = workbook.getSheetAt( sheetIndex );
- float tableWidthIn = processSheet( workbook, sheet, flow );
+ HSSFSheet sheet = workbook.getSheetAt(sheetIndex);
+ float tableWidthIn = processSheet(workbook, sheet, flow);
- if ( tableWidthIn == 0 )
+ if (tableWidthIn == 0) {
return false;
+ }
- createPageMaster( tableWidthIn, pageMasterName );
- foDocumentFacade.addPageSequence( pageSequence );
+ createPageMaster(tableWidthIn, pageMasterName);
+ foDocumentFacade.addPageSequence(pageSequence);
return true;
}
- protected void processSheetName( HSSFSheet sheet, Element flow )
- {
+ protected void processSheetName(HSSFSheet sheet, Element flow) {
Element titleBlock = foDocumentFacade.createBlock();
Triplet triplet = new Triplet();
triplet.bold = true;
triplet.italic = false;
triplet.fontName = "Arial";
- getFontReplacer().update( triplet );
+ getFontReplacer().update(triplet);
- setBlockProperties( titleBlock, triplet );
- titleBlock.setAttribute( "font-size", "200%" );
+ setBlockProperties(titleBlock, triplet);
+ titleBlock.setAttribute("font-size", "200%");
Element titleInline = foDocumentFacade.createInline();
- titleInline.appendChild( foDocumentFacade.createText( sheet
- .getSheetName() ) );
- titleBlock.appendChild( titleInline );
- flow.appendChild( titleBlock );
+ titleInline.appendChild(foDocumentFacade.createText(sheet
+ .getSheetName()));
+ titleBlock.appendChild(titleInline);
+ flow.appendChild(titleBlock);
Element titleBlock2 = foDocumentFacade.createBlock();
Element titleInline2 = foDocumentFacade.createInline();
- titleBlock2.appendChild( titleInline2 );
- flow.appendChild( titleBlock2 );
+ titleBlock2.appendChild(titleInline2);
+ flow.appendChild(titleBlock2);
}
- public void processWorkbook( HSSFWorkbook workbook )
- {
+ public void processWorkbook(HSSFWorkbook workbook) {
final SummaryInformation summaryInformation = workbook
- .getSummaryInformation();
- if ( summaryInformation != null )
- {
- processDocumentInformation( summaryInformation );
+ .getSummaryInformation();
+ if (summaryInformation != null) {
+ processDocumentInformation(summaryInformation);
}
- for ( int s = 0; s < workbook.getNumberOfSheets(); s++ )
- {
- processSheet( workbook, s );
+ for (int s = 0; s < workbook.getNumberOfSheets(); s++) {
+ processSheet(workbook, s);
}
}
- private void setBlockProperties( Element textBlock, Triplet triplet )
- {
- if ( triplet.bold )
- textBlock.setAttribute( "font-weight", "bold" );
+ private void setBlockProperties(Element textBlock, Triplet triplet) {
+ if (triplet.bold) {
+ textBlock.setAttribute("font-weight", "bold");
+ }
- if ( triplet.italic )
- textBlock.setAttribute( "font-style", "italic" );
+ if (triplet.italic) {
+ textBlock.setAttribute("font-style", "italic");
+ }
- if ( AbstractExcelUtils.isNotEmpty( triplet.fontName ) )
- textBlock.setAttribute( "font-family", triplet.fontName );
+ if (isNotEmpty(triplet.fontName)) {
+ textBlock.setAttribute("font-family", triplet.fontName);
+ }
}
- public void setPageMarginInches( float pageMarginInches )
- {
+ public void setPageMarginInches(float pageMarginInches) {
this.pageMarginInches = pageMarginInches;
}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java b/poi-scratchpad/src/main/java/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java
index 0110c71ec9..aab72a0e69 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java
@@ -16,6 +16,16 @@
==================================================================== */
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.IOException;
import java.io.InputStream;
@@ -53,8 +63,6 @@ import org.w3c.dom.Text;
/**
* Converts xls files (97-2007) to HTML file.
- *
- * @author Sergey Vladimirov (vlsergey {at} gmail {dot} com)
*/
@Beta
public class ExcelToHtmlConverter extends AbstractExcelConverter {
@@ -69,37 +77,36 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
* Where infile is an input .xls file ( Word 97-2007) which will be rendered
* as HTML into outfile
*/
- public static void main( String[] args ) throws Exception {
- if ( args.length < 2 ) {
- System.err.println( "Usage: ExcelToHtmlConverter <inputFile.xls> <saveTo.html>" );
+ public static void main(String[] args) throws Exception {
+ if (args.length < 2) {
+ System.err.println("Usage: ExcelToHtmlConverter <inputFile.xls> <saveTo.html>");
return;
}
- System.out.println( "Converting " + args[0] );
- System.out.println( "Saving output to " + args[1] );
+ System.out.println("Converting " + args[0]);
+ System.out.println("Saving output to " + args[1]);
- Document doc = ExcelToHtmlConverter.process( new File( args[0] ) );
+ Document doc = ExcelToHtmlConverter.process(new File(args[0]));
- DOMSource domSource = new DOMSource( doc );
- StreamResult streamResult = new StreamResult( new File(args[1]) );
+ DOMSource domSource = new DOMSource(doc);
+ StreamResult streamResult = new StreamResult(new File(args[1]));
Transformer serializer = XMLHelper.newTransformer();
// TODO set encoding from a command argument
- serializer.setOutputProperty( OutputKeys.METHOD, "html" );
- serializer.transform( domSource, streamResult );
+ serializer.setOutputProperty(OutputKeys.METHOD, "html");
+ serializer.transform(domSource, streamResult);
}
/**
* Converts Excel file (97-2007) into HTML file.
*
- * @param xlsFile
- * workbook file to process
+ * @param xlsFile workbook file to process
* @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
*/
- public static Document process( File xlsFile ) throws IOException, ParserConfigurationException {
- try (HSSFWorkbook workbook = AbstractExcelUtils.loadXls(xlsFile)) {
+ public static Document process(File xlsFile) throws IOException, ParserConfigurationException {
+ try (HSSFWorkbook workbook = loadXls(xlsFile)) {
return ExcelToHtmlConverter.process(workbook);
}
}
@@ -109,10 +116,10 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
*
* @param xlsStream workbook stream to process
* @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
*/
- public static Document process( InputStream xlsStream ) throws IOException, ParserConfigurationException {
+ public static Document process(InputStream xlsStream) throws IOException, ParserConfigurationException {
try (HSSFWorkbook workbook = new HSSFWorkbook(xlsStream)) {
return ExcelToHtmlConverter.process(workbook);
}
@@ -123,13 +130,13 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
*
* @param workbook workbook instance to process
* @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
*/
- public static Document process( HSSFWorkbook workbook ) throws IOException, ParserConfigurationException {
+ public static Document process(HSSFWorkbook workbook) throws IOException, ParserConfigurationException {
ExcelToHtmlConverter excelToHtmlConverter = new ExcelToHtmlConverter(
- XMLHelper.newDocumentBuilder().newDocument() );
- excelToHtmlConverter.processWorkbook( workbook );
+ XMLHelper.newDocumentBuilder().newDocument());
+ excelToHtmlConverter.processWorkbook(workbook);
return excelToHtmlConverter.getDocument();
}
@@ -145,221 +152,215 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
private String cssClassPrefixTable = "t";
- private Map<Short, String> excelStyleToClass = new LinkedHashMap<>();
+ private final Map<Short, String> excelStyleToClass = new LinkedHashMap<>();
private final HtmlDocumentFacade htmlDocumentFacade;
private boolean useDivsToSpan;
- public ExcelToHtmlConverter( Document doc )
- {
- htmlDocumentFacade = new HtmlDocumentFacade( doc );
+ public ExcelToHtmlConverter(Document doc) {
+ htmlDocumentFacade = new HtmlDocumentFacade(doc);
}
- public ExcelToHtmlConverter( HtmlDocumentFacade htmlDocumentFacade ) {
+ public ExcelToHtmlConverter(HtmlDocumentFacade htmlDocumentFacade) {
this.htmlDocumentFacade = htmlDocumentFacade;
}
- protected String buildStyle( HSSFWorkbook workbook, HSSFCellStyle cellStyle ) {
+ protected String buildStyle(HSSFWorkbook workbook, HSSFCellStyle cellStyle) {
StringBuilder style = new StringBuilder();
- style.append( "white-space:pre-wrap;" );
- ExcelToHtmlUtils.appendAlign( style, cellStyle.getAlignment() );
+ style.append("white-space:pre-wrap;");
+ appendAlign(style, cellStyle.getAlignment());
switch (cellStyle.getFillPattern()) {
// no fill
- case NO_FILL: break;
+ case NO_FILL:
+ break;
case SOLID_FOREGROUND:
final HSSFColor foregroundColor = cellStyle.getFillForegroundColorColor();
- if ( foregroundColor == null ) break;
- String fgCol = AbstractExcelUtils.getColor( foregroundColor );
+ if (foregroundColor == null) {
+ break;
+ }
+ String fgCol = getColor(foregroundColor);
style.append("background-color:").append(fgCol).append(";");
break;
default:
final HSSFColor backgroundColor = cellStyle.getFillBackgroundColorColor();
- if ( backgroundColor == null ) break;
- String bgCol = AbstractExcelUtils.getColor( backgroundColor );
+ if (backgroundColor == null) {
+ break;
+ }
+ String bgCol = getColor(backgroundColor);
style.append("background-color:").append(bgCol).append(";");
break;
}
- buildStyle_border( workbook, style, "top", cellStyle.getBorderTop(),
- cellStyle.getTopBorderColor() );
- buildStyle_border( workbook, style, "right",
- cellStyle.getBorderRight(), cellStyle.getRightBorderColor() );
- buildStyle_border( workbook, style, "bottom",
- cellStyle.getBorderBottom(), cellStyle.getBottomBorderColor() );
- buildStyle_border( workbook, style, "left", cellStyle.getBorderLeft(),
- cellStyle.getLeftBorderColor() );
+ buildStyle_border(workbook, style, "top", cellStyle.getBorderTop(),
+ cellStyle.getTopBorderColor());
+ buildStyle_border(workbook, style, "right",
+ cellStyle.getBorderRight(), cellStyle.getRightBorderColor());
+ buildStyle_border(workbook, style, "bottom",
+ cellStyle.getBorderBottom(), cellStyle.getBottomBorderColor());
+ buildStyle_border(workbook, style, "left", cellStyle.getBorderLeft(),
+ cellStyle.getLeftBorderColor());
- HSSFFont font = cellStyle.getFont( workbook );
- buildStyle_font( workbook, style, font );
+ HSSFFont font = cellStyle.getFont(workbook);
+ buildStyle_font(workbook, style, font);
return style.toString();
}
- private void buildStyle_border( HSSFWorkbook workbook, StringBuilder style,
- String type, BorderStyle xlsBorder, short borderColor ) {
- if ( xlsBorder == BorderStyle.NONE ) {
+ private void buildStyle_border(HSSFWorkbook workbook, StringBuilder style,
+ String type, BorderStyle xlsBorder, short borderColor) {
+ if (xlsBorder == BorderStyle.NONE) {
return;
}
StringBuilder borderStyle = new StringBuilder();
- borderStyle.append( AbstractExcelUtils.getBorderWidth( xlsBorder ) );
- borderStyle.append( ' ' );
- borderStyle.append( AbstractExcelUtils.getBorderStyle( xlsBorder ) );
-
- final HSSFColor color = workbook.getCustomPalette().getColor(
- borderColor );
- if ( color != null )
- {
- borderStyle.append( ' ' );
- borderStyle.append( AbstractExcelUtils.getColor( color ) );
+ borderStyle.append(getBorderWidth(xlsBorder));
+ borderStyle.append(' ');
+ borderStyle.append(getBorderStyle(xlsBorder));
+
+ final HSSFColor color = workbook.getCustomPalette().getColor(borderColor);
+ if (color != null) {
+ borderStyle.append(' ');
+ borderStyle.append(getColor(color));
}
style.append("border-").append(type).append(":").append(borderStyle).append(";");
}
- void buildStyle_font( HSSFWorkbook workbook, StringBuilder style,
- HSSFFont font ) {
- if ( font.getBold() )
- {
- style.append( "font-weight:bold;" );
+ void buildStyle_font(HSSFWorkbook workbook, StringBuilder style,
+ HSSFFont font) {
+ if (font.getBold()) {
+ style.append("font-weight:bold;");
}
final HSSFColor fontColor = workbook.getCustomPalette().getColor(
- font.getColor() );
- if ( fontColor != null )
- style.append("color: ").append(AbstractExcelUtils.getColor(fontColor)).append("; ");
+ font.getColor());
+ if (fontColor != null) {
+ style.append("color: ").append(getColor(fontColor)).append("; ");
+ }
- if ( font.getFontHeightInPoints() != 0 )
+ if (font.getFontHeightInPoints() != 0) {
style.append("font-size:").append(font.getFontHeightInPoints()).append("pt;");
+ }
- if ( font.getItalic() )
- {
- style.append( "font-style:italic;" );
+ if (font.getItalic()) {
+ style.append("font-style:italic;");
}
}
- public String getCssClassPrefixCell()
- {
+ public String getCssClassPrefixCell() {
return cssClassPrefixCell;
}
- public String getCssClassPrefixDiv()
- {
+ public String getCssClassPrefixDiv() {
return cssClassPrefixDiv;
}
- public String getCssClassPrefixRow()
- {
+ public String getCssClassPrefixRow() {
return cssClassPrefixRow;
}
- public String getCssClassPrefixTable()
- {
+ public String getCssClassPrefixTable() {
return cssClassPrefixTable;
}
- public Document getDocument()
- {
+ public Document getDocument() {
return htmlDocumentFacade.getDocument();
}
- protected String getStyleClassName( HSSFWorkbook workbook,
- HSSFCellStyle cellStyle ) {
- final Short cellStyleKey = Short.valueOf( cellStyle.getIndex() );
+ protected String getStyleClassName(HSSFWorkbook workbook,
+ HSSFCellStyle cellStyle) {
+ final Short cellStyleKey = Short.valueOf(cellStyle.getIndex());
- String knownClass = excelStyleToClass.get( cellStyleKey );
- if ( knownClass != null )
+ String knownClass = excelStyleToClass.get(cellStyleKey);
+ if (knownClass != null) {
return knownClass;
+ }
- String cssStyle = buildStyle( workbook, cellStyle );
+ String cssStyle = buildStyle(workbook, cellStyle);
String cssClass = htmlDocumentFacade.getOrCreateCssClass(
- cssClassPrefixCell, cssStyle );
- excelStyleToClass.put( cellStyleKey, cssClass );
+ cssClassPrefixCell, cssStyle);
+ excelStyleToClass.put(cellStyleKey, cssClass);
return cssClass;
}
- public boolean isUseDivsToSpan()
- {
+ public boolean isUseDivsToSpan() {
return useDivsToSpan;
}
- protected boolean processCell( HSSFCell cell, Element tableCellElement,
- int normalWidthPx, int maxSpannedWidthPx, float normalHeightPt ) {
+ protected boolean processCell(HSSFCell cell, Element tableCellElement,
+ int normalWidthPx, int maxSpannedWidthPx, float normalHeightPt) {
final HSSFCellStyle cellStyle = cell.getCellStyle();
String value;
- switch ( cell.getCellType() ) {
- case STRING:
- // XXX: enrich
- value = cell.getRichStringCellValue().getString();
- break;
- case FORMULA:
- switch ( cell.getCachedFormulaResultType() ) {
+ switch (cell.getCellType()) {
case STRING:
- HSSFRichTextString str = cell.getRichStringCellValue();
- if ( str != null && str.length() > 0 )
- {
- value = ( str.toString() );
- }
- else
- {
- value = AbstractExcelUtils.EMPTY;
+ // XXX: enrich
+ value = cell.getRichStringCellValue().getString();
+ break;
+ case FORMULA:
+ switch (cell.getCachedFormulaResultType()) {
+ case STRING:
+ HSSFRichTextString str = cell.getRichStringCellValue();
+ if (str != null && str.length() > 0) {
+ value = (str.toString());
+ } else {
+ value = AbstractExcelUtils.EMPTY;
+ }
+ break;
+ case NUMERIC:
+ double nValue = cell.getNumericCellValue();
+ short df = cellStyle.getDataFormat();
+ String dfs = cellStyle.getDataFormatString();
+ value = _formatter.formatRawCellContents(nValue, df, dfs);
+ break;
+ case BOOLEAN:
+ value = String.valueOf(cell.getBooleanCellValue());
+ break;
+ case ERROR:
+ value = ErrorEval.getText(cell.getErrorCellValue());
+ break;
+ default:
+ LOG.atWarn().log("Unexpected cell cachedFormulaResultType ({})", cell.getCachedFormulaResultType());
+ value = AbstractExcelUtils.EMPTY;
+ break;
}
break;
+ case BLANK:
+ value = AbstractExcelUtils.EMPTY;
+ break;
case NUMERIC:
- double nValue = cell.getNumericCellValue();
- short df = cellStyle.getDataFormat();
- String dfs = cellStyle.getDataFormatString();
- value = _formatter.formatRawCellContents(nValue, df, dfs);
+ value = _formatter.formatCellValue(cell);
break;
case BOOLEAN:
- value = String.valueOf( cell.getBooleanCellValue() );
+ value = String.valueOf(cell.getBooleanCellValue());
break;
case ERROR:
- value = ErrorEval.getText( cell.getErrorCellValue() );
+ value = ErrorEval.getText(cell.getErrorCellValue());
break;
default:
- LOG.atWarn().log("Unexpected cell cachedFormulaResultType ({})", cell.getCachedFormulaResultType());
- value = AbstractExcelUtils.EMPTY;
- break;
- }
- break;
- case BLANK:
- value = AbstractExcelUtils.EMPTY;
- break;
- case NUMERIC:
- value = _formatter.formatCellValue( cell );
- break;
- case BOOLEAN:
- value = String.valueOf( cell.getBooleanCellValue() );
- break;
- case ERROR:
- value = ErrorEval.getText( cell.getErrorCellValue() );
- break;
- default:
- LOG.atWarn().log("Unexpected cell type ({})", cell.getCellType());
- return true;
- }
-
- final boolean noText = AbstractExcelUtils.isEmpty( value );
+ LOG.atWarn().log("Unexpected cell type ({})", cell.getCellType());
+ return true;
+ }
+
+ final boolean noText = isEmpty(value);
final boolean wrapInDivs = !noText && isUseDivsToSpan() && !cellStyle.getWrapText();
- if ( cellStyle.getIndex() != 0 ) {
+ if (cellStyle.getIndex() != 0) {
@SuppressWarnings("resource")
HSSFWorkbook workbook = cell.getRow().getSheet().getWorkbook();
- String mainCssClass = getStyleClassName( workbook, cellStyle );
+ String mainCssClass = getStyleClassName(workbook, cellStyle);
- if ( wrapInDivs ) {
- tableCellElement.setAttribute( "class", mainCssClass + " "
- + cssClassContainerCell );
+ if (wrapInDivs) {
+ tableCellElement.setAttribute("class", mainCssClass + " "
+ + cssClassContainerCell);
} else {
- tableCellElement.setAttribute( "class", mainCssClass );
+ tableCellElement.setAttribute("class", mainCssClass);
}
- if ( noText ) {
+ if (noText) {
/*
* if cell style is defined (like borders, etc.) but cell text
* is empty, add "&nbsp;" to output, so browser won't collapse
@@ -369,216 +370,219 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
}
}
- if ( isOutputLeadingSpacesAsNonBreaking() && value.startsWith( " " ) ) {
+ if (isOutputLeadingSpacesAsNonBreaking() && value.startsWith(" ")) {
StringBuilder builder = new StringBuilder();
- for ( int c = 0; c < value.length(); c++ )
- {
- if ( value.charAt( c ) != ' ' )
+ for (int c = 0; c < value.length(); c++) {
+ if (value.charAt(c) != ' ') {
break;
- builder.append( '\u00a0' );
+ }
+ builder.append('\u00a0');
}
- if ( value.length() != builder.length() )
- builder.append( value.substring( builder.length() ) );
+ if (value.length() != builder.length()) {
+ builder.append(value.substring(builder.length()));
+ }
value = builder.toString();
}
- Text text = htmlDocumentFacade.createText( value );
+ Text text = htmlDocumentFacade.createText(value);
- if ( wrapInDivs ) {
+ if (wrapInDivs) {
Element outerDiv = htmlDocumentFacade.createBlock();
- outerDiv.setAttribute( "class", this.cssClassContainerDiv );
+ outerDiv.setAttribute("class", this.cssClassContainerDiv);
Element innerDiv = htmlDocumentFacade.createBlock();
StringBuilder innerDivStyle = new StringBuilder();
- innerDivStyle.append( "position:absolute;min-width:" );
- innerDivStyle.append( normalWidthPx );
- innerDivStyle.append( "px;" );
- if ( maxSpannedWidthPx != Integer.MAX_VALUE ) {
- innerDivStyle.append( "max-width:" );
- innerDivStyle.append( maxSpannedWidthPx );
- innerDivStyle.append( "px;" );
+ innerDivStyle.append("position:absolute;min-width:");
+ innerDivStyle.append(normalWidthPx);
+ innerDivStyle.append("px;");
+ if (maxSpannedWidthPx != Integer.MAX_VALUE) {
+ innerDivStyle.append("max-width:");
+ innerDivStyle.append(maxSpannedWidthPx);
+ innerDivStyle.append("px;");
}
- innerDivStyle.append( "overflow:hidden;max-height:" );
- innerDivStyle.append( normalHeightPt );
- innerDivStyle.append( "pt;white-space:nowrap;" );
- ExcelToHtmlUtils.appendAlign( innerDivStyle, cellStyle.getAlignment() );
- htmlDocumentFacade.addStyleClass( outerDiv, cssClassPrefixDiv,
- innerDivStyle.toString() );
-
- innerDiv.appendChild( text );
- outerDiv.appendChild( innerDiv );
- tableCellElement.appendChild( outerDiv );
+ innerDivStyle.append("overflow:hidden;max-height:");
+ innerDivStyle.append(normalHeightPt);
+ innerDivStyle.append("pt;white-space:nowrap;");
+ appendAlign(innerDivStyle, cellStyle.getAlignment());
+ htmlDocumentFacade.addStyleClass(outerDiv, cssClassPrefixDiv,
+ innerDivStyle.toString());
+
+ innerDiv.appendChild(text);
+ outerDiv.appendChild(innerDiv);
+ tableCellElement.appendChild(outerDiv);
} else {
- 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,
- Element table ) {
+ protected void processColumnHeaders(HSSFSheet sheet, int maxSheetColumns,
+ Element table) {
Element tableHeader = htmlDocumentFacade.createTableHeader();
- table.appendChild( tableHeader );
+ table.appendChild(tableHeader);
Element tr = htmlDocumentFacade.createTableRow();
- if ( isOutputRowNumbers() ) {
+ if (isOutputRowNumbers()) {
// empty row at left-top corner
- tr.appendChild( htmlDocumentFacade.createTableHeaderCell() );
+ tr.appendChild(htmlDocumentFacade.createTableHeaderCell());
}
- for ( int c = 0; c < maxSheetColumns; c++ ) {
- if ( !isOutputHiddenColumns() && sheet.isColumnHidden( c ) )
+ for (int c = 0; c < maxSheetColumns; c++) {
+ if (!isOutputHiddenColumns() && sheet.isColumnHidden(c)) {
continue;
+ }
Element th = htmlDocumentFacade.createTableHeaderCell();
- String text = getColumnName( c );
- th.appendChild( htmlDocumentFacade.createText( text ) );
- tr.appendChild( th );
+ String text = getColumnName(c);
+ th.appendChild(htmlDocumentFacade.createText(text));
+ tr.appendChild(th);
}
- tableHeader.appendChild( tr );
+ tableHeader.appendChild(tr);
}
/**
* Creates COLGROUP element with width specified for all columns. (Except
* first if <tt>{@link #isOutputRowNumbers()}==true</tt>)
*/
- protected void processColumnWidths( HSSFSheet sheet, int maxSheetColumns,
- Element table ) {
+ protected void processColumnWidths(HSSFSheet sheet, int maxSheetColumns,
+ Element table) {
// draw COLS after we know max column number
Element columnGroup = htmlDocumentFacade.createTableColumnGroup();
- if ( isOutputRowNumbers() )
- {
- columnGroup.appendChild( htmlDocumentFacade.createTableColumn() );
+ if (isOutputRowNumbers()) {
+ columnGroup.appendChild(htmlDocumentFacade.createTableColumn());
}
- for ( int c = 0; c < maxSheetColumns; c++ )
- {
- if ( !isOutputHiddenColumns() && sheet.isColumnHidden( c ) )
+ for (int c = 0; c < maxSheetColumns; c++) {
+ if (!isOutputHiddenColumns() && sheet.isColumnHidden(c)) {
continue;
+ }
Element col = htmlDocumentFacade.createTableColumn();
- col.setAttribute( "width",
- String.valueOf( getColumnWidth( sheet, c ) ) );
- columnGroup.appendChild( col );
+ col.setAttribute("width",
+ String.valueOf(getColumnWidth(sheet, c)));
+ columnGroup.appendChild(col);
}
- table.appendChild( columnGroup );
+ table.appendChild(columnGroup);
}
- protected void processDocumentInformation(SummaryInformation summaryInformation ) {
- if ( AbstractExcelUtils.isNotEmpty( summaryInformation.getTitle() ) )
- htmlDocumentFacade.setTitle( summaryInformation.getTitle() );
+ protected void processDocumentInformation(SummaryInformation summaryInformation) {
+ if (isNotEmpty(summaryInformation.getTitle())) {
+ htmlDocumentFacade.setTitle(summaryInformation.getTitle());
+ }
- if ( AbstractExcelUtils.isNotEmpty( summaryInformation.getAuthor() ) )
- htmlDocumentFacade.addAuthor( summaryInformation.getAuthor() );
+ if (isNotEmpty(summaryInformation.getAuthor())) {
+ htmlDocumentFacade.addAuthor(summaryInformation.getAuthor());
+ }
- if ( AbstractExcelUtils.isNotEmpty( summaryInformation.getKeywords() ) )
- htmlDocumentFacade.addKeywords( summaryInformation.getKeywords() );
+ if (isNotEmpty(summaryInformation.getKeywords())) {
+ htmlDocumentFacade.addKeywords(summaryInformation.getKeywords());
+ }
- if ( AbstractExcelUtils.isNotEmpty( summaryInformation.getComments() ) )
+ if (isNotEmpty(summaryInformation.getComments())) {
htmlDocumentFacade
- .addDescription( summaryInformation.getComments() );
+ .addDescription(summaryInformation.getComments());
+ }
}
/**
* @return maximum 1-base index of column that were rendered, zero if none
*/
- protected int processRow( CellRangeAddress[][] mergedRanges, HSSFRow row,
- Element tableRowElement ) {
+ protected int processRow(CellRangeAddress[][] mergedRanges, HSSFRow row,
+ Element tableRowElement) {
final HSSFSheet sheet = row.getSheet();
final short maxColIx = row.getLastCellNum();
- if ( maxColIx <= 0 )
+ if (maxColIx <= 0) {
return 0;
+ }
final List<Element> emptyCells = new ArrayList<>(maxColIx);
- if ( isOutputRowNumbers() )
- {
+ if (isOutputRowNumbers()) {
Element tableRowNumberCellElement = htmlDocumentFacade
- .createTableHeaderCell();
- processRowNumber( row, tableRowNumberCellElement );
- emptyCells.add( tableRowNumberCellElement );
+ .createTableHeaderCell();
+ processRowNumber(row, tableRowNumberCellElement);
+ emptyCells.add(tableRowNumberCellElement);
}
int maxRenderedColumn = 0;
- for ( int colIx = 0; colIx < maxColIx; colIx++ )
- {
- if ( !isOutputHiddenColumns() && sheet.isColumnHidden( colIx ) )
+ for (int colIx = 0; colIx < maxColIx; colIx++) {
+ if (!isOutputHiddenColumns() && sheet.isColumnHidden(colIx)) {
continue;
+ }
- CellRangeAddress range = AbstractExcelUtils.getMergedRange(
- mergedRanges, row.getRowNum(), colIx );
+ CellRangeAddress range = getMergedRange(mergedRanges, row.getRowNum(), colIx);
- if ( range != null
- && ( range.getFirstColumn() != colIx || range.getFirstRow() != row
- .getRowNum() ) )
+ if (range != null
+ && (range.getFirstColumn() != colIx || range.getFirstRow() != row
+ .getRowNum())) {
continue;
+ }
- HSSFCell cell = row.getCell( colIx );
+ HSSFCell cell = row.getCell(colIx);
int divWidthPx = 0;
- if ( isUseDivsToSpan() )
- {
- divWidthPx = getColumnWidth( sheet, colIx );
+ if (isUseDivsToSpan()) {
+ divWidthPx = getColumnWidth(sheet, colIx);
boolean hasBreaks = false;
- for ( int nextColumnIndex = colIx + 1; nextColumnIndex < maxColIx; nextColumnIndex++ )
- {
- if ( !isOutputHiddenColumns()
- && sheet.isColumnHidden( nextColumnIndex ) )
+ for (int nextColumnIndex = colIx + 1; nextColumnIndex < maxColIx; nextColumnIndex++) {
+ if (!isOutputHiddenColumns()
+ && sheet.isColumnHidden(nextColumnIndex)) {
continue;
+ }
- if ( row.getCell( nextColumnIndex ) != null
- && !isTextEmpty( row.getCell( nextColumnIndex ) ) )
- {
+ if (row.getCell(nextColumnIndex) != null
+ && !isTextEmpty(row.getCell(nextColumnIndex))) {
hasBreaks = true;
break;
}
- divWidthPx += getColumnWidth( sheet, nextColumnIndex );
+ divWidthPx += getColumnWidth(sheet, nextColumnIndex);
}
- if ( !hasBreaks )
+ if (!hasBreaks) {
divWidthPx = Integer.MAX_VALUE;
+ }
}
Element tableCellElement = htmlDocumentFacade.createTableCell();
- if ( range != null )
- {
- if ( range.getFirstColumn() != range.getLastColumn() )
+ if (range != null) {
+ if (range.getFirstColumn() != range.getLastColumn()) {
tableCellElement.setAttribute(
- "colspan",
- String.valueOf( range.getLastColumn()
- - range.getFirstColumn() + 1 ) );
- if ( range.getFirstRow() != range.getLastRow() )
+ "colspan",
+ String.valueOf(range.getLastColumn()
+ - range.getFirstColumn() + 1));
+ }
+ if (range.getFirstRow() != range.getLastRow()) {
tableCellElement.setAttribute(
- "rowspan",
- String.valueOf( range.getLastRow()
- - range.getFirstRow() + 1 ) );
+ "rowspan",
+ String.valueOf(range.getLastRow()
+ - range.getFirstRow() + 1));
+ }
}
boolean emptyCell;
- if ( cell != null )
- {
- emptyCell = processCell( cell, tableCellElement,
- getColumnWidth( sheet, colIx ), divWidthPx,
- row.getHeight() / 20f );
+ if (cell != null) {
+ emptyCell = processCell(cell, tableCellElement,
+ getColumnWidth(sheet, colIx), divWidthPx,
+ row.getHeight() / 20f);
} else {
emptyCell = true;
}
- if ( emptyCell ) {
- emptyCells.add( tableCellElement );
+ if (emptyCell) {
+ emptyCells.add(tableCellElement);
} else {
- for ( Element emptyCellElement : emptyCells )
- {
- tableRowElement.appendChild( emptyCellElement );
+ for (Element emptyCellElement : emptyCells) {
+ tableRowElement.appendChild(emptyCellElement);
}
emptyCells.clear();
- tableRowElement.appendChild( tableCellElement );
+ tableRowElement.appendChild(tableCellElement);
maxRenderedColumn = colIx;
}
}
@@ -586,122 +590,120 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
return maxRenderedColumn + 1;
}
- protected void processRowNumber( HSSFRow row,
- Element tableRowNumberCellElement ) {
- tableRowNumberCellElement.setAttribute( "class", "rownumber" );
- Text text = htmlDocumentFacade.createText( getRowName( row ) );
- tableRowNumberCellElement.appendChild( text );
+ protected void processRowNumber(HSSFRow row,
+ Element tableRowNumberCellElement) {
+ tableRowNumberCellElement.setAttribute("class", "rownumber");
+ Text text = htmlDocumentFacade.createText(getRowName(row));
+ tableRowNumberCellElement.appendChild(text);
}
- protected void processSheet( HSSFSheet sheet ) {
- processSheetHeader( htmlDocumentFacade.getBody(), sheet );
+ protected void processSheet(HSSFSheet sheet) {
+ processSheetHeader(htmlDocumentFacade.getBody(), sheet);
final int physicalNumberOfRows = sheet.getPhysicalNumberOfRows();
- if ( physicalNumberOfRows <= 0 )
+ if (physicalNumberOfRows <= 0) {
return;
+ }
Element table = htmlDocumentFacade.createTable();
- htmlDocumentFacade.addStyleClass( table, cssClassPrefixTable,
- "border-collapse:collapse;border-spacing:0;" );
+ htmlDocumentFacade.addStyleClass(table, cssClassPrefixTable,
+ "border-collapse:collapse;border-spacing:0;");
Element tableBody = htmlDocumentFacade.createTableBody();
- final CellRangeAddress[][] mergedRanges = ExcelToHtmlUtils
- .buildMergedRangesMap( sheet );
+ final CellRangeAddress[][] mergedRanges = buildMergedRangesMap(sheet);
final List<Element> emptyRowElements = new ArrayList<>(
- physicalNumberOfRows);
+ physicalNumberOfRows);
int maxSheetColumns = 1;
- for ( int r = sheet.getFirstRowNum(); r <= sheet.getLastRowNum(); r++ ) {
- HSSFRow row = sheet.getRow( r );
+ for (int r = sheet.getFirstRowNum(); r <= sheet.getLastRowNum(); r++) {
+ HSSFRow row = sheet.getRow(r);
- if ( row == null )
+ if (row == null) {
continue;
+ }
- if ( !isOutputHiddenRows() && row.getZeroHeight() )
+ if (!isOutputHiddenRows() && row.getZeroHeight()) {
continue;
+ }
Element tableRowElement = htmlDocumentFacade.createTableRow();
- htmlDocumentFacade.addStyleClass( tableRowElement,
- cssClassPrefixRow, "height:" + ( row.getHeight() / 20f )
- + "pt;" );
+ htmlDocumentFacade.addStyleClass(tableRowElement,
+ cssClassPrefixRow, "height:" + (row.getHeight() / 20f)
+ + "pt;");
- int maxRowColumnNumber = processRow( mergedRanges, row,
- tableRowElement );
+ int maxRowColumnNumber = processRow(mergedRanges, row,
+ tableRowElement);
- if ( maxRowColumnNumber == 0 ) {
- emptyRowElements.add( tableRowElement );
+ if (maxRowColumnNumber == 0) {
+ emptyRowElements.add(tableRowElement);
} else {
- if ( !emptyRowElements.isEmpty() ) {
- for ( Element emptyRowElement : emptyRowElements ) {
- tableBody.appendChild( emptyRowElement );
+ if (!emptyRowElements.isEmpty()) {
+ for (Element emptyRowElement : emptyRowElements) {
+ tableBody.appendChild(emptyRowElement);
}
emptyRowElements.clear();
}
- tableBody.appendChild( tableRowElement );
+ tableBody.appendChild(tableRowElement);
}
- maxSheetColumns = Math.max( maxSheetColumns, maxRowColumnNumber );
+ maxSheetColumns = Math.max(maxSheetColumns, maxRowColumnNumber);
}
- processColumnWidths( sheet, maxSheetColumns, table );
+ processColumnWidths(sheet, maxSheetColumns, table);
- if ( isOutputColumnHeaders() ) {
- processColumnHeaders( sheet, maxSheetColumns, table );
+ if (isOutputColumnHeaders()) {
+ processColumnHeaders(sheet, maxSheetColumns, table);
}
- table.appendChild( tableBody );
+ table.appendChild(tableBody);
- htmlDocumentFacade.getBody().appendChild( table );
+ htmlDocumentFacade.getBody().appendChild(table);
}
- protected void processSheetHeader( Element htmlBody, HSSFSheet sheet ) {
+ protected void processSheetHeader(Element htmlBody, HSSFSheet sheet) {
Element h2 = htmlDocumentFacade.createHeader2();
- h2.appendChild( htmlDocumentFacade.createText( sheet.getSheetName() ) );
- htmlBody.appendChild( h2 );
+ h2.appendChild(htmlDocumentFacade.createText(sheet.getSheetName()));
+ htmlBody.appendChild(h2);
}
- public void processWorkbook( HSSFWorkbook workbook ) {
+ public void processWorkbook(HSSFWorkbook workbook) {
final SummaryInformation summaryInformation = workbook
- .getSummaryInformation();
- if ( summaryInformation != null ) {
- processDocumentInformation( summaryInformation );
+ .getSummaryInformation();
+ if (summaryInformation != null) {
+ processDocumentInformation(summaryInformation);
}
- if ( isUseDivsToSpan() ) {
+ if (isUseDivsToSpan()) {
// prepare CSS classes for later usage
this.cssClassContainerCell = htmlDocumentFacade
- .getOrCreateCssClass( cssClassPrefixCell,
- "padding:0;margin:0;align:left;vertical-align:top;" );
+ .getOrCreateCssClass(cssClassPrefixCell,
+ "padding:0;margin:0;align:left;vertical-align:top;");
this.cssClassContainerDiv = htmlDocumentFacade.getOrCreateCssClass(
- cssClassPrefixDiv, "position:relative;" );
+ cssClassPrefixDiv, "position:relative;");
}
- for ( int s = 0; s < workbook.getNumberOfSheets(); s++ ) {
- HSSFSheet sheet = workbook.getSheetAt( s );
- processSheet( sheet );
+ for (int s = 0; s < workbook.getNumberOfSheets(); s++) {
+ HSSFSheet sheet = workbook.getSheetAt(s);
+ processSheet(sheet);
}
htmlDocumentFacade.updateStylesheet();
}
- public void setCssClassPrefixCell( String cssClassPrefixCell )
- {
+ public void setCssClassPrefixCell(String cssClassPrefixCell) {
this.cssClassPrefixCell = cssClassPrefixCell;
}
- public void setCssClassPrefixDiv( String cssClassPrefixDiv )
- {
+ public void setCssClassPrefixDiv(String cssClassPrefixDiv) {
this.cssClassPrefixDiv = cssClassPrefixDiv;
}
- public void setCssClassPrefixRow( String cssClassPrefixRow )
- {
+ public void setCssClassPrefixRow(String cssClassPrefixRow) {
this.cssClassPrefixRow = cssClassPrefixRow;
}
- public void setCssClassPrefixTable( String cssClassPrefixTable )
- {
+ public void setCssClassPrefixTable(String cssClassPrefixTable) {
this.cssClassPrefixTable = cssClassPrefixTable;
}
@@ -713,8 +715,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
* with INDENT=YES option, because line breaks will make additional
* (unwanted) changes
*/
- public void setUseDivsToSpan( boolean useDivsToSpan )
- {
+ public void setUseDivsToSpan(boolean useDivsToSpan) {
this.useDivsToSpan = useDivsToSpan;
}
}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hssf/converter/ExcelToHtmlUtils.java b/poi-scratchpad/src/main/java/org/apache/poi/hssf/converter/ExcelToHtmlUtils.java
deleted file mode 100644
index 63e71d9b98..0000000000
--- a/poi-scratchpad/src/main/java/org/apache/poi/hssf/converter/ExcelToHtmlUtils.java
+++ /dev/null
@@ -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;
- }
-}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfBitmapDib.java b/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfBitmapDib.java
index 91597803e1..0a824df569 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfBitmapDib.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfBitmapDib.java
@@ -58,7 +58,7 @@ public class HwmfBitmapDib implements GenericRecord {
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]
* 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_BITFIELDS ||
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);
leis.readFully(imageData, 0, introSize);
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;
- /**
+ /*
* DIBHeaderInfo (variable): Either a BitmapCoreHeader Object or a
* BitmapInfoHeader Object that specifies information about the image.
*
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/extractor/WordExtractor.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/extractor/WordExtractor.java
index 1cd5d0d654..4e4d190536 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/extractor/WordExtractor.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/extractor/WordExtractor.java
@@ -205,7 +205,7 @@ public final class WordExtractor implements POIOLE2TextExtractor {
/**
* 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.
*/
public String getTextFromPieces() {
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/CharIndexTranslator.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/CharIndexTranslator.java
index 2ab1735cdd..da2e913b1c 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/CharIndexTranslator.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/CharIndexTranslator.java
@@ -23,7 +23,7 @@ import org.apache.poi.util.Internal;
public interface CharIndexTranslator {
/**
* Calculates the byte index of the given char index.
- *
+ *
* @param charPos
* The char position
* @return The byte index
@@ -32,7 +32,7 @@ public interface CharIndexTranslator {
/**
* Finds character ranges that includes specified byte range.
- *
+ *
* @param startBytePosInclusive
* start byte range
* @param endBytePosExclusive
@@ -43,14 +43,14 @@ public interface CharIndexTranslator {
/**
* Check if index is in table
- *
+ *
* @param bytePos
* @return true if index in table, false if not
*/
boolean isIndexInTable(int bytePos);
/**
- * Return first index >= bytePos that is in table
+ * Return first index &gt;= bytePos that is in table
*
* @param bytePos
* @return first index greater or equal to bytePos that is in table
@@ -58,7 +58,7 @@ public interface CharIndexTranslator {
int lookIndexForward(int bytePos);
/**
- * Return last index <= bytePos that is in table
+ * Return last index &lt;= bytePos that is in table
*
* @param bytePos
* @return last index less of equal to bytePos that is in table
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/ListTables.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/ListTables.java
index e163b2f005..3903b04a77 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/ListTables.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/ListTables.java
@@ -137,7 +137,7 @@ public final class ListTables
/**
* 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)
{
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PicturesTable.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PicturesTable.java
index e01f6ff0e1..d3ef0b51a9 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PicturesTable.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PicturesTable.java
@@ -17,6 +17,8 @@
package org.apache.poi.hwpf.model;
+import static org.apache.logging.log4j.util.Unbox.box;
+
import java.io.OutputStream;
import java.util.ArrayList;
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.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.
* 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
* 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
@@ -60,194 +60,171 @@ public final class PicturesTable {
private static final Logger LOG = LogManager.getLogger(PicturesTable.class);
static final int TYPE_IMAGE = 0x08;
- static final int TYPE_IMAGE_WORD2000 = 0x00;
- static final int TYPE_IMAGE_PASTED_FROM_CLIPBOARD = 0xA;
- static final int TYPE_IMAGE_PASTED_FROM_CLIPBOARD_WORD2000 = 0x2;
- static final int TYPE_HORIZONTAL_LINE = 0xE;
- static final int BLOCK_TYPE_OFFSET = 0xE;
- static final int MM_MODE_TYPE_OFFSET = 0x6;
-
- private HWPFDocument _document;
- private byte[] _dataStream;
- private byte[] _mainStream;
- @Deprecated
- private FSPATable _fspa;
- @Deprecated
- private OfficeArtContent _dgg;
-
- /** @link dependency
- * @stereotype instantiate*/
- /*# Picture lnkPicture; */
-
- /**
- *
- * @param _document
- * @param _dataStream
- */
- @Deprecated
- public PicturesTable(HWPFDocument _document, byte[] _dataStream, byte[] _mainStream, FSPATable fspa, OfficeArtContent dgg)
- {
- this._document = _document;
- this._dataStream = _dataStream;
- this._mainStream = _mainStream;
- this._fspa = fspa;
- this._dgg = dgg;
- }
-
- public PicturesTable( HWPFDocument _document, byte[] _dataStream,
- byte[] _mainStream )
- {
+ static final int TYPE_IMAGE_WORD2000 = 0x00;
+ static final int TYPE_IMAGE_PASTED_FROM_CLIPBOARD = 0xA;
+ static final int TYPE_IMAGE_PASTED_FROM_CLIPBOARD_WORD2000 = 0x2;
+ static final int TYPE_HORIZONTAL_LINE = 0xE;
+ static final int BLOCK_TYPE_OFFSET = 0xE;
+ static final int MM_MODE_TYPE_OFFSET = 0x6;
+
+ private final HWPFDocument _document;
+ private final byte[] _dataStream;
+ private final byte[] _mainStream;
+ @Deprecated
+ private FSPATable _fspa;
+ @Deprecated
+ private OfficeArtContent _dgg;
+
+ @Deprecated
+ public PicturesTable(HWPFDocument _document, byte[] _dataStream, byte[] _mainStream, FSPATable fspa, OfficeArtContent dgg) {
+ this._document = _document;
+ this._dataStream = _dataStream;
+ this._mainStream = _mainStream;
+ this._fspa = fspa;
+ this._dgg = dgg;
+ }
+
+ public PicturesTable(HWPFDocument _document, byte[] _dataStream,
+ byte[] _mainStream) {
this._document = _document;
this._dataStream = _dataStream;
this._mainStream = _mainStream;
}
- /**
- * determines whether specified CharacterRun contains reference to a picture
- * @param run
- */
- public boolean hasPicture(CharacterRun run) {
- if (run==null) {
+ /**
+ * determines whether specified CharacterRun contains reference to a picture
+ */
+ public boolean hasPicture(CharacterRun run) {
+ if (run == null) {
+ return false;
+ }
+
+ if (run.isSpecialCharacter() && !run.isObj() && !run.isOle2() && !run.isData()) {
+ // Image should be in it's own run, or in a run with the end-of-special marker
+ if ("\u0001".equals(run.text()) || "\u0001\u0015".equals(run.text())) {
+ return isBlockContainsImage(run.getPicOffset());
+ }
+ }
+ return false;
+ }
+
+ public boolean hasEscherPicture(CharacterRun run) {
+ return run.isSpecialCharacter() && !run.isObj() && !run.isOle2() && !run.isData() && run.text().startsWith("\u0008");
+ }
+
+ /**
+ * determines whether specified CharacterRun contains reference to a picture
+ */
+ public boolean hasHorizontalLine(CharacterRun run) {
+ if (run.isSpecialCharacter() && "\u0001".equals(run.text())) {
+ return isBlockContainsHorizontalLine(run.getPicOffset());
+ }
return false;
}
- if (run.isSpecialCharacter() && !run.isObj() && !run.isOle2() && !run.isData()) {
- // Image should be in it's own run, or in a run with the end-of-special marker
- if("\u0001".equals(run.text()) || "\u0001\u0015".equals(run.text())) {
- return isBlockContainsImage(run.getPicOffset());
- }
+ 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 false;
- }
- public boolean hasEscherPicture(CharacterRun run) {
- if (run.isSpecialCharacter() && !run.isObj() && !run.isOle2() && !run.isData() && run.text().startsWith("\u0008")) {
- return true;
+ private static short getBlockType(byte[] dataStream, int pictOffset) {
+ return LittleEndian.getShort(dataStream, pictOffset + BLOCK_TYPE_OFFSET);
}
- return false;
- }
-
- /**
- * determines whether specified CharacterRun contains reference to a picture
- * @param run
- */
- public boolean hasHorizontalLine(CharacterRun run) {
- if (run.isSpecialCharacter() && "\u0001".equals(run.text())) {
- return isBlockContainsHorizontalLine(run.getPicOffset());
+
+ private static short getMmMode(byte[] dataStream, int pictOffset) {
+ return LittleEndian.getShort(dataStream, pictOffset + MM_MODE_TYPE_OFFSET);
}
- return false;
- }
-
- 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));
- }
-
- private static short getBlockType(byte[] dataStream, int pictOffset) {
- return LittleEndian.getShort(dataStream, pictOffset + BLOCK_TYPE_OFFSET);
- }
-
- private static short getMmMode(byte[] dataStream, int pictOffset) {
- return LittleEndian.getShort(dataStream, pictOffset + MM_MODE_TYPE_OFFSET);
- }
-
- /**
- * 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
- * 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.
- * @see #hasPicture(CharacterRun)
- */
- public Picture extractPicture(CharacterRun run, boolean fillBytes) {
- if (hasPicture(run)) {
- return new Picture(run.getPicOffset(), _dataStream, fillBytes);
+
+ /**
+ * Returns picture object tied to specified CharacterRun
+ *
+ * @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
+ * @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)
+ */
+ public Picture extractPicture(CharacterRun run, boolean fillBytes) {
+ if (hasPicture(run)) {
+ return new Picture(run.getPicOffset(), _dataStream, fillBytes);
+ }
+ return null;
}
- return null;
- }
- /**
+ /**
* Performs a search for pictures in the given list of 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)
- {
- for(EscherRecord escherRecord : escherRecords) {
- if (escherRecord instanceof EscherBSERecord) {
- EscherBSERecord bse = (EscherBSERecord) escherRecord;
- EscherBlipRecord blip = bse.getBlipRecord();
- if (blip != null)
- {
- pictures.add(new Picture(blip));
- }
- else if ( bse.getOffset() > 0 )
- {
- try
- {
+ private void searchForPictures(List<EscherRecord> escherRecords, List<Picture> pictures) {
+ for (EscherRecord escherRecord : escherRecords) {
+ if (escherRecord instanceof EscherBSERecord) {
+ EscherBSERecord bse = (EscherBSERecord) escherRecord;
+ EscherBlipRecord blip = bse.getBlipRecord();
+ if (blip != null) {
+ pictures.add(new Picture(blip));
+ } else if (bse.getOffset() > 0) {
+ try {
// Blip stored in delay stream, which in a word doc, is
// the main stream
EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
EscherRecord record = recordFactory.createRecord(
- _mainStream, bse.getOffset() );
+ _mainStream, bse.getOffset());
- if ( record instanceof EscherBlipRecord )
- {
- record.fillFields( _mainStream, bse.getOffset(),
- recordFactory );
+ if (record instanceof EscherBlipRecord) {
+ record.fillFields(_mainStream, bse.getOffset(),
+ recordFactory);
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()));
}
}
- }
- }
+ }
+ }
}
- /**
- * Not all documents have all the images concatenated in the data stream
- * although MS claims so. The best approach is to scan all character runs.
- *
- * @return a list of Picture objects found in current document
- */
- public List<Picture> getAllPictures() {
- ArrayList<Picture> pictures = new ArrayList<>();
-
- Range range = _document.getOverallRange();
- for (int i = 0; i < range.numCharacterRuns(); i++) {
- CharacterRun run = range.getCharacterRun(i);
-
- if (run==null) {
- continue;
+ /**
+ * Not all documents have all the images concatenated in the data stream
+ * although MS claims so. The best approach is to scan all character runs.
+ *
+ * @return a list of Picture objects found in current document
+ */
+ public List<Picture> getAllPictures() {
+ ArrayList<Picture> pictures = new ArrayList<>();
+
+ Range range = _document.getOverallRange();
+ for (int i = 0; i < range.numCharacterRuns(); i++) {
+ CharacterRun run = range.getCharacterRun(i);
+
+ if (run == null) {
+ continue;
+ }
+
+ Picture picture = extractPicture(run, false);
+ if (picture != null) {
+ pictures.add(picture);
+ }
+ }
+
+ EscherContainerRecord bStore = _dgg.getBStoreContainer();
+ if (bStore != null) {
+ searchForPictures(bStore.getChildRecords(), pictures);
}
- Picture picture = extractPicture(run, false);
- if (picture != null) {
- pictures.add(picture);
- }
- }
-
- EscherContainerRecord bStore = _dgg.getBStoreContainer();
- if (bStore != null) {
- searchForPictures(bStore.getChildRecords(), pictures);
- }
-
- return pictures;
- }
-
- private boolean isBlockContainsImage(int i)
- {
- return isPictureRecognized(getBlockType(_dataStream, i), getMmMode(_dataStream, i));
- }
-
- private boolean isBlockContainsHorizontalLine(int i)
- {
- return getBlockType(_dataStream, i)==TYPE_HORIZONTAL_LINE && getMmMode(_dataStream, i)==0x64;
- }
+ return pictures;
+ }
+
+ private boolean isBlockContainsImage(int i) {
+ return isPictureRecognized(getBlockType(_dataStream, i), getMmMode(_dataStream, i));
+ }
+
+ private boolean isBlockContainsHorizontalLine(int i) {
+ return getBlockType(_dataStream, i) == TYPE_HORIZONTAL_LINE && getMmMode(_dataStream, i) == 0x64;
+ }
}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/FRDAbstractType.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/FRDAbstractType.java
index 1c75451897..9a0f5d4bf9 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/FRDAbstractType.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/FRDAbstractType.java
@@ -56,17 +56,13 @@ public abstract class FRDAbstractType {
public String toString()
{
- StringBuilder builder = new StringBuilder();
- builder.append( "[FRD]\n" );
- builder.append( " .nAuto = " );
- builder.append( " (" ).append( getNAuto() ).append( " )\n" );
-
- builder.append( "[/FRD]\n" );
- return builder.toString();
+ return "[FRD]\n" +
+ " .nAuto = (" + getNAuto() + " )\n" +
+ "[/FRD]\n";
}
/**
- * 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.
*/
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.
*/
public void setNAuto( short field_1_nAuto )
@@ -83,4 +79,4 @@ public abstract class FRDAbstractType {
this.field_1_nAuto = field_1_nAuto;
}
-} // END OF CLASS
+}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/GrfhicAbstractType.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/GrfhicAbstractType.java
index a6433f8597..ac54a45f20 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/GrfhicAbstractType.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/GrfhicAbstractType.java
@@ -81,7 +81,7 @@ public abstract class GrfhicAbstractType
*/
public static int getSize()
{
- return 0 + 1;
+ return 1;
}
@Override
@@ -94,9 +94,7 @@ public abstract class GrfhicAbstractType
if ( getClass() != obj.getClass() )
return false;
GrfhicAbstractType other = (GrfhicAbstractType) obj;
- if ( field_1_grfhic != other.field_1_grfhic )
- return false;
- return true;
+ return field_1_grfhic == other.field_1_grfhic;
}
@Override
@@ -106,22 +104,19 @@ public abstract class GrfhicAbstractType
public String toString()
{
- StringBuilder builder = new StringBuilder();
-
- builder.append("[Grfhic]\n");
- builder.append( " .grfhic = " );
- builder.append(" ( ").append( field_1_grfhic ).append( " )\n" );
- builder.append(" .fHtmlChecked = ").append(isFHtmlChecked()).append('\n');
- builder.append(" .fHtmlUnsupported = ").append(isFHtmlUnsupported()).append('\n');
- builder.append(" .fHtmlListTextNotSharpDot = ").append(isFHtmlListTextNotSharpDot()).append('\n');
- builder.append(" .fHtmlNotPeriod = ").append(isFHtmlNotPeriod()).append('\n');
- builder.append(" .fHtmlFirstLineMismatch = ").append(isFHtmlFirstLineMismatch()).append('\n');
- builder.append(" .fHtmlTabLeftIndentMismatch = ").append(isFHtmlTabLeftIndentMismatch()).append('\n');
- builder.append(" .fHtmlHangingIndentBeneathNumber = ").append(isFHtmlHangingIndentBeneathNumber()).append('\n');
- builder.append(" .fHtmlBuiltInBullet = ").append(isFHtmlBuiltInBullet()).append('\n');
-
- builder.append("[/Grfhic]");
- return builder.toString();
+ String builder = "[Grfhic]\n" +
+ " .grfhic = " +
+ " ( " + field_1_grfhic + " )\n" +
+ " .fHtmlChecked = " + isFHtmlChecked() + '\n' +
+ " .fHtmlUnsupported = " + isFHtmlUnsupported() + '\n' +
+ " .fHtmlListTextNotSharpDot = " + isFHtmlListTextNotSharpDot() + '\n' +
+ " .fHtmlNotPeriod = " + isFHtmlNotPeriod() + '\n' +
+ " .fHtmlFirstLineMismatch = " + isFHtmlFirstLineMismatch() + '\n' +
+ " .fHtmlTabLeftIndentMismatch = " + isFHtmlTabLeftIndentMismatch() + '\n' +
+ " .fHtmlHangingIndentBeneathNumber = " + isFHtmlHangingIndentBeneathNumber() + '\n' +
+ " .fHtmlBuiltInBullet = " + isFHtmlBuiltInBullet() + '\n' +
+ "[/Grfhic]";
+ return builder;
}
/**
@@ -164,7 +159,7 @@ public abstract class GrfhicAbstractType
/**
* 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
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.
*/
@Internal
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/PAPAbstractType.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/PAPAbstractType.java
index 220a6aff63..ce5499b3f7 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/PAPAbstractType.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/PAPAbstractType.java
@@ -247,174 +247,91 @@ public abstract class PAPAbstractType {
}
- public String toString()
- {
- StringBuilder builder = new StringBuilder();
- builder.append("[PAP]\n");
- builder.append(" .istd = ");
- builder.append(" (").append(getIstd()).append(" )\n");
- builder.append(" .fSideBySide = ");
- builder.append(" (").append(getFSideBySide()).append(" )\n");
- builder.append(" .fKeep = ");
- builder.append(" (").append(getFKeep()).append(" )\n");
- builder.append(" .fKeepFollow = ");
- builder.append(" (").append(getFKeepFollow()).append(" )\n");
- builder.append(" .fPageBreakBefore = ");
- builder.append(" (").append(getFPageBreakBefore()).append(" )\n");
- builder.append(" .brcl = ");
- builder.append(" (").append(getBrcl()).append(" )\n");
- builder.append(" .brcp = ");
- builder.append(" (").append(getBrcp()).append(" )\n");
- builder.append(" .ilvl = ");
- builder.append(" (").append(getIlvl()).append(" )\n");
- builder.append(" .ilfo = ");
- builder.append(" (").append(getIlfo()).append(" )\n");
- builder.append(" .fNoLnn = ");
- builder.append(" (").append(getFNoLnn()).append(" )\n");
- builder.append(" .lspd = ");
- builder.append(" (").append(getLspd()).append(" )\n");
- builder.append(" .dyaBefore = ");
- builder.append(" (").append(getDyaBefore()).append(" )\n");
- builder.append(" .dyaAfter = ");
- builder.append(" (").append(getDyaAfter()).append(" )\n");
- builder.append(" .fInTable = ");
- builder.append(" (").append(getFInTable()).append(" )\n");
- builder.append(" .finTableW97 = ");
- builder.append(" (").append(getFinTableW97()).append(" )\n");
- builder.append(" .fTtp = ");
- builder.append(" (").append(getFTtp()).append(" )\n");
- builder.append(" .dxaAbs = ");
- builder.append(" (").append(getDxaAbs()).append(" )\n");
- builder.append(" .dyaAbs = ");
- builder.append(" (").append(getDyaAbs()).append(" )\n");
- builder.append(" .dxaWidth = ");
- builder.append(" (").append(getDxaWidth()).append(" )\n");
- builder.append(" .fBrLnAbove = ");
- builder.append(" (").append(getFBrLnAbove()).append(" )\n");
- builder.append(" .fBrLnBelow = ");
- builder.append(" (").append(getFBrLnBelow()).append(" )\n");
- builder.append(" .pcVert = ");
- builder.append(" (").append(getPcVert()).append(" )\n");
- builder.append(" .pcHorz = ");
- builder.append(" (").append(getPcHorz()).append(" )\n");
- builder.append(" .wr = ");
- builder.append(" (").append(getWr()).append(" )\n");
- builder.append(" .fNoAutoHyph = ");
- builder.append(" (").append(getFNoAutoHyph()).append(" )\n");
- builder.append(" .dyaHeight = ");
- builder.append(" (").append(getDyaHeight()).append(" )\n");
- builder.append(" .fMinHeight = ");
- builder.append(" (").append(getFMinHeight()).append(" )\n");
- builder.append(" .dcs = ");
- builder.append(" (").append(getDcs()).append(" )\n");
- builder.append(" .dyaFromText = ");
- builder.append(" (").append(getDyaFromText()).append(" )\n");
- builder.append(" .dxaFromText = ");
- builder.append(" (").append(getDxaFromText()).append(" )\n");
- builder.append(" .fLocked = ");
- builder.append(" (").append(getFLocked()).append(" )\n");
- builder.append(" .fWidowControl = ");
- builder.append(" (").append(getFWidowControl()).append(" )\n");
- builder.append(" .fKinsoku = ");
- builder.append(" (").append(getFKinsoku()).append(" )\n");
- builder.append(" .fWordWrap = ");
- builder.append(" (").append(getFWordWrap()).append(" )\n");
- builder.append(" .fOverflowPunct = ");
- builder.append(" (").append(getFOverflowPunct()).append(" )\n");
- builder.append(" .fTopLinePunct = ");
- builder.append(" (").append(getFTopLinePunct()).append(" )\n");
- builder.append(" .fAutoSpaceDE = ");
- builder.append(" (").append(getFAutoSpaceDE()).append(" )\n");
- builder.append(" .fAutoSpaceDN = ");
- builder.append(" (").append(getFAutoSpaceDN()).append(" )\n");
- builder.append(" .wAlignFont = ");
- builder.append(" (").append(getWAlignFont()).append(" )\n");
- builder.append(" .fontAlign = ");
- builder.append(" (").append(getFontAlign()).append(" )\n");
- builder.append(" .fVertical = ").append(isFVertical()).append('\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();
+ public String toString() {
+ return "[PAP]\n" +
+ " .istd = (" + getIstd() + " )\n" +
+ " .fSideBySide = (" + getFSideBySide() + " )\n" +
+ " .fKeep = (" + getFKeep() + " )\n" +
+ " .fKeepFollow = (" + getFKeepFollow() + " )\n" +
+ " .fPageBreakBefore = (" + getFPageBreakBefore() + " )\n" +
+ " .brcl = (" + getBrcl() + " )\n" +
+ " .brcp = (" + getBrcp() + " )\n" +
+ " .ilvl = (" + getIlvl() + " )\n" +
+ " .ilfo = (" + getIlfo() + " )\n" +
+ " .fNoLnn = (" + getFNoLnn() + " )\n" +
+ " .lspd = (" + getLspd() + " )\n" +
+ " .dyaBefore = (" + getDyaBefore() + " )\n" +
+ " .dyaAfter = (" + getDyaAfter() + " )\n" +
+ " .fInTable = (" + getFInTable() + " )\n" +
+ " .finTableW97 = (" + getFinTableW97() + " )\n" +
+ " .fTtp = (" + getFTtp() + " )\n" +
+ " .dxaAbs = (" + getDxaAbs() + " )\n" +
+ " .dyaAbs = (" + getDyaAbs() + " )\n" +
+ " .dxaWidth = (" + getDxaWidth() + " )\n" +
+ " .fBrLnAbove = (" + getFBrLnAbove() + " )\n" +
+ " .fBrLnBelow = (" + getFBrLnBelow() + " )\n" +
+ " .pcVert = (" + getPcVert() + " )\n" +
+ " .pcHorz = (" + getPcHorz() + " )\n" +
+ " .wr = (" + getWr() + " )\n" +
+ " .fNoAutoHyph = (" + getFNoAutoHyph() + " )\n" +
+ " .dyaHeight = (" + getDyaHeight() + " )\n" +
+ " .fMinHeight = (" + getFMinHeight() + " )\n" +
+ " .dcs = (" + getDcs() + " )\n" +
+ " .dyaFromText = (" + getDyaFromText() + " )\n" +
+ " .dxaFromText = (" + getDxaFromText() + " )\n" +
+ " .fLocked = (" + getFLocked() + " )\n" +
+ " .fWidowControl = (" + getFWidowControl() + " )\n" +
+ " .fKinsoku = (" + getFKinsoku() + " )\n" +
+ " .fWordWrap = (" + getFWordWrap() + " )\n" +
+ " .fOverflowPunct = (" + getFOverflowPunct() + " )\n" +
+ " .fTopLinePunct = (" + getFTopLinePunct() + " )\n" +
+ " .fAutoSpaceDE = (" + getFAutoSpaceDE() + " )\n" +
+ " .fAutoSpaceDN = (" + getFAutoSpaceDN() + " )\n" +
+ " .wAlignFont = (" + getWAlignFont() + " )\n" +
+ " .fontAlign = (" + getFontAlign() + " )\n" +
+ " .fVertical = " + isFVertical() + '\n' +
+ " .fBackward = " + isFBackward() + '\n' +
+ " .fRotateFont = " + isFRotateFont() + '\n' +
+ " .lvl = (" + getLvl() + " )\n" +
+ " .fBiDi = (" + getFBiDi() + " )\n" +
+ " .fNumRMIns = (" + getFNumRMIns() + " )\n" +
+ " .fCrLf = (" + getFCrLf() + " )\n" +
+ " .fUsePgsuSettings = (" + getFUsePgsuSettings() + " )\n" +
+ " .fAdjustRight = (" + getFAdjustRight() + " )\n" +
+ " .itap = (" + getItap() + " )\n" +
+ " .fInnerTableCell = (" + getFInnerTableCell() + " )\n" +
+ " .fOpenTch = (" + getFOpenTch() + " )\n" +
+ " .fTtpEmbedded = (" + getFTtpEmbedded() + " )\n" +
+ " .dxcRight = (" + getDxcRight() + " )\n" +
+ " .dxcLeft = (" + getDxcLeft() + " )\n" +
+ " .dxcLeft1 = (" + getDxcLeft1() + " )\n" +
+ " .fDyaBeforeAuto = (" + getFDyaBeforeAuto() + " )\n" +
+ " .fDyaAfterAuto = (" + getFDyaAfterAuto() + " )\n" +
+ " .dxaRight = (" + getDxaRight() + " )\n" +
+ " .dxaLeft = (" + getDxaLeft() + " )\n" +
+ " .dxaLeft1 = (" + getDxaLeft1() + " )\n" +
+ " .jc = (" + getJc() + " )\n" +
+ " .brcTop = (" + getBrcTop() + " )\n" +
+ " .brcLeft = (" + getBrcLeft() + " )\n" +
+ " .brcBottom = (" + getBrcBottom() + " )\n" +
+ " .brcRight = (" + getBrcRight() + " )\n" +
+ " .brcBetween = (" + getBrcBetween() + " )\n" +
+ " .brcBar = (" + getBrcBar() + " )\n" +
+ " .shd = (" + getShd() + " )\n" +
+ " .anld = (" + Arrays.toString(getAnld()) + " )\n" +
+ " .phe = (" + Arrays.toString(getPhe()) + " )\n" +
+ " .fPropRMark = (" + getFPropRMark() + " )\n" +
+ " .ibstPropRMark = (" + getIbstPropRMark() + " )\n" +
+ " .dttmPropRMark = (" + getDttmPropRMark() + " )\n" +
+ " .itbdMac = (" + getItbdMac() + " )\n" +
+ " .rgdxaTab = (" + Arrays.toString(getRgdxaTab()) + " )\n" +
+ " .rgtbd = (" + Arrays.toString(getRgtbd()) + " )\n" +
+ " .numrm = (" + Arrays.toString(getNumrm()) + " )\n" +
+ " .ptap = (" + Arrays.toString(getPtap()) + " )\n" +
+ " .fNoAllowOverlap = (" + getFNoAllowOverlap() + " )\n" +
+ " .ipgp = (" + getIpgp() + " )\n" +
+ " .rsid = (" + getRsid() + " )\n" +
+ "[/PAP]\n";
}
/**
@@ -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
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
public void setItbdMac( int field_72_itbdMac )
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/TAPAbstractType.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/TAPAbstractType.java
index ffed2cbcc1..ff3729c9e2 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/TAPAbstractType.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/TAPAbstractType.java
@@ -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
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
public void setItcMac( short field_26_itcMac )
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/Paragraph.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/Paragraph.java
index e5d1395f75..0447624336 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/Paragraph.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/Paragraph.java
@@ -547,11 +547,9 @@ public class Paragraph extends Range implements Duplicatable {
}
/**
- * Returns number of tabs stops defined for paragraph. Must be >= 0 and <=
- * 64.
+ * Returns number of tabs stops defined for paragraph. Must be &gt;= 0 and &lt;= 64.
*
- * @return number of tabs stops defined for paragraph. Must be >= 0 and <=
- * 64
+ * @return number of tabs stops defined for paragraph. Must be &gt;= 0 and &lt;= 64
*/
public int getTabStopsNumber()
{
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hssf/converter/TestExcelConverterSuite.java b/poi-scratchpad/src/test/java/org/apache/poi/hssf/converter/TestExcelConverterSuite.java
index 67ccae0cb4..927d54e88e 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hssf/converter/TestExcelConverterSuite.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hssf/converter/TestExcelConverterSuite.java
@@ -65,7 +65,7 @@ public class TestExcelConverterSuite
{
HSSFWorkbook workbook;
try {
- workbook = ExcelToHtmlUtils.loadXls( child );
+ workbook = AbstractExcelUtils.loadXls( child );
} catch ( Exception exc ) {
// unable to parse file -- not ExcelToFoConverter fault
return;
@@ -91,7 +91,7 @@ public class TestExcelConverterSuite
{
HSSFWorkbook workbook;
try {
- workbook = ExcelToHtmlUtils.loadXls( child );
+ workbook = AbstractExcelUtils.loadXls( child );
} catch ( Exception exc ) {
// unable to parse file -- not ExcelToFoConverter fault
return;