1 /* 2 * Copyright (c) 2025 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_nweb/bridge/ark_web_print_attributes_adapter_wrapper.h" 17 #include "base/bridge/ark_web_bridge_macros.h" 18 19 namespace OHOS::ArkWeb { 20 GetBool(uint32_t attrId)21bool NWebPrintAttributesAdapterWrapper::GetBool(uint32_t attrId) 22 { 23 if (ref_) { 24 return ref_->GetBool(attrId); 25 } 26 return false; 27 } 28 GetUInt32(uint32_t attrId)29uint32_t NWebPrintAttributesAdapterWrapper::GetUInt32(uint32_t attrId) 30 { 31 if (ref_) { 32 return ref_->GetUInt32(attrId); 33 } 34 return 0; 35 } 36 GetString(uint32_t attrId)37std::string NWebPrintAttributesAdapterWrapper::GetString(uint32_t attrId) 38 { 39 if (ref_) { 40 ArkWebString str = ref_->GetString(attrId); 41 std::string ret = ArkWebStringStructToClass(str); 42 ArkWebStringStructRelease(str); 43 return ret; 44 } 45 return ""; 46 } 47 GetUint32Vector(uint32_t attrId)48std::vector<uint32_t> NWebPrintAttributesAdapterWrapper::GetUint32Vector(uint32_t attrId) 49 { 50 if (ref_) { 51 ArkWebUint32Vector data = ref_->GetUint32Vector(attrId); 52 std::vector<uint32_t> ret = ArkWebBasicVectorStructToClass<uint32_t, ArkWebUint32Vector>(data); 53 ArkWebBasicVectorStructRelease<ArkWebUint32Vector>(data); 54 return ret; 55 } 56 return std::vector<uint32_t>(); 57 } 58 59 } // namespace OHOS::ArkWeb