diff options
author | Aron Budea <aron.budea@collabora.com> | 2025-04-11 03:54:20 +0930 |
---|---|---|
committer | Aron Budea <aron.budea@collabora.com> | 2025-04-20 22:49:47 +0200 |
commit | 8397af1bc49897a2d8ebe30c1e960661271503e9 (patch) | |
tree | 956a2c5001b83215ffea2b8e41a1d3f6dd983028 | |
parent | f74142e6d02a65e811f9b84bada99b1489c0f9ff (diff) |
tdf#165886 sc: parse various quote characters
Otherwise roundtripped formulas in XLSX containing them
can end up with extra parenthesis, eg:
- Expected: OR(D1=0,D1<>““)
- Actual : OR(D1=0,D1<>““))
Change-Id: I6d296687cc2467ca0cdee329f9b04f6c956d2de0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183987
Reviewed-by: Aron Budea <aron.budea@collabora.com>
Tested-by: Jenkins
-rw-r--r-- | i18npool/source/characterclassification/cclass_unicode_parser.cxx | 20 | ||||
-rw-r--r-- | sc/qa/unit/data/xlsx/tdf165886.xlsx | bin | 0 -> 8859 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_export_test4.cxx | 32 |
3 files changed, 52 insertions, 0 deletions
diff --git a/i18npool/source/characterclassification/cclass_unicode_parser.cxx b/i18npool/source/characterclassification/cclass_unicode_parser.cxx index 32c49eb8661e..ddb895882dcd 100644 --- a/i18npool/source/characterclassification/cclass_unicode_parser.cxx +++ b/i18npool/source/characterclassification/cclass_unicode_parser.cxx @@ -672,6 +672,26 @@ ParserFlags cclass_Unicode::getFlagsExtended(sal_uInt32 const c, const cclass_Un ParserFlags::WORD : ParserFlags::ILLEGAL; } break; + case U_START_PUNCTUATION: + // left angle, double angle and corner brackets + if (c != 0x3008 && c != 0x300a && c != 0x300c && c != 0x300e) + return ParserFlags::ILLEGAL; + return bStart ? ParserFlags::CHAR_WORD : ParserFlags::WORD; + case U_END_PUNCTUATION: + // right angle, double angle and corner brackets + if (c != 0x3009 && c != 0x300b && c != 0x300d && c != 0x300f) + return ParserFlags::ILLEGAL; + return bStart ? ParserFlags::CHAR_WORD : ParserFlags::WORD; + case U_INITIAL_PUNCTUATION: + // left single / double quotation marks + if (c != 0x2018 && c != 0x201c) + return ParserFlags::ILLEGAL; + return bStart ? ParserFlags::CHAR_WORD : ParserFlags::WORD; + case U_FINAL_PUNCTUATION: + // right single / double quotation marks + if (c != 0x2019 && c != 0x201d) + return ParserFlags::ILLEGAL; + return bStart ? ParserFlags::CHAR_WORD : ParserFlags::WORD; } return ParserFlags::ILLEGAL; diff --git a/sc/qa/unit/data/xlsx/tdf165886.xlsx b/sc/qa/unit/data/xlsx/tdf165886.xlsx Binary files differnew file mode 100644 index 000000000000..146d08823181 --- /dev/null +++ b/sc/qa/unit/data/xlsx/tdf165886.xlsx diff --git a/sc/qa/unit/subsequent_export_test4.cxx b/sc/qa/unit/subsequent_export_test4.cxx index ad3642a666f3..ef9d49c775da 100644 --- a/sc/qa/unit/subsequent_export_test4.cxx +++ b/sc/qa/unit/subsequent_export_test4.cxx @@ -2209,6 +2209,38 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf165655) CPPUNIT_ASSERT_EQUAL(3, aNodes); } +CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf165886) +{ + createScDoc("xlsx/tdf165886.xlsx"); + + save(u"Calc Office Open XML"_ustr); + + xmlDocUniquePtr pSheet = parseExport(u"xl/worksheets/sheet1.xml"_ustr); + CPPUNIT_ASSERT(pSheet); + + assertXPathContent(pSheet, "/x:worksheet/x:sheetData/x:row[1]/x:c[1]/x:f", u"“"); + // Without the accompanying fix in place, this test would have failed with + // - Expected: OR(D1=0,D1<>““) + // - Actual : OR(D1=0,D1<>““)) + assertXPathContent(pSheet, "/x:worksheet/x:sheetData/x:row[1]/x:c[2]/x:f", u"OR(D1=0,D1<>““)"); + // Similarly + // - Expected: OR(E1=0,E1<>“) + // - Actual : OR(E1=0,E1<>“)) + assertXPathContent(pSheet, "/x:worksheet/x:sheetData/x:row[1]/x:c[3]/x:f", u"OR(E1=0,E1<>“)"); + // Similarly + // - Expected: OR(D2=0,D2<>””) + // - Actual : OR(D2=0,D2<>””)) + assertXPathContent(pSheet, "/x:worksheet/x:sheetData/x:row[2]/x:c[2]/x:f", u"OR(D2=0,D2<>””)"); + // Similarly + // - Expected: OR(D3=0,D3<>‘‘) + // - Actual : OR(D3=0,D3<>‘‘)) + assertXPathContent(pSheet, "/x:worksheet/x:sheetData/x:row[3]/x:c[2]/x:f", u"OR(D3=0,D3<>‘‘)"); + // Similarly + // - Expected: OR(D4=0,D4<>’’) + // - Actual : OR(D4=0,D4<>’’)) + assertXPathContent(pSheet, "/x:worksheet/x:sheetData/x:row[4]/x:c[2]/x:f", u"OR(D4=0,D4<>’’)"); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |