static LISP x_get_cell(LISP row, LISP col, LISP bname) { int r, c; char *p; buffer *buf; int s; r = get_c_long(row); c = get_c_long(col); if (r < 1 || r > BUFFER_ROWS || c < 1 || c > BUFFER_COLS) return NIL; if (NULLP(bname)) { buf = siag_buffer; s = siag_sht; } else if (TYPEP(bname, tc_string)) { buf = find_sheet_by_name(bname->storage_as.string.data, siag_buffer, &s); if (buf == NULL) return NIL; } else return NIL; switch (ret_type(buf, s, r, c)) { case STRING: p = ret_string(buf, s, r, c); return strcons(strlen(p), p); case LABEL: p = ret_text(buf, s, r, c); return strcons(strlen(p), p); case EMPTY: case ERROR: return NIL; default: return flocons(ret_val(buf, s, r, c).number); } }
static LISP get_text(LISP row, LISP col) { char *text = ret_text(buffer_of_window(w_list), w_list->sht, get_c_long(row), get_c_long(col)); if (!text) text = ""; return strcons(strlen(text), text); }
void text::display() { char tmp[10000]; std::cout << "TEXT\n"; entity_display(); std::cout << "\ndxf_text = " << ret_text(tmp) << std::flush; }
static int save_flat(char *fn, buffer * buf) { int i, j, lastcell, lr; int s; FILE *fp; int sw = buf->sw, sh = buf->sh, sf = std_fmt_get(buf); int intp, f; MwFmt fmt; char *taddr; property_list *p; char *used_fmt = MwCalloc(MwFormatCount+1, 1); char *used_style = MwCalloc(nstyle+1, 1); if ((fp = fopen(fn, "w")) == (FILE *) 0) return 1; /* start by saving standard values */ fprintf(fp, "# Creator: %s\n", version); fprintf(fp, ".sw %d\n", sw); fprintf(fp, ".sh %d\n", sh); fprintf(fp, ".margins %d %d %d %d %d %d\n", buf->top_margin, buf->bottom_margin, buf->left_margin, buf->right_margin, buf->header_margin, buf->footer_margin); fprintf(fp, ".paper %s %d %d %d\n", buf->paper_name, buf->paper_width, buf->paper_height, buf->orientation); fprintf(fp, ".header %s\n", buf->header); fprintf(fp, ".footer %s\n", buf->footer); fprintf(fp, ".header_on_first %d\n", buf->header_on_first); fprintf(fp, ".first_page %d\n", buf->first_page_number); fprintf(fp, ".a1_refs %d\n", buf->a1_refs); MwDecodeFormat(sf, ~0, &fmt); if (!used_style[fmt.style]) { /* haven't saved style before */ save_styles(fp, fmt.style); used_style[fmt.style] = 1; } if (!used_fmt[sf]) { /* we haven't saved this format before */ MwSaveFormats(fp, sf); used_fmt[sf] = 1; } fprintf(fp, ".nsf %d\n", sf); /* properties */ for (p = buf->p_list; p; p = p->next) { fprintf(fp, ".p%d %s\n", strlen(p->value), p->key); fwrite(p->value, strlen(p->value), 1, fp); fprintf(fp, "\n"); /* terminate last line */ } for (s = 0; s < buf->nsht; s++) { fprintf(fp, ".sheet %d %s\n", s, buf->sht[s].name); lr = line_last_used(buf, s); fprintf(fp, "# %s\n# %d lines\n#\n", fn, lr); for (i = 1; i <= buf->sht[s].used_lines; i++) { int height = cell_height(buf, s, i); if (height != sh) fprintf(fp, ".rh %d %d\n", i, height); } for (i = 1; i <= buf->sht[s].used_cols; i++) { int width = cell_width(buf, s, i); if (width != sw) fprintf(fp, ".cw %d %d\n", i, width); } for (i = 0; i < buf->sht[s].nplugin; i++) { int width, height; int n = plugin_size_get(buf->sht[s].plugin[i].ph, &width, &height); if (n != 0) continue; fprintf(fp, ".plugin %d %d %s\n", buf->sht[s].plugin[i].row, buf->sht[s].plugin[i].col, buf->sht[s].plugin[i].name); fprintf(fp, ".plugin-geometry %d %d\n", width, height); } for (i = 1; i <= lr; i++) { fprintf(fp, "# Line %d\n", i); lastcell = col_last_changed(buf, s, i, sf); for (j = 1; j <= lastcell; j++) { f = ret_format(buf, s, i, j); MwDecodeFormat(f, ~0, &fmt); if (!used_style[fmt.style]) { /* haven't saved style before */ save_styles(fp, fmt.style); used_style[fmt.style] = 1; } if (!used_fmt[f]) { /* we haven't saved this format before */ MwSaveFormats(fp, f); used_fmt[f] = 1; } switch (ret_type(buf, s, i, j)) { case EMPTY: if (f != sf) fprintf(fp, "%d %d %d\t#\n", i, j, f); break; case LABEL: fprintf(fp, "%d %d %d\t\"%s\n", i, j, f, ret_text(buf, s, i, j)); break; case EMBED: fprintf(fp, "%d %d %d\tm%s\n", i, j, f, ret_text(buf, s, i, j)); break; case MNUMBER: case MTEXT: break; /* not stored at all */ /* ERRORs and CONSTANTs are stored as EXPRESSION */ default: /* EXPRESSION */ /* Special case SIOD and C for backward compatibility. */ intp = ret_interpreter(buf, s, i, j); taddr = ret_text(buf, s, i, j); if (intp == siod_interpreter && taddr[0] == '=') { intp = C_interpreter; taddr++; } if (intp == siod_interpreter) { fprintf(fp, "%d %d %d\t=%s\n", i, j, f, taddr); } else if (intp == C_interpreter) { fprintf(fp, "%d %d %d\t==%s\n", i, j, f, taddr); } else { fprintf(fp, "%d %d %d\t+%s,%s\n", i, j, f, interpreter2name(intp), taddr); } } } } } fprintf(fp, "# End of file %s\n", fn); fclose(fp); MwFree(used_fmt); MwFree(used_style); return 0; } /* save_flat */