1 /* 2 * Copyright (c) 2023 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 PRINT_MANAGER_ADAPTER_H 17 #define PRINT_MANAGER_ADAPTER_H 18 19 #include <string> 20 #include <vector> 21 22 namespace OHOS::NWeb { 23 24 struct PrintRangeAdapter { 25 uint32_t startPage; 26 uint32_t endPage; 27 std::vector<uint32_t> pages; 28 }; 29 30 struct PrintPageSizeAdapter { 31 uint32_t width; 32 uint32_t height; 33 }; 34 35 struct PrintMarginAdapter { 36 uint32_t top; 37 uint32_t bottom; 38 uint32_t left; 39 uint32_t right; 40 }; 41 42 struct PrintAttributesAdapter { 43 uint32_t copyNumber; 44 PrintRangeAdapter pageRange; 45 bool isSequential; 46 PrintPageSizeAdapter pageSize; 47 bool isLandscape; 48 uint32_t colorMode; 49 uint32_t duplexMode; 50 PrintMarginAdapter margin; 51 bool hasOption; 52 std::string option; 53 }; 54 55 /*[clang::lto_visibility_public]:Prevent this class from being optimized away at compile time*/ 56 class [[clang::lto_visibility_public]] PrintWriteResultCallbackAdapter { 57 public: 58 PrintWriteResultCallbackAdapter() = default; 59 virtual ~PrintWriteResultCallbackAdapter() = default; 60 61 virtual void WriteResultCallback(std::string jobId, uint32_t code) = 0; 62 }; 63 64 class PrintDocumentAdapterAdapter { 65 public: 66 PrintDocumentAdapterAdapter() = default; 67 virtual ~PrintDocumentAdapterAdapter() = default; 68 69 virtual void OnStartLayoutWrite(const std::string& jobId, const PrintAttributesAdapter& oldAttrs, 70 const PrintAttributesAdapter& newAttrs, uint32_t fd, 71 std::shared_ptr<PrintWriteResultCallbackAdapter> callback) = 0; 72 73 virtual void OnJobStateChanged(const std::string& jobId, uint32_t state) = 0; 74 }; 75 76 class PrintManagerAdapter { 77 public: 78 PrintManagerAdapter() = default; 79 80 virtual ~PrintManagerAdapter() = default; 81 82 virtual int32_t StartPrint( 83 const std::vector<std::string>& fileList, const std::vector<uint32_t>& fdList, std::string& taskId) = 0; 84 85 virtual int32_t Print(const std::string& printJobName, const std::shared_ptr<PrintDocumentAdapterAdapter> listener, 86 const PrintAttributesAdapter& printAttributes) = 0; 87 88 virtual int32_t Print(const std::string& printJobName, const std::shared_ptr<PrintDocumentAdapterAdapter> listener, 89 const PrintAttributesAdapter& printAttributes, void* contextToken) = 0; 90 }; 91 92 } // namespace OHOS::NWeb 93 94 #endif // PRINT_MANAGER_ADAPTER_H 95