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/printing_context.h" | 5 #include "printing/printing_context.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "printing/page_setup.h" | 9 #include "printing/page_setup.h" |
10 #include "printing/page_size_margins.h" | |
11 #include "printing/print_settings_initializer.h" | 10 #include "printing/print_settings_initializer.h" |
12 | 11 |
13 namespace printing { | 12 namespace printing { |
14 | 13 |
15 PrintingContext::PrintingContext(const std::string& app_locale) | 14 PrintingContext::PrintingContext(const std::string& app_locale) |
16 : dialog_box_dismissed_(false), | 15 : dialog_box_dismissed_(false), |
17 in_print_job_(false), | 16 in_print_job_(false), |
18 abort_printing_(false), | 17 abort_printing_(false), |
19 app_locale_(app_locale) { | 18 app_locale_(app_locale) { |
20 } | 19 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 if (!job_settings.GetInteger(kSettingMarginsType, &margin_type) || | 55 if (!job_settings.GetInteger(kSettingMarginsType, &margin_type) || |
57 (margin_type != DEFAULT_MARGINS && | 56 (margin_type != DEFAULT_MARGINS && |
58 margin_type != NO_MARGINS && | 57 margin_type != NO_MARGINS && |
59 margin_type != CUSTOM_MARGINS && | 58 margin_type != CUSTOM_MARGINS && |
60 margin_type != PRINTABLE_AREA_MARGINS)) { | 59 margin_type != PRINTABLE_AREA_MARGINS)) { |
61 NOTREACHED(); | 60 NOTREACHED(); |
62 } | 61 } |
63 settings_.margin_type = static_cast<MarginType>(margin_type); | 62 settings_.margin_type = static_cast<MarginType>(margin_type); |
64 | 63 |
65 if (margin_type == CUSTOM_MARGINS) { | 64 if (margin_type == CUSTOM_MARGINS) { |
66 printing::PageSizeMargins page_size_margins; | 65 double top_margin_in_points = 0; |
67 getCustomMarginsFromJobSettings(job_settings, &page_size_margins); | 66 double bottom_margin_in_points = 0; |
68 | 67 double left_margin_in_points = 0; |
| 68 double right_margin_in_points = 0; |
| 69 DictionaryValue* custom_margins; |
| 70 if (!job_settings.GetDictionary(kSettingMarginsCustom, &custom_margins) || |
| 71 !custom_margins->GetDouble(kSettingMarginTop, &top_margin_in_points) || |
| 72 !custom_margins->GetDouble(kSettingMarginBottom, |
| 73 &bottom_margin_in_points) || |
| 74 !custom_margins->GetDouble(kSettingMarginLeft, |
| 75 &left_margin_in_points) || |
| 76 !custom_margins->GetDouble(kSettingMarginRight, |
| 77 &right_margin_in_points)) { |
| 78 NOTREACHED(); |
| 79 } |
69 PageMargins margins_in_points; | 80 PageMargins margins_in_points; |
70 margins_in_points.Clear(); | 81 margins_in_points.Clear(); |
71 margins_in_points.top = page_size_margins.margin_top; | 82 margins_in_points.top = top_margin_in_points; |
72 margins_in_points.bottom = page_size_margins.margin_bottom; | 83 margins_in_points.bottom = bottom_margin_in_points; |
73 margins_in_points.left = page_size_margins.margin_left; | 84 margins_in_points.left = left_margin_in_points; |
74 margins_in_points.right = page_size_margins.margin_right; | 85 margins_in_points.right = right_margin_in_points; |
75 | 86 |
76 settings_.SetCustomMargins(margins_in_points); | 87 settings_.SetCustomMargins(margins_in_points); |
77 } | 88 } |
78 | 89 |
79 PrintingContext::Result result = UpdatePrinterSettings(job_settings, ranges); | 90 PrintingContext::Result result = UpdatePrinterSettings(job_settings, ranges); |
80 PrintSettingsInitializer::InitHeaderFooterStrings(job_settings, &settings_); | 91 PrintSettingsInitializer::InitHeaderFooterStrings(job_settings, &settings_); |
81 return result; | 92 return result; |
82 } | 93 } |
83 | 94 |
84 } // namespace printing | 95 } // namespace printing |
OLD | NEW |