include/i18nutil/searchopt.hxx         |  113 ++++++++++++++++-----------------
 include/svl/srchitem.hxx               |   13 ---
 include/unotools/textsearch.hxx        |    7 --
 include/vcl/textview.hxx               |    6 -
 include/vcl/xtextedt.hxx               |    4 -
 sfx2/source/doc/SfxRedactionHelper.cxx |    2 
 svl/source/items/srchitem.cxx          |   27 +++----
 sw/qa/core/macros-test.cxx             |    4 -
 sw/qa/extras/uiwriter/uiwriter7.cxx    |    3 
 sw/source/core/crsr/findtxt.cxx        |    6 -
 sw/source/core/edit/edtox.cxx          |    1 
 sw/source/core/unocore/unosrch.cxx     |    3 
 sw/source/ui/index/swuiidxmrk.cxx      |    1 
 sw/source/uibase/uiview/view2.cxx      |    2 
 unotools/source/i18n/textsearch.cxx    |   39 -----------
 vcl/source/edit/textview.cxx           |    4 -
 vcl/source/edit/xtextedt.cxx           |    6 -
 17 files changed, 85 insertions(+), 156 deletions(-)

New commits:
commit 67c807ada5d7930f262ace9798629c06f0175a86
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Jun 28 05:47:16 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Jun 28 11:06:54 2023 +0200

    Drop i18nutil::SearchOptions
    
    It was mostly unused by now, only remained in a couple of function
    arguments, where callers actually passed SearchOptions2, and where
    internally it was converted back to SearchOptions2.
    
    Change-Id: Ib188ec3bf0de6d1f70a04eb90fb3a577df8b3d98
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153687
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/include/i18nutil/searchopt.hxx b/include/i18nutil/searchopt.hxx
index c215da0d296f..0fd5f98676d4 100644
--- a/include/i18nutil/searchopt.hxx
+++ b/include/i18nutil/searchopt.hxx
@@ -22,6 +22,7 @@
 #include <sal/types.h>
 #include <com/sun/star/lang/Locale.hpp>
 #include <com/sun/star/util/SearchAlgorithms.hpp>
+#include <com/sun/star/util/SearchAlgorithms2.hpp>
 #include <com/sun/star/util/SearchOptions2.hpp>
 #include <i18nutil/transliteration.hxx>
 #include <utility>
