1/* 2 * Copyright (c) 2021 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 16/** 17 * @file 18 * @kit BasicServicesKit 19 */ 20 21import { AsyncCallback } from './@ohos.base'; 22import Want from './@ohos.app.ability.Want'; 23import image from './@ohos.multimedia.image'; 24import unifiedDataChannel from './@ohos.data.unifiedDataChannel'; 25 26/** 27 * systemPasteboard 28 * @namespace pasteboard 29 * @syscap SystemCapability.MiscServices.Pasteboard 30 * @since 6 31 */ 32/** 33 * systemPasteboard 34 * @namespace pasteboard 35 * @syscap SystemCapability.MiscServices.Pasteboard 36 * @atomicservice 37 * @since 11 38 */ 39declare namespace pasteboard { 40 /** 41 * Indicates the maximum number of records allowed in a PasteData object. 42 * @constant 43 * @syscap SystemCapability.MiscServices.Pasteboard 44 * @since 7 45 */ 46 /** 47 * Indicates the maximum number of records allowed in a PasteData object. 48 * @constant 49 * @syscap SystemCapability.MiscServices.Pasteboard 50 * @atomicservice 51 * @since 11 52 */ 53 const MAX_RECORD_NUM: number; 54 /** 55 * Indicates MIME types of HTML text. 56 * @constant 57 * @syscap SystemCapability.MiscServices.Pasteboard 58 * @since 7 59 */ 60 /** 61 * Indicates MIME types of HTML text. 62 * @constant 63 * @syscap SystemCapability.MiscServices.Pasteboard 64 * @atomicservice 65 * @since 11 66 */ 67 const MIMETYPE_TEXT_HTML: string; 68 /** 69 * Indicates MIME types of wants. 70 * @constant 71 * @syscap SystemCapability.MiscServices.Pasteboard 72 * @since 7 73 */ 74 /** 75 * Indicates MIME types of wants. 76 * @constant 77 * @syscap SystemCapability.MiscServices.Pasteboard 78 * @atomicservice 79 * @since 11 80 */ 81 const MIMETYPE_TEXT_WANT: string; 82 /** 83 * Indicates MIME types of plain text. 84 * @constant 85 * @syscap SystemCapability.MiscServices.Pasteboard 86 * @since 7 87 */ 88 /** 89 * Indicates MIME types of plain text. 90 * @constant 91 * @syscap SystemCapability.MiscServices.Pasteboard 92 * @atomicservice 93 * @since 11 94 */ 95 const MIMETYPE_TEXT_PLAIN: string; 96 /** 97 * Indicates MIME types of URIs. 98 * @constant 99 * @syscap SystemCapability.MiscServices.Pasteboard 100 * @since 7 101 */ 102 /** 103 * Indicates MIME types of URIs. 104 * @constant 105 * @syscap SystemCapability.MiscServices.Pasteboard 106 * @atomicservice 107 * @since 11 108 */ 109 const MIMETYPE_TEXT_URI: string; 110 /** 111 * Indicates MIME type of PixelMap. 112 * @constant 113 * @syscap SystemCapability.MiscServices.Pasteboard 114 * @since 9 115 */ 116 /** 117 * Indicates MIME type of PixelMap. 118 * @constant 119 * @syscap SystemCapability.MiscServices.Pasteboard 120 * @atomicservice 121 * @since 11 122 */ 123 const MIMETYPE_PIXELMAP: string; 124 125 /** 126 * Indicates type of value. 127 * @type { string | image.PixelMap | Want | ArrayBuffer } 128 * @syscap SystemCapability.MiscServices.Pasteboard 129 * @since 9 130 */ 131 /** 132 * Indicates type of value. 133 * @typedef { string | image.PixelMap | Want | ArrayBuffer } 134 * @syscap SystemCapability.MiscServices.Pasteboard 135 * @atomicservice 136 * @since 11 137 */ 138 type ValueType = string | image.PixelMap | Want | ArrayBuffer; 139 140 /** 141 * Creates a PasteData object for PasteData#MIMETYPE_TEXT_HTML. 142 * @param { string } htmlText - To save the Html text content. 143 * @returns { PasteData } Containing the contents of the clipboard content object. 144 * @syscap SystemCapability.MiscServices.Pasteboard 145 * @since 7 146 * @deprecated since 9 147 * @useinstead ohos.pasteboard.pasteboard#createData 148 */ 149 function createHtmlData(htmlText: string): PasteData; 150 151 /** 152 * Creates a PasteData object for PasteData#MIMETYPE_TEXT_WANT. 153 * @param { Want } want - To save the want of content. 154 * @returns { PasteData } Containing the contents of the clipboard content object. 155 * @syscap SystemCapability.MiscServices.Pasteboard 156 * @since 7 157 * @deprecated since 9 158 * @useinstead ohos.pasteboard.pasteboard#createData 159 */ 160 function createWantData(want: Want): PasteData; 161 162 /** 163 * Creates a PasteData object for PasteData#MIMETYPE_TEXT_PLAIN. 164 * @param { string } text - To save the text of content. 165 * @returns { PasteData } Containing the contents of the clipboard content object. 166 * @syscap SystemCapability.MiscServices.Pasteboard 167 * @since 6 168 * @deprecated since 9 169 * @useinstead ohos.pasteboard.pasteboard#createData 170 */ 171 function createPlainTextData(text: string): PasteData; 172 173 /** 174 * Creates a PasteData object for PasteData#MIMETYPE_TEXT_URI. 175 * @param { string } uri - To save the uri of content. 176 * @returns { PasteData } Containing the contents of the clipboard content object. 177 * @syscap SystemCapability.MiscServices.Pasteboard 178 * @since 7 179 * @deprecated since 9 180 * @useinstead ohos.pasteboard.pasteboard#createData 181 */ 182 function createUriData(uri: string): PasteData; 183 184 /** 185 * Creates a PasteData object with MIME type and value. 186 * @param { string } mimeType - indicates MIME type of value, its size cannot be greater than 1024 bytes. 187 * @param { ValueType } value - indicates the content that is set to PasteData. 188 * @returns { PasteData } a new PasteData object which contains mimeType and value. 189 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 190 * 2. Incorrect parameters types; 191 * 3. Parameter verification failed. 192 * @syscap SystemCapability.MiscServices.Pasteboard 193 * @since 9 194 */ 195 /** 196 * Creates a PasteData object with MIME type and value. 197 * @param { string } mimeType - indicates MIME type of value, its size cannot be greater than 1024 bytes. 198 * @param { ValueType } value - indicates the content that is set to PasteData. 199 * @returns { PasteData } a new PasteData object which contains mimeType and value. 200 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 201 * 2. Incorrect parameters types; 202 * 3. Parameter verification failed. 203 * @syscap SystemCapability.MiscServices.Pasteboard 204 * @atomicservice 205 * @since 11 206 */ 207 function createData(mimeType: string, value: ValueType): PasteData; 208 209 /** 210 * Creates a Record object for PasteData#MIMETYPE_TEXT_HTML. 211 * @param { string } htmlText - To save the Html text content. 212 * @returns { PasteDataRecord } The content of a new record 213 * @syscap SystemCapability.MiscServices.Pasteboard 214 * @since 7 215 * @deprecated since 9 216 * @useinstead ohos.pasteboard.pasteboard#createRecord 217 */ 218 function createHtmlTextRecord(htmlText: string): PasteDataRecord; 219 220 /** 221 * Creates a Record object for PasteData#MIMETYPE_TEXT_WANT. 222 * @param { Want } want - To save the want of content. 223 * @returns { PasteDataRecord } The content of a new record 224 * @syscap SystemCapability.MiscServices.Pasteboard 225 * @since 7 226 * @deprecated since 9 227 * @useinstead ohos.pasteboard.pasteboard#createRecord 228 */ 229 function createWantRecord(want: Want): PasteDataRecord; 230 231 /** 232 * Creates a Record object for PasteData#MIMETYPE_TEXT_PLAIN. 233 * @param { string } text - To save the text of content. 234 * @returns { PasteDataRecord } The content of a new record 235 * @syscap SystemCapability.MiscServices.Pasteboard 236 * @since 7 237 * @deprecated since 9 238 * @useinstead ohos.pasteboard.pasteboard#createRecord 239 */ 240 function createPlainTextRecord(text: string): PasteDataRecord; 241 242 /** 243 * Creates a Record object for PasteData#MIMETYPE_TEXT_URI. 244 * @param { string } uri - To save the uri of content. 245 * @returns { PasteDataRecord } The content of a new record 246 * @syscap SystemCapability.MiscServices.Pasteboard 247 * @since 7 248 * @deprecated since 9 249 * @useinstead ohos.pasteboard.pasteboard#createRecord 250 */ 251 function createUriRecord(uri: string): PasteDataRecord; 252 253 /** 254 * Creates a record object with MIME type and value. 255 * @param { string } mimeType - indicates MIME type of value, its size cannot be greater than 1024 bytes. 256 * @param { ValueType } value - content to be saved. 257 * @returns { PasteDataRecord } a new PasteDataRecord object which contains mimeType and value. 258 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 259 * 2. Incorrect parameters types; 260 * 3. Parameter verification failed. 261 * @syscap SystemCapability.MiscServices.Pasteboard 262 * @since 9 263 */ 264 /** 265 * Creates a record object with MIME type and value. 266 * @param { string } mimeType - indicates MIME type of value, its size cannot be greater than 1024 bytes. 267 * @param { ValueType } value - content to be saved. 268 * @returns { PasteDataRecord } a new PasteDataRecord object which contains mimeType and value. 269 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 270 * 2. Incorrect parameters types; 271 * 3. Parameter verification failed. 272 * @syscap SystemCapability.MiscServices.Pasteboard 273 * @atomicservice 274 * @since 11 275 */ 276 function createRecord(mimeType: string, value: ValueType): PasteDataRecord; 277 278 /** 279 * get SystemPasteboard 280 * @returns { SystemPasteboard } The system clipboard object 281 * @syscap SystemCapability.MiscServices.Pasteboard 282 * @since 6 283 */ 284 /** 285 * get SystemPasteboard 286 * @returns { SystemPasteboard } The system clipboard object 287 * @syscap SystemCapability.MiscServices.Pasteboard 288 * @atomicservice 289 * @since 11 290 */ 291 function getSystemPasteboard(): SystemPasteboard; 292 293 /** 294 * Types of scope that PasteData can be pasted. 295 * @enum { number } 296 * @syscap SystemCapability.MiscServices.Pasteboard 297 * @since 9 298 */ 299 /** 300 * Types of scope that PasteData can be pasted. 301 * @enum { number } 302 * @syscap SystemCapability.MiscServices.Pasteboard 303 * @atomicservice 304 * @since 11 305 */ 306 enum ShareOption { 307 /** 308 * INAPP indicates that only paste in the same app is allowed. 309 * @syscap SystemCapability.MiscServices.Pasteboard 310 * @since 9 311 */ 312 /** 313 * INAPP indicates that only paste in the same app is allowed. 314 * @syscap SystemCapability.MiscServices.Pasteboard 315 * @atomicservice 316 * @since 11 317 */ 318 INAPP, 319 /** 320 * LOCALDEVICE indicates that paste in any app in this device is allowed. 321 * @syscap SystemCapability.MiscServices.Pasteboard 322 * @since 9 323 */ 324 /** 325 * LOCALDEVICE indicates that paste in any app in this device is allowed. 326 * @syscap SystemCapability.MiscServices.Pasteboard 327 * @atomicservice 328 * @since 11 329 */ 330 LOCALDEVICE, 331 /** 332 * CROSSDEVICE indicates that paste in any app across devices is allowed. 333 * @syscap SystemCapability.MiscServices.Pasteboard 334 * @since 9 335 */ 336 /** 337 * CROSSDEVICE indicates that paste in any app across devices is allowed. 338 * @syscap SystemCapability.MiscServices.Pasteboard 339 * @atomicservice 340 * @since 11 341 * @deprecated since 12 342 */ 343 CROSSDEVICE 344 } 345 346 /** 347 * Enumerates the patterns allowed in the system pasteboard. 348 * @enum { number } 349 * @syscap SystemCapability.MiscServices.Pasteboard 350 * @since 13 351 */ 352 enum Pattern { 353 /** 354 * URL pattern. 355 * @syscap SystemCapability.MiscServices.Pasteboard 356 * @since 13 357 */ 358 URL = 0, 359 /** 360 * Number pattern. 361 * @syscap SystemCapability.MiscServices.Pasteboard 362 * @since 13 363 */ 364 NUMBER = 1, 365 /** 366 * Email address pattern. 367 * @syscap SystemCapability.MiscServices.Pasteboard 368 * @since 13 369 */ 370 EMAIL_ADDRESS = 2, 371 } 372 373 374 /** 375 * Paste data property. 376 * @interface PasteDataProperty 377 * @syscap SystemCapability.MiscServices.Pasteboard 378 * @since 7 379 */ 380 /** 381 * Paste data property. 382 * @interface PasteDataProperty 383 * @syscap SystemCapability.MiscServices.Pasteboard 384 * @atomicservice 385 * @since 11 386 */ 387 interface PasteDataProperty { 388 /** 389 * additional property data. key-value pairs. 390 * @type { object } 391 * @syscap SystemCapability.MiscServices.Pasteboard 392 * @since 7 393 */ 394 /** 395 * additional property data. key-value pairs. 396 * @type { object } 397 * @syscap SystemCapability.MiscServices.Pasteboard 398 * @atomicservice 399 * @since 11 400 */ 401 additions: { 402 [key: string]: object 403 } 404 /** 405 * non-repeating MIME types of all records in PasteData. 406 * @type { Array<string> } 407 * @readonly 408 * @syscap SystemCapability.MiscServices.Pasteboard 409 * @since 7 410 */ 411 /** 412 * non-repeating MIME types of all records in PasteData. 413 * @type { Array<string> } 414 * @readonly 415 * @syscap SystemCapability.MiscServices.Pasteboard 416 * @atomicservice 417 * @since 11 418 */ 419 readonly mimeTypes: Array<string>; 420 /** 421 * the user-defined tag of a PasteData object. 422 * @type { string } 423 * @syscap SystemCapability.MiscServices.Pasteboard 424 * @since 7 425 */ 426 /** 427 * the user-defined tag of a PasteData object. 428 * @type { string } 429 * @syscap SystemCapability.MiscServices.Pasteboard 430 * @atomicservice 431 * @since 11 432 */ 433 tag: string; 434 /** 435 * a timestamp, which indicates when data is written to the system pasteboard. 436 * @type { number } 437 * @readonly 438 * @syscap SystemCapability.MiscServices.Pasteboard 439 * @since 7 440 */ 441 /** 442 * a timestamp, which indicates when data is written to the system pasteboard. 443 * @type { number } 444 * @readonly 445 * @syscap SystemCapability.MiscServices.Pasteboard 446 * @atomicservice 447 * @since 11 448 */ 449 readonly timestamp: number; 450 /** 451 * Checks whether PasteData is set for local access only. 452 * @type { boolean } 453 * @syscap SystemCapability.MiscServices.Pasteboard 454 * @since 7 455 */ 456 /** 457 * Checks whether PasteData is set for local access only. 458 * @type { boolean } 459 * @syscap SystemCapability.MiscServices.Pasteboard 460 * @atomicservice 461 * @since 11 462 */ 463 localOnly: boolean; 464 /** 465 * Indicates the scope of clipboard data which can be pasted. 466 * If it is not set or is incorrectly set, The default value is CrossDevice. 467 * @type { ShareOption } 468 * @syscap SystemCapability.MiscServices.Pasteboard 469 * @since 9 470 */ 471 /** 472 * Indicates the scope of clipboard data which can be pasted. 473 * If it is not set or is incorrectly set, The default value is CrossDevice. 474 * @type { ShareOption } 475 * @syscap SystemCapability.MiscServices.Pasteboard 476 * @atomicservice 477 * @since 11 478 */ 479 shareOption: ShareOption; 480 } 481 482 /** 483 * Paste data record. 484 * @interface PasteDataRecord 485 * @syscap SystemCapability.MiscServices.Pasteboard 486 * @since 7 487 */ 488 /** 489 * Paste data record. 490 * @interface PasteDataRecord 491 * @syscap SystemCapability.MiscServices.Pasteboard 492 * @atomicservice 493 * @since 11 494 */ 495 interface PasteDataRecord { 496 /** 497 * HTML text in a record. 498 * @type { string } 499 * @syscap SystemCapability.MiscServices.Pasteboard 500 * @since 7 501 */ 502 /** 503 * HTML text in a record. 504 * @type { string } 505 * @syscap SystemCapability.MiscServices.Pasteboard 506 * @atomicservice 507 * @since 11 508 */ 509 htmlText: string; 510 /** 511 * an want in a record. 512 * @type { Want } 513 * @syscap SystemCapability.MiscServices.Pasteboard 514 * @since 7 515 */ 516 /** 517 * an want in a record. 518 * @type { Want } 519 * @syscap SystemCapability.MiscServices.Pasteboard 520 * @atomicservice 521 * @since 11 522 */ 523 want: Want; 524 /** 525 * MIME types of a record. 526 * @type { string } 527 * @syscap SystemCapability.MiscServices.Pasteboard 528 * @since 7 529 */ 530 /** 531 * MIME types of a record. 532 * @type { string } 533 * @syscap SystemCapability.MiscServices.Pasteboard 534 * @atomicservice 535 * @since 11 536 */ 537 mimeType: string; 538 /** 539 * plain text in a record. 540 * @type { string } 541 * @syscap SystemCapability.MiscServices.Pasteboard 542 * @since 7 543 */ 544 /** 545 * plain text in a record. 546 * @type { string } 547 * @syscap SystemCapability.MiscServices.Pasteboard 548 * @atomicservice 549 * @since 11 550 */ 551 plainText: string; 552 /** 553 * an URI in a record. 554 * @type { string } 555 * @syscap SystemCapability.MiscServices.Pasteboard 556 * @since 7 557 */ 558 /** 559 * an URI in a record. 560 * @type { string } 561 * @syscap SystemCapability.MiscServices.Pasteboard 562 * @atomicservice 563 * @since 11 564 */ 565 uri: string; 566 /** 567 * PixelMap in a record. 568 * @type { image.PixelMap } 569 * @syscap SystemCapability.MiscServices.Pasteboard 570 * @since 9 571 */ 572 /** 573 * PixelMap in a record. 574 * @type { image.PixelMap } 575 * @syscap SystemCapability.MiscServices.Pasteboard 576 * @atomicservice 577 * @since 11 578 */ 579 pixelMap: image.PixelMap; 580 /** 581 * Custom data in a record, mimeType indicates the MIME type of custom data, ArrayBuffer indicates the value of custom data. 582 * @type { object } 583 * @syscap SystemCapability.MiscServices.Pasteboard 584 * @since 9 585 */ 586 /** 587 * Custom data in a record, mimeType indicates the MIME type of custom data, ArrayBuffer indicates the value of custom data. 588 * @type { object } 589 * @syscap SystemCapability.MiscServices.Pasteboard 590 * @atomicservice 591 * @since 11 592 */ 593 data: { 594 [mimeType: string]: ArrayBuffer 595 } 596 597 /** 598 * Converts data in PasteData to text format. 599 * @param { AsyncCallback<string> } callback - the callback of convertToText. 600 * @throws { BusinessError } 401 - Possible causes: Incorrect parameters types. 601 * @syscap SystemCapability.MiscServices.Pasteboard 602 * @since 7 603 * @deprecated since 9 604 * @useinstead ohos.pasteboard.pasteboard#convertToTextV9 605 */ 606 convertToText(callback: AsyncCallback<string>): void; 607 608 /** 609 * Converts data in PasteData to text format. 610 * @returns { Promise<string> } the promise returned by the function. 611 * @syscap SystemCapability.MiscServices.Pasteboard 612 * @since 7 613 * @deprecated since 9 614 * @useinstead ohos.pasteboard.pasteboard#convertToTextV9 615 */ 616 convertToText(): Promise<string>; 617 618 /** 619 * Converts data in PasteData to text format. 620 * @returns { string } the string returned by the function. 621 * @syscap SystemCapability.MiscServices.Pasteboard 622 * @since 9 623 */ 624 /** 625 * Converts data in PasteData to text format. 626 * @returns { string } the string returned by the function. 627 * @syscap SystemCapability.MiscServices.Pasteboard 628 * @atomicservice 629 * @since 11 630 */ 631 toPlainText(): string; 632 } 633 634 /** 635 * Classes for paste data. 636 * @interface PasteData 637 * @syscap SystemCapability.MiscServices.Pasteboard 638 * @since 6 639 */ 640 /** 641 * Classes for paste data. 642 * @interface PasteData 643 * @syscap SystemCapability.MiscServices.Pasteboard 644 * @atomicservice 645 * @since 11 646 */ 647 interface PasteData { 648 /** 649 * Adds a Record for HTML text to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_HTML in DataProperty. 650 * @param { string } htmlText - To save the Html text content. 651 * @syscap SystemCapability.MiscServices.Pasteboard 652 * @since 7 653 * @deprecated since 9 654 * @useinstead ohos.pasteboard.pasteboard#addRecord 655 */ 656 addHtmlRecord(htmlText: string): void; 657 658 /** 659 * Adds an want Record to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_WANT in DataProperty. 660 * @param { Want } want - To save the want content. 661 * @syscap SystemCapability.MiscServices.Pasteboard 662 * @since 7 663 * @deprecated since 9 664 * @useinstead ohos.pasteboard.pasteboard#addRecord 665 */ 666 addWantRecord(want: Want): void; 667 668 /** 669 * Adds a PasteRecord to a PasteData object and updates MIME types in DataProperty. 670 * @param { PasteDataRecord } record - The content of a new record. 671 * @syscap SystemCapability.MiscServices.Pasteboard 672 * @since 7 673 */ 674 /** 675 * Adds a PasteRecord to a PasteData object and updates MIME types in DataProperty. 676 * @param { PasteDataRecord } record - The content of a new record. 677 * @syscap SystemCapability.MiscServices.Pasteboard 678 * @atomicservice 679 * @since 11 680 */ 681 addRecord(record: PasteDataRecord): void; 682 683 /** 684 * Adds a Record for plain text to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_PLAIN in DataProperty. 685 * @param { string } text - To save the text of content. 686 * @syscap SystemCapability.MiscServices.Pasteboard 687 * @since 7 688 * @deprecated since 9 689 * @useinstead ohos.pasteboard.pasteboard#addRecord 690 */ 691 addTextRecord(text: string): void; 692 693 /** 694 * Adds a URI Record to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_URI in DataProperty. 695 * @param { string } uri - To save the uri of content. 696 * @syscap SystemCapability.MiscServices.Pasteboard 697 * @since 7 698 * @deprecated since 9 699 * @useinstead ohos.pasteboard.pasteboard#addRecord 700 */ 701 addUriRecord(uri: string): void; 702 703 /** 704 * Adds a record with mimeType and value to a PasteData object. 705 * @param { string } mimeType - indicates the MIME type of value, its size cannot be greater than 1024 bytes. 706 * @param { ValueType } value - content to be saved. 707 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 708 * 2. Incorrect parameters types; 709 * 3. Parameter verification failed. 710 * @throws { BusinessError } 12900002 - The number of records exceeds the upper limit. 711 * @syscap SystemCapability.MiscServices.Pasteboard 712 * @since 9 713 */ 714 /** 715 * Adds a record with mimeType and value to a PasteData object. 716 * @param { string } mimeType - indicates the MIME type of value, its size cannot be greater than 1024 bytes. 717 * @param { ValueType } value - content to be saved. 718 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 719 * 2. Incorrect parameters types; 720 * 3. Parameter verification failed. 721 * @syscap SystemCapability.MiscServices.Pasteboard 722 * @since 10 723 */ 724 /** 725 * Adds a record with mimeType and value to a PasteData object. 726 * @param { string } mimeType - indicates the MIME type of value, its size cannot be greater than 1024 bytes. 727 * @param { ValueType } value - content to be saved. 728 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 729 * 2. Incorrect parameters types; 730 * 3. Parameter verification failed. 731 * @syscap SystemCapability.MiscServices.Pasteboard 732 * @atomicservice 733 * @since 11 734 */ 735 addRecord(mimeType: string, value: ValueType): void; 736 737 /** 738 * MIME types of all content on the pasteboard. 739 * @returns { Array<string> } type of array 740 * @syscap SystemCapability.MiscServices.Pasteboard 741 * @since 7 742 */ 743 /** 744 * MIME types of all content on the pasteboard. 745 * @returns { Array<string> } type of array 746 * @syscap SystemCapability.MiscServices.Pasteboard 747 * @atomicservice 748 * @since 11 749 */ 750 getMimeTypes(): Array<string>; 751 752 /** 753 * HTML text of the primary record in a PasteData object. 754 * @returns { string } type of htmltext 755 * @syscap SystemCapability.MiscServices.Pasteboard 756 * @since 7 757 */ 758 /** 759 * HTML text of the primary record in a PasteData object. 760 * @returns { string } type of htmltext 761 * @syscap SystemCapability.MiscServices.Pasteboard 762 * @atomicservice 763 * @since 11 764 */ 765 getPrimaryHtml(): string; 766 767 /** 768 * the want of the primary record in a PasteData object. 769 * @returns { Want } type of want 770 * @syscap SystemCapability.MiscServices.Pasteboard 771 * @since 7 772 */ 773 /** 774 * the want of the primary record in a PasteData object. 775 * @returns { Want } type of want 776 * @syscap SystemCapability.MiscServices.Pasteboard 777 * @atomicservice 778 * @since 11 779 */ 780 getPrimaryWant(): Want; 781 782 /** 783 * the MIME type of the primary record in a PasteData object. 784 * @returns { string } type of mimetype 785 * @syscap SystemCapability.MiscServices.Pasteboard 786 * @since 7 787 */ 788 /** 789 * the MIME type of the primary record in a PasteData object. 790 * @returns { string } type of mimetype 791 * @syscap SystemCapability.MiscServices.Pasteboard 792 * @atomicservice 793 * @since 11 794 */ 795 getPrimaryMimeType(): string; 796 797 /** 798 * the plain text of the primary record in a PasteData object. 799 * @returns { string } type of text 800 * @syscap SystemCapability.MiscServices.Pasteboard 801 * @since 6 802 */ 803 /** 804 * the plain text of the primary record in a PasteData object. 805 * @returns { string } type of text 806 * @syscap SystemCapability.MiscServices.Pasteboard 807 * @atomicservice 808 * @since 11 809 */ 810 getPrimaryText(): string; 811 812 /** 813 * the URI of the primary record in a PasteData object. 814 * @returns { string } type of uri 815 * @syscap SystemCapability.MiscServices.Pasteboard 816 * @since 7 817 */ 818 /** 819 * the URI of the primary record in a PasteData object. 820 * @returns { string } type of uri 821 * @syscap SystemCapability.MiscServices.Pasteboard 822 * @atomicservice 823 * @since 11 824 */ 825 getPrimaryUri(): string; 826 827 /** 828 * Gets the primary PixelMap record in a PasteData object. 829 * @returns { image.PixelMap } pixelMap 830 * @syscap SystemCapability.MiscServices.Pasteboard 831 * @since 9 832 */ 833 /** 834 * Gets the primary PixelMap record in a PasteData object. 835 * @returns { image.PixelMap } pixelMap 836 * @syscap SystemCapability.MiscServices.Pasteboard 837 * @atomicservice 838 * @since 11 839 */ 840 getPrimaryPixelMap(): image.PixelMap; 841 842 /** 843 * DataProperty of a PasteData object. 844 * @returns { PasteDataProperty } PasteDataProperty type of PasteDataProperty 845 * @syscap SystemCapability.MiscServices.Pasteboard 846 * @since 7 847 */ 848 /** 849 * DataProperty of a PasteData object. 850 * @returns { PasteDataProperty } PasteDataProperty type of PasteDataProperty 851 * @syscap SystemCapability.MiscServices.Pasteboard 852 * @atomicservice 853 * @since 11 854 */ 855 getProperty(): PasteDataProperty; 856 857 /** 858 * Sets PasteDataProperty to a PasteData object, Modifying shareOption is supported only. 859 * @param { PasteDataProperty } property - save property to PasteData object. 860 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 861 * 2. Incorrect parameters types. 862 * @syscap SystemCapability.MiscServices.Pasteboard 863 * @since 9 864 */ 865 /** 866 * Sets PasteDataProperty to a PasteData object, Modifying shareOption is supported only. 867 * @param { PasteDataProperty } property - save property to PasteData object. 868 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 869 * 2. Incorrect parameters types. 870 * @syscap SystemCapability.MiscServices.Pasteboard 871 * @atomicservice 872 * @since 11 873 */ 874 setProperty(property: PasteDataProperty): void; 875 876 /** 877 * Gets record by index in PasteData. 878 * @param { number } index - indicates the record index in PasteData. 879 * @returns { PasteDataRecord } the record in PasteData with index. 880 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 881 * 2. Incorrect parameters types. 882 * @syscap SystemCapability.MiscServices.Pasteboard 883 * @since 7 884 * @deprecated since 9 885 * @useinstead ohos.pasteboard.pasteboard#getRecord 886 */ 887 getRecordAt(index: number): PasteDataRecord; 888 889 /** 890 * Gets record by index in PasteData. 891 * @param { number } index - indicates the record index in PasteData. 892 * @returns { PasteDataRecord } the record in PasteData with index. 893 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 894 * 2. Incorrect parameters types. 895 * @throws { BusinessError } 12900001 - The index is out of the record. 896 * @syscap SystemCapability.MiscServices.Pasteboard 897 * @since 9 898 */ 899 /** 900 * Gets record by index in PasteData. 901 * @param { number } index - indicates the record index in PasteData. 902 * @returns { PasteDataRecord } the record in PasteData with index. 903 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 904 * 2. Incorrect parameters types. 905 * @throws { BusinessError } 12900001 - The index is out of the record. 906 * @syscap SystemCapability.MiscServices.Pasteboard 907 * @atomicservice 908 * @since 11 909 */ 910 getRecord(index: number): PasteDataRecord; 911 912 /** 913 * the number of records in a PasteData object. 914 * @returns { number } The number of the clipboard contents 915 * @syscap SystemCapability.MiscServices.Pasteboard 916 * @since 7 917 */ 918 /** 919 * the number of records in a PasteData object. 920 * @returns { number } The number of the clipboard contents 921 * @syscap SystemCapability.MiscServices.Pasteboard 922 * @atomicservice 923 * @since 11 924 */ 925 getRecordCount(): number; 926 927 /** 928 * the user-defined tag of a PasteData object. 929 * @returns { string } type of tag 930 * @syscap SystemCapability.MiscServices.Pasteboard 931 * @since 7 932 */ 933 /** 934 * the user-defined tag of a PasteData object. 935 * @returns { string } type of tag 936 * @syscap SystemCapability.MiscServices.Pasteboard 937 * @atomicservice 938 * @since 11 939 */ 940 getTag(): string; 941 942 /** 943 * Checks whether there is a specified MIME type of data in DataProperty. 944 * @param { string } mimeType - indicates to query data type. 945 * @returns { boolean } if having mimeType in PasteData returns true, else returns false. 946 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 947 * 2. Incorrect parameters types. 948 * @syscap SystemCapability.MiscServices.Pasteboard 949 * @since 7 950 * @deprecated since 9 951 * @useinstead ohos.pasteboard.pasteboard#hasType 952 */ 953 hasMimeType(mimeType: string): boolean; 954 955 /** 956 * Checks whether there is a specified MIME type of data in DataProperty. 957 * @param { string } mimeType - indicates to query data type. 958 * @returns { boolean } if having mimeType in PasteData returns true, else returns false. 959 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 960 * 2. Incorrect parameters types. 961 * @syscap SystemCapability.MiscServices.Pasteboard 962 * @since 9 963 */ 964 /** 965 * Checks whether there is a specified MIME type of data in DataProperty. 966 * @param { string } mimeType - indicates to query data type. 967 * @returns { boolean } if having mimeType in PasteData returns true, else returns false. 968 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 969 * 2. Incorrect parameters types. 970 * @syscap SystemCapability.MiscServices.Pasteboard 971 * @atomicservice 972 * @since 11 973 */ 974 hasType(mimeType: string): boolean; 975 976 /** 977 * Removes a Record based on a specified index. 978 * @param { number } index - indicates the record index in PasteData. 979 * @returns { boolean } The query returns True on success, or False on failure. 980 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 981 * 2. Incorrect parameters types. 982 * @syscap SystemCapability.MiscServices.Pasteboard 983 * @since 7 984 * @deprecated since 9 985 * @useinstead ohos.pasteboard.pasteboard#removeRecord 986 */ 987 removeRecordAt(index: number): boolean; 988 989 /** 990 * Removes a Record based on a specified index. 991 * @param { number } index - indicates the record index in PasteData. 992 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 993 * 2. Incorrect parameters types. 994 * @throws { BusinessError } 12900001 - The index is out of the record. 995 * @syscap SystemCapability.MiscServices.Pasteboard 996 * @since 9 997 */ 998 /** 999 * Removes a Record based on a specified index. 1000 * @param { number } index - indicates the record index in PasteData. 1001 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1002 * 2. Incorrect parameters types. 1003 * @throws { BusinessError } 12900001 - The index is out of the record. 1004 * @syscap SystemCapability.MiscServices.Pasteboard 1005 * @atomicservice 1006 * @since 11 1007 */ 1008 removeRecord(index: number): void; 1009 1010 /** 1011 * Replaces a specified record with a new one. 1012 * @param { number } index - indicates the record index in PasteData. 1013 * @param { PasteDataRecord } record - the content of a new record. 1014 * @returns { boolean } The query returns True on success, or False on failure. 1015 * @syscap SystemCapability.MiscServices.Pasteboard 1016 * @since 7 1017 * @deprecated since 9 1018 * @useinstead ohos.pasteboard.pasteboard#replaceRecord 1019 */ 1020 replaceRecordAt(index: number, record: PasteDataRecord): boolean; 1021 1022 /** 1023 * Replaces a specified record with a new one. 1024 * @param { number } index - indicates the record index in PasteData. 1025 * @param { PasteDataRecord } record - the content of a new record. 1026 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1027 * 2. Incorrect parameters types. 1028 * @throws { BusinessError } 12900001 - The index is out of the record. 1029 * @syscap SystemCapability.MiscServices.Pasteboard 1030 * @since 9 1031 */ 1032 /** 1033 * Replaces a specified record with a new one. 1034 * @param { number } index - indicates the record index in PasteData. 1035 * @param { PasteDataRecord } record - the content of a new record. 1036 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1037 * 2. Incorrect parameters types. 1038 * @throws { BusinessError } 12900001 - The index is out of the record. 1039 * @syscap SystemCapability.MiscServices.Pasteboard 1040 * @atomicservice 1041 * @since 11 1042 */ 1043 replaceRecord(index: number, record: PasteDataRecord): void; 1044 1045 /** 1046 * Utilized to notify pasteboard service while reading PasteData, in this case, the service will help to preserve the context and resources 1047 * @syscap SystemCapability.MiscServices.Pasteboard 1048 * @since 12 1049 */ 1050 pasteStart(): void; 1051 1052 /** 1053 * Invoked to notify pasteboard service the utilization of PasteData has completed and occupied resources can be released for further usage 1054 * @syscap SystemCapability.MiscServices.Pasteboard 1055 * @since 12 1056 */ 1057 pasteComplete(): void; 1058 } 1059 1060 /** 1061 * Classes for system pasteboard. 1062 * @interface SystemPasteboard 1063 * @syscap SystemCapability.MiscServices.Pasteboard 1064 * @since 6 1065 */ 1066 /** 1067 * Classes for system pasteboard. 1068 * @interface SystemPasteboard 1069 * @syscap SystemCapability.MiscServices.Pasteboard 1070 * @atomicservice 1071 * @since 11 1072 */ 1073 interface SystemPasteboard { 1074 /** 1075 * Callback invoked when pasteboard content changes. 1076 * @param { 'update' } type - indicates pasteboard content changed. 1077 * @param { function } callback - the callback to add. 1078 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1079 * 2. Incorrect parameters types. 1080 * @syscap SystemCapability.MiscServices.Pasteboard 1081 * @since 7 1082 */ 1083 on(type: 'update', callback: () => void): void; 1084 1085 /** 1086 * Remove a callback invoked when pasteboard content changes. 1087 * @param { 'update' } type - indicates pasteboard content changed. 1088 * @param { function } [callback] - the callback to remove. If this parameter is not filled in, it indicates that all 1089 * callbacks for this application will be cleared. Otherwise, it indicates that the specified callback will be cleared. 1090 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1091 * 2. Incorrect parameters types. 1092 * @syscap SystemCapability.MiscServices.Pasteboard 1093 * @since 7 1094 */ 1095 off(type: 'update', callback?: () => void): void; 1096 1097 /** 1098 * Checks whether the data is remote. 1099 * @returns { boolean } True is remote data, else false. 1100 * @throws { BusinessError } 12900005 - Request timed out. 1101 * @syscap SystemCapability.MiscServices.Pasteboard 1102 * @atomicservice 1103 * @since 11 1104 */ 1105 isRemoteData(): boolean; 1106 1107 /** 1108 * Gets source of data. 1109 * @returns { string } data source. 1110 * @throws { BusinessError } 12900005 - Request timed out. 1111 * @syscap SystemCapability.MiscServices.Pasteboard 1112 * @atomicservice 1113 * @since 11 1114 */ 1115 getDataSource(): string; 1116 1117 /** 1118 * Checks whether there is a specified MIME type of data in Data. 1119 * @param { string } mimeType - indicates to query data type. 1120 * @returns { boolean } if having mimeType in PasteData returns true, else returns false. 1121 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1122 * 2. Incorrect parameters types. 1123 * @throws { BusinessError } 12900005 - Request timed out. 1124 * @syscap SystemCapability.MiscServices.Pasteboard 1125 * @atomicservice 1126 * @since 11 1127 */ 1128 hasDataType(mimeType: string): boolean; 1129 1130 /** 1131 * Clears the pasteboard. 1132 * @param { AsyncCallback<void> } callback - the callback of clearData. 1133 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1134 * 2. Incorrect parameters types. 1135 * @syscap SystemCapability.MiscServices.Pasteboard 1136 * @since 7 1137 * @deprecated since 9 1138 * @useinstead ohos.pasteboard.pasteboard#clearData 1139 */ 1140 clear(callback: AsyncCallback<void>): void; 1141 1142 /** 1143 * Clears the pasteboard. 1144 * @returns { Promise<void> } the promise returned by the clearData. 1145 * @syscap SystemCapability.MiscServices.Pasteboard 1146 * @since 7 1147 * @deprecated since 9 1148 * @useinstead ohos.pasteboard.pasteboard#clearData 1149 */ 1150 clear(): Promise<void>; 1151 1152 /** 1153 * Clears the pasteboard. 1154 * @param { AsyncCallback<void> } callback - the callback of clearData. 1155 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1156 * 2. Incorrect parameters types. 1157 * @syscap SystemCapability.MiscServices.Pasteboard 1158 * @since 9 1159 */ 1160 /** 1161 * Clears the pasteboard. 1162 * @param { AsyncCallback<void> } callback - the callback of clearData. 1163 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1164 * 2. Incorrect parameters types. 1165 * @syscap SystemCapability.MiscServices.Pasteboard 1166 * @atomicservice 1167 * @since 11 1168 */ 1169 clearData(callback: AsyncCallback<void>): void; 1170 1171 /** 1172 * Clears the pasteboard. 1173 * @returns { Promise<void> } the promise returned by the clearData. 1174 * @syscap SystemCapability.MiscServices.Pasteboard 1175 * @since 9 1176 */ 1177 /** 1178 * Clears the pasteboard. 1179 * @returns { Promise<void> } the promise returned by the clearData. 1180 * @syscap SystemCapability.MiscServices.Pasteboard 1181 * @atomicservice 1182 * @since 11 1183 */ 1184 clearData(): Promise<void>; 1185 1186 /** 1187 * Clears the pasteboard. 1188 * @throws { BusinessError } 12900005 - Request timed out. 1189 * @syscap SystemCapability.MiscServices.Pasteboard 1190 * @atomicservice 1191 * @since 11 1192 */ 1193 clearDataSync(): void; 1194 1195 /** 1196 * Gets pastedata from the system pasteboard. 1197 * @param { AsyncCallback<PasteData> } callback - the callback of getData. 1198 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1199 * 2. Incorrect parameters types. 1200 * @syscap SystemCapability.MiscServices.Pasteboard 1201 * @since 6 1202 * @deprecated since 9 1203 * @useinstead ohos.pasteboard.pasteboard#getData 1204 */ 1205 getPasteData(callback: AsyncCallback<PasteData>): void; 1206 1207 /** 1208 * Gets pastedata from the system pasteboard. 1209 * @returns { Promise<PasteData> } the promise returned by the getData. 1210 * @syscap SystemCapability.MiscServices.Pasteboard 1211 * @since 6 1212 * @deprecated since 9 1213 * @useinstead ohos.pasteboard.pasteboard#getData 1214 */ 1215 getPasteData(): Promise<PasteData>; 1216 1217 /** 1218 * Gets pastedata from the system pasteboard. 1219 * @param { AsyncCallback<PasteData> } callback - the callback of getData. 1220 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1221 * 2. Incorrect parameters types. 1222 * @throws { BusinessError } 12900003 - Another copy or paste operation is in progress. 1223 * @syscap SystemCapability.MiscServices.Pasteboard 1224 * @since 9 1225 */ 1226 /** 1227 * Gets pastedata from the system pasteboard. 1228 * @param { AsyncCallback<PasteData> } callback - the callback of getData. 1229 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1230 * 2. Incorrect parameters types. 1231 * @throws { BusinessError } 12900003 - Another copy or paste operation is in progress. 1232 * @syscap SystemCapability.MiscServices.Pasteboard 1233 * @atomicservice 1234 * @since 11 1235 */ 1236 /** 1237 * Gets pastedata from the system pasteboard. 1238 * @permission ohos.permission.READ_PASTEBOARD 1239 * @param { AsyncCallback<PasteData> } callback - the callback of getData. 1240 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the 1241 * permission required to call the API. 1242 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1243 * 2. Incorrect parameters types. 1244 * @throws { BusinessError } 12900003 - Another copy or paste operation is in progress. 1245 * @syscap SystemCapability.MiscServices.Pasteboard 1246 * @atomicservice 1247 * @since 12 1248 */ 1249 getData(callback: AsyncCallback<PasteData>): void; 1250 1251 /** 1252 * Gets pastedata from the system pasteboard. 1253 * @returns { Promise<PasteData> } the promise returned by the getData. 1254 * @throws { BusinessError } 12900003 - Another copy or paste operation is in progress. 1255 * @syscap SystemCapability.MiscServices.Pasteboard 1256 * @since 9 1257 */ 1258 /** 1259 * Gets pastedata from the system pasteboard. 1260 * @returns { Promise<PasteData> } the promise returned by the getData. 1261 * @throws { BusinessError } 12900003 - Another copy or paste operation is in progress. 1262 * @syscap SystemCapability.MiscServices.Pasteboard 1263 * @atomicservice 1264 * @since 11 1265 */ 1266 /** 1267 * Gets pastedata from the system pasteboard. 1268 * @permission ohos.permission.READ_PASTEBOARD 1269 * @returns { Promise<PasteData> } the promise returned by the getData. 1270 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the 1271 * permission required to call the API. 1272 * @throws { BusinessError } 12900003 - Another copy or paste operation is in progress. 1273 * @syscap SystemCapability.MiscServices.Pasteboard 1274 * @atomicservice 1275 * @since 12 1276 */ 1277 getData(): Promise<PasteData>; 1278 1279 /** 1280 * Gets pasteData from the system pasteboard. 1281 * @returns { PasteData } a new PasteData. 1282 * @throws { BusinessError } 12900005 - Request timed out. 1283 * @syscap SystemCapability.MiscServices.Pasteboard 1284 * @atomicservice 1285 * @since 11 1286 */ 1287 /** 1288 * Gets pasteData from the system pasteboard. 1289 * @permission ohos.permission.READ_PASTEBOARD 1290 * @returns { PasteData } a new PasteData. 1291 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the 1292 * permission required to call the API. 1293 * @throws { BusinessError } 12900005 - Request timed out. 1294 * @syscap SystemCapability.MiscServices.Pasteboard 1295 * @atomicservice 1296 * @since 12 1297 */ 1298 getDataSync(): PasteData; 1299 1300 /** 1301 * Checks whether there is content in the pasteboard. 1302 * @param { AsyncCallback<boolean> } callback - the callback of setPasteData. 1303 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1304 * 2. Incorrect parameters types. 1305 * @syscap SystemCapability.MiscServices.Pasteboard 1306 * @since 7 1307 * @deprecated since 9 1308 * @useinstead ohos.pasteboard.pasteboard#hasData 1309 */ 1310 hasPasteData(callback: AsyncCallback<boolean>): void; 1311 1312 /** 1313 * Checks whether there is content in the pasteboard. 1314 * @returns { Promise<boolean> } the promise returned by the function. 1315 * @syscap SystemCapability.MiscServices.Pasteboard 1316 * @since 7 1317 * @deprecated since 9 1318 * @useinstead ohos.pasteboard.pasteboard#hasData 1319 */ 1320 hasPasteData(): Promise<boolean>; 1321 1322 /** 1323 * Checks whether there is content in the system pasteboard. 1324 * @param { AsyncCallback<boolean> } callback - the callback of hasData. 1325 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1326 * 2. Incorrect parameters types. 1327 * @syscap SystemCapability.MiscServices.Pasteboard 1328 * @since 9 1329 */ 1330 /** 1331 * Checks whether there is content in the system pasteboard. 1332 * @param { AsyncCallback<boolean> } callback - the callback of hasData. 1333 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1334 * 2. Incorrect parameters types. 1335 * @syscap SystemCapability.MiscServices.Pasteboard 1336 * @atomicservice 1337 * @since 11 1338 */ 1339 hasData(callback: AsyncCallback<boolean>): void; 1340 1341 /** 1342 * Checks whether there is content in the system pasteboard. 1343 * @returns { Promise<boolean> } the promise returned by the function. 1344 * @syscap SystemCapability.MiscServices.Pasteboard 1345 * @since 9 1346 */ 1347 /** 1348 * Checks whether there is content in the system pasteboard. 1349 * @returns { Promise<boolean> } the promise returned by the function. 1350 * @syscap SystemCapability.MiscServices.Pasteboard 1351 * @atomicservice 1352 * @since 11 1353 */ 1354 hasData(): Promise<boolean>; 1355 1356 /** 1357 * Checks whether there is content in the system pasteboard. 1358 * @returns { boolean } True exists, false does not exist. 1359 * @throws { BusinessError } 12900005 - Request timed out. 1360 * @syscap SystemCapability.MiscServices.Pasteboard 1361 * @atomicservice 1362 * @since 11 1363 */ 1364 hasDataSync(): boolean; 1365 1366 /** 1367 * Writes PasteData to the pasteboard. 1368 * @param { PasteData } data - PasteData will be written to the clipboard 1369 * @param { AsyncCallback<void> } callback - the callback of setPasteData. 1370 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1371 * 2. Incorrect parameters types. 1372 * @syscap SystemCapability.MiscServices.Pasteboard 1373 * @since 6 1374 * @deprecated since 9 1375 * @useinstead ohos.pasteboard.pasteboard#setData 1376 */ 1377 setPasteData(data: PasteData, callback: AsyncCallback<void>): void; 1378 1379 /** 1380 * Writes PasteData to the pasteboard. 1381 * @param { PasteData } data - Containing the contents of the clipboard content object. 1382 * @returns { Promise<void> } the promise returned by the function. 1383 * @syscap SystemCapability.MiscServices.Pasteboard 1384 * @since 6 1385 * @deprecated since 9 1386 * @useinstead ohos.pasteboard.pasteboard#setData 1387 */ 1388 setPasteData(data: PasteData): Promise<void>; 1389 1390 /** 1391 * Writes PasteData to the system pasteboard. 1392 * @param { PasteData } data - PasteData will be written to the clipboard 1393 * @param { AsyncCallback<void> } callback - the callback of setData. 1394 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified. 1395 * 2. Incorrect parameters types. 1396 * @throws { BusinessError } 12900003 - Another copy or paste operation is in progress. 1397 * @throws { BusinessError } 12900004 - Replication is prohibited. 1398 * @syscap SystemCapability.MiscServices.Pasteboard 1399 * @since 9 1400 */ 1401 /** 1402 * Writes PasteData to the system pasteboard. 1403 * @param { PasteData } data - PasteData will be written to the clipboard 1404 * @param { AsyncCallback<void> } callback - the callback of setData. 1405 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1406 * 2. Incorrect parameters types. 1407 * @throws { BusinessError } 12900003 - Another copy or paste operation is in progress. 1408 * @throws { BusinessError } 12900004 - Replication is prohibited. 1409 * @syscap SystemCapability.MiscServices.Pasteboard 1410 * @atomicservice 1411 * @since 11 1412 */ 1413 setData(data: PasteData, callback: AsyncCallback<void>): void; 1414 1415 /** 1416 * Writes PasteData to the system pasteboard. 1417 * @param { PasteData } data - PasteData will be written to the clipboard. 1418 * @returns { Promise<void> } the promise returned by the function. 1419 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1420 * 2. Incorrect parameters types. 1421 * @throws { BusinessError } 12900003 - Another copy or paste operation is in progress. 1422 * @throws { BusinessError } 12900004 - Replication is prohibited. 1423 * @syscap SystemCapability.MiscServices.Pasteboard 1424 * @since 9 1425 */ 1426 /** 1427 * Writes PasteData to the system pasteboard. 1428 * @param { PasteData } data - PasteData will be written to the clipboard. 1429 * @returns { Promise<void> } the promise returned by the function. 1430 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1431 * 2. Incorrect parameters types. 1432 * @throws { BusinessError } 12900003 - Another copy or paste operation is in progress. 1433 * @throws { BusinessError } 12900004 - Replication is prohibited. 1434 * @syscap SystemCapability.MiscServices.Pasteboard 1435 * @atomicservice 1436 * @since 11 1437 */ 1438 setData(data: PasteData): Promise<void>; 1439 1440 /** 1441 * Writes PasteData to the system pasteboard. 1442 * @param { PasteData } data - PasteData will be written to the clipboard. 1443 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1444 * 2. Incorrect parameters types. 1445 * @throws { BusinessError } 12900005 - Request timed out. 1446 * @syscap SystemCapability.MiscServices.Pasteboard 1447 * @atomicservice 1448 * @since 11 1449 */ 1450 setDataSync(data: PasteData): void; 1451 1452 /** 1453 * Gets unified data from the system pasteboard. 1454 * @permission ohos.permission.READ_PASTEBOARD 1455 * @returns { Promise<unifiedDataChannel.UnifiedData> } the promise returned by the getData. 1456 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the 1457 * permission required to call the API. 1458 * @throws { BusinessError } 12900003 - Another copy or paste operation is in progress. 1459 * @syscap SystemCapability.MiscServices.Pasteboard 1460 * @atomicservice 1461 * @since 12 1462 */ 1463 getUnifiedData(): Promise<unifiedDataChannel.UnifiedData>; 1464 1465 /** 1466 * Gets unified data from the system pasteboard. 1467 * @permission ohos.permission.READ_PASTEBOARD 1468 * @returns { unifiedDataChannel.UnifiedData } a new UnifiedData. 1469 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the 1470 * permission required to call the API. 1471 * @throws { BusinessError } 12900005 - Request timed out. 1472 * @syscap SystemCapability.MiscServices.Pasteboard 1473 * @atomicservice 1474 * @since 12 1475 */ 1476 getUnifiedDataSync(): unifiedDataChannel.UnifiedData; 1477 1478 /** 1479 * Writes unified data to the system pasteboard. 1480 * @param { unifiedDataChannel.UnifiedData } data - Unified data will be written to the pasteboard. 1481 * @returns { Promise<void> } the promise returned by the function. 1482 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1483 * 2. Incorrect parameters types. 1484 * @throws { BusinessError } 12900003 - Another copy or paste operation is in progress. 1485 * @throws { BusinessError } 12900004 - Replication is prohibited. 1486 * @syscap SystemCapability.MiscServices.Pasteboard 1487 * @atomicservice 1488 * @since 12 1489 */ 1490 setUnifiedData(data: unifiedDataChannel.UnifiedData): Promise<void>; 1491 1492 /** 1493 * Writes unified data to the system pasteboard. 1494 * @param { unifiedDataChannel.UnifiedData } data - Unified data will be written to the pasteboard. 1495 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1496 * 2. Incorrect parameters types. 1497 * @throws { BusinessError } 12900005 - Request timed out. 1498 * @syscap SystemCapability.MiscServices.Pasteboard 1499 * @atomicservice 1500 * @since 12 1501 */ 1502 setUnifiedDataSync(data: unifiedDataChannel.UnifiedData): void; 1503 1504 /** 1505 * Sets a unified ShareOptions for your application, so that the PasteData copied from your application is applicable to this ShareOptions. 1506 * 1507 * @param { ShareOption } shareOptions - Scope that PasteData can be pasted. 1508 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1509 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1510 * 2. Incorrect parameter types; 1511 * 3. Parameter verification failed. 1512 * @throws { BusinessError } 12900006 - Settings already exist. 1513 * @syscap SystemCapability.MiscServices.Pasteboard 1514 * @systemapi 1515 * @since 12 1516 */ 1517 setAppShareOptions(shareOptions: ShareOption): void; 1518 1519 /** 1520 * Removes the unified ShareOptions of your application. 1521 * 1522 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1523 * @syscap SystemCapability.MiscServices.Pasteboard 1524 * @systemapi 1525 * @since 12 1526 */ 1527 removeAppShareOptions(): void; 1528 1529 /** 1530 * Detects the patterns in the pasteboard. 1531 * 1532 * @param { Array<Pattern> } patterns - Patterns to detect. 1533 * @returns { Promise<Array<Pattern>> } Promise used to return the patterns detected. 1534 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1535 * 2. Incorrect parameter types; 1536 * 3. Parameter verification failed. 1537 * @syscap SystemCapability.MiscServices.Pasteboard 1538 * @since 13 1539 */ 1540 detectPatterns(patterns: Array<Pattern>): Promise<Array<Pattern>>; 1541 } 1542} 1543 1544export default pasteboard;