• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 FOUNDATION_ACE_INTERFACE_INNERKITS_DATA_DETECTOR_MGR_H
17 #define FOUNDATION_ACE_INTERFACE_INNERKITS_DATA_DETECTOR_MGR_H
18 
19 #include "data_detector_loader.h"
20 
21 #include "base/utils/macros.h"
22 #include "core/components/common/layout/constants.h"
23 #include "core/components_ng/base/frame_node.h"
24 
25 namespace OHOS::AAFwk {
26 class WantParams;
27 } // namespace OHOS::AAFwk
28 
29 namespace OHOS::Ace {
30 class ACE_EXPORT DataDetectorMgr : public DataDetectorInterface {
31 public:
32     static DataDetectorMgr& GetInstance();
33 
34     bool IsDataDetectorSupported() override;
35     void DataDetect(const TextDataDetectInfo& info, const TextDetectResultFunc& resultFunc) override;
36 
37     void AdjustCursorPosition(int32_t& caretPos, const std::string& content, TimeStamp& lastAiPosTimeStamp,
38         const TimeStamp& lastClickTimeStamp);
39     void AdjustWordSelection(int32_t& caretPos, const std::string& content, int32_t& start, int32_t& end);
40 
41     int8_t GetCursorPosition(const std::string& text, int8_t offset) override;
42     std::vector<int8_t> GetWordSelection(const std::string& text, int8_t offset) override;
43 
44 protected:
45     ~DataDetectorMgr() = default;
46 
47 private:
48     DataDetectorMgr();
49     DataDetectorInstance engine_ = nullptr;
50 };
51 } // namespace OHOS::Ace
52 #endif // FOUNDATION_ACE_INTERFACE_INNERKITS_DATA_DETECTOR_MGR_H
53