Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Side by Side Diff: printing/print_settings.h

Issue 47823002: De-duplicate job_settings parsing code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Noam's comments Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « printing/print_job_constants.cc ('k') | printing/print_settings.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <string> 8 #include <string>
9 9
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 18 matching lines...) Expand all
29 // OS-independent print settings. 29 // OS-independent print settings.
30 class PRINTING_EXPORT PrintSettings { 30 class PRINTING_EXPORT PrintSettings {
31 public: 31 public:
32 PrintSettings(); 32 PrintSettings();
33 ~PrintSettings(); 33 ~PrintSettings();
34 34
35 // Reinitialize the settings to the default values. 35 // Reinitialize the settings to the default values.
36 void Clear(); 36 void Clear();
37 37
38 // Set printer printable area in in device units. 38 // Set printer printable area in in device units.
39 void SetPrinterPrintableArea(gfx::Size const& physical_size_device_units, 39 // Some platforms already provide flipped area. Set |landscape_needs_flip|
40 gfx::Rect const& printable_area_device_units, 40 // to false on those platforms to avoid double flipping.
41 int units_per_inch); 41 void SetPrinterPrintableArea(const gfx::Size& physical_size_device_units,
42 const gfx::Rect& printable_area_device_units,
43 int units_per_inch,
44 bool landscape_needs_flip);
42 45
43 void SetCustomMargins(const PageMargins& requested_margins_in_points); 46 void SetCustomMargins(const PageMargins& requested_margins_in_points);
47 void set_margin_type(MarginType margin_type) { margin_type_ = margin_type; }
48 MarginType margin_type() const { return margin_type_; }
44 49
45 // Equality operator. 50 // Updates the orientation and flip the page if needed.
46 // NOTE: printer_name is NOT tested for equality since it doesn't affect the 51 void SetOrientation(bool landscape);
47 // output. 52 bool landscape() const { return landscape_; }
48 bool Equals(const PrintSettings& rhs) const;
49 53
50 void set_landscape(bool landscape) { landscape_ = landscape; }
51 void set_device_name(const base::string16& device_name) { 54 void set_device_name(const base::string16& device_name) {
52 device_name_ = device_name; 55 device_name_ = device_name;
53 } 56 }
54 const base::string16& device_name() const { return device_name_; } 57 const base::string16& device_name() const { return device_name_; }
58
55 void set_dpi(int dpi) { dpi_ = dpi; } 59 void set_dpi(int dpi) { dpi_ = dpi; }
56 int dpi() const { return dpi_; } 60 int dpi() const { return dpi_; }
61
57 void set_supports_alpha_blend(bool supports_alpha_blend) { 62 void set_supports_alpha_blend(bool supports_alpha_blend) {
58 supports_alpha_blend_ = supports_alpha_blend; 63 supports_alpha_blend_ = supports_alpha_blend;
59 } 64 }
60 bool supports_alpha_blend() const { return supports_alpha_blend_; } 65 bool supports_alpha_blend() const { return supports_alpha_blend_; }
66
61 const PageSetup& page_setup_device_units() const { 67 const PageSetup& page_setup_device_units() const {
62 return page_setup_device_units_; 68 return page_setup_device_units_;
63 } 69 }
64 int device_units_per_inch() const { 70 int device_units_per_inch() const {
65 #if defined(OS_MACOSX) 71 #if defined(OS_MACOSX)
66 return 72; 72 return 72;
67 #else // defined(OS_MACOSX) 73 #else // defined(OS_MACOSX)
68 return dpi(); 74 return dpi();
69 #endif // defined(OS_MACOSX) 75 #endif // defined(OS_MACOSX)
70 } 76 }
71 77
78 void set_ranges(const PageRanges& ranges) { ranges_ = ranges; };
79 const PageRanges& ranges() const { return ranges_; };
80
81 bool selection_only() const { return selection_only_; }
82 void set_selection_only(bool selection_only) {
83 selection_only_ = selection_only;
84 }
85
86 bool should_print_backgrounds() const { return should_print_backgrounds_; }
87 void set_should_print_backgrounds(bool should_print_backgrounds) {
88 should_print_backgrounds_ = should_print_backgrounds;
89 }
90
91 bool display_header_footer() const { return display_header_footer_; }
92 void set_display_header_footer(bool display_header_footer) {
93 display_header_footer_ = display_header_footer;
94 }
95
96 const base::string16& title() const { return title_; }
97 void set_title(const base::string16& title) { title_ = title; }
98
99 const base::string16& url() const { return url_; }
100 void set_url(const base::string16& url) { url_ = url; }
101
102 bool collate() const { return collate_; }
103 void set_collate(bool collate) { collate_ = collate; }
104
105 ColorModel color() const { return color_; }
106 void set_color(ColorModel color) { color_ = color; }
107
108 int copies() const { return copies_; }
109 void set_copies(int copies) { copies_ = copies; }
110
111 DuplexMode duplex_mode() const { return duplex_mode_; }
112 void set_duplex_mode(DuplexMode duplex_mode) { duplex_mode_ = duplex_mode; }
113
114 int desired_dpi() const { return desired_dpi_; }
115
116 double max_shrink() const { return max_shrink_; }
117
118 double min_shrink() const { return min_shrink_; }
119
120 // Cookie generator. It is used to initialize PrintedDocument with its
121 // associated PrintSettings, to be sure that each generated PrintedPage is
122 // correctly associated with its corresponding PrintedDocument.
123 static int NewCookie();
124
125 private:
72 // Multi-page printing. Each PageRange describes a from-to page combination. 126 // Multi-page printing. Each PageRange describes a from-to page combination.
73 // This permits printing selected pages only. 127 // This permits printing selected pages only.
74 PageRanges ranges; 128 PageRanges ranges_;
75 129
76 // By imaging to a width a little wider than the available pixels, thin pages 130 // By imaging to a width a little wider than the available pixels, thin pages
77 // will be scaled down a little, matching the way they print in IE and Camino. 131 // will be scaled down a little, matching the way they print in IE and Camino.
78 // This lets them use fewer sheets than they would otherwise, which is 132 // This lets them use fewer sheets than they would otherwise, which is
79 // presumably why other browsers do this. Wide pages will be scaled down more 133 // presumably why other browsers do this. Wide pages will be scaled down more
80 // than this. 134 // than this.
81 double min_shrink; 135 double min_shrink_;
82 136
83 // This number determines how small we are willing to reduce the page content 137 // This number determines how small we are willing to reduce the page content
84 // in order to accommodate the widest line. If the page would have to be 138 // in order to accommodate the widest line. If the page would have to be
85 // reduced smaller to make the widest line fit, we just clip instead (this 139 // reduced smaller to make the widest line fit, we just clip instead (this
86 // behavior matches MacIE and Mozilla, at least) 140 // behavior matches MacIE and Mozilla, at least)
87 double max_shrink; 141 double max_shrink_;
88 142
89 // Desired visible dots per inch rendering for output. Printing should be 143 // Desired visible dots per inch rendering for output. Printing should be
90 // scaled to ScreenDpi/dpix*desired_dpi. 144 // scaled to ScreenDpi/dpix*desired_dpi.
91 int desired_dpi; 145 int desired_dpi_;
92 146
93 // Indicates if the user only wants to print the current selection. 147 // Indicates if the user only wants to print the current selection.
94 bool selection_only; 148 bool selection_only_;
95 149
96 // Indicates what kind of margins should be applied to the printable area. 150 // Indicates what kind of margins should be applied to the printable area.
97 MarginType margin_type; 151 MarginType margin_type_;
98
99 // Cookie generator. It is used to initialize PrintedDocument with its
100 // associated PrintSettings, to be sure that each generated PrintedPage is
101 // correctly associated with its corresponding PrintedDocument.
102 static int NewCookie();
103
104 // Updates the orientation and flip the page if needed.
105 void SetOrientation(bool landscape);
106 152
107 // Strings to be printed as headers and footers if requested by the user. 153 // Strings to be printed as headers and footers if requested by the user.
108 base::string16 title; 154 base::string16 title_;
109 base::string16 url; 155 base::string16 url_;
110 156
111 // True if the user wants headers and footers to be displayed. 157 // True if the user wants headers and footers to be displayed.
112 bool display_header_footer; 158 bool display_header_footer_;
113 159
114 // True if the user wants to print CSS backgrounds. 160 // True if the user wants to print CSS backgrounds.
115 bool should_print_backgrounds; 161 bool should_print_backgrounds_;
116 162
117 private: 163 // True if the user wants to print with collate.
118 ////////////////////////////////////////////////////////////////////////////// 164 bool collate_;
119 // Settings that can't be changed without side-effects. 165
166 // True if the user wants to print with collate.
167 ColorModel color_;
168
169 // Number of copies user wants to print.
170 int copies_;
171
172 // Duplex type user wants to use.
173 DuplexMode duplex_mode_;
120 174
121 // Printer device name as opened by the OS. 175 // Printer device name as opened by the OS.
122 base::string16 device_name_; 176 base::string16 device_name_;
123 177
124 // Page setup in device units. 178 // Page setup in device units.
125 PageSetup page_setup_device_units_; 179 PageSetup page_setup_device_units_;
126 180
127 // Printer's device effective dots per inch in both axis. 181 // Printer's device effective dots per inch in both axis.
128 int dpi_; 182 int dpi_;
129 183
130 // Is the orientation landscape or portrait. 184 // Is the orientation landscape or portrait.
131 bool landscape_; 185 bool landscape_;
132 186
133 // True if this printer supports AlphaBlend. 187 // True if this printer supports AlphaBlend.
134 bool supports_alpha_blend_; 188 bool supports_alpha_blend_;
135 189
136 // If margin type is custom, this is what was requested. 190 // If margin type is custom, this is what was requested.
137 PageMargins requested_custom_margins_in_points_; 191 PageMargins requested_custom_margins_in_points_;
138 }; 192 };
139 193
140 } // namespace printing 194 } // namespace printing
141 195
142 #endif // PRINTING_PRINT_SETTINGS_H_ 196 #endif // PRINTING_PRINT_SETTINGS_H_
OLDNEW
« no previous file with comments | « printing/print_job_constants.cc ('k') | printing/print_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698