初始化PHP-Xlswrite扩展
This commit is contained in:
446
library/libxlsxwriter/src/app.c
Normal file
446
library/libxlsxwriter/src/app.c
Normal file
@ -0,0 +1,446 @@
|
||||
/*****************************************************************************
|
||||
* app - A library for creating Excel XLSX app files.
|
||||
*
|
||||
* Used in conjunction with the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2021, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "xlsxwriter/xmlwriter.h"
|
||||
#include "xlsxwriter/app.h"
|
||||
#include "xlsxwriter/utility.h"
|
||||
|
||||
/*
|
||||
* Forward declarations.
|
||||
*/
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Private functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Create a new app object.
|
||||
*/
|
||||
lxw_app *
|
||||
lxw_app_new(void)
|
||||
{
|
||||
lxw_app *app = calloc(1, sizeof(lxw_app));
|
||||
GOTO_LABEL_ON_MEM_ERROR(app, mem_error);
|
||||
|
||||
app->heading_pairs = calloc(1, sizeof(struct lxw_heading_pairs));
|
||||
GOTO_LABEL_ON_MEM_ERROR(app->heading_pairs, mem_error);
|
||||
STAILQ_INIT(app->heading_pairs);
|
||||
|
||||
app->part_names = calloc(1, sizeof(struct lxw_part_names));
|
||||
GOTO_LABEL_ON_MEM_ERROR(app->part_names, mem_error);
|
||||
STAILQ_INIT(app->part_names);
|
||||
|
||||
return app;
|
||||
|
||||
mem_error:
|
||||
lxw_app_free(app);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free a app object.
|
||||
*/
|
||||
void
|
||||
lxw_app_free(lxw_app *app)
|
||||
{
|
||||
lxw_heading_pair *heading_pair;
|
||||
lxw_part_name *part_name;
|
||||
|
||||
if (!app)
|
||||
return;
|
||||
|
||||
/* Free the lists in the App object. */
|
||||
if (app->heading_pairs) {
|
||||
while (!STAILQ_EMPTY(app->heading_pairs)) {
|
||||
heading_pair = STAILQ_FIRST(app->heading_pairs);
|
||||
STAILQ_REMOVE_HEAD(app->heading_pairs, list_pointers);
|
||||
free(heading_pair->key);
|
||||
free(heading_pair->value);
|
||||
free(heading_pair);
|
||||
}
|
||||
free(app->heading_pairs);
|
||||
}
|
||||
|
||||
if (app->part_names) {
|
||||
while (!STAILQ_EMPTY(app->part_names)) {
|
||||
part_name = STAILQ_FIRST(app->part_names);
|
||||
STAILQ_REMOVE_HEAD(app->part_names, list_pointers);
|
||||
free(part_name->name);
|
||||
free(part_name);
|
||||
}
|
||||
free(app->part_names);
|
||||
}
|
||||
|
||||
free(app);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* XML functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Write the XML declaration.
|
||||
*/
|
||||
STATIC void
|
||||
_app_xml_declaration(lxw_app *self)
|
||||
{
|
||||
lxw_xml_declaration(self->file);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <Properties> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_properties(lxw_app *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
char xmlns[] = LXW_SCHEMA_OFFICEDOC "/extended-properties";
|
||||
char xmlns_vt[] = LXW_SCHEMA_OFFICEDOC "/docPropsVTypes";
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns", xmlns);
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns:vt", xmlns_vt);
|
||||
|
||||
lxw_xml_start_tag(self->file, "Properties", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <Application> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_application(lxw_app *self)
|
||||
{
|
||||
lxw_xml_data_element(self->file, "Application", "Microsoft Excel", NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <DocSecurity> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_doc_security(lxw_app *self)
|
||||
{
|
||||
if (self->doc_security == 2)
|
||||
lxw_xml_data_element(self->file, "DocSecurity", "2", NULL);
|
||||
else
|
||||
lxw_xml_data_element(self->file, "DocSecurity", "0", NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <ScaleCrop> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_scale_crop(lxw_app *self)
|
||||
{
|
||||
lxw_xml_data_element(self->file, "ScaleCrop", "false", NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <vt:lpstr> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_vt_lpstr(lxw_app *self, const char *str)
|
||||
{
|
||||
lxw_xml_data_element(self->file, "vt:lpstr", str, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <vt:i4> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_vt_i4(lxw_app *self, const char *value)
|
||||
{
|
||||
lxw_xml_data_element(self->file, "vt:i4", value, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <vt:variant> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_vt_variant(lxw_app *self, const char *key, const char *value)
|
||||
{
|
||||
/* Write the vt:lpstr element. */
|
||||
lxw_xml_start_tag(self->file, "vt:variant", NULL);
|
||||
_write_vt_lpstr(self, key);
|
||||
lxw_xml_end_tag(self->file, "vt:variant");
|
||||
|
||||
/* Write the vt:i4 element. */
|
||||
lxw_xml_start_tag(self->file, "vt:variant", NULL);
|
||||
_write_vt_i4(self, value);
|
||||
lxw_xml_end_tag(self->file, "vt:variant");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <vt:vector> element for the heading pairs.
|
||||
*/
|
||||
STATIC void
|
||||
_write_vt_vector_heading_pairs(lxw_app *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
lxw_heading_pair *heading_pair;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_INT("size", self->num_heading_pairs * 2);
|
||||
LXW_PUSH_ATTRIBUTES_STR("baseType", "variant");
|
||||
|
||||
lxw_xml_start_tag(self->file, "vt:vector", &attributes);
|
||||
|
||||
STAILQ_FOREACH(heading_pair, self->heading_pairs, list_pointers) {
|
||||
_write_vt_variant(self, heading_pair->key, heading_pair->value);
|
||||
}
|
||||
|
||||
lxw_xml_end_tag(self->file, "vt:vector");
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <vt:vector> element for the named parts.
|
||||
*/
|
||||
STATIC void
|
||||
_write_vt_vector_lpstr_named_parts(lxw_app *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
lxw_part_name *part_name;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_INT("size", self->num_part_names);
|
||||
LXW_PUSH_ATTRIBUTES_STR("baseType", "lpstr");
|
||||
|
||||
lxw_xml_start_tag(self->file, "vt:vector", &attributes);
|
||||
|
||||
STAILQ_FOREACH(part_name, self->part_names, list_pointers) {
|
||||
_write_vt_lpstr(self, part_name->name);
|
||||
}
|
||||
|
||||
lxw_xml_end_tag(self->file, "vt:vector");
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <HeadingPairs> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_heading_pairs(lxw_app *self)
|
||||
{
|
||||
lxw_xml_start_tag(self->file, "HeadingPairs", NULL);
|
||||
|
||||
/* Write the vt:vector element. */
|
||||
_write_vt_vector_heading_pairs(self);
|
||||
|
||||
lxw_xml_end_tag(self->file, "HeadingPairs");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <TitlesOfParts> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_titles_of_parts(lxw_app *self)
|
||||
{
|
||||
lxw_xml_start_tag(self->file, "TitlesOfParts", NULL);
|
||||
|
||||
/* Write the vt:vector element. */
|
||||
_write_vt_vector_lpstr_named_parts(self);
|
||||
|
||||
lxw_xml_end_tag(self->file, "TitlesOfParts");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <Manager> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_manager(lxw_app *self)
|
||||
{
|
||||
lxw_doc_properties *properties = self->properties;
|
||||
|
||||
if (!properties)
|
||||
return;
|
||||
|
||||
if (properties->manager)
|
||||
lxw_xml_data_element(self->file, "Manager", properties->manager,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <Company> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_company(lxw_app *self)
|
||||
{
|
||||
lxw_doc_properties *properties = self->properties;
|
||||
|
||||
if (properties && properties->company)
|
||||
lxw_xml_data_element(self->file, "Company", properties->company,
|
||||
NULL);
|
||||
else
|
||||
lxw_xml_data_element(self->file, "Company", "", NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <LinksUpToDate> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_links_up_to_date(lxw_app *self)
|
||||
{
|
||||
lxw_xml_data_element(self->file, "LinksUpToDate", "false", NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <SharedDoc> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_shared_doc(lxw_app *self)
|
||||
{
|
||||
lxw_xml_data_element(self->file, "SharedDoc", "false", NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <HyperlinkBase> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_hyperlink_base(lxw_app *self)
|
||||
{
|
||||
lxw_doc_properties *properties = self->properties;
|
||||
|
||||
if (!properties)
|
||||
return;
|
||||
|
||||
if (properties->hyperlink_base)
|
||||
lxw_xml_data_element(self->file, "HyperlinkBase",
|
||||
properties->hyperlink_base, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <HyperlinksChanged> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_hyperlinks_changed(lxw_app *self)
|
||||
{
|
||||
lxw_xml_data_element(self->file, "HyperlinksChanged", "false", NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <AppVersion> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_app_version(lxw_app *self)
|
||||
{
|
||||
lxw_xml_data_element(self->file, "AppVersion", "12.0000", NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* XML file assembly functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Assemble and write the XML file.
|
||||
*/
|
||||
void
|
||||
lxw_app_assemble_xml_file(lxw_app *self)
|
||||
{
|
||||
|
||||
/* Write the XML declaration. */
|
||||
_app_xml_declaration(self);
|
||||
|
||||
_write_properties(self);
|
||||
_write_application(self);
|
||||
_write_doc_security(self);
|
||||
_write_scale_crop(self);
|
||||
_write_heading_pairs(self);
|
||||
_write_titles_of_parts(self);
|
||||
_write_manager(self);
|
||||
_write_company(self);
|
||||
_write_links_up_to_date(self);
|
||||
_write_shared_doc(self);
|
||||
_write_hyperlink_base(self);
|
||||
_write_hyperlinks_changed(self);
|
||||
_write_app_version(self);
|
||||
|
||||
lxw_xml_end_tag(self->file, "Properties");
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Public functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Add the name of a workbook Part such as 'Sheet1' or 'Print_Titles'.
|
||||
*/
|
||||
void
|
||||
lxw_app_add_part_name(lxw_app *self, const char *name)
|
||||
{
|
||||
lxw_part_name *part_name;
|
||||
|
||||
if (!name)
|
||||
return;
|
||||
|
||||
part_name = calloc(1, sizeof(lxw_part_name));
|
||||
GOTO_LABEL_ON_MEM_ERROR(part_name, mem_error);
|
||||
|
||||
part_name->name = lxw_strdup(name);
|
||||
GOTO_LABEL_ON_MEM_ERROR(part_name->name, mem_error);
|
||||
|
||||
STAILQ_INSERT_TAIL(self->part_names, part_name, list_pointers);
|
||||
self->num_part_names++;
|
||||
|
||||
return;
|
||||
|
||||
mem_error:
|
||||
if (part_name) {
|
||||
free(part_name->name);
|
||||
free(part_name);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the name of a workbook Heading Pair such as 'Worksheets', 'Charts' or
|
||||
* 'Named Ranges'.
|
||||
*/
|
||||
void
|
||||
lxw_app_add_heading_pair(lxw_app *self, const char *key, const char *value)
|
||||
{
|
||||
lxw_heading_pair *heading_pair;
|
||||
|
||||
if (!key || !value)
|
||||
return;
|
||||
|
||||
heading_pair = calloc(1, sizeof(lxw_heading_pair));
|
||||
GOTO_LABEL_ON_MEM_ERROR(heading_pair, mem_error);
|
||||
|
||||
heading_pair->key = lxw_strdup(key);
|
||||
GOTO_LABEL_ON_MEM_ERROR(heading_pair->key, mem_error);
|
||||
|
||||
heading_pair->value = lxw_strdup(value);
|
||||
GOTO_LABEL_ON_MEM_ERROR(heading_pair->value, mem_error);
|
||||
|
||||
STAILQ_INSERT_TAIL(self->heading_pairs, heading_pair, list_pointers);
|
||||
self->num_heading_pairs++;
|
||||
|
||||
return;
|
||||
|
||||
mem_error:
|
||||
if (heading_pair) {
|
||||
free(heading_pair->key);
|
||||
free(heading_pair->value);
|
||||
free(heading_pair);
|
||||
}
|
||||
}
|
18
library/libxlsxwriter/src/app.dep
Normal file
18
library/libxlsxwriter/src/app.dep
Normal file
@ -0,0 +1,18 @@
|
||||
library/libxlsxwriter/src/app.lo: \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/src/app.c \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/xmlwriter.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/utility.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/common.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/queue.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/tree.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/app.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/workbook.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/worksheet.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/shared_strings.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/chart.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/format.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/hash_table.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/drawing.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/styles.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/relationships.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/chartsheet.h
|
6749
library/libxlsxwriter/src/chart.c
Normal file
6749
library/libxlsxwriter/src/chart.c
Normal file
File diff suppressed because it is too large
Load Diff
10
library/libxlsxwriter/src/chart.dep
Normal file
10
library/libxlsxwriter/src/chart.dep
Normal file
@ -0,0 +1,10 @@
|
||||
library/libxlsxwriter/src/chart.lo: \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/src/chart.c \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/xmlwriter.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/utility.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/common.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/queue.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/tree.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/chart.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/format.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/hash_table.h
|
508
library/libxlsxwriter/src/chartsheet.c
Normal file
508
library/libxlsxwriter/src/chartsheet.c
Normal file
@ -0,0 +1,508 @@
|
||||
/*****************************************************************************
|
||||
* chartsheet - A library for creating Excel XLSX chartsheet files.
|
||||
*
|
||||
* Used in conjunction with the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2021, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "xlsxwriter/xmlwriter.h"
|
||||
#include "xlsxwriter/chartsheet.h"
|
||||
#include "xlsxwriter/utility.h"
|
||||
|
||||
/*
|
||||
* Forward declarations.
|
||||
*/
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Private functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Create a new chartsheet object.
|
||||
*/
|
||||
lxw_chartsheet *
|
||||
lxw_chartsheet_new(lxw_worksheet_init_data *init_data)
|
||||
{
|
||||
lxw_chartsheet *chartsheet = calloc(1, sizeof(lxw_chartsheet));
|
||||
GOTO_LABEL_ON_MEM_ERROR(chartsheet, mem_error);
|
||||
|
||||
/* Use an embedded worksheet instance to write XML records that are
|
||||
* shared with worksheet.c. */
|
||||
chartsheet->worksheet = lxw_worksheet_new(NULL);
|
||||
GOTO_LABEL_ON_MEM_ERROR(chartsheet->worksheet, mem_error);
|
||||
|
||||
if (init_data) {
|
||||
chartsheet->name = init_data->name;
|
||||
chartsheet->quoted_name = init_data->quoted_name;
|
||||
chartsheet->tmpdir = init_data->tmpdir;
|
||||
chartsheet->index = init_data->index;
|
||||
chartsheet->hidden = init_data->hidden;
|
||||
chartsheet->active_sheet = init_data->active_sheet;
|
||||
chartsheet->first_sheet = init_data->first_sheet;
|
||||
}
|
||||
|
||||
chartsheet->worksheet->is_chartsheet = LXW_TRUE;
|
||||
chartsheet->worksheet->zoom_scale_normal = LXW_FALSE;
|
||||
chartsheet->worksheet->orientation = LXW_LANDSCAPE;
|
||||
|
||||
return chartsheet;
|
||||
|
||||
mem_error:
|
||||
lxw_chartsheet_free(chartsheet);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free a chartsheet object.
|
||||
*/
|
||||
void
|
||||
lxw_chartsheet_free(lxw_chartsheet *chartsheet)
|
||||
{
|
||||
if (!chartsheet)
|
||||
return;
|
||||
|
||||
lxw_worksheet_free(chartsheet->worksheet);
|
||||
free(chartsheet->name);
|
||||
free(chartsheet->quoted_name);
|
||||
free(chartsheet);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* XML functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Write the XML declaration.
|
||||
*/
|
||||
STATIC void
|
||||
_chartsheet_xml_declaration(lxw_chartsheet *self)
|
||||
{
|
||||
lxw_xml_declaration(self->file);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <chartsheet> element.
|
||||
*/
|
||||
STATIC void
|
||||
_chartsheet_write_chartsheet(lxw_chartsheet *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
char xmlns[] = "http://schemas.openxmlformats.org/"
|
||||
"spreadsheetml/2006/main";
|
||||
char xmlns_r[] = "http://schemas.openxmlformats.org/"
|
||||
"officeDocument/2006/relationships";
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns", xmlns);
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns:r", xmlns_r);
|
||||
|
||||
lxw_xml_start_tag(self->file, "chartsheet", &attributes);
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <sheetPr> element.
|
||||
*/
|
||||
STATIC void
|
||||
_chartsheet_write_sheet_pr(lxw_chartsheet *self)
|
||||
{
|
||||
lxw_worksheet_write_sheet_pr(self->worksheet);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <sheetViews> element.
|
||||
*/
|
||||
STATIC void
|
||||
_chartsheet_write_sheet_views(lxw_chartsheet *self)
|
||||
{
|
||||
lxw_worksheet_write_sheet_views(self->worksheet);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <pageMargins> element.
|
||||
*/
|
||||
STATIC void
|
||||
_chartsheet_write_page_margins(lxw_chartsheet *self)
|
||||
{
|
||||
lxw_worksheet_write_page_margins(self->worksheet);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <drawing> elements.
|
||||
*/
|
||||
STATIC void
|
||||
_chartsheet_write_drawings(lxw_chartsheet *self)
|
||||
{
|
||||
lxw_worksheet_write_drawings(self->worksheet);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <sheetProtection> element.
|
||||
*/
|
||||
STATIC void
|
||||
_chartsheet_write_sheet_protection(lxw_chartsheet *self)
|
||||
{
|
||||
lxw_worksheet_write_sheet_protection(self->worksheet, &self->protection);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <pageSetup> element.
|
||||
*/
|
||||
STATIC void
|
||||
_chartsheet_write_page_setup(lxw_chartsheet *self)
|
||||
{
|
||||
lxw_worksheet_write_page_setup(self->worksheet);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <headerFooter> element.
|
||||
*/
|
||||
STATIC void
|
||||
_chartsheet_write_header_footer(lxw_chartsheet *self)
|
||||
{
|
||||
lxw_worksheet_write_header_footer(self->worksheet);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* XML file assembly functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Assemble and write the XML file.
|
||||
*/
|
||||
void
|
||||
lxw_chartsheet_assemble_xml_file(lxw_chartsheet *self)
|
||||
{
|
||||
/* Set the embedded worksheet filehandle to the same as the chartsheet. */
|
||||
self->worksheet->file = self->file;
|
||||
|
||||
/* Write the XML declaration. */
|
||||
_chartsheet_xml_declaration(self);
|
||||
|
||||
/* Write the chartsheet element. */
|
||||
_chartsheet_write_chartsheet(self);
|
||||
|
||||
/* Write the sheetPr element. */
|
||||
_chartsheet_write_sheet_pr(self);
|
||||
|
||||
/* Write the sheetViews element. */
|
||||
_chartsheet_write_sheet_views(self);
|
||||
|
||||
/* Write the sheetProtection element. */
|
||||
_chartsheet_write_sheet_protection(self);
|
||||
|
||||
/* Write the pageMargins element. */
|
||||
_chartsheet_write_page_margins(self);
|
||||
|
||||
/* Write the chartsheet page setup. */
|
||||
_chartsheet_write_page_setup(self);
|
||||
|
||||
/* Write the headerFooter element. */
|
||||
_chartsheet_write_header_footer(self);
|
||||
|
||||
/* Write the drawing element. */
|
||||
_chartsheet_write_drawings(self);
|
||||
|
||||
lxw_xml_end_tag(self->file, "chartsheet");
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Public functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
/*
|
||||
* Set a chartsheet chart, with options.
|
||||
*/
|
||||
lxw_error
|
||||
chartsheet_set_chart_opt(lxw_chartsheet *self,
|
||||
lxw_chart *chart, lxw_chart_options *user_options)
|
||||
{
|
||||
lxw_object_properties *object_props;
|
||||
lxw_chart_series *series;
|
||||
|
||||
if (!chart) {
|
||||
LXW_WARN("chartsheet_set_chart()/_opt(): chart must be non-NULL.");
|
||||
return LXW_ERROR_NULL_PARAMETER_IGNORED;
|
||||
}
|
||||
|
||||
/* Check that the chart isn't being used more than once. */
|
||||
if (chart->in_use) {
|
||||
LXW_WARN("chartsheet_set_chart()/_opt(): the same chart object "
|
||||
"cannot be set for a chartsheet more than once.");
|
||||
|
||||
return LXW_ERROR_PARAMETER_VALIDATION;
|
||||
}
|
||||
|
||||
/* Check that the chart has a data series. */
|
||||
if (STAILQ_EMPTY(chart->series_list)) {
|
||||
LXW_WARN("chartsheet_set_chart()/_opt(): chart must have a series.");
|
||||
|
||||
return LXW_ERROR_PARAMETER_VALIDATION;
|
||||
}
|
||||
|
||||
/* Check that the chart has a 'values' series. */
|
||||
STAILQ_FOREACH(series, chart->series_list, list_pointers) {
|
||||
if (!series->values->formula && !series->values->sheetname) {
|
||||
LXW_WARN("chartsheet_set_chart()/_opt(): chart must have a "
|
||||
"'values' series.");
|
||||
|
||||
return LXW_ERROR_PARAMETER_VALIDATION;
|
||||
}
|
||||
}
|
||||
|
||||
/* Create a new object to hold the chart image properties. */
|
||||
object_props = calloc(1, sizeof(lxw_object_properties));
|
||||
RETURN_ON_MEM_ERROR(object_props, LXW_ERROR_MEMORY_MALLOC_FAILED);
|
||||
|
||||
if (user_options) {
|
||||
object_props->x_offset = user_options->x_offset;
|
||||
object_props->y_offset = user_options->y_offset;
|
||||
object_props->x_scale = user_options->x_scale;
|
||||
object_props->y_scale = user_options->y_scale;
|
||||
}
|
||||
|
||||
object_props->width = 480;
|
||||
object_props->height = 288;
|
||||
|
||||
if (object_props->x_scale == 0.0)
|
||||
object_props->x_scale = 1;
|
||||
|
||||
if (object_props->y_scale == 0.0)
|
||||
object_props->y_scale = 1;
|
||||
|
||||
/* Store chart references so they can be ordered in the workbook. */
|
||||
object_props->chart = chart;
|
||||
|
||||
/* Store the chart data in the embedded worksheet. */
|
||||
STAILQ_INSERT_TAIL(self->worksheet->chart_data, object_props,
|
||||
list_pointers);
|
||||
|
||||
chart->in_use = LXW_TRUE;
|
||||
chart->is_chartsheet = LXW_TRUE;
|
||||
|
||||
chart->is_protected = self->is_protected;
|
||||
|
||||
self->chart = chart;
|
||||
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set a chartsheet charts.
|
||||
*/
|
||||
lxw_error
|
||||
chartsheet_set_chart(lxw_chartsheet *self, lxw_chart *chart)
|
||||
{
|
||||
return chartsheet_set_chart_opt(self, chart, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set this chartsheet as a selected worksheet, i.e. the worksheet has its tab
|
||||
* highlighted.
|
||||
*/
|
||||
void
|
||||
chartsheet_select(lxw_chartsheet *self)
|
||||
{
|
||||
self->selected = LXW_TRUE;
|
||||
|
||||
/* Selected worksheet can't be hidden. */
|
||||
self->hidden = LXW_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set this chartsheet as the active worksheet, i.e. the worksheet that is
|
||||
* displayed when the workbook is opened. Also set it as selected.
|
||||
*/
|
||||
void
|
||||
chartsheet_activate(lxw_chartsheet *self)
|
||||
{
|
||||
self->worksheet->selected = LXW_TRUE;
|
||||
self->worksheet->active = LXW_TRUE;
|
||||
|
||||
/* Active worksheet can't be hidden. */
|
||||
self->worksheet->hidden = LXW_FALSE;
|
||||
|
||||
*self->active_sheet = self->index;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set this chartsheet as the first visible sheet. This is necessary
|
||||
* when there are a large number of worksheets and the activated
|
||||
* worksheet is not visible on the screen.
|
||||
*/
|
||||
void
|
||||
chartsheet_set_first_sheet(lxw_chartsheet *self)
|
||||
{
|
||||
/* Active worksheet can't be hidden. */
|
||||
self->hidden = LXW_FALSE;
|
||||
|
||||
*self->first_sheet = self->index;
|
||||
}
|
||||
|
||||
/*
|
||||
* Hide this chartsheet.
|
||||
*/
|
||||
void
|
||||
chartsheet_hide(lxw_chartsheet *self)
|
||||
{
|
||||
self->hidden = LXW_TRUE;
|
||||
|
||||
/* A hidden worksheet shouldn't be active or selected. */
|
||||
self->selected = LXW_FALSE;
|
||||
|
||||
/* If this is active_sheet or first_sheet reset the workbook value. */
|
||||
if (*self->first_sheet == self->index)
|
||||
*self->first_sheet = 0;
|
||||
|
||||
if (*self->active_sheet == self->index)
|
||||
*self->active_sheet = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the color of the chartsheet tab.
|
||||
*/
|
||||
void
|
||||
chartsheet_set_tab_color(lxw_chartsheet *self, lxw_color_t color)
|
||||
{
|
||||
self->worksheet->tab_color = color;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the chartsheet protection flags to prevent modification of chartsheet
|
||||
* objects.
|
||||
*/
|
||||
void
|
||||
chartsheet_protect(lxw_chartsheet *self, const char *password,
|
||||
lxw_protection *options)
|
||||
{
|
||||
struct lxw_protection_obj *protect = &self->protection;
|
||||
|
||||
/* Copy any user parameters to the internal structure. */
|
||||
if (options) {
|
||||
protect->objects = options->no_objects;
|
||||
protect->no_content = options->no_content;
|
||||
}
|
||||
else {
|
||||
protect->objects = LXW_FALSE;
|
||||
protect->no_content = LXW_FALSE;
|
||||
}
|
||||
|
||||
if (password) {
|
||||
uint16_t hash = lxw_hash_password(password);
|
||||
lxw_snprintf(protect->hash, 5, "%X", hash);
|
||||
}
|
||||
else {
|
||||
if (protect->objects && protect->no_content)
|
||||
return;
|
||||
}
|
||||
|
||||
protect->no_sheet = LXW_TRUE;
|
||||
protect->scenarios = LXW_TRUE;
|
||||
protect->is_configured = LXW_TRUE;
|
||||
|
||||
if (self->chart)
|
||||
self->chart->is_protected = LXW_TRUE;
|
||||
else
|
||||
self->is_protected = LXW_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the chartsheet zoom factor.
|
||||
*/
|
||||
void
|
||||
chartsheet_set_zoom(lxw_chartsheet *self, uint16_t scale)
|
||||
{
|
||||
/* Confine the scale to Excel"s range */
|
||||
if (scale < 10 || scale > 400) {
|
||||
LXW_WARN("chartsheet_set_zoom(): "
|
||||
"Zoom factor scale outside range: 10 <= zoom <= 400.");
|
||||
return;
|
||||
}
|
||||
|
||||
self->worksheet->zoom = scale;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the page orientation as portrait.
|
||||
*/
|
||||
void
|
||||
chartsheet_set_portrait(lxw_chartsheet *self)
|
||||
{
|
||||
worksheet_set_portrait(self->worksheet);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the page orientation as landscape.
|
||||
*/
|
||||
void
|
||||
chartsheet_set_landscape(lxw_chartsheet *self)
|
||||
{
|
||||
worksheet_set_landscape(self->worksheet);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the paper type. Example. 1 = US Letter, 9 = A4
|
||||
*/
|
||||
void
|
||||
chartsheet_set_paper(lxw_chartsheet *self, uint8_t paper_size)
|
||||
{
|
||||
worksheet_set_paper(self->worksheet, paper_size);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set all the page margins in inches.
|
||||
*/
|
||||
void
|
||||
chartsheet_set_margins(lxw_chartsheet *self, double left, double right,
|
||||
double top, double bottom)
|
||||
{
|
||||
worksheet_set_margins(self->worksheet, left, right, top, bottom);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the page header caption and options.
|
||||
*/
|
||||
lxw_error
|
||||
chartsheet_set_header_opt(lxw_chartsheet *self, const char *string,
|
||||
lxw_header_footer_options *options)
|
||||
{
|
||||
return worksheet_set_header_opt(self->worksheet, string, options);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the page footer caption and options.
|
||||
*/
|
||||
lxw_error
|
||||
chartsheet_set_footer_opt(lxw_chartsheet *self, const char *string,
|
||||
lxw_header_footer_options *options)
|
||||
{
|
||||
return worksheet_set_footer_opt(self->worksheet, string, options);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the page header caption.
|
||||
*/
|
||||
lxw_error
|
||||
chartsheet_set_header(lxw_chartsheet *self, const char *string)
|
||||
{
|
||||
return chartsheet_set_header_opt(self, string, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the page footer caption.
|
||||
*/
|
||||
lxw_error
|
||||
chartsheet_set_footer(lxw_chartsheet *self, const char *string)
|
||||
{
|
||||
return chartsheet_set_footer_opt(self, string, NULL);
|
||||
}
|
16
library/libxlsxwriter/src/chartsheet.dep
Normal file
16
library/libxlsxwriter/src/chartsheet.dep
Normal file
@ -0,0 +1,16 @@
|
||||
library/libxlsxwriter/src/chartsheet.lo: \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/src/chartsheet.c \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/xmlwriter.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/utility.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/common.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/queue.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/tree.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/chartsheet.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/worksheet.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/shared_strings.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/chart.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/format.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/hash_table.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/drawing.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/styles.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/relationships.h
|
443
library/libxlsxwriter/src/comment.c
Normal file
443
library/libxlsxwriter/src/comment.c
Normal file
@ -0,0 +1,443 @@
|
||||
/*****************************************************************************
|
||||
* comment - A library for creating Excel XLSX comment files.
|
||||
*
|
||||
* Used in conjunction with the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2021, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "xlsxwriter/xmlwriter.h"
|
||||
#include "xlsxwriter/comment.h"
|
||||
#include "xlsxwriter/utility.h"
|
||||
|
||||
/*
|
||||
* Forward declarations.
|
||||
*/
|
||||
|
||||
STATIC int _author_id_cmp(lxw_author_id *tuple1, lxw_author_id *tuple2);
|
||||
|
||||
#ifndef __clang_analyzer__
|
||||
LXW_RB_GENERATE_AUTHOR_IDS(lxw_author_ids, lxw_author_id,
|
||||
tree_pointers, _author_id_cmp);
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Private functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Comparator for the author ids.
|
||||
*/
|
||||
STATIC int
|
||||
_author_id_cmp(lxw_author_id *author_id1, lxw_author_id *author_id2)
|
||||
{
|
||||
return strcmp(author_id1->author, author_id2->author);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if an author already existing in the author/id table.
|
||||
*/
|
||||
STATIC uint8_t
|
||||
_check_author(lxw_comment *self, char *author)
|
||||
{
|
||||
lxw_author_id tmp_author_id;
|
||||
lxw_author_id *existing_author = NULL;
|
||||
|
||||
if (!author)
|
||||
return LXW_TRUE;
|
||||
|
||||
tmp_author_id.author = author;
|
||||
existing_author = RB_FIND(lxw_author_ids,
|
||||
self->author_ids, &tmp_author_id);
|
||||
|
||||
if (existing_author)
|
||||
return LXW_TRUE;
|
||||
else
|
||||
return LXW_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the index used for an author name.
|
||||
*/
|
||||
STATIC uint32_t
|
||||
_get_author_index(lxw_comment *self, char *author)
|
||||
{
|
||||
lxw_author_id tmp_author_id;
|
||||
lxw_author_id *existing_author = NULL;
|
||||
lxw_author_id *new_author_id = NULL;
|
||||
|
||||
if (!author)
|
||||
return 0;
|
||||
|
||||
tmp_author_id.author = author;
|
||||
existing_author = RB_FIND(lxw_author_ids,
|
||||
self->author_ids, &tmp_author_id);
|
||||
|
||||
if (existing_author) {
|
||||
return existing_author->id;
|
||||
}
|
||||
else {
|
||||
new_author_id = calloc(1, sizeof(lxw_author_id));
|
||||
|
||||
if (new_author_id) {
|
||||
new_author_id->id = self->author_id;
|
||||
new_author_id->author = lxw_strdup(author);
|
||||
self->author_id++;
|
||||
|
||||
RB_INSERT(lxw_author_ids, self->author_ids, new_author_id);
|
||||
|
||||
return new_author_id->id;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a new comment object.
|
||||
*/
|
||||
lxw_comment *
|
||||
lxw_comment_new(void)
|
||||
{
|
||||
lxw_comment *comment = calloc(1, sizeof(lxw_comment));
|
||||
GOTO_LABEL_ON_MEM_ERROR(comment, mem_error);
|
||||
|
||||
comment->author_ids = calloc(1, sizeof(struct lxw_author_ids));
|
||||
GOTO_LABEL_ON_MEM_ERROR(comment->author_ids, mem_error);
|
||||
RB_INIT(comment->author_ids);
|
||||
|
||||
return comment;
|
||||
|
||||
mem_error:
|
||||
lxw_comment_free(comment);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free a comment object.
|
||||
*/
|
||||
void
|
||||
lxw_comment_free(lxw_comment *comment)
|
||||
{
|
||||
struct lxw_author_id *author_id;
|
||||
struct lxw_author_id *next_author_id;
|
||||
|
||||
if (!comment)
|
||||
return;
|
||||
|
||||
if (comment->author_ids) {
|
||||
for (author_id =
|
||||
RB_MIN(lxw_author_ids, comment->author_ids);
|
||||
author_id; author_id = next_author_id) {
|
||||
|
||||
next_author_id =
|
||||
RB_NEXT(lxw_author_ids, worksheet->author_id, author_id);
|
||||
RB_REMOVE(lxw_author_ids, comment->author_ids, author_id);
|
||||
free(author_id->author);
|
||||
free(author_id);
|
||||
}
|
||||
|
||||
free(comment->author_ids);
|
||||
}
|
||||
|
||||
free(comment);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* XML functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Write the XML declaration.
|
||||
*/
|
||||
STATIC void
|
||||
_comment_xml_declaration(lxw_comment *self)
|
||||
{
|
||||
lxw_xml_declaration(self->file);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* XML file assembly functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Write the <t> element.
|
||||
*/
|
||||
STATIC void
|
||||
_comment_write_text_t(lxw_comment *self, lxw_vml_obj *comment_obj)
|
||||
{
|
||||
lxw_xml_data_element(self->file, "t", comment_obj->text, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <family> element.
|
||||
*/
|
||||
STATIC void
|
||||
_comment_write_family(lxw_comment *self, lxw_vml_obj *comment_obj)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_INT("val", comment_obj->font_family);
|
||||
|
||||
lxw_xml_empty_tag(self->file, "family", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <rFont> element.
|
||||
*/
|
||||
STATIC void
|
||||
_comment_write_r_font(lxw_comment *self, lxw_vml_obj *comment_obj)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
char font_name[LXW_ATTR_32];
|
||||
|
||||
if (comment_obj->font_name)
|
||||
lxw_snprintf(font_name, LXW_ATTR_32, "%s", comment_obj->font_name);
|
||||
else
|
||||
lxw_snprintf(font_name, LXW_ATTR_32, "Tahoma");
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("val", font_name);
|
||||
|
||||
lxw_xml_empty_tag(self->file, "rFont", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <color> element.
|
||||
*/
|
||||
STATIC void
|
||||
_comment_write_color(lxw_comment *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
char indexed[] = "81";
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("indexed", indexed);
|
||||
|
||||
lxw_xml_empty_tag(self->file, "color", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <sz> element.
|
||||
*/
|
||||
STATIC void
|
||||
_comment_write_sz(lxw_comment *self, lxw_vml_obj *comment_obj)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_DBL("val", comment_obj->font_size);
|
||||
|
||||
lxw_xml_empty_tag(self->file, "sz", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <rPr> element.
|
||||
*/
|
||||
STATIC void
|
||||
_comment_write_r_pr(lxw_comment *self, lxw_vml_obj *comment_obj)
|
||||
{
|
||||
lxw_xml_start_tag(self->file, "rPr", NULL);
|
||||
|
||||
/* Write the sz element. */
|
||||
_comment_write_sz(self, comment_obj);
|
||||
|
||||
/* Write the color element. */
|
||||
_comment_write_color(self);
|
||||
|
||||
/* Write the rFont element. */
|
||||
_comment_write_r_font(self, comment_obj);
|
||||
|
||||
/* Write the family element. */
|
||||
_comment_write_family(self, comment_obj);
|
||||
|
||||
lxw_xml_end_tag(self->file, "rPr");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <r> element.
|
||||
*/
|
||||
STATIC void
|
||||
_comment_write_r(lxw_comment *self, lxw_vml_obj *comment_obj)
|
||||
{
|
||||
lxw_xml_start_tag(self->file, "r", NULL);
|
||||
|
||||
/* Write the rPr element. */
|
||||
_comment_write_r_pr(self, comment_obj);
|
||||
|
||||
/* Write the t element. */
|
||||
_comment_write_text_t(self, comment_obj);
|
||||
|
||||
lxw_xml_end_tag(self->file, "r");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <text> element.
|
||||
*/
|
||||
STATIC void
|
||||
_comment_write_text(lxw_comment *self, lxw_vml_obj *comment_obj)
|
||||
{
|
||||
lxw_xml_start_tag(self->file, "text", NULL);
|
||||
|
||||
/* Write the r element. */
|
||||
_comment_write_r(self, comment_obj);
|
||||
|
||||
lxw_xml_end_tag(self->file, "text");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <comment> element.
|
||||
*/
|
||||
STATIC void
|
||||
_comment_write_comment(lxw_comment *self, lxw_vml_obj *comment_obj)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
char ref[LXW_MAX_CELL_NAME_LENGTH];
|
||||
|
||||
lxw_rowcol_to_cell(ref, comment_obj->row, comment_obj->col);
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("ref", ref);
|
||||
LXW_PUSH_ATTRIBUTES_INT("authorId", comment_obj->author_id);
|
||||
|
||||
lxw_xml_start_tag(self->file, "comment", &attributes);
|
||||
|
||||
/* Write the text element. */
|
||||
_comment_write_text(self, comment_obj);
|
||||
|
||||
lxw_xml_end_tag(self->file, "comment");
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <commentList> element.
|
||||
*/
|
||||
STATIC void
|
||||
_comment_write_comment_list(lxw_comment *self)
|
||||
{
|
||||
lxw_vml_obj *comment_obj;
|
||||
|
||||
lxw_xml_start_tag(self->file, "commentList", NULL);
|
||||
|
||||
STAILQ_FOREACH(comment_obj, self->comment_objs, list_pointers) {
|
||||
/* Write the comment element. */
|
||||
_comment_write_comment(self, comment_obj);
|
||||
}
|
||||
|
||||
lxw_xml_end_tag(self->file, "commentList");
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <author> element.
|
||||
*/
|
||||
STATIC void
|
||||
_comment_write_author(lxw_comment *self, char *author)
|
||||
{
|
||||
lxw_xml_data_element(self->file, "author", author, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <authors> element.
|
||||
*/
|
||||
STATIC void
|
||||
_comment_write_authors(lxw_comment *self)
|
||||
{
|
||||
lxw_vml_obj *comment_obj;
|
||||
char *author;
|
||||
|
||||
lxw_xml_start_tag(self->file, "authors", NULL);
|
||||
|
||||
/* Set the default author (from worksheet_set_comments_author()). */
|
||||
if (self->comment_author) {
|
||||
_get_author_index(self, self->comment_author);
|
||||
_comment_write_author(self, self->comment_author);
|
||||
}
|
||||
else {
|
||||
_get_author_index(self, "");
|
||||
_comment_write_author(self, "");
|
||||
}
|
||||
|
||||
STAILQ_FOREACH(comment_obj, self->comment_objs, list_pointers) {
|
||||
author = comment_obj->author;
|
||||
|
||||
if (author) {
|
||||
|
||||
if (!_check_author(self, author))
|
||||
_comment_write_author(self, author);
|
||||
|
||||
comment_obj->author_id = _get_author_index(self, author);
|
||||
}
|
||||
}
|
||||
|
||||
lxw_xml_end_tag(self->file, "authors");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <comments> element.
|
||||
*/
|
||||
STATIC void
|
||||
_comment_write_comments(lxw_comment *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
char xmlns[] =
|
||||
"http://schemas.openxmlformats.org/spreadsheetml/2006/main";
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns", xmlns);
|
||||
|
||||
lxw_xml_start_tag(self->file, "comments", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Assemble and write the XML file.
|
||||
*/
|
||||
void
|
||||
lxw_comment_assemble_xml_file(lxw_comment *self)
|
||||
{
|
||||
/* Write the XML declaration. */
|
||||
_comment_xml_declaration(self);
|
||||
|
||||
/* Write the comments element. */
|
||||
_comment_write_comments(self);
|
||||
|
||||
/* Write the authors element. */
|
||||
_comment_write_authors(self);
|
||||
|
||||
/* Write the commentList element. */
|
||||
_comment_write_comment_list(self);
|
||||
|
||||
lxw_xml_end_tag(self->file, "comments");
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Public functions.
|
||||
*
|
||||
****************************************************************************/
|
16
library/libxlsxwriter/src/comment.dep
Normal file
16
library/libxlsxwriter/src/comment.dep
Normal file
@ -0,0 +1,16 @@
|
||||
library/libxlsxwriter/src/comment.lo: \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/src/comment.c \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/xmlwriter.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/utility.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/common.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/queue.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/tree.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/comment.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/worksheet.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/shared_strings.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/chart.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/format.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/hash_table.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/drawing.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/styles.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/relationships.h
|
382
library/libxlsxwriter/src/content_types.c
Normal file
382
library/libxlsxwriter/src/content_types.c
Normal file
@ -0,0 +1,382 @@
|
||||
/*****************************************************************************
|
||||
* content_types - A library for creating Excel XLSX content_types files.
|
||||
*
|
||||
* Used in conjunction with the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2021, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "xlsxwriter/xmlwriter.h"
|
||||
#include "xlsxwriter/content_types.h"
|
||||
#include "xlsxwriter/utility.h"
|
||||
|
||||
/*
|
||||
* Forward declarations.
|
||||
*/
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Private functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Create a new content_types object.
|
||||
*/
|
||||
lxw_content_types *
|
||||
lxw_content_types_new(void)
|
||||
{
|
||||
lxw_content_types *content_types = calloc(1, sizeof(lxw_content_types));
|
||||
GOTO_LABEL_ON_MEM_ERROR(content_types, mem_error);
|
||||
|
||||
content_types->default_types = calloc(1, sizeof(struct lxw_tuples));
|
||||
GOTO_LABEL_ON_MEM_ERROR(content_types->default_types, mem_error);
|
||||
STAILQ_INIT(content_types->default_types);
|
||||
|
||||
content_types->overrides = calloc(1, sizeof(struct lxw_tuples));
|
||||
GOTO_LABEL_ON_MEM_ERROR(content_types->overrides, mem_error);
|
||||
STAILQ_INIT(content_types->overrides);
|
||||
|
||||
lxw_ct_add_default(content_types, "rels",
|
||||
LXW_APP_PACKAGE "relationships+xml");
|
||||
lxw_ct_add_default(content_types, "xml", "application/xml");
|
||||
|
||||
lxw_ct_add_override(content_types, "/docProps/app.xml",
|
||||
LXW_APP_DOCUMENT "extended-properties+xml");
|
||||
lxw_ct_add_override(content_types, "/docProps/core.xml",
|
||||
LXW_APP_PACKAGE "core-properties+xml");
|
||||
lxw_ct_add_override(content_types, "/xl/styles.xml",
|
||||
LXW_APP_DOCUMENT "spreadsheetml.styles+xml");
|
||||
lxw_ct_add_override(content_types, "/xl/theme/theme1.xml",
|
||||
LXW_APP_DOCUMENT "theme+xml");
|
||||
|
||||
return content_types;
|
||||
|
||||
mem_error:
|
||||
lxw_content_types_free(content_types);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free a content_types object.
|
||||
*/
|
||||
void
|
||||
lxw_content_types_free(lxw_content_types *content_types)
|
||||
{
|
||||
lxw_tuple *default_type;
|
||||
lxw_tuple *override;
|
||||
|
||||
if (!content_types)
|
||||
return;
|
||||
|
||||
if (content_types->default_types) {
|
||||
while (!STAILQ_EMPTY(content_types->default_types)) {
|
||||
default_type = STAILQ_FIRST(content_types->default_types);
|
||||
STAILQ_REMOVE_HEAD(content_types->default_types, list_pointers);
|
||||
free(default_type->key);
|
||||
free(default_type->value);
|
||||
free(default_type);
|
||||
}
|
||||
free(content_types->default_types);
|
||||
}
|
||||
|
||||
if (content_types->overrides) {
|
||||
while (!STAILQ_EMPTY(content_types->overrides)) {
|
||||
override = STAILQ_FIRST(content_types->overrides);
|
||||
STAILQ_REMOVE_HEAD(content_types->overrides, list_pointers);
|
||||
free(override->key);
|
||||
free(override->value);
|
||||
free(override);
|
||||
}
|
||||
free(content_types->overrides);
|
||||
}
|
||||
|
||||
free(content_types);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* XML functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Write the XML declaration.
|
||||
*/
|
||||
STATIC void
|
||||
_content_types_xml_declaration(lxw_content_types *self)
|
||||
{
|
||||
lxw_xml_declaration(self->file);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <Types> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_types(lxw_content_types *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns", LXW_SCHEMA_CONTENT);
|
||||
|
||||
lxw_xml_start_tag(self->file, "Types", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <Default> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_default(lxw_content_types *self, const char *ext, const char *type)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("Extension", ext);
|
||||
LXW_PUSH_ATTRIBUTES_STR("ContentType", type);
|
||||
|
||||
lxw_xml_empty_tag(self->file, "Default", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <Override> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_override(lxw_content_types *self, const char *part_name,
|
||||
const char *type)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("PartName", part_name);
|
||||
LXW_PUSH_ATTRIBUTES_STR("ContentType", type);
|
||||
|
||||
lxw_xml_empty_tag(self->file, "Override", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* XML file assembly functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Write out all of the <Default> types.
|
||||
*/
|
||||
STATIC void
|
||||
_write_defaults(lxw_content_types *self)
|
||||
{
|
||||
lxw_tuple *tuple;
|
||||
|
||||
STAILQ_FOREACH(tuple, self->default_types, list_pointers) {
|
||||
_write_default(self, tuple->key, tuple->value);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Write out all of the <Override> types.
|
||||
*/
|
||||
STATIC void
|
||||
_write_overrides(lxw_content_types *self)
|
||||
{
|
||||
lxw_tuple *tuple;
|
||||
|
||||
STAILQ_FOREACH(tuple, self->overrides, list_pointers) {
|
||||
_write_override(self, tuple->key, tuple->value);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Assemble and write the XML file.
|
||||
*/
|
||||
void
|
||||
lxw_content_types_assemble_xml_file(lxw_content_types *self)
|
||||
{
|
||||
/* Write the XML declaration. */
|
||||
_content_types_xml_declaration(self);
|
||||
|
||||
_write_types(self);
|
||||
_write_defaults(self);
|
||||
_write_overrides(self);
|
||||
|
||||
/* Close the content_types tag. */
|
||||
lxw_xml_end_tag(self->file, "Types");
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Public functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
/*
|
||||
* Add elements to the ContentTypes defaults.
|
||||
*/
|
||||
void
|
||||
lxw_ct_add_default(lxw_content_types *self, const char *key,
|
||||
const char *value)
|
||||
{
|
||||
lxw_tuple *tuple;
|
||||
|
||||
if (!key || !value)
|
||||
return;
|
||||
|
||||
tuple = calloc(1, sizeof(lxw_tuple));
|
||||
GOTO_LABEL_ON_MEM_ERROR(tuple, mem_error);
|
||||
|
||||
tuple->key = lxw_strdup(key);
|
||||
GOTO_LABEL_ON_MEM_ERROR(tuple->key, mem_error);
|
||||
|
||||
tuple->value = lxw_strdup(value);
|
||||
GOTO_LABEL_ON_MEM_ERROR(tuple->value, mem_error);
|
||||
|
||||
STAILQ_INSERT_TAIL(self->default_types, tuple, list_pointers);
|
||||
|
||||
return;
|
||||
|
||||
mem_error:
|
||||
if (tuple) {
|
||||
free(tuple->key);
|
||||
free(tuple->value);
|
||||
free(tuple);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Add elements to the ContentTypes overrides.
|
||||
*/
|
||||
void
|
||||
lxw_ct_add_override(lxw_content_types *self, const char *key,
|
||||
const char *value)
|
||||
{
|
||||
lxw_tuple *tuple;
|
||||
|
||||
if (!key || !value)
|
||||
return;
|
||||
|
||||
tuple = calloc(1, sizeof(lxw_tuple));
|
||||
GOTO_LABEL_ON_MEM_ERROR(tuple, mem_error);
|
||||
|
||||
tuple->key = lxw_strdup(key);
|
||||
GOTO_LABEL_ON_MEM_ERROR(tuple->key, mem_error);
|
||||
|
||||
tuple->value = lxw_strdup(value);
|
||||
GOTO_LABEL_ON_MEM_ERROR(tuple->value, mem_error);
|
||||
|
||||
STAILQ_INSERT_TAIL(self->overrides, tuple, list_pointers);
|
||||
|
||||
return;
|
||||
|
||||
mem_error:
|
||||
if (tuple) {
|
||||
free(tuple->key);
|
||||
free(tuple->value);
|
||||
free(tuple);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the name of a worksheet to the ContentTypes overrides.
|
||||
*/
|
||||
void
|
||||
lxw_ct_add_worksheet_name(lxw_content_types *self, const char *name)
|
||||
{
|
||||
lxw_ct_add_override(self, name,
|
||||
LXW_APP_DOCUMENT "spreadsheetml.worksheet+xml");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the name of a chartsheet to the ContentTypes overrides.
|
||||
*/
|
||||
void
|
||||
lxw_ct_add_chartsheet_name(lxw_content_types *self, const char *name)
|
||||
{
|
||||
lxw_ct_add_override(self, name,
|
||||
LXW_APP_DOCUMENT "spreadsheetml.chartsheet+xml");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the name of a chart to the ContentTypes overrides.
|
||||
*/
|
||||
void
|
||||
lxw_ct_add_chart_name(lxw_content_types *self, const char *name)
|
||||
{
|
||||
lxw_ct_add_override(self, name, LXW_APP_DOCUMENT "drawingml.chart+xml");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the name of a drawing to the ContentTypes overrides.
|
||||
*/
|
||||
void
|
||||
lxw_ct_add_drawing_name(lxw_content_types *self, const char *name)
|
||||
{
|
||||
lxw_ct_add_override(self, name, LXW_APP_DOCUMENT "drawing+xml");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the name of a VML drawing to the ContentTypes overrides.
|
||||
*/
|
||||
void
|
||||
lxw_ct_add_vml_name(lxw_content_types *self)
|
||||
{
|
||||
lxw_ct_add_default(self, "vml", LXW_APP_DOCUMENT "vmlDrawing");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the name of a comment to the ContentTypes overrides.
|
||||
*/
|
||||
void
|
||||
lxw_ct_add_comment_name(lxw_content_types *self, const char *name)
|
||||
{
|
||||
lxw_ct_add_override(self, name,
|
||||
LXW_APP_DOCUMENT "spreadsheetml.comments+xml");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the sharedStrings link to the ContentTypes overrides.
|
||||
*/
|
||||
void
|
||||
lxw_ct_add_shared_strings(lxw_content_types *self)
|
||||
{
|
||||
lxw_ct_add_override(self, "/xl/sharedStrings.xml",
|
||||
LXW_APP_DOCUMENT "spreadsheetml.sharedStrings+xml");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the calcChain link to the ContentTypes overrides.
|
||||
*/
|
||||
void
|
||||
lxw_ct_add_calc_chain(lxw_content_types *self)
|
||||
{
|
||||
lxw_ct_add_override(self, "/xl/calcChain.xml",
|
||||
LXW_APP_DOCUMENT "spreadsheetml.calcChain+xml");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the custom properties to the ContentTypes overrides.
|
||||
*/
|
||||
void
|
||||
lxw_ct_add_custom_properties(lxw_content_types *self)
|
||||
{
|
||||
lxw_ct_add_override(self, "/docProps/custom.xml",
|
||||
LXW_APP_DOCUMENT "custom-properties+xml");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the metadata file to the ContentTypes overrides.
|
||||
*/
|
||||
void
|
||||
lxw_ct_add_metadata(lxw_content_types *self)
|
||||
{
|
||||
lxw_ct_add_override(self, "/xl/metadata.xml",
|
||||
LXW_APP_DOCUMENT "spreadsheetml.sheetMetadata+xml");
|
||||
}
|
8
library/libxlsxwriter/src/content_types.dep
Normal file
8
library/libxlsxwriter/src/content_types.dep
Normal file
@ -0,0 +1,8 @@
|
||||
library/libxlsxwriter/src/content_types.lo: \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/src/content_types.c \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/xmlwriter.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/utility.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/common.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/queue.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/tree.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/content_types.h
|
293
library/libxlsxwriter/src/core.c
Normal file
293
library/libxlsxwriter/src/core.c
Normal file
@ -0,0 +1,293 @@
|
||||
/*****************************************************************************
|
||||
* core - A library for creating Excel XLSX core files.
|
||||
*
|
||||
* Used in conjunction with the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2021, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "xlsxwriter/xmlwriter.h"
|
||||
#include "xlsxwriter/core.h"
|
||||
#include "xlsxwriter/utility.h"
|
||||
|
||||
/*
|
||||
* Forward declarations.
|
||||
*/
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Private functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Create a new core object.
|
||||
*/
|
||||
lxw_core *
|
||||
lxw_core_new(void)
|
||||
{
|
||||
lxw_core *core = calloc(1, sizeof(lxw_core));
|
||||
GOTO_LABEL_ON_MEM_ERROR(core, mem_error);
|
||||
|
||||
return core;
|
||||
|
||||
mem_error:
|
||||
lxw_core_free(core);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free a core object.
|
||||
*/
|
||||
void
|
||||
lxw_core_free(lxw_core *core)
|
||||
{
|
||||
if (!core)
|
||||
return;
|
||||
|
||||
free(core);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a time_t to a ISO 8601 style "2010-01-01T00:00:00Z" date.
|
||||
*/
|
||||
static void
|
||||
_datetime_to_iso8601_date(time_t *timer, char *str, size_t size)
|
||||
{
|
||||
struct tm *tmp_datetime;
|
||||
time_t current_time = time(NULL);
|
||||
|
||||
if (*timer)
|
||||
tmp_datetime = gmtime(timer);
|
||||
else
|
||||
tmp_datetime = gmtime(¤t_time);
|
||||
|
||||
strftime(str, size - 1, "%Y-%m-%dT%H:%M:%SZ", tmp_datetime);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* XML functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Write the XML declaration.
|
||||
*/
|
||||
STATIC void
|
||||
_core_xml_declaration(lxw_core *self)
|
||||
{
|
||||
lxw_xml_declaration(self->file);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <cp:coreProperties> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_cp_core_properties(lxw_core *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns:cp",
|
||||
"http://schemas.openxmlformats.org/package/2006/metadata/core-properties");
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns:dc", "http://purl.org/dc/elements/1.1/");
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns:dcterms", "http://purl.org/dc/terms/");
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns:dcmitype", "http://purl.org/dc/dcmitype/");
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns:xsi",
|
||||
"http://www.w3.org/2001/XMLSchema-instance");
|
||||
|
||||
lxw_xml_start_tag(self->file, "cp:coreProperties", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <dc:creator> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_dc_creator(lxw_core *self)
|
||||
{
|
||||
if (self->properties->author) {
|
||||
lxw_xml_data_element(self->file, "dc:creator",
|
||||
self->properties->author, NULL);
|
||||
}
|
||||
else {
|
||||
lxw_xml_data_element(self->file, "dc:creator", "", NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <cp:lastModifiedBy> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_cp_last_modified_by(lxw_core *self)
|
||||
{
|
||||
if (self->properties->author) {
|
||||
lxw_xml_data_element(self->file, "cp:lastModifiedBy",
|
||||
self->properties->author, NULL);
|
||||
}
|
||||
else {
|
||||
lxw_xml_data_element(self->file, "cp:lastModifiedBy", "", NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <dcterms:created> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_dcterms_created(lxw_core *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
char datetime[LXW_ATTR_32];
|
||||
|
||||
_datetime_to_iso8601_date(&self->properties->created, datetime,
|
||||
LXW_ATTR_32);
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("xsi:type", "dcterms:W3CDTF");
|
||||
|
||||
lxw_xml_data_element(self->file, "dcterms:created", datetime,
|
||||
&attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <dcterms:modified> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_dcterms_modified(lxw_core *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
char datetime[LXW_ATTR_32];
|
||||
|
||||
_datetime_to_iso8601_date(&self->properties->created, datetime,
|
||||
LXW_ATTR_32);
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("xsi:type", "dcterms:W3CDTF");
|
||||
|
||||
lxw_xml_data_element(self->file, "dcterms:modified", datetime,
|
||||
&attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <dc:title> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_dc_title(lxw_core *self)
|
||||
{
|
||||
if (!self->properties->title)
|
||||
return;
|
||||
|
||||
lxw_xml_data_element(self->file, "dc:title", self->properties->title,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <dc:subject> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_dc_subject(lxw_core *self)
|
||||
{
|
||||
if (!self->properties->subject)
|
||||
return;
|
||||
|
||||
lxw_xml_data_element(self->file, "dc:subject", self->properties->subject,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <cp:keywords> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_cp_keywords(lxw_core *self)
|
||||
{
|
||||
if (!self->properties->keywords)
|
||||
return;
|
||||
|
||||
lxw_xml_data_element(self->file, "cp:keywords",
|
||||
self->properties->keywords, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <dc:description> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_dc_description(lxw_core *self)
|
||||
{
|
||||
if (!self->properties->comments)
|
||||
return;
|
||||
|
||||
lxw_xml_data_element(self->file, "dc:description",
|
||||
self->properties->comments, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <cp:category> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_cp_category(lxw_core *self)
|
||||
{
|
||||
if (!self->properties->category)
|
||||
return;
|
||||
|
||||
lxw_xml_data_element(self->file, "cp:category",
|
||||
self->properties->category, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <cp:contentStatus> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_cp_content_status(lxw_core *self)
|
||||
{
|
||||
if (!self->properties->status)
|
||||
return;
|
||||
|
||||
lxw_xml_data_element(self->file, "cp:contentStatus",
|
||||
self->properties->status, NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* XML file assembly functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Assemble and write the XML file.
|
||||
*/
|
||||
void
|
||||
lxw_core_assemble_xml_file(lxw_core *self)
|
||||
{
|
||||
/* Write the XML declaration. */
|
||||
_core_xml_declaration(self);
|
||||
|
||||
_write_cp_core_properties(self);
|
||||
_write_dc_title(self);
|
||||
_write_dc_subject(self);
|
||||
_write_dc_creator(self);
|
||||
_write_cp_keywords(self);
|
||||
_write_dc_description(self);
|
||||
_write_cp_last_modified_by(self);
|
||||
_write_dcterms_created(self);
|
||||
_write_dcterms_modified(self);
|
||||
_write_cp_category(self);
|
||||
_write_cp_content_status(self);
|
||||
|
||||
lxw_xml_end_tag(self->file, "cp:coreProperties");
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Public functions.
|
||||
*
|
||||
****************************************************************************/
|
18
library/libxlsxwriter/src/core.dep
Normal file
18
library/libxlsxwriter/src/core.dep
Normal file
@ -0,0 +1,18 @@
|
||||
library/libxlsxwriter/src/core.lo: \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/src/core.c \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/xmlwriter.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/utility.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/common.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/queue.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/tree.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/core.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/workbook.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/worksheet.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/shared_strings.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/chart.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/format.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/hash_table.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/drawing.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/styles.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/relationships.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/chartsheet.h
|
224
library/libxlsxwriter/src/custom.c
Normal file
224
library/libxlsxwriter/src/custom.c
Normal file
@ -0,0 +1,224 @@
|
||||
/*****************************************************************************
|
||||
* custom - A library for creating Excel custom property files.
|
||||
*
|
||||
* Used in conjunction with the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2021, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "xlsxwriter/xmlwriter.h"
|
||||
#include "xlsxwriter/custom.h"
|
||||
#include "xlsxwriter/utility.h"
|
||||
|
||||
/*
|
||||
* Forward declarations.
|
||||
*/
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Private functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Create a new custom object.
|
||||
*/
|
||||
lxw_custom *
|
||||
lxw_custom_new(void)
|
||||
{
|
||||
lxw_custom *custom = calloc(1, sizeof(lxw_custom));
|
||||
GOTO_LABEL_ON_MEM_ERROR(custom, mem_error);
|
||||
|
||||
return custom;
|
||||
|
||||
mem_error:
|
||||
lxw_custom_free(custom);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free a custom object.
|
||||
*/
|
||||
void
|
||||
lxw_custom_free(lxw_custom *custom)
|
||||
{
|
||||
if (!custom)
|
||||
return;
|
||||
|
||||
free(custom);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* XML functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Write the XML declaration.
|
||||
*/
|
||||
STATIC void
|
||||
_custom_xml_declaration(lxw_custom *self)
|
||||
{
|
||||
lxw_xml_declaration(self->file);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <vt:lpwstr> element.
|
||||
*/
|
||||
STATIC void
|
||||
_chart_write_vt_lpwstr(lxw_custom *self, char *value)
|
||||
{
|
||||
lxw_xml_data_element(self->file, "vt:lpwstr", value, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <vt:r8> element.
|
||||
*/
|
||||
STATIC void
|
||||
_chart_write_vt_r_8(lxw_custom *self, double value)
|
||||
{
|
||||
char data[LXW_ATTR_32];
|
||||
|
||||
lxw_sprintf_dbl(data, value);
|
||||
|
||||
lxw_xml_data_element(self->file, "vt:r8", data, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <vt:i4> element.
|
||||
*/
|
||||
STATIC void
|
||||
_custom_write_vt_i_4(lxw_custom *self, int32_t value)
|
||||
{
|
||||
char data[LXW_ATTR_32];
|
||||
|
||||
lxw_snprintf(data, LXW_ATTR_32, "%d", value);
|
||||
|
||||
lxw_xml_data_element(self->file, "vt:i4", data, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <vt:bool> element.
|
||||
*/
|
||||
STATIC void
|
||||
_custom_write_vt_bool(lxw_custom *self, uint8_t value)
|
||||
{
|
||||
if (value)
|
||||
lxw_xml_data_element(self->file, "vt:bool", "true", NULL);
|
||||
else
|
||||
lxw_xml_data_element(self->file, "vt:bool", "false", NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <vt:filetime> element.
|
||||
*/
|
||||
STATIC void
|
||||
_custom_write_vt_filetime(lxw_custom *self, lxw_datetime *datetime)
|
||||
{
|
||||
char data[LXW_DATETIME_LENGTH];
|
||||
|
||||
lxw_snprintf(data, LXW_DATETIME_LENGTH, "%4d-%02d-%02dT%02d:%02d:%02dZ",
|
||||
datetime->year, datetime->month, datetime->day,
|
||||
datetime->hour, datetime->min, (int) datetime->sec);
|
||||
|
||||
lxw_xml_data_element(self->file, "vt:filetime", data, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <property> element.
|
||||
*/
|
||||
STATIC void
|
||||
_chart_write_custom_property(lxw_custom *self,
|
||||
lxw_custom_property *custom_property)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
char fmtid[] = "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}";
|
||||
|
||||
self->pid++;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("fmtid", fmtid);
|
||||
LXW_PUSH_ATTRIBUTES_INT("pid", self->pid + 1);
|
||||
LXW_PUSH_ATTRIBUTES_STR("name", custom_property->name);
|
||||
|
||||
lxw_xml_start_tag(self->file, "property", &attributes);
|
||||
|
||||
if (custom_property->type == LXW_CUSTOM_STRING) {
|
||||
/* Write the vt:lpwstr element. */
|
||||
_chart_write_vt_lpwstr(self, custom_property->u.string);
|
||||
}
|
||||
else if (custom_property->type == LXW_CUSTOM_DOUBLE) {
|
||||
/* Write the vt:r8 element. */
|
||||
_chart_write_vt_r_8(self, custom_property->u.number);
|
||||
}
|
||||
else if (custom_property->type == LXW_CUSTOM_INTEGER) {
|
||||
/* Write the vt:i4 element. */
|
||||
_custom_write_vt_i_4(self, custom_property->u.integer);
|
||||
}
|
||||
else if (custom_property->type == LXW_CUSTOM_BOOLEAN) {
|
||||
/* Write the vt:bool element. */
|
||||
_custom_write_vt_bool(self, custom_property->u.boolean);
|
||||
}
|
||||
else if (custom_property->type == LXW_CUSTOM_DATETIME) {
|
||||
/* Write the vt:filetime element. */
|
||||
_custom_write_vt_filetime(self, &custom_property->u.datetime);
|
||||
}
|
||||
|
||||
lxw_xml_end_tag(self->file, "property");
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <Properties> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_custom_properties(lxw_custom *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
char xmlns[] = LXW_SCHEMA_OFFICEDOC "/custom-properties";
|
||||
char xmlns_vt[] = LXW_SCHEMA_OFFICEDOC "/docPropsVTypes";
|
||||
lxw_custom_property *custom_property;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns", xmlns);
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns:vt", xmlns_vt);
|
||||
|
||||
lxw_xml_start_tag(self->file, "Properties", &attributes);
|
||||
|
||||
STAILQ_FOREACH(custom_property, self->custom_properties, list_pointers) {
|
||||
_chart_write_custom_property(self, custom_property);
|
||||
}
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* XML file assembly functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Assemble and write the XML file.
|
||||
*/
|
||||
void
|
||||
lxw_custom_assemble_xml_file(lxw_custom *self)
|
||||
{
|
||||
/* Write the XML declaration. */
|
||||
_custom_xml_declaration(self);
|
||||
|
||||
_write_custom_properties(self);
|
||||
|
||||
lxw_xml_end_tag(self->file, "Properties");
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Public functions.
|
||||
*
|
||||
****************************************************************************/
|
8
library/libxlsxwriter/src/custom.dep
Normal file
8
library/libxlsxwriter/src/custom.dep
Normal file
@ -0,0 +1,8 @@
|
||||
library/libxlsxwriter/src/custom.lo: \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/src/custom.c \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/xmlwriter.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/utility.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/common.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/queue.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/tree.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/custom.h
|
963
library/libxlsxwriter/src/drawing.c
Normal file
963
library/libxlsxwriter/src/drawing.c
Normal file
@ -0,0 +1,963 @@
|
||||
/*****************************************************************************
|
||||
* drawing - A library for creating Excel XLSX drawing files.
|
||||
*
|
||||
* Used in conjunction with the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2021, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "xlsxwriter/xmlwriter.h"
|
||||
#include "xlsxwriter/common.h"
|
||||
#include "xlsxwriter/drawing.h"
|
||||
#include "xlsxwriter/worksheet.h"
|
||||
#include "xlsxwriter/utility.h"
|
||||
|
||||
#define LXW_OBJ_NAME_LENGTH 14 /* "Picture 65536", or "Chart 65536" */
|
||||
/*
|
||||
* Forward declarations.
|
||||
*/
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Private functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Create a new drawing collection.
|
||||
*/
|
||||
lxw_drawing *
|
||||
lxw_drawing_new(void)
|
||||
{
|
||||
lxw_drawing *drawing = calloc(1, sizeof(lxw_drawing));
|
||||
GOTO_LABEL_ON_MEM_ERROR(drawing, mem_error);
|
||||
|
||||
drawing->drawing_objects = calloc(1, sizeof(struct lxw_drawing_objects));
|
||||
GOTO_LABEL_ON_MEM_ERROR(drawing->drawing_objects, mem_error);
|
||||
|
||||
STAILQ_INIT(drawing->drawing_objects);
|
||||
|
||||
return drawing;
|
||||
|
||||
mem_error:
|
||||
lxw_drawing_free(drawing);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free a drawing object.
|
||||
*/
|
||||
void
|
||||
lxw_free_drawing_object(lxw_drawing_object *drawing_object)
|
||||
{
|
||||
if (!drawing_object)
|
||||
return;
|
||||
|
||||
free(drawing_object->description);
|
||||
free(drawing_object->tip);
|
||||
|
||||
free(drawing_object);
|
||||
}
|
||||
|
||||
/*
|
||||
* Free a drawing collection.
|
||||
*/
|
||||
void
|
||||
lxw_drawing_free(lxw_drawing *drawing)
|
||||
{
|
||||
lxw_drawing_object *drawing_object;
|
||||
|
||||
if (!drawing)
|
||||
return;
|
||||
|
||||
if (drawing->drawing_objects) {
|
||||
while (!STAILQ_EMPTY(drawing->drawing_objects)) {
|
||||
drawing_object = STAILQ_FIRST(drawing->drawing_objects);
|
||||
STAILQ_REMOVE_HEAD(drawing->drawing_objects, list_pointers);
|
||||
lxw_free_drawing_object(drawing_object);
|
||||
}
|
||||
|
||||
free(drawing->drawing_objects);
|
||||
}
|
||||
|
||||
free(drawing);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a drawing object to the drawing collection.
|
||||
*/
|
||||
void
|
||||
lxw_add_drawing_object(lxw_drawing *drawing,
|
||||
lxw_drawing_object *drawing_object)
|
||||
{
|
||||
STAILQ_INSERT_TAIL(drawing->drawing_objects, drawing_object,
|
||||
list_pointers);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* XML functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Write the XML declaration.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_xml_declaration(lxw_drawing *self)
|
||||
{
|
||||
lxw_xml_declaration(self->file);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <xdr:wsDr> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_drawing_workspace(lxw_drawing *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
char xmlns_xdr[] = LXW_SCHEMA_DRAWING "/spreadsheetDrawing";
|
||||
char xmlns_a[] = LXW_SCHEMA_DRAWING "/main";
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns:xdr", xmlns_xdr);
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns:a", xmlns_a);
|
||||
|
||||
lxw_xml_start_tag(self->file, "xdr:wsDr", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <xdr:col> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_col(lxw_drawing *self, char *data)
|
||||
{
|
||||
lxw_xml_data_element(self->file, "xdr:col", data, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <xdr:colOff> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_col_off(lxw_drawing *self, char *data)
|
||||
{
|
||||
lxw_xml_data_element(self->file, "xdr:colOff", data, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <xdr:row> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_row(lxw_drawing *self, char *data)
|
||||
{
|
||||
lxw_xml_data_element(self->file, "xdr:row", data, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <xdr:rowOff> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_row_off(lxw_drawing *self, char *data)
|
||||
{
|
||||
lxw_xml_data_element(self->file, "xdr:rowOff", data, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the main part of the <xdr:from> and <xdr:to> elements.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_coords(lxw_drawing *self, lxw_drawing_coords *coords)
|
||||
{
|
||||
char data[LXW_UINT32_T_LENGTH];
|
||||
|
||||
lxw_snprintf(data, LXW_UINT32_T_LENGTH, "%u", coords->col);
|
||||
_drawing_write_col(self, data);
|
||||
|
||||
lxw_snprintf(data, LXW_UINT32_T_LENGTH, "%u",
|
||||
(uint32_t) coords->col_offset);
|
||||
_drawing_write_col_off(self, data);
|
||||
|
||||
lxw_snprintf(data, LXW_UINT32_T_LENGTH, "%u", coords->row);
|
||||
_drawing_write_row(self, data);
|
||||
|
||||
lxw_snprintf(data, LXW_UINT32_T_LENGTH, "%u",
|
||||
(uint32_t) coords->row_offset);
|
||||
_drawing_write_row_off(self, data);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <xdr:from> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_from(lxw_drawing *self, lxw_drawing_coords *coords)
|
||||
{
|
||||
lxw_xml_start_tag(self->file, "xdr:from", NULL);
|
||||
|
||||
_drawing_write_coords(self, coords);
|
||||
|
||||
lxw_xml_end_tag(self->file, "xdr:from");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <xdr:to> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_to(lxw_drawing *self, lxw_drawing_coords *coords)
|
||||
{
|
||||
lxw_xml_start_tag(self->file, "xdr:to", NULL);
|
||||
|
||||
_drawing_write_coords(self, coords);
|
||||
|
||||
lxw_xml_end_tag(self->file, "xdr:to");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <a:hlinkClick> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_a_hlink_click(lxw_drawing *self, uint32_t rel_index, char *tip)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
char xmlns_r[] = "http://schemas.openxmlformats.org/"
|
||||
"officeDocument/2006/relationships";
|
||||
char r_id[LXW_MAX_ATTRIBUTE_LENGTH];
|
||||
|
||||
lxw_snprintf(r_id, LXW_ATTR_32, "rId%d", rel_index);
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns:r", xmlns_r);
|
||||
LXW_PUSH_ATTRIBUTES_STR("r:id", r_id);
|
||||
|
||||
if (tip)
|
||||
LXW_PUSH_ATTRIBUTES_STR("tooltip", tip);
|
||||
|
||||
lxw_xml_empty_tag(self->file, "a:hlinkClick", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <a16:creationId> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_a16_creation_id(lxw_drawing *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
char xmlns[] = "http://schemas.microsoft.com/office/drawing/2014/main";
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns:a16", xmlns);
|
||||
LXW_PUSH_ATTRIBUTES_STR("id", "{00000000-0008-0000-0000-000002000000}");
|
||||
|
||||
lxw_xml_empty_tag(self->file, "a16:creationId", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <adec:decorative> element.
|
||||
*/
|
||||
STATIC void
|
||||
_workbook_write_adec_decorative(lxw_drawing *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
char xmlns[] =
|
||||
"http://schemas.microsoft.com/office/drawing/2017/decorative";
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns:adec", xmlns);
|
||||
LXW_PUSH_ATTRIBUTES_STR("val", "1");
|
||||
|
||||
lxw_xml_empty_tag(self->file, "adec:decorative", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <a:ext> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_uri_ext(lxw_drawing *self, char *uri)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("uri", uri);
|
||||
|
||||
lxw_xml_start_tag(self->file, "a:ext", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the decorative elements.
|
||||
*/
|
||||
STATIC void
|
||||
_workbook_write_decorative(lxw_drawing *self)
|
||||
{
|
||||
lxw_xml_start_tag(self->file, "a:extLst", NULL);
|
||||
|
||||
_drawing_write_uri_ext(self, "{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}");
|
||||
_drawing_write_a16_creation_id(self);
|
||||
lxw_xml_end_tag(self->file, "a:ext");
|
||||
|
||||
_drawing_write_uri_ext(self, "{C183D7F6-B498-43B3-948B-1728B52AA6E4}");
|
||||
_workbook_write_adec_decorative(self);
|
||||
lxw_xml_end_tag(self->file, "a:ext");
|
||||
|
||||
lxw_xml_end_tag(self->file, "a:extLst");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <xdr:cNvPr> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_c_nv_pr(lxw_drawing *self, char *object_name, uint32_t index,
|
||||
lxw_drawing_object *drawing_object)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
char name[LXW_OBJ_NAME_LENGTH];
|
||||
lxw_snprintf(name, LXW_OBJ_NAME_LENGTH, "%s %d", object_name, index);
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
|
||||
LXW_PUSH_ATTRIBUTES_INT("id", index + 1);
|
||||
LXW_PUSH_ATTRIBUTES_STR("name", name);
|
||||
|
||||
if (drawing_object && drawing_object->description
|
||||
&& strlen(drawing_object->description)
|
||||
&& !drawing_object->decorative) {
|
||||
|
||||
LXW_PUSH_ATTRIBUTES_STR("descr", drawing_object->description);
|
||||
}
|
||||
|
||||
if (drawing_object
|
||||
&& (drawing_object->url_rel_index || drawing_object->decorative)) {
|
||||
lxw_xml_start_tag(self->file, "xdr:cNvPr", &attributes);
|
||||
|
||||
if (drawing_object->url_rel_index) {
|
||||
/* Write the a:hlinkClick element. */
|
||||
_drawing_write_a_hlink_click(self,
|
||||
drawing_object->url_rel_index,
|
||||
drawing_object->tip);
|
||||
}
|
||||
|
||||
if (drawing_object->decorative) {
|
||||
_workbook_write_decorative(self);
|
||||
}
|
||||
|
||||
lxw_xml_end_tag(self->file, "xdr:cNvPr");
|
||||
}
|
||||
else {
|
||||
lxw_xml_empty_tag(self->file, "xdr:cNvPr", &attributes);
|
||||
}
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <a:picLocks> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_a_pic_locks(lxw_drawing *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("noChangeAspect", "1");
|
||||
|
||||
lxw_xml_empty_tag(self->file, "a:picLocks", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <xdr:cNvPicPr> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_c_nv_pic_pr(lxw_drawing *self)
|
||||
{
|
||||
lxw_xml_start_tag(self->file, "xdr:cNvPicPr", NULL);
|
||||
|
||||
/* Write the a:picLocks element. */
|
||||
_drawing_write_a_pic_locks(self);
|
||||
|
||||
lxw_xml_end_tag(self->file, "xdr:cNvPicPr");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <xdr:nvPicPr> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_nv_pic_pr(lxw_drawing *self, uint32_t index,
|
||||
lxw_drawing_object *drawing_object)
|
||||
{
|
||||
lxw_xml_start_tag(self->file, "xdr:nvPicPr", NULL);
|
||||
|
||||
/* Write the xdr:cNvPr element. */
|
||||
_drawing_write_c_nv_pr(self, "Picture", index, drawing_object);
|
||||
|
||||
/* Write the xdr:cNvPicPr element. */
|
||||
_drawing_write_c_nv_pic_pr(self);
|
||||
|
||||
lxw_xml_end_tag(self->file, "xdr:nvPicPr");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <a:blip> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_a_blip(lxw_drawing *self, uint32_t index)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
char xmlns_r[] = LXW_SCHEMA_OFFICEDOC "/relationships";
|
||||
char r_id[LXW_MAX_ATTRIBUTE_LENGTH];
|
||||
|
||||
lxw_snprintf(r_id, LXW_ATTR_32, "rId%d", index);
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns:r", xmlns_r);
|
||||
LXW_PUSH_ATTRIBUTES_STR("r:embed", r_id);
|
||||
|
||||
lxw_xml_empty_tag(self->file, "a:blip", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <a:fillRect> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_a_fill_rect(lxw_drawing *self)
|
||||
{
|
||||
lxw_xml_empty_tag(self->file, "a:fillRect", NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <a:stretch> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_a_stretch(lxw_drawing *self)
|
||||
{
|
||||
lxw_xml_start_tag(self->file, "a:stretch", NULL);
|
||||
|
||||
/* Write the a:fillRect element. */
|
||||
_drawing_write_a_fill_rect(self);
|
||||
|
||||
lxw_xml_end_tag(self->file, "a:stretch");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <xdr:blipFill> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_blip_fill(lxw_drawing *self, uint32_t index)
|
||||
{
|
||||
lxw_xml_start_tag(self->file, "xdr:blipFill", NULL);
|
||||
|
||||
/* Write the a:blip element. */
|
||||
_drawing_write_a_blip(self, index);
|
||||
|
||||
/* Write the a:stretch element. */
|
||||
_drawing_write_a_stretch(self);
|
||||
|
||||
lxw_xml_end_tag(self->file, "xdr:blipFill");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <a:ext> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_a_ext(lxw_drawing *self, lxw_drawing_object *drawing_object)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_INT("cx", drawing_object->width);
|
||||
LXW_PUSH_ATTRIBUTES_INT("cy", drawing_object->height);
|
||||
|
||||
lxw_xml_empty_tag(self->file, "a:ext", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <a:off> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_a_off(lxw_drawing *self, lxw_drawing_object *drawing_object)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_INT("x", drawing_object->col_absolute);
|
||||
LXW_PUSH_ATTRIBUTES_INT("y", drawing_object->row_absolute);
|
||||
|
||||
lxw_xml_empty_tag(self->file, "a:off", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <a:xfrm> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_a_xfrm(lxw_drawing *self, lxw_drawing_object *drawing_object)
|
||||
{
|
||||
lxw_xml_start_tag(self->file, "a:xfrm", NULL);
|
||||
|
||||
/* Write the a:off element. */
|
||||
_drawing_write_a_off(self, drawing_object);
|
||||
|
||||
/* Write the a:ext element. */
|
||||
_drawing_write_a_ext(self, drawing_object);
|
||||
|
||||
lxw_xml_end_tag(self->file, "a:xfrm");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <a:avLst> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_a_av_lst(lxw_drawing *self)
|
||||
{
|
||||
lxw_xml_empty_tag(self->file, "a:avLst", NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <a:prstGeom> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_a_prst_geom(lxw_drawing *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("prst", "rect");
|
||||
|
||||
lxw_xml_start_tag(self->file, "a:prstGeom", &attributes);
|
||||
|
||||
/* Write the a:avLst element. */
|
||||
_drawing_write_a_av_lst(self);
|
||||
|
||||
lxw_xml_end_tag(self->file, "a:prstGeom");
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <xdr:spPr> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_sp_pr(lxw_drawing *self, lxw_drawing_object *drawing_object)
|
||||
{
|
||||
lxw_xml_start_tag(self->file, "xdr:spPr", NULL);
|
||||
|
||||
/* Write the a:xfrm element. */
|
||||
_drawing_write_a_xfrm(self, drawing_object);
|
||||
|
||||
/* Write the a:prstGeom element. */
|
||||
_drawing_write_a_prst_geom(self);
|
||||
|
||||
lxw_xml_end_tag(self->file, "xdr:spPr");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <xdr:pic> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_pic(lxw_drawing *self, uint32_t index,
|
||||
lxw_drawing_object *drawing_object)
|
||||
{
|
||||
lxw_xml_start_tag(self->file, "xdr:pic", NULL);
|
||||
|
||||
/* Write the xdr:nvPicPr element. */
|
||||
_drawing_write_nv_pic_pr(self, index, drawing_object);
|
||||
|
||||
/* Write the xdr:blipFill element. */
|
||||
_drawing_write_blip_fill(self, drawing_object->rel_index);
|
||||
|
||||
/* Write the xdr:spPr element. */
|
||||
_drawing_write_sp_pr(self, drawing_object);
|
||||
|
||||
lxw_xml_end_tag(self->file, "xdr:pic");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <xdr:clientData> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_client_data(lxw_drawing *self)
|
||||
{
|
||||
lxw_xml_empty_tag(self->file, "xdr:clientData", NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <a:graphicFrameLocks> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_a_graphic_frame_locks(lxw_drawing *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_INT("noGrp", 1);
|
||||
|
||||
lxw_xml_empty_tag(self->file, "a:graphicFrameLocks", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <xdr:cNvGraphicFramePr> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_c_nv_graphic_frame_pr(lxw_drawing *self)
|
||||
{
|
||||
if (self->embedded) {
|
||||
lxw_xml_empty_tag(self->file, "xdr:cNvGraphicFramePr", NULL);
|
||||
}
|
||||
else {
|
||||
lxw_xml_start_tag(self->file, "xdr:cNvGraphicFramePr", NULL);
|
||||
|
||||
/* Write the a:graphicFrameLocks element. */
|
||||
_drawing_write_a_graphic_frame_locks(self);
|
||||
|
||||
lxw_xml_end_tag(self->file, "xdr:cNvGraphicFramePr");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <xdr:nvGraphicFramePr> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_nv_graphic_frame_pr(lxw_drawing *self, uint32_t index,
|
||||
lxw_drawing_object *drawing_object)
|
||||
{
|
||||
lxw_xml_start_tag(self->file, "xdr:nvGraphicFramePr", NULL);
|
||||
|
||||
/* Write the xdr:cNvPr element. */
|
||||
_drawing_write_c_nv_pr(self, "Chart", index, drawing_object);
|
||||
|
||||
/* Write the xdr:cNvGraphicFramePr element. */
|
||||
_drawing_write_c_nv_graphic_frame_pr(self);
|
||||
|
||||
lxw_xml_end_tag(self->file, "xdr:nvGraphicFramePr");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <a:off> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_xfrm_offset(lxw_drawing *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("x", "0");
|
||||
LXW_PUSH_ATTRIBUTES_STR("y", "0");
|
||||
|
||||
lxw_xml_empty_tag(self->file, "a:off", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <a:ext> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_xfrm_extension(lxw_drawing *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("cx", "0");
|
||||
LXW_PUSH_ATTRIBUTES_STR("cy", "0");
|
||||
|
||||
lxw_xml_empty_tag(self->file, "a:ext", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <xdr:xfrm> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_xfrm(lxw_drawing *self)
|
||||
{
|
||||
lxw_xml_start_tag(self->file, "xdr:xfrm", NULL);
|
||||
|
||||
/* Write the a:off element. */
|
||||
_drawing_write_xfrm_offset(self);
|
||||
|
||||
/* Write the a:ext element. */
|
||||
_drawing_write_xfrm_extension(self);
|
||||
|
||||
lxw_xml_end_tag(self->file, "xdr:xfrm");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <c:chart> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_chart(lxw_drawing *self, uint32_t index)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
char xmlns_c[] = LXW_SCHEMA_DRAWING "/chart";
|
||||
char xmlns_r[] = LXW_SCHEMA_OFFICEDOC "/relationships";
|
||||
char r_id[LXW_MAX_ATTRIBUTE_LENGTH];
|
||||
|
||||
lxw_snprintf(r_id, LXW_ATTR_32, "rId%d", index);
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns:c", xmlns_c);
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns:r", xmlns_r);
|
||||
LXW_PUSH_ATTRIBUTES_STR("r:id", r_id);
|
||||
|
||||
lxw_xml_empty_tag(self->file, "c:chart", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <a:graphicData> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_a_graphic_data(lxw_drawing *self, uint32_t index)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
char uri[] = LXW_SCHEMA_DRAWING "/chart";
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("uri", uri);
|
||||
|
||||
lxw_xml_start_tag(self->file, "a:graphicData", &attributes);
|
||||
|
||||
/* Write the c:chart element. */
|
||||
_drawing_write_chart(self, index);
|
||||
|
||||
lxw_xml_end_tag(self->file, "a:graphicData");
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <a:graphic> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_a_graphic(lxw_drawing *self, uint32_t index)
|
||||
{
|
||||
|
||||
lxw_xml_start_tag(self->file, "a:graphic", NULL);
|
||||
|
||||
/* Write the a:graphicData element. */
|
||||
_drawing_write_a_graphic_data(self, index);
|
||||
|
||||
lxw_xml_end_tag(self->file, "a:graphic");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <xdr:graphicFrame> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_graphic_frame(lxw_drawing *self, uint32_t index,
|
||||
uint32_t rel_index,
|
||||
lxw_drawing_object *drawing_object)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("macro", "");
|
||||
|
||||
lxw_xml_start_tag(self->file, "xdr:graphicFrame", &attributes);
|
||||
|
||||
/* Write the xdr:nvGraphicFramePr element. */
|
||||
_drawing_write_nv_graphic_frame_pr(self, index, drawing_object);
|
||||
|
||||
/* Write the xdr:xfrm element. */
|
||||
_drawing_write_xfrm(self);
|
||||
|
||||
/* Write the a:graphic element. */
|
||||
_drawing_write_a_graphic(self, rel_index);
|
||||
|
||||
lxw_xml_end_tag(self->file, "xdr:graphicFrame");
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <xdr:twoCellAnchor> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_two_cell_anchor(lxw_drawing *self, uint32_t index,
|
||||
lxw_drawing_object *drawing_object)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
|
||||
if (drawing_object->anchor == LXW_OBJECT_MOVE_DONT_SIZE)
|
||||
LXW_PUSH_ATTRIBUTES_STR("editAs", "oneCell");
|
||||
else if (drawing_object->anchor == LXW_OBJECT_DONT_MOVE_DONT_SIZE)
|
||||
LXW_PUSH_ATTRIBUTES_STR("editAs", "absolute");
|
||||
|
||||
lxw_xml_start_tag(self->file, "xdr:twoCellAnchor", &attributes);
|
||||
|
||||
_drawing_write_from(self, &drawing_object->from);
|
||||
_drawing_write_to(self, &drawing_object->to);
|
||||
|
||||
if (drawing_object->type == LXW_DRAWING_CHART) {
|
||||
/* Write the xdr:graphicFrame element for charts. */
|
||||
_drawing_write_graphic_frame(self, index, drawing_object->rel_index,
|
||||
drawing_object);
|
||||
}
|
||||
else if (drawing_object->type == LXW_DRAWING_IMAGE) {
|
||||
/* Write the xdr:pic element. */
|
||||
_drawing_write_pic(self, index, drawing_object);
|
||||
}
|
||||
else {
|
||||
/* Write the xdr:sp element for shapes. */
|
||||
/* _drawing_write_sp(self, index, col_absolute, row_absolute, width,
|
||||
height, shape); */
|
||||
}
|
||||
|
||||
/* Write the xdr:clientData element. */
|
||||
_drawing_write_client_data(self);
|
||||
|
||||
lxw_xml_end_tag(self->file, "xdr:twoCellAnchor");
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <xdr:ext> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_ext(lxw_drawing *self, uint32_t cx, uint32_t cy)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_INT("cx", cx);
|
||||
LXW_PUSH_ATTRIBUTES_INT("cy", cy);
|
||||
|
||||
lxw_xml_empty_tag(self->file, "xdr:ext", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <xdr:pos> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_pos(lxw_drawing *self, int32_t x, int32_t y)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_INT("x", x);
|
||||
LXW_PUSH_ATTRIBUTES_INT("y", y);
|
||||
|
||||
lxw_xml_empty_tag(self->file, "xdr:pos", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <xdr:absoluteAnchor> element.
|
||||
*/
|
||||
STATIC void
|
||||
_drawing_write_absolute_anchor(lxw_drawing *self, uint32_t frame_index)
|
||||
{
|
||||
lxw_xml_start_tag(self->file, "xdr:absoluteAnchor", NULL);
|
||||
|
||||
if (self->orientation == LXW_LANDSCAPE) {
|
||||
/* Write the xdr:pos element. */
|
||||
_drawing_write_pos(self, 0, 0);
|
||||
|
||||
/* Write the xdr:ext element. */
|
||||
_drawing_write_ext(self, 9308969, 6078325);
|
||||
}
|
||||
else {
|
||||
/* Write the xdr:pos element. */
|
||||
_drawing_write_pos(self, 0, -47625);
|
||||
|
||||
/* Write the xdr:ext element. */
|
||||
_drawing_write_ext(self, 6162675, 6124575);
|
||||
}
|
||||
|
||||
_drawing_write_graphic_frame(self, frame_index, frame_index, NULL);
|
||||
|
||||
/* Write the xdr:clientData element. */
|
||||
_drawing_write_client_data(self);
|
||||
|
||||
lxw_xml_end_tag(self->file, "xdr:absoluteAnchor");
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* XML file assembly functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Assemble and write the XML file.
|
||||
*/
|
||||
void
|
||||
lxw_drawing_assemble_xml_file(lxw_drawing *self)
|
||||
{
|
||||
uint32_t index;
|
||||
lxw_drawing_object *drawing_object;
|
||||
|
||||
/* Write the XML declaration. */
|
||||
_drawing_xml_declaration(self);
|
||||
|
||||
/* Write the xdr:wsDr element. */
|
||||
_write_drawing_workspace(self);
|
||||
|
||||
if (self->embedded) {
|
||||
index = 1;
|
||||
|
||||
STAILQ_FOREACH(drawing_object, self->drawing_objects, list_pointers) {
|
||||
_drawing_write_two_cell_anchor(self, index, drawing_object);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Write the xdr:absoluteAnchor element. Mainly for chartsheets. */
|
||||
_drawing_write_absolute_anchor(self, 1);
|
||||
}
|
||||
|
||||
lxw_xml_end_tag(self->file, "xdr:wsDr");
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Public functions.
|
||||
*
|
||||
****************************************************************************/
|
15
library/libxlsxwriter/src/drawing.dep
Normal file
15
library/libxlsxwriter/src/drawing.dep
Normal file
@ -0,0 +1,15 @@
|
||||
library/libxlsxwriter/src/drawing.lo: \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/src/drawing.c \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/xmlwriter.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/utility.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/common.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/queue.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/tree.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/drawing.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/worksheet.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/shared_strings.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/chart.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/format.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/hash_table.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/styles.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/relationships.h
|
801
library/libxlsxwriter/src/format.c
Normal file
801
library/libxlsxwriter/src/format.c
Normal file
@ -0,0 +1,801 @@
|
||||
/*****************************************************************************
|
||||
* format - A library for creating Excel XLSX format files.
|
||||
*
|
||||
* Used in conjunction with the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2021, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "xlsxwriter/xmlwriter.h"
|
||||
#include "xlsxwriter/format.h"
|
||||
#include "xlsxwriter/utility.h"
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Private functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Create a new format object.
|
||||
*/
|
||||
lxw_format *
|
||||
lxw_format_new(void)
|
||||
{
|
||||
lxw_format *format = calloc(1, sizeof(lxw_format));
|
||||
GOTO_LABEL_ON_MEM_ERROR(format, mem_error);
|
||||
|
||||
format->xf_format_indices = NULL;
|
||||
format->dxf_format_indices = NULL;
|
||||
|
||||
format->xf_index = LXW_PROPERTY_UNSET;
|
||||
format->dxf_index = LXW_PROPERTY_UNSET;
|
||||
format->xf_id = 0;
|
||||
|
||||
format->font_name[0] = '\0';
|
||||
format->font_scheme[0] = '\0';
|
||||
format->num_format[0] = '\0';
|
||||
format->num_format_index = 0;
|
||||
format->font_index = 0;
|
||||
format->has_font = LXW_FALSE;
|
||||
format->has_dxf_font = LXW_FALSE;
|
||||
format->font_size = 11.0;
|
||||
format->bold = LXW_FALSE;
|
||||
format->italic = LXW_FALSE;
|
||||
format->font_color = LXW_COLOR_UNSET;
|
||||
format->underline = LXW_UNDERLINE_NONE;
|
||||
format->font_strikeout = LXW_FALSE;
|
||||
format->font_outline = LXW_FALSE;
|
||||
format->font_shadow = LXW_FALSE;
|
||||
format->font_script = LXW_FALSE;
|
||||
format->font_family = LXW_DEFAULT_FONT_FAMILY;
|
||||
format->font_charset = LXW_FALSE;
|
||||
format->font_condense = LXW_FALSE;
|
||||
format->font_extend = LXW_FALSE;
|
||||
format->theme = 0;
|
||||
format->hyperlink = LXW_FALSE;
|
||||
|
||||
format->hidden = LXW_FALSE;
|
||||
format->locked = LXW_TRUE;
|
||||
|
||||
format->text_h_align = LXW_ALIGN_NONE;
|
||||
format->text_wrap = LXW_FALSE;
|
||||
format->text_v_align = LXW_ALIGN_NONE;
|
||||
format->text_justlast = LXW_FALSE;
|
||||
format->rotation = 0;
|
||||
|
||||
format->fg_color = LXW_COLOR_UNSET;
|
||||
format->bg_color = LXW_COLOR_UNSET;
|
||||
format->pattern = LXW_PATTERN_NONE;
|
||||
format->has_fill = LXW_FALSE;
|
||||
format->has_dxf_fill = LXW_FALSE;
|
||||
format->fill_index = 0;
|
||||
format->fill_count = 0;
|
||||
|
||||
format->border_index = 0;
|
||||
format->has_border = LXW_FALSE;
|
||||
format->has_dxf_border = LXW_FALSE;
|
||||
format->border_count = 0;
|
||||
|
||||
format->bottom = LXW_BORDER_NONE;
|
||||
format->left = LXW_BORDER_NONE;
|
||||
format->right = LXW_BORDER_NONE;
|
||||
format->top = LXW_BORDER_NONE;
|
||||
format->diag_border = LXW_BORDER_NONE;
|
||||
format->diag_type = LXW_BORDER_NONE;
|
||||
format->bottom_color = LXW_COLOR_UNSET;
|
||||
format->left_color = LXW_COLOR_UNSET;
|
||||
format->right_color = LXW_COLOR_UNSET;
|
||||
format->top_color = LXW_COLOR_UNSET;
|
||||
format->diag_color = LXW_COLOR_UNSET;
|
||||
|
||||
format->indent = 0;
|
||||
format->shrink = LXW_FALSE;
|
||||
format->merge_range = LXW_FALSE;
|
||||
format->reading_order = 0;
|
||||
format->just_distrib = LXW_FALSE;
|
||||
format->color_indexed = LXW_FALSE;
|
||||
format->font_only = LXW_FALSE;
|
||||
|
||||
return format;
|
||||
|
||||
mem_error:
|
||||
lxw_format_free(format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free a format object.
|
||||
*/
|
||||
void
|
||||
lxw_format_free(lxw_format *format)
|
||||
{
|
||||
if (!format)
|
||||
return;
|
||||
|
||||
free(format);
|
||||
format = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check a user input border.
|
||||
*/
|
||||
STATIC uint8_t
|
||||
_check_border(uint8_t border)
|
||||
{
|
||||
if (border >= LXW_BORDER_THIN && border <= LXW_BORDER_SLANT_DASH_DOT)
|
||||
return border;
|
||||
else
|
||||
return LXW_BORDER_NONE;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Public functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Returns a format struct suitable for hashing as a lookup key. This is
|
||||
* mainly a memcpy with any pointer members set to NULL.
|
||||
*/
|
||||
STATIC lxw_format *
|
||||
_get_format_key(lxw_format *self)
|
||||
{
|
||||
lxw_format *key = calloc(1, sizeof(lxw_format));
|
||||
GOTO_LABEL_ON_MEM_ERROR(key, mem_error);
|
||||
|
||||
memcpy(key, self, sizeof(lxw_format));
|
||||
|
||||
/* Set pointer members to NULL since they aren't part of the comparison. */
|
||||
key->xf_format_indices = NULL;
|
||||
key->dxf_format_indices = NULL;
|
||||
key->num_xf_formats = NULL;
|
||||
key->num_dxf_formats = NULL;
|
||||
key->list_pointers.stqe_next = NULL;
|
||||
|
||||
return key;
|
||||
|
||||
mem_error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a font struct suitable for hashing as a lookup key.
|
||||
*/
|
||||
lxw_font *
|
||||
lxw_format_get_font_key(lxw_format *self)
|
||||
{
|
||||
lxw_font *key = calloc(1, sizeof(lxw_font));
|
||||
GOTO_LABEL_ON_MEM_ERROR(key, mem_error);
|
||||
|
||||
LXW_FORMAT_FIELD_COPY(key->font_name, self->font_name);
|
||||
key->font_size = self->font_size;
|
||||
key->bold = self->bold;
|
||||
key->italic = self->italic;
|
||||
key->underline = self->underline;
|
||||
key->theme = self->theme;
|
||||
key->font_color = self->font_color;
|
||||
key->font_strikeout = self->font_strikeout;
|
||||
key->font_outline = self->font_outline;
|
||||
key->font_shadow = self->font_shadow;
|
||||
key->font_script = self->font_script;
|
||||
key->font_family = self->font_family;
|
||||
key->font_charset = self->font_charset;
|
||||
key->font_condense = self->font_condense;
|
||||
key->font_extend = self->font_extend;
|
||||
|
||||
return key;
|
||||
|
||||
mem_error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a border struct suitable for hashing as a lookup key.
|
||||
*/
|
||||
lxw_border *
|
||||
lxw_format_get_border_key(lxw_format *self)
|
||||
{
|
||||
lxw_border *key = calloc(1, sizeof(lxw_border));
|
||||
GOTO_LABEL_ON_MEM_ERROR(key, mem_error);
|
||||
|
||||
key->bottom = self->bottom;
|
||||
key->left = self->left;
|
||||
key->right = self->right;
|
||||
key->top = self->top;
|
||||
key->diag_border = self->diag_border;
|
||||
key->diag_type = self->diag_type;
|
||||
key->bottom_color = self->bottom_color;
|
||||
key->left_color = self->left_color;
|
||||
key->right_color = self->right_color;
|
||||
key->top_color = self->top_color;
|
||||
key->diag_color = self->diag_color;
|
||||
|
||||
return key;
|
||||
|
||||
mem_error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a pattern fill struct suitable for hashing as a lookup key.
|
||||
*/
|
||||
lxw_fill *
|
||||
lxw_format_get_fill_key(lxw_format *self)
|
||||
{
|
||||
lxw_fill *key = calloc(1, sizeof(lxw_fill));
|
||||
GOTO_LABEL_ON_MEM_ERROR(key, mem_error);
|
||||
|
||||
key->fg_color = self->fg_color;
|
||||
key->bg_color = self->bg_color;
|
||||
key->pattern = self->pattern;
|
||||
|
||||
return key;
|
||||
|
||||
mem_error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the XF index number used by Excel to identify a format.
|
||||
*/
|
||||
int32_t
|
||||
lxw_format_get_xf_index(lxw_format *self)
|
||||
{
|
||||
lxw_format *format_key;
|
||||
lxw_format *existing_format;
|
||||
lxw_hash_element *hash_element;
|
||||
lxw_hash_table *formats_hash_table = self->xf_format_indices;
|
||||
int32_t index;
|
||||
|
||||
/* Note: The formats_hash_table/xf_format_indices contains the unique and
|
||||
* more importantly the *used* formats in the workbook.
|
||||
*/
|
||||
|
||||
/* Format already has an index number so return it. */
|
||||
if (self->xf_index != LXW_PROPERTY_UNSET) {
|
||||
return self->xf_index;
|
||||
}
|
||||
|
||||
/* Otherwise, the format doesn't have an index number so we assign one.
|
||||
* First generate a unique key to identify the format in the hash table.
|
||||
*/
|
||||
format_key = _get_format_key(self);
|
||||
|
||||
/* Return the default format index if the key generation failed. */
|
||||
if (!format_key)
|
||||
return 0;
|
||||
|
||||
/* Look up the format in the hash table. */
|
||||
hash_element =
|
||||
lxw_hash_key_exists(formats_hash_table, format_key,
|
||||
sizeof(lxw_format));
|
||||
|
||||
if (hash_element) {
|
||||
/* Format matches existing format with an index. */
|
||||
free(format_key);
|
||||
existing_format = hash_element->value;
|
||||
return existing_format->xf_index;
|
||||
}
|
||||
else {
|
||||
/* New format requiring an index. */
|
||||
index = formats_hash_table->unique_count;
|
||||
self->xf_index = index;
|
||||
lxw_insert_hash_element(formats_hash_table, format_key, self,
|
||||
sizeof(lxw_format));
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the DXF index number used by Excel to identify a format.
|
||||
*/
|
||||
int32_t
|
||||
lxw_format_get_dxf_index(lxw_format *self)
|
||||
{
|
||||
lxw_format *format_key;
|
||||
lxw_format *existing_format;
|
||||
lxw_hash_element *hash_element;
|
||||
lxw_hash_table *formats_hash_table = self->dxf_format_indices;
|
||||
int32_t index;
|
||||
|
||||
/* Note: The formats_hash_table/dxf_format_indices contains the unique and
|
||||
* more importantly the *used* formats in the workbook.
|
||||
*/
|
||||
|
||||
/* Format already has an index number so return it. */
|
||||
if (self->dxf_index != LXW_PROPERTY_UNSET) {
|
||||
return self->dxf_index;
|
||||
}
|
||||
|
||||
/* Otherwise, the format doesn't have an index number so we assign one.
|
||||
* First generate a unique key to identify the format in the hash table.
|
||||
*/
|
||||
format_key = _get_format_key(self);
|
||||
|
||||
/* Return the default format index if the key generation failed. */
|
||||
if (!format_key)
|
||||
return 0;
|
||||
|
||||
/* Look up the format in the hash table. */
|
||||
hash_element =
|
||||
lxw_hash_key_exists(formats_hash_table, format_key,
|
||||
sizeof(lxw_format));
|
||||
|
||||
if (hash_element) {
|
||||
/* Format matches existing format with an index. */
|
||||
free(format_key);
|
||||
existing_format = hash_element->value;
|
||||
return existing_format->dxf_index;
|
||||
}
|
||||
else {
|
||||
/* New format requiring an index. */
|
||||
index = formats_hash_table->unique_count;
|
||||
self->dxf_index = index;
|
||||
lxw_insert_hash_element(formats_hash_table, format_key, self,
|
||||
sizeof(lxw_format));
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the font_name property.
|
||||
*/
|
||||
void
|
||||
format_set_font_name(lxw_format *self, const char *font_name)
|
||||
{
|
||||
LXW_FORMAT_FIELD_COPY(self->font_name, font_name);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the font_size property.
|
||||
*/
|
||||
void
|
||||
format_set_font_size(lxw_format *self, double size)
|
||||
{
|
||||
|
||||
if (size >= LXW_MIN_FONT_SIZE && size <= LXW_MAX_FONT_SIZE)
|
||||
self->font_size = size;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the font_color property.
|
||||
*/
|
||||
void
|
||||
format_set_font_color(lxw_format *self, lxw_color_t color)
|
||||
{
|
||||
self->font_color = color;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the bold property.
|
||||
*/
|
||||
void
|
||||
format_set_bold(lxw_format *self)
|
||||
{
|
||||
self->bold = LXW_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the italic property.
|
||||
*/
|
||||
|
||||
void
|
||||
format_set_italic(lxw_format *self)
|
||||
{
|
||||
self->italic = LXW_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the underline property.
|
||||
*/
|
||||
void
|
||||
format_set_underline(lxw_format *self, uint8_t style)
|
||||
{
|
||||
if (style >= LXW_UNDERLINE_SINGLE
|
||||
&& style <= LXW_UNDERLINE_DOUBLE_ACCOUNTING)
|
||||
self->underline = style;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the font_strikeout property.
|
||||
*/
|
||||
void
|
||||
format_set_font_strikeout(lxw_format *self)
|
||||
{
|
||||
self->font_strikeout = LXW_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the font_script property.
|
||||
*/
|
||||
void
|
||||
format_set_font_script(lxw_format *self, uint8_t style)
|
||||
{
|
||||
if (style >= LXW_FONT_SUPERSCRIPT && style <= LXW_FONT_SUBSCRIPT)
|
||||
self->font_script = style;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the font_outline property.
|
||||
*/
|
||||
void
|
||||
format_set_font_outline(lxw_format *self)
|
||||
{
|
||||
self->font_outline = LXW_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the font_shadow property.
|
||||
*/
|
||||
void
|
||||
format_set_font_shadow(lxw_format *self)
|
||||
{
|
||||
self->font_shadow = LXW_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the num_format property.
|
||||
*/
|
||||
void
|
||||
format_set_num_format(lxw_format *self, const char *num_format)
|
||||
{
|
||||
LXW_FORMAT_FIELD_COPY(self->num_format, num_format);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the unlocked property.
|
||||
*/
|
||||
void
|
||||
format_set_unlocked(lxw_format *self)
|
||||
{
|
||||
self->locked = LXW_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the hidden property.
|
||||
*/
|
||||
void
|
||||
format_set_hidden(lxw_format *self)
|
||||
{
|
||||
self->hidden = LXW_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the align property.
|
||||
*/
|
||||
void
|
||||
format_set_align(lxw_format *self, uint8_t value)
|
||||
{
|
||||
if (value >= LXW_ALIGN_LEFT && value <= LXW_ALIGN_DISTRIBUTED) {
|
||||
self->text_h_align = value;
|
||||
}
|
||||
|
||||
if (value >= LXW_ALIGN_VERTICAL_TOP
|
||||
&& value <= LXW_ALIGN_VERTICAL_DISTRIBUTED) {
|
||||
self->text_v_align = value;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the text_wrap property.
|
||||
*/
|
||||
void
|
||||
format_set_text_wrap(lxw_format *self)
|
||||
{
|
||||
self->text_wrap = LXW_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the rotation property.
|
||||
*/
|
||||
void
|
||||
format_set_rotation(lxw_format *self, int16_t angle)
|
||||
{
|
||||
/* Convert user angle to Excel angle. */
|
||||
if (angle == 270) {
|
||||
self->rotation = 255;
|
||||
}
|
||||
else if (angle >= -90 && angle <= 90) {
|
||||
if (angle < 0)
|
||||
angle = -angle + 90;
|
||||
|
||||
self->rotation = angle;
|
||||
}
|
||||
else {
|
||||
LXW_WARN("Rotation rotation outside range: -90 <= angle <= 90.");
|
||||
self->rotation = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the indent property.
|
||||
*/
|
||||
void
|
||||
format_set_indent(lxw_format *self, uint8_t value)
|
||||
{
|
||||
self->indent = value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the shrink property.
|
||||
*/
|
||||
void
|
||||
format_set_shrink(lxw_format *self)
|
||||
{
|
||||
self->shrink = LXW_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the text_justlast property.
|
||||
*/
|
||||
void
|
||||
format_set_text_justlast(lxw_format *self)
|
||||
{
|
||||
self->text_justlast = LXW_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the pattern property.
|
||||
*/
|
||||
void
|
||||
format_set_pattern(lxw_format *self, uint8_t value)
|
||||
{
|
||||
self->pattern = value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the bg_color property.
|
||||
*/
|
||||
void
|
||||
format_set_bg_color(lxw_format *self, lxw_color_t color)
|
||||
{
|
||||
self->bg_color = color;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the fg_color property.
|
||||
*/
|
||||
void
|
||||
format_set_fg_color(lxw_format *self, lxw_color_t color)
|
||||
{
|
||||
self->fg_color = color;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the border property.
|
||||
*/
|
||||
void
|
||||
format_set_border(lxw_format *self, uint8_t style)
|
||||
{
|
||||
style = _check_border(style);
|
||||
self->bottom = style;
|
||||
self->top = style;
|
||||
self->left = style;
|
||||
self->right = style;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the border_color property.
|
||||
*/
|
||||
void
|
||||
format_set_border_color(lxw_format *self, lxw_color_t color)
|
||||
{
|
||||
self->bottom_color = color;
|
||||
self->top_color = color;
|
||||
self->left_color = color;
|
||||
self->right_color = color;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the bottom property.
|
||||
*/
|
||||
void
|
||||
format_set_bottom(lxw_format *self, uint8_t style)
|
||||
{
|
||||
self->bottom = _check_border(style);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the bottom_color property.
|
||||
*/
|
||||
void
|
||||
format_set_bottom_color(lxw_format *self, lxw_color_t color)
|
||||
{
|
||||
self->bottom_color = color;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the left property.
|
||||
*/
|
||||
void
|
||||
format_set_left(lxw_format *self, uint8_t style)
|
||||
{
|
||||
self->left = _check_border(style);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the left_color property.
|
||||
*/
|
||||
void
|
||||
format_set_left_color(lxw_format *self, lxw_color_t color)
|
||||
{
|
||||
self->left_color = color;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the right property.
|
||||
*/
|
||||
void
|
||||
format_set_right(lxw_format *self, uint8_t style)
|
||||
{
|
||||
self->right = _check_border(style);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the right_color property.
|
||||
*/
|
||||
void
|
||||
format_set_right_color(lxw_format *self, lxw_color_t color)
|
||||
{
|
||||
self->right_color = color;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the top property.
|
||||
*/
|
||||
void
|
||||
format_set_top(lxw_format *self, uint8_t style)
|
||||
{
|
||||
self->top = _check_border(style);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the top_color property.
|
||||
*/
|
||||
void
|
||||
format_set_top_color(lxw_format *self, lxw_color_t color)
|
||||
{
|
||||
self->top_color = color;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the diag_type property.
|
||||
*/
|
||||
void
|
||||
format_set_diag_type(lxw_format *self, uint8_t type)
|
||||
{
|
||||
if (type >= LXW_DIAGONAL_BORDER_UP && type <= LXW_DIAGONAL_BORDER_UP_DOWN)
|
||||
self->diag_type = type;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the diag_color property.
|
||||
*/
|
||||
void
|
||||
format_set_diag_color(lxw_format *self, lxw_color_t color)
|
||||
{
|
||||
self->diag_color = color;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the diag_border property.
|
||||
*/
|
||||
void
|
||||
format_set_diag_border(lxw_format *self, uint8_t style)
|
||||
{
|
||||
self->diag_border = style;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the num_format_index property.
|
||||
*/
|
||||
void
|
||||
format_set_num_format_index(lxw_format *self, uint8_t value)
|
||||
{
|
||||
self->num_format_index = value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the valign property.
|
||||
*/
|
||||
void
|
||||
format_set_valign(lxw_format *self, uint8_t value)
|
||||
{
|
||||
self->text_v_align = value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the reading_order property.
|
||||
*/
|
||||
void
|
||||
format_set_reading_order(lxw_format *self, uint8_t value)
|
||||
{
|
||||
self->reading_order = value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the font_family property.
|
||||
*/
|
||||
void
|
||||
format_set_font_family(lxw_format *self, uint8_t value)
|
||||
{
|
||||
self->font_family = value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the font_charset property.
|
||||
*/
|
||||
void
|
||||
format_set_font_charset(lxw_format *self, uint8_t value)
|
||||
{
|
||||
self->font_charset = value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the font_scheme property.
|
||||
*/
|
||||
void
|
||||
format_set_font_scheme(lxw_format *self, const char *font_scheme)
|
||||
{
|
||||
LXW_FORMAT_FIELD_COPY(self->font_scheme, font_scheme);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the font_condense property.
|
||||
*/
|
||||
void
|
||||
format_set_font_condense(lxw_format *self)
|
||||
{
|
||||
self->font_condense = LXW_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the font_extend property.
|
||||
*/
|
||||
void
|
||||
format_set_font_extend(lxw_format *self)
|
||||
{
|
||||
self->font_extend = LXW_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the theme property.
|
||||
*/
|
||||
void
|
||||
format_set_theme(lxw_format *self, uint8_t value)
|
||||
{
|
||||
self->theme = value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the color_indexed property.
|
||||
*/
|
||||
void
|
||||
format_set_color_indexed(lxw_format *self, uint8_t value)
|
||||
{
|
||||
self->color_indexed = value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the font_only property.
|
||||
*/
|
||||
void
|
||||
format_set_font_only(lxw_format *self)
|
||||
{
|
||||
self->font_only = LXW_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the theme property.
|
||||
*/
|
||||
void
|
||||
format_set_hyperlink(lxw_format *self)
|
||||
{
|
||||
self->hyperlink = LXW_TRUE;
|
||||
self->xf_id = 1;
|
||||
self->underline = LXW_UNDERLINE_SINGLE;
|
||||
self->theme = 10;
|
||||
}
|
9
library/libxlsxwriter/src/format.dep
Normal file
9
library/libxlsxwriter/src/format.dep
Normal file
@ -0,0 +1,9 @@
|
||||
library/libxlsxwriter/src/format.lo: \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/src/format.c \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/xmlwriter.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/utility.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/common.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/queue.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/tree.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/format.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/hash_table.h
|
223
library/libxlsxwriter/src/hash_table.c
Normal file
223
library/libxlsxwriter/src/hash_table.c
Normal file
@ -0,0 +1,223 @@
|
||||
/*****************************************************************************
|
||||
* hash_table - Hash table functions for libxlsxwriter.
|
||||
*
|
||||
* Used in conjunction with the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2021, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include "xlsxwriter/hash_table.h"
|
||||
|
||||
/*
|
||||
* Calculate the hash key using the FNV function. See:
|
||||
* http://en.wikipedia.org/wiki/Fowler-Noll-Vo_hash_function
|
||||
*/
|
||||
STATIC size_t
|
||||
_generate_hash_key(void *data, size_t data_len, size_t num_buckets)
|
||||
{
|
||||
unsigned char *p = data;
|
||||
size_t hash = 2166136261U;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < data_len; i++)
|
||||
hash = (hash * 16777619) ^ p[i];
|
||||
|
||||
return hash % num_buckets;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if an element exists in the hash table and return a pointer
|
||||
* to it if it does.
|
||||
*/
|
||||
lxw_hash_element *
|
||||
lxw_hash_key_exists(lxw_hash_table *lxw_hash, void *key, size_t key_len)
|
||||
{
|
||||
size_t hash_key = _generate_hash_key(key, key_len, lxw_hash->num_buckets);
|
||||
struct lxw_hash_bucket_list *list;
|
||||
lxw_hash_element *element;
|
||||
|
||||
if (!lxw_hash->buckets[hash_key]) {
|
||||
/* The key isn't in the LXW_HASH hash table. */
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
/* The key is already in the table or there is a hash collision. */
|
||||
list = lxw_hash->buckets[hash_key];
|
||||
|
||||
/* Iterate over the keys in the bucket's linked list. */
|
||||
SLIST_FOREACH(element, list, lxw_hash_list_pointers) {
|
||||
if (memcmp(element->key, key, key_len) == 0) {
|
||||
/* The key already exists in the table. */
|
||||
return element;
|
||||
}
|
||||
}
|
||||
|
||||
/* Key doesn't exist in the list so this is a hash collision. */
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert or update a value in the LXW_HASH table based on a key
|
||||
* and return a pointer to the new or updated element.
|
||||
*/
|
||||
lxw_hash_element *
|
||||
lxw_insert_hash_element(lxw_hash_table *lxw_hash, void *key, void *value,
|
||||
size_t key_len)
|
||||
{
|
||||
size_t hash_key = _generate_hash_key(key, key_len, lxw_hash->num_buckets);
|
||||
struct lxw_hash_bucket_list *list = NULL;
|
||||
lxw_hash_element *element = NULL;
|
||||
|
||||
if (!lxw_hash->buckets[hash_key]) {
|
||||
/* The key isn't in the LXW_HASH hash table. */
|
||||
|
||||
/* Create a linked list in the bucket to hold the lxw_hash keys. */
|
||||
list = calloc(1, sizeof(struct lxw_hash_bucket_list));
|
||||
GOTO_LABEL_ON_MEM_ERROR(list, mem_error1);
|
||||
|
||||
/* Initialize the bucket linked list. */
|
||||
SLIST_INIT(list);
|
||||
|
||||
/* Create an lxw_hash element to add to the linked list. */
|
||||
element = calloc(1, sizeof(lxw_hash_element));
|
||||
GOTO_LABEL_ON_MEM_ERROR(element, mem_error1);
|
||||
|
||||
/* Store the key and value. */
|
||||
element->key = key;
|
||||
element->value = value;
|
||||
|
||||
/* Add the lxw_hash element to the bucket's linked list. */
|
||||
SLIST_INSERT_HEAD(list, element, lxw_hash_list_pointers);
|
||||
|
||||
/* Also add it to the insertion order linked list. */
|
||||
STAILQ_INSERT_TAIL(lxw_hash->order_list, element,
|
||||
lxw_hash_order_pointers);
|
||||
|
||||
/* Store the bucket list at the hash index. */
|
||||
lxw_hash->buckets[hash_key] = list;
|
||||
|
||||
lxw_hash->used_buckets++;
|
||||
lxw_hash->unique_count++;
|
||||
|
||||
return element;
|
||||
}
|
||||
else {
|
||||
/* The key is already in the table or there is a hash collision. */
|
||||
list = lxw_hash->buckets[hash_key];
|
||||
|
||||
/* Iterate over the keys in the bucket's linked list. */
|
||||
SLIST_FOREACH(element, list, lxw_hash_list_pointers) {
|
||||
if (memcmp(element->key, key, key_len) == 0) {
|
||||
/* The key already exists in the table. Update the value. */
|
||||
if (lxw_hash->free_value)
|
||||
free(element->value);
|
||||
|
||||
element->value = value;
|
||||
return element;
|
||||
}
|
||||
}
|
||||
|
||||
/* Key doesn't exist in the list so this is a hash collision.
|
||||
* Create an lxw_hash element to add to the linked list. */
|
||||
element = calloc(1, sizeof(lxw_hash_element));
|
||||
GOTO_LABEL_ON_MEM_ERROR(element, mem_error2);
|
||||
|
||||
/* Store the key and value. */
|
||||
element->key = key;
|
||||
element->value = value;
|
||||
|
||||
/* Add the lxw_hash element to the bucket linked list. */
|
||||
SLIST_INSERT_HEAD(list, element, lxw_hash_list_pointers);
|
||||
|
||||
/* Also add it to the insertion order linked list. */
|
||||
STAILQ_INSERT_TAIL(lxw_hash->order_list, element,
|
||||
lxw_hash_order_pointers);
|
||||
|
||||
lxw_hash->unique_count++;
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
mem_error1:
|
||||
free(list);
|
||||
|
||||
mem_error2:
|
||||
free(element);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a new LXW_HASH hash table object.
|
||||
*/
|
||||
lxw_hash_table *
|
||||
lxw_hash_new(uint32_t num_buckets, uint8_t free_key, uint8_t free_value)
|
||||
{
|
||||
/* Create the new hash table. */
|
||||
lxw_hash_table *lxw_hash = calloc(1, sizeof(lxw_hash_table));
|
||||
RETURN_ON_MEM_ERROR(lxw_hash, NULL);
|
||||
|
||||
lxw_hash->free_key = free_key;
|
||||
lxw_hash->free_value = free_value;
|
||||
|
||||
/* Add the lxw_hash element buckets. */
|
||||
lxw_hash->buckets =
|
||||
calloc(num_buckets, sizeof(struct lxw_hash_bucket_list *));
|
||||
GOTO_LABEL_ON_MEM_ERROR(lxw_hash->buckets, mem_error);
|
||||
|
||||
/* Add a list for tracking the insertion order. */
|
||||
lxw_hash->order_list = calloc(1, sizeof(struct lxw_hash_order_list));
|
||||
GOTO_LABEL_ON_MEM_ERROR(lxw_hash->order_list, mem_error);
|
||||
|
||||
/* Initialize the order list. */
|
||||
STAILQ_INIT(lxw_hash->order_list);
|
||||
|
||||
/* Store the number of buckets to calculate the load factor. */
|
||||
lxw_hash->num_buckets = num_buckets;
|
||||
|
||||
return lxw_hash;
|
||||
|
||||
mem_error:
|
||||
lxw_hash_free(lxw_hash);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free the LXW_HASH hash table object.
|
||||
*/
|
||||
void
|
||||
lxw_hash_free(lxw_hash_table *lxw_hash)
|
||||
{
|
||||
size_t i;
|
||||
lxw_hash_element *element;
|
||||
lxw_hash_element *element_temp;
|
||||
|
||||
if (!lxw_hash)
|
||||
return;
|
||||
|
||||
/* Free the lxw_hash_elements and data using the ordered linked list. */
|
||||
if (lxw_hash->order_list) {
|
||||
STAILQ_FOREACH_SAFE(element, lxw_hash->order_list,
|
||||
lxw_hash_order_pointers, element_temp) {
|
||||
if (lxw_hash->free_key)
|
||||
free(element->key);
|
||||
if (lxw_hash->free_value)
|
||||
free(element->value);
|
||||
free(element);
|
||||
}
|
||||
}
|
||||
|
||||
/* Free the buckets from the hash table. */
|
||||
for (i = 0; i < lxw_hash->num_buckets; i++) {
|
||||
free(lxw_hash->buckets[i]);
|
||||
}
|
||||
|
||||
free(lxw_hash->order_list);
|
||||
free(lxw_hash->buckets);
|
||||
free(lxw_hash);
|
||||
}
|
6
library/libxlsxwriter/src/hash_table.dep
Normal file
6
library/libxlsxwriter/src/hash_table.dep
Normal file
@ -0,0 +1,6 @@
|
||||
library/libxlsxwriter/src/hash_table.lo: \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/src/hash_table.c \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/hash_table.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/common.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/queue.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/tree.h
|
283
library/libxlsxwriter/src/metadata.c
Normal file
283
library/libxlsxwriter/src/metadata.c
Normal file
@ -0,0 +1,283 @@
|
||||
/*****************************************************************************
|
||||
* metadata - A library for creating Excel XLSX metadata files.
|
||||
*
|
||||
* Used in conjunction with the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2021, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "xlsxwriter/xmlwriter.h"
|
||||
#include "xlsxwriter/metadata.h"
|
||||
#include "xlsxwriter/utility.h"
|
||||
|
||||
/*
|
||||
* Forward declarations.
|
||||
*/
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Private functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Create a new metadata object.
|
||||
*/
|
||||
lxw_metadata *
|
||||
lxw_metadata_new(void)
|
||||
{
|
||||
lxw_metadata *metadata = calloc(1, sizeof(lxw_metadata));
|
||||
GOTO_LABEL_ON_MEM_ERROR(metadata, mem_error);
|
||||
|
||||
return metadata;
|
||||
|
||||
mem_error:
|
||||
lxw_metadata_free(metadata);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free a metadata object.
|
||||
*/
|
||||
void
|
||||
lxw_metadata_free(lxw_metadata *metadata)
|
||||
{
|
||||
if (!metadata)
|
||||
return;
|
||||
|
||||
free(metadata);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* XML functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Write the XML declaration.
|
||||
*/
|
||||
STATIC void
|
||||
_metadata_xml_declaration(lxw_metadata *self)
|
||||
{
|
||||
lxw_xml_declaration(self->file);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <metadata> element.
|
||||
*/
|
||||
STATIC void
|
||||
_metadata_write_metadata(lxw_metadata *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
char xmlns[] = "http://schemas.openxmlformats.org/"
|
||||
"spreadsheetml/2006/main";
|
||||
char xmlns_xda[] = "http://schemas.microsoft.com/office/"
|
||||
"spreadsheetml/2017/dynamicarray";
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns", xmlns);
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns:xda", xmlns_xda);
|
||||
|
||||
lxw_xml_start_tag(self->file, "metadata", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <metadataType> element.
|
||||
*/
|
||||
STATIC void
|
||||
_metadata_write_metadata_type(lxw_metadata *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("name", "XLDAPR");
|
||||
LXW_PUSH_ATTRIBUTES_INT("minSupportedVersion", 120000);
|
||||
LXW_PUSH_ATTRIBUTES_INT("copy", 1);
|
||||
LXW_PUSH_ATTRIBUTES_INT("pasteAll", 1);
|
||||
LXW_PUSH_ATTRIBUTES_INT("pasteValues", 1);
|
||||
LXW_PUSH_ATTRIBUTES_INT("merge", 1);
|
||||
LXW_PUSH_ATTRIBUTES_INT("splitFirst", 1);
|
||||
LXW_PUSH_ATTRIBUTES_INT("rowColShift", 1);
|
||||
LXW_PUSH_ATTRIBUTES_INT("clearFormats", 1);
|
||||
LXW_PUSH_ATTRIBUTES_INT("clearComments", 1);
|
||||
LXW_PUSH_ATTRIBUTES_INT("assign", 1);
|
||||
LXW_PUSH_ATTRIBUTES_INT("coerce", 1);
|
||||
LXW_PUSH_ATTRIBUTES_INT("cellMeta", 1);
|
||||
|
||||
lxw_xml_empty_tag(self->file, "metadataType", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <metadataTypes> element.
|
||||
*/
|
||||
STATIC void
|
||||
_metadata_write_metadata_types(lxw_metadata *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_INT("count", 1);
|
||||
|
||||
lxw_xml_start_tag(self->file, "metadataTypes", &attributes);
|
||||
|
||||
/* Write the metadataType element. */
|
||||
_metadata_write_metadata_type(self);
|
||||
|
||||
lxw_xml_end_tag(self->file, "metadataTypes");
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <xda:dynamicArrayProperties> element.
|
||||
*/
|
||||
STATIC void
|
||||
_metadata_write_xda_dynamic_array_properties(lxw_metadata *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("fDynamic", "1");
|
||||
LXW_PUSH_ATTRIBUTES_STR("fCollapsed", "0");
|
||||
|
||||
lxw_xml_empty_tag(self->file, "xda:dynamicArrayProperties", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <ext> element.
|
||||
*/
|
||||
STATIC void
|
||||
_metadata_write_ext(lxw_metadata *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("uri", "{bdbb8cdc-fa1e-496e-a857-3c3f30c029c3}");
|
||||
|
||||
lxw_xml_start_tag(self->file, "ext", &attributes);
|
||||
|
||||
/* Write the xda:dynamicArrayProperties element. */
|
||||
_metadata_write_xda_dynamic_array_properties(self);
|
||||
|
||||
lxw_xml_end_tag(self->file, "ext");
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <futureMetadata> element.
|
||||
*/
|
||||
STATIC void
|
||||
_metadata_write_future_metadata(lxw_metadata *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("name", "XLDAPR");
|
||||
LXW_PUSH_ATTRIBUTES_INT("count", 1);
|
||||
|
||||
lxw_xml_start_tag(self->file, "futureMetadata", &attributes);
|
||||
|
||||
lxw_xml_start_tag(self->file, "bk", NULL);
|
||||
|
||||
lxw_xml_start_tag(self->file, "extLst", NULL);
|
||||
|
||||
/* Write the ext element. */
|
||||
_metadata_write_ext(self);
|
||||
|
||||
lxw_xml_end_tag(self->file, "extLst");
|
||||
|
||||
lxw_xml_end_tag(self->file, "bk");
|
||||
|
||||
lxw_xml_end_tag(self->file, "futureMetadata");
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <rc> element.
|
||||
*/
|
||||
STATIC void
|
||||
_metadata_write_rc(lxw_metadata *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("t", "1");
|
||||
LXW_PUSH_ATTRIBUTES_STR("v", "0");
|
||||
|
||||
lxw_xml_empty_tag(self->file, "rc", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <cellMetadata> element.
|
||||
*/
|
||||
STATIC void
|
||||
_metadata_write_cell_metadata(lxw_metadata *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("count", "1");
|
||||
|
||||
lxw_xml_start_tag(self->file, "cellMetadata", &attributes);
|
||||
|
||||
lxw_xml_start_tag(self->file, "bk", NULL);
|
||||
|
||||
/* Write the rc element. */
|
||||
_metadata_write_rc(self);
|
||||
|
||||
lxw_xml_end_tag(self->file, "bk");
|
||||
|
||||
lxw_xml_end_tag(self->file, "cellMetadata");
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* XML file assembly functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Assemble and write the XML file.
|
||||
*/
|
||||
void
|
||||
lxw_metadata_assemble_xml_file(lxw_metadata *self)
|
||||
{
|
||||
/* Write the XML declaration. */
|
||||
_metadata_xml_declaration(self);
|
||||
|
||||
/* Write the metadata element. */
|
||||
_metadata_write_metadata(self);
|
||||
|
||||
/* Write the metadataTypes element. */
|
||||
_metadata_write_metadata_types(self);
|
||||
|
||||
/* Write the futureMetadata element. */
|
||||
_metadata_write_future_metadata(self);
|
||||
|
||||
/* Write the cellMetadata element. */
|
||||
_metadata_write_cell_metadata(self);
|
||||
|
||||
lxw_xml_end_tag(self->file, "metadata");
|
||||
}
|
8
library/libxlsxwriter/src/metadata.dep
Normal file
8
library/libxlsxwriter/src/metadata.dep
Normal file
@ -0,0 +1,8 @@
|
||||
library/libxlsxwriter/src/metadata.lo: \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/src/metadata.c \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/xmlwriter.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/utility.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/common.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/queue.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/tree.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/metadata.h
|
1573
library/libxlsxwriter/src/packager.c
Normal file
1573
library/libxlsxwriter/src/packager.c
Normal file
File diff suppressed because it is too large
Load Diff
27
library/libxlsxwriter/src/packager.dep
Normal file
27
library/libxlsxwriter/src/packager.dep
Normal file
@ -0,0 +1,27 @@
|
||||
library/libxlsxwriter/src/packager.lo: \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/src/packager.c \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/xmlwriter.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/utility.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/common.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/queue.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/tree.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/packager.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/zip.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/workbook.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/worksheet.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/shared_strings.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/chart.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/format.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/hash_table.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/drawing.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/styles.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/relationships.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/chartsheet.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/app.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/core.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/custom.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/theme.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/content_types.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/vml.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/comment.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/metadata.h
|
245
library/libxlsxwriter/src/relationships.c
Normal file
245
library/libxlsxwriter/src/relationships.c
Normal file
@ -0,0 +1,245 @@
|
||||
/*****************************************************************************
|
||||
* relationships - A library for creating Excel XLSX relationships files.
|
||||
*
|
||||
* Used in conjunction with the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2021, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "xlsxwriter/xmlwriter.h"
|
||||
#include "xlsxwriter/relationships.h"
|
||||
#include "xlsxwriter/utility.h"
|
||||
|
||||
/*
|
||||
* Forward declarations.
|
||||
*/
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Private functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Create a new relationships object.
|
||||
*/
|
||||
lxw_relationships *
|
||||
lxw_relationships_new(void)
|
||||
{
|
||||
lxw_relationships *rels = calloc(1, sizeof(lxw_relationships));
|
||||
GOTO_LABEL_ON_MEM_ERROR(rels, mem_error);
|
||||
|
||||
rels->relationships = calloc(1, sizeof(struct lxw_rel_tuples));
|
||||
GOTO_LABEL_ON_MEM_ERROR(rels->relationships, mem_error);
|
||||
STAILQ_INIT(rels->relationships);
|
||||
|
||||
return rels;
|
||||
|
||||
mem_error:
|
||||
lxw_free_relationships(rels);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free a relationships object.
|
||||
*/
|
||||
void
|
||||
lxw_free_relationships(lxw_relationships *rels)
|
||||
{
|
||||
lxw_rel_tuple *relationship;
|
||||
|
||||
if (!rels)
|
||||
return;
|
||||
|
||||
if (rels->relationships) {
|
||||
while (!STAILQ_EMPTY(rels->relationships)) {
|
||||
relationship = STAILQ_FIRST(rels->relationships);
|
||||
STAILQ_REMOVE_HEAD(rels->relationships, list_pointers);
|
||||
free(relationship->type);
|
||||
free(relationship->target);
|
||||
free(relationship->target_mode);
|
||||
free(relationship);
|
||||
}
|
||||
|
||||
free(rels->relationships);
|
||||
}
|
||||
|
||||
free(rels);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* XML functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Write the XML declaration.
|
||||
*/
|
||||
STATIC void
|
||||
_relationships_xml_declaration(lxw_relationships *self)
|
||||
{
|
||||
lxw_xml_declaration(self->file);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <Relationship> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_relationship(lxw_relationships *self, const char *type,
|
||||
const char *target, const char *target_mode)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
char r_id[LXW_MAX_ATTRIBUTE_LENGTH] = { 0 };
|
||||
|
||||
self->rel_id++;
|
||||
lxw_snprintf(r_id, LXW_ATTR_32, "rId%d", self->rel_id);
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("Id", r_id);
|
||||
LXW_PUSH_ATTRIBUTES_STR("Type", type);
|
||||
LXW_PUSH_ATTRIBUTES_STR("Target", target);
|
||||
|
||||
if (target_mode)
|
||||
LXW_PUSH_ATTRIBUTES_STR("TargetMode", target_mode);
|
||||
|
||||
lxw_xml_empty_tag(self->file, "Relationship", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <Relationships> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_relationships(lxw_relationships *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
lxw_rel_tuple *rel;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns", LXW_SCHEMA_PACKAGE);
|
||||
|
||||
lxw_xml_start_tag(self->file, "Relationships", &attributes);
|
||||
|
||||
STAILQ_FOREACH(rel, self->relationships, list_pointers) {
|
||||
_write_relationship(self, rel->type, rel->target, rel->target_mode);
|
||||
}
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* XML file assembly functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Assemble and write the XML file.
|
||||
*/
|
||||
void
|
||||
lxw_relationships_assemble_xml_file(lxw_relationships *self)
|
||||
{
|
||||
/* Write the XML declaration. */
|
||||
_relationships_xml_declaration(self);
|
||||
|
||||
_write_relationships(self);
|
||||
|
||||
/* Close the relationships tag. */
|
||||
lxw_xml_end_tag(self->file, "Relationships");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a generic container relationship to XLSX .rels xml files.
|
||||
*/
|
||||
STATIC void
|
||||
_add_relationship(lxw_relationships *self, const char *schema,
|
||||
const char *type, const char *target,
|
||||
const char *target_mode)
|
||||
{
|
||||
lxw_rel_tuple *relationship;
|
||||
|
||||
if (!schema || !type || !target)
|
||||
return;
|
||||
|
||||
relationship = calloc(1, sizeof(lxw_rel_tuple));
|
||||
GOTO_LABEL_ON_MEM_ERROR(relationship, mem_error);
|
||||
|
||||
relationship->type = calloc(1, LXW_MAX_ATTRIBUTE_LENGTH);
|
||||
GOTO_LABEL_ON_MEM_ERROR(relationship->type, mem_error);
|
||||
|
||||
/* Add the schema to the relationship type. */
|
||||
lxw_snprintf(relationship->type, LXW_MAX_ATTRIBUTE_LENGTH, "%s%s",
|
||||
schema, type);
|
||||
|
||||
relationship->target = lxw_strdup(target);
|
||||
GOTO_LABEL_ON_MEM_ERROR(relationship->target, mem_error);
|
||||
|
||||
if (target_mode) {
|
||||
relationship->target_mode = lxw_strdup(target_mode);
|
||||
GOTO_LABEL_ON_MEM_ERROR(relationship->target_mode, mem_error);
|
||||
}
|
||||
|
||||
STAILQ_INSERT_TAIL(self->relationships, relationship, list_pointers);
|
||||
|
||||
return;
|
||||
|
||||
mem_error:
|
||||
if (relationship) {
|
||||
free(relationship->type);
|
||||
free(relationship->target);
|
||||
free(relationship->target_mode);
|
||||
free(relationship);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Public functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Add a document relationship to XLSX .rels xml files.
|
||||
*/
|
||||
void
|
||||
lxw_add_document_relationship(lxw_relationships *self, const char *type,
|
||||
const char *target)
|
||||
{
|
||||
_add_relationship(self, LXW_SCHEMA_DOCUMENT, type, target, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a package relationship to XLSX .rels xml files.
|
||||
*/
|
||||
void
|
||||
lxw_add_package_relationship(lxw_relationships *self, const char *type,
|
||||
const char *target)
|
||||
{
|
||||
_add_relationship(self, LXW_SCHEMA_PACKAGE, type, target, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a MS schema package relationship to XLSX .rels xml files.
|
||||
*/
|
||||
void
|
||||
lxw_add_ms_package_relationship(lxw_relationships *self, const char *type,
|
||||
const char *target)
|
||||
{
|
||||
_add_relationship(self, LXW_SCHEMA_MS, type, target, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a worksheet relationship to sheet .rels xml files.
|
||||
*/
|
||||
void
|
||||
lxw_add_worksheet_relationship(lxw_relationships *self, const char *type,
|
||||
const char *target, const char *target_mode)
|
||||
{
|
||||
_add_relationship(self, LXW_SCHEMA_DOCUMENT, type, target, target_mode);
|
||||
}
|
8
library/libxlsxwriter/src/relationships.dep
Normal file
8
library/libxlsxwriter/src/relationships.dep
Normal file
@ -0,0 +1,8 @@
|
||||
library/libxlsxwriter/src/relationships.lo: \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/src/relationships.c \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/xmlwriter.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/utility.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/common.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/queue.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/tree.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/relationships.h
|
278
library/libxlsxwriter/src/shared_strings.c
Normal file
278
library/libxlsxwriter/src/shared_strings.c
Normal file
@ -0,0 +1,278 @@
|
||||
/*****************************************************************************
|
||||
* shared_strings - A library for creating Excel XLSX sst files.
|
||||
*
|
||||
* Used in conjunction with the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2021, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "xlsxwriter/xmlwriter.h"
|
||||
#include "xlsxwriter/shared_strings.h"
|
||||
#include "xlsxwriter/utility.h"
|
||||
#include <ctype.h>
|
||||
|
||||
/*
|
||||
* Forward declarations.
|
||||
*/
|
||||
|
||||
STATIC int _element_cmp(struct sst_element *element1,
|
||||
struct sst_element *element2);
|
||||
|
||||
#ifndef __clang_analyzer__
|
||||
LXW_RB_GENERATE_ELEMENT(sst_rb_tree, sst_element, sst_tree_pointers,
|
||||
_element_cmp);
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Private functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Create a new SST SharedString object.
|
||||
*/
|
||||
lxw_sst *
|
||||
lxw_sst_new(void)
|
||||
{
|
||||
/* Create the new shared string table. */
|
||||
lxw_sst *sst = calloc(1, sizeof(lxw_sst));
|
||||
RETURN_ON_MEM_ERROR(sst, NULL);
|
||||
|
||||
/* Add the sst RB tree. */
|
||||
sst->rb_tree = calloc(1, sizeof(struct sst_rb_tree));
|
||||
GOTO_LABEL_ON_MEM_ERROR(sst->rb_tree, mem_error);
|
||||
|
||||
/* Add a list for tracking the insertion order. */
|
||||
sst->order_list = calloc(1, sizeof(struct sst_order_list));
|
||||
GOTO_LABEL_ON_MEM_ERROR(sst->order_list, mem_error);
|
||||
|
||||
/* Initialize the order list. */
|
||||
STAILQ_INIT(sst->order_list);
|
||||
|
||||
/* Initialize the RB tree. */
|
||||
RB_INIT(sst->rb_tree);
|
||||
|
||||
return sst;
|
||||
|
||||
mem_error:
|
||||
lxw_sst_free(sst);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free a SST SharedString table object.
|
||||
*/
|
||||
void
|
||||
lxw_sst_free(lxw_sst *sst)
|
||||
{
|
||||
struct sst_element *sst_element;
|
||||
struct sst_element *sst_element_temp;
|
||||
|
||||
if (!sst)
|
||||
return;
|
||||
|
||||
/* Free the sst_elements and their data using the ordered linked list. */
|
||||
if (sst->order_list) {
|
||||
STAILQ_FOREACH_SAFE(sst_element, sst->order_list, sst_order_pointers,
|
||||
sst_element_temp) {
|
||||
|
||||
if (sst_element && sst_element->string)
|
||||
free(sst_element->string);
|
||||
if (sst_element)
|
||||
free(sst_element);
|
||||
}
|
||||
}
|
||||
|
||||
free(sst->order_list);
|
||||
free(sst->rb_tree);
|
||||
free(sst);
|
||||
}
|
||||
|
||||
/*
|
||||
* Comparator for the element structure
|
||||
*/
|
||||
STATIC int
|
||||
_element_cmp(struct sst_element *element1, struct sst_element *element2)
|
||||
{
|
||||
return strcmp(element1->string, element2->string);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* XML functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
/*
|
||||
* Write the XML declaration.
|
||||
*/
|
||||
STATIC void
|
||||
_sst_xml_declaration(lxw_sst *self)
|
||||
{
|
||||
lxw_xml_declaration(self->file);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <t> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_t(lxw_sst *self, char *string)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
|
||||
/* Add attribute to preserve leading or trailing whitespace. */
|
||||
if (isspace((unsigned char) string[0])
|
||||
|| isspace((unsigned char) string[strlen(string) - 1]))
|
||||
LXW_PUSH_ATTRIBUTES_STR("xml:space", "preserve");
|
||||
|
||||
lxw_xml_data_element(self->file, "t", string, &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <si> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_si(lxw_sst *self, char *string)
|
||||
{
|
||||
uint8_t escaped_string = LXW_FALSE;
|
||||
|
||||
lxw_xml_start_tag(self->file, "si", NULL);
|
||||
|
||||
/* Look for and escape control chars in the string. */
|
||||
if (lxw_has_control_characters(string)) {
|
||||
string = lxw_escape_control_characters(string);
|
||||
escaped_string = LXW_TRUE;
|
||||
}
|
||||
|
||||
/* Write the t element. */
|
||||
_write_t(self, string);
|
||||
|
||||
lxw_xml_end_tag(self->file, "si");
|
||||
|
||||
if (escaped_string)
|
||||
free(string);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <si> element for rich strings.
|
||||
*/
|
||||
STATIC void
|
||||
_write_rich_si(lxw_sst *self, char *string)
|
||||
{
|
||||
lxw_xml_rich_si_element(self->file, string);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the <sst> element.
|
||||
*/
|
||||
STATIC void
|
||||
_write_sst(lxw_sst *self)
|
||||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
char xmlns[] =
|
||||
"http://schemas.openxmlformats.org/spreadsheetml/2006/main";
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
LXW_PUSH_ATTRIBUTES_STR("xmlns", xmlns);
|
||||
LXW_PUSH_ATTRIBUTES_INT("count", self->string_count);
|
||||
LXW_PUSH_ATTRIBUTES_INT("uniqueCount", self->unique_count);
|
||||
|
||||
lxw_xml_start_tag(self->file, "sst", &attributes);
|
||||
|
||||
LXW_FREE_ATTRIBUTES();
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* XML file assembly functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Assemble and write the XML file.
|
||||
*/
|
||||
STATIC void
|
||||
_write_sst_strings(lxw_sst *self)
|
||||
{
|
||||
struct sst_element *sst_element;
|
||||
|
||||
STAILQ_FOREACH(sst_element, self->order_list, sst_order_pointers) {
|
||||
/* Write the si element. */
|
||||
if (sst_element->is_rich_string)
|
||||
_write_rich_si(self, sst_element->string);
|
||||
else
|
||||
_write_si(self, sst_element->string);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Assemble and write the XML file.
|
||||
*/
|
||||
void
|
||||
lxw_sst_assemble_xml_file(lxw_sst *self)
|
||||
{
|
||||
/* Write the XML declaration. */
|
||||
_sst_xml_declaration(self);
|
||||
|
||||
/* Write the sst element. */
|
||||
_write_sst(self);
|
||||
|
||||
/* Write the sst strings. */
|
||||
_write_sst_strings(self);
|
||||
|
||||
/* Close the sst tag. */
|
||||
lxw_xml_end_tag(self->file, "sst");
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Public functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
/*
|
||||
* Add to or find a string in the SST SharedString table and return it's index.
|
||||
*/
|
||||
struct sst_element *
|
||||
lxw_get_sst_index(lxw_sst *sst, const char *string, uint8_t is_rich_string)
|
||||
{
|
||||
struct sst_element *element;
|
||||
struct sst_element *existing_element;
|
||||
|
||||
/* Create an sst element to potentially add to the table. */
|
||||
element = calloc(1, sizeof(struct sst_element));
|
||||
if (!element)
|
||||
return NULL;
|
||||
|
||||
/* Create potential new element with the string and its index. */
|
||||
element->index = sst->unique_count;
|
||||
element->string = lxw_strdup(string);
|
||||
element->is_rich_string = is_rich_string;
|
||||
|
||||
/* Try to insert it and see whether we already have that string. */
|
||||
existing_element = RB_INSERT(sst_rb_tree, sst->rb_tree, element);
|
||||
|
||||
/* If existing_element is not NULL, then it already existed. */
|
||||
/* Free new created element. */
|
||||
if (existing_element) {
|
||||
free(element->string);
|
||||
free(element);
|
||||
sst->string_count++;
|
||||
return existing_element;
|
||||
}
|
||||
|
||||
/* If it didn't exist, also add it to the insertion order linked list. */
|
||||
STAILQ_INSERT_TAIL(sst->order_list, element, sst_order_pointers);
|
||||
|
||||
/* Update SST string counts. */
|
||||
sst->string_count++;
|
||||
sst->unique_count++;
|
||||
return element;
|
||||
}
|
8
library/libxlsxwriter/src/shared_strings.dep
Normal file
8
library/libxlsxwriter/src/shared_strings.dep
Normal file
@ -0,0 +1,8 @@
|
||||
library/libxlsxwriter/src/shared_strings.lo: \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/src/shared_strings.c \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/xmlwriter.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/utility.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/common.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/queue.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/tree.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/shared_strings.h
|
1427
library/libxlsxwriter/src/styles.c
Normal file
1427
library/libxlsxwriter/src/styles.c
Normal file
File diff suppressed because it is too large
Load Diff
10
library/libxlsxwriter/src/styles.dep
Normal file
10
library/libxlsxwriter/src/styles.dep
Normal file
@ -0,0 +1,10 @@
|
||||
library/libxlsxwriter/src/styles.lo: \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/src/styles.c \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/xmlwriter.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/utility.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/common.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/queue.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/tree.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/styles.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/format.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/hash_table.h
|
348
library/libxlsxwriter/src/theme.c
Normal file
348
library/libxlsxwriter/src/theme.c
Normal file
@ -0,0 +1,348 @@
|
||||
/*****************************************************************************
|
||||
* theme - A library for creating Excel XLSX theme files.
|
||||
*
|
||||
* Used in conjunction with the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2021, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "xlsxwriter/xmlwriter.h"
|
||||
#include "xlsxwriter/theme.h"
|
||||
#include "xlsxwriter/utility.h"
|
||||
|
||||
const char *theme_strs[] = {
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n",
|
||||
"<a:theme xmlns:a=\"http://schemas.openxmlformats.org/",
|
||||
"drawingml/2006/main\" name=\"Office Theme\">",
|
||||
"<a:themeElements>",
|
||||
"<a:clrScheme name=\"Office\"><a:dk1>",
|
||||
"<a:sysClr val=\"windowText\" lastClr=\"000000\"/>",
|
||||
"</a:dk1><a:lt1>",
|
||||
"<a:sysClr val=\"window\" lastClr=\"FFFFFF\"/></a:lt1><a:dk2>",
|
||||
"<a:srgbClr val=\"1F497D\"/></a:dk2><a:lt2>",
|
||||
"<a:srgbClr val=\"EEECE1\"/></a:lt2><a:accent1>",
|
||||
"<a:srgbClr val=\"4F81BD\"/></a:accent1><a:accent2>",
|
||||
"<a:srgbClr val=\"C0504D\"/></a:accent2><a:accent3>",
|
||||
"<a:srgbClr val=\"9BBB59\"/></a:accent3><a:accent4>",
|
||||
"<a:srgbClr val=\"8064A2\"/></a:accent4><a:accent5>",
|
||||
"<a:srgbClr val=\"4BACC6\"/></a:accent5><a:accent6>",
|
||||
"<a:srgbClr val=\"F79646\"/></a:accent6><a:hlink>",
|
||||
"<a:srgbClr val=\"0000FF\"/></a:hlink><a:folHlink>",
|
||||
"<a:srgbClr val=\"800080\"/></a:folHlink></a:clrScheme>",
|
||||
"<a:fontScheme name=\"Office\"><a:majorFont>",
|
||||
"<a:latin typeface=\"Cambria\"/><a:ea typeface=\"\"/>",
|
||||
"<a:cs typeface=\"\"/>",
|
||||
"<a:font script=\"Jpan\" typeface=\"MS Pゴシック\"/>",
|
||||
"<a:font script=\"Hang\" typeface=\"맑은 고딕\"/>",
|
||||
"<a:font script=\"Hans\" typeface=\"宋体\"/>",
|
||||
"<a:font script=\"Hant\" typeface=\"新細明體\"/>",
|
||||
"<a:font script=\"Arab\" typeface=\"Times New Roman\"/>",
|
||||
"<a:font script=\"Hebr\" typeface=\"Times New Roman\"/>",
|
||||
"<a:font script=\"Thai\" typeface=\"Tahoma\"/>",
|
||||
"<a:font script=\"Ethi\" typeface=\"Nyala\"/>",
|
||||
"<a:font script=\"Beng\" typeface=\"Vrinda\"/>",
|
||||
"<a:font script=\"Gujr\" typeface=\"Shruti\"/>",
|
||||
"<a:font script=\"Khmr\" typeface=\"MoolBoran\"/>",
|
||||
"<a:font script=\"Knda\" typeface=\"Tunga\"/>",
|
||||
"<a:font script=\"Guru\" typeface=\"Raavi\"/>",
|
||||
"<a:font script=\"Cans\" typeface=\"Euphemia\"/>",
|
||||
"<a:font script=\"Cher\" typeface=\"Plantagenet Cherokee\"/>",
|
||||
"<a:font script=\"Yiii\" typeface=\"Microsoft Yi Baiti\"/>",
|
||||
"<a:font script=\"Tibt\" typeface=\"Microsoft Himalaya\"/>",
|
||||
"<a:font script=\"Thaa\" typeface=\"MV Boli\"/>",
|
||||
"<a:font script=\"Deva\" typeface=\"Mangal\"/>",
|
||||
"<a:font script=\"Telu\" typeface=\"Gautami\"/>",
|
||||
"<a:font script=\"Taml\" typeface=\"Latha\"/>",
|
||||
"<a:font script=\"Syrc\" typeface=\"Estrangelo Edessa\"/>",
|
||||
"<a:font script=\"Orya\" typeface=\"Kalinga\"/>",
|
||||
"<a:font script=\"Mlym\" typeface=\"Kartika\"/>",
|
||||
"<a:font script=\"Laoo\" typeface=\"DokChampa\"/>",
|
||||
"<a:font script=\"Sinh\" typeface=\"Iskoola Pota\"/>",
|
||||
"<a:font script=\"Mong\" typeface=\"Mongolian Baiti\"/>",
|
||||
"<a:font script=\"Viet\" typeface=\"Times New Roman\"/>",
|
||||
"<a:font script=\"Uigh\" typeface=\"Microsoft Uighur\"/>",
|
||||
"</a:majorFont>",
|
||||
"<a:minorFont>",
|
||||
"<a:latin typeface=\"Calibri\"/>",
|
||||
"<a:ea typeface=\"\"/>",
|
||||
"<a:cs typeface=\"\"/>",
|
||||
"<a:font script=\"Jpan\" typeface=\"MS Pゴシック\"/>",
|
||||
"<a:font script=\"Hang\" typeface=\"맑은 고딕\"/>",
|
||||
"<a:font script=\"Hans\" typeface=\"宋体\"/>",
|
||||
"<a:font script=\"Hant\" typeface=\"新細明體\"/>",
|
||||
"<a:font script=\"Arab\" typeface=\"Arial\"/>",
|
||||
"<a:font script=\"Hebr\" typeface=\"Arial\"/>",
|
||||
"<a:font script=\"Thai\" typeface=\"Tahoma\"/>",
|
||||
"<a:font script=\"Ethi\" typeface=\"Nyala\"/>",
|
||||
"<a:font script=\"Beng\" typeface=\"Vrinda\"/>",
|
||||
"<a:font script=\"Gujr\" typeface=\"Shruti\"/>",
|
||||
"<a:font script=\"Khmr\" typeface=\"DaunPenh\"/>",
|
||||
"<a:font script=\"Knda\" typeface=\"Tunga\"/>",
|
||||
"<a:font script=\"Guru\" typeface=\"Raavi\"/>",
|
||||
"<a:font script=\"Cans\" typeface=\"Euphemia\"/>",
|
||||
"<a:font script=\"Cher\" typeface=\"Plantagenet Cherokee\"/>",
|
||||
"<a:font script=\"Yiii\" typeface=\"Microsoft Yi Baiti\"/>",
|
||||
"<a:font script=\"Tibt\" typeface=\"Microsoft Himalaya\"/>",
|
||||
"<a:font script=\"Thaa\" typeface=\"MV Boli\"/>",
|
||||
"<a:font script=\"Deva\" typeface=\"Mangal\"/>",
|
||||
"<a:font script=\"Telu\" typeface=\"Gautami\"/>",
|
||||
"<a:font script=\"Taml\" typeface=\"Latha\"/>",
|
||||
"<a:font script=\"Syrc\" typeface=\"Estrangelo Edessa\"/>",
|
||||
"<a:font script=\"Orya\" typeface=\"Kalinga\"/>",
|
||||
"<a:font script=\"Mlym\" typeface=\"Kartika\"/>",
|
||||
"<a:font script=\"Laoo\" typeface=\"DokChampa\"/>",
|
||||
"<a:font script=\"Sinh\" typeface=\"Iskoola Pota\"/>",
|
||||
"<a:font script=\"Mong\" typeface=\"Mongolian Baiti\"/>",
|
||||
"<a:font script=\"Viet\" typeface=\"Arial\"/>",
|
||||
"<a:font script=\"Uigh\" typeface=\"Microsoft Uighur\"/>",
|
||||
"</a:minorFont>",
|
||||
"</a:fontScheme><a:fmtScheme name=\"Office\">",
|
||||
"<a:fillStyleLst>",
|
||||
"<a:solidFill>",
|
||||
"<a:schemeClr val=\"phClr\"/>",
|
||||
"</a:solidFill>",
|
||||
"<a:gradFill rotWithShape=\"1\">",
|
||||
"<a:gsLst>",
|
||||
"<a:gs pos=\"0\">",
|
||||
"<a:schemeClr val=\"phClr\">",
|
||||
"<a:tint val=\"50000\"/>",
|
||||
"<a:satMod val=\"300000\"/>",
|
||||
"</a:schemeClr>",
|
||||
"</a:gs>",
|
||||
"<a:gs pos=\"35000\">",
|
||||
"<a:schemeClr val=\"phClr\">",
|
||||
"<a:tint val=\"37000\"/>",
|
||||
"<a:satMod val=\"300000\"/>",
|
||||
"</a:schemeClr>",
|
||||
"</a:gs>",
|
||||
"<a:gs pos=\"100000\">",
|
||||
"<a:schemeClr val=\"phClr\">",
|
||||
"<a:tint val=\"15000\"/>",
|
||||
"<a:satMod val=\"350000\"/>",
|
||||
"</a:schemeClr>",
|
||||
"</a:gs>",
|
||||
"</a:gsLst>",
|
||||
"<a:lin ang=\"16200000\" scaled=\"1\"/>",
|
||||
"</a:gradFill>",
|
||||
"<a:gradFill rotWithShape=\"1\">",
|
||||
"<a:gsLst>",
|
||||
"<a:gs pos=\"0\">",
|
||||
"<a:schemeClr val=\"phClr\">",
|
||||
"<a:shade val=\"51000\"/>",
|
||||
"<a:satMod val=\"130000\"/>",
|
||||
"</a:schemeClr>",
|
||||
"</a:gs>",
|
||||
"<a:gs pos=\"80000\">",
|
||||
"<a:schemeClr val=\"phClr\">",
|
||||
"<a:shade val=\"93000\"/>",
|
||||
"<a:satMod val=\"130000\"/>",
|
||||
"</a:schemeClr>",
|
||||
"</a:gs>",
|
||||
"<a:gs pos=\"100000\">",
|
||||
"<a:schemeClr val=\"phClr\">",
|
||||
"<a:shade val=\"94000\"/>",
|
||||
"<a:satMod val=\"135000\"/>",
|
||||
"</a:schemeClr>",
|
||||
"</a:gs>",
|
||||
"</a:gsLst>",
|
||||
"<a:lin ang=\"16200000\" scaled=\"0\"/>",
|
||||
"</a:gradFill>",
|
||||
"</a:fillStyleLst>",
|
||||
"<a:lnStyleLst>",
|
||||
"<a:ln w=\"9525\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">",
|
||||
"<a:solidFill>",
|
||||
"<a:schemeClr val=\"phClr\">",
|
||||
"<a:shade val=\"95000\"/>",
|
||||
"<a:satMod val=\"105000\"/>",
|
||||
"</a:schemeClr>",
|
||||
"</a:solidFill>",
|
||||
"<a:prstDash val=\"solid\"/>",
|
||||
"</a:ln>",
|
||||
"<a:ln w=\"25400\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">",
|
||||
"<a:solidFill>",
|
||||
"<a:schemeClr val=\"phClr\"/>",
|
||||
"</a:solidFill>",
|
||||
"<a:prstDash val=\"solid\"/>",
|
||||
"</a:ln>",
|
||||
"<a:ln w=\"38100\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">",
|
||||
"<a:solidFill>",
|
||||
"<a:schemeClr val=\"phClr\"/>",
|
||||
"</a:solidFill>",
|
||||
"<a:prstDash val=\"solid\"/>",
|
||||
"</a:ln>",
|
||||
"</a:lnStyleLst>",
|
||||
"<a:effectStyleLst>",
|
||||
"<a:effectStyle>",
|
||||
"<a:effectLst>",
|
||||
"<a:outerShdw blurRad=\"40000\" dist=\"20000\" ",
|
||||
"dir=\"5400000\" rotWithShape=\"0\">",
|
||||
"<a:srgbClr val=\"000000\">",
|
||||
"<a:alpha val=\"38000\"/>",
|
||||
"</a:srgbClr>",
|
||||
"</a:outerShdw>",
|
||||
"</a:effectLst>",
|
||||
"</a:effectStyle>",
|
||||
"<a:effectStyle>",
|
||||
"<a:effectLst>",
|
||||
"<a:outerShdw blurRad=\"40000\" dist=\"23000\" ",
|
||||
"dir=\"5400000\" rotWithShape=\"0\">",
|
||||
"<a:srgbClr val=\"000000\">",
|
||||
"<a:alpha val=\"35000\"/>",
|
||||
"</a:srgbClr>",
|
||||
"</a:outerShdw>",
|
||||
"</a:effectLst>",
|
||||
"</a:effectStyle>",
|
||||
"<a:effectStyle>",
|
||||
"<a:effectLst>",
|
||||
"<a:outerShdw blurRad=\"40000\" dist=\"23000\" ",
|
||||
"dir=\"5400000\" rotWithShape=\"0\">",
|
||||
"<a:srgbClr val=\"000000\">",
|
||||
"<a:alpha val=\"35000\"/>",
|
||||
"</a:srgbClr>",
|
||||
"</a:outerShdw>",
|
||||
"</a:effectLst>",
|
||||
"<a:scene3d>",
|
||||
"<a:camera prst=\"orthographicFront\">",
|
||||
"<a:rot lat=\"0\" lon=\"0\" rev=\"0\"/>",
|
||||
"</a:camera>",
|
||||
"<a:lightRig rig=\"threePt\" dir=\"t\">",
|
||||
"<a:rot lat=\"0\" lon=\"0\" rev=\"1200000\"/>",
|
||||
"</a:lightRig>",
|
||||
"</a:scene3d>",
|
||||
"<a:sp3d>",
|
||||
"<a:bevelT w=\"63500\" h=\"25400\"/>",
|
||||
"</a:sp3d>",
|
||||
"</a:effectStyle>",
|
||||
"</a:effectStyleLst>",
|
||||
"<a:bgFillStyleLst>",
|
||||
"<a:solidFill>",
|
||||
"<a:schemeClr val=\"phClr\"/>",
|
||||
"</a:solidFill>",
|
||||
"<a:gradFill rotWithShape=\"1\">",
|
||||
"<a:gsLst>",
|
||||
"<a:gs pos=\"0\">",
|
||||
"<a:schemeClr val=\"phClr\">",
|
||||
"<a:tint val=\"40000\"/>",
|
||||
"<a:satMod val=\"350000\"/>",
|
||||
"</a:schemeClr>",
|
||||
"</a:gs>",
|
||||
"<a:gs pos=\"40000\">",
|
||||
"<a:schemeClr val=\"phClr\">",
|
||||
"<a:tint val=\"45000\"/>",
|
||||
"<a:shade val=\"99000\"/>",
|
||||
"<a:satMod val=\"350000\"/>",
|
||||
"</a:schemeClr>",
|
||||
"</a:gs>",
|
||||
"<a:gs pos=\"100000\">",
|
||||
"<a:schemeClr val=\"phClr\">",
|
||||
"<a:shade val=\"20000\"/>",
|
||||
"<a:satMod val=\"255000\"/>",
|
||||
"</a:schemeClr>",
|
||||
"</a:gs>",
|
||||
"</a:gsLst>",
|
||||
"<a:path path=\"circle\">",
|
||||
"<a:fillToRect l=\"50000\" t=\"-80000\" r=\"50000\" b=\"180000\"/>",
|
||||
"</a:path>",
|
||||
"</a:gradFill>",
|
||||
"<a:gradFill rotWithShape=\"1\">",
|
||||
"<a:gsLst>",
|
||||
"<a:gs pos=\"0\">",
|
||||
"<a:schemeClr val=\"phClr\">",
|
||||
"<a:tint val=\"80000\"/>",
|
||||
"<a:satMod val=\"300000\"/>",
|
||||
"</a:schemeClr>",
|
||||
"</a:gs>",
|
||||
"<a:gs pos=\"100000\">",
|
||||
"<a:schemeClr val=\"phClr\">",
|
||||
"<a:shade val=\"30000\"/>",
|
||||
"<a:satMod val=\"200000\"/>",
|
||||
"</a:schemeClr>",
|
||||
"</a:gs>",
|
||||
"</a:gsLst>",
|
||||
"<a:path path=\"circle\">",
|
||||
"<a:fillToRect l=\"50000\" t=\"50000\" r=\"50000\" b=\"50000\"/>",
|
||||
"</a:path>",
|
||||
"</a:gradFill>",
|
||||
"</a:bgFillStyleLst>",
|
||||
"</a:fmtScheme>",
|
||||
"</a:themeElements>",
|
||||
"<a:objectDefaults/>",
|
||||
"<a:extraClrSchemeLst/>",
|
||||
"</a:theme>\n",
|
||||
""
|
||||
};
|
||||
|
||||
/*
|
||||
* Forward declarations.
|
||||
*/
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Private functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Create a new theme object.
|
||||
*/
|
||||
lxw_theme *
|
||||
lxw_theme_new(void)
|
||||
{
|
||||
lxw_theme *theme = calloc(1, sizeof(lxw_theme));
|
||||
GOTO_LABEL_ON_MEM_ERROR(theme, mem_error);
|
||||
|
||||
return theme;
|
||||
|
||||
mem_error:
|
||||
lxw_theme_free(theme);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free a theme object.
|
||||
*/
|
||||
void
|
||||
lxw_theme_free(lxw_theme *theme)
|
||||
{
|
||||
if (!theme)
|
||||
return;
|
||||
|
||||
free(theme);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* XML functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* This library isn't a xmlwriter. */
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* XML file assembly functions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Assemble and write the XML file.
|
||||
*/
|
||||
void
|
||||
lxw_theme_assemble_xml_file(lxw_theme *self)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
while (strlen(theme_strs[i])) {
|
||||
fprintf(self->file, "%s", theme_strs[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Public functions.
|
||||
*
|
||||
****************************************************************************/
|
8
library/libxlsxwriter/src/theme.dep
Normal file
8
library/libxlsxwriter/src/theme.dep
Normal file
@ -0,0 +1,8 @@
|
||||
library/libxlsxwriter/src/theme.lo: \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/src/theme.c \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/xmlwriter.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/utility.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/common.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/queue.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/tree.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/theme.h
|
684
library/libxlsxwriter/src/utility.c
Normal file
684
library/libxlsxwriter/src/utility.c
Normal file
@ -0,0 +1,684 @@
|
||||
/*****************************************************************************
|
||||
* utility - Utility functions for libxlsxwriter.
|
||||
*
|
||||
* Used in conjunction with the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2021, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include "xlsxwriter.h"
|
||||
#include "xlsxwriter/common.h"
|
||||
#include "xlsxwriter/third_party/tmpfileplus.h"
|
||||
|
||||
#ifdef USE_DTOA_LIBRARY
|
||||
#include "xlsxwriter/third_party/emyg_dtoa.h"
|
||||
#endif
|
||||
|
||||
char *error_strings[LXW_MAX_ERRNO + 1] = {
|
||||
"No error.",
|
||||
"Memory error, failed to malloc() required memory.",
|
||||
"Error creating output xlsx file. Usually a permissions error.",
|
||||
"Error encountered when creating a tmpfile during file assembly.",
|
||||
"Error reading a tmpfile.",
|
||||
"Zip generic error ZIP_ERRNO while creating the xlsx file.",
|
||||
"Zip error ZIP_PARAMERROR while creating the xlsx file.",
|
||||
"Zip error ZIP_BADZIPFILE (use_zip64 option may be required).",
|
||||
"Zip error ZIP_INTERNALERROR while creating the xlsx file.",
|
||||
"File error or unknown zip error when adding sub file to xlsx file.",
|
||||
"Unknown zip error when closing xlsx file.",
|
||||
"Feature is not currently supported in this configuration.",
|
||||
"NULL function parameter ignored.",
|
||||
"Function parameter validation error.",
|
||||
"Worksheet name exceeds Excel's limit of 31 characters.",
|
||||
"Worksheet name cannot contain invalid characters: '[ ] : * ? / \\'",
|
||||
"Worksheet name cannot start or end with an apostrophe.",
|
||||
"Worksheet name is already in use.",
|
||||
"Parameter exceeds Excel's limit of 32 characters.",
|
||||
"Parameter exceeds Excel's limit of 128 characters.",
|
||||
"Parameter exceeds Excel's limit of 255 characters.",
|
||||
"String exceeds Excel's limit of 32,767 characters.",
|
||||
"Error finding internal string index.",
|
||||
"Worksheet row or column index out of range.",
|
||||
"Maximum hyperlink length (2079) exceeded.",
|
||||
"Maximum number of worksheet URLs (65530) exceeded.",
|
||||
"Couldn't read image dimensions or DPI.",
|
||||
"Unknown error number."
|
||||
};
|
||||
|
||||
char *
|
||||
lxw_strerror(lxw_error error_num)
|
||||
{
|
||||
if (error_num > LXW_MAX_ERRNO)
|
||||
error_num = LXW_MAX_ERRNO;
|
||||
|
||||
return error_strings[error_num];
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert Excel A-XFD style column name to zero based number.
|
||||
*/
|
||||
void
|
||||
lxw_col_to_name(char *col_name, lxw_col_t col_num, uint8_t absolute)
|
||||
{
|
||||
uint8_t pos = 0;
|
||||
size_t len;
|
||||
size_t i;
|
||||
|
||||
/* Change from 0 index to 1 index. */
|
||||
col_num++;
|
||||
|
||||
/* Convert the column number to a string in reverse order. */
|
||||
while (col_num) {
|
||||
|
||||
/* Get the remainder in base 26. */
|
||||
int remainder = col_num % 26;
|
||||
|
||||
if (remainder == 0)
|
||||
remainder = 26;
|
||||
|
||||
/* Convert the remainder value to a character. */
|
||||
col_name[pos++] = 'A' + remainder - 1;
|
||||
col_name[pos] = '\0';
|
||||
|
||||
/* Get the next order of magnitude. */
|
||||
col_num = (col_num - 1) / 26;
|
||||
}
|
||||
|
||||
if (absolute) {
|
||||
col_name[pos] = '$';
|
||||
col_name[pos + 1] = '\0';
|
||||
}
|
||||
|
||||
/* Reverse the column name string. */
|
||||
len = strlen(col_name);
|
||||
for (i = 0; i < (len / 2); i++) {
|
||||
char tmp = col_name[i];
|
||||
col_name[i] = col_name[len - i - 1];
|
||||
col_name[len - i - 1] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert zero indexed row and column to an Excel style A1 cell reference.
|
||||
*/
|
||||
void
|
||||
lxw_rowcol_to_cell(char *cell_name, lxw_row_t row, lxw_col_t col)
|
||||
{
|
||||
size_t pos;
|
||||
|
||||
/* Add the column to the cell. */
|
||||
lxw_col_to_name(cell_name, col, 0);
|
||||
|
||||
/* Get the end of the cell. */
|
||||
pos = strlen(cell_name);
|
||||
|
||||
/* Add the row to the cell. */
|
||||
lxw_snprintf(&cell_name[pos], LXW_MAX_ROW_NAME_LENGTH, "%d", ++row);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert zero indexed row and column to an Excel style $A$1 cell with
|
||||
* an absolute reference.
|
||||
*/
|
||||
void
|
||||
lxw_rowcol_to_cell_abs(char *cell_name, lxw_row_t row, lxw_col_t col,
|
||||
uint8_t abs_row, uint8_t abs_col)
|
||||
{
|
||||
size_t pos;
|
||||
|
||||
/* Add the column to the cell. */
|
||||
lxw_col_to_name(cell_name, col, abs_col);
|
||||
|
||||
/* Get the end of the cell. */
|
||||
pos = strlen(cell_name);
|
||||
|
||||
if (abs_row)
|
||||
cell_name[pos++] = '$';
|
||||
|
||||
/* Add the row to the cell. */
|
||||
lxw_snprintf(&cell_name[pos], LXW_MAX_ROW_NAME_LENGTH, "%d", ++row);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert zero indexed row and column pair to an Excel style A1:C5
|
||||
* range reference.
|
||||
*/
|
||||
void
|
||||
lxw_rowcol_to_range(char *range,
|
||||
lxw_row_t first_row, lxw_col_t first_col,
|
||||
lxw_row_t last_row, lxw_col_t last_col)
|
||||
{
|
||||
size_t pos;
|
||||
|
||||
/* Add the first cell to the range. */
|
||||
lxw_rowcol_to_cell(range, first_row, first_col);
|
||||
|
||||
/* If the start and end cells are the same just return a single cell. */
|
||||
if (first_row == last_row && first_col == last_col)
|
||||
return;
|
||||
|
||||
/* Get the end of the cell. */
|
||||
pos = strlen(range);
|
||||
|
||||
/* Add the range separator. */
|
||||
range[pos++] = ':';
|
||||
|
||||
/* Add the first cell to the range. */
|
||||
lxw_rowcol_to_cell(&range[pos], last_row, last_col);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert zero indexed row and column pairs to an Excel style $A$1:$C$5
|
||||
* range reference with absolute values.
|
||||
*/
|
||||
void
|
||||
lxw_rowcol_to_range_abs(char *range,
|
||||
lxw_row_t first_row, lxw_col_t first_col,
|
||||
lxw_row_t last_row, lxw_col_t last_col)
|
||||
{
|
||||
size_t pos;
|
||||
|
||||
/* Add the first cell to the range. */
|
||||
lxw_rowcol_to_cell_abs(range, first_row, first_col, 1, 1);
|
||||
|
||||
/* If the start and end cells are the same just return a single cell. */
|
||||
if (first_row == last_row && first_col == last_col)
|
||||
return;
|
||||
|
||||
/* Get the end of the cell. */
|
||||
pos = strlen(range);
|
||||
|
||||
/* Add the range separator. */
|
||||
range[pos++] = ':';
|
||||
|
||||
/* Add the first cell to the range. */
|
||||
lxw_rowcol_to_cell_abs(&range[pos], last_row, last_col, 1, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert sheetname and zero indexed row and column pairs to an Excel style
|
||||
* Sheet1!$A$1:$C$5 formula reference with absolute values.
|
||||
*/
|
||||
void
|
||||
lxw_rowcol_to_formula_abs(char *formula, const char *sheetname,
|
||||
lxw_row_t first_row, lxw_col_t first_col,
|
||||
lxw_row_t last_row, lxw_col_t last_col)
|
||||
{
|
||||
size_t pos;
|
||||
char *quoted_name = lxw_quote_sheetname(sheetname);
|
||||
|
||||
strncpy(formula, quoted_name, LXW_MAX_FORMULA_RANGE_LENGTH - 1);
|
||||
free(quoted_name);
|
||||
|
||||
/* Get the end of the sheetname. */
|
||||
pos = strlen(formula);
|
||||
|
||||
/* Add the range separator. */
|
||||
formula[pos++] = '!';
|
||||
|
||||
/* Add the first cell to the range. */
|
||||
lxw_rowcol_to_cell_abs(&formula[pos], first_row, first_col, 1, 1);
|
||||
|
||||
/* If the start and end cells are the same just return a single cell. */
|
||||
if (first_row == last_row && first_col == last_col)
|
||||
return;
|
||||
|
||||
/* Get the end of the cell. */
|
||||
pos = strlen(formula);
|
||||
|
||||
/* Add the range separator. */
|
||||
formula[pos++] = ':';
|
||||
|
||||
/* Add the first cell to the range. */
|
||||
lxw_rowcol_to_cell_abs(&formula[pos], last_row, last_col, 1, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an Excel style A1 cell reference to a zero indexed row number.
|
||||
*/
|
||||
lxw_row_t
|
||||
lxw_name_to_row(const char *row_str)
|
||||
{
|
||||
lxw_row_t row_num = 0;
|
||||
const char *p = row_str;
|
||||
|
||||
/* Skip the column letters and absolute symbol of the A1 cell. */
|
||||
while (p && !isdigit((unsigned char) *p))
|
||||
p++;
|
||||
|
||||
/* Convert the row part of the A1 cell to a number. */
|
||||
if (p)
|
||||
row_num = atoi(p);
|
||||
|
||||
if (row_num)
|
||||
return row_num - 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an Excel style A1 cell reference to a zero indexed column number.
|
||||
*/
|
||||
lxw_col_t
|
||||
lxw_name_to_col(const char *col_str)
|
||||
{
|
||||
lxw_col_t col_num = 0;
|
||||
const char *p = col_str;
|
||||
|
||||
/* Convert leading column letters of A1 cell. Ignore absolute $ marker. */
|
||||
while (p && (isupper((unsigned char) *p) || *p == '$')) {
|
||||
if (*p != '$')
|
||||
col_num = (col_num * 26) + (*p - 'A' + 1);
|
||||
p++;
|
||||
}
|
||||
|
||||
return col_num - 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert the second row of an Excel range ref to a zero indexed number.
|
||||
*/
|
||||
uint32_t
|
||||
lxw_name_to_row_2(const char *row_str)
|
||||
{
|
||||
const char *p = row_str;
|
||||
|
||||
/* Find the : separator in the range. */
|
||||
while (p && *p != ':')
|
||||
p++;
|
||||
|
||||
if (p)
|
||||
return lxw_name_to_row(++p);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert the second column of an Excel range ref to a zero indexed number.
|
||||
*/
|
||||
uint16_t
|
||||
lxw_name_to_col_2(const char *col_str)
|
||||
{
|
||||
const char *p = col_str;
|
||||
|
||||
/* Find the : separator in the range. */
|
||||
while (p && *p != ':')
|
||||
p++;
|
||||
|
||||
if (p)
|
||||
return lxw_name_to_col(++p);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a lxw_datetime struct to an Excel serial date, with a 1900
|
||||
* or 1904 epoch.
|
||||
*/
|
||||
double
|
||||
lxw_datetime_to_excel_date_epoch(lxw_datetime *datetime, uint8_t date_1904)
|
||||
{
|
||||
int year = datetime->year;
|
||||
int month = datetime->month;
|
||||
int day = datetime->day;
|
||||
int hour = datetime->hour;
|
||||
int min = datetime->min;
|
||||
double sec = datetime->sec;
|
||||
double seconds;
|
||||
int epoch = date_1904 ? 1904 : 1900;
|
||||
int offset = date_1904 ? 4 : 0;
|
||||
int norm = 300;
|
||||
int range;
|
||||
/* Set month days and check for leap year. */
|
||||
int mdays[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
int leap = 0;
|
||||
int days = 0;
|
||||
int i;
|
||||
|
||||
/* For times without dates set the default date for the epoch. */
|
||||
if (!year) {
|
||||
if (!date_1904) {
|
||||
year = 1899;
|
||||
month = 12;
|
||||
day = 31;
|
||||
}
|
||||
else {
|
||||
year = 1904;
|
||||
month = 1;
|
||||
day = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert the Excel seconds to a fraction of the seconds in 24 hours. */
|
||||
seconds = (hour * 60 * 60 + min * 60 + sec) / (24 * 60 * 60.0);
|
||||
|
||||
/* Special cases for Excel dates in the 1900 epoch. */
|
||||
if (!date_1904) {
|
||||
/* Excel 1900 epoch. */
|
||||
if (year == 1899 && month == 12 && day == 31)
|
||||
return seconds;
|
||||
|
||||
/* Excel 1900 epoch. */
|
||||
if (year == 1900 && month == 1 && day == 0)
|
||||
return seconds;
|
||||
|
||||
/* Excel false leapday */
|
||||
if (year == 1900 && month == 2 && day == 29)
|
||||
return 60 + seconds;
|
||||
}
|
||||
|
||||
/* We calculate the date by calculating the number of days since the */
|
||||
/* epoch and adjust for the number of leap days. We calculate the */
|
||||
/* number of leap days by normalizing the year in relation to the */
|
||||
/* epoch. Thus the year 2000 becomes 100 for 4-year and 100-year */
|
||||
/* leapdays and 400 for 400-year leapdays. */
|
||||
range = year - epoch;
|
||||
|
||||
if (year % 4 == 0 && (year % 100 > 0 || year % 400 == 0)) {
|
||||
leap = 1;
|
||||
mdays[2] = 29;
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the serial date by accumulating the number of days
|
||||
* since the epoch.
|
||||
*/
|
||||
|
||||
/* Add days for previous months. */
|
||||
for (i = 0; i < month; i++) {
|
||||
days += mdays[i];
|
||||
}
|
||||
/* Add days for current month. */
|
||||
days += day;
|
||||
/* Add days for all previous years. */
|
||||
days += range * 365;
|
||||
/* Add 4 year leapdays. */
|
||||
days += range / 4;
|
||||
/* Remove 100 year leapdays. */
|
||||
days -= (range + offset) / 100;
|
||||
/* Add 400 year leapdays. */
|
||||
days += (range + offset + norm) / 400;
|
||||
/* Remove leap days already counted. */
|
||||
days -= leap;
|
||||
|
||||
/* Adjust for Excel erroneously treating 1900 as a leap year. */
|
||||
if (!date_1904 && days > 59)
|
||||
days++;
|
||||
|
||||
return days + seconds;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a lxw_datetime struct to an Excel serial date, for the 1900 epoch.
|
||||
*/
|
||||
double
|
||||
lxw_datetime_to_excel_datetime(lxw_datetime *datetime)
|
||||
{
|
||||
return lxw_datetime_to_excel_date_epoch(datetime, LXW_FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a unix datetime (1970/01/01 epoch) to an Excel serial date, with a
|
||||
* 1900 epoch.
|
||||
*/
|
||||
double
|
||||
lxw_unixtime_to_excel_date(int64_t unixtime)
|
||||
{
|
||||
return lxw_unixtime_to_excel_date_epoch(unixtime, LXW_FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a unix datetime (1970/01/01 epoch) to an Excel serial date, with a
|
||||
* 1900 or 1904 epoch.
|
||||
*/
|
||||
double
|
||||
lxw_unixtime_to_excel_date_epoch(int64_t unixtime, uint8_t date_1904)
|
||||
{
|
||||
double excel_datetime = 0.0;
|
||||
int epoch = date_1904 ? 24107.0 : 25568.0;
|
||||
|
||||
excel_datetime = epoch + (unixtime / (24 * 60 * 60.0));
|
||||
|
||||
if (!date_1904 && excel_datetime >= 60.0)
|
||||
excel_datetime = excel_datetime + 1.0;
|
||||
|
||||
return excel_datetime;
|
||||
}
|
||||
|
||||
/* Simple strdup() implementation since it isn't ANSI C. */
|
||||
char *
|
||||
lxw_strdup(const char *str)
|
||||
{
|
||||
size_t len;
|
||||
char *copy;
|
||||
|
||||
if (!str)
|
||||
return NULL;
|
||||
|
||||
len = strlen(str) + 1;
|
||||
copy = malloc(len);
|
||||
|
||||
if (copy)
|
||||
memcpy(copy, str, len);
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
/* Simple function to strdup() a formula string without the leading "=". */
|
||||
char *
|
||||
lxw_strdup_formula(const char *formula)
|
||||
{
|
||||
if (!formula)
|
||||
return NULL;
|
||||
|
||||
if (formula[0] == '=')
|
||||
return lxw_strdup(formula + 1);
|
||||
else
|
||||
return lxw_strdup(formula);
|
||||
}
|
||||
|
||||
/* Simple strlen that counts UTF-8 characters. Assumes well formed UTF-8. */
|
||||
size_t
|
||||
lxw_utf8_strlen(const char *str)
|
||||
{
|
||||
size_t byte_count = 0;
|
||||
size_t char_count = 0;
|
||||
|
||||
while (str[byte_count]) {
|
||||
if ((str[byte_count] & 0xc0) != 0x80)
|
||||
char_count++;
|
||||
|
||||
byte_count++;
|
||||
}
|
||||
|
||||
return char_count;
|
||||
}
|
||||
|
||||
/* Simple tolower() for strings. */
|
||||
void
|
||||
lxw_str_tolower(char *str)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; str[i]; i++)
|
||||
str[i] = tolower(str[i]);
|
||||
}
|
||||
|
||||
/* Create a quoted version of the worksheet name, or return an unmodified
|
||||
* copy if it doesn't required quoting. */
|
||||
char *
|
||||
lxw_quote_sheetname(const char *str)
|
||||
{
|
||||
|
||||
uint8_t needs_quoting = 0;
|
||||
size_t number_of_quotes = 2;
|
||||
size_t i, j;
|
||||
size_t len = strlen(str);
|
||||
|
||||
/* Don't quote the sheetname if it is already quoted. */
|
||||
if (str[0] == '\'')
|
||||
return lxw_strdup(str);
|
||||
|
||||
/* Check if the sheetname contains any characters that require it
|
||||
* to be quoted. Also check for single quotes within the string. */
|
||||
for (i = 0; i < len; i++) {
|
||||
if (!isalnum((unsigned char) str[i]) && str[i] != '_'
|
||||
&& str[i] != '.')
|
||||
needs_quoting = 1;
|
||||
|
||||
if (str[i] == '\'') {
|
||||
needs_quoting = 1;
|
||||
number_of_quotes++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!needs_quoting) {
|
||||
return lxw_strdup(str);
|
||||
}
|
||||
else {
|
||||
/* Add single quotes to the start and end of the string. */
|
||||
char *quoted_name = calloc(1, len + number_of_quotes + 1);
|
||||
RETURN_ON_MEM_ERROR(quoted_name, NULL);
|
||||
|
||||
quoted_name[0] = '\'';
|
||||
|
||||
for (i = 0, j = 1; i < len; i++, j++) {
|
||||
quoted_name[j] = str[i];
|
||||
|
||||
/* Double quote inline single quotes. */
|
||||
if (str[i] == '\'') {
|
||||
quoted_name[++j] = '\'';
|
||||
}
|
||||
}
|
||||
quoted_name[j++] = '\'';
|
||||
quoted_name[j++] = '\0';
|
||||
|
||||
return quoted_name;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Thin wrapper for tmpfile() so it can be over-ridden with a user defined
|
||||
* version if required for safety or portability.
|
||||
*/
|
||||
FILE *
|
||||
lxw_tmpfile(char *tmpdir)
|
||||
{
|
||||
#ifndef USE_STANDARD_TMPFILE
|
||||
return tmpfileplus(tmpdir, NULL, NULL, 0);
|
||||
#else
|
||||
(void) tmpdir;
|
||||
return tmpfile();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Use third party function to handle sprintf of doubles for locale portable
|
||||
* code.
|
||||
*/
|
||||
#ifdef USE_DTOA_LIBRARY
|
||||
int
|
||||
lxw_sprintf_dbl(char *data, double number)
|
||||
{
|
||||
emyg_dtoa(number, data);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Retrieve runtime library version.
|
||||
*/
|
||||
const char *
|
||||
lxw_version(void)
|
||||
{
|
||||
return LXW_VERSION;
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve runtime library version ID.
|
||||
*/
|
||||
uint16_t
|
||||
lxw_version_id(void)
|
||||
{
|
||||
return LXW_VERSION_ID;
|
||||
}
|
||||
|
||||
/*
|
||||
* Hash a worksheet password. Based on the algorithm provided by Daniel Rentz
|
||||
* of OpenOffice.
|
||||
*/
|
||||
uint16_t
|
||||
lxw_hash_password(const char *password)
|
||||
{
|
||||
size_t count;
|
||||
size_t i;
|
||||
uint16_t hash = 0x0000;
|
||||
|
||||
count = strlen(password);
|
||||
|
||||
for (i = 0; i < (uint8_t) count; i++) {
|
||||
uint32_t low_15;
|
||||
uint32_t high_15;
|
||||
uint32_t letter = password[i] << (i + 1);
|
||||
|
||||
low_15 = letter & 0x7fff;
|
||||
high_15 = letter & (0x7fff << 15);
|
||||
high_15 = high_15 >> 15;
|
||||
letter = low_15 | high_15;
|
||||
|
||||
hash ^= letter;
|
||||
}
|
||||
|
||||
hash ^= count;
|
||||
hash ^= 0xCE4B;
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
/* Make a simple portable version of fopen() for Windows. */
|
||||
#ifdef __MINGW32__
|
||||
#undef _WIN32
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
FILE *
|
||||
lxw_fopen(const char *filename, const char *mode)
|
||||
{
|
||||
int n;
|
||||
wchar_t wide_filename[_MAX_PATH + 1] = L"";
|
||||
wchar_t wide_mode[_MAX_PATH + 1] = L"";
|
||||
|
||||
n = MultiByteToWideChar(CP_UTF8, 0, filename, (int) strlen(filename),
|
||||
wide_filename, _MAX_PATH);
|
||||
|
||||
if (n == 0) {
|
||||
LXW_ERROR("MultiByteToWideChar error: filename");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
n = MultiByteToWideChar(CP_UTF8, 0, mode, (int) strlen(mode),
|
||||
wide_mode, _MAX_PATH);
|
||||
|
||||
if (n == 0) {
|
||||
LXW_ERROR("MultiByteToWideChar error: mode");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return _wfopen(wide_filename, wide_mode);
|
||||
}
|
||||
#else
|
||||
FILE *
|
||||
lxw_fopen(const char *filename, const char *mode)
|
||||
{
|
||||
return fopen(filename, mode);
|
||||
}
|
||||
#endif
|
19
library/libxlsxwriter/src/utility.dep
Normal file
19
library/libxlsxwriter/src/utility.dep
Normal file
@ -0,0 +1,19 @@
|
||||
library/libxlsxwriter/src/utility.lo: \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/src/utility.c \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/workbook.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/worksheet.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/shared_strings.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/common.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/queue.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/tree.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/chart.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/format.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/hash_table.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/drawing.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/styles.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/utility.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/xmlwriter.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/relationships.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/chartsheet.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/tmpfileplus.h
|
1032
library/libxlsxwriter/src/vml.c
Normal file
1032
library/libxlsxwriter/src/vml.c
Normal file
File diff suppressed because it is too large
Load Diff
16
library/libxlsxwriter/src/vml.dep
Normal file
16
library/libxlsxwriter/src/vml.dep
Normal file
@ -0,0 +1,16 @@
|
||||
library/libxlsxwriter/src/vml.lo: \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/src/vml.c \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/xmlwriter.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/utility.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/common.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/queue.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/tree.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/vml.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/worksheet.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/shared_strings.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/chart.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/format.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/hash_table.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/drawing.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/styles.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/relationships.h
|
2647
library/libxlsxwriter/src/workbook.c
Normal file
2647
library/libxlsxwriter/src/workbook.c
Normal file
File diff suppressed because it is too large
Load Diff
27
library/libxlsxwriter/src/workbook.dep
Normal file
27
library/libxlsxwriter/src/workbook.dep
Normal file
@ -0,0 +1,27 @@
|
||||
library/libxlsxwriter/src/workbook.lo: \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/src/workbook.c \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/xmlwriter.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/utility.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/common.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/queue.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/tree.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/workbook.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/worksheet.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/shared_strings.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/chart.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/format.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/hash_table.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/drawing.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/styles.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/relationships.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/chartsheet.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/packager.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/zip.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/app.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/core.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/custom.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/theme.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/content_types.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/vml.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/comment.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/metadata.h
|
10391
library/libxlsxwriter/src/worksheet.c
Normal file
10391
library/libxlsxwriter/src/worksheet.c
Normal file
File diff suppressed because it is too large
Load Diff
16
library/libxlsxwriter/src/worksheet.dep
Normal file
16
library/libxlsxwriter/src/worksheet.dep
Normal file
@ -0,0 +1,16 @@
|
||||
library/libxlsxwriter/src/worksheet.lo: \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/src/worksheet.c \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/xmlwriter.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/utility.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/common.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/queue.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/tree.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/worksheet.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/shared_strings.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/chart.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/format.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/hash_table.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/drawing.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/styles.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/relationships.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/md5.h
|
443
library/libxlsxwriter/src/xmlwriter.c
Normal file
443
library/libxlsxwriter/src/xmlwriter.c
Normal file
@ -0,0 +1,443 @@
|
||||
/*****************************************************************************
|
||||
* xmlwriter - A base library for libxlsxwriter libraries.
|
||||
*
|
||||
* Used in conjunction with the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2021, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "xlsxwriter/xmlwriter.h"
|
||||
|
||||
#define LXW_AMP "&"
|
||||
#define LXW_LT "<"
|
||||
#define LXW_GT ">"
|
||||
#define LXW_QUOT """
|
||||
|
||||
/* Defines. */
|
||||
#define LXW_MAX_ENCODED_ATTRIBUTE_LENGTH (LXW_MAX_ATTRIBUTE_LENGTH*6)
|
||||
|
||||
/* Forward declarations. */
|
||||
STATIC char *_escape_attributes(struct xml_attribute *attribute);
|
||||
|
||||
char *lxw_escape_data(const char *data);
|
||||
|
||||
STATIC void _fprint_escaped_attributes(FILE * xmlfile,
|
||||
struct xml_attribute_list *attributes);
|
||||
|
||||
STATIC void _fprint_escaped_data(FILE * xmlfile, const char *data);
|
||||
|
||||
/*
|
||||
* Write the XML declaration.
|
||||
*/
|
||||
void
|
||||
lxw_xml_declaration(FILE * xmlfile)
|
||||
{
|
||||
fprintf(xmlfile, "<?xml version=\"1.0\" "
|
||||
"encoding=\"UTF-8\" standalone=\"yes\"?>\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write an XML start tag with optional attributes.
|
||||
*/
|
||||
void
|
||||
lxw_xml_start_tag(FILE * xmlfile,
|
||||
const char *tag, struct xml_attribute_list *attributes)
|
||||
{
|
||||
fprintf(xmlfile, "<%s", tag);
|
||||
|
||||
_fprint_escaped_attributes(xmlfile, attributes);
|
||||
|
||||
fprintf(xmlfile, ">");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write an XML start tag with optional, unencoded, attributes.
|
||||
* This is a minor speed optimization for elements that don't need encoding.
|
||||
*/
|
||||
void
|
||||
lxw_xml_start_tag_unencoded(FILE * xmlfile,
|
||||
const char *tag,
|
||||
struct xml_attribute_list *attributes)
|
||||
{
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
fprintf(xmlfile, "<%s", tag);
|
||||
|
||||
if (attributes) {
|
||||
STAILQ_FOREACH(attribute, attributes, list_entries) {
|
||||
fprintf(xmlfile, " %s=\"%s\"", attribute->key, attribute->value);
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(xmlfile, ">");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write an XML end tag.
|
||||
*/
|
||||
void
|
||||
lxw_xml_end_tag(FILE * xmlfile, const char *tag)
|
||||
{
|
||||
fprintf(xmlfile, "</%s>", tag);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write an empty XML tag with optional attributes.
|
||||
*/
|
||||
void
|
||||
lxw_xml_empty_tag(FILE * xmlfile,
|
||||
const char *tag, struct xml_attribute_list *attributes)
|
||||
{
|
||||
fprintf(xmlfile, "<%s", tag);
|
||||
|
||||
_fprint_escaped_attributes(xmlfile, attributes);
|
||||
|
||||
fprintf(xmlfile, "/>");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write an XML start tag with optional, unencoded, attributes.
|
||||
* This is a minor speed optimization for elements that don't need encoding.
|
||||
*/
|
||||
void
|
||||
lxw_xml_empty_tag_unencoded(FILE * xmlfile,
|
||||
const char *tag,
|
||||
struct xml_attribute_list *attributes)
|
||||
{
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
fprintf(xmlfile, "<%s", tag);
|
||||
|
||||
if (attributes) {
|
||||
STAILQ_FOREACH(attribute, attributes, list_entries) {
|
||||
fprintf(xmlfile, " %s=\"%s\"", attribute->key, attribute->value);
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(xmlfile, "/>");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write an XML element containing data with optional attributes.
|
||||
*/
|
||||
void
|
||||
lxw_xml_data_element(FILE * xmlfile,
|
||||
const char *tag,
|
||||
const char *data, struct xml_attribute_list *attributes)
|
||||
{
|
||||
fprintf(xmlfile, "<%s", tag);
|
||||
|
||||
_fprint_escaped_attributes(xmlfile, attributes);
|
||||
|
||||
fprintf(xmlfile, ">");
|
||||
|
||||
_fprint_escaped_data(xmlfile, data);
|
||||
|
||||
fprintf(xmlfile, "</%s>", tag);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write an XML <si> element for rich strings, without encoding.
|
||||
*/
|
||||
void
|
||||
lxw_xml_rich_si_element(FILE * xmlfile, const char *string)
|
||||
{
|
||||
fprintf(xmlfile, "<si>%s</si>", string);
|
||||
}
|
||||
|
||||
/*
|
||||
* Escape XML characters in attributes.
|
||||
*/
|
||||
STATIC char *
|
||||
_escape_attributes(struct xml_attribute *attribute)
|
||||
{
|
||||
char *encoded = (char *) calloc(LXW_MAX_ENCODED_ATTRIBUTE_LENGTH, 1);
|
||||
char *p_encoded = encoded;
|
||||
char *p_attr = attribute->value;
|
||||
|
||||
while (*p_attr) {
|
||||
switch (*p_attr) {
|
||||
case '&':
|
||||
memcpy(p_encoded, LXW_AMP, sizeof(LXW_AMP) - 1);
|
||||
p_encoded += sizeof(LXW_AMP) - 1;
|
||||
break;
|
||||
case '<':
|
||||
memcpy(p_encoded, LXW_LT, sizeof(LXW_LT) - 1);
|
||||
p_encoded += sizeof(LXW_LT) - 1;
|
||||
break;
|
||||
case '>':
|
||||
memcpy(p_encoded, LXW_GT, sizeof(LXW_GT) - 1);
|
||||
p_encoded += sizeof(LXW_GT) - 1;
|
||||
break;
|
||||
case '"':
|
||||
memcpy(p_encoded, LXW_QUOT, sizeof(LXW_QUOT) - 1);
|
||||
p_encoded += sizeof(LXW_QUOT) - 1;
|
||||
break;
|
||||
default:
|
||||
*p_encoded = *p_attr;
|
||||
p_encoded++;
|
||||
break;
|
||||
}
|
||||
p_attr++;
|
||||
}
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
/*
|
||||
* Escape XML characters in data sections of tags.
|
||||
* Note, this is different from _escape_attributes()
|
||||
* in that double quotes are not escaped by Excel.
|
||||
*/
|
||||
char *
|
||||
lxw_escape_data(const char *data)
|
||||
{
|
||||
size_t encoded_len = (strlen(data) * 5 + 1);
|
||||
|
||||
char *encoded = (char *) calloc(encoded_len, 1);
|
||||
char *p_encoded = encoded;
|
||||
|
||||
while (*data) {
|
||||
switch (*data) {
|
||||
case '&':
|
||||
memcpy(p_encoded, LXW_AMP, sizeof(LXW_AMP) - 1);
|
||||
p_encoded += sizeof(LXW_AMP) - 1;
|
||||
break;
|
||||
case '<':
|
||||
memcpy(p_encoded, LXW_LT, sizeof(LXW_LT) - 1);
|
||||
p_encoded += sizeof(LXW_LT) - 1;
|
||||
break;
|
||||
case '>':
|
||||
memcpy(p_encoded, LXW_GT, sizeof(LXW_GT) - 1);
|
||||
p_encoded += sizeof(LXW_GT) - 1;
|
||||
break;
|
||||
default:
|
||||
*p_encoded = *data;
|
||||
p_encoded++;
|
||||
break;
|
||||
}
|
||||
data++;
|
||||
}
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for control characters in strings.
|
||||
*/
|
||||
uint8_t
|
||||
lxw_has_control_characters(const char *string)
|
||||
{
|
||||
while (string) {
|
||||
/* 0xE0 == 0b11100000 masks values > 0x19 == 0b00011111. */
|
||||
if (!(*string & 0xE0) && *string != 0x0A && *string != 0x09)
|
||||
return LXW_TRUE;
|
||||
|
||||
string++;
|
||||
}
|
||||
|
||||
return LXW_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Escape control characters in strings with _xHHHH_.
|
||||
*/
|
||||
char *
|
||||
lxw_escape_control_characters(const char *string)
|
||||
{
|
||||
size_t escape_len = sizeof("_xHHHH_") - 1;
|
||||
size_t encoded_len = (strlen(string) * escape_len + 1);
|
||||
|
||||
char *encoded = (char *) calloc(encoded_len, 1);
|
||||
char *p_encoded = encoded;
|
||||
|
||||
while (*string) {
|
||||
switch (*string) {
|
||||
case '\x01':
|
||||
case '\x02':
|
||||
case '\x03':
|
||||
case '\x04':
|
||||
case '\x05':
|
||||
case '\x06':
|
||||
case '\x07':
|
||||
case '\x08':
|
||||
case '\x0B':
|
||||
case '\x0C':
|
||||
case '\x0D':
|
||||
case '\x0E':
|
||||
case '\x0F':
|
||||
case '\x10':
|
||||
case '\x11':
|
||||
case '\x12':
|
||||
case '\x13':
|
||||
case '\x14':
|
||||
case '\x15':
|
||||
case '\x16':
|
||||
case '\x17':
|
||||
case '\x18':
|
||||
case '\x19':
|
||||
case '\x1A':
|
||||
case '\x1B':
|
||||
case '\x1C':
|
||||
case '\x1D':
|
||||
case '\x1E':
|
||||
case '\x1F':
|
||||
lxw_snprintf(p_encoded, escape_len + 1, "_x%04X_", *string);
|
||||
p_encoded += escape_len;
|
||||
break;
|
||||
default:
|
||||
*p_encoded = *string;
|
||||
p_encoded++;
|
||||
break;
|
||||
}
|
||||
string++;
|
||||
}
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
/*
|
||||
* Escape special characters in URL strings with with %XX.
|
||||
*/
|
||||
char *
|
||||
lxw_escape_url_characters(const char *string, uint8_t escape_hash)
|
||||
{
|
||||
|
||||
size_t escape_len = sizeof("%XX") - 1;
|
||||
size_t encoded_len = (strlen(string) * escape_len + 1);
|
||||
|
||||
char *encoded = (char *) calloc(encoded_len, 1);
|
||||
char *p_encoded = encoded;
|
||||
|
||||
while (*string) {
|
||||
switch (*string) {
|
||||
case ' ':
|
||||
case '"':
|
||||
case '<':
|
||||
case '>':
|
||||
case '[':
|
||||
case ']':
|
||||
case '`':
|
||||
case '^':
|
||||
case '{':
|
||||
case '}':
|
||||
lxw_snprintf(p_encoded, escape_len + 1, "%%%2x", *string);
|
||||
p_encoded += escape_len;
|
||||
break;
|
||||
case '#':
|
||||
/* This is only escaped for "external:" style links. */
|
||||
if (escape_hash) {
|
||||
lxw_snprintf(p_encoded, escape_len + 1, "%%%2x", *string);
|
||||
p_encoded += escape_len;
|
||||
}
|
||||
else {
|
||||
*p_encoded = *string;
|
||||
p_encoded++;
|
||||
}
|
||||
break;
|
||||
case '%':
|
||||
/* Only escape % if it isn't already an escape. */
|
||||
if (!isxdigit(*(string + 1)) || !isxdigit(*(string + 2))) {
|
||||
lxw_snprintf(p_encoded, escape_len + 1, "%%%2x", *string);
|
||||
p_encoded += escape_len;
|
||||
}
|
||||
else {
|
||||
*p_encoded = *string;
|
||||
p_encoded++;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
*p_encoded = *string;
|
||||
p_encoded++;
|
||||
break;
|
||||
}
|
||||
string++;
|
||||
}
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
/* Write out escaped attributes. */
|
||||
STATIC void
|
||||
_fprint_escaped_attributes(FILE * xmlfile,
|
||||
struct xml_attribute_list *attributes)
|
||||
{
|
||||
struct xml_attribute *attribute;
|
||||
|
||||
if (attributes) {
|
||||
STAILQ_FOREACH(attribute, attributes, list_entries) {
|
||||
fprintf(xmlfile, " %s=", attribute->key);
|
||||
|
||||
if (!strpbrk(attribute->value, "&<>\"")) {
|
||||
fprintf(xmlfile, "\"%s\"", attribute->value);
|
||||
}
|
||||
else {
|
||||
char *encoded = _escape_attributes(attribute);
|
||||
|
||||
if (encoded) {
|
||||
fprintf(xmlfile, "\"%s\"", encoded);
|
||||
|
||||
free(encoded);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Write out escaped XML data. */
|
||||
STATIC void
|
||||
_fprint_escaped_data(FILE * xmlfile, const char *data)
|
||||
{
|
||||
/* Escape the data section of the XML element. */
|
||||
if (!strpbrk(data, "&<>")) {
|
||||
fprintf(xmlfile, "%s", data);
|
||||
}
|
||||
else {
|
||||
char *encoded = lxw_escape_data(data);
|
||||
if (encoded) {
|
||||
fprintf(xmlfile, "%s", encoded);
|
||||
free(encoded);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Create a new string XML attribute. */
|
||||
struct xml_attribute *
|
||||
lxw_new_attribute_str(const char *key, const char *value)
|
||||
{
|
||||
struct xml_attribute *attribute = malloc(sizeof(struct xml_attribute));
|
||||
|
||||
LXW_ATTRIBUTE_COPY(attribute->key, key);
|
||||
LXW_ATTRIBUTE_COPY(attribute->value, value);
|
||||
|
||||
return attribute;
|
||||
}
|
||||
|
||||
/* Create a new integer XML attribute. */
|
||||
struct xml_attribute *
|
||||
lxw_new_attribute_int(const char *key, uint32_t value)
|
||||
{
|
||||
struct xml_attribute *attribute = malloc(sizeof(struct xml_attribute));
|
||||
|
||||
LXW_ATTRIBUTE_COPY(attribute->key, key);
|
||||
lxw_snprintf(attribute->value, LXW_MAX_ATTRIBUTE_LENGTH, "%d", value);
|
||||
|
||||
return attribute;
|
||||
}
|
||||
|
||||
/* Create a new double XML attribute. */
|
||||
struct xml_attribute *
|
||||
lxw_new_attribute_dbl(const char *key, double value)
|
||||
{
|
||||
struct xml_attribute *attribute = malloc(sizeof(struct xml_attribute));
|
||||
|
||||
LXW_ATTRIBUTE_COPY(attribute->key, key);
|
||||
lxw_sprintf_dbl(attribute->value, value);
|
||||
|
||||
return attribute;
|
||||
}
|
7
library/libxlsxwriter/src/xmlwriter.dep
Normal file
7
library/libxlsxwriter/src/xmlwriter.dep
Normal file
@ -0,0 +1,7 @@
|
||||
library/libxlsxwriter/src/xmlwriter.lo: \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/src/xmlwriter.c \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/xmlwriter.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/utility.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/common.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/queue.h \
|
||||
/Users/ykxiao/nginx/www/phpext/php-ext-xlswriter/library/libxlsxwriter/include/xlsxwriter/third_party/tree.h
|
Reference in New Issue
Block a user