public void endRow(IRowContent row) throws BirtException {
    if (cellEmitter != null) {
      cellEmitter.endRow(row);
    } else {
      if (!isNestTable()) {
        layout.endRow(row);
        lastRowId = row.getRowID();
        hasDropCell = layout.hasDropCell();
        if (hasDropCell()) {
          return;
        }
        if (layoutEvents.size() > 0) {
          flush();
          return;
        }
      }
      // For fixed layout reports and in run task, we need to emit the
      // invisible content to PDF layout engine.
      boolean hiddenMask =
          context.isFixedLayout()
              && (Integer) context.getLayoutEngine().getOption(EngineTask.TASK_TYPE)
                  == IEngineTask.TASK_RUN;
      boolean isHidden =
          LayoutUtil.isHidden(
              row, emitter.getOutputFormat(), context.getOutputDisplayNone(), hiddenMask);

      if (!isHidden) {
        emitter.endRow(row);
      }
    }
  }
 public void endTable(ITableContent table) throws BirtException {
   if (cellEmitter != null) {
     cellEmitter.endTable(table);
   } else {
     if (!isNestTable()) {
       resolveAll(isContentFinished(table));
       flush();
       emitter.endTable(layout.getWrappedTableContent());
     } else {
       emitter.endTable(table);
     }
   }
   nestTableCount--;
 }
 public void startTableGroup(ITableGroupContent group) throws BirtException {
   if (cellEmitter != null) {
     cellEmitter.startTableGroup(group);
   } else {
     if (!isNestTable()) {
       int groupLevel = group.getGroupLevel();
       groupStack.push(Integer.valueOf(groupLevel));
       if (hasDropCell()) {
         layoutEvents.push(new LayoutEvent(LayoutEvent.START_GROUP, group));
         return;
       }
     }
     emitter.startTableGroup(group);
   }
 }
 public void startTable(ITableContent table) throws BirtException {
   nestTableCount++;
   if (cellEmitter != null) {
     cellEmitter.startTable(table);
   } else {
     if (!isNestTable()) {
       UnresolvedRowHint hint = null;
       initLayout(table);
       emitter.startTable(layout.getWrappedTableContent());
       this.lastRowId = -1;
     } else {
       emitter.startTable(table);
     }
   }
 }
 public void endCell(ICellContent cell) throws BirtException {
   if (!isNestTable()) {
     if (cellEmitter != null) {
       cellEmitter = null;
       return;
     } else {
       emitter.endCell(layout.getWrappedCellContent(cell));
     }
   } else {
     if (cellEmitter != null) {
       cellEmitter.endCell(cell);
     } else {
       emitter.endCell(cell);
     }
   }
 }
  public void startRow(IRowContent row) throws BirtException {
    if (cellEmitter != null) {
      cellEmitter.startRow(row);
    } else {
      // For fixed layout reports and in run task, we need to emit the
      // invisible content to PDF layout engine.
      boolean hiddenMask =
          context.isFixedLayout()
              && (Integer) context.getLayoutEngine().getOption(EngineTask.TASK_TYPE)
                  == IEngineTask.TASK_RUN;
      boolean isHidden =
          LayoutUtil.isHidden(
              row, emitter.getOutputFormat(), context.getOutputDisplayNone(), hiddenMask);

      if (!isNestTable()) {
        int rowId = row.getRowID();
        if (lastRowId >= 0 && rowId > lastRowId + 1) {
          for (int i = lastRowId + 1; i < rowId; i++) {
            IRowContent newRow = (IRowContent) row.cloneContent(false);
            newRow.setParent(row.getParent());
            newRow.setRowID(i);
            startRow(newRow);
            endRow(newRow);
          }
        }
        layout.createRow(row, isHidden);
        if (!isHidden) {
          if (hasDropCell()) {
            layoutEvents.push(
                new LayoutEvent(LayoutEvent.ON_ROW, new StartInfo(layout.getRowCount() - 1, 0)));
            return;
          } else if (layout.hasUnResolvedRow() && !LayoutUtil.isRepeatableRow(row)) {
            layoutEvents.push(
                new LayoutEvent(LayoutEvent.ON_ROW, new StartInfo(layout.getRowCount() - 1, 0)));
            hasDropCell = true;
            return;
          }
        }

        // TODO: here we need handle the hidden row and change the row
        // id.
      }
      if (!isHidden) {
        emitter.startRow(row);
      }
    }
  }
  public void startCell(ICellContent cell) throws BirtException {
    if (cellEmitter != null) {
      cellEmitter.startCell(cell);
    } else {
      if (!isNestTable()) {
        BufferedReportEmitter buffer = null;
        int colId = cell.getColumn();
        int colSpan = cell.getColSpan();
        int rowSpan = cell.getRowSpan();

        // the current executed cell is rowIndex, columnIndex
        // get the span value of that cell.
        if (cell.getGenerateBy() instanceof CellDesign) {
          CellDesign cellDesign = (CellDesign) cell.getGenerateBy();
          if (cellDesign != null) {
            String dropType = cellDesign.getDrop();
            if (dropType != null && !"none".equals(dropType)) // $NON-NLS-1$
            {
              rowSpan = createDropID(getGroupLevel(), dropType);
            }
          }
        }

        // the table has no cache, the cell is the first drop or spanned cell
        if (!hasDropCell() && (rowSpan < 0 || rowSpan > 1)) {
          layoutEvents.push(
              new LayoutEvent(
                  LayoutEvent.ON_FIRST_DROP_CELL, new StartInfo(layout.getRowCount() - 1, colId)));
        }
        if (hasDropCell() || rowSpan < 0 || rowSpan > 1) {
          buffer = new BufferedReportEmitter(emitter);
          cellEmitter = buffer;
        }
        // we need cache the cell
        createCell(colId, rowSpan, colSpan, new CellContent(cell, buffer));
        if (hasDropCell()) {
          return;
        }
        // TODO: changes the column id and output it.
        emitter.startCell(layout.getWrappedCellContent(cell));
      } else {
        emitter.startCell(cell);
      }
    }
  }
 public void startTableBand(ITableBandContent band) throws BirtException {
   if (cellEmitter != null) {
     cellEmitter.startTableBand(band);
   } else {
     if (!isNestTable()) {
       if (band.getBandType() == IBandContent.BAND_GROUP_FOOTER) {
         int groupLevel = getGroupLevel();
         resolveCellsOfDrop(groupLevel, false, true);
       }
       if (hasDropCell()) {
         layoutEvents.push(new LayoutEvent(LayoutEvent.START_BAND, band));
         return;
       }
       flush();
     }
     emitter.startTableBand(band);
   }
 }
 public void endTableBand(ITableBandContent band) throws BirtException {
   if (cellEmitter != null) {
     cellEmitter.endTableBand(band);
   } else {
     if (!isNestTable()) {
       if (LayoutUtil.isRepeatableBand(band)) {
         lastRowId = -1;
       }
       if (band.getBandType() == IBandContent.BAND_GROUP_FOOTER) {
         int groupLevel = getGroupLevel();
         resolveCellsOfDrop(groupLevel, true, isContentFinished(band));
       }
       if (hasDropCell()) {
         layoutEvents.push(new LayoutEvent(LayoutEvent.END_BAND, band));
         return;
       }
       flush();
     }
     emitter.endTableBand(band);
   }
 }
 public void endTableGroup(ITableGroupContent group) throws BirtException {
   if (cellEmitter != null) {
     cellEmitter.endTableGroup(group);
   } else {
     if (!isNestTable()) {
       // if there is no group footer, we still need to do with the
       // drop.
       int groupLevel = getGroupLevel();
       resolveCellsOfDrop(groupLevel, false, isContentFinished(group));
       resolveCellsOfDrop(groupLevel, true, isContentFinished(group));
       assert !groupStack.isEmpty();
       groupStack.pop();
       if (hasDropCell()) {
         layoutEvents.push(new LayoutEvent(LayoutEvent.END_GROUP, group));
         return;
       }
       flush();
     }
     emitter.endTableGroup(group);
   }
 }
  protected void flushRow(int rowId, int colId, boolean withStart) throws BirtException {
    int colCount = layout.getColCount();
    int columnId = layout.getColumnId(colId);
    Row row = layout.getRow(rowId);
    IRowContent rowContent = (IRowContent) row.getContent();
    if (withStart) {
      emitter.startRow(rowContent);
    }
    for (int j = columnId; j < colCount; j++) {
      Cell cell = row.getCell(j);
      if (cell.getStatus() == Cell.CELL_USED) {
        CellContent content = (CellContent) cell.getContent();
        CellContentWrapper tempCell = new CellContentWrapper(content.cell);
        tempCell.setColumn(cell.getColId());
        tempCell.setRowSpan(cell.getRowSpan());
        tempCell.setColSpan(cell.getColSpan());

        emitter.startCell(tempCell);
        if (content.buffer != null) {
          content.buffer.flush();
        }
        emitter.endCell(tempCell);
      }
      if (cell.getStatus() == Cell.CELL_EMPTY) {
        IReportContent report = rowContent.getReportContent();
        ICellContent cellContent = report.createCellContent();
        cellContent.setParent(rowContent);
        cellContent.setColumn(cell.getColId() + 1);
        cellContent.setRowSpan(cell.getRowSpan());
        cellContent.setColSpan(cell.getColSpan());
        emitter.startCell(cellContent);
        emitter.endCell(cellContent);
      }
    }
    emitter.endRow(rowContent);
  }
 public void start(IReportContent report) throws BirtException {
   emitter.start(report);
 }
 public void initialize(IEmitterServices service) throws BirtException {
   emitter.initialize(service);
 }
 public String getOutputFormat() {
   return emitter.getOutputFormat();
 }
 public void end(IReportContent report) throws BirtException {
   emitter.end(report);
 }