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

Side by Side Diff: printing/printing_context.cc

Issue 8528053: Print Preview: Making margin selection sticky (part 2/2, again) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing Created 9 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/printing.gyp ('k') | no next file » | 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) 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"
10 #include "printing/print_settings_initializer.h" 11 #include "printing/print_settings_initializer.h"
11 12
12 namespace printing { 13 namespace printing {
13 14
14 PrintingContext::PrintingContext(const std::string& app_locale) 15 PrintingContext::PrintingContext(const std::string& app_locale)
15 : dialog_box_dismissed_(false), 16 : dialog_box_dismissed_(false),
16 in_print_job_(false), 17 in_print_job_(false),
17 abort_printing_(false), 18 abort_printing_(false),
18 app_locale_(app_locale) { 19 app_locale_(app_locale) {
19 } 20 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 if (!job_settings.GetInteger(kSettingMarginsType, &margin_type) || 56 if (!job_settings.GetInteger(kSettingMarginsType, &margin_type) ||
56 (margin_type != DEFAULT_MARGINS && 57 (margin_type != DEFAULT_MARGINS &&
57 margin_type != NO_MARGINS && 58 margin_type != NO_MARGINS &&
58 margin_type != CUSTOM_MARGINS && 59 margin_type != CUSTOM_MARGINS &&
59 margin_type != PRINTABLE_AREA_MARGINS)) { 60 margin_type != PRINTABLE_AREA_MARGINS)) {
60 NOTREACHED(); 61 NOTREACHED();
61 } 62 }
62 settings_.margin_type = static_cast<MarginType>(margin_type); 63 settings_.margin_type = static_cast<MarginType>(margin_type);
63 64
64 if (margin_type == CUSTOM_MARGINS) { 65 if (margin_type == CUSTOM_MARGINS) {
65 double top_margin_in_points = 0; 66 printing::PageSizeMargins page_size_margins;
66 double bottom_margin_in_points = 0; 67 GetCustomMarginsFromJobSettings(job_settings, &page_size_margins);
67 double left_margin_in_points = 0; 68
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 }
80 PageMargins margins_in_points; 69 PageMargins margins_in_points;
81 margins_in_points.Clear(); 70 margins_in_points.Clear();
82 margins_in_points.top = top_margin_in_points; 71 margins_in_points.top = page_size_margins.margin_top;
83 margins_in_points.bottom = bottom_margin_in_points; 72 margins_in_points.bottom = page_size_margins.margin_bottom;
84 margins_in_points.left = left_margin_in_points; 73 margins_in_points.left = page_size_margins.margin_left;
85 margins_in_points.right = right_margin_in_points; 74 margins_in_points.right = page_size_margins.margin_right;
86 75
87 settings_.SetCustomMargins(margins_in_points); 76 settings_.SetCustomMargins(margins_in_points);
88 } 77 }
89 78
90 PrintingContext::Result result = UpdatePrinterSettings(job_settings, ranges); 79 PrintingContext::Result result = UpdatePrinterSettings(job_settings, ranges);
91 PrintSettingsInitializer::InitHeaderFooterStrings(job_settings, &settings_); 80 PrintSettingsInitializer::InitHeaderFooterStrings(job_settings, &settings_);
92 return result; 81 return result;
93 } 82 }
94 83
95 } // namespace printing 84 } // namespace printing
OLDNEW
« no previous file with comments | « printing/printing.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698