From ac18fc6dde31fd5a6663594df2ecb07132ae1f65 Mon Sep 17 00:00:00 2001 From: Adam Hooper Date: Tue, 25 Feb 2020 14:32:14 -0500 Subject: [PATCH] Parse inlineStr values inlineStr XML structure is . This was being parsed incorrectly when streaming (because has_value wasn't being set to true) and when reading the whole file (because the was ignored). [closes #445] --- source/detail/serialization/xlsx_consumer.cpp | 13 ++++++++++-- tests/data/Issue445_inline_str.xlsx | Bin 0 -> 4593 bytes tests/workbook/serialization_test_suite.cpp | 20 ++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 tests/data/Issue445_inline_str.xlsx diff --git a/source/detail/serialization/xlsx_consumer.cpp b/source/detail/serialization/xlsx_consumer.cpp index d23d35db..ea64b131 100644 --- a/source/detail/serialization/xlsx_consumer.cpp +++ b/source/detail/serialization/xlsx_consumer.cpp @@ -272,8 +272,8 @@ Cell parse_cell(xlnt::row_t row_arg, xml::parser *parser) if (level == 2) { // -> numeric values - // -> inline string - if (string_equal(parser->name(), "v") || string_equal(parser->name(), "is")) + // -> inline string + if (string_equal(parser->name(), "v")) { c.value += std::move(parser->value()); } @@ -283,6 +283,14 @@ Cell parse_cell(xlnt::row_t row_arg, xml::parser *parser) c.formula_string += std::move(parser->value()); } } + else if (level == 3) + { + // -> inline string + if (string_equal(parser->name(), "t")) + { + c.value += std::move(parser->value()); + } + } break; } case xml::parser::start_namespace_decl: @@ -561,6 +569,7 @@ cell xlsx_consumer::read_cell() else if (current_element == qn("spreadsheetml", "is")) // CT_Rst { expect_start_element(qn("spreadsheetml", "t"), xml::content::simple); + has_value = true; value_string = read_text(); expect_end_element(qn("spreadsheetml", "t")); } diff --git a/tests/data/Issue445_inline_str.xlsx b/tests/data/Issue445_inline_str.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..4085593b67b33337710668b8f08a48fed77fadf3 GIT binary patch literal 4593 zcmZ`+2Q(aO8(u9~L|G+PkD6GKMf5JZ=rw}9*sHU8N%T(i-g`t{5?M7mQNl(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J97kivJ3Wx7qH@6afUrP?^_9Mi0>O|0)I5mBP<8vk&Ff;tq4|H zH$y1NtDfbjF51ULFgk)Pr0X~}ZJDZ9D~u3kbg4dbUlDI14Gp1n>rl1Hgv9pCG#=;6 ztW@_s^WBot+4OY(Z`6ORYTt<4PJlpt0i)*yc= zL<7$6Qmjq`-MNR6;!VtllKzz94+}7NaK;fvILF8E=_9)VBnYj^@52ehMG?F~l)Vuc8$|?Yn52|z zW-v}k75tH3@~0Pv)WNDpN#^rPd0eSF1a8KSxmt1-+TV^{|NWca6={>k%CWhHa~ zgYOcDnaQ636c{${j*s0jePfzGZrx+6ngsPdb>GUz!58zgAt1c`mheSLAW=*#af@Dl z45n~9}`oE+WYj&5eU-Uzs>$qy}6>0q>k zF}4&g1IlK^LO`Y|m%(Zv)7_(IwO`X(W)d$XvWn#kfzO{ePMM;&-b!wKK80dY=XheR zzhGC<&@OcB;HHGiz=|V3aGUcx!L@x#QOr!#(TZgj%mlhxXszm0JL~Z|tzGfCZ{zM| z+AjLsFQ9#LcWH{>M`~Ikf=N+=pBTiFdsN>*`aIqHxl;Flp@Z#nUmEIhmhDN-xL-{P z=m$soY>V874dfG}0LwYjqN2j=O+mpuuPuI^M1g+d!O)pT% z7*X>m6j!(D;u@H99;PT@%D{3>5!OMMox9fLLAS&9b-UVRlDj;NColbA=XY9Oe5$`M zY5pa_e53jhRQA^(Z~@9caPes!Gu z1s}q^{$Ga6s{yVqC;ko)c%9&{0ROtUxEkeZbNo9BRv6)5QGT_`tI(^i{R_&4G4X$R z_*LLl7yJbzC;mJ0|9aw8@YMqU1$M(), std::string("a")); + } + + void test_Issue445_inline_str_streaming_read() + { + xlnt::streaming_workbook_reader wbr; + wbr.open(path_helper::test_file("Issue445_inline_str.xlsx")); + wbr.begin_worksheet("Sheet"); + auto cell = wbr.read_cell(); + xlnt_assert_equals(cell.value(), std::string("a")); + } }; static serialization_test_suite x;