summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-02-19 12:33:47 +0100
committerEike Rathke <erack@redhat.com>2016-02-20 00:39:25 +0100
commitfb3f66c20f79f178ba0f53b850ed0af0d1c5b2ff (patch)
treecb0fb5e1cde70f22b88cc168251e79846b900f1b
parent4bc2e84c8bf9ff685ecb00b1bf782eae9ee93e8d (diff)
add ConvertToSearchType() ConvertToBool(), tdf#72196
Change-Id: Iaab31cd6afe5cedccd4f79b142aa1ecee8a6e8d4
-rw-r--r--include/unotools/textsearch.hxx30
1 files changed, 30 insertions, 0 deletions
diff --git a/include/unotools/textsearch.hxx b/include/unotools/textsearch.hxx
index 7ddfbf0ed4e8..67c440ad033c 100644
--- a/include/unotools/textsearch.hxx
+++ b/include/unotools/textsearch.hxx
@@ -49,6 +49,36 @@ class UNOTOOLS_DLLPUBLIC SearchParam
public:
enum SearchType{ SRCH_NORMAL, SRCH_REGEXP, SRCH_LEVDIST, SRCH_WILDCARD };
+ /** Convert configuration and document boolean settings to SearchType.
+ If bWildcard is true it takes precedence over bRegExp.
+ */
+ static SearchType ConvertToSearchType( bool bWildcard, bool bRegExp )
+ {
+ return bWildcard ? SRCH_WILDCARD : (bRegExp ? SRCH_REGEXP : SRCH_NORMAL);
+ }
+
+ /** Convert SearchType to configuration and document boolean settings.
+ */
+ static void ConvertToBool( const SearchType eSearchType, bool& rbWildcard, bool& rbRegExp )
+ {
+ switch (eSearchType)
+ {
+ case SRCH_WILDCARD:
+ rbWildcard = true;
+ rbRegExp = false;
+ break;
+ case SRCH_REGEXP:
+ rbWildcard = false;
+ rbRegExp = true;
+ break;
+ default:
+ // SRCH_LEVDIST is not a persistent setting.
+ rbWildcard = false;
+ rbRegExp = false;
+ break;
+ }
+ }
+
private:
OUString sSrchStr; // the search string
OUString sReplaceStr; // the replace string