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

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

Issue 118338: Add support for printing selection only flag. This only adds the flag to the ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/printing/print_settings.h ('k') | chrome/browser/printing/printer_query.h » ('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) 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/common/render_messages.h" 9 #include "chrome/common/render_messages.h"
10 #include "printing/units.h" 10 #include "printing/units.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),
20 desired_dpi(72), 20 desired_dpi(72),
21 selection_only(false),
21 dpi_(0), 22 dpi_(0),
22 landscape_(false) { 23 landscape_(false) {
23 } 24 }
24 25
25 void PrintSettings::Clear() { 26 void PrintSettings::Clear() {
26 ranges.clear(); 27 ranges.clear();
27 min_shrink = 1.25; 28 min_shrink = 1.25;
28 max_shrink = 2.; 29 max_shrink = 2.;
29 desired_dpi = 72; 30 desired_dpi = 72;
31 selection_only = false;
30 printer_name_.clear(); 32 printer_name_.clear();
31 device_name_.clear(); 33 device_name_.clear();
32 page_setup_pixels_.Clear(); 34 page_setup_pixels_.Clear();
33 dpi_ = 0; 35 dpi_ = 0;
34 landscape_ = false; 36 landscape_ = false;
35 } 37 }
36 38
37 #ifdef WIN32 39 #ifdef WIN32
38 void PrintSettings::Init(HDC hdc, 40 void PrintSettings::Init(HDC hdc,
39 const DEVMODE& dev_mode, 41 const DEVMODE& dev_mode,
40 const PageRanges& new_ranges, 42 const PageRanges& new_ranges,
41 const std::wstring& new_device_name) { 43 const std::wstring& new_device_name,
44 bool print_selection_only) {
42 DCHECK(hdc); 45 DCHECK(hdc);
43 printer_name_ = dev_mode.dmDeviceName; 46 printer_name_ = dev_mode.dmDeviceName;
44 device_name_ = new_device_name; 47 device_name_ = new_device_name;
45 ranges = new_ranges; 48 ranges = new_ranges;
46 landscape_ = dev_mode.dmOrientation == DMORIENT_LANDSCAPE; 49 landscape_ = dev_mode.dmOrientation == DMORIENT_LANDSCAPE;
50 selection_only = print_selection_only;
47 51
48 dpi_ = GetDeviceCaps(hdc, LOGPIXELSX); 52 dpi_ = GetDeviceCaps(hdc, LOGPIXELSX);
49 // No printer device is known to advertise different dpi in X and Y axis; even 53 // No printer device is known to advertise different dpi in X and Y axis; even
50 // the fax device using the 200x100 dpi setting. It's ought to break so many 54 // the fax device using the 200x100 dpi setting. It's ought to break so many
51 // applications that it's not even needed to care about. WebKit doesn't 55 // applications that it's not even needed to care about. WebKit doesn't
52 // support different dpi settings in X and Y axis. 56 // support different dpi settings in X and Y axis.
53 DCHECK_EQ(dpi_, GetDeviceCaps(hdc, LOGPIXELSY)); 57 DCHECK_EQ(dpi_, GetDeviceCaps(hdc, LOGPIXELSY));
54 58
55 DCHECK_EQ(GetDeviceCaps(hdc, SCALINGFACTORX), 0); 59 DCHECK_EQ(GetDeviceCaps(hdc, SCALINGFACTORX), 0);
56 DCHECK_EQ(GetDeviceCaps(hdc, SCALINGFACTORY), 0); 60 DCHECK_EQ(GetDeviceCaps(hdc, SCALINGFACTORY), 0);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 page_setup_pixels_.content_area().height()); 98 page_setup_pixels_.content_area().height());
95 params->dpi = dpi_; 99 params->dpi = dpi_;
96 // Currently hardcoded at 1.25. See PrintSettings' constructor. 100 // Currently hardcoded at 1.25. See PrintSettings' constructor.
97 params->min_shrink = min_shrink; 101 params->min_shrink = min_shrink;
98 // Currently hardcoded at 2.0. See PrintSettings' constructor. 102 // Currently hardcoded at 2.0. See PrintSettings' constructor.
99 params->max_shrink = max_shrink; 103 params->max_shrink = max_shrink;
100 // Currently hardcoded at 72dpi. See PrintSettings' constructor. 104 // Currently hardcoded at 72dpi. See PrintSettings' constructor.
101 params->desired_dpi = desired_dpi; 105 params->desired_dpi = desired_dpi;
102 // Always use an invalid cookie. 106 // Always use an invalid cookie.
103 params->document_cookie = 0; 107 params->document_cookie = 0;
108 params->selection_only = selection_only;
104 } 109 }
105 110
106 bool PrintSettings::Equals(const PrintSettings& rhs) const { 111 bool PrintSettings::Equals(const PrintSettings& rhs) const {
107 // Do not test the display device name (printer_name_) for equality since it 112 // Do not test the display device name (printer_name_) for equality since it
108 // may sometimes be chopped off at 30 chars. As long as device_name is the 113 // may sometimes be chopped off at 30 chars. As long as device_name is the
109 // same, that's fine. 114 // same, that's fine.
110 return ranges == rhs.ranges && 115 return ranges == rhs.ranges &&
111 min_shrink == rhs.min_shrink && 116 min_shrink == rhs.min_shrink &&
112 max_shrink == rhs.max_shrink && 117 max_shrink == rhs.max_shrink &&
113 desired_dpi == rhs.desired_dpi && 118 desired_dpi == rhs.desired_dpi &&
114 overlays.Equals(rhs.overlays) && 119 overlays.Equals(rhs.overlays) &&
115 device_name_ == rhs.device_name_ && 120 device_name_ == rhs.device_name_ &&
116 page_setup_pixels_.Equals(rhs.page_setup_pixels_) && 121 page_setup_pixels_.Equals(rhs.page_setup_pixels_) &&
117 dpi_ == rhs.dpi_ && 122 dpi_ == rhs.dpi_ &&
118 landscape_ == rhs.landscape_; 123 landscape_ == rhs.landscape_;
119 } 124 }
120 125
121 int PrintSettings::NewCookie() { 126 int PrintSettings::NewCookie() {
122 // A cookie of 0 is used to mark a document as unassigned, count from 1. 127 // A cookie of 0 is used to mark a document as unassigned, count from 1.
123 return cookie_seq.GetNext() + 1; 128 return cookie_seq.GetNext() + 1;
124 } 129 }
125 130
126 } // namespace printing 131 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_settings.h ('k') | chrome/browser/printing/printer_query.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698