Fixed typos
[gnumeric.git] / plugins / excel / ms-excel-util.h
blob05505a26db8f52fbb4be952b5bbc201a68f6df9b
1 /* vim: set sw=8 ts=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /**
3 * ms-excel-util.h: Utility functions for MS Excel import / export
5 * Author:
6 * Jon K Hellan (hellan@acm.org)
8 * (C) 1999-2005 Jon K Hellan
9 **/
10 #ifndef GNM_MS_EXCEL_UTIL_H
11 #define GNM_MS_EXCEL_UTIL_H
13 #include <glib.h>
14 #include <stdlib.h>
15 #include <print-info.h>
17 #define XL_CHECK_CONDITION_FULL(cond,code) \
18 do { \
19 if (!(cond)) { \
20 g_warning ("File is most likely corrupted.\n" \
21 "(Condition \"%s\" failed in %s.)\n", \
22 #cond, \
23 G_STRFUNC); \
24 code \
25 } \
26 } while (0)
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;
39 struct _TwoWayTable {
40 GHashTable *all_keys;
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,
48 gboolean was_added,
49 gint index,
50 gconstpointer closure);
52 TwoWayTable *
53 two_way_table_new (GHashFunc hash_func,
54 GCompareFunc key_compare_func,
55 gint base,
56 GDestroyNotify key_destroy_func);
58 void
59 two_way_table_free (TwoWayTable *table);
61 gint
62 two_way_table_put (TwoWayTable const *table, gpointer key,
63 gboolean unique, AfterPutFunc apf, gconstpointer closure);
65 void
66 two_way_table_move (TwoWayTable const *table, gint dst_idx, gint src_idx);
68 gint
69 two_way_table_key_to_idx (TwoWayTable const *table, gconstpointer key);
71 gpointer
72 two_way_table_idx_to_key (TwoWayTable const *table, gint idx);
74 /*****************************************************************************/
76 typedef struct {
77 char const *name;
78 int defcol_unit;
79 int colinfo_baseline;
80 double colinfo_step;
81 } XL_font_width;
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 /*****************************************************************************/
101 typedef enum {
102 XL_ARROW_NONE = 0,
103 XL_ARROW_REGULAR = 1,
104 XL_ARROW_STEALTH = 2,
105 XL_ARROW_DIAMOND = 3,
106 XL_ARROW_OVAL = 4,
107 XL_ARROW_OPEN = 5
108 } XLArrowType;
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);
119 typedef struct {
120 GnmValidation const *v;
121 GnmInputMsg *msg;
122 GSList *ranges;
123 } XLValInputPair;
124 GHashTable *xls_collect_validations (GnmStyleList *ptr,
125 int max_col, int max_row);
127 /*****************************************************************************/
129 #endif /* GNM_MS_EXCEL_UTIL_H */