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

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


        ColumnInfoRecordsAggregate columns = new ColumnInfoRecordsAggregate();
        records.add( columns );
        _columnInfos = columns;
        _dimensions = createDimensions();
        records.add(_dimensions);
        _rowsAggregate = new RowRecordsAggregate();
        records.add(_rowsAggregate);
        // 'Sheet View Settings'
        records.add(windowTwo = createWindowTwo());
        _selection = createSelection();
        records.add(_selection);
View Full Code Here


        // Make sure the array formula has been removed properly

        recs = RecordInspector.getRecords(s, 0);
        assertTrue(findRecordOfType(recs, ArrayRecord.class, 0) < 0);
        assertTrue(findRecordOfType(recs, FormulaRecord.class, 0) < 0);
        RowRecordsAggregate rra = s.getSheet().getRowsAggregate();
        SharedValueManager svm = TestSharedValueManager.extractFromRRA(rra);
        if (svm.getArrayRecord(4, 1) != null) {
            throw new AssertionFailedError("Array record was not cleaned up properly.");
        }
    }
View Full Code Here

                if (retval._rowsAggregate != null) {
                    throw new RuntimeException("row/cell records found in the wrong place");
                }
                RowBlocksReader rbr = new RowBlocksReader(inRecs, k);
                retval._mergedCellsTable.addRecords(rbr.getLooseMergedCells());
                retval._rowsAggregate = new RowRecordsAggregate(rbr.getPlainRecordStream(), rbr.getSharedFormulaManager());
                records.add(retval._rowsAggregate); //only add the aggregate once
                k += rbr.getTotalNumberOfRecords() - 1;
                continue;
            }
            
            if (PageSettingsBlock.isComponentRecord(rec.getSid())) {
                RecordStream rs = new RecordStream(inRecs, k);
                PageSettingsBlock psb = new PageSettingsBlock(rs);
                if (bofEofNestingLevel == 1) {
                    if (retval._psBlock == null) {
                        retval._psBlock = psb;
                    } else {
                        // more than one 'Page Settings Block' at nesting level 1 ?
                        // apparently this happens in about 15 test sample files
                    }
                }
                records.add(psb);
                k += rs.getCountRead()-1;
                continue;
            }
           
            if (rec.getSid() == MergeCellsRecord.sid) {
                // when the MergedCellsTable is found in the right place, we expect those records to be contiguous
                RecordStream rs = new RecordStream(inRecs, k);
                retval._mergedCellsTable.read(rs);
                k += rs.getCountRead()-1;
                continue;
            }
            if (rec.getSid() == UncalcedRecord.sid) {
                // don't add UncalcedRecord to the list
                retval._isUncalced = true; // this flag is enough
                continue;
            }

            if (rec.getSid() == BOFRecord.sid)
            {
                bofEofNestingLevel++;
                if (log.check( POILogger.DEBUG ))
                    log.log(POILogger.DEBUG, "Hit BOF record. Nesting increased to " + bofEofNestingLevel);
            }
            else if (rec.getSid() == EOFRecord.sid)
            {
                --bofEofNestingLevel;
                if (log.check( POILogger.DEBUG ))
                    log.log(POILogger.DEBUG, "Hit EOF record. Nesting decreased to " + bofEofNestingLevel);
                if (bofEofNestingLevel == 0) {
                    records.add(rec);
                    retval.eofLoc = k;
                    break;
                }
            }
            else if (rec.getSid() == DimensionsRecord.sid)
            {
                // Make a columns aggregate if one hasn't ready been created.
                if (retval._columnInfos == null)
                {
                    retval._columnInfos = new ColumnInfoRecordsAggregate();
                    records.add(retval._columnInfos);
                }

                retval._dimensions    = ( DimensionsRecord ) rec;
                retval.dimsloc = records.size();
            }
            else if (rec.getSid() == DefaultColWidthRecord.sid)
            {
                retval.defaultcolwidth = ( DefaultColWidthRecord ) rec;
            }
            else if (rec.getSid() == DefaultRowHeightRecord.sid)
            {
                retval.defaultrowheight = ( DefaultRowHeightRecord ) rec;
            }
            else if ( rec.getSid() == PrintGridlinesRecord.sid )
            {
                retval.printGridlines = (PrintGridlinesRecord) rec;
            }
            else if ( rec.getSid() == GridsetRecord.sid )
            {
                retval.gridset = (GridsetRecord) rec;
            }
            else if ( rec.getSid() == SelectionRecord.sid )
            {
                retval.selection = (SelectionRecord) rec;
            }
            else if ( rec.getSid() == WindowTwoRecord.sid )
            {
                retval.windowTwo = (WindowTwoRecord) rec;
            }
            else if ( rec.getSid() == ProtectRecord.sid )
            {
                retval.protect = (ProtectRecord) rec;
            }
            else if ( rec.getSid() == ObjectProtectRecord.sid )
            {
                retval.objprotect = (ObjectProtectRecord) rec;
            }
            else if ( rec.getSid() == ScenarioProtectRecord.sid )
            {
                retval.scenprotect = (ScenarioProtectRecord) rec;
            }
            else if ( rec.getSid() == PasswordRecord.sid )
            {
                retval.password = (PasswordRecord) rec;
            }

            records.add(rec);
        }
        if (retval._dimensions == null) {
            throw new RuntimeException("DimensionsRecord was not found");
        }
        if (retval.windowTwo == null) {
            throw new RuntimeException("WINDOW2 was not found");
        }
        if (retval._rowsAggregate == null) {
          retval._rowsAggregate = new RowRecordsAggregate();
            records.add(retval.dimsloc + 1, retval._rowsAggregate);
        }
        // put merged cells table in the right place (regardless of where the first MergedCellsRecord was found */
        RecordOrderer.addNewSheetRecord(records, retval._mergedCellsTable);
        retval.records = records;
