You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by cm...@apache.org on 2022/02/18 21:50:23 UTC

[openoffice] branch AOO41X updated: #i60307# search for strings in date formats fails. When "Search in" is set to "Values", search the formatted values instead of just the raw input. This fixes a 9 year old bug that's been duplicated at least 6 times, and matches what Excel does. Tests show even "Replace" works, and works well: if "October" is replaced by "November", it converts the original month from 10 to 11; it only converts the cell type to text if the resulting text is no longer a valid date. Also added BVT tests for t [...]

This is an automated email from the ASF dual-hosted git repository.

cmarcum pushed a commit to branch AOO41X
in repository https://gitbox.apache.org/repos/asf/openoffice.git


The following commit(s) were added to refs/heads/AOO41X by this push:
     new 133efdc  #i60307# search for strings in date formats fails. When "Search in" is set to "Values", search the formatted values instead of just the raw input. This fixes a 9 year old bug that's been duplicated at least 6 times, and matches what Excel does. Tests show even "Replace" works, and works well: if "October" is replaced by "November", it converts the original month from 10 to 11; it only converts the cell type to text if the resulting text is no longer a valid date. Also ad [...]
133efdc is described below

commit 133efdc14496caaf90c15e33666ab1c0c1e2fbea
Author: Damjan Jovanovic <da...@apache.org>
AuthorDate: Tue Nov 3 18:44:21 2015 +0000

    #i60307# search for strings in date formats fails.
    When "Search in" is set to "Values", search the formatted values
    instead of just the raw input. This fixes a 9 year old
    bug that's been duplicated at least 6 times, and matches what Excel
    does. Tests show even "Replace" works, and works well: if
    "October" is replaced by "November", it converts the original
    month from 10 to 11; it only converts the cell type to text if the
    resulting text is no longer a valid date. Also added BVT tests
    for the expected behaviour.
    
    git-svn-id: https://svn.apache.org/repos/asf/openoffice/trunk@1712367 13f79535-47bb-0310-9956-ffa450edef68
    (cherry picked from commit 2e4d2335e101b0658cddb9e31f2fd229d84bfc1d)
---
 main/sc/source/core/data/table6.cxx                |   2 +-
 test/testgui/data/bvt/searchFormulasValues.ods     | Bin 0 -> 7934 bytes
 test/testgui/source/bvt/gui/BasicFunctionTest.java |  30 +++++++++++++++++++++
 test/testgui/source/testlib/gui/UIMap.java         |   1 +
 4 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/main/sc/source/core/data/table6.cxx b/main/sc/source/core/data/table6.cxx
index 5a96ce1..745a07c 100644
--- a/main/sc/source/core/data/table6.cxx
+++ b/main/sc/source/core/data/table6.cxx
@@ -91,7 +91,7 @@ sal_Bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW
 					bMultiLine = lcl_GetTextWithBreaks(
 						*(const ScEditCell*)pCell, pDocument, aString );
 				else
-					aCol[nCol].GetInputString( nRow, aString );
+					aCol[nCol].GetString( nRow, aString );
 				break;
 			case SVX_SEARCHIN_NOTE:
 				{
diff --git a/test/testgui/data/bvt/searchFormulasValues.ods b/test/testgui/data/bvt/searchFormulasValues.ods
new file mode 100644
index 0000000..cdfe86f
Binary files /dev/null and b/test/testgui/data/bvt/searchFormulasValues.ods differ
diff --git a/test/testgui/source/bvt/gui/BasicFunctionTest.java b/test/testgui/source/bvt/gui/BasicFunctionTest.java
index ec7d770..a5dd69f 100644
--- a/test/testgui/source/bvt/gui/BasicFunctionTest.java
+++ b/test/testgui/source/bvt/gui/BasicFunctionTest.java
@@ -327,6 +327,36 @@ public class BasicFunctionTest {
 				copyAll());
 		discard();
 	}
+	
+	@Test
+	public void testFindFormulasAndValues() {
+	    open(prepareData("bvt/searchFormulasValues.ods"));
+	    calc.waitForExistence(10, 2);
+	    
+	    // Searching for 2003 by formula finds A2
+	    SCTool.selectRange("A1");
+	    app.dispatch(".uno:SearchDialog");
+        findDlgFor.setText("2003");
+        findDlgMore.click();
+        findDlgCalcSearchIn.select("Formulas");
+        findDlgFind.click();
+        sleep(1);
+	    assertEquals("wrong cell found for formulas search", "A2", scInputBarPosition.getText());
+	    findDlg.close();
+	    
+	    // Searching for October by value finds A2
+	    SCTool.selectRange("A1");
+	    app.dispatch(".uno:SearchDialog");
+	    findDlgFor.setText("October");
+	    findDlgMore.click();
+	    findDlgCalcSearchIn.select("Values");
+	    findDlgFind.click();
+	    sleep(1);
+	    assertEquals("wrong cell found for values search", "A2", scInputBarPosition.getText());
+	    findDlg.close();
+	    
+	    discard();
+	}
 
 	@Test
 	public void testFillInSpreadsheet() {
diff --git a/test/testgui/source/testlib/gui/UIMap.java b/test/testgui/source/testlib/gui/UIMap.java
index e370b76..a25c809 100644
--- a/test/testgui/source/testlib/gui/UIMap.java
+++ b/test/testgui/source/testlib/gui/UIMap.java
@@ -181,6 +181,7 @@ public class UIMap {
 	public static final VclButton findDlgMatchCase = button("svx:CheckBox:RID_SVXDLG_SEARCH:CB_MATCH_CASE");
 	public static final VclButton findDlgWholeWord = button("svx:CheckBox:RID_SVXDLG_SEARCH:CB_WHOLE_WORDS");
 	public static final VclButton findDlgMore = button("svx:MoreButton:RID_SVXDLG_SEARCH:BTN_MORE");
+	public static final VclListBox findDlgCalcSearchIn = listbox("svx:ListBox:RID_SVXDLG_SEARCH:LB_CALC_SEARCHIN");
 	public static final VclWindow chart = window("CHART2_HID_SCH_WIN_DOCUMENT");
 	public static final VclDialog chartWizard = dialog("CHART2_HID_SCH_CHART_AUTO_FORMAT");
 	public static final VclDialog filePrintDlg = dialog(".HelpID:vcl:PrintDialog:Dialog");