> extends Pr
* use char positions for all operations. Including save
* operations, because only char positions are preserved.
*/
- @Deprecated
+ @Deprecated
public int getStartBytes()
{
return startBytes;
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/CHPBinTable.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/CHPBinTable.java
index 24cfb6d183..1d0a570791 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/CHPBinTable.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/CHPBinTable.java
@@ -384,11 +384,11 @@ public class CHPBinTable
CHPX chpx = _textRuns.get(listIndex);
if (chpx.getStart() < cpStart)
{
- // Copy the properties of the one before to afterwards
- // Will go:
- // Original, until insert at point
- // New one
- // Clone of original, on to the old end
+ // Copy the properties of the one before to afterwards
+ // Will go:
+ // Original, until insert at point
+ // New one
+ // Clone of original, on to the old end
CHPX clone = new CHPX(0, 0, chpx.getSprmBuf());
// Again ensure contains character based offsets no matter what
clone.setStart(cpStart);
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/Ffn.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/Ffn.java
index 32d9631277..559e1af71e 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/Ffn.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/Ffn.java
@@ -98,22 +98,22 @@ public final class Ffn
public short getWeight()
{
- return _wWeight;
+ return _wWeight;
}
public byte getChs()
{
- return _chs;
+ return _chs;
}
public byte [] getPanose()
{
- return _panose;
+ return _panose;
}
public byte [] getFontSig()
{
- return _fontSig;
+ return _fontSig;
}
public int getSize()
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/FileInformationBlock.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/FileInformationBlock.java
index ecb125b6e8..37ed665ed4 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/FileInformationBlock.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/FileInformationBlock.java
@@ -688,13 +688,13 @@ public final class FileInformationBlock {
* i.e. lcbPlcfHdd
*/
public int getPlcfHddSize() {
- return _fieldHandler.getFieldSize(FIBFieldHandler.PLCFHDD);
+ return _fieldHandler.getFieldSize(FIBFieldHandler.PLCFHDD);
}
public void setPlcfHddOffset(int fcPlcfHdd) {
- _fieldHandler.setFieldOffset(FIBFieldHandler.PLCFHDD, fcPlcfHdd);
+ _fieldHandler.setFieldOffset(FIBFieldHandler.PLCFHDD, fcPlcfHdd);
}
public void setPlcfHddSize(int lcbPlcfHdd) {
- _fieldHandler.setFieldSize(FIBFieldHandler.PLCFHDD, lcbPlcfHdd);
+ _fieldHandler.setFieldSize(FIBFieldHandler.PLCFHDD, lcbPlcfHdd);
}
public int getFcSttbSavedBy()
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/ListLevel.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/ListLevel.java
index f13e9a3884..39c0628487 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/ListLevel.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/ListLevel.java
@@ -189,7 +189,7 @@ public final class ListLevel
* the numbering does not restart or {@code -1} if no restart is applicable
*/
public short getRestart() {
- return _lvlf.isFNoRestart() ? _lvlf.getIlvlRestartLim() : -1;
+ return _lvlf.isFNoRestart() ? _lvlf.getIlvlRestartLim() : -1;
}
/**
@@ -202,7 +202,7 @@ public final class ListLevel
* significant levels must be overridden; {@code false} otherwise
*/
public boolean isLegalNumbering() {
- return _lvlf.isFLegal();
+ return _lvlf.isFLegal();
}
/**
@@ -213,7 +213,7 @@ public final class ListLevel
* @return {@code 0}-terminated array, unless it is full
*/
public byte[] getLevelNumberingPlaceholderOffsets() {
- return _lvlf.getRgbxchNums();
+ return _lvlf.getRgbxchNums();
}
int read( final byte[] data, final int startOffset )
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/ListTables.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/ListTables.java
index 3903b04a77..1ae1679046 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/ListTables.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/ListTables.java
@@ -150,7 +150,7 @@ public final class ListTables
return lst.getLevels()[level];
}
LOGGER.atWarn().log("Requested level {} which was greater than the maximum defined ({})", box(level),box(lst.numLevels()));
- return null;
+ return null;
}
public ListData getListData(int lsid)
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OfficeArtContent.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OfficeArtContent.java
index df53ee6bc4..d8c13132b7 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OfficeArtContent.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OfficeArtContent.java
@@ -38,82 +38,82 @@ import static org.apache.logging.log4j.util.Unbox.box;
@Internal
public final class OfficeArtContent {
- /**
- * {@link EscherRecordTypes#DGG_CONTAINER} containing drawing group information for the document.
- */
- private final EscherContainerRecord drawingGroupData = new EscherContainerRecord();
+ /**
+ * {@link EscherRecordTypes#DGG_CONTAINER} containing drawing group information for the document.
+ */
+ private final EscherContainerRecord drawingGroupData = new EscherContainerRecord();
- /**
- * {@link EscherRecordTypes#DG_CONTAINER} for drawings in the Main Document.
- *
- * {@code null} to indicate that the document does not have a {@link EscherRecordTypes#DG_CONTAINER} for the Main
- * Document.
- */
- private EscherContainerRecord mainDocumentDgContainer;
+ /**
+ * {@link EscherRecordTypes#DG_CONTAINER} for drawings in the Main Document.
+ *
+ * {@code null} to indicate that the document does not have a {@link EscherRecordTypes#DG_CONTAINER} for the Main
+ * Document.
+ */
+ private EscherContainerRecord mainDocumentDgContainer;
- /**
- * {@link EscherRecordTypes#DG_CONTAINER} for drawings in the Header Document.
- *
- * {@code null} to indicate that the document does not have a {@link EscherRecordTypes#DG_CONTAINER} for the Header
- * Document.
- */
- private EscherContainerRecord headerDocumentDgContainer;
+ /**
+ * {@link EscherRecordTypes#DG_CONTAINER} for drawings in the Header Document.
+ *
+ * {@code null} to indicate that the document does not have a {@link EscherRecordTypes#DG_CONTAINER} for the Header
+ * Document.
+ */
+ private EscherContainerRecord headerDocumentDgContainer;
- public OfficeArtContent(byte[] data, int offset, int size) {
- fillEscherRecords(data, offset, size);
- }
+ public OfficeArtContent(byte[] data, int offset, int size) {
+ fillEscherRecords(data, offset, size);
+ }
- /**
- * Parses the records out of the given data.
- *
- * The thing to be aware of here is that if {@code size} is {@code 0}, the document does not contain images.
- *
- * @see FileInformationBlock#getLcbDggInfo()
- */
- private void fillEscherRecords(byte[] data, int offset, int size) {
- if (size == 0) return;
+ /**
+ * Parses the records out of the given data.
+ *
+ * The thing to be aware of here is that if {@code size} is {@code 0}, the document does not contain images.
+ *
+ * @see FileInformationBlock#getLcbDggInfo()
+ */
+ private void fillEscherRecords(byte[] data, int offset, int size) {
+ if (size == 0) return;
- EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
- int pos = offset;
- pos += drawingGroupData.fillFields(data, pos, recordFactory);
- assert drawingGroupData.getRecordId() == EscherRecordTypes.DGG_CONTAINER.typeID;
+ EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
+ int pos = offset;
+ pos += drawingGroupData.fillFields(data, pos, recordFactory);
+ assert drawingGroupData.getRecordId() == EscherRecordTypes.DGG_CONTAINER.typeID;
- /*
- * After the drawingGroupData there is an array (2 slots max) that has data about drawings. According to the
- * spec, the first slot is for the Main Document, the second for the Header Document. Additionally, the
- * OfficeArtWordDrawing structure has a byte (dgglbl) that indicates whether the structure is for the Main or
- * Header Document. In practice we've seen documents such as 61911.doc where the order of array entries does not
- * match the dgglbl byte. As the byte is more likely to be reliable, we base the parsing off of that rather than
- * array order.
- */
+ /*
+ * After the drawingGroupData there is an array (2 slots max) that has data about drawings. According to the
+ * spec, the first slot is for the Main Document, the second for the Header Document. Additionally, the
+ * OfficeArtWordDrawing structure has a byte (dgglbl) that indicates whether the structure is for the Main or
+ * Header Document. In practice we've seen documents such as 61911.doc where the order of array entries does not
+ * match the dgglbl byte. As the byte is more likely to be reliable, we base the parsing off of that rather than
+ * array order.
+ */
- // This should loop at most twice
- while (pos < offset + size) {
+ // This should loop at most twice
+ while (pos < offset + size) {
- // Named this way to match section 2.9.172 of [MS-DOC] - v20191119.
- byte dgglbl = data[pos];
- assert dgglbl == 0x00 || dgglbl == 0x01;
- pos++;
+ // Named this way to match section 2.9.172 of [MS-DOC] - v20191119.
+ byte dgglbl = data[pos];
+ assert dgglbl == 0x00 || dgglbl == 0x01;
+ pos++;
- EscherContainerRecord dgContainer = new EscherContainerRecord();
- pos+= dgContainer.fillFields(data, pos, recordFactory);
- assert dgContainer.getRecordId() == EscherRecordTypes.DG_CONTAINER.typeID;
+ EscherContainerRecord dgContainer = new EscherContainerRecord();
+ pos+= dgContainer.fillFields(data, pos, recordFactory);
+ assert dgContainer.getRecordId() == EscherRecordTypes.DG_CONTAINER.typeID;
- switch (dgglbl) {
- case 0x00:
- mainDocumentDgContainer = dgContainer;
- break;
- case 0x01:
- headerDocumentDgContainer = dgContainer;
- break;
- default:
- LogManager.getLogger(OfficeArtContent.class).atWarn()
- .log("dgglbl {} for OfficeArtWordDrawing is out of bounds [0, 1]", box(dgglbl));
- }
- }
+ switch (dgglbl) {
+ case 0x00:
+ mainDocumentDgContainer = dgContainer;
+ break;
+ case 0x01:
+ headerDocumentDgContainer = dgContainer;
+ break;
+ default:
+ LogManager.getLogger(OfficeArtContent.class).atWarn()
+ .log("dgglbl {} for OfficeArtWordDrawing is out of bounds [0, 1]", box(dgglbl));
+ }
+ }
- assert pos == offset + size;
- }
+ assert pos == offset + size;
+ }
private List extends EscherContainerRecord> getDgContainers() {
List dgContainers = new ArrayList<>(2);
@@ -126,11 +126,11 @@ public final class OfficeArtContent {
return dgContainers;
}
- /**
- * @return The {@link EscherRecordTypes#BSTORE_CONTAINER} or {@code null} if the document doesn't have one.
- */
- public EscherContainerRecord getBStoreContainer() {
- return drawingGroupData.getChildById(EscherRecordTypes.BSTORE_CONTAINER.typeID);
+ /**
+ * @return The {@link EscherRecordTypes#BSTORE_CONTAINER} or {@code null} if the document doesn't have one.
+ */
+ public EscherContainerRecord getBStoreContainer() {
+ return drawingGroupData.getChildById(EscherRecordTypes.BSTORE_CONTAINER.typeID);
}
public List extends EscherContainerRecord> getSpgrContainers()
@@ -167,12 +167,12 @@ public final class OfficeArtContent {
return spContainers;
}
- @Override
- public String toString() {
- return "OfficeArtContent{" +
- "drawingGroupData=" + drawingGroupData +
- ", mainDocumentDgContainer=" + mainDocumentDgContainer +
- ", headerDocumentDgContainer=" + headerDocumentDgContainer +
- '}';
- }
+ @Override
+ public String toString() {
+ return "OfficeArtContent{" +
+ "drawingGroupData=" + drawingGroupData +
+ ", mainDocumentDgContainer=" + mainDocumentDgContainer +
+ ", headerDocumentDgContainer=" + headerDocumentDgContainer +
+ '}';
+ }
}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/RevisionMarkAuthorTable.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/RevisionMarkAuthorTable.java
index 3cad305e05..abda3b3557 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/RevisionMarkAuthorTable.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/RevisionMarkAuthorTable.java
@@ -31,61 +31,61 @@ import org.apache.poi.util.Internal;
*/
@Internal
public final class RevisionMarkAuthorTable {
- /**
- * Array of entries.
- */
- private String[] entries;
+ /**
+ * Array of entries.
+ */
+ private String[] entries;
- /**
- * Constructor to read the table from the table stream.
- *
- * @param tableStream the table stream.
- * @param offset the offset into the byte array.
- * @param size the size of the table in the byte array.
- */
+ /**
+ * Constructor to read the table from the table stream.
+ *
+ * @param tableStream the table stream.
+ * @param offset the offset into the byte array.
+ * @param size the size of the table in the byte array.
+ */
public RevisionMarkAuthorTable( byte[] tableStream, int offset, int size )
throws IOException
{
entries = SttbUtils.readSttbfRMark( tableStream, offset );
}
- /**
- * Gets the entries. The returned list cannot be modified.
- *
- * @return the list of entries.
- */
- public List getEntries() {
- return Collections.unmodifiableList(Arrays.asList(entries));
- }
+ /**
+ * Gets the entries. The returned list cannot be modified.
+ *
+ * @return the list of entries.
+ */
+ public List getEntries() {
+ return Collections.unmodifiableList(Arrays.asList(entries));
+ }
- /**
- * Get an author by its index. Returns null if it does not exist.
- *
- * @return the revision mark author
- */
- public String getAuthor(int index) {
- String auth = null;
- if(index >= 0 && index < entries.length) {
- auth = entries[index];
- }
- return auth;
- }
+ /**
+ * Get an author by its index. Returns null if it does not exist.
+ *
+ * @return the revision mark author
+ */
+ public String getAuthor(int index) {
+ String auth = null;
+ if(index >= 0 && index < entries.length) {
+ auth = entries[index];
+ }
+ return auth;
+ }
- /**
- * Gets the number of entries.
- *
- * @return the number of entries.
- */
- public int getSize() {
- return entries.length;
- }
+ /**
+ * Gets the number of entries.
+ *
+ * @return the number of entries.
+ */
+ public int getSize() {
+ return entries.length;
+ }
- /**
- * Writes this table to the table stream.
- *
- * @param tableStream the table stream to write to.
- * @throws IOException if an error occurs while writing.
- */
+ /**
+ * Writes this table to the table stream.
+ *
+ * @param tableStream the table stream to write to.
+ * @throws IOException if an error occurs while writing.
+ */
public void writeTo( ByteArrayOutputStream tableStream ) throws IOException
{
SttbUtils.writeSttbfRMark( entries, tableStream );
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPiece.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPiece.java
index bdb9ba492a..4dada2805b 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPiece.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPiece.java
@@ -149,10 +149,10 @@ public class TextPiece extends PropertyNode {
int myEnd = getEnd();
int end = start + length;
- /* do we have to delete from this text piece? */
+ /* do we have to delete from this text piece? */
if (start <= myEnd && end >= myStart) {
- /* find where the deleted area overlaps with this text piece */
+ /* find where the deleted area overlaps with this text piece */
int overlapStart = Math.max(myStart, start);
int overlapEnd = Math.min(myEnd, end);
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/UnhandledDataStructure.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/UnhandledDataStructure.java
index 89d5c492fd..3e69c5979a 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/UnhandledDataStructure.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/UnhandledDataStructure.java
@@ -44,7 +44,7 @@ public final class UnhandledDataStructure
if (offset < 0 || length < 0)
{
throw new IndexOutOfBoundsException("Offset and Length must both be >= 0, negative " +
- "indicies are not permitted - code is tried to read " + length + " from offset " + offset);
+ "indicies are not permitted - code is tried to read " + length + " from offset " + offset);
}
// Save that requested portion of the data
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/CharacterSprmUncompressor.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/CharacterSprmUncompressor.java
index bad4429041..372393945e 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/CharacterSprmUncompressor.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/CharacterSprmUncompressor.java
@@ -217,7 +217,7 @@ public final class CharacterSprmUncompressor extends SprmUncompressor
break;
case 0xd:
- // undocumented
+ // undocumented
break;
case 0xe:
newCHP.setFcObj (sprm.getOperand());
@@ -689,17 +689,17 @@ public final class CharacterSprmUncompressor extends SprmUncompressor
case 0x74:
// sprmCRgLid1
break;
- case 0x75:
- // sprmCFNoProof -- 0x875
- /*
- * "A ToggleOperand value that specifies whether the text is excluded from the proofing analysis. By default, text is not excluded from the proofing analysis."
- *
- * Word (.doc) Binary File Format. Copyright (c) 2012 Microsoft
- * Corporation. Released: October 8, 2012
- */
- newCHP.setFNoProof(getCHPFlag((byte) sprm.getOperand(),
- oldCHP.isFNoProof()));
- break;
+ case 0x75:
+ // sprmCFNoProof -- 0x875
+ /*
+ * "A ToggleOperand value that specifies whether the text is excluded from the proofing analysis. By default, text is not excluded from the proofing analysis."
+ *
+ * Word (.doc) Binary File Format. Copyright (c) 2012 Microsoft
+ * Corporation. Released: October 8, 2012
+ */
+ newCHP.setFNoProof(getCHPFlag((byte) sprm.getOperand(),
+ oldCHP.isFNoProof()));
+ break;
default:
LOG.atDebug().log("Unknown CHP sprm ignored: {}", sprm);
break;
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/SprmUncompressor.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/SprmUncompressor.java
index ef2e117ead..453d8b8122 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/SprmUncompressor.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/SprmUncompressor.java
@@ -42,7 +42,7 @@ public abstract class SprmUncompressor
{
return true;
}
- return false;
+ return false;
}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/HeaderStories.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/HeaderStories.java
index 8df6f545c7..738253c3d5 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/HeaderStories.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/HeaderStories.java
@@ -34,14 +34,14 @@ import org.apache.poi.hwpf.model.SubdocumentType;
* as offsets are not yet updated!
*/
public final class HeaderStories {
- private final Range headerStories;
- private PlexOfCps plcfHdd;
+ private final Range headerStories;
+ private PlexOfCps plcfHdd;
- private boolean stripFields;
+ private boolean stripFields;
- public HeaderStories(HWPFDocument doc) {
- this.headerStories = doc.getHeaderStoryRange();
- FileInformationBlock fib = doc.getFileInformationBlock();
+ public HeaderStories(HWPFDocument doc) {
+ this.headerStories = doc.getHeaderStoryRange();
+ FileInformationBlock fib = doc.getFileInformationBlock();
// // If there's no PlcfHdd, nothing to do
// if(fib.getCcpHdd() == 0) {
@@ -49,11 +49,11 @@ public final class HeaderStories {
// }
if (fib.getSubdocumentTextStreamLength( SubdocumentType.HEADER ) == 0)
- return;
+ return;
- if(fib.getPlcfHddSize() == 0) {
- return;
- }
+ if(fib.getPlcfHddSize() == 0) {
+ return;
+ }
// Handle the PlcfHdd
/*
@@ -169,24 +169,24 @@ public final class HeaderStories {
/**
* @deprecated 3.8 beta 4
*/
- @Deprecated
- public String getEvenHeader() {
- return getAt(6+0);
- }
- /**
+ @Deprecated
+ public String getEvenHeader() {
+ return getAt(6+0);
+ }
+ /**
* @deprecated 3.8 beta 4
*/
@Deprecated
public String getOddHeader() {
- return getAt(6+1);
- }
+ return getAt(6+1);
+ }
/**
* @deprecated 3.8 beta 4
*/
@Deprecated
public String getFirstHeader() {
- return getAt(6+4);
- }
+ return getAt(6+4);
+ }
public Range getEvenHeaderSubrange() {
@@ -199,33 +199,33 @@ public final class HeaderStories {
return getSubrangeAt(6+4);
}
- /**
- * Returns the correct, defined header for the given
- * one based page
- * @param pageNumber The one based page number
- */
- public String getHeader(int pageNumber) {
- // First page header is optional, only return
- // if it's set
- if(pageNumber == 1) {
+ /**
+ * Returns the correct, defined header for the given
+ * one based page
+ * @param pageNumber The one based page number
+ */
+ public String getHeader(int pageNumber) {
+ // First page header is optional, only return
+ // if it's set
+ if(pageNumber == 1) {
final String fh = getFirstHeader();
- if(fh != null && !fh.isEmpty()) {
- return fh;
- }
- }
- // Even page header is optional, only return
- // if it's set
- if(pageNumber % 2 == 0) {
+ if(fh != null && !fh.isEmpty()) {
+ return fh;
+ }
+ }
+ // Even page header is optional, only return
+ // if it's set
+ if(pageNumber % 2 == 0) {
final String eh = getEvenHeader();
- if(eh != null && !eh.isEmpty()) {
- return eh;
- }
- }
- // Odd is the default
- return getOddHeader();
- }
+ if(eh != null && !eh.isEmpty()) {
+ return eh;
+ }
+ }
+ // Odd is the default
+ return getOddHeader();
+ }
- /**
+ /**
* @deprecated 3.8 beta 4
*/
@Deprecated
@@ -234,7 +234,7 @@ public final class HeaderStories {
return getAt( 6 + 2 );
}
- /**
+ /**
* @deprecated 3.8 beta 4
*/
@Deprecated
@@ -267,73 +267,73 @@ public final class HeaderStories {
return getSubrangeAt( 6 + 5 );
}
- /**
- * Returns the correct, defined footer for the given
- * one based page
- * @param pageNumber The one based page number
- */
- public String getFooter(int pageNumber) {
- // First page footer is optional, only return
- // if it's set
- if(pageNumber == 1) {
- final String ff = getFirstFooter();
- if(ff != null && !ff.isEmpty()) {
- return ff;
- }
- }
- // Even page footer is optional, only return
- // if it's set
- if(pageNumber % 2 == 0) {
- final String ef = getEvenFooter();
- if(ef != null && !ef.isEmpty()) {
- return ef;
- }
- }
- // Odd is the default
- return getOddFooter();
- }
+ /**
+ * Returns the correct, defined footer for the given
+ * one based page
+ * @param pageNumber The one based page number
+ */
+ public String getFooter(int pageNumber) {
+ // First page footer is optional, only return
+ // if it's set
+ if(pageNumber == 1) {
+ final String ff = getFirstFooter();
+ if(ff != null && !ff.isEmpty()) {
+ return ff;
+ }
+ }
+ // Even page footer is optional, only return
+ // if it's set
+ if(pageNumber % 2 == 0) {
+ final String ef = getEvenFooter();
+ if(ef != null && !ef.isEmpty()) {
+ return ef;
+ }
+ }
+ // Odd is the default
+ return getOddFooter();
+ }
- /**
- * Get the string that's pointed to by the
- * given plcfHdd index
- * @deprecated 3.8 beta 4
- */
+ /**
+ * Get the string that's pointed to by the
+ * given plcfHdd index
+ * @deprecated 3.8 beta 4
+ */
@Deprecated
- private String getAt(int plcfHddIndex) {
- if(plcfHdd == null) return null;
+ private String getAt(int plcfHddIndex) {
+ if(plcfHdd == null) return null;
- GenericPropertyNode prop = plcfHdd.getProperty(plcfHddIndex);
- if(prop.getStart() == prop.getEnd()) {
- // Empty story
- return "";
- }
- if(prop.getEnd() < prop.getStart()) {
- // Broken properties?
- return "";
- }
+ GenericPropertyNode prop = plcfHdd.getProperty(plcfHddIndex);
+ if(prop.getStart() == prop.getEnd()) {
+ // Empty story
+ return "";
+ }
+ if(prop.getEnd() < prop.getStart()) {
+ // Broken properties?
+ return "";
+ }
- // Ensure we're getting a sensible length
- String rawText = headerStories.text();
- int start = Math.min(prop.getStart(), rawText.length());
- int end = Math.min(prop.getEnd(), rawText.length());
+ // Ensure we're getting a sensible length
+ String rawText = headerStories.text();
+ int start = Math.min(prop.getStart(), rawText.length());
+ int end = Math.min(prop.getEnd(), rawText.length());
- // Grab the contents
- String text = rawText.substring(start, end);
+ // Grab the contents
+ String text = rawText.substring(start, end);
- // Strip off fields and macros if requested
- if(stripFields) {
- return Range.stripFields(text);
- }
- // If you create a header/footer, then remove it again, word
- // will leave \r\r. Turn these back into an empty string,
- // which is more what you'd expect
- if(text.equals("\r\r")) {
- return "";
- }
+ // Strip off fields and macros if requested
+ if(stripFields) {
+ return Range.stripFields(text);
+ }
+ // If you create a header/footer, then remove it again, word
+ // will leave \r\r. Turn these back into an empty string,
+ // which is more what you'd expect
+ if(text.equals("\r\r")) {
+ return "";
+ }
- return text;
- }
+ return text;
+ }
private Range getSubrangeAt( int plcfHddIndex )
{
@@ -361,27 +361,27 @@ public final class HeaderStories {
headerStories.getStartOffset() + end, headerStories );
}
- public Range getRange() {
- return headerStories;
- }
- protected PlexOfCps getPlcfHdd() {
- return plcfHdd;
- }
+ public Range getRange() {
+ return headerStories;
+ }
+ protected PlexOfCps getPlcfHdd() {
+ return plcfHdd;
+ }
- /**
- * Are fields currently being stripped from
- * the text that this HeaderStories returns?
- * Default is false, but can be changed
- */
- public boolean areFieldsStripped() {
- return stripFields;
- }
- /**
- * Should fields (eg macros) be stripped from
- * the text that this class returns?
- * Default is not to strip.
- */
- public void setAreFieldsStripped(boolean stripFields) {
- this.stripFields = stripFields;
- }
+ /**
+ * Are fields currently being stripped from
+ * the text that this HeaderStories returns?
+ * Default is false, but can be changed
+ */
+ public boolean areFieldsStripped() {
+ return stripFields;
+ }
+ /**
+ * Should fields (eg macros) be stripped from
+ * the text that this class returns?
+ * Default is not to strip.
+ */
+ public void setAreFieldsStripped(boolean stripFields) {
+ this.stripFields = stripFields;
+ }
}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/Range.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/Range.java
index ec37019226..a3fd882d64 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/Range.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/Range.java
@@ -56,11 +56,11 @@ public class Range {
private static final Logger LOG = LogManager.getLogger(Range.class);
- /**
+ /**
* @deprecated POI 3.8 beta 5
*/
@Deprecated
- public static final int TYPE_PARAGRAPH = 0;
+ public static final int TYPE_PARAGRAPH = 0;
/**
* @deprecated POI 3.8 beta 5
@@ -98,226 +98,226 @@ public class Range {
@Deprecated
public static final int TYPE_UNDEFINED = 6;
- /** Needed so inserts and deletes will ripple up through containing Ranges */
- private final Range _parent;
+ /** Needed so inserts and deletes will ripple up through containing Ranges */
+ private final Range _parent;
- /** The starting character offset of this range. */
- protected final int _start;
+ /** The starting character offset of this range. */
+ protected final int _start;
- /** The ending character offset of this range. */
- protected int _end;
+ /** The ending character offset of this range. */
+ protected int _end;
- /** The document this range belongs to. */
- protected final HWPFDocumentCore _doc;
+ /** The document this range belongs to. */
+ protected final HWPFDocumentCore _doc;
- /** Have we loaded the section indexes yet */
- boolean _sectionRangeFound;
+ /** Have we loaded the section indexes yet */
+ boolean _sectionRangeFound;
- /** All sections that belong to the document this Range belongs to. */
- protected final List _sections;
+ /** All sections that belong to the document this Range belongs to. */
+ protected final List _sections;
- /** The start index in the sections list for this Range */
- protected int _sectionStart;
+ /** The start index in the sections list for this Range */
+ protected int _sectionStart;
- /** The end index in the sections list for this Range. */
- protected int _sectionEnd;
+ /** The end index in the sections list for this Range. */
+ protected int _sectionEnd;
- /** Have we loaded the paragraph indexes yet. */
- protected boolean _parRangeFound;
+ /** Have we loaded the paragraph indexes yet. */
+ protected boolean _parRangeFound;
- /** All paragraphs that belong to the document this Range belongs to. */
- protected final List _paragraphs;
+ /** All paragraphs that belong to the document this Range belongs to. */
+ protected final List _paragraphs;
- /** The start index in the paragraphs list for this Range, inclusive */
- protected int _parStart;
+ /** The start index in the paragraphs list for this Range, inclusive */
+ protected int _parStart;
- /** The end index in the paragraphs list for this Range, exclusive */
- protected int _parEnd;
+ /** The end index in the paragraphs list for this Range, exclusive */
+ protected int _parEnd;
- /** Have we loaded the characterRun indexes yet. */
- protected boolean _charRangeFound;
+ /** Have we loaded the characterRun indexes yet. */
+ protected boolean _charRangeFound;
- /** All CharacterRuns that belong to the document this Range belongs to. */
- protected List _characters;
+ /** All CharacterRuns that belong to the document this Range belongs to. */
+ protected List _characters;
- /** The start index in the characterRuns list for this Range */
- protected int _charStart;
+ /** The start index in the characterRuns list for this Range */
+ protected int _charStart;
- /** The end index in the characterRuns list for this Range. */
- protected int _charEnd;
+ /** The end index in the characterRuns list for this Range. */
+ protected int _charEnd;
- protected StringBuilder _text;
+ protected StringBuilder _text;
- /**
- * Used to construct a Range from a document. This is generally used to
- * create a Range that spans the whole document, or at least one whole part
- * of the document (eg main text, header, comment)
- *
- * @param start Starting character offset of the range.
- * @param end Ending character offset of the range.
- * @param doc The HWPFDocument the range is based on.
- */
- public Range(int start, int end, HWPFDocumentCore doc) {
- _start = start;
- _end = end;
- _doc = doc;
- _sections = _doc.getSectionTable().getSections();
- _paragraphs = _doc.getParagraphTable().getParagraphs();
- _characters = _doc.getCharacterTable().getTextRuns();
- _text = _doc.getText();
- _parent = null;
+ /**
+ * Used to construct a Range from a document. This is generally used to
+ * create a Range that spans the whole document, or at least one whole part
+ * of the document (eg main text, header, comment)
+ *
+ * @param start Starting character offset of the range.
+ * @param end Ending character offset of the range.
+ * @param doc The HWPFDocument the range is based on.
+ */
+ public Range(int start, int end, HWPFDocumentCore doc) {
+ _start = start;
+ _end = end;
+ _doc = doc;
+ _sections = _doc.getSectionTable().getSections();
+ _paragraphs = _doc.getParagraphTable().getParagraphs();
+ _characters = _doc.getCharacterTable().getTextRuns();
+ _text = _doc.getText();
+ _parent = null;
- sanityCheckStartEnd();
- }
+ sanityCheckStartEnd();
+ }
- /**
- * Used to create Ranges that are children of other Ranges.
- *
- * @param start Starting character offset of the range.
- * @param end Ending character offset of the range.
- * @param parent The parent this range belongs to.
- */
- protected Range(int start, int end, Range parent) {
- _start = start;
- _end = end;
- _doc = parent._doc;
- _sections = parent._sections;
- _paragraphs = parent._paragraphs;
- _characters = parent._characters;
- _text = parent._text;
- _parent = parent;
+ /**
+ * Used to create Ranges that are children of other Ranges.
+ *
+ * @param start Starting character offset of the range.
+ * @param end Ending character offset of the range.
+ * @param parent The parent this range belongs to.
+ */
+ protected Range(int start, int end, Range parent) {
+ _start = start;
+ _end = end;
+ _doc = parent._doc;
+ _sections = parent._sections;
+ _paragraphs = parent._paragraphs;
+ _characters = parent._characters;
+ _text = parent._text;
+ _parent = parent;
- sanityCheckStartEnd();
- sanityCheck();
- }
+ sanityCheckStartEnd();
+ sanityCheck();
+ }
- protected Range(Range other) {
- _parent = other._parent;
- _start = other._start;
- _end = other._end;
- _doc = other._doc;
- _sectionRangeFound = other._sectionRangeFound;
- _sections = (other._sections == null) ? null : other._sections.stream().map(SEPX::copy).collect(toList());
- _sectionStart = other._sectionStart;
- _sectionEnd = other._sectionEnd;
- _parRangeFound = other._parRangeFound;
- _paragraphs = (other._paragraphs == null) ? null : other._paragraphs.stream().map(PAPX::copy).collect(toList());
- _parStart = other._parStart;
- _parEnd = other._parEnd;
- _charRangeFound = other._charRangeFound;
- _characters = (other._characters == null) ? null : other._characters.stream().map(CHPX::copy).collect(toList());
- _charStart = other._charStart;
- _charEnd = other._charEnd;
- _text = (other._text == null) ? null : new StringBuilder(other._text);
- }
+ protected Range(Range other) {
+ _parent = other._parent;
+ _start = other._start;
+ _end = other._end;
+ _doc = other._doc;
+ _sectionRangeFound = other._sectionRangeFound;
+ _sections = (other._sections == null) ? null : other._sections.stream().map(SEPX::copy).collect(toList());
+ _sectionStart = other._sectionStart;
+ _sectionEnd = other._sectionEnd;
+ _parRangeFound = other._parRangeFound;
+ _paragraphs = (other._paragraphs == null) ? null : other._paragraphs.stream().map(PAPX::copy).collect(toList());
+ _parStart = other._parStart;
+ _parEnd = other._parEnd;
+ _charRangeFound = other._charRangeFound;
+ _characters = (other._characters == null) ? null : other._characters.stream().map(CHPX::copy).collect(toList());
+ _charStart = other._charStart;
+ _charEnd = other._charEnd;
+ _text = (other._text == null) ? null : new StringBuilder(other._text);
+ }
- /**
- * Ensures that the start and end were were given are actually valid, to
- * avoid issues later on if they're not
- */
- private void sanityCheckStartEnd() {
- if (_start < 0) {
- throw new IllegalArgumentException("Range start must not be negative. Given " + _start);
- }
- if (_end < _start) {
- throw new IllegalArgumentException("The end (" + _end
- + ") must not be before the start (" + _start + ")");
- }
- }
+ /**
+ * Ensures that the start and end were were given are actually valid, to
+ * avoid issues later on if they're not
+ */
+ private void sanityCheckStartEnd() {
+ if (_start < 0) {
+ throw new IllegalArgumentException("Range start must not be negative. Given " + _start);
+ }
+ if (_end < _start) {
+ throw new IllegalArgumentException("The end (" + _end
+ + ") must not be before the start (" + _start + ")");
+ }
+ }
- /**
- * Gets the text that this Range contains.
- *
- * @return The text for this range.
- */
- public String text() {
- return _text.substring( _start, _end );
- }
+ /**
+ * Gets the text that this Range contains.
+ *
+ * @return The text for this range.
+ */
+ public String text() {
+ return _text.substring( _start, _end );
+ }
- /**
- * Removes any fields (eg macros, page markers etc) from the string.
- * Normally used to make some text suitable for showing to humans, and the
- * resultant text should not normally be saved back into the document!
- */
- public static String stripFields(String text) {
- // First up, fields can be nested...
- // A field can be 0x13 [contents] 0x15
- // Or it can be 0x13 [contents] 0x14 [real text] 0x15
+ /**
+ * Removes any fields (eg macros, page markers etc) from the string.
+ * Normally used to make some text suitable for showing to humans, and the
+ * resultant text should not normally be saved back into the document!
+ */
+ public static String stripFields(String text) {
+ // First up, fields can be nested...
+ // A field can be 0x13 [contents] 0x15
+ // Or it can be 0x13 [contents] 0x14 [real text] 0x15
- // If there are no fields, all easy
- if (text.indexOf('\u0013') == -1)
- return text;
+ // If there are no fields, all easy
+ if (text.indexOf('\u0013') == -1)
+ return text;
- // Loop over until they're all gone
- // That's when we're out of both 0x13s and 0x15s
- while (text.indexOf('\u0013') > -1 && text.indexOf('\u0015') > -1) {
- int first13 = text.indexOf('\u0013');
- int next13 = text.indexOf('\u0013', first13 + 1);
- int first14 = text.indexOf('\u0014', first13 + 1);
- int last15 = text.lastIndexOf('\u0015');
+ // Loop over until they're all gone
+ // That's when we're out of both 0x13s and 0x15s
+ while (text.indexOf('\u0013') > -1 && text.indexOf('\u0015') > -1) {
+ int first13 = text.indexOf('\u0013');
+ int next13 = text.indexOf('\u0013', first13 + 1);
+ int first14 = text.indexOf('\u0014', first13 + 1);
+ int last15 = text.lastIndexOf('\u0015');
- // If they're the wrong way around, give up
- if (last15 < first13) {
- break;
- }
+ // If they're the wrong way around, give up
+ if (last15 < first13) {
+ break;
+ }
- // If no more 13s and 14s, just zap
- if (next13 == -1 && first14 == -1) {
- text = text.substring(0, first13) + text.substring(last15 + 1);
- break;
- }
+ // If no more 13s and 14s, just zap
+ if (next13 == -1 && first14 == -1) {
+ text = text.substring(0, first13) + text.substring(last15 + 1);
+ break;
+ }
- // If a 14 comes before the next 13, then
- // zap from the 13 to the 14, and remove
- // the 15
- if (first14 != -1 && (first14 < next13 || next13 == -1)) {
- text = text.substring(0, first13) + text.substring(first14 + 1, last15)
- + text.substring(last15 + 1);
- continue;
- }
+ // If a 14 comes before the next 13, then
+ // zap from the 13 to the 14, and remove
+ // the 15
+ if (first14 != -1 && (first14 < next13 || next13 == -1)) {
+ text = text.substring(0, first13) + text.substring(first14 + 1, last15)
+ + text.substring(last15 + 1);
+ continue;
+ }
- // Another 13 comes before the next 14.
- // This means there's nested stuff, so we
- // can just zap the lot
- text = text.substring(0, first13) + text.substring(last15 + 1);
- }
+ // Another 13 comes before the next 14.
+ // This means there's nested stuff, so we
+ // can just zap the lot
+ text = text.substring(0, first13) + text.substring(last15 + 1);
+ }
- return text;
- }
+ return text;
+ }
- /**
- * Used to get the number of sections in a range. If this range is smaller
- * than a section, it will return 1 for its containing section.
- *
- * @return The number of sections in this range.
- */
- public int numSections() {
- initSections();
- return _sectionEnd - _sectionStart;
- }
+ /**
+ * Used to get the number of sections in a range. If this range is smaller
+ * than a section, it will return 1 for its containing section.
+ *
+ * @return The number of sections in this range.
+ */
+ public int numSections() {
+ initSections();
+ return _sectionEnd - _sectionStart;
+ }
- /**
- * Used to get the number of paragraphs in a range. If this range is smaller
- * than a paragraph, it will return 1 for its containing paragraph.
- *
- * @return The number of paragraphs in this range.
- */
+ /**
+ * Used to get the number of paragraphs in a range. If this range is smaller
+ * than a paragraph, it will return 1 for its containing paragraph.
+ *
+ * @return The number of paragraphs in this range.
+ */
- public int numParagraphs() {
- initParagraphs();
- return _parEnd - _parStart;
- }
+ public int numParagraphs() {
+ initParagraphs();
+ return _parEnd - _parStart;
+ }
- /**
- *
- * @return The number of characterRuns in this range.
- */
+ /**
+ *
+ * @return The number of characterRuns in this range.
+ */
- public int numCharacterRuns() {
- initCharacterRuns();
- return _charEnd - _charStart;
- }
+ public int numCharacterRuns() {
+ initCharacterRuns();
+ return _charEnd - _charStart;
+ }
/**
* Inserts text into the front of this range.
@@ -344,7 +344,7 @@ public class Range {
// update the FIB.CCPText + friends fields
adjustFIB( text.length() );
- sanityCheck();
+ sanityCheck();
return getCharacterRun( 0 );
}
@@ -376,195 +376,195 @@ public class Range {
return getCharacterRun( numCharacterRuns() - 1 );
}
- /**
- * Inserts text into the front of this range and it gives that text the
- * CharacterProperties specified in props.
- *
- * @param text
- * The text to insert.
- * @param props
- * The CharacterProperties to give the text.
- * @return A new CharacterRun that has the given text and properties and is
- * n ow a part of the document.
+ /**
+ * Inserts text into the front of this range and it gives that text the
+ * CharacterProperties specified in props.
+ *
+ * @param text
+ * The text to insert.
+ * @param props
+ * The CharacterProperties to give the text.
+ * @return A new CharacterRun that has the given text and properties and is
+ * n ow a part of the document.
* @deprecated POI 3.8 beta 4. User code should not work with {@link CharacterProperties}
- */
+ */
@Deprecated
- private CharacterRun insertBefore(String text, CharacterProperties props)
- {
- initAll();
- PAPX papx = _paragraphs.get(_parStart);
- short istd = papx.getIstd();
+ private CharacterRun insertBefore(String text, CharacterProperties props)
+ {
+ initAll();
+ PAPX papx = _paragraphs.get(_parStart);
+ short istd = papx.getIstd();
- StyleSheet ss = _doc.getStyleSheet();
- CharacterProperties baseStyle = ss.getCharacterStyle(istd);
- byte[] grpprl = CharacterSprmCompressor.compressCharacterProperty(props, baseStyle);
- SprmBuffer buf = new SprmBuffer(grpprl, 0);
- _doc.getCharacterTable().insert(_charStart, _start, buf);
+ StyleSheet ss = _doc.getStyleSheet();
+ CharacterProperties baseStyle = ss.getCharacterStyle(istd);
+ byte[] grpprl = CharacterSprmCompressor.compressCharacterProperty(props, baseStyle);
+ SprmBuffer buf = new SprmBuffer(grpprl, 0);
+ _doc.getCharacterTable().insert(_charStart, _start, buf);
- return insertBefore(text);
- }
+ return insertBefore(text);
+ }
- /**
- * Inserts text onto the end of this range and gives that text the
- * CharacterProperties specified in props.
- *
- * @param text
- * The text to insert.
- * @param props
- * The CharacterProperties to give the text.
- * @return A new CharacterRun that has the given text and properties and is
- * n ow a part of the document.
- * @deprecated POI 3.8 beta 4. User code should not work with {@link CharacterProperties}
- */
+ /**
+ * Inserts text onto the end of this range and gives that text the
+ * CharacterProperties specified in props.
+ *
+ * @param text
+ * The text to insert.
+ * @param props
+ * The CharacterProperties to give the text.
+ * @return A new CharacterRun that has the given text and properties and is
+ * n ow a part of the document.
+ * @deprecated POI 3.8 beta 4. User code should not work with {@link CharacterProperties}
+ */
@Deprecated
- private CharacterRun insertAfter(String text, CharacterProperties props)
- {
- initAll();
- PAPX papx = _paragraphs.get(_parEnd - 1);
- short istd = papx.getIstd();
+ private CharacterRun insertAfter(String text, CharacterProperties props)
+ {
+ initAll();
+ PAPX papx = _paragraphs.get(_parEnd - 1);
+ short istd = papx.getIstd();
- StyleSheet ss = _doc.getStyleSheet();
- CharacterProperties baseStyle = ss.getCharacterStyle(istd);
- byte[] grpprl = CharacterSprmCompressor.compressCharacterProperty(props, baseStyle);
- SprmBuffer buf = new SprmBuffer(grpprl, 0);
- _doc.getCharacterTable().insert(_charEnd, _end, buf);
- _charEnd++;
- return insertAfter(text);
- }
+ StyleSheet ss = _doc.getStyleSheet();
+ CharacterProperties baseStyle = ss.getCharacterStyle(istd);
+ byte[] grpprl = CharacterSprmCompressor.compressCharacterProperty(props, baseStyle);
+ SprmBuffer buf = new SprmBuffer(grpprl, 0);
+ _doc.getCharacterTable().insert(_charEnd, _end, buf);
+ _charEnd++;
+ return insertAfter(text);
+ }
- /**
- * Inserts and empty paragraph into the front of this range.
- *
- * @param props
- * The properties that the new paragraph will have.
- * @param styleIndex
- * The index into the stylesheet for the new paragraph.
- * @return The newly inserted paragraph.
- * @deprecated POI 3.8 beta 4. Use code shall not work with {@link ParagraphProperties}
- */
- @Deprecated
- private Paragraph insertBefore(ParagraphProperties props, int styleIndex)
- {
- return this.insertBefore(props, styleIndex, "\r");
- }
-
- /**
- * Inserts a paragraph into the front of this range. The paragraph will
- * contain one character run that has the default properties for the
- * paragraph's style.
- *
- * It is necessary for the text to end with the character '\r'
- *
- * @param props
- * The paragraph's properties.
- * @param styleIndex
- * The index of the paragraph's style in the style sheet.
- * @param text
- * The text to insert.
- * @return A newly inserted paragraph.
+ /**
+ * Inserts and empty paragraph into the front of this range.
+ *
+ * @param props
+ * The properties that the new paragraph will have.
+ * @param styleIndex
+ * The index into the stylesheet for the new paragraph.
+ * @return The newly inserted paragraph.
* @deprecated POI 3.8 beta 4. Use code shall not work with {@link ParagraphProperties}
- */
+ */
@Deprecated
- private Paragraph insertBefore(ParagraphProperties props, int styleIndex, String text)
- {
- initAll();
- StyleSheet ss = _doc.getStyleSheet();
- ParagraphProperties baseStyle = ss.getParagraphStyle(styleIndex);
- CharacterProperties baseChp = ss.getCharacterStyle(styleIndex);
+ private Paragraph insertBefore(ParagraphProperties props, int styleIndex)
+ {
+ return this.insertBefore(props, styleIndex, "\r");
+ }
- byte[] grpprl = ParagraphSprmCompressor.compressParagraphProperty(props, baseStyle);
- byte[] withIndex = new byte[grpprl.length + LittleEndianConsts.SHORT_SIZE];
- LittleEndian.putShort(withIndex, 0, (short) styleIndex);
- System.arraycopy(grpprl, 0, withIndex, LittleEndianConsts.SHORT_SIZE, grpprl.length);
- SprmBuffer buf = new SprmBuffer(withIndex, 2);
-
- _doc.getParagraphTable().insert(_parStart, _start, buf);
- insertBefore(text, baseChp);
- return getParagraph(0);
- }
-
- /**
- * Inserts and empty paragraph into the end of this range.
- *
- * @param props
- * The properties that the new paragraph will have.
- * @param styleIndex
- * The index into the stylesheet for the new paragraph.
- * @return The newly inserted paragraph.
+ /**
+ * Inserts a paragraph into the front of this range. The paragraph will
+ * contain one character run that has the default properties for the
+ * paragraph's style.
+ *
+ * It is necessary for the text to end with the character '\r'
+ *
+ * @param props
+ * The paragraph's properties.
+ * @param styleIndex
+ * The index of the paragraph's style in the style sheet.
+ * @param text
+ * The text to insert.
+ * @return A newly inserted paragraph.
* @deprecated POI 3.8 beta 4. Use code shall not work with {@link ParagraphProperties}
- */
+ */
@Deprecated
- Paragraph insertAfter(ParagraphProperties props, int styleIndex)
- {
- return this.insertAfter(props, styleIndex, "\r");
- }
+ private Paragraph insertBefore(ParagraphProperties props, int styleIndex, String text)
+ {
+ initAll();
+ StyleSheet ss = _doc.getStyleSheet();
+ ParagraphProperties baseStyle = ss.getParagraphStyle(styleIndex);
+ CharacterProperties baseChp = ss.getCharacterStyle(styleIndex);
- /**
- * Inserts a paragraph into the end of this range. The paragraph will
- * contain one character run that has the default properties for the
- * paragraph's style.
- *
- * It is necessary for the text to end with the character '\r'
- *
- * @param props
- * The paragraph's properties.
- * @param styleIndex
- * The index of the paragraph's style in the style sheet.
- * @param text
- * The text to insert.
- * @return A newly inserted paragraph.
+ byte[] grpprl = ParagraphSprmCompressor.compressParagraphProperty(props, baseStyle);
+ byte[] withIndex = new byte[grpprl.length + LittleEndianConsts.SHORT_SIZE];
+ LittleEndian.putShort(withIndex, 0, (short) styleIndex);
+ System.arraycopy(grpprl, 0, withIndex, LittleEndianConsts.SHORT_SIZE, grpprl.length);
+ SprmBuffer buf = new SprmBuffer(withIndex, 2);
+
+ _doc.getParagraphTable().insert(_parStart, _start, buf);
+ insertBefore(text, baseChp);
+ return getParagraph(0);
+ }
+
+ /**
+ * Inserts and empty paragraph into the end of this range.
+ *
+ * @param props
+ * The properties that the new paragraph will have.
+ * @param styleIndex
+ * The index into the stylesheet for the new paragraph.
+ * @return The newly inserted paragraph.
* @deprecated POI 3.8 beta 4. Use code shall not work with {@link ParagraphProperties}
- */
+ */
@Deprecated
- Paragraph insertAfter(ParagraphProperties props, int styleIndex, String text)
- {
- initAll();
- StyleSheet ss = _doc.getStyleSheet();
- ParagraphProperties baseStyle = ss.getParagraphStyle(styleIndex);
- CharacterProperties baseChp = ss.getCharacterStyle(styleIndex);
+ Paragraph insertAfter(ParagraphProperties props, int styleIndex)
+ {
+ return this.insertAfter(props, styleIndex, "\r");
+ }
- byte[] grpprl = ParagraphSprmCompressor.compressParagraphProperty(props, baseStyle);
- byte[] withIndex = new byte[grpprl.length + LittleEndianConsts.SHORT_SIZE];
- LittleEndian.putShort(withIndex, 0, (short) styleIndex);
- System.arraycopy(grpprl, 0, withIndex, LittleEndianConsts.SHORT_SIZE, grpprl.length);
- SprmBuffer buf = new SprmBuffer(withIndex, 2);
+ /**
+ * Inserts a paragraph into the end of this range. The paragraph will
+ * contain one character run that has the default properties for the
+ * paragraph's style.
+ *
+ * It is necessary for the text to end with the character '\r'
+ *
+ * @param props
+ * The paragraph's properties.
+ * @param styleIndex
+ * The index of the paragraph's style in the style sheet.
+ * @param text
+ * The text to insert.
+ * @return A newly inserted paragraph.
+ * @deprecated POI 3.8 beta 4. Use code shall not work with {@link ParagraphProperties}
+ */
+ @Deprecated
+ Paragraph insertAfter(ParagraphProperties props, int styleIndex, String text)
+ {
+ initAll();
+ StyleSheet ss = _doc.getStyleSheet();
+ ParagraphProperties baseStyle = ss.getParagraphStyle(styleIndex);
+ CharacterProperties baseChp = ss.getCharacterStyle(styleIndex);
- _doc.getParagraphTable().insert(_parEnd, _end, buf);
- _parEnd++;
- insertAfter(text, baseChp);
- return getParagraph(numParagraphs() - 1);
- }
+ byte[] grpprl = ParagraphSprmCompressor.compressParagraphProperty(props, baseStyle);
+ byte[] withIndex = new byte[grpprl.length + LittleEndianConsts.SHORT_SIZE];
+ LittleEndian.putShort(withIndex, 0, (short) styleIndex);
+ System.arraycopy(grpprl, 0, withIndex, LittleEndianConsts.SHORT_SIZE, grpprl.length);
+ SprmBuffer buf = new SprmBuffer(withIndex, 2);
- public void delete() {
+ _doc.getParagraphTable().insert(_parEnd, _end, buf);
+ _parEnd++;
+ insertAfter(text, baseChp);
+ return getParagraph(numParagraphs() - 1);
+ }
- initAll();
+ public void delete() {
- int numSections = _sections.size();
- int numRuns = _characters.size();
- int numParagraphs = _paragraphs.size();
+ initAll();
- for (int x = _charStart; x < numRuns; x++) {
- CHPX chpx = _characters.get(x);
- chpx.adjustForDelete(_start, _end - _start);
- }
+ int numSections = _sections.size();
+ int numRuns = _characters.size();
+ int numParagraphs = _paragraphs.size();
- for (int x = _parStart; x < numParagraphs; x++) {
- PAPX papx = _paragraphs.get(x);
- // System.err.println("Paragraph " + x + " was " + papx.getStart() +
- // " -> " + papx.getEnd());
- papx.adjustForDelete(_start, _end - _start);
- // System.err.println("Paragraph " + x + " is now " +
- // papx.getStart() + " -> " + papx.getEnd());
- }
+ for (int x = _charStart; x < numRuns; x++) {
+ CHPX chpx = _characters.get(x);
+ chpx.adjustForDelete(_start, _end - _start);
+ }
- for (int x = _sectionStart; x < numSections; x++) {
- SEPX sepx = _sections.get(x);
- // System.err.println("Section " + x + " was " + sepx.getStart() +
- // " -> " + sepx.getEnd());
- sepx.adjustForDelete(_start, _end - _start);
- // System.err.println("Section " + x + " is now " + sepx.getStart()
- // + " -> " + sepx.getEnd());
- }
+ for (int x = _parStart; x < numParagraphs; x++) {
+ PAPX papx = _paragraphs.get(x);
+ // System.err.println("Paragraph " + x + " was " + papx.getStart() +
+ // " -> " + papx.getEnd());
+ papx.adjustForDelete(_start, _end - _start);
+ // System.err.println("Paragraph " + x + " is now " +
+ // papx.getStart() + " -> " + papx.getEnd());
+ }
+
+ for (int x = _sectionStart; x < numSections; x++) {
+ SEPX sepx = _sections.get(x);
+ // System.err.println("Section " + x + " was " + sepx.getStart() +
+ // " -> " + sepx.getEnd());
+ sepx.adjustForDelete(_start, _end - _start);
+ // System.err.println("Section " + x + " is now " + sepx.getStart()
+ // + " -> " + sepx.getEnd());
+ }
if ( _doc instanceof HWPFDocument )
{
@@ -579,9 +579,9 @@ public class Range {
parent.adjustForInsert( -( _end - _start ) );
}
- // update the FIB.CCPText + friends field
- adjustFIB(-(_end - _start));
- }
+ // update the FIB.CCPText + friends field
+ adjustFIB(-(_end - _start));
+ }
/**
* Inserts a simple table into the beginning of this range.
@@ -592,7 +592,7 @@ public class Range {
* The number of rows.
* @return The empty Table that is now part of the document.
*/
- public Table insertTableBefore(short columns, int rows) {
+ public Table insertTableBefore(short columns, int rows) {
ParagraphProperties parProps = new ParagraphProperties();
parProps.setFInTable(true);
parProps.setItap( 1 );
@@ -617,7 +617,7 @@ public class Range {
final int diff = newEnd - oldEnd;
return new Table( _start, _start + diff, this, 1 );
- }
+ }
/**
* Replace range text with new one, adding it to the range and deleting
@@ -648,60 +648,60 @@ public class Range {
}
}
- /**
- * Replace (one instance of) a piece of text with another...
- *
- * @param pPlaceHolder
- * The text to be replaced (e.g., "${organization}")
- * @param pValue
- * The replacement text (e.g., "Apache Software Foundation")
- * @param pOffset
- * The offset or index where the text to be replaced begins
- * (relative to/within this {@code Range})
- */
- @Internal
- public void replaceText(String pPlaceHolder, String pValue, int pOffset) {
- int absPlaceHolderIndex = getStartOffset() + pOffset;
+ /**
+ * Replace (one instance of) a piece of text with another...
+ *
+ * @param pPlaceHolder
+ * The text to be replaced (e.g., "${organization}")
+ * @param pValue
+ * The replacement text (e.g., "Apache Software Foundation")
+ * @param pOffset
+ * The offset or index where the text to be replaced begins
+ * (relative to/within this {@code Range})
+ */
+ @Internal
+ public void replaceText(String pPlaceHolder, String pValue, int pOffset) {
+ int absPlaceHolderIndex = getStartOffset() + pOffset;
- Range subRange = new Range(absPlaceHolderIndex,
- (absPlaceHolderIndex + pPlaceHolder.length()), this);
- subRange.insertBefore(pValue);
+ Range subRange = new Range(absPlaceHolderIndex,
+ (absPlaceHolderIndex + pPlaceHolder.length()), this);
+ subRange.insertBefore(pValue);
- // re-create the sub-range so we can delete it
- subRange = new Range((absPlaceHolderIndex + pValue.length()), (absPlaceHolderIndex
- + pPlaceHolder.length() + pValue.length()), this);
+ // re-create the sub-range so we can delete it
+ subRange = new Range((absPlaceHolderIndex + pValue.length()), (absPlaceHolderIndex
+ + pPlaceHolder.length() + pValue.length()), this);
- // deletes are automagically propagated
- subRange.delete();
- }
+ // deletes are automagically propagated
+ subRange.delete();
+ }
- /**
- * Replace (all instances of) a piece of text with another...
- *
- * @param pPlaceHolder
- * The text to be replaced (e.g., "${organization}")
- * @param pValue
- * The replacement text (e.g., "Apache Software Foundation")
- */
- public void replaceText(String pPlaceHolder, String pValue) {
- while (true) {
- String text = text();
- int offset = text.indexOf(pPlaceHolder);
- if (offset >= 0) {
- replaceText(pPlaceHolder, pValue, offset);
- } else {
- break;
- }
- }
- }
+ /**
+ * Replace (all instances of) a piece of text with another...
+ *
+ * @param pPlaceHolder
+ * The text to be replaced (e.g., "${organization}")
+ * @param pValue
+ * The replacement text (e.g., "Apache Software Foundation")
+ */
+ public void replaceText(String pPlaceHolder, String pValue) {
+ while (true) {
+ String text = text();
+ int offset = text.indexOf(pPlaceHolder);
+ if (offset >= 0) {
+ replaceText(pPlaceHolder, pValue, offset);
+ } else {
+ break;
+ }
+ }
+ }
- /**
- * Gets the character run at index. The index is relative to this range.
- *
- * @param index
- * The index of the character run to get.
- * @return The character run at the specified index in this range.
- */
+ /**
+ * Gets the character run at index. The index is relative to this range.
+ *
+ * @param index
+ * The index of the character run to get.
+ * @return The character run at the specified index in this range.
+ */
public CharacterRun getCharacterRun( int index )
{
initCharacterRuns();
@@ -740,32 +740,32 @@ public class Range {
istd = papx.getIstd();
}
- return new CharacterRun( chpx, _doc.getStyleSheet(), istd,
- this);
+ return new CharacterRun( chpx, _doc.getStyleSheet(), istd,
+ this);
}
- /**
- * Gets the section at index. The index is relative to this range.
- *
- * @param index
- * The index of the section to get.
- * @return The section at the specified index in this range.
- */
- public Section getSection(int index) {
- initSections();
- SEPX sepx = _sections.get(index + _sectionStart);
- return new Section(sepx, this);
- }
+ /**
+ * Gets the section at index. The index is relative to this range.
+ *
+ * @param index
+ * The index of the section to get.
+ * @return The section at the specified index in this range.
+ */
+ public Section getSection(int index) {
+ initSections();
+ SEPX sepx = _sections.get(index + _sectionStart);
+ return new Section(sepx, this);
+ }
- /**
- * Gets the paragraph at index. The index is relative to this range.
- *
- * @param index
- * The index of the paragraph to get.
- * @return The paragraph at the specified index in this range.
- */
+ /**
+ * Gets the paragraph at index. The index is relative to this range.
+ *
+ * @param index
+ * The index of the paragraph to get.
+ * @return The paragraph at the specified index in this range.
+ */
- public Paragraph getParagraph(int index) {
+ public Paragraph getParagraph(int index) {
initParagraphs();
if ( index + _parStart >= _parEnd )
@@ -773,27 +773,27 @@ public class Range {
+ (index + _parStart) + ") not in range [" + _parStart
+ "; " + _parEnd + ")" );
- PAPX papx = _paragraphs.get(index + _parStart);
- return Paragraph.newParagraph( this, papx );
- }
+ PAPX papx = _paragraphs.get(index + _parStart);
+ return Paragraph.newParagraph( this, papx );
+ }
- /**
- * Gets the table that starts with paragraph. In a Word file, a table
- * consists of a group of paragraphs with certain flags set.
- *
- * @param paragraph
- * The paragraph that is the first paragraph in the table.
- * @return The table that starts with paragraph
- */
- public Table getTable(Paragraph paragraph) {
- if (!paragraph.isInTable()) {
- throw new IllegalArgumentException("This paragraph doesn't belong to a table");
- }
+ /**
+ * Gets the table that starts with paragraph. In a Word file, a table
+ * consists of a group of paragraphs with certain flags set.
+ *
+ * @param paragraph
+ * The paragraph that is the first paragraph in the table.
+ * @return The table that starts with paragraph
+ */
+ public Table getTable(Paragraph paragraph) {
+ if (!paragraph.isInTable()) {
+ throw new IllegalArgumentException("This paragraph doesn't belong to a table");
+ }
- Range r = paragraph;
- if (r._parent != this) {
- throw new IllegalArgumentException("This paragraph is not a child of this range instance");
- }
+ Range r = paragraph;
+ if (r._parent != this) {
+ throw new IllegalArgumentException("This paragraph is not a child of this range instance");
+ }
r.initAll();
int tableLevel = paragraph.getTableLevel();
@@ -825,8 +825,8 @@ public class Range {
initAll();
if ( tableEndInclusive >= this._parEnd )
{
- LOG.atWarn().log("The table's bounds [{}; {}) fall outside of this Range paragraphs numbers [{}; {})",
- this._parStart, box(tableEndInclusive),box(this._parStart),box(this._parEnd));
+ LOG.atWarn().log("The table's bounds [{}; {}) fall outside of this Range paragraphs numbers [{}; {})",
+ this._parStart, box(tableEndInclusive),box(this._parStart),box(this._parEnd));
}
if ( tableEndInclusive < 0 )
@@ -841,50 +841,50 @@ public class Range {
this, paragraph.getTableLevel() );
}
- /**
- * loads all of the list indexes.
- */
- protected void initAll() {
- initCharacterRuns();
- initParagraphs();
- initSections();
- }
+ /**
+ * loads all of the list indexes.
+ */
+ protected void initAll() {
+ initCharacterRuns();
+ initParagraphs();
+ initSections();
+ }
- /**
- * inits the paragraph list indexes.
- */
- private void initParagraphs() {
- if (!_parRangeFound) {
- int[] point = findRange(_paragraphs, _start, _end);
- _parStart = point[0];
- _parEnd = point[1];
- _parRangeFound = true;
- }
- }
+ /**
+ * inits the paragraph list indexes.
+ */
+ private void initParagraphs() {
+ if (!_parRangeFound) {
+ int[] point = findRange(_paragraphs, _start, _end);
+ _parStart = point[0];
+ _parEnd = point[1];
+ _parRangeFound = true;
+ }
+ }
- /**
- * inits the character run list indexes.
- */
- private void initCharacterRuns() {
- if (!_charRangeFound) {
- int[] point = findRange(_characters, _start, _end);
- _charStart = point[0];
- _charEnd = point[1];
- _charRangeFound = true;
- }
- }
+ /**
+ * inits the character run list indexes.
+ */
+ private void initCharacterRuns() {
+ if (!_charRangeFound) {
+ int[] point = findRange(_characters, _start, _end);
+ _charStart = point[0];
+ _charEnd = point[1];
+ _charRangeFound = true;
+ }
+ }
- /**
- * inits the section list indexes.
- */
- private void initSections() {
- if (!_sectionRangeFound) {
- int[] point = findRange(_sections, _sectionStart, _start, _end);
- _sectionStart = point[0];
- _sectionEnd = point[1];
- _sectionRangeFound = true;
- }
- }
+ /**
+ * inits the section list indexes.
+ */
+ private void initSections() {
+ if (!_sectionRangeFound) {
+ int[] point = findRange(_sections, _sectionStart, _start, _end);
+ _sectionStart = point[0];
+ _sectionEnd = point[1];
+ _sectionRangeFound = true;
+ }
+ }
private static int binarySearchStart( List extends PropertyNode>> rpl,
int start )
@@ -980,43 +980,43 @@ public class Range {
if ( startIndex < 0 || startIndex >= rpl.size()
|| startIndex > endIndex || endIndex < 0
|| endIndex >= rpl.size() ) {
- throw new DocumentFormatException("problem finding range");
- }
+ throw new DocumentFormatException("problem finding range");
+ }
return new int[] { startIndex, endIndex + 1 };
}
- /**
- * Used to find the list indexes of a particular property.
- *
- * @param rpl
- * A list of property nodes.
- * @param min
- * A hint on where to start looking.
- * @param start
- * The starting character offset.
- * @param end
- * The ending character offset.
- * @return An int array of length 2. The first int is the start index and
- * the second int is the end index.
- */
- private int[] findRange(List extends PropertyNode>> rpl, int min, int start, int end) {
- int x = min;
+ /**
+ * Used to find the list indexes of a particular property.
+ *
+ * @param rpl
+ * A list of property nodes.
+ * @param min
+ * A hint on where to start looking.
+ * @param start
+ * The starting character offset.
+ * @param end
+ * The ending character offset.
+ * @return An int array of length 2. The first int is the start index and
+ * the second int is the end index.
+ */
+ private int[] findRange(List extends PropertyNode>> rpl, int min, int start, int end) {
+ int x = min;
if ( rpl.size() == min )
return new int[] { min, min };
PropertyNode> node = rpl.get( x );
- while (node==null || (node.getEnd() <= start && x < rpl.size() - 1)) {
- x++;
+ while (node==null || (node.getEnd() <= start && x < rpl.size() - 1)) {
+ x++;
if (x>=rpl.size()) {
return new int[] {0, 0};
}
- node = rpl.get(x);
- }
+ node = rpl.get(x);
+ }
if ( node.getStart() > end )
{
@@ -1045,14 +1045,14 @@ public class Range {
return new int[] { x, rpl.size() };
}
- /**
- * resets the list indexes.
- */
- protected void reset() {
- _charRangeFound = false;
- _parRangeFound = false;
- _sectionRangeFound = false;
- }
+ /**
+ * resets the list indexes.
+ */
+ protected void reset() {
+ _charRangeFound = false;
+ _parRangeFound = false;
+ _sectionRangeFound = false;
+ }
/**
* Adjust the value of the various FIB character count fields, eg
@@ -1066,8 +1066,8 @@ public class Range {
protected void adjustFIB( int adjustment )
{
if (!( _doc instanceof HWPFDocument)) {
- throw new IllegalArgumentException("doc must be instance of HWPFDocument");
- }
+ throw new IllegalArgumentException("doc must be instance of HWPFDocument");
+ }
// update the FIB.CCPText field (this should happen once per adjustment,
// so we don't want it in
@@ -1121,40 +1121,40 @@ public class Range {
}
}
- /**
- * adjust this range after an insert happens.
- *
- * @param length
- * the length to adjust for (expected to be a count of
- * code-points, not necessarily chars)
- */
- private void adjustForInsert(int length) {
- _end += length;
+ /**
+ * adjust this range after an insert happens.
+ *
+ * @param length
+ * the length to adjust for (expected to be a count of
+ * code-points, not necessarily chars)
+ */
+ private void adjustForInsert(int length) {
+ _end += length;
- reset();
- Range parent = _parent;
- if (parent != null) {
- parent.adjustForInsert(length);
- }
- }
+ reset();
+ Range parent = _parent;
+ if (parent != null) {
+ parent.adjustForInsert(length);
+ }
+ }
- /**
- * @return Starting character offset of the range
- */
- public int getStartOffset() {
- return _start;
- }
+ /**
+ * @return Starting character offset of the range
+ */
+ public int getStartOffset() {
+ return _start;
+ }
- /**
- * @return The ending character offset of this range
- */
- public int getEndOffset() {
- return _end;
- }
+ /**
+ * @return The ending character offset of this range
+ */
+ public int getEndOffset() {
+ return _end;
+ }
- protected HWPFDocumentCore getDocument() {
- return _doc;
- }
+ protected HWPFDocumentCore getDocument() {
+ return _doc;
+ }
@Override
public String toString()
@@ -1169,14 +1169,14 @@ public class Range {
*/
public boolean sanityCheck()
{
- DocumentFormatException.check(_start >= 0,
- "start can't be < 0");
- DocumentFormatException.check( _start <= _text.length(),
- "start can't be > text length");
+ DocumentFormatException.check(_start >= 0,
+ "start can't be < 0");
+ DocumentFormatException.check( _start <= _text.length(),
+ "start can't be > text length");
DocumentFormatException.check( _end >= 0,
- "end can't be < 0");
+ "end can't be < 0");
DocumentFormatException.check( _end <= _text.length(),
- "end can't be > text length");
+ "end can't be > text length");
DocumentFormatException.check( _start <= _end,"start can't be > end");
if ( _charRangeFound )
@@ -1200,7 +1200,7 @@ public class Range {
int right = Math.min( this._end, papx.getEnd() );
DocumentFormatException.check( left < right,
- "left must be < right");
+ "left must be < right");
}
}
return true;
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hdgf/TestHDGFLZW.java b/poi-scratchpad/src/test/java/org/apache/poi/hdgf/TestHDGFLZW.java
index 86163afe33..674156c00a 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hdgf/TestHDGFLZW.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hdgf/TestHDGFLZW.java
@@ -125,11 +125,11 @@ public final class TestHDGFLZW {
assertEquals(632, dec.length);
/*
- // Encode it again using our engine
- byte[] comp = lzw.compress(new ByteArrayInputStream(testTrailerDecomp));
+ // Encode it again using our engine
+ byte[] comp = lzw.compress(new ByteArrayInputStream(testTrailerDecomp));
- // Check it's of the right size
- assertEquals(339, comp.length);
+ // Check it's of the right size
+ assertEquals(339, comp.length);
*/
}
@@ -164,12 +164,12 @@ public final class TestHDGFLZW {
byte[] decomp = lzw.decompress(new ByteArrayInputStream(comp));
// First up, check the round tripping
- assertEquals(12, decomp.length);
- assertArrayEquals(Arrays.copyOfRange(testTrailerDecomp, 0, decomp.length), decomp);
+ assertEquals(12, decomp.length);
+ assertArrayEquals(Arrays.copyOfRange(testTrailerDecomp, 0, decomp.length), decomp);
// Now check the compressed intermediate version
assertEquals(11, comp.length);
- assertArrayEquals(Arrays.copyOfRange(testTrailerComp, 0, comp.length), comp);
+ assertArrayEquals(Arrays.copyOfRange(testTrailerComp, 0, comp.length), comp);
}
/**
@@ -192,7 +192,7 @@ public final class TestHDGFLZW {
// We can only check the round-tripping, as for now
// visio cheats on re-using a block
- assertArrayEquals(sourceDecomp, decomp);
+ assertArrayEquals(sourceDecomp, decomp);
}
@Test
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hdgf/chunks/TestChunks.java b/poi-scratchpad/src/test/java/org/apache/poi/hdgf/chunks/TestChunks.java
index 3b97b03b50..58254a5933 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hdgf/chunks/TestChunks.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hdgf/chunks/TestChunks.java
@@ -30,160 +30,160 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
public final class TestChunks {
- private static byte[] data_a, data_b;
+ private static byte[] data_a, data_b;
- @BeforeAll
- public static void setup() throws IOException {
- data_a = RawDataUtil.decompress(
- "H4sIAAAAAAAAAHNjYGD4DwRMQNqFAQygFAMTWAIbYIBqQqZRARMSOwNKMwOxChAzMoRIACkeNC3MUAwDjEjGTEISb" +
- "wGLh3pCeCfsoYwD9vbojP1QqQ/2cAYLplNBIACV+8EeuzKE2/4DXaoAZm6HOhUE/CFOU1BwgCnEw+DgcIQxHXGrYv" +
- "zMD6JOMCACwwNiC9SNF+zxMFC988GeEepUdrg/+MHMVKgnQFiGAR5F6KEFU4IMmpHYXBCXsUIdCQUApUvwomMCAAA=");
- data_b = RawDataUtil.decompress(
- "H4sIAAAAAAAAAHNjYGD4DwTMQNqFAQygFAMTWAIbYIBqQqZRATMSOwNuHgODAhAzMoRIACkONC1MUAwDjFB6EpJYC" +
- "1hNqD2Ep+gAZajBGAfsYYz9nhDGB3s4A9OVYBCAysWpDu4uYFixKICZJ5Cc6YHitAv2eBioFn2wZwQZwsjIwA63gR" +
- "/MTIUaD8IyDPCAY0F3EJIrYKAZic0FcRkrkPKDC55kQIR2G9iAAJAZNlDMii8EaAoA66WHVpECAAA=");
- }
+ @BeforeAll
+ public static void setup() throws IOException {
+ data_a = RawDataUtil.decompress(
+ "H4sIAAAAAAAAAHNjYGD4DwRMQNqFAQygFAMTWAIbYIBqQqZRARMSOwNKMwOxChAzMoRIACkeNC3MUAwDjEjGTEISb" +
+ "wGLh3pCeCfsoYwD9vbojP1QqQ/2cAYLplNBIACV+8EeuzKE2/4DXaoAZm6HOhUE/CFOU1BwgCnEw+DgcIQxHXGrYv" +
+ "zMD6JOMCACwwNiC9SNF+zxMFC988GeEepUdrg/+MHMVKgnQFiGAR5F6KEFU4IMmpHYXBCXsUIdCQUApUvwomMCAAA=");
+ data_b = RawDataUtil.decompress(
+ "H4sIAAAAAAAAAHNjYGD4DwTMQNqFAQygFAMTWAIbYIBqQqZRATMSOwNuHgODAhAzMoRIACkONC1MUAwDjFB6EpJYC" +
+ "1hNqD2Ep+gAZajBGAfsYYz9nhDGB3s4A9OVYBCAysWpDu4uYFixKICZJ5Cc6YHitAv2eBioFn2wZwQZwsjIwA63gR" +
+ "/MTIUaD8IyDPCAY0F3EJIrYKAZic0FcRkrkPKDC55kQIR2G9iAAJAZNlDMii8EaAoA66WHVpECAAA=");
+ }
@Test
- void testChunkHeaderA() {
- ChunkHeader h = ChunkHeader.createChunkHeader(11, data_a, 0);
+ void testChunkHeaderA() {
+ ChunkHeader h = ChunkHeader.createChunkHeader(11, data_a, 0);
- assertTrue(h instanceof ChunkHeaderV11);
- ChunkHeaderV11 header = (ChunkHeaderV11)h;
+ assertTrue(h instanceof ChunkHeaderV11);
+ ChunkHeaderV11 header = (ChunkHeaderV11)h;
- assertEquals(70, header.getType());
- assertEquals(-1, header.getId());
- assertEquals(2, header.getUnknown1());
- assertEquals(68, header.getLength());
- assertEquals(0, header.getUnknown2());
- assertEquals(0, header.getUnknown3());
+ assertEquals(70, header.getType());
+ assertEquals(-1, header.getId());
+ assertEquals(2, header.getUnknown1());
+ assertEquals(68, header.getLength());
+ assertEquals(0, header.getUnknown2());
+ assertEquals(0, header.getUnknown3());
- assertTrue(header.hasTrailer());
- assertTrue(header.hasSeparator());
- }
+ assertTrue(header.hasTrailer());
+ assertTrue(header.hasSeparator());
+ }
@Test
void testChunkHeaderB() {
- ChunkHeader h = ChunkHeader.createChunkHeader(11, data_b, 0);
+ ChunkHeader h = ChunkHeader.createChunkHeader(11, data_b, 0);
- assertTrue(h instanceof ChunkHeaderV11);
- ChunkHeaderV11 header = (ChunkHeaderV11)h;
+ assertTrue(h instanceof ChunkHeaderV11);
+ ChunkHeaderV11 header = (ChunkHeaderV11)h;
- assertEquals(70, header.getType());
- assertEquals(-1, header.getId());
- assertEquals(3, header.getUnknown1());
- assertEquals(68, header.getLength());
- assertEquals(0, header.getUnknown2());
- assertEquals(0, header.getUnknown3());
+ assertEquals(70, header.getType());
+ assertEquals(-1, header.getId());
+ assertEquals(3, header.getUnknown1());
+ assertEquals(68, header.getLength());
+ assertEquals(0, header.getUnknown2());
+ assertEquals(0, header.getUnknown3());
- assertTrue(header.hasTrailer());
- assertTrue(header.hasSeparator());
- }
+ assertTrue(header.hasTrailer());
+ assertTrue(header.hasSeparator());
+ }
@Test
void testOneChunk() throws Exception {
- ChunkFactory cf = new ChunkFactory(11);
- cf.createChunk(data_a, 0);
- cf.createChunk(data_b, 0);
+ ChunkFactory cf = new ChunkFactory(11);
+ cf.createChunk(data_a, 0);
+ cf.createChunk(data_b, 0);
- Chunk chunk = cf.createChunk(data_a, 0);
- assertNotNull(chunk.getHeader());
- assertNotNull(chunk.getTrailer());
- assertNotNull(chunk.getSeparator());
+ Chunk chunk = cf.createChunk(data_a, 0);
+ assertNotNull(chunk.getHeader());
+ assertNotNull(chunk.getTrailer());
+ assertNotNull(chunk.getSeparator());
- // Should be 19 + length + 8 + 4 big
- assertEquals(68, chunk.getHeader().getLength());
- assertEquals(68+19+8+4, chunk.getOnDiskSize());
+ // Should be 19 + length + 8 + 4 big
+ assertEquals(68, chunk.getHeader().getLength());
+ assertEquals(68+19+8+4, chunk.getOnDiskSize());
- // Type is 70, or 0x46
- assertEquals(70, chunk.getHeader().getType());
- assertEquals(0x46, chunk.getHeader().getType());
+ // Type is 70, or 0x46
+ assertEquals(70, chunk.getHeader().getType());
+ assertEquals(0x46, chunk.getHeader().getType());
- // Should have two virtual chunk commands, a
- // 10 (page sheet) and an 18
- assertEquals(2, chunk.getCommandDefinitions().length);
- assertEquals(0, chunk.getCommands().length);
+ // Should have two virtual chunk commands, a
+ // 10 (page sheet) and an 18
+ assertEquals(2, chunk.getCommandDefinitions().length);
+ assertEquals(0, chunk.getCommands().length);
- assertEquals(10, chunk.getCommandDefinitions()[0].getType());
- assertEquals(0, chunk.getCommandDefinitions()[0].getOffset());
- assertEquals("PageSheet", chunk.getCommandDefinitions()[0].getName());
+ assertEquals(10, chunk.getCommandDefinitions()[0].getType());
+ assertEquals(0, chunk.getCommandDefinitions()[0].getOffset());
+ assertEquals("PageSheet", chunk.getCommandDefinitions()[0].getName());
- assertEquals(18, chunk.getCommandDefinitions()[1].getType());
- assertEquals(0, chunk.getCommandDefinitions()[1].getOffset());
- assertEquals("0", chunk.getCommandDefinitions()[1].getName());
- }
+ assertEquals(18, chunk.getCommandDefinitions()[1].getType());
+ assertEquals(0, chunk.getCommandDefinitions()[1].getOffset());
+ assertEquals("0", chunk.getCommandDefinitions()[1].getName());
+ }
@Test
void testAnotherChunk() throws Exception {
- ChunkFactory cf = new ChunkFactory(11);
+ ChunkFactory cf = new ChunkFactory(11);
- // Go for the 2nd chunk in the stream
- int offset = 0;
- Chunk chunk = cf.createChunk(data_b, offset);
- offset += chunk.getOnDiskSize();
- chunk = cf.createChunk(data_b, offset);
+ // Go for the 2nd chunk in the stream
+ int offset = 0;
+ Chunk chunk = cf.createChunk(data_b, offset);
+ offset += chunk.getOnDiskSize();
+ chunk = cf.createChunk(data_b, offset);
- assertNotNull(chunk.getHeader());
- assertNotNull(chunk.getTrailer());
- assertNotNull(chunk.getSeparator());
+ assertNotNull(chunk.getHeader());
+ assertNotNull(chunk.getTrailer());
+ assertNotNull(chunk.getSeparator());
- // Should be 19 + length + 8 + 4 big
- assertEquals(32, chunk.getHeader().getLength());
- assertEquals(32+19+8+4, chunk.getOnDiskSize());
+ // Should be 19 + length + 8 + 4 big
+ assertEquals(32, chunk.getHeader().getLength());
+ assertEquals(32+19+8+4, chunk.getOnDiskSize());
- // Type is 104, or 0x68
- assertEquals(104, chunk.getHeader().getType());
- assertEquals(0x68, chunk.getHeader().getType());
+ // Type is 104, or 0x68
+ assertEquals(104, chunk.getHeader().getType());
+ assertEquals(0x68, chunk.getHeader().getType());
- // Should have two virtual chunk commands, a
- // 10 (Unknown) and an 18
- final CommandDefinition[] cdef = chunk.getCommandDefinitions();
- assertEquals(2, cdef.length);
- assertEquals(0, chunk.getCommands().length);
+ // Should have two virtual chunk commands, a
+ // 10 (Unknown) and an 18
+ final CommandDefinition[] cdef = chunk.getCommandDefinitions();
+ assertEquals(2, cdef.length);
+ assertEquals(0, chunk.getCommands().length);
- assertEquals(10, cdef[0].getType());
- assertEquals(0, cdef[0].getOffset());
- assertEquals("PropList", cdef[0].getName());
+ assertEquals(10, cdef[0].getType());
+ assertEquals(0, cdef[0].getOffset());
+ assertEquals("PropList", cdef[0].getName());
- assertEquals(18, cdef[1].getType());
- assertEquals(0, cdef[1].getOffset());
- assertEquals("0", cdef[1].getName());
- }
+ assertEquals(18, cdef[1].getType());
+ assertEquals(0, cdef[1].getOffset());
+ assertEquals("0", cdef[1].getName());
+ }
@Test
void testManyChunks() throws Exception {
- ChunkFactory cf = new ChunkFactory(11);
- Chunk chunk;
- int offset = 0;
+ ChunkFactory cf = new ChunkFactory(11);
+ Chunk chunk;
+ int offset = 0;
- chunk = cf.createChunk(data_a, offset);
- assertNotNull(chunk.getHeader());
- assertNotNull(chunk.getTrailer());
- assertNotNull(chunk.getSeparator());
- offset += chunk.getOnDiskSize();
+ chunk = cf.createChunk(data_a, offset);
+ assertNotNull(chunk.getHeader());
+ assertNotNull(chunk.getTrailer());
+ assertNotNull(chunk.getSeparator());
+ offset += chunk.getOnDiskSize();
- chunk = cf.createChunk(data_a, offset);
- assertNotNull(chunk.getHeader());
- assertNotNull(chunk.getTrailer());
- assertNotNull(chunk.getSeparator());
- offset += chunk.getOnDiskSize();
+ chunk = cf.createChunk(data_a, offset);
+ assertNotNull(chunk.getHeader());
+ assertNotNull(chunk.getTrailer());
+ assertNotNull(chunk.getSeparator());
+ offset += chunk.getOnDiskSize();
- // Has a separator but no trailer
- chunk = cf.createChunk(data_a, offset);
- assertNotNull(chunk.getHeader());
- assertNull(chunk.getTrailer());
- assertNotNull(chunk.getSeparator());
- offset += chunk.getOnDiskSize();
+ // Has a separator but no trailer
+ chunk = cf.createChunk(data_a, offset);
+ assertNotNull(chunk.getHeader());
+ assertNull(chunk.getTrailer());
+ assertNotNull(chunk.getSeparator());
+ offset += chunk.getOnDiskSize();
- chunk = cf.createChunk(data_a, offset);
- assertNotNull(chunk.getHeader());
- assertNull(chunk.getTrailer());
- assertNotNull(chunk.getSeparator());
- offset += chunk.getOnDiskSize();
+ chunk = cf.createChunk(data_a, offset);
+ assertNotNull(chunk.getHeader());
+ assertNull(chunk.getTrailer());
+ assertNotNull(chunk.getSeparator());
+ offset += chunk.getOnDiskSize();
- chunk = cf.createChunk(data_a, offset);
- assertNotNull(chunk.getHeader());
- assertNull(chunk.getTrailer());
- assertNotNull(chunk.getSeparator());
- }
+ chunk = cf.createChunk(data_a, offset);
+ assertNotNull(chunk.getHeader());
+ assertNull(chunk.getTrailer());
+ assertNotNull(chunk.getSeparator());
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hdgf/extractor/TestVisioExtractor.java b/poi-scratchpad/src/test/java/org/apache/poi/hdgf/extractor/TestVisioExtractor.java
index dc747a07a5..47afe3f74c 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hdgf/extractor/TestVisioExtractor.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hdgf/extractor/TestVisioExtractor.java
@@ -33,70 +33,70 @@ import org.junit.jupiter.params.provider.ValueSource;
public final class TestVisioExtractor {
private static final POIDataSamples _dgTests = POIDataSamples.getDiagramInstance();
- private final String defFilename = "Test_Visio-Some_Random_Text.vsd";
- private final int defTextChunks = 5;
+ private final String defFilename = "Test_Visio-Some_Random_Text.vsd";
+ private final int defTextChunks = 5;
- /**
- * Test the 3 different ways of creating one
- */
- @Test
- void testCreation() throws IOException {
- try (VisioTextExtractor extractor1 = openExtractor(defFilename)) {
- assertNotNull(extractor1);
- assertNotNull(extractor1.getAllText());
- assertEquals(defTextChunks, extractor1.getAllText().length);
- }
+ /**
+ * Test the 3 different ways of creating one
+ */
+ @Test
+ void testCreation() throws IOException {
+ try (VisioTextExtractor extractor1 = openExtractor(defFilename)) {
+ assertNotNull(extractor1);
+ assertNotNull(extractor1.getAllText());
+ assertEquals(defTextChunks, extractor1.getAllText().length);
+ }
- try (InputStream is2 = _dgTests.openResourceAsStream(defFilename);
- POIFSFileSystem poifs2 = new POIFSFileSystem(is2);
- VisioTextExtractor extractor2 = new VisioTextExtractor(poifs2)) {
- assertNotNull(extractor2);
- assertNotNull(extractor2.getAllText());
- assertEquals(defTextChunks, extractor2.getAllText().length);
- }
+ try (InputStream is2 = _dgTests.openResourceAsStream(defFilename);
+ POIFSFileSystem poifs2 = new POIFSFileSystem(is2);
+ VisioTextExtractor extractor2 = new VisioTextExtractor(poifs2)) {
+ assertNotNull(extractor2);
+ assertNotNull(extractor2.getAllText());
+ assertEquals(defTextChunks, extractor2.getAllText().length);
+ }
try (InputStream is3 = _dgTests.openResourceAsStream(defFilename);
- POIFSFileSystem poifs3 = new POIFSFileSystem(is3);
- HDGFDiagram hdgf3 = new HDGFDiagram(poifs3);
- VisioTextExtractor extractor3 = new VisioTextExtractor(hdgf3)) {
- assertNotNull(extractor3);
- assertNotNull(extractor3.getAllText());
- assertEquals(defTextChunks, extractor3.getAllText().length);
- }
- }
+ POIFSFileSystem poifs3 = new POIFSFileSystem(is3);
+ HDGFDiagram hdgf3 = new HDGFDiagram(poifs3);
+ VisioTextExtractor extractor3 = new VisioTextExtractor(hdgf3)) {
+ assertNotNull(extractor3);
+ assertNotNull(extractor3.getAllText());
+ assertEquals(defTextChunks, extractor3.getAllText().length);
+ }
+ }
@Test
- void testExtraction() throws Exception {
- try (VisioTextExtractor extractor = openExtractor(defFilename)) {
+ void testExtraction() throws Exception {
+ try (VisioTextExtractor extractor = openExtractor(defFilename)) {
- // Check the array fetch
- String[] text = extractor.getAllText();
- assertNotNull(text);
- assertEquals(defTextChunks, text.length);
+ // Check the array fetch
+ String[] text = extractor.getAllText();
+ assertNotNull(text);
+ assertEquals(defTextChunks, text.length);
- assertEquals("text\n", text[0]);
- assertEquals("View\n", text[1]);
- assertEquals("Test View\n", text[2]);
- assertEquals("I am a test view\n", text[3]);
- assertEquals("Some random text, on a page\n", text[4]);
+ assertEquals("text\n", text[0]);
+ assertEquals("View\n", text[1]);
+ assertEquals("Test View\n", text[2]);
+ assertEquals("I am a test view\n", text[3]);
+ assertEquals("Some random text, on a page\n", text[4]);
- // And the all-in fetch
- String textS = extractor.getText();
- assertEquals("text\nView\nTest View\nI am a test view\nSome random text, on a page\n", textS);
- }
- }
+ // And the all-in fetch
+ String textS = extractor.getText();
+ assertEquals("text\nView\nTest View\nI am a test view\nSome random text, on a page\n", textS);
+ }
+ }
@ParameterizedTest
- @ValueSource(strings = {
- "44594.vsd", "44594-2.vsd",
- "ShortChunk1.vsd", "ShortChunk2.vsd", "ShortChunk3.vsd",
- "NegativeChunkLength.vsd", "NegativeChunkLength2.vsd"
- })
- void testProblemFiles(String file) throws Exception {
- try (VisioTextExtractor ex = openExtractor(file)) {
- assertNotNull(ex.getText());
- }
- }
+ @ValueSource(strings = {
+ "44594.vsd", "44594-2.vsd",
+ "ShortChunk1.vsd", "ShortChunk2.vsd", "ShortChunk3.vsd",
+ "NegativeChunkLength.vsd", "NegativeChunkLength2.vsd"
+ })
+ void testProblemFiles(String file) throws Exception {
+ try (VisioTextExtractor ex = openExtractor(file)) {
+ assertNotNull(ex.getText());
+ }
+ }
private VisioTextExtractor openExtractor(String fileName) throws IOException {
try (InputStream is = _dgTests.openResourceAsStream(fileName)) {
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hdgf/pointers/TestPointerFactory.java b/poi-scratchpad/src/test/java/org/apache/poi/hdgf/pointers/TestPointerFactory.java
index 3beedf60c0..641f8909b3 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hdgf/pointers/TestPointerFactory.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hdgf/pointers/TestPointerFactory.java
@@ -34,32 +34,32 @@ public final class TestPointerFactory {
0x4d, 1, 0, 0
};
- // Type: 16 Addr: 0143aff4 Offset: 80 Len: 54 Format: 46 From: 8a94
- private static byte[] vp6_a = {
- 22, 0, 0, 0, -12, -81, 67, 1, -128, 0, 0, 0, 84, 0, 0, 0, 70, 0
- };
- // Type: 17 Addr: 014fd84c Offset: d4 Len: 20 Format: 54 From: 8a94
- private static byte[] vp6_b = {
- 23, 0, 0, 0, 76, -40, 79, 1, -44, 0, 0, 0, 32, 0, 0, 0, 84, 0
- };
- // Type: 17 Addr: 014fd8bc Offset: f8 Len: 20 Format: 54 From: 8a94
- private static byte[] vp6_c = {
- 23, 0, 0, 0, -68, -40, 79, 1, -8, 0, 0, 0, 32, 0, 0, 0, 84, 0
- };
- // Type: ff Addr: 014fffac Offset: 0 Len: 0 Format: 60 From: 8a94
- private static byte[] vp6_d = {
- -1, 0, 0, 0, -84, -1, 79, 1, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0
- };
+ // Type: 16 Addr: 0143aff4 Offset: 80 Len: 54 Format: 46 From: 8a94
+ private static byte[] vp6_a = {
+ 22, 0, 0, 0, -12, -81, 67, 1, -128, 0, 0, 0, 84, 0, 0, 0, 70, 0
+ };
+ // Type: 17 Addr: 014fd84c Offset: d4 Len: 20 Format: 54 From: 8a94
+ private static byte[] vp6_b = {
+ 23, 0, 0, 0, 76, -40, 79, 1, -44, 0, 0, 0, 32, 0, 0, 0, 84, 0
+ };
+ // Type: 17 Addr: 014fd8bc Offset: f8 Len: 20 Format: 54 From: 8a94
+ private static byte[] vp6_c = {
+ 23, 0, 0, 0, -68, -40, 79, 1, -8, 0, 0, 0, 32, 0, 0, 0, 84, 0
+ };
+ // Type: ff Addr: 014fffac Offset: 0 Len: 0 Format: 60 From: 8a94
+ private static byte[] vp6_d = {
+ -1, 0, 0, 0, -84, -1, 79, 1, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0
+ };
- @Test
- void testCreateV4() {
- PointerFactory pf = new PointerFactory(4);
- assertThrows(IllegalArgumentException.class, () -> pf.createPointer(new byte[]{}, 0));
- }
+ @Test
+ void testCreateV4() {
+ PointerFactory pf = new PointerFactory(4);
+ assertThrows(IllegalArgumentException.class, () -> pf.createPointer(new byte[]{}, 0));
+ }
- @Test
- void testCreateV5() {
- PointerFactory pf = new PointerFactory(5);
+ @Test
+ void testCreateV5() {
+ PointerFactory pf = new PointerFactory(5);
Pointer a = pf.createPointer(vp5_a, 0);
assertEquals(0x14, a.getType());
@@ -75,84 +75,84 @@ public final class TestPointerFactory {
assertTrue(a.destinationHasPointers());
assertEquals(16, a.getSizeInBytes());
- }
+ }
- @Test
- void testCreateV6() {
- PointerFactory pf = new PointerFactory(6);
+ @Test
+ void testCreateV6() {
+ PointerFactory pf = new PointerFactory(6);
- Pointer a = pf.createPointer(vp6_a, 0);
- assertEquals(0x16, a.getType());
- assertEquals(0x0143aff4, a.getAddress());
- assertEquals(0x80, a.getOffset());
- assertEquals(0x54, a.getLength());
- assertEquals(0x46, a.getFormat());
+ Pointer a = pf.createPointer(vp6_a, 0);
+ assertEquals(0x16, a.getType());
+ assertEquals(0x0143aff4, a.getAddress());
+ assertEquals(0x80, a.getOffset());
+ assertEquals(0x54, a.getLength());
+ assertEquals(0x46, a.getFormat());
- assertTrue(a.destinationCompressed());
- assertTrue(a.destinationHasStrings());
- assertFalse(a.destinationHasChunks());
- assertFalse(a.destinationHasPointers());
+ assertTrue(a.destinationCompressed());
+ assertTrue(a.destinationHasStrings());
+ assertFalse(a.destinationHasChunks());
+ assertFalse(a.destinationHasPointers());
- assertEquals(18, a.getSizeInBytes());
+ assertEquals(18, a.getSizeInBytes());
- Pointer b = pf.createPointer(vp6_b, 0);
- assertEquals(0x17, b.getType());
- assertEquals(0x014fd84c, b.getAddress());
- assertEquals(0xd4, b.getOffset());
- assertEquals(0x20, b.getLength());
- assertEquals(0x54, b.getFormat());
+ Pointer b = pf.createPointer(vp6_b, 0);
+ assertEquals(0x17, b.getType());
+ assertEquals(0x014fd84c, b.getAddress());
+ assertEquals(0xd4, b.getOffset());
+ assertEquals(0x20, b.getLength());
+ assertEquals(0x54, b.getFormat());
- assertFalse(b.destinationCompressed());
- assertFalse(b.destinationHasStrings());
- assertFalse(b.destinationHasChunks());
- assertTrue(b.destinationHasPointers());
+ assertFalse(b.destinationCompressed());
+ assertFalse(b.destinationHasStrings());
+ assertFalse(b.destinationHasChunks());
+ assertTrue(b.destinationHasPointers());
- Pointer c = pf.createPointer(vp6_c, 0);
- assertEquals(0x17, c.getType());
- assertEquals(0x014fd8bc, c.getAddress());
- assertEquals(0xf8, c.getOffset());
- assertEquals(0x20, c.getLength());
- assertEquals(0x54, c.getFormat());
+ Pointer c = pf.createPointer(vp6_c, 0);
+ assertEquals(0x17, c.getType());
+ assertEquals(0x014fd8bc, c.getAddress());
+ assertEquals(0xf8, c.getOffset());
+ assertEquals(0x20, c.getLength());
+ assertEquals(0x54, c.getFormat());
- assertFalse(c.destinationCompressed());
- assertFalse(c.destinationHasStrings());
- assertFalse(c.destinationHasChunks());
- assertTrue(c.destinationHasPointers());
+ assertFalse(c.destinationCompressed());
+ assertFalse(c.destinationHasStrings());
+ assertFalse(c.destinationHasChunks());
+ assertTrue(c.destinationHasPointers());
- // Type: ff Addr: 014fffac Offset: 0 Len: 0 Format: 60 From: 8a94
- Pointer d = pf.createPointer(vp6_d, 0);
- assertEquals(0xff, d.getType());
- assertEquals(0x014fffac, d.getAddress());
- assertEquals(0x00, d.getOffset());
- assertEquals(0x00, d.getLength());
- assertEquals(0x60, d.getFormat());
+ // Type: ff Addr: 014fffac Offset: 0 Len: 0 Format: 60 From: 8a94
+ Pointer d = pf.createPointer(vp6_d, 0);
+ assertEquals(0xff, d.getType());
+ assertEquals(0x014fffac, d.getAddress());
+ assertEquals(0x00, d.getOffset());
+ assertEquals(0x00, d.getLength());
+ assertEquals(0x60, d.getFormat());
- assertFalse(d.destinationCompressed());
- assertFalse(d.destinationHasStrings());
- assertFalse(d.destinationHasChunks());
- assertFalse(d.destinationHasPointers());
- }
+ assertFalse(d.destinationCompressed());
+ assertFalse(d.destinationHasStrings());
+ assertFalse(d.destinationHasChunks());
+ assertFalse(d.destinationHasPointers());
+ }
- @Test
- void testCreateV6FromMid() {
- PointerFactory pf = new PointerFactory(11);
+ @Test
+ void testCreateV6FromMid() {
+ PointerFactory pf = new PointerFactory(11);
- // Create a from part way down the byte stream
- byte[] bytes = new byte[28];
- System.arraycopy(vp6_b, 0, bytes, 0, 10);
- System.arraycopy(vp6_a, 0, bytes, 10, 18);
+ // Create a from part way down the byte stream
+ byte[] bytes = new byte[28];
+ System.arraycopy(vp6_b, 0, bytes, 0, 10);
+ System.arraycopy(vp6_a, 0, bytes, 10, 18);
- Pointer a = pf.createPointer(bytes, 10);
- assertEquals(0x16, a.getType());
- assertEquals(0x0143aff4, a.getAddress());
- assertEquals(0x80, a.getOffset());
- assertEquals(0x54, a.getLength());
- assertEquals(0x46, a.getFormat());
+ Pointer a = pf.createPointer(bytes, 10);
+ assertEquals(0x16, a.getType());
+ assertEquals(0x0143aff4, a.getAddress());
+ assertEquals(0x80, a.getOffset());
+ assertEquals(0x54, a.getLength());
+ assertEquals(0x46, a.getFormat());
- assertTrue(a.destinationCompressed());
- assertTrue(a.destinationHasStrings());
- assertFalse(a.destinationHasChunks());
- assertFalse(a.destinationHasPointers());
- }
+ assertTrue(a.destinationCompressed());
+ assertTrue(a.destinationHasStrings());
+ assertFalse(a.destinationHasChunks());
+ assertFalse(a.destinationHasPointers());
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hdgf/streams/TestStreamBasics.java b/poi-scratchpad/src/test/java/org/apache/poi/hdgf/streams/TestStreamBasics.java
index 847eaa05d1..1f79f2f967 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hdgf/streams/TestStreamBasics.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hdgf/streams/TestStreamBasics.java
@@ -30,10 +30,10 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
public final class TestStreamBasics extends StreamTest {
- private static byte[] compressedStream, uncompressedStream;
+ private static byte[] compressedStream, uncompressedStream;
- @BeforeAll
- public static void init() throws IOException {
+ @BeforeAll
+ public static void init() throws IOException {
compressedStream = decompress(
"H4sIAAAAAAAAAAFTAaz+e8QC6/ABAAC48/BO4PsBAAPr8AoFBOvwFQnr8Gfr8CLc/zQPRg94WA/5/u"+
"T3hRUALIYB/GgP6PMoniBOZr3//uJAKL2Pt3SeqwJCewltqwKnDsi7rbHe/XhuS/f2FPrn9Bbr8PSv"+
@@ -52,44 +52,44 @@ public final class TestStreamBasics extends StreamTest {
"I0MRA8NiBuwuvAHES5xCGZPKGRgugP1lBAo951DGwEYGBj42kIg9yHaXUEa5DgYGLbAaF6DIFtdQxr"+
"ROmAgIAAD6SJPAdAIAAA=="
);
- }
+ }
- @Test
- void testCompressedStream() {
- // Create a fake pointer
- Pointer ptr = new TestPointer(true, 0, compressedStream.length, -1, (short)-1);
- // Now the stream
- Stream stream = Stream.createStream(ptr, compressedStream, null, null);
+ @Test
+ void testCompressedStream() {
+ // Create a fake pointer
+ Pointer ptr = new TestPointer(true, 0, compressedStream.length, -1, (short)-1);
+ // Now the stream
+ Stream stream = Stream.createStream(ptr, compressedStream, null, null);
- // Check
- assertNotNull(stream.getPointer());
- assertNotNull(stream.getStore());
- assertTrue(stream.getStore() instanceof CompressedStreamStore);
- assertTrue(stream instanceof UnknownStream);
+ // Check
+ assertNotNull(stream.getPointer());
+ assertNotNull(stream.getStore());
+ assertTrue(stream.getStore() instanceof CompressedStreamStore);
+ assertTrue(stream instanceof UnknownStream);
- // Check the stream store
- CompressedStreamStore ss = (CompressedStreamStore)stream.getStore();
- assertEquals(4, ss._getBlockHeader().length);
- assertEquals(compressedStream.length, ss._getCompressedContents().length);
- assertEquals(uncompressedStream.length, ss.getContents().length);
+ // Check the stream store
+ CompressedStreamStore ss = (CompressedStreamStore)stream.getStore();
+ assertEquals(4, ss._getBlockHeader().length);
+ assertEquals(compressedStream.length, ss._getCompressedContents().length);
+ assertEquals(uncompressedStream.length, ss.getContents().length);
- for(int i=0; i pStream.findChildren(contents));
- }
- }
+ // Get with recursing into chunks and pointers
+ for (Pointer ptr : ptrs) {
+ Stream stream = Stream.createStream(ptr, contents, chunkFactory, ptrFactory);
+ if(stream instanceof PointerContainingStream) {
+ PointerContainingStream pStream = (PointerContainingStream)stream;
+ assertDoesNotThrow(() -> pStream.findChildren(contents));
+ }
+ }
- trailer.findChildren(contents);
- }
+ trailer.findChildren(contents);
+ }
- @Test
+ @Test
void testOpen() throws IOException {
- try (HDGFDiagram dia = new HDGFDiagram(filesystem)) {
- assertEquals(20, dia.getTopLevelStreams().length);
- }
- }
+ try (HDGFDiagram dia = new HDGFDiagram(filesystem)) {
+ assertEquals(20, dia.getTopLevelStreams().length);
+ }
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hdgf/streams/TestStreamComplex.java b/poi-scratchpad/src/test/java/org/apache/poi/hdgf/streams/TestStreamComplex.java
index e65121ffaf..f4e9efe3c7 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hdgf/streams/TestStreamComplex.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hdgf/streams/TestStreamComplex.java
@@ -37,246 +37,246 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public final class TestStreamComplex extends StreamTest {
- private byte[] contents;
- private final int trailerPointerAt = 0x24;
- private final int trailerDataAt = 0x8a94;
- private ChunkFactory chunkFactory;
- private PointerFactory ptrFactory;
+ private byte[] contents;
+ private final int trailerPointerAt = 0x24;
+ private final int trailerDataAt = 0x8a94;
+ private ChunkFactory chunkFactory;
+ private PointerFactory ptrFactory;
- @BeforeEach
+ @BeforeEach
void setUp() throws IOException {
- ptrFactory = new PointerFactory(11);
- chunkFactory = new ChunkFactory(11);
+ ptrFactory = new PointerFactory(11);
+ chunkFactory = new ChunkFactory(11);
InputStream is = POIDataSamples.getDiagramInstance().openResourceAsStream("Test_Visio-Some_Random_Text.vsd");
- POIFSFileSystem filesystem = new POIFSFileSystem(is);
- is.close();
+ POIFSFileSystem filesystem = new POIFSFileSystem(is);
+ is.close();
- // Grab the document stream
- InputStream is2 = filesystem.createDocumentInputStream("VisioDocument");
- contents = IOUtils.toByteArray(is2);
- is2.close();
+ // Grab the document stream
+ InputStream is2 = filesystem.createDocumentInputStream("VisioDocument");
+ contents = IOUtils.toByteArray(is2);
+ is2.close();
- filesystem.close();
- }
+ filesystem.close();
+ }
- /**
- * Test creating the trailer, but not looking for children
- */
- @Test
+ /**
+ * Test creating the trailer, but not looking for children
+ */
+ @Test
void testTrailer() {
- // Find the trailer
- Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
+ // Find the trailer
+ Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
- assertEquals(20, trailerPtr.getType());
- assertEquals(trailerDataAt, trailerPtr.getOffset());
+ assertEquals(20, trailerPtr.getType());
+ assertEquals(trailerDataAt, trailerPtr.getOffset());
- Stream stream = Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
- assertTrue(stream instanceof TrailerStream);
- TrailerStream ts = (TrailerStream)stream;
+ Stream stream = Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
+ assertTrue(stream instanceof TrailerStream);
+ TrailerStream ts = (TrailerStream)stream;
- assertNotNull(ts.getChildPointers());
- assertNull(ts.getPointedToStreams());
+ assertNotNull(ts.getChildPointers());
+ assertNull(ts.getPointedToStreams());
- assertEquals(20, ts.getChildPointers().length);
- assertEquals(0x16, ts.getChildPointers()[0].getType());
- assertEquals(0x17, ts.getChildPointers()[1].getType());
- assertEquals(0x17, ts.getChildPointers()[2].getType());
- assertEquals(0xff, ts.getChildPointers()[3].getType());
- }
+ assertEquals(20, ts.getChildPointers().length);
+ assertEquals(0x16, ts.getChildPointers()[0].getType());
+ assertEquals(0x17, ts.getChildPointers()[1].getType());
+ assertEquals(0x17, ts.getChildPointers()[2].getType());
+ assertEquals(0xff, ts.getChildPointers()[3].getType());
+ }
- @Test
+ @Test
void testChunks() {
- Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
- TrailerStream ts = (TrailerStream)
- Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
+ Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
+ TrailerStream ts = (TrailerStream)
+ Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
- // Should be 7th one
- Pointer chunkPtr = ts.getChildPointers()[5];
- assertFalse(chunkPtr.destinationHasStrings());
- assertTrue(chunkPtr.destinationHasChunks());
- assertFalse(chunkPtr.destinationHasPointers());
+ // Should be 7th one
+ Pointer chunkPtr = ts.getChildPointers()[5];
+ assertFalse(chunkPtr.destinationHasStrings());
+ assertTrue(chunkPtr.destinationHasChunks());
+ assertFalse(chunkPtr.destinationHasPointers());
- Stream stream = Stream.createStream(chunkPtr, contents, chunkFactory, ptrFactory);
- assertNotNull(stream);
- assertTrue(stream instanceof ChunkStream);
+ Stream stream = Stream.createStream(chunkPtr, contents, chunkFactory, ptrFactory);
+ assertNotNull(stream);
+ assertTrue(stream instanceof ChunkStream);
- // Now find the chunks within it
- ChunkStream cs = (ChunkStream)stream;
- cs.findChunks();
- }
+ // Now find the chunks within it
+ ChunkStream cs = (ChunkStream)stream;
+ cs.findChunks();
+ }
- @Test
+ @Test
void testStrings() {
- Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
- TrailerStream ts = (TrailerStream)
- Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
+ Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
+ TrailerStream ts = (TrailerStream)
+ Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
- // Should be the 1st one
- Pointer stringPtr = ts.getChildPointers()[0];
- assertTrue(stringPtr.destinationHasStrings());
- assertFalse(stringPtr.destinationHasChunks());
- assertFalse(stringPtr.destinationHasPointers());
+ // Should be the 1st one
+ Pointer stringPtr = ts.getChildPointers()[0];
+ assertTrue(stringPtr.destinationHasStrings());
+ assertFalse(stringPtr.destinationHasChunks());
+ assertFalse(stringPtr.destinationHasPointers());
- Stream stream = Stream.createStream(stringPtr, contents, chunkFactory, ptrFactory);
- assertNotNull(stream);
- assertTrue(stream instanceof StringsStream);
- }
+ Stream stream = Stream.createStream(stringPtr, contents, chunkFactory, ptrFactory);
+ assertNotNull(stream);
+ assertTrue(stream instanceof StringsStream);
+ }
- @Test
+ @Test
void testPointerToStrings() {
- // The stream at 0x347f has strings
- // The stream at 0x4312 has a pointer to 0x347f
- // The stream at 0x44d3 has a pointer to 0x4312
- // (it's the 2nd one of 3, and the block is compressed)
+ // The stream at 0x347f has strings
+ // The stream at 0x4312 has a pointer to 0x347f
+ // The stream at 0x44d3 has a pointer to 0x4312
+ // (it's the 2nd one of 3, and the block is compressed)
- TestPointer ptr44d3 = new TestPointer(true, 0x44d3, 0x51, 0x4e, (short)0x56);
- ptr44d3.hasPointers = true;
- PointerContainingStream s44d3 = (PointerContainingStream)
- Stream.createStream(ptr44d3, contents, chunkFactory, ptrFactory);
+ TestPointer ptr44d3 = new TestPointer(true, 0x44d3, 0x51, 0x4e, (short)0x56);
+ ptr44d3.hasPointers = true;
+ PointerContainingStream s44d3 = (PointerContainingStream)
+ Stream.createStream(ptr44d3, contents, chunkFactory, ptrFactory);
- // Type: 0d Addr: 014ff644 Offset: 4312 Len: 48 Format: 54 From: 44d3
- Pointer ptr4312 = s44d3.getChildPointers()[1];
- assertEquals(0x0d, ptr4312.getType());
- assertEquals(0x4312, ptr4312.getOffset());
- assertEquals(0x48, ptr4312.getLength());
- assertEquals(0x54, ptr4312.getFormat());
- assertTrue(ptr4312.destinationHasPointers());
- assertFalse(ptr4312.destinationHasStrings());
+ // Type: 0d Addr: 014ff644 Offset: 4312 Len: 48 Format: 54 From: 44d3
+ Pointer ptr4312 = s44d3.getChildPointers()[1];
+ assertEquals(0x0d, ptr4312.getType());
+ assertEquals(0x4312, ptr4312.getOffset());
+ assertEquals(0x48, ptr4312.getLength());
+ assertEquals(0x54, ptr4312.getFormat());
+ assertTrue(ptr4312.destinationHasPointers());
+ assertFalse(ptr4312.destinationHasStrings());
- PointerContainingStream s4312 = (PointerContainingStream)
- Stream.createStream(ptr4312, contents, chunkFactory, ptrFactory);
+ PointerContainingStream s4312 = (PointerContainingStream)
+ Stream.createStream(ptr4312, contents, chunkFactory, ptrFactory);
- // Check it has 0x347f
- // Type: 1f Addr: 01540004 Offset: 347f Len: 8e8 Format: 46 From: 4312
- assertEquals(2, s4312.getChildPointers().length);
- Pointer ptr347f = s4312.getChildPointers()[0];
- assertEquals(0x1f, ptr347f.getType());
- assertEquals(0x347f, ptr347f.getOffset());
- assertEquals(0x8e8, ptr347f.getLength());
- assertEquals(0x46, ptr347f.getFormat());
- assertFalse(ptr347f.destinationHasPointers());
- assertTrue(ptr347f.destinationHasStrings());
+ // Check it has 0x347f
+ // Type: 1f Addr: 01540004 Offset: 347f Len: 8e8 Format: 46 From: 4312
+ assertEquals(2, s4312.getChildPointers().length);
+ Pointer ptr347f = s4312.getChildPointers()[0];
+ assertEquals(0x1f, ptr347f.getType());
+ assertEquals(0x347f, ptr347f.getOffset());
+ assertEquals(0x8e8, ptr347f.getLength());
+ assertEquals(0x46, ptr347f.getFormat());
+ assertFalse(ptr347f.destinationHasPointers());
+ assertTrue(ptr347f.destinationHasStrings());
- // Find the children of 0x4312
- assertNull(s4312.getPointedToStreams());
- s4312.findChildren(contents);
- // Should have two, both strings
- assertNotNull(s4312.getPointedToStreams());
- assertEquals(2, s4312.getPointedToStreams().length);
- assertTrue(s4312.getPointedToStreams()[0] instanceof StringsStream);
- assertTrue(s4312.getPointedToStreams()[1] instanceof StringsStream);
- }
+ // Find the children of 0x4312
+ assertNull(s4312.getPointedToStreams());
+ s4312.findChildren(contents);
+ // Should have two, both strings
+ assertNotNull(s4312.getPointedToStreams());
+ assertEquals(2, s4312.getPointedToStreams().length);
+ assertTrue(s4312.getPointedToStreams()[0] instanceof StringsStream);
+ assertTrue(s4312.getPointedToStreams()[1] instanceof StringsStream);
+ }
- @Test
+ @Test
void testTrailerContents() {
- Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
- TrailerStream ts = (TrailerStream)
- Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
+ Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
+ TrailerStream ts = (TrailerStream)
+ Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
- assertNotNull(ts.getChildPointers());
- assertNull(ts.getPointedToStreams());
- assertEquals(20, ts.getChildPointers().length);
+ assertNotNull(ts.getChildPointers());
+ assertNull(ts.getPointedToStreams());
+ assertEquals(20, ts.getChildPointers().length);
- ts.findChildren(contents);
+ ts.findChildren(contents);
- assertNotNull(ts.getChildPointers());
- assertNotNull(ts.getPointedToStreams());
- assertEquals(20, ts.getChildPointers().length);
- assertEquals(20, ts.getPointedToStreams().length);
+ assertNotNull(ts.getChildPointers());
+ assertNotNull(ts.getPointedToStreams());
+ assertEquals(20, ts.getChildPointers().length);
+ assertEquals(20, ts.getPointedToStreams().length);
- // Step down:
- // 8 -> 4 -> 5 -> 1 -> 0 == String
- assertNotNull(ts.getPointedToStreams()[8]);
- assertTrue(ts.getPointedToStreams()[8] instanceof PointerContainingStream);
+ // Step down:
+ // 8 -> 4 -> 5 -> 1 -> 0 == String
+ assertNotNull(ts.getPointedToStreams()[8]);
+ assertTrue(ts.getPointedToStreams()[8] instanceof PointerContainingStream);
- PointerContainingStream s8 =
- (PointerContainingStream)ts.getPointedToStreams()[8];
- assertNotNull(s8.getPointedToStreams());
+ PointerContainingStream s8 =
+ (PointerContainingStream)ts.getPointedToStreams()[8];
+ assertNotNull(s8.getPointedToStreams());
- assertNotNull(s8.getPointedToStreams()[4]);
- assertTrue(s8.getPointedToStreams()[4] instanceof PointerContainingStream);
+ assertNotNull(s8.getPointedToStreams()[4]);
+ assertTrue(s8.getPointedToStreams()[4] instanceof PointerContainingStream);
- PointerContainingStream s84 =
- (PointerContainingStream)s8.getPointedToStreams()[4];
- assertNotNull(s84.getPointedToStreams());
+ PointerContainingStream s84 =
+ (PointerContainingStream)s8.getPointedToStreams()[4];
+ assertNotNull(s84.getPointedToStreams());
- assertNotNull(s84.getPointedToStreams()[5]);
- assertTrue(s84.getPointedToStreams()[5] instanceof PointerContainingStream);
+ assertNotNull(s84.getPointedToStreams()[5]);
+ assertTrue(s84.getPointedToStreams()[5] instanceof PointerContainingStream);
- PointerContainingStream s845 =
- (PointerContainingStream)s84.getPointedToStreams()[5];
- assertNotNull(s845.getPointedToStreams());
+ PointerContainingStream s845 =
+ (PointerContainingStream)s84.getPointedToStreams()[5];
+ assertNotNull(s845.getPointedToStreams());
- assertNotNull(s845.getPointedToStreams()[1]);
- assertTrue(s845.getPointedToStreams()[1] instanceof PointerContainingStream);
+ assertNotNull(s845.getPointedToStreams()[1]);
+ assertTrue(s845.getPointedToStreams()[1] instanceof PointerContainingStream);
- PointerContainingStream s8451 =
- (PointerContainingStream)s845.getPointedToStreams()[1];
- assertNotNull(s8451.getPointedToStreams());
+ PointerContainingStream s8451 =
+ (PointerContainingStream)s845.getPointedToStreams()[1];
+ assertNotNull(s8451.getPointedToStreams());
- assertNotNull(s8451.getPointedToStreams()[0]);
- assertTrue(s8451.getPointedToStreams()[0] instanceof StringsStream);
- assertTrue(s8451.getPointedToStreams()[1] instanceof StringsStream);
- }
+ assertNotNull(s8451.getPointedToStreams()[0]);
+ assertTrue(s8451.getPointedToStreams()[0] instanceof StringsStream);
+ assertTrue(s8451.getPointedToStreams()[1] instanceof StringsStream);
+ }
- @Test
+ @Test
void testChunkWithText() {
- // Parent ChunkStream is at 0x7194
- // This is one of the last children of the trailer
- Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
- TrailerStream ts = (TrailerStream)
- Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
+ // Parent ChunkStream is at 0x7194
+ // This is one of the last children of the trailer
+ Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
+ TrailerStream ts = (TrailerStream)
+ Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
- ts.findChildren(contents);
+ ts.findChildren(contents);
- assertNotNull(ts.getChildPointers());
- assertNotNull(ts.getPointedToStreams());
- assertEquals(20, ts.getChildPointers().length);
- assertEquals(20, ts.getPointedToStreams().length);
+ assertNotNull(ts.getChildPointers());
+ assertNotNull(ts.getPointedToStreams());
+ assertEquals(20, ts.getChildPointers().length);
+ assertEquals(20, ts.getPointedToStreams().length);
- assertEquals(0x7194, ts.getChildPointers()[13].getOffset());
- assertEquals(0x7194, ts.getPointedToStreams()[13].getPointer().getOffset());
+ assertEquals(0x7194, ts.getChildPointers()[13].getOffset());
+ assertEquals(0x7194, ts.getPointedToStreams()[13].getPointer().getOffset());
- PointerContainingStream ps7194 = (PointerContainingStream)
- ts.getPointedToStreams()[13];
+ PointerContainingStream ps7194 = (PointerContainingStream)
+ ts.getPointedToStreams()[13];
- // First child is at 0x64b3
- assertEquals(0x64b3, ps7194.getChildPointers()[0].getOffset());
- assertEquals(0x64b3, ps7194.getPointedToStreams()[0].getPointer().getOffset());
+ // First child is at 0x64b3
+ assertEquals(0x64b3, ps7194.getChildPointers()[0].getOffset());
+ assertEquals(0x64b3, ps7194.getPointedToStreams()[0].getPointer().getOffset());
- ChunkStream cs = (ChunkStream)ps7194.getPointedToStreams()[0];
+ ChunkStream cs = (ChunkStream)ps7194.getPointedToStreams()[0];
- // Should be 26bc bytes un-compressed
- assertEquals(0x26bc, cs.getStore().getContents().length);
- // And should have lots of children
- assertEquals(131, cs.getChunks().length);
+ // Should be 26bc bytes un-compressed
+ assertEquals(0x26bc, cs.getStore().getContents().length);
+ // And should have lots of children
+ assertEquals(131, cs.getChunks().length);
- // One of which is Text
- boolean hasText = false;
- for(int i=0; i 0);
- assertTrue(doc.getQuillContents().getData().length > 0);
- assertTrue(doc.getEscherStm().getData().length > 0);
+ assertTrue(doc.getMainContents().getData().length > 0);
+ assertTrue(doc.getQuillContents().getData().length > 0);
+ assertTrue(doc.getEscherStm().getData().length > 0);
assertEquals(0, doc.getEscherDelayStm().getData().length);
doc.close();
- }
+ }
- // TODO
-// void testWrite() throws Exception {
-// }
+ // TODO
+// void testWrite() throws Exception {
+// }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hpbf/model/TestEscherParts.java b/poi-scratchpad/src/test/java/org/apache/poi/hpbf/model/TestEscherParts.java
index c96fdbda80..dc52a8c0db 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hpbf/model/TestEscherParts.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hpbf/model/TestEscherParts.java
@@ -31,55 +31,55 @@ public final class TestEscherParts {
private static final POIDataSamples _samples = POIDataSamples.getPublisherInstance();
@Test
- void testBasics() throws IOException {
+ void testBasics() throws IOException {
InputStream is = _samples.openResourceAsStream("Sample.pub");
- HPBFDocument doc = new HPBFDocument(is);
- is.close();
+ HPBFDocument doc = new HPBFDocument(is);
+ is.close();
- EscherStm es = doc.getEscherStm();
- EscherDelayStm eds = doc.getEscherDelayStm();
+ EscherStm es = doc.getEscherStm();
+ EscherDelayStm eds = doc.getEscherDelayStm();
- assertNotNull(es);
- assertNotNull(eds);
+ assertNotNull(es);
+ assertNotNull(eds);
- assertEquals(13, es.getEscherRecords().length);
- assertEquals(0, eds.getEscherRecords().length);
+ assertEquals(13, es.getEscherRecords().length);
+ assertEquals(0, eds.getEscherRecords().length);
- // TODO - check the contents
- doc.close();
- }
+ // TODO - check the contents
+ doc.close();
+ }
@Test
void testComplex() throws Exception {
InputStream is = _samples.openResourceAsStream("SampleBrochure.pub");
- HPBFDocument doc1 = new HPBFDocument(is);
- is.close();
+ HPBFDocument doc1 = new HPBFDocument(is);
+ is.close();
- EscherStm es = doc1.getEscherStm();
- EscherDelayStm eds = doc1.getEscherDelayStm();
+ EscherStm es = doc1.getEscherStm();
+ EscherDelayStm eds = doc1.getEscherDelayStm();
- assertNotNull(es);
- assertNotNull(eds);
+ assertNotNull(es);
+ assertNotNull(eds);
- assertEquals(30, es.getEscherRecords().length);
- assertEquals(19, eds.getEscherRecords().length);
+ assertEquals(30, es.getEscherRecords().length);
+ assertEquals(19, eds.getEscherRecords().length);
- // TODO - check contents
- doc1.close();
+ // TODO - check contents
+ doc1.close();
- // Now do another complex file
- InputStream is2 = _samples.openResourceAsStream("SampleNewsletter.pub");
+ // Now do another complex file
+ InputStream is2 = _samples.openResourceAsStream("SampleNewsletter.pub");
HPBFDocument doc2 = new HPBFDocument(is2);
- is2.close();
+ is2.close();
- es = doc2.getEscherStm();
- eds = doc2.getEscherDelayStm();
+ es = doc2.getEscherStm();
+ eds = doc2.getEscherDelayStm();
- assertNotNull(es);
- assertNotNull(eds);
+ assertNotNull(es);
+ assertNotNull(eds);
- assertEquals(51, es.getEscherRecords().length);
- assertEquals(92, eds.getEscherRecords().length);
- doc2.close();
- }
+ assertEquals(51, es.getEscherRecords().length);
+ assertEquals(92, eds.getEscherRecords().length);
+ doc2.close();
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hpbf/model/TestQuillContents.java b/poi-scratchpad/src/test/java/org/apache/poi/hpbf/model/TestQuillContents.java
index 8fd5a6bf3b..0c7a647ea7 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hpbf/model/TestQuillContents.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hpbf/model/TestQuillContents.java
@@ -40,409 +40,409 @@ public final class TestQuillContents {
@Test
void testBasics() throws IOException {
- HPBFDocument doc = new HPBFDocument(
- _samples.openResourceAsStream("Sample.pub")
- );
+ HPBFDocument doc = new HPBFDocument(
+ _samples.openResourceAsStream("Sample.pub")
+ );
- QuillContents qc = doc.getQuillContents();
- assertEquals(20, qc.getBits().length);
- for(int i=0; i<19; i++) {
- assertNotNull(qc.getBits()[i]);
- }
- // Last one is blank
- assertNull(qc.getBits()[19]);
+ QuillContents qc = doc.getQuillContents();
+ assertEquals(20, qc.getBits().length);
+ for(int i=0; i<19; i++) {
+ assertNotNull(qc.getBits()[i]);
+ }
+ // Last one is blank
+ assertNull(qc.getBits()[19]);
- // Should be text, then three STSHs
- assertEquals("TEXT", qc.getBits()[0].getThingType());
- assertEquals("TEXT", qc.getBits()[0].getBitType());
- assertEquals(0, qc.getBits()[0].getOptA());
+ // Should be text, then three STSHs
+ assertEquals("TEXT", qc.getBits()[0].getThingType());
+ assertEquals("TEXT", qc.getBits()[0].getBitType());
+ assertEquals(0, qc.getBits()[0].getOptA());
- assertEquals("STSH", qc.getBits()[1].getThingType());
- assertEquals("STSH", qc.getBits()[1].getBitType());
- assertEquals(0, qc.getBits()[1].getOptA());
+ assertEquals("STSH", qc.getBits()[1].getThingType());
+ assertEquals("STSH", qc.getBits()[1].getBitType());
+ assertEquals(0, qc.getBits()[1].getOptA());
- assertEquals("STSH", qc.getBits()[2].getThingType());
- assertEquals("STSH", qc.getBits()[2].getBitType());
- assertEquals(1, qc.getBits()[2].getOptA());
+ assertEquals("STSH", qc.getBits()[2].getThingType());
+ assertEquals("STSH", qc.getBits()[2].getBitType());
+ assertEquals(1, qc.getBits()[2].getOptA());
- assertEquals("STSH", qc.getBits()[3].getThingType());
- assertEquals("STSH", qc.getBits()[3].getBitType());
- assertEquals(2, qc.getBits()[3].getOptA());
+ assertEquals("STSH", qc.getBits()[3].getThingType());
+ assertEquals("STSH", qc.getBits()[3].getBitType());
+ assertEquals(2, qc.getBits()[3].getOptA());
- doc.close();
- }
+ doc.close();
+ }
@Test
- void testText() throws IOException {
- HPBFDocument doc = new HPBFDocument(
+ void testText() throws IOException {
+ HPBFDocument doc = new HPBFDocument(
_samples.openResourceAsStream("Sample.pub")
- );
+ );
- QuillContents qc = doc.getQuillContents();
- assertEquals(20, qc.getBits().length);
+ QuillContents qc = doc.getQuillContents();
+ assertEquals(20, qc.getBits().length);
- QCTextBit text = (QCTextBit)qc.getBits()[0];
- String t = text.getText();
- assertStartsWith(t, "This is some text on the first page");
- assertEndsWith(t, "Within doc to page 1\r");
+ QCTextBit text = (QCTextBit)qc.getBits()[0];
+ String t = text.getText();
+ assertStartsWith(t, "This is some text on the first page");
+ assertEndsWith(t, "Within doc to page 1\r");
doc.close();
- }
+ }
@Test
- void testPLC() throws IOException {
- HPBFDocument doc = new HPBFDocument(
+ void testPLC() throws IOException {
+ HPBFDocument doc = new HPBFDocument(
_samples.openResourceAsStream("Simple.pub")
- );
+ );
- QuillContents qc = doc.getQuillContents();
- assertEquals(20, qc.getBits().length);
+ QuillContents qc = doc.getQuillContents();
+ assertEquals(20, qc.getBits().length);
- assertTrue(qc.getBits()[9] instanceof Type4);
- assertTrue(qc.getBits()[10] instanceof Type4);
- assertTrue(qc.getBits()[12] instanceof Type8);
+ assertTrue(qc.getBits()[9] instanceof Type4);
+ assertTrue(qc.getBits()[10] instanceof Type4);
+ assertTrue(qc.getBits()[12] instanceof Type8);
- Type4 plc9 = (Type4)qc.getBits()[9];
- Type4 plc10 = (Type4)qc.getBits()[10];
- Type8 plc12 = (Type8)qc.getBits()[12];
+ Type4 plc9 = (Type4)qc.getBits()[9];
+ Type4 plc10 = (Type4)qc.getBits()[10];
+ Type8 plc12 = (Type8)qc.getBits()[12];
- assertEquals(1, plc9.getNumberOfPLCs());
- assertEquals(4, plc9.getPreData().length);
- assertEquals(1, plc9.getPlcValA().length);
- assertEquals(1, plc9.getPlcValB().length);
+ assertEquals(1, plc9.getNumberOfPLCs());
+ assertEquals(4, plc9.getPreData().length);
+ assertEquals(1, plc9.getPlcValA().length);
+ assertEquals(1, plc9.getPlcValB().length);
- assertEquals(0, plc9.getPreData()[0]);
- assertEquals(0, plc9.getPreData()[1]);
- assertEquals(0, plc9.getPreData()[2]);
- assertEquals(0, plc9.getPreData()[3]);
- assertEquals(0x356, plc9.getPlcValA()[0]);
- assertEquals(0x600, plc9.getPlcValB()[0]);
+ assertEquals(0, plc9.getPreData()[0]);
+ assertEquals(0, plc9.getPreData()[1]);
+ assertEquals(0, plc9.getPreData()[2]);
+ assertEquals(0, plc9.getPreData()[3]);
+ assertEquals(0x356, plc9.getPlcValA()[0]);
+ assertEquals(0x600, plc9.getPlcValB()[0]);
- assertEquals(1, plc10.getNumberOfPLCs());
- assertEquals(4, plc10.getPreData().length);
- assertEquals(1, plc10.getPlcValA().length);
- assertEquals(1, plc10.getPlcValB().length);
+ assertEquals(1, plc10.getNumberOfPLCs());
+ assertEquals(4, plc10.getPreData().length);
+ assertEquals(1, plc10.getPlcValA().length);
+ assertEquals(1, plc10.getPlcValB().length);
- assertEquals(0, plc10.getPreData()[0]);
- assertEquals(0, plc10.getPreData()[1]);
- assertEquals(0, plc10.getPreData()[2]);
- assertEquals(0, plc10.getPreData()[3]);
- assertEquals(0x356, plc10.getPlcValA()[0]);
- assertEquals(0x800, plc10.getPlcValB()[0]);
+ assertEquals(0, plc10.getPreData()[0]);
+ assertEquals(0, plc10.getPreData()[1]);
+ assertEquals(0, plc10.getPreData()[2]);
+ assertEquals(0, plc10.getPreData()[3]);
+ assertEquals(0x356, plc10.getPlcValA()[0]);
+ assertEquals(0x800, plc10.getPlcValB()[0]);
- assertEquals(2, plc12.getNumberOfPLCs());
- assertEquals(7, plc12.getPreData().length);
- assertEquals(2, plc12.getPlcValA().length);
- assertEquals(2, plc12.getPlcValB().length);
+ assertEquals(2, plc12.getNumberOfPLCs());
+ assertEquals(7, plc12.getPreData().length);
+ assertEquals(2, plc12.getPlcValA().length);
+ assertEquals(2, plc12.getPlcValB().length);
- assertEquals(0xff, plc12.getPreData()[0]);
- assertEquals(0, plc12.getPreData()[1]);
- assertEquals(0x3d, plc12.getPreData()[2]);
- assertEquals(0, plc12.getPreData()[3]);
- assertEquals(0x6e, plc12.getPreData()[4]);
- assertEquals(0, plc12.getPreData()[5]);
- assertEquals(0, plc12.getPreData()[6]);
- assertEquals(0xa0000, plc12.getPlcValA()[0]);
- assertEquals(0x22000000, plc12.getPlcValB()[0]);
- assertEquals(0x05, plc12.getPlcValA()[1]);
- assertEquals(0x04, plc12.getPlcValB()[1]);
+ assertEquals(0xff, plc12.getPreData()[0]);
+ assertEquals(0, plc12.getPreData()[1]);
+ assertEquals(0x3d, plc12.getPreData()[2]);
+ assertEquals(0, plc12.getPreData()[3]);
+ assertEquals(0x6e, plc12.getPreData()[4]);
+ assertEquals(0, plc12.getPreData()[5]);
+ assertEquals(0, plc12.getPreData()[6]);
+ assertEquals(0xa0000, plc12.getPlcValA()[0]);
+ assertEquals(0x22000000, plc12.getPlcValB()[0]);
+ assertEquals(0x05, plc12.getPlcValA()[1]);
+ assertEquals(0x04, plc12.getPlcValB()[1]);
- doc.close();
- }
+ doc.close();
+ }
@SuppressWarnings("unused")
@Test
- void testComplexPLC() throws IOException {
- HPBFDocument doc = new HPBFDocument(
+ void testComplexPLC() throws IOException {
+ HPBFDocument doc = new HPBFDocument(
_samples.openResourceAsStream("Sample.pub")
- );
+ );
- QuillContents qc = doc.getQuillContents();
- assertEquals(20, qc.getBits().length);
+ QuillContents qc = doc.getQuillContents();
+ assertEquals(20, qc.getBits().length);
- assertTrue(qc.getBits()[10] instanceof Type4);
- assertTrue(qc.getBits()[11] instanceof Type4);
- assertTrue(qc.getBits()[13] instanceof Type0);
- assertTrue(qc.getBits()[14] instanceof Type12);
- assertTrue(qc.getBits()[15] instanceof Type12);
- assertTrue(qc.getBits()[16] instanceof Type8);
+ assertTrue(qc.getBits()[10] instanceof Type4);
+ assertTrue(qc.getBits()[11] instanceof Type4);
+ assertTrue(qc.getBits()[13] instanceof Type0);
+ assertTrue(qc.getBits()[14] instanceof Type12);
+ assertTrue(qc.getBits()[15] instanceof Type12);
+ assertTrue(qc.getBits()[16] instanceof Type8);
- Type4 plc10 = (Type4)qc.getBits()[10];
- Type4 plc11 = (Type4)qc.getBits()[11];
- Type0 plc13 = (Type0)qc.getBits()[13];
- Type12 plc14 = (Type12)qc.getBits()[14];
- Type12 plc15 = (Type12)qc.getBits()[15];
- Type8 plc16 = (Type8)qc.getBits()[16];
+ Type4 plc10 = (Type4)qc.getBits()[10];
+ Type4 plc11 = (Type4)qc.getBits()[11];
+ Type0 plc13 = (Type0)qc.getBits()[13];
+ Type12 plc14 = (Type12)qc.getBits()[14];
+ Type12 plc15 = (Type12)qc.getBits()[15];
+ Type8 plc16 = (Type8)qc.getBits()[16];
- assertEquals(1, plc10.getNumberOfPLCs());
- assertEquals(4, plc10.getPreData().length);
- assertEquals(1, plc10.getPlcValA().length);
- assertEquals(1, plc10.getPlcValB().length);
+ assertEquals(1, plc10.getNumberOfPLCs());
+ assertEquals(4, plc10.getPreData().length);
+ assertEquals(1, plc10.getPlcValA().length);
+ assertEquals(1, plc10.getPlcValB().length);
- assertEquals(0, plc10.getPreData()[0]);
- assertEquals(0, plc10.getPreData()[1]);
- assertEquals(0, plc10.getPreData()[2]);
- assertEquals(0, plc10.getPreData()[3]);
- assertEquals(0x5d0, plc10.getPlcValA()[0]);
- assertEquals(0x800, plc10.getPlcValB()[0]);
+ assertEquals(0, plc10.getPreData()[0]);
+ assertEquals(0, plc10.getPreData()[1]);
+ assertEquals(0, plc10.getPreData()[2]);
+ assertEquals(0, plc10.getPreData()[3]);
+ assertEquals(0x5d0, plc10.getPlcValA()[0]);
+ assertEquals(0x800, plc10.getPlcValB()[0]);
- assertEquals(2, plc11.getNumberOfPLCs());
- assertEquals(4, plc11.getPreData().length);
- assertEquals(2, plc11.getPlcValA().length);
- assertEquals(2, plc11.getPlcValB().length);
+ assertEquals(2, plc11.getNumberOfPLCs());
+ assertEquals(4, plc11.getPreData().length);
+ assertEquals(2, plc11.getPlcValA().length);
+ assertEquals(2, plc11.getPlcValB().length);
- assertEquals(0, plc11.getPreData()[0]);
- assertEquals(0, plc11.getPreData()[1]);
- assertEquals(0, plc11.getPreData()[2]);
- assertEquals(0, plc11.getPreData()[3]);
- assertEquals(0x53a, plc11.getPlcValA()[0]);
- assertEquals(0x5d0, plc11.getPlcValB()[0]);
- assertEquals(0xa00, plc11.getPlcValA()[1]);
- assertEquals(0xc00, plc11.getPlcValB()[1]);
+ assertEquals(0, plc11.getPreData()[0]);
+ assertEquals(0, plc11.getPreData()[1]);
+ assertEquals(0, plc11.getPreData()[2]);
+ assertEquals(0, plc11.getPreData()[3]);
+ assertEquals(0x53a, plc11.getPlcValA()[0]);
+ assertEquals(0x5d0, plc11.getPlcValB()[0]);
+ assertEquals(0xa00, plc11.getPlcValA()[1]);
+ assertEquals(0xc00, plc11.getPlcValB()[1]);
- assertEquals(5, plc13.getNumberOfPLCs());
- assertEquals(4, plc13.getPreData().length);
- assertEquals(5, plc13.getPlcValA().length);
- assertEquals(5, plc13.getPlcValB().length);
+ assertEquals(5, plc13.getNumberOfPLCs());
+ assertEquals(4, plc13.getPreData().length);
+ assertEquals(5, plc13.getPlcValA().length);
+ assertEquals(5, plc13.getPlcValB().length);
- assertEquals(0xff00, plc13.getPreData()[0]);
- assertEquals(0, plc13.getPreData()[1]);
- assertEquals(0xf, plc13.getPreData()[2]);
- assertEquals(0, plc13.getPreData()[3]);
- assertEquals(0x19, plc13.getPlcValA()[0]);
- assertEquals(0x00, plc13.getPlcValB()[0]);
- assertEquals(0x27, plc13.getPlcValA()[1]);
- assertEquals(0x00, plc13.getPlcValB()[1]);
- assertEquals(0x36, plc13.getPlcValA()[2]);
- assertEquals(0x00, plc13.getPlcValB()[2]);
- assertEquals(0x42, plc13.getPlcValA()[3]);
- assertEquals(0x00, plc13.getPlcValB()[3]);
- assertEquals(0x50, plc13.getPlcValA()[4]);
- assertEquals(0x00, plc13.getPlcValB()[4]);
+ assertEquals(0xff00, plc13.getPreData()[0]);
+ assertEquals(0, plc13.getPreData()[1]);
+ assertEquals(0xf, plc13.getPreData()[2]);
+ assertEquals(0, plc13.getPreData()[3]);
+ assertEquals(0x19, plc13.getPlcValA()[0]);
+ assertEquals(0x00, plc13.getPlcValB()[0]);
+ assertEquals(0x27, plc13.getPlcValA()[1]);
+ assertEquals(0x00, plc13.getPlcValB()[1]);
+ assertEquals(0x36, plc13.getPlcValA()[2]);
+ assertEquals(0x00, plc13.getPlcValB()[2]);
+ assertEquals(0x42, plc13.getPlcValA()[3]);
+ assertEquals(0x00, plc13.getPlcValB()[3]);
+ assertEquals(0x50, plc13.getPlcValA()[4]);
+ assertEquals(0x00, plc13.getPlcValB()[4]);
- // TODO - test the type 12s
+ // TODO - test the type 12s
- assertEquals(6, plc16.getNumberOfPLCs());
- assertEquals(7, plc16.getPreData().length);
- assertEquals(6, plc16.getPlcValA().length);
- assertEquals(6, plc16.getPlcValB().length);
+ assertEquals(6, plc16.getNumberOfPLCs());
+ assertEquals(7, plc16.getPreData().length);
+ assertEquals(6, plc16.getPlcValA().length);
+ assertEquals(6, plc16.getPlcValB().length);
- assertEquals(0xff, plc16.getPreData()[0]);
- assertEquals(0, plc16.getPreData()[1]);
- assertEquals(0x56, plc16.getPreData()[2]);
- assertEquals(0, plc16.getPreData()[3]);
- assertEquals(0x62, plc16.getPreData()[4]);
- assertEquals(0, plc16.getPreData()[5]);
- assertEquals(0x3e, plc16.getPreData()[6]);
- assertEquals(0x500000, plc16.getPlcValA()[0]);
- assertEquals(0x570000, plc16.getPlcValB()[0]);
- assertEquals(0x4b0000, plc16.getPlcValA()[1]);
- assertEquals(0x000000, plc16.getPlcValB()[1]);
- assertEquals(0x0a0000, plc16.getPlcValA()[2]);
- assertEquals(0x22000000, plc16.getPlcValB()[2]);
- assertEquals(0x000005, plc16.getPlcValA()[3]);
- assertEquals(0x000004, plc16.getPlcValB()[3]);
- assertEquals(0x000004, plc16.getPlcValA()[4]);
- assertEquals(0x000004, plc16.getPlcValB()[4]);
- assertEquals(0x000004, plc16.getPlcValA()[5]);
- assertEquals(0x000004, plc16.getPlcValB()[5]);
+ assertEquals(0xff, plc16.getPreData()[0]);
+ assertEquals(0, plc16.getPreData()[1]);
+ assertEquals(0x56, plc16.getPreData()[2]);
+ assertEquals(0, plc16.getPreData()[3]);
+ assertEquals(0x62, plc16.getPreData()[4]);
+ assertEquals(0, plc16.getPreData()[5]);
+ assertEquals(0x3e, plc16.getPreData()[6]);
+ assertEquals(0x500000, plc16.getPlcValA()[0]);
+ assertEquals(0x570000, plc16.getPlcValB()[0]);
+ assertEquals(0x4b0000, plc16.getPlcValA()[1]);
+ assertEquals(0x000000, plc16.getPlcValB()[1]);
+ assertEquals(0x0a0000, plc16.getPlcValA()[2]);
+ assertEquals(0x22000000, plc16.getPlcValB()[2]);
+ assertEquals(0x000005, plc16.getPlcValA()[3]);
+ assertEquals(0x000004, plc16.getPlcValB()[3]);
+ assertEquals(0x000004, plc16.getPlcValA()[4]);
+ assertEquals(0x000004, plc16.getPlcValB()[4]);
+ assertEquals(0x000004, plc16.getPlcValA()[5]);
+ assertEquals(0x000004, plc16.getPlcValB()[5]);
doc.close();
- }
+ }
@Test
- void testNoHyperlinks() throws IOException {
- HPBFDocument doc = new HPBFDocument(
+ void testNoHyperlinks() throws IOException {
+ HPBFDocument doc = new HPBFDocument(
_samples.openResourceAsStream("SampleNewsletter.pub")
- );
+ );
- QuillContents qc = doc.getQuillContents();
- assertEquals(20, qc.getBits().length);
+ QuillContents qc = doc.getQuillContents();
+ assertEquals(20, qc.getBits().length);
- Type12 plc18 = (Type12)qc.getBits()[18];
+ Type12 plc18 = (Type12)qc.getBits()[18];
- assertEquals(1, plc18.getNumberOfPLCs());
- assertEquals(0, plc18.getNumberOfHyperlinks());
- assertEquals(0, plc18.getTextStartAt(0));
- assertEquals(601, plc18.getAllTextEndAt());
+ assertEquals(1, plc18.getNumberOfPLCs());
+ assertEquals(0, plc18.getNumberOfHyperlinks());
+ assertEquals(0, plc18.getTextStartAt(0));
+ assertEquals(601, plc18.getAllTextEndAt());
doc.close();
- }
+ }
@Test
- void testSimpleHyperlink() throws IOException {
- HPBFDocument doc;
- QuillContents qc;
- Type12 hlBit;
+ void testSimpleHyperlink() throws IOException {
+ HPBFDocument doc;
+ QuillContents qc;
+ Type12 hlBit;
- // Link at 10
- doc = new HPBFDocument(
+ // Link at 10
+ doc = new HPBFDocument(
_samples.openResourceAsStream("LinkAt10.pub")
- );
- qc = doc.getQuillContents();
+ );
+ qc = doc.getQuillContents();
- hlBit = (Type12)qc.getBits()[12];
- assertEquals(1, hlBit.getNumberOfPLCs());
- assertEquals(1, hlBit.getNumberOfHyperlinks());
+ hlBit = (Type12)qc.getBits()[12];
+ assertEquals(1, hlBit.getNumberOfPLCs());
+ assertEquals(1, hlBit.getNumberOfHyperlinks());
- assertEquals(10, hlBit.getTextStartAt(0));
- assertEquals(15, hlBit.getAllTextEndAt());
- assertEquals("http://poi.apache.org/", hlBit.getHyperlink(0));
+ assertEquals(10, hlBit.getTextStartAt(0));
+ assertEquals(15, hlBit.getAllTextEndAt());
+ assertEquals("http://poi.apache.org/", hlBit.getHyperlink(0));
doc.close();
- // Longer link at 10
- doc = new HPBFDocument(
+ // Longer link at 10
+ doc = new HPBFDocument(
_samples.openResourceAsStream("LinkAt10Longer.pub")
- );
- qc = doc.getQuillContents();
+ );
+ qc = doc.getQuillContents();
- hlBit = (Type12)qc.getBits()[12];
- assertEquals(1, hlBit.getNumberOfPLCs());
- assertEquals(1, hlBit.getNumberOfHyperlinks());
+ hlBit = (Type12)qc.getBits()[12];
+ assertEquals(1, hlBit.getNumberOfPLCs());
+ assertEquals(1, hlBit.getNumberOfHyperlinks());
- assertEquals(10, hlBit.getTextStartAt(0));
- assertEquals(15, hlBit.getAllTextEndAt());
- assertEquals("http://poi.apache.org/hpbf/", hlBit.getHyperlink(0));
+ assertEquals(10, hlBit.getTextStartAt(0));
+ assertEquals(15, hlBit.getAllTextEndAt());
+ assertEquals("http://poi.apache.org/hpbf/", hlBit.getHyperlink(0));
doc.close();
- // Link at 20
- doc = new HPBFDocument(
+ // Link at 20
+ doc = new HPBFDocument(
_samples.openResourceAsStream("LinkAt20.pub")
- );
- qc = doc.getQuillContents();
+ );
+ qc = doc.getQuillContents();
- hlBit = (Type12)qc.getBits()[12];
- assertEquals(1, hlBit.getNumberOfPLCs());
- assertEquals(1, hlBit.getNumberOfHyperlinks());
+ hlBit = (Type12)qc.getBits()[12];
+ assertEquals(1, hlBit.getNumberOfPLCs());
+ assertEquals(1, hlBit.getNumberOfHyperlinks());
- assertEquals(20, hlBit.getTextStartAt(0));
- assertEquals(25, hlBit.getAllTextEndAt());
- assertEquals("http://poi.apache.org/", hlBit.getHyperlink(0));
- doc.close();
- }
+ assertEquals(20, hlBit.getTextStartAt(0));
+ assertEquals(25, hlBit.getAllTextEndAt());
+ assertEquals("http://poi.apache.org/", hlBit.getHyperlink(0));
+ doc.close();
+ }
@Test
- void testManyHyperlinks() throws IOException {
- HPBFDocument doc;
- QuillContents qc;
- Type12 hlBit;
+ void testManyHyperlinks() throws IOException {
+ HPBFDocument doc;
+ QuillContents qc;
+ Type12 hlBit;
- // Link at 10
- doc = new HPBFDocument(
+ // Link at 10
+ doc = new HPBFDocument(
_samples.openResourceAsStream("LinkAt10.pub")
- );
- qc = doc.getQuillContents();
+ );
+ qc = doc.getQuillContents();
- hlBit = (Type12)qc.getBits()[12];
- assertEquals(1, hlBit.getNumberOfPLCs());
- assertEquals(1, hlBit.getNumberOfHyperlinks());
+ hlBit = (Type12)qc.getBits()[12];
+ assertEquals(1, hlBit.getNumberOfPLCs());
+ assertEquals(1, hlBit.getNumberOfHyperlinks());
- assertEquals(10, hlBit.getTextStartAt(0));
- assertEquals(15, hlBit.getAllTextEndAt());
- assertEquals("http://poi.apache.org/", hlBit.getHyperlink(0));
+ assertEquals(10, hlBit.getTextStartAt(0));
+ assertEquals(15, hlBit.getAllTextEndAt());
+ assertEquals("http://poi.apache.org/", hlBit.getHyperlink(0));
doc.close();
- }
+ }
@Test
- void testHyperlinkDifferentVersions() throws IOException {
- HPBFDocument doc;
- QuillContents qc;
- Type12 hlBitA;
- Type12 hlBitB;
+ void testHyperlinkDifferentVersions() throws IOException {
+ HPBFDocument doc;
+ QuillContents qc;
+ Type12 hlBitA;
+ Type12 hlBitB;
- // Latest version
- doc = new HPBFDocument(
+ // Latest version
+ doc = new HPBFDocument(
_samples.openResourceAsStream("Sample.pub")
- );
- qc = doc.getQuillContents();
+ );
+ qc = doc.getQuillContents();
- hlBitA = (Type12)qc.getBits()[14];
- assertEquals(2, hlBitA.getNumberOfPLCs());
- assertEquals(2, hlBitA.getNumberOfHyperlinks());
+ hlBitA = (Type12)qc.getBits()[14];
+ assertEquals(2, hlBitA.getNumberOfPLCs());
+ assertEquals(2, hlBitA.getNumberOfHyperlinks());
- assertEquals(25, hlBitA.getTextStartAt(0));
- assertEquals(72, hlBitA.getTextStartAt(1));
- assertEquals(87, hlBitA.getAllTextEndAt());
- assertEquals("http://poi.apache.org/", hlBitA.getHyperlink(0));
- assertEquals("C:\\Documents and Settings\\Nick\\My Documents\\Booleans.xlsx", hlBitA.getHyperlink(1));
+ assertEquals(25, hlBitA.getTextStartAt(0));
+ assertEquals(72, hlBitA.getTextStartAt(1));
+ assertEquals(87, hlBitA.getAllTextEndAt());
+ assertEquals("http://poi.apache.org/", hlBitA.getHyperlink(0));
+ assertEquals("C:\\Documents and Settings\\Nick\\My Documents\\Booleans.xlsx", hlBitA.getHyperlink(1));
- hlBitB = (Type12)qc.getBits()[15];
- assertEquals(3, hlBitB.getNumberOfPLCs());
- assertEquals(3, hlBitB.getNumberOfHyperlinks());
+ hlBitB = (Type12)qc.getBits()[15];
+ assertEquals(3, hlBitB.getNumberOfPLCs());
+ assertEquals(3, hlBitB.getNumberOfHyperlinks());
- assertEquals(27, hlBitB.getTextStartAt(0));
- assertEquals(37, hlBitB.getTextStartAt(1));
- assertEquals(54, hlBitB.getTextStartAt(2));
- assertEquals(75, hlBitB.getAllTextEndAt());
- assertEquals("", hlBitB.getHyperlink(0));
- assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(1));
- assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(2));
+ assertEquals(27, hlBitB.getTextStartAt(0));
+ assertEquals(37, hlBitB.getTextStartAt(1));
+ assertEquals(54, hlBitB.getTextStartAt(2));
+ assertEquals(75, hlBitB.getAllTextEndAt());
+ assertEquals("", hlBitB.getHyperlink(0));
+ assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(1));
+ assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(2));
doc.close();
- // 2000 version
- doc = new HPBFDocument(
+ // 2000 version
+ doc = new HPBFDocument(
_samples.openResourceAsStream("Sample2000.pub")
- );
- qc = doc.getQuillContents();
+ );
+ qc = doc.getQuillContents();
- hlBitA = (Type12)qc.getBits()[13];
- assertEquals(2, hlBitA.getNumberOfPLCs());
- assertEquals(2, hlBitA.getNumberOfHyperlinks());
+ hlBitA = (Type12)qc.getBits()[13];
+ assertEquals(2, hlBitA.getNumberOfPLCs());
+ assertEquals(2, hlBitA.getNumberOfHyperlinks());
- assertEquals(25, hlBitA.getTextStartAt(0));
- assertEquals(72, hlBitA.getTextStartAt(1));
- assertEquals(87, hlBitA.getAllTextEndAt());
- assertEquals("http://poi.apache.org/", hlBitA.getHyperlink(0));
- assertEquals("C:\\Documents and Settings\\Nick\\My Documents\\Booleans.xlsx", hlBitA.getHyperlink(1));
+ assertEquals(25, hlBitA.getTextStartAt(0));
+ assertEquals(72, hlBitA.getTextStartAt(1));
+ assertEquals(87, hlBitA.getAllTextEndAt());
+ assertEquals("http://poi.apache.org/", hlBitA.getHyperlink(0));
+ assertEquals("C:\\Documents and Settings\\Nick\\My Documents\\Booleans.xlsx", hlBitA.getHyperlink(1));
- hlBitB = (Type12)qc.getBits()[14];
- assertEquals(3, hlBitB.getNumberOfPLCs());
- assertEquals(3, hlBitB.getNumberOfHyperlinks());
+ hlBitB = (Type12)qc.getBits()[14];
+ assertEquals(3, hlBitB.getNumberOfPLCs());
+ assertEquals(3, hlBitB.getNumberOfHyperlinks());
- assertEquals(27, hlBitB.getTextStartAt(0));
- assertEquals(37, hlBitB.getTextStartAt(1));
- assertEquals(54, hlBitB.getTextStartAt(2));
- assertEquals(75, hlBitB.getAllTextEndAt());
- assertEquals("", hlBitB.getHyperlink(0));
- assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(1));
- assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(2));
+ assertEquals(27, hlBitB.getTextStartAt(0));
+ assertEquals(37, hlBitB.getTextStartAt(1));
+ assertEquals(54, hlBitB.getTextStartAt(2));
+ assertEquals(75, hlBitB.getAllTextEndAt());
+ assertEquals("", hlBitB.getHyperlink(0));
+ assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(1));
+ assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(2));
doc.close();
- // 98 version
- doc = new HPBFDocument(
+ // 98 version
+ doc = new HPBFDocument(
_samples.openResourceAsStream("Sample98.pub")
- );
- qc = doc.getQuillContents();
+ );
+ qc = doc.getQuillContents();
- hlBitA = (Type12)qc.getBits()[13];
- assertEquals(2, hlBitA.getNumberOfPLCs());
- assertEquals(2, hlBitA.getNumberOfHyperlinks());
+ hlBitA = (Type12)qc.getBits()[13];
+ assertEquals(2, hlBitA.getNumberOfPLCs());
+ assertEquals(2, hlBitA.getNumberOfHyperlinks());
- assertEquals(25, hlBitA.getTextStartAt(0));
- assertEquals(72, hlBitA.getTextStartAt(1));
- assertEquals(87, hlBitA.getAllTextEndAt());
- assertEquals("http://poi.apache.org/", hlBitA.getHyperlink(0));
- assertEquals("C:\\Documents and Settings\\Nick\\My Documents\\Booleans.xlsx", hlBitA.getHyperlink(1));
+ assertEquals(25, hlBitA.getTextStartAt(0));
+ assertEquals(72, hlBitA.getTextStartAt(1));
+ assertEquals(87, hlBitA.getAllTextEndAt());
+ assertEquals("http://poi.apache.org/", hlBitA.getHyperlink(0));
+ assertEquals("C:\\Documents and Settings\\Nick\\My Documents\\Booleans.xlsx", hlBitA.getHyperlink(1));
- hlBitB = (Type12)qc.getBits()[14];
- assertEquals(3, hlBitB.getNumberOfPLCs());
- assertEquals(3, hlBitB.getNumberOfHyperlinks());
+ hlBitB = (Type12)qc.getBits()[14];
+ assertEquals(3, hlBitB.getNumberOfPLCs());
+ assertEquals(3, hlBitB.getNumberOfHyperlinks());
- assertEquals(27, hlBitB.getTextStartAt(0));
- assertEquals(37, hlBitB.getTextStartAt(1));
- assertEquals(54, hlBitB.getTextStartAt(2));
- assertEquals(75, hlBitB.getAllTextEndAt());
- assertEquals("", hlBitB.getHyperlink(0));
- assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(1));
- assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(2));
+ assertEquals(27, hlBitB.getTextStartAt(0));
+ assertEquals(37, hlBitB.getTextStartAt(1));
+ assertEquals(54, hlBitB.getTextStartAt(2));
+ assertEquals(75, hlBitB.getAllTextEndAt());
+ assertEquals("", hlBitB.getHyperlink(0));
+ assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(1));
+ assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(2));
doc.close();
}
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/HSLFTestDataSamples.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/HSLFTestDataSamples.java
index 9a08f18eb6..881d543b0d 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/HSLFTestDataSamples.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/HSLFTestDataSamples.java
@@ -28,53 +28,53 @@ import org.apache.poi.hslf.usermodel.HSLFSlideShowImpl;
public class HSLFTestDataSamples {
- private static final POIDataSamples _inst = POIDataSamples.getSlideShowInstance();
+ private static final POIDataSamples _inst = POIDataSamples.getSlideShowInstance();
- public static InputStream openSampleFileStream(String sampleFileName) {
- return _inst.openResourceAsStream(sampleFileName);
- }
+ public static InputStream openSampleFileStream(String sampleFileName) {
+ return _inst.openResourceAsStream(sampleFileName);
+ }
- public static File getSampleFile(String sampleFileName) {
- return _inst.getFile(sampleFileName);
- }
+ public static File getSampleFile(String sampleFileName) {
+ return _inst.getFile(sampleFileName);
+ }
- public static byte[] getTestDataFileContent(String fileName) {
- return _inst.readFile(fileName);
- }
+ public static byte[] getTestDataFileContent(String fileName) {
+ return _inst.readFile(fileName);
+ }
- public static HSLFSlideShow getSlideShow(String fileName) throws IOException {
+ public static HSLFSlideShow getSlideShow(String fileName) throws IOException {
try (InputStream is = openSampleFileStream(fileName)) {
return new HSLFSlideShow(is);
}
- }
+ }
- /**
- * Writes a slideshow to a {@code UnsynchronizedByteArrayOutputStream} and reads it back
- * from a {@code ByteArrayInputStream}.
- * Useful for verifying that the serialisation round trip
- */
- public static HSLFSlideShowImpl writeOutAndReadBack(HSLFSlideShowImpl original) {
- try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream()) {
- original.write(baos);
- try (InputStream is = baos.toInputStream()) {
- return new HSLFSlideShowImpl(is);
- }
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
+ /**
+ * Writes a slideshow to a {@code UnsynchronizedByteArrayOutputStream} and reads it back
+ * from a {@code ByteArrayInputStream}.
+ * Useful for verifying that the serialisation round trip
+ */
+ public static HSLFSlideShowImpl writeOutAndReadBack(HSLFSlideShowImpl original) {
+ try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream()) {
+ original.write(baos);
+ try (InputStream is = baos.toInputStream()) {
+ return new HSLFSlideShowImpl(is);
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
- /**
- * Writes a slideshow to a {@code UnsynchronizedByteArrayOutputStream} and reads it back
- * from a {@code ByteArrayInputStream}.
- * Useful for verifying that the serialisation round trip
- */
- public static HSLFSlideShow writeOutAndReadBack(HSLFSlideShow original) {
- try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream(4096)) {
- original.write(baos);
- return new HSLFSlideShow(baos.toInputStream());
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
+ /**
+ * Writes a slideshow to a {@code UnsynchronizedByteArrayOutputStream} and reads it back
+ * from a {@code ByteArrayInputStream}.
+ * Useful for verifying that the serialisation round trip
+ */
+ public static HSLFSlideShow writeOutAndReadBack(HSLFSlideShow original) {
+ try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream(4096)) {
+ original.write(baos);
+ return new HSLFSlideShow(baos.toInputStream());
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestEncryptedFile.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestEncryptedFile.java
index 64e61a4c14..5a2983027f 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestEncryptedFile.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestEncryptedFile.java
@@ -36,16 +36,16 @@ public final class TestEncryptedFile {
private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
@Test
- void testLoadNonEncrypted() throws IOException {
+ void testLoadNonEncrypted() throws IOException {
InputStream is = slTests.openResourceAsStream("basic_test_ppt_file.ppt");
- HSLFSlideShowImpl hss = new HSLFSlideShowImpl(is);
- assertNotNull(hss);
- hss.close();
- is.close();
- }
+ HSLFSlideShowImpl hss = new HSLFSlideShowImpl(is);
+ assertNotNull(hss);
+ hss.close();
+ is.close();
+ }
@Test
- void testLoadEncrypted1() throws IOException {
+ void testLoadEncrypted1() throws IOException {
try (InputStream is = slTests.openResourceAsStream("Password_Protected-hello.ppt")) {
assertThrows(EncryptedPowerPointFileException.class, () -> new HSLFSlideShowImpl(is).close());
}
@@ -63,5 +63,5 @@ public final class TestEncryptedFile {
try (InputStream is = slTests.openResourceAsStream("Password_Protected-56-hello.ppt")) {
assertThrows(EncryptedPowerPointFileException.class, () -> new HSLFSlideShowImpl(is).close());
}
- }
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestPOIDocumentScratchpad.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestPOIDocumentScratchpad.java
index 2d795452b9..2d905db04e 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestPOIDocumentScratchpad.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestPOIDocumentScratchpad.java
@@ -43,64 +43,64 @@ import org.junit.jupiter.api.Test;
* which are part of the scratchpad (not main)
*/
public final class TestPOIDocumentScratchpad {
- @Test
- void testReadProperties() throws IOException {
- try (POIDocument doc = HSLFTestDataSamples.getSlideShow("basic_test_ppt_file.ppt")) {
- testReadPropertiesHelper(doc);
- }
- }
+ @Test
+ void testReadProperties() throws IOException {
+ try (POIDocument doc = HSLFTestDataSamples.getSlideShow("basic_test_ppt_file.ppt")) {
+ testReadPropertiesHelper(doc);
+ }
+ }
- private void testReadPropertiesHelper(POIDocument docPH) {
- // We should have both sets
- assertNotNull(docPH.getDocumentSummaryInformation());
- assertNotNull(docPH.getSummaryInformation());
+ private void testReadPropertiesHelper(POIDocument docPH) {
+ // We should have both sets
+ assertNotNull(docPH.getDocumentSummaryInformation());
+ assertNotNull(docPH.getSummaryInformation());
- // Check they are as expected for the test doc
- assertEquals("Hogwarts", docPH.getSummaryInformation().getAuthor());
- assertEquals(10598, docPH.getDocumentSummaryInformation().getByteCount());
- }
+ // Check they are as expected for the test doc
+ assertEquals("Hogwarts", docPH.getSummaryInformation().getAuthor());
+ assertEquals(10598, docPH.getDocumentSummaryInformation().getByteCount());
+ }
- @Test
- void testReadProperties2() throws IOException {
- try (POIDocument doc2 = HWPFTestDataSamples.openSampleFile("test2.doc")) {
- // Check again on the word one
- assertNotNull(doc2.getDocumentSummaryInformation());
- assertNotNull(doc2.getSummaryInformation());
+ @Test
+ void testReadProperties2() throws IOException {
+ try (POIDocument doc2 = HWPFTestDataSamples.openSampleFile("test2.doc")) {
+ // Check again on the word one
+ assertNotNull(doc2.getDocumentSummaryInformation());
+ assertNotNull(doc2.getSummaryInformation());
- assertEquals("Hogwarts", doc2.getSummaryInformation().getAuthor());
- assertEquals("", doc2.getSummaryInformation().getKeywords());
- assertEquals(0, doc2.getDocumentSummaryInformation().getByteCount());
- }
- }
+ assertEquals("Hogwarts", doc2.getSummaryInformation().getAuthor());
+ assertEquals("", doc2.getSummaryInformation().getKeywords());
+ assertEquals(0, doc2.getDocumentSummaryInformation().getByteCount());
+ }
+ }
- @Test
- void testWriteProperties() throws IOException {
- // Just check we can write them back out into a filesystem
- try (POIDocument doc = HSLFTestDataSamples.getSlideShow("basic_test_ppt_file.ppt");
- POIFSFileSystem outFS = new POIFSFileSystem()) {
- doc.writeProperties(outFS);
+ @Test
+ void testWriteProperties() throws IOException {
+ // Just check we can write them back out into a filesystem
+ try (POIDocument doc = HSLFTestDataSamples.getSlideShow("basic_test_ppt_file.ppt");
+ POIFSFileSystem outFS = new POIFSFileSystem()) {
+ doc.writeProperties(outFS);
- // Should now hold them
- assertNotNull(outFS.createDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME));
- assertNotNull(outFS.createDocumentInputStream(DocumentSummaryInformation.DEFAULT_STREAM_NAME));
- }
- }
+ // Should now hold them
+ assertNotNull(outFS.createDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME));
+ assertNotNull(outFS.createDocumentInputStream(DocumentSummaryInformation.DEFAULT_STREAM_NAME));
+ }
+ }
- @Test
+ @Test
void testWriteReadProperties() throws IOException {
- // Write them out
- try (POIDocument doc = HSLFTestDataSamples.getSlideShow("basic_test_ppt_file.ppt");
- POIFSFileSystem outFS = new POIFSFileSystem()) {
- doc.writeProperties(outFS);
+ // Write them out
+ try (POIDocument doc = HSLFTestDataSamples.getSlideShow("basic_test_ppt_file.ppt");
+ POIFSFileSystem outFS = new POIFSFileSystem()) {
+ doc.writeProperties(outFS);
- // Check they're still there
- try (POIFSFileSystem inFS = writeOutAndReadBack(outFS);
- POIDocument ppt = new HPSFPropertiesOnlyDocument(inFS)) {
- ppt.readProperties();
+ // Check they're still there
+ try (POIFSFileSystem inFS = writeOutAndReadBack(outFS);
+ POIDocument ppt = new HPSFPropertiesOnlyDocument(inFS)) {
+ ppt.readProperties();
- // Delegate test
- testReadPropertiesHelper(ppt);
- }
- }
+ // Delegate test
+ testReadPropertiesHelper(ppt);
+ }
+ }
}
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestRecordCounts.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestRecordCounts.java
index 5c8463ca3e..b21f6ecc17 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestRecordCounts.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestRecordCounts.java
@@ -35,58 +35,58 @@ import org.junit.jupiter.api.Test;
*/
public final class TestRecordCounts {
- private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- // HSLFSlideShow primed on the test data
- private HSLFSlideShowImpl ss;
+ private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
+ // HSLFSlideShow primed on the test data
+ private HSLFSlideShowImpl ss;
- @BeforeEach
- void setup() throws Exception {
- ss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
- }
+ @BeforeEach
+ void setup() throws Exception {
+ ss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ }
- @Test
- void testSheetsCount() {
- // Top level
- Record[] r = ss.getRecords();
+ @Test
+ void testSheetsCount() {
+ // Top level
+ Record[] r = ss.getRecords();
- int count = 0;
- for (final Record rec : r) {
- if(rec instanceof Slide) {
- count++;
- }
- }
- // Currently still sees the Master Sheet, but might not in the future
- assertEquals(3,count);
- }
+ int count = 0;
+ for (final Record rec : r) {
+ if(rec instanceof Slide) {
+ count++;
+ }
+ }
+ // Currently still sees the Master Sheet, but might not in the future
+ assertEquals(3,count);
+ }
- @Test
- void testNotesCount() {
- // Top level
- Record[] r = ss.getRecords();
+ @Test
+ void testNotesCount() {
+ // Top level
+ Record[] r = ss.getRecords();
- int count = 0;
- for (final Record rec : r) {
- if (rec instanceof Notes && rec.getRecordType() == 1008L) {
- count++;
- }
- }
- // Two real sheets, plus the master sheet
- assertEquals(3,count);
- }
+ int count = 0;
+ for (final Record rec : r) {
+ if (rec instanceof Notes && rec.getRecordType() == 1008L) {
+ count++;
+ }
+ }
+ // Two real sheets, plus the master sheet
+ assertEquals(3,count);
+ }
- @Test
- void testSlideListWithTextCount() {
- // Second level
- Record[] rt = ss.getRecords();
- Record[] r = rt[0].getChildRecords();
+ @Test
+ void testSlideListWithTextCount() {
+ // Second level
+ Record[] rt = ss.getRecords();
+ Record[] r = rt[0].getChildRecords();
- int count = 0;
- for (final Record rec : r) {
- if (rec instanceof SlideListWithText && rec.getRecordType() == 4080L) {
- count++;
- }
- }
- // Two real sheets, plus the master sheet
- assertEquals(3,count);
- }
+ int count = 0;
+ for (final Record rec : r) {
+ if (rec instanceof SlideListWithText && rec.getRecordType() == 4080L) {
+ count++;
+ }
+ }
+ // Two real sheets, plus the master sheet
+ assertEquals(3,count);
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/BaseTestPPTIterating.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/BaseTestPPTIterating.java
index ca5b1ac380..9797cb74c8 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/BaseTestPPTIterating.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/BaseTestPPTIterating.java
@@ -42,7 +42,7 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
-@Isolated // this test changes global static BYTE_ARRAY_MAX_OVERRIDE
+@Isolated // this test changes global static BYTE_ARRAY_MAX_OVERRIDE
public abstract class BaseTestPPTIterating {
protected static final Set OLD_FILES = new HashSet<>();
static {
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/TestSlideShowDumper.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/TestSlideShowDumper.java
index 5eecf4370f..1b62833aec 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/TestSlideShowDumper.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/TestSlideShowDumper.java
@@ -31,7 +31,7 @@ import org.apache.poi.util.IOUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.Isolated;
-@Isolated // this test changes global static BYTE_ARRAY_MAX_OVERRIDE
+@Isolated // this test changes global static BYTE_ARRAY_MAX_OVERRIDE
public class TestSlideShowDumper extends BaseTestPPTIterating {
private static final Set FAILING = new HashSet<>();
static {
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/extractor/TestCruddyExtractor.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/extractor/TestCruddyExtractor.java
index 71e1258d1e..e56aad9a17 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/extractor/TestCruddyExtractor.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/extractor/TestCruddyExtractor.java
@@ -31,64 +31,64 @@ import org.junit.jupiter.api.Test;
* Tests that the QuickButCruddyTextExtractor works correctly
*/
public final class TestCruddyExtractor {
- private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
+ private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- // Extractor primed on the test data
- private QuickButCruddyTextExtractor te;
+ // Extractor primed on the test data
+ private QuickButCruddyTextExtractor te;
- // All the text to be found in the file
- String[] allTheText = new String[] {
- "This is a test title",
- "This is a test subtitle\nThis is on page 1",
- "Click to edit Master title style",
- "Click to edit Master text styles\nSecond level\nThird level\nFourth level\nFifth level",
- "*",
- "*",
- "*",
- "*",
- "*",
- "Click to edit Master text styles\nSecond level\nThird level\nFourth level\nFifth level",
- "*",
- "*",
- "These are the notes for page 1",
- "This is a test title",
- "This is a test subtitle\nThis is on page 1",
- "This is the title on page 2",
- "This is page two\nIt has several blocks of text\nNone of them have formattingT",
- "These are the notes on page two, again lacking formatting",
- "This is a test title",
- "This is a test subtitle\nThis is on page 1",
- "This is the title on page 2",
- "This is page two\nIt has several blocks of text\nNone of them have formatting",
- };
+ // All the text to be found in the file
+ String[] allTheText = new String[] {
+ "This is a test title",
+ "This is a test subtitle\nThis is on page 1",
+ "Click to edit Master title style",
+ "Click to edit Master text styles\nSecond level\nThird level\nFourth level\nFifth level",
+ "*",
+ "*",
+ "*",
+ "*",
+ "*",
+ "Click to edit Master text styles\nSecond level\nThird level\nFourth level\nFifth level",
+ "*",
+ "*",
+ "These are the notes for page 1",
+ "This is a test title",
+ "This is a test subtitle\nThis is on page 1",
+ "This is the title on page 2",
+ "This is page two\nIt has several blocks of text\nNone of them have formattingT",
+ "These are the notes on page two, again lacking formatting",
+ "This is a test title",
+ "This is a test subtitle\nThis is on page 1",
+ "This is the title on page 2",
+ "This is page two\nIt has several blocks of text\nNone of them have formatting",
+ };
- @BeforeEach
+ @BeforeEach
void setup() throws Exception {
- te = new QuickButCruddyTextExtractor(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ te = new QuickButCruddyTextExtractor(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
}
- @Test
+ @Test
void testReadAsVector() {
- // Extract the text from the file as a vector
- List foundTextV = te.getTextAsVector();
+ // Extract the text from the file as a vector
+ List foundTextV = te.getTextAsVector();
- // Ensure they match
- assertEquals(allTheText.length,foundTextV.size());
- for(int i=0; i tr1 = ppt1.getSlides().get(0).getTextParagraphs().get(0);
- List tr2 = ppt1.getSlides().get(0).getTextParagraphs().get(1);
+ // Grab the first text run on the first sheet
+ List tr1 = ppt1.getSlides().get(0).getTextParagraphs().get(0);
+ List tr2 = ppt1.getSlides().get(0).getTextParagraphs().get(1);
- assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
- assertEquals(179, HSLFTextParagraph.getRawText(tr2).length());
+ assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
+ assertEquals(179, HSLFTextParagraph.getRawText(tr2).length());
- assertEquals(1, tr1.size());
- assertEquals(30, HSLFTextParagraph.getText(tr1).length());
- assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
- assertEquals(31, tr1.get(0).getTextRuns().get(0).getCharacterStyle().getCharactersCovered());
- assertEquals(31, tr1.get(0).getParagraphStyle().getCharactersCovered());
+ assertEquals(1, tr1.size());
+ assertEquals(30, HSLFTextParagraph.getText(tr1).length());
+ assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
+ assertEquals(31, tr1.get(0).getTextRuns().get(0).getCharacterStyle().getCharactersCovered());
+ assertEquals(31, tr1.get(0).getParagraphStyle().getCharactersCovered());
- // Set the text to be as it is now
- HSLFTextParagraph.setText(tr1, HSLFTextParagraph.getRawText(tr1));
- tr1 = ppt1.getSlides().get(0).getTextParagraphs().get(0);
+ // Set the text to be as it is now
+ HSLFTextParagraph.setText(tr1, HSLFTextParagraph.getRawText(tr1));
+ tr1 = ppt1.getSlides().get(0).getTextParagraphs().get(0);
- // Check the text lengths are still right
- assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
- assertEquals(179, HSLFTextParagraph.getRawText(tr2).length());
+ // Check the text lengths are still right
+ assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
+ assertEquals(179, HSLFTextParagraph.getRawText(tr2).length());
- assertEquals(1, tr1.size());
- assertEquals(30, HSLFTextParagraph.getText(tr1).length());
- assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
- assertEquals(31, tr1.get(0).getTextRuns().get(0).getCharacterStyle().getCharactersCovered());
- assertEquals(31, tr1.get(0).getParagraphStyle().getCharactersCovered());
+ assertEquals(1, tr1.size());
+ assertEquals(30, HSLFTextParagraph.getText(tr1).length());
+ assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
+ assertEquals(31, tr1.get(0).getTextRuns().get(0).getCharacterStyle().getCharactersCovered());
+ assertEquals(31, tr1.get(0).getParagraphStyle().getCharactersCovered());
- // Use POIFS to query that lot
- try (POIFSFileSystem npfs = writeOutAndReadBack(ppt1.getDirectory().getFileSystem())) {
- // Check that the "PowerPoint Document" sections have the same size
- DirectoryNode oDir = ppt1.getSlideShowImpl().getDirectory();
+ // Use POIFS to query that lot
+ try (POIFSFileSystem npfs = writeOutAndReadBack(ppt1.getDirectory().getFileSystem())) {
+ // Check that the "PowerPoint Document" sections have the same size
+ DirectoryNode oDir = ppt1.getSlideShowImpl().getDirectory();
- DocumentEntry oProps = (DocumentEntry) oDir.getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT);
- DocumentEntry nProps = (DocumentEntry) npfs.getRoot().getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT);
- assertEquals(oProps.getSize(), nProps.getSize());
+ DocumentEntry oProps = (DocumentEntry) oDir.getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT);
+ DocumentEntry nProps = (DocumentEntry) npfs.getRoot().getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT);
+ assertEquals(oProps.getSize(), nProps.getSize());
- // Check that they contain the same data
- byte[] _oData = new byte[oProps.getSize()];
- byte[] _nData = new byte[nProps.getSize()];
- int oLen = oDir.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT).read(_oData);
- int nLen = npfs.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT).read(_nData);
- assertEquals(_oData.length, oLen);
- assertEquals(_nData.length, nLen);
- assertArrayEquals(_oData, _nData);
- }
- }
- }
+ // Check that they contain the same data
+ byte[] _oData = new byte[oProps.getSize()];
+ byte[] _nData = new byte[nProps.getSize()];
+ int oLen = oDir.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT).read(_oData);
+ int nLen = npfs.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT).read(_nData);
+ assertEquals(_oData.length, oLen);
+ assertEquals(_nData.length, nLen);
+ assertArrayEquals(_oData, _nData);
+ }
+ }
+ }
@Test
void testWritesOutTheSameRich() throws IOException {
- try (HSLFSlideShow ppt1 = getSlideShow("Single_Coloured_Page_With_Fonts_and_Alignments.ppt")) {
- // Grab the first text run on the first sheet
- List tr1 = ppt1.getSlides().get(0).getTextParagraphs().get(0);
+ try (HSLFSlideShow ppt1 = getSlideShow("Single_Coloured_Page_With_Fonts_and_Alignments.ppt")) {
+ // Grab the first text run on the first sheet
+ List tr1 = ppt1.getSlides().get(0).getTextParagraphs().get(0);
- // Get the first rich text run
- HSLFTextRun rtr1 = tr1.get(0).getTextRuns().get(0);
+ // Get the first rich text run
+ HSLFTextRun rtr1 = tr1.get(0).getTextRuns().get(0);
- // Check that the text sizes are as expected
- assertEquals(1, tr1.get(0).getTextRuns().size());
- assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
- assertEquals(30, rtr1.getLength());
- assertEquals(30, rtr1.getRawText().length());
- assertEquals(31, rtr1.getCharacterStyle().getCharactersCovered());
- assertEquals(31, tr1.get(0).getParagraphStyle().getCharactersCovered());
+ // Check that the text sizes are as expected
+ assertEquals(1, tr1.get(0).getTextRuns().size());
+ assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
+ assertEquals(30, rtr1.getLength());
+ assertEquals(30, rtr1.getRawText().length());
+ assertEquals(31, rtr1.getCharacterStyle().getCharactersCovered());
+ assertEquals(31, tr1.get(0).getParagraphStyle().getCharactersCovered());
- // Set the text to be as it is now
- rtr1.setText(rtr1.getRawText());
- rtr1 = tr1.get(0).getTextRuns().get(0);
+ // Set the text to be as it is now
+ rtr1.setText(rtr1.getRawText());
+ rtr1 = tr1.get(0).getTextRuns().get(0);
- // Check that the text sizes are still as expected
- assertEquals(1, tr1.get(0).getTextRuns().size());
- assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
- assertEquals(30, tr1.get(0).getTextRuns().get(0).getRawText().length());
- assertEquals(30, rtr1.getLength());
- assertEquals(30, rtr1.getRawText().length());
- assertEquals(31, rtr1.getCharacterStyle().getCharactersCovered());
- assertEquals(31, tr1.get(0).getParagraphStyle().getCharactersCovered());
+ // Check that the text sizes are still as expected
+ assertEquals(1, tr1.get(0).getTextRuns().size());
+ assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
+ assertEquals(30, tr1.get(0).getTextRuns().get(0).getRawText().length());
+ assertEquals(30, rtr1.getLength());
+ assertEquals(30, rtr1.getRawText().length());
+ assertEquals(31, rtr1.getCharacterStyle().getCharactersCovered());
+ assertEquals(31, tr1.get(0).getParagraphStyle().getCharactersCovered());
- // Use POIFS to query that lot
- try (POIFSFileSystem npfs = writeOutAndReadBack(ppt1.getDirectory().getFileSystem())) {
- // Check that the "PowerPoint Document" sections have the same size
- DirectoryNode oDir = ppt1.getSlideShowImpl().getDirectory();
+ // Use POIFS to query that lot
+ try (POIFSFileSystem npfs = writeOutAndReadBack(ppt1.getDirectory().getFileSystem())) {
+ // Check that the "PowerPoint Document" sections have the same size
+ DirectoryNode oDir = ppt1.getSlideShowImpl().getDirectory();
- DocumentEntry oProps = (DocumentEntry) oDir.getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT);
- DocumentEntry nProps = (DocumentEntry) npfs.getRoot().getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT);
- assertEquals(oProps.getSize(), nProps.getSize());
+ DocumentEntry oProps = (DocumentEntry) oDir.getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT);
+ DocumentEntry nProps = (DocumentEntry) npfs.getRoot().getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT);
+ assertEquals(oProps.getSize(), nProps.getSize());
- // Check that they contain the same data
- byte[] _oData = new byte[oProps.getSize()];
- byte[] _nData = new byte[nProps.getSize()];
+ // Check that they contain the same data
+ byte[] _oData = new byte[oProps.getSize()];
+ byte[] _nData = new byte[nProps.getSize()];
- int oLen = oDir.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT).read(_oData);
- int nLen = npfs.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT).read(_nData);
- assertEquals(_oData.length, oLen);
- assertEquals(_nData.length, nLen);
- assertArrayEquals(_oData, _nData);
- }
- }
- }
+ int oLen = oDir.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT).read(_oData);
+ int nLen = npfs.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT).read(_nData);
+ assertEquals(_oData.length, oLen);
+ assertEquals(_nData.length, nLen);
+ assertArrayEquals(_oData, _nData);
+ }
+ }
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCString.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCString.java
index 054b5c9790..57af6afcb5 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCString.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCString.java
@@ -29,79 +29,79 @@ import org.junit.jupiter.api.Test;
* Tests that CString works properly
*/
public final class TestCString {
- // From a real file
- private final byte[] data_a = { 0, 0, 0xBA-256, 0x0f, 0x10, 0, 0, 0,
- 0x48, 0, 0x6F, 0, 0x67, 0, 0x77, 0,
- 0x61, 0, 0x72, 0, 0x74, 0, 0x73, 0 };
- private final byte[] data_b = new byte[] { 0x10, 0, 0xBA-256, 0x0f, 0x10, 0, 0, 0,
- 0x43, 0, 0x6F, 0, 0x6D, 0, 0x6D, 0,
- 0x65, 0, 0x6E, 0, 0x74, 0, 0x73, 0 };
+ // From a real file
+ private final byte[] data_a = { 0, 0, 0xBA-256, 0x0f, 0x10, 0, 0, 0,
+ 0x48, 0, 0x6F, 0, 0x67, 0, 0x77, 0,
+ 0x61, 0, 0x72, 0, 0x74, 0, 0x73, 0 };
+ private final byte[] data_b = new byte[] { 0x10, 0, 0xBA-256, 0x0f, 0x10, 0, 0, 0,
+ 0x43, 0, 0x6F, 0, 0x6D, 0, 0x6D, 0,
+ 0x65, 0, 0x6E, 0, 0x74, 0, 0x73, 0 };
- @Test
+ @Test
void testRecordType() {
- CString ca = new CString(data_a, 0, data_a.length);
- assertEquals(4026L, ca.getRecordType());
- CString cb = new CString(data_b, 0, data_a.length);
- assertEquals(4026L, cb.getRecordType());
- }
+ CString ca = new CString(data_a, 0, data_a.length);
+ assertEquals(4026L, ca.getRecordType());
+ CString cb = new CString(data_b, 0, data_a.length);
+ assertEquals(4026L, cb.getRecordType());
+ }
- @Test
- void testCount() {
- CString ca = new CString(data_a, 0, data_a.length);
- assertEquals(0, ca.getOptions());
- CString cb = new CString(data_b, 0, data_a.length);
- assertEquals(0x10, cb.getOptions());
+ @Test
+ void testCount() {
+ CString ca = new CString(data_a, 0, data_a.length);
+ assertEquals(0, ca.getOptions());
+ CString cb = new CString(data_b, 0, data_a.length);
+ assertEquals(0x10, cb.getOptions());
- ca.setOptions(28);
- assertEquals(28, ca.getOptions());
- }
+ ca.setOptions(28);
+ assertEquals(28, ca.getOptions());
+ }
- @Test
- void testText() {
- CString ca = new CString(data_a, 0, data_a.length);
- assertEquals("Hogwarts", ca.getText());
- CString cb = new CString(data_b, 0, data_a.length);
- assertEquals("Comments", cb.getText());
+ @Test
+ void testText() {
+ CString ca = new CString(data_a, 0, data_a.length);
+ assertEquals("Hogwarts", ca.getText());
+ CString cb = new CString(data_b, 0, data_a.length);
+ assertEquals("Comments", cb.getText());
- ca.setText("FooBar");
- assertEquals("FooBar", ca.getText());
- }
+ ca.setText("FooBar");
+ assertEquals("FooBar", ca.getText());
+ }
- @Test
- void testWrite() throws Exception {
- CString ca = new CString(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- ca.writeOut(baos);
- byte[] b = baos.toByteArray();
- assertArrayEquals(data_a, b);
+ @Test
+ void testWrite() throws Exception {
+ CString ca = new CString(data_a, 0, data_a.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ ca.writeOut(baos);
+ byte[] b = baos.toByteArray();
+ assertArrayEquals(data_a, b);
- CString cb = new CString(data_b, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baosB = new UnsynchronizedByteArrayOutputStream();
- cb.writeOut(baosB);
- b = baosB.toByteArray();
- assertArrayEquals(data_b, b);
- }
+ CString cb = new CString(data_b, 0, data_a.length);
+ UnsynchronizedByteArrayOutputStream baosB = new UnsynchronizedByteArrayOutputStream();
+ cb.writeOut(baosB);
+ b = baosB.toByteArray();
+ assertArrayEquals(data_b, b);
+ }
- // Turn data_a into data_b
- @Test
- void testChange() throws Exception {
- CString ca = new CString(data_a, 0, data_a.length);
- ca.setText("Comments");
- ca.setOptions(0x10);
+ // Turn data_a into data_b
+ @Test
+ void testChange() throws Exception {
+ CString ca = new CString(data_a, 0, data_a.length);
+ ca.setText("Comments");
+ ca.setOptions(0x10);
- // Check bytes weren't the same
- boolean equals = true;
- for(int i=0; i new HSLFSlideShowImpl(fs).close());
+ assertThrows(EncryptedPowerPointFileException.class, () -> new HSLFSlideShowImpl(fs).close());
}
- }
+ }
- @Test
- void writeNormal() throws Exception {
- // Get raw contents from a known file
- byte[] contents;
- try (POIFSFileSystem fs = new POIFSFileSystem(_slTests.getFile(normalFile))) {
- DocumentEntry docProps = (DocumentEntry) fs.getRoot().getEntry("Current User");
- contents = new byte[docProps.getSize()];
- try (InputStream in = fs.getRoot().createDocumentInputStream("Current User")) {
- in.read(contents);
- }
- }
+ @Test
+ void writeNormal() throws Exception {
+ // Get raw contents from a known file
+ byte[] contents;
+ try (POIFSFileSystem fs = new POIFSFileSystem(_slTests.getFile(normalFile))) {
+ DocumentEntry docProps = (DocumentEntry) fs.getRoot().getEntry("Current User");
+ contents = new byte[docProps.getSize()];
+ try (InputStream in = fs.getRoot().createDocumentInputStream("Current User")) {
+ in.read(contents);
+ }
+ }
- // Now build up a new one
- CurrentUserAtom cu = new CurrentUserAtom();
- cu.setLastEditUsername("Hogwarts");
- cu.setCurrentEditOffset(0x2942);
+ // Now build up a new one
+ CurrentUserAtom cu = new CurrentUserAtom();
+ cu.setLastEditUsername("Hogwarts");
+ cu.setCurrentEditOffset(0x2942);
- // Check it matches
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- cu.writeOut(baos);
- byte[] out = baos.toByteArray();
+ // Check it matches
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ cu.writeOut(baos);
+ byte[] out = baos.toByteArray();
- assertArrayEquals(contents, out);
- }
+ assertArrayEquals(contents, out);
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocument.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocument.java
index 949a0c1ac4..ffcfd95956 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocument.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocument.java
@@ -30,57 +30,57 @@ import org.junit.jupiter.api.Test;
* Tests that Document works properly (Also tests Environment while we're at it)
*/
public final class TestDocument {
- private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
+ private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- // HSLFSlideShow primed on the test data
- private HSLFSlideShowImpl ss;
- // POIFS primed on the test data
- private POIFSFileSystem pfs;
+ // HSLFSlideShow primed on the test data
+ private HSLFSlideShowImpl ss;
+ // POIFS primed on the test data
+ private POIFSFileSystem pfs;
- @BeforeEach
- void setup() throws Exception {
- pfs = new POIFSFileSystem(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
- ss = new HSLFSlideShowImpl(pfs);
- }
+ @BeforeEach
+ void setup() throws Exception {
+ pfs = new POIFSFileSystem(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ ss = new HSLFSlideShowImpl(pfs);
+ }
- private Document getDocRecord() {
- Record[] r = ss.getRecords();
- for (int i = (r.length - 1); i >= 0; i--) {
- if (r[i] instanceof Document) {
- return (Document) r[i];
- }
- }
- throw new IllegalStateException("No Document record found");
- }
+ private Document getDocRecord() {
+ Record[] r = ss.getRecords();
+ for (int i = (r.length - 1); i >= 0; i--) {
+ if (r[i] instanceof Document) {
+ return (Document) r[i];
+ }
+ }
+ throw new IllegalStateException("No Document record found");
+ }
- @Test
- void testRecordType() {
- Document dr = getDocRecord();
- assertEquals(1000, dr.getRecordType());
- }
+ @Test
+ void testRecordType() {
+ Document dr = getDocRecord();
+ assertEquals(1000, dr.getRecordType());
+ }
- @Test
- void testChildRecords() {
- Document dr = getDocRecord();
- assertNotNull(dr.getDocumentAtom());
+ @Test
+ void testChildRecords() {
+ Document dr = getDocRecord();
+ assertNotNull(dr.getDocumentAtom());
- assertNotNull(dr.getEnvironment());
+ assertNotNull(dr.getEnvironment());
- assertNotNull(dr.getSlideListWithTexts());
- assertEquals(3, dr.getSlideListWithTexts().length);
- assertNotNull(dr.getSlideListWithTexts()[0]);
- assertNotNull(dr.getSlideListWithTexts()[1]);
- assertNotNull(dr.getSlideListWithTexts()[2]);
- }
+ assertNotNull(dr.getSlideListWithTexts());
+ assertEquals(3, dr.getSlideListWithTexts().length);
+ assertNotNull(dr.getSlideListWithTexts()[0]);
+ assertNotNull(dr.getSlideListWithTexts()[1]);
+ assertNotNull(dr.getSlideListWithTexts()[2]);
+ }
- @Test
- void testEnvironment() {
- Document dr = getDocRecord();
- Environment env = dr.getEnvironment();
+ @Test
+ void testEnvironment() {
+ Document dr = getDocRecord();
+ Environment env = dr.getEnvironment();
- assertEquals(1010, env.getRecordType());
- assertNotNull(env.getFontCollection());
- }
+ assertEquals(1010, env.getRecordType());
+ assertNotNull(env.getFontCollection());
+ }
- // No need to check re-writing - hslf.TestReWrite does all that for us
+ // No need to check re-writing - hslf.TestReWrite does all that for us
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentAtom.java
index c831a478c6..34f2480ffe 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentAtom.java
@@ -30,59 +30,59 @@ import org.junit.jupiter.api.Test;
* Tests that DocumentAtom works properly
*/
public final class TestDocumentAtom {
- // From a real file
- private final byte[] data_a = { 1, 0, 0xE9-256, 3, 0x28, 0, 0, 0,
- 0x80-256, 0x16, 0, 0, 0xE0-256, 0x10, 0, 0,
- 0xE0-256, 0x10, 0, 0, 0x80-256, 0x16, 0, 0,
- 0x05, 0, 0, 0, 0x0A, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
- 1, 0, 0, 0, 0, 0, 0, 1 };
+ // From a real file
+ private final byte[] data_a = { 1, 0, 0xE9-256, 3, 0x28, 0, 0, 0,
+ 0x80-256, 0x16, 0, 0, 0xE0-256, 0x10, 0, 0,
+ 0xE0-256, 0x10, 0, 0, 0x80-256, 0x16, 0, 0,
+ 0x05, 0, 0, 0, 0x0A, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
+ 1, 0, 0, 0, 0, 0, 0, 1 };
- @Test
+ @Test
void testRecordType() {
- DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
- assertEquals(1001L, da.getRecordType());
- }
+ DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
+ assertEquals(1001L, da.getRecordType());
+ }
- @Test
- void testSizeAndZoom() {
- DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
- assertEquals(5760L, da.getSlideSizeX());
- assertEquals(4320L, da.getSlideSizeY());
- assertEquals(4320L, da.getNotesSizeX());
- assertEquals(5760L, da.getNotesSizeY());
+ @Test
+ void testSizeAndZoom() {
+ DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
+ assertEquals(5760L, da.getSlideSizeX());
+ assertEquals(4320L, da.getSlideSizeY());
+ assertEquals(4320L, da.getNotesSizeX());
+ assertEquals(5760L, da.getNotesSizeY());
- assertEquals(5L, da.getServerZoomFrom());
- assertEquals(10L, da.getServerZoomTo());
- }
+ assertEquals(5L, da.getServerZoomFrom());
+ assertEquals(10L, da.getServerZoomTo());
+ }
- @Test
- void testMasterPersist() {
- DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
- assertEquals(2L, da.getNotesMasterPersist());
- assertEquals(0L, da.getHandoutMasterPersist());
- }
+ @Test
+ void testMasterPersist() {
+ DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
+ assertEquals(2L, da.getNotesMasterPersist());
+ assertEquals(0L, da.getHandoutMasterPersist());
+ }
- @Test
- void testSlideDetails() {
- DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
- assertEquals(1, da.getFirstSlideNum());
- assertEquals(DocumentAtom.SlideSize.ON_SCREEN, da.getSlideSizeTypeEnum());
- }
+ @Test
+ void testSlideDetails() {
+ DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
+ assertEquals(1, da.getFirstSlideNum());
+ assertEquals(DocumentAtom.SlideSize.ON_SCREEN, da.getSlideSizeTypeEnum());
+ }
- @Test
- void testBooleans() {
- DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
+ @Test
+ void testBooleans() {
+ DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
assertFalse(da.getSaveWithFonts());
assertFalse(da.getOmitTitlePlace());
assertFalse(da.getRightToLeft());
assertTrue(da.getShowComments());
- }
+ }
- @Test
- void testWrite() throws Exception {
- DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- da.writeOut(baos);
- assertArrayEquals(data_a, baos.toByteArray());
- }
+ @Test
+ void testWrite() throws Exception {
+ DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ da.writeOut(baos);
+ assertArrayEquals(data_a, baos.toByteArray());
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentEncryptionAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentEncryptionAtom.java
index c33507c404..eb1c6fba04 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentEncryptionAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentEncryptionAtom.java
@@ -28,82 +28,82 @@ import org.junit.jupiter.api.Test;
* Tests that DocumentEncryptionAtom works properly.
*/
public final class TestDocumentEncryptionAtom {
- // From a real file
- private final byte[] data_a = new byte[] {
- 0x0F, 00, 0x14, 0x2F, 0xBE-256, 00, 00, 00,
- 02, 00, 02, 00, 0x0C, 00, 00, 00,
- 0x76, 00, 00, 00, 0x0C, 00, 00, 00,
- 00, 00, 00, 00, 01, 0x68, 00, 00,
- 04, 0x80-256, 00, 00, 0x28, 00, 00, 00,
- 01, 00, 00, 00, 0x30, 00, 0x26, 01,
- 00, 00, 00, 00,
+ // From a real file
+ private final byte[] data_a = new byte[] {
+ 0x0F, 00, 0x14, 0x2F, 0xBE-256, 00, 00, 00,
+ 02, 00, 02, 00, 0x0C, 00, 00, 00,
+ 0x76, 00, 00, 00, 0x0C, 00, 00, 00,
+ 00, 00, 00, 00, 01, 0x68, 00, 00,
+ 04, 0x80-256, 00, 00, 0x28, 00, 00, 00,
+ 01, 00, 00, 00, 0x30, 00, 0x26, 01,
+ 00, 00, 00, 00,
- 0x4D, 00, 0x69, 00,
- 0x63, 00, 0x72, 00, 0x6F, 00, 0x73, 00,
- 0x6F, 00, 0x66, 00, 0x74, 00, 0x20, 00,
- 0x42, 00, 0x61, 00, 0x73, 00, 0x65, 00,
- 0x20, 00, 0x43, 00, 0x72, 00, 0x79, 00,
- 0x70, 00, 0x74, 00, 0x6F, 00, 0x67, 00,
- 0x72, 00, 0x61, 00, 0x70, 00, 0x68, 00,
- 0x69, 00, 0x63, 00, 0x20, 00, 0x50, 00,
- 0x72, 00, 0x6F, 00, 0x76, 00, 0x69, 00,
- 0x64, 00, 0x65, 00, 0x72, 00, 0x20, 00,
- 0x76, 00, 0x31, 00, 0x2E, 00, 0x30, 00,
- 0x00, 0x00,
+ 0x4D, 00, 0x69, 00,
+ 0x63, 00, 0x72, 00, 0x6F, 00, 0x73, 00,
+ 0x6F, 00, 0x66, 00, 0x74, 00, 0x20, 00,
+ 0x42, 00, 0x61, 00, 0x73, 00, 0x65, 00,
+ 0x20, 00, 0x43, 00, 0x72, 00, 0x79, 00,
+ 0x70, 00, 0x74, 00, 0x6F, 00, 0x67, 00,
+ 0x72, 00, 0x61, 00, 0x70, 00, 0x68, 00,
+ 0x69, 00, 0x63, 00, 0x20, 00, 0x50, 00,
+ 0x72, 00, 0x6F, 00, 0x76, 00, 0x69, 00,
+ 0x64, 00, 0x65, 00, 0x72, 00, 0x20, 00,
+ 0x76, 00, 0x31, 00, 0x2E, 00, 0x30, 00,
+ 0x00, 0x00,
- 0x10, 00, 0x00, 00,
- 0x62, 0xA6-256,
- 0xDF-256, 0xEA-256, 0x96-256, 0x84-256,
- 0xFB-256, 0x89-256, 0x93-256, 0xCA-256,
- 0xBA-256, 0xEE-256, 0x8E-256, 0x43,
- 0xC8-256, 0x71, 0xD1-256, 0x89-256,
- 0xF6-256, 0x4B, 0x2B, 0xD9-256,
- 0x7E, 0x0B, 0x52, 0xFB-256,
- 0x68, 0xD7-256, 0x5A, 0x4E, 0x45, 0xDF-256, 0x14, 0x00,
- 0x00, 0x00, 0x93-256, 0x15, 0x27, 0xEB-256, 0x21, 0x54,
- 0x7F, 0x0B, 0x56, 0x07, 0xEE-256, 0x66, 0xEB-256, 0x6F,
- 0xB2-256, 0x8E-256, 0x67, 0x54, 0x07, 0x04, 0x00
- };
+ 0x10, 00, 0x00, 00,
+ 0x62, 0xA6-256,
+ 0xDF-256, 0xEA-256, 0x96-256, 0x84-256,
+ 0xFB-256, 0x89-256, 0x93-256, 0xCA-256,
+ 0xBA-256, 0xEE-256, 0x8E-256, 0x43,
+ 0xC8-256, 0x71, 0xD1-256, 0x89-256,
+ 0xF6-256, 0x4B, 0x2B, 0xD9-256,
+ 0x7E, 0x0B, 0x52, 0xFB-256,
+ 0x68, 0xD7-256, 0x5A, 0x4E, 0x45, 0xDF-256, 0x14, 0x00,
+ 0x00, 0x00, 0x93-256, 0x15, 0x27, 0xEB-256, 0x21, 0x54,
+ 0x7F, 0x0B, 0x56, 0x07, 0xEE-256, 0x66, 0xEB-256, 0x6F,
+ 0xB2-256, 0x8E-256, 0x67, 0x54, 0x07, 0x04, 0x00
+ };
- private final byte[] data_b = new byte[] {
- 15, 0, 20, 47, -66, 0, 0, 0,
- 2, 0, 2, 0, 4,
- 0, 0, 0, 118, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0,
- 0, 1, 104, 0, 0, 4, -128, 0, 0, 56, 0, 0, 0,
- 1, 0, 0, 0, 48, 0, 38, 1, 0, 0, 0, 0, 77, 0,
- 105, 0, 99, 0, 114, 0, 111, 0, 115, 0, 111,
- 0, 102, 0, 116, 0, 32, 0, 66, 0, 97, 0, 115,
- 0, 101, 0, 32, 0, 67, 0, 114, 0, 121, 0, 112,
- 0, 116, 0, 111, 0, 103, 0, 114, 0, 97, 0,
- 112, 0, 104, 0, 105, 0, 99, 0, 32, 0, 80, 0,
- 114, 0, 111, 0, 118, 0, 105, 0, 100, 0, 101,
- 0, 114, 0, 32, 0, 118, 0, 49, 0, 46, 0, 48,
- 0, 0, 0, 16, 0, 0, 0, -80, -66, 112, -40, 57,
- 110, 54, 80, 64, 61, -73, -29, 48, -35, -20,
- 17, -40, 84, 54, 6, -103, 125, -22, -72, 53,
- 103, -114, 13, -48, 111, 29, 78, 20, 0, 0,
- 0, -97, -67, 55, -62, -94, 14, 15, -21, 37,
- 3, -104, 22, 6, 102, -61, -98, 62, 40, 61, 21
- };
+ private final byte[] data_b = new byte[] {
+ 15, 0, 20, 47, -66, 0, 0, 0,
+ 2, 0, 2, 0, 4,
+ 0, 0, 0, 118, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0,
+ 0, 1, 104, 0, 0, 4, -128, 0, 0, 56, 0, 0, 0,
+ 1, 0, 0, 0, 48, 0, 38, 1, 0, 0, 0, 0, 77, 0,
+ 105, 0, 99, 0, 114, 0, 111, 0, 115, 0, 111,
+ 0, 102, 0, 116, 0, 32, 0, 66, 0, 97, 0, 115,
+ 0, 101, 0, 32, 0, 67, 0, 114, 0, 121, 0, 112,
+ 0, 116, 0, 111, 0, 103, 0, 114, 0, 97, 0,
+ 112, 0, 104, 0, 105, 0, 99, 0, 32, 0, 80, 0,
+ 114, 0, 111, 0, 118, 0, 105, 0, 100, 0, 101,
+ 0, 114, 0, 32, 0, 118, 0, 49, 0, 46, 0, 48,
+ 0, 0, 0, 16, 0, 0, 0, -80, -66, 112, -40, 57,
+ 110, 54, 80, 64, 61, -73, -29, 48, -35, -20,
+ 17, -40, 84, 54, 6, -103, 125, -22, -72, 53,
+ 103, -114, 13, -48, 111, 29, 78, 20, 0, 0,
+ 0, -97, -67, 55, -62, -94, 14, 15, -21, 37,
+ 3, -104, 22, 6, 102, -61, -98, 62, 40, 61, 21
+ };
- @Test
+ @Test
void recordType() throws IOException {
- DocumentEncryptionAtom dea1 = new DocumentEncryptionAtom(data_a, 0, data_a.length);
- assertEquals(12052l, dea1.getRecordType());
+ DocumentEncryptionAtom dea1 = new DocumentEncryptionAtom(data_a, 0, data_a.length);
+ assertEquals(12052l, dea1.getRecordType());
- DocumentEncryptionAtom dea2 = new DocumentEncryptionAtom(data_b, 0, data_b.length);
- assertEquals(12052l, dea2.getRecordType());
+ DocumentEncryptionAtom dea2 = new DocumentEncryptionAtom(data_b, 0, data_b.length);
+ assertEquals(12052l, dea2.getRecordType());
- assertEquals(199, data_a.length);
- assertEquals(198, data_b.length);
- }
+ assertEquals(199, data_a.length);
+ assertEquals(198, data_b.length);
+ }
- @Test
+ @Test
void encryptionTypeName() throws IOException {
- DocumentEncryptionAtom dea1 = new DocumentEncryptionAtom(data_a, 0, data_a.length);
- assertEquals("Microsoft Base Cryptographic Provider v1.0", dea1.getEncryptionProviderName());
+ DocumentEncryptionAtom dea1 = new DocumentEncryptionAtom(data_a, 0, data_a.length);
+ assertEquals("Microsoft Base Cryptographic Provider v1.0", dea1.getEncryptionProviderName());
- DocumentEncryptionAtom dea2 = new DocumentEncryptionAtom(data_b, 0, data_b.length);
- assertEquals("Microsoft Base Cryptographic Provider v1.0", dea2.getEncryptionProviderName());
+ DocumentEncryptionAtom dea2 = new DocumentEncryptionAtom(data_b, 0, data_b.length);
+ assertEquals("Microsoft Base Cryptographic Provider v1.0", dea2.getEncryptionProviderName());
}
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExControl.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExControl.java
index 2faa7ebfd8..2b1cfa3bda 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExControl.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExControl.java
@@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test;
*/
public final class TestExControl {
- // From a real file (embedded SWF control)
+ // From a real file (embedded SWF control)
/*
@@ -70,53 +70,53 @@ public final class TestExControl {
0x65, 0x00, 0x63, 0x00, 0x74, 0x00
};
- @Test
- void testRead() {
- ExControl record = new ExControl(data, 0, data.length);
- assertEquals(RecordTypes.ExControl.typeID, record.getRecordType());
+ @Test
+ void testRead() {
+ ExControl record = new ExControl(data, 0, data.length);
+ assertEquals(RecordTypes.ExControl.typeID, record.getRecordType());
- assertNotNull(record.getExControlAtom());
- assertEquals(256, record.getExControlAtom().getSlideId());
+ assertNotNull(record.getExControlAtom());
+ assertEquals(256, record.getExControlAtom().getSlideId());
- ExOleObjAtom oleObj = record.getExOleObjAtom();
- assertNotNull(oleObj);
- assertEquals(oleObj.getDrawAspect(), ExOleObjAtom.DRAW_ASPECT_VISIBLE);
- assertEquals(oleObj.getType(), ExOleObjAtom.TYPE_CONTROL);
- assertEquals(oleObj.getSubType(), ExOleObjAtom.SUBTYPE_DEFAULT);
+ ExOleObjAtom oleObj = record.getExOleObjAtom();
+ assertNotNull(oleObj);
+ assertEquals(oleObj.getDrawAspect(), ExOleObjAtom.DRAW_ASPECT_VISIBLE);
+ assertEquals(oleObj.getType(), ExOleObjAtom.TYPE_CONTROL);
+ assertEquals(oleObj.getSubType(), ExOleObjAtom.SUBTYPE_DEFAULT);
- assertEquals("Shockwave Flash Object", record.getMenuName());
- assertEquals("ShockwaveFlash.ShockwaveFlash.9", record.getProgId());
- assertEquals("Shockwave Flash Object", record.getClipboardName());
- }
+ assertEquals("Shockwave Flash Object", record.getMenuName());
+ assertEquals("ShockwaveFlash.ShockwaveFlash.9", record.getProgId());
+ assertEquals("Shockwave Flash Object", record.getClipboardName());
+ }
- @Test
- void testWrite() throws Exception {
- ExControl record = new ExControl(data, 0, data.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- record.writeOut(baos);
- assertArrayEquals(data, baos.toByteArray());
- }
+ @Test
+ void testWrite() throws Exception {
+ ExControl record = new ExControl(data, 0, data.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ record.writeOut(baos);
+ assertArrayEquals(data, baos.toByteArray());
+ }
- @Test
- void testNewRecord() throws Exception {
- ExControl record = new ExControl();
- ExControlAtom ctrl = record.getExControlAtom();
- ctrl.setSlideId(256);
+ @Test
+ void testNewRecord() throws Exception {
+ ExControl record = new ExControl();
+ ExControlAtom ctrl = record.getExControlAtom();
+ ctrl.setSlideId(256);
- ExOleObjAtom oleObj = record.getExOleObjAtom();
- oleObj.setDrawAspect(ExOleObjAtom.DRAW_ASPECT_VISIBLE);
- oleObj.setType(ExOleObjAtom.TYPE_CONTROL);
- oleObj.setObjID(1);
- oleObj.setSubType(ExOleObjAtom.SUBTYPE_DEFAULT);
- oleObj.setObjStgDataRef(2);
- oleObj.setOptions(1283584);
+ ExOleObjAtom oleObj = record.getExOleObjAtom();
+ oleObj.setDrawAspect(ExOleObjAtom.DRAW_ASPECT_VISIBLE);
+ oleObj.setType(ExOleObjAtom.TYPE_CONTROL);
+ oleObj.setObjID(1);
+ oleObj.setSubType(ExOleObjAtom.SUBTYPE_DEFAULT);
+ oleObj.setObjStgDataRef(2);
+ oleObj.setOptions(1283584);
- record.setMenuName("Shockwave Flash Object");
- record.setProgId("ShockwaveFlash.ShockwaveFlash.9");
- record.setClipboardName("Shockwave Flash Object");
+ record.setMenuName("Shockwave Flash Object");
+ record.setProgId("ShockwaveFlash.ShockwaveFlash.9");
+ record.setClipboardName("Shockwave Flash Object");
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- record.writeOut(baos);
- assertArrayEquals(data, baos.toByteArray());
- }
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ record.writeOut(baos);
+ assertArrayEquals(data, baos.toByteArray());
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlink.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlink.java
index 42a9867560..d67a9db105 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlink.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlink.java
@@ -36,17 +36,17 @@ import org.junit.jupiter.api.Test;
* Tests that ExHyperlink works properly.
*/
public final class TestExHyperlink {
- @Test
+ @Test
void testReadWrite() throws IOException {
// From a real file
byte[] exHyperlinkBytes = org.apache.poi.poifs.storage.RawDataUtil.decompress(
"H4sIAAAAAAAAAONnuM6/ggEELvOzAElmMHsXvxuQzGAoAcICBisGfSDMYkhkyAbi"+
"IqBYIoMeEBcAcTJQVSqQlw8UTweqKgCyMoF0BkMxEKYBWQJUNQ0A/k1x3rAAAAA="
);
- ExHyperlink exHyperlink = new ExHyperlink(exHyperlinkBytes, 0, exHyperlinkBytes.length);
+ ExHyperlink exHyperlink = new ExHyperlink(exHyperlinkBytes, 0, exHyperlinkBytes.length);
- assertEquals(4055L, exHyperlink.getRecordType());
+ assertEquals(4055L, exHyperlink.getRecordType());
assertEquals(3, exHyperlink.getExHyperlinkAtom().getNumber());
String expURL = "http://jakarta.apache.org/poi/hssf/";
assertEquals(expURL, exHyperlink.getLinkURL());
@@ -56,56 +56,56 @@ public final class TestExHyperlink {
UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
exHyperlink.writeOut(baos);
assertArrayEquals(exHyperlinkBytes, baos.toByteArray());
- }
+ }
- @Test
- void testRealFile() throws IOException {
+ @Test
+ void testRealFile() throws IOException {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- HSLFSlideShowImpl hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("WithLinks.ppt"));
- HSLFSlideShow ss = new HSLFSlideShow(hss);
+ HSLFSlideShowImpl hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("WithLinks.ppt"));
+ HSLFSlideShow ss = new HSLFSlideShow(hss);
- // Get the document
- Document doc = ss.getDocumentRecord();
- // Get the ExObjList
- ExObjList exObjList = null;
- for (final Record rec : doc._children) {
- if(rec instanceof ExObjList) {
- exObjList = (ExObjList)rec;
- }
- }
+ // Get the document
+ Document doc = ss.getDocumentRecord();
+ // Get the ExObjList
+ ExObjList exObjList = null;
+ for (final Record rec : doc._children) {
+ if(rec instanceof ExObjList) {
+ exObjList = (ExObjList)rec;
+ }
+ }
- assertNotNull(exObjList);
+ assertNotNull(exObjList);
- // Within that, grab out the Hyperlink atoms
- List linksA = new ArrayList<>();
- for (Record ch : exObjList._children) {
- if(ch instanceof ExHyperlink) {
- linksA.add((ExHyperlink) ch);
- }
- }
+ // Within that, grab out the Hyperlink atoms
+ List linksA = new ArrayList<>();
+ for (Record ch : exObjList._children) {
+ if(ch instanceof ExHyperlink) {
+ linksA.add((ExHyperlink) ch);
+ }
+ }
- // Should be 4 of them
- assertEquals(4, linksA.size());
- ExHyperlink[] links = new ExHyperlink[linksA.size()];
- linksA.toArray(links);
+ // Should be 4 of them
+ assertEquals(4, linksA.size());
+ ExHyperlink[] links = new ExHyperlink[linksA.size()];
+ linksA.toArray(links);
- assertEquals(4, exObjList.getExHyperlinks().length);
+ assertEquals(4, exObjList.getExHyperlinks().length);
- // Check the other way
+ // Check the other way
- // Check they have what we expect in them
- assertEquals(1, links[0].getExHyperlinkAtom().getNumber());
- assertEquals("http://jakarta.apache.org/poi/", links[0].getLinkURL());
+ // Check they have what we expect in them
+ assertEquals(1, links[0].getExHyperlinkAtom().getNumber());
+ assertEquals("http://jakarta.apache.org/poi/", links[0].getLinkURL());
- assertEquals(2, links[1].getExHyperlinkAtom().getNumber());
- assertEquals("http://slashdot.org/", links[1].getLinkURL());
+ assertEquals(2, links[1].getExHyperlinkAtom().getNumber());
+ assertEquals("http://slashdot.org/", links[1].getLinkURL());
- assertEquals(3, links[2].getExHyperlinkAtom().getNumber());
- assertEquals("http://jakarta.apache.org/poi/hssf/", links[2].getLinkURL());
+ assertEquals(3, links[2].getExHyperlinkAtom().getNumber());
+ assertEquals("http://jakarta.apache.org/poi/hssf/", links[2].getLinkURL());
- assertEquals(4, links[3].getExHyperlinkAtom().getNumber());
- assertEquals("http://jakarta.apache.org/hslf/", links[3].getLinkURL());
+ assertEquals(4, links[3].getExHyperlinkAtom().getNumber());
+ assertEquals("http://jakarta.apache.org/hslf/", links[3].getLinkURL());
- ss.close();
- }
+ ss.close();
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlinkAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlinkAtom.java
index f868d96b16..f738f44ec8 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlinkAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlinkAtom.java
@@ -28,64 +28,64 @@ import org.junit.jupiter.api.Test;
* Tests that ExHyperlinkAtom works properly.
*/
public class TestExHyperlinkAtom {
- // From a real file
- private final byte[] data_a = new byte[] {
- 0, 0, 0xD3-256, 0x0F, 4, 0, 0, 0,
- 1, 0, 0, 0
- };
- private final byte[] data_b = new byte[] {
- 0, 0, 0xD3-256, 0x0F, 4, 0, 0, 0,
- 4, 0, 0, 0
- };
+ // From a real file
+ private final byte[] data_a = new byte[] {
+ 0, 0, 0xD3-256, 0x0F, 4, 0, 0, 0,
+ 1, 0, 0, 0
+ };
+ private final byte[] data_b = new byte[] {
+ 0, 0, 0xD3-256, 0x0F, 4, 0, 0, 0,
+ 4, 0, 0, 0
+ };
- @Test
+ @Test
void testRecordType() {
- ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
- assertEquals(4051L, eha.getRecordType());
- }
-
- @Test
- void testGetNumber() {
- ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
- ExHyperlinkAtom ehb = new ExHyperlinkAtom(data_b, 0, data_b.length);
-
- assertEquals(1, eha.getNumber());
- assertEquals(4, ehb.getNumber());
+ ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
+ assertEquals(4051L, eha.getRecordType());
}
- @Test
- void testWrite() throws Exception {
- ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- eha.writeOut(baos);
- assertArrayEquals(data_a, baos.toByteArray());
- }
+ @Test
+ void testGetNumber() {
+ ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
+ ExHyperlinkAtom ehb = new ExHyperlinkAtom(data_b, 0, data_b.length);
- // Create A from scratch
- @Test
- void testCreate() throws Exception {
- ExHyperlinkAtom eha = new ExHyperlinkAtom();
+ assertEquals(1, eha.getNumber());
+ assertEquals(4, ehb.getNumber());
+ }
- // Set value
- eha.setNumber(1);
+ @Test
+ void testWrite() throws Exception {
+ ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ eha.writeOut(baos);
+ assertArrayEquals(data_a, baos.toByteArray());
+ }
- // Check it's now the same as a
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- eha.writeOut(baos);
- assertArrayEquals(data_a, baos.toByteArray());
- }
+ // Create A from scratch
+ @Test
+ void testCreate() throws Exception {
+ ExHyperlinkAtom eha = new ExHyperlinkAtom();
- // Try to turn a into b
- @Test
- void testChange() throws Exception {
- ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
+ // Set value
+ eha.setNumber(1);
- // Change the number
- eha.setNumber(4);
+ // Check it's now the same as a
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ eha.writeOut(baos);
+ assertArrayEquals(data_a, baos.toByteArray());
+ }
- // Check bytes are now the same
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- eha.writeOut(baos);
- assertArrayEquals(data_b, baos.toByteArray());
- }
+ // Try to turn a into b
+ @Test
+ void testChange() throws Exception {
+ ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
+
+ // Change the number
+ eha.setNumber(4);
+
+ // Check bytes are now the same
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ eha.writeOut(baos);
+ assertArrayEquals(data_b, baos.toByteArray());
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExMediaAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExMediaAtom.java
index 606f0ac827..6d7e08c6a9 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExMediaAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExMediaAtom.java
@@ -30,68 +30,68 @@ import org.junit.jupiter.api.Test;
* Tests that {@link org.apache.poi.hslf.record.HeadersFootersAtom} works properly
*/
public final class TestExMediaAtom {
- // From a real file
- private static final byte[] data = {
- 0x00, 0x00, (byte)0x04, 0x10, 0x08, 0x00, 0x00, 0,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+ // From a real file
+ private static final byte[] data = {
+ 0x00, 0x00, (byte)0x04, 0x10, 0x08, 0x00, 0x00, 0,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
- @Test
- void testRead() {
- ExMediaAtom record = new ExMediaAtom(data, 0, data.length);
- assertEquals(RecordTypes.ExMediaAtom.typeID, record.getRecordType());
+ @Test
+ void testRead() {
+ ExMediaAtom record = new ExMediaAtom(data, 0, data.length);
+ assertEquals(RecordTypes.ExMediaAtom.typeID, record.getRecordType());
- assertEquals(1, record.getObjectId());
- assertFalse(record.getFlag(ExMediaAtom.fLoop));
- assertFalse(record.getFlag(ExMediaAtom.fNarration));
- assertFalse(record.getFlag(ExMediaAtom.fRewind));
- }
+ assertEquals(1, record.getObjectId());
+ assertFalse(record.getFlag(ExMediaAtom.fLoop));
+ assertFalse(record.getFlag(ExMediaAtom.fNarration));
+ assertFalse(record.getFlag(ExMediaAtom.fRewind));
+ }
- @Test
- void testWrite() throws Exception {
- ExMediaAtom record = new ExMediaAtom(data, 0, data.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- record.writeOut(baos);
- byte[] b = baos.toByteArray();
+ @Test
+ void testWrite() throws Exception {
+ ExMediaAtom record = new ExMediaAtom(data, 0, data.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ record.writeOut(baos);
+ byte[] b = baos.toByteArray();
- assertArrayEquals(data, b);
- }
+ assertArrayEquals(data, b);
+ }
- @Test
- void testNewRecord() throws Exception {
- ExMediaAtom ref = new ExMediaAtom(data, 0, data.length);
- assertEquals(0, ref.getMask()); //
+ @Test
+ void testNewRecord() throws Exception {
+ ExMediaAtom ref = new ExMediaAtom(data, 0, data.length);
+ assertEquals(0, ref.getMask()); //
- ExMediaAtom record = new ExMediaAtom();
- record.setObjectId(1);
- record.setFlag(HeadersFootersAtom.fHasDate, false);
- record.setFlag(HeadersFootersAtom.fHasTodayDate, false);
- record.setFlag(HeadersFootersAtom.fHasFooter, false);
+ ExMediaAtom record = new ExMediaAtom();
+ record.setObjectId(1);
+ record.setFlag(HeadersFootersAtom.fHasDate, false);
+ record.setFlag(HeadersFootersAtom.fHasTodayDate, false);
+ record.setFlag(HeadersFootersAtom.fHasFooter, false);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- record.writeOut(baos);
- byte[] b = baos.toByteArray();
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ record.writeOut(baos);
+ byte[] b = baos.toByteArray();
- assertArrayEquals(data, b);
- }
+ assertArrayEquals(data, b);
+ }
- @Test
- void testFlags() {
- ExMediaAtom record = new ExMediaAtom();
+ @Test
+ void testFlags() {
+ ExMediaAtom record = new ExMediaAtom();
- //in a new record all the bits are 0
- for(int i = 0; i < 3; i++) assertFalse(record.getFlag(1 << i));
+ //in a new record all the bits are 0
+ for(int i = 0; i < 3; i++) assertFalse(record.getFlag(1 << i));
- record.setFlag(ExMediaAtom.fLoop, true);
- assertTrue(record.getFlag(ExMediaAtom.fLoop));
+ record.setFlag(ExMediaAtom.fLoop, true);
+ assertTrue(record.getFlag(ExMediaAtom.fLoop));
- record.setFlag(ExMediaAtom.fNarration, true);
- assertTrue(record.getFlag(ExMediaAtom.fNarration));
+ record.setFlag(ExMediaAtom.fNarration, true);
+ assertTrue(record.getFlag(ExMediaAtom.fNarration));
- record.setFlag(ExMediaAtom.fNarration, false);
- assertFalse(record.getFlag(ExMediaAtom.fNarration));
+ record.setFlag(ExMediaAtom.fNarration, false);
+ assertFalse(record.getFlag(ExMediaAtom.fNarration));
- record.setFlag(ExMediaAtom.fNarration, false);
- assertFalse(record.getFlag(ExMediaAtom.fNarration));
+ record.setFlag(ExMediaAtom.fNarration, false);
+ assertFalse(record.getFlag(ExMediaAtom.fNarration));
- }
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjList.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjList.java
index 0301b61463..56cc3ed677 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjList.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjList.java
@@ -32,38 +32,38 @@ public class TestExObjList {
@Test
void testRealFile() throws Exception {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- HSLFSlideShow ss = new HSLFSlideShow(slTests.openResourceAsStream("WithLinks.ppt"));
+ HSLFSlideShow ss = new HSLFSlideShow(slTests.openResourceAsStream("WithLinks.ppt"));
- // Get the document
- Document doc = ss.getDocumentRecord();
- // Get the ExObjList
- ExObjList exObjList = doc.getExObjList(false);
- assertNotNull(exObjList);
- assertEquals(1033l, exObjList.getRecordType());
+ // Get the document
+ Document doc = ss.getDocumentRecord();
+ // Get the ExObjList
+ ExObjList exObjList = doc.getExObjList(false);
+ assertNotNull(exObjList);
+ assertEquals(1033l, exObjList.getRecordType());
- // Check the atom
- assertNotNull(exObjList.getExObjListAtom());
- assertEquals(4, exObjList.getExObjListAtom().getObjectIDSeed());
+ // Check the atom
+ assertNotNull(exObjList.getExObjListAtom());
+ assertEquals(4, exObjList.getExObjListAtom().getObjectIDSeed());
- // Check the Hyperlinks
- assertEquals(4, exObjList.getExHyperlinks().length);
+ // Check the Hyperlinks
+ assertEquals(4, exObjList.getExHyperlinks().length);
- // Check the contents
- ExHyperlink[] links = exObjList.getExHyperlinks();
+ // Check the contents
+ ExHyperlink[] links = exObjList.getExHyperlinks();
- // Check they have what we expect in them
- assertEquals(1, links[0].getExHyperlinkAtom().getNumber());
- assertEquals("http://jakarta.apache.org/poi/", links[0].getLinkURL());
+ // Check they have what we expect in them
+ assertEquals(1, links[0].getExHyperlinkAtom().getNumber());
+ assertEquals("http://jakarta.apache.org/poi/", links[0].getLinkURL());
- assertEquals(2, links[1].getExHyperlinkAtom().getNumber());
- assertEquals("http://slashdot.org/", links[1].getLinkURL());
+ assertEquals(2, links[1].getExHyperlinkAtom().getNumber());
+ assertEquals("http://slashdot.org/", links[1].getLinkURL());
- assertEquals(3, links[2].getExHyperlinkAtom().getNumber());
- assertEquals("http://jakarta.apache.org/poi/hssf/", links[2].getLinkURL());
+ assertEquals(3, links[2].getExHyperlinkAtom().getNumber());
+ assertEquals("http://jakarta.apache.org/poi/hssf/", links[2].getLinkURL());
- assertEquals(4, links[3].getExHyperlinkAtom().getNumber());
- assertEquals("http://jakarta.apache.org/hslf/", links[3].getLinkURL());
+ assertEquals(4, links[3].getExHyperlinkAtom().getNumber());
+ assertEquals("http://jakarta.apache.org/hslf/", links[3].getLinkURL());
- ss.close();
- }
+ ss.close();
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjListAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjListAtom.java
index 97d3ef1707..d8a5229aba 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjListAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjListAtom.java
@@ -28,64 +28,64 @@ import org.junit.jupiter.api.Test;
* Tests that ExObjListAtom works properly.
*/
public class TestExObjListAtom {
- // From a real file
- private final byte[] data_a = new byte[] {
- 0, 0, 0x0A, 0x04, 4, 0, 0, 0,
- 1, 0, 0, 0
- };
- private final byte[] data_b = new byte[] {
- 0, 0, 0x0A, 0x04, 4, 0, 0, 0,
- 4, 0, 0, 0
- };
+ // From a real file
+ private final byte[] data_a = new byte[] {
+ 0, 0, 0x0A, 0x04, 4, 0, 0, 0,
+ 1, 0, 0, 0
+ };
+ private final byte[] data_b = new byte[] {
+ 0, 0, 0x0A, 0x04, 4, 0, 0, 0,
+ 4, 0, 0, 0
+ };
- @Test
- void testRecordType() {
- ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
- BaseTestNumeric.assertDouble(1034L, eoa.getRecordType());
- }
+ @Test
+ void testRecordType() {
+ ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
+ BaseTestNumeric.assertDouble(1034L, eoa.getRecordType());
+ }
- @Test
- void testGetSeed() {
- ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
- ExObjListAtom eob = new ExObjListAtom(data_b, 0, data_b.length);
+ @Test
+ void testGetSeed() {
+ ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
+ ExObjListAtom eob = new ExObjListAtom(data_b, 0, data_b.length);
- BaseTestNumeric.assertDouble(1, eoa.getObjectIDSeed());
- BaseTestNumeric.assertDouble(4, eob.getObjectIDSeed());
- }
+ BaseTestNumeric.assertDouble(1, eoa.getObjectIDSeed());
+ BaseTestNumeric.assertDouble(4, eob.getObjectIDSeed());
+ }
- @Test
- void testWrite() throws Exception {
- ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- eoa.writeOut(baos);
- assertArrayEquals(data_a, baos.toByteArray());
- }
+ @Test
+ void testWrite() throws Exception {
+ ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ eoa.writeOut(baos);
+ assertArrayEquals(data_a, baos.toByteArray());
+ }
- // Create A from scratch
- @Test
- void testCreate() throws Exception {
- ExObjListAtom eoa = new ExObjListAtom();
+ // Create A from scratch
+ @Test
+ void testCreate() throws Exception {
+ ExObjListAtom eoa = new ExObjListAtom();
- // Set seed
- eoa.setObjectIDSeed(1);
+ // Set seed
+ eoa.setObjectIDSeed(1);
- // Check it's now the same as a
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- eoa.writeOut(baos);
- assertArrayEquals(data_a, baos.toByteArray());
- }
+ // Check it's now the same as a
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ eoa.writeOut(baos);
+ assertArrayEquals(data_a, baos.toByteArray());
+ }
- // Try to turn a into b
- @Test
- void testChange() throws Exception {
- ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
+ // Try to turn a into b
+ @Test
+ void testChange() throws Exception {
+ ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
- // Change the number
- eoa.setObjectIDSeed(4);
+ // Change the number
+ eoa.setObjectIDSeed(4);
- // Check bytes are now the same
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- eoa.writeOut(baos);
- assertArrayEquals(data_b, baos.toByteArray());
- }
+ // Check bytes are now the same
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ eoa.writeOut(baos);
+ assertArrayEquals(data_b, baos.toByteArray());
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExOleObjAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExOleObjAtom.java
index a0860abbbe..01d72f3265 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExOleObjAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExOleObjAtom.java
@@ -27,45 +27,45 @@ import org.junit.jupiter.api.Test;
* Tests that {@link ExOleObjAtom} works properly
*/
public final class TestExOleObjAtom {
- // From a real file (embedded SWF control)
- private final byte[] data = {
- 0x01, 0x00, (byte)0xC3, 0x0F, 0x18, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, (byte)0x96, 0x13, 0x00 };
+ // From a real file (embedded SWF control)
+ private final byte[] data = {
+ 0x01, 0x00, (byte)0xC3, 0x0F, 0x18, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, (byte)0x96, 0x13, 0x00 };
- @Test
- void testRead() {
- ExOleObjAtom record = new ExOleObjAtom(data, 0, data.length);
- assertEquals(RecordTypes.ExOleObjAtom.typeID, record.getRecordType());
+ @Test
+ void testRead() {
+ ExOleObjAtom record = new ExOleObjAtom(data, 0, data.length);
+ assertEquals(RecordTypes.ExOleObjAtom.typeID, record.getRecordType());
- assertEquals(record.getDrawAspect(), ExOleObjAtom.DRAW_ASPECT_VISIBLE);
- assertEquals(record.getType(), ExOleObjAtom.TYPE_CONTROL);
- assertEquals(record.getObjID(), 1);
- assertEquals(record.getSubType(), ExOleObjAtom.SUBTYPE_DEFAULT);
- assertEquals(record.getObjStgDataRef(), 2);
- assertEquals(record.getOptions(), 1283584); //ther meaning is unknown
- }
+ assertEquals(record.getDrawAspect(), ExOleObjAtom.DRAW_ASPECT_VISIBLE);
+ assertEquals(record.getType(), ExOleObjAtom.TYPE_CONTROL);
+ assertEquals(record.getObjID(), 1);
+ assertEquals(record.getSubType(), ExOleObjAtom.SUBTYPE_DEFAULT);
+ assertEquals(record.getObjStgDataRef(), 2);
+ assertEquals(record.getOptions(), 1283584); //ther meaning is unknown
+ }
- @Test
- void testWrite() throws Exception {
- ExOleObjAtom record = new ExOleObjAtom(data, 0, data.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- record.writeOut(baos);
- assertArrayEquals(data, baos.toByteArray());
- }
+ @Test
+ void testWrite() throws Exception {
+ ExOleObjAtom record = new ExOleObjAtom(data, 0, data.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ record.writeOut(baos);
+ assertArrayEquals(data, baos.toByteArray());
+ }
- @Test
- void testNewRecord() throws Exception {
- ExOleObjAtom record = new ExOleObjAtom();
- record.setDrawAspect(ExOleObjAtom.DRAW_ASPECT_VISIBLE);
- record.setType(ExOleObjAtom.TYPE_CONTROL);
- record.setObjID(1);
- record.setSubType(ExOleObjAtom.SUBTYPE_DEFAULT);
- record.setObjStgDataRef(2);
- record.setOptions(1283584);
+ @Test
+ void testNewRecord() throws Exception {
+ ExOleObjAtom record = new ExOleObjAtom();
+ record.setDrawAspect(ExOleObjAtom.DRAW_ASPECT_VISIBLE);
+ record.setType(ExOleObjAtom.TYPE_CONTROL);
+ record.setObjID(1);
+ record.setSubType(ExOleObjAtom.SUBTYPE_DEFAULT);
+ record.setObjStgDataRef(2);
+ record.setOptions(1283584);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- record.writeOut(baos);
- assertArrayEquals(data, baos.toByteArray());
- }
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ record.writeOut(baos);
+ assertArrayEquals(data, baos.toByteArray());
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestHeadersFootersAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestHeadersFootersAtom.java
index 7277fc4790..71ea592da2 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestHeadersFootersAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestHeadersFootersAtom.java
@@ -30,15 +30,15 @@ import org.junit.jupiter.api.Test;
* Tests that {@link HeadersFootersAtom} works properly
*/
public final class TestHeadersFootersAtom {
- // From a real file
- private final byte[] data = new byte[] {
+ // From a real file
+ private final byte[] data = new byte[] {
0x00, 0x00, (byte)0xDA, 0x0F, 0x04, 0x00, 0x00, 0,
0x00, 0x00, 0x23, 0x00 };
@Test
void testRead() {
- HeadersFootersAtom record = new HeadersFootersAtom(data, 0, data.length);
- assertEquals(RecordTypes.HeadersFootersAtom.typeID, record.getRecordType());
+ HeadersFootersAtom record = new HeadersFootersAtom(data, 0, data.length);
+ assertEquals(RecordTypes.HeadersFootersAtom.typeID, record.getRecordType());
assertEquals(0, record.getFormatId());
assertEquals(0x23, record.getMask());
@@ -52,12 +52,12 @@ public final class TestHeadersFootersAtom {
}
@Test
- void testWrite() throws Exception {
- HeadersFootersAtom record = new HeadersFootersAtom(data, 0, data.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- record.writeOut(baos);
- assertArrayEquals(data, baos.toByteArray());
- }
+ void testWrite() throws Exception {
+ HeadersFootersAtom record = new HeadersFootersAtom(data, 0, data.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ record.writeOut(baos);
+ assertArrayEquals(data, baos.toByteArray());
+ }
@Test
void testNewRecord() throws Exception {
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestHeadersFootersContainer.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestHeadersFootersContainer.java
index 5d6d15b798..21d7a83d16 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestHeadersFootersContainer.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestHeadersFootersContainer.java
@@ -30,8 +30,8 @@ import org.junit.jupiter.api.Test;
* Tests that {@link HeadersFootersContainer} works properly
*/
public final class TestHeadersFootersContainer {
- // SlideHeadersFootersContainer
- private final byte[] slideData = new byte[] {
+ // SlideHeadersFootersContainer
+ private final byte[] slideData = new byte[] {
0x3F, 0x00, (byte)0xD9, 0x0F, 0x2E, 0x00, 0x00, 0x00,
0x00, 0x00, (byte)0xDA, 0x0F, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00,
0x20, 0x00, (byte)0xBA, 0x0F, 0x1A, 0x00, 0x00, 0x00,
@@ -54,8 +54,8 @@ public final class TestHeadersFootersContainer {
@Test
void testReadSlideHeadersFootersContainer() {
- HeadersFootersContainer record = new HeadersFootersContainer(slideData, 0, slideData.length);
- assertEquals(RecordTypes.HeadersFooters.typeID, record.getRecordType());
+ HeadersFootersContainer record = new HeadersFootersContainer(slideData, 0, slideData.length);
+ assertEquals(RecordTypes.HeadersFooters.typeID, record.getRecordType());
assertEquals(HeadersFootersContainer.SlideHeadersFootersContainer, record.getOptions());
assertEquals(2, record.getChildRecords().length);
@@ -73,12 +73,12 @@ public final class TestHeadersFootersContainer {
}
@Test
- void testWriteSlideHeadersFootersContainer() throws Exception {
- HeadersFootersContainer record = new HeadersFootersContainer(slideData, 0, slideData.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- record.writeOut(baos);
- assertArrayEquals(slideData, baos.toByteArray());
- }
+ void testWriteSlideHeadersFootersContainer() throws Exception {
+ HeadersFootersContainer record = new HeadersFootersContainer(slideData, 0, slideData.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ record.writeOut(baos);
+ assertArrayEquals(slideData, baos.toByteArray());
+ }
@Test
void testNewSlideHeadersFootersContainer() throws Exception {
@@ -106,8 +106,8 @@ public final class TestHeadersFootersContainer {
@Test
void testReadNotesHeadersFootersContainer() {
- HeadersFootersContainer record = new HeadersFootersContainer(notesData, 0, notesData.length);
- assertEquals(RecordTypes.HeadersFooters.typeID, record.getRecordType());
+ HeadersFootersContainer record = new HeadersFootersContainer(notesData, 0, notesData.length);
+ assertEquals(RecordTypes.HeadersFooters.typeID, record.getRecordType());
assertEquals(HeadersFootersContainer.NotesHeadersFootersContainer, record.getOptions());
assertEquals(3, record.getChildRecords().length);
@@ -126,12 +126,12 @@ public final class TestHeadersFootersContainer {
}
@Test
- void testWriteNotesHeadersFootersContainer() throws Exception {
- HeadersFootersContainer record = new HeadersFootersContainer(notesData, 0, notesData.length);
+ void testWriteNotesHeadersFootersContainer() throws Exception {
+ HeadersFootersContainer record = new HeadersFootersContainer(notesData, 0, notesData.length);
UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- record.writeOut(baos);
- assertArrayEquals(notesData, baos.toByteArray());
- }
+ record.writeOut(baos);
+ assertArrayEquals(notesData, baos.toByteArray());
+ }
@Test
void testNewNotesHeadersFootersContainer() throws Exception {
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestInteractiveInfo.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestInteractiveInfo.java
index 1b1ab55491..3e003969a9 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestInteractiveInfo.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestInteractiveInfo.java
@@ -31,51 +31,51 @@ import org.junit.jupiter.api.Test;
* Tests that InteractiveInfoAtom works properly.
*/
public class TestInteractiveInfo {
- // From a real file
- private final byte[] data_a = {
- 0x0F, 0, 0xF2-256, 0x0F, 0x18, 0, 0, 0,
- 0, 0, 0xF3-256, 0x0F, 0x10, 0, 0, 0,
- 0, 0, 0, 0, 1, 0, 0, 0,
- 4, 0, 0, 0, 8, 0, 0, 0
- };
+ // From a real file
+ private final byte[] data_a = {
+ 0x0F, 0, 0xF2-256, 0x0F, 0x18, 0, 0, 0,
+ 0, 0, 0xF3-256, 0x0F, 0x10, 0, 0, 0,
+ 0, 0, 0, 0, 1, 0, 0, 0,
+ 4, 0, 0, 0, 8, 0, 0, 0
+ };
- @Test
- void testRecordType() {
- InteractiveInfo ii = new InteractiveInfo(data_a, 0, data_a.length);
- assertEquals(4082, ii.getRecordType());
- }
+ @Test
+ void testRecordType() {
+ InteractiveInfo ii = new InteractiveInfo(data_a, 0, data_a.length);
+ assertEquals(4082, ii.getRecordType());
+ }
- @Test
- void testGetChildDetails() {
- InteractiveInfo ii = new InteractiveInfo(data_a, 0, data_a.length);
- InteractiveInfoAtom ia = ii.getInteractiveInfoAtom();
+ @Test
+ void testGetChildDetails() {
+ InteractiveInfo ii = new InteractiveInfo(data_a, 0, data_a.length);
+ InteractiveInfoAtom ia = ii.getInteractiveInfoAtom();
- assertEquals(1, ia.getHyperlinkID());
- }
+ assertEquals(1, ia.getHyperlinkID());
+ }
- @Test
- void testWrite() throws Exception {
- InteractiveInfo ii = new InteractiveInfo(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- ii.writeOut(baos);
- assertArrayEquals(data_a, baos.toByteArray());
- }
+ @Test
+ void testWrite() throws Exception {
+ InteractiveInfo ii = new InteractiveInfo(data_a, 0, data_a.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ ii.writeOut(baos);
+ assertArrayEquals(data_a, baos.toByteArray());
+ }
- // Create A from scratch
- @Test
- void testCreate() throws Exception {
- InteractiveInfo ii = new InteractiveInfo();
- InteractiveInfoAtom ia = ii.getInteractiveInfoAtom();
+ // Create A from scratch
+ @Test
+ void testCreate() throws Exception {
+ InteractiveInfo ii = new InteractiveInfo();
+ InteractiveInfoAtom ia = ii.getInteractiveInfoAtom();
- // Set values
- ia.setHyperlinkID(1);
- ia.setSoundRef(0);
- ia.setAction((byte)4);
- ia.setHyperlinkType((byte)8);
+ // Set values
+ ia.setHyperlinkID(1);
+ ia.setSoundRef(0);
+ ia.setAction((byte)4);
+ ia.setHyperlinkType((byte)8);
- // Check it's now the same as a
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- ii.writeOut(baos);
- assertArrayEquals(data_a, baos.toByteArray());
+ // Check it's now the same as a
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ ii.writeOut(baos);
+ assertArrayEquals(data_a, baos.toByteArray());
}
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestInteractiveInfoAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestInteractiveInfoAtom.java
index 9eeab59618..824cfce1fd 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestInteractiveInfoAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestInteractiveInfoAtom.java
@@ -28,84 +28,84 @@ import org.junit.jupiter.api.Test;
* Tests that InteractiveInfoAtom works properly.
*/
public class TestInteractiveInfoAtom {
- // From a real file
- private final byte[] data_a = new byte[] {
- 0, 0, 0xF3-256, 0x0F, 0x10, 0, 0, 0,
- 0, 0, 0, 0, 1, 0, 0, 0,
- 4, 0, 0, 0, 8, 0, 0, 0
- };
- private final byte[] data_b = new byte[] {
- 0, 0, 0xF3-256, 0x0F, 0x10, 0, 0, 0,
- 0, 0, 0, 0, 4, 0, 0, 0,
- 4, 0, 0, 0, 8, 0, 0, 0
- };
+ // From a real file
+ private final byte[] data_a = new byte[] {
+ 0, 0, 0xF3-256, 0x0F, 0x10, 0, 0, 0,
+ 0, 0, 0, 0, 1, 0, 0, 0,
+ 4, 0, 0, 0, 8, 0, 0, 0
+ };
+ private final byte[] data_b = new byte[] {
+ 0, 0, 0xF3-256, 0x0F, 0x10, 0, 0, 0,
+ 0, 0, 0, 0, 4, 0, 0, 0,
+ 4, 0, 0, 0, 8, 0, 0, 0
+ };
- @Test
- void testRecordType() {
- InteractiveInfoAtom ia = new InteractiveInfoAtom(data_a, 0, data_a.length);
- assertEquals(4083L, ia.getRecordType());
- }
+ @Test
+ void testRecordType() {
+ InteractiveInfoAtom ia = new InteractiveInfoAtom(data_a, 0, data_a.length);
+ assertEquals(4083L, ia.getRecordType());
+ }
- @Test
- void testGetNumber() {
- InteractiveInfoAtom ia = new InteractiveInfoAtom(data_a, 0, data_a.length);
- InteractiveInfoAtom ib = new InteractiveInfoAtom(data_b, 0, data_b.length);
+ @Test
+ void testGetNumber() {
+ InteractiveInfoAtom ia = new InteractiveInfoAtom(data_a, 0, data_a.length);
+ InteractiveInfoAtom ib = new InteractiveInfoAtom(data_b, 0, data_b.length);
- assertEquals(1, ia.getHyperlinkID());
- assertEquals(4, ib.getHyperlinkID());
- }
+ assertEquals(1, ia.getHyperlinkID());
+ assertEquals(4, ib.getHyperlinkID());
+ }
- @Test
- void testGetRest() {
- InteractiveInfoAtom ia = new InteractiveInfoAtom(data_a, 0, data_a.length);
- InteractiveInfoAtom ib = new InteractiveInfoAtom(data_b, 0, data_b.length);
+ @Test
+ void testGetRest() {
+ InteractiveInfoAtom ia = new InteractiveInfoAtom(data_a, 0, data_a.length);
+ InteractiveInfoAtom ib = new InteractiveInfoAtom(data_b, 0, data_b.length);
- assertEquals(0, ia.getSoundRef());
- assertEquals(0, ib.getSoundRef());
+ assertEquals(0, ia.getSoundRef());
+ assertEquals(0, ib.getSoundRef());
- assertEquals(4, ia.getAction());
- assertEquals(4, ib.getAction());
+ assertEquals(4, ia.getAction());
+ assertEquals(4, ib.getAction());
- assertEquals(8, ia.getHyperlinkType());
- assertEquals(8, ib.getHyperlinkType());
- }
+ assertEquals(8, ia.getHyperlinkType());
+ assertEquals(8, ib.getHyperlinkType());
+ }
- @Test
- void testWrite() throws Exception {
- InteractiveInfoAtom ia = new InteractiveInfoAtom(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- ia.writeOut(baos);
- assertArrayEquals(data_a, baos.toByteArray());
- }
+ @Test
+ void testWrite() throws Exception {
+ InteractiveInfoAtom ia = new InteractiveInfoAtom(data_a, 0, data_a.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ ia.writeOut(baos);
+ assertArrayEquals(data_a, baos.toByteArray());
+ }
- // Create A from scratch
- @Test
- void testCreate() throws Exception {
- InteractiveInfoAtom ia = new InteractiveInfoAtom();
+ // Create A from scratch
+ @Test
+ void testCreate() throws Exception {
+ InteractiveInfoAtom ia = new InteractiveInfoAtom();
- // Set values
- ia.setHyperlinkID(1);
- ia.setSoundRef(0);
- ia.setAction((byte)4);
- ia.setHyperlinkType((byte)8);
+ // Set values
+ ia.setHyperlinkID(1);
+ ia.setSoundRef(0);
+ ia.setAction((byte)4);
+ ia.setHyperlinkType((byte)8);
- // Check it's now the same as a
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- ia.writeOut(baos);
- assertArrayEquals(data_a, baos.toByteArray());
- }
+ // Check it's now the same as a
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ ia.writeOut(baos);
+ assertArrayEquals(data_a, baos.toByteArray());
+ }
- // Try to turn a into b
- @Test
- void testChange() throws Exception {
- InteractiveInfoAtom ia = new InteractiveInfoAtom(data_a, 0, data_a.length);
+ // Try to turn a into b
+ @Test
+ void testChange() throws Exception {
+ InteractiveInfoAtom ia = new InteractiveInfoAtom(data_a, 0, data_a.length);
- // Change the number
- ia.setHyperlinkID(4);
+ // Change the number
+ ia.setHyperlinkID(4);
- // Check bytes are now the same
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- ia.writeOut(baos);
- assertArrayEquals(data_b, baos.toByteArray());
- }
+ // Check bytes are now the same
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ ia.writeOut(baos);
+ assertArrayEquals(data_b, baos.toByteArray());
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestNotesAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestNotesAtom.java
index d122f019dd..5528d26293 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestNotesAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestNotesAtom.java
@@ -29,30 +29,30 @@ import org.junit.jupiter.api.Test;
* Tests that NotesAtom works properly
*/
public final class TestNotesAtom {
- // From a real file
- private final byte[] data_a = new byte[] { 1, 0, 0xF1-256, 3, 8, 0, 0, 0,
- 0, 0, 0, 0x80-256, 0, 0, 0x0D, 0x30 };
+ // From a real file
+ private final byte[] data_a = new byte[] { 1, 0, 0xF1-256, 3, 8, 0, 0, 0,
+ 0, 0, 0, 0x80-256, 0, 0, 0x0D, 0x30 };
- @Test
- void testRecordType() {
- NotesAtom na = new NotesAtom(data_a, 0, data_a.length);
- assertEquals(1009L, na.getRecordType());
- }
+ @Test
+ void testRecordType() {
+ NotesAtom na = new NotesAtom(data_a, 0, data_a.length);
+ assertEquals(1009L, na.getRecordType());
+ }
- @Test
- void testFlags() {
- NotesAtom na = new NotesAtom(data_a, 0, data_a.length);
- assertEquals(0x80000000, na.getSlideID());
+ @Test
+ void testFlags() {
+ NotesAtom na = new NotesAtom(data_a, 0, data_a.length);
+ assertEquals(0x80000000, na.getSlideID());
assertFalse(na.getFollowMasterObjects());
assertFalse(na.getFollowMasterScheme());
assertFalse(na.getFollowMasterBackground());
- }
+ }
- @Test
- void testWrite() throws Exception {
- NotesAtom na = new NotesAtom(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- na.writeOut(baos);
- assertArrayEquals(data_a, baos.toByteArray());
- }
+ @Test
+ void testWrite() throws Exception {
+ NotesAtom na = new NotesAtom(data_a, 0, data_a.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ na.writeOut(baos);
+ assertArrayEquals(data_a, baos.toByteArray());
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestRecordContainer.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestRecordContainer.java
index dccb8f2cad..49c4061887 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestRecordContainer.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestRecordContainer.java
@@ -36,7 +36,7 @@ import org.junit.jupiter.api.Test;
*/
public final class TestRecordContainer {
private HSLFSlideShowImpl hss;
- private RecordContainer recordContainer;
+ private RecordContainer recordContainer;
private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
@BeforeEach
@@ -60,115 +60,115 @@ public final class TestRecordContainer {
hss.close();
}
- @Test
- void testIsAnAtom() {
- assertFalse( recordContainer.isAnAtom() );
- }
+ @Test
+ void testIsAnAtom() {
+ assertFalse( recordContainer.isAnAtom() );
+ }
@Test
- void testAppendChildRecord() {
- // Grab records for testing with
- Record r = recordContainer.getChildRecords()[0];
- Record rb = recordContainer.getChildRecords()[1];
- Record rc = recordContainer.getChildRecords()[2];
- Record rd = recordContainer.getChildRecords()[3];
+ void testAppendChildRecord() {
+ // Grab records for testing with
+ Record r = recordContainer.getChildRecords()[0];
+ Record rb = recordContainer.getChildRecords()[1];
+ Record rc = recordContainer.getChildRecords()[2];
+ Record rd = recordContainer.getChildRecords()[3];
- // Start with an empty set
- Record[] rs = new Record[0];
- recordContainer._children = rs;
- recordContainer.appendChildRecord(r);
- Record[] nrs = recordContainer.getChildRecords();
+ // Start with an empty set
+ Record[] rs = new Record[0];
+ recordContainer._children = rs;
+ recordContainer.appendChildRecord(r);
+ Record[] nrs = recordContainer.getChildRecords();
- assertEquals(1, nrs.length);
- assertEquals(r, nrs[0]);
+ assertEquals(1, nrs.length);
+ assertEquals(r, nrs[0]);
- // Now start with one with 3 entries
- rs = new Record[3];
- recordContainer._children = rs;
- rs[0] = rb;
- rs[1] = rc;
- rs[2] = rd;
+ // Now start with one with 3 entries
+ rs = new Record[3];
+ recordContainer._children = rs;
+ rs[0] = rb;
+ rs[1] = rc;
+ rs[2] = rd;
- recordContainer.appendChildRecord(r);
- nrs = recordContainer.getChildRecords();
+ recordContainer.appendChildRecord(r);
+ nrs = recordContainer.getChildRecords();
- assertEquals(4, nrs.length);
- assertEquals(rb, nrs[0]);
- assertEquals(rc, nrs[1]);
- assertEquals(rd, nrs[2]);
- assertEquals(r, nrs[3]);
- }
+ assertEquals(4, nrs.length);
+ assertEquals(rb, nrs[0]);
+ assertEquals(rc, nrs[1]);
+ assertEquals(rd, nrs[2]);
+ assertEquals(r, nrs[3]);
+ }
@Test
- void testAddChildAfter() {
- // Working with new StyleTextPropAtom
- Record newRecord = new StyleTextPropAtom(0);
+ void testAddChildAfter() {
+ // Working with new StyleTextPropAtom
+ Record newRecord = new StyleTextPropAtom(0);
- // Try to add after a mid-record
- Record[] cr = recordContainer.getChildRecords();
- Record after = cr[2];
- Record before = cr[3];
+ // Try to add after a mid-record
+ Record[] cr = recordContainer.getChildRecords();
+ Record after = cr[2];
+ Record before = cr[3];
- recordContainer.addChildAfter(newRecord, after);
- Record[] ncr = recordContainer.getChildRecords();
+ recordContainer.addChildAfter(newRecord, after);
+ Record[] ncr = recordContainer.getChildRecords();
- assertEquals(cr.length+1, ncr.length);
- assertEquals(after, ncr[2]);
- assertEquals(newRecord, ncr[3]);
- assertEquals(before, ncr[4]);
+ assertEquals(cr.length+1, ncr.length);
+ assertEquals(after, ncr[2]);
+ assertEquals(newRecord, ncr[3]);
+ assertEquals(before, ncr[4]);
- // Try again at the end
- recordContainer._children = cr;
- after = cr[cr.length-1];
+ // Try again at the end
+ recordContainer._children = cr;
+ after = cr[cr.length-1];
- recordContainer.addChildAfter(newRecord, after);
- ncr = recordContainer.getChildRecords();
+ recordContainer.addChildAfter(newRecord, after);
+ ncr = recordContainer.getChildRecords();
- assertEquals(cr.length+1, ncr.length);
- assertEquals(after, ncr[cr.length-1]);
- assertEquals(newRecord, ncr[cr.length]);
- }
+ assertEquals(cr.length+1, ncr.length);
+ assertEquals(after, ncr[cr.length-1]);
+ assertEquals(newRecord, ncr[cr.length]);
+ }
@Test
- void testAddChildBefore() {
- // Working with new StyleTextPropAtom
- Record newRecord = new StyleTextPropAtom(0);
+ void testAddChildBefore() {
+ // Working with new StyleTextPropAtom
+ Record newRecord = new StyleTextPropAtom(0);
- // Try to add before a mid-record
- Record[] cr = recordContainer.getChildRecords();
- Record before = cr[2];
+ // Try to add before a mid-record
+ Record[] cr = recordContainer.getChildRecords();
+ Record before = cr[2];
- recordContainer.addChildBefore(newRecord, before);
- Record[] ncr = recordContainer.getChildRecords();
+ recordContainer.addChildBefore(newRecord, before);
+ Record[] ncr = recordContainer.getChildRecords();
- assertEquals(cr.length+1, ncr.length);
- assertEquals(newRecord, ncr[2]);
- assertEquals(before, ncr[3]);
+ assertEquals(cr.length+1, ncr.length);
+ assertEquals(newRecord, ncr[2]);
+ assertEquals(before, ncr[3]);
- // Try again at the end
- recordContainer._children = cr;
- before = cr[cr.length-1];
+ // Try again at the end
+ recordContainer._children = cr;
+ before = cr[cr.length-1];
- recordContainer.addChildBefore(newRecord, before);
- ncr = recordContainer.getChildRecords();
+ recordContainer.addChildBefore(newRecord, before);
+ ncr = recordContainer.getChildRecords();
- assertEquals(cr.length+1, ncr.length);
- assertEquals(newRecord, ncr[cr.length-1]);
- assertEquals(before, ncr[cr.length]);
+ assertEquals(cr.length+1, ncr.length);
+ assertEquals(newRecord, ncr[cr.length-1]);
+ assertEquals(before, ncr[cr.length]);
- // And at the start
- recordContainer._children = cr;
- before = cr[0];
+ // And at the start
+ recordContainer._children = cr;
+ before = cr[0];
- recordContainer.addChildBefore(newRecord, before);
- ncr = recordContainer.getChildRecords();
+ recordContainer.addChildBefore(newRecord, before);
+ ncr = recordContainer.getChildRecords();
- assertEquals(cr.length+1, ncr.length);
- assertEquals(newRecord, ncr[0]);
- assertEquals(before, ncr[1]);
- }
+ assertEquals(cr.length+1, ncr.length);
+ assertEquals(newRecord, ncr[0]);
+ assertEquals(before, ncr[1]);
+ }
@Test
void testRemove() {
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestRecordTypes.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestRecordTypes.java
index 869dc427d7..a3c52a7060 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestRecordTypes.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestRecordTypes.java
@@ -28,23 +28,23 @@ import org.junit.jupiter.api.Test;
*/
public final class TestRecordTypes {
@Test
- void testPPTNameLookups() {
- assertEquals("MainMaster", RecordTypes.MainMaster.name());
- assertEquals("TextBytesAtom", RecordTypes.TextBytesAtom.name());
- assertEquals("VBAInfo", RecordTypes.VBAInfo.name());
- }
+ void testPPTNameLookups() {
+ assertEquals("MainMaster", RecordTypes.MainMaster.name());
+ assertEquals("TextBytesAtom", RecordTypes.TextBytesAtom.name());
+ assertEquals("VBAInfo", RecordTypes.VBAInfo.name());
+ }
@Test
- void testEscherNameLookups() {
- assertEquals("DGG_CONTAINER", EscherRecordTypes.DGG_CONTAINER.name());
- assertEquals("CLIENT_TEXTBOX", EscherRecordTypes.CLIENT_TEXTBOX.name());
- assertEquals("SELECTION", EscherRecordTypes.SELECTION.name());
- }
+ void testEscherNameLookups() {
+ assertEquals("DGG_CONTAINER", EscherRecordTypes.DGG_CONTAINER.name());
+ assertEquals("CLIENT_TEXTBOX", EscherRecordTypes.CLIENT_TEXTBOX.name());
+ assertEquals("SELECTION", EscherRecordTypes.SELECTION.name());
+ }
@Test
- void testPPTClassLookups() {
- // If this record is ever implemented, change to one that isn't!
- // This is checking the "unhandled default" stuff works
- assertEquals(RecordTypes.UnknownRecordPlaceholder, RecordTypes.forTypeID(-10));
- }
+ void testPPTClassLookups() {
+ // If this record is ever implemented, change to one that isn't!
+ // This is checking the "unhandled default" stuff works
+ assertEquals(RecordTypes.UnknownRecordPlaceholder, RecordTypes.forTypeID(-10));
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestSlideAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestSlideAtom.java
index 7f67088716..366f85310f 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestSlideAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestSlideAtom.java
@@ -35,63 +35,63 @@ import org.junit.jupiter.api.Test;
* Tests that SlideAtom works properly
*/
public final class TestSlideAtom {
- // From a real file
- private static final byte[] data_a = new byte[] { 1, 0, 0xEF-256, 3, 0x18, 0, 0, 0,
- 0, 0, 0, 0, 0x0F, 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x80-256,
- 0, 1, 0, 0, 7, 0, 0x0C, 0x30 };
-
- @Test
- void testRecordType() {
- SlideAtom sa = new SlideAtom(data_a, 0, data_a.length);
- assertEquals(1007L, sa.getRecordType());
- }
+ // From a real file
+ private static final byte[] data_a = new byte[] { 1, 0, 0xEF-256, 3, 0x18, 0, 0, 0,
+ 0, 0, 0, 0, 0x0F, 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x80-256,
+ 0, 1, 0, 0, 7, 0, 0x0C, 0x30 };
@Test
- void testFlags() {
- SlideAtom sa = new SlideAtom(data_a, 0, data_a.length);
+ void testRecordType() {
+ SlideAtom sa = new SlideAtom(data_a, 0, data_a.length);
+ assertEquals(1007L, sa.getRecordType());
+ }
- // First 12 bytes are a SSlideLayoutAtom, checked elsewhere
+ @Test
+ void testFlags() {
+ SlideAtom sa = new SlideAtom(data_a, 0, data_a.length);
- // Check the IDs
- assertEquals(SlideAtom.USES_MASTER_SLIDE_ID, sa.getMasterID());
- assertEquals(256, sa.getNotesID());
+ // First 12 bytes are a SSlideLayoutAtom, checked elsewhere
- // Check the flags
+ // Check the IDs
+ assertEquals(SlideAtom.USES_MASTER_SLIDE_ID, sa.getMasterID());
+ assertEquals(256, sa.getNotesID());
+
+ // Check the flags
assertTrue(sa.getFollowMasterObjects());
assertTrue(sa.getFollowMasterScheme());
assertTrue(sa.getFollowMasterBackground());
- }
+ }
@Test
void testSSlideLayoutAtom() {
- SlideAtom sa = new SlideAtom(data_a, 0, data_a.length);
- SlideAtomLayout ssla = sa.getSSlideLayoutAtom();
+ SlideAtom sa = new SlideAtom(data_a, 0, data_a.length);
+ SlideAtomLayout ssla = sa.getSSlideLayoutAtom();
- assertEquals(SlideLayoutType.TITLE_SLIDE, ssla.getGeometryType());
+ assertEquals(SlideLayoutType.TITLE_SLIDE, ssla.getGeometryType());
- // Should also check the placeholder IDs at some point
- }
+ // Should also check the placeholder IDs at some point
+ }
@Test
- void testWrite() throws IOException {
- SlideAtom sa = new SlideAtom(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- sa.writeOut(baos);
- assertArrayEquals(data_a, baos.toByteArray());
- }
+ void testWrite() throws IOException {
+ SlideAtom sa = new SlideAtom(data_a, 0, data_a.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ sa.writeOut(baos);
+ assertArrayEquals(data_a, baos.toByteArray());
+ }
@Test
- void testSSSlideInfoAtom() throws IOException {
- try (HSLFSlideShow ppt1 = new HSLFSlideShow()) {
- HSLFSlide slide1 = ppt1.createSlide(), slide2 = ppt1.createSlide();
- slide2.setHidden(true);
+ void testSSSlideInfoAtom() throws IOException {
+ try (HSLFSlideShow ppt1 = new HSLFSlideShow()) {
+ HSLFSlide slide1 = ppt1.createSlide(), slide2 = ppt1.createSlide();
+ slide2.setHidden(true);
- try (HSLFSlideShow ppt2 = HSLFTestDataSamples.writeOutAndReadBack(ppt1)) {
- slide1 = ppt2.getSlides().get(0);
- slide2 = ppt2.getSlides().get(1);
- assertFalse(slide1.isHidden());
- assertTrue(slide2.isHidden());
- }
- }
- }
+ try (HSLFSlideShow ppt2 = HSLFTestDataSamples.writeOutAndReadBack(ppt1)) {
+ slide1 = ppt2.getSlides().get(0);
+ slide2 = ppt2.getSlides().get(1);
+ assertFalse(slide1.isHidden());
+ assertTrue(slide2.isHidden());
+ }
+ }
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestSlidePersistAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestSlidePersistAtom.java
index d5f1105f47..4e0386d1ca 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestSlidePersistAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestSlidePersistAtom.java
@@ -29,31 +29,31 @@ import org.junit.jupiter.api.Test;
* Tests that SlidePersistAtom works properly
*/
public final class TestSlidePersistAtom {
- // From a real file
- private final byte[] data_a = new byte[] { 0, 0, 0xF3-256, 3, 0x14, 0, 0, 0,
- 4, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0, 0, 0,
- 1, 0, 0, 0, 0, 0, 0 };
+ // From a real file
+ private final byte[] data_a = new byte[] { 0, 0, 0xF3-256, 3, 0x14, 0, 0, 0,
+ 4, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0, 0, 0,
+ 1, 0, 0, 0, 0, 0, 0 };
- @Test
- void testRecordType() {
- SlidePersistAtom spa = new SlidePersistAtom(data_a, 0, data_a.length);
- assertEquals(1011L, spa.getRecordType());
- }
+ @Test
+ void testRecordType() {
+ SlidePersistAtom spa = new SlidePersistAtom(data_a, 0, data_a.length);
+ assertEquals(1011L, spa.getRecordType());
+ }
- @Test
- void testFlags() {
- SlidePersistAtom spa = new SlidePersistAtom(data_a, 0, data_a.length);
- assertEquals(4, spa.getRefID() );
+ @Test
+ void testFlags() {
+ SlidePersistAtom spa = new SlidePersistAtom(data_a, 0, data_a.length);
+ assertEquals(4, spa.getRefID() );
assertTrue(spa.getHasShapesOtherThanPlaceholders());
- assertEquals(2, spa.getNumPlaceholderTexts() );
- assertEquals(256, spa.getSlideIdentifier());
- }
+ assertEquals(2, spa.getNumPlaceholderTexts() );
+ assertEquals(256, spa.getSlideIdentifier());
+ }
- @Test
- void testWrite() throws Exception {
- SlidePersistAtom spa = new SlidePersistAtom(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- spa.writeOut(baos);
- assertArrayEquals(data_a, baos.toByteArray());
- }
+ @Test
+ void testWrite() throws Exception {
+ SlidePersistAtom spa = new SlidePersistAtom(data_a, 0, data_a.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ spa.writeOut(baos);
+ assertArrayEquals(data_a, baos.toByteArray());
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestSound.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestSound.java
index 4bfbc23526..5fcdf2f79f 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestSound.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestSound.java
@@ -33,43 +33,43 @@ import org.junit.jupiter.api.Test;
*/
public final class TestSound {
@Test
- void testRealFile() throws IOException {
+ void testRealFile() throws IOException {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- HSLFSlideShow ppt = new HSLFSlideShow(slTests.openResourceAsStream("sound.ppt"));
+ HSLFSlideShow ppt = new HSLFSlideShow(slTests.openResourceAsStream("sound.ppt"));
- // Get the document
- Document doc = ppt.getDocumentRecord();
- SoundCollection soundCollection = null;
- Record[] doc_ch = doc.getChildRecords();
- for ( org.apache.poi.hslf.record.Record rec : doc_ch) {
- if (rec instanceof SoundCollection) {
- soundCollection = (SoundCollection) rec;
- break;
- }
- }
- assertNotNull(soundCollection);
+ // Get the document
+ Document doc = ppt.getDocumentRecord();
+ SoundCollection soundCollection = null;
+ Record[] doc_ch = doc.getChildRecords();
+ for ( org.apache.poi.hslf.record.Record rec : doc_ch) {
+ if (rec instanceof SoundCollection) {
+ soundCollection = (SoundCollection) rec;
+ break;
+ }
+ }
+ assertNotNull(soundCollection);
- Sound sound = null;
- Record[] sound_ch = soundCollection.getChildRecords();
- int k = 0;
- for ( org.apache.poi.hslf.record.Record rec : sound_ch) {
- if (rec instanceof Sound) {
- sound = (Sound) rec;
- k++;
- }
- }
+ Sound sound = null;
+ Record[] sound_ch = soundCollection.getChildRecords();
+ int k = 0;
+ for ( org.apache.poi.hslf.record.Record rec : sound_ch) {
+ if (rec instanceof Sound) {
+ sound = (Sound) rec;
+ k++;
+ }
+ }
- assertNotNull(sound);
- assertEquals(1, k);
+ assertNotNull(sound);
+ assertEquals(1, k);
- assertEquals("ringin.wav", sound.getSoundName());
- assertEquals(".WAV", sound.getSoundType());
- assertNotNull(sound.getSoundData());
+ assertEquals("ringin.wav", sound.getSoundName());
+ assertEquals(".WAV", sound.getSoundType());
+ assertNotNull(sound.getSoundData());
- byte[] ref_data = slTests.readFile("ringin.wav");
- assertArrayEquals(ref_data, sound.getSoundData());
+ byte[] ref_data = slTests.readFile("ringin.wav");
+ assertArrayEquals(ref_data, sound.getSoundData());
- ppt.close();
+ ppt.close();
}
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextBytesAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextBytesAtom.java
index c06eff77d1..d50fc18a92 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextBytesAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextBytesAtom.java
@@ -30,50 +30,50 @@ import org.junit.jupiter.api.Test;
* Tests that TextBytesAtom works properly
*/
public final class TestTextBytesAtom {
- // From a real file
- private final byte[] data = { 0, 0, 0xA8-256, 0x0f, 0x1c, 0, 0, 0,
- 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68,
- 0x65, 0x20, 0x74, 0x69, 0x74, 0x6C, 0x65, 0x20, 0x6F, 0x6E,
- 0x20, 0x70, 0x61, 0x67, 0x65, 0x20, 0x32 };
- private final byte[] alt_data = { 0, 0, 0xA8-256, 0x0F, 0x14, 0, 0, 0,
- 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20,
- 0x74, 0x65, 0x73, 0x74, 0x20, 0x74, 0x69, 0x74, 0x6C, 0x65 };
- private final String alt_text = "This is a test title";
+ // From a real file
+ private final byte[] data = { 0, 0, 0xA8-256, 0x0f, 0x1c, 0, 0, 0,
+ 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68,
+ 0x65, 0x20, 0x74, 0x69, 0x74, 0x6C, 0x65, 0x20, 0x6F, 0x6E,
+ 0x20, 0x70, 0x61, 0x67, 0x65, 0x20, 0x32 };
+ private final byte[] alt_data = { 0, 0, 0xA8-256, 0x0F, 0x14, 0, 0, 0,
+ 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20,
+ 0x74, 0x65, 0x73, 0x74, 0x20, 0x74, 0x69, 0x74, 0x6C, 0x65 };
+ private final String alt_text = "This is a test title";
- @Test
+ @Test
void testRecordType() {
- TextBytesAtom tba = new TextBytesAtom(data,0,data.length);
- assertEquals(4008L, tba.getRecordType());
- }
+ TextBytesAtom tba = new TextBytesAtom(data,0,data.length);
+ assertEquals(4008L, tba.getRecordType());
+ }
- @Test
- void testTextA() {
- TextBytesAtom tba = new TextBytesAtom(data,0,data.length);
- String data_text = "This is the title on page 2";
- assertEquals(data_text, tba.getText());
- }
+ @Test
+ void testTextA() {
+ TextBytesAtom tba = new TextBytesAtom(data,0,data.length);
+ String data_text = "This is the title on page 2";
+ assertEquals(data_text, tba.getText());
+ }
- @Test
- void testTextB() {
- TextBytesAtom tba = new TextBytesAtom(alt_data,0,alt_data.length);
- assertEquals(alt_text, tba.getText());
- }
+ @Test
+ void testTextB() {
+ TextBytesAtom tba = new TextBytesAtom(alt_data,0,alt_data.length);
+ assertEquals(alt_text, tba.getText());
+ }
- @Test
- void testChangeText() throws Exception {
- TextBytesAtom tba = new TextBytesAtom(data,0,data.length);
- tba.setText(alt_text.getBytes(StandardCharsets.ISO_8859_1));
+ @Test
+ void testChangeText() throws Exception {
+ TextBytesAtom tba = new TextBytesAtom(data,0,data.length);
+ tba.setText(alt_text.getBytes(StandardCharsets.ISO_8859_1));
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- tba.writeOut(baos);
- assertArrayEquals(alt_data, baos.toByteArray());
- }
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ tba.writeOut(baos);
+ assertArrayEquals(alt_data, baos.toByteArray());
+ }
- @Test
- void testWrite() throws Exception {
- TextBytesAtom tba = new TextBytesAtom(data,0,data.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- tba.writeOut(baos);
- assertArrayEquals(data, baos.toByteArray());
- }
+ @Test
+ void testWrite() throws Exception {
+ TextBytesAtom tba = new TextBytesAtom(data,0,data.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ tba.writeOut(baos);
+ assertArrayEquals(data, baos.toByteArray());
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextCharsAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextCharsAtom.java
index 382719cdfc..d2357a8fdc 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextCharsAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextCharsAtom.java
@@ -28,62 +28,62 @@ import org.junit.jupiter.api.Test;
* Tests that TextCharsAtom works properly
*/
public final class TestTextCharsAtom {
- // From a real file
- private final byte[] data = new byte[] { 0, 0, 0xA0-256, 0x0f, 0x08, 0, 0, 0,
- 0x54, 0x00, 0x68, 0x00, 0x69, 0x00, 0x73, 0x00 };
- private final String data_text = "This";
- private final byte[] alt_data = new byte[] { 0, 0, 0xA0-256, 0x0F, 0x0a, 0, 0, 0,
- 0x54, 0x00, 0x68, 0x00, 0x69, 0x00, 0x73, 0x00, 0xa3-256, 0x01 };
- private final String alt_text = "This\u01A3";
+ // From a real file
+ private final byte[] data = new byte[] { 0, 0, 0xA0-256, 0x0f, 0x08, 0, 0, 0,
+ 0x54, 0x00, 0x68, 0x00, 0x69, 0x00, 0x73, 0x00 };
+ private final String data_text = "This";
+ private final byte[] alt_data = new byte[] { 0, 0, 0xA0-256, 0x0F, 0x0a, 0, 0, 0,
+ 0x54, 0x00, 0x68, 0x00, 0x69, 0x00, 0x73, 0x00, 0xa3-256, 0x01 };
+ private final String alt_text = "This\u01A3";
- @Test
+ @Test
void testRecordType() {
- TextCharsAtom tca = new TextCharsAtom(data,0,data.length);
- assertEquals(4000L, tca.getRecordType());
- }
+ TextCharsAtom tca = new TextCharsAtom(data,0,data.length);
+ assertEquals(4000L, tca.getRecordType());
+ }
- @Test
- void testTextA() {
- TextCharsAtom tca = new TextCharsAtom(data,0,data.length);
- assertEquals(data_text, tca.getText());
- }
+ @Test
+ void testTextA() {
+ TextCharsAtom tca = new TextCharsAtom(data,0,data.length);
+ assertEquals(data_text, tca.getText());
+ }
- @Test
- void testTextB() {
- TextCharsAtom tca = new TextCharsAtom(alt_data,0,alt_data.length);
- assertEquals(alt_text, tca.getText());
- }
+ @Test
+ void testTextB() {
+ TextCharsAtom tca = new TextCharsAtom(alt_data,0,alt_data.length);
+ assertEquals(alt_text, tca.getText());
+ }
- @Test
- void testChangeText() throws Exception {
- TextCharsAtom tca = new TextCharsAtom(data,0,data.length);
- tca.setText(alt_text);
+ @Test
+ void testChangeText() throws Exception {
+ TextCharsAtom tca = new TextCharsAtom(data,0,data.length);
+ tca.setText(alt_text);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- tca.writeOut(baos);
- assertArrayEquals(alt_data, baos.toByteArray());
- }
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ tca.writeOut(baos);
+ assertArrayEquals(alt_data, baos.toByteArray());
+ }
- @Test
- void testWrite() throws Exception {
- TextCharsAtom tca = new TextCharsAtom(data,0,data.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- tca.writeOut(baos);
- assertArrayEquals(data, baos.toByteArray());
- }
+ @Test
+ void testWrite() throws Exception {
+ TextCharsAtom tca = new TextCharsAtom(data,0,data.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ tca.writeOut(baos);
+ assertArrayEquals(data, baos.toByteArray());
+ }
- @Test
- void testCreateNew() throws Exception {
- TextCharsAtom tca = new TextCharsAtom();
- assertEquals(0, tca.getText().length());
+ @Test
+ void testCreateNew() throws Exception {
+ TextCharsAtom tca = new TextCharsAtom();
+ assertEquals(0, tca.getText().length());
- tca.setText(data_text);
- assertEquals(data_text, tca.getText());
+ tca.setText(data_text);
+ assertEquals(data_text, tca.getText());
- // Check it's now like data
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- tca.writeOut(baos);
- assertArrayEquals(data, baos.toByteArray());
- }
+ // Check it's now like data
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ tca.writeOut(baos);
+ assertArrayEquals(data, baos.toByteArray());
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextHeaderAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextHeaderAtom.java
index 6eddf527af..22bce9375b 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextHeaderAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextHeaderAtom.java
@@ -29,32 +29,32 @@ import org.junit.jupiter.api.Test;
* Tests that TextHeaderAtom works properly
*/
public final class TestTextHeaderAtom {
- // From a real file
- private final byte[] notes_data = { 0, 0, 0x9f-256, 0x0f, 4, 0, 0, 0, 2, 0, 0, 0 };
- private final byte[] title_data = { 0, 0, 0x9f-256, 0x0f, 4, 0, 0, 0, 0, 0, 0, 0 };
- private final byte[] body_data = { 0, 0, 0x9f-256, 0x0f, 4, 0, 0, 0, 1, 0, 0, 0 };
+ // From a real file
+ private final byte[] notes_data = { 0, 0, 0x9f-256, 0x0f, 4, 0, 0, 0, 2, 0, 0, 0 };
+ private final byte[] title_data = { 0, 0, 0x9f-256, 0x0f, 4, 0, 0, 0, 0, 0, 0, 0 };
+ private final byte[] body_data = { 0, 0, 0x9f-256, 0x0f, 4, 0, 0, 0, 1, 0, 0, 0 };
- @Test
- void testRecordType() {
- TextHeaderAtom tha = new TextHeaderAtom(notes_data,0,12);
- assertEquals(3999L, tha.getRecordType());
- }
+ @Test
+ void testRecordType() {
+ TextHeaderAtom tha = new TextHeaderAtom(notes_data,0,12);
+ assertEquals(3999L, tha.getRecordType());
+ }
- @Test
- void testTypes() {
- TextHeaderAtom n_tha = new TextHeaderAtom(notes_data,0,12);
- TextHeaderAtom t_tha = new TextHeaderAtom(title_data,0,12);
- TextHeaderAtom b_tha = new TextHeaderAtom(body_data,0,12);
- assertEquals(TextPlaceholder.NOTES.nativeId, n_tha.getTextType());
- assertEquals(TextPlaceholder.TITLE.nativeId, t_tha.getTextType());
- assertEquals(TextPlaceholder.BODY.nativeId, b_tha.getTextType());
- }
+ @Test
+ void testTypes() {
+ TextHeaderAtom n_tha = new TextHeaderAtom(notes_data,0,12);
+ TextHeaderAtom t_tha = new TextHeaderAtom(title_data,0,12);
+ TextHeaderAtom b_tha = new TextHeaderAtom(body_data,0,12);
+ assertEquals(TextPlaceholder.NOTES.nativeId, n_tha.getTextType());
+ assertEquals(TextPlaceholder.TITLE.nativeId, t_tha.getTextType());
+ assertEquals(TextPlaceholder.BODY.nativeId, b_tha.getTextType());
+ }
- @Test
- void testWrite() throws Exception {
- TextHeaderAtom tha = new TextHeaderAtom(notes_data,0,12);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- tha.writeOut(baos);
- assertArrayEquals(notes_data, baos.toByteArray());
- }
+ @Test
+ void testWrite() throws Exception {
+ TextHeaderAtom tha = new TextHeaderAtom(notes_data,0,12);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ tha.writeOut(baos);
+ assertArrayEquals(notes_data, baos.toByteArray());
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextRulerAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextRulerAtom.java
index a24402ec2a..2a64d4fc21 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextRulerAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextRulerAtom.java
@@ -29,53 +29,53 @@ import org.junit.jupiter.api.Test;
public final class TestTextRulerAtom {
- //from a real file
- private final byte[] data_1 = new byte[] {
- 0x00, 0x00, (byte)0xA6, 0x0F, 0x18, 0x00, 0x00, 0x00,
- (byte)0xF8, 0x1F, 0x00, 0x00, 0x75, 0x00, (byte)0xE2, 0x00, 0x59,
- 0x01, (byte)0xC3, 0x01, 0x1A, 0x03, (byte)0x87, 0x03, (byte)0xF8,
- 0x03, 0x69, 0x04, (byte)0xF6, 0x05, (byte)0xF6, 0x05
- };
+ //from a real file
+ private final byte[] data_1 = new byte[] {
+ 0x00, 0x00, (byte)0xA6, 0x0F, 0x18, 0x00, 0x00, 0x00,
+ (byte)0xF8, 0x1F, 0x00, 0x00, 0x75, 0x00, (byte)0xE2, 0x00, 0x59,
+ 0x01, (byte)0xC3, 0x01, 0x1A, 0x03, (byte)0x87, 0x03, (byte)0xF8,
+ 0x03, 0x69, 0x04, (byte)0xF6, 0x05, (byte)0xF6, 0x05
+ };
- private final byte[] data_2 = new byte[] {
- 0x00, 0x00, (byte)0xA6, 0x0F, 0x0A, 0x00, 0x00, 0x00,
- 0x08, 0x03, 0x00, 0x00, (byte)0xF9, 0x00, 0x41, 0x01, 0x41, 0x01
- };
-
- @Test
- void testReadRuler() {
- TextRulerAtom ruler = new TextRulerAtom(data_1, 0, data_1.length);
- assertEquals(ruler.getNumberOfLevels(), 0);
- assertEquals(ruler.getDefaultTabSize(), 0);
-
- List tabStops = ruler.getTabStops();
- assertNotNull(tabStops);
-
- Integer[] textOffsets = ruler.getTextOffsets();
- assertArrayEquals(new Integer[]{117, 345, 794, 1016, 1526}, textOffsets);
-
- Integer[] bulletOffsets = ruler.getBulletOffsets();
- assertArrayEquals(new Integer[]{226, 451, 903, 1129, 1526}, bulletOffsets);
- }
+ private final byte[] data_2 = new byte[] {
+ 0x00, 0x00, (byte)0xA6, 0x0F, 0x0A, 0x00, 0x00, 0x00,
+ 0x08, 0x03, 0x00, 0x00, (byte)0xF9, 0x00, 0x41, 0x01, 0x41, 0x01
+ };
@Test
- void testWriteRuler() throws Exception {
- TextRulerAtom ruler = new TextRulerAtom(data_1, 0, data_1.length);
- UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream();
- ruler.writeOut(out);
+ void testReadRuler() {
+ TextRulerAtom ruler = new TextRulerAtom(data_1, 0, data_1.length);
+ assertEquals(ruler.getNumberOfLevels(), 0);
+ assertEquals(ruler.getDefaultTabSize(), 0);
- byte[] result = out.toByteArray();
- assertArrayEquals(result, data_1);
- }
+ List tabStops = ruler.getTabStops();
+ assertNotNull(tabStops);
+
+ Integer[] textOffsets = ruler.getTextOffsets();
+ assertArrayEquals(new Integer[]{117, 345, 794, 1016, 1526}, textOffsets);
+
+ Integer[] bulletOffsets = ruler.getBulletOffsets();
+ assertArrayEquals(new Integer[]{226, 451, 903, 1129, 1526}, bulletOffsets);
+ }
@Test
- void testRead2() throws Exception {
- TextRulerAtom ruler = TextRulerAtom.getParagraphInstance();
- ruler.setParagraphIndent((short)249, (short)321);
- UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream();
- ruler.writeOut(out);
+ void testWriteRuler() throws Exception {
+ TextRulerAtom ruler = new TextRulerAtom(data_1, 0, data_1.length);
+ UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream();
+ ruler.writeOut(out);
- byte[] result = out.toByteArray();
- assertArrayEquals(data_2, result);
- }
+ byte[] result = out.toByteArray();
+ assertArrayEquals(result, data_1);
+ }
+
+ @Test
+ void testRead2() throws Exception {
+ TextRulerAtom ruler = TextRulerAtom.getParagraphInstance();
+ ruler.setParagraphIndent((short)249, (short)321);
+ UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream();
+ ruler.writeOut(out);
+
+ byte[] result = out.toByteArray();
+ assertArrayEquals(data_2, result);
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextSpecInfoAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextSpecInfoAtom.java
index 93e8b5e420..c3cd26d1ce 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextSpecInfoAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextSpecInfoAtom.java
@@ -56,7 +56,7 @@ public final class TestTextSpecInfoAtom {
UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream();
spec.writeOut(out);
assertArrayEquals(data_1, out.toByteArray());
- }
+ }
@Test
void testReset() throws Exception {
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTxInteractiveInfoAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTxInteractiveInfoAtom.java
index 601baf0dc6..4671e7a8aa 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTxInteractiveInfoAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTxInteractiveInfoAtom.java
@@ -28,67 +28,67 @@ import org.junit.jupiter.api.Test;
* Tests that TxInteractiveInfoAtom works properly.
*/
public final class TestTxInteractiveInfoAtom {
- // From WithLinks.ppt
- private final byte[] data_a = {
- 0, 0, (byte)0xDF, 0x0F, 0x08, 0, 0, 0,
- 0x19, 0, 0, 0, 0x38, 0, 0, 0
- };
+ // From WithLinks.ppt
+ private final byte[] data_a = {
+ 0, 0, (byte)0xDF, 0x0F, 0x08, 0, 0, 0,
+ 0x19, 0, 0, 0, 0x38, 0, 0, 0
+ };
- private final byte[] data_b = {
- 0, 0, (byte)0xDF, 0x0F, 0x08, 0, 0, 0,
- 0x39, 0, 0, 0, 0x4E, 0, 0, 0
- };
+ private final byte[] data_b = {
+ 0, 0, (byte)0xDF, 0x0F, 0x08, 0, 0, 0,
+ 0x39, 0, 0, 0, 0x4E, 0, 0, 0
+ };
- @Test
- void testRead() {
- TxInteractiveInfoAtom ia1 = new TxInteractiveInfoAtom(data_a, 0, data_a.length);
+ @Test
+ void testRead() {
+ TxInteractiveInfoAtom ia1 = new TxInteractiveInfoAtom(data_a, 0, data_a.length);
- assertEquals(4063, ia1.getRecordType());
- assertEquals(25, ia1.getStartIndex());
- assertEquals(56, ia1.getEndIndex());
+ assertEquals(4063, ia1.getRecordType());
+ assertEquals(25, ia1.getStartIndex());
+ assertEquals(56, ia1.getEndIndex());
- TxInteractiveInfoAtom ia2 = new TxInteractiveInfoAtom(data_b, 0, data_b.length);
+ TxInteractiveInfoAtom ia2 = new TxInteractiveInfoAtom(data_b, 0, data_b.length);
- assertEquals(4063, ia2.getRecordType());
- assertEquals(57, ia2.getStartIndex());
- assertEquals(78, ia2.getEndIndex());
- }
+ assertEquals(4063, ia2.getRecordType());
+ assertEquals(57, ia2.getStartIndex());
+ assertEquals(78, ia2.getEndIndex());
+ }
- @Test
- void testWrite() throws Exception {
- TxInteractiveInfoAtom atom = new TxInteractiveInfoAtom(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- atom.writeOut(baos);
- assertArrayEquals(data_a, baos.toByteArray());
- }
+ @Test
+ void testWrite() throws Exception {
+ TxInteractiveInfoAtom atom = new TxInteractiveInfoAtom(data_a, 0, data_a.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ atom.writeOut(baos);
+ assertArrayEquals(data_a, baos.toByteArray());
+ }
- // Create A from scratch
- @Test
- void testCreate() throws Exception {
- TxInteractiveInfoAtom ia = new TxInteractiveInfoAtom();
+ // Create A from scratch
+ @Test
+ void testCreate() throws Exception {
+ TxInteractiveInfoAtom ia = new TxInteractiveInfoAtom();
- // Set values
- ia.setStartIndex(25);
- ia.setEndIndex(56);
+ // Set values
+ ia.setStartIndex(25);
+ ia.setEndIndex(56);
- // Check it's now the same as a
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- ia.writeOut(baos);
- assertArrayEquals(data_a, baos.toByteArray());
- }
+ // Check it's now the same as a
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ ia.writeOut(baos);
+ assertArrayEquals(data_a, baos.toByteArray());
+ }
- // Try to turn a into b
- @Test
- void testChange() throws Exception {
- TxInteractiveInfoAtom ia = new TxInteractiveInfoAtom(data_a, 0, data_a.length);
+ // Try to turn a into b
+ @Test
+ void testChange() throws Exception {
+ TxInteractiveInfoAtom ia = new TxInteractiveInfoAtom(data_a, 0, data_a.length);
- // Change the number
- ia.setStartIndex(57);
- ia.setEndIndex(78);
+ // Change the number
+ ia.setStartIndex(57);
+ ia.setEndIndex(78);
- // Check bytes are now the same
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- ia.writeOut(baos);
- assertArrayEquals(data_b, baos.toByteArray());
- }
+ // Check bytes are now the same
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ ia.writeOut(baos);
+ assertArrayEquals(data_b, baos.toByteArray());
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestUserEditAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestUserEditAtom.java
index 42b34157d9..a7defb0e38 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestUserEditAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestUserEditAtom.java
@@ -28,36 +28,36 @@ import org.junit.jupiter.api.Test;
* Tests that UserEditAtom works properly
*/
public final class TestUserEditAtom {
- // From a real file
- private final byte[] data_a = new byte[] { 0, 0, 0xF5-256, 0x0F, 0x1C, 0, 0, 0,
- 0, 1, 0, 0, 0xD9-256, 18, 0, 3,
- 0, 0, 0, 0, 0, 0x18, 0, 0, 1, 0, 0, 0,
- 5, 0, 0, 0, 1, 0, 0xF6-256, 77 };
+ // From a real file
+ private final byte[] data_a = new byte[] { 0, 0, 0xF5-256, 0x0F, 0x1C, 0, 0, 0,
+ 0, 1, 0, 0, 0xD9-256, 18, 0, 3,
+ 0, 0, 0, 0, 0, 0x18, 0, 0, 1, 0, 0, 0,
+ 5, 0, 0, 0, 1, 0, 0xF6-256, 77 };
- @Test
- void testRecordType() {
- UserEditAtom uea = new UserEditAtom(data_a, 0, data_a.length);
- assertEquals(4085L, uea.getRecordType());
- }
+ @Test
+ void testRecordType() {
+ UserEditAtom uea = new UserEditAtom(data_a, 0, data_a.length);
+ assertEquals(4085L, uea.getRecordType());
+ }
- @Test
- void testFlags() {
- UserEditAtom uea = new UserEditAtom(data_a, 0, data_a.length);
+ @Test
+ void testFlags() {
+ UserEditAtom uea = new UserEditAtom(data_a, 0, data_a.length);
- assertEquals(256, uea.getLastViewedSlideID() );
- //assertEquals(0x030018D9, uea.getPPTVersion() );
- assertEquals(0, uea.getLastUserEditAtomOffset() );
- assertEquals(0x1800, uea.getPersistPointersOffset() );
- assertEquals(1, uea.getDocPersistRef() );
- assertEquals(5, uea.getMaxPersistWritten() );
- assertEquals((short)1, uea.getLastViewType() );
- }
+ assertEquals(256, uea.getLastViewedSlideID() );
+ //assertEquals(0x030018D9, uea.getPPTVersion() );
+ assertEquals(0, uea.getLastUserEditAtomOffset() );
+ assertEquals(0x1800, uea.getPersistPointersOffset() );
+ assertEquals(1, uea.getDocPersistRef() );
+ assertEquals(5, uea.getMaxPersistWritten() );
+ assertEquals((short)1, uea.getLastViewType() );
+ }
- @Test
- void testWrite() throws Exception {
- UserEditAtom uea = new UserEditAtom(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- uea.writeOut(baos);
- assertArrayEquals(data_a, baos.toByteArray());
- }
+ @Test
+ void testWrite() throws Exception {
+ UserEditAtom uea = new UserEditAtom(data_a, 0, data_a.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ uea.writeOut(baos);
+ assertArrayEquals(data_a, baos.toByteArray());
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestBugs.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestBugs.java
index 17ddfa4a8a..6e8c8b5e92 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestBugs.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestBugs.java
@@ -381,7 +381,7 @@ public final class TestBugs {
*/
@Test
void bug41711() throws IOException {
- // New file is fine
+ // New file is fine
open("SampleShow.ppt").close();
// PowerPoint 95 gives an old format exception
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestCounts.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestCounts.java
index d4dce2b13f..9f6c4d49ff 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestCounts.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestCounts.java
@@ -31,49 +31,49 @@ import org.junit.jupiter.api.Test;
*/
public final class TestCounts {
@Test
- void testSheetsCount() throws IOException {
- HSLFSlideShow ppt = HSLFTestDataSamples.getSlideShow("basic_test_ppt_file.ppt");
+ void testSheetsCount() throws IOException {
+ HSLFSlideShow ppt = HSLFTestDataSamples.getSlideShow("basic_test_ppt_file.ppt");
- List slides = ppt.getSlides();
- // Two sheets - master sheet is separate
- assertEquals(2, slides.size());
+ List slides = ppt.getSlides();
+ // Two sheets - master sheet is separate
+ assertEquals(2, slides.size());
- // They are slides 1+2
- assertEquals(1, slides.get(0).getSlideNumber());
- assertEquals(2, slides.get(1).getSlideNumber());
+ // They are slides 1+2
+ assertEquals(1, slides.get(0).getSlideNumber());
+ assertEquals(2, slides.get(1).getSlideNumber());
- // The ref IDs are 4 and 6
- assertEquals(4, slides.get(0)._getSheetRefId());
- assertEquals(6, slides.get(1)._getSheetRefId());
+ // The ref IDs are 4 and 6
+ assertEquals(4, slides.get(0)._getSheetRefId());
+ assertEquals(6, slides.get(1)._getSheetRefId());
- // These are slides 1+2 -> 256+257
- assertEquals(256, slides.get(0)._getSheetNumber());
- assertEquals(257, slides.get(1)._getSheetNumber());
+ // These are slides 1+2 -> 256+257
+ assertEquals(256, slides.get(0)._getSheetNumber());
+ assertEquals(257, slides.get(1)._getSheetNumber());
- ppt.close();
- }
+ ppt.close();
+ }
@Test
void testNotesCount() throws IOException {
HSLFSlideShow ppt = HSLFTestDataSamples.getSlideShow("basic_test_ppt_file.ppt");
- List notes = ppt.getNotes();
- // Two sheets -> two notes
- // Note: there are also notes on the slide master
- //assertEquals(3, notes.length); // When we do slide masters
- assertEquals(2, notes.size());
+ List notes = ppt.getNotes();
+ // Two sheets -> two notes
+ // Note: there are also notes on the slide master
+ //assertEquals(3, notes.length); // When we do slide masters
+ assertEquals(2, notes.size());
- // First is for master
- //assertEquals(-2147483648, notes.get(0)._getSheetNumber()); // When we do slide masters
+ // First is for master
+ //assertEquals(-2147483648, notes.get(0)._getSheetNumber()); // When we do slide masters
- // Next two are for the two slides
- assertEquals(256, notes.get(0)._getSheetNumber());
- assertEquals(257, notes.get(1)._getSheetNumber());
+ // Next two are for the two slides
+ assertEquals(256, notes.get(0)._getSheetNumber());
+ assertEquals(257, notes.get(1)._getSheetNumber());
- // They happen to go between the two slides in Ref terms
- assertEquals(5, notes.get(0)._getSheetRefId());
- assertEquals(7, notes.get(1)._getSheetRefId());
+ // They happen to go between the two slides in Ref terms
+ assertEquals(5, notes.get(0)._getSheetRefId());
+ assertEquals(7, notes.get(1)._getSheetRefId());
- ppt.close();
- }
+ ppt.close();
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java
index d96201b89f..17c5b3728c 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java
@@ -28,73 +28,73 @@ import org.junit.jupiter.api.Test;
* Tests that SlideShow finds the right records as its most recent ones
*/
public final class TestMostRecentRecords {
- // HSLFSlideShow primed on the test data
- private HSLFSlideShowImpl hss;
- // SlideShow primed on the test data
- private HSLFSlideShow ss;
+ // HSLFSlideShow primed on the test data
+ private HSLFSlideShowImpl hss;
+ // SlideShow primed on the test data
+ private HSLFSlideShow ss;
- @BeforeEach
- void setup() throws Exception {
- POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
- ss = new HSLFSlideShow(hss);
- }
+ @BeforeEach
+ void setup() throws Exception {
+ POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
+ hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ ss = new HSLFSlideShow(hss);
+ }
- @Test
- void testCount() {
- // Most recent core records
- org.apache.poi.hslf.record.Record[] mrcr = ss.getMostRecentCoreRecords();
+ @Test
+ void testCount() {
+ // Most recent core records
+ org.apache.poi.hslf.record.Record[] mrcr = ss.getMostRecentCoreRecords();
- // Master sheet + master notes + 2 slides + 2 notes + document
- assertEquals(7, mrcr.length);
- }
+ // Master sheet + master notes + 2 slides + 2 notes + document
+ assertEquals(7, mrcr.length);
+ }
- @Test
- void testRightRecordTypes() {
- // Most recent core records
- org.apache.poi.hslf.record.Record[] mrcr = ss.getMostRecentCoreRecords();
+ @Test
+ void testRightRecordTypes() {
+ // Most recent core records
+ org.apache.poi.hslf.record.Record[] mrcr = ss.getMostRecentCoreRecords();
- // Document
- assertEquals(1000, mrcr[0].getRecordType());
- // Notes of master
- assertEquals(1008, mrcr[1].getRecordType());
- // Master
- assertEquals(1016, mrcr[2].getRecordType());
+ // Document
+ assertEquals(1000, mrcr[0].getRecordType());
+ // Notes of master
+ assertEquals(1008, mrcr[1].getRecordType());
+ // Master
+ assertEquals(1016, mrcr[2].getRecordType());
- // Slide
- assertEquals(1006, mrcr[3].getRecordType());
- // Notes
- assertEquals(1008, mrcr[4].getRecordType());
- // Slide
- assertEquals(1006, mrcr[5].getRecordType());
- // Notes
- assertEquals(1008, mrcr[6].getRecordType());
- }
+ // Slide
+ assertEquals(1006, mrcr[3].getRecordType());
+ // Notes
+ assertEquals(1008, mrcr[4].getRecordType());
+ // Slide
+ assertEquals(1006, mrcr[5].getRecordType());
+ // Notes
+ assertEquals(1008, mrcr[6].getRecordType());
+ }
- @Test
- void testCorrectRecords() {
- // Most recent core records
- org.apache.poi.hslf.record.Record[] mrcr = ss.getMostRecentCoreRecords();
+ @Test
+ void testCorrectRecords() {
+ // Most recent core records
+ org.apache.poi.hslf.record.Record[] mrcr = ss.getMostRecentCoreRecords();
- // All records
- org.apache.poi.hslf.record.Record[] allr = hss.getRecords();
+ // All records
+ org.apache.poi.hslf.record.Record[] allr = hss.getRecords();
- // Ensure they are the right (latest) version of each
+ // Ensure they are the right (latest) version of each
- // Document - late version
- assertEquals(allr[12], mrcr[0]);
- // Notes of master - unchanged
- assertEquals(allr[2], mrcr[1]);
- // Master - unchanged
- assertEquals(allr[1], mrcr[2]);
+ // Document - late version
+ assertEquals(allr[12], mrcr[0]);
+ // Notes of master - unchanged
+ assertEquals(allr[2], mrcr[1]);
+ // Master - unchanged
+ assertEquals(allr[1], mrcr[2]);
- // Slide - added at start
- assertEquals(allr[3], mrcr[3]);
- // Notes - added at start
- assertEquals(allr[4], mrcr[4]);
- // Slide - added later and then changed
- assertEquals(allr[13], mrcr[5]);
- // Notes - added later but not changed
- assertEquals(allr[9], mrcr[6]);
- }
+ // Slide - added at start
+ assertEquals(allr[3], mrcr[3]);
+ // Notes - added at start
+ assertEquals(allr[4], mrcr[4]);
+ // Slide - added later and then changed
+ assertEquals(allr[13], mrcr[5]);
+ // Notes - added later but not changed
+ assertEquals(allr[9], mrcr[6]);
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestNotesText.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestNotesText.java
index 69863e5685..6ca766172e 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestNotesText.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestNotesText.java
@@ -28,31 +28,31 @@ import org.junit.jupiter.api.Test;
* Tests that SlideShow returns MetaSheets which have the right text in them
*/
public final class TestNotesText {
- // SlideShow primed on the test data
- private HSLFSlideShow ss;
+ // SlideShow primed on the test data
+ private HSLFSlideShow ss;
- @BeforeEach
- void setup() throws Exception {
- POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- HSLFSlideShowImpl hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
- ss = new HSLFSlideShow(hss);
- }
+ @BeforeEach
+ void setup() throws Exception {
+ POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
+ HSLFSlideShowImpl hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ ss = new HSLFSlideShow(hss);
+ }
- @Test
- void testNotesOne() {
- HSLFNotes notes = ss.getNotes().get(0);
- String[] expectText = {"These are the notes for page 1"};
- assertArrayEquals(expectText, toStrings(notes));
- }
+ @Test
+ void testNotesOne() {
+ HSLFNotes notes = ss.getNotes().get(0);
+ String[] expectText = {"These are the notes for page 1"};
+ assertArrayEquals(expectText, toStrings(notes));
+ }
- @Test
- void testNotesTwo() {
- HSLFNotes notes = ss.getNotes().get(1);
- String[] expectText = {"These are the notes on page two, again lacking formatting"};
- assertArrayEquals(expectText, toStrings(notes));
- }
+ @Test
+ void testNotesTwo() {
+ HSLFNotes notes = ss.getNotes().get(1);
+ String[] expectText = {"These are the notes on page two, again lacking formatting"};
+ assertArrayEquals(expectText, toStrings(notes));
+ }
- private static String[] toStrings(HSLFNotes notes) {
- return notes.getTextParagraphs().stream().map(HSLFTextParagraph::getRawText).toArray(String[]::new);
- }
+ private static String[] toStrings(HSLFNotes notes) {
+ return notes.getTextParagraphs().stream().map(HSLFTextParagraph::getRawText).toArray(String[]::new);
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestNumberedList.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestNumberedList.java
index e39ef463f9..398f6e5bc0 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestNumberedList.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestNumberedList.java
@@ -45,96 +45,96 @@ public final class TestNumberedList {
@Test
void testNumberedList() throws Exception {
- HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("numbers.ppt"));
- final List slides = ppt.getSlides();
- assertEquals(2, slides.size());
- checkSlide0(slides.get(0));
- checkSlide1(slides.get(1));
- ppt.close();
- }
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("numbers.ppt"));
+ final List slides = ppt.getSlides();
+ assertEquals(2, slides.size());
+ checkSlide0(slides.get(0));
+ checkSlide1(slides.get(1));
+ ppt.close();
+ }
private void checkSlide0(final HSLFSlide s) {
- final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
- assertNotNull(numberedListArray);
- assertEquals(1, numberedListArray.length);//Just one text box here
- final StyleTextProp9Atom numberedListInfo = numberedListArray[0];
- assertNotNull(numberedListInfo);
- final TextPFException9[] autoNumbers = numberedListInfo.getAutoNumberTypes();
- assertNotNull(autoNumbers);
- assertEquals(4, autoNumbers.length);
+ final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
+ assertNotNull(numberedListArray);
+ assertEquals(1, numberedListArray.length);//Just one text box here
+ final StyleTextProp9Atom numberedListInfo = numberedListArray[0];
+ assertNotNull(numberedListInfo);
+ final TextPFException9[] autoNumbers = numberedListInfo.getAutoNumberTypes();
+ assertNotNull(autoNumbers);
+ assertEquals(4, autoNumbers.length);
assertEquals(4, (short) autoNumbers[0].getAutoNumberStartNumber());
- assertNull(autoNumbers[1].getAutoNumberStartNumber());
+ assertNull(autoNumbers[1].getAutoNumberStartNumber());
assertEquals(3, (short) autoNumbers[2].getAutoNumberStartNumber());
assertSame(AutoNumberingScheme.arabicPeriod, autoNumbers[0].getAutoNumberScheme());
- assertNull(autoNumbers[1].getAutoNumberScheme());
+ assertNull(autoNumbers[1].getAutoNumberScheme());
assertSame(AutoNumberingScheme.alphaLcParenRight, autoNumbers[2].getAutoNumberScheme());
- List> textParass = s.getTextParagraphs();
- assertEquals(2, textParass.size());
+ List> textParass = s.getTextParagraphs();
+ assertEquals(2, textParass.size());
- List textParas = textParass.get(0);
- assertEquals("titTe", HSLFTextParagraph.getRawText(textParas));
- assertEquals(1, textParas.size());
- assertFalse(textParas.get(0).isBullet());
+ List textParas = textParass.get(0);
+ assertEquals("titTe", HSLFTextParagraph.getRawText(textParas));
+ assertEquals(1, textParas.size());
+ assertFalse(textParas.get(0).isBullet());
- String expected =
- "This is a text placeholder that \r" +
- "follows the design pattern\r" +
- "Just a test\rWithout any paragraph\r" +
- "Second paragraph first line c) ;\r" +
- "Second paragraph second line d) . \r";
- assertEquals(expected, HSLFTextParagraph.getRawText(textParass.get(1)));
+ String expected =
+ "This is a text placeholder that \r" +
+ "follows the design pattern\r" +
+ "Just a test\rWithout any paragraph\r" +
+ "Second paragraph first line c) ;\r" +
+ "Second paragraph second line d) . \r";
+ assertEquals(expected, HSLFTextParagraph.getRawText(textParass.get(1)));
- final EscherTextboxWrapper[] styleAtoms = s.getTextboxWrappers();
- assertEquals(textParass.size(), styleAtoms.length);
- final EscherTextboxWrapper wrapper = styleAtoms[1];
- final StyleTextPropAtom styleTextPropAtom = wrapper.getStyleTextPropAtom();
- final List textProps = styleTextPropAtom.getCharacterStyles();
- assertEquals(60, textProps.get(0).getCharactersCovered());
- assertEquals(34, textProps.get(1).getCharactersCovered());
- assertEquals(68, textProps.get(2).getCharactersCovered());
- }
+ final EscherTextboxWrapper[] styleAtoms = s.getTextboxWrappers();
+ assertEquals(textParass.size(), styleAtoms.length);
+ final EscherTextboxWrapper wrapper = styleAtoms[1];
+ final StyleTextPropAtom styleTextPropAtom = wrapper.getStyleTextPropAtom();
+ final List textProps = styleTextPropAtom.getCharacterStyles();
+ assertEquals(60, textProps.get(0).getCharactersCovered());
+ assertEquals(34, textProps.get(1).getCharactersCovered());
+ assertEquals(68, textProps.get(2).getCharactersCovered());
+ }
private void checkSlide1(final HSLFSlide s) {
- final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
- assertNotNull(numberedListArray);
- assertEquals(1, numberedListArray.length);//Just one text box here
- final StyleTextProp9Atom numberedListInfo = numberedListArray[0];
- assertNotNull(numberedListInfo);
- final TextPFException9[] autoNumbers = numberedListInfo.getAutoNumberTypes();
- assertNotNull(autoNumbers);
- assertEquals(4, autoNumbers.length);
+ final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
+ assertNotNull(numberedListArray);
+ assertEquals(1, numberedListArray.length);//Just one text box here
+ final StyleTextProp9Atom numberedListInfo = numberedListArray[0];
+ assertNotNull(numberedListInfo);
+ final TextPFException9[] autoNumbers = numberedListInfo.getAutoNumberTypes();
+ assertNotNull(autoNumbers);
+ assertEquals(4, autoNumbers.length);
assertEquals(9, (short) autoNumbers[0].getAutoNumberStartNumber());
- assertNull(autoNumbers[1].getAutoNumberStartNumber());
+ assertNull(autoNumbers[1].getAutoNumberStartNumber());
assertEquals(3, (short) autoNumbers[2].getAutoNumberStartNumber());
assertSame(AutoNumberingScheme.arabicParenRight, autoNumbers[0].getAutoNumberScheme());
- assertNull(autoNumbers[1].getAutoNumberScheme());
+ assertNull(autoNumbers[1].getAutoNumberScheme());
assertSame(AutoNumberingScheme.alphaUcPeriod, autoNumbers[2].getAutoNumberScheme());
- final List> textParass = s.getTextParagraphs();
- assertEquals(2, textParass.size());
+ final List> textParass = s.getTextParagraphs();
+ assertEquals(2, textParass.size());
- List textParas = textParass.get(0);
- assertEquals("Second Slide Title", HSLFTextParagraph.getRawText(textParas));
- assertEquals(1, textParas.size());
- assertFalse(textParas.get(0).isBullet());
+ List textParas = textParass.get(0);
+ assertEquals("Second Slide Title", HSLFTextParagraph.getRawText(textParas));
+ assertEquals(1, textParas.size());
+ assertFalse(textParas.get(0).isBullet());
- String expected =
- "This is a text placeholder that \r" +
- "follows the design pattern\r" +
- "Just a test\rWithout any paragraph\r" +
- "Second paragraph first line c) ;\r" +
- "Second paragraph second line d) . \r";
- assertEquals(expected, HSLFTextParagraph.getRawText(textParass.get(1)));
+ String expected =
+ "This is a text placeholder that \r" +
+ "follows the design pattern\r" +
+ "Just a test\rWithout any paragraph\r" +
+ "Second paragraph first line c) ;\r" +
+ "Second paragraph second line d) . \r";
+ assertEquals(expected, HSLFTextParagraph.getRawText(textParass.get(1)));
- final EscherTextboxWrapper[] styleAtoms = s.getTextboxWrappers();
- assertEquals(textParass.size(), styleAtoms.length);
- final EscherTextboxWrapper wrapper = styleAtoms[1];
- final StyleTextPropAtom styleTextPropAtom = wrapper.getStyleTextPropAtom();
- final List textProps = styleTextPropAtom.getCharacterStyles();
+ final EscherTextboxWrapper[] styleAtoms = s.getTextboxWrappers();
+ assertEquals(textParass.size(), styleAtoms.length);
+ final EscherTextboxWrapper wrapper = styleAtoms[1];
+ final StyleTextPropAtom styleTextPropAtom = wrapper.getStyleTextPropAtom();
+ final List textProps = styleTextPropAtom.getCharacterStyles();
- assertEquals(33, textProps.get(0).getCharactersCovered());
- assertEquals(61, textProps.get(1).getCharactersCovered());
- assertEquals(68, textProps.get(2).getCharactersCovered());
- }
+ assertEquals(33, textProps.get(0).getCharactersCovered());
+ assertEquals(61, textProps.get(1).getCharactersCovered());
+ assertEquals(68, textProps.get(2).getCharactersCovered());
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestNumberedList2.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestNumberedList2.java
index 6e49fd10d7..4ce43c380d 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestNumberedList2.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestNumberedList2.java
@@ -47,88 +47,88 @@ public final class TestNumberedList2 {
private static final POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
@Test
- void testNumberedList() throws IOException {
- try (HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("numbers2.ppt"))) {
- final List slides = ppt.getSlides();
- assertEquals(2, slides.size());
- checkSlide0(slides.get(0));
- checkSlide1(slides.get(1));
- }
+ void testNumberedList() throws IOException {
+ try (HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("numbers2.ppt"))) {
+ final List slides = ppt.getSlides();
+ assertEquals(2, slides.size());
+ checkSlide0(slides.get(0));
+ checkSlide1(slides.get(1));
+ }
}
private void checkSlide0(final HSLFSlide s) {
- final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
- assertNotNull(numberedListArray);
- assertEquals(2, numberedListArray.length);
- final StyleTextProp9Atom numberedListInfoForTextBox0 = numberedListArray[0];
- final StyleTextProp9Atom numberedListInfoForTextBox1 = numberedListArray[1];
- assertNotNull(numberedListInfoForTextBox0);
- assertNotNull(numberedListInfoForTextBox1);
- final TextPFException9[] autoNumbersOfTextBox0 = numberedListInfoForTextBox0.getAutoNumberTypes();
- assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox0[0].getfBulletHasAutoNumber());
- assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox0[0].getAutoNumberStartNumber());//Default value = 1 will be used
+ final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
+ assertNotNull(numberedListArray);
+ assertEquals(2, numberedListArray.length);
+ final StyleTextProp9Atom numberedListInfoForTextBox0 = numberedListArray[0];
+ final StyleTextProp9Atom numberedListInfoForTextBox1 = numberedListArray[1];
+ assertNotNull(numberedListInfoForTextBox0);
+ assertNotNull(numberedListInfoForTextBox1);
+ final TextPFException9[] autoNumbersOfTextBox0 = numberedListInfoForTextBox0.getAutoNumberTypes();
+ assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox0[0].getfBulletHasAutoNumber());
+ assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox0[0].getAutoNumberStartNumber());//Default value = 1 will be used
assertSame(AutoNumberingScheme.arabicPeriod, autoNumbersOfTextBox0[0].getAutoNumberScheme());
- final TextPFException9[] autoNumbersOfTextBox1 = numberedListInfoForTextBox1.getAutoNumberTypes();
- assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox1[0].getfBulletHasAutoNumber());
- assertEquals(Short.valueOf((short)6), autoNumbersOfTextBox1[0].getAutoNumberStartNumber());//Default value = 1 will be used
+ final TextPFException9[] autoNumbersOfTextBox1 = numberedListInfoForTextBox1.getAutoNumberTypes();
+ assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox1[0].getfBulletHasAutoNumber());
+ assertEquals(Short.valueOf((short)6), autoNumbersOfTextBox1[0].getAutoNumberStartNumber());//Default value = 1 will be used
assertSame(AutoNumberingScheme.arabicPeriod, autoNumbersOfTextBox1[0].getAutoNumberScheme());
- List> textParass = s.getTextParagraphs();
- assertEquals(2, textParass.size());
+ List> textParass = s.getTextParagraphs();
+ assertEquals(2, textParass.size());
- List textParas = textParass.get(0);
- assertEquals("List Item One\rList Item Two\rList Item Three", HSLFTextParagraph.getRawText(textParas));
- assertEquals(3, textParas.size());
- assertTrue(textParas.get(0).isBullet());
+ List textParas = textParass.get(0);
+ assertEquals("List Item One\rList Item Two\rList Item Three", HSLFTextParagraph.getRawText(textParas));
+ assertEquals(3, textParas.size());
+ assertTrue(textParas.get(0).isBullet());
- String expected =
- "A numbered list may start at any number \r" +
- "This would be used as a continuation list on another page\r" +
+ String expected =
+ "A numbered list may start at any number \r" +
+ "This would be used as a continuation list on another page\r" +
"This list should start with #6";
- assertEquals(expected, HSLFTextParagraph.getRawText(textParass.get(1)));
+ assertEquals(expected, HSLFTextParagraph.getRawText(textParass.get(1)));
- final EscherTextboxWrapper[] styleAtoms = s.getTextboxWrappers();
- assertEquals(textParass.size(), styleAtoms.length);
- checkSingleRunWrapper(44, styleAtoms[0]);
- checkSingleRunWrapper(130, styleAtoms[1]);
- }
+ final EscherTextboxWrapper[] styleAtoms = s.getTextboxWrappers();
+ assertEquals(textParass.size(), styleAtoms.length);
+ checkSingleRunWrapper(44, styleAtoms[0]);
+ checkSingleRunWrapper(130, styleAtoms[1]);
+ }
- private void checkSlide1(final HSLFSlide s) {
- final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
- assertNotNull(numberedListArray);
- assertEquals(1, numberedListArray.length);
- final StyleTextProp9Atom numberedListInfoForTextBox = numberedListArray[0];
- assertNotNull(numberedListInfoForTextBox);
- final TextPFException9[] autoNumbersOfTextBox = numberedListInfoForTextBox.getAutoNumberTypes();
- assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox[0].getfBulletHasAutoNumber());
- assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox[0].getAutoNumberStartNumber());//Default value = 1 will be used
+ private void checkSlide1(final HSLFSlide s) {
+ final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
+ assertNotNull(numberedListArray);
+ assertEquals(1, numberedListArray.length);
+ final StyleTextProp9Atom numberedListInfoForTextBox = numberedListArray[0];
+ assertNotNull(numberedListInfoForTextBox);
+ final TextPFException9[] autoNumbersOfTextBox = numberedListInfoForTextBox.getAutoNumberTypes();
+ assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox[0].getfBulletHasAutoNumber());
+ assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox[0].getAutoNumberStartNumber());//Default value = 1 will be used
assertSame(AutoNumberingScheme.arabicPeriod, autoNumbersOfTextBox[0].getAutoNumberScheme());
- List> textParass = s.getTextParagraphs();
- assertEquals(3, textParass.size());
+ List> textParass = s.getTextParagraphs();
+ assertEquals(3, textParass.size());
- List textParas = textParass.get(0);
- assertEquals("Bulleted list\rMore bullets", HSLFTextParagraph.getRawText(textParas));
- assertEquals(2, textParas.size());
- assertTrue(textParas.get(0).isBullet());
+ List textParas = textParass.get(0);
+ assertEquals("Bulleted list\rMore bullets", HSLFTextParagraph.getRawText(textParas));
+ assertEquals(2, textParas.size());
+ assertTrue(textParas.get(0).isBullet());
- String expected = "Numbered list between two bulleted lists\rSecond numbered list item";
- assertEquals(expected, HSLFTextParagraph.getRawText(textParass.get(1)));
- expected = "Second bulleted list \u2013 should appear after numbered list\rMore bullets";
- assertEquals(expected, HSLFTextParagraph.getRawText(textParass.get(2)));
+ String expected = "Numbered list between two bulleted lists\rSecond numbered list item";
+ assertEquals(expected, HSLFTextParagraph.getRawText(textParass.get(1)));
+ expected = "Second bulleted list \u2013 should appear after numbered list\rMore bullets";
+ assertEquals(expected, HSLFTextParagraph.getRawText(textParass.get(2)));
- final EscherTextboxWrapper[] styleAtoms = s.getTextboxWrappers();
- assertEquals(textParass.size(), styleAtoms.length);
- checkSingleRunWrapper(27, styleAtoms[0]);
- checkSingleRunWrapper(67, styleAtoms[1]);
- checkSingleRunWrapper(70, styleAtoms[2]);
- }
+ final EscherTextboxWrapper[] styleAtoms = s.getTextboxWrappers();
+ assertEquals(textParass.size(), styleAtoms.length);
+ checkSingleRunWrapper(27, styleAtoms[0]);
+ checkSingleRunWrapper(67, styleAtoms[1]);
+ checkSingleRunWrapper(70, styleAtoms[2]);
+ }
- private void checkSingleRunWrapper(final int exceptedLength, final EscherTextboxWrapper wrapper) {
- final StyleTextPropAtom styleTextPropAtom = wrapper.getStyleTextPropAtom();
- final List textProps = styleTextPropAtom.getCharacterStyles();
- assertEquals(1, textProps.size());
- assertEquals(exceptedLength, textProps.get(0).getCharactersCovered());
- }
+ private void checkSingleRunWrapper(final int exceptedLength, final EscherTextboxWrapper wrapper) {
+ final StyleTextPropAtom styleTextPropAtom = wrapper.getStyleTextPropAtom();
+ final List textProps = styleTextPropAtom.getCharacterStyles();
+ assertEquals(1, textProps.size());
+ assertEquals(exceptedLength, textProps.get(0).getCharactersCovered());
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestNumberedList3.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestNumberedList3.java
index 6475d51b5d..5cca1478cc 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestNumberedList3.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestNumberedList3.java
@@ -49,61 +49,61 @@ public final class TestNumberedList3 {
@Test
void testNumberedList() throws IOException {
- try (HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("numbers3.ppt"))) {
- final List slides = ppt.getSlides();
- assertEquals(1, slides.size());
- final HSLFSlide slide = slides.get(0);
- checkSlide(slide);
- }
- }
- private void checkSlide(final HSLFSlide s) {
- final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
- assertNotNull(numberedListArray);
- assertEquals(1, numberedListArray.length);
- final StyleTextProp9Atom numberedListInfoForTextBox = numberedListArray[0];
- assertNotNull(numberedListInfoForTextBox);
- final TextPFException9[] autoNumbersOfTextBox0 = numberedListInfoForTextBox.getAutoNumberTypes();
- assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox0[0].getfBulletHasAutoNumber());
- assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox0[0].getAutoNumberStartNumber());//Default value = 1 will be used
+ try (HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("numbers3.ppt"))) {
+ final List slides = ppt.getSlides();
+ assertEquals(1, slides.size());
+ final HSLFSlide slide = slides.get(0);
+ checkSlide(slide);
+ }
+ }
+ private void checkSlide(final HSLFSlide s) {
+ final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
+ assertNotNull(numberedListArray);
+ assertEquals(1, numberedListArray.length);
+ final StyleTextProp9Atom numberedListInfoForTextBox = numberedListArray[0];
+ assertNotNull(numberedListInfoForTextBox);
+ final TextPFException9[] autoNumbersOfTextBox0 = numberedListInfoForTextBox.getAutoNumberTypes();
+ assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox0[0].getfBulletHasAutoNumber());
+ assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox0[0].getAutoNumberStartNumber());//Default value = 1 will be used
assertSame(AutoNumberingScheme.arabicPeriod, autoNumbersOfTextBox0[0].getAutoNumberScheme());
- final List> textParass = s.getTextParagraphs();
- assertEquals(3, textParass.size());
- assertEquals("Bulleted list\rMore bullets\rNo bullets here", HSLFTextParagraph.getRawText(textParass.get(0)));
- assertEquals("Numbered list between two bulleted lists\rSecond numbered list item", HSLFTextParagraph.getRawText(textParass.get(1)));
- assertEquals("Second bulleted list \u2013 should appear after numbered list\rMore bullets", HSLFTextParagraph.getRawText(textParass.get(2)));
- assertEquals(3, textParass.get(0).size());
- assertEquals(2, textParass.get(1).size());
- assertEquals(2, textParass.get(2).size());
- assertNull(textParass.get(0).get(0).getStyleTextProp9Atom());
- assertNotNull(textParass.get(1).get(0).getStyleTextProp9Atom());
- assertNull(textParass.get(2).get(0).getStyleTextProp9Atom());
- final TextPFException9[] autoNumbers = textParass.get(1).get(0).getStyleTextProp9Atom().getAutoNumberTypes();
- assertEquals(1, autoNumbers.length);
- assertEquals(Short.valueOf((short)1), autoNumbers[0].getfBulletHasAutoNumber());
- assertEquals(Short.valueOf((short)1), autoNumbers[0].getAutoNumberStartNumber());//Default value = 1 will be used
+ final List> textParass = s.getTextParagraphs();
+ assertEquals(3, textParass.size());
+ assertEquals("Bulleted list\rMore bullets\rNo bullets here", HSLFTextParagraph.getRawText(textParass.get(0)));
+ assertEquals("Numbered list between two bulleted lists\rSecond numbered list item", HSLFTextParagraph.getRawText(textParass.get(1)));
+ assertEquals("Second bulleted list \u2013 should appear after numbered list\rMore bullets", HSLFTextParagraph.getRawText(textParass.get(2)));
+ assertEquals(3, textParass.get(0).size());
+ assertEquals(2, textParass.get(1).size());
+ assertEquals(2, textParass.get(2).size());
+ assertNull(textParass.get(0).get(0).getStyleTextProp9Atom());
+ assertNotNull(textParass.get(1).get(0).getStyleTextProp9Atom());
+ assertNull(textParass.get(2).get(0).getStyleTextProp9Atom());
+ final TextPFException9[] autoNumbers = textParass.get(1).get(0).getStyleTextProp9Atom().getAutoNumberTypes();
+ assertEquals(1, autoNumbers.length);
+ assertEquals(Short.valueOf((short)1), autoNumbers[0].getfBulletHasAutoNumber());
+ assertEquals(Short.valueOf((short)1), autoNumbers[0].getAutoNumberStartNumber());//Default value = 1 will be used
assertSame(AutoNumberingScheme.arabicPeriod, autoNumbersOfTextBox0[0].getAutoNumberScheme());
- int chCovered = 0;
- for (HSLFTextParagraph htp : textParass.get(1)) {
- for (HSLFTextRun htr : htp.getTextRuns()) {
- TextPropCollection textProp = htr.getCharacterStyle();
- chCovered += textProp.getCharactersCovered();
- }
- }
- assertEquals(67, chCovered);
+ int chCovered = 0;
+ for (HSLFTextParagraph htp : textParass.get(1)) {
+ for (HSLFTextRun htr : htp.getTextRuns()) {
+ TextPropCollection textProp = htr.getCharacterStyle();
+ chCovered += textProp.getCharactersCovered();
+ }
+ }
+ assertEquals(67, chCovered);
- assertTrue(textParass.get(0).get(0).isBullet());
+ assertTrue(textParass.get(0).get(0).isBullet());
- final EscherTextboxWrapper[] styleAtoms = s.getTextboxWrappers();
- assertEquals(textParass.size(), styleAtoms.length);
- checkSingleRunWrapper(43, styleAtoms[0]);
- checkSingleRunWrapper(67, styleAtoms[1]);
- }
- private void checkSingleRunWrapper(final int exceptedLength, final EscherTextboxWrapper wrapper) {
- final StyleTextPropAtom styleTextPropAtom = wrapper.getStyleTextPropAtom();
- final List textProps = styleTextPropAtom.getCharacterStyles();
- assertEquals(1, textProps.size());
- assertEquals(exceptedLength, textProps.get(0).getCharactersCovered());
- }
+ final EscherTextboxWrapper[] styleAtoms = s.getTextboxWrappers();
+ assertEquals(textParass.size(), styleAtoms.length);
+ checkSingleRunWrapper(43, styleAtoms[0]);
+ checkSingleRunWrapper(67, styleAtoms[1]);
+ }
+ private void checkSingleRunWrapper(final int exceptedLength, final EscherTextboxWrapper wrapper) {
+ final StyleTextPropAtom styleTextPropAtom = wrapper.getStyleTextPropAtom();
+ final List textProps = styleTextPropAtom.getCharacterStyles();
+ assertEquals(1, textProps.size());
+ assertEquals(exceptedLength, textProps.get(0).getCharactersCovered());
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestPictures.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestPictures.java
index 65a2716711..918d844ec8 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestPictures.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestPictures.java
@@ -228,13 +228,13 @@ public final class TestPictures {
}
}
- /**
- * Test that on a party corrupt powerpoint document, which has
- * crazy pictures of type 0, we do our best.
- */
+ /**
+ * Test that on a party corrupt powerpoint document, which has
+ * crazy pictures of type 0, we do our best.
+ */
@Test
- void testZeroPictureType() throws IOException {
- try (HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(slTests.openResourceAsStream("PictureTypeZero.ppt"))) {
+ void testZeroPictureType() throws IOException {
+ try (HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(slTests.openResourceAsStream("PictureTypeZero.ppt"))) {
// Should still have 2 real pictures
assertEquals(2, hslf.getPictureData().size());
@@ -262,7 +262,7 @@ public final class TestPictures {
assertTrue(pdata instanceof WMF);
assertEquals(PictureType.WMF, pdata.getType());
}
- }
+ }
/**
* YK: The test is disabled because the owner asked to delete the test file from POI svn.
@@ -271,10 +271,10 @@ public final class TestPictures {
@Test
@Disabled("requires an internet connection to a 3rd party site")
// As of 2017-06-20, the file still exists at the specified URL and the test passes.
- void testZeroPictureLength() throws IOException {
+ void testZeroPictureLength() throws IOException {
// take the data from www instead of test directory
URL url = new URL("http://www.cs.sfu.ca/~anoop/courses/CMPT-882-Fall-2002/chris.ppt");
- HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(url.openStream());
+ HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(url.openStream());
/* Assume that the file could retrieved...
InputStream is;
HSLFSlideShowImpl hslf;
@@ -288,14 +288,14 @@ public final class TestPictures {
}
*/
- // Should still have 2 real pictures
- assertEquals(2, hslf.getPictureData().size());
- // Both are real pictures, both WMF
- assertEquals(PictureType.WMF, hslf.getPictureData().get(0).getType());
- assertEquals(PictureType.WMF, hslf.getPictureData().get(1).getType());
+ // Should still have 2 real pictures
+ assertEquals(2, hslf.getPictureData().size());
+ // Both are real pictures, both WMF
+ assertEquals(PictureType.WMF, hslf.getPictureData().get(0).getType());
+ assertEquals(PictureType.WMF, hslf.getPictureData().get(1).getType());
- // Now test what happens when we use the SlideShow interface
- try (HSLFSlideShow ppt = new HSLFSlideShow(hslf)) {
+ // Now test what happens when we use the SlideShow interface
+ try (HSLFSlideShow ppt = new HSLFSlideShow(hslf)) {
List slides = ppt.getSlides();
List pictures = ppt.getPictureData();
assertEquals(27, slides.size());
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestReOrderingSlides.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestReOrderingSlides.java
index 0b9255050b..ad6a00b6e3 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestReOrderingSlides.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestReOrderingSlides.java
@@ -31,268 +31,268 @@ import org.junit.jupiter.api.Test;
* Tests that SlideShow can re-order slides properly
*/
public final class TestReOrderingSlides {
- // A SlideShow with one slide
- private HSLFSlideShowImpl hss_one;
- private HSLFSlideShow ss_one;
+ // A SlideShow with one slide
+ private HSLFSlideShowImpl hss_one;
+ private HSLFSlideShow ss_one;
- // A SlideShow with two slides
- private HSLFSlideShowImpl hss_two;
- private HSLFSlideShow ss_two;
+ // A SlideShow with two slides
+ private HSLFSlideShowImpl hss_two;
+ private HSLFSlideShow ss_two;
- // A SlideShow with three slides
- private HSLFSlideShowImpl hss_three;
- private HSLFSlideShow ss_three;
+ // A SlideShow with three slides
+ private HSLFSlideShowImpl hss_three;
+ private HSLFSlideShow ss_three;
- /**
- * Create/open the slideshows
- */
- @BeforeEach
- void setUp() throws Exception {
+ /**
+ * Create/open the slideshows
+ */
+ @BeforeEach
+ void setUp() throws Exception {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- hss_one = new HSLFSlideShowImpl(slTests.openResourceAsStream("Single_Coloured_Page.ppt"));
- ss_one = new HSLFSlideShow(hss_one);
+ hss_one = new HSLFSlideShowImpl(slTests.openResourceAsStream("Single_Coloured_Page.ppt"));
+ ss_one = new HSLFSlideShow(hss_one);
- hss_two = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
- ss_two = new HSLFSlideShow(hss_two);
+ hss_two = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ ss_two = new HSLFSlideShow(hss_two);
- hss_three = new HSLFSlideShowImpl(slTests.openResourceAsStream("incorrect_slide_order.ppt"));
- ss_three = new HSLFSlideShow(hss_three);
- }
+ hss_three = new HSLFSlideShowImpl(slTests.openResourceAsStream("incorrect_slide_order.ppt"));
+ ss_three = new HSLFSlideShow(hss_three);
+ }
- /**
- * Test that we can "re-order" a slideshow with only 1 slide on it
- */
- @Test
- void testReOrder1() throws IOException {
- // Has one slide
- assertEquals(1, ss_one.getSlides().size());
- HSLFSlide s1 = ss_one.getSlides().get(0);
+ /**
+ * Test that we can "re-order" a slideshow with only 1 slide on it
+ */
+ @Test
+ void testReOrder1() throws IOException {
+ // Has one slide
+ assertEquals(1, ss_one.getSlides().size());
+ HSLFSlide s1 = ss_one.getSlides().get(0);
- // Check slide 1 is as expected
- assertEquals(256, s1._getSheetNumber());
- assertEquals(3, s1._getSheetRefId());
- assertEquals(1, s1.getSlideNumber());
+ // Check slide 1 is as expected
+ assertEquals(256, s1._getSheetNumber());
+ assertEquals(3, s1._getSheetRefId());
+ assertEquals(1, s1.getSlideNumber());
- // Now move it to one
- ss_one.reorderSlide(1, 1);
+ // Now move it to one
+ ss_one.reorderSlide(1, 1);
- // Write out, and read back in
+ // Write out, and read back in
HSLFSlideShow ss_read = HSLFTestDataSamples.writeOutAndReadBack(ss_one);
- // Check it still has 1 slide
- assertEquals(1, ss_read.getSlides().size());
+ // Check it still has 1 slide
+ assertEquals(1, ss_read.getSlides().size());
- // And check it's as expected
- s1 = ss_read.getSlides().get(0);
- assertEquals(256, s1._getSheetNumber());
- assertEquals(3, s1._getSheetRefId());
- assertEquals(1, s1.getSlideNumber());
-
- ss_read.close();
- }
-
- /**
- * Test doing a dummy re-order on a slideshow with
- * two slides in it
- */
- @Test
- void testReOrder2() throws IOException {
- // Has two slides
- assertEquals(2, ss_two.getSlides().size());
- HSLFSlide s1 = ss_two.getSlides().get(0);
- HSLFSlide s2 = ss_two.getSlides().get(1);
-
- // Check slide 1 is as expected
- assertEquals(256, s1._getSheetNumber());
- assertEquals(4, s1._getSheetRefId()); // master has notes
- assertEquals(1, s1.getSlideNumber());
- // Check slide 2 is as expected
- assertEquals(257, s2._getSheetNumber());
- assertEquals(6, s2._getSheetRefId()); // master and 1 have notes
- assertEquals(2, s2.getSlideNumber());
-
- // Don't swap them around
- ss_two.reorderSlide(2, 2);
-
- // Write out, and read back in
- HSLFSlideShow ss_read = HSLFTestDataSamples.writeOutAndReadBack(ss_two);
-
- // Check it still has 2 slides
- assertEquals(2, ss_read.getSlides().size());
-
- // And check it's as expected
- s1 = ss_read.getSlides().get(0);
- s2 = ss_read.getSlides().get(1);
- assertEquals(256, s1._getSheetNumber());
- assertEquals(4, s1._getSheetRefId());
- assertEquals(1, s1.getSlideNumber());
- assertEquals(257, s2._getSheetNumber());
- assertEquals(6, s2._getSheetRefId());
- assertEquals(2, s2.getSlideNumber());
+ // And check it's as expected
+ s1 = ss_read.getSlides().get(0);
+ assertEquals(256, s1._getSheetNumber());
+ assertEquals(3, s1._getSheetRefId());
+ assertEquals(1, s1.getSlideNumber());
ss_read.close();
}
- /**
- * Test re-ordering slides in a slideshow with 2 slides on it
- */
+ /**
+ * Test doing a dummy re-order on a slideshow with
+ * two slides in it
+ */
@Test
- void testReOrder2swap() throws IOException {
- // Has two slides
- assertEquals(2, ss_two.getSlides().size());
- HSLFSlide s1 = ss_two.getSlides().get(0);
- HSLFSlide s2 = ss_two.getSlides().get(1);
+ void testReOrder2() throws IOException {
+ // Has two slides
+ assertEquals(2, ss_two.getSlides().size());
+ HSLFSlide s1 = ss_two.getSlides().get(0);
+ HSLFSlide s2 = ss_two.getSlides().get(1);
- // Check slide 1 is as expected
- assertEquals(256, s1._getSheetNumber());
- assertEquals(4, s1._getSheetRefId()); // master has notes
- assertEquals(1, s1.getSlideNumber());
- // Check slide 2 is as expected
- assertEquals(257, s2._getSheetNumber());
- assertEquals(6, s2._getSheetRefId()); // master and 1 have notes
- assertEquals(2, s2.getSlideNumber());
+ // Check slide 1 is as expected
+ assertEquals(256, s1._getSheetNumber());
+ assertEquals(4, s1._getSheetRefId()); // master has notes
+ assertEquals(1, s1.getSlideNumber());
+ // Check slide 2 is as expected
+ assertEquals(257, s2._getSheetNumber());
+ assertEquals(6, s2._getSheetRefId()); // master and 1 have notes
+ assertEquals(2, s2.getSlideNumber());
- // Swap them around
- ss_two.reorderSlide(2, 1);
+ // Don't swap them around
+ ss_two.reorderSlide(2, 2);
- // Write out, and read back in
+ // Write out, and read back in
HSLFSlideShow ss_read = HSLFTestDataSamples.writeOutAndReadBack(ss_two);
- // Check it still has 2 slides
- assertEquals(2, ss_read.getSlides().size());
+ // Check it still has 2 slides
+ assertEquals(2, ss_read.getSlides().size());
- // And check it's as expected
- s1 = ss_read.getSlides().get(0);
- s2 = ss_read.getSlides().get(1);
- assertEquals(257, s1._getSheetNumber());
- assertEquals(6, s1._getSheetRefId());
- assertEquals(1, s1.getSlideNumber());
- assertEquals(256, s2._getSheetNumber());
- assertEquals(4, s2._getSheetRefId());
- assertEquals(2, s2.getSlideNumber());
+ // And check it's as expected
+ s1 = ss_read.getSlides().get(0);
+ s2 = ss_read.getSlides().get(1);
+ assertEquals(256, s1._getSheetNumber());
+ assertEquals(4, s1._getSheetRefId());
+ assertEquals(1, s1.getSlideNumber());
+ assertEquals(257, s2._getSheetNumber());
+ assertEquals(6, s2._getSheetRefId());
+ assertEquals(2, s2.getSlideNumber());
- ss_read.close();
+ ss_read.close();
}
- /**
- * Test doing a dummy re-order on a slideshow with
- * three slides in it
- */
+ /**
+ * Test re-ordering slides in a slideshow with 2 slides on it
+ */
@Test
- void testReOrder3() throws IOException {
- // Has three slides
- assertEquals(3, ss_three.getSlides().size());
- HSLFSlide s1 = ss_three.getSlides().get(0);
- HSLFSlide s2 = ss_three.getSlides().get(1);
- HSLFSlide s3 = ss_three.getSlides().get(2);
+ void testReOrder2swap() throws IOException {
+ // Has two slides
+ assertEquals(2, ss_two.getSlides().size());
+ HSLFSlide s1 = ss_two.getSlides().get(0);
+ HSLFSlide s2 = ss_two.getSlides().get(1);
- // Check slide 1 is as expected
- assertEquals(256, s1._getSheetNumber());
- assertEquals(3, s1._getSheetRefId()); // no notes on master
- assertEquals(1, s1.getSlideNumber());
- // Check slide 2 is as expected (was re-ordered from 3)
- assertEquals(258, s2._getSheetNumber());
- assertEquals(5, s2._getSheetRefId()); // no notes on slide
- assertEquals(2, s2.getSlideNumber());
- // Check slide 3 is as expected (was re-ordered from 2)
- assertEquals(257, s3._getSheetNumber());
- assertEquals(4, s3._getSheetRefId()); // no notes on slide
- assertEquals(3, s3.getSlideNumber());
+ // Check slide 1 is as expected
+ assertEquals(256, s1._getSheetNumber());
+ assertEquals(4, s1._getSheetRefId()); // master has notes
+ assertEquals(1, s1.getSlideNumber());
+ // Check slide 2 is as expected
+ assertEquals(257, s2._getSheetNumber());
+ assertEquals(6, s2._getSheetRefId()); // master and 1 have notes
+ assertEquals(2, s2.getSlideNumber());
- // Don't swap them around
- ss_three.reorderSlide(2, 2);
+ // Swap them around
+ ss_two.reorderSlide(2, 1);
- // Write out, and read back in
+ // Write out, and read back in
+ HSLFSlideShow ss_read = HSLFTestDataSamples.writeOutAndReadBack(ss_two);
+
+ // Check it still has 2 slides
+ assertEquals(2, ss_read.getSlides().size());
+
+ // And check it's as expected
+ s1 = ss_read.getSlides().get(0);
+ s2 = ss_read.getSlides().get(1);
+ assertEquals(257, s1._getSheetNumber());
+ assertEquals(6, s1._getSheetRefId());
+ assertEquals(1, s1.getSlideNumber());
+ assertEquals(256, s2._getSheetNumber());
+ assertEquals(4, s2._getSheetRefId());
+ assertEquals(2, s2.getSlideNumber());
+
+ ss_read.close();
+ }
+
+ /**
+ * Test doing a dummy re-order on a slideshow with
+ * three slides in it
+ */
+ @Test
+ void testReOrder3() throws IOException {
+ // Has three slides
+ assertEquals(3, ss_three.getSlides().size());
+ HSLFSlide s1 = ss_three.getSlides().get(0);
+ HSLFSlide s2 = ss_three.getSlides().get(1);
+ HSLFSlide s3 = ss_three.getSlides().get(2);
+
+ // Check slide 1 is as expected
+ assertEquals(256, s1._getSheetNumber());
+ assertEquals(3, s1._getSheetRefId()); // no notes on master
+ assertEquals(1, s1.getSlideNumber());
+ // Check slide 2 is as expected (was re-ordered from 3)
+ assertEquals(258, s2._getSheetNumber());
+ assertEquals(5, s2._getSheetRefId()); // no notes on slide
+ assertEquals(2, s2.getSlideNumber());
+ // Check slide 3 is as expected (was re-ordered from 2)
+ assertEquals(257, s3._getSheetNumber());
+ assertEquals(4, s3._getSheetRefId()); // no notes on slide
+ assertEquals(3, s3.getSlideNumber());
+
+ // Don't swap them around
+ ss_three.reorderSlide(2, 2);
+
+ // Write out, and read back in
HSLFSlideShow ss_read = HSLFTestDataSamples.writeOutAndReadBack(ss_three);
- // Check it still has 3 slides
- assertEquals(3, ss_read.getSlides().size());
+ // Check it still has 3 slides
+ assertEquals(3, ss_read.getSlides().size());
- // And check it's as expected
- s1 = ss_read.getSlides().get(0);
- s2 = ss_read.getSlides().get(1);
- s3 = ss_read.getSlides().get(2);
+ // And check it's as expected
+ s1 = ss_read.getSlides().get(0);
+ s2 = ss_read.getSlides().get(1);
+ s3 = ss_read.getSlides().get(2);
- assertEquals(256, s1._getSheetNumber());
- assertEquals(3, s1._getSheetRefId());
- assertEquals(1, s1.getSlideNumber());
- assertEquals(258, s2._getSheetNumber());
- assertEquals(5, s2._getSheetRefId());
- assertEquals(2, s2.getSlideNumber());
- assertEquals(257, s3._getSheetNumber());
- assertEquals(4, s3._getSheetRefId());
- assertEquals(3, s3.getSlideNumber());
+ assertEquals(256, s1._getSheetNumber());
+ assertEquals(3, s1._getSheetRefId());
+ assertEquals(1, s1.getSlideNumber());
+ assertEquals(258, s2._getSheetNumber());
+ assertEquals(5, s2._getSheetRefId());
+ assertEquals(2, s2.getSlideNumber());
+ assertEquals(257, s3._getSheetNumber());
+ assertEquals(4, s3._getSheetRefId());
+ assertEquals(3, s3.getSlideNumber());
ss_read.close();
}
- /**
- * Test re-ordering slides in a slideshow with 3 slides on it
- */
+ /**
+ * Test re-ordering slides in a slideshow with 3 slides on it
+ */
@Test
- void testReOrder3swap() throws IOException {
- // Has three slides
- assertEquals(3, ss_three.getSlides().size());
- HSLFSlide s1 = ss_three.getSlides().get(0);
- HSLFSlide s2 = ss_three.getSlides().get(1);
- HSLFSlide s3 = ss_three.getSlides().get(2);
+ void testReOrder3swap() throws IOException {
+ // Has three slides
+ assertEquals(3, ss_three.getSlides().size());
+ HSLFSlide s1 = ss_three.getSlides().get(0);
+ HSLFSlide s2 = ss_three.getSlides().get(1);
+ HSLFSlide s3 = ss_three.getSlides().get(2);
- // Check slide 1 is as expected
- assertEquals(256, s1._getSheetNumber());
- assertEquals(3, s1._getSheetRefId()); // no notes on master
- assertEquals(1, s1.getSlideNumber());
- // Check slide 2 is as expected (was re-ordered from 3)
- assertEquals(258, s2._getSheetNumber());
- assertEquals(5, s2._getSheetRefId()); // no notes on slide
- assertEquals(2, s2.getSlideNumber());
- // Check slide 3 is as expected (was re-ordered from 2)
- assertEquals(257, s3._getSheetNumber());
- assertEquals(4, s3._getSheetRefId()); // no notes on slide
- assertEquals(3, s3.getSlideNumber());
+ // Check slide 1 is as expected
+ assertEquals(256, s1._getSheetNumber());
+ assertEquals(3, s1._getSheetRefId()); // no notes on master
+ assertEquals(1, s1.getSlideNumber());
+ // Check slide 2 is as expected (was re-ordered from 3)
+ assertEquals(258, s2._getSheetNumber());
+ assertEquals(5, s2._getSheetRefId()); // no notes on slide
+ assertEquals(2, s2.getSlideNumber());
+ // Check slide 3 is as expected (was re-ordered from 2)
+ assertEquals(257, s3._getSheetNumber());
+ assertEquals(4, s3._getSheetRefId()); // no notes on slide
+ assertEquals(3, s3.getSlideNumber());
- // Put 3 in place of 1
- // (1 -> 2, 2 -> 3)
- ss_three.reorderSlide(3, 1);
+ // Put 3 in place of 1
+ // (1 -> 2, 2 -> 3)
+ ss_three.reorderSlide(3, 1);
- // refresh the slides
- s1 = ss_three.getSlides().get(0);
+ // refresh the slides
+ s1 = ss_three.getSlides().get(0);
s2 = ss_three.getSlides().get(1);
s3 = ss_three.getSlides().get(2);
- assertEquals(1, s1.getSlideNumber());
+ assertEquals(1, s1.getSlideNumber());
assertEquals(2, s2.getSlideNumber());
assertEquals(3, s3.getSlideNumber());
assertEquals("Slide 3", ((HSLFTextShape)s1.getShapes().get(0)).getText());
assertEquals("Slide 1", ((HSLFTextShape)s3.getShapes().get(0)).getText());
- // Write out, and read back in
+ // Write out, and read back in
HSLFSlideShow ss_read = HSLFTestDataSamples.writeOutAndReadBack(ss_three);
- // Check it still has 3 slides
- assertEquals(3, ss_read.getSlides().size());
+ // Check it still has 3 slides
+ assertEquals(3, ss_read.getSlides().size());
- // And check it's as expected
- HSLFSlide _s1 = ss_read.getSlides().get(0);
- HSLFSlide _s2 = ss_read.getSlides().get(1);
- HSLFSlide _s3 = ss_read.getSlides().get(2);
+ // And check it's as expected
+ HSLFSlide _s1 = ss_read.getSlides().get(0);
+ HSLFSlide _s2 = ss_read.getSlides().get(1);
+ HSLFSlide _s3 = ss_read.getSlides().get(2);
// 1 --> 3
assertEquals(s1._getSheetNumber(), _s1._getSheetNumber());
- assertEquals(s1._getSheetRefId(), _s1._getSheetRefId());
- assertEquals(1, s1.getSlideNumber());
+ assertEquals(s1._getSheetRefId(), _s1._getSheetRefId());
+ assertEquals(1, s1.getSlideNumber());
// 2nd slide is not updated
assertEquals(s2._getSheetNumber(), _s2._getSheetNumber());
assertEquals(s2._getSheetRefId(), _s2._getSheetRefId());
- assertEquals(2, s2.getSlideNumber());
+ assertEquals(2, s2.getSlideNumber());
// 3 --> 1
assertEquals(s3._getSheetNumber(), _s3._getSheetNumber());
assertEquals(s3._getSheetRefId(), _s3._getSheetRefId());
- assertEquals(3, s3.getSlideNumber());
+ assertEquals(3, s3.getSlideNumber());
- ss_read.close();
- }
+ ss_read.close();
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestRecordSetup.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestRecordSetup.java
index 962cc7e4d4..126d34c45f 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestRecordSetup.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestRecordSetup.java
@@ -30,36 +30,36 @@ import org.junit.jupiter.api.Test;
* Note: most recent record stuff has its own test
*/
public final class TestRecordSetup {
- // SlideShow primed on the test data
- @SuppressWarnings("unused")
+ // SlideShow primed on the test data
+ @SuppressWarnings("unused")
private HSLFSlideShow ss;
- private HSLFSlideShowImpl hss;
+ private HSLFSlideShowImpl hss;
- @BeforeEach
- void init() throws Exception {
+ @BeforeEach
+ void init() throws Exception {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
- ss = new HSLFSlideShow(hss);
- }
+ hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ ss = new HSLFSlideShow(hss);
+ }
- @Test
- void testHandleParentAwareRecords() {
- org.apache.poi.hslf.record.Record[] records = hss.getRecords();
- for ( org.apache.poi.hslf.record.Record record : records) {
- ensureParentAware(record,null);
- }
- }
- private void ensureParentAware( org.apache.poi.hslf.record.Record r,RecordContainer parent) {
- if(r instanceof ParentAwareRecord) {
- ParentAwareRecord pr = (ParentAwareRecord)r;
- assertEquals(parent, pr.getParentRecord());
- }
- if(r instanceof RecordContainer) {
- RecordContainer rc = (RecordContainer)r;
- org.apache.poi.hslf.record.Record[] children = rc.getChildRecords();
- for ( org.apache.poi.hslf.record.Record rec : children) {
- ensureParentAware(rec, rc);
- }
- }
- }
+ @Test
+ void testHandleParentAwareRecords() {
+ org.apache.poi.hslf.record.Record[] records = hss.getRecords();
+ for ( org.apache.poi.hslf.record.Record record : records) {
+ ensureParentAware(record,null);
+ }
+ }
+ private void ensureParentAware( org.apache.poi.hslf.record.Record r,RecordContainer parent) {
+ if(r instanceof ParentAwareRecord) {
+ ParentAwareRecord pr = (ParentAwareRecord)r;
+ assertEquals(parent, pr.getParentRecord());
+ }
+ if(r instanceof RecordContainer) {
+ RecordContainer rc = (RecordContainer)r;
+ org.apache.poi.hslf.record.Record[] children = rc.getChildRecords();
+ for ( org.apache.poi.hslf.record.Record rec : children) {
+ ensureParentAware(rec, rc);
+ }
+ }
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestRichTextRun.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestRichTextRun.java
index 90a84b815e..87fb7e0033 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestRichTextRun.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestRichTextRun.java
@@ -81,554 +81,554 @@ public final class TestRichTextRun {
ssChinese.close();
}
- /**
- * Test the stuff about getting/setting bold
- * on a non rich text run
- */
+ /**
+ * Test the stuff about getting/setting bold
+ * on a non rich text run
+ */
@Test
- void testBoldNonRich() {
- HSLFSlide slideOne = ss.getSlides().get(0);
- List> textParass = slideOne.getTextParagraphs();
- List textParas = textParass.get(0);
- HSLFTextRun rtr = textParas.get(0).getTextRuns().get(0);
+ void testBoldNonRich() {
+ HSLFSlide slideOne = ss.getSlides().get(0);
+ List> textParass = slideOne.getTextParagraphs();
+ List textParas = textParass.get(0);
+ HSLFTextRun rtr = textParas.get(0).getTextRuns().get(0);
- assertNotNull(rtr.getCharacterStyle());
- assertNotNull(textParas.get(0).getParagraphStyle());
- assertFalse(rtr.isBold());
-
- // Now set it to not bold
- rtr.setBold(false);
- // in Pre 3.12: setting bold=false doesn't change the internal state
- // now: also allow explicitly disable styles and there aren't any non rich text runs anymore
- assertNotNull(rtr.getCharacterStyle());
- assertNotNull(textParas.get(0).getParagraphStyle());
-
- assertFalse(rtr.isBold());
-
- // And now make it bold
- rtr.setBold(true);
- assertNotNull(rtr.getCharacterStyle());
+ assertNotNull(rtr.getCharacterStyle());
assertNotNull(textParas.get(0).getParagraphStyle());
- assertTrue(rtr.isBold());
- }
+ assertFalse(rtr.isBold());
- /**
- * Test the stuff about getting/setting bold
- * on a rich text run
- */
+ // Now set it to not bold
+ rtr.setBold(false);
+ // in Pre 3.12: setting bold=false doesn't change the internal state
+ // now: also allow explicitly disable styles and there aren't any non rich text runs anymore
+ assertNotNull(rtr.getCharacterStyle());
+ assertNotNull(textParas.get(0).getParagraphStyle());
+
+ assertFalse(rtr.isBold());
+
+ // And now make it bold
+ rtr.setBold(true);
+ assertNotNull(rtr.getCharacterStyle());
+ assertNotNull(textParas.get(0).getParagraphStyle());
+ assertTrue(rtr.isBold());
+ }
+
+ /**
+ * Test the stuff about getting/setting bold
+ * on a rich text run
+ */
@Test
- void testBoldRich() {
- HSLFSlide slideOneR = ssRichA.getSlides().get(0);
- List> textParass = slideOneR.getTextParagraphs();
- List textParas = textParass.get(1);
- assertEquals(3, textParas.size());
+ void testBoldRich() {
+ HSLFSlide slideOneR = ssRichA.getSlides().get(0);
+ List> textParass = slideOneR.getTextParagraphs();
+ List textParas = textParass.get(1);
+ assertEquals(3, textParas.size());
- assertTrue(textParas.get(0).getTextRuns().get(0).isBold());
- assertFalse(textParas.get(1).getTextRuns().get(0).isBold());
- assertFalse(textParas.get(2).getTextRuns().get(0).isBold());
+ assertTrue(textParas.get(0).getTextRuns().get(0).isBold());
+ assertFalse(textParas.get(1).getTextRuns().get(0).isBold());
+ assertFalse(textParas.get(2).getTextRuns().get(0).isBold());
- textParas.get(0).getTextRuns().get(0).setBold(true);
- textParas.get(1).getTextRuns().get(0).setBold(true);
+ textParas.get(0).getTextRuns().get(0).setBold(true);
+ textParas.get(1).getTextRuns().get(0).setBold(true);
- assertTrue(textParas.get(0).getTextRuns().get(0).isBold());
- assertTrue(textParas.get(1).getTextRuns().get(0).isBold());
+ assertTrue(textParas.get(0).getTextRuns().get(0).isBold());
+ assertTrue(textParas.get(1).getTextRuns().get(0).isBold());
- textParas.get(0).getTextRuns().get(0).setBold(false);
- textParas.get(1).getTextRuns().get(0).setBold(false);
+ textParas.get(0).getTextRuns().get(0).setBold(false);
+ textParas.get(1).getTextRuns().get(0).setBold(false);
- assertFalse(textParas.get(0).getTextRuns().get(0).isBold());
- assertFalse(textParas.get(1).getTextRuns().get(0).isBold());
- }
+ assertFalse(textParas.get(0).getTextRuns().get(0).isBold());
+ assertFalse(textParas.get(1).getTextRuns().get(0).isBold());
+ }
- /**
- * Tests getting and setting the font size on rich and non
- * rich text runs
- */
+ /**
+ * Tests getting and setting the font size on rich and non
+ * rich text runs
+ */
@Test
- void testFontSize() {
+ void testFontSize() {
- HSLFSlide slideOne = ss.getSlides().get(0);
- List> textParass = slideOne.getTextParagraphs();
- HSLFTextRun rtr = textParass.get(0).get(0).getTextRuns().get(0);
+ HSLFSlide slideOne = ss.getSlides().get(0);
+ List> textParass = slideOne.getTextParagraphs();
+ HSLFTextRun rtr = textParass.get(0).get(0).getTextRuns().get(0);
- HSLFSlide slideOneR = ssRichB.getSlides().get(0);
- List> textParassR = slideOneR.getTextParagraphs();
- HSLFTextRun rtrRa = textParassR.get(0).get(0).getTextRuns().get(0);
- HSLFTextRun rtrRb = textParassR.get(1).get(0).getTextRuns().get(0);
- HSLFTextRun rtrRc = textParassR.get(1).get(3).getTextRuns().get(0);
+ HSLFSlide slideOneR = ssRichB.getSlides().get(0);
+ List> textParassR = slideOneR.getTextParagraphs();
+ HSLFTextRun rtrRa = textParassR.get(0).get(0).getTextRuns().get(0);
+ HSLFTextRun rtrRb = textParassR.get(1).get(0).getTextRuns().get(0);
+ HSLFTextRun rtrRc = textParassR.get(1).get(3).getTextRuns().get(0);
- String defaultFont = "Arial";
+ String defaultFont = "Arial";
- // Start off with rich one
- // First run has defaults
- assertNotNull(rtrRa.getFontSize());
- assertEquals(44, rtrRa.getFontSize(), 0);
- assertEquals(defaultFont, rtrRa.getFontFamily());
+ // Start off with rich one
+ // First run has defaults
+ assertNotNull(rtrRa.getFontSize());
+ assertEquals(44, rtrRa.getFontSize(), 0);
+ assertEquals(defaultFont, rtrRa.getFontFamily());
- // Second is size 20, default font
- assertNotNull(rtrRb.getFontSize());
- assertEquals(20, rtrRb.getFontSize(), 0);
- assertEquals(defaultFont, rtrRb.getFontFamily());
- // Third is size 24, alt font
- assertNotNull(rtrRc.getFontSize());
- assertEquals(24, rtrRc.getFontSize(), 0);
- assertEquals("Times New Roman", rtrRc.getFontFamily());
+ // Second is size 20, default font
+ assertNotNull(rtrRb.getFontSize());
+ assertEquals(20, rtrRb.getFontSize(), 0);
+ assertEquals(defaultFont, rtrRb.getFontFamily());
+ // Third is size 24, alt font
+ assertNotNull(rtrRc.getFontSize());
+ assertEquals(24, rtrRc.getFontSize(), 0);
+ assertEquals("Times New Roman", rtrRc.getFontFamily());
- // Change 2nd to different size and font
- assertEquals(2, ssRichB.getFontCollection().getChildRecords().length); // Default + TNR
- rtrRb.setFontSize(18d);
- rtrRb.setFontFamily("Courier");
- assertEquals(3, ssRichB.getFontCollection().getChildRecords().length); // Default + TNR + Courier
- assertEquals(18, rtrRb.getFontSize(), 0);
- assertEquals("Courier", rtrRb.getFontFamily());
+ // Change 2nd to different size and font
+ assertEquals(2, ssRichB.getFontCollection().getChildRecords().length); // Default + TNR
+ rtrRb.setFontSize(18d);
+ rtrRb.setFontFamily("Courier");
+ assertEquals(3, ssRichB.getFontCollection().getChildRecords().length); // Default + TNR + Courier
+ assertEquals(18, rtrRb.getFontSize(), 0);
+ assertEquals("Courier", rtrRb.getFontFamily());
- // Now do non rich one
- assertNotNull(rtr.getFontSize());
- assertEquals(44, rtr.getFontSize(), 0);
- assertEquals(defaultFont, rtr.getFontFamily());
- assertEquals(1, ss.getFontCollection().getChildRecords().length); // Default
- assertNotNull(rtr.getCharacterStyle());
- assertNotNull(rtr.getTextParagraph().getParagraphStyle());
+ // Now do non rich one
+ assertNotNull(rtr.getFontSize());
+ assertEquals(44, rtr.getFontSize(), 0);
+ assertEquals(defaultFont, rtr.getFontFamily());
+ assertEquals(1, ss.getFontCollection().getChildRecords().length); // Default
+ assertNotNull(rtr.getCharacterStyle());
+ assertNotNull(rtr.getTextParagraph().getParagraphStyle());
- // Change Font size
- rtr.setFontSize(99d);
- assertEquals(99, rtr.getFontSize(), 0);
- assertEquals(defaultFont, rtr.getFontFamily());
- assertNotNull(rtr.getCharacterStyle());
- assertNotNull(rtr.getTextParagraph().getParagraphStyle());
- assertEquals(1, ss.getFontCollection().getChildRecords().length); // Default
+ // Change Font size
+ rtr.setFontSize(99d);
+ assertEquals(99, rtr.getFontSize(), 0);
+ assertEquals(defaultFont, rtr.getFontFamily());
+ assertNotNull(rtr.getCharacterStyle());
+ assertNotNull(rtr.getTextParagraph().getParagraphStyle());
+ assertEquals(1, ss.getFontCollection().getChildRecords().length); // Default
- // Change Font size and name
- rtr.setFontSize(25d);
- rtr.setFontFamily("Times New Roman");
- assertEquals(25, rtr.getFontSize(), 0);
- assertEquals("Times New Roman", rtr.getFontFamily());
- assertNotNull(rtr.getCharacterStyle());
- assertNotNull(rtr.getTextParagraph().getParagraphStyle());
- assertEquals(2, ss.getFontCollection().getChildRecords().length);
- }
+ // Change Font size and name
+ rtr.setFontSize(25d);
+ rtr.setFontFamily("Times New Roman");
+ assertEquals(25, rtr.getFontSize(), 0);
+ assertEquals("Times New Roman", rtr.getFontFamily());
+ assertNotNull(rtr.getCharacterStyle());
+ assertNotNull(rtr.getTextParagraph().getParagraphStyle());
+ assertEquals(2, ss.getFontCollection().getChildRecords().length);
+ }
@Test
- void testChangeWriteRead() throws IOException {
- for(HSLFSlideShow h : new HSLFSlideShow[] { ss, ssRichA, ssRichB }) {
- // Change
- HSLFSlide slideOne = h.getSlides().get(0);
- List> textParass = slideOne.getTextParagraphs();
- HSLFTextRun rtr = textParass.get(0).get(0).getTextRuns().get(0);
+ void testChangeWriteRead() throws IOException {
+ for(HSLFSlideShow h : new HSLFSlideShow[] { ss, ssRichA, ssRichB }) {
+ // Change
+ HSLFSlide slideOne = h.getSlides().get(0);
+ List> textParass = slideOne.getTextParagraphs();
+ HSLFTextRun rtr = textParass.get(0).get(0).getTextRuns().get(0);
- rtr.setBold(true);
- rtr.setFontSize(18d);
- rtr.setFontFamily("Courier");
+ rtr.setBold(true);
+ rtr.setFontSize(18d);
+ rtr.setFontFamily("Courier");
HSLFTextParagraph.storeText(textParass.get(0));
- // Check it took those
- assertTrue(rtr.isBold());
- assertNotNull(rtr.getFontSize());
- assertEquals(18., rtr.getFontSize(), 0);
- assertEquals("Courier", rtr.getFontFamily());
+ // Check it took those
+ assertTrue(rtr.isBold());
+ assertNotNull(rtr.getFontSize());
+ assertEquals(18., rtr.getFontSize(), 0);
+ assertEquals("Courier", rtr.getFontFamily());
- // Write out and back in
- try (HSLFSlideShow readS = HSLFTestDataSamples.writeOutAndReadBack(h)) {
+ // Write out and back in
+ try (HSLFSlideShow readS = HSLFTestDataSamples.writeOutAndReadBack(h)) {
- // Tweak existing one again, to ensure really worked
- rtr.setBold(false);
- rtr.setFontSize(17d);
- rtr.setFontFamily("CourierZZ");
+ // Tweak existing one again, to ensure really worked
+ rtr.setBold(false);
+ rtr.setFontSize(17d);
+ rtr.setFontFamily("CourierZZ");
- // Check it took those changes
- assertFalse(rtr.isBold());
- assertEquals(17., rtr.getFontSize(), 0);
- assertEquals("CourierZZ", rtr.getFontFamily());
+ // Check it took those changes
+ assertFalse(rtr.isBold());
+ assertEquals(17., rtr.getFontSize(), 0);
+ assertEquals("CourierZZ", rtr.getFontFamily());
- // Now, look at the one we changed, wrote out, and read back in
- // Ensure it does contain our original modifications
- HSLFSlide slideOneRR = readS.getSlides().get(0);
- List> textParassRR = slideOneRR.getTextParagraphs();
- HSLFTextRun rtrRRa = textParassRR.get(0).get(0).getTextRuns().get(0);
+ // Now, look at the one we changed, wrote out, and read back in
+ // Ensure it does contain our original modifications
+ HSLFSlide slideOneRR = readS.getSlides().get(0);
+ List> textParassRR = slideOneRR.getTextParagraphs();
+ HSLFTextRun rtrRRa = textParassRR.get(0).get(0).getTextRuns().get(0);
- assertTrue(rtrRRa.isBold());
- assertNotNull(rtrRRa.getFontSize());
- assertEquals(18., rtrRRa.getFontSize(), 0);
- assertEquals("Courier", rtrRRa.getFontFamily());
- }
- }
- }
+ assertTrue(rtrRRa.isBold());
+ assertNotNull(rtrRRa.getFontSize());
+ assertEquals(18., rtrRRa.getFontSize(), 0);
+ assertEquals("Courier", rtrRRa.getFontFamily());
+ }
+ }
+ }
- /**
- * Test that we can do the right things when the paragraph styles
- * run out before the character styles do
- */
+ /**
+ * Test that we can do the right things when the paragraph styles
+ * run out before the character styles do
+ */
@Test
- void testParagraphStylesShorterTheCharStyles() {
- // Check we have the right number of sheets
- List slides = ssRichC.getSlides();
- assertEquals(14, slides.size());
+ void testParagraphStylesShorterTheCharStyles() {
+ // Check we have the right number of sheets
+ List slides = ssRichC.getSlides();
+ assertEquals(14, slides.size());
- // Check the number of text runs on interesting sheets
- HSLFSlide slideThreeC = ssRichC.getSlides().get(2);
- HSLFSlide slideSevenC = ssRichC.getSlides().get(6);
- assertEquals(4, slideThreeC.getTextParagraphs().size());
- assertEquals(5, slideSevenC.getTextParagraphs().size());
+ // Check the number of text runs on interesting sheets
+ HSLFSlide slideThreeC = ssRichC.getSlides().get(2);
+ HSLFSlide slideSevenC = ssRichC.getSlides().get(6);
+ assertEquals(4, slideThreeC.getTextParagraphs().size());
+ assertEquals(5, slideSevenC.getTextParagraphs().size());
- // On slide three, we should have:
- // TR:
- // You are an important supplier of various items that I need
- // .
- // TR:
- // Source: Internal focus groups
- // TR:
- // Illustrative Example
- // .
+ // On slide three, we should have:
+ // TR:
+ // You are an important supplier of various items that I need
+ // .
+ // TR:
+ // Source: Internal focus groups
+ // TR:
+ // Illustrative Example
+ // .
List> s3tr = slideThreeC.getTextParagraphs();
- List s3rtr0 = s3tr.get(0).get(0).getTextRuns();
- List s3rtr1 = s3tr.get(2).get(0).getTextRuns();
- List s3rtr2 = s3tr.get(3).get(0).getTextRuns();
+ List s3rtr0 = s3tr.get(0).get(0).getTextRuns();
+ List s3rtr1 = s3tr.get(2).get(0).getTextRuns();
+ List s3rtr2 = s3tr.get(3).get(0).getTextRuns();
- assertEquals(2, s3rtr0.size());
- assertEquals(1, s3rtr1.size());
- assertEquals(2, s3rtr2.size());
+ assertEquals(2, s3rtr0.size());
+ assertEquals(1, s3rtr1.size());
+ assertEquals(2, s3rtr2.size());
- assertEquals("You are an important supplier of various items that I need", s3rtr0.get(0).getRawText());
- assertEquals("", s3rtr0.get(1).getRawText());
- assertEquals("Source: Internal focus groups", s3rtr1.get(0).getRawText());
- assertEquals("Illustrative Example", s3rtr2.get(0).getRawText());
- assertEquals("", s3rtr2.get(1).getRawText());
+ assertEquals("You are an important supplier of various items that I need", s3rtr0.get(0).getRawText());
+ assertEquals("", s3rtr0.get(1).getRawText());
+ assertEquals("Source: Internal focus groups", s3rtr1.get(0).getRawText());
+ assertEquals("Illustrative Example", s3rtr2.get(0).getRawText());
+ assertEquals("", s3rtr2.get(1).getRawText());
- // On slide seven, we have:
- // TR:
- // (text)
- // TR:
- // (text a)(text a)(text b)
- // TR:
- // (text)
- List> s7tr = slideSevenC.getTextParagraphs();
- List s7rtr0 = s7tr.get(0);
- List s7rtr1 = s7tr.get(1);
- List s7rtr2 = s7tr.get(2);
+ // On slide seven, we have:
+ // TR:
+ // (text)
+ // TR:
+ // (text a)(text a)(text b)
+ // TR:
+ // (text)
+ List> s7tr = slideSevenC.getTextParagraphs();
+ List s7rtr0 = s7tr.get(0);
+ List s7rtr1 = s7tr.get(1);
+ List s7rtr2 = s7tr.get(2);
- assertEquals(1, s7rtr0.size());
- assertEquals(8, s7rtr1.size());
- assertEquals(1, s7rtr2.size());
- }
+ assertEquals(1, s7rtr0.size());
+ assertEquals(8, s7rtr1.size());
+ assertEquals(1, s7rtr2.size());
+ }
- /**
- * Test that we can do the right things when the paragraph styles
- * run out before the character styles do, when we tweak something
- * and write back out.
- */
+ /**
+ * Test that we can do the right things when the paragraph styles
+ * run out before the character styles do, when we tweak something
+ * and write back out.
+ */
@Test
- @SuppressWarnings("unused")
+ @SuppressWarnings("unused")
void testParagraphStylesShorterTheCharStylesWrite() throws IOException {
- assertMatchesSLTWC(ssRichC);
- assertMatchesFileC(ssRichC);
+ assertMatchesSLTWC(ssRichC);
+ assertMatchesFileC(ssRichC);
- HSLFSlide slideSevenC = ssRichC.getSlides().get(6);
- List> s7tr = slideSevenC.getTextParagraphs();
- List s7rtr0 = s7tr.get(0).get(0).getTextRuns();
- List s7rtr1 = s7tr.get(1).get(0).getTextRuns();
- List s7rtr2 = s7tr.get(2).get(0).getTextRuns();
+ HSLFSlide slideSevenC = ssRichC.getSlides().get(6);
+ List> s7tr = slideSevenC.getTextParagraphs();
+ List s7rtr0 = s7tr.get(0).get(0).getTextRuns();
+ List s7rtr1 = s7tr.get(1).get(0).getTextRuns();
+ List s7rtr2 = s7tr.get(2).get(0).getTextRuns();
- String oldText;
+ String oldText;
- // Reset the text on the last run
- // Need to ensure it's a run that really has styles!
- oldText = s7rtr2.get(0).getRawText();
- s7rtr2.get(0).setText( oldText );
- HSLFTextParagraph.storeText(s7tr.get(2));
- assertEquals(oldText, s7rtr2.get(0).getRawText());
- assertEquals(oldText, HSLFTextParagraph.getRawText(s7tr.get(2)));
- assertEquals(oldText.length() + 1, s7rtr2.get(0).getCharacterStyle().getCharactersCovered());
- assertEquals(oldText.length() + 1, s7rtr2.get(0).getTextParagraph().getParagraphStyle().getCharactersCovered());
- assertMatchesSLTWC(ssRichC);
- assertMatchesFileC(ssRichC);
+ // Reset the text on the last run
+ // Need to ensure it's a run that really has styles!
+ oldText = s7rtr2.get(0).getRawText();
+ s7rtr2.get(0).setText( oldText );
+ HSLFTextParagraph.storeText(s7tr.get(2));
+ assertEquals(oldText, s7rtr2.get(0).getRawText());
+ assertEquals(oldText, HSLFTextParagraph.getRawText(s7tr.get(2)));
+ assertEquals(oldText.length() + 1, s7rtr2.get(0).getCharacterStyle().getCharactersCovered());
+ assertEquals(oldText.length() + 1, s7rtr2.get(0).getTextParagraph().getParagraphStyle().getCharactersCovered());
+ assertMatchesSLTWC(ssRichC);
+ assertMatchesFileC(ssRichC);
- // Reset the text on a shared paragraph
- oldText = s7rtr1.get(0).getRawText();
- s7rtr1.get(0).setText( oldText );
+ // Reset the text on a shared paragraph
+ oldText = s7rtr1.get(0).getRawText();
+ s7rtr1.get(0).setText( oldText );
HSLFTextParagraph.storeText(s7tr.get(1));
- assertEquals(oldText, s7rtr1.get(0).getRawText());
- assertEquals(oldText.length(), s7rtr1.get(0).getCharacterStyle().getCharactersCovered());
- assertMatchesSLTWC(ssRichC);
- assertMatchesFileC(ssRichC);
+ assertEquals(oldText, s7rtr1.get(0).getRawText());
+ assertEquals(oldText.length(), s7rtr1.get(0).getCharacterStyle().getCharactersCovered());
+ assertMatchesSLTWC(ssRichC);
+ assertMatchesFileC(ssRichC);
- // Reset the text on a shared paragraph+character
- s7rtr1.get(0).setText( s7rtr1.get(0).getRawText() );
- HSLFTextParagraph.storeText(s7tr.get(1));
- assertMatchesSLTWC(ssRichC);
- assertMatchesFileC(ssRichC);
- }
+ // Reset the text on a shared paragraph+character
+ s7rtr1.get(0).setText( s7rtr1.get(0).getRawText() );
+ HSLFTextParagraph.storeText(s7tr.get(1));
+ assertMatchesSLTWC(ssRichC);
+ assertMatchesFileC(ssRichC);
+ }
- /**
- * Opens a new copy of SlideShow C, writes the active
- * SlideListWithText out, and compares it to the write
- * out of the supplied SlideShow. Also compares the
- * contents.
- */
- private void assertMatchesSLTWC(HSLFSlideShow s) throws IOException {
- // Grab a new copy of slideshow C
- try (HSLFSlideShow refC = HSLFTestDataSamples.getSlideShow(filenameC)) {
+ /**
+ * Opens a new copy of SlideShow C, writes the active
+ * SlideListWithText out, and compares it to the write
+ * out of the supplied SlideShow. Also compares the
+ * contents.
+ */
+ private void assertMatchesSLTWC(HSLFSlideShow s) throws IOException {
+ // Grab a new copy of slideshow C
+ try (HSLFSlideShow refC = HSLFTestDataSamples.getSlideShow(filenameC)) {
- // Write out the 2nd SLWT in the active document
- SlideListWithText refSLWT = refC.getDocumentRecord().getSlideListWithTexts()[1];
- byte[] raw_slwt = writeRecord(refSLWT);
+ // Write out the 2nd SLWT in the active document
+ SlideListWithText refSLWT = refC.getDocumentRecord().getSlideListWithTexts()[1];
+ byte[] raw_slwt = writeRecord(refSLWT);
- // Write out the same for the supplied slideshow
- SlideListWithText s_SLWT = s.getDocumentRecord().getSlideListWithTexts()[1];
- byte[] s_slwt = writeRecord(s_SLWT);
+ // Write out the same for the supplied slideshow
+ SlideListWithText s_SLWT = s.getDocumentRecord().getSlideListWithTexts()[1];
+ byte[] s_slwt = writeRecord(s_SLWT);
- // Check the records are the same
- assertEquals(refSLWT.getChildRecords().length, s_SLWT.getChildRecords().length);
- for (int i = 0; i < refSLWT.getChildRecords().length; i++) {
- Record ref_r = refSLWT.getChildRecords()[i];
- Record s_r = s_SLWT.getChildRecords()[i];
+ // Check the records are the same
+ assertEquals(refSLWT.getChildRecords().length, s_SLWT.getChildRecords().length);
+ for (int i = 0; i < refSLWT.getChildRecords().length; i++) {
+ Record ref_r = refSLWT.getChildRecords()[i];
+ Record s_r = s_SLWT.getChildRecords()[i];
- byte[] r_rb = writeRecord(ref_r);
- byte[] s_rb = writeRecord(s_r);
- assertArrayEquals(r_rb, s_rb);
- }
+ byte[] r_rb = writeRecord(ref_r);
+ byte[] s_rb = writeRecord(s_r);
+ assertArrayEquals(r_rb, s_rb);
+ }
- // Check the bytes are the same
- assertArrayEquals(raw_slwt, s_slwt);
- }
- }
+ // Check the bytes are the same
+ assertArrayEquals(raw_slwt, s_slwt);
+ }
+ }
- /**
- * Checks that the supplied slideshow still matches the bytes
- * of slideshow c
- */
- private static void assertMatchesFileC(HSLFSlideShow s) throws IOException {
- // Grab the bytes of the file
- byte[] raw_file;
- try (POIFSFileSystem fs = new POIFSFileSystem(HSLFTestDataSamples.openSampleFileStream(filenameC));
- InputStream is = fs.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT)) {
- raw_file = IOUtils.toByteArray(is);
- }
+ /**
+ * Checks that the supplied slideshow still matches the bytes
+ * of slideshow c
+ */
+ private static void assertMatchesFileC(HSLFSlideShow s) throws IOException {
+ // Grab the bytes of the file
+ byte[] raw_file;
+ try (POIFSFileSystem fs = new POIFSFileSystem(HSLFTestDataSamples.openSampleFileStream(filenameC));
+ InputStream is = fs.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT)) {
+ raw_file = IOUtils.toByteArray(is);
+ }
- // Now write out the slideshow
- byte[] raw_ss;
+ // Now write out the slideshow
+ byte[] raw_ss;
UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- s.write(baos);
- try (POIFSFileSystem fs = new POIFSFileSystem(baos.toInputStream());
- InputStream is = fs.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT)) {
- raw_ss = IOUtils.toByteArray(is);
- }
+ s.write(baos);
+ try (POIFSFileSystem fs = new POIFSFileSystem(baos.toInputStream());
+ InputStream is = fs.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT)) {
+ raw_ss = IOUtils.toByteArray(is);
+ }
- // different paragraph mask, because of sanitizing
- raw_ss[169030] = 0x0a;
+ // different paragraph mask, because of sanitizing
+ raw_ss[169030] = 0x0a;
- // Ensure they're the same
- assertArrayEquals(raw_file, raw_ss);
- }
+ // Ensure they're the same
+ assertArrayEquals(raw_file, raw_ss);
+ }
- private byte[] writeRecord( org.apache.poi.hslf.record.Record r) throws IOException {
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- r.writeOut(baos);
- return baos.toByteArray();
- }
+ private byte[] writeRecord( org.apache.poi.hslf.record.Record r) throws IOException {
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ r.writeOut(baos);
+ return baos.toByteArray();
+ }
@Test
- void testIndentationLevel() throws Exception {
- try (HSLFSlideShow ppt = HSLFTestDataSamples.getSlideShow("ParagraphStylesShorterThanCharStyles.ppt")) {
- for (HSLFSlide sl : ppt.getSlides()) {
- for (List txt : sl.getTextParagraphs()) {
- for (HSLFTextParagraph p : txt) {
- int indent = p.getIndentLevel();
- assertTrue(indent >= 0 && indent <= 4);
- }
+ void testIndentationLevel() throws Exception {
+ try (HSLFSlideShow ppt = HSLFTestDataSamples.getSlideShow("ParagraphStylesShorterThanCharStyles.ppt")) {
+ for (HSLFSlide sl : ppt.getSlides()) {
+ for (List txt : sl.getTextParagraphs()) {
+ for (HSLFTextParagraph p : txt) {
+ int indent = p.getIndentLevel();
+ assertTrue(indent >= 0 && indent <= 4);
+ }
- }
- }
- }
- }
+ }
+ }
+ }
+ }
@Test
- void testReadParagraphStyles() throws Exception {
- try (HSLFSlideShow ppt = HSLFTestDataSamples.getSlideShow("bullets.ppt")) {
- HSLFTextParagraph rt;
- List> txt;
- List slide = ppt.getSlides();
- assertEquals(2, slide.size());
+ void testReadParagraphStyles() throws Exception {
+ try (HSLFSlideShow ppt = HSLFTestDataSamples.getSlideShow("bullets.ppt")) {
+ HSLFTextParagraph rt;
+ List> txt;
+ List slide = ppt.getSlides();
+ assertEquals(2, slide.size());
- txt = slide.get(0).getTextParagraphs();
- assertEquals(2, txt.size());
+ txt = slide.get(0).getTextParagraphs();
+ assertEquals(2, txt.size());
- assertEquals("Title text", HSLFTextParagraph.getRawText(txt.get(0)));
- assertEquals(1, txt.get(0).size());
- rt = txt.get(0).get(0);
- assertFalse(rt.isBullet());
+ assertEquals("Title text", HSLFTextParagraph.getRawText(txt.get(0)));
+ assertEquals(1, txt.get(0).size());
+ rt = txt.get(0).get(0);
+ assertFalse(rt.isBullet());
- String expected =
- "This is a text placeholder that \r" +
- "follows the design pattern\r" +
- "Defined in the slide master\r" +
- "and has bullets by default";
- assertEquals(expected, HSLFTextParagraph.getRawText(txt.get(1)));
- assertEquals(4, txt.get(1).size());
- rt = txt.get(1).get(0);
- assertNotNull(rt.getBulletChar());
- assertEquals('\u2022', (char) rt.getBulletChar());
- assertTrue(rt.isBullet());
+ String expected =
+ "This is a text placeholder that \r" +
+ "follows the design pattern\r" +
+ "Defined in the slide master\r" +
+ "and has bullets by default";
+ assertEquals(expected, HSLFTextParagraph.getRawText(txt.get(1)));
+ assertEquals(4, txt.get(1).size());
+ rt = txt.get(1).get(0);
+ assertNotNull(rt.getBulletChar());
+ assertEquals('\u2022', (char) rt.getBulletChar());
+ assertTrue(rt.isBullet());
- txt = slide.get(1).getTextParagraphs();
- assertEquals(2, txt.size());
+ txt = slide.get(1).getTextParagraphs();
+ assertEquals(2, txt.size());
- expected =
- "I\u2019m a text box\r" +
- "With bullets\r" +
- "That follow the design pattern\r" +
- "From the slide master";
- assertEquals(expected, HSLFTextParagraph.getRawText(txt.get(0)));
- assertEquals(4, txt.get(0).size());
- rt = txt.get(0).get(0);
- assertTrue(rt.isBullet());
- assertNotNull(rt.getBulletChar());
- assertEquals('\u2022', (char) rt.getBulletChar());
+ expected =
+ "I\u2019m a text box\r" +
+ "With bullets\r" +
+ "That follow the design pattern\r" +
+ "From the slide master";
+ assertEquals(expected, HSLFTextParagraph.getRawText(txt.get(0)));
+ assertEquals(4, txt.get(0).size());
+ rt = txt.get(0).get(0);
+ assertTrue(rt.isBullet());
+ assertNotNull(rt.getBulletChar());
+ assertEquals('\u2022', (char) rt.getBulletChar());
- expected =
- "I\u2019m a text box with user-defined\r" +
- "bullet character";
- assertEquals(expected, HSLFTextParagraph.getRawText(txt.get(1)));
- assertEquals(2, txt.get(1).size());
- rt = txt.get(1).get(0);
- assertTrue(rt.isBullet());
- assertNotNull(rt.getBulletChar());
- assertEquals('\u263A', (char) rt.getBulletChar());
- }
- }
+ expected =
+ "I\u2019m a text box with user-defined\r" +
+ "bullet character";
+ assertEquals(expected, HSLFTextParagraph.getRawText(txt.get(1)));
+ assertEquals(2, txt.get(1).size());
+ rt = txt.get(1).get(0);
+ assertTrue(rt.isBullet());
+ assertNotNull(rt.getBulletChar());
+ assertEquals('\u263A', (char) rt.getBulletChar());
+ }
+ }
@Test
- void testSetParagraphStyles() throws IOException {
- try (HSLFSlideShow ppt1 = new HSLFSlideShow()) {
+ void testSetParagraphStyles() throws IOException {
+ try (HSLFSlideShow ppt1 = new HSLFSlideShow()) {
- HSLFSlide slide = ppt1.createSlide();
+ HSLFSlide slide = ppt1.createSlide();
- HSLFTextBox shape = new HSLFTextBox();
- shape.setText(
- "Hello, World!\r" +
- "This should be\r" +
- "Multiline text");
- HSLFTextParagraph rt = shape.getTextParagraphs().get(0);
- HSLFTextRun tr = rt.getTextRuns().get(0);
- tr.setFontSize(42d);
- rt.setBullet(true);
- rt.setLeftMargin(50d);
- rt.setIndent(0d);
- rt.setBulletChar('\u263A');
- slide.addShape(shape);
+ HSLFTextBox shape = new HSLFTextBox();
+ shape.setText(
+ "Hello, World!\r" +
+ "This should be\r" +
+ "Multiline text");
+ HSLFTextParagraph rt = shape.getTextParagraphs().get(0);
+ HSLFTextRun tr = rt.getTextRuns().get(0);
+ tr.setFontSize(42d);
+ rt.setBullet(true);
+ rt.setLeftMargin(50d);
+ rt.setIndent(0d);
+ rt.setBulletChar('\u263A');
+ slide.addShape(shape);
- assertNotNull(tr.getFontSize());
- assertEquals(42.0, tr.getFontSize(), 0);
- assertTrue(rt.isBullet());
- assertNotNull(rt.getLeftMargin());
- assertEquals(50.0, rt.getLeftMargin(), 0);
- assertNotNull(rt.getIndent());
- assertEquals(0, rt.getIndent(), 0);
- assertNotNull(rt.getBulletChar());
- assertEquals('\u263A', (char) rt.getBulletChar());
+ assertNotNull(tr.getFontSize());
+ assertEquals(42.0, tr.getFontSize(), 0);
+ assertTrue(rt.isBullet());
+ assertNotNull(rt.getLeftMargin());
+ assertEquals(50.0, rt.getLeftMargin(), 0);
+ assertNotNull(rt.getIndent());
+ assertEquals(0, rt.getIndent(), 0);
+ assertNotNull(rt.getBulletChar());
+ assertEquals('\u263A', (char) rt.getBulletChar());
- shape.setAnchor(new java.awt.Rectangle(50, 50, 500, 300));
- slide.addShape(shape);
+ shape.setAnchor(new java.awt.Rectangle(50, 50, 500, 300));
+ slide.addShape(shape);
- //serialize and read again
- try (HSLFSlideShow ppt2 = HSLFTestDataSamples.writeOutAndReadBack(ppt1)) {
- slide = ppt2.getSlides().get(0);
- shape = (HSLFTextBox) slide.getShapes().get(0);
- rt = shape.getTextParagraphs().get(0);
- tr = rt.getTextRuns().get(0);
- assertNotNull(tr.getFontSize());
- assertEquals(42.0, tr.getFontSize(), 0);
- assertTrue(rt.isBullet());
- assertNotNull(rt.getLeftMargin());
- assertEquals(50.0, rt.getLeftMargin(), 0);
- assertNotNull(rt.getIndent());
- assertEquals(0, rt.getIndent(), 0);
- assertNotNull(rt.getBulletChar());
- assertEquals('\u263A', (char) rt.getBulletChar());
- }
- }
- }
+ //serialize and read again
+ try (HSLFSlideShow ppt2 = HSLFTestDataSamples.writeOutAndReadBack(ppt1)) {
+ slide = ppt2.getSlides().get(0);
+ shape = (HSLFTextBox) slide.getShapes().get(0);
+ rt = shape.getTextParagraphs().get(0);
+ tr = rt.getTextRuns().get(0);
+ assertNotNull(tr.getFontSize());
+ assertEquals(42.0, tr.getFontSize(), 0);
+ assertTrue(rt.isBullet());
+ assertNotNull(rt.getLeftMargin());
+ assertEquals(50.0, rt.getLeftMargin(), 0);
+ assertNotNull(rt.getIndent());
+ assertEquals(0, rt.getIndent(), 0);
+ assertNotNull(rt.getBulletChar());
+ assertEquals('\u263A', (char) rt.getBulletChar());
+ }
+ }
+ }
@Test
- void testAddText() throws Exception {
- try (HSLFSlideShow ppt1 = HSLFTestDataSamples.getSlideShow("bullets.ppt")) {
+ void testAddText() throws Exception {
+ try (HSLFSlideShow ppt1 = HSLFTestDataSamples.getSlideShow("bullets.ppt")) {
- HSLFTextParagraph rt;
- HSLFTextRun tr;
- List> txt;
- List slides = ppt1.getSlides();
+ HSLFTextParagraph rt;
+ HSLFTextRun tr;
+ List> txt;
+ List slides = ppt1.getSlides();
- assertEquals(2, slides.size());
- txt = slides.get(0).getTextParagraphs();
- assertEquals(2, txt.size());
+ assertEquals(2, slides.size());
+ txt = slides.get(0).getTextParagraphs();
+ assertEquals(2, txt.size());
- assertEquals("Title text", HSLFTextParagraph.getRawText(txt.get(0)));
- assertEquals(1, txt.get(0).size());
- rt = txt.get(0).get(0);
- assertFalse(rt.isBullet());
+ assertEquals("Title text", HSLFTextParagraph.getRawText(txt.get(0)));
+ assertEquals(1, txt.get(0).size());
+ rt = txt.get(0).get(0);
+ assertFalse(rt.isBullet());
- // Add some new text
- HSLFTextParagraph.appendText(txt.get(0), "Foo! I'm new!", true);
- assertEquals(2, txt.get(0).size());
+ // Add some new text
+ HSLFTextParagraph.appendText(txt.get(0), "Foo! I'm new!", true);
+ assertEquals(2, txt.get(0).size());
- rt = txt.get(0).get(0);
- tr = rt.getTextRuns().get(0);
- assertFalse(tr.isBold());
- assertEquals("Title text\r", tr.getRawText());
- rt = txt.get(0).get(1);
- tr = rt.getTextRuns().get(0);
- assertFalse(tr.isBold());
- assertEquals("Foo! I'm new!", tr.getRawText());
- tr.setBold(true);
- HSLFTextParagraph.storeText(txt.get(0));
+ rt = txt.get(0).get(0);
+ tr = rt.getTextRuns().get(0);
+ assertFalse(tr.isBold());
+ assertEquals("Title text\r", tr.getRawText());
+ rt = txt.get(0).get(1);
+ tr = rt.getTextRuns().get(0);
+ assertFalse(tr.isBold());
+ assertEquals("Foo! I'm new!", tr.getRawText());
+ tr.setBold(true);
+ HSLFTextParagraph.storeText(txt.get(0));
- // And some more, attributes will be copied from previous run
- HSLFTextParagraph.appendText(txt.get(0), "Me too!", true);
- HSLFTextParagraph.storeText(txt.get(0));
- assertEquals(3, txt.get(0).size());
- rt = txt.get(0).get(0);
- tr = rt.getTextRuns().get(0);
- assertFalse(tr.isBold());
- assertEquals("Title text\r", tr.getRawText());
- rt = txt.get(0).get(1);
- tr = rt.getTextRuns().get(0);
- assertTrue(tr.isBold());
- assertEquals("Foo! I'm new!\r", tr.getRawText());
- rt = txt.get(0).get(2);
- tr = rt.getTextRuns().get(0);
- assertTrue(tr.isBold());
- assertEquals("Me too!", tr.getRawText());
+ // And some more, attributes will be copied from previous run
+ HSLFTextParagraph.appendText(txt.get(0), "Me too!", true);
+ HSLFTextParagraph.storeText(txt.get(0));
+ assertEquals(3, txt.get(0).size());
+ rt = txt.get(0).get(0);
+ tr = rt.getTextRuns().get(0);
+ assertFalse(tr.isBold());
+ assertEquals("Title text\r", tr.getRawText());
+ rt = txt.get(0).get(1);
+ tr = rt.getTextRuns().get(0);
+ assertTrue(tr.isBold());
+ assertEquals("Foo! I'm new!\r", tr.getRawText());
+ rt = txt.get(0).get(2);
+ tr = rt.getTextRuns().get(0);
+ assertTrue(tr.isBold());
+ assertEquals("Me too!", tr.getRawText());
- // Save and re-open
- try (HSLFSlideShow ppt2 = HSLFTestDataSamples.writeOutAndReadBack(ppt1)) {
- slides = ppt2.getSlides();
+ // Save and re-open
+ try (HSLFSlideShow ppt2 = HSLFTestDataSamples.writeOutAndReadBack(ppt1)) {
+ slides = ppt2.getSlides();
- assertEquals(2, slides.size());
+ assertEquals(2, slides.size());
- txt = slides.get(0).getTextParagraphs();
- assertEquals(2, txt.size());
- assertEquals(3, txt.get(0).size());
- rt = txt.get(0).get(0);
- tr = rt.getTextRuns().get(0);
- assertFalse(tr.isBold());
- assertEquals("Title text\r", tr.getRawText());
- rt = txt.get(0).get(1);
- tr = rt.getTextRuns().get(0);
- assertTrue(tr.isBold());
- assertEquals("Foo! I'm new!\r", tr.getRawText());
- rt = txt.get(0).get(2);
- tr = rt.getTextRuns().get(0);
- assertTrue(tr.isBold());
- assertEquals("Me too!", tr.getRawText());
- }
- }
- }
+ txt = slides.get(0).getTextParagraphs();
+ assertEquals(2, txt.size());
+ assertEquals(3, txt.get(0).size());
+ rt = txt.get(0).get(0);
+ tr = rt.getTextRuns().get(0);
+ assertFalse(tr.isBold());
+ assertEquals("Title text\r", tr.getRawText());
+ rt = txt.get(0).get(1);
+ tr = rt.getTextRuns().get(0);
+ assertTrue(tr.isBold());
+ assertEquals("Foo! I'm new!\r", tr.getRawText());
+ rt = txt.get(0).get(2);
+ tr = rt.getTextRuns().get(0);
+ assertTrue(tr.isBold());
+ assertEquals("Me too!", tr.getRawText());
+ }
+ }
+ }
@Test
- void testChineseParagraphs() {
+ void testChineseParagraphs() {
List rts;
HSLFTextRun rt;
List> txt;
@@ -659,5 +659,5 @@ public final class TestRichTextRun {
// Font is Calibri
assertEquals("Calibri", rt.getFontFamily());
- }
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestSheetText.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestSheetText.java
index a2c0469bc1..b6f93ec228 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestSheetText.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestSheetText.java
@@ -31,66 +31,66 @@ import org.junit.jupiter.api.Test;
* Tests that SlideShow returns Sheets which have the right text in them
*/
public final class TestSheetText {
- // SlideShow primed on the test data
- private HSLFSlideShow ss;
+ // SlideShow primed on the test data
+ private HSLFSlideShow ss;
- @BeforeEach
- void init() throws IOException {
- ss = HSLFTestDataSamples.getSlideShow("basic_test_ppt_file.ppt");
- }
+ @BeforeEach
+ void init() throws IOException {
+ ss = HSLFTestDataSamples.getSlideShow("basic_test_ppt_file.ppt");
+ }
- @AfterEach
- void tearDown() throws IOException {
- ss.close();
- }
+ @AfterEach
+ void tearDown() throws IOException {
+ ss.close();
+ }
- @Test
- void testSheetOne() {
- HSLFSheet slideOne = ss.getSlides().get(0);
+ @Test
+ void testSheetOne() {
+ HSLFSheet slideOne = ss.getSlides().get(0);
- String[] expectText = new String[] {"This is a test title","This is a test subtitle\rThis is on page 1"};
- assertEquals(expectText.length, slideOne.getTextParagraphs().size());
- int i = 0;
- for(List textParas : slideOne.getTextParagraphs()) {
- assertEquals(expectText[i++], HSLFTextParagraph.getRawText(textParas));
- }
- }
+ String[] expectText = new String[] {"This is a test title","This is a test subtitle\rThis is on page 1"};
+ assertEquals(expectText.length, slideOne.getTextParagraphs().size());
+ int i = 0;
+ for(List textParas : slideOne.getTextParagraphs()) {
+ assertEquals(expectText[i++], HSLFTextParagraph.getRawText(textParas));
+ }
+ }
- void testSheetTwo() {
- HSLFSheet slideTwo = ss.getSlides().get(1);
- String[] expectText = new String[] {"This is the title on page 2","This is page two\rIt has several blocks of text\rNone of them have formatting"};
- assertEquals(expectText.length, slideTwo.getTextParagraphs().size());
+ void testSheetTwo() {
+ HSLFSheet slideTwo = ss.getSlides().get(1);
+ String[] expectText = new String[] {"This is the title on page 2","This is page two\rIt has several blocks of text\rNone of them have formatting"};
+ assertEquals(expectText.length, slideTwo.getTextParagraphs().size());
int i = 0;
for(List textParas : slideTwo.getTextParagraphs()) {
assertEquals(expectText[i++], HSLFTextParagraph.getRawText(textParas));
}
- }
+ }
- /**
- * Check we can still get the text from a file where the
- * TextProps don't have enough data.
- * (Make sure we don't screw up / throw an exception etc)
- */
- void testWithShortTextPropData() throws IOException {
- HSLFSlideShow sss = HSLFTestDataSamples.getSlideShow("iisd_report.ppt");
+ /**
+ * Check we can still get the text from a file where the
+ * TextProps don't have enough data.
+ * (Make sure we don't screw up / throw an exception etc)
+ */
+ void testWithShortTextPropData() throws IOException {
+ HSLFSlideShow sss = HSLFTestDataSamples.getSlideShow("iisd_report.ppt");
- // Should come out with 10 slides, no notes
- assertEquals(10, sss.getSlides().size());
- assertEquals(0, sss.getNotes().size());
+ // Should come out with 10 slides, no notes
+ assertEquals(10, sss.getSlides().size());
+ assertEquals(0, sss.getNotes().size());
- // Check text on first slide
- HSLFSlide s = sss.getSlides().get(0);
- String exp =
- "Realizing the Development Dividend:\n" +
- "Community Capacity Building and CDM.\n" +
- "Can they co-exist?\n\n" +
- "Gay Harley\n" +
- "Clean Development Alliance\n" +
- "COP 11 \u2013 MOP 1\n" + // special long hyphen
- "December 5, 2005\n";
+ // Check text on first slide
+ HSLFSlide s = sss.getSlides().get(0);
+ String exp =
+ "Realizing the Development Dividend:\n" +
+ "Community Capacity Building and CDM.\n" +
+ "Can they co-exist?\n\n" +
+ "Gay Harley\n" +
+ "Clean Development Alliance\n" +
+ "COP 11 \u2013 MOP 1\n" + // special long hyphen
+ "December 5, 2005\n";
- assertEquals(1, s.getTextParagraphs().size());
- assertEquals(exp, HSLFTextParagraph.getRawText(s.getTextParagraphs().get(0)));
- sss.close();
- }
+ assertEquals(1, s.getTextParagraphs().size());
+ assertEquals(exp, HSLFTextParagraph.getRawText(s.getTextParagraphs().get(0)));
+ sss.close();
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestSlideOrdering.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestSlideOrdering.java
index 0a5df4dde3..c4b2853642 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestSlideOrdering.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestSlideOrdering.java
@@ -31,104 +31,104 @@ import org.junit.jupiter.api.Test;
* Tests that SlideShow returns Sheets in the right order
*/
public final class TestSlideOrdering {
- // Simple slideshow, record order matches slide order
- private HSLFSlideShow ssA;
- // Complex slideshow, record order doesn't match slide order
- private HSLFSlideShow ssB;
+ // Simple slideshow, record order matches slide order
+ private HSLFSlideShow ssA;
+ // Complex slideshow, record order doesn't match slide order
+ private HSLFSlideShow ssB;
- @BeforeEach
- void init() throws IOException {
- ssA = HSLFTestDataSamples.getSlideShow("basic_test_ppt_file.ppt");
- ssB = HSLFTestDataSamples.getSlideShow("incorrect_slide_order.ppt");
- }
+ @BeforeEach
+ void init() throws IOException {
+ ssA = HSLFTestDataSamples.getSlideShow("basic_test_ppt_file.ppt");
+ ssB = HSLFTestDataSamples.getSlideShow("incorrect_slide_order.ppt");
+ }
- @AfterEach
- void tearDown() throws IOException {
- ssA.close();
- ssB.close();
- }
+ @AfterEach
+ void tearDown() throws IOException {
+ ssA.close();
+ ssB.close();
+ }
- /**
- * Test the simple case - record order matches slide order
- */
- @Test
- void testSimpleCase() {
- assertEquals(2, ssA.getSlides().size());
-
- HSLFSlide s1 = ssA.getSlides().get(0);
- HSLFSlide s2 = ssA.getSlides().get(1);
-
- String[] firstTRs = new String[] { "This is a test title", "This is the title on page 2" };
-
- assertEquals(firstTRs[0], HSLFTextParagraph.getRawText(s1.getTextParagraphs().get(0)));
- assertEquals(firstTRs[1], HSLFTextParagraph.getRawText(s2.getTextParagraphs().get(0)));
- }
-
- /**
- * Test the complex case - record order differs from slide order
- */
+ /**
+ * Test the simple case - record order matches slide order
+ */
@Test
- void testComplexCase() {
- assertEquals(3, ssB.getSlides().size());
- int i=1;
- for (HSLFSlide s : ssB.getSlides()) {
- assertEquals("Slide "+(i++), HSLFTextParagraph.getRawText(s.getTextParagraphs().get(0)));
- }
- }
+ void testSimpleCase() {
+ assertEquals(2, ssA.getSlides().size());
- /**
- * Assert that the order of slides is correct.
- *
- * @param filename
- * file name of the slide show to assert
- * @param titles
- * array of reference slide titles
- */
- protected void assertSlideOrdering(String filename, String[] titles) throws IOException {
+ HSLFSlide s1 = ssA.getSlides().get(0);
+ HSLFSlide s2 = ssA.getSlides().get(1);
+
+ String[] firstTRs = new String[] { "This is a test title", "This is the title on page 2" };
+
+ assertEquals(firstTRs[0], HSLFTextParagraph.getRawText(s1.getTextParagraphs().get(0)));
+ assertEquals(firstTRs[1], HSLFTextParagraph.getRawText(s2.getTextParagraphs().get(0)));
+ }
+
+ /**
+ * Test the complex case - record order differs from slide order
+ */
+ @Test
+ void testComplexCase() {
+ assertEquals(3, ssB.getSlides().size());
+ int i=1;
+ for (HSLFSlide s : ssB.getSlides()) {
+ assertEquals("Slide "+(i++), HSLFTextParagraph.getRawText(s.getTextParagraphs().get(0)));
+ }
+ }
+
+ /**
+ * Assert that the order of slides is correct.
+ *
+ * @param filename
+ * file name of the slide show to assert
+ * @param titles
+ * array of reference slide titles
+ */
+ protected void assertSlideOrdering(String filename, String[] titles) throws IOException {
HSLFSlideShow ppt = HSLFTestDataSamples.getSlideShow(filename);
- List slide = ppt.getSlides();
+ List slide = ppt.getSlides();
- assertEquals(titles.length, slide.size());
- for (int i = 0; i < slide.size(); i++) {
- String title = slide.get(i).getTitle();
- assertEquals(titles[i], title, "Wrong slide title in " + filename);
- }
- ppt.close();
- }
+ assertEquals(titles.length, slide.size());
+ for (int i = 0; i < slide.size(); i++) {
+ String title = slide.get(i).getTitle();
+ assertEquals(titles[i], title, "Wrong slide title in " + filename);
+ }
+ ppt.close();
+ }
@Test
- void testTitles() throws Exception {
- assertSlideOrdering("basic_test_ppt_file.ppt", new String[] {
- "This is a test title", "This is the title on page 2" });
+ void testTitles() throws Exception {
+ assertSlideOrdering("basic_test_ppt_file.ppt", new String[] {
+ "This is a test title", "This is the title on page 2" });
- assertSlideOrdering("incorrect_slide_order.ppt", new String[] { "Slide 1",
- "Slide 2", "Slide 3" });
+ assertSlideOrdering("incorrect_slide_order.ppt", new String[] { "Slide 1",
+ "Slide 2", "Slide 3" });
- assertSlideOrdering("next_test_ppt_file.ppt", new String[] {
- "This is a test title", "This is the title on page 2" });
+ assertSlideOrdering("next_test_ppt_file.ppt", new String[] {
+ "This is a test title", "This is the title on page 2" });
- assertSlideOrdering("Single_Coloured_Page.ppt",
- new String[] { "This is a title, it" + (char) 0x2019 + "s in black" });
+ assertSlideOrdering("Single_Coloured_Page.ppt",
+ new String[] { "This is a title, it" + (char) 0x2019 + "s in black" });
- assertSlideOrdering("Single_Coloured_Page_With_Fonts_and_Alignments.ppt",
- new String[] { "This is a title, it" + (char) 0x2019 + "s in black" });
+ assertSlideOrdering("Single_Coloured_Page_With_Fonts_and_Alignments.ppt",
+ new String[] { "This is a title, it" + (char) 0x2019 + "s in black" });
- assertSlideOrdering(
- "ParagraphStylesShorterThanCharStyles.ppt",
- new String[] {
- "ROMANCE: AN ANALYSIS",
- "AGENDA",
- "You are an important supplier of various items that I need",
- '\n' + "Although The Psycho set back my relationship process, recovery is luckily enough under way",
- "Since the time that we seriously go out together, you rank highly among existing relationships",
- "Although our personal interests are mostly compatible, the greatest gap exists in Sex and Shopping",
- "Your physical characteristics are strong when compared with your competition",
- "The combination of your high physical appearance and personality rank you highly, although your sister is also a top prospect",
- "When people found out that we were going out, their responses have been mixed",
- "The benchmark of relationship lifecycles, suggests that we are on schedule",
- "In summary we can say that we are on the right track, but we must remain aware of possible roadblocks ",
- "THE ANSWER",
- "Unfortunately a huge disconnect exists between my needs and your existing service",
- "SUMMARY", });
- }
+ assertSlideOrdering(
+ "ParagraphStylesShorterThanCharStyles.ppt",
+ new String[] {
+ "ROMANCE: AN ANALYSIS",
+ "AGENDA",
+ "You are an important supplier of various items that I need",
+ '\n' + "Although The Psycho set back my relationship process, recovery is luckily enough under way",
+ "Since the time that we seriously go out together, you rank highly among existing relationships",
+ "Although our personal interests are mostly compatible, the greatest gap exists in Sex and Shopping",
+ "Your physical characteristics are strong when compared with your competition",
+ "The combination of your high physical appearance and personality rank you highly, although your sister is also a top prospect",
+ "When people found out that we were going out, their responses have been mixed",
+ "The benchmark of relationship lifecycles, suggests that we are on schedule",
+ "In summary we can say that we are on the right track, but we must remain aware of possible roadblocks ",
+ "THE ANSWER",
+ "Unfortunately a huge disconnect exists between my needs and your existing service",
+ "SUMMARY", });
+ }
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestTable.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestTable.java
index 437cb592ff..b02fd31b32 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestTable.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestTable.java
@@ -68,42 +68,42 @@ public class TestTable {
@Test
void testTable() throws IOException {
- try (HSLFSlideShow ppt = HSLFTestDataSamples.getSlideShow("54111.ppt")) {
+ try (HSLFSlideShow ppt = HSLFTestDataSamples.getSlideShow("54111.ppt")) {
List slides = ppt.getSlides();
assertEquals(1, slides.size());
checkSlide(slides.get(0));
}
- }
+ }
- private void checkSlide(final HSLFSlide s) {
- List> textRuns = s.getTextParagraphs();
- assertEquals(2, textRuns.size());
+ private void checkSlide(final HSLFSlide s) {
+ List> textRuns = s.getTextParagraphs();
+ assertEquals(2, textRuns.size());
- HSLFTextRun textRun = textRuns.get(0).get(0).getTextRuns().get(0);
- assertEquals("Table sample", textRun.getRawText().trim());
- assertEquals(1, textRuns.get(0).get(0).getTextRuns().size());
- assertFalse(textRun.getTextParagraph().isBullet());
+ HSLFTextRun textRun = textRuns.get(0).get(0).getTextRuns().get(0);
+ assertEquals("Table sample", textRun.getRawText().trim());
+ assertEquals(1, textRuns.get(0).get(0).getTextRuns().size());
+ assertFalse(textRun.getTextParagraph().isBullet());
- assertEquals("Dummy text", HSLFTextParagraph.getRawText(textRuns.get(1)));
+ assertEquals("Dummy text", HSLFTextParagraph.getRawText(textRuns.get(1)));
- List shapes = s.getShapes();
- assertNotNull(shapes);
- assertEquals(3, shapes.size());
- assertTrue(shapes.get(2) instanceof HSLFTable);
- final HSLFTable table = (HSLFTable) shapes.get(2);
- assertEquals(4, table.getNumberOfColumns());
- assertEquals(6, table.getNumberOfRows());
- for (int x = 0; x < 4; x ++) {
+ List shapes = s.getShapes();
+ assertNotNull(shapes);
+ assertEquals(3, shapes.size());
+ assertTrue(shapes.get(2) instanceof HSLFTable);
+ final HSLFTable table = (HSLFTable) shapes.get(2);
+ assertEquals(4, table.getNumberOfColumns());
+ assertEquals(6, table.getNumberOfRows());
+ for (int x = 0; x < 4; x ++) {
HSLFTableCell c = table.getCell(0, x);
assertNotNull(c);
- assertEquals("TH Cell " + (x + 1), HSLFTextParagraph.getRawText(c.getTextParagraphs()));
- for (int y = 1; y < 6; y++) {
- c = table.getCell(y, x);
- assertNotNull(c);
- assertEquals("Row " + y + ", Cell " + (x + 1), c.getText());
- }
- }
- }
+ assertEquals("TH Cell " + (x + 1), HSLFTextParagraph.getRawText(c.getTextParagraphs()));
+ for (int y = 1; y < 6; y++) {
+ c = table.getCell(y, x);
+ assertNotNull(c);
+ assertEquals("Row " + y + ", Cell " + (x + 1), c.getText());
+ }
+ }
+ }
@Test
void testAddText() throws IOException {
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestTextRun.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestTextRun.java
index 6fc4dc6030..0079c348dc 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestTextRun.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestTextRun.java
@@ -43,141 +43,106 @@ import org.junit.jupiter.api.Test;
*/
@SuppressWarnings("UnusedAssignment")
public final class TestTextRun {
- // SlideShow primed on the test data
- private HSLFSlideShow ss;
- private HSLFSlideShow ssRich;
+ // SlideShow primed on the test data
+ private HSLFSlideShow ss;
+ private HSLFSlideShow ssRich;
- @BeforeEach
- void setUp() throws IOException {
- // Basic (non rich) test file
- ss = HSLFTestDataSamples.getSlideShow("basic_test_ppt_file.ppt");
+ @BeforeEach
+ void setUp() throws IOException {
+ // Basic (non rich) test file
+ ss = HSLFTestDataSamples.getSlideShow("basic_test_ppt_file.ppt");
- // Rich test file
- ssRich = HSLFTestDataSamples.getSlideShow("Single_Coloured_Page.ppt");
- }
+ // Rich test file
+ ssRich = HSLFTestDataSamples.getSlideShow("Single_Coloured_Page.ppt");
+ }
- @AfterEach
- void tearDown() throws IOException {
- ssRich.close();
- ss.close();
- }
+ @AfterEach
+ void tearDown() throws IOException {
+ ssRich.close();
+ ss.close();
+ }
- /**
- * Test to ensure that getting the text works correctly
- */
- @Test
- void testGetText() {
- HSLFSlide slideOne = ss.getSlides().get(0);
- List> textParas = slideOne.getTextParagraphs();
-
- assertEquals(2, textParas.size());
-
- // Get text works with \n
- assertEquals("This is a test title", HSLFTextParagraph.getText(textParas.get(0)));
- assertEquals("This is a test subtitle\nThis is on page 1", HSLFTextParagraph.getText(textParas.get(1)));
-
- // Raw text has \r instead
- assertEquals("This is a test title", HSLFTextParagraph.getRawText(textParas.get(0)));
- assertEquals("This is a test subtitle\rThis is on page 1", HSLFTextParagraph.getRawText(textParas.get(1)));
-
-
- // Now check on a rich text run
- HSLFSlide slideOneR = ssRich.getSlides().get(0);
- textParas = slideOneR.getTextParagraphs();
-
- assertEquals(2, textParas.size());
- assertEquals("This is a title, it\u2019s in black", HSLFTextParagraph.getText(textParas.get(0)));
- assertEquals("This is the subtitle, in bold\nThis bit is blue and italic\nThis bit is red (normal)", HSLFTextParagraph.getText(textParas.get(1)));
- assertEquals("This is a title, it\u2019s in black", HSLFTextParagraph.getRawText(textParas.get(0)));
- assertEquals("This is the subtitle, in bold\rThis bit is blue and italic\rThis bit is red (normal)", HSLFTextParagraph.getRawText(textParas.get(1)));
- }
-
- /**
- * Test to ensure changing non rich text bytes->bytes works correctly
- */
- @Test
- void testSetText() {
- HSLFSlide slideOne = ss.getSlides().get(0);
- List> textRuns = slideOne.getTextParagraphs();
- HSLFTextParagraph run = textRuns.get(0).get(0);
- HSLFTextRun tr = run.getTextRuns().get(0);
-
- // Check current text
- assertEquals("This is a test title", tr.getRawText());
-
- // Change
- String changeTo = "New test title";
- tr.setText(changeTo);
- assertEquals(changeTo, tr.getRawText());
-
- // Ensure trailing \n's are NOT stripped, it is legal to set a text with a trailing '\r'
- tr.setText(changeTo + "\n");
- assertEquals(changeTo + "\r", tr.getRawText());
- }
-
- /**
- * Test to ensure that changing non rich text between bytes and
- * chars works correctly
- */
- @SuppressWarnings("unused")
+ /**
+ * Test to ensure that getting the text works correctly
+ */
@Test
- void testAdvancedSetText() {
- HSLFSlide slideOne = ss.getSlides().get(0);
- List paras = slideOne.getTextParagraphs().get(0);
- HSLFTextParagraph para = paras.get(0);
+ void testGetText() {
+ HSLFSlide slideOne = ss.getSlides().get(0);
+ List> textParas = slideOne.getTextParagraphs();
+
+ assertEquals(2, textParas.size());
+
+ // Get text works with \n
+ assertEquals("This is a test title", HSLFTextParagraph.getText(textParas.get(0)));
+ assertEquals("This is a test subtitle\nThis is on page 1", HSLFTextParagraph.getText(textParas.get(1)));
+
+ // Raw text has \r instead
+ assertEquals("This is a test title", HSLFTextParagraph.getRawText(textParas.get(0)));
+ assertEquals("This is a test subtitle\rThis is on page 1", HSLFTextParagraph.getRawText(textParas.get(1)));
+
+
+ // Now check on a rich text run
+ HSLFSlide slideOneR = ssRich.getSlides().get(0);
+ textParas = slideOneR.getTextParagraphs();
+
+ assertEquals(2, textParas.size());
+ assertEquals("This is a title, it\u2019s in black", HSLFTextParagraph.getText(textParas.get(0)));
+ assertEquals("This is the subtitle, in bold\nThis bit is blue and italic\nThis bit is red (normal)", HSLFTextParagraph.getText(textParas.get(1)));
+ assertEquals("This is a title, it\u2019s in black", HSLFTextParagraph.getRawText(textParas.get(0)));
+ assertEquals("This is the subtitle, in bold\rThis bit is blue and italic\rThis bit is red (normal)", HSLFTextParagraph.getRawText(textParas.get(1)));
+ }
+
+ /**
+ * Test to ensure changing non rich text bytes->bytes works correctly
+ */
+ @Test
+ void testSetText() {
+ HSLFSlide slideOne = ss.getSlides().get(0);
+ List> textRuns = slideOne.getTextParagraphs();
+ HSLFTextParagraph run = textRuns.get(0).get(0);
+ HSLFTextRun tr = run.getTextRuns().get(0);
+
+ // Check current text
+ assertEquals("This is a test title", tr.getRawText());
+
+ // Change
+ String changeTo = "New test title";
+ tr.setText(changeTo);
+ assertEquals(changeTo, tr.getRawText());
+
+ // Ensure trailing \n's are NOT stripped, it is legal to set a text with a trailing '\r'
+ tr.setText(changeTo + "\n");
+ assertEquals(changeTo + "\r", tr.getRawText());
+ }
+
+ /**
+ * Test to ensure that changing non rich text between bytes and
+ * chars works correctly
+ */
+ @SuppressWarnings("unused")
+ @Test
+ void testAdvancedSetText() {
+ HSLFSlide slideOne = ss.getSlides().get(0);
+ List paras = slideOne.getTextParagraphs().get(0);
+ HSLFTextParagraph para = paras.get(0);
TextHeaderAtom tha = null;
TextBytesAtom tba = null;
TextCharsAtom tca = null;
- for ( org.apache.poi.hslf.record.Record r : para.getRecords()) {
- if (r instanceof TextHeaderAtom) tha = (TextHeaderAtom)r;
- else if (r instanceof TextBytesAtom) tba = (TextBytesAtom)r;
- else if (r instanceof TextCharsAtom) tca = (TextCharsAtom)r;
- }
-
- // Bytes -> Bytes
- assertNull(tca);
- assertNotNull(tba);
- // assertFalse(run._isUnicode);
- assertEquals("This is a test title", para.getTextRuns().get(0).getRawText());
-
- String changeBytesOnly = "New Test Title";
- HSLFTextParagraph.setText(paras, changeBytesOnly);
- para = paras.get(0);
- tha = null; tba = null; tca = null;
for ( org.apache.poi.hslf.record.Record r : para.getRecords()) {
if (r instanceof TextHeaderAtom) tha = (TextHeaderAtom)r;
else if (r instanceof TextBytesAtom) tba = (TextBytesAtom)r;
else if (r instanceof TextCharsAtom) tca = (TextCharsAtom)r;
}
- assertEquals(changeBytesOnly, HSLFTextParagraph.getRawText(paras));
- assertNull(tca);
- assertNotNull(tba);
+ // Bytes -> Bytes
+ assertNull(tca);
+ assertNotNull(tba);
+ // assertFalse(run._isUnicode);
+ assertEquals("This is a test title", para.getTextRuns().get(0).getRawText());
- // Bytes -> Chars
- assertEquals(changeBytesOnly, HSLFTextParagraph.getRawText(paras));
-
- String changeByteChar = "This is a test title with a '\u0121' g with a dot";
- HSLFTextParagraph.setText(paras, changeByteChar);
- para = paras.get(0);
- tha = null; tba = null; tca = null;
- for ( org.apache.poi.hslf.record.Record r : para.getRecords()) {
- if (r instanceof TextHeaderAtom) tha = (TextHeaderAtom)r;
- else if (r instanceof TextBytesAtom) tba = (TextBytesAtom)r;
- else if (r instanceof TextCharsAtom) tca = (TextCharsAtom)r;
- }
-
- assertEquals(changeByteChar, HSLFTextParagraph.getRawText(paras));
- assertNotNull(tca);
- assertNull(tba);
-
- // Chars -> Chars
- assertNotNull(tca);
- assertEquals(changeByteChar, HSLFTextParagraph.getRawText(paras));
-
- String changeCharChar = "This is a test title with a '\u0147' N with a hat";
- HSLFTextParagraph.setText(paras, changeCharChar);
+ String changeBytesOnly = "New Test Title";
+ HSLFTextParagraph.setText(paras, changeBytesOnly);
para = paras.get(0);
tha = null; tba = null; tca = null;
for ( org.apache.poi.hslf.record.Record r : para.getRecords()) {
@@ -186,334 +151,369 @@ public final class TestTextRun {
else if (r instanceof TextCharsAtom) tca = (TextCharsAtom)r;
}
- assertEquals(changeCharChar, HSLFTextParagraph.getRawText(paras));
- assertNotNull(tca);
- assertNull(tba);
- }
+ assertEquals(changeBytesOnly, HSLFTextParagraph.getRawText(paras));
+ assertNull(tca);
+ assertNotNull(tba);
- /**
- * Tests to ensure that non rich text has the right default rich text run
- * set up for it
- */
- @Test
- void testGetRichTextNonRich() {
- HSLFSlide slideOne = ss.getSlides().get(0);
- List> textParass = slideOne.getTextParagraphs();
+ // Bytes -> Chars
+ assertEquals(changeBytesOnly, HSLFTextParagraph.getRawText(paras));
- assertEquals(2, textParass.size());
+ String changeByteChar = "This is a test title with a '\u0121' g with a dot";
+ HSLFTextParagraph.setText(paras, changeByteChar);
+ para = paras.get(0);
+ tha = null; tba = null; tca = null;
+ for ( org.apache.poi.hslf.record.Record r : para.getRecords()) {
+ if (r instanceof TextHeaderAtom) tha = (TextHeaderAtom)r;
+ else if (r instanceof TextBytesAtom) tba = (TextBytesAtom)r;
+ else if (r instanceof TextCharsAtom) tca = (TextCharsAtom)r;
+ }
- List trA = textParass.get(0);
- List trB = textParass.get(1);
+ assertEquals(changeByteChar, HSLFTextParagraph.getRawText(paras));
+ assertNotNull(tca);
+ assertNull(tba);
- assertEquals(1, trA.size());
- assertEquals(2, trB.size());
+ // Chars -> Chars
+ assertNotNull(tca);
+ assertEquals(changeByteChar, HSLFTextParagraph.getRawText(paras));
- HSLFTextRun rtrA = trA.get(0).getTextRuns().get(0);
- HSLFTextRun rtrB = trB.get(0).getTextRuns().get(0);
+ String changeCharChar = "This is a test title with a '\u0147' N with a hat";
+ HSLFTextParagraph.setText(paras, changeCharChar);
+ para = paras.get(0);
+ tha = null; tba = null; tca = null;
+ for ( org.apache.poi.hslf.record.Record r : para.getRecords()) {
+ if (r instanceof TextHeaderAtom) tha = (TextHeaderAtom)r;
+ else if (r instanceof TextBytesAtom) tba = (TextBytesAtom)r;
+ else if (r instanceof TextCharsAtom) tca = (TextCharsAtom)r;
+ }
- assertEquals(HSLFTextParagraph.getRawText(trA), rtrA.getRawText());
- assertEquals(HSLFTextParagraph.getRawText(trB.subList(0, 1)), rtrB.getRawText());
- }
+ assertEquals(changeCharChar, HSLFTextParagraph.getRawText(paras));
+ assertNotNull(tca);
+ assertNull(tba);
+ }
- /**
- * Tests to ensure that the rich text runs are built up correctly
- */
- @Test
- void testGetRichText() {
- HSLFSlide slideOne = ssRich.getSlides().get(0);
- List> textParass = slideOne.getTextParagraphs();
+ /**
+ * Tests to ensure that non rich text has the right default rich text run
+ * set up for it
+ */
+ @Test
+ void testGetRichTextNonRich() {
+ HSLFSlide slideOne = ss.getSlides().get(0);
+ List> textParass = slideOne.getTextParagraphs();
- assertEquals(2, textParass.size());
+ assertEquals(2, textParass.size());
- List trA = textParass.get(0);
- List trB = textParass.get(1);
+ List trA = textParass.get(0);
+ List trB = textParass.get(1);
- assertEquals(1, trA.size());
- assertEquals(3, trB.size());
+ assertEquals(1, trA.size());
+ assertEquals(2, trB.size());
- HSLFTextRun rtrA = trA.get(0).getTextRuns().get(0);
- HSLFTextRun rtrB = trB.get(0).getTextRuns().get(0);
- HSLFTextRun rtrC = trB.get(1).getTextRuns().get(0);
- HSLFTextRun rtrD = trB.get(2).getTextRuns().get(0);
+ HSLFTextRun rtrA = trA.get(0).getTextRuns().get(0);
+ HSLFTextRun rtrB = trB.get(0).getTextRuns().get(0);
- assertEquals(HSLFTextParagraph.getRawText(trA), rtrA.getRawText());
+ assertEquals(HSLFTextParagraph.getRawText(trA), rtrA.getRawText());
+ assertEquals(HSLFTextParagraph.getRawText(trB.subList(0, 1)), rtrB.getRawText());
+ }
- String trBstr = HSLFTextParagraph.getRawText(trB);
- assertEquals(trBstr.substring(0, 30), rtrB.getRawText());
- assertEquals(trBstr.substring(30,58), rtrC.getRawText());
- assertEquals(trBstr.substring(58,82), rtrD.getRawText());
+ /**
+ * Tests to ensure that the rich text runs are built up correctly
+ */
+ @Test
+ void testGetRichText() {
+ HSLFSlide slideOne = ssRich.getSlides().get(0);
+ List> textParass = slideOne.getTextParagraphs();
- // Same paragraph styles
- assertEquals(trB.get(0).getParagraphStyle(), trB.get(1).getParagraphStyle());
- assertEquals(trB.get(0).getParagraphStyle(), trB.get(2).getParagraphStyle());
+ assertEquals(2, textParass.size());
- // Different char styles
- assertNotEquals(rtrB.getCharacterStyle(), rtrC.getCharacterStyle());
+ List trA = textParass.get(0);
+ List trB = textParass.get(1);
+
+ assertEquals(1, trA.size());
+ assertEquals(3, trB.size());
+
+ HSLFTextRun rtrA = trA.get(0).getTextRuns().get(0);
+ HSLFTextRun rtrB = trB.get(0).getTextRuns().get(0);
+ HSLFTextRun rtrC = trB.get(1).getTextRuns().get(0);
+ HSLFTextRun rtrD = trB.get(2).getTextRuns().get(0);
+
+ assertEquals(HSLFTextParagraph.getRawText(trA), rtrA.getRawText());
+
+ String trBstr = HSLFTextParagraph.getRawText(trB);
+ assertEquals(trBstr.substring(0, 30), rtrB.getRawText());
+ assertEquals(trBstr.substring(30,58), rtrC.getRawText());
+ assertEquals(trBstr.substring(58,82), rtrD.getRawText());
+
+ // Same paragraph styles
+ assertEquals(trB.get(0).getParagraphStyle(), trB.get(1).getParagraphStyle());
+ assertEquals(trB.get(0).getParagraphStyle(), trB.get(2).getParagraphStyle());
+
+ // Different char styles
+ assertNotEquals(rtrB.getCharacterStyle(), rtrC.getCharacterStyle());
assertNotEquals(rtrB.getCharacterStyle(), rtrD.getCharacterStyle());
assertNotEquals(rtrC.getCharacterStyle(), rtrD.getCharacterStyle());
- }
+ }
- /**
- * Tests to ensure that setting the text where the text isn't rich,
- * ensuring that everything stays with the same default styling
- */
- @Test
- void testSetTextWhereNotRich() {
- HSLFSlide slideOne = ss.getSlides().get(0);
- List> textParass = slideOne.getTextParagraphs();
- List trB = textParass.get(0);
- assertEquals(1, trB.size());
+ /**
+ * Tests to ensure that setting the text where the text isn't rich,
+ * ensuring that everything stays with the same default styling
+ */
+ @Test
+ void testSetTextWhereNotRich() {
+ HSLFSlide slideOne = ss.getSlides().get(0);
+ List> textParass = slideOne.getTextParagraphs();
+ List trB = textParass.get(0);
+ assertEquals(1, trB.size());
- HSLFTextRun rtrB = trB.get(0).getTextRuns().get(0);
- assertEquals(HSLFTextParagraph.getText(trB), rtrB.getRawText());
+ HSLFTextRun rtrB = trB.get(0).getTextRuns().get(0);
+ assertEquals(HSLFTextParagraph.getText(trB), rtrB.getRawText());
- // Change text via normal
- HSLFTextParagraph.setText(trB, "Test Foo Test");
- rtrB = trB.get(0).getTextRuns().get(0);
- assertEquals("Test Foo Test", HSLFTextParagraph.getRawText(trB));
- assertEquals("Test Foo Test", rtrB.getRawText());
- }
+ // Change text via normal
+ HSLFTextParagraph.setText(trB, "Test Foo Test");
+ rtrB = trB.get(0).getTextRuns().get(0);
+ assertEquals("Test Foo Test", HSLFTextParagraph.getRawText(trB));
+ assertEquals("Test Foo Test", rtrB.getRawText());
+ }
- /**
- * Tests to ensure that setting the text where the text is rich
- * sets everything to the same styling
- */
- @Test
- void testSetTextWhereRich() {
- HSLFSlide slideOne = ssRich.getSlides().get(0);
- List> textParass = slideOne.getTextParagraphs();
- List trB = textParass.get(1);
- assertEquals(3, trB.size());
+ /**
+ * Tests to ensure that setting the text where the text is rich
+ * sets everything to the same styling
+ */
+ @Test
+ void testSetTextWhereRich() {
+ HSLFSlide slideOne = ssRich.getSlides().get(0);
+ List> textParass = slideOne.getTextParagraphs();
+ List trB = textParass.get(1);
+ assertEquals(3, trB.size());
- HSLFTextRun rtrB = trB.get(0).getTextRuns().get(0);
- HSLFTextRun rtrC = trB.get(1).getTextRuns().get(0);
- HSLFTextRun rtrD = trB.get(2).getTextRuns().get(0);
- TextPropCollection tpBP = rtrB.getTextParagraph().getParagraphStyle();
- TextPropCollection tpBC = rtrB.getCharacterStyle();
- TextPropCollection tpCP = rtrC.getTextParagraph().getParagraphStyle();
- TextPropCollection tpCC = rtrC.getCharacterStyle();
- TextPropCollection tpDP = rtrD.getTextParagraph().getParagraphStyle();
- TextPropCollection tpDC = rtrD.getCharacterStyle();
+ HSLFTextRun rtrB = trB.get(0).getTextRuns().get(0);
+ HSLFTextRun rtrC = trB.get(1).getTextRuns().get(0);
+ HSLFTextRun rtrD = trB.get(2).getTextRuns().get(0);
+ TextPropCollection tpBP = rtrB.getTextParagraph().getParagraphStyle();
+ TextPropCollection tpBC = rtrB.getCharacterStyle();
+ TextPropCollection tpCP = rtrC.getTextParagraph().getParagraphStyle();
+ TextPropCollection tpCC = rtrC.getCharacterStyle();
+ TextPropCollection tpDP = rtrD.getTextParagraph().getParagraphStyle();
+ TextPropCollection tpDC = rtrD.getCharacterStyle();
-// assertEquals(trB.getRawText().substring(0, 30), rtrB.getRawText());
- assertNotNull(tpBP);
- assertNotNull(tpBC);
- assertNotNull(tpCP);
- assertNotNull(tpCC);
- assertNotNull(tpDP);
- assertNotNull(tpDC);
- assertEquals(tpBP,tpCP);
- assertEquals(tpBP,tpDP);
- assertEquals(tpCP,tpDP);
- assertNotEquals(tpBC,tpCC);
- assertNotEquals(tpBC,tpDC);
- assertNotEquals(tpCC,tpDC);
+// assertEquals(trB.getRawText().substring(0, 30), rtrB.getRawText());
+ assertNotNull(tpBP);
+ assertNotNull(tpBC);
+ assertNotNull(tpCP);
+ assertNotNull(tpCC);
+ assertNotNull(tpDP);
+ assertNotNull(tpDC);
+ assertEquals(tpBP,tpCP);
+ assertEquals(tpBP,tpDP);
+ assertEquals(tpCP,tpDP);
+ assertNotEquals(tpBC,tpCC);
+ assertNotEquals(tpBC,tpDC);
+ assertNotEquals(tpCC,tpDC);
- // Change text via normal
- HSLFTextParagraph.setText(trB, "Test Foo Test");
+ // Change text via normal
+ HSLFTextParagraph.setText(trB, "Test Foo Test");
- // Ensure now have first style
- assertEquals(1, trB.get(0).getTextRuns().size());
- rtrB = trB.get(0).getTextRuns().get(0);
- assertEquals("Test Foo Test", HSLFTextParagraph.getRawText(trB));
- assertEquals("Test Foo Test", rtrB.getRawText());
- assertNotNull(rtrB.getCharacterStyle());
- assertNotNull(rtrB.getTextParagraph().getParagraphStyle());
- assertEquals( tpBP, rtrB.getTextParagraph().getParagraphStyle() );
- assertEquals( tpBC, rtrB.getCharacterStyle() );
- }
-
- /**
- * Test to ensure the right stuff happens if we change the text
- * in a rich text run, that doesn't happen to actually be rich
- */
- @Test
- void testChangeTextInRichTextRunNonRich() {
- HSLFSlide slideOne = ss.getSlides().get(0);
- List> textRuns = slideOne.getTextParagraphs();
- List trB = textRuns.get(1);
- assertEquals(1, trB.get(0).getTextRuns().size());
-
- HSLFTextRun rtrB = trB.get(0).getTextRuns().get(0);
- assertEquals(HSLFTextParagraph.getRawText(trB.subList(0, 1)), rtrB.getRawText());
- assertNotNull(rtrB.getCharacterStyle());
- assertNotNull(rtrB.getTextParagraph().getParagraphStyle());
-
- // Change text via rich
- rtrB.setText("Test Test Test");
- assertEquals("Test Test Test", HSLFTextParagraph.getRawText(trB.subList(0, 1)));
- assertEquals("Test Test Test", rtrB.getRawText());
-
- // Will now have dummy props
+ // Ensure now have first style
+ assertEquals(1, trB.get(0).getTextRuns().size());
+ rtrB = trB.get(0).getTextRuns().get(0);
+ assertEquals("Test Foo Test", HSLFTextParagraph.getRawText(trB));
+ assertEquals("Test Foo Test", rtrB.getRawText());
assertNotNull(rtrB.getCharacterStyle());
assertNotNull(rtrB.getTextParagraph().getParagraphStyle());
- }
+ assertEquals( tpBP, rtrB.getTextParagraph().getParagraphStyle() );
+ assertEquals( tpBC, rtrB.getCharacterStyle() );
+ }
- /**
- * Tests to ensure changing the text within rich text runs works
- * correctly
- */
- @Test
- void testChangeTextInRichTextRun() {
- HSLFSlide slideOne = ssRich.getSlides().get(0);
- List> textParass = slideOne.getTextParagraphs();
- List trB = textParass.get(1);
- assertEquals(3, trB.size());
+ /**
+ * Test to ensure the right stuff happens if we change the text
+ * in a rich text run, that doesn't happen to actually be rich
+ */
+ @Test
+ void testChangeTextInRichTextRunNonRich() {
+ HSLFSlide slideOne = ss.getSlides().get(0);
+ List> textRuns = slideOne.getTextParagraphs();
+ List trB = textRuns.get(1);
+ assertEquals(1, trB.get(0).getTextRuns().size());
- // We start with 3 text runs, each with their own set of styles,
- // but all sharing the same paragraph styles
- HSLFTextRun rtrB = trB.get(0).getTextRuns().get(0);
- HSLFTextRun rtrC = trB.get(1).getTextRuns().get(0);
- HSLFTextRun rtrD = trB.get(2).getTextRuns().get(0);
- TextPropCollection tpBP = rtrB.getTextParagraph().getParagraphStyle();
- TextPropCollection tpBC = rtrB.getCharacterStyle();
- TextPropCollection tpCP = rtrC.getTextParagraph().getParagraphStyle();
- TextPropCollection tpCC = rtrC.getCharacterStyle();
- TextPropCollection tpDP = rtrD.getTextParagraph().getParagraphStyle();
- TextPropCollection tpDC = rtrD.getCharacterStyle();
+ HSLFTextRun rtrB = trB.get(0).getTextRuns().get(0);
+ assertEquals(HSLFTextParagraph.getRawText(trB.subList(0, 1)), rtrB.getRawText());
+ assertNotNull(rtrB.getCharacterStyle());
+ assertNotNull(rtrB.getTextParagraph().getParagraphStyle());
- // Check text and stylings
- assertEquals(HSLFTextParagraph.getRawText(trB).substring(0, 30), rtrB.getRawText());
- assertNotNull(tpBP);
- assertNotNull(tpBC);
- assertNotNull(tpCP);
- assertNotNull(tpCC);
- assertNotNull(tpDP);
- assertNotNull(tpDC);
- assertEquals(tpBP, tpCP);
- assertEquals(tpBP, tpDP);
- assertEquals(tpCP, tpDP);
- assertNotEquals(tpBC, tpCC);
- assertNotEquals(tpBC, tpDC);
- assertNotEquals(tpCC, tpDC);
+ // Change text via rich
+ rtrB.setText("Test Test Test");
+ assertEquals("Test Test Test", HSLFTextParagraph.getRawText(trB.subList(0, 1)));
+ assertEquals("Test Test Test", rtrB.getRawText());
- // Check text in the rich runs
- assertEquals("This is the subtitle, in bold\r", rtrB.getRawText());
- assertEquals("This bit is blue and italic\r", rtrC.getRawText());
- assertEquals("This bit is red (normal)", rtrD.getRawText());
+ // Will now have dummy props
+ assertNotNull(rtrB.getCharacterStyle());
+ assertNotNull(rtrB.getTextParagraph().getParagraphStyle());
+ }
- String newBText = "New Subtitle, will still be bold\n";
- String newCText = "New blue and italic text\n";
- String newDText = "Funky new normal red text";
- rtrB.setText(newBText);
- rtrC.setText(newCText);
- rtrD.setText(newDText);
- HSLFTextParagraph.storeText(trB);
+ /**
+ * Tests to ensure changing the text within rich text runs works
+ * correctly
+ */
+ @Test
+ void testChangeTextInRichTextRun() {
+ HSLFSlide slideOne = ssRich.getSlides().get(0);
+ List> textParass = slideOne.getTextParagraphs();
+ List trB = textParass.get(1);
+ assertEquals(3, trB.size());
- assertEquals(newBText.replace('\n','\r'), rtrB.getRawText());
- assertEquals(newCText.replace('\n','\r'), rtrC.getRawText());
- assertEquals(newDText.replace('\n','\r'), rtrD.getRawText());
+ // We start with 3 text runs, each with their own set of styles,
+ // but all sharing the same paragraph styles
+ HSLFTextRun rtrB = trB.get(0).getTextRuns().get(0);
+ HSLFTextRun rtrC = trB.get(1).getTextRuns().get(0);
+ HSLFTextRun rtrD = trB.get(2).getTextRuns().get(0);
+ TextPropCollection tpBP = rtrB.getTextParagraph().getParagraphStyle();
+ TextPropCollection tpBC = rtrB.getCharacterStyle();
+ TextPropCollection tpCP = rtrC.getTextParagraph().getParagraphStyle();
+ TextPropCollection tpCC = rtrC.getCharacterStyle();
+ TextPropCollection tpDP = rtrD.getTextParagraph().getParagraphStyle();
+ TextPropCollection tpDC = rtrD.getCharacterStyle();
- assertEquals(newBText.replace('\n','\r') + newCText.replace('\n','\r') + newDText.replace('\n','\r'), HSLFTextParagraph.getRawText(trB));
+ // Check text and stylings
+ assertEquals(HSLFTextParagraph.getRawText(trB).substring(0, 30), rtrB.getRawText());
+ assertNotNull(tpBP);
+ assertNotNull(tpBC);
+ assertNotNull(tpCP);
+ assertNotNull(tpCC);
+ assertNotNull(tpDP);
+ assertNotNull(tpDC);
+ assertEquals(tpBP, tpCP);
+ assertEquals(tpBP, tpDP);
+ assertEquals(tpCP, tpDP);
+ assertNotEquals(tpBC, tpCC);
+ assertNotEquals(tpBC, tpDC);
+ assertNotEquals(tpCC, tpDC);
- // The styles should have been updated for the new sizes
- assertEquals(newBText.length(), tpBC.getCharactersCovered());
- assertEquals(newCText.length(), tpCC.getCharactersCovered());
- assertEquals(newDText.length()+1, tpDC.getCharactersCovered()); // Last one is always one larger
+ // Check text in the rich runs
+ assertEquals("This is the subtitle, in bold\r", rtrB.getRawText());
+ assertEquals("This bit is blue and italic\r", rtrC.getRawText());
+ assertEquals("This bit is red (normal)", rtrD.getRawText());
+
+ String newBText = "New Subtitle, will still be bold\n";
+ String newCText = "New blue and italic text\n";
+ String newDText = "Funky new normal red text";
+ rtrB.setText(newBText);
+ rtrC.setText(newCText);
+ rtrD.setText(newDText);
+ HSLFTextParagraph.storeText(trB);
+
+ assertEquals(newBText.replace('\n','\r'), rtrB.getRawText());
+ assertEquals(newCText.replace('\n','\r'), rtrC.getRawText());
+ assertEquals(newDText.replace('\n','\r'), rtrD.getRawText());
+
+ assertEquals(newBText.replace('\n','\r') + newCText.replace('\n','\r') + newDText.replace('\n','\r'), HSLFTextParagraph.getRawText(trB));
+
+ // The styles should have been updated for the new sizes
+ assertEquals(newBText.length(), tpBC.getCharactersCovered());
+ assertEquals(newCText.length(), tpCC.getCharactersCovered());
+ assertEquals(newDText.length()+1, tpDC.getCharactersCovered()); // Last one is always one larger
// Paragraph style should be sum of text length
- assertEquals(
- newBText.length() + newCText.length() + newDText.length() +1,
- tpBP.getCharactersCovered() + tpCP.getCharactersCovered() + tpDP.getCharactersCovered()
- );
+ assertEquals(
+ newBText.length() + newCText.length() + newDText.length() +1,
+ tpBP.getCharactersCovered() + tpCP.getCharactersCovered() + tpDP.getCharactersCovered()
+ );
- // Check stylings still as expected
- TextPropCollection ntpBC = rtrB.getCharacterStyle();
- TextPropCollection ntpCC = rtrC.getCharacterStyle();
- TextPropCollection ntpDC = rtrD.getCharacterStyle();
- assertEquals(tpBC.getTextPropList(), ntpBC.getTextPropList());
- assertEquals(tpCC.getTextPropList(), ntpCC.getTextPropList());
- assertEquals(tpDC.getTextPropList(), ntpDC.getTextPropList());
- }
+ // Check stylings still as expected
+ TextPropCollection ntpBC = rtrB.getCharacterStyle();
+ TextPropCollection ntpCC = rtrC.getCharacterStyle();
+ TextPropCollection ntpDC = rtrD.getCharacterStyle();
+ assertEquals(tpBC.getTextPropList(), ntpBC.getTextPropList());
+ assertEquals(tpCC.getTextPropList(), ntpCC.getTextPropList());
+ assertEquals(tpDC.getTextPropList(), ntpDC.getTextPropList());
+ }
- /**
- * Test case for Bug 41015.
- *
- * In some cases RichTextRun.getText() threw StringIndexOutOfBoundsException because
- * of the wrong list of potential paragraph properties defined in StyleTextPropAtom.
- *
- */
- @Test
- void testBug41015() throws IOException {
- List rt;
+ /**
+ * Test case for Bug 41015.
+ *
+ * In some cases RichTextRun.getText() threw StringIndexOutOfBoundsException because
+ * of the wrong list of potential paragraph properties defined in StyleTextPropAtom.
+ *
+ */
+ @Test
+ void testBug41015() throws IOException {
+ List rt;
- HSLFSlideShow ppt = HSLFTestDataSamples.getSlideShow("bug-41015.ppt");
- HSLFSlide sl = ppt.getSlides().get(0);
+ HSLFSlideShow ppt = HSLFTestDataSamples.getSlideShow("bug-41015.ppt");
+ HSLFSlide sl = ppt.getSlides().get(0);
List> textParass = sl.getTextParagraphs();
- assertEquals(2, textParass.size());
+ assertEquals(2, textParass.size());
- List textParas = textParass.get(0);
- rt = textParass.get(0).get(0).getTextRuns();
- assertEquals(1, rt.size());
- assertEquals(0, textParass.get(0).get(0).getIndentLevel());
- assertEquals("sdfsdfsdf", rt.get(0).getRawText());
+ List textParas = textParass.get(0);
+ rt = textParass.get(0).get(0).getTextRuns();
+ assertEquals(1, rt.size());
+ assertEquals(0, textParass.get(0).get(0).getIndentLevel());
+ assertEquals("sdfsdfsdf", rt.get(0).getRawText());
- textParas = textParass.get(1);
+ textParas = textParass.get(1);
String[] texts = {"Sdfsdfsdf\r", "Dfgdfg\r", "Dfgdfgdfg\r", "Sdfsdfs\r", "Sdfsdf\r"};
int[] indents = {0, 0, 0, 1, 1};
- int i=0;
- for (HSLFTextParagraph p : textParas) {
- assertEquals(texts[i], p.getTextRuns().get(0).getRawText());
- assertEquals(indents[i], p.getIndentLevel());
- i++;
- }
- ppt.close();
- }
+ int i=0;
+ for (HSLFTextParagraph p : textParas) {
+ assertEquals(texts[i], p.getTextRuns().get(0).getRawText());
+ assertEquals(indents[i], p.getIndentLevel());
+ i++;
+ }
+ ppt.close();
+ }
- /**
- * Test creation of TextRun objects.
- */
- @Test
- void testAddTextRun() throws IOException {
- HSLFSlideShow ppt = new HSLFSlideShow();
- HSLFSlide slide = ppt.createSlide();
+ /**
+ * Test creation of TextRun objects.
+ */
+ @Test
+ void testAddTextRun() throws IOException {
+ HSLFSlideShow ppt = new HSLFSlideShow();
+ HSLFSlide slide = ppt.createSlide();
- assertEquals(0, slide.getTextParagraphs().size());
+ assertEquals(0, slide.getTextParagraphs().size());
- HSLFTextBox shape1 = new HSLFTextBox();
- List run1 = shape1.getTextParagraphs();
- shape1.setText("Text 1");
- slide.addShape(shape1);
+ HSLFTextBox shape1 = new HSLFTextBox();
+ List run1 = shape1.getTextParagraphs();
+ shape1.setText("Text 1");
+ slide.addShape(shape1);
- //The array of Slide's text runs must be updated when new text shapes are added.
- List> runs = slide.getTextParagraphs();
- assertNotNull(runs);
- assertSame(run1, runs.get(0));
+ //The array of Slide's text runs must be updated when new text shapes are added.
+ List> runs = slide.getTextParagraphs();
+ assertNotNull(runs);
+ assertSame(run1, runs.get(0));
- HSLFTextBox shape2 = new HSLFTextBox();
- List run2 = shape2.getTextParagraphs();
- shape2.setText("Text 2");
- slide.addShape(shape2);
+ HSLFTextBox shape2 = new HSLFTextBox();
+ List run2 = shape2.getTextParagraphs();
+ shape2.setText("Text 2");
+ slide.addShape(shape2);
- runs = slide.getTextParagraphs();
- assertEquals(2, runs.size());
+ runs = slide.getTextParagraphs();
+ assertEquals(2, runs.size());
- assertSame(run1, runs.get(0));
- assertSame(run2, runs.get(1));
+ assertSame(run1, runs.get(0));
+ assertSame(run2, runs.get(1));
- // as getShapes()
- List