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

Side by Side Diff: chrome/browser/printing/print_settings.cc

Issue 21475: Move units to new module printing. (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 months 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/browser/printing/print_settings.h" 5 #include "chrome/browser/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 "chrome/browser/printing/units.h" 9 #include "printing/units.h"
brettw 2009/02/20 17:22:05 Move down one.
10 #include "chrome/common/render_messages.h" 10 #include "chrome/common/render_messages.h"
11 11
12 namespace printing { 12 namespace printing {
13 13
14 // Global SequenceNumber used for generating unique cookie values. 14 // Global SequenceNumber used for generating unique cookie values.
15 static base::AtomicSequenceNumber cookie_seq(base::LINKER_INITIALIZED); 15 static base::AtomicSequenceNumber cookie_seq(base::LINKER_INITIALIZED);
16 16
17 PrintSettings::PrintSettings() 17 PrintSettings::PrintSettings()
18 : min_shrink(1.25), 18 : min_shrink(1.25),
19 max_shrink(2.0), 19 max_shrink(2.0),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 DCHECK_EQ(GetDeviceCaps(hdc, SCALINGFACTORY), 0); 58 DCHECK_EQ(GetDeviceCaps(hdc, SCALINGFACTORY), 0);
59 59
60 // Initialize page_setup_pixels_. 60 // Initialize page_setup_pixels_.
61 gfx::Size physical_size_pixels(GetDeviceCaps(hdc, PHYSICALWIDTH), 61 gfx::Size physical_size_pixels(GetDeviceCaps(hdc, PHYSICALWIDTH),
62 GetDeviceCaps(hdc, PHYSICALHEIGHT)); 62 GetDeviceCaps(hdc, PHYSICALHEIGHT));
63 gfx::Rect printable_area_pixels(GetDeviceCaps(hdc, PHYSICALOFFSETX), 63 gfx::Rect printable_area_pixels(GetDeviceCaps(hdc, PHYSICALOFFSETX),
64 GetDeviceCaps(hdc, PHYSICALOFFSETY), 64 GetDeviceCaps(hdc, PHYSICALOFFSETY),
65 GetDeviceCaps(hdc, HORZRES), 65 GetDeviceCaps(hdc, HORZRES),
66 GetDeviceCaps(hdc, VERTRES)); 66 GetDeviceCaps(hdc, VERTRES));
67 // Hard-code text_height = 0.5cm = ~1/5 of inch 67 // Hard-code text_height = 0.5cm = ~1/5 of inch
68 page_setup_pixels_.Init(physical_size_pixels, printable_area_pixels, 68 page_setup_pixels_.Init(physical_size_pixels,
69 printable_area_pixels,
69 ConvertUnit(500, kHundrethsMMPerInch, dpi_)); 70 ConvertUnit(500, kHundrethsMMPerInch, dpi_));
70 71
71 // Initialize page_setup_cmm_. 72 // Initialize page_setup_cmm_.
72 // In theory, we should be using HORZSIZE and VERTSIZE but their value is 73 // In theory, we should be using HORZSIZE and VERTSIZE but their value is
73 // so wrong it's useless. So read the values in dpi unit and convert them back 74 // so wrong it's useless. So read the values in dpi unit and convert them back
74 // in 0.01 mm. 75 // in 0.01 mm.
75 gfx::Size physical_size_cmm( 76 gfx::Size physical_size_cmm(
76 ConvertUnit(physical_size_pixels.width(), dpi_, kHundrethsMMPerInch), 77 ConvertUnit(physical_size_pixels.width(), dpi_, kHundrethsMMPerInch),
77 ConvertUnit(physical_size_pixels.height(), dpi_, kHundrethsMMPerInch)); 78 ConvertUnit(physical_size_pixels.height(), dpi_, kHundrethsMMPerInch));
78 gfx::Rect printable_area_cmm( 79 gfx::Rect printable_area_cmm(
(...skipping 18 matching lines...) Expand all
97 page_setup_cmm_.Init(physical_size_cmm, printable_area_cmm, 500); 98 page_setup_cmm_.Init(physical_size_cmm, printable_area_cmm, 500);
98 } 99 }
99 #endif 100 #endif
100 101
101 void PrintSettings::UpdateMarginsMetric(const PageMargins& new_margins) { 102 void PrintSettings::UpdateMarginsMetric(const PageMargins& new_margins) {
102 // Apply the new margins in 0.01 mm unit. 103 // Apply the new margins in 0.01 mm unit.
103 page_setup_cmm_.SetRequestedMargins(new_margins); 104 page_setup_cmm_.SetRequestedMargins(new_margins);
104 105
105 // Converts the margins in dpi unit and apply those too. 106 // Converts the margins in dpi unit and apply those too.
106 PageMargins pixels_margins; 107 PageMargins pixels_margins;
107 pixels_margins.header = ConvertUnit(new_margins.header, kHundrethsMMPerInch, 108 pixels_margins.header = ConvertUnit(new_margins.header,
109 kHundrethsMMPerInch,
108 dpi_); 110 dpi_);
109 pixels_margins.footer = ConvertUnit(new_margins.footer, kHundrethsMMPerInch, 111 pixels_margins.footer = ConvertUnit(new_margins.footer,
112 kHundrethsMMPerInch,
110 dpi_); 113 dpi_);
111 pixels_margins.left = ConvertUnit(new_margins.left, kHundrethsMMPerInch, 114 pixels_margins.left = ConvertUnit(new_margins.left,
115 kHundrethsMMPerInch,
112 dpi_); 116 dpi_);
113 pixels_margins.top = ConvertUnit(new_margins.top, kHundrethsMMPerInch, dpi_); 117 pixels_margins.top = ConvertUnit(new_margins.top, kHundrethsMMPerInch, dpi_);
114 pixels_margins.right = ConvertUnit(new_margins.right, kHundrethsMMPerInch, 118 pixels_margins.right = ConvertUnit(new_margins.right,
119 kHundrethsMMPerInch,
115 dpi_); 120 dpi_);
116 pixels_margins.bottom = ConvertUnit(new_margins.bottom, kHundrethsMMPerInch, 121 pixels_margins.bottom = ConvertUnit(new_margins.bottom,
122 kHundrethsMMPerInch,
117 dpi_); 123 dpi_);
118 page_setup_pixels_.SetRequestedMargins(pixels_margins); 124 page_setup_pixels_.SetRequestedMargins(pixels_margins);
119 } 125 }
120 126
121 void PrintSettings::UpdateMarginsMilliInch(const PageMargins& new_margins) { 127 void PrintSettings::UpdateMarginsMilliInch(const PageMargins& new_margins) {
122 // Convert margins from thousandth inches to cmm (0.01mm). 128 // Convert margins from thousandth inches to cmm (0.01mm).
123 PageMargins cmm_margins; 129 PageMargins cmm_margins;
124 cmm_margins.header = 130 cmm_margins.header =
125 ConvertMilliInchToHundredThousanthMeter(new_margins.header); 131 ConvertMilliInchToHundredThousanthMeter(new_margins.header);
126 cmm_margins.footer = 132 cmm_margins.footer =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 landscape_ == rhs.landscape_; 171 landscape_ == rhs.landscape_;
166 } 172 }
167 173
168 int PrintSettings::NewCookie() { 174 int PrintSettings::NewCookie() {
169 // A cookie of 0 is used to mark a document as unassigned, count from 1. 175 // A cookie of 0 is used to mark a document as unassigned, count from 1.
170 return cookie_seq.GetNext() + 1; 176 return cookie_seq.GetNext() + 1;
171 } 177 }
172 178
173 } // namespace printing 179 } // namespace printing
174 180
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698