@@ -29,12 +30,42 @@
 namespace i18nutil
 {
 
+inline constexpr css::util::SearchAlgorithms 
downgradeSearchAlgorithms2(sal_Int16 searchAlgorithms2)
+{
+    switch (searchAlgorithms2)
+    {
+        case css::util::SearchAlgorithms2::ABSOLUTE:
+            return css::util::SearchAlgorithms_ABSOLUTE;
+        case css::util::SearchAlgorithms2::REGEXP:
+            return css::util::SearchAlgorithms_REGEXP;
+        case css::util::SearchAlgorithms2::APPROXIMATE:
+            return css::util::SearchAlgorithms_APPROXIMATE;
+        default: // default what?
+        case css::util::SearchAlgorithms2::WILDCARD: // something valid
+            return css::util::SearchAlgorithms_ABSOLUTE;
+    }
+}
+
+inline constexpr sal_Int16 upgradeSearchAlgorithms(css::util::SearchAlgorithms 
searchAlgorithms)
+{
+    switch (searchAlgorithms)
+    {
+        default: // default what?
+        case css::util::SearchAlgorithms_ABSOLUTE:
+            return css::util::SearchAlgorithms2::ABSOLUTE;
+        case css::util::SearchAlgorithms_REGEXP:
+            return css::util::SearchAlgorithms2::REGEXP;
+        case css::util::SearchAlgorithms_APPROXIMATE:
+            return css::util::SearchAlgorithms2::APPROXIMATE;
+    }
+}
+
 /**
- * This is a wrapper around com::sun::star::util::SearchOptions
- * but using the more type-safe TransliterationFlags enum.
+ * This is a wrapper around com::sun::star::util::SearchOptions and 
SearchOptions2,
+ * but using the more type-safe TransliterationFlags enum, and without obsolete
+ * algorithmType, which is superseded by AlgorithmType2.
  */
-struct SAL_WARN_UNUSED SearchOptions {
-    css::util::SearchAlgorithms algorithmType;
+struct SAL_WARN_UNUSED SearchOptions2 {
     sal_Int32 searchFlag;
     OUString searchString;
     OUString replaceString;
@@ -44,9 +75,11 @@ struct SAL_WARN_UNUSED SearchOptions {
     sal_Int32 insertedChars;
     TransliterationFlags transliterateFlags;
 
-    SearchOptions& operator=(css::util::SearchOptions const & other)
+    sal_Int16 AlgorithmType2;
+    sal_Int32 WildcardEscapeCharacter;
+
+    SearchOptions2& operator=(css::util::SearchOptions2 const & other)
     {
-        algorithmType = other.algorithmType;
         searchFlag = other.searchFlag;
         searchString = other.searchString;
         replaceString = other.replaceString;
@@ -55,58 +88,14 @@ struct SAL_WARN_UNUSED SearchOptions {
         deletedChars = other.deletedChars;
         insertedChars = other.insertedChars;
         transliterateFlags = 
static_cast<TransliterationFlags>(other.transliterateFlags);
-        return *this;
-    }
-
-    SearchOptions()
-        : algorithmType(::css::util::SearchAlgorithms_ABSOLUTE)
-        , searchFlag(0)
-        , changedChars(0)
-        , deletedChars(0)
-        , insertedChars(0)
-        , transliterateFlags(TransliterationFlags::NONE)
-    {
-    }
-
-    SearchOptions(const css::util::SearchAlgorithms& algorithmType_, const 
sal_Int32 searchFlag_,
-                   OUString searchString_, OUString replaceString_,
-                   css::lang::Locale Locale_,
-                   const sal_Int32 changedChars_, const sal_Int32 
deletedChars_, const sal_Int32 insertedChars_,
-                   const TransliterationFlags& transliterateFlags_)
-        : algorithmType(algorithmType_)
-        , searchFlag(searchFlag_)
-        , searchString(std::move(searchString_))
-        , replaceString(std::move(replaceString_))
-        , Locale(std::move(Locale_))
-        , changedChars(changedChars_)
-        , deletedChars(deletedChars_)
-        , insertedChars(insertedChars_)
-        , transliterateFlags(transliterateFlags_)
-    {
-    }
-};
-
-/**
- * This is a wrapper around com::sun::star::util::SearchOptions and 
SearchOptions2,
- * but using the more type-safe TransliterationFlags enum.
- */
-struct SAL_WARN_UNUSED SearchOptions2 : public SearchOptions {
-
-    sal_Int16 AlgorithmType2;
-    sal_Int32 WildcardEscapeCharacter;
-
-    SearchOptions2& operator=(css::util::SearchOptions2 const & other)
-    {
-        SearchOptions::operator=(other);
         AlgorithmType2 = other.AlgorithmType2;
         WildcardEscapeCharacter = other.WildcardEscapeCharacter;
         return *this;
     }
 
-
     css::util::SearchOptions2 toUnoSearchOptions2() const
     {
-        return css::util::SearchOptions2(algorithmType, searchFlag,
+        return 
css::util::SearchOptions2(downgradeSearchAlgorithms2(AlgorithmType2), 
searchFlag,
                        searchString, replaceString,
                        Locale,
                        changedChars, deletedChars, insertedChars,
@@ -115,17 +104,29 @@ struct SAL_WARN_UNUSED SearchOptions2 : public 
SearchOptions {
     }
 
     SearchOptions2()
-        : AlgorithmType2(0)
+        : searchFlag(0)
+        , changedChars(0)
+        , deletedChars(0)
+        , insertedChars(0)
+        , transliterateFlags(TransliterationFlags::NONE)
+        , AlgorithmType2(0)
         , WildcardEscapeCharacter(0)
     {}
 
-    SearchOptions2(const css::util::SearchAlgorithms& algorithmType_, const 
sal_Int32 searchFlag_,
-                   const OUString& searchString_, const OUString& 
replaceString_,
-                   const css::lang::Locale& Locale_,
+    SearchOptions2(const sal_Int32 searchFlag_,
+                   OUString searchString_, OUString replaceString_,
+                   css::lang::Locale Locale_,
                    const sal_Int32 changedChars_, const sal_Int32 
deletedChars_, const sal_Int32 insertedChars_,
                    const TransliterationFlags& transliterateFlags_,
                    const sal_Int16 AlgorithmType2_, const sal_Int32 
WildcardEscapeCharacter_)
-        : SearchOptions(algorithmType_, searchFlag_, searchString_, 
replaceString_, Locale_, changedChars_, deletedChars_, insertedChars_, 
transliterateFlags_)
+        : searchFlag(searchFlag_)
+        , searchString(std::move(searchString_))
+        , replaceString(std::move(replaceString_))
+        , Locale(std::move(Locale_))
+        , changedChars(changedChars_)
+        , deletedChars(deletedChars_)
+        , insertedChars(insertedChars_)
+        , transliterateFlags(transliterateFlags_)
         , AlgorithmType2(AlgorithmType2_)
         , WildcardEscapeCharacter(WildcardEscapeCharacter_)
     {}
diff --git a/include/svl/srchitem.hxx b/include/svl/srchitem.hxx
index 7aa403211ed6..516677e6e75b 100644
--- a/include/svl/srchitem.hxx
+++ b/include/svl/srchitem.hxx
@@ -239,20 +239,11 @@ bool SvxSearchItem::GetSelection() const
 
 bool SvxSearchItem::GetRegExp() const
 {
-    // Ensure old and new algorithm types are in sync until all places are
-    // adapted to use only new types.
-    assert( (m_aSearchOpt.algorithmType == css::util::SearchAlgorithms_REGEXP) 
==
-            (m_aSearchOpt.AlgorithmType2 == 
css::util::SearchAlgorithms2::REGEXP));
     return m_aSearchOpt.AlgorithmType2 == css::util::SearchAlgorithms2::REGEXP 
;
 }
 
 bool SvxSearchItem::GetWildcard() const
 {
-    // Ensure old and new algorithm types are in sync, in this case old is not
-    // REGEXP or APPROXIMATE.
-    assert( m_aSearchOpt.AlgorithmType2 != 
css::util::SearchAlgorithms2::WILDCARD ||
-            (m_aSearchOpt.algorithmType != css::util::SearchAlgorithms_REGEXP 
&&
-             m_aSearchOpt.algorithmType != 
css::util::SearchAlgorithms_APPROXIMATE) );
     return m_aSearchOpt.AlgorithmType2 == 
css::util::SearchAlgorithms2::WILDCARD ;
 }
 
@@ -293,10 +284,6 @@ void SvxSearchItem::SetLEVLonger( sal_uInt16 nVal )
 
 bool SvxSearchItem::IsLevenshtein() const
 {
-    // Ensure old and new algorithm types are in sync until all places are
-    // adapted to use only new types.
-    assert( (m_aSearchOpt.algorithmType == 
css::util::SearchAlgorithms_APPROXIMATE) ==
-            (m_aSearchOpt.AlgorithmType2 == 
css::util::SearchAlgorithms2::APPROXIMATE));
     return m_aSearchOpt.AlgorithmType2 == 
css::util::SearchAlgorithms2::APPROXIMATE;
 }
 
diff --git a/include/unotools/textsearch.hxx b/include/unotools/textsearch.hxx
index 140200fec83f..b07d7d364801 100644
--- a/include/unotools/textsearch.hxx
+++ b/include/unotools/textsearch.hxx
@@ -209,13 +209,6 @@ public:
 
     /* replace back references in the replace string by the sub expressions 
from the search result */
     void ReplaceBackReferences( OUString& rReplaceStr, std::u16string_view 
rStr, const css::util::SearchResult& rResult ) const;
-
-    /** Upgrade SearchOptions to SearchOptions2 for places that don't handle
-        SearchOptions2 yet. Better fix your module if you want to support
-        wildcard search.
-     */
-    static i18nutil::SearchOptions2 UpgradeToSearchOptions2( const 
i18nutil::SearchOptions& rOptions );
-
 };
 
 }   // namespace utl
diff --git a/include/vcl/textview.hxx b/include/vcl/textview.hxx
index 903e1b4fae2a..84a89e8c58d8 100644
--- a/include/vcl/textview.hxx
+++ b/include/vcl/textview.hxx
@@ -41,7 +41,7 @@ namespace com::sun::star::datatransfer::clipboard {
     class XClipboard;
 }
 namespace i18nutil {
-    struct SearchOptions;
+    struct SearchOptions2;
 }
 
 
@@ -217,8 +217,8 @@ public:
     // tdf#49482: Moves the start of the PaM to the center of the textview
     void                CenterPaM( const TextPaM& rPaM );
 
-    bool                Search( const i18nutil::SearchOptions& rSearchOptions, 
bool bForward );
-    sal_uInt16          Replace( const i18nutil::SearchOptions& 
rSearchOptions, bool bAll, bool bForward );
+    bool                Search( const i18nutil::SearchOptions2& 
rSearchOptions, bool bForward );
+    sal_uInt16          Replace( const i18nutil::SearchOptions2& 
rSearchOptions, bool bAll, bool bForward );
 
     bool                IndentBlock();
     bool                UnindentBlock();
diff --git a/include/vcl/xtextedt.hxx b/include/vcl/xtextedt.hxx
index d9e06ddd8055..c15707dcac69 100644
--- a/include/vcl/xtextedt.hxx
+++ b/include/vcl/xtextedt.hxx
@@ -22,7 +22,7 @@
 #include <vcl/dllapi.h>
 #include <vcl/texteng.hxx>
 
-namespace i18nutil { struct SearchOptions; }
+namespace i18nutil { struct SearchOptions2; }
 
 class VCL_DLLPUBLIC ExtTextEngine final : public TextEngine
 {
@@ -31,7 +31,7 @@ public:
                         virtual ~ExtTextEngine() override;
 
     TextSelection       MatchGroup( const TextPaM& rCursor ) const;
-    bool                Search( TextSelection& rSel, const 
i18nutil::SearchOptions& rSearchOptions, bool bForward = true ) const;
+    bool                Search( TextSelection& rSel, const 
i18nutil::SearchOptions2& rSearchOptions, bool bForward = true ) const;
 };
 
 #endif // INCLUDED_VCL_XTEXTEDT_HXX
diff --git a/sfx2/source/doc/SfxRedactionHelper.cxx 
b/sfx2/source/doc/SfxRedactionHelper.cxx
index 73b8eab1d3d5..ced615899035 100644
--- a/sfx2/source/doc/SfxRedactionHelper.cxx
+++ b/sfx2/source/doc/SfxRedactionHelper.cxx
@@ -532,12 +532,10 @@ void 
SfxRedactionHelper::fillSearchOptions(i18nutil::SearchOptions2& rSearchOpt,
     if (rTarget.sType == RedactionTargetType::REDACTION_TARGET_REGEX
         || rTarget.sType == RedactionTargetType::REDACTION_TARGET_PREDEFINED)
     {
-        rSearchOpt.algorithmType = util::SearchAlgorithms_REGEXP;
         rSearchOpt.AlgorithmType2 = util::SearchAlgorithms2::REGEXP;
     }
     else
     {
-        rSearchOpt.algorithmType = util::SearchAlgorithms_ABSOLUTE;
         rSearchOpt.AlgorithmType2 = util::SearchAlgorithms2::ABSOLUTE;
     }
 
diff --git a/svl/source/items/srchitem.cxx b/svl/source/items/srchitem.cxx
index 1554f55efd3e..d3b2fad7c216 100644
--- a/svl/source/items/srchitem.cxx
+++ b/svl/source/items/srchitem.cxx
@@ -100,8 +100,7 @@ SvxSearchItem::SvxSearchItem( const sal_uInt16 nId ) :
     SfxPoolItem( nId ),
     ConfigItem( CFG_ROOT_NODE ),
 
-    m_aSearchOpt      ( SearchAlgorithms_ABSOLUTE,
-                        SearchFlags::LEV_RELAXED,
+    m_aSearchOpt      ( SearchFlags::LEV_RELAXED,
                         OUString(),
                         OUString(),
                         lang::Locale(),
@@ -135,17 +134,14 @@ SvxSearchItem::SvxSearchItem( const sal_uInt16 nId ) :
     if (aOpt.IsUseWildcard())
     {
         m_aSearchOpt.AlgorithmType2 = SearchAlgorithms2::WILDCARD;
-        m_aSearchOpt.algorithmType = SearchAlgorithms_ABSOLUTE; // something 
valid
     }
     if (aOpt.IsUseRegularExpression())
     {
         m_aSearchOpt.AlgorithmType2 = SearchAlgorithms2::REGEXP;
-        m_aSearchOpt.algorithmType = SearchAlgorithms_REGEXP;
     }
     if (aOpt.IsSimilaritySearch())
     {
         m_aSearchOpt.AlgorithmType2 = SearchAlgorithms2::APPROXIMATE;
-        m_aSearchOpt.algorithmType = SearchAlgorithms_APPROXIMATE;
     }
     if (aOpt.IsWholeWordsOnly())
         m_aSearchOpt.searchFlag |= SearchFlags::NORM_WORD_ONLY;
@@ -238,8 +234,7 @@ SvxSearchItem* SvxSearchItem::Clone( SfxItemPool *) const
 static bool equalsWithoutLocaleOrReplace(const i18nutil::SearchOptions2& 
rItem1,
                                          const i18nutil::SearchOptions2& 
rItem2)
 {
-    return rItem1.algorithmType         == rItem2.algorithmType &&
-           rItem1.searchFlag            == rItem2.searchFlag    &&
+    return rItem1.searchFlag            == rItem2.searchFlag    &&
            rItem1.searchString          == rItem2.searchString  &&
            //rItem1.replaceString       == rItem2.replaceString &&
            //rItem1.Locale              == rItem2.Locale        &&
@@ -353,12 +348,10 @@ void SvxSearchItem::SetRegExp( bool bVal )
     if ( bVal )
     {
         m_aSearchOpt.AlgorithmType2 = SearchAlgorithms2::REGEXP;
-        m_aSearchOpt.algorithmType = SearchAlgorithms_REGEXP;
     }
     else if ( SearchAlgorithms2::REGEXP == m_aSearchOpt.AlgorithmType2 )
     {
         m_aSearchOpt.AlgorithmType2 = SearchAlgorithms2::ABSOLUTE;
-        m_aSearchOpt.algorithmType = SearchAlgorithms_ABSOLUTE;
     }
 }
 
@@ -368,12 +361,10 @@ void SvxSearchItem::SetWildcard( bool bVal )
     if ( bVal )
     {
         m_aSearchOpt.AlgorithmType2 = SearchAlgorithms2::WILDCARD;
-        m_aSearchOpt.algorithmType = SearchAlgorithms_ABSOLUTE; // something 
valid
     }
     else if ( SearchAlgorithms2::REGEXP == m_aSearchOpt.AlgorithmType2 )
     {
         m_aSearchOpt.AlgorithmType2 = SearchAlgorithms2::ABSOLUTE;
-        m_aSearchOpt.algorithmType = SearchAlgorithms_ABSOLUTE;
     }
 }
 
@@ -392,12 +383,10 @@ void SvxSearchItem::SetLevenshtein( bool bVal )
     if ( bVal )
     {
         m_aSearchOpt.AlgorithmType2 = SearchAlgorithms2::APPROXIMATE;
-        m_aSearchOpt.algorithmType = SearchAlgorithms_APPROXIMATE;
     }
     else if ( SearchAlgorithms2::APPROXIMATE == m_aSearchOpt.AlgorithmType2 )
     {
         m_aSearchOpt.AlgorithmType2 = SearchAlgorithms2::ABSOLUTE;
-        m_aSearchOpt.algorithmType = SearchAlgorithms_ABSOLUTE;
     }
 }
 
@@ -460,7 +449,7 @@ bool SvxSearchItem::QueryValue( css::uno::Any& rVal, 
sal_uInt8 nMemberId ) const
         case MID_SEARCH_ASIANOPTIONS:
             rVal <<= m_bAsianOptions; break;
         case MID_SEARCH_ALGORITHMTYPE:
-            rVal <<= static_cast<sal_Int16>(m_aSearchOpt.algorithmType); break;
+            rVal <<= 
static_cast<sal_Int16>(i18nutil::downgradeSearchAlgorithms2(m_aSearchOpt.AlgorithmType2));
 break;
         case MID_SEARCH_ALGORITHMTYPE2:
             rVal <<= m_aSearchOpt.AlgorithmType2; break;
         case MID_SEARCH_FLAGS:
@@ -626,9 +615,15 @@ bool SvxSearchItem::PutValue( const css::uno::Any& rVal, 
sal_uInt8 nMemberId )
         case MID_SEARCH_ASIANOPTIONS:
             bRet = (rVal >>= m_bAsianOptions); break;
         case MID_SEARCH_ALGORITHMTYPE:
-            bRet = (rVal >>= nInt); m_aSearchOpt.algorithmType = 
static_cast<SearchAlgorithms>(static_cast<sal_Int16>(nInt)); break;
+            bRet = (rVal >>= nInt);
+            if (bRet)
+                m_aSearchOpt.AlgorithmType2 = 
i18nutil::upgradeSearchAlgorithms(static_cast<SearchAlgorithms>(static_cast<sal_Int16>(nInt)));
+            break;
         case MID_SEARCH_ALGORITHMTYPE2:
-            bRet = (rVal >>= nInt); m_aSearchOpt.AlgorithmType2 = 
static_cast<sal_Int16>(nInt); break;
+            bRet = (rVal >>= nInt);
+            if (bRet)
+                m_aSearchOpt.AlgorithmType2 = static_cast<sal_Int16>(nInt);
+            break;
         case MID_SEARCH_FLAGS:
             bRet = (rVal >>= m_aSearchOpt.searchFlag); break;
         case MID_SEARCH_SEARCHSTRING:
diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx
index 33511c471733..e79271ac764e 100644
--- a/sw/qa/core/macros-test.cxx
+++ b/sw/qa/core/macros-test.cxx
@@ -32,6 +32,7 @@
 #include <com/sun/star/text/TextContentAnchorType.hpp>
 #include <com/sun/star/text/XTextDocument.hpp>
 #include <com/sun/star/util/SearchAlgorithms2.hpp>
+#include <com/sun/star/util/SearchFlags.hpp>
 
 #include <i18nutil/searchopt.hxx>
 #include <comphelper/processfactory.hxx>
@@ -487,8 +488,7 @@ void SwMacrosTest::testFindReplace()
 
     bool bCancel(false);
     i18nutil::SearchOptions2 opts(
-            util::SearchAlgorithms_REGEXP,
-            65536,
+            css::util::SearchFlags::LEV_RELAXED,
             "$",
             "",
             lang::Locale("en", "US", ""),
diff --git a/sw/qa/extras/uiwriter/uiwriter7.cxx 
b/sw/qa/extras/uiwriter/uiwriter7.cxx
index c3b70c8cad08..9185f58bec56 100644
--- a/sw/qa/extras/uiwriter/uiwriter7.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter7.cxx
@@ -683,7 +683,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, 
testSearchWithTransliterate)
         pDoc->getIDocumentContentOperations().InsertString(aPaM, "This is 
Other PARAGRAPH");
     }
     i18nutil::SearchOptions2 SearchOpt;
-    SearchOpt.algorithmType = css::util::SearchAlgorithms_ABSOLUTE;
     SearchOpt.searchFlag = css::util::SearchFlags::ALL_IGNORE_CASE;
     SearchOpt.searchString = "other";
     SearchOpt.replaceString.clear();
@@ -727,8 +726,8 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf73660)
     pWrtShell->Insert("Now we have enough text let's test search for all the 
cases");
     //searching for all 5 strings entered with soft-hyphen, search string 
contains no soft-hyphen
     i18nutil::SearchOptions2 searchOpt;
-    searchOpt.algorithmType = css::util::SearchAlgorithms_REGEXP;
     searchOpt.searchFlag = css::util::SearchFlags::NORM_WORD_ONLY;
+    searchOpt.AlgorithmType2 = css::util::SearchAlgorithms2::REGEXP;
     //case 1
     searchOpt.searchString = "First";
     CPPUNIT_ASSERT_EQUAL(
diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx
index 498a89054880..d3694f6e0fd8 100644
--- a/sw/source/core/crsr/findtxt.cxx
+++ b/sw/source/core/crsr/findtxt.cxx
@@ -803,7 +803,7 @@ bool DoSearch(SwPaM & rSearchPam,
                 {
                     const lang::Locale aLocale(
                             g_pBreakIt->GetLocale( eCurrLang ) );
-                    rSText.SetLocale( 
utl::TextSearch::UpgradeToSearchOptions2( rSearchOpt), aLocale );
+                    rSText.SetLocale(rSearchOpt, aLocale);
                     eLastLang = eCurrLang;
                 }
             }
@@ -924,7 +924,7 @@ struct SwFindParaText : public SwFindParas
         : m_rSearchOpt( rOpt )
         , m_rCursor( rCursor )
         , m_pLayout(pLayout)
-        , m_aSText( utl::TextSearch::UpgradeToSearchOptions2(rOpt) )
+        , m_aSText(rOpt)
         , m_bReplace( bRepl )
         , m_bSearchInNotes( bSearchInNotes )
     {}
@@ -1127,7 +1127,7 @@ std::optional<OUString> ReplaceBackReferences(const 
i18nutil::SearchOptions2& rS
                 ? sw::FrameContainsNode(*pFrame, 
pPam->GetMark()->GetNodeIndex())
                 : pTextNode == pMarkTextNode))
         {
-            utl::TextSearch aSText( utl::TextSearch::UpgradeToSearchOptions2( 
rSearchOpt) );
+            utl::TextSearch aSText(rSearchOpt);
             SearchResult aResult;
             OUString aReplaceStr( rSearchOpt.replaceString );
             if (bParaEnd)
diff --git a/sw/source/core/edit/edtox.cxx b/sw/source/core/edit/edtox.cxx
index 655a6dfd0174..602224c80efd 100644
--- a/sw/source/core/edit/edtox.cxx
+++ b/sw/source/core/edit/edtox.cxx
@@ -306,7 +306,6 @@ void SwEditShell::ApplyAutoMark()
         sal_Int32 const nLEV_Shorter  = 1;    //! -> insertedChars;
 
         i18nutil::SearchOptions2 aSearchOpt(
-                            SearchAlgorithms_ABSOLUTE,
                             SearchFlags::LEV_RELAXED,
                             "", "",
                             SvtSysLocale().GetLanguageTag().getLocale(),
diff --git a/sw/source/core/unocore/unosrch.cxx 
b/sw/source/core/unocore/unosrch.cxx
index 096e4f8fca57..f4ec332be90b 100644
--- a/sw/source/core/unocore/unosrch.cxx
+++ b/sw/source/core/unocore/unosrch.cxx
@@ -569,7 +569,6 @@ void SwXTextSearch::FillSearchOptions( 
i18nutil::SearchOptions2& rSearchOpt ) co
 {
     if( m_bSimilarity )
     {
-        rSearchOpt.algorithmType = util::SearchAlgorithms_APPROXIMATE;
         rSearchOpt.AlgorithmType2 = util::SearchAlgorithms2::APPROXIMATE;
         rSearchOpt.changedChars = m_nLevExchange;
         rSearchOpt.deletedChars = m_nLevRemove;
@@ -579,12 +578,10 @@ void SwXTextSearch::FillSearchOptions( 
i18nutil::SearchOptions2& rSearchOpt ) co
     }
     else if( m_bExpr )
     {
-        rSearchOpt.algorithmType = util::SearchAlgorithms_REGEXP;
         rSearchOpt.AlgorithmType2 = util::SearchAlgorithms2::REGEXP;
     }
     else
     {
-        rSearchOpt.algorithmType = util::SearchAlgorithms_ABSOLUTE;
         rSearchOpt.AlgorithmType2 = util::SearchAlgorithms2::ABSOLUTE;
     }
 
diff --git a/sw/source/ui/index/swuiidxmrk.cxx 
b/sw/source/ui/index/swuiidxmrk.cxx
index 140b4e48d0a0..52904b73d68e 100644
--- a/sw/source/ui/index/swuiidxmrk.cxx
+++ b/sw/source/ui/index/swuiidxmrk.cxx
@@ -498,7 +498,6 @@ static void lcl_SelectSameStrings(SwWrtShell& rSh, bool 
bWordOnly, bool bCaseSen
     rSh.Push();
 
     i18nutil::SearchOptions2 aSearchOpt(
-                        SearchAlgorithms_ABSOLUTE,
                         ( bWordOnly ? SearchFlags::NORM_WORD_ONLY : 0 ),
                         rSh.GetSelText(), OUString(),
                         GetAppLanguageTag().getLocale(),
diff --git a/sw/source/uibase/uiview/view2.cxx 
b/sw/source/uibase/uiview/view2.cxx
index ed0982f037dc..ccc1a32dd4de 100644
--- a/sw/source/uibase/uiview/view2.cxx
+++ b/sw/source/uibase/uiview/view2.cxx
@@ -2611,7 +2611,7 @@ bool SwView::JumpToSwMark( std::u16string_view rMark )
                 m_pWrtShell->EnterStdMode();
 
                 i18nutil::SearchOptions2 aSearchOpt(
-                                    SearchAlgorithms_ABSOLUTE, 0,
+                                    0,
                                     sName, OUString(),
                                     
SvtSysLocale().GetLanguageTag().getLocale(),
                                     0,0,0,
diff --git a/unotools/source/i18n/textsearch.cxx 
b/unotools/source/i18n/textsearch.cxx
index b7f104895f8c..f61aeaf1a2a7 100644
--- a/unotools/source/i18n/textsearch.cxx
+++ b/unotools/source/i18n/textsearch.cxx
@@ -75,7 +75,6 @@ static bool lcl_Equals( const i18nutil::SearchOptions2& rSO1, 
const i18nutil::Se
     return
         rSO1.AlgorithmType2 == rSO2.AlgorithmType2 &&
         rSO1.WildcardEscapeCharacter == rSO2.WildcardEscapeCharacter &&
-        rSO1.algorithmType == rSO2.algorithmType &&
         rSO1.searchFlag == rSO2.searchFlag &&
         rSO1.searchString == rSO2.searchString &&
         rSO1.replaceString == rSO2.replaceString &&
@@ -134,41 +133,6 @@ TextSearch::TextSearch( const i18nutil::SearchOptions2& 
rPara )
     xTextSearch = getXTextSearch( rPara );
 }
 
-i18nutil::SearchOptions2 TextSearch::UpgradeToSearchOptions2( const 
i18nutil::SearchOptions& rOptions )
-{
-    sal_Int16 nAlgorithmType2;
-    switch (rOptions.algorithmType)
-    {
-        case SearchAlgorithms_REGEXP:
-            nAlgorithmType2 = SearchAlgorithms2::REGEXP;
-            break;
-        case SearchAlgorithms_APPROXIMATE:
-            nAlgorithmType2 = SearchAlgorithms2::APPROXIMATE;
-            break;
-        case SearchAlgorithms_ABSOLUTE:
-            nAlgorithmType2 = SearchAlgorithms2::ABSOLUTE;
-            break;
-        default:
-            for (;;) std::abort();
-    }
-    // It would be nice if an inherited struct had a ctor that takes an
-    // instance of the object the struct derived from...
-    i18nutil::SearchOptions2 aOptions2(
-            rOptions.algorithmType,
-            rOptions.searchFlag,
-            rOptions.searchString,
-            rOptions.replaceString,
-            rOptions.Locale,
-            rOptions.changedChars,
-            rOptions.deletedChars,
-            rOptions.insertedChars,
-            rOptions.transliterateFlags,
-            nAlgorithmType2,
-            0       // no wildcard search, no escape character...
-            );
-    return aOptions2;
-}
-
 void TextSearch::Init( const SearchParam & rParam,
                         const css::lang::Locale& rLocale )
 {
@@ -179,7 +143,6 @@ void TextSearch::Init( const SearchParam & rParam,
     {
     case SearchParam::SearchType::Wildcard:
         aSOpt.AlgorithmType2 = SearchAlgorithms2::WILDCARD;
-        aSOpt.algorithmType = 
SearchAlgorithms::SearchAlgorithms_MAKE_FIXED_SIZE;    // no old enum for that
         aSOpt.WildcardEscapeCharacter = rParam.GetWildEscChar();
         if (rParam.IsWildMatchSel())
             aSOpt.searchFlag |= SearchFlags::WILD_MATCH_SELECTION;
@@ -187,12 +150,10 @@ void TextSearch::Init( const SearchParam & rParam,
 
     case SearchParam::SearchType::Regexp:
         aSOpt.AlgorithmType2 = SearchAlgorithms2::REGEXP;
-        aSOpt.algorithmType = SearchAlgorithms_REGEXP;
         break;
 
     case SearchParam::SearchType::Normal:
         aSOpt.AlgorithmType2 = SearchAlgorithms2::ABSOLUTE;
-        aSOpt.algorithmType = SearchAlgorithms_ABSOLUTE;
         break;
 
     default:
diff --git a/vcl/source/edit/textview.cxx b/vcl/source/edit/textview.cxx
index 128db7f7b088..ad1d28d1997b 100644
--- a/vcl/source/edit/textview.cxx
+++ b/vcl/source/edit/textview.cxx
@@ -2071,7 +2071,7 @@ void TextView::CenterPaM( const TextPaM& rPaM )
     Scroll(0, (nVisStartY + nVisEndY) / 2 - aRect.TopLeft().getY());
 }
 
-bool TextView::Search( const i18nutil::SearchOptions& rSearchOptions, bool 
bForward )
+bool TextView::Search( const i18nutil::SearchOptions2& rSearchOptions, bool 
bForward )
 {
     bool bFound = false;
     TextSelection aSel( GetSelection() );
@@ -2099,7 +2099,7 @@ bool TextView::Search( const i18nutil::SearchOptions& 
rSearchOptions, bool bForw
     return bFound;
 }
 
-sal_uInt16 TextView::Replace( const i18nutil::SearchOptions& rSearchOptions, 
bool bAll, bool bForward )
+sal_uInt16 TextView::Replace( const i18nutil::SearchOptions2& rSearchOptions, 
bool bAll, bool bForward )
 {
     sal_uInt16 nFound = 0;
 
diff --git a/vcl/source/edit/xtextedt.cxx b/vcl/source/edit/xtextedt.cxx
index 106ad69bf425..87097a5be27b 100644
--- a/vcl/source/edit/xtextedt.cxx
+++ b/vcl/source/edit/xtextedt.cxx
@@ -137,7 +137,7 @@ TextSelection ExtTextEngine::MatchGroup( const TextPaM& 
rCursor ) const
     return aSel;
 }
 
-bool ExtTextEngine::Search( TextSelection& rSel, const 
i18nutil::SearchOptions& rSearchOptions, bool bForward ) const
+bool ExtTextEngine::Search( TextSelection& rSel, const 
i18nutil::SearchOptions2& rSearchOptions, bool bForward ) const
 {
     TextSelection aSel( rSel );
     aSel.Justify();
@@ -160,9 +160,9 @@ bool ExtTextEngine::Search( TextSelection& rSel, const 
i18nutil::SearchOptions&
 
     const sal_uInt32 nStartNode = aStartPaM.GetPara();
 
-    i18nutil::SearchOptions aOptions( rSearchOptions );
+    i18nutil::SearchOptions2 aOptions( rSearchOptions );
     aOptions.Locale = Application::GetSettings().GetLanguageTag().getLocale();
-    utl::TextSearch aSearcher( 
utl::TextSearch::UpgradeToSearchOptions2(aOptions) );
+    utl::TextSearch aSearcher(aOptions);
 
     // iterate over the paragraphs
     for ( sal_uInt32 nNode = nStartNode;

Reply via email to