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_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_RICH_EDITOR_TEXT_CONTENT_MODIFIER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_RICH_EDITOR_TEXT_CONTENT_MODIFIER_H
18 
19 #include "core/components_ng/pattern/rich_editor/paragraph_manager.h"
20 #include "core/components_ng/pattern/text/text_content_modifier.h"
21 
22 namespace OHOS::Ace::NG {
23 class RichEditorContentModifier : public TextContentModifier {
24     DECLARE_ACE_TYPE(RichEditorContentModifier, TextContentModifier)
25 
26 public:
27     explicit RichEditorContentModifier(const std::optional<TextStyle>& textStyle, const ParagraphManager* pManager,
28         const WeakPtr<OHOS::Ace::NG::Pattern>& pattern);
29 
30     ~RichEditorContentModifier() override = default;
31 
32     void onDraw(DrawingContext& drawingContext) override;
33 
SetRichTextRectX(float value)34     void SetRichTextRectX(float value)
35     {
36         richTextRectX_->Set(value);
37     }
38 
SetRichTextRectY(float value)39     void SetRichTextRectY(float value)
40     {
41         richTextRectY_->Set(value);
42     }
43 
SetClipOffset(OffsetF offset)44     void SetClipOffset(OffsetF offset)
45     {
46         clipOffset_->Set(offset);
47     }
48 
SetClipSize(SizeF size)49     void SetClipSize(SizeF size)
50     {
51         clipSize_->Set(size);
52     }
53 
54 private:
55     void PaintCustomSpan(DrawingContext& drawingContext);
56     const ParagraphManager* pManager_;
57     WeakPtr<OHOS::Ace::NG::Pattern> pattern_;
58     RefPtr<PropertyFloat> richTextRectX_;
59     RefPtr<PropertyFloat> richTextRectY_;
60     RefPtr<AnimatablePropertyOffsetF> clipOffset_;
61     RefPtr<AnimatablePropertySizeF> clipSize_;
62     ACE_DISALLOW_COPY_AND_MOVE(RichEditorContentModifier);
63 };
64 } // namespace OHOS::Ace::NG
65 
66 #endif