Пример #1
0
void deletecell(int col, int row, int display)
/* Deletes a cell */
{
 CELLPTR cellptr = cell[col][row];

 if (cellptr == NULL)
  return;
 switch (cellptr->attrib)
 {
  case TEXT :
   memleft += textcellsize(cellptr->v.text);
   clearoflags(col + 1, row, display);
   break;
  case VALUE :
   memleft += valuecellsize;
   break;
  case FORMULA :
   memleft += formulacellsize(cellptr->v.f.formula);
   break;
 } /* switch */
 format[col][row] &= ~OVERWRITE;
 free(cell[col][row]);
 cell[col][row] = NULL;
 if (col == lastcol)
  setlastcol();
 if (row == lastrow)
  setlastrow();
 updateoflags(col, row, display);
 changed = TRUE;
} /* deletecell */
Пример #2
0
void insertrow(int row)
/* Inserts a row */
{
 int counter, rowc;

 if (lastrow == MAXROWS - 1)
 {
  for (counter = 0; counter <= lastcol; counter++)
   deletecell(counter, lastrow, NOUPDATE);
  printfreemem();
 }
 if (row != MAXROWS - 1)
 {
  for (counter = 0; counter < MAXCOLS; counter++)
  {
   movmem(&cell[counter][row], &cell[counter][row + 1],
    sizeof(CELLPTR) * (MAXROWS - row - 1));
   movmem(&format[counter][row], &format[counter][row + 1], MAXROWS - row - 1);
  }
 }
 for (counter = 0; counter < MAXCOLS; counter++)
 {
  cell[counter][row] = NULL;
  format[counter][row] = DEFAULTFORMAT;
 }
 lastrow = MAXROWS - 1;
 setlastrow();
 for (counter = 0; counter <= lastcol; counter++)
 {
  for (rowc = 0; rowc <= lastrow; rowc++)
  {
   if ((cell[counter][rowc] != NULL) &&
    (cell[counter][rowc]->attrib == FORMULA))
    fixformula(counter, rowc, ROWADD, row);
  }
 }
 while (row <= bottomrow)
  displayrow(row++, NOUPDATE);
 changed = TRUE;
 recalc();
} /* insertrow */