Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java Thu Apr 16 22:11:16 2020 @@ -21,6 +21,7 @@ import java.awt.Dimension; import java.io.IOException; import java.io.OutputStream; import java.security.MessageDigest; +import java.util.Arrays; import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; @@ -129,9 +130,7 @@ public abstract class HSLFPictureData im * Returns 16-byte checksum of this picture */ public byte[] getUID(){ - byte[] uid = new byte[16]; - System.arraycopy(rawdata, 0, uid, 0, uid.length); - return uid; + return Arrays.copyOf(rawdata, 16); } @Override
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java Thu Apr 16 22:11:16 2020 @@ -301,7 +301,7 @@ public final class HSLFSlideShowImpl ext // check for corrupted user edit atom and try to repair it // if the next user edit atom offset is already known, we would go into an endless loop if (usrOffset > 0 && recordMap.containsKey(usrOffset)) { - // a user edit atom is usually located 36 byte before the smallest known record offset + // a user edit atom is usually located 36 byte before the smallest known record offset usrOffset = recordMap.firstKey() - 36; // check that we really are located on a user edit atom int ver_inst = LittleEndian.getUShort(docstream, usrOffset); @@ -415,8 +415,7 @@ public final class HSLFSlideShowImpl ext pict.setSignature(signature); // Copy the data, ready to pass to PictureData - byte[] imgdata = IOUtils.safelyAllocate(imgsize, MAX_RECORD_LENGTH); - System.arraycopy(pictstream, pos, imgdata, 0, imgdata.length); + byte[] imgdata = IOUtils.safelyClone(pictstream, pos, imgsize, MAX_RECORD_LENGTH); pict.setRawData(imgdata); pict.setOffset(offset); @@ -563,7 +562,7 @@ public final class HSLFSlideShowImpl ext validateInPlaceWritePossible(); // Write the PowerPoint streams to the current FileSystem - // No need to do anything to other streams, already there! + // No need to do anything to other streams, already there! write(getDirectory().getFileSystem(), false); // Sync with the File on disk @@ -649,7 +648,7 @@ public final class HSLFSlideShowImpl ext } private void write(POIFSFileSystem outFS, boolean copyAllOtherNodes) throws IOException { - // read properties and pictures, with old encryption settings where appropriate + // read properties and pictures, with old encryption settings where appropriate if (_pictures == null) { readPictures(); } @@ -673,8 +672,7 @@ public final class HSLFSlideShowImpl ext updateAndWriteDependantRecords(baos, null); // Update our cached copy of the bytes that make up the PPT stream - _docstream = new byte[baos.size()]; - System.arraycopy(baos.getBuf(), 0, _docstream, 0, baos.size()); + _docstream = baos.toByteArray(); baos.close(); // Write the PPT stream into the POIFS layer @@ -701,7 +699,7 @@ public final class HSLFSlideShowImpl ext } } - + // If requested, copy over any other streams we spot, eg Macros if (copyAllOtherNodes) { EntryUtils.copyNodes(getDirectory().getFileSystem(), outFS, writtenEntries); @@ -715,9 +713,9 @@ public final class HSLFSlideShowImpl ext return (dea != null) ? dea.getEncryptionInfo() : null; } - - - + + + /* ******************* adding methods follow ********************* */ /** Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java Thu Apr 16 22:11:16 2020 @@ -22,6 +22,7 @@ import static org.apache.poi.hslf.record import java.awt.Color; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.function.Consumer; @@ -333,8 +334,7 @@ public final class HSLFTextParagraph imp } } - org.apache.poi.hslf.record.Record[] result = new org.apache.poi.hslf.record.Record[length]; - System.arraycopy(records, startIdx[0], result, 0, length); + org.apache.poi.hslf.record.Record[] result = Arrays.copyOfRange(records, startIdx[0], startIdx[0]+length, org.apache.poi.hslf.record.Record[].class); startIdx[0] += length; return result; Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlUtils.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlUtils.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlUtils.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlUtils.java Thu Apr 16 22:11:16 2020 @@ -39,7 +39,7 @@ public class ExcelToHtmlUtils extends Ab * Creates a map (i.e. two-dimensional array) filled with ranges. Allow fast * retrieving {@link CellRangeAddress} of any cell, if cell is contained in * range. - * + * * @see #getMergedRange(CellRangeAddress[][], int, int) */ public static CellRangeAddress[][] buildMergedRangesMap( Sheet sheet ) { @@ -47,10 +47,7 @@ public class ExcelToHtmlUtils extends Ab for ( final CellRangeAddress cellRangeAddress : sheet.getMergedRegions() ) { final int requiredHeight = cellRangeAddress.getLastRow() + 1; if ( mergedRanges.length < requiredHeight ) { - CellRangeAddress[][] newArray = new CellRangeAddress[requiredHeight][]; - System.arraycopy( mergedRanges, 0, newArray, 0, - mergedRanges.length ); - mergedRanges = newArray; + mergedRanges = Arrays.copyOf(mergedRanges, requiredHeight, CellRangeAddress[][].class); } for ( int r = cellRangeAddress.getFirstRow(); r <= cellRangeAddress @@ -63,14 +60,9 @@ public class ExcelToHtmlUtils extends Ab mergedRanges[r] = rowMerged; } else { final int rowMergedLength = rowMerged.length; - if ( rowMergedLength < requiredWidth ) - { - final CellRangeAddress[] newRow = new CellRangeAddress[requiredWidth]; - System.arraycopy( rowMerged, 0, newRow, 0, - rowMergedLength ); - - mergedRanges[r] = newRow; - rowMerged = newRow; + if ( rowMergedLength < requiredWidth ) { + rowMerged = mergedRanges[r] = + Arrays.copyOf(rowMerged, requiredWidth, CellRangeAddress[].class); } } Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfText.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfText.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfText.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfText.java Thu Apr 16 22:11:16 2020 @@ -225,9 +225,7 @@ public class HwmfText { * This does not include the extra optional padding on the byte array. */ private byte[] getTextBytes() { - byte[] ret = IOUtils.safelyAllocate(stringLength, MAX_RECORD_LENGTH); - System.arraycopy(rawTextBytes, 0, ret, 0, stringLength); - return ret; + return IOUtils.safelyClone(rawTextBytes, 0, stringLength, MAX_RECORD_LENGTH); } @Override Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFOldDocument.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFOldDocument.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFOldDocument.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFOldDocument.java Thu Apr 16 22:11:16 2020 @@ -60,12 +60,12 @@ public class HWPFOldDocument extends HWP private final static Charset DEFAULT_CHARSET = StringUtil.WIN_1252; private OldTextPieceTable tpt; - + private StringBuilder _text; private final OldFontTable fontTable; private final Charset guessedCharset; - + public HWPFOldDocument(POIFSFileSystem fs) throws IOException { this(fs.getRoot()); } @@ -73,7 +73,7 @@ public class HWPFOldDocument extends HWP public HWPFOldDocument(DirectoryNode directory) throws IOException { super(directory); - + // Where are things? int sedTableOffset = LittleEndian.getInt(_mainStream, 0x88); int sedTableSize = LittleEndian.getInt(_mainStream, 0x8c); @@ -91,7 +91,7 @@ public class HWPFOldDocument extends HWP guessedCharset = guessCodePage(fontTable); int complexTableOffset = LittleEndian.getInt(_mainStream, 0x160); - + // We need to get hold of the text that makes up the // document, which might be regular or fast-saved ComplexFileTable cft = null; @@ -101,7 +101,7 @@ public class HWPFOldDocument extends HWP complexTableOffset, _fib.getFibBase().getFcMin(), guessedCharset ); tpt = (OldTextPieceTable)cft.getTextPieceTable(); - + } else { // TODO Discover if these older documents can ever hold Unicode Strings? // (We think not, because they seem to lack a Piece table) @@ -118,7 +118,7 @@ public class HWPFOldDocument extends HWP logger.log(POILogger.WARN, "Error with "+guessedCharset +". Backing off to Windows-1252"); } tpt.add(tp); - + } _text = tpt.getText(); @@ -171,19 +171,16 @@ public class HWPFOldDocument extends HWP // Generate a single Text Piece Table, with a single Text Piece // which covers all the (8 bit only) text in the file tpt = new OldTextPieceTable(); - byte[] textData = IOUtils.safelyAllocate( - _fib.getFibBase().getFcMac()-_fib.getFibBase().getFcMin(), MAX_RECORD_LENGTH); - System.arraycopy(_mainStream, _fib.getFibBase().getFcMin(), textData, 0, textData.length); + + byte[] textData = IOUtils.safelyClone(_mainStream, _fib.getFibBase().getFcMin(), + _fib.getFibBase().getFcMac()-_fib.getFibBase().getFcMin(), MAX_RECORD_LENGTH); int numChars = textData.length; if (CodePageUtil.DOUBLE_BYTE_CHARSETS.contains(guessedCharset)) { numChars /= 2; } - return new TextPiece( - 0, numChars, textData, pd - ); - + return new TextPiece(0, numChars, textData, pd); } Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java Thu Apr 16 22:11:16 2020 @@ -62,7 +62,7 @@ public final class CHPFormattedDiskPage /** * This constructs a CHPFormattedDiskPage from a raw fkp (512 byte array * read from a Word file). - * + * * @deprecated Use * {@link #CHPFormattedDiskPage(byte[], int, CharIndexTranslator)} * instead @@ -134,17 +134,13 @@ public final class CHPFormattedDiskPage int chpxOffset = 2 * LittleEndian.getUByte(_fkp, _offset + (((_crun + 1) * 4) + index)); //optimization if offset == 0 use "Normal" style - if(chpxOffset == 0) - { + if(chpxOffset == 0) { return new byte[0]; } int size = LittleEndian.getUByte(_fkp, _offset + chpxOffset); - byte[] chpx = IOUtils.safelyAllocate(size, MAX_RECORD_LENGTH); - - System.arraycopy(_fkp, _offset + ++chpxOffset, chpx, 0, size); - return chpx; + return IOUtils.safelyClone(_fkp, _offset + chpxOffset + 1, size, MAX_RECORD_LENGTH); } protected byte[] toByteArray( CharIndexTranslator translator ) @@ -184,7 +180,7 @@ public final class CHPFormattedDiskPage if (index == 0) { throw new RecordFormatException("empty grpprl entry."); } - + // see if we couldn't fit some if ( index != size ) { Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ComplexFileTable.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ComplexFileTable.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ComplexFileTable.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ComplexFileTable.java Thu Apr 16 22:11:16 2020 @@ -25,6 +25,7 @@ import java.util.List; import org.apache.poi.hwpf.model.io.HWPFFileSystem; import org.apache.poi.hwpf.sprm.SprmBuffer; +import org.apache.poi.util.IOUtils; import org.apache.poi.util.Internal; import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndianConsts; @@ -56,7 +57,7 @@ public class ComplexFileTable { offset++; int size = LittleEndian.getShort(tableStream, offset); offset += LittleEndianConsts.SHORT_SIZE; - byte[] bs = LittleEndian.getByteArray(tableStream, offset, size, MAX_RECORD_LENGTH); + byte[] bs = IOUtils.safelyClone(tableStream, offset, size, MAX_RECORD_LENGTH); offset += size; SprmBuffer sprmBuffer = new SprmBuffer(bs, false, 0); Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/DocumentProperties.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/DocumentProperties.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/DocumentProperties.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/DocumentProperties.java Thu Apr 16 22:11:16 2020 @@ -23,11 +23,10 @@ import java.io.IOException; import org.apache.poi.hwpf.model.types.DOPAbstractType; import org.apache.poi.util.IOUtils; import org.apache.poi.util.Internal; -import org.apache.poi.util.LittleEndian; /** * Comment me - * + * * @author Ryan Ackley */ @Internal @@ -54,8 +53,7 @@ public final class DocumentProperties ex final int supportedSize = DOPAbstractType.getSize(); if ( length != supportedSize ) { - this._preserved = LittleEndian.getByteArray( tableStream, offset - + supportedSize, length - supportedSize, MAX_RECORD_LENGTH ); + this._preserved = IOUtils.safelyClone( tableStream, offset + supportedSize, length - supportedSize, MAX_RECORD_LENGTH ); } else { Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FileInformationBlock.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FileInformationBlock.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FileInformationBlock.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FileInformationBlock.java Thu Apr 16 22:11:16 2020 @@ -111,7 +111,6 @@ public final class FileInformationBlock _cbRgFcLcb = LittleEndian.getUShort( mainDocument, offset ); offset += LittleEndianConsts.SHORT_SIZE; - assert offset == 154; // skip fibRgFcLcbBlob (read later at fillVariableFields) offset += _cbRgFcLcb * LittleEndianConsts.INT_SIZE * 2; @@ -125,11 +124,8 @@ public final class FileInformationBlock offset += LittleEndianConsts.SHORT_SIZE; // first short is already read as _nFibNew - final int fibRgCswNewLength = ( _cswNew - 1 ) - * LittleEndianConsts.SHORT_SIZE; - _fibRgCswNew = IOUtils.safelyAllocate(fibRgCswNewLength, MAX_RECORD_LENGTH); - LittleEndian.getByteArray( mainDocument, offset, fibRgCswNewLength, MAX_RECORD_LENGTH ); - offset += fibRgCswNewLength; + final int fibRgCswNewLength = ( _cswNew - 1 ) * LittleEndianConsts.SHORT_SIZE; + _fibRgCswNew = IOUtils.safelyClone(mainDocument, offset, fibRgCswNewLength, MAX_RECORD_LENGTH); } else { Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java Thu Apr 16 22:11:16 2020 @@ -72,9 +72,8 @@ public final class OldSectionTable exten // section properties, and we're trying to decode them as if they // were the new ones, we sometimes "need" more data than we have. // As a workaround, have a few extra 0 bytes on the end! - byte[] buf = IOUtils.safelyAllocate(sepxSize+2, Short.MAX_VALUE+2); fileOffset += LittleEndianConsts.SHORT_SIZE; - System.arraycopy(documentStream, fileOffset, buf, 0, buf.length); + byte[] buf = IOUtils.safelyClone(documentStream, fileOffset, sepxSize+2, Short.MAX_VALUE+2); sepx = new SEPX(sed, startAt, endAt, buf); } Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldTextPiece.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldTextPiece.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldTextPiece.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldTextPiece.java Thu Apr 16 22:11:16 2020 @@ -68,9 +68,7 @@ public class OldTextPiece extends TextPi @Override public byte[] getRawBytes() { - byte[] buf = new byte[rawBytes.length]; - System.arraycopy(rawBytes, 0, buf, 0, rawBytes.length); - return buf; + return rawBytes.clone(); } /** Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldTextPieceTable.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldTextPieceTable.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldTextPieceTable.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldTextPieceTable.java Thu Apr 16 22:11:16 2020 @@ -82,12 +82,10 @@ public class OldTextPieceTable extends T int textSizeBytes = textSizeChars * multiple; // Grab the data that makes up the piece - byte[] buf = IOUtils.safelyAllocate(textSizeBytes, MAX_RECORD_LENGTH); - System.arraycopy(documentStream, start, buf, 0, textSizeBytes); + byte[] buf = IOUtils.safelyClone(documentStream, start, textSizeBytes, MAX_RECORD_LENGTH); // And now build the piece - final TextPiece newTextPiece = newTextPiece(nodeStartChars, nodeEndChars, buf, - pieces[x]); + final TextPiece newTextPiece = newTextPiece(nodeStartChars, nodeEndChars, buf, pieces[x]); _textPieces.add(newTextPiece); } Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PICFAndOfficeArtData.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PICFAndOfficeArtData.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PICFAndOfficeArtData.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PICFAndOfficeArtData.java Thu Apr 16 22:11:16 2020 @@ -23,6 +23,7 @@ import org.apache.poi.ddf.DefaultEscherR import org.apache.poi.ddf.EscherContainerRecord; import org.apache.poi.ddf.EscherRecord; import org.apache.poi.hwpf.model.types.PICFAbstractType; +import org.apache.poi.util.IOUtils; import org.apache.poi.util.Internal; import org.apache.poi.util.LittleEndian; @@ -55,8 +56,7 @@ public class PICFAndOfficeArtData _cchPicName = LittleEndian.getUByte( dataStream, offset ); offset += 1; - _stPicName = LittleEndian.getByteArray( dataStream, offset, - _cchPicName, MAX_RECORD_LENGTH); + _stPicName = IOUtils.safelyClone(dataStream, offset, _cchPicName, MAX_RECORD_LENGTH); offset += _cchPicName; } Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PlexOfCps.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PlexOfCps.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PlexOfCps.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PlexOfCps.java Thu Apr 16 22:11:16 2020 @@ -128,9 +128,7 @@ public final class PlexOfCps { int start = LittleEndian.getInt(buf, offset + getIntOffset(index)); int end = LittleEndian.getInt(buf, offset + getIntOffset(index + 1)); - byte[] struct = IOUtils.safelyAllocate(_cbStruct, MAX_RECORD_LENGTH); - System.arraycopy(buf, offset + getStructOffset(index), struct, 0, - _cbStruct); + byte[] struct = IOUtils.safelyClone(buf, offset + getStructOffset(index), _cbStruct, MAX_RECORD_LENGTH); return new GenericPropertyNode(start, end, struct); } Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SectionTable.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SectionTable.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SectionTable.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SectionTable.java Thu Apr 16 22:11:16 2020 @@ -81,9 +81,8 @@ public class SectionTable { // The first short at the offset is the size of the grpprl. int sepxSize = LittleEndian.getShort(documentStream, fileOffset); - byte[] buf = IOUtils.safelyAllocate(sepxSize, MAX_RECORD_LENGTH); fileOffset += LittleEndianConsts.SHORT_SIZE; - System.arraycopy(documentStream, fileOffset, buf, 0, buf.length); + byte[] buf = IOUtils.safelyClone(documentStream, fileOffset, sepxSize, MAX_RECORD_LENGTH); _sections.add(new SEPX(sed, startAt, endAt, buf)); } } Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/Sttb.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/Sttb.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/Sttb.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/Sttb.java Thu Apr 16 22:11:16 2020 @@ -116,8 +116,7 @@ public class Sttb _data[i] = StringUtil.getFromUnicodeLE( buffer, offset, cchData ); offset += cchData * 2; - _extraData[i] = LittleEndian - .getByteArray( buffer, offset, _cbExtra ); + _extraData[i] = Arrays.copyOfRange( buffer, offset, offset+_cbExtra ); offset += _cbExtra; } } Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/StyleDescription.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/StyleDescription.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/StyleDescription.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/StyleDescription.java Thu Apr 16 22:11:16 2020 @@ -110,8 +110,7 @@ public final class StyleDescription { int upxSize = LittleEndian.getShort(std, varOffset); varOffset += LittleEndianConsts.SHORT_SIZE; - byte[] upx = IOUtils.safelyAllocate(upxSize, Short.MAX_VALUE); - System.arraycopy(std, varOffset, upx, 0, upxSize); + byte[] upx = IOUtils.safelyClone(std, varOffset, upxSize, Short.MAX_VALUE); _upxs[x] = new UPX(upx); varOffset += upxSize; Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java Thu Apr 16 22:11:16 2020 @@ -101,8 +101,7 @@ public class TextPieceTable implements C int textSizeBytes = textSizeChars * multiple; // Grab the data that makes up the piece - byte[] buf = IOUtils.safelyAllocate(textSizeBytes, MAX_RECORD_LENGTH); - System.arraycopy(documentStream, start, buf, 0, textSizeBytes); + byte[] buf = IOUtils.safelyClone(documentStream, start, textSizeBytes, MAX_RECORD_LENGTH); // And now build the piece final TextPiece newTextPiece = newTextPiece(nodeStartChars, nodeEndChars, buf, Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/types/DOPAbstractType.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/types/DOPAbstractType.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/types/DOPAbstractType.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/types/DOPAbstractType.java Thu Apr 16 22:11:16 2020 @@ -224,16 +224,16 @@ public abstract class DOPAbstractType { field_32_view = LittleEndian.getShort(data, 0x52 + offset); field_33_docinfo4 = LittleEndian.getInt(data, 0x54 + offset); field_34_adt = LittleEndian.getShort(data, 0x58 + offset); - field_35_doptypography = LittleEndian.getByteArray(data, 0x5a + offset,310); - field_36_dogrid = LittleEndian.getByteArray(data, 0x190 + offset,10); + field_35_doptypography = Arrays.copyOfRange(data, 0x5a + offset, 0x5a + offset+ 310); + field_36_dogrid = Arrays.copyOfRange(data, 0x190 + offset,0x190 + offset + 10); field_37_docinfo5 = LittleEndian.getShort(data, 0x19a + offset); field_38_docinfo6 = LittleEndian.getShort(data, 0x19c + offset); - field_39_asumyi = LittleEndian.getByteArray(data, 0x19e + offset,12); + field_39_asumyi = Arrays.copyOfRange(data, 0x19e + offset, 0x19e + offset + 12); field_40_cChWS = LittleEndian.getInt(data, 0x1aa + offset); field_41_cChWSFtnEdn = LittleEndian.getInt(data, 0x1ae + offset); field_42_grfDocEvents = LittleEndian.getInt(data, 0x1b2 + offset); field_43_virusinfo = LittleEndian.getInt(data, 0x1b6 + offset); - field_44_Spare = LittleEndian.getByteArray(data, 0x1ba + offset,30); + field_44_Spare = Arrays.copyOfRange(data, 0x1ba + offset, 0x1ba + offset + 30); field_45_reserved1 = LittleEndian.getInt(data, 0x1d8 + offset); field_46_reserved2 = LittleEndian.getInt(data, 0x1dc + offset); field_47_cDBC = LittleEndian.getInt(data, 0x1e0 + offset); @@ -1473,7 +1473,7 @@ public abstract class DOPAbstractType { /** * Sets the fFacingPages field value. - * + * */ @Internal public void setFFacingPages( boolean value ) @@ -1482,7 +1482,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fFacingPages field value. */ @Internal @@ -1493,7 +1493,7 @@ public abstract class DOPAbstractType { /** * Sets the fWidowControl field value. - * + * */ @Internal public void setFWidowControl( boolean value ) @@ -1502,7 +1502,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fWidowControl field value. */ @Internal @@ -1513,7 +1513,7 @@ public abstract class DOPAbstractType { /** * Sets the fPMHMainDoc field value. - * + * */ @Internal public void setFPMHMainDoc( boolean value ) @@ -1522,7 +1522,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fPMHMainDoc field value. */ @Internal @@ -1533,7 +1533,7 @@ public abstract class DOPAbstractType { /** * Sets the grfSupression field value. - * + * */ @Internal public void setGrfSupression( byte value ) @@ -1542,7 +1542,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the grfSupression field value. */ @Internal @@ -1553,7 +1553,7 @@ public abstract class DOPAbstractType { /** * Sets the fpc field value. - * + * */ @Internal public void setFpc( byte value ) @@ -1562,7 +1562,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fpc field value. */ @Internal @@ -1573,7 +1573,7 @@ public abstract class DOPAbstractType { /** * Sets the unused1 field value. - * + * */ @Internal public void setUnused1( boolean value ) @@ -1582,7 +1582,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the unused1 field value. */ @Internal @@ -1593,7 +1593,7 @@ public abstract class DOPAbstractType { /** * Sets the rncFtn field value. - * + * */ @Internal public void setRncFtn( byte value ) @@ -1602,7 +1602,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the rncFtn field value. */ @Internal @@ -1613,7 +1613,7 @@ public abstract class DOPAbstractType { /** * Sets the nFtn field value. - * + * */ @Internal public void setNFtn( short value ) @@ -1622,7 +1622,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the nFtn field value. */ @Internal @@ -1633,7 +1633,7 @@ public abstract class DOPAbstractType { /** * Sets the fOnlyMacPics field value. - * + * */ @Internal public void setFOnlyMacPics( boolean value ) @@ -1642,7 +1642,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fOnlyMacPics field value. */ @Internal @@ -1653,7 +1653,7 @@ public abstract class DOPAbstractType { /** * Sets the fOnlyWinPics field value. - * + * */ @Internal public void setFOnlyWinPics( boolean value ) @@ -1662,7 +1662,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fOnlyWinPics field value. */ @Internal @@ -1673,7 +1673,7 @@ public abstract class DOPAbstractType { /** * Sets the fLabelDoc field value. - * + * */ @Internal public void setFLabelDoc( boolean value ) @@ -1682,7 +1682,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fLabelDoc field value. */ @Internal @@ -1693,7 +1693,7 @@ public abstract class DOPAbstractType { /** * Sets the fHyphCapitals field value. - * + * */ @Internal public void setFHyphCapitals( boolean value ) @@ -1702,7 +1702,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fHyphCapitals field value. */ @Internal @@ -1713,7 +1713,7 @@ public abstract class DOPAbstractType { /** * Sets the fAutoHyphen field value. - * + * */ @Internal public void setFAutoHyphen( boolean value ) @@ -1722,7 +1722,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fAutoHyphen field value. */ @Internal @@ -1733,7 +1733,7 @@ public abstract class DOPAbstractType { /** * Sets the fFormNoFields field value. - * + * */ @Internal public void setFFormNoFields( boolean value ) @@ -1742,7 +1742,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fFormNoFields field value. */ @Internal @@ -1753,7 +1753,7 @@ public abstract class DOPAbstractType { /** * Sets the fLinkStyles field value. - * + * */ @Internal public void setFLinkStyles( boolean value ) @@ -1762,7 +1762,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fLinkStyles field value. */ @Internal @@ -1773,7 +1773,7 @@ public abstract class DOPAbstractType { /** * Sets the fRevMarking field value. - * + * */ @Internal public void setFRevMarking( boolean value ) @@ -1782,7 +1782,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fRevMarking field value. */ @Internal @@ -1793,7 +1793,7 @@ public abstract class DOPAbstractType { /** * Sets the fBackup field value. - * + * */ @Internal public void setFBackup( boolean value ) @@ -1802,7 +1802,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fBackup field value. */ @Internal @@ -1813,7 +1813,7 @@ public abstract class DOPAbstractType { /** * Sets the fExactCWords field value. - * + * */ @Internal public void setFExactCWords( boolean value ) @@ -1822,7 +1822,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fExactCWords field value. */ @Internal @@ -1833,7 +1833,7 @@ public abstract class DOPAbstractType { /** * Sets the fPagHidden field value. - * + * */ @Internal public void setFPagHidden( boolean value ) @@ -1842,7 +1842,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fPagHidden field value. */ @Internal @@ -1853,7 +1853,7 @@ public abstract class DOPAbstractType { /** * Sets the fPagResults field value. - * + * */ @Internal public void setFPagResults( boolean value ) @@ -1862,7 +1862,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fPagResults field value. */ @Internal @@ -1873,7 +1873,7 @@ public abstract class DOPAbstractType { /** * Sets the fLockAtn field value. - * + * */ @Internal public void setFLockAtn( boolean value ) @@ -1882,7 +1882,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fLockAtn field value. */ @Internal @@ -1893,7 +1893,7 @@ public abstract class DOPAbstractType { /** * Sets the fMirrorMargins field value. - * + * */ @Internal public void setFMirrorMargins( boolean value ) @@ -1902,7 +1902,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fMirrorMargins field value. */ @Internal @@ -1913,7 +1913,7 @@ public abstract class DOPAbstractType { /** * Sets the unused3 field value. - * + * */ @Internal public void setUnused3( boolean value ) @@ -1922,7 +1922,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the unused3 field value. */ @Internal @@ -1933,7 +1933,7 @@ public abstract class DOPAbstractType { /** * Sets the fDfltTrueType field value. - * + * */ @Internal public void setFDfltTrueType( boolean value ) @@ -1942,7 +1942,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fDfltTrueType field value. */ @Internal @@ -1953,7 +1953,7 @@ public abstract class DOPAbstractType { /** * Sets the fPagSupressTopSpacing field value. - * + * */ @Internal public void setFPagSupressTopSpacing( boolean value ) @@ -1962,7 +1962,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fPagSupressTopSpacing field value. */ @Internal @@ -1973,7 +1973,7 @@ public abstract class DOPAbstractType { /** * Sets the fProtEnabled field value. - * + * */ @Internal public void setFProtEnabled( boolean value ) @@ -1982,7 +1982,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fProtEnabled field value. */ @Internal @@ -1993,7 +1993,7 @@ public abstract class DOPAbstractType { /** * Sets the fDispFormFldSel field value. - * + * */ @Internal public void setFDispFormFldSel( boolean value ) @@ -2002,7 +2002,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fDispFormFldSel field value. */ @Internal @@ -2013,7 +2013,7 @@ public abstract class DOPAbstractType { /** * Sets the fRMView field value. - * + * */ @Internal public void setFRMView( boolean value ) @@ -2022,7 +2022,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fRMView field value. */ @Internal @@ -2033,7 +2033,7 @@ public abstract class DOPAbstractType { /** * Sets the fRMPrint field value. - * + * */ @Internal public void setFRMPrint( boolean value ) @@ -2042,7 +2042,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fRMPrint field value. */ @Internal @@ -2053,7 +2053,7 @@ public abstract class DOPAbstractType { /** * Sets the unused4 field value. - * + * */ @Internal public void setUnused4( boolean value ) @@ -2062,7 +2062,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the unused4 field value. */ @Internal @@ -2073,7 +2073,7 @@ public abstract class DOPAbstractType { /** * Sets the fLockRev field value. - * + * */ @Internal public void setFLockRev( boolean value ) @@ -2082,7 +2082,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fLockRev field value. */ @Internal @@ -2093,7 +2093,7 @@ public abstract class DOPAbstractType { /** * Sets the fEmbedFonts field value. - * + * */ @Internal public void setFEmbedFonts( boolean value ) @@ -2102,7 +2102,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fEmbedFonts field value. */ @Internal @@ -2113,7 +2113,7 @@ public abstract class DOPAbstractType { /** * Sets the oldfNoTabForInd field value. - * + * */ @Internal public void setOldfNoTabForInd( boolean value ) @@ -2122,7 +2122,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the oldfNoTabForInd field value. */ @Internal @@ -2133,7 +2133,7 @@ public abstract class DOPAbstractType { /** * Sets the oldfNoSpaceRaiseLower field value. - * + * */ @Internal public void setOldfNoSpaceRaiseLower( boolean value ) @@ -2142,7 +2142,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the oldfNoSpaceRaiseLower field value. */ @Internal @@ -2153,7 +2153,7 @@ public abstract class DOPAbstractType { /** * Sets the oldfSuppressSpbfAfterPageBreak field value. - * + * */ @Internal public void setOldfSuppressSpbfAfterPageBreak( boolean value ) @@ -2162,7 +2162,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the oldfSuppressSpbfAfterPageBreak field value. */ @Internal @@ -2173,7 +2173,7 @@ public abstract class DOPAbstractType { /** * Sets the oldfWrapTrailSpaces field value. - * + * */ @Internal public void setOldfWrapTrailSpaces( boolean value ) @@ -2182,7 +2182,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the oldfWrapTrailSpaces field value. */ @Internal @@ -2193,7 +2193,7 @@ public abstract class DOPAbstractType { /** * Sets the oldfMapPrintTextColor field value. - * + * */ @Internal public void setOldfMapPrintTextColor( boolean value ) @@ -2202,7 +2202,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the oldfMapPrintTextColor field value. */ @Internal @@ -2213,7 +2213,7 @@ public abstract class DOPAbstractType { /** * Sets the oldfNoColumnBalance field value. - * + * */ @Internal public void setOldfNoColumnBalance( boolean value ) @@ -2222,7 +2222,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the oldfNoColumnBalance field value. */ @Internal @@ -2233,7 +2233,7 @@ public abstract class DOPAbstractType { /** * Sets the oldfConvMailMergeEsc field value. - * + * */ @Internal public void setOldfConvMailMergeEsc( boolean value ) @@ -2242,7 +2242,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the oldfConvMailMergeEsc field value. */ @Internal @@ -2253,7 +2253,7 @@ public abstract class DOPAbstractType { /** * Sets the oldfSupressTopSpacing field value. - * + * */ @Internal public void setOldfSupressTopSpacing( boolean value ) @@ -2262,7 +2262,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the oldfSupressTopSpacing field value. */ @Internal @@ -2273,7 +2273,7 @@ public abstract class DOPAbstractType { /** * Sets the oldfOrigWordTableRules field value. - * + * */ @Internal public void setOldfOrigWordTableRules( boolean value ) @@ -2282,7 +2282,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the oldfOrigWordTableRules field value. */ @Internal @@ -2293,7 +2293,7 @@ public abstract class DOPAbstractType { /** * Sets the oldfTransparentMetafiles field value. - * + * */ @Internal public void setOldfTransparentMetafiles( boolean value ) @@ -2302,7 +2302,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the oldfTransparentMetafiles field value. */ @Internal @@ -2313,7 +2313,7 @@ public abstract class DOPAbstractType { /** * Sets the oldfShowBreaksInFrames field value. - * + * */ @Internal public void setOldfShowBreaksInFrames( boolean value ) @@ -2322,7 +2322,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the oldfShowBreaksInFrames field value. */ @Internal @@ -2333,7 +2333,7 @@ public abstract class DOPAbstractType { /** * Sets the oldfSwapBordersFacingPgs field value. - * + * */ @Internal public void setOldfSwapBordersFacingPgs( boolean value ) @@ -2342,7 +2342,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the oldfSwapBordersFacingPgs field value. */ @Internal @@ -2353,7 +2353,7 @@ public abstract class DOPAbstractType { /** * Sets the unused5 field value. - * + * */ @Internal public void setUnused5( byte value ) @@ -2362,7 +2362,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the unused5 field value. */ @Internal @@ -2373,7 +2373,7 @@ public abstract class DOPAbstractType { /** * Sets the rncEdn field value. - * + * */ @Internal public void setRncEdn( byte value ) @@ -2382,7 +2382,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the rncEdn field value. */ @Internal @@ -2393,7 +2393,7 @@ public abstract class DOPAbstractType { /** * Sets the nEdn field value. - * + * */ @Internal public void setNEdn( short value ) @@ -2402,7 +2402,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the nEdn field value. */ @Internal @@ -2413,7 +2413,7 @@ public abstract class DOPAbstractType { /** * Sets the epc field value. - * + * */ @Internal public void setEpc( byte value ) @@ -2422,7 +2422,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the epc field value. */ @Internal @@ -2433,7 +2433,7 @@ public abstract class DOPAbstractType { /** * Sets the nfcFtnRef1 field value. - * + * */ @Internal public void setNfcFtnRef1( byte value ) @@ -2442,7 +2442,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the nfcFtnRef1 field value. */ @Internal @@ -2453,7 +2453,7 @@ public abstract class DOPAbstractType { /** * Sets the nfcEdnRef1 field value. - * + * */ @Internal public void setNfcEdnRef1( byte value ) @@ -2462,7 +2462,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the nfcEdnRef1 field value. */ @Internal @@ -2473,7 +2473,7 @@ public abstract class DOPAbstractType { /** * Sets the fPrintFormData field value. - * + * */ @Internal public void setFPrintFormData( boolean value ) @@ -2482,7 +2482,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fPrintFormData field value. */ @Internal @@ -2493,7 +2493,7 @@ public abstract class DOPAbstractType { /** * Sets the fSaveFormData field value. - * + * */ @Internal public void setFSaveFormData( boolean value ) @@ -2502,7 +2502,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fSaveFormData field value. */ @Internal @@ -2513,7 +2513,7 @@ public abstract class DOPAbstractType { /** * Sets the fShadeFormData field value. - * + * */ @Internal public void setFShadeFormData( boolean value ) @@ -2522,7 +2522,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fShadeFormData field value. */ @Internal @@ -2533,7 +2533,7 @@ public abstract class DOPAbstractType { /** * Sets the fWCFtnEdn field value. - * + * */ @Internal public void setFWCFtnEdn( boolean value ) @@ -2542,7 +2542,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fWCFtnEdn field value. */ @Internal @@ -2553,7 +2553,7 @@ public abstract class DOPAbstractType { /** * Sets the wvkSaved field value. - * + * */ @Internal public void setWvkSaved( byte value ) @@ -2562,7 +2562,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the wvkSaved field value. */ @Internal @@ -2573,7 +2573,7 @@ public abstract class DOPAbstractType { /** * Sets the wScaleSaved field value. - * + * */ @Internal public void setWScaleSaved( short value ) @@ -2582,7 +2582,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the wScaleSaved field value. */ @Internal @@ -2593,7 +2593,7 @@ public abstract class DOPAbstractType { /** * Sets the zkSaved field value. - * + * */ @Internal public void setZkSaved( byte value ) @@ -2602,7 +2602,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the zkSaved field value. */ @Internal @@ -2613,7 +2613,7 @@ public abstract class DOPAbstractType { /** * Sets the fRotateFontW6 field value. - * + * */ @Internal public void setFRotateFontW6( boolean value ) @@ -2622,7 +2622,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fRotateFontW6 field value. */ @Internal @@ -2633,7 +2633,7 @@ public abstract class DOPAbstractType { /** * Sets the iGutterPos field value. - * + * */ @Internal public void setIGutterPos( boolean value ) @@ -2642,7 +2642,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the iGutterPos field value. */ @Internal @@ -2653,7 +2653,7 @@ public abstract class DOPAbstractType { /** * Sets the fNoTabForInd field value. - * + * */ @Internal public void setFNoTabForInd( boolean value ) @@ -2662,7 +2662,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fNoTabForInd field value. */ @Internal @@ -2673,7 +2673,7 @@ public abstract class DOPAbstractType { /** * Sets the fNoSpaceRaiseLower field value. - * + * */ @Internal public void setFNoSpaceRaiseLower( boolean value ) @@ -2682,7 +2682,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fNoSpaceRaiseLower field value. */ @Internal @@ -2693,7 +2693,7 @@ public abstract class DOPAbstractType { /** * Sets the fSupressSpdfAfterPageBreak field value. - * + * */ @Internal public void setFSupressSpdfAfterPageBreak( boolean value ) @@ -2702,7 +2702,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fSupressSpdfAfterPageBreak field value. */ @Internal @@ -2713,7 +2713,7 @@ public abstract class DOPAbstractType { /** * Sets the fWrapTrailSpaces field value. - * + * */ @Internal public void setFWrapTrailSpaces( boolean value ) @@ -2722,7 +2722,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fWrapTrailSpaces field value. */ @Internal @@ -2733,7 +2733,7 @@ public abstract class DOPAbstractType { /** * Sets the fMapPrintTextColor field value. - * + * */ @Internal public void setFMapPrintTextColor( boolean value ) @@ -2742,7 +2742,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fMapPrintTextColor field value. */ @Internal @@ -2753,7 +2753,7 @@ public abstract class DOPAbstractType { /** * Sets the fNoColumnBalance field value. - * + * */ @Internal public void setFNoColumnBalance( boolean value ) @@ -2762,7 +2762,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fNoColumnBalance field value. */ @Internal @@ -2773,7 +2773,7 @@ public abstract class DOPAbstractType { /** * Sets the fConvMailMergeEsc field value. - * + * */ @Internal public void setFConvMailMergeEsc( boolean value ) @@ -2782,7 +2782,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fConvMailMergeEsc field value. */ @Internal @@ -2793,7 +2793,7 @@ public abstract class DOPAbstractType { /** * Sets the fSupressTopSpacing field value. - * + * */ @Internal public void setFSupressTopSpacing( boolean value ) @@ -2802,7 +2802,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fSupressTopSpacing field value. */ @Internal @@ -2813,7 +2813,7 @@ public abstract class DOPAbstractType { /** * Sets the fOrigWordTableRules field value. - * + * */ @Internal public void setFOrigWordTableRules( boolean value ) @@ -2822,7 +2822,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fOrigWordTableRules field value. */ @Internal @@ -2833,7 +2833,7 @@ public abstract class DOPAbstractType { /** * Sets the fTransparentMetafiles field value. - * + * */ @Internal public void setFTransparentMetafiles( boolean value ) @@ -2842,7 +2842,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fTransparentMetafiles field value. */ @Internal @@ -2853,7 +2853,7 @@ public abstract class DOPAbstractType { /** * Sets the fShowBreaksInFrames field value. - * + * */ @Internal public void setFShowBreaksInFrames( boolean value ) @@ -2862,7 +2862,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fShowBreaksInFrames field value. */ @Internal @@ -2873,7 +2873,7 @@ public abstract class DOPAbstractType { /** * Sets the fSwapBordersFacingPgs field value. - * + * */ @Internal public void setFSwapBordersFacingPgs( boolean value ) @@ -2882,7 +2882,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fSwapBordersFacingPgs field value. */ @Internal @@ -2893,7 +2893,7 @@ public abstract class DOPAbstractType { /** * Sets the fSuppressTopSPacingMac5 field value. - * + * */ @Internal public void setFSuppressTopSPacingMac5( boolean value ) @@ -2902,7 +2902,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fSuppressTopSPacingMac5 field value. */ @Internal @@ -2913,7 +2913,7 @@ public abstract class DOPAbstractType { /** * Sets the fTruncDxaExpand field value. - * + * */ @Internal public void setFTruncDxaExpand( boolean value ) @@ -2922,7 +2922,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fTruncDxaExpand field value. */ @Internal @@ -2933,7 +2933,7 @@ public abstract class DOPAbstractType { /** * Sets the fPrintBodyBeforeHdr field value. - * + * */ @Internal public void setFPrintBodyBeforeHdr( boolean value ) @@ -2942,7 +2942,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fPrintBodyBeforeHdr field value. */ @Internal @@ -2953,7 +2953,7 @@ public abstract class DOPAbstractType { /** * Sets the fNoLeading field value. - * + * */ @Internal public void setFNoLeading( boolean value ) @@ -2962,7 +2962,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fNoLeading field value. */ @Internal @@ -2973,7 +2973,7 @@ public abstract class DOPAbstractType { /** * Sets the fMWSmallCaps field value. - * + * */ @Internal public void setFMWSmallCaps( boolean value ) @@ -2982,7 +2982,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fMWSmallCaps field value. */ @Internal @@ -2993,7 +2993,7 @@ public abstract class DOPAbstractType { /** * Sets the lvl field value. - * + * */ @Internal public void setLvl( byte value ) @@ -3002,7 +3002,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the lvl field value. */ @Internal @@ -3013,7 +3013,7 @@ public abstract class DOPAbstractType { /** * Sets the fGramAllDone field value. - * + * */ @Internal public void setFGramAllDone( boolean value ) @@ -3022,7 +3022,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fGramAllDone field value. */ @Internal @@ -3033,7 +3033,7 @@ public abstract class DOPAbstractType { /** * Sets the fGramAllClean field value. - * + * */ @Internal public void setFGramAllClean( boolean value ) @@ -3042,7 +3042,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fGramAllClean field value. */ @Internal @@ -3053,7 +3053,7 @@ public abstract class DOPAbstractType { /** * Sets the fSubsetFonts field value. - * + * */ @Internal public void setFSubsetFonts( boolean value ) @@ -3062,7 +3062,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fSubsetFonts field value. */ @Internal @@ -3073,7 +3073,7 @@ public abstract class DOPAbstractType { /** * Sets the fHideLastVersion field value. - * + * */ @Internal public void setFHideLastVersion( boolean value ) @@ -3082,7 +3082,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fHideLastVersion field value. */ @Internal @@ -3093,7 +3093,7 @@ public abstract class DOPAbstractType { /** * Sets the fHtmlDoc field value. - * + * */ @Internal public void setFHtmlDoc( boolean value ) @@ -3102,7 +3102,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fHtmlDoc field value. */ @Internal @@ -3113,7 +3113,7 @@ public abstract class DOPAbstractType { /** * Sets the fSnapBorder field value. - * + * */ @Internal public void setFSnapBorder( boolean value ) @@ -3122,7 +3122,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fSnapBorder field value. */ @Internal @@ -3133,7 +3133,7 @@ public abstract class DOPAbstractType { /** * Sets the fIncludeHeader field value. - * + * */ @Internal public void setFIncludeHeader( boolean value ) @@ -3142,7 +3142,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fIncludeHeader field value. */ @Internal @@ -3153,7 +3153,7 @@ public abstract class DOPAbstractType { /** * Sets the fIncludeFooter field value. - * + * */ @Internal public void setFIncludeFooter( boolean value ) @@ -3162,7 +3162,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fIncludeFooter field value. */ @Internal @@ -3173,7 +3173,7 @@ public abstract class DOPAbstractType { /** * Sets the fForcePageSizePag field value. - * + * */ @Internal public void setFForcePageSizePag( boolean value ) @@ -3182,7 +3182,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fForcePageSizePag field value. */ @Internal @@ -3193,7 +3193,7 @@ public abstract class DOPAbstractType { /** * Sets the fMinFontSizePag field value. - * + * */ @Internal public void setFMinFontSizePag( boolean value ) @@ -3202,7 +3202,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fMinFontSizePag field value. */ @Internal @@ -3213,7 +3213,7 @@ public abstract class DOPAbstractType { /** * Sets the fHaveVersions field value. - * + * */ @Internal public void setFHaveVersions( boolean value ) @@ -3222,7 +3222,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fHaveVersions field value. */ @Internal @@ -3233,7 +3233,7 @@ public abstract class DOPAbstractType { /** * Sets the fAutoVersions field value. - * + * */ @Internal public void setFAutoVersions( boolean value ) @@ -3242,7 +3242,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fAutoVersions field value. */ @Internal @@ -3253,7 +3253,7 @@ public abstract class DOPAbstractType { /** * Sets the fVirusPrompted field value. - * + * */ @Internal public void setFVirusPrompted( boolean value ) @@ -3262,7 +3262,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fVirusPrompted field value. */ @Internal @@ -3273,7 +3273,7 @@ public abstract class DOPAbstractType { /** * Sets the fVirusLoadSafe field value. - * + * */ @Internal public void setFVirusLoadSafe( boolean value ) @@ -3282,7 +3282,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the fVirusLoadSafe field value. */ @Internal @@ -3293,7 +3293,7 @@ public abstract class DOPAbstractType { /** * Sets the KeyVirusSession30 field value. - * + * */ @Internal public void setKeyVirusSession30( int value ) @@ -3302,7 +3302,7 @@ public abstract class DOPAbstractType { } /** - * + * * @return the KeyVirusSession30 field value. */ @Internal Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/types/LVLFAbstractType.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/types/LVLFAbstractType.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/types/LVLFAbstractType.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/types/LVLFAbstractType.java Thu Apr 16 22:11:16 2020 @@ -74,7 +74,7 @@ public abstract class LVLFAbstractType field_1_iStartAt = LittleEndian.getInt( data, 0x0 + offset ); field_2_nfc = data[ 0x4 + offset ]; field_3_info = data[ 0x5 + offset ]; - field_4_rgbxchNums = LittleEndian.getByteArray( data, 0x6 + offset,9 ); + field_4_rgbxchNums = Arrays.copyOfRange( data, 0x6 + offset, 0x6 + offset + 9 ); field_5_ixchFollow = data[ 0xf + offset ]; field_6_dxaIndentSav = LittleEndian.getInt( data, 0x10 + offset ); field_7_unused2 = LittleEndian.getInt( data, 0x14 + offset ); Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/types/PICFAbstractType.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/types/PICFAbstractType.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/types/PICFAbstractType.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/types/PICFAbstractType.java Thu Apr 16 22:11:16 2020 @@ -21,7 +21,8 @@ package org.apache.poi.hwpf.model.types; import java.util.Arrays; -import org.apache.poi.util.*; +import org.apache.poi.util.Internal; +import org.apache.poi.util.LittleEndian; /** * The PICF structure specifies the type of a picture, as well as the size of the @@ -29,17 +30,17 @@ import org.apache.poi.util.*; from Microsoft Office Word 97-2007 Binary File Format and [MS-DOC] - v20110608 Word (.doc) Binary File Format - + * <p> * NOTE: This source is automatically generated please do not modify this file. Either subclass or * remove the record in src/types/definitions. * <p> - * This class is internal. It content or properties may change without notice + * This class is internal. It content or properties may change without notice * due to changes in our knowledge of internal Microsoft Word binary structures. * @author Sergey Vladimirov; according to Microsoft Office Word 97-2007 Binary File Format Specification [*.doc] and [MS-DOC] - v20110608 Word (.doc) Binary File Format - + */ @Internal public abstract class PICFAbstractType @@ -103,10 +104,10 @@ public abstract class PICFAbstractType field_18_dyaReserved2 = LittleEndian.getShort( data, 0x2a + offset ); field_19_fReserved = data[ 0x2c + offset ]; field_20_bpp = data[ 0x2d + offset ]; - field_21_brcTop80 = LittleEndian.getByteArray( data, 0x2e + offset,4 ); - field_22_brcLeft80 = LittleEndian.getByteArray( data, 0x32 + offset,4 ); - field_23_brcBottom80 = LittleEndian.getByteArray( data, 0x36 + offset,4 ); - field_24_brcRight80 = LittleEndian.getByteArray( data, 0x3a + offset,4 ); + field_21_brcTop80 = Arrays.copyOfRange( data, 0x2e + offset, 0x2e + offset + 4 ); + field_22_brcLeft80 = Arrays.copyOfRange( data, 0x32 + offset, 0x32 + offset + 4 ); + field_23_brcBottom80 = Arrays.copyOfRange( data, 0x36 + offset, 0x36 + offset + 4 ); + field_24_brcRight80 = Arrays.copyOfRange( data, 0x3a + offset, 0x3a + offset + 4 ); field_25_dxaReserved3 = LittleEndian.getShort( data, 0x3e + offset ); field_26_dyaReserved3 = LittleEndian.getShort( data, 0x40 + offset ); field_27_cProps = LittleEndian.getShort( data, 0x42 + offset ); Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/ParagraphSprmUncompressor.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/ParagraphSprmUncompressor.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/ParagraphSprmUncompressor.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/ParagraphSprmUncompressor.java Thu Apr 16 22:11:16 2020 @@ -18,6 +18,7 @@ package org.apache.poi.hwpf.sprm; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -314,11 +315,9 @@ public final class ParagraphSprmUncompre case 0x3b: //obsolete break; - case 0x3e: - { - byte[] buf = new byte[sprm.size() - 3]; - System.arraycopy(buf, 0, sprm.getGrpprl(), sprm.getGrpprlOffset(), - buf.length); + case 0x3e: { + // TODO: REMOVEME + byte[] buf = Arrays.copyOfRange(sprm.getGrpprl(), sprm.getGrpprlOffset(), sprm.getGrpprlOffset() + (sprm.size() - 3)); newPAP.setAnld(buf); break; } Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SectionSprmUncompressor.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SectionSprmUncompressor.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SectionSprmUncompressor.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SectionSprmUncompressor.java Thu Apr 16 22:11:16 2020 @@ -17,6 +17,8 @@ package org.apache.poi.hwpf.sprm; +import java.util.Arrays; + import org.apache.poi.hwpf.usermodel.BorderCode; import org.apache.poi.hwpf.usermodel.SectionProperties; import org.apache.poi.util.HexDump; @@ -69,8 +71,7 @@ public final class SectionSprmUncompress newSEP.setIHeadingPgn ((byte) sprm.getOperand()); break; case 0x2: - byte[] buf = new byte[sprm.size() - 3]; - System.arraycopy(sprm.getGrpprl(), sprm.getGrpprlOffset(), buf, 0, buf.length); + byte[] buf = Arrays.copyOfRange(sprm.getGrpprl(), sprm.getGrpprlOffset(), sprm.getGrpprlOffset() + (sprm.size() - 3)); newSEP.setOlstAnm (buf); break; case 0x3: @@ -216,11 +217,11 @@ public final class SectionSprmUncompress newSEP.setWTextFlow ((short) sprm.getOperand()); break; case 0x3C: - // [MS-DOC], v20140721, 2.6.4, sprmSRncFtn + // [MS-DOC], v20140721, 2.6.4, sprmSRncFtn newSEP.setRncFtn((short) sprm.getOperand()); break; case 0x3E: - // [MS-DOC], v20140721, 2.6.4, sprmSRncEdn + // [MS-DOC], v20140721, 2.6.4, sprmSRncEdn newSEP.setRncEdn((short) sprm.getOperand()); break; case 0x3F: Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmBuffer.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmBuffer.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmBuffer.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmBuffer.java Thu Apr 16 22:11:16 2020 @@ -127,9 +127,8 @@ public final class SprmBuffer implements // commented - buffer shall not contain any additional bytes -- // sergey // byte[] newBuf = new byte[_offset + addition + 6]; - byte[] newBuf = IOUtils.safelyAllocate(_offset + addition, MAX_RECORD_LENGTH); - System.arraycopy(_buf, 0, newBuf, 0, _buf.length); - _buf = newBuf; + IOUtils.safelyAllocateCheck(_offset + addition, MAX_RECORD_LENGTH); + _buf = Arrays.copyOf(_buf, _offset + addition); } } Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmOperation.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmOperation.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmOperation.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmOperation.java Thu Apr 16 22:11:16 2020 @@ -17,6 +17,8 @@ package org.apache.poi.hwpf.sprm; +import java.util.Arrays; + import org.apache.poi.util.BitField; import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.Internal; @@ -75,9 +77,7 @@ public final class SprmOperation public byte[] toByteArray() { - byte[] result = new byte[size()]; - System.arraycopy( _grpprl, _offset, result, 0, size() ); - return result; + return Arrays.copyOfRange(_grpprl, _offset, _offset + size()); } public byte[] getGrpprl() Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/TestCompressedRTF.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/TestCompressedRTF.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/TestCompressedRTF.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/TestCompressedRTF.java Thu Apr 16 22:11:16 2020 @@ -119,8 +119,7 @@ public final class TestCompressedRTF { MAPIRtfAttribute rtfAttr = (MAPIRtfAttribute) attr; // Truncate to header + flag + data for flag - byte[] data = new byte[16 + 12]; - System.arraycopy(rtfAttr.getRawData(), 0, data, 0, data.length); + byte[] data = Arrays.copyOf(rtfAttr.getRawData(), 16 + 12); // Decompress it CompressedRTF comp = new CompressedRTF(); Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java Thu Apr 16 22:11:16 2020 @@ -26,6 +26,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.net.URL; +import java.util.Arrays; import java.util.List; import org.apache.poi.POIDataSamples; @@ -49,7 +50,7 @@ import org.junit.Test; * @author Yegor Kozlov */ public final class TestPictures { - private static POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); + private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); /** * Test read/write Macintosh PICT @@ -66,11 +67,11 @@ public final class TestPictures { Dimension nDim = nHeader.getSize(); assertEquals(expWidth, nDim.getWidth(), 0); assertEquals(expHeight, nDim.getHeight(), 0); - + Dimension dim = data.getImageDimensionInPixels(); assertEquals(Units.pointsToPixel(expWidth), dim.getWidth(), 0); assertEquals(Units.pointsToPixel(expHeight), dim.getHeight(), 0); - + HSLFPictureShape pict = new HSLFPictureShape(data); assertEquals(data.getIndex(), pict.getPictureIndex()); slide.addShape(pict); @@ -91,12 +92,12 @@ public final class TestPictures { //check picture data List<HSLFPictureData> pictures = ppt.getPictureData(); assertEquals(1, pictures.size()); - + HSLFPictureData pd = pictures.get(0); dim = pd.getImageDimension(); assertEquals(expWidth, dim.width); assertEquals(expHeight, dim.height); - + //the Picture shape refers to the PictureData object in the Presentation assertEquals(pict.getPictureData(), pd); @@ -107,10 +108,8 @@ public final class TestPictures { byte[] ppt_bytes = pd.getData(); assertEquals(src_bytes.length, ppt_bytes.length); //in PICT the first 512 bytes are MAC specific and may not be preserved, ignore them - byte[] b1 = new byte[src_bytes.length-512]; - System.arraycopy(src_bytes, 512, b1, 0, b1.length); - byte[] b2 = new byte[ppt_bytes.length-512]; - System.arraycopy(ppt_bytes, 512, b2, 0, b2.length); + byte[] b1 = Arrays.copyOfRange(src_bytes, 512, src_bytes.length); + byte[] b2 = Arrays.copyOfRange(ppt_bytes, 512, ppt_bytes.length); assertArrayEquals(b1, b2); } @@ -133,7 +132,7 @@ public final class TestPictures { Dimension dim = data.getImageDimensionInPixels(); assertEquals(Units.pointsToPixel(expWidth), dim.getWidth(), 0); assertEquals(Units.pointsToPixel(expHeight), dim.getHeight(), 0); - + HSLFPictureShape pict = new HSLFPictureShape(data); assertEquals(data.getIndex(), pict.getPictureIndex()); slide.addShape(pict); @@ -159,20 +158,18 @@ public final class TestPictures { dim = pd.getImageDimension(); assertEquals(expWidth, dim.width); assertEquals(expHeight, dim.height); - + //the Picture shape refers to the PictureData object in the Presentation assertEquals(pict.getPictureData(), pd); - + assertEquals(PictureType.WMF, pd.getType()); assertTrue(pd instanceof WMF); //compare the content of the initial file with what is stored in the PictureData byte[] ppt_bytes = pd.getData(); assertEquals(src_bytes.length, ppt_bytes.length); //in WMF the first 22 bytes - is a metafile header - byte[] b1 = new byte[src_bytes.length-22]; - System.arraycopy(src_bytes, 22, b1, 0, b1.length); - byte[] b2 = new byte[ppt_bytes.length-22]; - System.arraycopy(ppt_bytes, 22, b2, 0, b2.length); + byte[] b1 = Arrays.copyOfRange(src_bytes, 22, src_bytes.length); + byte[] b2 = Arrays.copyOfRange(ppt_bytes, 22, ppt_bytes.length); assertArrayEquals(b1, b2); } @@ -195,7 +192,7 @@ public final class TestPictures { Dimension dim = data.getImageDimensionInPixels(); assertEquals(Units.pointsToPixel(expWidth), dim.getWidth(), 0); assertEquals(Units.pointsToPixel(expHeight), dim.getHeight(), 0); - + HSLFPictureShape pict = new HSLFPictureShape(data); assertEquals(data.getIndex(), pict.getPictureIndex()); slide.addShape(pict); @@ -216,12 +213,12 @@ public final class TestPictures { //check picture data List<HSLFPictureData> pictures = ppt.getPictureData(); assertEquals(1, pictures.size()); - + HSLFPictureData pd = pictures.get(0); dim = pd.getImageDimension(); assertEquals(expWidth, dim.width); assertEquals(expHeight, dim.height); - + //the Picture shape refers to the PictureData object in the Presentation assertEquals(pict.getPictureData(), pd); @@ -393,10 +390,8 @@ public final class TestPictures { ppt_bytes = slTests.readFile("santa.wmf"); assertEquals(src_bytes.length, ppt_bytes.length); //ignore the first 22 bytes - it is a WMF metafile header - b1 = new byte[src_bytes.length-22]; - System.arraycopy(src_bytes, 22, b1, 0, b1.length); - b2 = new byte[ppt_bytes.length-22]; - System.arraycopy(ppt_bytes, 22, b2, 0, b2.length); + b1 = Arrays.copyOfRange(src_bytes, 22, src_bytes.length); + b2 = Arrays.copyOfRange(ppt_bytes, 22, ppt_bytes.length); assertArrayEquals(b1, b2); pict = (HSLFPictureShape)slides.get(3).getShapes().get(0); //the forth slide contains PICT @@ -407,10 +402,8 @@ public final class TestPictures { ppt_bytes = slTests.readFile("cow.pict"); assertEquals(src_bytes.length, ppt_bytes.length); //ignore the first 512 bytes - it is a MAC specific crap - b1 = new byte[src_bytes.length-512]; - System.arraycopy(src_bytes, 512, b1, 0, b1.length); - b2 = new byte[ppt_bytes.length-512]; - System.arraycopy(ppt_bytes, 512, b2, 0, b2.length); + b1 = Arrays.copyOfRange(src_bytes, 512, src_bytes.length); + b2 = Arrays.copyOfRange(ppt_bytes, 512, ppt_bytes.length); assertArrayEquals(b1, b2); pict = (HSLFPictureShape)slides.get(4).getShapes().get(0); //the fifth slide contains EMF @@ -457,7 +450,7 @@ public final class TestPictures { pdata = pict.getPictureData(); assertTrue(pdata instanceof WMF); assertEquals(PictureType.WMF, pdata.getType()); - + ppt.close(); } Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java Thu Apr 16 22:11:16 2020 @@ -26,6 +26,7 @@ import static org.junit.Assert.assertSam import static org.junit.Assert.assertTrue; import java.io.IOException; +import java.util.Arrays; import org.apache.poi.hssf.HSSFITestDataProvider; import org.apache.poi.hssf.record.CFRuleBase.ComparisonOperator; @@ -85,8 +86,7 @@ public final class TestCFRuleRecord { byte[] serializedRecord = record.serialize(); // Strip header - byte[] recordData = new byte[serializedRecord.length - 4]; - System.arraycopy(serializedRecord, 4, recordData, 0, recordData.length); + byte[] recordData = Arrays.copyOfRange(serializedRecord, 4, serializedRecord.length); // Deserialize record = new CFRuleRecord(TestcaseRecordInputStream.create(CFRuleRecord.sid, recordData)); @@ -109,8 +109,7 @@ public final class TestCFRuleRecord { byte[] serializedRecord = record.serialize(); // Strip header - byte[] recordData = new byte[serializedRecord.length - 4]; - System.arraycopy(serializedRecord, 4, recordData, 0, recordData.length); + byte[] recordData = Arrays.copyOfRange(serializedRecord, 4, serializedRecord.length); // Deserialize record = new CFRule12Record(TestcaseRecordInputStream.create(CFRule12Record.sid, recordData)); @@ -140,8 +139,7 @@ public final class TestCFRuleRecord { byte[] serializedRecord = record.serialize(); // Strip header - byte[] recordData = new byte[serializedRecord.length - 4]; - System.arraycopy(serializedRecord, 4, recordData, 0, recordData.length); + byte[] recordData = Arrays.copyOfRange(serializedRecord, 4, serializedRecord.length); // Deserialize record = new CFRule12Record(TestcaseRecordInputStream.create(CFRule12Record.sid, recordData)); Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java?rev=1876640&r1=1876639&r2=1876640&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java Thu Apr 16 22:11:16 2020 @@ -25,6 +25,7 @@ import static org.junit.Assert.assertNot import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; +import java.util.Arrays; import org.apache.poi.hpsf.ClassID; import org.apache.poi.hpsf.ClassIDPredefined; @@ -262,7 +263,7 @@ public final class TestHyperlinkRecord { /** * From Bugzilla 47498 */ - private static byte[] data_47498 = { + private static final byte[] data_47498 = { 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, (byte)0xD0, (byte)0xC9, (byte)0xEA, 0x79, (byte)0xF9, (byte)0xBA, (byte)0xCE, 0x11, (byte)0x8C, (byte)0x82, 0x00, (byte)0xAA, 0x00, 0x4B, (byte)0xA9, 0x0B, 0x02, 0x00, @@ -388,8 +389,7 @@ public final class TestHyperlinkRecord { link.setAddress("http://www.lakings.com/"); byte[] tmp = link.serialize(); - byte[] ser = new byte[tmp.length-4]; - System.arraycopy(tmp, 4, ser, 0, ser.length); + byte[] ser = Arrays.copyOfRange(tmp, 4, tmp.length); assertEquals(data1.length, ser.length); assertArrayEquals(data1, ser); } @@ -404,8 +404,7 @@ public final class TestHyperlinkRecord { link.setShortFilename("link1.xls"); byte[] tmp = link.serialize(); - byte[] ser = new byte[tmp.length-4]; - System.arraycopy(tmp, 4, ser, 0, ser.length); + byte[] ser = Arrays.copyOfRange(tmp, 4, tmp.length); assertEquals(data2.length, ser.length); assertArrayEquals(data2, ser); } @@ -420,8 +419,7 @@ public final class TestHyperlinkRecord { link.setTextMark("Sheet1!A1"); byte[] tmp = link.serialize(); - byte[] ser = new byte[tmp.length-4]; - System.arraycopy(tmp, 4, ser, 0, ser.length); + byte[] ser = Arrays.copyOfRange(tmp, 4, tmp.length); assertEquals(data4.length, ser.length); assertArrayEquals(data4, ser); } @@ -436,8 +434,7 @@ public final class TestHyperlinkRecord { link.setAddress("mailto:[email protected]?subject=Hello,%20Ebgans!"); byte[] tmp = link.serialize(); - byte[] ser = new byte[tmp.length-4]; - System.arraycopy(tmp, 4, ser, 0, ser.length); + byte[] ser = Arrays.copyOfRange(tmp, 4, tmp.length); assertEquals(data3.length, ser.length); assertArrayEquals(data3, ser); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
