1 /* 2 * Copyright (c) 2022 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 #include "ohos_adapter/bridge/ark_paste_data_adapter_impl.h" 17 18 #include "ohos_adapter/bridge/ark_paste_data_record_adapter_impl.h" 19 #include "ohos_adapter/cpptoc/ark_paste_record_vector_cpptoc.h" 20 21 #include "base/bridge/ark_web_bridge_macros.h" 22 23 namespace OHOS::ArkWeb { 24 ArkPasteDataAdapterImpl(std::shared_ptr<OHOS::NWeb::PasteDataAdapter> ref)25ArkPasteDataAdapterImpl::ArkPasteDataAdapterImpl(std::shared_ptr<OHOS::NWeb::PasteDataAdapter> ref) : real_(ref) {} 26 AddHtmlRecord(const ArkWebString & html)27void ArkPasteDataAdapterImpl::AddHtmlRecord(const ArkWebString& html) 28 { 29 real_->AddHtmlRecord(ArkWebStringStructToClass(html)); 30 } 31 AddTextRecord(const ArkWebString & text)32void ArkPasteDataAdapterImpl::AddTextRecord(const ArkWebString& text) 33 { 34 real_->AddTextRecord(ArkWebStringStructToClass(text)); 35 } 36 GetMimeTypes()37ArkWebStringVector ArkPasteDataAdapterImpl::GetMimeTypes() 38 { 39 return ArkWebStringVectorClassToStruct(real_->GetMimeTypes()); 40 } 41 GetPrimaryHtml(void * data)42void ArkPasteDataAdapterImpl::GetPrimaryHtml(void* data) 43 { 44 std::shared_ptr<std::string> str = real_->GetPrimaryHtml(); 45 std::shared_ptr<std::string>* html = static_cast<std::shared_ptr<std::string>*>(data); 46 *html = str; 47 } 48 GetPrimaryText(void * data)49void ArkPasteDataAdapterImpl::GetPrimaryText(void* data) 50 { 51 std::shared_ptr<std::string> str = real_->GetPrimaryText(); 52 std::shared_ptr<std::string>* text = static_cast<std::shared_ptr<std::string>*>(data); 53 *text = str; 54 } 55 GetPrimaryMimeType(void * data)56void ArkPasteDataAdapterImpl::GetPrimaryMimeType(void* data) 57 { 58 std::shared_ptr<std::string> str = real_->GetPrimaryMimeType(); 59 std::shared_ptr<std::string>* mimeType = static_cast<std::shared_ptr<std::string>*>(data); 60 *mimeType = str; 61 } 62 GetRecordAt(size_t index)63ArkWebRefPtr<ArkPasteDataRecordAdapter> ArkPasteDataAdapterImpl::GetRecordAt(size_t index) 64 { 65 return new ArkPasteDataRecordAdapterImpl(real_->GetRecordAt(index)); 66 } 67 GetRecordCount()68size_t ArkPasteDataAdapterImpl::GetRecordCount() 69 { 70 return real_->GetRecordCount(); 71 } 72 AllRecords()73ArkPasteRecordVector ArkPasteDataAdapterImpl::AllRecords() 74 { 75 NWeb::PasteRecordVector temp = real_->AllRecords(); 76 return ArkPasteRecordVectorClassToStruct(temp); 77 } 78 79 } // namespace OHOS::ArkWeb 80