diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2015-11-08 22:23:44 +1000 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2015-11-23 19:03:32 +0000 |
commit | 4cf1d290bab29e18e1312b63ff862f5102e00387 (patch) | |
tree | dc803f9c321df1642f7b2a6e818acf163c7674c9 /i18npool/qa | |
parent | 0c75202ad20d3dc1f0a2a68375253d547f054405 (diff) |
tdf#94810: fix reverse offset mapping
With simple transliteration, TextSearch::searchForward used to use
whole string to perform the search, then started to create substring
to search. But it left the precautions from
commit c00601dab0f5533b152cd63cec0a89bfec1ba95f by Eike Rathke:
searching for $ may actually return a result set pointing behind the
search string which it does with the ICU regex engine.
The precaution made it to skip reverse mapping if index was 0.
Commit 9aae521b451269007f03527c83645b8b935eb419 by Michael Stahl
didn't consider the case when nStop is 0, and startPos > 0. Then it
tried to get offset[-1].
Anyway, using value of startPos in those conditions seems illogical.
Removed those precautions (and made assertions for that).
Fixed handling zero indexes.
Change-Id: I2066abc51fff7fb7323bc7f6198bdea06439d4f3
Reviewed-on: https://gerrit.libreoffice.org/19840
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'i18npool/qa')
-rw-r--r-- | i18npool/qa/cppunit/test_textsearch.cxx | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/i18npool/qa/cppunit/test_textsearch.cxx b/i18npool/qa/cppunit/test_textsearch.cxx index a5713d00da70..50bab9a0036c 100644 --- a/i18npool/qa/cppunit/test_textsearch.cxx +++ b/i18npool/qa/cppunit/test_textsearch.cxx @@ -23,6 +23,7 @@ #include <com/sun/star/util/SearchOptions.hpp> #include <com/sun/star/util/SearchAlgorithms.hpp> #include <com/sun/star/util/XTextSearch.hpp> +#include <com/sun/star/i18n/Transliteration.hpp> #include <unotest/bootstrapfixturebase.hxx> #include <unicode/regex.h> @@ -122,6 +123,16 @@ void TestTextSearch::testSearches() CPPUNIT_ASSERT( aRes.subRegExpressions > 0 ); CPPUNIT_ASSERT( aRes.startOffset[0] == bStartRes ); CPPUNIT_ASSERT( aRes.endOffset[0] == bEndRes ); + + aOptions.transliterateFlags = ::css::i18n::TransliterationModules::TransliterationModules_IGNORE_CASE + | ::css::i18n::TransliterationModules::TransliterationModules_IGNORE_WIDTH; + aOptions.searchString = "([^ ]*)[ ]*([^ ]*)"; + m_xSearch->setOptions(aOptions); + aRes = m_xSearch->searchForward("11 22 33", 2, 7); + CPPUNIT_ASSERT(aRes.subRegExpressions == 3); + CPPUNIT_ASSERT((aRes.startOffset[0] == 2) && (aRes.endOffset[0] == 5)); + CPPUNIT_ASSERT((aRes.startOffset[1] == 2) && (aRes.endOffset[1] == 2)); + CPPUNIT_ASSERT((aRes.startOffset[2] == 3) && (aRes.endOffset[2] == 5)); } void TestTextSearch::setUp() |