You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2021/05/22 21:37:10 UTC

svn commit: r1890122 [10/16] - in /poi/trunk/poi-scratchpad/src: main/java/org/apache/poi/hdgf/ main/java/org/apache/poi/hdgf/chunks/ main/java/org/apache/poi/hdgf/dev/ main/java/org/apache/poi/hdgf/exceptions/ main/java/org/apache/poi/hdgf/extractor/ ...

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/Range.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/Range.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/Range.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/Range.java Sat May 22 21:37:08 2021
@@ -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 ending character offset of this range. */
+    protected int _end;
+
+    /** The document this range belongs to. */
+    protected final HWPFDocumentCore _doc;
+
+    /** Have we loaded the section indexes yet */
+    boolean _sectionRangeFound;
+
+    /** All sections that belong to the document this Range belongs to. */
+    protected final List<SEPX> _sections;
+
+    /** 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;
+
+    /** Have we loaded the paragraph indexes yet. */
+    protected boolean _parRangeFound;
+
+    /** All paragraphs that belong to the document this Range belongs to. */
+    protected final List<PAPX> _paragraphs;
+
+    /** 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;
+
+    /** Have we loaded the characterRun indexes yet. */
+    protected boolean _charRangeFound;
+
+    /** All CharacterRuns that belong to the document this Range belongs to. */
+    protected List<CHPX> _characters;
+
+    /** 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;
+
+    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;
+
+        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;
+
+        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);
+    }
+
+
+    /**
+     * 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 );
+    }
+
+    /**
+     * 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;
+
+        // 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;
+            }
 
-	/** The starting character offset of this range. */
-	protected final int _start;
+            // If no more 13s and 14s, just zap
+            if (next13 == -1 && first14 == -1) {
+                text = text.substring(0, first13) + text.substring(last15 + 1);
+                break;
+            }
 
-	/** The ending character offset of this range. */
-	protected int _end;
+            // 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;
+            }
 
-	/** The document this range belongs to. */
-	protected final HWPFDocumentCore _doc;
-
-	/** Have we loaded the section indexes yet */
-	boolean _sectionRangeFound;
-
-	/** All sections that belong to the document this Range belongs to. */
-	protected final List<SEPX> _sections;
-
-	/** 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;
-
-	/** Have we loaded the paragraph indexes yet. */
-	protected boolean _parRangeFound;
-
-	/** All paragraphs that belong to the document this Range belongs to. */
-	protected final List<PAPX> _paragraphs;
-
-	/** 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;
-
-	/** Have we loaded the characterRun indexes yet. */
-	protected boolean _charRangeFound;
-
-	/** All CharacterRuns that belong to the document this Range belongs to. */
-	protected List<CHPX> _characters;
-
-	/** 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;
-
-	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;
-
-		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;
-
-		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);
-	}
-
-
-	/**
-	 * 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 );
-	}
-
-	/**
-	 * 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;
-
-		// 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 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;
-			}
-
-			// 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;
-	}
-
-	/**
-	 * 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.
-	 */
-
-	public int numParagraphs() {
-		initParagraphs();
-		return _parEnd - _parStart;
-	}
-
-	/**
-	 *
-	 * @return The number of characterRuns in this range.
-	 */
-
-	public int numCharacterRuns() {
-		initCharacterRuns();
-		return _charEnd - _charStart;
-	}
+            // 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;
+    }
+
+    /**
+     * 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.
+     */
+
+    public int numParagraphs() {
+        initParagraphs();
+        return _parEnd - _parStart;
+    }
+
+    /**
+     *
+     * @return The number of characterRuns in this range.
+     */
+
+    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();
-
-		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);
-	}
-
-	/**
-	 * 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}
-	 */
+    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);
+
+        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}
+     */
     @Deprecated
