harmony 鸿蒙oh_pasteboard.h

  • 2025-06-12
  • 浏览 (3)

oh_pasteboard.h

概述

提供访问系统剪贴板的接口、数据结构、枚举类型。

库: libpasteboard.so

引用文件:

系统能力: SystemCapability.MiscServices.Pasteboard

起始版本: 13

相关模块:Pasteboard

汇总

类型定义

名称 描述
typedef enum Pasteboard_NotifyType Pasteboard_NotifyType 剪贴板的数据变更类型。
typedef void(* Pasteboard_Notify) (void *context, Pasteboard_NotifyType type) 定义剪贴板内容变更时触发的回调函数。
typedef void(* Pasteboard_Finalize) (void *context) 定义用于释放上下文的回调函数,剪贴板数据变更观察者对象销毁时触发。
typedef struct OH_PasteboardObserver OH_PasteboardObserver 定义剪贴板数据变更观察者。
typedef struct OH_Pasteboard OH_Pasteboard 定义剪贴板对象,用以操作系统剪贴板。
typedef enum Pasteboard_FileConflictOptions Pasteboard_FileConflictOptions 定义文件拷贝冲突时的选项。
typedef enum Pasteboard_ProgressIndicator Pasteboard_ProgressIndicator 定义进度条指示选项,可选择是否采用系统默认进度显示。
typedef struct Pasteboard_ProgressInfo Pasteboard_ProgressInfo 定义进度上报的数据结构,且仅当进度指示选项Pasteboard_ProgressIndicator设置为PASTEBOARD_NONE时才会上报此信息。
typedef void (* OH_Pasteboard_ProgressListener)(Pasteboard_ProgressInfo* progressInfo) 定义获取进度数据的回调函数,当选择不使用系统默认进度显示时,可设置该项获取粘贴过程的进度。
typedef struct Pasteboard_GetDataParams Pasteboard_GetDataParams 获取剪贴板数据支持进度提示时需要设置的参数,包含进度条指示选项、目标文件路径、文件冲突选项等。

枚举

名称 描述
Pasteboard_NotifyType { [NOTIFY_LOCAL_DATA_CHANGE] = 1, [NOTIFY_REMOTE_DATA_CHANGE] = 2 } 剪贴板的数据变更类型。
Pasteboard_FileConflictOptions { [PASTEBOARD_OVERWRITE] = 0, [PASTEBOARD_SKIP] = 1 } 拷贝文件文件冲突时的选项。
Pasteboard_ProgressIndicator { [PASTEBOARD_NONE] = 0, [PASTEBOARD_DEFAULT] = 1 } 从剪贴板获取数据时的进度条类型。

函数

名称 描述
OH_PasteboardObserver * OH_PasteboardObserver_Create () 创建一个剪贴板数据变更观察者OH_PasteboardObserver指针及实例对象。
int OH_PasteboardObserver_Destroy (OH_PasteboardObserver *observer) 销毁剪贴板数据变更观察者OH_PasteboardObserver指针指向的实例对象。
int OH_PasteboardObserver_SetData (OH_PasteboardObserver *observer, void *context, const Pasteboard_Notify callback, const Pasteboard_Finalize finalize) 向剪贴板数据变更观察者设置回调函数。
OH_Pasteboard * OH_Pasteboard_Create () 创建剪贴板OH_Pasteboard指针及实例对象。
void OH_Pasteboard_Destroy (OH_Pasteboard *pasteboard) 销毁剪贴板OH_Pasteboard实例对象。
int OH_Pasteboard_Subscribe (OH_Pasteboard *pasteboard, int type, const OH_PasteboardObserver *observer) 订阅剪贴板的数据变更事件。
int OH_Pasteboard_Unsubscribe (OH_Pasteboard *pasteboard, int type, const OH_PasteboardObserver *observer) 取消对剪贴板数据变更事件的订阅。
bool OH_Pasteboard_IsRemoteData (OH_Pasteboard *pasteboard) 判断剪贴板中的数据是否来自远端设备。
int OH_Pasteboard_GetDataSource (OH_Pasteboard *pasteboard, char *source, unsigned int len) 获取剪贴板中数据的数据源。
bool OH_Pasteboard_HasType (OH_Pasteboard *pasteboard, const char *type) 判断剪贴板中是否有指定类型的数据。
bool OH_Pasteboard_HasData (OH_Pasteboard *pasteboard) 判断剪贴板中是否有数据。
OH_UdmfData * OH_Pasteboard_GetData (OH_Pasteboard *pasteboard, int *status) 获取剪贴板中的数据。
int OH_Pasteboard_SetData (OH_Pasteboard *pasteboard, OH_UdmfData *data) 将统一数据对象数据写入剪贴板。
int OH_Pasteboard_ClearData (OH_Pasteboard *pasteboard) 清空剪贴板中的数据。
char ** OH_Pasteboard_GetMimeTypes (OH_Pasteboard *pasteboard, unsigned int *count) 获取剪贴板中的MIME类型。
Pasteboard_GetDataParams *OH_Pasteboard_GetDataParams_Create(void) 创建剪贴板Pasteboard_GetDataParams指针及实例对象。
void OH_Pasteboard_GetDataParams_Destroy(Pasteboard_GetDataParams* params) 销毁剪贴板Pasteboard_GetDataParams实例对象。
void OH_Pasteboard_GetDataParams_SetProgressIndicator(Pasteboard_GetDataParams* params, Pasteboard_ProgressIndicator progressIndicator) 向剪贴板Pasteboard_GetDataParams设置进度条指示选项,可选择是否采用系统默认进度显示。
void OH_Pasteboard_GetDataParams_SetDestUri(Pasteboard_GetDataParams* params, const char* destUri, uint32_t destUriLen) 向剪贴板Pasteboard_GetDataParams设置目标路径。
void OH_Pasteboard_GetDataParams_SetFileConflictOptions(Pasteboard_GetDataParams* params, Pasteboard_FileConflictOptions option) 向剪贴板Pasteboard_GetDataParams设置文件拷贝冲突选项。
void OH_Pasteboard_GetDataParams_SetProgressListener(Pasteboard_GetDataParams* params, const OH_Pasteboard_ProgressListener listener) 向剪贴板Pasteboard_GetDataParams设置进度上报回调函数。
int OH_Pasteboard_ProgressInfo_GetProgress(Pasteboard_ProgressInfo* progressInfo) 通过Pasteboard_ProgressInfo获取粘贴进度。
void OH_Pasteboard_ProgressCancel(Pasteboard_GetDataParams* params) 通过Pasteboard_GetDataParams取消正在进行的拷贝粘贴任务。
OH_UdmfData* OH_Pasteboard_GetDataWithProgress(OH_Pasteboard* pasteboard, Pasteboard_GetDataParams* params, int* status) 获取剪贴板的数据以及粘贴进度,不支持对文件夹的拷贝。
int32_t OH_Pasteboard_GetChangeCount (OH_Pasteboard *pasteboard) 获取剪贴板内容的变化次数。

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Basic Services Kit(基础服务)

harmony 鸿蒙DeviceInfo

harmony 鸿蒙OH_Print

harmony 鸿蒙Pasteboard

harmony 鸿蒙Print_Margin

harmony 鸿蒙Print_PageSize

harmony 鸿蒙Print_PrintAttributes

harmony 鸿蒙Print_PrintDocCallback

harmony 鸿蒙Print_Range

harmony 鸿蒙TimeService

0  赞