From 39da89b35ba95f9f47067d7d709073b2fbaea759 Mon Sep 17 00:00:00 2001 From: gzwhdd Date: Thu, 14 Nov 2024 14:15:43 +0800 Subject: [PATCH] add create string for textmodelng Signed-off-by: gzwhdd Change-Id: I3a89078b7ebcd797ff4a33c20f61e0d9d226c024 --- .../core/components_ng/pattern/text/text_model_ng.cpp | 6 ++++++ frameworks/core/components_ng/pattern/text/text_model_ng.h | 1 + 2 files changed, 7 insertions(+) diff --git a/frameworks/core/components_ng/pattern/text/text_model_ng.cpp b/frameworks/core/components_ng/pattern/text/text_model_ng.cpp index 143e73b4186..05b52bc306a 100644 --- a/frameworks/core/components_ng/pattern/text/text_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/text/text_model_ng.cpp @@ -16,6 +16,7 @@ #include "core/components_ng/pattern/text/text_model_ng.h" #include "base/geometry/dimension.h" +#include "base/utils/utf_helper.h" #include "core/components/common/properties/alignment.h" #include "core/components/common/properties/text_style.h" #include "core/components_ng/base/frame_node.h" @@ -58,6 +59,11 @@ void TextModelNG::Create(const std::u16string& content) textPattern->ClearSelectionMenu(); } +void TextModelNG::Create(const std::string& content) +{ + Create(UtfUtils::Str8ToStr16(content)); +} + void TextModelNG::Create(const RefPtr& spanBase) { TextModelNG::Create(u""); diff --git a/frameworks/core/components_ng/pattern/text/text_model_ng.h b/frameworks/core/components_ng/pattern/text/text_model_ng.h index e9629900752..2e22ea68cd7 100644 --- a/frameworks/core/components_ng/pattern/text/text_model_ng.h +++ b/frameworks/core/components_ng/pattern/text/text_model_ng.h @@ -29,6 +29,7 @@ namespace OHOS::Ace::NG { class ACE_EXPORT TextModelNG : public TextModel { public: void Create(const std::u16string& content) override; + void Create(const std::string& content) override; void Create(const RefPtr& spanString) override; void SetFont(const Font& value) override; void SetFontSize(const Dimension& value) override;