-	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);
-	}
-
-	/**
-	 * 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.
+    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);
+    }
+
+    /**
+     * 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);
-
-		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.
+    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.
+     * @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);
+
+        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)
-	{
-		return this.insertAfter(props, styleIndex, "\r");
-	}
-
-	/**
-	 * 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.
+    Paragraph insertAfter(ParagraphProperties props, int styleIndex)
+    {
+        return this.insertAfter(props, styleIndex, "\r");
+    }
+
+    /**
+     * 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);
-
-		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(_parEnd, _end, buf);
-		_parEnd++;
-		insertAfter(text, baseChp);
-		return getParagraph(numParagraphs() - 1);
-	}
-
-	public void delete() {
-
-		initAll();
-
-		int numSections = _sections.size();
-		int numRuns = _characters.size();
-		int numParagraphs = _paragraphs.size();
-
-		for (int x = _charStart; x < numRuns; x++) {
-			CHPX chpx = _characters.get(x);
-			chpx.adjustForDelete(_start, _end - _start);
-		}
-
-		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());
-		}
+    Paragraph insertAfter(ParagraphProperties props, int styleIndex, String text)
+    {
+        initAll();
+        StyleSheet ss = _doc.getStyleSheet();
+        ParagraphProperties baseStyle = ss.getParagraphStyle(styleIndex);
+        CharacterProperties baseChp = ss.getCharacterStyle(styleIndex);
+
+        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(_parEnd, _end, buf);
+        _parEnd++;
+        insertAfter(text, baseChp);
+        return getParagraph(numParagraphs() - 1);
+    }
+
+    public void delete() {
+
+        initAll();
+
+        int numSections = _sections.size();
+        int numRuns = _characters.size();
+        int numParagraphs = _paragraphs.size();
+
+        for (int x = _charStart; x < numRuns; x++) {
+            CHPX chpx = _characters.get(x);
+            chpx.adjustForDelete(_start, _end - _start);
+        }
+
+        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;
-
-		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);
-
-		// 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;
-			}
-		}
-	}
-
-	/**
-	 * 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.
-	 */
+    /**
+     * 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);
+
+        // 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();
+    }
+
+    /**
+     * 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.
+     */
     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 );
