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 #ifndef PRINT_PAGESIZE_H 17 #define PRINT_PAGESIZE_H 18 19 #include <map> 20 #include "parcel.h" 21 22 namespace OHOS::Print { 23 enum PageSizeId { 24 ISO_A0, 25 ISO_A1, 26 ISO_A2, 27 ISO_A3, 28 ISO_A4, 29 ISO_A5, 30 ISO_A6, 31 ISO_A7, 32 ISO_A8, 33 ISO_A9, 34 ISO_A10, 35 36 ISO_B0, 37 ISO_B1, 38 ISO_B2, 39 ISO_B3, 40 ISO_B4, 41 ISO_B5, 42 ISO_B6, 43 ISO_B7, 44 ISO_B8, 45 ISO_B9, 46 ISO_B10, 47 48 ISO_C0, 49 ISO_C1, 50 ISO_C2, 51 ISO_C3, 52 ISO_C4, 53 ISO_C5, 54 ISO_C6, 55 ISO_C7, 56 ISO_C8, 57 ISO_C9, 58 ISO_C10, 59 60 NA_LETTER, 61 NA_GOVT_LETTER, 62 NA_LEGAL, 63 NA_JUNIOR_LEGAL, 64 NA_LEDGER, 65 NA_TABLOID, 66 NA_INDEX_3X5, 67 NA_INDEX_4X6, 68 NA_INDEX_5X8, 69 NA_MONARCH, 70 NA_QUARTO, 71 NA_FOOLSCAP, 72 73 ROC_8K, 74 ROC_16K, 75 PRC_1, 76 PRC_2, 77 PRC_3, 78 PRC_4, 79 PRC_5, 80 PRC_6, 81 PRC_7, 82 PRC_8, 83 PRC_9, 84 PRC_10, 85 PRC_16K, 86 OM_PA_KAI, 87 OM_DAI_PA_KAI, 88 OM_JUURO_KU_KAI, 89 90 JIS_B10, 91 JIS_B9, 92 JIS_B8, 93 JIS_B7, 94 JIS_B6, 95 JIS_B5, 96 JIS_B4, 97 JIS_B3, 98 JIS_B2, 99 JIS_B1, 100 JIS_B0, 101 JIS_EXEC, 102 JPN_CHOU4, 103 JPN_CHOU3, 104 JPN_CHOU2, 105 JPN_HAGAKI, 106 JPN_OUFUKU, 107 JPN_KAHU, 108 JPN_KAKU2, 109 JPN_YOU4, 110 }; 111 112 const std::string PAGE_SIZE_TABLE[] = { 113 "ISO_A0", "ISO_A1", "ISO_A2", "ISO_A3", 114 "ISO_A4", "ISO_A5", "ISO_A6", "ISO_A7", 115 "ISO_A8", "ISO_A9", "ISO_A10", 116 117 "ISO_B0", "ISO_B1", "ISO_B2", "ISO_B3", 118 "ISO_B4", "ISO_B5", "ISO_B6", "ISO_B7", 119 "ISO_B8", "ISO_B9", "ISO_B10", 120 121 "ISO_C0", "ISO_C1", "ISO_C2", "ISO_C3", 122 "ISO_C4", "ISO_C5", "ISO_C6", "ISO_C7", 123 "ISO_C8", "ISO_C9", "ISO_C10", 124 125 "NA_LETTER", "NA_GOVT_LETTER", "NA_LEGAL", "NA_JUNIOR_LEGAL", 126 "NA_LEDGER", "NA_TABLOID", "NA_INDEX_3X5", "NA_INDEX_4X6", 127 "NA_INDEX_5X8", "NA_MONARCH", "NA_QUARTO", "NA_FOOLSCAP", 128 129 "ROC_8K", "ROC_16K", "PRC_1", "PRC_2", 130 "PRC_3", "PRC_4", "PRC_5", "PRC_6", 131 "PRC_7", "PRC_8", "PRC_9", "PRC_10", 132 "PRC_16K", "OM_PA_KAI", "OM_DAI_PA_KAI", "OM_JUURO_KU_KAI", 133 134 "JIS_B10", "JIS_B9", "JIS_B8", "JIS_B7", 135 "JIS_B6", "JIS_B5", "JIS_B4", "JIS_B3", 136 "JIS_B2", "JIS_B1", "JIS_B0", "JIS_EXEC", 137 "JPN_CHOU4", "JPN_CHOU3", "JPN_CHOU2", "JPN_HAGAKI", 138 "JPN_OUFUKU", "JPN_KAHU", "JPN_KAKU2", "JPN_YOU4", 139 }; 140 141 using DiscreteId = std::string; 142 using DiscretePageName = std::string; 143 using PAGE_SIZE_ID = std::string; 144 145 class PrintPageSize final : public Parcelable { 146 public: 147 static void BuildPageSizeMap(); 148 149 static PrintPageSize GetPageSize(PageSizeId id); 150 151 explicit PrintPageSize(); 152 153 PrintPageSize(PAGE_SIZE_ID id, DiscretePageName name, uint32_t width, uint32_t height); 154 155 PrintPageSize(const PrintPageSize &right); 156 157 PrintPageSize &operator=(const PrintPageSize &right); 158 159 virtual ~PrintPageSize(); 160 161 void Reset(); 162 163 [[nodiscard]] const std::string &GetId() const; 164 165 [[nodiscard]] const std::string &GetName() const; 166 167 [[nodiscard]] uint32_t GetWidth() const; 168 169 [[nodiscard]] uint32_t GetHeight() const; 170 171 void SetId(const std::string &id); 172 173 void SetName(const std::string &name); 174 175 void SetWidth(uint32_t width); 176 177 void SetHeight(uint32_t height); 178 179 virtual bool Marshalling(Parcel &parcel) const override; 180 181 static std::shared_ptr<PrintPageSize> Unmarshalling(Parcel &parcel); 182 183 void Dump(); 184 185 private: 186 void ReadFromParcel(Parcel &parcel); 187 188 private: 189 std::string id_; 190 std::string name_; 191 uint32_t width_; 192 uint32_t height_; 193 static std::map<PAGE_SIZE_ID, std::shared_ptr<PrintPageSize>> pageSize_; 194 }; 195 } // namespace OHOS::Print 196 #endif // PRINT_PAGESIZE_H 197