Sonar Fixes - "static" base class members should not be accessed via derived types

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1876067 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2020-04-02 23:54:48 +00:00
parent 3f7d718a67
commit 1dc771394b
60 changed files with 406 additions and 384 deletions

View File

@ -233,7 +233,7 @@ public class VariantSupport extends Variant {
* *
* August 20, 2009 * August 20, 2009
*/ */
// l1 = LittleEndian.getInt(src, o1); o1 += LittleEndian.INT_SIZE; // l1 = LittleEndian.getInt(src, o1); o1 += LittleEndianConts.INT_SIZE;
// } // }
// final byte[] v = new byte[l1]; // final byte[] v = new byte[l1];
// System.arraycopy(src, o1, v, 0, v.length); // System.arraycopy(src, o1, v, 0, v.length);

View File

@ -36,24 +36,62 @@ import org.apache.poi.hssf.record.EscherAggregate;
import org.apache.poi.hssf.record.ObjRecord; import org.apache.poi.hssf.record.ObjRecord;
import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType; import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType;
import org.apache.poi.ss.usermodel.Picture; import org.apache.poi.ss.usermodel.Picture;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.ImageUtils; import org.apache.poi.ss.util.ImageUtils;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.Removal;
import org.apache.poi.util.POILogger;
import org.apache.poi.util.StringUtil; import org.apache.poi.util.StringUtil;
/** /**
* Represents a escher picture. Eg. A GIF, JPEG etc... * Represents a escher picture. Eg. A GIF, JPEG etc...
*/ */
public class HSSFPicture extends HSSFSimpleShape implements Picture { public class HSSFPicture extends HSSFSimpleShape implements Picture {
@SuppressWarnings("unused") /**
private static POILogger logger = POILogFactory.getLogger(HSSFPicture.class); * Windows Enhanced Metafile
* @deprecated use {@link Workbook#PICTURE_TYPE_EMF}
*/
@Removal(version = "5.0.0")
@Deprecated
public static final int PICTURE_TYPE_EMF = Workbook.PICTURE_TYPE_EMF;
public static final int PICTURE_TYPE_EMF = HSSFWorkbook.PICTURE_TYPE_EMF; // Windows Enhanced Metafile /**
public static final int PICTURE_TYPE_WMF = HSSFWorkbook.PICTURE_TYPE_WMF; // Windows Metafile * Windows Metafile
public static final int PICTURE_TYPE_PICT = HSSFWorkbook.PICTURE_TYPE_PICT; // Macintosh PICT * @deprecated use {@link Workbook#PICTURE_TYPE_WMF}
public static final int PICTURE_TYPE_JPEG = HSSFWorkbook.PICTURE_TYPE_JPEG; // JFIF */
public static final int PICTURE_TYPE_PNG = HSSFWorkbook.PICTURE_TYPE_PNG; // PNG @Removal(version = "5.0.0")
public static final int PICTURE_TYPE_DIB = HSSFWorkbook.PICTURE_TYPE_DIB; // Windows DIB @Deprecated
public static final int PICTURE_TYPE_WMF = Workbook.PICTURE_TYPE_WMF;
/**
* Macintosh PICT
* @deprecated use {@link Workbook#PICTURE_TYPE_PICT}
*/
@Removal(version = "5.0.0")
@Deprecated
public static final int PICTURE_TYPE_PICT = Workbook.PICTURE_TYPE_PICT;
/**
* JFIF / JPEG
* @deprecated use {@link Workbook#PICTURE_TYPE_JPEG}
*/
@Removal(version = "5.0.0")
@Deprecated
public static final int PICTURE_TYPE_JPEG = Workbook.PICTURE_TYPE_JPEG;
/**
* PNG
* @deprecated use {@link Workbook#PICTURE_TYPE_PNG}
*/
@Removal(version = "5.0.0")
@Deprecated
public static final int PICTURE_TYPE_PNG = Workbook.PICTURE_TYPE_PNG;
/**
* Windows DIB
* @deprecated use {@link Workbook#PICTURE_TYPE_DIB}
*/
@Removal(version = "5.0.0")
@Deprecated
public static final int PICTURE_TYPE_DIB = Workbook.PICTURE_TYPE_DIB;
public HSSFPicture(EscherContainerRecord spContainer, ObjRecord objRecord) { public HSSFPicture(EscherContainerRecord spContainer, ObjRecord objRecord) {
super(spContainer, objRecord); super(spContainer, objRecord);
@ -88,6 +126,7 @@ public class HSSFPicture extends HSSFSimpleShape implements Picture {
protected EscherContainerRecord createSpContainer() { protected EscherContainerRecord createSpContainer() {
EscherContainerRecord spContainer = super.createSpContainer(); EscherContainerRecord spContainer = super.createSpContainer();
EscherOptRecord opt = spContainer.getChildById(EscherOptRecord.RECORD_ID); EscherOptRecord opt = spContainer.getChildById(EscherOptRecord.RECORD_ID);
assert(opt != null);
opt.removeEscherProperty(EscherPropertyTypes.LINESTYLE__LINEDASHING); opt.removeEscherProperty(EscherPropertyTypes.LINESTYLE__LINEDASHING);
opt.removeEscherProperty(EscherPropertyTypes.LINESTYLE__NOLINEDRAWDASH); opt.removeEscherProperty(EscherPropertyTypes.LINESTYLE__NOLINEDRAWDASH);
spContainer.removeChildRecord(spContainer.getChildById(EscherTextboxRecord.RECORD_ID)); spContainer.removeChildRecord(spContainer.getChildById(EscherTextboxRecord.RECORD_ID));

View File

@ -26,6 +26,7 @@ import java.util.List;
import org.apache.poi.poifs.common.POIFSBigBlockSize; import org.apache.poi.poifs.common.POIFSBigBlockSize;
import org.apache.poi.poifs.common.POIFSConstants; import org.apache.poi.poifs.common.POIFSConstants;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
/** /**
* A block of block allocation table entries. BATBlocks are created * A block of block allocation table entries. BATBlocks are created
@ -91,7 +92,7 @@ public final class BATBlock implements BlockWritable {
BATBlock block = new BATBlock(bigBlockSize); BATBlock block = new BATBlock(bigBlockSize);
// Fill it // Fill it
byte[] buffer = new byte[LittleEndian.INT_SIZE]; byte[] buffer = new byte[LittleEndianConsts.INT_SIZE];
for(int i=0; i<block._values.length; i++) { for(int i=0; i<block._values.length; i++) {
data.get(buffer); data.get(buffer);
block._values[i] = LittleEndian.getInt(buffer); block._values[i] = LittleEndian.getInt(buffer);
@ -255,7 +256,7 @@ public final class BATBlock implements BlockWritable {
int offset = 0; int offset = 0;
for (int _value : _values) { for (int _value : _values) {
LittleEndian.putInt(data, offset, _value); LittleEndian.putInt(data, offset, _value);
offset += LittleEndian.INT_SIZE; offset += LittleEndianConsts.INT_SIZE;
} }
// Done // Done

View File

@ -24,6 +24,7 @@ import java.io.OutputStream;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
import org.apache.poi.util.Units; import org.apache.poi.util.Units;
@ -77,7 +78,7 @@ public class ImageHeaderWMF {
public ImageHeaderWMF(byte[] data, final int off) { public ImageHeaderWMF(byte[] data, final int off) {
int offset = off; int offset = off;
int key = LittleEndian.getInt(data, offset); offset += LittleEndian.INT_SIZE; //header key int key = LittleEndian.getInt(data, offset); offset += LittleEndianConsts.INT_SIZE; //header key
if (key != APMHEADER_KEY) { if (key != APMHEADER_KEY) {
LOG.log(POILogger.WARN, "WMF file doesn't contain a placeable header - ignore parsing"); LOG.log(POILogger.WARN, "WMF file doesn't contain a placeable header - ignore parsing");
handle = 0; handle = 0;
@ -90,16 +91,16 @@ public class ImageHeaderWMF {
return; return;
} }
handle = LittleEndian.getUShort(data, offset); offset += LittleEndian.SHORT_SIZE; handle = LittleEndian.getUShort(data, offset); offset += LittleEndianConsts.SHORT_SIZE;
left = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE; left = LittleEndian.getShort(data, offset); offset += LittleEndianConsts.SHORT_SIZE;
top = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE; top = LittleEndian.getShort(data, offset); offset += LittleEndianConsts.SHORT_SIZE;
right = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE; right = LittleEndian.getShort(data, offset); offset += LittleEndianConsts.SHORT_SIZE;
bottom = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE; bottom = LittleEndian.getShort(data, offset); offset += LittleEndianConsts.SHORT_SIZE;
inch = LittleEndian.getUShort(data, offset); offset += LittleEndian.SHORT_SIZE; inch = LittleEndian.getUShort(data, offset); offset += LittleEndianConsts.SHORT_SIZE;
reserved = LittleEndian.getInt(data, offset); offset += LittleEndian.INT_SIZE; reserved = LittleEndian.getInt(data, offset); offset += LittleEndianConsts.INT_SIZE;
checksum = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE; checksum = LittleEndian.getShort(data, offset); offset += LittleEndianConsts.SHORT_SIZE;
if (checksum != getChecksum()){ if (checksum != getChecksum()){
LOG.log(POILogger.WARN, "WMF checksum does not match the header data"); LOG.log(POILogger.WARN, "WMF checksum does not match the header data");
} }
@ -124,14 +125,14 @@ public class ImageHeaderWMF {
public void write(OutputStream out) throws IOException { public void write(OutputStream out) throws IOException {
byte[] header = new byte[22]; byte[] header = new byte[22];
int pos = 0; int pos = 0;
LittleEndian.putInt(header, pos, APMHEADER_KEY); pos += LittleEndian.INT_SIZE; //header key LittleEndian.putInt(header, pos, APMHEADER_KEY); pos += LittleEndianConsts.INT_SIZE; //header key
LittleEndian.putUShort(header, pos, 0); pos += LittleEndian.SHORT_SIZE; //hmf LittleEndian.putUShort(header, pos, 0); pos += LittleEndianConsts.SHORT_SIZE; //hmf
LittleEndian.putUShort(header, pos, left); pos += LittleEndian.SHORT_SIZE; //left LittleEndian.putUShort(header, pos, left); pos += LittleEndianConsts.SHORT_SIZE; //left
LittleEndian.putUShort(header, pos, top); pos += LittleEndian.SHORT_SIZE; //top LittleEndian.putUShort(header, pos, top); pos += LittleEndianConsts.SHORT_SIZE; //top
LittleEndian.putUShort(header, pos, right); pos += LittleEndian.SHORT_SIZE; //right LittleEndian.putUShort(header, pos, right); pos += LittleEndianConsts.SHORT_SIZE; //right
LittleEndian.putUShort(header, pos, bottom); pos += LittleEndian.SHORT_SIZE; //bottom LittleEndian.putUShort(header, pos, bottom); pos += LittleEndianConsts.SHORT_SIZE; //bottom
LittleEndian.putUShort(header, pos, inch); pos += LittleEndian.SHORT_SIZE; //inch LittleEndian.putUShort(header, pos, inch); pos += LittleEndianConsts.SHORT_SIZE; //inch
LittleEndian.putInt(header, pos, 0); pos += LittleEndian.INT_SIZE; //reserved LittleEndian.putInt(header, pos, 0); pos += LittleEndianConsts.INT_SIZE; //reserved
checksum = getChecksum(); checksum = getChecksum();
LittleEndian.putUShort(header, pos, checksum); LittleEndian.putUShort(header, pos, checksum);

View File

@ -19,6 +19,7 @@ package org.apache.poi.ss.format;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols; import java.text.DecimalFormatSymbols;
import java.text.FieldPosition; import java.text.FieldPosition;
import java.text.NumberFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Formatter; import java.util.Formatter;
@ -558,7 +559,7 @@ public class CellNumberFormatter extends CellFormatter {
private void writeScientific(double value, StringBuffer output, Set<CellNumberStringMod> mods) { private void writeScientific(double value, StringBuffer output, Set<CellNumberStringMod> mods) {
StringBuffer result = new StringBuffer(); StringBuffer result = new StringBuffer();
FieldPosition fractionPos = new FieldPosition(DecimalFormat.FRACTION_FIELD); FieldPosition fractionPos = new FieldPosition(NumberFormat.FRACTION_FIELD);
decimalFmt.format(value, result, fractionPos); decimalFmt.format(value, result, fractionPos);
writeInteger(result, output, integerSpecials, mods, showGroupingSeparator); writeInteger(result, output, integerSpecials, mods, showGroupingSeparator);
writeFractional(result, output); writeFractional(result, output);

View File

@ -19,7 +19,7 @@ package org.apache.poi.ss.formula.ptg;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.LittleEndianInput; import org.apache.poi.util.LittleEndianInput;
import org.apache.poi.util.LittleEndianOutput; import org.apache.poi.util.LittleEndianOutput;
@ -208,7 +208,7 @@ public final class AttrPtg extends ControlPtg {
public int getSize() { public int getSize() {
if (_jumpTable != null) { if (_jumpTable != null) {
return SIZE + (_jumpTable.length + 1) * LittleEndian.SHORT_SIZE; return SIZE + (_jumpTable.length + 1) * LittleEndianConsts.SHORT_SIZE;
} }
return SIZE; return SIZE;
} }

View File

@ -40,6 +40,7 @@ import java.util.stream.Collectors;
import javax.xml.crypto.URIDereferencer; import javax.xml.crypto.URIDereferencer;
import javax.xml.crypto.dsig.CanonicalizationMethod; import javax.xml.crypto.dsig.CanonicalizationMethod;
import javax.xml.crypto.dsig.DigestMethod; import javax.xml.crypto.dsig.DigestMethod;
import javax.xml.crypto.dsig.Transform;
import javax.xml.crypto.dsig.XMLSignatureFactory; import javax.xml.crypto.dsig.XMLSignatureFactory;
import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory; import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory;
@ -405,9 +406,9 @@ public class SignatureConfig {
} }
switch (canonicalizationMethod) { switch (canonicalizationMethod) {
case Transform.ENVELOPED:
case CanonicalizationMethod.INCLUSIVE: case CanonicalizationMethod.INCLUSIVE:
case CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS: case CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS:
case CanonicalizationMethod.ENVELOPED:
case CanonicalizationMethod.EXCLUSIVE: case CanonicalizationMethod.EXCLUSIVE:
case CanonicalizationMethod.EXCLUSIVE_WITH_COMMENTS: case CanonicalizationMethod.EXCLUSIVE_WITH_COMMENTS:
return canonicalizationMethod; return canonicalizationMethod;

View File

@ -53,7 +53,7 @@ public class EnvelopedSignatureFacet implements SignatureFacet {
, List<XMLObject> objects) , List<XMLObject> objects)
throws XMLSignatureException { throws XMLSignatureException {
List<Transform> transforms = new ArrayList<>(); List<Transform> transforms = new ArrayList<>();
Transform envelopedTransform = newTransform(signatureInfo, CanonicalizationMethod.ENVELOPED); Transform envelopedTransform = newTransform(signatureInfo, Transform.ENVELOPED);
transforms.add(envelopedTransform); transforms.add(envelopedTransform);
Transform exclusiveTransform = newTransform(signatureInfo, CanonicalizationMethod.EXCLUSIVE); Transform exclusiveTransform = newTransform(signatureInfo, CanonicalizationMethod.EXCLUSIVE);
transforms.add(exclusiveTransform); transforms.add(exclusiveTransform);

View File

@ -17,6 +17,7 @@
package org.apache.poi.xdgf.geom; package org.apache.poi.xdgf.geom;
import com.graphbuilder.curve.BSpline;
import com.graphbuilder.curve.ControlPath; import com.graphbuilder.curve.ControlPath;
import com.graphbuilder.curve.GroupIterator; import com.graphbuilder.curve.GroupIterator;
import com.graphbuilder.curve.NURBSpline; import com.graphbuilder.curve.NURBSpline;
@ -49,7 +50,7 @@ public class SplineRenderer {
NURBSpline spline = new NURBSpline(controlPoints, gi); NURBSpline spline = new NURBSpline(controlPoints, gi);
spline.setDegree(degree); spline.setDegree(degree);
spline.setKnotVectorType(NURBSpline.NON_UNIFORM); spline.setKnotVectorType(BSpline.NON_UNIFORM);
spline.setKnotVector(knots); spline.setKnotVector(knots);
if (weights == null) { if (weights == null) {

View File

@ -19,6 +19,7 @@ package org.apache.poi.xssf.binary;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
/** /**
* This class encapsulates what the spec calls a "Cell" object. * This class encapsulates what the spec calls a "Cell" object.
@ -39,7 +40,7 @@ class XSSFBCellHeader {
* @param cell cell buffer to update * @param cell cell buffer to update
*/ */
public static void parse(byte[] data, int offset, int currentRow, XSSFBCellHeader cell) { public static void parse(byte[] data, int offset, int currentRow, XSSFBCellHeader cell) {
int colNum = XSSFBUtils.castToInt(LittleEndian.getUInt(data, offset)); offset += LittleEndian.INT_SIZE; int colNum = XSSFBUtils.castToInt(LittleEndian.getUInt(data, offset)); offset += LittleEndianConsts.INT_SIZE;
int styleIdx = XSSFBUtils.get24BitInt(data, offset); offset += 3; int styleIdx = XSSFBUtils.get24BitInt(data, offset); offset += 3;
//TODO: range checking //TODO: range checking
boolean showPhonetic = false;//TODO: fill this out boolean showPhonetic = false;//TODO: fill this out

View File

@ -20,6 +20,7 @@ package org.apache.poi.xssf.binary;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
/** /**
* @since 3.16-beta3 * @since 3.16-beta3
@ -28,7 +29,7 @@ import org.apache.poi.util.LittleEndian;
class XSSFBCellRange { class XSSFBCellRange {
//TODO: Convert this to generate an AreaReference //TODO: Convert this to generate an AreaReference
public static final int length = 4* LittleEndian.INT_SIZE; public static final int length = 4* LittleEndianConsts.INT_SIZE;
/** /**
* Parses an RfX cell range from the data starting at the offset. * Parses an RfX cell range from the data starting at the offset.
* This performs no range checking. * This performs no range checking.
@ -41,9 +42,9 @@ class XSSFBCellRange {
if (cellRange == null) { if (cellRange == null) {
cellRange = new XSSFBCellRange(); cellRange = new XSSFBCellRange();
} }
cellRange.firstRow = XSSFBUtils.castToInt(LittleEndian.getUInt(data, offset)); offset += LittleEndian.INT_SIZE; cellRange.firstRow = XSSFBUtils.castToInt(LittleEndian.getUInt(data, offset)); offset += LittleEndianConsts.INT_SIZE;
cellRange.lastRow = XSSFBUtils.castToInt(LittleEndian.getUInt(data, offset)); offset += LittleEndian.INT_SIZE; cellRange.lastRow = XSSFBUtils.castToInt(LittleEndian.getUInt(data, offset)); offset += LittleEndianConsts.INT_SIZE;
cellRange.firstCol = XSSFBUtils.castToInt(LittleEndian.getUInt(data, offset)); offset += LittleEndian.INT_SIZE; cellRange.firstCol = XSSFBUtils.castToInt(LittleEndian.getUInt(data, offset)); offset += LittleEndianConsts.INT_SIZE;
cellRange.lastCol = XSSFBUtils.castToInt(LittleEndian.getUInt(data, offset)); cellRange.lastCol = XSSFBUtils.castToInt(LittleEndian.getUInt(data, offset));
return cellRange; return cellRange;

View File

@ -29,6 +29,7 @@ import java.util.TreeMap;
import org.apache.poi.ss.util.CellAddress; import org.apache.poi.ss.util.CellAddress;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
/** /**
* @since 3.16-beta3 * @since 3.16-beta3
@ -60,7 +61,7 @@ public class XSSFBCommentsTable extends XSSFBParser {
switch (recordType) { switch (recordType) {
case BrtBeginComment: case BrtBeginComment:
int offset = 0; int offset = 0;
authorId = XSSFBUtils.castToInt(LittleEndian.getUInt(data)); offset += LittleEndian.INT_SIZE; authorId = XSSFBUtils.castToInt(LittleEndian.getUInt(data)); offset += LittleEndianConsts.INT_SIZE;
cellRange = XSSFBCellRange.parse(data, offset, cellRange); cellRange = XSSFBCellRange.parse(data, offset, cellRange);
offset+= XSSFBCellRange.length; offset+= XSSFBCellRange.length;
//for strict parsing; confirm that firstRow==lastRow and firstCol==colLats (2.4.28) //for strict parsing; confirm that firstRow==lastRow and firstCol==colLats (2.4.28)

View File

@ -36,8 +36,8 @@ import org.apache.poi.openxml4j.opc.PackagePartName;
import org.apache.poi.openxml4j.opc.PackageRelationship; import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.openxml4j.opc.PackageRelationshipCollection; import org.apache.poi.openxml4j.opc.PackageRelationshipCollection;
import org.apache.poi.openxml4j.opc.PackagingURIHelper; import org.apache.poi.openxml4j.opc.PackagingURIHelper;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
import org.apache.poi.xssf.binary.XSSFBCommentsTable; import org.apache.poi.xssf.binary.XSSFBCommentsTable;
@ -236,9 +236,9 @@ public class XSSFBReader extends XSSFReader {
int offset = 0; int offset = 0;
//this is the sheet state #2.5.142 //this is the sheet state #2.5.142
/*long hsShtat =*/ //noinspection ResultOfMethodCallIgnored /*long hsShtat =*/ //noinspection ResultOfMethodCallIgnored
LittleEndian.getUInt(data, offset); offset += LittleEndian.INT_SIZE; LittleEndian.getUInt(data, offset); offset += LittleEndianConsts.INT_SIZE;
long iTabID = LittleEndian.getUInt(data, offset); offset += LittleEndian.INT_SIZE; long iTabID = LittleEndian.getUInt(data, offset); offset += LittleEndianConsts.INT_SIZE;
//according to #2.4.304 //according to #2.4.304
if (iTabID < 1 || iTabID > 0x0000FFFFL) { if (iTabID < 1 || iTabID > 0x0000FFFFL) {
throw new XSSFBParseException("table id out of range: "+iTabID); throw new XSSFBParseException("table id out of range: "+iTabID);
@ -257,7 +257,7 @@ public class XSSFBReader extends XSSFReader {
//undocumented what is contained in these 8 bytes. //undocumented what is contained in these 8 bytes.
//for the non-beta xlsb files, this would be 4, not 8. //for the non-beta xlsb files, this would be 4, not 8.
int offset = 8; int offset = 8;
long iTabID = LittleEndian.getUInt(data, offset); offset += LittleEndian.INT_SIZE; long iTabID = LittleEndian.getUInt(data, offset); offset += LittleEndianConsts.INT_SIZE;
if (iTabID < 1 || iTabID > 0x0000FFFFL) { if (iTabID < 1 || iTabID > 0x0000FFFFL) {
throw new XSSFBParseException("table id out of range: "+iTabID); throw new XSSFBParseException("table id out of range: "+iTabID);
} }

View File

@ -17,10 +17,10 @@
package org.apache.poi.hdgf.chunks; package org.apache.poi.hdgf.chunks;
import org.apache.poi.util.LittleEndian;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import org.apache.poi.util.LittleEndian;
/** /**
* A chunk header * A chunk header
*/ */
@ -79,13 +79,7 @@ public abstract class ChunkHeader {
* @return the header size * @return the header size
*/ */
public static int getHeaderSize(int documentVersion) { public static int getHeaderSize(int documentVersion) {
if(documentVersion > 6) { return documentVersion >= 6 ? ChunkHeaderV6.getHeaderSize() : ChunkHeaderV4V5.getHeaderSize();
return ChunkHeaderV11.getHeaderSize();
} else if(documentVersion == 6) {
return ChunkHeaderV6.getHeaderSize();
} else {
return ChunkHeaderV4V5.getHeaderSize();
}
} }
public abstract int getSizeInBytes(); public abstract int getSizeInBytes();

View File

@ -49,7 +49,6 @@ import org.apache.poi.hwmf.record.HwmfTernaryRasterOp;
import org.apache.poi.util.GenericRecordJsonWriter; import org.apache.poi.util.GenericRecordJsonWriter;
import org.apache.poi.util.GenericRecordUtil; import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.IOUtils; import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts; import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.LittleEndianInputStream; import org.apache.poi.util.LittleEndianInputStream;
@ -875,7 +874,7 @@ public final class HemfFill {
xform.setToIdentity(); xform.setToIdentity();
} }
return 6 * LittleEndian.INT_SIZE; return 6 * LittleEndianConsts.INT_SIZE;
} }
static Shape getRgnShape(List<Rectangle2D> rgnRects) { static Shape getRgnShape(List<Rectangle2D> rgnRects) {

View File

@ -33,6 +33,7 @@ import org.apache.poi.poifs.filesystem.DirectoryNode;
import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.util.IOUtils; import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
/** /**
* Utility class which dumps raw contents of a ppt file into XML format * Utility class which dumps raw contents of a ppt file into XML format
@ -118,11 +119,11 @@ public final class PPTXMLDump {
//read record header //read record header
int info = LittleEndian.getUShort(data, pos); int info = LittleEndian.getUShort(data, pos);
pos += LittleEndian.SHORT_SIZE; pos += LittleEndianConsts.SHORT_SIZE;
int type = LittleEndian.getUShort(data, pos); int type = LittleEndian.getUShort(data, pos);
pos += LittleEndian.SHORT_SIZE; pos += LittleEndianConsts.SHORT_SIZE;
int size = (int)LittleEndian.getUInt(data, pos); int size = (int)LittleEndian.getUInt(data, pos);
pos += LittleEndian.INT_SIZE; pos += LittleEndianConsts.INT_SIZE;
//get name of the record by type //get name of the record by type
String recname = RecordTypes.forTypeID(type).name(); String recname = RecordTypes.forTypeID(type).name();

View File

@ -32,7 +32,6 @@ import java.util.function.Supplier;
import org.apache.poi.common.Duplicatable; import org.apache.poi.common.Duplicatable;
import org.apache.poi.common.usermodel.GenericRecord; import org.apache.poi.common.usermodel.GenericRecord;
import org.apache.poi.hslf.exceptions.HSLFException; import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.hslf.record.StyleTextPropAtom;
import org.apache.poi.util.HexDump; import org.apache.poi.util.HexDump;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
@ -292,12 +291,12 @@ public class TextPropCollection implements GenericRecord, Duplicatable {
if (!isMasterStyle) { if (!isMasterStyle) {
// First goes the number of characters we affect // First goes the number of characters we affect
// MasterStyles don't have this field // MasterStyles don't have this field
StyleTextPropAtom.writeLittleEndian(charactersCovered,o); org.apache.poi.hslf.record.Record.writeLittleEndian(charactersCovered,o);
} }
// Then we have the indentLevel field if it's a paragraph collection // Then we have the indentLevel field if it's a paragraph collection
if (textPropType == TextPropType.paragraph && indentLevel > -1) { if (textPropType == TextPropType.paragraph && indentLevel > -1) {
StyleTextPropAtom.writeLittleEndian(indentLevel, o); org.apache.poi.hslf.record.Record.writeLittleEndian(indentLevel, o);
} }
// Then the mask field // Then the mask field
@ -305,7 +304,7 @@ public class TextPropCollection implements GenericRecord, Duplicatable {
for (TextProp textProp : textProps.values()) { for (TextProp textProp : textProps.values()) {
mask |= textProp.getWriteMask(); mask |= textProp.getWriteMask();
} }
StyleTextPropAtom.writeLittleEndian(mask,o); org.apache.poi.hslf.record.Record.writeLittleEndian(mask,o);
// Then the contents of all the properties // Then the contents of all the properties
for (TextProp textProp : getTextPropList()) { for (TextProp textProp : getTextPropList()) {
@ -314,9 +313,9 @@ public class TextPropCollection implements GenericRecord, Duplicatable {
// don't add empty properties, as they can't be recognized while reading // don't add empty properties, as they can't be recognized while reading
continue; continue;
} else if (textProp.getSize() == 2) { } else if (textProp.getSize() == 2) {
StyleTextPropAtom.writeLittleEndian((short)val,o); org.apache.poi.hslf.record.Record.writeLittleEndian((short)val,o);
} else if (textProp.getSize() == 4) { } else if (textProp.getSize() == 4) {
StyleTextPropAtom.writeLittleEndian(val,o); org.apache.poi.hslf.record.Record.writeLittleEndian(val,o);
} else if (textProp instanceof HSLFTabStopPropCollection) { } else if (textProp instanceof HSLFTabStopPropCollection) {
((HSLFTabStopPropCollection)textProp).writeProperty(o); ((HSLFTabStopPropCollection)textProp).writeProperty(o);
} }

View File

@ -20,6 +20,7 @@ package org.apache.poi.hslf.record;
import java.util.function.Supplier; import java.util.function.Supplier;
import org.apache.poi.ddf.DefaultEscherRecordFactory; import org.apache.poi.ddf.DefaultEscherRecordFactory;
import org.apache.poi.ddf.EscherClientDataRecord;
import org.apache.poi.ddf.EscherRecord; import org.apache.poi.ddf.EscherRecord;
import org.apache.poi.ddf.EscherRecordFactory; import org.apache.poi.ddf.EscherRecordFactory;
@ -40,7 +41,7 @@ public class HSLFEscherRecordFactory extends DefaultEscherRecordFactory {
protected Supplier<? extends EscherRecord> getConstructor(short options, short recordId) { protected Supplier<? extends EscherRecord> getConstructor(short options, short recordId) {
if (recordId == EscherPlaceholder.RECORD_ID) { if (recordId == EscherPlaceholder.RECORD_ID) {
return EscherPlaceholder::new; return EscherPlaceholder::new;
} else if (recordId == HSLFEscherClientDataRecord.RECORD_ID) { } else if (recordId == EscherClientDataRecord.RECORD_ID) {
return HSLFEscherClientDataRecord::new; return HSLFEscherClientDataRecord::new;
} }
return super.getConstructor(options, recordId); return super.getConstructor(options, recordId);

View File

@ -32,6 +32,7 @@ import org.apache.poi.sl.usermodel.TextShape.TextPlaceholder;
import org.apache.poi.util.GenericRecordUtil; import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.IOUtils; import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.LittleEndianOutputStream; import org.apache.poi.util.LittleEndianOutputStream;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
@ -148,7 +149,7 @@ public final class TxMasterStyleAtom extends RecordAtom {
//number of indentation levels //number of indentation levels
short levels = LittleEndian.getShort(_data, 0); short levels = LittleEndian.getShort(_data, 0);
pos += LittleEndian.SHORT_SIZE; pos += LittleEndianConsts.SHORT_SIZE;
paragraphStyles = new ArrayList<>(levels); paragraphStyles = new ArrayList<>(levels);
charStyles = new ArrayList<>(levels); charStyles = new ArrayList<>(levels);
@ -159,19 +160,19 @@ public final class TxMasterStyleAtom extends RecordAtom {
// Fetch the 2 byte value, that is safe to ignore for some types of text // Fetch the 2 byte value, that is safe to ignore for some types of text
short indentLevel = LittleEndian.getShort(_data, pos); short indentLevel = LittleEndian.getShort(_data, pos);
prprops.setIndentLevel(indentLevel); prprops.setIndentLevel(indentLevel);
pos += LittleEndian.SHORT_SIZE; pos += LittleEndianConsts.SHORT_SIZE;
} else { } else {
prprops.setIndentLevel((short)-1); prprops.setIndentLevel((short)-1);
} }
head = LittleEndian.getInt(_data, pos); head = LittleEndian.getInt(_data, pos);
pos += LittleEndian.INT_SIZE; pos += LittleEndianConsts.INT_SIZE;
pos += prprops.buildTextPropList( head, _data, pos); pos += prprops.buildTextPropList( head, _data, pos);
paragraphStyles.add(prprops); paragraphStyles.add(prprops);
head = LittleEndian.getInt(_data, pos); head = LittleEndian.getInt(_data, pos);
pos += LittleEndian.INT_SIZE; pos += LittleEndianConsts.INT_SIZE;
TextPropCollection chprops = new TextPropCollection(0, TextPropType.character); TextPropCollection chprops = new TextPropCollection(0, TextPropType.character);
pos += chprops.buildTextPropList( head, _data, pos); pos += chprops.buildTextPropList( head, _data, pos);
charStyles.add(chprops); charStyles.add(chprops);

View File

@ -247,7 +247,7 @@ public class HSLFAutoShape extends HSLFTextShape implements AutoShape<HSLFShape,
while (segIter.hasNext()) { while (segIter.hasNext()) {
byte[] segElem = segIter.next(); byte[] segElem = segIter.next();
HSLFFreeformShape.PathInfo pi = getPathInfo(segElem); HSLFAutoShape.PathInfo pi = getPathInfo(segElem);
if (pi == null) { if (pi == null) {
continue; continue;
} }
@ -376,7 +376,7 @@ public class HSLFAutoShape extends HSLFTextShape implements AutoShape<HSLFShape,
} }
private static void handleEscapeInfo(CTPath2D pathCT, Path2D path2D, byte[] segElem, Iterator<byte[]> vertIter) { private static void handleEscapeInfo(CTPath2D pathCT, Path2D path2D, byte[] segElem, Iterator<byte[]> vertIter) {
HSLFFreeformShape.EscapeInfo ei = getEscapeInfo(segElem); HSLFAutoShape.EscapeInfo ei = getEscapeInfo(segElem);
if (ei == null) { if (ei == null) {
return; return;
} }
@ -474,16 +474,16 @@ public class HSLFAutoShape extends HSLFTextShape implements AutoShape<HSLFShape,
return new Point2D.Double(xyPoints[0],xyPoints[1]); return new Point2D.Double(xyPoints[0],xyPoints[1]);
} }
private static HSLFFreeformShape.PathInfo getPathInfo(byte[] elem) { private static HSLFAutoShape.PathInfo getPathInfo(byte[] elem) {
int elemUS = LittleEndian.getUShort(elem, 0); int elemUS = LittleEndian.getUShort(elem, 0);
int pathInfo = PATH_INFO.getValue(elemUS); int pathInfo = PATH_INFO.getValue(elemUS);
return HSLFFreeformShape.PathInfo.valueOf(pathInfo); return HSLFAutoShape.PathInfo.valueOf(pathInfo);
} }
private static HSLFFreeformShape.EscapeInfo getEscapeInfo(byte[] elem) { private static HSLFAutoShape.EscapeInfo getEscapeInfo(byte[] elem) {
int elemUS = LittleEndian.getUShort(elem, 0); int elemUS = LittleEndian.getUShort(elem, 0);
int escInfo = ESCAPE_INFO.getValue(elemUS); int escInfo = ESCAPE_INFO.getValue(elemUS);
return HSLFFreeformShape.EscapeInfo.valueOf(escInfo); return HSLFAutoShape.EscapeInfo.valueOf(escInfo);
} }

View File

@ -37,6 +37,7 @@ import org.apache.poi.poifs.crypt.CryptoFunctions;
import org.apache.poi.poifs.crypt.HashAlgorithm; import org.apache.poi.poifs.crypt.HashAlgorithm;
import org.apache.poi.sl.usermodel.PictureData; import org.apache.poi.sl.usermodel.PictureData;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.Units; import org.apache.poi.util.Units;
/** /**
@ -153,18 +154,18 @@ public abstract class HSLFPictureData implements PictureData, GenericRecord {
public void write(OutputStream out) throws IOException { public void write(OutputStream out) throws IOException {
byte[] data; byte[] data;
data = new byte[LittleEndian.SHORT_SIZE]; data = new byte[LittleEndianConsts.SHORT_SIZE];
LittleEndian.putUShort(data, 0, getSignature()); LittleEndian.putUShort(data, 0, getSignature());
out.write(data); out.write(data);
data = new byte[LittleEndian.SHORT_SIZE]; data = new byte[LittleEndianConsts.SHORT_SIZE];
PictureType pt = getType(); PictureType pt = getType();
LittleEndian.putUShort(data, 0, pt.nativeId + 0xF018); LittleEndian.putUShort(data, 0, pt.nativeId + 0xF018);
out.write(data); out.write(data);
byte[] rd = getRawData(); byte[] rd = getRawData();
data = new byte[LittleEndian.INT_SIZE]; data = new byte[LittleEndianConsts.INT_SIZE];
LittleEndian.putInt(data, 0, rd.length); LittleEndian.putInt(data, 0, rd.length);
out.write(data); out.write(data);

View File

@ -41,13 +41,13 @@ public abstract class AbstractExcelConverter
{ {
protected static int getColumnWidth( HSSFSheet sheet, int columnIndex ) protected static int getColumnWidth( HSSFSheet sheet, int columnIndex )
{ {
return ExcelToHtmlUtils.getColumnWidthInPx( sheet return AbstractExcelUtils.getColumnWidthInPx( sheet
.getColumnWidth( columnIndex ) ); .getColumnWidth( columnIndex ) );
} }
protected static int getDefaultColumnWidth( HSSFSheet sheet ) protected static int getDefaultColumnWidth( HSSFSheet sheet )
{ {
return ExcelToHtmlUtils.getColumnWidthInPx( sheet return AbstractExcelUtils.getColumnWidthInPx( sheet
.getDefaultColumnWidth() ); .getDefaultColumnWidth() );
} }
@ -151,12 +151,12 @@ public abstract class AbstractExcelConverter
value = ErrorEval.getText( cell.getErrorCellValue() ); value = ErrorEval.getText( cell.getErrorCellValue() );
break; break;
default: default:
value = ExcelToHtmlUtils.EMPTY; value = AbstractExcelUtils.EMPTY;
break; break;
} }
break; break;
case BLANK: case BLANK:
value = ExcelToHtmlUtils.EMPTY; value = AbstractExcelUtils.EMPTY;
break; break;
case NUMERIC: case NUMERIC:
value = _formatter.formatCellValue( cell ); value = _formatter.formatCellValue( cell );
@ -171,7 +171,7 @@ public abstract class AbstractExcelConverter
return true; return true;
} }
return ExcelToHtmlUtils.isEmpty( value ); return AbstractExcelUtils.isEmpty( value );
} }
public void setFontReplacer( FontReplacer fontReplacer ) public void setFontReplacer( FontReplacer fontReplacer )

View File

@ -217,7 +217,7 @@ public class ExcelToFoConverter extends AbstractExcelConverter
} }
else else
{ {
value = ExcelToHtmlUtils.EMPTY; value = AbstractExcelUtils.EMPTY;
} }
break; break;
case NUMERIC: case NUMERIC:
@ -237,12 +237,12 @@ public class ExcelToFoConverter extends AbstractExcelConverter
POILogger.WARN, POILogger.WARN,
"Unexpected cell cachedFormulaResultType (" "Unexpected cell cachedFormulaResultType ("
+ cell.getCachedFormulaResultType() + ")" ); + cell.getCachedFormulaResultType() + ")" );
value = ExcelToHtmlUtils.EMPTY; value = AbstractExcelUtils.EMPTY;
break; break;
} }
break; break;
case BLANK: case BLANK:
value = ExcelToHtmlUtils.EMPTY; value = AbstractExcelUtils.EMPTY;
break; break;
case NUMERIC: case NUMERIC:
value = _formatter.formatCellValue( cell ); value = _formatter.formatCellValue( cell );
@ -259,7 +259,7 @@ public class ExcelToFoConverter extends AbstractExcelConverter
return true; return true;
} }
final boolean noText = ExcelToHtmlUtils.isEmpty( value ); final boolean noText = AbstractExcelUtils.isEmpty( value );
final boolean wrapInDivs = !noText && !cellStyle.getWrapText(); final boolean wrapInDivs = !noText && !cellStyle.getWrapText();
final boolean emptyStyle = isEmptyStyle( cellStyle ); final boolean emptyStyle = isEmptyStyle( cellStyle );
@ -318,7 +318,7 @@ public class ExcelToFoConverter extends AbstractExcelConverter
block.appendChild( text ); block.appendChild( text );
tableCellElement.appendChild( block ); tableCellElement.appendChild( block );
return ExcelToHtmlUtils.isEmpty( value ) && emptyStyle; return AbstractExcelUtils.isEmpty( value ) && emptyStyle;
} }
protected void processCellStyle( HSSFWorkbook workbook, protected void processCellStyle( HSSFWorkbook workbook,
@ -349,7 +349,7 @@ public class ExcelToFoConverter extends AbstractExcelConverter
.getFillBackgroundColorColor(); .getFillBackgroundColorColor();
if ( backgroundColor != null ) if ( backgroundColor != null )
cellTarget.setAttribute( "background-color", cellTarget.setAttribute( "background-color",
ExcelToHtmlUtils.getColor( backgroundColor ) ); AbstractExcelUtils.getColor( backgroundColor ) );
} }
processCellStyleBorder( workbook, cellTarget, "top", processCellStyleBorder( workbook, cellTarget, "top",
@ -373,17 +373,17 @@ public class ExcelToFoConverter extends AbstractExcelConverter
return; return;
StringBuilder borderStyle = new StringBuilder(); StringBuilder borderStyle = new StringBuilder();
borderStyle.append( ExcelToHtmlUtils.getBorderWidth( xlsBorder ) ); borderStyle.append( AbstractExcelUtils.getBorderWidth( xlsBorder ) );
final HSSFColor color = workbook.getCustomPalette().getColor( final HSSFColor color = workbook.getCustomPalette().getColor(
borderColor ); borderColor );
if ( color != null ) if ( color != null )
{ {
borderStyle.append( ' ' ); borderStyle.append( ' ' );
borderStyle.append( ExcelToHtmlUtils.getColor( color ) ); borderStyle.append( AbstractExcelUtils.getColor( color ) );
borderStyle.append( ' ' ); borderStyle.append( ' ' );
borderStyle.append( ExcelToHtmlUtils.getBorderStyle( xlsBorder ) ); borderStyle.append( AbstractExcelUtils.getBorderStyle( xlsBorder ) );
} }
cellTarget.setAttribute( "border-" + type, borderStyle.toString() ); cellTarget.setAttribute( "border-" + type, borderStyle.toString() );
@ -404,7 +404,7 @@ public class ExcelToFoConverter extends AbstractExcelConverter
font.getColor() ); font.getColor() );
if ( fontColor != null ) if ( fontColor != null )
blockTarget.setAttribute( "color", blockTarget.setAttribute( "color",
ExcelToHtmlUtils.getColor( fontColor ) ); AbstractExcelUtils.getColor( fontColor ) );
if ( font.getFontHeightInPoints() != 0 ) if ( font.getFontHeightInPoints() != 0 )
blockTarget.setAttribute( "font-size", font.getFontHeightInPoints() blockTarget.setAttribute( "font-size", font.getFontHeightInPoints()
@ -532,7 +532,7 @@ public class ExcelToFoConverter extends AbstractExcelConverter
if ( !isOutputHiddenColumns() && sheet.isColumnHidden( colIx ) ) if ( !isOutputHiddenColumns() && sheet.isColumnHidden( colIx ) )
continue; continue;
CellRangeAddress range = ExcelToHtmlUtils.getMergedRange( CellRangeAddress range = AbstractExcelUtils.getMergedRange(
mergedRanges, row.getRowNum(), colIx ); mergedRanges, row.getRowNum(), colIx );
if ( range != null if ( range != null

View File

@ -100,7 +100,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
* @throws ParserConfigurationException If configuration is incorrect * @throws ParserConfigurationException If configuration is incorrect
*/ */
public static Document process( File xlsFile ) throws IOException, ParserConfigurationException { public static Document process( File xlsFile ) throws IOException, ParserConfigurationException {
try (HSSFWorkbook workbook = ExcelToHtmlUtils.loadXls(xlsFile)) { try (HSSFWorkbook workbook = AbstractExcelUtils.loadXls(xlsFile)) {
return ExcelToHtmlConverter.process(workbook); return ExcelToHtmlConverter.process(workbook);
} }
} }
@ -173,13 +173,13 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
case SOLID_FOREGROUND: case SOLID_FOREGROUND:
final HSSFColor foregroundColor = cellStyle.getFillForegroundColorColor(); final HSSFColor foregroundColor = cellStyle.getFillForegroundColorColor();
if ( foregroundColor == null ) break; if ( foregroundColor == null ) break;
String fgCol = ExcelToHtmlUtils.getColor( foregroundColor ); String fgCol = AbstractExcelUtils.getColor( foregroundColor );
style.append("background-color:").append(fgCol).append(";"); style.append("background-color:").append(fgCol).append(";");
break; break;
default: default:
final HSSFColor backgroundColor = cellStyle.getFillBackgroundColorColor(); final HSSFColor backgroundColor = cellStyle.getFillBackgroundColorColor();
if ( backgroundColor == null ) break; if ( backgroundColor == null ) break;
String bgCol = ExcelToHtmlUtils.getColor( backgroundColor ); String bgCol = AbstractExcelUtils.getColor( backgroundColor );
style.append("background-color:").append(bgCol).append(";"); style.append("background-color:").append(bgCol).append(";");
break; break;
} }
@ -206,16 +206,16 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
} }
StringBuilder borderStyle = new StringBuilder(); StringBuilder borderStyle = new StringBuilder();
borderStyle.append( ExcelToHtmlUtils.getBorderWidth( xlsBorder ) ); borderStyle.append( AbstractExcelUtils.getBorderWidth( xlsBorder ) );
borderStyle.append( ' ' ); borderStyle.append( ' ' );
borderStyle.append( ExcelToHtmlUtils.getBorderStyle( xlsBorder ) ); borderStyle.append( AbstractExcelUtils.getBorderStyle( xlsBorder ) );
final HSSFColor color = workbook.getCustomPalette().getColor( final HSSFColor color = workbook.getCustomPalette().getColor(
borderColor ); borderColor );
if ( color != null ) if ( color != null )
{ {
borderStyle.append( ' ' ); borderStyle.append( ' ' );
borderStyle.append( ExcelToHtmlUtils.getColor( color ) ); borderStyle.append( AbstractExcelUtils.getColor( color ) );
} }
style.append("border-").append(type).append(":").append(borderStyle).append(";"); style.append("border-").append(type).append(":").append(borderStyle).append(";");
@ -231,7 +231,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
final HSSFColor fontColor = workbook.getCustomPalette().getColor( final HSSFColor fontColor = workbook.getCustomPalette().getColor(
font.getColor() ); font.getColor() );
if ( fontColor != null ) if ( fontColor != null )
style.append("color: ").append(ExcelToHtmlUtils.getColor(fontColor)).append("; "); style.append("color: ").append(AbstractExcelUtils.getColor(fontColor)).append("; ");
if ( font.getFontHeightInPoints() != 0 ) if ( font.getFontHeightInPoints() != 0 )
style.append("font-size:").append(font.getFontHeightInPoints()).append("pt;"); style.append("font-size:").append(font.getFontHeightInPoints()).append("pt;");
@ -307,7 +307,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
} }
else else
{ {
value = ExcelToHtmlUtils.EMPTY; value = AbstractExcelUtils.EMPTY;
} }
break; break;
case NUMERIC: case NUMERIC:
@ -327,12 +327,12 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
POILogger.WARN, POILogger.WARN,
"Unexpected cell cachedFormulaResultType (" "Unexpected cell cachedFormulaResultType ("
+ cell.getCachedFormulaResultType() + ")" ); + cell.getCachedFormulaResultType() + ")" );
value = ExcelToHtmlUtils.EMPTY; value = AbstractExcelUtils.EMPTY;
break; break;
} }
break; break;
case BLANK: case BLANK:
value = ExcelToHtmlUtils.EMPTY; value = AbstractExcelUtils.EMPTY;
break; break;
case NUMERIC: case NUMERIC:
value = _formatter.formatCellValue( cell ); value = _formatter.formatCellValue( cell );
@ -349,7 +349,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
return true; return true;
} }
final boolean noText = ExcelToHtmlUtils.isEmpty( value ); final boolean noText = AbstractExcelUtils.isEmpty( value );
final boolean wrapInDivs = !noText && isUseDivsToSpan() && !cellStyle.getWrapText(); final boolean wrapInDivs = !noText && isUseDivsToSpan() && !cellStyle.getWrapText();
if ( cellStyle.getIndex() != 0 ) { if ( cellStyle.getIndex() != 0 ) {
@ -419,7 +419,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
tableCellElement.appendChild( text ); tableCellElement.appendChild( text );
} }
return ExcelToHtmlUtils.isEmpty( value ) && (cellStyle.getIndex() == 0); return AbstractExcelUtils.isEmpty( value ) && (cellStyle.getIndex() == 0);
} }
protected void processColumnHeaders( HSSFSheet sheet, int maxSheetColumns, protected void processColumnHeaders( HSSFSheet sheet, int maxSheetColumns,
@ -472,16 +472,16 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
} }
protected void processDocumentInformation(SummaryInformation summaryInformation ) { protected void processDocumentInformation(SummaryInformation summaryInformation ) {
if ( ExcelToHtmlUtils.isNotEmpty( summaryInformation.getTitle() ) ) if ( AbstractExcelUtils.isNotEmpty( summaryInformation.getTitle() ) )
htmlDocumentFacade.setTitle( summaryInformation.getTitle() ); htmlDocumentFacade.setTitle( summaryInformation.getTitle() );
if ( ExcelToHtmlUtils.isNotEmpty( summaryInformation.getAuthor() ) ) if ( AbstractExcelUtils.isNotEmpty( summaryInformation.getAuthor() ) )
htmlDocumentFacade.addAuthor( summaryInformation.getAuthor() ); htmlDocumentFacade.addAuthor( summaryInformation.getAuthor() );
if ( ExcelToHtmlUtils.isNotEmpty( summaryInformation.getKeywords() ) ) if ( AbstractExcelUtils.isNotEmpty( summaryInformation.getKeywords() ) )
htmlDocumentFacade.addKeywords( summaryInformation.getKeywords() ); htmlDocumentFacade.addKeywords( summaryInformation.getKeywords() );
if ( ExcelToHtmlUtils.isNotEmpty( summaryInformation.getComments() ) ) if ( AbstractExcelUtils.isNotEmpty( summaryInformation.getComments() ) )
htmlDocumentFacade htmlDocumentFacade
.addDescription( summaryInformation.getComments() ); .addDescription( summaryInformation.getComments() );
} }
@ -512,7 +512,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
if ( !isOutputHiddenColumns() && sheet.isColumnHidden( colIx ) ) if ( !isOutputHiddenColumns() && sheet.isColumnHidden( colIx ) )
continue; continue;
CellRangeAddress range = ExcelToHtmlUtils.getMergedRange( CellRangeAddress range = AbstractExcelUtils.getMergedRange(
mergedRanges, row.getRowNum(), colIx ); mergedRanges, row.getRowNum(), colIx );
if ( range != null if ( range != null

View File

@ -934,7 +934,7 @@ public abstract class AbstractWordConverter
picture.suggestPictureType(), picture.suggestPictureType(),
picture.suggestFullFileName(), imageWidth, imageHeight ); picture.suggestFullFileName(), imageWidth, imageHeight );
if ( WordToFoUtils.isNotEmpty( url ) ) if ( AbstractWordUtils.isNotEmpty( url ) )
{ {
processImage( currentBlock, inlined, picture, url ); processImage( currentBlock, inlined, picture, url );
return; return;

View File

@ -137,7 +137,7 @@ public class AbstractWordUtils
{ {
Node child1 = childNodes.item( i ); Node child1 = childNodes.item( i );
Node child2 = childNodes.item( i + 1 ); Node child2 = childNodes.item( i + 1 );
if ( !WordToFoUtils.canBeMerged( child1, child2, childTagName ) ) if ( !AbstractWordUtils.canBeMerged( child1, child2, childTagName ) )
continue; continue;
// merge // merge

View File

@ -309,9 +309,8 @@ public class FoDocumentFacade
if ( child.getNodeType() == Node.ELEMENT_NODE ) if ( child.getNodeType() == Node.ELEMENT_NODE )
{ {
Element childElement = (Element) child; Element childElement = (Element) child;
if ( WordToFoUtils.isNotEmpty( childElement.getNamespaceURI() ) if ( AbstractWordUtils.isNotEmpty( childElement.getNamespaceURI() )
&& WordToFoUtils.isNotEmpty( childElement && AbstractWordUtils.isNotEmpty( childElement.getLocalName() )
.getLocalName() )
&& namespace.equals( childElement.getNamespaceURI() ) && namespace.equals( childElement.getNamespaceURI() )
&& name.equals( childElement.getLocalName() ) ) && name.equals( childElement.getLocalName() ) )
{ {
@ -321,7 +320,7 @@ public class FoDocumentFacade
} }
} }
if ( WordToFoUtils.isNotEmpty( value ) ) if ( AbstractWordUtils.isNotEmpty( value ) )
{ {
Element property = document.createElementNS( namespace, prefix Element property = document.createElementNS( namespace, prefix
+ ":" + name ); + ":" + name );

View File

@ -27,6 +27,7 @@ import org.apache.poi.hwpf.model.io.HWPFFileSystem;
import org.apache.poi.hwpf.sprm.SprmBuffer; import org.apache.poi.hwpf.sprm.SprmBuffer;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.StringUtil; import org.apache.poi.util.StringUtil;
@Internal @Internal
@ -54,7 +55,7 @@ public class ComplexFileTable {
while (tableStream[offset] == GRPPRL_TYPE) { while (tableStream[offset] == GRPPRL_TYPE) {
offset++; offset++;
int size = LittleEndian.getShort(tableStream, offset); int size = LittleEndian.getShort(tableStream, offset);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
byte[] bs = LittleEndian.getByteArray(tableStream, offset, size, MAX_RECORD_LENGTH); byte[] bs = LittleEndian.getByteArray(tableStream, offset, size, MAX_RECORD_LENGTH);
offset += size; offset += size;
@ -68,7 +69,7 @@ public class ComplexFileTable {
" but had " + tableStream[offset]); " but had " + tableStream[offset]);
} }
int pieceTableSize = LittleEndian.getInt(tableStream, ++offset); int pieceTableSize = LittleEndian.getInt(tableStream, ++offset);
offset += LittleEndian.INT_SIZE; offset += LittleEndianConsts.INT_SIZE;
_tpt = newTextPieceTable(documentStream, tableStream, offset, pieceTableSize, fcMin, charset); _tpt = newTextPieceTable(documentStream, tableStream, offset, pieceTableSize, fcMin, charset);
} }
@ -99,7 +100,7 @@ public class ComplexFileTable {
byte[] table = _tpt.writeTo(wordDocumentStream); byte[] table = _tpt.writeTo(wordDocumentStream);
byte[] numHolder = new byte[LittleEndian.INT_SIZE]; byte[] numHolder = new byte[LittleEndianConsts.INT_SIZE];
LittleEndian.putInt(numHolder, 0, table.length); LittleEndian.putInt(numHolder, 0, table.length);
tableStream.write(numHolder); tableStream.write(numHolder);
tableStream.write(table); tableStream.write(table);

View File

@ -18,6 +18,7 @@ package org.apache.poi.hwpf.model;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
/** /**
* The FFData structure specifies form field data for a text box, check box, or * The FFData structure specifies form field data for a text box, check box, or
@ -114,7 +115,7 @@ public class FFData
{ {
this._wDef = Integer this._wDef = Integer
.valueOf( LittleEndian.getUShort( std, offset ) ); .valueOf( LittleEndian.getUShort( std, offset ) );
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
} }
else else
{ {
@ -170,7 +171,7 @@ public class FFData
if ( _base.getIType() == FFDataBase.ITYPE_CHCK if ( _base.getIType() == FFDataBase.ITYPE_CHCK
|| _base.getIType() == FFDataBase.ITYPE_DROP ) || _base.getIType() == FFDataBase.ITYPE_DROP )
{ {
size += LittleEndian.SHORT_SIZE; size += LittleEndianConsts.SHORT_SIZE;
} }
size += _xstzTextFormat.getSize(); size += _xstzTextFormat.getSize();
@ -211,7 +212,7 @@ public class FFData
|| _base.getIType() == FFDataBase.ITYPE_DROP ) || _base.getIType() == FFDataBase.ITYPE_DROP )
{ {
LittleEndian.putUShort( buffer, offset, _wDef ); LittleEndian.putUShort( buffer, offset, _wDef );
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
} }
offset += _xstzTextFormat.serialize( buffer, offset ); offset += _xstzTextFormat.serialize( buffer, offset );

View File

@ -26,6 +26,7 @@ import java.util.Map;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
@ -146,7 +147,7 @@ public final class FIBFieldHandler
private final static POILogger log = POILogFactory.getLogger(FIBFieldHandler.class); private final static POILogger log = POILogFactory.getLogger(FIBFieldHandler.class);
private static final int FIELD_SIZE = LittleEndian.INT_SIZE * 2; private static final int FIELD_SIZE = LittleEndianConsts.INT_SIZE * 2;
private Map<Integer, UnhandledDataStructure> _unknownMap = new HashMap<>(); private Map<Integer, UnhandledDataStructure> _unknownMap = new HashMap<>();
private int[] _fields; private int[] _fields;
@ -161,7 +162,7 @@ public final class FIBFieldHandler
{ {
int fieldOffset = (x * FIELD_SIZE) + offset; int fieldOffset = (x * FIELD_SIZE) + offset;
int dsOffset = LittleEndian.getInt(mainStream, fieldOffset); int dsOffset = LittleEndian.getInt(mainStream, fieldOffset);
fieldOffset += LittleEndian.INT_SIZE; fieldOffset += LittleEndianConsts.INT_SIZE;
int dsSize = LittleEndian.getInt(mainStream, fieldOffset); int dsSize = LittleEndian.getInt(mainStream, fieldOffset);
if (offsetList.contains(Integer.valueOf(x)) ^ areKnown) if (offsetList.contains(Integer.valueOf(x)) ^ areKnown)
@ -216,7 +217,7 @@ public final class FIBFieldHandler
public int sizeInBytes() public int sizeInBytes()
{ {
return (_fields.length * LittleEndian.INT_SIZE); return (_fields.length * LittleEndianConsts.INT_SIZE);
} }
public int getFieldsCount() { public int getFieldsCount() {
@ -233,21 +234,21 @@ public final class FIBFieldHandler
{ {
_fields[x * 2] = tableStream.size(); _fields[x * 2] = tableStream.size();
LittleEndian.putInt(mainStream, offset, tableStream.size()); LittleEndian.putInt(mainStream, offset, tableStream.size());
offset += LittleEndian.INT_SIZE; offset += LittleEndianConsts.INT_SIZE;
byte[] buf = ds.getBuf(); byte[] buf = ds.getBuf();
tableStream.write(buf); tableStream.write(buf);
_fields[(x * 2) + 1] = buf.length; _fields[(x * 2) + 1] = buf.length;
LittleEndian.putInt(mainStream, offset, buf.length); LittleEndian.putInt(mainStream, offset, buf.length);
offset += LittleEndian.INT_SIZE; offset += LittleEndianConsts.INT_SIZE;
} }
else else
{ {
LittleEndian.putInt(mainStream, offset, _fields[x * 2]); LittleEndian.putInt(mainStream, offset, _fields[x * 2]);
offset += LittleEndian.INT_SIZE; offset += LittleEndianConsts.INT_SIZE;
LittleEndian.putInt(mainStream, offset, _fields[(x * 2) + 1]); LittleEndian.putInt(mainStream, offset, _fields[(x * 2) + 1]);
offset += LittleEndian.INT_SIZE; offset += LittleEndianConsts.INT_SIZE;
} }
} }
} }
@ -283,9 +284,9 @@ public final class FIBFieldHandler
{ {
result.append( '\t' ); result.append( '\t' );
result.append( leftPad( Integer.toString( x ), 8, ' ' ) ); result.append( leftPad( Integer.toString( x ), 8, ' ' ) );
result.append( leftPad( Integer.toString( 154 + x * LittleEndian.INT_SIZE * 2 ), 6, ' ' ) ); result.append( leftPad( Integer.toString( 154 + x * LittleEndianConsts.INT_SIZE * 2 ), 6, ' ' ) );
result.append( " 0x" ); result.append( " 0x" );
result.append( leftPad( Integer.toHexString( 154 + x * LittleEndian.INT_SIZE * 2 ), 4, '0' ) ); result.append( leftPad( Integer.toHexString( 154 + x * LittleEndianConsts.INT_SIZE * 2 ), 4, '0' ) );
result.append( leftPad( Integer.toString( getFieldOffset( x ) ), 8, ' ' ) ); result.append( leftPad( Integer.toString( getFieldOffset( x ) ), 8, ' ' ) );
result.append( leftPad( Integer.toString( getFieldSize( x ) ), 8, ' ' ) ); result.append( leftPad( Integer.toString( getFieldSize( x ) ), 8, ' ' ) );

View File

@ -24,6 +24,7 @@ import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.IOUtils; import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
/** /**
* FFN - Font Family Name. FFN is a data structure that stores the names of the Main * FFN - Font Family Name. FFN is a data structure that stores the names of the Main
@ -63,15 +64,15 @@ public final class Ffn
int offsetTmp = offset; int offsetTmp = offset;
_cbFfnM1 = LittleEndian.getUByte(buf,offset); _cbFfnM1 = LittleEndian.getUByte(buf,offset);
offset += LittleEndian.BYTE_SIZE; offset += LittleEndianConsts.BYTE_SIZE;
_info = buf[offset]; _info = buf[offset];
offset += LittleEndian.BYTE_SIZE; offset += LittleEndianConsts.BYTE_SIZE;
_wWeight = LittleEndian.getShort(buf, offset); _wWeight = LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
_chs = buf[offset]; _chs = buf[offset];
offset += LittleEndian.BYTE_SIZE; offset += LittleEndianConsts.BYTE_SIZE;
_ixchSzAlt = buf[offset]; _ixchSzAlt = buf[offset];
offset += LittleEndian.BYTE_SIZE; offset += LittleEndianConsts.BYTE_SIZE;
// read panose and fs so we can write them back out. // read panose and fs so we can write them back out.
System.arraycopy(buf, offset, _panose, 0, _panose.length); System.arraycopy(buf, offset, _panose, 0, _panose.length);
@ -86,7 +87,7 @@ public final class Ffn
for(int i = 0; i < _xszFfnLength; i++) for(int i = 0; i < _xszFfnLength; i++)
{ {
_xszFfn[i] = (char)LittleEndian.getShort(buf, offset); _xszFfn[i] = (char)LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
} }
@ -161,15 +162,15 @@ public final class Ffn
byte[] buf = IOUtils.safelyAllocate(this.getSize(), MAX_RECORD_LENGTH); byte[] buf = IOUtils.safelyAllocate(this.getSize(), MAX_RECORD_LENGTH);
buf[offset] = (byte)_cbFfnM1; buf[offset] = (byte)_cbFfnM1;
offset += LittleEndian.BYTE_SIZE; offset += LittleEndianConsts.BYTE_SIZE;
buf[offset] = _info; buf[offset] = _info;
offset += LittleEndian.BYTE_SIZE; offset += LittleEndianConsts.BYTE_SIZE;
LittleEndian.putShort(buf, offset, _wWeight); LittleEndian.putShort(buf, offset, _wWeight);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
buf[offset] = _chs; buf[offset] = _chs;
offset += LittleEndian.BYTE_SIZE; offset += LittleEndianConsts.BYTE_SIZE;
buf[offset] = _ixchSzAlt; buf[offset] = _ixchSzAlt;
offset += LittleEndian.BYTE_SIZE; offset += LittleEndianConsts.BYTE_SIZE;
System.arraycopy(_panose,0,buf, offset,_panose.length); System.arraycopy(_panose,0,buf, offset,_panose.length);
offset += _panose.length; offset += _panose.length;
@ -179,7 +180,7 @@ public final class Ffn
for(int i = 0; i < _xszFfn.length; i++) for(int i = 0; i < _xszFfn.length; i++)
{ {
LittleEndian.putShort(buf, offset, (short)_xszFfn[i]); LittleEndian.putShort(buf, offset, (short)_xszFfn[i]);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
} }
return buf; return buf;

View File

@ -27,6 +27,7 @@ import java.util.Locale;
import org.apache.poi.util.IOUtils; import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
@ -72,7 +73,7 @@ public final class FileInformationBlock
assert offset == 32; assert offset == 32;
_csw = LittleEndian.getUShort( mainDocument, offset ); _csw = LittleEndian.getUShort( mainDocument, offset );
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
assert offset == 34; assert offset == 34;
_fibRgW = new FibRgW97( mainDocument, offset ); _fibRgW = new FibRgW97( mainDocument, offset );
@ -80,7 +81,7 @@ public final class FileInformationBlock
assert offset == 62; assert offset == 62;
_cslw = LittleEndian.getUShort( mainDocument, offset ); _cslw = LittleEndian.getUShort( mainDocument, offset );
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
assert offset == 64; assert offset == 64;
if ( _fibBase.getNFib() < 105 ) if ( _fibBase.getNFib() < 105 )
@ -92,10 +93,10 @@ public final class FileInformationBlock
_cbRgFcLcb = 74; _cbRgFcLcb = 74;
// skip fibRgFcLcbBlob (read later at fillVariableFields) // skip fibRgFcLcbBlob (read later at fillVariableFields)
offset += _cbRgFcLcb * LittleEndian.INT_SIZE * 2; offset += _cbRgFcLcb * LittleEndianConsts.INT_SIZE * 2;
_cswNew = LittleEndian.getUShort( mainDocument, offset ); _cswNew = LittleEndian.getUShort( mainDocument, offset );
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
_cswNew = 0; _cswNew = 0;
_nFibNew = -1; _nFibNew = -1;
@ -109,23 +110,23 @@ public final class FileInformationBlock
assert offset == 152; assert offset == 152;
_cbRgFcLcb = LittleEndian.getUShort( mainDocument, offset ); _cbRgFcLcb = LittleEndian.getUShort( mainDocument, offset );
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
assert offset == 154; assert offset == 154;
// skip fibRgFcLcbBlob (read later at fillVariableFields) // skip fibRgFcLcbBlob (read later at fillVariableFields)
offset += _cbRgFcLcb * LittleEndian.INT_SIZE * 2; offset += _cbRgFcLcb * LittleEndianConsts.INT_SIZE * 2;
_cswNew = LittleEndian.getUShort( mainDocument, offset ); _cswNew = LittleEndian.getUShort( mainDocument, offset );
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
if ( _cswNew != 0 ) if ( _cswNew != 0 )
{ {
_nFibNew = LittleEndian.getUShort( mainDocument, offset ); _nFibNew = LittleEndian.getUShort( mainDocument, offset );
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
// first short is already read as _nFibNew // first short is already read as _nFibNew
final int fibRgCswNewLength = ( _cswNew - 1 ) final int fibRgCswNewLength = ( _cswNew - 1 )
* LittleEndian.SHORT_SIZE; * LittleEndianConsts.SHORT_SIZE;
_fibRgCswNew = IOUtils.safelyAllocate(fibRgCswNewLength, MAX_RECORD_LENGTH); _fibRgCswNew = IOUtils.safelyAllocate(fibRgCswNewLength, MAX_RECORD_LENGTH);
LittleEndian.getByteArray( mainDocument, offset, fibRgCswNewLength, MAX_RECORD_LENGTH ); LittleEndian.getByteArray( mainDocument, offset, fibRgCswNewLength, MAX_RECORD_LENGTH );
offset += fibRgCswNewLength; offset += fibRgCswNewLength;
@ -1081,29 +1082,29 @@ public final class FileInformationBlock
int offset = FibBase.getSize(); int offset = FibBase.getSize();
LittleEndian.putUShort( mainStream, offset, _csw ); LittleEndian.putUShort( mainStream, offset, _csw );
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
_fibRgW.serialize( mainStream, offset ); _fibRgW.serialize( mainStream, offset );
offset += FibRgW97.getSize(); offset += FibRgW97.getSize();
LittleEndian.putUShort( mainStream, offset, _cslw ); LittleEndian.putUShort( mainStream, offset, _cslw );
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
( (FibRgLw97) _fibRgLw ).serialize( mainStream, offset ); ( (FibRgLw97) _fibRgLw ).serialize( mainStream, offset );
offset += FibRgLw97.getSize(); offset += FibRgLw97.getSize();
LittleEndian.putUShort( mainStream, offset, _cbRgFcLcb ); LittleEndian.putUShort( mainStream, offset, _cbRgFcLcb );
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
_fieldHandler.writeTo( mainStream, offset, tableStream ); _fieldHandler.writeTo( mainStream, offset, tableStream );
offset += _cbRgFcLcb * LittleEndian.INT_SIZE * 2; offset += _cbRgFcLcb * LittleEndianConsts.INT_SIZE * 2;
LittleEndian.putUShort( mainStream, offset, _cswNew ); LittleEndian.putUShort( mainStream, offset, _cswNew );
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
if ( _cswNew != 0 ) if ( _cswNew != 0 )
{ {
LittleEndian.putUShort( mainStream, offset, _nFibNew ); LittleEndian.putUShort( mainStream, offset, _nFibNew );
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
System.arraycopy( _fibRgCswNew, 0, mainStream, offset, System.arraycopy( _fibRgCswNew, 0, mainStream, offset,
_fibRgCswNew.length ); _fibRgCswNew.length );
@ -1113,9 +1114,9 @@ public final class FileInformationBlock
public int getSize() public int getSize()
{ {
return FibBase.getSize() + LittleEndian.SHORT_SIZE + FibRgW97.getSize() return FibBase.getSize() + LittleEndianConsts.SHORT_SIZE + FibRgW97.getSize()
+ LittleEndian.SHORT_SIZE + FibRgLw97.getSize() + LittleEndianConsts.SHORT_SIZE + FibRgLw97.getSize()
+ LittleEndian.SHORT_SIZE + _fieldHandler.sizeInBytes(); + LittleEndianConsts.SHORT_SIZE + _fieldHandler.sizeInBytes();
} }
public FibBase getFibBase() public FibBase getFibBase()

View File

@ -23,6 +23,7 @@ import java.io.IOException;
import org.apache.poi.hwpf.model.io.HWPFFileSystem; import org.apache.poi.hwpf.model.io.HWPFFileSystem;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
@ -55,9 +56,9 @@ public final class FontTable
this.fcSttbfffn = offset; this.fcSttbfffn = offset;
_stringCount = LittleEndian.getShort(buf, offset); _stringCount = LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
_extraDataSz = LittleEndian.getShort(buf, offset); _extraDataSz = LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
_fontNames = new Ffn[_stringCount]; //Ffn corresponds to a Pascal style String in STTBF. _fontNames = new Ffn[_stringCount]; //Ffn corresponds to a Pascal style String in STTBF.
@ -124,7 +125,7 @@ public final class FontTable
public void writeTo( ByteArrayOutputStream tableStream ) throws IOException public void writeTo( ByteArrayOutputStream tableStream ) throws IOException
{ {
byte[] buf = new byte[LittleEndian.SHORT_SIZE]; byte[] buf = new byte[LittleEndianConsts.SHORT_SIZE];
LittleEndian.putShort(buf, 0, _stringCount); LittleEndian.putShort(buf, 0, _stringCount);
tableStream.write(buf); tableStream.write(buf);
LittleEndian.putShort(buf, 0, _extraDataSz); LittleEndian.putShort(buf, 0, _extraDataSz);

View File

@ -24,6 +24,7 @@ import java.util.Arrays;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
/** /**
* The LFOData structure contains the Main Document CP of the corresponding LFO, * The LFOData structure contains the Main Document CP of the corresponding LFO,
@ -49,7 +50,7 @@ public class LFOData
int offset = startOffset; int offset = startOffset;
_cp = LittleEndian.getInt( buf, offset ); _cp = LittleEndian.getInt( buf, offset );
offset += LittleEndian.INT_SIZE; offset += LittleEndianConsts.INT_SIZE;
_rgLfoLvl = new ListFormatOverrideLevel[cLfolvl]; _rgLfoLvl = new ListFormatOverrideLevel[cLfolvl];
for ( int x = 0; x < cLfolvl; x++ ) for ( int x = 0; x < cLfolvl; x++ )
@ -72,7 +73,7 @@ public class LFOData
public int getSizeInBytes() public int getSizeInBytes()
{ {
int result = 0; int result = 0;
result += LittleEndian.INT_SIZE; result += LittleEndianConsts.INT_SIZE;
for ( ListFormatOverrideLevel lfolvl : _rgLfoLvl ) for ( ListFormatOverrideLevel lfolvl : _rgLfoLvl )
result += lfolvl.getSizeInBytes(); result += lfolvl.getSizeInBytes();

View File

@ -25,6 +25,7 @@ import java.util.Objects;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
@ -56,7 +57,7 @@ public final class ListTables
int offset = lstOffset; int offset = lstOffset;
int cLst = LittleEndian.getShort( tableStream, offset ); int cLst = LittleEndian.getShort( tableStream, offset );
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
int levelOffset = offset + ( cLst * LSTF.getSize() ); int levelOffset = offset + ( cLst * LSTF.getSize() );
for ( int x = 0; x < cLst; x++ ) for ( int x = 0; x < cLst; x++ )

View File

@ -16,12 +16,13 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hwpf.model; package org.apache.poi.hwpf.model;
import java.util.Arrays;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
import java.util.Arrays;
public class NilPICFAndBinData public class NilPICFAndBinData
{ {
@ -39,7 +40,7 @@ public class NilPICFAndBinData
{ {
int lcb = LittleEndian.getInt( data, offset ); int lcb = LittleEndian.getInt( data, offset );
int cbHeader = LittleEndian.getUShort( data, offset int cbHeader = LittleEndian.getUShort( data, offset
+ LittleEndian.INT_SIZE ); + LittleEndianConsts.INT_SIZE );
if ( cbHeader != 0x44 ) if ( cbHeader != 0x44 )
{ {

View File

@ -21,7 +21,7 @@ import java.nio.charset.Charset;
import org.apache.poi.common.usermodel.fonts.FontCharset; import org.apache.poi.common.usermodel.fonts.FontCharset;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
import org.apache.poi.util.StringUtil; import org.apache.poi.util.StringUtil;
@ -74,12 +74,12 @@ public final class OldFfn {
charset = wmfCharset.getCharset(); charset = wmfCharset.getCharset();
} }
charset = charset == null ? StringUtil.WIN_1252 : charset; charset = charset == null ? StringUtil.WIN_1252 : charset;
offset += LittleEndian.BYTE_SIZE; offset += LittleEndianConsts.BYTE_SIZE;
//if this byte here == 7, it _may_ signify existence of //if this byte here == 7, it _may_ signify existence of
//an altername font name //an altername font name
//not sure what the byte after the _chs does //not sure what the byte after the _chs does
offset += LittleEndian.BYTE_SIZE; offset += LittleEndianConsts.BYTE_SIZE;
int fontNameLength = -1; int fontNameLength = -1;
for (int i = offset; i < fontTableEnd; i++) { for (int i = offset; i < fontTableEnd; i++) {
if (buf[i] == 0) { if (buf[i] == 0) {
@ -109,7 +109,7 @@ public final class OldFfn {
//reset to 0 for length calculation //reset to 0 for length calculation
altFontNameLength = (altFontNameLength < 0) ? 0 : altFontNameLength + 1;//add one for zero byte altFontNameLength = (altFontNameLength < 0) ? 0 : altFontNameLength + 1;//add one for zero byte
int len = LittleEndian.INT_SIZE + LittleEndian.BYTE_SIZE + LittleEndian.BYTE_SIZE +//6 starting bytes int len = LittleEndianConsts.INT_SIZE + LittleEndianConsts.BYTE_SIZE + LittleEndianConsts.BYTE_SIZE +//6 starting bytes
fontNameLength + altFontNameLength + 1;//+1 is for the zero byte fontNameLength + altFontNameLength + 1;//+1 is for the zero byte
//this len should == fontDescriptionLength //this len should == fontDescriptionLength

View File

@ -23,6 +23,7 @@ import java.util.List;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
@ -46,7 +47,7 @@ public final class OldFontTable {
int fontTableLength = LittleEndian.getShort(buf, offset); int fontTableLength = LittleEndian.getShort(buf, offset);
int endOfTableOffset = offset + length; int endOfTableOffset = offset + length;
int startOffset = offset + LittleEndian.SHORT_SIZE;//first short should == length! int startOffset = offset + LittleEndianConsts.SHORT_SIZE;//first short should == length!
while (true) { while (true) {
OldFfn oldFfn = OldFfn.build(buf, startOffset, endOfTableOffset); OldFfn oldFfn = OldFfn.build(buf, startOffset, endOfTableOffset);

View File

@ -20,6 +20,7 @@ package org.apache.poi.hwpf.model;
import org.apache.poi.util.IOUtils; import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
/** /**
* This class holds all of the section formatting * This class holds all of the section formatting
@ -72,7 +73,7 @@ public final class OldSectionTable extends SectionTable
// were the new ones, we sometimes "need" more data than we have. // were the new ones, we sometimes "need" more data than we have.
// As a workaround, have a few extra 0 bytes on the end! // As a workaround, have a few extra 0 bytes on the end!
byte[] buf = IOUtils.safelyAllocate(sepxSize+2, Short.MAX_VALUE+2); byte[] buf = IOUtils.safelyAllocate(sepxSize+2, Short.MAX_VALUE+2);
fileOffset += LittleEndian.SHORT_SIZE; fileOffset += LittleEndianConsts.SHORT_SIZE;
System.arraycopy(documentStream, fileOffset, buf, 0, buf.length); System.arraycopy(documentStream, fileOffset, buf, 0, buf.length);
sepx = new SEPX(sed, startAt, endAt, buf); sepx = new SEPX(sed, startAt, endAt, buf);
} }

View File

@ -25,6 +25,7 @@ import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
@Internal @Internal
public final class ParagraphHeight implements Duplicatable { public final class ParagraphHeight implements Duplicatable {
@ -50,11 +51,11 @@ public final class ParagraphHeight implements Duplicatable {
public ParagraphHeight(byte[] buf, int offset) { public ParagraphHeight(byte[] buf, int offset) {
infoField = LittleEndian.getShort(buf, offset); infoField = LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
reserved = LittleEndian.getShort(buf, offset); reserved = LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
dxaCol = LittleEndian.getInt(buf, offset); dxaCol = LittleEndian.getInt(buf, offset);
offset += LittleEndian.INT_SIZE; offset += LittleEndianConsts.INT_SIZE;
dymLineOrHeight = LittleEndian.getInt(buf, offset); dymLineOrHeight = LittleEndian.getInt(buf, offset);
} }
@ -69,11 +70,11 @@ public final class ParagraphHeight implements Duplicatable {
byte[] buf = new byte[12]; byte[] buf = new byte[12];
int offset = 0; int offset = 0;
LittleEndian.putShort(buf, offset, infoField); LittleEndian.putShort(buf, offset, infoField);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
LittleEndian.putShort(buf, offset, reserved); LittleEndian.putShort(buf, offset, reserved);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
LittleEndian.putInt(buf, offset, dxaCol); LittleEndian.putInt(buf, offset, dxaCol);
offset += LittleEndian.INT_SIZE; offset += LittleEndianConsts.INT_SIZE;
LittleEndian.putInt(buf, offset, dymLineOrHeight); LittleEndian.putInt(buf, offset, dymLineOrHeight);
return buf; return buf;

View File

@ -23,6 +23,7 @@ import java.util.Objects;
import org.apache.poi.common.Duplicatable; import org.apache.poi.common.Duplicatable;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.StringUtil; import org.apache.poi.util.StringUtil;
@Internal @Internal
@ -54,9 +55,9 @@ public final class PieceDescriptor implements Duplicatable {
*/ */
public PieceDescriptor(byte[] buf, int offset, Charset charset) { public PieceDescriptor(byte[] buf, int offset, Charset charset) {
descriptor = LittleEndian.getShort(buf, offset); descriptor = LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
fc = LittleEndian.getInt(buf, offset); fc = LittleEndian.getInt(buf, offset);
offset += LittleEndian.INT_SIZE; offset += LittleEndianConsts.INT_SIZE;
prm = new PropertyModifier(LittleEndian.getShort(buf, offset)); prm = new PropertyModifier(LittleEndian.getShort(buf, offset));
if (charset == null) { if (charset == null) {
// see if this piece uses unicode. // see if this piece uses unicode.
@ -125,9 +126,9 @@ public final class PieceDescriptor implements Duplicatable {
int offset = 0; int offset = 0;
byte[] buf = new byte[8]; byte[] buf = new byte[8];
LittleEndian.putShort(buf, offset, descriptor); LittleEndian.putShort(buf, offset, descriptor);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
LittleEndian.putInt(buf, offset, tempFc); LittleEndian.putInt(buf, offset, tempFc);
offset += LittleEndian.INT_SIZE; offset += LittleEndianConsts.INT_SIZE;
LittleEndian.putShort(buf, offset, prm.getValue()); LittleEndian.putShort(buf, offset, prm.getValue());
return buf; return buf;

View File

@ -23,6 +23,7 @@ import java.util.List;
import org.apache.poi.util.IOUtils; import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
/** /**
* Plex of CPs stored in File (PLCF) * Plex of CPs stored in File (PLCF)
@ -100,7 +101,7 @@ public final class PlexOfCps {
public byte[] toByteArray() { public byte[] toByteArray() {
int size = _props.size(); int size = _props.size();
int cpBufSize = ((size + 1) * LittleEndian.INT_SIZE); int cpBufSize = ((size + 1) * LittleEndianConsts.INT_SIZE);
int structBufSize = +(_cbStruct * size); int structBufSize = +(_cbStruct * size);
int bufSize = cpBufSize + structBufSize; int bufSize = cpBufSize + structBufSize;
@ -112,13 +113,13 @@ public final class PlexOfCps {
nodeEnd = node.getEnd(); nodeEnd = node.getEnd();
// put the starting offset of the property into the plcf. // put the starting offset of the property into the plcf.
LittleEndian.putInt(buf, (LittleEndian.INT_SIZE * x), node.getStart()); LittleEndian.putInt(buf, (LittleEndianConsts.INT_SIZE * x), node.getStart());
// put the struct into the plcf // put the struct into the plcf
System.arraycopy(node.getBytes(), 0, buf, cpBufSize + (x * _cbStruct), _cbStruct); System.arraycopy(node.getBytes(), 0, buf, cpBufSize + (x * _cbStruct), _cbStruct);
} }
// put the ending offset of the last property into the plcf. // put the ending offset of the last property into the plcf.
LittleEndian.putInt(buf, LittleEndian.INT_SIZE * size, nodeEnd); LittleEndian.putInt(buf, LittleEndianConsts.INT_SIZE * size, nodeEnd);
return buf; return buf;
} }

View File

@ -24,6 +24,7 @@ import java.util.Arrays;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
@ -65,7 +66,7 @@ public class PlfLfo
* [MS-DOC] -- v20110315 Word (.doc) Binary File Format * [MS-DOC] -- v20110315 Word (.doc) Binary File Format
*/ */
long lfoMacLong = LittleEndian.getUInt( tableStream, offset ); long lfoMacLong = LittleEndian.getUInt( tableStream, offset );
offset += LittleEndian.INT_SIZE; offset += LittleEndianConsts.INT_SIZE;
if ( lfoMacLong > Integer.MAX_VALUE ) if ( lfoMacLong > Integer.MAX_VALUE )
{ {

View File

@ -20,6 +20,7 @@ package org.apache.poi.hwpf.model;
import org.apache.poi.common.Duplicatable; import org.apache.poi.common.Duplicatable;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
/** /**
* Section Descriptor (SED) * Section Descriptor (SED)
@ -64,11 +65,11 @@ public final class SectionDescriptor implements Duplicatable {
public SectionDescriptor(byte[] buf, int offset) public SectionDescriptor(byte[] buf, int offset)
{ {
fn = LittleEndian.getShort(buf, offset); fn = LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
fcSepx = LittleEndian.getInt(buf, offset); fcSepx = LittleEndian.getInt(buf, offset);
offset += LittleEndian.INT_SIZE; offset += LittleEndianConsts.INT_SIZE;
fnMpr = LittleEndian.getShort(buf, offset); fnMpr = LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
fcMpr = LittleEndian.getInt(buf, offset); fcMpr = LittleEndian.getInt(buf, offset);
} }
@ -102,11 +103,11 @@ public final class SectionDescriptor implements Duplicatable {
byte[] buf = new byte[12]; byte[] buf = new byte[12];
LittleEndian.putShort(buf, offset, fn); LittleEndian.putShort(buf, offset, fn);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
LittleEndian.putInt(buf, offset, fcSepx); LittleEndian.putInt(buf, offset, fcSepx);
offset += LittleEndian.INT_SIZE; offset += LittleEndianConsts.INT_SIZE;
LittleEndian.putShort(buf, offset, fnMpr); LittleEndian.putShort(buf, offset, fnMpr);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
LittleEndian.putInt(buf, offset, fcMpr); LittleEndian.putInt(buf, offset, fcMpr);
return buf; return buf;

View File

@ -26,6 +26,7 @@ import org.apache.poi.hwpf.model.io.HWPFFileSystem;
import org.apache.poi.util.IOUtils; import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
@ -81,7 +82,7 @@ public class SectionTable
// The first short at the offset is the size of the grpprl. // The first short at the offset is the size of the grpprl.
int sepxSize = LittleEndian.getShort(documentStream, fileOffset); int sepxSize = LittleEndian.getShort(documentStream, fileOffset);
byte[] buf = IOUtils.safelyAllocate(sepxSize, MAX_RECORD_LENGTH); byte[] buf = IOUtils.safelyAllocate(sepxSize, MAX_RECORD_LENGTH);
fileOffset += LittleEndian.SHORT_SIZE; fileOffset += LittleEndianConsts.SHORT_SIZE;
System.arraycopy(documentStream, fileOffset, buf, 0, buf.length); System.arraycopy(documentStream, fileOffset, buf, 0, buf.length);
_sections.add(new SEPX(sed, startAt, endAt, buf)); _sections.add(new SEPX(sed, startAt, endAt, buf));
} }

View File

@ -19,6 +19,7 @@ package org.apache.poi.hwpf.model;
import java.util.Arrays; import java.util.Arrays;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
import org.apache.poi.util.StringUtil; import org.apache.poi.util.StringUtil;
@ -76,7 +77,7 @@ public class Sttb
public void fillFields( byte[] buffer, int startOffset ) public void fillFields( byte[] buffer, int startOffset )
{ {
short ffff = LittleEndian.getShort( buffer, startOffset ); short ffff = LittleEndian.getShort( buffer, startOffset );
int offset = startOffset + LittleEndian.SHORT_SIZE; int offset = startOffset + LittleEndianConsts.SHORT_SIZE;
if ( ffff != (short) 0xffff ) if ( ffff != (short) 0xffff )
{ {
@ -137,20 +138,20 @@ public class Sttb
public int getSize() public int getSize()
{ {
// ffff // ffff
int size = LittleEndian.SHORT_SIZE; int size = LittleEndianConsts.SHORT_SIZE;
// cData // cData
size += _cDataLength; size += _cDataLength;
// cbExtra // cbExtra
size += LittleEndian.SHORT_SIZE; size += LittleEndianConsts.SHORT_SIZE;
if ( this._fExtend ) if ( this._fExtend )
{ {
for ( String data : _data ) for ( String data : _data )
{ {
// cchData // cchData
size += LittleEndian.SHORT_SIZE; size += LittleEndianConsts.SHORT_SIZE;
// data // data
size += 2 * data.length(); size += 2 * data.length();
} }
@ -160,9 +161,9 @@ public class Sttb
for ( String data : _data ) for ( String data : _data )
{ {
// cchData // cchData
size += LittleEndian.BYTE_SIZE; size += LittleEndianConsts.BYTE_SIZE;
// data // data
size += 1 * data.length(); size += data.length();
} }
} }
@ -200,13 +201,13 @@ public class Sttb
{ {
LittleEndian.putInt( buffer, 2, _data.length ); LittleEndian.putInt( buffer, 2, _data.length );
LittleEndian.putUShort( buffer, 6, _cbExtra ); LittleEndian.putUShort( buffer, 6, _cbExtra );
offset = 2 + LittleEndian.INT_SIZE + LittleEndian.SHORT_SIZE; offset = 2 + LittleEndianConsts.INT_SIZE + LittleEndianConsts.SHORT_SIZE;
} }
else else
{ {
LittleEndian.putUShort( buffer, 2, _data.length ); LittleEndian.putUShort( buffer, 2, _data.length );
LittleEndian.putUShort( buffer, 4, _cbExtra ); LittleEndian.putUShort( buffer, 4, _cbExtra );
offset = 2 + LittleEndian.SHORT_SIZE + LittleEndian.SHORT_SIZE; offset = 2 + LittleEndianConsts.SHORT_SIZE + LittleEndianConsts.SHORT_SIZE;
} }
for ( int i = 0; i < _data.length; i++ ) for ( int i = 0; i < _data.length; i++ )
@ -224,7 +225,7 @@ public class Sttb
if ( _fExtend ) if ( _fExtend )
{ {
LittleEndian.putUShort( buffer, offset, entry.length() ); LittleEndian.putUShort( buffer, offset, entry.length() );
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
StringUtil.putUnicodeLE( entry, buffer, offset ); StringUtil.putUnicodeLE( entry, buffer, offset );
offset += 2 * entry.length(); offset += 2 * entry.length();

View File

@ -24,6 +24,7 @@ import org.apache.poi.hwpf.usermodel.ParagraphProperties;
import org.apache.poi.util.IOUtils; import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
import org.apache.poi.util.StringUtil; import org.apache.poi.util.StringUtil;
@ -91,7 +92,7 @@ public final class StyleDescription {
if (word9) { if (word9) {
nameLength = LittleEndian.getShort(std, nameStart); nameLength = LittleEndian.getShort(std, nameStart);
multiplier = 2; multiplier = 2;
nameStart += LittleEndian.SHORT_SIZE; nameStart += LittleEndianConsts.SHORT_SIZE;
} else { } else {
nameLength = std[nameStart]; nameLength = std[nameStart];
} }
@ -107,7 +108,7 @@ public final class StyleDescription {
_upxs = new UPX[countOfUPX]; _upxs = new UPX[countOfUPX];
for (int x = 0; x < countOfUPX; x++) { for (int x = 0; x < countOfUPX; x++) {
int upxSize = LittleEndian.getShort(std, varOffset); int upxSize = LittleEndian.getShort(std, varOffset);
varOffset += LittleEndian.SHORT_SIZE; varOffset += LittleEndianConsts.SHORT_SIZE;
byte[] upx = IOUtils.safelyAllocate(upxSize, Short.MAX_VALUE); byte[] upx = IOUtils.safelyAllocate(upxSize, Short.MAX_VALUE);
System.arraycopy(std, varOffset, upx, 0, upxSize); System.arraycopy(std, varOffset, upx, 0, upxSize);
@ -199,18 +200,18 @@ public final class StyleDescription {
char[] letters = _name.toCharArray(); char[] letters = _name.toCharArray();
LittleEndian.putShort(buf, _baseLength, (short) letters.length); LittleEndian.putShort(buf, _baseLength, (short) letters.length);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
for (int x = 0; x < letters.length; x++) { for (int x = 0; x < letters.length; x++) {
LittleEndian.putShort(buf, offset, (short) letters[x]); LittleEndian.putShort(buf, offset, (short) letters[x]);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
} }
// get past the null delimiter for the name. // get past the null delimiter for the name.
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
for (int x = 0; x < _upxs.length; x++) { for (int x = 0; x < _upxs.length; x++) {
short upxSize = (short) _upxs[x].size(); short upxSize = (short) _upxs[x].size();
LittleEndian.putShort(buf, offset, upxSize); LittleEndian.putShort(buf, offset, upxSize);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
System.arraycopy(_upxs[x].getUPX(), 0, buf, offset, upxSize); System.arraycopy(_upxs[x].getUPX(), 0, buf, offset, upxSize);
offset += upxSize + (upxSize % 2); offset += upxSize + (upxSize % 2);
} }

View File

@ -26,6 +26,7 @@ import org.apache.poi.hwpf.usermodel.CharacterProperties;
import org.apache.poi.hwpf.usermodel.ParagraphProperties; import org.apache.poi.hwpf.usermodel.ParagraphProperties;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
/** /**
* Represents a document's stylesheet. A word documents formatting is stored as * Represents a document's stylesheet. A word documents formatting is stored as
@ -77,7 +78,7 @@ public final class StyleSheet {
public StyleSheet(byte[] tableStream, int offset) { public StyleSheet(byte[] tableStream, int offset) {
int startOffset = offset; int startOffset = offset;
_cbStshi = LittleEndian.getShort(tableStream, offset); _cbStshi = LittleEndian.getShort(tableStream, offset);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
/* /*
* Count of styles in stylesheet * Count of styles in stylesheet
@ -92,7 +93,7 @@ public final class StyleSheet {
// shall we discard cbLSD and mpstilsd? // shall we discard cbLSD and mpstilsd?
offset = startOffset + LittleEndian.SHORT_SIZE + _cbStshi; offset = startOffset + LittleEndianConsts.SHORT_SIZE + _cbStshi;
_styleDescriptions = new StyleDescription[_stshif.getCstd()]; _styleDescriptions = new StyleDescription[_stshif.getCstd()];
for (int x = 0; x < _stshif.getCstd(); x++) { for (int x = 0; x < _stshif.getCstd(); x++) {
int stdSize = LittleEndian.getShort(tableStream, offset); int stdSize = LittleEndian.getShort(tableStream, offset);
@ -134,7 +135,7 @@ public final class StyleSheet {
byte[] buf = new byte[_cbStshi + 2]; byte[] buf = new byte[_cbStshi + 2];
LittleEndian.putUShort(buf, offset, (short) _cbStshi); LittleEndian.putUShort(buf, offset, (short) _cbStshi);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
_stshif.setCstd(_styleDescriptions.length); _stshif.setCstd(_styleDescriptions.length);
_stshif.serialize(buf, offset); _stshif.serialize(buf, offset);

View File

@ -21,6 +21,7 @@ package org.apache.poi.hwpf.model;
import java.util.Arrays; import java.util.Arrays;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
/** /**
* The Xst structure is a string. The string is prepended by its length and is * The Xst structure is a string. The string is prepended by its length and is
@ -56,13 +57,13 @@ public class Xst
int offset = startOffset; int offset = startOffset;
_cch = LittleEndian.getUShort( data, offset ); _cch = LittleEndian.getUShort( data, offset );
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
_rgtchar = new char[_cch]; _rgtchar = new char[_cch];
for ( int x = 0; x < _cch; x++ ) for ( int x = 0; x < _cch; x++ )
{ {
_rgtchar[x] = (char) LittleEndian.getShort( data, offset ); _rgtchar[x] = (char) LittleEndian.getShort( data, offset );
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
} }
} }
@ -114,7 +115,7 @@ public class Xst
public int getSize() public int getSize()
{ {
return LittleEndian.SHORT_SIZE + _rgtchar.length * 2; return LittleEndianConsts.SHORT_SIZE + _rgtchar.length * 2;
} }
@Override @Override
@ -127,12 +128,12 @@ public class Xst
int offset = startOffset; int offset = startOffset;
LittleEndian.putUShort( data, offset, _cch ); LittleEndian.putUShort( data, offset, _cch );
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
for ( char c : _rgtchar ) for ( char c : _rgtchar )
{ {
LittleEndian.putShort( data, offset, (short) c ); LittleEndian.putShort( data, offset, (short) c );
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
} }
} }

View File

@ -18,6 +18,7 @@ package org.apache.poi.hwpf.model;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
@ -63,7 +64,7 @@ public class Xstz
public int getSize() public int getSize()
{ {
return _xst.getSize() + LittleEndian.SHORT_SIZE; return _xst.getSize() + LittleEndianConsts.SHORT_SIZE;
} }
public int serialize( byte[] data, int startOffset ) public int serialize( byte[] data, int startOffset )
@ -74,7 +75,7 @@ public class Xstz
offset += _xst.getSize(); offset += _xst.getSize();
LittleEndian.putUShort( data, offset, _chTerm ); LittleEndian.putUShort( data, offset, _chTerm );
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
return offset - startOffset; return offset - startOffset;
} }

View File

@ -33,6 +33,7 @@ import org.apache.poi.hwpf.usermodel.ShadingDescriptor;
import org.apache.poi.hwpf.usermodel.ShadingDescriptor80; import org.apache.poi.hwpf.usermodel.ShadingDescriptor80;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
@ -435,7 +436,7 @@ public final class ParagraphSprmUncompressor
for (int x = 0; x < delSize; x++) for (int x = 0; x < delSize; x++)
{ {
tabMap.remove(Integer.valueOf(LittleEndian.getShort(grpprl, offset))); tabMap.remove(Integer.valueOf(LittleEndian.getShort(grpprl, offset)));
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
} }
int addSize = grpprl[offset++]; int addSize = grpprl[offset++];
@ -445,7 +446,7 @@ public final class ParagraphSprmUncompressor
Integer key = Integer.valueOf(LittleEndian.getShort(grpprl, offset)); Integer key = Integer.valueOf(LittleEndian.getShort(grpprl, offset));
TabDescriptor val = new TabDescriptor( grpprl, start + ((TabDescriptor.getSize() * addSize) + x) ); TabDescriptor val = new TabDescriptor( grpprl, start + ((TabDescriptor.getSize() * addSize) + x) );
tabMap.put(key, val); tabMap.put(key, val);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
} }
tabPositions = new int[tabMap.size()]; tabPositions = new int[tabMap.size()];
@ -467,56 +468,4 @@ public final class ParagraphSprmUncompressor
pap.setRgdxaTab(tabPositions); pap.setRgdxaTab(tabPositions);
pap.setRgtbd(tabDescriptors); pap.setRgtbd(tabDescriptors);
} }
// private static void handleTabsAgain(ParagraphProperties pap, SprmOperation sprm)
// {
// byte[] grpprl = sprm.getGrpprl();
// int offset = sprm.getGrpprlOffset();
// int delSize = grpprl[offset++];
// int[] tabPositions = pap.getRgdxaTab();
// byte[] tabDescriptors = pap.getRgtbd();
//
// HashMap tabMap = new HashMap();
// for (int x = 0; x < tabPositions.length; x++)
// {
// tabMap.put(Integer.valueOf(tabPositions[x]), Byte.valueOf(tabDescriptors[x]));
// }
//
// for (int x = 0; x < delSize; x++)
// {
// tabMap.remove(Integer.valueOf(LittleEndian.getInt(grpprl, offset)));
// offset += LittleEndian.INT_SIZE;;
// }
//
// int addSize = grpprl[offset++];
// for (int x = 0; x < addSize; x++)
// {
// Integer key = Integer.valueOf(LittleEndian.getInt(grpprl, offset));
// Byte val = Byte.valueOf(grpprl[(LittleEndian.INT_SIZE * (addSize - x)) + x]);
// tabMap.put(key, val);
// offset += LittleEndian.INT_SIZE;
// }
//
// tabPositions = new int[tabMap.size()];
// tabDescriptors = new byte[tabPositions.length];
// ArrayList list = new ArrayList();
//
// Iterator keyIT = tabMap.keySet().iterator();
// while (keyIT.hasNext())
// {
// list.add(keyIT.next());
// }
// Collections.sort(list);
//
// for (int x = 0; x < tabPositions.length; x++)
// {
// Integer key = ((Integer)list.get(x));
// tabPositions[x] = key.intValue();
// tabDescriptors[x] = ((Byte)tabMap.get(key)).byteValue();
// }
//
// pap.setRgdxaTab(tabPositions);
// pap.setRgtbd(tabDescriptors);
// }
} }

View File

@ -24,6 +24,7 @@ import java.util.List;
import org.apache.poi.hwpf.usermodel.SectionProperties; import org.apache.poi.hwpf.usermodel.SectionProperties;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
@Internal @Internal
public final class SectionSprmCompressor public final class SectionSprmCompressor
@ -187,9 +188,9 @@ public final class SectionSprmCompressor
{ {
byte[] buf = new byte[7]; byte[] buf = new byte[7];
buf[0] = (byte)(newSEP.getFPropMark() ? 1 : 0); buf[0] = (byte)(newSEP.getFPropMark() ? 1 : 0);
int offset = LittleEndian.BYTE_SIZE; int offset = LittleEndianConsts.BYTE_SIZE;
LittleEndian.putShort(buf, 0, (short)newSEP.getIbstPropRMark()); LittleEndian.putShort(buf, 0, (short)newSEP.getIbstPropRMark());
offset += LittleEndian.SHORT_SIZE; offset += LittleEndianConsts.SHORT_SIZE;
newSEP.getDttmPropRMark().serialize(buf, offset); newSEP.getDttmPropRMark().serialize(buf, offset);
size += SprmUtils.addSprm((short)0xD227, -1, buf, sprmList); size += SprmUtils.addSprm((short)0xD227, -1, buf, sprmList);
} }

View File

@ -23,6 +23,7 @@ import org.apache.poi.common.Duplicatable;
import org.apache.poi.util.IOUtils; import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.Removal; import org.apache.poi.util.Removal;
@Internal @Internal
@ -62,38 +63,38 @@ public final class SprmBuffer implements Duplicatable {
} }
public void addSprm(short opcode, byte operand) { public void addSprm(short opcode, byte operand) {
int addition = LittleEndian.SHORT_SIZE + LittleEndian.BYTE_SIZE; int addition = LittleEndianConsts.SHORT_SIZE + LittleEndianConsts.BYTE_SIZE;
ensureCapacity(addition); ensureCapacity(addition);
LittleEndian.putShort(_buf, _offset, opcode); LittleEndian.putShort(_buf, _offset, opcode);
_offset += LittleEndian.SHORT_SIZE; _offset += LittleEndianConsts.SHORT_SIZE;
_buf[_offset++] = operand; _buf[_offset++] = operand;
} }
public void addSprm(short opcode, byte[] operand) { public void addSprm(short opcode, byte[] operand) {
int addition = LittleEndian.SHORT_SIZE + LittleEndian.BYTE_SIZE + operand.length; int addition = LittleEndianConsts.SHORT_SIZE + LittleEndianConsts.BYTE_SIZE + operand.length;
ensureCapacity(addition); ensureCapacity(addition);
LittleEndian.putShort(_buf, _offset, opcode); LittleEndian.putShort(_buf, _offset, opcode);
_offset += LittleEndian.SHORT_SIZE; _offset += LittleEndianConsts.SHORT_SIZE;
_buf[_offset++] = (byte) operand.length; _buf[_offset++] = (byte) operand.length;
System.arraycopy(operand, 0, _buf, _offset, operand.length); System.arraycopy(operand, 0, _buf, _offset, operand.length);
} }
public void addSprm(short opcode, int operand) { public void addSprm(short opcode, int operand) {
int addition = LittleEndian.SHORT_SIZE + LittleEndian.INT_SIZE; int addition = LittleEndianConsts.SHORT_SIZE + LittleEndianConsts.INT_SIZE;
ensureCapacity(addition); ensureCapacity(addition);
LittleEndian.putShort(_buf, _offset, opcode); LittleEndian.putShort(_buf, _offset, opcode);
_offset += LittleEndian.SHORT_SIZE; _offset += LittleEndianConsts.SHORT_SIZE;
LittleEndian.putInt(_buf, _offset, operand); LittleEndian.putInt(_buf, _offset, operand);
_offset += LittleEndian.INT_SIZE; _offset += LittleEndianConsts.INT_SIZE;
} }
public void addSprm(short opcode, short operand) { public void addSprm(short opcode, short operand) {
int addition = LittleEndian.SHORT_SIZE + LittleEndian.SHORT_SIZE; int addition = LittleEndianConsts.SHORT_SIZE + LittleEndianConsts.SHORT_SIZE;
ensureCapacity(addition); ensureCapacity(addition);
LittleEndian.putShort(_buf, _offset, opcode); LittleEndian.putShort(_buf, _offset, opcode);
_offset += LittleEndian.SHORT_SIZE; _offset += LittleEndianConsts.SHORT_SIZE;
LittleEndian.putShort(_buf, _offset, operand); LittleEndian.putShort(_buf, _offset, operand);
_offset += LittleEndian.SHORT_SIZE; _offset += LittleEndianConsts.SHORT_SIZE;
} }
public void append(byte[] grpprl) { public void append(byte[] grpprl) {

View File

@ -21,6 +21,7 @@ import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
/** /**
* This class is used to represent a sprm operation from a Word 97/2000/XP * This class is used to represent a sprm operation from a Word 97/2000/XP
@ -107,7 +108,7 @@ public final class SprmOperation
byte operandLength = _grpprl[_gOffset + 1]; byte operandLength = _grpprl[_gOffset + 1];
// initialized to zeros by JVM // initialized to zeros by JVM
byte[] codeBytes = new byte[LittleEndian.INT_SIZE]; byte[] codeBytes = new byte[LittleEndianConsts.INT_SIZE];
for ( int i = 0; i < operandLength; i++ ) for ( int i = 0; i < operandLength; i++ )
if ( _gOffset + i < _grpprl.length ) if ( _gOffset + i < _grpprl.length )
codeBytes[i] = _grpprl[_gOffset + 1 + i]; codeBytes[i] = _grpprl[_gOffset + 1 + i];

View File

@ -22,6 +22,7 @@ import java.util.List;
import org.apache.poi.util.IOUtils; import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
@Internal @Internal
@ -37,11 +38,11 @@ public final class SprmUtils
public static byte[] shortArrayToByteArray(short[] convert) public static byte[] shortArrayToByteArray(short[] convert)
{ {
byte[] buf = IOUtils.safelyAllocate(convert.length * (long)LittleEndian.SHORT_SIZE, MAX_RECORD_LENGTH); byte[] buf = IOUtils.safelyAllocate(convert.length * (long)LittleEndianConsts.SHORT_SIZE, MAX_RECORD_LENGTH);
for (int x = 0; x < convert.length; x++) for (int x = 0; x < convert.length; x++)
{ {
LittleEndian.putShort(buf, x * LittleEndian.SHORT_SIZE, convert[x]); LittleEndian.putShort(buf, x * LittleEndianConsts.SHORT_SIZE, convert[x]);
} }
return buf; return buf;
@ -130,7 +131,7 @@ public final class SprmUtils
{ {
byte[] buf = new byte[4]; byte[] buf = new byte[4];
LittleEndian.putShort(buf, 0, brc[0]); LittleEndian.putShort(buf, 0, brc[0]);
LittleEndian.putShort(buf, LittleEndian.SHORT_SIZE, brc[1]); LittleEndian.putShort(buf, LittleEndianConsts.SHORT_SIZE, brc[1]);
return LittleEndian.getInt(buf); return LittleEndian.getInt(buf);
} }
} }

View File

@ -28,6 +28,7 @@ import org.apache.poi.hwpf.usermodel.TableProperties;
import org.apache.poi.util.IOUtils; import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
@Internal @Internal
public final class TableSprmCompressor public final class TableSprmCompressor
@ -82,7 +83,7 @@ public final class TableSprmCompressor
int itcMac = newTAP.getItcMac(); int itcMac = newTAP.getItcMac();
byte[] buf = IOUtils.safelyAllocate( byte[] buf = IOUtils.safelyAllocate(
1 1
+ (LittleEndian.SHORT_SIZE*((long)itcMac + 1)) + (LittleEndianConsts.SHORT_SIZE*((long)itcMac + 1))
+ (TableCellDescriptor.SIZE*(long)itcMac), + (TableCellDescriptor.SIZE*(long)itcMac),
MAX_RECORD_LENGTH); MAX_RECORD_LENGTH);
buf[0] = (byte)itcMac; buf[0] = (byte)itcMac;
@ -90,7 +91,7 @@ public final class TableSprmCompressor
short[] dxaCenters = newTAP.getRgdxaCenter(); short[] dxaCenters = newTAP.getRgdxaCenter();
for (int x = 0; x < dxaCenters.length; x++) for (int x = 0; x < dxaCenters.length; x++)
{ {
LittleEndian.putShort(buf, 1 + (x * LittleEndian.SHORT_SIZE), LittleEndian.putShort(buf, 1 + (x * LittleEndianConsts.SHORT_SIZE),
dxaCenters[x]); dxaCenters[x]);
} }
@ -98,7 +99,7 @@ public final class TableSprmCompressor
for (int x = 0; x < cellDescriptors.length; x++) for (int x = 0; x < cellDescriptors.length; x++)
{ {
cellDescriptors[x].serialize(buf, cellDescriptors[x].serialize(buf,
1+((itcMac+1)*LittleEndian.SHORT_SIZE)+(x*TableCellDescriptor.SIZE)); 1+((itcMac+1)* LittleEndianConsts.SHORT_SIZE)+(x*TableCellDescriptor.SIZE));
} }
size += SprmUtils.addSpecialSprm((short)0xD608, buf, sprmList); size += SprmUtils.addSpecialSprm((short)0xD608, buf, sprmList);

View File

@ -21,6 +21,7 @@ import org.apache.poi.common.Duplicatable;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.Removal; import org.apache.poi.util.Removal;
/** /**
@ -52,13 +53,13 @@ public final class BorderCode implements Duplicatable {
public BorderCode(byte[] buf, int offset) public BorderCode(byte[] buf, int offset)
{ {
_info = LittleEndian.getShort(buf, offset); _info = LittleEndian.getShort(buf, offset);
_info2 = LittleEndian.getShort(buf, offset + LittleEndian.SHORT_SIZE); _info2 = LittleEndian.getShort(buf, offset + LittleEndianConsts.SHORT_SIZE);
} }
public void serialize(byte[] buf, int offset) public void serialize(byte[] buf, int offset)
{ {
LittleEndian.putShort(buf, offset, _info); LittleEndian.putShort(buf, offset, _info);
LittleEndian.putShort(buf, offset + LittleEndian.SHORT_SIZE, _info2); LittleEndian.putShort(buf, offset + LittleEndianConsts.SHORT_SIZE, _info2);
} }
public int toInt() public int toInt()

View File

@ -23,6 +23,7 @@ import org.apache.poi.common.Duplicatable;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.LocaleUtil; import org.apache.poi.util.LocaleUtil;
import org.apache.poi.util.Removal; import org.apache.poi.util.Removal;
@ -50,7 +51,7 @@ public final class DateAndTime implements Duplicatable {
public DateAndTime(byte[] buf, int offset) { public DateAndTime(byte[] buf, int offset) {
_info = LittleEndian.getShort(buf, offset); _info = LittleEndian.getShort(buf, offset);
_info2 = LittleEndian.getShort(buf, offset + LittleEndian.SHORT_SIZE); _info2 = LittleEndian.getShort(buf, offset + LittleEndianConsts.SHORT_SIZE);
} }
public Calendar getDate() { public Calendar getDate() {
@ -68,7 +69,7 @@ public final class DateAndTime implements Duplicatable {
public void serialize(byte[] buf, int offset) public void serialize(byte[] buf, int offset)
{ {
LittleEndian.putShort(buf, offset, _info); LittleEndian.putShort(buf, offset, _info);
LittleEndian.putShort(buf, offset + LittleEndian.SHORT_SIZE, _info2); LittleEndian.putShort(buf, offset + LittleEndianConsts.SHORT_SIZE, _info2);
} }
@Override @Override

View File

@ -19,6 +19,7 @@ package org.apache.poi.hwpf.usermodel;
import org.apache.poi.common.Duplicatable; import org.apache.poi.common.Duplicatable;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.Removal; import org.apache.poi.util.Removal;
/** /**
@ -41,7 +42,7 @@ public final class LineSpacingDescriptor implements Duplicatable {
public LineSpacingDescriptor(byte[] buf, int offset) { public LineSpacingDescriptor(byte[] buf, int offset) {
_dyaLine = LittleEndian.getShort(buf, offset); _dyaLine = LittleEndian.getShort(buf, offset);
_fMultiLinespace = LittleEndian.getShort(buf, offset + LittleEndian.SHORT_SIZE); _fMultiLinespace = LittleEndian.getShort(buf, offset + LittleEndianConsts.SHORT_SIZE);
} }
@Override @Override
@ -72,7 +73,7 @@ public final class LineSpacingDescriptor implements Duplicatable {
public void serialize(byte[] buf, int offset) public void serialize(byte[] buf, int offset)
{ {
LittleEndian.putShort(buf, offset, _dyaLine); LittleEndian.putShort(buf, offset, _dyaLine);
LittleEndian.putShort(buf, offset + LittleEndian.SHORT_SIZE, _fMultiLinespace); LittleEndian.putShort(buf, offset + LittleEndianConsts.SHORT_SIZE, _fMultiLinespace);
} }
public void setDyaLine(short dyaLine) public void setDyaLine(short dyaLine)

View File

@ -36,6 +36,7 @@ import org.apache.poi.hwpf.sprm.SprmBuffer;
import org.apache.poi.util.DocumentFormatException; import org.apache.poi.util.DocumentFormatException;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
@ -471,9 +472,9 @@ public class Range {
CharacterProperties baseChp = ss.getCharacterStyle(styleIndex); CharacterProperties baseChp = ss.getCharacterStyle(styleIndex);
byte[] grpprl = ParagraphSprmCompressor.compressParagraphProperty(props, baseStyle); byte[] grpprl = ParagraphSprmCompressor.compressParagraphProperty(props, baseStyle);
byte[] withIndex = new byte[grpprl.length + LittleEndian.SHORT_SIZE]; byte[] withIndex = new byte[grpprl.length + LittleEndianConsts.SHORT_SIZE];
LittleEndian.putShort(withIndex, 0, (short) styleIndex); LittleEndian.putShort(withIndex, 0, (short) styleIndex);
System.arraycopy(grpprl, 0, withIndex, LittleEndian.SHORT_SIZE, grpprl.length); System.arraycopy(grpprl, 0, withIndex, LittleEndianConsts.SHORT_SIZE, grpprl.length);
SprmBuffer buf = new SprmBuffer(withIndex, 2); SprmBuffer buf = new SprmBuffer(withIndex, 2);
_doc.getParagraphTable().insert(_parStart, _start, buf); _doc.getParagraphTable().insert(_parStart, _start, buf);
@ -522,9 +523,9 @@ public class Range {
CharacterProperties baseChp = ss.getCharacterStyle(styleIndex); CharacterProperties baseChp = ss.getCharacterStyle(styleIndex);
byte[] grpprl = ParagraphSprmCompressor.compressParagraphProperty(props, baseStyle); byte[] grpprl = ParagraphSprmCompressor.compressParagraphProperty(props, baseStyle);
byte[] withIndex = new byte[grpprl.length + LittleEndian.SHORT_SIZE]; byte[] withIndex = new byte[grpprl.length + LittleEndianConsts.SHORT_SIZE];
LittleEndian.putShort(withIndex, 0, (short) styleIndex); LittleEndian.putShort(withIndex, 0, (short) styleIndex);
System.arraycopy(grpprl, 0, withIndex, LittleEndian.SHORT_SIZE, grpprl.length); System.arraycopy(grpprl, 0, withIndex, LittleEndianConsts.SHORT_SIZE, grpprl.length);
SprmBuffer buf = new SprmBuffer(withIndex, 2); SprmBuffer buf = new SprmBuffer(withIndex, 2);
_doc.getParagraphTable().insert(_parEnd, _end, buf); _doc.getParagraphTable().insert(_parEnd, _end, buf);