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 
18 using namespace OHOS::MiscServices;
OH_TextEditorProxy_Create(void)19 InputMethod_TextEditorProxy *OH_TextEditorProxy_Create(void)
20 {
21     return new InputMethod_TextEditorProxy();
22 }
OH_TextEditorProxy_Destroy(InputMethod_TextEditorProxy * proxy)23 void OH_TextEditorProxy_Destroy(InputMethod_TextEditorProxy *proxy)
24 {
25     if (proxy == nullptr) {
26         IMSA_HILOGE("proxy is nullptr");
27         return;
28     }
29     delete proxy;
30 }
31 
OH_TextEditorProxy_SetGetTextConfigFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_GetTextConfigFunc getTextConfigFunc)32 InputMethod_ErrorCode OH_TextEditorProxy_SetGetTextConfigFunc(
33     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_GetTextConfigFunc getTextConfigFunc)
34 {
35     if (proxy == nullptr) {
36         IMSA_HILOGE("proxy is nullptr");
37         return IME_ERR_NULL_POINTER;
38     }
39 
40     if (getTextConfigFunc == nullptr) {
41         IMSA_HILOGE("getTextConfigFunc is nullptr");
42         return IME_ERR_NULL_POINTER;
43     }
44 
45     proxy->getTextConfigFunc = getTextConfigFunc;
46     return IME_ERR_OK;
47 }
OH_TextEditorProxy_SetInsertTextFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_InsertTextFunc insertTextFunc)48 InputMethod_ErrorCode OH_TextEditorProxy_SetInsertTextFunc(
49     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_InsertTextFunc insertTextFunc)
50 {
51     if (proxy == nullptr) {
52         IMSA_HILOGE("proxy is nullptr");
53         return IME_ERR_NULL_POINTER;
54     }
55 
56     if (insertTextFunc == nullptr) {
57         IMSA_HILOGE("insertTextFunc is nullptr");
58         return IME_ERR_NULL_POINTER;
59     }
60     proxy->insertTextFunc = insertTextFunc;
61     return IME_ERR_OK;
62 }
63 
OH_TextEditorProxy_SetDeleteForwardFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_DeleteForwardFunc deleteForwardFunc)64 InputMethod_ErrorCode OH_TextEditorProxy_SetDeleteForwardFunc(
65     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_DeleteForwardFunc deleteForwardFunc)
66 {
67     if (proxy == nullptr) {
68         IMSA_HILOGE("proxy is nullptr");
69         return IME_ERR_NULL_POINTER;
70     }
71 
72     if (deleteForwardFunc == nullptr) {
73         IMSA_HILOGE("deleteForwardFunc is nullptr");
74         return IME_ERR_NULL_POINTER;
75     }
76 
77     proxy->deleteForwardFunc = deleteForwardFunc;
78     return IME_ERR_OK;
79 }
80 
OH_TextEditorProxy_SetDeleteBackwardFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_DeleteBackwardFunc deleteBackwardFunc)81 InputMethod_ErrorCode OH_TextEditorProxy_SetDeleteBackwardFunc(
82     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_DeleteBackwardFunc deleteBackwardFunc)
83 {
84     if (proxy == nullptr) {
85         IMSA_HILOGE("proxy is nullptr");
86         return IME_ERR_NULL_POINTER;
87     }
88 
89     if (deleteBackwardFunc == nullptr) {
90         IMSA_HILOGE("deleteBackwardFunc is nullptr");
91         return IME_ERR_NULL_POINTER;
92     }
93 
94     proxy->deleteBackwardFunc = deleteBackwardFunc;
95     return IME_ERR_OK;
96 }
97 
OH_TextEditorProxy_SetSendKeyboardStatusFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_SendKeyboardStatusFunc sendKeyboardStatusFunc)98 InputMethod_ErrorCode OH_TextEditorProxy_SetSendKeyboardStatusFunc(
99     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_SendKeyboardStatusFunc sendKeyboardStatusFunc)
100 {
101     if (proxy == nullptr) {
102         IMSA_HILOGE("proxy is nullptr");
103         return IME_ERR_NULL_POINTER;
104     }
105 
106     if (sendKeyboardStatusFunc == nullptr) {
107         IMSA_HILOGE("sendKeyboardStatusFunc is nullptr");
108         return IME_ERR_NULL_POINTER;
109     }
110 
111     proxy->sendKeyboardStatusFunc = sendKeyboardStatusFunc;
112     return IME_ERR_OK;
113 }
114 
OH_TextEditorProxy_SetSendEnterKeyFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_SendEnterKeyFunc sendEnterKeyFunc)115 InputMethod_ErrorCode OH_TextEditorProxy_SetSendEnterKeyFunc(
116     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_SendEnterKeyFunc sendEnterKeyFunc)
117 {
118     if (proxy == nullptr) {
119         IMSA_HILOGE("proxy is nullptr");
120         return IME_ERR_NULL_POINTER;
121     }
122 
123     if (sendEnterKeyFunc == nullptr) {
124         IMSA_HILOGE("sendEnterKeyFunc is nullptr");
125         return IME_ERR_NULL_POINTER;
126     }
127 
128     proxy->sendEnterKeyFunc = sendEnterKeyFunc;
129     return IME_ERR_OK;
130 }
131 
OH_TextEditorProxy_SetMoveCursorFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_MoveCursorFunc moveCursorFunc)132 InputMethod_ErrorCode OH_TextEditorProxy_SetMoveCursorFunc(
133     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_MoveCursorFunc moveCursorFunc)
134 {
135     if (proxy == nullptr) {
136         IMSA_HILOGE("proxy is nullptr");
137         return IME_ERR_NULL_POINTER;
138     }
139 
140     if (moveCursorFunc == nullptr) {
141         IMSA_HILOGE("moveCursorFunc is nullptr");
142         return IME_ERR_NULL_POINTER;
143     }
144 
145     proxy->moveCursorFunc = moveCursorFunc;
146     return IME_ERR_OK;
147 }
148 
OH_TextEditorProxy_SetHandleSetSelectionFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_HandleSetSelectionFunc handleSetSelectionFunc)149 InputMethod_ErrorCode OH_TextEditorProxy_SetHandleSetSelectionFunc(
150     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_HandleSetSelectionFunc handleSetSelectionFunc)
151 {
152     if (proxy == nullptr) {
153         IMSA_HILOGE("proxy is nullptr");
154         return IME_ERR_NULL_POINTER;
155     }
156 
157     if (handleSetSelectionFunc == nullptr) {
158         IMSA_HILOGE("handleSetSelectionFunc is nullptr");
159         return IME_ERR_NULL_POINTER;
160     }
161 
162     proxy->handleSetSelectionFunc = handleSetSelectionFunc;
163     return IME_ERR_OK;
164 }
165 
OH_TextEditorProxy_SetHandleExtendActionFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_HandleExtendActionFunc handleExtendActionFunc)166 InputMethod_ErrorCode OH_TextEditorProxy_SetHandleExtendActionFunc(
167     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_HandleExtendActionFunc handleExtendActionFunc)
168 {
169     if (proxy == nullptr) {
170         IMSA_HILOGE("proxy is nullptr");
171         return IME_ERR_NULL_POINTER;
172     }
173 
174     if (handleExtendActionFunc == nullptr) {
175         IMSA_HILOGE("handleExtendActionFunc is nullptr");
176         return IME_ERR_NULL_POINTER;
177     }
178 
179     proxy->handleExtendActionFunc = handleExtendActionFunc;
180     return IME_ERR_OK;
181 }
182 
OH_TextEditorProxy_SetGetLeftTextOfCursorFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_GetLeftTextOfCursorFunc getLeftTextOfCursorFunc)183 InputMethod_ErrorCode OH_TextEditorProxy_SetGetLeftTextOfCursorFunc(
184     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_GetLeftTextOfCursorFunc getLeftTextOfCursorFunc)
185 {
186     if (proxy == nullptr) {
187         IMSA_HILOGE("proxy is nullptr");
188         return IME_ERR_NULL_POINTER;
189     }
190 
191     if (getLeftTextOfCursorFunc == nullptr) {
192         IMSA_HILOGE("getLeftTextOfCursorFunc is nullptr");
193         return IME_ERR_NULL_POINTER;
194     }
195 
196     proxy->getLeftTextOfCursorFunc = getLeftTextOfCursorFunc;
197     return IME_ERR_OK;
198 }
OH_TextEditorProxy_SetGetRightTextOfCursorFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_GetRightTextOfCursorFunc getRightTextOfCursorFunc)199 InputMethod_ErrorCode OH_TextEditorProxy_SetGetRightTextOfCursorFunc(
200     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_GetRightTextOfCursorFunc getRightTextOfCursorFunc)
201 {
202     if (proxy == nullptr) {
203         IMSA_HILOGE("proxy is nullptr");
204         return IME_ERR_NULL_POINTER;
205     }
206 
207     if (getRightTextOfCursorFunc == nullptr) {
208         IMSA_HILOGE("getRightTextOfCursorFunc is nullptr");
209         return IME_ERR_NULL_POINTER;
210     }
211 
212     proxy->getRightTextOfCursorFunc = getRightTextOfCursorFunc;
213     return IME_ERR_OK;
214 }
OH_TextEditorProxy_SetGetTextIndexAtCursorFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_GetTextIndexAtCursorFunc getTextIndexAtCursorFunc)215 InputMethod_ErrorCode OH_TextEditorProxy_SetGetTextIndexAtCursorFunc(
216     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_GetTextIndexAtCursorFunc getTextIndexAtCursorFunc)
217 {
218     if (proxy == nullptr) {
219         IMSA_HILOGE("proxy is nullptr");
220         return IME_ERR_NULL_POINTER;
221     }
222 
223     if (getTextIndexAtCursorFunc == nullptr) {
224         IMSA_HILOGE("getTextIndexAtCursorFunc is nullptr");
225         return IME_ERR_NULL_POINTER;
226     }
227 
228     proxy->getTextIndexAtCursorFunc = getTextIndexAtCursorFunc;
229     return IME_ERR_OK;
230 }
231 
OH_TextEditorProxy_SetReceivePrivateCommandFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_ReceivePrivateCommandFunc receivePrivateCommandFunc)232 InputMethod_ErrorCode OH_TextEditorProxy_SetReceivePrivateCommandFunc(
233     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_ReceivePrivateCommandFunc receivePrivateCommandFunc)
234 {
235     if (proxy == nullptr) {
236         IMSA_HILOGE("proxy is nullptr");
237         return IME_ERR_NULL_POINTER;
238     }
239 
240     if (receivePrivateCommandFunc == nullptr) {
241         IMSA_HILOGE("receivePrivateCommandFunc is nullptr");
242         return IME_ERR_NULL_POINTER;
243     }
244 
245     proxy->receivePrivateCommandFunc = receivePrivateCommandFunc;
246     return IME_ERR_OK;
247 }
OH_TextEditorProxy_SetSetPreviewTextFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_SetPreviewTextFunc setPreviewTextFunc)248 InputMethod_ErrorCode OH_TextEditorProxy_SetSetPreviewTextFunc(
249     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_SetPreviewTextFunc setPreviewTextFunc)
250 {
251     if (proxy == nullptr) {
252         IMSA_HILOGE("proxy is nullptr");
253         return IME_ERR_NULL_POINTER;
254     }
255 
256     if (setPreviewTextFunc == nullptr) {
257         IMSA_HILOGE("setPreviewTextFunc is nullptr");
258         return IME_ERR_NULL_POINTER;
259     }
260 
261     proxy->setPreviewTextFunc = setPreviewTextFunc;
262     return IME_ERR_OK;
263 }
OH_TextEditorProxy_SetFinishTextPreviewFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_FinishTextPreviewFunc finishTextPreviewFunc)264 InputMethod_ErrorCode OH_TextEditorProxy_SetFinishTextPreviewFunc(
265     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_FinishTextPreviewFunc finishTextPreviewFunc)
266 {
267     if (proxy == nullptr) {
268         IMSA_HILOGE("proxy is nullptr");
269         return IME_ERR_NULL_POINTER;
270     }
271 
272     if (finishTextPreviewFunc == nullptr) {
273         IMSA_HILOGE("finishTextPreviewFunc is nullptr");
274         return IME_ERR_NULL_POINTER;
275     }
276 
277     proxy->finishTextPreviewFunc = finishTextPreviewFunc;
278     return IME_ERR_OK;
279 }
280 
OH_TextEditorProxy_GetGetTextConfigFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_GetTextConfigFunc * getTextConfigFunc)281 InputMethod_ErrorCode OH_TextEditorProxy_GetGetTextConfigFunc(
282     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_GetTextConfigFunc *getTextConfigFunc)
283 {
284     if (proxy == nullptr) {
285         IMSA_HILOGE("proxy is nullptr");
286         return IME_ERR_NULL_POINTER;
287     }
288 
289     if (getTextConfigFunc == nullptr) {
290         IMSA_HILOGE("getTextConfigFunc is nullptr");
291         return IME_ERR_NULL_POINTER;
292     }
293     *getTextConfigFunc = proxy->getTextConfigFunc;
294     return IME_ERR_OK;
295 }
296 
OH_TextEditorProxy_GetInsertTextFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_InsertTextFunc * insertTextFunc)297 InputMethod_ErrorCode OH_TextEditorProxy_GetInsertTextFunc(
298     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_InsertTextFunc *insertTextFunc)
299 {
300     if (proxy == nullptr) {
301         IMSA_HILOGE("proxy is nullptr");
302         return IME_ERR_NULL_POINTER;
303     }
304 
305     if (insertTextFunc == nullptr) {
306         IMSA_HILOGE("insertTextFunc is nullptr");
307         return IME_ERR_NULL_POINTER;
308     }
309 
310     *insertTextFunc = proxy->insertTextFunc;
311     return IME_ERR_OK;
312 }
OH_TextEditorProxy_GetDeleteForwardFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_DeleteForwardFunc * deleteForwardFunc)313 InputMethod_ErrorCode OH_TextEditorProxy_GetDeleteForwardFunc(
314     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_DeleteForwardFunc *deleteForwardFunc)
315 {
316     if (proxy == nullptr) {
317         IMSA_HILOGE("proxy is nullptr");
318         return IME_ERR_NULL_POINTER;
319     }
320     if (deleteForwardFunc == nullptr) {
321         IMSA_HILOGE("deleteForwardFunc is nullptr");
322         return IME_ERR_NULL_POINTER;
323     }
324     *deleteForwardFunc = proxy->deleteForwardFunc;
325     return IME_ERR_OK;
326 }
327 
OH_TextEditorProxy_GetDeleteBackwardFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_DeleteBackwardFunc * deleteBackwardFunc)328 InputMethod_ErrorCode OH_TextEditorProxy_GetDeleteBackwardFunc(
329     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_DeleteBackwardFunc *deleteBackwardFunc)
330 {
331     if (proxy == nullptr) {
332         IMSA_HILOGE("proxy is nullptr");
333         return IME_ERR_NULL_POINTER;
334     }
335     if (deleteBackwardFunc == nullptr) {
336         IMSA_HILOGE("deleteBackwardFunc is nullptr");
337         return IME_ERR_NULL_POINTER;
338     }
339     *deleteBackwardFunc = proxy->deleteBackwardFunc;
340     return IME_ERR_OK;
341 }
342 
OH_TextEditorProxy_GetSendKeyboardStatusFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_SendKeyboardStatusFunc * sendKeyboardStatusFunc)343 InputMethod_ErrorCode OH_TextEditorProxy_GetSendKeyboardStatusFunc(
344     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_SendKeyboardStatusFunc *sendKeyboardStatusFunc)
345 {
346     if (proxy == nullptr) {
347         IMSA_HILOGE("proxy is nullptr");
348         return IME_ERR_NULL_POINTER;
349     }
350     if (sendKeyboardStatusFunc == nullptr) {
351         IMSA_HILOGE("sendKeyboardStatusFunc is nullptr");
352         return IME_ERR_NULL_POINTER;
353     }
354     *sendKeyboardStatusFunc = proxy->sendKeyboardStatusFunc;
355     return IME_ERR_OK;
356 }
357 
OH_TextEditorProxy_GetSendEnterKeyFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_SendEnterKeyFunc * sendEnterKeyFunc)358 InputMethod_ErrorCode OH_TextEditorProxy_GetSendEnterKeyFunc(
359     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_SendEnterKeyFunc *sendEnterKeyFunc)
360 {
361     if (proxy == nullptr) {
362         IMSA_HILOGE("proxy is nullptr");
363         return IME_ERR_NULL_POINTER;
364     }
365     if (sendEnterKeyFunc == nullptr) {
366         IMSA_HILOGE("sendEnterKeyFunc is nullptr");
367         return IME_ERR_NULL_POINTER;
368     }
369     *sendEnterKeyFunc = proxy->sendEnterKeyFunc;
370     return IME_ERR_OK;
371 }
372 
OH_TextEditorProxy_GetMoveCursorFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_MoveCursorFunc * moveCursorFunc)373 InputMethod_ErrorCode OH_TextEditorProxy_GetMoveCursorFunc(
374     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_MoveCursorFunc *moveCursorFunc)
375 {
376     if (proxy == nullptr) {
377         IMSA_HILOGE("proxy is nullptr");
378         return IME_ERR_NULL_POINTER;
379     }
380     if (moveCursorFunc == nullptr) {
381         IMSA_HILOGE("moveCursorFunc is nullptr");
382         return IME_ERR_NULL_POINTER;
383     }
384     *moveCursorFunc = proxy->moveCursorFunc;
385     return IME_ERR_OK;
386 }
387 
OH_TextEditorProxy_GetHandleSetSelectionFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_HandleSetSelectionFunc * handleSetSelectionFunc)388 InputMethod_ErrorCode OH_TextEditorProxy_GetHandleSetSelectionFunc(
389     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_HandleSetSelectionFunc *handleSetSelectionFunc)
390 {
391     if (proxy == nullptr) {
392         IMSA_HILOGE("proxy is nullptr");
393         return IME_ERR_NULL_POINTER;
394     }
395     if (handleSetSelectionFunc == nullptr) {
396         IMSA_HILOGE("handleSetSelectionFunc is nullptr");
397         return IME_ERR_NULL_POINTER;
398     }
399     *handleSetSelectionFunc = proxy->handleSetSelectionFunc;
400     return IME_ERR_OK;
401 }
402 
OH_TextEditorProxy_GetHandleExtendActionFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_HandleExtendActionFunc * handleExtendActionFunc)403 InputMethod_ErrorCode OH_TextEditorProxy_GetHandleExtendActionFunc(
404     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_HandleExtendActionFunc *handleExtendActionFunc)
405 {
406     if (proxy == nullptr) {
407         IMSA_HILOGE("proxy is nullptr");
408         return IME_ERR_NULL_POINTER;
409     }
410     if (handleExtendActionFunc == nullptr) {
411         IMSA_HILOGE("handleExtendActionFunc is nullptr");
412         return IME_ERR_NULL_POINTER;
413     }
414     *handleExtendActionFunc = proxy->handleExtendActionFunc;
415     return IME_ERR_OK;
416 }
417 
OH_TextEditorProxy_GetGetLeftTextOfCursorFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_GetLeftTextOfCursorFunc * getLeftTextOfCursorFunc)418 InputMethod_ErrorCode OH_TextEditorProxy_GetGetLeftTextOfCursorFunc(
419     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_GetLeftTextOfCursorFunc *getLeftTextOfCursorFunc)
420 {
421     if (proxy == nullptr) {
422         IMSA_HILOGE("proxy is nullptr");
423         return IME_ERR_NULL_POINTER;
424     }
425     if (getLeftTextOfCursorFunc == nullptr) {
426         IMSA_HILOGE("getLeftTextOfCursorFunc is nullptr");
427         return IME_ERR_NULL_POINTER;
428     }
429     *getLeftTextOfCursorFunc = proxy->getLeftTextOfCursorFunc;
430     return IME_ERR_OK;
431 }
432 
OH_TextEditorProxy_GetGetRightTextOfCursorFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_GetRightTextOfCursorFunc * getRightTextOfCursorFunc)433 InputMethod_ErrorCode OH_TextEditorProxy_GetGetRightTextOfCursorFunc(
434     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_GetRightTextOfCursorFunc *getRightTextOfCursorFunc)
435 {
436     if (proxy == nullptr) {
437         IMSA_HILOGE("proxy is nullptr");
438         return IME_ERR_NULL_POINTER;
439     }
440     if (getRightTextOfCursorFunc == nullptr) {
441         IMSA_HILOGE("getRightTextOfCursorFunc is nullptr");
442         return IME_ERR_NULL_POINTER;
443     }
444     *getRightTextOfCursorFunc = proxy->getRightTextOfCursorFunc;
445     return IME_ERR_OK;
446 }
447 
OH_TextEditorProxy_GetGetTextIndexAtCursorFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_GetTextIndexAtCursorFunc * getTextIndexAtCursorFunc)448 InputMethod_ErrorCode OH_TextEditorProxy_GetGetTextIndexAtCursorFunc(
449     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_GetTextIndexAtCursorFunc *getTextIndexAtCursorFunc)
450 {
451     if (proxy == nullptr) {
452         IMSA_HILOGE("proxy is nullptr");
453         return IME_ERR_NULL_POINTER;
454     }
455     if (getTextIndexAtCursorFunc == nullptr) {
456         IMSA_HILOGE("getTextIndexAtCursorFunc is nullptr");
457         return IME_ERR_NULL_POINTER;
458     }
459     *getTextIndexAtCursorFunc = proxy->getTextIndexAtCursorFunc;
460     return IME_ERR_OK;
461 }
462 
OH_TextEditorProxy_GetReceivePrivateCommandFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_ReceivePrivateCommandFunc * receivePrivateCommandFunc)463 InputMethod_ErrorCode OH_TextEditorProxy_GetReceivePrivateCommandFunc(
464     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_ReceivePrivateCommandFunc *receivePrivateCommandFunc)
465 {
466     if (proxy == nullptr) {
467         IMSA_HILOGE("proxy is nullptr");
468         return IME_ERR_NULL_POINTER;
469     }
470     if (receivePrivateCommandFunc == nullptr) {
471         IMSA_HILOGE("receivePrivateCommandFunc is nullptr");
472         return IME_ERR_NULL_POINTER;
473     }
474     *receivePrivateCommandFunc = proxy->receivePrivateCommandFunc;
475     return IME_ERR_OK;
476 }
477 
OH_TextEditorProxy_GetSetPreviewTextFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_SetPreviewTextFunc * setPreviewTextFunc)478 InputMethod_ErrorCode OH_TextEditorProxy_GetSetPreviewTextFunc(
479     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_SetPreviewTextFunc *setPreviewTextFunc)
480 {
481     if (proxy == nullptr) {
482         IMSA_HILOGE("proxy is nullptr");
483         return IME_ERR_NULL_POINTER;
484     }
485     if (setPreviewTextFunc == nullptr) {
486         IMSA_HILOGE("setPreviewTextFunc is nullptr");
487         return IME_ERR_NULL_POINTER;
488     }
489     *setPreviewTextFunc = proxy->setPreviewTextFunc;
490     return IME_ERR_OK;
491 }
492 
OH_TextEditorProxy_GetFinishTextPreviewFunc(InputMethod_TextEditorProxy * proxy,OH_TextEditorProxy_FinishTextPreviewFunc * finishTextPreviewFunc)493 InputMethod_ErrorCode OH_TextEditorProxy_GetFinishTextPreviewFunc(
494     InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_FinishTextPreviewFunc *finishTextPreviewFunc)
495 {
496     if (proxy == nullptr) {
497         IMSA_HILOGE("proxy is nullptr");
498         return IME_ERR_NULL_POINTER;
499     }
500     if (finishTextPreviewFunc == nullptr) {
501         IMSA_HILOGE("finishTextPreviewFunc is nullptr");
502         return IME_ERR_NULL_POINTER;
503     }
504     *finishTextPreviewFunc = proxy->finishTextPreviewFunc;
505     return IME_ERR_OK;
506 }