• 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 SetBorderless(bool borderless);
46 
47     void SetOption(const std::string &option);
48 
49     [[nodiscard]] bool HasDefaultDuplexMode() const;
50 
51     [[nodiscard]] uint32_t GetDefaultDuplexMode() const;
52 
53     [[nodiscard]] bool HasDefaultPrintQuality() const;
54 
55     [[nodiscard]] uint32_t GetDefaultPrintQuality() const;
56 
57     [[nodiscard]] bool HasDefaultMediaType() const;
58 
59     [[nodiscard]] const std::string &GetDefaultMediaType() const;
60 
61     [[nodiscard]] bool HasDefaultPageSizeId() const;
62 
63     [[nodiscard]] const std::string &GetDefaultPageSizeId() const;
64 
65     [[nodiscard]] bool HasDefaultOrientation() const;
66 
67     [[nodiscard]] uint32_t GetDefaultOrientation() const;
68 
69     [[nodiscard]] bool HasBorderless() const;
70 
71     [[nodiscard]] bool GetBorderless() const;
72 
73     [[nodiscard]] bool HasOption() const;
74 
75     [[nodiscard]] std::string GetOption() const;
76 
77     virtual bool Marshalling(Parcel &parcel) const override;
78 
79     static std::shared_ptr<PrinterPreferences> Unmarshalling(Parcel &parcel);
80 
81     void Dump() const;
82 
83     Json::Value ConvertToJson();
84 
85     void ConvertJsonToPrinterPreferences(Json::Value &preferencesJson);
86 
87 private:
88     bool ReadFromParcel(Parcel &parcel);
89 
90 private:
91     bool hasDefaultDuplexMode_;
92 
93     uint32_t defaultDuplexMode_;
94 
95     bool hasDefaultPrintQuality_;
96 
97     uint32_t defaultPrintQuality_;
98 
99     bool hasDefaultMediaType_;
100 
101     std::string defaultMediaType_;
102 
103     bool hasDefaultPageSizeId_;
104 
105     std::string defaultPageSizeId_;
106 
107     bool hasDefaultOrientation_;
108 
109     uint32_t defaultOrientation_;
110 
111     bool hasBorderless_;
112 
113     bool borderless_;
114 
115     bool hasOption_;
116 
117     std::string option_;
118 };
119 }  // namespace OHOS::Print
120 #endif  // PRINTER_PREFERENCES_H
121