1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef PASTE_DATA_RECORD_IMPL_H 17 #define PASTE_DATA_RECORD_IMPL_H 18 19 #include "ffi_remote_data.h" 20 #include "pixel_map_impl.h" 21 #include "paste_data.h" 22 #include "pasteboard_client.h" 23 #include "pasteboard_log.h" 24 25 namespace OHOS { 26 namespace MiscServicesCj { 27 struct CJValueType { 28 std::string stringValue; 29 AAFwk::Want wantValue; 30 std::shared_ptr<Media::PixelMap> pixelMap = nullptr; 31 uint8_t *arrayBufferData; 32 int64_t arrayBufferSize; 33 }; 34 35 class PasteDataRecordImpl : public OHOS::FFI::FFIData { 36 public: 37 PasteDataRecordImpl(); 38 explicit PasteDataRecordImpl(std::shared_ptr<MiscServices::PasteDataRecord> pasteDataRecord); 39 PasteDataRecordImpl(std::string mimeType, CJValueType value); 40 std::shared_ptr<MiscServices::PasteDataRecord> GetRealPasteDataRecord(); GetRuntimeType()41 OHOS::FFI::RuntimeType *GetRuntimeType() override { return GetClassType(); } 42 43 private: 44 friend class OHOS::FFI::RuntimeType; 45 friend class OHOS::FFI::TypeBase; 46 static OHOS::FFI::RuntimeType *GetClassType(); 47 void CreateHtmlDataRecord(std::string mimeType, CJValueType value); 48 void CreatePlainTextDataRecord(std::string mimeType, CJValueType value); 49 void CreateUriDataRecord(std::string mimeType, CJValueType value); 50 void CreatePixelMapDataRecord(std::string mimeType, CJValueType value); 51 void CreateWantDataRecord(std::string mimeType, CJValueType value); 52 53 std::shared_ptr<MiscServices::PasteDataRecord> value_ = nullptr; 54 }; 55 56 int64_t CreateCjPasteDataRecordObject(std::string mimeType, CJValueType value); 57 sptr<PasteDataRecordImpl> getCjPasteDataRecordImpl(std::shared_ptr<MiscServices::PasteDataRecord> record); 58 void removeCjPasteDataRecordImpl(std::shared_ptr<MiscServices::PasteDataRecord> record); 59 void addCjPasteDataRecordImpl(std::shared_ptr<MiscServices::PasteDataRecord> record, 60 sptr<PasteDataRecordImpl> pasteDataRecordImpl); 61 62 } 63 } 64 65 #endif