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 = 512; 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 = 'text/html'; 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 = 'text/want'; 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 = 'text/plain'; 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 = 'text/uri'; 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 = 'pixelMap'; 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 PasteData object with the specified MIME types and values. 211 * @param { Record<string, ValueType> } data - indicates the MEME types and values of the PasteData object to create. 212 * @returns { PasteData } Returns the PasteData object created. 213 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 214 * 2. Incorrect parameters types; 215 * 3. Parameter verification failed. 216 * @syscap SystemCapability.MiscServices.Pasteboard 217 * @since 14 218 */ 219 function createData(data: Record<string, ValueType>): PasteData; 220 221 /** 222 * Creates a Record object for PasteData#MIMETYPE_TEXT_HTML. 223 * @param { string } htmlText - To save the Html text content. 224 * @returns { PasteDataRecord } The content of a new record 225 * @syscap SystemCapability.MiscServices.Pasteboard 226 * @since 7 227 * @deprecated since 9 228 * @useinstead ohos.pasteboard.pasteboard#createRecord 229 */ 230 function createHtmlTextRecord(htmlText: string): PasteDataRecord; 231 232 /** 233 * Creates a Record object for PasteData#MIMETYPE_TEXT_WANT. 234 * @param { Want } want - To save the want of content. 235 * @returns { PasteDataRecord } The content of a new record 236 * @syscap SystemCapability.MiscServices.Pasteboard 237 * @since 7 238 * @deprecated since 9 239 * @useinstead ohos.pasteboard.pasteboard#createRecord 240 */ 241 function createWantRecord(want: Want): PasteDataRecord; 242 243 /** 244 * Creates a Record object for PasteData#MIMETYPE_TEXT_PLAIN. 245 * @param { string } text - To save the text of content. 246 * @returns { PasteDataRecord } The content of a new record 247 * @syscap SystemCapability.MiscServices.Pasteboard 248 * @since 7 249 * @deprecated since 9 250 * @useinstead ohos.pasteboard.pasteboard#createRecord 251 */ 252 function createPlainTextRecord(text: string): PasteDataRecord; 253 254 /** 255 * Creates a Record object for PasteData#MIMETYPE_TEXT_URI. 256 * @param { string } uri - To save the uri of content. 257 * @returns { PasteDataRecord } The content of a new record 258 * @syscap SystemCapability.MiscServices.Pasteboard 259 * @since 7 260 * @deprecated since 9 261 * @useinstead ohos.pasteboard.pasteboard#createRecord 262 */ 263 function createUriRecord(uri: string): PasteDataRecord; 264 265 /** 266 * Creates a record object with MIME type and value. 267 * @param { string } mimeType - indicates MIME type of value, its size cannot be greater than 1024 bytes. 268 * @param { ValueType } value - content to be saved. 269 * @returns { PasteDataRecord } a new PasteDataRecord object which contains mimeType and value. 270 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 271 * 2. Incorrect parameters types; 272 * 3. Parameter verification failed. 273 * @syscap SystemCapability.MiscServices.Pasteboard 274 * @since 9 275 */ 276 /** 277 * Creates a record object with MIME type and value. 278 * @param { string } mimeType - indicates MIME type of value, its size cannot be greater than 1024 bytes. 279 * @param { ValueType } value - content to be saved. 280 * @returns { PasteDataRecord } a new PasteDataRecord object which contains mimeType and value. 281 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 282 * 2. Incorrect parameters types; 283 * 3. Parameter verification failed. 284 * @syscap SystemCapability.MiscServices.Pasteboard 285 * @atomicservice 286 * @since 11 287 */ 288 function createRecord(mimeType: string, value: ValueType): PasteDataRecord; 289 290 /** 291 * get SystemPasteboard 292 * @returns { SystemPasteboard } The system clipboard object 293 * @syscap SystemCapability.MiscServices.Pasteboard 294 * @since 6 295 */ 296 /** 297 * get SystemPasteboard 298 * @returns { SystemPasteboard } The system clipboard object 299 * @syscap SystemCapability.MiscServices.Pasteboard 300 * @atomicservice 301 * @since 11 302 */ 303 function getSystemPasteboard(): SystemPasteboard; 304 305 /** 306 * Types of scope that PasteData can be pasted. 307 * @enum { number } 308 * @syscap SystemCapability.MiscServices.Pasteboard 309 * @since 9 310 */ 311 /** 312 * Types of scope that PasteData can be pasted. 313 * @enum { number } 314 * @syscap SystemCapability.MiscServices.Pasteboard 315 * @atomicservice 316 * @since 11 317 */ 318 enum ShareOption { 319 /** 320 * INAPP indicates that only paste in the same app is allowed. 321 * @syscap SystemCapability.MiscServices.Pasteboard 322 * @since 9 323 */ 324 /** 325 * INAPP indicates that only paste in the same app is allowed. 326 * @syscap SystemCapability.MiscServices.Pasteboard 327 * @atomicservice 328 * @since 11 329 */ 330 INAPP, 331 /** 332 * LOCALDEVICE indicates that paste in any app in this device is allowed. 333 * @syscap SystemCapability.MiscServices.Pasteboard 334 * @since 9 335 */ 336 /** 337 * LOCALDEVICE indicates that paste in any app in this device is allowed. 338 * @syscap SystemCapability.MiscServices.Pasteboard 339 * @atomicservice 340 * @since 11 341 */ 342 LOCALDEVICE, 343 /** 344 * CROSSDEVICE indicates that paste in any app across devices is allowed. 345 * @syscap SystemCapability.MiscServices.Pasteboard 346 * @since 9 347 */ 348 /** 349 * CROSSDEVICE indicates that paste in any app across devices is allowed. 350 * @syscap SystemCapability.MiscServices.Pasteboard 351 * @atomicservice 352 * @since 11 353 * @deprecated since 12 354 */ 355 CROSSDEVICE 356 } 357 358 /** 359 * Enumerates the patterns allowed in the system pasteboard. 360 * @enum { number } 361 * @syscap SystemCapability.MiscServices.Pasteboard 362 * @since 13 363 */ 364 enum Pattern { 365 /** 366 * URL pattern. 367 * @syscap SystemCapability.MiscServices.Pasteboard 368 * @since 13 369 */ 370 URL = 0, 371 /** 372 * Number pattern. 373 * @syscap SystemCapability.MiscServices.Pasteboard 374 * @since 13 375 */ 376 NUMBER = 1, 377 /** 378 * Email address pattern. 379 * @syscap SystemCapability.MiscServices.Pasteboard 380 * @since 13 381 */ 382 EMAIL_ADDRESS = 2, 383 } 384 385 386 /** 387 * Paste data property. 388 * @interface PasteDataProperty 389 * @syscap SystemCapability.MiscServices.Pasteboard 390 * @since 7 391 */ 392 /** 393 * Paste data property. 394 * @interface PasteDataProperty 395 * @syscap SystemCapability.MiscServices.Pasteboard 396 * @atomicservice 397 * @since 11 398 */ 399 interface PasteDataProperty { 400 /** 401 * additional property data. key-value pairs. 402 * @type { object } 403 * @syscap SystemCapability.MiscServices.Pasteboard 404 * @since 7 405 */ 406 /** 407 * additional property data. key-value pairs. 408 * @type { object } 409 * @syscap SystemCapability.MiscServices.Pasteboard 410 * @atomicservice 411 * @since 11 412 */ 413 additions: { 414 [key: string]: object 415 } 416 /** 417 * non-repeating MIME types of all records in PasteData. 418 * @type { Array<string> } 419 * @readonly 420 * @syscap SystemCapability.MiscServices.Pasteboard 421 * @since 7 422 */ 423 /** 424 * non-repeating MIME types of all records in PasteData. 425 * @type { Array<string> } 426 * @readonly 427 * @syscap SystemCapability.MiscServices.Pasteboard 428 * @atomicservice 429 * @since 11 430 */ 431 readonly mimeTypes: Array<string>; 432 /** 433 * the user-defined tag of a PasteData object. 434 * @type { string } 435 * @syscap SystemCapability.MiscServices.Pasteboard 436 * @since 7 437 */ 438 /** 439 * the user-defined tag of a PasteData object. 440 * @type { string } 441 * @syscap SystemCapability.MiscServices.Pasteboard 442 * @atomicservice 443 * @since 11 444 */ 445 tag: string; 446 /** 447 * a timestamp, which indicates when data is written to the system pasteboard. 448 * @type { number } 449 * @readonly 450 * @syscap SystemCapability.MiscServices.Pasteboard 451 * @since 7 452 */ 453 /** 454 * a timestamp, which indicates when data is written to the system pasteboard. 455 * @type { number } 456 * @readonly 457 * @syscap SystemCapability.MiscServices.Pasteboard 458 * @atomicservice 459 * @since 11 460 */ 461 readonly timestamp: number; 462 /** 463 * Checks whether PasteData is set for local access only. 464 * @type { boolean } 465 * @syscap SystemCapability.MiscServices.Pasteboard 466 * @since 7 467 */ 468 /** 469 * Checks whether PasteData is set for local access only. 470 * @type { boolean } 471 * @syscap SystemCapability.MiscServices.Pasteboard 472 * @atomicservice 473 * @since 11 474 */ 475 localOnly: boolean; 476 /** 477 * Indicates the scope of clipboard data which can be pasted. 478 * If it is not set or is incorrectly set, The default value is CrossDevice. 479 * @type { ShareOption } 480 * @syscap SystemCapability.MiscServices.Pasteboard 481 * @since 9 482 */ 483 /** 484 * Indicates the scope of clipboard data which can be pasted. 485 * If it is not set or is incorrectly set, The default value is CrossDevice. 486 * @type { ShareOption } 487 * @syscap SystemCapability.MiscServices.Pasteboard 488 * @atomicservice 489 * @since 11 490 */ 491 shareOption: ShareOption; 492 } 493 494 /** 495 * Paste data record. 496 * @interface PasteDataRecord 497 * @syscap SystemCapability.MiscServices.Pasteboard 498 * @since 7 499 */ 500 /** 501 * Paste data record. 502 * @interface PasteDataRecord 503 * @syscap SystemCapability.MiscServices.Pasteboard 504 * @atomicservice 505 * @since 11 506 */ 507 interface PasteDataRecord { 508 /** 509 * HTML text in a record. 510 * @type { string } 511 * @syscap SystemCapability.MiscServices.Pasteboard 512 * @since 7 513 */ 514 /** 515 * HTML text in a record. 516 * @type { string } 517 * @syscap SystemCapability.MiscServices.Pasteboard 518 * @atomicservice 519 * @since 11 520 */ 521 htmlText: string; 522 /** 523 * an want in a record. 524 * @type { Want } 525 * @syscap SystemCapability.MiscServices.Pasteboard 526 * @since 7 527 */ 528 /** 529 * an want in a record. 530 * @type { Want } 531 * @syscap SystemCapability.MiscServices.Pasteboard 532 * @atomicservice 533 * @since 11 534 */ 535 want: Want; 536 /** 537 * MIME types of a record. 538 * @type { string } 539 * @syscap SystemCapability.MiscServices.Pasteboard 540 * @since 7 541 */ 542 /** 543 * MIME types of a record. 544 * @type { string } 545 * @syscap SystemCapability.MiscServices.Pasteboard 546 * @atomicservice 547 * @since 11 548 */ 549 mimeType: string; 550 /** 551 * plain text in a record. 552 * @type { string } 553 * @syscap SystemCapability.MiscServices.Pasteboard 554 * @since 7 555 */ 556 /** 557 * plain text in a record. 558 * @type { string } 559 * @syscap SystemCapability.MiscServices.Pasteboard 560 * @atomicservice 561 * @since 11 562 */ 563 plainText: string; 564 /** 565 * an URI in a record. 566 * @type { string } 567 * @syscap SystemCapability.MiscServices.Pasteboard 568 * @since 7 569 */ 570 /** 571 * an URI in a record. 572 * @type { string } 573 * @syscap SystemCapability.MiscServices.Pasteboard 574 * @atomicservice 575 * @since 11 576 */ 577 uri: string; 578 /** 579 * PixelMap in a record. 580 * @type { image.PixelMap } 581 * @syscap SystemCapability.MiscServices.Pasteboard 582 * @since 9 583 */ 584 /** 585 * PixelMap in a record. 586 * @type { image.PixelMap } 587 * @syscap SystemCapability.MiscServices.Pasteboard 588 * @atomicservice 589 * @since 11 590 */ 591 pixelMap: image.PixelMap; 592 /** 593 * Custom data in a record, mimeType indicates the MIME type of custom data, ArrayBuffer indicates the value of custom data. 594 * @type { object } 595 * @syscap SystemCapability.MiscServices.Pasteboard 596 * @since 9 597 */ 598 /** 599 * Custom data in a record, mimeType indicates the MIME type of custom data, ArrayBuffer indicates the value of custom data. 600 * @type { object } 601 * @syscap SystemCapability.MiscServices.Pasteboard 602 * @atomicservice 603 * @since 11 604 */ 605 data: { 606 [mimeType: string]: ArrayBuffer 607 } 608 609 /** 610 * Converts data in PasteData to text format. 611 * @param { AsyncCallback<string> } callback - the callback of convertToText. 612 * @throws { BusinessError } 401 - Possible causes: Incorrect parameters types. 613 * @syscap SystemCapability.MiscServices.Pasteboard 614 * @since 7 615 * @deprecated since 9 616 * @useinstead ohos.pasteboard.pasteboard#convertToTextV9 617 */ 618 convertToText(callback: AsyncCallback<string>): void; 619 620 /** 621 * Converts data in PasteData to text format. 622 * @returns { Promise<string> } the promise returned by the function. 623 * @syscap SystemCapability.MiscServices.Pasteboard 624 * @since 7 625 * @deprecated since 9 626 * @useinstead ohos.pasteboard.pasteboard#convertToTextV9 627 */ 628 convertToText(): Promise<string>; 629 630 /** 631 * Converts data in PasteData to text format. 632 * @returns { string } the string returned by the function. 633 * @syscap SystemCapability.MiscServices.Pasteboard 634 * @since 9 635 */ 636 /** 637 * Converts data in PasteData to text format. 638 * @returns { string } the string returned by the function. 639 * @syscap SystemCapability.MiscServices.Pasteboard 640 * @atomicservice 641 * @since 11 642 */ 643 toPlainText(): string; 644 645 /** 646 * Adds data to the PasteDataRecord object. 647 * @param { string } type - indicates MIME type of the value to add. It cannot exceed 1024 bytes. 648 * @param { ValueType } value - indicates the value of the data to add. 649 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 650 * 2. Incorrect parameters types; 651 * 3. Parameter verification failed. 652 * @syscap SystemCapability.MiscServices.Pasteboard 653 * @since 14 654 */ 655 addEntry(type: string, value: ValueType): void; 656 657 /** 658 * Obtains the valid types in the PasteDataRecord object. 659 * @param { Array<string> } types - indicates an array of types from which the valid types are obtained. 660 * @returns { Array<string> } Returns the valid types obtained. 661 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 662 * 2. Incorrect parameters types; 663 * 3. Parameter verification failed. 664 * @syscap SystemCapability.MiscServices.Pasteboard 665 * @since 14 666 */ 667 getValidTypes(types: Array<string>): Array<string>; 668 669 /** 670 * Obtains data of the specified type. 671 * @param { string } type - indicates the type of the data to obtain. 672 * @returns { Promise<ValueType> } Promise used to return the data obtained. 673 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 674 * 2. Incorrect parameters types; 675 * 3. Parameter verification failed. 676 * @syscap SystemCapability.MiscServices.Pasteboard 677 * @since 14 678 */ 679 getData(type: string): Promise<ValueType>; 680 } 681 682 /** 683 * Classes for paste data. 684 * @interface PasteData 685 * @syscap SystemCapability.MiscServices.Pasteboard 686 * @since 6 687 */ 688 /** 689 * Classes for paste data. 690 * @interface PasteData 691 * @syscap SystemCapability.MiscServices.Pasteboard 692 * @atomicservice 693 * @since 11 694 */ 695 interface PasteData { 696 /** 697 * Adds a Record for HTML text to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_HTML in DataProperty. 698 * @param { string } htmlText - To save the Html text content. 699 * @syscap SystemCapability.MiscServices.Pasteboard 700 * @since 7 701 * @deprecated since 9 702 * @useinstead ohos.pasteboard.pasteboard#addRecord 703 */ 704 addHtmlRecord(htmlText: string): void; 705 706 /** 707 * Adds an want Record to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_WANT in DataProperty. 708 * @param { Want } want - To save the want content. 709 * @syscap SystemCapability.MiscServices.Pasteboard 710 * @since 7 711 * @deprecated since 9 712 * @useinstead ohos.pasteboard.pasteboard#addRecord 713 */ 714 addWantRecord(want: Want): void; 715 716 /** 717 * Adds a PasteRecord to a PasteData object and updates MIME types in DataProperty. 718 * @param { PasteDataRecord } record - The content of a new record. 719 * @syscap SystemCapability.MiscServices.Pasteboard 720 * @since 7 721 */ 722 /** 723 * Adds a PasteRecord to a PasteData object and updates MIME types in DataProperty. 724 * @param { PasteDataRecord } record - The content of a new record. 725 * @syscap SystemCapability.MiscServices.Pasteboard 726 * @atomicservice 727 * @since 11 728 */ 729 addRecord(record: PasteDataRecord): void; 730 731 /** 732 * Adds a Record for plain text to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_PLAIN in DataProperty. 733 * @param { string } text - To save the text of content. 734 * @syscap SystemCapability.MiscServices.Pasteboard 735 * @since 7 736 * @deprecated since 9 737 * @useinstead ohos.pasteboard.pasteboard#addRecord 738 */ 739 addTextRecord(text: string): void; 740 741 /** 742 * Adds a URI Record to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_URI in DataProperty. 743 * @param { string } uri - To save the uri of content. 744 * @syscap SystemCapability.MiscServices.Pasteboard 745 * @since 7 746 * @deprecated since 9 747 * @useinstead ohos.pasteboard.pasteboard#addRecord 748 */ 749 addUriRecord(uri: string): void; 750 751 /** 752 * Adds a record with mimeType and value to a PasteData object. 753 * @param { string } mimeType - indicates the MIME type of value, its size cannot be greater than 1024 bytes. 754 * @param { ValueType } value - content to be saved. 755 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 756 * 2. Incorrect parameters types; 757 * 3. Parameter verification failed. 758 * @throws { BusinessError } 12900002 - The number of records exceeds the upper limit. 759 * @syscap SystemCapability.MiscServices.Pasteboard 760 * @since 9 761 */ 762 /** 763 * Adds a record with mimeType and value to a PasteData object. 764 * @param { string } mimeType - indicates the MIME type of value, its size cannot be greater than 1024 bytes. 765 * @param { ValueType } value - content to be saved. 766 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 767 * 2. Incorrect parameters types; 768 * 3. Parameter verification failed. 769 * @syscap SystemCapability.MiscServices.Pasteboard 770 * @since 10 771 */ 772 /** 773 * Adds a record with mimeType and value to a PasteData object. 774 * @param { string } mimeType - indicates the MIME type of value, its size cannot be greater than 1024 bytes. 775 * @param { ValueType } value - content to be saved. 776 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 777 * 2. Incorrect parameters types; 778 * 3. Parameter verification failed. 779 * @syscap SystemCapability.MiscServices.Pasteboard 780 * @atomicservice 781 * @since 11 782 */ 783 addRecord(mimeType: string, value: ValueType): void; 784 785 /** 786 * MIME types of all content on the pasteboard. 787 * @returns { Array<string> } type of array 788 * @syscap SystemCapability.MiscServices.Pasteboard 789 * @since 7 790 */ 791 /** 792 * MIME types of all content on the pasteboard. 793 * @returns { Array<string> } type of array 794 * @syscap SystemCapability.MiscServices.Pasteboard 795 * @atomicservice 796 * @since 11 797 */ 798 getMimeTypes(): Array<string>; 799 800 /** 801 * HTML text of the primary record in a PasteData object. 802 * @returns { string } type of htmltext 803 * @syscap SystemCapability.MiscServices.Pasteboard 804 * @since 7 805 */ 806 /** 807 * HTML text of the primary record in a PasteData object. 808 * @returns { string } type of htmltext 809 * @syscap SystemCapability.MiscServices.Pasteboard 810 * @atomicservice 811 * @since 11 812 */ 813 getPrimaryHtml(): string; 814 815 /** 816 * the want of the primary record in a PasteData object. 817 * @returns { Want } type of want 818 * @syscap SystemCapability.MiscServices.Pasteboard 819 * @since 7 820 */ 821 /** 822 * the want of the primary record in a PasteData object. 823 * @returns { Want } type of want 824 * @syscap SystemCapability.MiscServices.Pasteboard 825 * @atomicservice 826 * @since 11 827 */ 828 getPrimaryWant(): Want; 829 830 /** 831 * the MIME type of the primary record in a PasteData object. 832 * @returns { string } type of mimetype 833 * @syscap SystemCapability.MiscServices.Pasteboard 834 * @since 7 835 */ 836 /** 837 * the MIME type of the primary record in a PasteData object. 838 * @returns { string } type of mimetype 839 * @syscap SystemCapability.MiscServices.Pasteboard 840 * @atomicservice 841 * @since 11 842 */ 843 getPrimaryMimeType(): string; 844 845 /** 846 * the plain text of the primary record in a PasteData object. 847 * @returns { string } type of text 848 * @syscap SystemCapability.MiscServices.Pasteboard 849 * @since 6 850 */ 851 /** 852 * the plain text of the primary record in a PasteData object. 853 * @returns { string } type of text 854 * @syscap SystemCapability.MiscServices.Pasteboard 855 * @atomicservice 856 * @since 11 857 */ 858 getPrimaryText(): string; 859 860 /** 861 * the URI of the primary record in a PasteData object. 862 * @returns { string } type of uri 863 * @syscap SystemCapability.MiscServices.Pasteboard 864 * @since 7 865 */ 866 /** 867 * the URI of the primary record in a PasteData object. 868 * @returns { string } type of uri 869 * @syscap SystemCapability.MiscServices.Pasteboard 870 * @atomicservice 871 * @since 11 872 */ 873 getPrimaryUri(): string; 874 875 /** 876 * Gets the primary PixelMap record in a PasteData object. 877 * @returns { image.PixelMap } pixelMap 878 * @syscap SystemCapability.MiscServices.Pasteboard 879 * @since 9 880 */ 881 /** 882 * Gets the primary PixelMap record in a PasteData object. 883 * @returns { image.PixelMap } pixelMap 884 * @syscap SystemCapability.MiscServices.Pasteboard 885 * @atomicservice 886 * @since 11 887 */ 888 getPrimaryPixelMap(): image.PixelMap; 889 890 /** 891 * DataProperty of a PasteData object. 892 * @returns { PasteDataProperty } PasteDataProperty type of PasteDataProperty 893 * @syscap SystemCapability.MiscServices.Pasteboard 894 * @since 7 895 */ 896 /** 897 * DataProperty of a PasteData object. 898 * @returns { PasteDataProperty } PasteDataProperty type of PasteDataProperty 899 * @syscap SystemCapability.MiscServices.Pasteboard 900 * @atomicservice 901 * @since 11 902 */ 903 getProperty(): PasteDataProperty; 904 905 /** 906 * Sets PasteDataProperty to a PasteData object, Modifying shareOption is supported only. 907 * @param { PasteDataProperty } property - save property to PasteData object. 908 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 909 * 2. Incorrect parameters types. 910 * @syscap SystemCapability.MiscServices.Pasteboard 911 * @since 9 912 */ 913 /** 914 * Sets PasteDataProperty to a PasteData object, Modifying shareOption is supported only. 915 * @param { PasteDataProperty } property - save property to PasteData object. 916 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 917 * 2. Incorrect parameters types. 918 * @syscap SystemCapability.MiscServices.Pasteboard 919 * @atomicservice 920 * @since 11 921 */ 922 setProperty(property: PasteDataProperty): void; 923 924 /** 925 * Gets record by index in PasteData. 926 * @param { number } index - indicates the record index in PasteData. 927 * @returns { PasteDataRecord } the record in PasteData with index. 928 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 929 * 2. Incorrect parameters types. 930 * @syscap SystemCapability.MiscServices.Pasteboard 931 * @since 7 932 * @deprecated since 9 933 * @useinstead ohos.pasteboard.pasteboard#getRecord 934 */ 935 getRecordAt(index: number): PasteDataRecord; 936 937 /** 938 * Gets record by index in PasteData. 939 * @param { number } index - indicates the record index in PasteData. 940 * @returns { PasteDataRecord } the record in PasteData with index. 941 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 942 * 2. Incorrect parameters types. 943 * @throws { BusinessError } 12900001 - The index is out of the record. 944 * @syscap SystemCapability.MiscServices.Pasteboard 945 * @since 9 946 */ 947 /** 948 * Gets record by index in PasteData. 949 * @param { number } index - indicates the record index in PasteData. 950 * @returns { PasteDataRecord } the record in PasteData with index. 951 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 952 * 2. Incorrect parameters types. 953 * @throws { BusinessError } 12900001 - The index is out of the record. 954 * @syscap SystemCapability.MiscServices.Pasteboard 955 * @atomicservice 956 * @since 11 957 */ 958 getRecord(index: number): PasteDataRecord; 959 960 /** 961 * the number of records in a PasteData object. 962 * @returns { number } The number of the clipboard contents 963 * @syscap SystemCapability.MiscServices.Pasteboard 964 * @since 7 965 */ 966 /** 967 * the number of records in a PasteData object. 968 * @returns { number } The number of the clipboard contents 969 * @syscap SystemCapability.MiscServices.Pasteboard 970 * @atomicservice 971 * @since 11 972 */ 973 getRecordCount(): number; 974 975 /** 976 * the user-defined tag of a PasteData object. 977 * @returns { string } type of tag 978 * @syscap SystemCapability.MiscServices.Pasteboard 979 * @since 7 980 */ 981 /** 982 * the user-defined tag of a PasteData object. 983 * @returns { string } type of tag 984 * @syscap SystemCapability.MiscServices.Pasteboard 985 * @atomicservice 986 * @since 11 987 */ 988 getTag(): string; 989 990 /** 991 * Checks whether there is a specified MIME type of data in DataProperty. 992 * @param { string } mimeType - indicates to query data type. 993 * @returns { boolean } if having mimeType in PasteData returns true, else returns false. 994 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 995 * 2. Incorrect parameters types. 996 * @syscap SystemCapability.MiscServices.Pasteboard 997 * @since 7 998 * @deprecated since 9 999 * @useinstead ohos.pasteboard.pasteboard#hasType 1000 */ 1001 hasMimeType(mimeType: string): boolean; 1002 1003 /** 1004 * Checks whether there is a specified MIME type of data in DataProperty. 1005 * @param { string } mimeType - indicates to query data type. 1006 * @returns { boolean } if having mimeType in PasteData returns true, else returns false. 1007 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1008 * 2. Incorrect parameters types. 1009 * @syscap SystemCapability.MiscServices.Pasteboard 1010 * @since 9 1011 */ 1012 /** 1013 * Checks whether there is a specified MIME type of data in DataProperty. 1014 * @param { string } mimeType - indicates to query data type. 1015 * @returns { boolean } if having mimeType in PasteData returns true, else returns false. 1016 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1017 * 2. Incorrect parameters types. 1018 * @syscap SystemCapability.MiscServices.Pasteboard 1019 * @atomicservice 1020 * @since 11 1021 */ 1022 hasType(mimeType: string): boolean; 1023 1024 /** 1025 * Removes a Record based on a specified index. 1026 * @param { number } index - indicates the record index in PasteData. 1027 * @returns { boolean } The query returns True on success, or False on failure. 1028 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1029 * 2. Incorrect parameters types. 1030 * @syscap SystemCapability.MiscServices.Pasteboard 1031 * @since 7 1032 * @deprecated since 9 1033 * @useinstead ohos.pasteboard.pasteboard#removeRecord 1034 */ 1035 removeRecordAt(index: number): boolean; 1036 1037 /** 1038 * Removes a Record based on a specified index. 1039 * @param { number } index - indicates the record index in PasteData. 1040 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1041 * 2. Incorrect parameters types. 1042 * @throws { BusinessError } 12900001 - The index is out of the record. 1043 * @syscap SystemCapability.MiscServices.Pasteboard 1044 * @since 9 1045 */ 1046 /** 1047 * Removes a Record based on a specified index. 1048 * @param { number } index - indicates the record index in PasteData. 1049 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1050 * 2. Incorrect parameters types. 1051 * @throws { BusinessError } 12900001 - The index is out of the record. 1052 * @syscap SystemCapability.MiscServices.Pasteboard 1053 * @atomicservice 1054 * @since 11 1055 */ 1056 removeRecord(index: number): void; 1057 1058 /** 1059 * Replaces a specified record with a new one. 1060 * @param { number } index - indicates the record index in PasteData. 1061 * @param { PasteDataRecord } record - the content of a new record. 1062 * @returns { boolean } The query returns True on success, or False on failure. 1063 * @syscap SystemCapability.MiscServices.Pasteboard 1064 * @since 7 1065 * @deprecated since 9 1066 * @useinstead ohos.pasteboard.pasteboard#replaceRecord 1067 */ 1068 replaceRecordAt(index: number, record: PasteDataRecord): boolean; 1069 1070 /** 1071 * Replaces a specified record with a new one. 1072 * @param { number } index - indicates the record index in PasteData. 1073 * @param { PasteDataRecord } record - the content of a new record. 1074 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1075 * 2. Incorrect parameters types. 1076 * @throws { BusinessError } 12900001 - The index is out of the record. 1077 * @syscap SystemCapability.MiscServices.Pasteboard 1078 * @since 9 1079 */ 1080 /** 1081 * Replaces a specified record with a new one. 1082 * @param { number } index - indicates the record index in PasteData. 1083 * @param { PasteDataRecord } record - the content of a new record. 1084 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1085 * 2. Incorrect parameters types. 1086 * @throws { BusinessError } 12900001 - The index is out of the record. 1087 * @syscap SystemCapability.MiscServices.Pasteboard 1088 * @atomicservice 1089 * @since 11 1090 */ 1091 replaceRecord(index: number, record: PasteDataRecord): void; 1092 1093 /** 1094 * Utilized to notify pasteboard service while reading PasteData, in this case, the service will help to preserve the context and resources 1095 * @syscap SystemCapability.MiscServices.Pasteboard 1096 * @since 12 1097 */ 1098 pasteStart(): void; 1099 1100 /** 1101 * Invoked to notify pasteboard service the utilization of PasteData has completed and occupied resources can be released for further usage 1102 * @syscap SystemCapability.MiscServices.Pasteboard 1103 * @since 12 1104 */ 1105 pasteComplete(): void; 1106 } 1107 1108 /** 1109 * Enumerates the types of file conflict options when getting data from the Pastedboard. 1110 * @enum { number } 1111 * @syscap SystemCapability.MiscServices.Pasteboard 1112 * @atomicservice 1113 * @since 15 1114 */ 1115 enum FileConflictOptions { 1116 /** 1117 * OVERWRITE overwrite when destUri has file with same name. 1118 * @syscap SystemCapability.MiscServices.Pasteboard 1119 * @atomicservice 1120 * @since 15 1121 */ 1122 OVERWRITE, 1123 1124 /** 1125 * SKIP skip when destUri has file with same name. 1126 * @syscap SystemCapability.MiscServices.Pasteboard 1127 * @atomicservice 1128 * @since 15 1129 */ 1130 SKIP 1131 } 1132 1133 /** 1134 * Enumerates the types of progress indicator when getting data from the Pastedboard. 1135 * @enum { number } 1136 * @syscap SystemCapability.MiscServices.Pasteboard 1137 * @atomicservice 1138 * @since 15 1139 */ 1140 enum ProgressIndicator { 1141 /** 1142 * NONE getting data without system default progress indicator. 1143 * @syscap SystemCapability.MiscServices.Pasteboard 1144 * @atomicservice 1145 * @since 15 1146 */ 1147 NONE, 1148 1149 /** 1150 * DEFALUT getting data with system default progress indicator. 1151 * @syscap SystemCapability.MiscServices.Pasteboard 1152 * @atomicservice 1153 * @since 15 1154 */ 1155 DEFAULT 1156 } 1157 1158 /** 1159 * Notifies progress when getting PasteData. 1160 * @interface ProgressInfo 1161 * @syscap SystemCapability.MiscServices.Pasteboard 1162 * @atomicservice 1163 * @since 15 1164 */ 1165 interface ProgressInfo { 1166 /** 1167 * Progress when getting PasteData without using default system progress. 1168 * @type { number } 1169 * @syscap SystemCapability.MiscServices.Pasteboard 1170 * @atomicservice 1171 * @since 15 1172 */ 1173 progress: number; 1174 } 1175 1176 /** 1177 * Indicates progress of getting PasteData. 1178 * @typedef { function } ProgressListener 1179 * @syscap SystemCapability.MiscServices.Pasteboard 1180 * @atomicservice 1181 * @since 15 1182 */ 1183 type ProgressListener = (progress: ProgressInfo) => void; 1184 1185 /** 1186 * Indicates the signals to process default system progress task. 1187 * @class ProgressSignal 1188 * @syscap SystemCapability.MiscServices.Pasteboard 1189 * @atomicservice 1190 * @since 15 1191 */ 1192 export class ProgressSignal { 1193 /** 1194 * Cancel the paste in progress. 1195 * @syscap SystemCapability.MiscServices.Pasteboard 1196 * @atomicservice 1197 * @since 15 1198 */ 1199 cancel(): void; 1200 } 1201 1202 /** 1203 * Represents the get data parameters when getting PasteData from Pasteboard. 1204 * @interface GetDataParams 1205 * @syscap SystemCapability.MiscServices.Pasteboard 1206 * @atomicservice 1207 * @since 15 1208 */ 1209 interface GetDataParams { 1210 /** 1211 * DestUri indicates the uri of dest path where copy files will be copied to sandbox of Application. 1212 * @type { ?string } 1213 * @default - 1214 * @syscap SystemCapability.MiscServices.Pasteboard 1215 * @atomicservice 1216 * @since 15 1217 */ 1218 destUri?: string; 1219 1220 /** 1221 * FileConflictOptions indicates fileConflictOptions when dest path has file with same name. 1222 * @type { ?FileConflictOptions } 1223 * @default FileConflictOptions.OVERWRITE 1224 * @syscap SystemCapability.MiscServices.Pasteboard 1225 * @atomicservice 1226 * @since 15 1227 */ 1228 fileConflictOptions?: FileConflictOptions; 1229 1230 /** 1231 * ProgressIndicator indicates whether to use default system progress indicator. 1232 * @type { ProgressIndicator } 1233 * @syscap SystemCapability.MiscServices.Pasteboard 1234 * @atomicservice 1235 * @since 15 1236 */ 1237 progressIndicator: ProgressIndicator; 1238 1239 /** 1240 * ProgressListener indicates progress listener when getting PasteDate without using default system progress. 1241 * @type { ?ProgressListener } 1242 * @default - 1243 * @syscap SystemCapability.MiscServices.Pasteboard 1244 * @atomicservice 1245 * @since 15 1246 */ 1247 progressListener?: ProgressListener; 1248 1249 /** 1250 * Progress signal when getting PasteData with system progress indacator. 1251 * @type { ?ProgressSignal } 1252 * @default - 1253 * @syscap SystemCapability.MiscServices.Pasteboard 1254 * @atomicservice 1255 * @since 15 1256 */ 1257 progressSignal?: ProgressSignal; 1258 } 1259 1260 /** 1261 * Classes for system pasteboard. 1262 * @interface SystemPasteboard 1263 * @syscap SystemCapability.MiscServices.Pasteboard 1264 * @since 6 1265 */ 1266 /** 1267 * Classes for system pasteboard. 1268 * @interface SystemPasteboard 1269 * @syscap SystemCapability.MiscServices.Pasteboard 1270 * @atomicservice 1271 * @since 11 1272 */ 1273 interface SystemPasteboard { 1274 /** 1275 * Callback invoked when pasteboard content changes. 1276 * @param { 'update' } type - indicates pasteboard content changed. 1277 * @param { function } callback - the callback to add. 1278 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1279 * 2. Incorrect parameters types. 1280 * @syscap SystemCapability.MiscServices.Pasteboard 1281 * @since 7 1282 */ 1283 on(type: 'update', callback: () => void): void; 1284 1285 /** 1286 * Remove a callback invoked when pasteboard content changes. 1287 * @param { 'update' } type - indicates pasteboard content changed. 1288 * @param { function } [callback] - the callback to remove. If this parameter is not filled in, it indicates that all 1289 * callbacks for this application will be cleared. Otherwise, it indicates that the specified callback will be cleared. 1290 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1291 * 2. Incorrect parameters types. 1292 * @syscap SystemCapability.MiscServices.Pasteboard 1293 * @since 7 1294 */ 1295 off(type: 'update', callback?: () => void): void; 1296 1297 /** 1298 * Checks whether the data is remote. 1299 * @returns { boolean } True is remote data, else false. 1300 * @throws { BusinessError } 12900005 - Request timed out. 1301 * @syscap SystemCapability.MiscServices.Pasteboard 1302 * @atomicservice 1303 * @since 11 1304 */ 1305 isRemoteData(): boolean; 1306 1307 /** 1308 * Gets source of data. 1309 * @returns { string } data source. 1310 * @throws { BusinessError } 12900005 - Request timed out. 1311 * @syscap SystemCapability.MiscServices.Pasteboard 1312 * @atomicservice 1313 * @since 11 1314 */ 1315 getDataSource(): string; 1316 1317 /** 1318 * Checks whether there is a specified MIME type of data in Data. 1319 * @param { string } mimeType - indicates to query data type. 1320 * @returns { boolean } if having mimeType in PasteData returns true, else returns false. 1321 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1322 * 2. Incorrect parameters types. 1323 * @throws { BusinessError } 12900005 - Request timed out. 1324 * @syscap SystemCapability.MiscServices.Pasteboard 1325 * @atomicservice 1326 * @since 11 1327 */ 1328 hasDataType(mimeType: string): boolean; 1329 1330 /** 1331 * Clears the pasteboard. 1332 * @param { AsyncCallback<void> } callback - the callback of clearData. 1333 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1334 * 2. Incorrect parameters types. 1335 * @syscap SystemCapability.MiscServices.Pasteboard 1336 * @since 7 1337 * @deprecated since 9 1338 * @useinstead ohos.pasteboard.pasteboard#clearData 1339 */ 1340 clear(callback: AsyncCallback<void>): void; 1341 1342 /** 1343 * Clears the pasteboard. 1344 * @returns { Promise<void> } the promise returned by the clearData. 1345 * @syscap SystemCapability.MiscServices.Pasteboard 1346 * @since 7 1347 * @deprecated since 9 1348 * @useinstead ohos.pasteboard.pasteboard#clearData 1349 */ 1350 clear(): Promise<void>; 1351 1352 /** 1353 * Clears the pasteboard. 1354 * @param { AsyncCallback<void> } callback - the callback of clearData. 1355 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1356 * 2. Incorrect parameters types. 1357 * @syscap SystemCapability.MiscServices.Pasteboard 1358 * @since 9 1359 */ 1360 /** 1361 * Clears the pasteboard. 1362 * @param { AsyncCallback<void> } callback - the callback of clearData. 1363 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1364 * 2. Incorrect parameters types. 1365 * @syscap SystemCapability.MiscServices.Pasteboard 1366 * @atomicservice 1367 * @since 11 1368 */ 1369 clearData(callback: AsyncCallback<void>): void; 1370 1371 /** 1372 * Clears the pasteboard. 1373 * @returns { Promise<void> } the promise returned by the clearData. 1374 * @syscap SystemCapability.MiscServices.Pasteboard 1375 * @since 9 1376 */ 1377 /** 1378 * Clears the pasteboard. 1379 * @returns { Promise<void> } the promise returned by the clearData. 1380 * @syscap SystemCapability.MiscServices.Pasteboard 1381 * @atomicservice 1382 * @since 11 1383 */ 1384 clearData(): Promise<void>; 1385 1386 /** 1387 * Clears the pasteboard. 1388 * @throws { BusinessError } 12900005 - Request timed out. 1389 * @syscap SystemCapability.MiscServices.Pasteboard 1390 * @atomicservice 1391 * @since 11 1392 */ 1393 clearDataSync(): void; 1394 1395 /** 1396 * Gets pastedata from the system pasteboard. 1397 * @param { AsyncCallback<PasteData> } callback - the callback of getData. 1398 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1399 * 2. Incorrect parameters types. 1400 * @syscap SystemCapability.MiscServices.Pasteboard 1401 * @since 6 1402 * @deprecated since 9 1403 * @useinstead ohos.pasteboard.pasteboard#getData 1404 */ 1405 getPasteData(callback: AsyncCallback<PasteData>): void; 1406 1407 /** 1408 * Gets pastedata from the system pasteboard. 1409 * @returns { Promise<PasteData> } the promise returned by the getData. 1410 * @syscap SystemCapability.MiscServices.Pasteboard 1411 * @since 6 1412 * @deprecated since 9 1413 * @useinstead ohos.pasteboard.pasteboard#getData 1414 */ 1415 getPasteData(): Promise<PasteData>; 1416 1417 /** 1418 * Gets pastedata from the system pasteboard. 1419 * @param { AsyncCallback<PasteData> } callback - the callback of getData. 1420 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1421 * 2. Incorrect parameters types. 1422 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1423 * @syscap SystemCapability.MiscServices.Pasteboard 1424 * @since 9 1425 */ 1426 /** 1427 * Gets pastedata from the system pasteboard. 1428 * @param { AsyncCallback<PasteData> } callback - the callback of getData. 1429 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1430 * 2. Incorrect parameters types. 1431 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1432 * @syscap SystemCapability.MiscServices.Pasteboard 1433 * @atomicservice 1434 * @since 11 1435 */ 1436 /** 1437 * Gets pastedata from the system pasteboard. 1438 * @permission ohos.permission.READ_PASTEBOARD 1439 * @param { AsyncCallback<PasteData> } callback - the callback of getData. 1440 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the 1441 * permission required to call the API. 1442 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1443 * 2. Incorrect parameters types. 1444 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1445 * @syscap SystemCapability.MiscServices.Pasteboard 1446 * @atomicservice 1447 * @since 12 1448 */ 1449 getData(callback: AsyncCallback<PasteData>): void; 1450 1451 /** 1452 * Gets pastedata from the system pasteboard. 1453 * @returns { Promise<PasteData> } the promise returned by the getData. 1454 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1455 * @syscap SystemCapability.MiscServices.Pasteboard 1456 * @since 9 1457 */ 1458 /** 1459 * Gets pastedata from the system pasteboard. 1460 * @returns { Promise<PasteData> } the promise returned by the getData. 1461 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1462 * @syscap SystemCapability.MiscServices.Pasteboard 1463 * @atomicservice 1464 * @since 11 1465 */ 1466 /** 1467 * Gets pastedata from the system pasteboard. 1468 * @permission ohos.permission.READ_PASTEBOARD 1469 * @returns { Promise<PasteData> } the promise returned by the getData. 1470 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the 1471 * permission required to call the API. 1472 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1473 * @syscap SystemCapability.MiscServices.Pasteboard 1474 * @atomicservice 1475 * @since 12 1476 */ 1477 getData(): Promise<PasteData>; 1478 1479 /** 1480 * Gets pasteData from the system pasteboard. 1481 * @returns { PasteData } a new PasteData. 1482 * @throws { BusinessError } 12900005 - Request timed out. 1483 * @syscap SystemCapability.MiscServices.Pasteboard 1484 * @atomicservice 1485 * @since 11 1486 */ 1487 /** 1488 * Gets pasteData from the system pasteboard. 1489 * @permission ohos.permission.READ_PASTEBOARD 1490 * @returns { PasteData } a new PasteData. 1491 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the 1492 * permission required to call the API. 1493 * @throws { BusinessError } 12900005 - Request timed out. 1494 * @syscap SystemCapability.MiscServices.Pasteboard 1495 * @atomicservice 1496 * @since 12 1497 */ 1498 getDataSync(): PasteData; 1499 1500 /** 1501 * Checks whether there is content in the pasteboard. 1502 * @param { AsyncCallback<boolean> } callback - the callback of setPasteData. 1503 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1504 * 2. Incorrect parameters types. 1505 * @syscap SystemCapability.MiscServices.Pasteboard 1506 * @since 7 1507 * @deprecated since 9 1508 * @useinstead ohos.pasteboard.pasteboard#hasData 1509 */ 1510 hasPasteData(callback: AsyncCallback<boolean>): void; 1511 1512 /** 1513 * Checks whether there is content in the pasteboard. 1514 * @returns { Promise<boolean> } the promise returned by the function. 1515 * @syscap SystemCapability.MiscServices.Pasteboard 1516 * @since 7 1517 * @deprecated since 9 1518 * @useinstead ohos.pasteboard.pasteboard#hasData 1519 */ 1520 hasPasteData(): Promise<boolean>; 1521 1522 /** 1523 * Checks whether there is content in the system pasteboard. 1524 * @param { AsyncCallback<boolean> } callback - the callback of hasData. 1525 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1526 * 2. Incorrect parameters types. 1527 * @syscap SystemCapability.MiscServices.Pasteboard 1528 * @since 9 1529 */ 1530 /** 1531 * Checks whether there is content in the system pasteboard. 1532 * @param { AsyncCallback<boolean> } callback - the callback of hasData. 1533 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1534 * 2. Incorrect parameters types. 1535 * @syscap SystemCapability.MiscServices.Pasteboard 1536 * @atomicservice 1537 * @since 11 1538 */ 1539 hasData(callback: AsyncCallback<boolean>): void; 1540 1541 /** 1542 * Checks whether there is content in the system pasteboard. 1543 * @returns { Promise<boolean> } the promise returned by the function. 1544 * @syscap SystemCapability.MiscServices.Pasteboard 1545 * @since 9 1546 */ 1547 /** 1548 * Checks whether there is content in the system pasteboard. 1549 * @returns { Promise<boolean> } the promise returned by the function. 1550 * @syscap SystemCapability.MiscServices.Pasteboard 1551 * @atomicservice 1552 * @since 11 1553 */ 1554 hasData(): Promise<boolean>; 1555 1556 /** 1557 * Checks whether there is content in the system pasteboard. 1558 * @returns { boolean } True exists, false does not exist. 1559 * @throws { BusinessError } 12900005 - Request timed out. 1560 * @syscap SystemCapability.MiscServices.Pasteboard 1561 * @atomicservice 1562 * @since 11 1563 */ 1564 hasDataSync(): boolean; 1565 1566 /** 1567 * Writes PasteData to the pasteboard. 1568 * @param { PasteData } data - PasteData will be written to the clipboard 1569 * @param { AsyncCallback<void> } callback - the callback of setPasteData. 1570 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1571 * 2. Incorrect parameters types. 1572 * @syscap SystemCapability.MiscServices.Pasteboard 1573 * @since 6 1574 * @deprecated since 9 1575 * @useinstead ohos.pasteboard.pasteboard#setData 1576 */ 1577 setPasteData(data: PasteData, callback: AsyncCallback<void>): void; 1578 1579 /** 1580 * Writes PasteData to the pasteboard. 1581 * @param { PasteData } data - Containing the contents of the clipboard content object. 1582 * @returns { Promise<void> } the promise returned by the function. 1583 * @syscap SystemCapability.MiscServices.Pasteboard 1584 * @since 6 1585 * @deprecated since 9 1586 * @useinstead ohos.pasteboard.pasteboard#setData 1587 */ 1588 setPasteData(data: PasteData): Promise<void>; 1589 1590 /** 1591 * Writes PasteData to the system pasteboard. 1592 * @param { PasteData } data - PasteData will be written to the clipboard 1593 * @param { AsyncCallback<void> } callback - the callback of setData. 1594 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified. 1595 * 2. Incorrect parameters types. 1596 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1597 * @throws { BusinessError } 27787278 - Replication is prohibited. 1598 * @syscap SystemCapability.MiscServices.Pasteboard 1599 * @since 9 1600 */ 1601 /** 1602 * Writes PasteData to the system pasteboard. 1603 * @param { PasteData } data - PasteData will be written to the clipboard 1604 * @param { AsyncCallback<void> } callback - the callback of setData. 1605 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1606 * 2. Incorrect parameters types. 1607 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1608 * @throws { BusinessError } 27787278 - Replication is prohibited. 1609 * @syscap SystemCapability.MiscServices.Pasteboard 1610 * @atomicservice 1611 * @since 11 1612 */ 1613 setData(data: PasteData, callback: AsyncCallback<void>): void; 1614 1615 /** 1616 * Writes PasteData to the system pasteboard. 1617 * @param { PasteData } data - PasteData will be written to the clipboard. 1618 * @returns { Promise<void> } the promise returned by the function. 1619 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1620 * 2. Incorrect parameters types. 1621 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1622 * @throws { BusinessError } 27787278 - Replication is prohibited. 1623 * @syscap SystemCapability.MiscServices.Pasteboard 1624 * @since 9 1625 */ 1626 /** 1627 * Writes PasteData to the system pasteboard. 1628 * @param { PasteData } data - PasteData will be written to the clipboard. 1629 * @returns { Promise<void> } the promise returned by the function. 1630 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1631 * 2. Incorrect parameters types. 1632 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1633 * @throws { BusinessError } 27787278 - Replication is prohibited. 1634 * @syscap SystemCapability.MiscServices.Pasteboard 1635 * @atomicservice 1636 * @since 11 1637 */ 1638 setData(data: PasteData): Promise<void>; 1639 1640 /** 1641 * Writes PasteData to the system pasteboard. 1642 * @param { PasteData } data - PasteData will be written to the clipboard. 1643 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1644 * 2. Incorrect parameters types. 1645 * @throws { BusinessError } 12900005 - Request timed out. 1646 * @syscap SystemCapability.MiscServices.Pasteboard 1647 * @atomicservice 1648 * @since 11 1649 */ 1650 setDataSync(data: PasteData): void; 1651 1652 /** 1653 * Gets unified data from the system pasteboard. 1654 * @permission ohos.permission.READ_PASTEBOARD 1655 * @returns { Promise<unifiedDataChannel.UnifiedData> } the promise returned by the getData. 1656 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the 1657 * permission required to call the API. 1658 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1659 * @syscap SystemCapability.MiscServices.Pasteboard 1660 * @atomicservice 1661 * @since 12 1662 */ 1663 getUnifiedData(): Promise<unifiedDataChannel.UnifiedData>; 1664 1665 /** 1666 * Gets unified data from the system pasteboard. 1667 * @permission ohos.permission.READ_PASTEBOARD 1668 * @returns { unifiedDataChannel.UnifiedData } a new UnifiedData. 1669 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the 1670 * permission required to call the API. 1671 * @throws { BusinessError } 12900005 - Request timed out. 1672 * @syscap SystemCapability.MiscServices.Pasteboard 1673 * @atomicservice 1674 * @since 12 1675 */ 1676 getUnifiedDataSync(): unifiedDataChannel.UnifiedData; 1677 1678 /** 1679 * Writes unified data to the system pasteboard. 1680 * @param { unifiedDataChannel.UnifiedData } data - Unified data will be written to the pasteboard. 1681 * @returns { Promise<void> } the promise returned by the function. 1682 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1683 * 2. Incorrect parameters types. 1684 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1685 * @throws { BusinessError } 27787278 - Replication is prohibited. 1686 * @syscap SystemCapability.MiscServices.Pasteboard 1687 * @atomicservice 1688 * @since 12 1689 */ 1690 setUnifiedData(data: unifiedDataChannel.UnifiedData): Promise<void>; 1691 1692 /** 1693 * Writes unified data to the system pasteboard. 1694 * @param { unifiedDataChannel.UnifiedData } data - Unified data will be written to the pasteboard. 1695 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1696 * 2. Incorrect parameters types. 1697 * @throws { BusinessError } 12900005 - Request timed out. 1698 * @syscap SystemCapability.MiscServices.Pasteboard 1699 * @atomicservice 1700 * @since 12 1701 */ 1702 setUnifiedDataSync(data: unifiedDataChannel.UnifiedData): void; 1703 1704 /** 1705 * Sets a unified ShareOptions for your application, so that the PasteData copied from your application is applicable to this ShareOptions. 1706 * 1707 * @param { ShareOption } shareOptions - Scope that PasteData can be pasted. 1708 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1709 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1710 * 2. Incorrect parameter types; 1711 * 3. Parameter verification failed. 1712 * @throws { BusinessError } 12900006 - Settings already exist. 1713 * @syscap SystemCapability.MiscServices.Pasteboard 1714 * @systemapi 1715 * @since 12 1716 */ 1717 /** 1718 * Sets a unified ShareOptions for your application, so that the PasteData copied from your application is applicable to this ShareOptions. 1719 * 1720 * @permission ohos.permission.MANAGE_PASTEBOARD_APP_SHARE_OPTION 1721 * @param { ShareOption } shareOptions - Scope that PasteData can be pasted, The parameter can only be set InApp. 1722 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the 1723 * permission required to call the API. 1724 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1725 * 2. Incorrect parameter types; 1726 * 3. Parameter verification failed. 1727 * @throws { BusinessError } 12900006 - Settings already exist. 1728 * @syscap SystemCapability.MiscServices.Pasteboard 1729 * @since 14 1730 */ 1731 setAppShareOptions(shareOptions: ShareOption): void; 1732 1733 /** 1734 * Removes the unified ShareOptions of your application. 1735 * 1736 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1737 * @syscap SystemCapability.MiscServices.Pasteboard 1738 * @systemapi 1739 * @since 12 1740 */ 1741 /** 1742 * Removes the unified ShareOptions of your application. 1743 * 1744 * @permission ohos.permission.MANAGE_PASTEBOARD_APP_SHARE_OPTION 1745 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the 1746 * permission required to call the API. 1747 * @syscap SystemCapability.MiscServices.Pasteboard 1748 * @since 14 1749 */ 1750 removeAppShareOptions(): void; 1751 1752 /** 1753 * Detects the patterns in the pasteboard. 1754 * 1755 * @param { Array<Pattern> } patterns - Patterns to detect. 1756 * @returns { Promise<Array<Pattern>> } Promise used to return the patterns detected. 1757 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1758 * 2. Incorrect parameter types; 1759 * 3. Parameter verification failed. 1760 * @syscap SystemCapability.MiscServices.Pasteboard 1761 * @since 13 1762 */ 1763 detectPatterns(patterns: Array<Pattern>): Promise<Array<Pattern>>; 1764 1765 /** 1766 * Get the MIME types in the pasteboard. 1767 * 1768 * @returns { Promise<Array<string>> } Promise used to return the MIME types. 1769 * @syscap SystemCapability.MiscServices.Pasteboard 1770 * @atomicservice 1771 * @since 14 1772 */ 1773 getMimeTypes(): Promise<Array<string>>; 1774 1775 /** 1776 * Gets the number of Pasteboard data changes. 1777 * 1778 * @returns { number } The number of Pasteboard data changes. 1779 * @syscap SystemCapability.MiscServices.Pasteboard 1780 * @atomicservice 1781 * @since 18 1782 */ 1783 getChangeCount(): number; 1784 1785 /** 1786 * Gets pastedata from the system pasteboard with system progress. 1787 * 1788 * @permission ohos.permission.READ_PASTEBOARD 1789 * @param { GetDataParams } params - Indicates the {@link GetDataParams}. 1790 * @returns { Promise<PasteData> } The promise returned by the getData. 1791 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the 1792 * permission required to call the API. 1793 * @throws { BusinessError } 401 - Parameter error. 1794 * @throws { BusinessError } 12900003 - Another copy or paste operation is in progress. 1795 * @throws { BusinessError } 12900007 - Copy file failed. 1796 * @throws { BusinessError } 12900008 - Failed to start progress. 1797 * @throws { BusinessError } 12900009 - Progress exits abnormally. 1798 * @throws { BusinessError } 12900010 - Get pasteData error. 1799 * @syscap SystemCapability.MiscServices.Pasteboard 1800 * @atomicservice 1801 * @since 15 1802 */ 1803 getDataWithProgress(params: GetDataParams): Promise<PasteData>; 1804 } 1805} 1806 1807export default pasteboard; 1808