-	}
-
-	/**
-	 * 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");
-		}
+        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");
+        }
+
+        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();
-	}
-
-	/**
-	 * 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 section list indexes.
-	 */
-	private void initSections() {
-		if (!_sectionRangeFound) {
-			int[] point = findRange(_sections, _sectionStart, _start, _end);
-			_sectionStart = point[0];
-			_sectionEnd = point[1];
-			_sectionRangeFound = true;
-		}
-	}
+    /**
+     * 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 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;
+        }
+    }
 
     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;
-
-		reset();
-		Range parent = _parent;
-		if (parent != null) {
-			parent.adjustForInsert(length);
-		}
-	}
-
-	/**
-	 * @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;
-	}
-
-	protected HWPFDocumentCore getDocument() {
-		return _doc;
-	}
+    /**
+     * 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);
+        }
+    }
+
+    /**
+     * @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;
+    }
+
+    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;

Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/TestHDGFLZW.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/TestHDGFLZW.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/TestHDGFLZW.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/TestHDGFLZW.java Sat May 22 21:37:08 2021
@@ -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

Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/chunks/TestChunks.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/chunks/TestChunks.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/chunks/TestChunks.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/chunks/TestChunks.java Sat May 22 21:37:08 2021
@@ -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());
-
-		assertTrue(header.hasTrailer());
-		assertTrue(header.hasSeparator());
-	}
+        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());
+    }
 
     @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());
-
-		assertTrue(header.hasTrailer());
-		assertTrue(header.hasSeparator());
-	}
+        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());
+    }
 
     @Test
     void testOneChunk() throws Exception {
-		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());
-
-		// 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());
-
-		// 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(18, chunk.getCommandDefinitions()[1].getType());
-		assertEquals(0, chunk.getCommandDefinitions()[1].getOffset());
-		assertEquals("0", chunk.getCommandDefinitions()[1].getName());
-	}
+        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());
+
+        // 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());
+
+        // 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(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);
-
-		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());
-
-		// 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);
-
-		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());
-	}
+        // 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());
+
+        // 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());
+
+        // 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(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;
-
-		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();
-
-		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());
-	}
+        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();
+
+        // 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());
+    }
 }

Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/extractor/TestVisioExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/extractor/TestVisioExtractor.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/extractor/TestVisioExtractor.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/extractor/TestVisioExtractor.java Sat May 22 21:37:08 2021
@@ -33,70 +33,70 @@ import org.junit.jupiter.params.provider
 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);
-		}
-
-		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);
-		}
+    /**
+     * 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 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);
-
-			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);
-		}
-	}
+            // 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]);
+
+            // 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)) {

Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/pointers/TestPointerFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/pointers/TestPointerFactory.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/pointers/TestPointerFactory.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/pointers/TestPointerFactory.java Sat May 22 21:37:08 2021
@@ -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
-	};
-
-	@Test
-	void testCreateV4() {
-		PointerFactory pf = new PointerFactory(4);
-		assertThrows(IllegalArgumentException.class, () -> pf.createPointer(new byte[]{}, 0));
-	}
-
-	@Test
-	void testCreateV5() {
-		PointerFactory pf = new PointerFactory(5);
+    // 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 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);
+
+        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());
+
+        assertEquals(18, a.getSizeInBytes());
+
 
-	@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());
-
-		assertTrue(a.destinationCompressed());
-		assertTrue(a.destinationHasStrings());
-		assertFalse(a.destinationHasChunks());
-		assertFalse(a.destinationHasPointers());
-
-		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());
-
-		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());
-
-		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());
-
-		assertFalse(d.destinationCompressed());
-		assertFalse(d.destinationHasStrings());
-		assertFalse(d.destinationHasChunks());
-		assertFalse(d.destinationHasPointers());
-	}
-
-	@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);
-
-		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());
-	}
+        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());
+
+        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());
+
+        // 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());
+    }
+
+    @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);
+
+        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());
+    }
 }

Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/streams/TestStreamBasics.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/streams/TestStreamBasics.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/streams/TestStreamBasics.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/streams/TestStreamBasics.java Sat May 22 21:37:08 2021
@@ -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 exte
             "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);
-
-		// 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);
-
-		for(int i=0; i<uncompressedStream.length; i++) {
-			assertEquals(uncompressedStream[i], ss.getContents()[i]);
-		}
-	}
+    @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 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<uncompressedStream.length; i++) {
+            assertEquals(uncompressedStream[i], ss.getContents()[i]);
+        }
+    }
 
-	@Test
+    @Test
     void testUncompressedStream() {
-		// Create a fake pointer
-		Pointer ptr = new TestPointer(false, 0, uncompressedStream.length, -1, (short)-1);
-		// Now the stream
-		Stream stream = Stream.createStream(ptr, uncompressedStream, null, null);
-
-		// Check
-		assertNotNull(stream.getPointer());
-		assertNotNull(stream.getStore());
-		assertFalse(stream.getStore() instanceof CompressedStreamStore);
-		assertTrue(stream instanceof UnknownStream);
-	}
+        // Create a fake pointer
+        Pointer ptr = new TestPointer(false, 0, uncompressedStream.length, -1, (short)-1);
+        // Now the stream
+        Stream stream = Stream.createStream(ptr, uncompressedStream, null, null);
+
+        // Check
+        assertNotNull(stream.getPointer());
+        assertNotNull(stream.getStore());
+        assertFalse(stream.getStore() instanceof CompressedStreamStore);
+        assertTrue(stream instanceof UnknownStream);
+    }
 }

Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/streams/TestStreamBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/streams/TestStreamBugs.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/streams/TestStreamBugs.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/streams/TestStreamBugs.java Sat May 22 21:37:08 2021
@@ -38,76 +38,76 @@ import org.junit.jupiter.api.Test;
  * Tests for bugs with streams
  */
 public final class TestStreamBugs extends StreamTest {
-	private byte[] contents;
-	private ChunkFactory chunkFactory;
-	private PointerFactory ptrFactory;
-	private POIFSFileSystem filesystem;
+    private byte[] contents;
+    private ChunkFactory chunkFactory;
+    private PointerFactory ptrFactory;
+    private POIFSFileSystem filesystem;
 
-	@BeforeEach
+    @BeforeEach
     void setUp() throws IOException {
-		ptrFactory = new PointerFactory(11);
-		chunkFactory = new ChunkFactory(11);
+        ptrFactory = new PointerFactory(11);
+        chunkFactory = new ChunkFactory(11);
 
         try (InputStream is = POIDataSamples.getDiagramInstance().openResourceAsStream("44594.vsd")) {
-			filesystem = new POIFSFileSystem(is);
-		}
+            filesystem = new POIFSFileSystem(is);
+        }
 
-		// Grab the document stream
-		try (InputStream is2 = filesystem.createDocumentInputStream("VisioDocument")) {
-			contents = IOUtils.toByteArray(is2);
-		}
-	}
+        // Grab the document stream
+        try (InputStream is2 = filesystem.createDocumentInputStream("VisioDocument")) {
+            contents = IOUtils.toByteArray(is2);
+        }
+    }
 
