File: ms-excel-write.h

package info (click to toggle)
gnumeric 1.12.32-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 129,260 kB
  • ctags: 25,173
  • sloc: ansic: 288,510; xml: 55,625; perl: 5,366; sh: 4,503; makefile: 2,905; yacc: 1,330; python: 203
file content (173 lines) | stat: -rw-r--r-- 4,489 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/* vim: set sw=8 ts=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/**
 * ms-excel-write.h: MS Excel export
 *
 * Authors:
 *    Jody Goldberg (jody@gnome.org)
 *    Michael Meeks (michael@ximian.com)
 *
 * (C) 1998-2001 Michael Meeks
 * (C) 2002-2005 Jody Goldberg
 **/
#ifndef GNM_MS_EXCEL_WRITE_H
#define GNM_MS_EXCEL_WRITE_H

#include "ms-biff.h"
#include "ms-excel-biff.h"
#include "ms-excel-util.h"
#include "style.h"
#include <goffice-data.h>

typedef struct {
	Sheet const *a, *b;
	int idx_a, idx_b;
} ExcelSheetPair;

typedef struct {
	/* Don't use GnmFont.  In the case where a font does not exist on the
	 * display system it does the wrong thing.  GnmStyle can contain an
	 * invalid font.  GnmFont gets remapped to the default
	 */
	guint32    color;
	char const *font_name;
	char       *font_name_copy; /* some times we need to keep a local copy */
	double		size_pts;
	gboolean	is_bold;
	gboolean	is_italic;
	gboolean	is_auto;
	GnmUnderline	underline;
	gboolean	strikethrough;
	unsigned	script;
} ExcelWriteFont;

typedef struct {
	ExcelWriteState	*ewb;
	Sheet		*gnum_sheet;
	unsigned	 streamPos;
	guint32		 boundsheetPos;
	gint32		 max_col, max_row;
	guint16		*col_xf;
	GnmStyle	**col_style;
	GnmStyleList	*conditions, *hlinks, *validations;
	GSList          *blips, *objects, *graphs, *comments;
	GHashTable	*commentshash;
	GHashTable      *widget_macroname;
	unsigned	 cur_obj, num_objs;
} ExcelWriteSheet;

typedef struct {
	Workbook      const *wb;
	WorkbookView  const *wb_view;

	struct {
		TwoWayTable *two_way_table;
		GnmStyle    *default_style;
		GHashTable  *value_fmt_styles;
		GHashTable  *cell_style_variant;
	} xf;
	struct {
		TwoWayTable *two_way_table;
		guint8 entry_in_use[EXCEL_DEF_PAL_LEN];
	} pal;
	struct {
		TwoWayTable *two_way_table;
	} fonts;
	struct {
		TwoWayTable *two_way_table;
	} formats;
	GHashTable *pivot_caches;
} XLExportBase;

struct _XLSExporter {
	XLExportBase	base;

	GOIOContext     *io_context;
	BiffPut	      *bp;

	GPtrArray     *esheets;
	GHashTable    *function_map;
	GHashTable    *sheet_pairs;
	GHashTable    *cell_markup;

	/* we use the ewb as a closure for things, this is useful */
	int tmp_counter;
	int supbook_idx;

	gboolean	 double_stream_file;
	GPtrArray	*externnames;
	GHashTable	*names;
	unsigned	 streamPos;

	/* no need to use a full fledged two table, we already know that the
	 * Strings are unique. */
	struct {
		GHashTable *strings;
		GPtrArray  *indicies;
	} sst;

	unsigned num_obj_groups, cur_obj_group, cur_blip;
	gboolean export_macros;

	guint32 unique_name_id;
};

#define XF_RESERVED 21
#define XF_MAGIC 0
#define FONTS_MINIMUM 5
#define FONT_SKIP 4
#define FONT_MAGIC 0
#define FORMAT_MAGIC 0
#define PALETTE_BLACK 8
#define PALETTE_WHITE 9
#define PALETTE_AUTO_PATTERN 64
#define PALETTE_AUTO_BACK 65
#define PALETTE_AUTO_FONT 0x7fff
#define FILL_NONE 0
#define FILL_SOLID 1
#define FILL_MAGIC FILL_NONE
#define BORDER_MAGIC GNM_STYLE_BORDER_NONE

typedef enum {
	STR_ONE_BYTE_LENGTH	= 0,
	STR_TWO_BYTE_LENGTH	= 1,
	STR_FOUR_BYTE_LENGTH	= 2,
	STR_NO_LENGTH		= 3,
	STR_LENGTH_MASK		= 3, /* (1 << (flag & LENGTH_MASK)) == size */

	/* biff7 will always be LEN_IN_BYTES,
	 * biff8 will respect the flag and default to length in characters */
	STR_LEN_IN_BYTES	= 1 << 2,

	/* Drop 2byte/rich/phonetic header and force the use of 2byte chars */
	STR_SUPPRESS_HEADER	= 1 << 3,

	/* include a trailing null */
	STR_TRAILING_NULL	= 1 << 4
} WriteStringFlags;

unsigned excel_write_string	(BiffPut *bp, WriteStringFlags flags,
				 guint8 const *txt);
unsigned excel_write_BOF	(BiffPut *bp, MsBiffFileType type);
void	 excel_write_SETUP	(BiffPut *bp, ExcelWriteSheet *esheet);
void	 excel_write_SCL	(BiffPut *bp, double zoom, gboolean force);

int palette_get_index (XLExportBase const *ewb, guint c);
int excel_write_get_externsheet_idx (ExcelWriteState *wb,
				     Sheet *gnum_sheeta,
				     Sheet *gnum_sheetb);

int excel_write_map_errcode (GnmValue const *v);

GHashTable *excel_collect_pivot_caches (Workbook const *wb);

void excel_sheet_extent (Sheet const *sheet, GnmRange *extent, GnmStyle **col_styles,
			 int maxcols, int maxrows, GOIOContext *io_context);

int excel_font_from_go_font (XLExportBase *ewb, GOFont const *font);

void xls_write_pivot_caches (ExcelWriteState *ewb, GsfOutfile *outfile,
			     MsBiffVersion version, int codepage);

int excel_write_add_object_format (ExcelWriteState *ewb, GOFormat *format);

#endif /* GNM_MS_EXCEL_WRITE_H */