| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "printing/print_settings.h" | 5 #include "printing/print_settings.h" |
| 6 | 6 |
| 7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "printing/print_job_constants.h" | 9 #include "printing/print_job_constants.h" |
| 10 #include "printing/units.h" | 10 #include "printing/units.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 void PrintSettings::SetPrinterPrintableArea( | 146 void PrintSettings::SetPrinterPrintableArea( |
| 147 gfx::Size const& physical_size_device_units, | 147 gfx::Size const& physical_size_device_units, |
| 148 gfx::Rect const& printable_area_device_units, | 148 gfx::Rect const& printable_area_device_units, |
| 149 int units_per_inch) { | 149 int units_per_inch) { |
| 150 int header_footer_text_height = 0; | 150 int header_footer_text_height = 0; |
| 151 if (display_header_footer) { | 151 if (display_header_footer) { |
| 152 // Hard-code text_height = 0.5cm = ~1/5 of inch. | 152 // Hard-code text_height = 0.5cm = ~1/5 of inch. |
| 153 header_footer_text_height = ConvertUnit(kSettingHeaderFooterInterstice, | 153 header_footer_text_height = ConvertUnit(kSettingHeaderFooterInterstice, |
| 154 kPointsPerInch, units_per_inch); | 154 kPointsPerInch, units_per_inch); |
| 155 } | 155 } |
| 156 page_setup_device_units_.Init(physical_size_device_units, | |
| 157 printable_area_device_units, | |
| 158 header_footer_text_height); | |
| 159 | 156 |
| 160 PageMargins margins; | 157 PageMargins margins; |
| 161 switch (margin_type) { | 158 switch (margin_type) { |
| 162 case DEFAULT_MARGINS: { | 159 case DEFAULT_MARGINS: { |
| 163 // Default margins 1.0cm = ~2/5 of an inch. | 160 // Default margins 1.0cm = ~2/5 of an inch. |
| 164 int margin_printer_units = ConvertUnit(1000, kHundrethsMMPerInch, | 161 int margin_printer_units = ConvertUnit(1000, kHundrethsMMPerInch, |
| 165 units_per_inch); | 162 units_per_inch); |
| 166 margins.header = header_footer_text_height; | 163 margins.header = header_footer_text_height; |
| 167 margins.footer = header_footer_text_height; | 164 margins.footer = header_footer_text_height; |
| 168 margins.top = margin_printer_units; | 165 margins.top = margin_printer_units; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 } | 201 } |
| 205 default: { | 202 default: { |
| 206 NOTREACHED(); | 203 NOTREACHED(); |
| 207 } | 204 } |
| 208 } | 205 } |
| 209 | 206 |
| 210 if (margin_type == DEFAULT_MARGINS || margin_type == PRINTABLE_AREA_MARGINS) | 207 if (margin_type == DEFAULT_MARGINS || margin_type == PRINTABLE_AREA_MARGINS) |
| 211 page_setup_device_units_.SetRequestedMargins(margins); | 208 page_setup_device_units_.SetRequestedMargins(margins); |
| 212 else | 209 else |
| 213 page_setup_device_units_.ForceRequestedMargins(margins); | 210 page_setup_device_units_.ForceRequestedMargins(margins); |
| 211 |
| 212 page_setup_device_units_.Init(physical_size_device_units, |
| 213 printable_area_device_units, |
| 214 header_footer_text_height); |
| 214 } | 215 } |
| 215 | 216 |
| 216 void PrintSettings::SetCustomMargins( | 217 void PrintSettings::SetCustomMargins( |
| 217 const PageMargins& requested_margins_in_points) { | 218 const PageMargins& requested_margins_in_points) { |
| 218 requested_custom_margins_in_points_ = requested_margins_in_points; | 219 requested_custom_margins_in_points_ = requested_margins_in_points; |
| 219 margin_type = CUSTOM_MARGINS; | 220 margin_type = CUSTOM_MARGINS; |
| 220 } | 221 } |
| 221 | 222 |
| 222 bool PrintSettings::Equals(const PrintSettings& rhs) const { | 223 bool PrintSettings::Equals(const PrintSettings& rhs) const { |
| 223 // Do not test the display device name (printer_name_) for equality since it | 224 // Do not test the display device name (printer_name_) for equality since it |
| (...skipping 15 matching lines...) Expand all Loading... |
| 239 } | 240 } |
| 240 | 241 |
| 241 void PrintSettings::SetOrientation(bool landscape) { | 242 void PrintSettings::SetOrientation(bool landscape) { |
| 242 if (landscape_ != landscape) { | 243 if (landscape_ != landscape) { |
| 243 landscape_ = landscape; | 244 landscape_ = landscape; |
| 244 page_setup_device_units_.FlipOrientation(); | 245 page_setup_device_units_.FlipOrientation(); |
| 245 } | 246 } |
| 246 } | 247 } |
| 247 | 248 |
| 248 } // namespace printing | 249 } // namespace printing |
| OLD | NEW |