blob: 4adbb358b1a52c8b549cb8f40aae4b384e93ded5 [file] [log] [blame]
[email protected]71f40a72012-05-16 07:26:591// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]8ff1d422009-07-07 21:31:395#ifndef PRINTING_PRINT_SETTINGS_H_
6#define PRINTING_PRINT_SETTINGS_H_
initial.commit09911bf2008-07-26 23:55:297
[email protected]dcd1e8862011-08-09 06:06:588#include <string>
9
[email protected]896d161f2013-06-11 22:52:2410#include "base/strings/string16.h"
[email protected]8ff1d422009-07-07 21:31:3911#include "printing/page_range.h"
12#include "printing/page_setup.h"
[email protected]1c23b4e82011-10-15 22:30:4813#include "printing/print_job_constants.h"
[email protected]63313ae2011-10-13 00:40:3914#include "printing/printing_export.h"
tfarina3b0452d2014-12-31 15:20:0915#include "ui/gfx/geometry/rect.h"
initial.commit09911bf2008-07-26 23:55:2916
initial.commit09911bf2008-07-26 23:55:2917namespace printing {
18
[email protected]675a1ae2013-10-14 20:24:3719// Returns true if |color_mode| is color and not B&W.
20PRINTING_EXPORT bool IsColorModelSelected(int color_mode);
[email protected]63313ae2011-10-13 00:40:3921
[email protected]fa879e512011-11-08 20:39:0122#if defined(USE_CUPS)
23// Get the color model setting name and value for the |color_mode|.
24PRINTING_EXPORT void GetColorModelForMode(int color_mode,
25 std::string* color_setting_name,
26 std::string* color_value);
[email protected]63313ae2011-10-13 00:40:3927#endif
28
halcanary73b63fd2015-11-06 00:02:1429// Inform the printing system that it may embed this user-agent string
30// in its output's metadata.
31PRINTING_EXPORT void SetAgent(const std::string& user_agent);
32PRINTING_EXPORT const std::string& GetAgent();
33
initial.commit09911bf2008-07-26 23:55:2934// OS-independent print settings.
[email protected]69f5b1e62011-09-01 06:34:0435class PRINTING_EXPORT PrintSettings {
initial.commit09911bf2008-07-26 23:55:2936 public:
[email protected]72ddef92014-06-12 08:08:0637 // Media properties requested by the user. Default instance represents
38 // default media selection.
39 struct RequestedMedia {
40 // Size of the media, in microns.
41 gfx::Size size_microns;
42 // Platform specific id to map it back to the particular media.
43 std::string vendor_id;
44
45 bool IsDefault() const {
46 return size_microns.IsEmpty() && vendor_id.empty();
47 }
48 };
49
initial.commit09911bf2008-07-26 23:55:2950 PrintSettings();
vmpstr04b8358f2016-02-26 01:38:2951 PrintSettings(const PrintSettings& other);
[email protected]20f0487a2010-09-30 20:06:3052 ~PrintSettings();
initial.commit09911bf2008-07-26 23:55:2953
54 // Reinitialize the settings to the default values.
55 void Clear();
56
[email protected]b076a082011-10-20 01:26:3257 void SetCustomMargins(const PageMargins& requested_margins_in_points);
[email protected]c95198b2014-06-12 16:56:5558 const PageMargins& requested_custom_margins_in_points() const {
59 return requested_custom_margins_in_points_;
60 }
[email protected]e5324b52013-10-29 03:16:3761 void set_margin_type(MarginType margin_type) { margin_type_ = margin_type; }
62 MarginType margin_type() const { return margin_type_; }
[email protected]1c23b4e82011-10-15 22:30:4863
[email protected]e5324b52013-10-29 03:16:3764 // Updates the orientation and flip the page if needed.
65 void SetOrientation(bool landscape);
66 bool landscape() const { return landscape_; }
initial.commit09911bf2008-07-26 23:55:2967
[email protected]72ddef92014-06-12 08:08:0668 // Updates user requested media.
69 void set_requested_media(const RequestedMedia& media) {
70 requested_media_ = media;
71 }
72 // Media properties requested by the user. Translated into device media by the
73 // platform specific layers.
74 const RequestedMedia& requested_media() const {
75 return requested_media_;
76 }
77
[email protected]e5324b52013-10-29 03:16:3778 // Set printer printable area in in device units.
79 // Some platforms already provide flipped area. Set |landscape_needs_flip|
80 // to false on those platforms to avoid double flipping.
81 void SetPrinterPrintableArea(const gfx::Size& physical_size_device_units,
82 const gfx::Rect& printable_area_device_units,
[email protected]e5324b52013-10-29 03:16:3783 bool landscape_needs_flip);
84 const PageSetup& page_setup_device_units() const {
85 return page_setup_device_units_;
86 }
87
[email protected]b5fa4ee2013-10-01 07:19:0788 void set_device_name(const base::string16& device_name) {
initial.commit09911bf2008-07-26 23:55:2989 device_name_ = device_name;
90 }
[email protected]b5fa4ee2013-10-01 07:19:0791 const base::string16& device_name() const { return device_name_; }
[email protected]e5324b52013-10-29 03:16:3792
[email protected]4993f342010-10-26 17:57:5293 void set_dpi(int dpi) { dpi_ = dpi; }
initial.commit09911bf2008-07-26 23:55:2994 int dpi() const { return dpi_; }
[email protected]e5324b52013-10-29 03:16:3795
[email protected]b2b0fce2011-01-12 16:34:4096 void set_supports_alpha_blend(bool supports_alpha_blend) {
97 supports_alpha_blend_ = supports_alpha_blend;
98 }
99 bool supports_alpha_blend() const { return supports_alpha_blend_; }
[email protected]e5324b52013-10-29 03:16:37100
[email protected]6ab86ac2010-05-29 07:18:29101 int device_units_per_inch() const {
102#if defined(OS_MACOSX)
103 return 72;
104#else // defined(OS_MACOSX)
105 return dpi();
106#endif // defined(OS_MACOSX)
107 }
initial.commit09911bf2008-07-26 23:55:29108
thestige85e6b62016-08-25 00:00:06109 void set_ranges(const PageRanges& ranges) { ranges_ = ranges; }
110 const PageRanges& ranges() const { return ranges_; }
initial.commit09911bf2008-07-26 23:55:29111
[email protected]e5324b52013-10-29 03:16:37112 void set_selection_only(bool selection_only) {
113 selection_only_ = selection_only;
114 }
115 bool selection_only() const { return selection_only_; }
initial.commit09911bf2008-07-26 23:55:29116
[email protected]e5324b52013-10-29 03:16:37117 void set_should_print_backgrounds(bool should_print_backgrounds) {
118 should_print_backgrounds_ = should_print_backgrounds;
119 }
120 bool should_print_backgrounds() const { return should_print_backgrounds_; }
initial.commit09911bf2008-07-26 23:55:29121
[email protected]e5324b52013-10-29 03:16:37122 void set_display_header_footer(bool display_header_footer) {
123 display_header_footer_ = display_header_footer;
124 }
125 bool display_header_footer() const { return display_header_footer_; }
initial.commit09911bf2008-07-26 23:55:29126
[email protected]e5324b52013-10-29 03:16:37127 void set_title(const base::string16& title) { title_ = title; }
128 const base::string16& title() const { return title_; }
[email protected]c8ad40c2009-06-08 17:05:21129
[email protected]e5324b52013-10-29 03:16:37130 void set_url(const base::string16& url) { url_ = url; }
131 const base::string16& url() const { return url_; }
132
133 void set_collate(bool collate) { collate_ = collate; }
134 bool collate() const { return collate_; }
135
136 void set_color(ColorModel color) { color_ = color; }
137 ColorModel color() const { return color_; }
138
139 void set_copies(int copies) { copies_ = copies; }
140 int copies() const { return copies_; }
141
142 void set_duplex_mode(DuplexMode duplex_mode) { duplex_mode_ = duplex_mode; }
143 DuplexMode duplex_mode() const { return duplex_mode_; }
144
145 int desired_dpi() const { return desired_dpi_; }
146
thestige85e6b62016-08-25 00:00:06147#if defined(OS_WIN)
148 void set_print_text_with_gdi(bool use_gdi) { print_text_with_gdi_ = use_gdi; }
149 bool print_text_with_gdi() const { return print_text_with_gdi_; }
thestig1f8436b2016-10-06 01:09:25150
151 void set_printer_is_xps(bool is_xps) { printer_is_xps_ = is_xps; }
152 bool printer_is_xps() const { return printer_is_xps_; }
thestige85e6b62016-08-25 00:00:06153#endif
154
[email protected]d30e8e642008-08-06 12:05:24155 // Cookie generator. It is used to initialize PrintedDocument with its
156 // associated PrintSettings, to be sure that each generated PrintedPage is
157 // correctly associated with its corresponding PrintedDocument.
initial.commit09911bf2008-07-26 23:55:29158 static int NewCookie();
159
[email protected]e5324b52013-10-29 03:16:37160 private:
161 // Multi-page printing. Each PageRange describes a from-to page combination.
162 // This permits printing selected pages only.
163 PageRanges ranges_;
164
[email protected]e5324b52013-10-29 03:16:37165 // Desired visible dots per inch rendering for output. Printing should be
166 // scaled to ScreenDpi/dpix*desired_dpi.
167 int desired_dpi_;
168
169 // Indicates if the user only wants to print the current selection.
170 bool selection_only_;
171
172 // Indicates what kind of margins should be applied to the printable area.
173 MarginType margin_type_;
[email protected]c48bee22011-03-29 02:36:26174
[email protected]55b23a02011-08-17 23:09:36175 // Strings to be printed as headers and footers if requested by the user.
[email protected]e5324b52013-10-29 03:16:37176 base::string16 title_;
177 base::string16 url_;
[email protected]55b23a02011-08-17 23:09:36178
179 // True if the user wants headers and footers to be displayed.
[email protected]e5324b52013-10-29 03:16:37180 bool display_header_footer_;
[email protected]55b23a02011-08-17 23:09:36181
[email protected]19d1c2d2013-01-14 00:59:46182 // True if the user wants to print CSS backgrounds.
[email protected]e5324b52013-10-29 03:16:37183 bool should_print_backgrounds_;
[email protected]19d1c2d2013-01-14 00:59:46184
[email protected]e5324b52013-10-29 03:16:37185 // True if the user wants to print with collate.
186 bool collate_;
187
188 // True if the user wants to print with collate.
189 ColorModel color_;
190
191 // Number of copies user wants to print.
192 int copies_;
193
194 // Duplex type user wants to use.
195 DuplexMode duplex_mode_;
initial.commit09911bf2008-07-26 23:55:29196
initial.commit09911bf2008-07-26 23:55:29197 // Printer device name as opened by the OS.
[email protected]b5fa4ee2013-10-01 07:19:07198 base::string16 device_name_;
initial.commit09911bf2008-07-26 23:55:29199
[email protected]72ddef92014-06-12 08:08:06200 // Media requested by the user.
201 RequestedMedia requested_media_;
202
[email protected]6ab86ac2010-05-29 07:18:29203 // Page setup in device units.
204 PageSetup page_setup_device_units_;
initial.commit09911bf2008-07-26 23:55:29205
206 // Printer's device effective dots per inch in both axis.
207 int dpi_;
208
209 // Is the orientation landscape or portrait.
210 bool landscape_;
[email protected]b2b0fce2011-01-12 16:34:40211
212 // True if this printer supports AlphaBlend.
213 bool supports_alpha_blend_;
[email protected]1c23b4e82011-10-15 22:30:48214
thestige85e6b62016-08-25 00:00:06215#if defined(OS_WIN)
216 // True to print text with GDI.
217 bool print_text_with_gdi_;
thestig1f8436b2016-10-06 01:09:25218
219 // True if the printer is an XPS printer.
220 bool printer_is_xps_;
thestige85e6b62016-08-25 00:00:06221#endif
222
[email protected]b076a082011-10-20 01:26:32223 // If margin type is custom, this is what was requested.
224 PageMargins requested_custom_margins_in_points_;
initial.commit09911bf2008-07-26 23:55:29225};
226
227} // namespace printing
228
[email protected]8ff1d422009-07-07 21:31:39229#endif // PRINTING_PRINT_SETTINGS_H_