void wbook_destroy(struct wbookctx *wbook) { int i; if (!wbook->fileclosed) wbook_close(wbook); /* Delete all sheets */ for (i = 0; i < wbook->sheetcount; i++) { wsheet_destroy(wbook->sheets[i]); } /* Delete all formats */ for (i = 0; i < wbook->formatcount; i++) { //free(wbook->formats[i]); fmt_destroy(wbook->formats[i]); } fmt_destroy(wbook->tmp_format); ow_destroy(wbook->OLEwriter); bw_destroy(wbook->biff); free(wbook->sheets); free(wbook->formats); free(wbook); }
static int _test_div(void) { int i; struct wsheet* wsh; struct obj objs[] = { /* * objs out of div. * ---------------- */ /* out at left */ {{OUTL_L, IN1_T, OUTL_R, IN1_B}, 0, 0, NULL}, /* out at right */ {{OUTR_L, IN1_T, OUTR_R, IN1_B}, 0, 0, NULL}, /* out at top */ {{IN12_L, OUTT_T, IN12_R, OUTT_B}, 0, 0, NULL}, /* out at bottom */ {{IN12_L, OUTB_T, IN12_R, OUTB_B}, 0, 0, NULL}, /* out at top left */ {{OUTL_L, OUTT_T, OUTL_R, OUTT_B}, 0, 0, NULL}, /* out at top right */ {{OUTR_L, OUTT_T, OUTR_R, OUTT_B}, 0, 0, NULL}, /* out at bottom left */ {{OUTL_L, OUTB_T, OUTL_R, OUTB_B}, 0, 0, NULL}, /* out at bottom right */ {{OUTR_L, OUTB_T, OUTR_R, OUTB_B}, 0, 0, NULL}, /* * objs overwrapped * ---------------- */ /* overwrapped at left */ {{OUTL_R, IN1_T, IN1_L, IN1_B}, 0, 0, NULL}, /* overwrapped at right */ {{IN2_R, IN1_T, OUTR_L, IN1_B}, 0, 0, NULL}, /* overwrapped at top */ {{IN1_L, OUTT_B, IN1_R, IN1_T}, 0, 0, NULL}, /* overwrapped at bottom */ {{IN1_L, IN1_B, IN1_R, OUTB_T}, 0, 0, NULL}, /* overwrapped at left top */ {{OUTL_R, OUTT_B, IN1_L, IN1_B}, 0, 0, NULL}, /* overwrapped at right top */ {{IN2_R, OUTT_B, OUTR_L, IN1_B}, 0, 0, NULL}, /* overwrapped at left bottom */ {{OUTL_R, IN1_B, IN1_R, OUTB_T}, 0, 0, NULL}, /* overwrapped at right bottom */ {{IN2_R, IN2_B, OUTR_L, OUTB_T}, 0, 0, NULL}, /* overwrapped at top with 1 and 2 */ {{OUTL_R, OUTT_B, OUTR_L, IN1_T}, 0, 0, NULL}, /* overwrapped at bottom with 1 and 2 */ {{OUTL_R, IN1_B, OUTR_L, OUTB_T}, 0, 0, NULL}, /* overwrapped at middle with 1 and 2 */ {{OUTL_R, IN1_T, OUTR_L, IN1_B}, 0, 0, NULL}, /* * objects covering 1 and 2 * ------------------------ */ /* overwrapped (covering 1 and 2) */ {{OUTL_R, OUTT_B, OUTR_L, OUTB_T}, 0, 0, NULL}, }; wsh = wsheet_create(); wsheet_init(wsh, 100, 100, 2, 1); for (i = 0; i < sizeof(objs)/sizeof(objs[0]); i++) { wsheet_add_obj(wsh, objs[i].ty, objs[i].priv, objs[i].extent.l, objs[i].extent.t, objs[i].extent.r, objs[i].extent.b); /* printf("%d, %d\n", list_size(&wsh->divs[0][0].objs), list_size(&wsh->divs[0][1].objs)); */ } wassert(9 == list_size(&wsh->divs[0][0].objs)); wassert(7 == list_size(&wsh->divs[0][1].objs)); wsheet_destroy(wsh); wsys_deinit(); return 0; }