1 /* 2 * Copyright (c) 2025 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_TEXT_PARAGRAPH_UTIL_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TEXT_PARAGRAPH_UTIL_H 18 19 #include <list> 20 #include <memory> 21 #include <optional> 22 #include <string> 23 24 #include "base/memory/referenced.h" 25 #include "core/components/common/layout/constants.h" 26 #include "core/components_ng/layout/layout_wrapper.h" 27 #include "core/components_ng/render/paragraph.h" 28 #include "core/components_ng/pattern/text/span_node.h" 29 30 namespace OHOS::Ace::NG { 31 32 class ParagraphUtil { 33 public: 34 static TextDirection GetTextDirection(const std::u16string& content, LayoutWrapper* layoutWrapper); 35 static TextDirection GetTextDirectionByContent(const std::u16string& content); 36 static void GetSpanParagraphStyle(LayoutWrapper* layoutWrapper, 37 const RefPtr<SpanItem>& spanItem, ParagraphStyle& pStyle); 38 static void ConstructParagraphSpanGroup(std::list<RefPtr<SpanItem>>& spans, 39 std::vector<std::list<RefPtr<SpanItem>>>& spanGroupVec, 40 bool& spanStringHasMaxLines); 41 static void HandleEmptyParagraph(RefPtr<Paragraph> paragraph, const std::list<RefPtr<SpanItem>>& spanGroup); 42 static void ApplyIndent(ParagraphStyle& paragraphStyle, const RefPtr<Paragraph>& paragraph, double width, 43 const TextStyle& textStyle, double indentMaxWidth); 44 static ParagraphStyle GetParagraphStyle(const TextStyle& textStyle); 45 static ImageSourceInfo CreateImageSourceInfo(const ImageSpanOptions& options); 46 static PlaceholderAlignment GetPlaceHolderAlignmentFromVerticalAlign(VerticalAlign verticalAlign); 47 }; 48 49 } // namespace OHOS::Ace::NG 50 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TEXT_PARAGRAPH_UTIL_H