summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--basic/source/runtime/runtime.cxx2
-rw-r--r--cui/source/options/optaboutconfig.cxx2
-rw-r--r--editeng/source/editeng/impedit4.cxx2
-rw-r--r--forms/source/xforms/computedexpression.cxx2
-rw-r--r--i18npool/source/search/i18nsearch.component1
-rw-r--r--i18npool/source/search/textsearch.cxx68
-rw-r--r--i18npool/source/search/textsearch.hxx15
-rw-r--r--include/unotools/textsearch.hxx23
-rw-r--r--reportdesign/source/ui/inspection/GeometryHandler.cxx6
-rw-r--r--sc/source/core/data/table6.cxx2
-rw-r--r--svx/source/form/fmsrcimp.cxx2
-rw-r--r--sw/source/core/crsr/findattr.cxx2
-rw-r--r--sw/source/core/crsr/findtxt.cxx7
-rw-r--r--unotools/source/i18n/textsearch.cxx78
-rw-r--r--vcl/source/edit/xtextedt.cxx2
15 files changed, 161 insertions, 53 deletions
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 65351188302e..e92c0a134a56 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -1569,7 +1569,7 @@ void SbiRuntime::StepLIKE()
aSearchOpt.transliterateFlags |= css::i18n::TransliterationModules_IGNORE_CASE;
}
SbxVariable* pRes = new SbxVariable;
- utl::TextSearch aSearch(aSearchOpt);
+ utl::TextSearch aSearch( utl::TextSearch::UpgradeToSearchOptions2( aSearchOpt));
sal_Int32 nStart=0, nEnd=value.getLength();
bool bRes = aSearch.SearchForward(value, &nStart, &nEnd);
pRes->PutBool( bRes );
diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx
index bf596513261a..85dc3f82f243 100644
--- a/cui/source/options/optaboutconfig.cxx
+++ b/cui/source/options/optaboutconfig.cxx
@@ -833,7 +833,7 @@ IMPL_LINK_NOARG_TYPED( CuiAboutConfigTabPage, SearchHdl_Impl, Button*, void)
else
{
m_options.searchString = m_pSearchEdit->GetText();
- utl::TextSearch textSearch( m_options );
+ utl::TextSearch textSearch( utl::TextSearch::UpgradeToSearchOptions2( m_options) );
for (auto const& it : m_prefBoxEntries)
{
sal_Int32 endPos, startPos = 0;
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 3a57c5dfb709..6544d80e2f17 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -2622,7 +2622,7 @@ bool ImpEditEngine::ImpSearch( const SvxSearchItem& rSearchItem,
nEndNode = bBack ? 0 : aEditDoc.Count()-1;
}
- utl::TextSearch aSearcher( aSearchOptions );
+ utl::TextSearch aSearcher( utl::TextSearch::UpgradeToSearchOptions2( aSearchOptions) );
// iterate over the paragraphs ...
for ( sal_Int32 nNode = nStartNode;
diff --git a/forms/source/xforms/computedexpression.cxx b/forms/source/xforms/computedexpression.cxx
index 08fc7511f460..34329860358d 100644
--- a/forms/source/xforms/computedexpression.cxx
+++ b/forms/source/xforms/computedexpression.cxx
@@ -91,7 +91,7 @@ bool ComputedExpression::_checkExpression( const sal_Char* pExpression ) const
SearchOptions aSearchOptions;
aSearchOptions.algorithmType = SearchAlgorithms_REGEXP;
aSearchOptions.searchString = OUString( pExpression, strlen(pExpression), RTL_TEXTENCODING_ASCII_US );
- utl::TextSearch aTextSearch( aSearchOptions );
+ utl::TextSearch aTextSearch( utl::TextSearch::UpgradeToSearchOptions2( aSearchOptions) );
sal_Int32 nLength = msExpression.getLength();
sal_Int32 nStart = 0;
diff --git a/i18npool/source/search/i18nsearch.component b/i18npool/source/search/i18nsearch.component
index 93bf92db6aad..ddb591f98b5f 100644
--- a/i18npool/source/search/i18nsearch.component
+++ b/i18npool/source/search/i18nsearch.component
@@ -21,5 +21,6 @@
prefix="i18nsearch" xmlns="http://openoffice.org/2010/uno-components">
<implementation name="com.sun.star.util.TextSearch_i18n">
<service name="com.sun.star.util.TextSearch"/>
+ <service name="com.sun.star.util.TextSearch2"/>
</implementation>
</component>
diff --git a/i18npool/source/search/textsearch.cxx b/i18npool/source/search/textsearch.cxx
index 57a995ee421f..d0e13e5d94fc 100644
--- a/i18npool/source/search/textsearch.cxx
+++ b/i18npool/source/search/textsearch.cxx
@@ -24,6 +24,7 @@
#include <comphelper/processfactory.hxx>
#include <com/sun/star/i18n/BreakIterator.hpp>
#include <com/sun/star/i18n/UnicodeType.hpp>
+#include <com/sun/star/util/SearchAlgorithms2.hpp>
#include <com/sun/star/util/SearchFlags.hpp>
#include <com/sun/star/i18n/WordType.hpp>
#include <com/sun/star/i18n/ScriptType.hpp>
@@ -112,7 +113,8 @@ TextSearch::TextSearch(const Reference < XComponentContext > & rxContext)
, pRegexMatcher( nullptr )
, pWLD( nullptr )
{
- SearchOptions aOpt;
+ SearchOptions2 aOpt;
+ aOpt.AlgorithmType2 = SearchAlgorithms2::ABSOLUTE;
aOpt.algorithmType = SearchAlgorithms_ABSOLUTE;
aOpt.searchFlag = SearchFlags::ALL_IGNORE_CASE;
//aOpt.Locale = ???;
@@ -127,7 +129,7 @@ TextSearch::~TextSearch()
delete pJumpTable2;
}
-void TextSearch::setOptions( const SearchOptions& rOptions ) throw( RuntimeException, std::exception )
+void TextSearch::setOptions2( const SearchOptions2& rOptions ) throw( RuntimeException, std::exception )
{
aSrchPara = rOptions;
@@ -165,7 +167,7 @@ void TextSearch::setOptions( const SearchOptions& rOptions ) throw( RuntimeExcep
sSrchStr = aSrchPara.searchString;
// Transliterate search string.
- if (aSrchPara.algorithmType == SearchAlgorithms_REGEXP)
+ if (aSrchPara.AlgorithmType2 == SearchAlgorithms2::REGEXP)
{
if (isSimpleRegexTrans( aSrchPara.transliterateFlags))
{
@@ -212,15 +214,17 @@ void TextSearch::setOptions( const SearchOptions& rOptions ) throw( RuntimeExcep
checkCTLEnd = (xBreak.is() && (xBreak->getScriptType(sSrchStr,
sSrchStr.getLength()-1) == ScriptType::COMPLEX));
- switch( aSrchPara.algorithmType)
+ // Take the new SearchOptions2::AlgorithmType2 field and ignore
+ // SearchOptions::algorithmType
+ switch( aSrchPara.AlgorithmType2)
{
- case SearchAlgorithms_REGEXP:
+ case SearchAlgorithms2::REGEXP:
fnForward = &TextSearch::RESrchFrwrd;
fnBackward = &TextSearch::RESrchBkwrd;
RESrchPrepare( aSrchPara);
break;
- case SearchAlgorithms_APPROXIMATE:
+ case SearchAlgorithms2::APPROXIMATE:
fnForward = &TextSearch::ApproxSrchFrwrd;
fnBackward = &TextSearch::ApproxSrchBkwrd;
@@ -232,12 +236,51 @@ void TextSearch::setOptions( const SearchOptions& rOptions ) throw( RuntimeExcep
break;
default:
+ case SearchAlgorithms2::WILDCARD: /* FIXME: temporary */
+ SAL_WARN("i18npool","TextSearch::setOptions2 - default what?");
+ // fallthru
+ case SearchAlgorithms2::ABSOLUTE:
fnForward = &TextSearch::NSrchFrwrd;
fnBackward = &TextSearch::NSrchBkwrd;
break;
}
}
+void TextSearch::setOptions( const SearchOptions& rOptions ) throw( RuntimeException, std::exception )
+{
+ sal_Int16 nAlgorithmType2;
+ switch (rOptions.algorithmType)
+ {
+ case SearchAlgorithms_REGEXP:
+ nAlgorithmType2 = SearchAlgorithms2::REGEXP;
+ break;
+ case SearchAlgorithms_APPROXIMATE:
+ nAlgorithmType2 = SearchAlgorithms2::APPROXIMATE;
+ break;
+ default:
+ SAL_WARN("i18npool","TextSearch::setOptions - default what?");
+ // fallthru
+ case SearchAlgorithms_ABSOLUTE:
+ nAlgorithmType2 = SearchAlgorithms2::ABSOLUTE;
+ break;
+ }
+ // It would be nice if an inherited struct had a ctor that takes an
+ // instance of the object the struct derived from..
+ SearchOptions2 aOptions2(
+ rOptions.algorithmType,
+ rOptions.searchFlag,
+ rOptions.searchString,
+ rOptions.replaceString,
+ rOptions.Locale,
+ rOptions.changedChars,
+ rOptions.deletedChars,
+ rOptions.insertedChars,
+ rOptions.transliterateFlags,
+ nAlgorithmType2
+ );
+ setOptions2( aOptions2);
+}
+
sal_Int32 FindPosInSeq_Impl( const Sequence <sal_Int32>& rOff, sal_Int32 nPos )
{
sal_Int32 nRet = 0, nEnd = rOff.getLength();
@@ -325,7 +368,7 @@ SearchResult TextSearch::searchForward( const OUString& searchStr, sal_Int32 sta
sres = (this->*fnForward)( in_str, startPos, endPos );
}
- if ( xTranslit2.is() && aSrchPara.algorithmType != SearchAlgorithms_REGEXP)
+ if ( xTranslit2.is() && aSrchPara.AlgorithmType2 != SearchAlgorithms2::REGEXP)
{
SearchResult sres2;
@@ -432,7 +475,7 @@ SearchResult TextSearch::searchBackward( const OUString& searchStr, sal_Int32 st
sres = (this->*fnBackward)( in_str, startPos, endPos );
}
- if ( xTranslit2.is() && aSrchPara.algorithmType != SearchAlgorithms_REGEXP )
+ if ( xTranslit2.is() && aSrchPara.AlgorithmType2 != SearchAlgorithms2::REGEXP )
{
SearchResult sres2;
@@ -776,7 +819,7 @@ SearchResult TextSearch::NSrchBkwrd( const OUString& searchStr, sal_Int32 startP
return aRet;
}
-void TextSearch::RESrchPrepare( const css::util::SearchOptions& rOptions)
+void TextSearch::RESrchPrepare( const css::util::SearchOptions2& rOptions)
{
// select the transliterated pattern string
const OUString& rPatternStr =
@@ -1080,9 +1123,12 @@ SearchResult TextSearch::ApproxSrchBkwrd( const OUString& searchStr,
static const sal_Char cSearchImpl[] = "com.sun.star.util.TextSearch_i18n";
-static OUString getServiceName_Static()
+static uno::Sequence< OUString > getServiceName_Static()
{
- return OUString( "com.sun.star.util.TextSearch" );
+ uno::Sequence< OUString > aRet(2);
+ aRet[0] = "com.sun.star.util.TextSearch";
+ aRet[1] = "com.sun.star.util.TextSearch2";
+ return aRet;
}
static OUString getImplementationName_Static()
diff --git a/i18npool/source/search/textsearch.hxx b/i18npool/source/search/textsearch.hxx
index 5c2ef0312290..ae189c29df63 100644
--- a/i18npool/source/search/textsearch.hxx
+++ b/i18npool/source/search/textsearch.hxx
@@ -21,7 +21,7 @@
#define INCLUDED_I18NPOOL_SOURCE_SEARCH_TEXTSEARCH_HXX
#include <cppuhelper/implbase.hxx>
-#include <com/sun/star/util/XTextSearch.hpp>
+#include <com/sun/star/util/XTextSearch2.hpp>
#include <com/sun/star/i18n/XBreakIterator.hpp>
#include <com/sun/star/i18n/XExtendedTransliteration.hpp>
#include <com/sun/star/i18n/XCharacterClassification.hpp>
@@ -39,13 +39,13 @@ typedef ::std::map< sal_Unicode, sal_Int32 > TextSearchJumpTable;
class TextSearch: public cppu::WeakImplHelper
<
- css::util::XTextSearch,
+ css::util::XTextSearch2,
css::lang::XServiceInfo
>
{
css::uno::Reference < css::uno::XComponentContext > m_xContext;
- css::util::SearchOptions aSrchPara;
+ css::util::SearchOptions2 aSrchPara;
OUString sSrchStr;
OUString sSrchStr2;
@@ -91,7 +91,7 @@ class TextSearch: public cppu::WeakImplHelper
RESrchBkwrd( const OUString& searchStr,
sal_Int32 startPos, sal_Int32 endPos )
throw(css::uno::RuntimeException);
- void RESrchPrepare( const css::util::SearchOptions&);
+ void RESrchPrepare( const css::util::SearchOptions2&);
// Members and methods for the "Weight Levenshtein-Distance" search
int nLimit;
@@ -118,7 +118,7 @@ public:
virtual ~TextSearch();
- // Methods
+ // XTextSearch
virtual void SAL_CALL
setOptions( const css::util::SearchOptions& options )
throw(css::uno::RuntimeException, std::exception) override;
@@ -131,6 +131,11 @@ public:
sal_Int32 startPos, sal_Int32 endPos )
throw(css::uno::RuntimeException, std::exception) override;
+ // XTextSearch2
+ virtual void SAL_CALL
+ setOptions2( const css::util::SearchOptions2& options )
+ throw(css::uno::RuntimeException, std::exception) override;
+
//XServiceInfo
virtual OUString SAL_CALL getImplementationName()
throw( css::uno::RuntimeException, std::exception ) override;
diff --git a/include/unotools/textsearch.hxx b/include/unotools/textsearch.hxx
index 20c9e65d261c..7ddfbf0ed4e8 100644
--- a/include/unotools/textsearch.hxx
+++ b/include/unotools/textsearch.hxx
@@ -25,8 +25,8 @@
#include <rtl/ustring.hxx>
#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/lang/Locale.hpp>
-#include <com/sun/star/util/XTextSearch.hpp>
-#include <com/sun/star/util/SearchOptions.hpp>
+#include <com/sun/star/util/XTextSearch2.hpp>
+#include <com/sun/star/util/SearchOptions2.hpp>
class CharClass;
@@ -47,7 +47,7 @@ namespace utl
class UNOTOOLS_DLLPUBLIC SearchParam
{
public:
- enum SearchType{ SRCH_NORMAL, SRCH_REGEXP, SRCH_LEVDIST };
+ enum SearchType{ SRCH_NORMAL, SRCH_REGEXP, SRCH_LEVDIST, SRCH_WILDCARD };
private:
OUString sSrchStr; // the search string
@@ -100,15 +100,16 @@ public:
// - ordinary text (Bayer/Moore)
// - regular expressions
// - weighted Levenshtein distance
+// - wildcards '*' and '?'
// This class allows forward and backward searching!
class UNOTOOLS_DLLPUBLIC TextSearch
{
- static css::uno::Reference< css::util::XTextSearch >
- getXTextSearch( const css::util::SearchOptions& rPara );
+ static css::uno::Reference< css::util::XTextSearch2 >
+ getXTextSearch( const css::util::SearchOptions2& rPara );
- css::uno::Reference < css::util::XTextSearch >
+ css::uno::Reference < css::util::XTextSearch2 >
xTextSearch;
void Init( const SearchParam & rParam,
@@ -120,7 +121,7 @@ public:
TextSearch( const SearchParam & rPara, LanguageType nLanguage );
TextSearch( const SearchParam & rPara, const CharClass& rCClass );
- TextSearch( const css::util::SearchOptions& rPara );
+ TextSearch( const css::util::SearchOptions2& rPara );
~TextSearch();
/* search in the (selected) text the search string:
@@ -149,12 +150,18 @@ public:
sal_Int32* pStart, sal_Int32* pEnd,
css::util::SearchResult* pRes = nullptr );
- void SetLocale( const css::util::SearchOptions& rOpt,
+ void SetLocale( const css::util::SearchOptions2& rOpt,
const css::lang::Locale& rLocale );
/* replace back references in the replace string by the sub expressions from the search result */
void ReplaceBackReferences( OUString& rReplaceStr, const OUString &rStr, const css::util::SearchResult& rResult );
+ /** Upgrade SearchOptions to SearchOptions2 for places that don't handle
+ SearchOptions2 yet. Better fix your module if you want to support
+ wildcard search.
+ */
+ static css::util::SearchOptions2 UpgradeToSearchOptions2( const css::util::SearchOptions& rOptions );
+
};
} // namespace utl
diff --git a/reportdesign/source/ui/inspection/GeometryHandler.cxx b/reportdesign/source/ui/inspection/GeometryHandler.cxx
index c234c0f0a55b..da2521782993 100644
--- a/reportdesign/source/ui/inspection/GeometryHandler.cxx
+++ b/reportdesign/source/ui/inspection/GeometryHandler.cxx
@@ -1858,13 +1858,13 @@ bool GeometryHandler::impl_isDefaultFunction_nothrow( const uno::Reference< repo
for (; aIter != aDeEnd; ++aIter)
{
aSearchOptions.searchString = aIter->m_sSearchString;
- utl::TextSearch aTextSearch(aSearchOptions);
+ utl::TextSearch aTextSearch( utl::TextSearch::UpgradeToSearchOptions2( aSearchOptions));
sal_Int32 start = 0;
sal_Int32 end = sFormula.getLength();
if ( aTextSearch.SearchForward(sFormula,&start,&end) && start == 0 && end == sFormula.getLength()) // default function found
{
aSearchOptions.searchString = "\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]";
- utl::TextSearch aDataSearch(aSearchOptions);
+ utl::TextSearch aDataSearch( utl::TextSearch::UpgradeToSearchOptions2( aSearchOptions));
aDataSearch.SearchForward(sFormula,&start,&end );
++start;
_rDataField = sFormula.copy(start,end-start-1);
@@ -2075,7 +2075,7 @@ bool GeometryHandler::impl_isCounterFunction_throw(const OUString& _sQuotedFunct
aSearchOptions.algorithmType = util::SearchAlgorithms_REGEXP;
aSearchOptions.searchFlag = 0x00000100;
aSearchOptions.searchString = m_aCounterFunction.m_sSearchString;
- utl::TextSearch aTextSearch(aSearchOptions);
+ utl::TextSearch aTextSearch( utl::TextSearch::UpgradeToSearchOptions2( aSearchOptions));
sal_Int32 start = 0;
sal_Int32 end = sFormula.getLength();
if ( aTextSearch.SearchForward(sFormula,&start,&end) && start == 0 && end == sFormula.getLength()) // counter function found
diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx
index 512bbd3e01d8..d99fa4258289 100644
--- a/sc/source/core/data/table6.cxx
+++ b/sc/source/core/data/table6.cxx
@@ -744,7 +744,7 @@ bool ScTable::SearchAndReplace(
( css::i18n::TransliterationModules_IGNORE_CASE |
css::i18n::TransliterationModules_IGNORE_WIDTH );
- pSearchText = new utl::TextSearch( aSearchOptions );
+ pSearchText = new utl::TextSearch( utl::TextSearch::UpgradeToSearchOptions2( aSearchOptions) );
if (nCommand == SvxSearchCmd::FIND)
bFound = Search(rSearchItem, rCol, rRow, rMark, rUndoStr, pUndoDoc);
diff --git a/svx/source/form/fmsrcimp.cxx b/svx/source/form/fmsrcimp.cxx
index 1d35cfa6d364..caf0bd2be212 100644
--- a/svx/source/form/fmsrcimp.cxx
+++ b/svx/source/form/fmsrcimp.cxx
@@ -568,7 +568,7 @@ FmSearchEngine::SEARCH_RESULT FmSearchEngine::SearchRegularApprox(const OUString
}
aParam.searchString = strExpression;
aParam.Locale = SvtSysLocale().GetLanguageTag().getLocale();
- ::utl::TextSearch aLocalEngine(aParam);
+ ::utl::TextSearch aLocalEngine( utl::TextSearch::UpgradeToSearchOptions2( aParam));
bool bFound = false;
diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx
index 3cbd168b35ff..c8f402ae895f 100644
--- a/sw/source/core/crsr/findattr.cxx
+++ b/sw/source/core/crsr/findattr.cxx
@@ -1117,7 +1117,7 @@ int SwFindParaAttr::Find( SwPaM* pCursor, SwMoveFn fnMove, const SwPaM* pRegion,
aTmp.Locale = SvtSysLocale().GetLanguageTag().getLocale();
- pSText = new utl::TextSearch( aTmp );
+ pSText = new utl::TextSearch( utl::TextSearch::UpgradeToSearchOptions2( aTmp) );
}
// TODO: searching for attributes in Outliner text?!
diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx
index caa436bc2702..61943acb0937 100644
--- a/sw/source/core/crsr/findtxt.cxx
+++ b/sw/source/core/crsr/findtxt.cxx
@@ -540,7 +540,7 @@ bool SwPaM::DoSearch( const SearchOptions& rSearchOpt, utl::TextSearch& rSText,
{
const lang::Locale aLocale(
g_pBreakIt->GetLocale( eCurrLang ) );
- rSText.SetLocale( rSearchOpt, aLocale );
+ rSText.SetLocale( utl::TextSearch::UpgradeToSearchOptions2( rSearchOpt), aLocale );
eLastLang = eCurrLang;
}
}
@@ -635,7 +635,8 @@ struct SwFindParaText : public SwFindParas
bool m_bSearchInNotes;
SwFindParaText( const SearchOptions& rOpt, bool bSearchInNotes, bool bRepl, SwCursor& rCursor )
- : m_rSearchOpt( rOpt ), m_rCursor( rCursor ), m_aSText( rOpt ), m_bReplace( bRepl ), m_bSearchInNotes( bSearchInNotes )
+ : m_rSearchOpt( rOpt ), m_rCursor( rCursor ), m_aSText( utl::TextSearch::UpgradeToSearchOptions2( rOpt) ),
+ m_bReplace( bRepl ), m_bSearchInNotes( bSearchInNotes )
{}
virtual int Find( SwPaM* , SwMoveFn , const SwPaM*, bool bInReadOnly ) override;
virtual bool IsReplaceMode() const override;
@@ -749,7 +750,7 @@ OUString *ReplaceBackReferences( const SearchOptions& rSearchOpt, SwPaM* pPam )
const SwContentNode* pTextNode = pPam->GetContentNode();
if( pTextNode && pTextNode->IsTextNode() && pTextNode == pPam->GetContentNode( false ) )
{
- utl::TextSearch aSText( rSearchOpt );
+ utl::TextSearch aSText( utl::TextSearch::UpgradeToSearchOptions2( rSearchOpt) );
const OUString& rStr = pTextNode->GetTextNode()->GetText();
sal_Int32 nStart = pPam->Start()->nContent.GetIndex();
sal_Int32 nEnd = pPam->End()->nContent.GetIndex();
diff --git a/unotools/source/i18n/textsearch.cxx b/unotools/source/i18n/textsearch.cxx
index d1b4678cf7c4..10919bef6dbb 100644
--- a/unotools/source/i18n/textsearch.cxx
+++ b/unotools/source/i18n/textsearch.cxx
@@ -19,7 +19,8 @@
#include <i18nlangtag/languagetag.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/util/TextSearch.hpp>
+#include <com/sun/star/util/TextSearch2.hpp>
+#include <com/sun/star/util/SearchAlgorithms2.hpp>
#include <com/sun/star/util/SearchFlags.hpp>
#include <com/sun/star/i18n/TransliterationModules.hpp>
#include <sal/log.hxx>
@@ -78,9 +79,11 @@ SearchParam::SearchParam( const SearchParam& rParam )
SearchParam::~SearchParam() {}
-static bool lcl_Equals( const SearchOptions& rSO1, const SearchOptions& rSO2 )
+static bool lcl_Equals( const SearchOptions2& rSO1, const SearchOptions2& rSO2 )
{
- return rSO1.algorithmType == rSO2.algorithmType &&
+ return
+ rSO1.AlgorithmType2 == rSO2.AlgorithmType2 &&
+ rSO1.algorithmType == rSO2.algorithmType &&
rSO1.searchFlag == rSO2.searchFlag &&
rSO1.searchString.equals(rSO2.searchString) &&
rSO1.replaceString.equals(rSO2.replaceString) &&
@@ -98,15 +101,15 @@ namespace
struct CachedTextSearch
{
::osl::Mutex mutex;
- css::util::SearchOptions Options;
- css::uno::Reference< css::util::XTextSearch > xTextSearch;
+ css::util::SearchOptions2 Options;
+ css::uno::Reference< css::util::XTextSearch2 > xTextSearch;
};
struct theCachedTextSearch
: public rtl::Static< CachedTextSearch, theCachedTextSearch > {};
}
-Reference<XTextSearch> TextSearch::getXTextSearch( const SearchOptions& rPara )
+Reference<XTextSearch2> TextSearch::getXTextSearch( const SearchOptions2& rPara )
{
CachedTextSearch &rCache = theCachedTextSearch::get();
@@ -116,8 +119,8 @@ Reference<XTextSearch> TextSearch::getXTextSearch( const SearchOptions& rPara )
return rCache.xTextSearch;
Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
- rCache.xTextSearch.set( ::TextSearch::create(xContext) );
- rCache.xTextSearch->setOptions( rPara );
+ rCache.xTextSearch.set( ::TextSearch2::create(xContext) );
+ rCache.xTextSearch->setOptions2( rPara );
rCache.Options = rPara;
return rCache.xTextSearch;
@@ -137,20 +140,61 @@ TextSearch::TextSearch(const SearchParam & rParam, const CharClass& rCClass )
Init( rParam, rCClass.getLanguageTag().getLocale() );
}
-TextSearch::TextSearch( const SearchOptions& rPara )
+TextSearch::TextSearch( const SearchOptions2& rPara )
{
xTextSearch = getXTextSearch( rPara );
}
+css::util::SearchOptions2 TextSearch::UpgradeToSearchOptions2( const css::util::SearchOptions& rOptions )
+{
+ sal_Int16 nAlgorithmType2;
+ switch (rOptions.algorithmType)
+ {
+ case SearchAlgorithms_REGEXP:
+ nAlgorithmType2 = SearchAlgorithms2::REGEXP;
+ break;
+ case SearchAlgorithms_APPROXIMATE:
+ nAlgorithmType2 = SearchAlgorithms2::APPROXIMATE;
+ break;
+ default:
+ assert(!"utl::TextSearch::UpgradeToSearchOptions2 - default what?");
+ // fallthru
+ case SearchAlgorithms_ABSOLUTE:
+ nAlgorithmType2 = SearchAlgorithms2::ABSOLUTE;
+ break;
+ }
+ // It would be nice if an inherited struct had a ctor that takes an
+ // instance of the object the struct derived from..
+ SearchOptions2 aOptions2(
+ rOptions.algorithmType,
+ rOptions.searchFlag,
+ rOptions.searchString,
+ rOptions.replaceString,
+ rOptions.Locale,
+ rOptions.changedChars,
+ rOptions.deletedChars,
+ rOptions.insertedChars,
+ rOptions.transliterateFlags,
+ nAlgorithmType2
+ );
+ return aOptions2;
+}
+
void TextSearch::Init( const SearchParam & rParam,
const css::lang::Locale& rLocale )
{
- // convert SearchParam to the UNO SearchOptions
- SearchOptions aSOpt;
+ // convert SearchParam to the UNO SearchOptions2
+ SearchOptions2 aSOpt;
switch( rParam.GetSrchType() )
{
+ case SearchParam::SRCH_WILDCARD:
+ aSOpt.AlgorithmType2 = SearchAlgorithms2::WILDCARD;
+ aSOpt.algorithmType = static_cast<SearchAlgorithms>(-1); // no old enum for that
+ break;
+
case SearchParam::SRCH_REGEXP:
+ aSOpt.AlgorithmType2 = SearchAlgorithms2::REGEXP;
aSOpt.algorithmType = SearchAlgorithms_REGEXP;
if( rParam.IsSrchInSelection() )
aSOpt.searchFlag |= SearchFlags::REG_NOT_BEGINOFLINE |
@@ -158,6 +202,7 @@ void TextSearch::Init( const SearchParam & rParam,
break;
case SearchParam::SRCH_LEVDIST:
+ aSOpt.AlgorithmType2 = SearchAlgorithms2::APPROXIMATE;
aSOpt.algorithmType = SearchAlgorithms_APPROXIMATE;
aSOpt.changedChars = rParam.GetLEVOther();
aSOpt.deletedChars = rParam.GetLEVLonger();
@@ -166,8 +211,11 @@ void TextSearch::Init( const SearchParam & rParam,
aSOpt.searchFlag |= SearchFlags::LEV_RELAXED;
break;
-// case SearchParam::SRCH_NORMAL:
default:
+ assert(!"default what?");
+ // fallthru
+ case SearchParam::SRCH_NORMAL:
+ aSOpt.AlgorithmType2 = SearchAlgorithms2::ABSOLUTE;
aSOpt.algorithmType = SearchAlgorithms_ABSOLUTE;
if( rParam.IsSrchWordOnly() )
aSOpt.searchFlag |= SearchFlags::NORM_WORD_ONLY;
@@ -186,11 +234,11 @@ void TextSearch::Init( const SearchParam & rParam,
xTextSearch = getXTextSearch( aSOpt );
}
-void TextSearch::SetLocale( const css::util::SearchOptions& rOptions,
+void TextSearch::SetLocale( const css::util::SearchOptions2& rOptions,
const css::lang::Locale& rLocale )
{
- // convert SearchParam to the UNO SearchOptions
- SearchOptions aSOpt( rOptions );
+ // convert SearchParam to the UNO SearchOptions2
+ SearchOptions2 aSOpt( rOptions );
aSOpt.Locale = rLocale;
xTextSearch = getXTextSearch( aSOpt );
diff --git a/vcl/source/edit/xtextedt.cxx b/vcl/source/edit/xtextedt.cxx
index 690cd8d9234e..950ab6d32337 100644
--- a/vcl/source/edit/xtextedt.cxx
+++ b/vcl/source/edit/xtextedt.cxx
@@ -158,7 +158,7 @@ bool ExtTextEngine::Search( TextSelection& rSel, const util::SearchOptions& rSea
util::SearchOptions aOptions( rSearchOptions );
aOptions.Locale = Application::GetSettings().GetLanguageTag().getLocale();
- utl::TextSearch aSearcher( aOptions );
+ utl::TextSearch aSearcher( utl::TextSearch::UpgradeToSearchOptions2( aOptions));
// iterate over the paragraphs
for ( sal_uInt32 nNode = nStartNode;