View Full Code Here

        records.add( columns );
        retval._columnInfos = columns;
        retval._dimensions = createDimensions();
        records.add(retval._dimensions);
        retval.dimsloc = records.size()-1;
        retval._rowsAggregate = new RowRecordsAggregate();
        records.add(retval._rowsAggregate);
        // 'Sheet View Settings'
        records.add(retval.windowTwo = retval.createWindowTwo());
        retval.selection = createSelection();
        records.add(retval.selection);
View Full Code Here

    public static Sheet createSheet(RecordStream rs) {
        return new Sheet(rs);
    }
    private Sheet(RecordStream rs) {
        _mergedCellsTable = new MergedCellsTable();
        RowRecordsAggregate rra = null;

        records            = new ArrayList(128);
        // TODO - take chart streams off into separate java objects
        int       bofEofNestingLevel = 0// nesting level can only get to 2 (when charts are present)
        int dimsloc = -1;

        while (rs.hasNext()) {
            int recSid = rs.peekNextSid();

            if ( recSid == CFHeaderRecord.sid ) {
                condFormatting = new ConditionalFormattingTable(rs);
                records.add(condFormatting);
                continue;
            }

            if (recSid == ColumnInfoRecord.sid) {
                _columnInfos = new ColumnInfoRecordsAggregate(rs);
                records.add(_columnInfos);
                continue;
            }
            if ( recSid == DVALRecord.sid) {
                _dataValidityTable = new DataValidityTable(rs);
                records.add(_dataValidityTable);
                continue;
            }

            if (RecordOrderer.isRowBlockRecord(recSid) && bofEofNestingLevel == 1 ) {
                //only add the aggregate once
                if (rra != null) {
                    throw new RuntimeException("row/cell records found in the wrong place");
                }
                RowBlocksReader rbr = new RowBlocksReader(rs);
                _mergedCellsTable.addRecords(rbr.getLooseMergedCells());
                rra = new RowRecordsAggregate(rbr.getPlainRecordStream(), rbr.getSharedFormulaManager());
                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 ?
                        // apparently this happens in about 15 test sample files
                    }
                }
                records.add(psb);
                continue;
            }

            if (recSid == MergeCellsRecord.sid) {
                // when the MergedCellsTable is found in the right place, we expect those records to be contiguous
                _mergedCellsTable.read(rs);
                continue;
            }

            Record rec = rs.getNext();
            if ( recSid == IndexRecord.sid ) {
                // ignore INDEX record because it is only needed by Excel,
                // and POI always re-calculates its contents
                continue;
            }


            if (recSid == UncalcedRecord.sid) {
                // don't add UncalcedRecord to the list
                _isUncalced = true; // this flag is enough
                continue;
            }

            if (recSid == BOFRecord.sid)
            {
                bofEofNestingLevel++;
                if (log.check( POILogger.DEBUG ))
                    log.log(POILogger.DEBUG, "Hit BOF record. Nesting increased to " + bofEofNestingLevel);
            }
            else if (recSid == EOFRecord.sid)
            {
                --bofEofNestingLevel;
                if (log.check( POILogger.DEBUG ))
                    log.log(POILogger.DEBUG, "Hit EOF record. Nesting decreased to " + bofEofNestingLevel);
                if (bofEofNestingLevel == 0) {
                    records.add(rec);
                    break;
                }
            }
            else if (recSid == DimensionsRecord.sid)
            {
                // Make a columns aggregate if one hasn't ready been created.
                if (_columnInfos == null)
                {
                    _columnInfos = new ColumnInfoRecordsAggregate();
                    records.add(_columnInfos);
                }

                _dimensions    = ( DimensionsRecord ) rec;
                dimsloc = records.size();
            }
            else if (recSid == DefaultColWidthRecord.sid)
            {
                defaultcolwidth = ( DefaultColWidthRecord ) rec;
            }
            else if (recSid == DefaultRowHeightRecord.sid)
            {
                defaultrowheight = ( DefaultRowHeightRecord ) rec;
            }
            else if ( recSid == PrintGridlinesRecord.sid )
            {
                printGridlines = (PrintGridlinesRecord) rec;
            }
            else if ( recSid == GridsetRecord.sid )
            {
                gridset = (GridsetRecord) rec;
            }
            else if ( recSid == SelectionRecord.sid )
            {
                selection = (SelectionRecord) rec;
            }
            else if ( recSid == WindowTwoRecord.sid )
            {
                windowTwo = (WindowTwoRecord) rec;
            }
            else if ( recSid == ProtectRecord.sid )
            {
                protect = (ProtectRecord) rec;
            }
            else if ( recSid == ObjectProtectRecord.sid )
            {
                objprotect = (ObjectProtectRecord) rec;
            }
            else if ( recSid == ScenarioProtectRecord.sid )
            {
                scenprotect = (ScenarioProtectRecord) rec;
            }
            else if ( recSid == PasswordRecord.sid )
            {
                password = (PasswordRecord) rec;
            }

            records.add(rec);
        }
        if (_dimensions == null) {
            throw new RuntimeException("DimensionsRecord was not found");
        }
        if (windowTwo == null) {
            throw new RuntimeException("WINDOW2 was not found");
        }
        if (rra == null) {
            rra = new RowRecordsAggregate();
            records.add(dimsloc + 1, rra);
        }
        _rowsAggregate = rra;
        // put merged cells table in the right place (regardless of where the first MergedCellsRecord was found */
        RecordOrderer.addNewSheetRecord(records, _mergedCellsTable);
