OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef PRINTING_PRINT_SETTINGS_H_ | 5 #ifndef PRINTING_PRINT_SETTINGS_H_ |
6 #define PRINTING_PRINT_SETTINGS_H_ | 6 #define PRINTING_PRINT_SETTINGS_H_ |
7 | 7 |
8 #include <algorithm> | |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
11 #include "printing/page_range.h" | 12 #include "printing/page_range.h" |
12 #include "printing/page_setup.h" | 13 #include "printing/page_setup.h" |
13 #include "printing/print_job_constants.h" | 14 #include "printing/print_job_constants.h" |
14 #include "printing/printing_export.h" | 15 #include "printing/printing_export.h" |
15 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
16 | 17 |
17 namespace printing { | 18 namespace printing { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 bool landscape_needs_flip); | 92 bool landscape_needs_flip); |
92 const PageSetup& page_setup_device_units() const { | 93 const PageSetup& page_setup_device_units() const { |
93 return page_setup_device_units_; | 94 return page_setup_device_units_; |
94 } | 95 } |
95 | 96 |
96 void set_device_name(const base::string16& device_name) { | 97 void set_device_name(const base::string16& device_name) { |
97 device_name_ = device_name; | 98 device_name_ = device_name; |
98 } | 99 } |
99 const base::string16& device_name() const { return device_name_; } | 100 const base::string16& device_name() const { return device_name_; } |
100 | 101 |
101 void set_dpi(int dpi) { dpi_ = dpi; } | 102 void set_dpi(int dpi) { |
102 int dpi() const { return dpi_; } | 103 dpi_[0] = dpi; |
104 dpi_[1] = dpi; | |
105 } | |
106 void set_dpi(int dpi_horizontal, int dpi_vertical) { | |
Lei Zhang
2017/04/04 00:03:03
Can we name this something else to avoid overloadi
rbpotter
2017/04/04 00:36:34
Done.
| |
107 dpi_[0] = dpi_horizontal; | |
108 dpi_[1] = dpi_vertical; | |
109 } | |
110 int dpi() const { return std::min(dpi_[0], dpi_[1]); } | |
103 | 111 |
104 void set_scale_factor(double scale_factor) { scale_factor_ = scale_factor; } | 112 void set_scale_factor(double scale_factor) { scale_factor_ = scale_factor; } |
105 double scale_factor() const { return scale_factor_; } | 113 double scale_factor() const { return scale_factor_; } |
106 | 114 |
107 void set_rasterize_pdf(bool rasterize_pdf) { rasterize_pdf_ = rasterize_pdf; } | 115 void set_rasterize_pdf(bool rasterize_pdf) { rasterize_pdf_ = rasterize_pdf; } |
108 bool rasterize_pdf() const { return rasterize_pdf_; } | 116 bool rasterize_pdf() const { return rasterize_pdf_; } |
109 | 117 |
110 void set_supports_alpha_blend(bool supports_alpha_blend) { | 118 void set_supports_alpha_blend(bool supports_alpha_blend) { |
111 supports_alpha_blend_ = supports_alpha_blend; | 119 supports_alpha_blend_ = supports_alpha_blend; |
112 } | 120 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 | 157 |
150 void set_color(ColorModel color) { color_ = color; } | 158 void set_color(ColorModel color) { color_ = color; } |
151 ColorModel color() const { return color_; } | 159 ColorModel color() const { return color_; } |
152 | 160 |
153 void set_copies(int copies) { copies_ = copies; } | 161 void set_copies(int copies) { copies_ = copies; } |
154 int copies() const { return copies_; } | 162 int copies() const { return copies_; } |
155 | 163 |
156 void set_duplex_mode(DuplexMode duplex_mode) { duplex_mode_ = duplex_mode; } | 164 void set_duplex_mode(DuplexMode duplex_mode) { duplex_mode_ = duplex_mode; } |
157 DuplexMode duplex_mode() const { return duplex_mode_; } | 165 DuplexMode duplex_mode() const { return duplex_mode_; } |
158 | 166 |
167 int dpi_horizontal() const { return dpi_[0]; } | |
Lei Zhang
2017/04/04 00:03:03
Can we keep these grouped with dpi() above?
rbpotter
2017/04/04 00:36:34
Done.
| |
168 int dpi_vertical() const { return dpi_[1]; } | |
169 | |
159 #if defined(OS_WIN) | 170 #if defined(OS_WIN) |
160 void set_print_text_with_gdi(bool use_gdi) { print_text_with_gdi_ = use_gdi; } | 171 void set_print_text_with_gdi(bool use_gdi) { print_text_with_gdi_ = use_gdi; } |
161 bool print_text_with_gdi() const { return print_text_with_gdi_; } | 172 bool print_text_with_gdi() const { return print_text_with_gdi_; } |
162 | 173 |
163 void set_printer_type(PrinterType type) { printer_type_ = type; } | 174 void set_printer_type(PrinterType type) { printer_type_ = type; } |
164 bool printer_is_xps() const { return printer_type_ == PrinterType::TYPE_XPS;} | 175 bool printer_is_xps() const { return printer_type_ == PrinterType::TYPE_XPS;} |
165 bool printer_is_ps2() const { | 176 bool printer_is_ps2() const { |
166 return printer_type_ == PrinterType::TYPE_POSTSCRIPT_LEVEL2; | 177 return printer_type_ == PrinterType::TYPE_POSTSCRIPT_LEVEL2; |
167 } | 178 } |
168 bool printer_is_ps3() const { | 179 bool printer_is_ps3() const { |
169 return printer_type_ == PrinterType::TYPE_POSTSCRIPT_LEVEL3; | 180 return printer_type_ == PrinterType::TYPE_POSTSCRIPT_LEVEL3; |
170 } | 181 } |
171 #endif | 182 #endif |
172 | 183 |
173 // Cookie generator. It is used to initialize PrintedDocument with its | 184 // Cookie generator. It is used to initialize PrintedDocument with its |
174 // associated PrintSettings, to be sure that each generated PrintedPage is | 185 // associated PrintSettings, to be sure that each generated PrintedPage is |
175 // correctly associated with its corresponding PrintedDocument. | 186 // correctly associated with its corresponding PrintedDocument. |
176 static int NewCookie(); | 187 static int NewCookie(); |
177 | 188 |
178 private: | 189 private: |
179 // Multi-page printing. Each PageRange describes a from-to page combination. | 190 // Multi-page printing. Each PageRange describes a from-to page combination. |
180 // This permits printing selected pages only. | 191 // This permits printing selected pages only. |
181 PageRanges ranges_; | 192 PageRanges ranges_; |
182 | 193 |
183 // Desired visible dots per inch rendering for output. Printing should be | |
184 // scaled to ScreenDpi/dpix*desired_dpi. | |
185 int desired_dpi_; | |
186 | |
187 // Indicates if the user only wants to print the current selection. | 194 // Indicates if the user only wants to print the current selection. |
188 bool selection_only_; | 195 bool selection_only_; |
189 | 196 |
190 // Indicates what kind of margins should be applied to the printable area. | 197 // Indicates what kind of margins should be applied to the printable area. |
191 MarginType margin_type_; | 198 MarginType margin_type_; |
192 | 199 |
193 // Strings to be printed as headers and footers if requested by the user. | 200 // Strings to be printed as headers and footers if requested by the user. |
194 base::string16 title_; | 201 base::string16 title_; |
195 base::string16 url_; | 202 base::string16 url_; |
196 | 203 |
(...skipping 17 matching lines...) Expand all Loading... | |
214 | 221 |
215 // Printer device name as opened by the OS. | 222 // Printer device name as opened by the OS. |
216 base::string16 device_name_; | 223 base::string16 device_name_; |
217 | 224 |
218 // Media requested by the user. | 225 // Media requested by the user. |
219 RequestedMedia requested_media_; | 226 RequestedMedia requested_media_; |
220 | 227 |
221 // Page setup in device units. | 228 // Page setup in device units. |
222 PageSetup page_setup_device_units_; | 229 PageSetup page_setup_device_units_; |
223 | 230 |
224 // Printer's device effective dots per inch in both axis. | 231 // Printer's device effective dots per inch in both axis. |
Lei Zhang
2017/04/04 00:03:03
Can we add some notes to say the two values can on
rbpotter
2017/04/04 00:36:34
Done.
| |
225 int dpi_; | 232 int dpi_[2]; |
226 | 233 |
227 // Scale factor | 234 // Scale factor |
228 double scale_factor_; | 235 double scale_factor_; |
229 | 236 |
230 // True if PDF should be printed as a raster PDF | 237 // True if PDF should be printed as a raster PDF |
231 bool rasterize_pdf_; | 238 bool rasterize_pdf_; |
232 | 239 |
233 // Is the orientation landscape or portrait. | 240 // Is the orientation landscape or portrait. |
234 bool landscape_; | 241 bool landscape_; |
235 | 242 |
236 // True if this printer supports AlphaBlend. | 243 // True if this printer supports AlphaBlend. |
237 bool supports_alpha_blend_; | 244 bool supports_alpha_blend_; |
238 | 245 |
239 #if defined(OS_WIN) | 246 #if defined(OS_WIN) |
240 // True to print text with GDI. | 247 // True to print text with GDI. |
241 bool print_text_with_gdi_; | 248 bool print_text_with_gdi_; |
242 | 249 |
243 PrinterType printer_type_; | 250 PrinterType printer_type_; |
244 #endif | 251 #endif |
245 | 252 |
246 // If margin type is custom, this is what was requested. | 253 // If margin type is custom, this is what was requested. |
247 PageMargins requested_custom_margins_in_points_; | 254 PageMargins requested_custom_margins_in_points_; |
248 }; | 255 }; |
249 | 256 |
250 } // namespace printing | 257 } // namespace printing |
251 | 258 |
252 #endif // PRINTING_PRINT_SETTINGS_H_ | 259 #endif // PRINTING_PRINT_SETTINGS_H_ |
OLD | NEW |