summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2021-08-25 19:38:50 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2021-08-26 09:22:15 +0200
commitf7cf8f988c7c2856df5cb79fcbef22258cbce6db (patch)
tree6588c1bb7065542ae027d8a41ac41f7d33c62f91
parent36baacbf86f81de457af40a4a91b294136bf8ddc (diff)
tdf#144089: Revert "tdf#137737 i18n search: don't expand start/end with regex ^ or $"
This reverts commit a511bffd67a9cebfdc878766581ac08c79d7ff51. Reason for revert: See https://gerrit.libreoffice.org/c/core/+/120981 Change-Id: If8a445448976a9963f76623d3d968b8d5e3d74dd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120990 Tested-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121048 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org>
-rw-r--r--i18npool/source/search/textsearch.cxx4
-rw-r--r--sw/qa/extras/uiwriter/data/tdf137737_FindReplace.docxbin6541 -> 0 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx32
3 files changed, 2 insertions, 34 deletions
diff --git a/i18npool/source/search/textsearch.cxx b/i18npool/source/search/textsearch.cxx
index e6ddd93c5be6..dcb31762e6c2 100644
--- a/i18npool/source/search/textsearch.cxx
+++ b/i18npool/source/search/textsearch.cxx
@@ -333,7 +333,7 @@ SearchResult TextSearch::searchForward( const OUString& searchStr, sal_Int32 sta
// apply normal transliteration (1<->1, 1<->0)
sal_Int32 nInStartPos = startPos;
- if (pRegexMatcher && startPos > 0 && !aSrchPara.searchString.startsWith("^"))
+ if (pRegexMatcher && startPos > 0)
{
// tdf#89665, tdf#75806: An optimization to avoid transliterating the whole string, yet
// transliterate enough of the leading text to allow sensible look-behind assertions.
@@ -345,7 +345,7 @@ SearchResult TextSearch::searchForward( const OUString& searchStr, sal_Int32 sta
nInStartPos -= std::min(nMaxLeadingLen, startPos);
}
sal_Int32 nInEndPos = endPos;
- if (pRegexMatcher && endPos < searchStr.getLength() && !aSrchPara.searchString.endsWith("$"))
+ if (pRegexMatcher && endPos < searchStr.getLength())
{
// tdf#65038: ditto for look-ahead assertions
const sal_Int32 nMaxTrailingLen = aSrchPara.searchString.endsWith(")") ? 100 : 3;
diff --git a/sw/qa/extras/uiwriter/data/tdf137737_FindReplace.docx b/sw/qa/extras/uiwriter/data/tdf137737_FindReplace.docx
deleted file mode 100644
index 42914ce3feaa..000000000000
--- a/sw/qa/extras/uiwriter/data/tdf137737_FindReplace.docx
+++ /dev/null
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index b7d4f0242f31..c6c205a1d759 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -46,7 +46,6 @@
#include <xmloff/odffields.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/dispatch.hxx>
-#include <svl/srchitem.hxx>
#include <svl/stritem.hxx>
#include <comphelper/lok.hxx>
#include <comphelper/scopeguard.hxx>
@@ -3997,37 +3996,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf118311)
assertXPath(pXmlDoc, "//page[1]//body/tab", 0);
}
-CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf137737_FindReplace)
-{
- createSwDoc(DATA_DIRECTORY, "tdf137737_FindReplace.docx");
-
- // Replace staight quotes with something (opening quotes in real life, but X is adequate here)
- uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence({
- { "SearchItem.SearchString", uno::makeAny(OUString("^\"")) },
- { "SearchItem.ReplaceString", uno::makeAny(OUString("X")) },
- { "SearchItem.Command", uno::makeAny(static_cast<sal_Int16>(SvxSearchCmd::REPLACE)) },
- { "SearchItem.AlgorithmType", uno::makeAny(static_cast<sal_Int16>(1)) }, //REGEX
- { "SearchItem.AlgorithmType2", uno::makeAny(static_cast<sal_Int16>(2)) }, //REGEX
- }));
- // Find the first match.
- dispatchCommand(mxComponent, ".uno:ExecuteSearch", aArgs);
- // Replace the first match.
- dispatchCommand(mxComponent, ".uno:ExecuteSearch", aArgs);
-
- // Replace staight quotes with something (closing quotes in real life)
- aArgs[0].Value <<= OUString("\"$");
- dispatchCommand(mxComponent, ".uno:ExecuteSearch", aArgs);
- dispatchCommand(mxComponent, ".uno:ExecuteSearch", aArgs);
-
- //Finding the searched string via XReplaceable
- uno::Reference<util::XReplaceable> xReplace(mxComponent, uno::UNO_QUERY);
- uno::Reference<util::XReplaceDescriptor> xReplaceDes = xReplace->createReplaceDescriptor();
- xReplaceDes->setSearchString("\"");
- //There should not be any straight quotes left.
- uno::Reference<container::XIndexAccess> xIndex(xReplace->findAll(xReplaceDes));
- CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndex->getCount());
-}
-
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testRedlineTableRowDeletion)
{
// load a 1-row table, and delete the row with enabled change tracking: