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 #ifndef NWEB_PRINT_MANAGER_ADAPTER_H 17 #define NWEB_PRINT_MANAGER_ADAPTER_H 18 19 #include <memory> 20 #include <string> 21 #include <vector> 22 23 namespace OHOS::NWeb { 24 25 const uint32_t NWEB_PRINT_ATTR_ID_IS_VALID = 0; 26 const uint32_t NWEB_PRINT_ATTR_ID_COPY_NUMBER = 1; 27 const uint32_t NWEB_PRINT_ATTR_ID_PAGE_RANGE_START = 2; 28 const uint32_t NWEB_PRINT_ATTR_ID_PAGE_RANGE_END = 3; 29 const uint32_t NWEB_PRINT_ATTR_ID_PAGE_RANGE_ARRAY = 4; 30 const uint32_t NWEB_PRINT_ATTR_ID_PAGE_IS_SEQUENTIAL = 5; 31 const uint32_t NWEB_PRINT_ATTR_ID_PAGE_SIZE_WIDTH = 6; 32 const uint32_t NWEB_PRINT_ATTR_ID_PAGE_SIZE_HEIGHT = 7; 33 const uint32_t NWEB_PRINT_ATTR_ID_IS_LANDSCAPE = 8; 34 const uint32_t NWEB_PRINT_ATTR_ID_COLOR_MODE = 9; 35 const uint32_t NWEB_PRINT_ATTR_ID_DUPLEX_MODE = 10; 36 const uint32_t NWEB_PRINT_ATTR_ID_MARGIN_TOP = 11; 37 const uint32_t NWEB_PRINT_ATTR_ID_MARGIN_BOTTOM = 12; 38 const uint32_t NWEB_PRINT_ATTR_ID_MARGIN_LEFT = 13; 39 const uint32_t NWEB_PRINT_ATTR_ID_MARGIN_RIGHT = 14; 40 const uint32_t NWEB_PRINT_ATTR_ID_HAS_OPTION = 15; 41 const uint32_t NWEB_PRINT_ATTR_ID_OPTION = 16; 42 43 class NWebPrintAttributesAdapter { 44 public: 45 virtual ~NWebPrintAttributesAdapter() = default; 46 virtual bool GetBool(uint32_t attrId) = 0; 47 virtual uint32_t GetUInt32(uint32_t attrId) = 0; 48 virtual std::string GetString(uint32_t attrId) = 0; 49 virtual std::vector<uint32_t> GetUint32Vector(uint32_t attrId) = 0; 50 }; 51 52 class NWebPrintWriteResultCallbackAdapter { 53 public: 54 NWebPrintWriteResultCallbackAdapter() = default; 55 virtual ~NWebPrintWriteResultCallbackAdapter() = default; 56 57 virtual void WriteResultCallback(const std::string& jobId, uint32_t code) = 0; 58 }; 59 60 class NWebPrintDocumentAdapterAdapter { 61 public: 62 NWebPrintDocumentAdapterAdapter() = default; 63 virtual ~NWebPrintDocumentAdapterAdapter() = default; 64 65 virtual void OnStartLayoutWrite(const std::string& jobId, 66 std::shared_ptr<NWebPrintAttributesAdapter> oldAttrs, 67 std::shared_ptr<NWebPrintAttributesAdapter> newAttrs, uint32_t fd, 68 std::shared_ptr<NWebPrintWriteResultCallbackAdapter> callback) = 0; 69 70 virtual void OnJobStateChanged(const std::string& jobId, uint32_t state) = 0; 71 }; 72 73 } // namespace OHOS::NWeb 74 75 #endif // NWEB_PRINT_MANAGER_ADAPTER_H 76