1 /* vim: set sw=8 ts=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * ms-excel-util.h: Utility functions for MS Excel import / export
6 * Jon K Hellan (hellan@acm.org)
8 * (C) 1999-2005 Jon K Hellan
10 #ifndef GNM_MS_EXCEL_UTIL_H
11 #define GNM_MS_EXCEL_UTIL_H
15 #include <print-info.h>
17 #define XL_CHECK_CONDITION_FULL(cond,code) \
20 g_warning ("File is most likely corrupted.\n" \
21 "(Condition \"%s\" failed in %s.)\n", \
29 * Check a condition relating to whether the file being read is ok.
30 * (Not to be confused with checking a programming error.)
32 * If it fails, print a warning and return.
34 #define XL_CHECK_CONDITION(cond) XL_CHECK_CONDITION_FULL(cond,return;)
35 #define XL_CHECK_CONDITION_VAL(cond,val) XL_CHECK_CONDITION_FULL(cond,return val;)
37 typedef struct _TwoWayTable TwoWayTable
;
41 GHashTable
*unique_keys
;
42 GPtrArray
*idx_to_key
;
43 gint base
; /* Indices assigned consecutively from base */
44 GDestroyNotify key_destroy_func
;
47 typedef void (*AfterPutFunc
) (gconstpointer key
,
50 gconstpointer closure
);
53 two_way_table_new (GHashFunc hash_func
,
54 GCompareFunc key_compare_func
,
56 GDestroyNotify key_destroy_func
);
59 two_way_table_free (TwoWayTable
*table
);
62 two_way_table_put (TwoWayTable
const *table
, gpointer key
,
63 gboolean unique
, AfterPutFunc apf
, gconstpointer closure
);
66 two_way_table_move (TwoWayTable
const *table
, gint dst_idx
, gint src_idx
);
69 two_way_table_key_to_idx (TwoWayTable
const *table
, gconstpointer key
);
72 two_way_table_idx_to_key (TwoWayTable
const *table
, gint idx
);
74 /*****************************************************************************/
83 /* Measures base character width for column sizing. Returns width. */
84 /* A new version based on hard coded tables to match XL */
85 XL_font_width
const *xl_lookup_font_specs (char const *name
);
86 void destroy_xl_font_widths (void);
89 /*****************************************************************************/
91 const char *xls_paper_name (unsigned idx
, gboolean
*rotated
);
92 unsigned xls_paper_size (GtkPaperSize
*ps
, gboolean rotated
);
94 /*****************************************************************************/
96 char *xls_header_footer_export (const GnmPrintHF
*hf
);
97 void xls_header_footer_import (GnmPrintHF
**hf
, const char *txt
);
99 /*****************************************************************************/
103 XL_ARROW_REGULAR
= 1,
104 XL_ARROW_STEALTH
= 2,
105 XL_ARROW_DIAMOND
= 3,
110 void xls_arrow_to_xl (GOArrow
const *arrow
, double width
,
111 XLArrowType
*ptyp
, int *pl
, int *pw
);
112 void xls_arrow_from_xl (GOArrow
*arrow
, double width
,
113 XLArrowType typ
, int l
, int w
);
115 /*****************************************************************************/
117 GHashTable
*xls_collect_hlinks (GnmStyleList
*sl
, int max_col
, int max_row
);
120 GnmValidation
const *v
;
124 GHashTable
*xls_collect_validations (GnmStyleList
*ptr
,
125 int max_col
, int max_row
);
127 /*****************************************************************************/
129 #endif /* GNM_MS_EXCEL_UTIL_H */