1 /*
2  * Copyright (c) 2022-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 FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_TEXT_MODEL_IMPL_H
17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_TEXT_MODEL_IMPL_H
18 
19 #include <functional>
20 #include <string>
21 
22 #include "core/components/common/properties/text_style.h"
23 #include "core/components/text/text_component_v2.h"
24 #include "core/components_ng/pattern/text/text_model.h"
25 
26 namespace OHOS::Ace::Framework {
27 class ACE_EXPORT TextModelImpl : public TextModel {
28 public:
29     void Create(const std::string& content) override;
Create(const RefPtr<SpanStringBase> & spanString)30     void Create(const RefPtr<SpanStringBase>& spanString) override {}
31     void SetFont(const Font& value) override;
32     void SetFontSize(const Dimension& value) override;
33     void SetTextColor(const Color& value) override;
34     void SetTextShadow(const std::vector<Shadow>& value) override;
SetTextSelection(int32_t startIndex,int32_t endIndex)35     void SetTextSelection(int32_t startIndex, int32_t endIndex) override {};
SetTextSelectableMode(TextSelectableMode value)36     void SetTextSelectableMode(TextSelectableMode value) override {};
37     void SetTextCaretColor(const Color& value) override;
38     void SetSelectedBackgroundColor(const Color& value) override;
39     void SetItalicFontStyle(Ace::FontStyle value) override;
40     void SetFontWeight(FontWeight value) override;
SetVariableFontWeight(int32_t value)41     void SetVariableFontWeight(int32_t value) override {};
SetEnableVariableFontWeight(bool value)42     void SetEnableVariableFontWeight(bool value) override {};
43     void SetMinFontScale(const float value) override;
44     void SetMaxFontScale(const float value) override;
45     void SetFontFamily(const std::vector<std::string>& value) override;
46     void SetTextAlign(TextAlign value) override;
47     void SetTextOverflow(TextOverflow value) override;
48     void SetMaxLines(uint32_t value) override;
49     void SetTextIndent(const Dimension& value) override;
50     void SetLineHeight(const Dimension& value) override;
51     void SetLineSpacing(const Dimension& value) override;
52     void SetTextDecoration(TextDecoration value) override;
53     void SetTextDecorationColor(const Color& value) override;
54     void SetTextDecorationStyle(TextDecorationStyle value) override;
55     void SetBaselineOffset(const Dimension& value) override;
56     void SetTextCase(TextCase value) override;
SetWordBreak(WordBreak value)57     void SetWordBreak(WordBreak value) override {};
SetLineBreakStrategy(LineBreakStrategy value)58     void SetLineBreakStrategy(LineBreakStrategy value) override {};
59     void SetLetterSpacing(const Dimension& value) override;
60     void SetAdaptMinFontSize(const Dimension& value) override;
61     void SetAdaptMaxFontSize(const Dimension& value) override;
62     void SetHeightAdaptivePolicy(TextHeightAdaptivePolicy value) override;
63     void SetTextDetectEnable(bool value) override;
64     void SetTextDetectConfig(const TextDetectConfig& textDetectConfig) override;
65     void OnSetHeight() override;
66     void OnSetWidth() override;
67     void OnSetAlign() override;
68     void SetOnClick(std::function<void(BaseEventInfo*)>&& click) override;
ClearOnClick()69     void ClearOnClick() override {};
70     void SetRemoteMessage(std::function<void()>&& event) override;
71     void SetCopyOption(CopyOptions copyOption) override;
SetOnCopy(std::function<void (const std::string &)> && func)72     void SetOnCopy(std::function<void(const std::string&)>&& func) override {};
SetEllipsisMode(EllipsisMode modal)73     void SetEllipsisMode(EllipsisMode modal) override {};
SetClipEdge(bool clip)74     void SetClipEdge(bool clip) override {};
SetFontFeature(const std::list<std::pair<std::string,int32_t>> & value)75     void SetFontFeature(const std::list<std::pair<std::string, int32_t>>& value) override {};
76     void SetOnDragStart(NG::OnDragStartFunc&& onDragStart) override;
77     void SetOnDragEnter(NG::OnDragDropFunc&& onDragEnter) override;
78     void SetOnDragMove(NG::OnDragDropFunc&& onDragMove) override;
79     void SetOnDragLeave(NG::OnDragDropFunc&& onDragLeave) override;
80     void SetOnDrop(NG::OnDragDropFunc&& onDrop) override;
81     void SetHalfLeading(bool halfLeading) override;
SetEnableHapticFeedback(bool state)82     void SetEnableHapticFeedback(bool state) override {};
83 
84 private:
85     static RefPtr<TextComponentV2> GetComponent();
86 };
87 } // namespace OHOS::Ace::Framework
88 
89 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_TEXT_MODEL_IMPL_H
90