-	@Test
+    @Test
     void testGetTrailer() {
-		Pointer trailerPointer = ptrFactory.createPointer(contents, 0x24);
-		Stream s = Stream.createStream(trailerPointer, contents, chunkFactory, ptrFactory);
-		assertNotNull(s);
-	}
+        Pointer trailerPointer = ptrFactory.createPointer(contents, 0x24);
+        Stream s = Stream.createStream(trailerPointer, contents, chunkFactory, ptrFactory);
+        assertNotNull(s);
+    }
 
-	@SuppressWarnings("unused")
+    @SuppressWarnings("unused")
     void TOIMPLEMENTtestGetCertainChunks() {
-		int offsetA = 3708;
-		int offsetB = 3744;
-	}
+        int offsetA = 3708;
+        int offsetB = 3744;
+    }
 
-	@Test
+    @Test
     void testGetChildren() {
-		Pointer trailerPointer = ptrFactory.createPointer(contents, 0x24);
-		TrailerStream trailer = (TrailerStream)
-			Stream.createStream(trailerPointer, contents, chunkFactory, ptrFactory);
-
-		// Get without recursing
-		Pointer[] ptrs = trailer.getChildPointers();
-		for (Pointer ptr : ptrs) {
-			Stream.createStream(ptr, contents, chunkFactory, ptrFactory);
-		}
-
-		// Get with recursing into chunks
-		for (Pointer ptr : ptrs) {
-			Stream stream = Stream.createStream(ptr, contents, chunkFactory, ptrFactory);
-			if(stream instanceof ChunkStream) {
-				ChunkStream cStream = (ChunkStream)stream;
-				assertDoesNotThrow(cStream::findChunks);
-			}
-		}
-
-		// 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));
-			}
-		}
+        Pointer trailerPointer = ptrFactory.createPointer(contents, 0x24);
+        TrailerStream trailer = (TrailerStream)
+            Stream.createStream(trailerPointer, contents, chunkFactory, ptrFactory);
+
+        // Get without recursing
+        Pointer[] ptrs = trailer.getChildPointers();
+        for (Pointer ptr : ptrs) {
+            Stream.createStream(ptr, contents, chunkFactory, ptrFactory);
+        }
+
+        // Get with recursing into chunks
+        for (Pointer ptr : ptrs) {
+            Stream stream = Stream.createStream(ptr, contents, chunkFactory, ptrFactory);
+            if(stream instanceof ChunkStream) {
+                ChunkStream cStream = (ChunkStream)stream;
+                assertDoesNotThrow(cStream::findChunks);
+            }
+        }
+
+        // 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);
+        }
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org