From 07157107a3b7fd3d1b55db9ce1aeb9f6d4e204ab Mon Sep 17 00:00:00 2001 From: Winfried Donkers Date: Wed, 8 Feb 2017 16:48:58 +0100 Subject: tdf#105772 apply all ODFF constraints with function SEARCH. Now the function both complies with ODFF1.2 and behaves the same as Excel does. Change-Id: Ic49af48cacedbac54688266a916c5fa6e28bb5c4 Reviewed-on: https://gerrit.libreoffice.org/34037 Tested-by: Jenkins Reviewed-by: Eike Rathke --- sc/qa/unit/data/functions/text/fods/search.fods | 354 +++++++++++++++--------- sc/source/core/tool/interpr1.cxx | 11 +- 2 files changed, 221 insertions(+), 144 deletions(-) (limited to 'sc') diff --git a/sc/qa/unit/data/functions/text/fods/search.fods b/sc/qa/unit/data/functions/text/fods/search.fods index 4d1b1a0f6bc9..b4d4ccf1585c 100644 --- a/sc/qa/unit/data/functions/text/fods/search.fods +++ b/sc/qa/unit/data/functions/text/fods/search.fods @@ -1,13 +1,13 @@ - 2017-02-02T18:52:02.797049582P0D1LibreOfficeDev/5.3.0.0.alpha1$Linux_X86_64 LibreOffice_project/883024d657fb45c7da459017d2f936aac5644bfb + 2017-02-02T18:52:02.797049582P0D1LibreOfficeDev/5.4.0.0.alpha0$Linux_X86_64 LibreOffice_project/cc33a1ccda26819ed1dff02ec54e7452a598273f 0 0 33104 - 13409 + 9427 view1 @@ -32,7 +32,7 @@ 4 - 20 + 19 0 0 0 @@ -50,7 +50,7 @@ Sheet2 - 1241 + 1857 0 85 60 @@ -91,10 +91,12 @@ true true true + true + true false 12632256 false - Lexmark-E352dn + Generic Printer en @@ -111,14 +113,12 @@ ([{£¥'"‵〈《「『【〔〖([{£¥〝︵︷︹︻︽︿﹁﹃﹙﹛﹝({“‘ - true - true 3 1 true 1 true - rgH+/0xleG1hcmstRTM1MmRuAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ1VQUzpMZXhtYXJrLUUzNTJkbgAAAAAAAAAAAAAAAAAWAAMAzwAAAAAAAAAEAAhSAAAEdAAASm9iRGF0YSAxCnByaW50ZXI9TGV4bWFyay1FMzUyZG4Kb3JpZW50YXRpb249UG9ydHJhaXQKY29waWVzPTEKY29sbGF0ZT1mYWxzZQptYXJnaW5kYWp1c3RtZW50PTAsMCwwLDAKY29sb3JkZXB0aD0yNApwc2xldmVsPTAKcGRmZGV2aWNlPTEKY29sb3JkZXZpY2U9MApQUERDb250ZXhEYXRhClBhZ2VTaXplOkE0AElucHV0U2xvdDpUcmF5MQBEdXBsZXg6Tm9uZQAAEgBDT01QQVRfRFVQTEVYX01PREUPAER1cGxleE1vZGU6Ok9mZg== + hQH+/0dlbmVyaWMgUHJpbnRlcgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAU0dFTlBSVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWAAMApgAAAAAAAAAEAAhSAAAEdAAASm9iRGF0YSAxCnByaW50ZXI9R2VuZXJpYyBQcmludGVyCm9yaWVudGF0aW9uPVBvcnRyYWl0CmNvcGllcz0xCm1hcmdpbmRhanVzdG1lbnQ9MCwwLDAsMApjb2xvcmRlcHRoPTI0CnBzbGV2ZWw9MApwZGZkZXZpY2U9MApjb2xvcmRldmljZT0wClBQRENvbnRleERhdGEKUGFnZVNpemU6QTQAABIAQ09NUEFUX0RVUExFWF9NT0RFDwBEdXBsZXhNb2RlOjpPZmY= false 0 @@ -146,7 +146,7 @@ - + @@ -733,15 +733,63 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -754,52 +802,49 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - + @@ -812,47 +857,47 @@ - + - + - + - + - + - + - + - + @@ -871,33 +916,50 @@ - + - + - + - + - + - - - - + + + + - + + + + + + + + - + + + + + + + + + + + @@ -910,37 +972,31 @@ - + - + - + - + - + - - - - - - @@ -959,7 +1015,7 @@ ??? (???) - 00/00/0000, 00:00:00 + 00/00/0000, 00:00:00 @@ -1081,7 +1137,7 @@ 10 - + TRUE @@ -1097,7 +1153,7 @@ 6 - + TRUE @@ -1113,7 +1169,7 @@ 2 - + TRUE @@ -1129,7 +1185,7 @@ 4 - + TRUE @@ -1151,7 +1207,7 @@ 6 - + TRUE @@ -1172,7 +1228,7 @@ 6 - + TRUE @@ -1188,7 +1244,7 @@ 6 - + TRUE @@ -1204,7 +1260,7 @@ #VALUE! - + TRUE @@ -1219,7 +1275,7 @@ 5 - + TRUE @@ -1238,7 +1294,7 @@ 11 - + TRUE @@ -1250,28 +1306,67 @@ - - - - + + + Err:502 + + + error + + + TRUE + + + =SEARCH("e",I1,0) + + + Tdf#105772 + + Wookie - - - - + + + Err:502 + + + error + + + TRUE + + + =SEARCH("e","LibreOffice",0) + + + Tdf#105772 + + Mark - - - - + + + Err:502 + + + error + + + TRUE + + + =SEARCH("e","LibreOffice",-1) + + + Tdf#105772 + + Mark @@ -1289,7 +1384,7 @@ - + @@ -1300,7 +1395,7 @@ - + @@ -1308,75 +1403,49 @@ - - - 5 - - - error - - - - =SEARCH("e",I1,0) - - Constraints: Start >= 1 - - + + + + Andromeda - - - 5 - - - error - - - - =SEARCH("e","LibreOffice",0) - - + + + + + + Mark - - - 5 - - - error - - - - =SEARCH("e","LibreOffice",-1) - - It is a non-compliance with a purpose to keep backward compatibility (extract from the source code):// This should use GetStringPositionArgument() but old versions up// to LibreOffice 4.2.5 allowed and ignored 0 and negative values.// It is unnecessary to break existing documents that "rely" on// that behavior. Though ODFF constrains Start to be >=1./* TODO: fix this and possibly break those broken documents? */Given that version 4.2.5 dates from June 2014, one could argue that making the code fully ODFF compliant will not really break backward compatibility (version 5.4.0 is scheduled for August 2017).OTOH, it doesn't do real harm, the source code simply replaces the value of argument Start with 1 when the value passed is 0 or negative. - - + + + + - + - + - + @@ -1385,13 +1454,13 @@ - + - + @@ -1407,10 +1476,25 @@ - - - - + + + + + + + + + + + + + + + + + + + diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index da43d6e55c44..626c9b34a955 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -8263,15 +8263,8 @@ void ScInterpreter::ScSearch() double fAnz; if (nParamCount == 3) { - // This should use GetStringPositionArgument() but old versions up - // to LibreOffice 4.2.5 allowed and ignored 0 and negative values. - // It is unnecessary to break existing documents that "rely" on - // that behavior. Though ODFF constrains Start to be >=1. - /* TODO: fix this and possibly break those broken documents? */ - fAnz = rtl::math::approxFloor( GetDouble()); - if (fAnz < 1.0) - fAnz = 1.0; - else if (!CheckStringPositionArgument( fAnz)) + fAnz = GetStringPositionArgument(); + if( fAnz < 1 ) { PushIllegalArgument(); return; -- cgit v1.2.3