17777dab0Sopenharmony_ci/*
27777dab0Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
37777dab0Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
47777dab0Sopenharmony_ci * you may not use this file except in compliance with the License.
57777dab0Sopenharmony_ci * You may obtain a copy of the License at
67777dab0Sopenharmony_ci *
77777dab0Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
87777dab0Sopenharmony_ci *
97777dab0Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
107777dab0Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
117777dab0Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
127777dab0Sopenharmony_ci * See the License for the specific language governing permissions and
137777dab0Sopenharmony_ci * limitations under the License.
147777dab0Sopenharmony_ci */
157777dab0Sopenharmony_ci
167777dab0Sopenharmony_ci/**
177777dab0Sopenharmony_ci * @addtogroup ArkUI_NativeModule
187777dab0Sopenharmony_ci * @{
197777dab0Sopenharmony_ci *
207777dab0Sopenharmony_ci * @brief Provides ArkUI UI capabilities on the Native side, such as UI component creation and destruction,
217777dab0Sopenharmony_ci * tree node operation, property setting, event monitoring, and so on.
227777dab0Sopenharmony_ci *
237777dab0Sopenharmony_ci * @since 12
247777dab0Sopenharmony_ci */
257777dab0Sopenharmony_ci
267777dab0Sopenharmony_ci/**
277777dab0Sopenharmony_ci * @file styled_string.h
287777dab0Sopenharmony_ci *
297777dab0Sopenharmony_ci * @brief Provides ArkUI with property string capabilities on the Native side.
307777dab0Sopenharmony_ci *
317777dab0Sopenharmony_ci * @library libace_ndk.z.so
327777dab0Sopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full
337777dab0Sopenharmony_ci * @kit ArkUI
347777dab0Sopenharmony_ci * @since 12
357777dab0Sopenharmony_ci */
367777dab0Sopenharmony_ci
377777dab0Sopenharmony_ci#ifndef ARKUI_NATIVE_STYLED_STRING_H
387777dab0Sopenharmony_ci#define ARKUI_NATIVE_STYLED_STRING_H
397777dab0Sopenharmony_ci
407777dab0Sopenharmony_ci#include "native_drawing/drawing_text_declaration.h"
417777dab0Sopenharmony_ci#include "native_drawing/drawing_text_typography.h"
427777dab0Sopenharmony_ci#include "native_type.h"
437777dab0Sopenharmony_ci
447777dab0Sopenharmony_ci#ifdef __cplusplus
457777dab0Sopenharmony_ciextern "C" {
467777dab0Sopenharmony_ci#endif
477777dab0Sopenharmony_ci
487777dab0Sopenharmony_ci/**
497777dab0Sopenharmony_ci * @brief Defines formatted string data objects supported by the text component.
507777dab0Sopenharmony_ci *
517777dab0Sopenharmony_ci * @since 12
527777dab0Sopenharmony_ci */
537777dab0Sopenharmony_citypedef struct ArkUI_StyledString ArkUI_StyledString;
547777dab0Sopenharmony_ci
557777dab0Sopenharmony_ci/**
567777dab0Sopenharmony_ci * @brief Creates a pointer to the ArkUI_StyledString object.
577777dab0Sopenharmony_ci *
587777dab0Sopenharmony_ci * @param style A pointer to OH_Drawing_TypographyStyle, obtained by {@link OH_Drawing_CreateTypographyStyle}.
597777dab0Sopenharmony_ci * @param collection A pointer to OH_Drawing_FontCollection, obtained by {@link OH_Drawing_CreateFontCollection}.
607777dab0Sopenharmony_ci * @return Creates a pointer to the ArkUI_StyledString object. If the object returns a null pointer,
617777dab0Sopenharmony_ci *         the creation failed, either because the address space was full,
627777dab0Sopenharmony_ci *         or because the style, collection parameter was an exception such as a null pointer.
637777dab0Sopenharmony_ci * @since 12
647777dab0Sopenharmony_ci */
657777dab0Sopenharmony_ciArkUI_StyledString* OH_ArkUI_StyledString_Create(
667777dab0Sopenharmony_ci    OH_Drawing_TypographyStyle* style, OH_Drawing_FontCollection* collection);
677777dab0Sopenharmony_ci
687777dab0Sopenharmony_ci/**
697777dab0Sopenharmony_ci * @brief Free the memory occupied by the ArkUI_StyledString object.
707777dab0Sopenharmony_ci *
717777dab0Sopenharmony_ci * @param handle A pointer to the ArkUI_StyledString object.
727777dab0Sopenharmony_ci * @since 12
737777dab0Sopenharmony_ci */
747777dab0Sopenharmony_civoid OH_ArkUI_StyledString_Destroy(ArkUI_StyledString* handle);
757777dab0Sopenharmony_ci
767777dab0Sopenharmony_ci/**
777777dab0Sopenharmony_ci * @brief Sets the new layout style to the top of the current format string style stack.
787777dab0Sopenharmony_ci *
797777dab0Sopenharmony_ci * @param handle A pointer to the ArkUI_StyledString object.
807777dab0Sopenharmony_ci * @param style A pointer to the OH_Drawing_TextStyle object.
817777dab0Sopenharmony_ci * @since 12
827777dab0Sopenharmony_ci */
837777dab0Sopenharmony_civoid OH_ArkUI_StyledString_PushTextStyle(ArkUI_StyledString* handle, OH_Drawing_TextStyle* style);
847777dab0Sopenharmony_ci
857777dab0Sopenharmony_ci/**
867777dab0Sopenharmony_ci * @brief Sets the corresponding text content based on the current format string style.
877777dab0Sopenharmony_ci *
887777dab0Sopenharmony_ci * @param handle A pointer to the ArkUI_StyledString object.
897777dab0Sopenharmony_ci * @param content A pointer to the text content.
907777dab0Sopenharmony_ci * @since 12
917777dab0Sopenharmony_ci */
927777dab0Sopenharmony_civoid OH_ArkUI_StyledString_AddText(ArkUI_StyledString* handle, const char* content);
937777dab0Sopenharmony_ci
947777dab0Sopenharmony_ci/**
957777dab0Sopenharmony_ci * @brief Removes the top style from the stack in the current format string object.
967777dab0Sopenharmony_ci *
977777dab0Sopenharmony_ci * @param handle A pointer to the ArkUI_StyledString object.
987777dab0Sopenharmony_ci * @since 12
997777dab0Sopenharmony_ci */
1007777dab0Sopenharmony_civoid OH_ArkUI_StyledString_PopTextStyle(ArkUI_StyledString* handle);
1017777dab0Sopenharmony_ci
1027777dab0Sopenharmony_ci/**
1037777dab0Sopenharmony_ci * @brief Creates a pointer to an OH_Drawing_Typography object based on a format string object
1047777dab0Sopenharmony_ci * for advanced text estimation and typography.
1057777dab0Sopenharmony_ci *
1067777dab0Sopenharmony_ci * @param handle A pointer to the ArkUI_StyledString object.
1077777dab0Sopenharmony_ci * @return A pointer to the OH_Drawing_Typography object. If the object returns a null pointer,
1087777dab0Sopenharmony_ci *         the creation fails because the handle parameter is abnormal, such as a null pointer.
1097777dab0Sopenharmony_ci * @since 12
1107777dab0Sopenharmony_ci */
1117777dab0Sopenharmony_ciOH_Drawing_Typography* OH_ArkUI_StyledString_CreateTypography(ArkUI_StyledString* handle);
1127777dab0Sopenharmony_ci
1137777dab0Sopenharmony_ci/**
1147777dab0Sopenharmony_ci * @brief Set the placeholder.
1157777dab0Sopenharmony_ci *
1167777dab0Sopenharmony_ci * @param handle A pointer to the ArkUI_StyledString object.
1177777dab0Sopenharmony_ci * @param placeholder A pointer to the OH_Drawing_PlaceholderSpan object.
1187777dab0Sopenharmony_ci * @since 12
1197777dab0Sopenharmony_ci */
1207777dab0Sopenharmony_civoid OH_ArkUI_StyledString_AddPlaceholder(ArkUI_StyledString* handle, OH_Drawing_PlaceholderSpan* placeholder);
1217777dab0Sopenharmony_ci
1227777dab0Sopenharmony_ci/**
1237777dab0Sopenharmony_ci * @brief Create a ArkUI_StyledString_Descriptor object.
1247777dab0Sopenharmony_ci *
1257777dab0Sopenharmony_ci * @return Pointer to the ArkUI_StyledString_Descriptor object.。
1267777dab0Sopenharmony_ci * @since 14
1277777dab0Sopenharmony_ci */
1287777dab0Sopenharmony_ciArkUI_StyledString_Descriptor* OH_ArkUI_StyledString_Descriptor_Create();
1297777dab0Sopenharmony_ci
1307777dab0Sopenharmony_ci/**
1317777dab0Sopenharmony_ci * @brief Release the memory occupied by the ArkUI_StyledString_Descriptor object.
1327777dab0Sopenharmony_ci *
1337777dab0Sopenharmony_ci * @param str Pointer to the ArkUI_StyledString_Descriptor object.
1347777dab0Sopenharmony_ci * @since 14
1357777dab0Sopenharmony_ci */
1367777dab0Sopenharmony_civoid OH_ArkUI_StyledString_Descriptor_Destroy(ArkUI_StyledString_Descriptor* str);
1377777dab0Sopenharmony_ci
1387777dab0Sopenharmony_ci/**
1397777dab0Sopenharmony_ci * @brief Convert the styled string into html.
1407777dab0Sopenharmony_ci *
1417777dab0Sopenharmony_ci * @param str Pointer to the ArkUI_StyledString_Descriptor object.
1427777dab0Sopenharmony_ci * @return The converted html.
1437777dab0Sopenharmony_ci * @since 14
1447777dab0Sopenharmony_ci */
1457777dab0Sopenharmony_ciconst char* OH_ArkUI_ConvertToHtml(ArkUI_StyledString_Descriptor* str);
1467777dab0Sopenharmony_ci
1477777dab0Sopenharmony_ci/**
1487777dab0Sopenharmony_ci * @brief Deserializes a byte array containing styled string information into a styled string.
1497777dab0Sopenharmony_ci *
1507777dab0Sopenharmony_ci * @param buffer Byte array to be deserialized.
1517777dab0Sopenharmony_ci * @param bufferSize Length of the byte array.
1527777dab0Sopenharmony_ci * @param descriptor Pointer to an <b>ArkUI_StyledString_Descriptor</b> object.
1537777dab0Sopenharmony_ci * @return Returns the result code.
1547777dab0Sopenharmony_ci *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
1557777dab0Sopenharmony_ci *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
1567777dab0Sopenharmony_ci * @since 14
1577777dab0Sopenharmony_ci */
1587777dab0Sopenharmony_ciint32_t OH_ArkUI_UnmarshallStyledStringDescriptor(
1597777dab0Sopenharmony_ci    uint8_t* buffer, size_t bufferSize, ArkUI_StyledString_Descriptor* descriptor);
1607777dab0Sopenharmony_ci
1617777dab0Sopenharmony_ci/**
1627777dab0Sopenharmony_ci * @brief Serializes the styled string information into a byte array.
1637777dab0Sopenharmony_ci *
1647777dab0Sopenharmony_ci * @param buffer Byte array where the serialized data will be stored.
1657777dab0Sopenharmony_ci * @param bufferSize Length of the byte array.
1667777dab0Sopenharmony_ci * @param descriptor Pointer to an <b>ArkUI_StyledString_Descriptor</b> object.
1677777dab0Sopenharmony_ci * @param resultSize Actual length of the byte array.
1687777dab0Sopenharmony_ci * @return Returns the result code.
1697777dab0Sopenharmony_ci *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
1707777dab0Sopenharmony_ci *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
1717777dab0Sopenharmony_ci *         Returns {@link ARKUI_ERROR_CODE_INVALID_STYLED_STRING} if the styled string is invalid.
1727777dab0Sopenharmony_ci * @since 14
1737777dab0Sopenharmony_ci */
1747777dab0Sopenharmony_ciint32_t OH_ArkUI_MarshallStyledStringDescriptor(
1757777dab0Sopenharmony_ci    uint8_t* buffer, size_t bufferSize, ArkUI_StyledString_Descriptor* descriptor, size_t* resultSize);
1767777dab0Sopenharmony_ci
1777777dab0Sopenharmony_ci#ifdef __cplusplus
1787777dab0Sopenharmony_ci};
1797777dab0Sopenharmony_ci#endif
1807777dab0Sopenharmony_ci
1817777dab0Sopenharmony_ci#endif // ARKUI_NATIVE_STYLED_STRING_H
1827777dab0Sopenharmony_ci/** @} */
183