• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.. All rights reserved.
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 ROSEN_MODULES_SPTEXT_PARAGRAPH_BUILDER_H
17 #define ROSEN_MODULES_SPTEXT_PARAGRAPH_BUILDER_H
18 
19 #include <memory>
20 #include <string>
21 
22 #include "font_collection.h"
23 #include "paragraph.h"
24 #include "paragraph_line_fetcher.h"
25 #include "paragraph_style.h"
26 #include "placeholder_run.h"
27 #include "text_style.h"
28 #include "utils.h"
29 
30 namespace OHOS {
31 namespace Rosen {
32 namespace SPText {
33 class ParagraphBuilder {
34 public:
35     static std::unique_ptr<ParagraphBuilder> Create(const ParagraphStyle& style,
36       std::shared_ptr<txt::FontCollection> fontCollection);
37 
38     virtual ~ParagraphBuilder() = default;
39 
40     virtual void PushStyle(const TextStyle& style) = 0;
41     virtual void Pop() = 0;
42     virtual void AddText(const std::u16string& text) = 0;
43     virtual void AddPlaceholder(PlaceholderRun& span) = 0;
44 
45     virtual std::unique_ptr<Paragraph> Build() = 0;
46     virtual std::unique_ptr<ParagraphLineFetcher> BuildLineFetcher() = 0;
47 
48 protected:
49     ParagraphBuilder() = default;
50 
51 private:
52     DISALLOW_COPY_AND_ASSIGN(ParagraphBuilder);
53 };
54 } // namespace SPText
55 } // namespace Rosen
56 } // namespace OHOS
57 
58 #endif // ROSEN_MODULES_SPTEXT_PARAGRAPH_BUILDER_H
59