Package org.apache.poi.hwpf.model

Examples of org.apache.poi.hwpf.model.StyleSheet


    _pictures = new PicturesTable(this, _dataStream, _mainStream, _fspa, _dgg);
    // And the art shapes stream
    _officeArts = new ShapesTable(_tableStream, _fib);

    _st = new SectionTable(_mainStream, _tableStream, _fib.getFcPlcfsed(), _fib.getLcbPlcfsed(), fcMin, _tpt, _cpSplit);
    _ss = new StyleSheet(_tableStream, _fib.getFcStshf());
    _ft = new FontTable(_tableStream, _fib.getFcSttbfffn(), _fib.getLcbSttbfffn());

    int listOffset = _fib.getFcPlcfLst();
    int lfoOffset = _fib.getFcPlfLfo();
    if (listOffset != 0 && _fib.getLcbPlcfLst() != 0)
View Full Code Here


    // And escher pictures
    _officeDrawingsHeaders = new OfficeDrawingsImpl( _fspaHeaders, _escherRecordHolder, _mainStream );
    _officeDrawingsMain = new OfficeDrawingsImpl( _fspaMain , _escherRecordHolder, _mainStream);

    _st = new SectionTable(_mainStream, _tableStream, _fib.getFcPlcfsed(), _fib.getLcbPlcfsed(), fcMin, _tpt, _fib.getSubdocumentTextStreamLength( SubdocumentType.MAIN));
    _ss = new StyleSheet(_tableStream, _fib.getFcStshf());
    _ft = new FontTable(_tableStream, _fib.getFcSttbfffn(), _fib.getLcbSttbfffn());

    int listOffset = _fib.getFcPlcfLst();
    int lfoOffset = _fib.getFcPlfLfo();
    if (listOffset != 0 && _fib.getLcbPlcfLst() != 0)
View Full Code Here

  {
    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);
View Full Code Here

  {
    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);
View Full Code Here

    @Deprecated
  protected Paragraph insertBefore(ParagraphProperties props, int styleIndex, String text)
  // throws UnsupportedEncodingException
  {
    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, (short) styleIndex);
    System.arraycopy(grpprl, 0, withIndex, LittleEndian.SHORT_SIZE, grpprl.length);
View Full Code Here

    @Deprecated
  protected Paragraph insertAfter(ParagraphProperties props, int styleIndex, String text)
  // throws UnsupportedEncodingException
  {
    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, (short) styleIndex);
    System.arraycopy(grpprl, 0, withIndex, LittleEndian.SHORT_SIZE, grpprl.length);
