Search in sources :

Example 1 with SprmBuffer

use of org.apache.poi.hwpf.sprm.SprmBuffer in project poi by apache.

the class Range method insertAfter.

/**
	 * 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
protected 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 + LittleEndian.SHORT_SIZE];
    LittleEndian.putShort(withIndex, 0, (short) styleIndex);
    System.arraycopy(grpprl, 0, withIndex, LittleEndian.SHORT_SIZE, grpprl.length);
    SprmBuffer buf = new SprmBuffer(withIndex, 2);
    _doc.getParagraphTable().insert(_parEnd, _end, buf);
    _parEnd++;
    insertAfter(text, baseChp);
    return getParagraph(numParagraphs() - 1);
}
Also used : StyleSheet(org.apache.poi.hwpf.model.StyleSheet) SprmBuffer(org.apache.poi.hwpf.sprm.SprmBuffer)

Example 2 with SprmBuffer

use of org.apache.poi.hwpf.sprm.SprmBuffer in project poi by apache.

the class Range method insertAfter.

/**
	 * 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);
}
Also used : StyleSheet(org.apache.poi.hwpf.model.StyleSheet) SprmBuffer(org.apache.poi.hwpf.sprm.SprmBuffer) PAPX(org.apache.poi.hwpf.model.PAPX)

Example 3 with SprmBuffer

use of org.apache.poi.hwpf.sprm.SprmBuffer in project poi by apache.

the class Range method insertBefore.

/**
	 * 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);
}
Also used : StyleSheet(org.apache.poi.hwpf.model.StyleSheet) SprmBuffer(org.apache.poi.hwpf.sprm.SprmBuffer) PAPX(org.apache.poi.hwpf.model.PAPX)

Example 4 with SprmBuffer

use of org.apache.poi.hwpf.sprm.SprmBuffer in project poi by apache.

the class Paragraph method clone.

public Object clone() throws CloneNotSupportedException {
    Paragraph p = (Paragraph) super.clone();
    p._props = (ParagraphProperties) _props.clone();
    //p._baseStyle = _baseStyle;
    p._papx = new SprmBuffer(0);
    return p;
}
Also used : SprmBuffer(org.apache.poi.hwpf.sprm.SprmBuffer)

Example 5 with SprmBuffer

use of org.apache.poi.hwpf.sprm.SprmBuffer in project poi by apache.

the class SEPX method getGrpprl.

public byte[] getGrpprl() {
    if (sectionProperties != null) {
        byte[] grpprl = SectionSprmCompressor.compressSectionProperty(sectionProperties);
        _buf = new SprmBuffer(grpprl, 0);
    }
    return ((SprmBuffer) _buf).toByteArray();
}
Also used : SprmBuffer(org.apache.poi.hwpf.sprm.SprmBuffer)

Aggregations

SprmBuffer (org.apache.poi.hwpf.sprm.SprmBuffer)10 StyleSheet (org.apache.poi.hwpf.model.StyleSheet)4 SprmOperation (org.apache.poi.hwpf.sprm.SprmOperation)3 ArrayList (java.util.ArrayList)2 Comparator (java.util.Comparator)2 IdentityHashMap (java.util.IdentityHashMap)2 LinkedList (java.util.LinkedList)2 PAPX (org.apache.poi.hwpf.model.PAPX)2 SprmIterator (org.apache.poi.hwpf.sprm.SprmIterator)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1