• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 PRINTER_PREFERENCES_H
17 #define PRINTER_PREFERENCES_H
18 
19 #include "parcel.h"
20 #include <json/json.h>
21 
22 namespace OHOS::Print {
23 class PrinterPreferences final : public Parcelable {
24 public:
25     explicit PrinterPreferences();
26 
27     PrinterPreferences(const PrinterPreferences &right);
28 
29     PrinterPreferences &operator=(const PrinterPreferences &right);
30 
31     virtual ~PrinterPreferences();
32 
33     void Reset();
34 
35     void SetDefaultDuplexMode(uint32_t defaultDuplexMode);
36 
37     void SetDefaultPrintQuality(uint32_t defaultPrintQuality);
38 
39     void SetDefaultMediaType(const std::string &defaultMediaType);
40 
41     void SetDefaultPageSizeId(const std::string &defaultPageSizeId);
42 
43     void SetDefaultOrientation(uint32_t defaultOrientation);
44 
45     void SetDefaultColorMode(uint32_t defaultColorMode);
46 
47     void SetBorderless(bool borderless);
48 
49     void SetDefaultCollate(bool defaultCollate);
50 
51     void SetDefaultReverse(bool defaultReverse);
52 
53     void SetOption(const std::string &option);
54 
55     [[nodiscard]] bool HasDefaultDuplexMode() const;
56 
57     [[nodiscard]] uint32_t GetDefaultDuplexMode() const;
58 
59     [[nodiscard]] bool HasDefaultPrintQuality() const;
60 
61     [[nodiscard]] uint32_t GetDefaultPrintQuality() const;
62 
63     [[nodiscard]] bool HasDefaultMediaType() const;
64 
65     [[nodiscard]] const std::string &GetDefaultMediaType() const;
66 
67     [[nodiscard]] bool HasDefaultPageSizeId() const;
68 
69     [[nodiscard]] const std::string &GetDefaultPageSizeId() const;
70 
71     [[nodiscard]] bool HasDefaultOrientation() const;
72 
73     [[nodiscard]] uint32_t GetDefaultOrientation() const;
74 
75     [[nodiscard]] bool HasDefaultColorMode() const;
76 
77     [[nodiscard]] uint32_t GetDefaultColorMode() const;
78 
79     [[nodiscard]] bool HasBorderless() const;
80 
81     [[nodiscard]] bool GetBorderless() const;
82 
83     [[nodiscard]] bool HasOption() const;
84 
85     [[nodiscard]] bool GetDefaultCollate() const;
86 
87     [[nodiscard]] bool HasDefaultCollate() const;
88 
89     [[nodiscard]] bool GetDefaultReverse() const;
90 
91     [[nodiscard]] bool HasDefaultReverse() const;
92 
93     [[nodiscard]] std::string GetOption() const;
94 
95     virtual bool Marshalling(Parcel &parcel) const override;
96 
97     static std::shared_ptr<PrinterPreferences> Unmarshalling(Parcel &parcel);
98 
99     void Dump() const;
100 
101     Json::Value ConvertToJson();
102 
103     void ConvertJsonToPrinterPreferences(Json::Value &preferencesJson);
104 
105 private:
106     bool ReadFromParcel(Parcel &parcel);
107     void ConvertBoolDefaultJsonToPrinterPreferences(Json::Value &preferencesJson);
108 
109 private:
110     bool hasDefaultDuplexMode_;
111 
112     uint32_t defaultDuplexMode_;
113 
114     bool hasDefaultPrintQuality_;
115 
116     uint32_t defaultPrintQuality_;
117 
118     bool hasDefaultMediaType_;
119 
120     std::string defaultMediaType_;
121 
122     bool hasDefaultPageSizeId_;
123 
124     std::string defaultPageSizeId_;
125 
126     bool hasDefaultOrientation_;
127 
128     uint32_t defaultOrientation_;
129 
130     bool hasDefaultColorMode_;
131 
132     uint32_t defaultColorMode_;
133 
134     bool hasBorderless_;
135 
136     bool borderless_;
137 
138     bool hasDefaultCollate_;
139 
140     bool defaultCollate_;
141 
142     bool hasDefaultReverse_;
143 
144     bool defaultReverse_;
145 
146     bool hasOption_;
147 
148     std::string option_;
149 };
150 }  // namespace OHOS::Print
151 #endif  // PRINTER_PREFERENCES_H
152