• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef PASTE_BOARD_PATTERN_H
17 #define PASTE_BOARD_PATTERN_H
18 
19 #include "pasteboard_types.h"
20 #include "paste_data.h"
21 
22 namespace OHOS::MiscServices {
23 class PatternDetection {
24 public:
25     static const std::set<Pattern> Detect(
26         const std::set<Pattern> &patternsToCheck, const PasteData &pasteData, bool hasHTML, bool hasPlain);
IsValid(const std::set<Pattern> & patterns)27     static inline bool IsValid(const std::set<Pattern> &patterns)
28     {
29         for (Pattern pattern : patterns) {
30             if (pattern >= Pattern::COUNT) {
31                 return false;
32             }
33         }
34         return true;
35     }
36 
37 private:
38     static std::string ExtractHtmlContent(const std::string &html_str);
39     static void DetectPlainText(
40         std::set<Pattern> &patternsOut, const std::set<Pattern> &PatternsIn, const std::string &plainText);
41 
42     static std::map<uint32_t, std::string> patterns_;
43 };
44 } // namespace OHOS::MiscServices
45 #endif // PASTE_BOARD_PATTERN_H