View Full Code Here

        ColumnInfoRecordsAggregate columns = new ColumnInfoRecordsAggregate();
        records.add( columns );
        _columnInfos = columns;
        _dimensions = createDimensions();
        records.add(_dimensions);
        _rowsAggregate = new RowRecordsAggregate();
        records.add(_rowsAggregate);
        // 'Sheet View Settings'
        records.add(windowTwo = createWindowTwo());
        selection = createSelection();
        records.add(selection);
View Full Code Here

                RowRecord row = (RowRecord)rec;
                if (!isfirstrow) rec = null; //only add the aggregate once

                if ( isfirstrow )
                {
                    retval.rows = new RowRecordsAggregate();
                    rec = retval.rows;                   
                    isfirstrow = false;
                }
                retval.rows.insertRow(row);
            }
View Full Code Here

        //Need to pull out the Row record and the Value records from their
        //Aggregates.
        //This is probably the best way to do it since we probably dont want the createSheet
        //To cater for these artificial Record types
        if (rec instanceof RowRecordsAggregate) {
          RowRecordsAggregate rrAgg = (RowRecordsAggregate)rec;
          for (Iterator rowIter = rrAgg.getIterator();rowIter.hasNext();) {
            Record rowRec = (Record)rowIter.next();
            clonedRecords.add(rowRec);
          }
        } else if (rec instanceof ValueRecordsAggregate) {
          ValueRecordsAggregate vrAgg = (ValueRecordsAggregate)rec;
View Full Code Here

    private void checkRows()
    {
        if (rows == null)
        {
            rows = new RowRecordsAggregate();
            records.add(getDimsLoc() + 1, rows);
        }
    }
View Full Code Here

                RowRecord row = (RowRecord)rec;
                if (!isfirstrow) rec = null; //only add the aggregate once

                if ( isfirstrow )
                {
                    retval.rows = new RowRecordsAggregate();
                    rec = retval.rows;                   
                    isfirstrow = false;
                }
                retval.rows.insertRow(row);
            }
View Full Code Here

TOP

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

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.