1 /*
2 * Copyright (c) 2024 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 #include "global.h"
16 #include "native_inputmethod_types.h"
17 #ifdef __cplusplus
18 extern "C" {
19 #endif /* __cplusplus */
20
OH_TextAvoidInfo_Create(double positionY,double height)21 InputMethod_TextAvoidInfo *OH_TextAvoidInfo_Create(double positionY, double height)
22 {
23 return new InputMethod_TextAvoidInfo({ positionY, height });
24 }
OH_TextAvoidInfo_Destroy(InputMethod_TextAvoidInfo * info)25 void OH_TextAvoidInfo_Destroy(InputMethod_TextAvoidInfo *info)
26 {
27 if (info == nullptr) {
28 IMSA_HILOGE("info is nullptr");
29 return;
30 }
31 delete info;
32 }
OH_TextAvoidInfo_SetPositionY(InputMethod_TextAvoidInfo * info,double positionY)33 InputMethod_ErrorCode OH_TextAvoidInfo_SetPositionY(InputMethod_TextAvoidInfo *info, double positionY)
34 {
35 if (info == nullptr) {
36 IMSA_HILOGE("info is nullptr");
37 return IME_ERR_NULL_POINTER;
38 }
39 info->positionY = positionY;
40 return IME_ERR_OK;
41 }
OH_TextAvoidInfo_SetHeight(InputMethod_TextAvoidInfo * info,double height)42 InputMethod_ErrorCode OH_TextAvoidInfo_SetHeight(InputMethod_TextAvoidInfo *info, double height)
43 {
44 if (info == nullptr) {
45 IMSA_HILOGE("info is nullptr");
46 return IME_ERR_NULL_POINTER;
47 }
48 info->height = height;
49 return IME_ERR_OK;
50 }
OH_TextAvoidInfo_GetPositionY(InputMethod_TextAvoidInfo * info,double * positionY)51 InputMethod_ErrorCode OH_TextAvoidInfo_GetPositionY(InputMethod_TextAvoidInfo *info, double *positionY)
52 {
53 if (info == nullptr) {
54 IMSA_HILOGE("info is nullptr");
55 return IME_ERR_NULL_POINTER;
56 }
57 if (positionY == nullptr) {
58 IMSA_HILOGE("positionY is nullptr");
59 return IME_ERR_NULL_POINTER;
60 }
61 *positionY = info->positionY;
62 return IME_ERR_OK;
63 }
OH_TextAvoidInfo_GetHeight(InputMethod_TextAvoidInfo * info,double * height)64 InputMethod_ErrorCode OH_TextAvoidInfo_GetHeight(InputMethod_TextAvoidInfo *info, double *height)
65 {
66 if (info == nullptr) {
67 IMSA_HILOGE("info is nullptr");
68 return IME_ERR_NULL_POINTER;
69 }
70 if (height == nullptr) {
71 IMSA_HILOGE("height is nullptr");
72 return IME_ERR_NULL_POINTER;
73 }
74 *height = info->height;
75 return IME_ERR_OK;
76 }
77 #ifdef __cplusplus
78 }
79 #endif /* __cplusplus */