This commit is contained in:
Brecht Sanders 2020-03-19 00:37:01 +01:00
parent dfa6b83154
commit 22a577ce9c
4 changed files with 37 additions and 6 deletions

View File

@ -1,3 +1,10 @@
0.2.24
2020-03-19 Brecht Sanders https://github.com/brechtsanders/
* fixed memory leak (missing free(data->basepath) in main_sheet_get_sheetfile_callback when sheet filename not found)
* added support for .xlsm, .xltx and .xltm files (thanks to coproc for suggesting this in issue #61)
0.2.23
2020-03-09 Brecht Sanders https://github.com/brechtsanders/

View File

@ -1,13 +1,13 @@
# depslib dependency file v1.0
1583791626 source:\\server\users\brecht\sources\cpp\xlsxio\lib\xlsxio_read.c
1584573202 source:\\server\users\brecht\sources\cpp\xlsxio\lib\xlsxio_read.c
"xlsxio_private.h"
"xlsxio_read_sharedstrings.h"
"xlsxio_read.h"
"xlsxio_version.h"
<stdlib.h>
<stdio.h>
<inttypes.h>
<string.h>
<stdio.h>
<expat.h>
<minizip/unzip.h>
<io.h>

View File

@ -49,7 +49,7 @@ THE SOFTWARE.
/*! \brief minor version number */
#define XLSXIO_VERSION_MINOR 2
/*! \brief micro version number */
#define XLSXIO_VERSION_MICRO 23
#define XLSXIO_VERSION_MICRO 24
/*! @} */
/*! \cond PRIVATE */

View File

@ -50,6 +50,11 @@
#define PARSE_BUFFER_SIZE 256
//#define PARSE_BUFFER_SIZE 4
static const XLSXIOCHAR* xlsx_content_type = X("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml");
static const XLSXIOCHAR* xlsm_content_type = X("application/vnd.ms-excel.sheet.macroEnabled.main+xml");
static const XLSXIOCHAR* xltx_content_type = X("application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml");
static const XLSXIOCHAR* xltm_content_type = X("application/vnd.ms-excel.template.macroEnabled.main+xml");
#if !defined(XML_UNICODE_WCHAR_T) && !defined(XML_UNICODE)
//UTF-8 version
@ -780,7 +785,10 @@ DLL_EXPORT_XLSXIO void xlsxioread_list_sheets (xlsxioreader handle, xlsxioread_l
.callback = callback,
.callbackdata = callbackdata
};
iterate_files_by_contenttype(handle->zip, X("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"), xlsxioread_list_sheets_callback, &sheetcallbackdata, &sheetcallbackdata.xmlparser);
iterate_files_by_contenttype(handle->zip, xlsx_content_type, xlsxioread_list_sheets_callback, &sheetcallbackdata, &sheetcallbackdata.xmlparser);
iterate_files_by_contenttype(handle->zip, xlsm_content_type, xlsxioread_list_sheets_callback, &sheetcallbackdata, &sheetcallbackdata.xmlparser);
iterate_files_by_contenttype(handle->zip, xltx_content_type, xlsxioread_list_sheets_callback, &sheetcallbackdata, &sheetcallbackdata.xmlparser);
iterate_files_by_contenttype(handle->zip, xltm_content_type, xlsxioread_list_sheets_callback, &sheetcallbackdata, &sheetcallbackdata.xmlparser);
}
////////////////////////////////////////////////////////////////////////
@ -874,6 +882,10 @@ void main_sheet_get_sheetfile_callback (ZIPFILETYPE* zip, const XML_Char* filena
} else {
free(data->sheetrelid);
data->sheetrelid = NULL;
if (data->basepath) {
free(data->basepath);
data->basepath = NULL;
}
}
}
}
@ -1262,7 +1274,13 @@ DLL_EXPORT_XLSXIO int xlsxioread_process (xlsxioreader handle, const XLSXIOCHAR*
.sharedstringsfile = NULL,
.stylesfile = NULL
};
iterate_files_by_contenttype(handle->zip, X("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"), main_sheet_get_sheetfile_callback, &getrelscallbackdata, NULL);
iterate_files_by_contenttype(handle->zip, xlsx_content_type, main_sheet_get_sheetfile_callback, &getrelscallbackdata, NULL);
if (!getrelscallbackdata.sheetrelid)
iterate_files_by_contenttype(handle->zip, xlsm_content_type, main_sheet_get_sheetfile_callback, &getrelscallbackdata, NULL);
if (!getrelscallbackdata.sheetrelid)
iterate_files_by_contenttype(handle->zip, xltx_content_type, main_sheet_get_sheetfile_callback, &getrelscallbackdata, NULL);
if (!getrelscallbackdata.sheetrelid)
iterate_files_by_contenttype(handle->zip, xltm_content_type, main_sheet_get_sheetfile_callback, &getrelscallbackdata, NULL);
//process shared strings
struct sharedstringlist* sharedstrings = NULL;
@ -1335,7 +1353,13 @@ DLL_EXPORT_XLSXIO xlsxioreadersheetlist xlsxioread_sheetlist_open (xlsxioreader
{
//determine main sheet name
XML_Char* mainsheetfile = NULL;
iterate_files_by_contenttype(handle->zip, X("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"), xlsxioread_find_main_sheet_file_callback, &mainsheetfile, NULL);
iterate_files_by_contenttype(handle->zip, xlsx_content_type, xlsxioread_find_main_sheet_file_callback, &mainsheetfile, NULL);
if (!mainsheetfile)
iterate_files_by_contenttype(handle->zip, xlsm_content_type, xlsxioread_find_main_sheet_file_callback, &mainsheetfile, NULL);
if (!mainsheetfile)
iterate_files_by_contenttype(handle->zip, xltx_content_type, xlsxioread_find_main_sheet_file_callback, &mainsheetfile, NULL);
if (!mainsheetfile)
iterate_files_by_contenttype(handle->zip, xltm_content_type, xlsxioread_find_main_sheet_file_callback, &mainsheetfile, NULL);
if (!mainsheetfile)
return NULL;
//process contents of main sheet