Skip to content

Commit dbcf9c0

Browse files
author
Matthieu Labas
committed
*** v4.3.3 - Added Sourceforge#12 by Alexander Goomenyuk (expose data source context to user).
- Added search unitest.
1 parent 9d55332 commit dbcf9c0

File tree

4 files changed

+63
-2
lines changed

4 files changed

+63
-2
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
*** v4.3.3 - Added Sourceforge#12 by Alexander Goomenyuk (expose data source context to user).
2+
- Added search unitest.
3+
14
*** v4.3.2 - Fixed GitHub#11 by Dami�n M. Gonz�lez (missing free() on XMLNode_set_text()).
25
- Doxygen documentation update.
36
- Correction of CHECK_NODE macro that returned false on valid nodes!

src/sxmlc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,6 +1693,8 @@ int XMLDoc_parse_file_SAX(const SXML_CHAR* filename, const SAX_Callbacks* sax, v
16931693

16941694
sd.name = (SXML_CHAR*)filename;
16951695
sd.user = user;
1696+
sd.type = DATA_SOURCE_FILE;
1697+
sd.src = (void*)f;
16961698
#ifdef SXMLC_UNICODE
16971699
bom = freadBOM(f, NULL, NULL); /* Skip BOM, if any */
16981700
/* In Unicode, re-open the file in text-mode if there is no BOM (or UTF-8) as we assume that
@@ -1723,6 +1725,8 @@ int XMLDoc_parse_buffer_SAX_len(const SXML_CHAR* buffer, int buffer_len, const S
17231725

17241726
sd.name = name;
17251727
sd.user = user;
1728+
sd.type = DATA_SOURCE_BUFFER;
1729+
sd.src = (void*)buffer;
17261730
return _parse_data_SAX((void*)&dsb, DATA_SOURCE_BUFFER, sax, &sd);
17271731
}
17281732

src/sxmlc.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
/**
3434
* \brief Current SXMLC version, as a `const char[]`.
3535
*/
36-
#define SXMLC_VERSION "4.3.2"
36+
#define SXMLC_VERSION "4.3.3"
3737

3838
#ifdef __cplusplus
3939
extern "C" {
@@ -326,6 +326,8 @@ typedef struct _SAX_Data {
326326
const SXML_CHAR* name; /**< Document name (file name or buffer name). */
327327
int line_num; /**< Current line number being processed. */
328328
void* user; /**< User-given data. */
329+
DataSourceType type; /**< Data source type [DATA_SOURCE_FILE|DATA_SOURCE_BUFFER]. */
330+
void* src; /**< Data source [DataSourceFile|DataSourceBuffer]. Depends on type. */
329331
} SAX_Data;
330332

331333
/**

src/unitest/unitest.c

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,59 @@ static test_result test_move(char* msg)
409409

410410
static test_result test_search(char* msg)
411411
{
412-
return _test_not_implemented(msg); // TODO
412+
static char buf_stylesxml[] = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
413+
"<styleSheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" mc:Ignorable=\"x14ac\" xmlns:x14ac=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac\">"
414+
"<fonts count=\"1\" x14ac:knownFonts=\"1\">"
415+
"<font>"
416+
"<sz val=\"11\"/>"
417+
"<color theme=\"1\"/>"
418+
"<name val=\"Calibri\"/>"
419+
"<family val=\"2\"/>"
420+
"<scheme val=\"minor\"/>"
421+
"</font>"
422+
"</fonts>"
423+
"<fills count=\"2\">"
424+
"<fill><patternFill patternType=\"none\"/></fill>"
425+
"<fill><patternFill patternType=\"gray125\"/></fill>"
426+
"</fills>"
427+
"<borders count=\"1\">"
428+
"<border><left/><right/><top/><bottom/><diagonal/></border>"
429+
"</borders>"
430+
"<cellStyleXfs count=\"1\">"
431+
"<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\"/>"
432+
"</cellStyleXfs>"
433+
"<cellXfs count=\"1\">"
434+
"<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" xfId=\"0\"/>"
435+
"</cellXfs>"
436+
"<cellStyles count=\"1\">"
437+
"<cellStyle name=\"Normal\" xfId=\"0\" builtinId=\"0\"/>"
438+
"</cellStyles>"
439+
"<dxfs count=\"0\"/>"
440+
"<tableStyles count=\"0\" defaultTableStyle=\"TableStyleMedium2\" defaultPivotStyle=\"PivotStyleMedium9\"/>"
441+
"<extLst>"
442+
"<ext uri=\"{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}\" xmlns:x14=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main\">"
443+
"<x14:slicerStyles defaultSlicerStyle=\"SlicerStyleLight1\"/>"
444+
"</ext>"
445+
"<ext uri=\"{9260A510-F301-46a8-8635-F512D64BE5F5}\" xmlns:x15=\"http://schemas.microsoft.com/office/spreadsheetml/2010/11/main\">"
446+
"<x15:timelineStyles defaultTimelineStyle=\"TimeSlicerStyleLight1\"/>"
447+
"</ext>"
448+
"</extLst>"
449+
"</styleSheet>";
450+
XMLDoc styles_xml;
451+
XMLDoc_init(&styles_xml);
452+
XMLDoc_parse_buffer_DOM(buf_stylesxml, "styles.xml", &styles_xml);
453+
454+
// start the search for cellXfs
455+
XMLSearch search_engine;
456+
XMLSearch_init(&search_engine);
457+
XMLSearch_search_set_tag(&search_engine, "cellXfs");
458+
XMLNode *cell_xfs_node = XMLSearch_next(styles_xml.nodes[styles_xml.i_root], &search_engine);
459+
460+
assert_true(cell_xfs_node != NULL, TEST_ERROR, "Node cellXfs not found", NOP);
461+
462+
// TODO: More tests
463+
464+
return TEST_OK;
413465
}
414466

415467

0 commit comments

Comments
 (0)