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 "pasteboard_client.h" 20 #include "pixel_map_impl.h" 21 22 namespace OHOS { 23 namespace MiscServicesCj { 24 struct CJValueType { 25 std::string stringValue; 26 AAFwk::Want wantValue; 27 std::shared_ptr<Media::PixelMap> pixelMap = nullptr; 28 uint8_t *arrayBufferData; 29 int64_t arrayBufferSize; 30 }; 31 32 class PasteDataRecordImpl : public OHOS::FFI::FFIData { 33 public: 34 PasteDataRecordImpl(); 35 explicit PasteDataRecordImpl(std::shared_ptr<MiscServices::PasteDataRecord> pasteDataRecord); 36 PasteDataRecordImpl(std::string mimeType, CJValueType value); 37 std::shared_ptr<MiscServices::PasteDataRecord> GetRealPasteDataRecord(); GetRuntimeType()38 OHOS::FFI::RuntimeType *GetRuntimeType() override 39 { 40 return GetClassType(); 41 } 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( 60 std::shared_ptr<MiscServices::PasteDataRecord> record, sptr<PasteDataRecordImpl> pasteDataRecordImpl); 61 62 } // namespace MiscServicesCj 63 } // namespace OHOS 64 65 #endif