summaryrefslogtreecommitdiffstats
path: root/printing/print_settings.h
diff options
context:
space:
mode:
authorvitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-29 03:16:37 +0000
committervitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-29 03:16:37 +0000
commite5324b55e4204451d02d9323a6ea013955b82bc0 (patch)
tree369de1fdbf16aee58036f9a0a95c27bb9a0aa1e8 /printing/print_settings.h
parentb7898896f26bc424e1e11d7533f866c2872a8c4f (diff)
downloadchromium_src-e5324b55e4204451d02d9323a6ea013955b82bc0.zip
chromium_src-e5324b55e4204451d02d9323a6ea013955b82bc0.tar.gz
chromium_src-e5324b55e4204451d02d9323a6ea013955b82bc0.tar.bz2
De-duplicate job_settings parsing code.
Proper set/get methods in PrintSettings. Objective of this re-factoring is to simplify processing of "print_to_pdf || is_cloud_dialog || print_to_cloud" case. Now all platforms for this case do almost the same by in different way: calculate and set printing area. In the next CL I'll move that code into common PrintingContext::UpdatePrintSettings and will ask platform specific implementation for desired page size only. BUG=305731 Review URL: https://codereview.chromium.org/47823002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231501 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/print_settings.h')
-rw-r--r--printing/print_settings.h122
1 files changed, 88 insertions, 34 deletions
diff --git a/printing/print_settings.h b/printing/print_settings.h
index 7cff3bd..b80d354 100644
--- a/printing/print_settings.h
+++ b/printing/print_settings.h
@@ -35,32 +35,38 @@ class PRINTING_EXPORT PrintSettings {
// Reinitialize the settings to the default values.
void Clear();
- // Set printer printable area in in device units.
- void SetPrinterPrintableArea(gfx::Size const& physical_size_device_units,
- gfx::Rect const& printable_area_device_units,
- int units_per_inch);
-
void SetCustomMargins(const PageMargins& requested_margins_in_points);
+ void set_margin_type(MarginType margin_type) { margin_type_ = margin_type; }
+ MarginType margin_type() const { return margin_type_; }
- // Equality operator.
- // NOTE: printer_name is NOT tested for equality since it doesn't affect the
- // output.
- bool Equals(const PrintSettings& rhs) const;
+ // Updates the orientation and flip the page if needed.
+ void SetOrientation(bool landscape);
+ bool landscape() const { return landscape_; }
+
+ // Set printer printable area in in device units.
+ // Some platforms already provide flipped area. Set |landscape_needs_flip|
+ // to false on those platforms to avoid double flipping.
+ void SetPrinterPrintableArea(const gfx::Size& physical_size_device_units,
+ const gfx::Rect& printable_area_device_units,
+ int units_per_inch,
+ bool landscape_needs_flip);
+ const PageSetup& page_setup_device_units() const {
+ return page_setup_device_units_;
+ }
- void set_landscape(bool landscape) { landscape_ = landscape; }
void set_device_name(const base::string16& device_name) {
device_name_ = device_name;
}
const base::string16& device_name() const { return device_name_; }
+
void set_dpi(int dpi) { dpi_ = dpi; }
int dpi() const { return dpi_; }
+
void set_supports_alpha_blend(bool supports_alpha_blend) {
supports_alpha_blend_ = supports_alpha_blend;
}
bool supports_alpha_blend() const { return supports_alpha_blend_; }
- const PageSetup& page_setup_device_units() const {
- return page_setup_device_units_;
- }
+
int device_units_per_inch() const {
#if defined(OS_MACOSX)
return 72;
@@ -69,54 +75,102 @@ class PRINTING_EXPORT PrintSettings {
#endif // defined(OS_MACOSX)
}
+ void set_ranges(const PageRanges& ranges) { ranges_ = ranges; };
+ const PageRanges& ranges() const { return ranges_; };
+
+ void set_selection_only(bool selection_only) {
+ selection_only_ = selection_only;
+ }
+ bool selection_only() const { return selection_only_; }
+
+ void set_should_print_backgrounds(bool should_print_backgrounds) {
+ should_print_backgrounds_ = should_print_backgrounds;
+ }
+ bool should_print_backgrounds() const { return should_print_backgrounds_; }
+
+ void set_display_header_footer(bool display_header_footer) {
+ display_header_footer_ = display_header_footer;
+ }
+ bool display_header_footer() const { return display_header_footer_; }
+
+ void set_title(const base::string16& title) { title_ = title; }
+ const base::string16& title() const { return title_; }
+
+ void set_url(const base::string16& url) { url_ = url; }
+ const base::string16& url() const { return url_; }
+
+ void set_collate(bool collate) { collate_ = collate; }
+ bool collate() const { return collate_; }
+
+ void set_color(ColorModel color) { color_ = color; }
+ ColorModel color() const { return color_; }
+
+ void set_copies(int copies) { copies_ = copies; }
+ int copies() const { return copies_; }
+
+ void set_duplex_mode(DuplexMode duplex_mode) { duplex_mode_ = duplex_mode; }
+ DuplexMode duplex_mode() const { return duplex_mode_; }
+
+ int desired_dpi() const { return desired_dpi_; }
+
+ double max_shrink() const { return max_shrink_; }
+
+ double min_shrink() const { return min_shrink_; }
+
+ // Cookie generator. It is used to initialize PrintedDocument with its
+ // associated PrintSettings, to be sure that each generated PrintedPage is
+ // correctly associated with its corresponding PrintedDocument.
+ static int NewCookie();
+
+ private:
// Multi-page printing. Each PageRange describes a from-to page combination.
// This permits printing selected pages only.
- PageRanges ranges;
+ PageRanges ranges_;
// By imaging to a width a little wider than the available pixels, thin pages
// will be scaled down a little, matching the way they print in IE and Camino.
// This lets them use fewer sheets than they would otherwise, which is
// presumably why other browsers do this. Wide pages will be scaled down more
// than this.
- double min_shrink;
+ double min_shrink_;
// This number determines how small we are willing to reduce the page content
// in order to accommodate the widest line. If the page would have to be
// reduced smaller to make the widest line fit, we just clip instead (this
// behavior matches MacIE and Mozilla, at least)
- double max_shrink;
+ double max_shrink_;
// Desired visible dots per inch rendering for output. Printing should be
// scaled to ScreenDpi/dpix*desired_dpi.
- int desired_dpi;
+ int desired_dpi_;
// Indicates if the user only wants to print the current selection.
- bool selection_only;
+ bool selection_only_;
// Indicates what kind of margins should be applied to the printable area.
- MarginType margin_type;
-
- // Cookie generator. It is used to initialize PrintedDocument with its
- // associated PrintSettings, to be sure that each generated PrintedPage is
- // correctly associated with its corresponding PrintedDocument.
- static int NewCookie();
-
- // Updates the orientation and flip the page if needed.
- void SetOrientation(bool landscape);
+ MarginType margin_type_;
// Strings to be printed as headers and footers if requested by the user.
- base::string16 title;
- base::string16 url;
+ base::string16 title_;
+ base::string16 url_;
// True if the user wants headers and footers to be displayed.
- bool display_header_footer;
+ bool display_header_footer_;
// True if the user wants to print CSS backgrounds.
- bool should_print_backgrounds;
+ bool should_print_backgrounds_;
- private:
- //////////////////////////////////////////////////////////////////////////////
- // Settings that can't be changed without side-effects.
+ // True if the user wants to print with collate.
+ bool collate_;
+
+ // True if the user wants to print with collate.
+ ColorModel color_;
+
+ // Number of copies user wants to print.
+ int copies_;
+
+ // Duplex type user wants to use.
+ DuplexMode duplex_mode_;
// Printer device name as opened by the OS.
base::string16 device_name_;