Package org.apache.poi.hssf.record.aggregates

Examples of org.apache.poi.hssf.record.aggregates.PageSettingsBlock


        retval.defaultrowheight = createDefaultRowHeight();
        records.add( retval.defaultrowheight );
        records.add( retval.createWSBool() );
       
        // 'Page Settings Block'
        retval._psBlock = new PageSettingsBlock();
        records.add(retval._psBlock);
       
        // 'Worksheet Protection Block' (after 'Page Settings Block' and before DEFCOLWIDTH)
        // PROTECT record normally goes here, don't add yet since the flag is initially false
       
View Full Code Here


    }

   
    public PageSettingsBlock getPageSettings() {
        if (_psBlock == null) {
            _psBlock = new PageSettingsBlock();
            RecordOrderer.addNewSheetRecord(records, _psBlock);
            dimsloc++;
        }
        return _psBlock;
    }
View Full Code Here

                records.add(rra); //only add the aggregate once
                continue;
            }

            if (PageSettingsBlock.isComponentRecord(recSid)) {
                PageSettingsBlock psb = new PageSettingsBlock(rs);
                if (bofEofNestingLevel == 1) {
                    if (_psBlock == null) {
                        _psBlock = psb;
                    } else {
                        // more than one 'Page Settings Block' at nesting level 1 ?
View Full Code Here

        defaultrowheight = createDefaultRowHeight();
        records.add( defaultrowheight );
        records.add( createWSBool() );

        // 'Page Settings Block'
        _psBlock = new PageSettingsBlock();
        records.add(_psBlock);

        // 'Worksheet Protection Block' (after 'Page Settings Block' and before DEFCOLWIDTH)
        // PROTECT record normally goes here, don't add yet since the flag is initially false
View Full Code Here

    }


    public PageSettingsBlock getPageSettings() {
        if (_psBlock == null) {
            _psBlock = new PageSettingsBlock();
            RecordOrderer.addNewSheetRecord(records, _psBlock);
        }
        return _psBlock;
    }
View Full Code Here

    public void testRowPageBreaks() {
        short colFrom = 0;
        short colTo = 255;

        Sheet worksheet = Sheet.createSheet();
        PageSettingsBlock sheet = worksheet.getPageSettings();
        sheet.setRowBreak(0, colFrom, colTo);

        assertTrue("no row break at 0", sheet.isRowBroken(0));
        assertEquals("1 row break available", 1, sheet.getNumRowBreaks());

        sheet.setRowBreak(0, colFrom, colTo);
        sheet.setRowBreak(0, colFrom, colTo);

        assertTrue("no row break at 0", sheet.isRowBroken(0));
        assertEquals("1 row break available", 1, sheet.getNumRowBreaks());

        sheet.setRowBreak(10, colFrom, colTo);
        sheet.setRowBreak(11, colFrom, colTo);

        assertTrue("no row break at 10", sheet.isRowBroken(10));
        assertTrue("no row break at 11", sheet.isRowBroken(11));
        assertEquals("3 row break available", 3, sheet.getNumRowBreaks());


        boolean is10 = false;
        boolean is0 = false;
        boolean is11 = false;

        int[] rowBreaks = sheet.getRowBreaks();
        for (int i = 0; i < rowBreaks.length; i++) {
            int main = rowBreaks[i];
            if (main != 0 && main != 10 && main != 11) fail("Invalid page break");
            if (main == 0)     is0 = true;
            if (main == 10) is10= true;
            if (main == 11) is11 = true;
        }

        assertTrue("one of the breaks didnt make it", is0 && is10 && is11);

        sheet.removeRowBreak(11);
        assertFalse("row should be removed", sheet.isRowBroken(11));

        sheet.removeRowBreak(0);
        assertFalse("row should be removed", sheet.isRowBroken(0));

        sheet.removeRowBreak(10);
        assertFalse("row should be removed", sheet.isRowBroken(10));

        assertEquals("no more breaks", 0, sheet.getNumRowBreaks());
    }
View Full Code Here

    public void testColPageBreaks() {
        short rowFrom = 0;
        short rowTo = (short)65535;

        Sheet worksheet = Sheet.createSheet();
        PageSettingsBlock sheet = worksheet.getPageSettings();
        sheet.setColumnBreak((short)0, rowFrom, rowTo);

        assertTrue("no col break at 0", sheet.isColumnBroken(0));
        assertEquals("1 col break available", 1, sheet.getNumColumnBreaks());

        sheet.setColumnBreak((short)0, rowFrom, rowTo);

        assertTrue("no col break at 0", sheet.isColumnBroken(0));
        assertEquals("1 col break available", 1, sheet.getNumColumnBreaks());

        sheet.setColumnBreak((short)1, rowFrom, rowTo);
        sheet.setColumnBreak((short)10, rowFrom, rowTo);
        sheet.setColumnBreak((short)15, rowFrom, rowTo);

        assertTrue("no col break at 1", sheet.isColumnBroken(1));
        assertTrue("no col break at 10", sheet.isColumnBroken(10));
        assertTrue("no col break at 15", sheet.isColumnBroken(15));
        assertEquals("4 col break available", 4, sheet.getNumColumnBreaks());

        boolean is10 = false;
        boolean is0 = false;
        boolean is1 = false;
        boolean is15 = false;

        int[] colBreaks = sheet.getColumnBreaks();
        for (int i = 0; i < colBreaks.length; i++) {
            int main = colBreaks[i];
            if (main != 0 && main != 1 && main != 10 && main != 15) fail("Invalid page break");
            if (main == 0is0 = true;
            if (main == 1is1 = true;
            if (main == 10) is10= true;
            if (main == 15) is15 = true;
        }

        assertTrue("one of the breaks didnt make it", is0 && is1 && is10 && is15);

        sheet.removeColumnBreak(15);
        assertFalse("column break should not be there", sheet.isColumnBroken(15));

        sheet.removeColumnBreak(0);
        assertFalse("column break should not be there", sheet.isColumnBroken(0));

        sheet.removeColumnBreak(1);
        assertFalse("column break should not be there", sheet.isColumnBroken(1));

        sheet.removeColumnBreak(10);
        assertFalse("column break should not be there", sheet.isColumnBroken(10));

        assertEquals("no more breaks", 0, sheet.getNumColumnBreaks());
    }
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.record.aggregates.PageSettingsBlock

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.