LibreOffice Module i18nutil (master) 1
searchopt.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#ifndef INCLUDED_I18NUTIL_SEARCHOPT_HXX
20#define INCLUDED_I18NUTIL_SEARCHOPT_HXX
21
22#include <sal/types.h>
23#include <com/sun/star/lang/Locale.hpp>
24#include <com/sun/star/util/SearchAlgorithms.hpp>
25#include <com/sun/star/util/SearchAlgorithms2.hpp>
26#include <com/sun/star/util/SearchOptions2.hpp>
28#include <utility>
29
30namespace i18nutil
31{
32
33inline constexpr css::util::SearchAlgorithms downgradeSearchAlgorithms2(sal_Int16 searchAlgorithms2)
34{
35 switch (searchAlgorithms2)
36 {
37 case css::util::SearchAlgorithms2::ABSOLUTE:
38 return css::util::SearchAlgorithms_ABSOLUTE;
39 case css::util::SearchAlgorithms2::REGEXP:
40 return css::util::SearchAlgorithms_REGEXP;
41 case css::util::SearchAlgorithms2::APPROXIMATE:
42 return css::util::SearchAlgorithms_APPROXIMATE;
43 default: // default what?
44 case css::util::SearchAlgorithms2::WILDCARD: // something valid
45 return css::util::SearchAlgorithms_ABSOLUTE;
46 }
47}
48
49inline constexpr sal_Int16 upgradeSearchAlgorithms(css::util::SearchAlgorithms searchAlgorithms)
50{
51 switch (searchAlgorithms)
52 {
53 default: // default what?
54 case css::util::SearchAlgorithms_ABSOLUTE:
55 return css::util::SearchAlgorithms2::ABSOLUTE;
56 case css::util::SearchAlgorithms_REGEXP:
57 return css::util::SearchAlgorithms2::REGEXP;
58 case css::util::SearchAlgorithms_APPROXIMATE:
59 return css::util::SearchAlgorithms2::APPROXIMATE;
60 }
61}
62
69 sal_Int32 searchFlag;
70 OUString searchString;
71 OUString replaceString;
72 css::lang::Locale Locale;
73 sal_Int32 changedChars;
74 sal_Int32 deletedChars;
75 sal_Int32 insertedChars;
77
78 sal_Int16 AlgorithmType2;
80
81 SearchOptions2& operator=(css::util::SearchOptions2 const & other)
82 {
83 searchFlag = other.searchFlag;
84 searchString = other.searchString;
85 replaceString = other.replaceString;
86 Locale = other.Locale;
87 changedChars = other.changedChars;
88 deletedChars = other.deletedChars;
89 insertedChars = other.insertedChars;
90 transliterateFlags = static_cast<TransliterationFlags>(other.transliterateFlags);
91 AlgorithmType2 = other.AlgorithmType2;
92 WildcardEscapeCharacter = other.WildcardEscapeCharacter;
93 return *this;
94 }
95
96 css::util::SearchOptions2 toUnoSearchOptions2() const
97 {
98 return css::util::SearchOptions2(downgradeSearchAlgorithms2(AlgorithmType2), searchFlag,
99 searchString, replaceString,
100 Locale,
101 changedChars, deletedChars, insertedChars,
102 static_cast<sal_Int32>(transliterateFlags),
103 AlgorithmType2, WildcardEscapeCharacter);
104 }
105
107 : searchFlag(0)
108 , changedChars(0)
109 , deletedChars(0)
110 , insertedChars(0)
111 , transliterateFlags(TransliterationFlags::NONE)
112 , AlgorithmType2(0)
113 , WildcardEscapeCharacter(0)
114 {}
115
116 SearchOptions2(const sal_Int32 searchFlag_,
117 OUString searchString_, OUString replaceString_,
118 css::lang::Locale Locale_,
119 const sal_Int32 changedChars_, const sal_Int32 deletedChars_, const sal_Int32 insertedChars_,
120 const TransliterationFlags& transliterateFlags_,
121 const sal_Int16 AlgorithmType2_, const sal_Int32 WildcardEscapeCharacter_)
122 : searchFlag(searchFlag_)
123 , searchString(std::move(searchString_))
124 , replaceString(std::move(replaceString_))
125 , Locale(std::move(Locale_))
126 , changedChars(changedChars_)
127 , deletedChars(deletedChars_)
128 , insertedChars(insertedChars_)
129 , transliterateFlags(transliterateFlags_)
130 , AlgorithmType2(AlgorithmType2_)
131 , WildcardEscapeCharacter(WildcardEscapeCharacter_)
132 {}
133};
134
135}; // namespace
136
137#endif
138
139/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
NONE
constexpr css::util::SearchAlgorithms downgradeSearchAlgorithms2(sal_Int16 searchAlgorithms2)
Definition: searchopt.hxx:33
constexpr sal_Int16 upgradeSearchAlgorithms(css::util::SearchAlgorithms searchAlgorithms)
Definition: searchopt.hxx:49
This is a wrapper around com::sun::star::util::SearchOptions and SearchOptions2, but using the more t...
Definition: searchopt.hxx:68
css::util::SearchOptions2 toUnoSearchOptions2() const
Definition: searchopt.hxx:96
TransliterationFlags transliterateFlags
Definition: searchopt.hxx:76
css::lang::Locale Locale
Definition: searchopt.hxx:72
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_)
Definition: searchopt.hxx:116
SearchOptions2 & operator=(css::util::SearchOptions2 const &other)
Definition: searchopt.hxx:81
sal_Int32 WildcardEscapeCharacter
Definition: searchopt.hxx:79
TransliterationFlags
This is a superset type of the com::sun::star::i18n::TransliterationModules and TransliterationModule...
#define SAL_WARN_UNUSED