/* * Copyright (C) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef PASTE_BOARD_UTILS_H #define PASTE_BOARD_UTILS_H #include "paste_data.h" #include "paste_data_record.h" #include "unified_data.h" #include "unified_record.h" namespace OHOS { namespace MiscServices { class API_EXPORT PasteboardUtils { public: using UnifiedRecord = UDMF::UnifiedRecord; using UnifiedData = UDMF::UnifiedData; using UnifiedDataProperties = UDMF::UnifiedDataProperties; using UDType = UDMF::UDType; using ShareOptions = UDMF::ShareOptions; static PasteboardUtils& GetInstance(); std::shared_ptr Convert(const UnifiedData& unifiedData); std::shared_ptr Convert(const PasteData& pasteData); std::vector DeduplicateVector(const std::vector &vec); private: using Convert2URecord = std::function(std::shared_ptr)>; using Convert2PRecord = std::function(std::shared_ptr)>; PasteboardUtils(); std::vector> Convert(const std::vector>& records); static PasteDataProperty Convert(const UnifiedDataProperties& properties); static std::shared_ptr Convert(const PasteDataProperty& properties); static std::vector Convert(const std::vector& utdIds); static std::string Convert(UDType uDType); static UDType Convert(int32_t uDType, const std::string& mimeType); void InitDecodeMap(); static std::shared_ptr PasteRecord2Text(std::shared_ptr record); static std::shared_ptr PasteRecord2PlaintText(std::shared_ptr record); static std::shared_ptr PasteRecord2Want(std::shared_ptr record); static std::shared_ptr PasteRecord2Html(std::shared_ptr record); static std::shared_ptr PasteRecord2Link(std::shared_ptr record); static std::shared_ptr PasteRecord2File(std::shared_ptr record); static std::shared_ptr PasteRecord2Image(std::shared_ptr record); static std::shared_ptr PasteRecord2Video(std::shared_ptr record); static std::shared_ptr PasteRecord2Audio(std::shared_ptr record); static std::shared_ptr PasteRecord2Folder(std::shared_ptr record); static std::shared_ptr PasteRecord2PixelMap(std::shared_ptr record); static std::shared_ptr PasteRecord2SystemDefined(std::shared_ptr record); static std::shared_ptr PasteRecord2AppItem(std::shared_ptr record); static std::shared_ptr PasteRecord2Form(std::shared_ptr record); static std::vector> Custom2AppDefined( std::shared_ptr record); static std::shared_ptr Text2PasteRecord(std::shared_ptr record); static std::shared_ptr PlainText2PasteRecord(std::shared_ptr record); static std::shared_ptr Want2PasteRecord(std::shared_ptr record); static std::shared_ptr Html2PasteRecord(std::shared_ptr record); static std::shared_ptr Link2PasteRecord(std::shared_ptr record); static std::shared_ptr File2PasteRecord(std::shared_ptr record); static std::shared_ptr Image2PasteRecord(std::shared_ptr record); static std::shared_ptr Video2PasteRecord(std::shared_ptr record); static std::shared_ptr Audio2PasteRecord(std::shared_ptr record); static std::shared_ptr Folder2PasteRecord(std::shared_ptr record); static std::shared_ptr PixelMap2PasteRecord(std::shared_ptr record); static std::shared_ptr AppItem2PasteRecord(std::shared_ptr record); static std::shared_ptr Form2PasteRecord(std::shared_ptr record); static std::shared_ptr SystemDefined2PasteRecord(std::shared_ptr record); static std::shared_ptr AppDefined2PasteRecord(std::shared_ptr record); std::map convert2URecordMap_; std::map convert2PRecordMap_; static ShareOption UdmfOptions2PbOption(ShareOptions udmfOptions); static ShareOptions PbOption2UdmfOptions(ShareOption pbOption); }; } // namespace MiscServices } // namespace OHOS #endif // PASTE_BOARD_UTILS_H