View Full Code Here

    @Internal
    static Paragraph newParagraph( Range parent, PAPX papx )
    {
        HWPFDocumentCore doc = parent._doc;
        ListTables listTables = doc.getListTables();
        StyleSheet styleSheet = doc.getStyleSheet();

        ParagraphProperties properties = new ParagraphProperties();
        properties.setIstd( papx.getIstd() );

        properties = newParagraph_applyStyleProperties( styleSheet, papx,
View Full Code Here

        assertEquals(15, a.getStyleSheet().numStyles());

        // Ensure none of the paragraphs refer to one that isn't there,
        //  and none of their character runs either
        // Also check all use the default style
        StyleSheet ss = a.getStyleSheet();
        for(int i=0; i<a.getRange().numParagraphs(); i++) {
            Paragraph p = a.getRange().getParagraph(i);
            int styleIndex = p.getStyleIndex();
            assertTrue(styleIndex < 15);
            assertEquals("Normal", ss.getStyleDescription(styleIndex).getName());
        }
        for(int i=0; i<a.getRange().numCharacterRuns(); i++) {
            CharacterRun c = a.getRange().getCharacterRun(i);
            int styleIndex = c.getStyleIndex();
            assertTrue(styleIndex < 15);
            assertEquals("Normal", ss.getStyleDescription(styleIndex).getName());
        }
    }
View Full Code Here

        Range r = u.getRange();
        String[] p1_parts = u_page_1.split("\r");

        Paragraph p1 = r.getParagraph(0);
        Paragraph p7 = r.getParagraph(6);
        StyleSheet ss = r._doc.getStyleSheet();

        // Line ending in its own run each time!
        assertEquals(2, p1.numCharacterRuns());
        assertEquals(2, p7.numCharacterRuns());

        CharacterRun c1a = p1.getCharacterRun(0);
        CharacterRun c1b = p1.getCharacterRun(1);
        CharacterRun c7a = p7.getCharacterRun(0);
        CharacterRun c7b = p7.getCharacterRun(1);

        assertEquals("Times New Roman", c1a.getFontName()); // No Calibri
        assertEquals(22, c1a.getFontSize());

        assertEquals("Times New Roman", c1b.getFontName()); // No Calibri
        assertEquals(22, c1b.getFontSize());

        assertEquals("Times New Roman", c7a.getFontName());
        assertEquals(48, c7a.getFontSize());

        assertEquals("Times New Roman", c7b.getFontName());
        assertEquals(48, c7b.getFontSize());

        // All use the default base style
        assertEquals("Normal", ss.getStyleDescription(c1a.getStyleIndex()).getName());
        assertEquals("Normal", ss.getStyleDescription(c1b.getStyleIndex()).getName());
        assertEquals("Heading 1", ss.getStyleDescription(c7a.getStyleIndex()).getName());
        assertEquals("Heading 1", ss.getStyleDescription(c7b.getStyleIndex()).getName());

        // Now check where they crop up
        assertEquals(
                0,
                c1a.getStartOffset()
        );
        assertEquals(
                p1_parts[0].length(),
                c1a.getEndOffset()
        );

        assertEquals(
                p1_parts[0].length(),
                c1b.getStartOffset()
        );
        assertEquals(
                p1_parts[0].length()+1,
                c1b.getEndOffset()
        );

        assertEquals(
                p1_parts[0].length() + 1 +
                p1_parts[1].length() + 1 +
                p1_parts[2].length() + 1 +
                p1_parts[3].length() + 1 +
                p1_parts[4].length() + 1 +
                p1_parts[5].length() + 1,
                c7a.getStartOffset()
        );
        assertEquals(
                p1_parts[0].length() + 1 +
                p1_parts[1].length() + 1 +
                p1_parts[2].length() + 1 +
                p1_parts[3].length() + 1 +
                p1_parts[4].length() + 1 +
                p1_parts[5].length() + 1 +
                1,
                c7a.getEndOffset()
        );

        assertEquals(
                p1_parts[0].length() + 1 +
                p1_parts[1].length() + 1 +
                p1_parts[2].length() + 1 +
                p1_parts[3].length() + 1 +
                p1_parts[4].length() + 1 +
                p1_parts[5].length() + 1 +
                1,
                c7b.getStartOffset()
        );
        assertEquals(
                p1_parts[0].length() + 1 +
                p1_parts[1].length() + 1 +
                p1_parts[2].length() + 1 +
                p1_parts[3].length() + 1 +
                p1_parts[4].length() + 1 +
                p1_parts[5].length() + 1 +
                p1_parts[6].length() + 1,
                c7b.getEndOffset()
        );

        // This document also has 22 styles
        assertEquals(22, ss.numStyles());

        // Ensure none of the paragraphs refer to one that isn't there,
        //  and none of their character runs either
        for(int i=0; i<r.numParagraphs(); i++) {
            Paragraph p = r.getParagraph(i);
            int styleIndex = p.getStyleIndex();
            assertTrue(styleIndex < 22);
            assertNotNull(ss.getStyleDescription(styleIndex).getName());
        }
        for(int i=0; i<r.numCharacterRuns(); i++) {
            CharacterRun c = r.getCharacterRun(i);
            int styleIndex = c.getStyleIndex();
            assertTrue(styleIndex < 22);
            assertNotNull(ss.getStyleDescription(styleIndex).getName());
        }
    }
View Full Code Here

  {
    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);
View Full Code Here

TOP

Related Classes of org.apache.poi.hwpf.model.StyleSheet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.