From 1f970c20a25deed282dbaf08a4be5af25e4951db Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Thu, 7 Mar 2019 16:38:20 +0300 Subject: [PATCH] tdf#123923: make COUNTIF propagate errors in its first parameter In a specific case, Err:504 was emitted by COUNTIF when its 1st parameter was #REF!. This value was written into pivot cache definition when exporting to XLSX. Clearly Excel only expected propagated #REF! there, emitted error to user, and dropped the pivot table. This problem made XLSX pivot table cache generated by Calc unusable by Excel, despite ECMA-376 Part 1, 18.10.1.27 tells that the error value is application-dependent. The change makes COUNTIF to propagate errors received in its 1st parameter, instead of owerwriting them with own Err:504. This will likely need to be extended to other functions, if similar problems would arise. Change-Id: I459fa163a0e3e5f2c658631d66e096f4d46b1ace Reviewed-on: https://gerrit.libreoffice.org/68868 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- .../data/ods/pivot-table-err-in-cache.ods | Bin 0 -> 9362 bytes sc/qa/unit/pivottable_filters_test.cxx | 19 ++++++++++++++++++ sc/source/core/tool/interpr1.cxx | 1 + 3 files changed, 20 insertions(+) create mode 100644 sc/qa/unit/data/ods/pivot-table-err-in-cache.ods diff --git a/sc/qa/unit/data/ods/pivot-table-err-in-cache.ods b/sc/qa/unit/data/ods/pivot-table-err-in-cache.ods new file mode 100644 index 0000000000000000000000000000000000000000..b566a61f88983266327ca8db4ccec330ffca1d01 GIT binary patch literal 9362 zcmdUVby!qu*EcF44brGINP~2DcOwl03@|YC(A^*<-5ml-3aE6WNH+{2okK}Te{i19 zN6&fnT;KKm_pZ72%sq4M^}E--?mcU-{aZ^#{sBBL92^oH+*1P!rC>1cOJ+DYxVz)_ zCpa6B4G`jP4+PlTgF&VM2*}Qs#l_Z)*$&_Ya$>f#2ilt1nL675Z6VA~_KrY+nUf_D z2vPYP<}J*B<>~E6+|Je>>-_IpkAI_O zZ)fjpf2aB{v;9ub2?BsP|9@Bsv9kmJyOqE53c%D92nOCd$?o60Li(HafouR4KqnS4 z5X1&x@ANN={GCh9!FB)$@ZYBV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RwF;eLb!_7f3yZ4S=urbxC3BRecI-N^|HQbh<#=cO{4I=(8L1Vb>W*06zn79 z#fbagYQFgI9hLC}z>H}m4_0Mnttihhj!_cDTExCqgk5XoYxHgq9%WTNk4U4Pu}Z4F zrz7$dWF)bd0PmVa=#9(qq|+h{4e9;4T#(8L?}s;0$n&@pTUyD4P9eic_?>gOpVM%j zp$4sbdGV^^0Yf<`GY;G6NPoQDu#@7V(-3zz`()H$A@nO6#ydd9oDkT!DDx`c?PMi` z8I^agW9F*-80G-NkqDiFR>&tX$~6Wgg`?#02DQi=qC`4N_G{97j90mz3gsJ|=5250 zOTKEO69Q!lCIpVo;Pc6`FoTH5WvPZmyWq~F8qx9cpJqe}i$5d&^z1?|h$@nFOD&*l zH3%b-)a@xH>Lw&8eoiJd-uNXB1)iC#X0RWw_8whRBKtGIeYN;Em0yNpYs_lCw6E7a z?rG;=?8|4MM;)&~5->We9+O>UnbhEWVvvlqa^%S>?+eSb@Vu8HEE+I#6Ciwrg@XNV z^HsXfyQ+R;zRRzJA{I=-#+4JtMCfC+<>P3uHpplD-tEDq)@-uxg#|$|;=84Dff4gV8A z%=>j8w=}M}A4<3{bf)pa%JLQ*ZH1i$a=Oimhn1pgT2Mqmc2dWC9$y(;L z1CWx;j7ypfbR^fd*4W5bZaA5kvG3Rrt_GL;FJS7V(%DV1%zU!-Eao$&ZFcV1R(&Y4 zRv+?vL)zDh4|W7K@;3^#Z~kI?`WyD_S>WN|tp7F8;N1oqMM(`&CRrsZmj802x4CBN+R7BV=v`S6Ojh)DoClose(); } +void ScPivotTableFiltersTest::testTdf123923() +{ + // tdf#123923: Excel fails when it finds "Err:504" instead of "#REF!" in pivot table cache + + ScDocShellRef xShell = loadDoc("pivot-table-err-in-cache.", FORMAT_ODS); + CPPUNIT_ASSERT(xShell.is()); + + std::shared_ptr pXPathFile + = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX); + xmlDocPtr pTable = XPathHelper::parseExport(pXPathFile, m_xSFactory, + "xl/pivotCache/pivotCacheDefinition1.xml"); + CPPUNIT_ASSERT(pTable); + + assertXPath(pTable, "/x:pivotCacheDefinition/x:cacheFields/x:cacheField[1]/x:sharedItems/x:e", + "v", "#REF!"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScPivotTableFiltersTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index bc57c63388ae..75fd8f82b874 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -5738,6 +5738,7 @@ void ScInterpreter::ScCountIf() } break; default: + PopError(); // Propagate it further PushIllegalParameter(); return ; }