Fixed typos
[gnumeric.git] / plugins / excel / ms-excel-write.h
blobf3e970df3c4b378309ed70d51e6789ee1df285a5
1 /* vim: set sw=8 ts=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /**
3 * ms-excel-write.h: MS Excel export
5 * Authors:
6 * Jody Goldberg (jody@gnome.org)
7 * Michael Meeks (michael@ximian.com)
9 * (C) 1998-2001 Michael Meeks
10 * (C) 2002-2005 Jody Goldberg
11 **/
12 #ifndef GNM_MS_EXCEL_WRITE_H
13 #define GNM_MS_EXCEL_WRITE_H
15 #include "ms-biff.h"
16 #include "ms-excel-biff.h"
17 #include "ms-excel-util.h"
18 #include "style.h"
19 #include <goffice-data.h>
21 typedef struct {
22 Sheet const *a, *b;
23 int idx_a, idx_b;
24 } ExcelSheetPair;
26 typedef struct {
27 /* Don't use GnmFont. In the case where a font does not exist on the
28 * display system it does the wrong thing. GnmStyle can contain an
29 * invalid font. GnmFont gets remapped to the default
31 guint32 color;
32 char const *font_name;
33 char *font_name_copy; /* some times we need to keep a local copy */
34 double size_pts;
35 gboolean is_bold;
36 gboolean is_italic;
37 gboolean is_auto;
38 GnmUnderline underline;
39 gboolean strikethrough;
40 unsigned script;
41 } ExcelWriteFont;
43 typedef struct {
44 ExcelWriteState *ewb;
45 Sheet *gnum_sheet;
46 unsigned streamPos;
47 guint32 boundsheetPos;
48 gint32 max_col, max_row;
49 guint16 *col_xf;
50 GnmStyle **col_style;
51 GnmStyleList *conditions, *hlinks, *validations;
52 GSList *blips, *objects, *graphs, *comments;
53 GHashTable *commentshash;
54 GHashTable *widget_macroname;
55 unsigned cur_obj, num_objs;
56 } ExcelWriteSheet;
58 typedef struct {
59 Workbook const *wb;
60 WorkbookView const *wb_view;
62 struct {
63 TwoWayTable *two_way_table;
64 GnmStyle *default_style;
65 GHashTable *value_fmt_styles;
66 GHashTable *cell_style_variant;
67 } xf;
68 struct {
69 TwoWayTable *two_way_table;
70 guint8 entry_in_use[EXCEL_DEF_PAL_LEN];
71 } pal;
72 struct {
73 TwoWayTable *two_way_table;
74 } fonts;
75 struct {
76 TwoWayTable *two_way_table;
77 } formats;
78 GHashTable *pivot_caches;
79 } XLExportBase;
81 struct _XLSExporter {
82 XLExportBase base;
84 GOIOContext *io_context;
85 BiffPut *bp;
87 GPtrArray *esheets;
88 GHashTable *function_map;
89 GHashTable *sheet_pairs;
90 GHashTable *cell_markup;
92 /* we use the ewb as a closure for things, this is useful */
93 int tmp_counter;
94 int supbook_idx;
96 gboolean double_stream_file;
97 GPtrArray *externnames;
98 GHashTable *names;
99 unsigned streamPos;
101 /* no need to use a full fledged two table, we already know that the
102 * Strings are unique. */
103 struct {
104 GHashTable *strings;
105 GPtrArray *indicies;
106 } sst;
108 unsigned num_obj_groups, cur_obj_group, cur_blip;
109 gboolean export_macros;
111 guint32 unique_name_id;
114 #define XF_RESERVED 21
115 #define XF_MAGIC 0
116 #define FONTS_MINIMUM 5
117 #define FONT_SKIP 4
118 #define FONT_MAGIC 0
119 #define FORMAT_MAGIC 0
120 #define PALETTE_BLACK 8
121 #define PALETTE_WHITE 9
122 #define PALETTE_AUTO_PATTERN 64
123 #define PALETTE_AUTO_BACK 65
124 #define PALETTE_AUTO_FONT 0x7fff
125 #define FILL_NONE 0
126 #define FILL_SOLID 1
127 #define FILL_MAGIC FILL_NONE
128 #define BORDER_MAGIC GNM_STYLE_BORDER_NONE
130 typedef enum {
131 STR_ONE_BYTE_LENGTH = 0,
132 STR_TWO_BYTE_LENGTH = 1,
133 STR_FOUR_BYTE_LENGTH = 2,
134 STR_NO_LENGTH = 3,
135 STR_LENGTH_MASK = 3, /* (1 << (flag & LENGTH_MASK)) == size */
137 /* biff7 will always be LEN_IN_BYTES,
138 * biff8 will respect the flag and default to length in characters */
139 STR_LEN_IN_BYTES = 1 << 2,
141 /* Drop 2byte/rich/phonetic header and force the use of 2byte chars */
142 STR_SUPPRESS_HEADER = 1 << 3,
144 /* include a trailing null */
145 STR_TRAILING_NULL = 1 << 4
146 } WriteStringFlags;
148 unsigned excel_write_string (BiffPut *bp, WriteStringFlags flags,
149 guint8 const *txt);
150 unsigned excel_write_BOF (BiffPut *bp, MsBiffFileType type);
151 void excel_write_SETUP (BiffPut *bp, ExcelWriteSheet *esheet);
152 void excel_write_SCL (BiffPut *bp, double zoom, gboolean force);
154 int palette_get_index (XLExportBase const *ewb, guint c);
155 int excel_write_get_externsheet_idx (ExcelWriteState *wb,
156 Sheet *gnum_sheeta,
157 Sheet *gnum_sheetb);
159 int excel_write_map_errcode (GnmValue const *v);
161 GHashTable *excel_collect_pivot_caches (Workbook const *wb);
163 void excel_sheet_extent (Sheet const *sheet, GnmRange *extent, GnmStyle **col_styles,
164 int maxcols, int maxrows, GOIOContext *io_context);
166 int excel_font_from_go_font (XLExportBase *ewb, GOFont const *font);
168 void xls_write_pivot_caches (ExcelWriteState *ewb, GsfOutfile *outfile,
169 MsBiffVersion version, int codepage);
171 int excel_write_add_object_format (ExcelWriteState *ewb, GOFormat *format);
173 #endif /* GNM_MS_EXCEL_WRITE_H */