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 #ifndef PRINTER_CAPABILITY_H 16 #define PRINTER_CAPABILITY_H 17 18 #include "iremote_broker.h" 19 #include "iremote_proxy.h" 20 #include "napi/native_api.h" 21 #include "parcel.h" 22 #include "print_margin.h" 23 #include "print_page_size.h" 24 #include "print_resolution.h" 25 26 namespace OHOS::Print { 27 class PrinterCapability final : public Parcelable { 28 public: 29 explicit PrinterCapability(); 30 31 PrinterCapability(const PrinterCapability &right); 32 33 PrinterCapability &operator=(const PrinterCapability &right); 34 35 virtual ~PrinterCapability(); 36 37 void Reset(); 38 39 [[nodiscard]] bool HasMargin() const; 40 41 void GetMinMargin(PrintMargin &margin) const; 42 43 void GetPageSize(std::vector<PrintPageSize> &pageSizeList) const; 44 45 [[nodiscard]] bool HasResolution() const; 46 47 void GetResolution(std::vector<PrintResolution> &resolutionList) const; 48 49 [[nodiscard]] uint32_t GetColorMode() const; 50 51 [[nodiscard]] uint32_t GetDuplexMode() const; 52 53 void SetOption(const std::string &option); 54 55 [[nodiscard]] bool HasOption() const; 56 57 [[nodiscard]] std::string GetOption() const; 58 59 void SetMinMargin(const PrintMargin &minMargin); 60 61 void SetPageSize(const std::vector<PrintPageSize> &pageSizeList); 62 63 void SetResolution(const std::vector<PrintResolution> &resolutionList); 64 65 void SetColorMode(uint32_t colorMode); 66 67 void SetDuplexMode(uint32_t duplexMode); 68 69 virtual bool Marshalling(Parcel &parcel) const override; 70 71 static std::shared_ptr<PrinterCapability> Unmarshalling(Parcel &parcel); 72 73 void Dump(); 74 75 private: 76 bool ReadFromParcel(Parcel &parcel); 77 78 private: 79 uint32_t colorMode_; 80 uint32_t duplexMode_; 81 std::vector<PrintPageSize> pageSizeList_; 82 83 bool hasResolution_; 84 std::vector<PrintResolution> resolutionList_; 85 86 bool hasMargin_; 87 PrintMargin minMargin_; 88 89 bool hasOption_; 90 std::string option_; 91 }; 92 } // namespace OHOS::Print 93 #endif // PRINTER_CAPABILITY_H 94