diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-15 19:54:10 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-15 19:54:10 +0000 |
commit | 2896dccc7a66c857f53f297d9ae9790b242a0e92 (patch) | |
tree | c99db90b743a12416d329403c9b6752c624b780c /printing | |
parent | a01d93551393e886430385e641b2bd80ef3ba913 (diff) | |
download | chromium_src-2896dccc7a66c857f53f297d9ae9790b242a0e92.zip chromium_src-2896dccc7a66c857f53f297d9ae9790b242a0e92.tar.gz chromium_src-2896dccc7a66c857f53f297d9ae9790b242a0e92.tar.bz2 |
Printing: Move the default margin constants out of PdfPsMetafile.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6694005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78266 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing')
-rw-r--r-- | printing/pdf_ps_metafile_cairo.cc | 5 | ||||
-rw-r--r-- | printing/pdf_ps_metafile_cairo.h | 7 | ||||
-rw-r--r-- | printing/print_settings_initializer_gtk.cc | 23 | ||||
-rw-r--r-- | printing/print_settings_initializer_gtk.h | 7 | ||||
-rw-r--r-- | printing/printing_context_cairo.cc | 18 |
5 files changed, 24 insertions, 36 deletions
diff --git a/printing/pdf_ps_metafile_cairo.cc b/printing/pdf_ps_metafile_cairo.cc index 8ab9258..bf0b0e2 100644 --- a/printing/pdf_ps_metafile_cairo.cc +++ b/printing/pdf_ps_metafile_cairo.cc @@ -257,9 +257,4 @@ void PdfPsMetafile::CleanUpAll() { skia::VectorPlatformDevice::ClearFontCache(); } -const double PdfPsMetafile::kTopMarginInInch = 0.25; -const double PdfPsMetafile::kBottomMarginInInch = 0.56; -const double PdfPsMetafile::kLeftMarginInInch = 0.25; -const double PdfPsMetafile::kRightMarginInInch = 0.25; - } // namespace printing diff --git a/printing/pdf_ps_metafile_cairo.h b/printing/pdf_ps_metafile_cairo.h index 645a462..0b7514a 100644 --- a/printing/pdf_ps_metafile_cairo.h +++ b/printing/pdf_ps_metafile_cairo.h @@ -77,13 +77,6 @@ class PdfPsMetafile : public NativeMetafile { // This function should ONLY be called after PDF file is closed. virtual bool SaveTo(const base::FileDescriptor& fd) const; - // The hardcoded margins, in points. These values are based on 72 dpi, - // with 0.25 margins on top, left, and right, and 0.56 on bottom. - static const double kTopMarginInInch; - static const double kRightMarginInInch; - static const double kBottomMarginInInch; - static const double kLeftMarginInInch; - // Returns the PdfPsMetafile object that owns the given context. Returns NULL // if the context was not created by a PdfPsMetafile object. static PdfPsMetafile* FromCairoContext(cairo_t* context); diff --git a/printing/print_settings_initializer_gtk.cc b/printing/print_settings_initializer_gtk.cc index 8a62929..833db52 100644 --- a/printing/print_settings_initializer_gtk.cc +++ b/printing/print_settings_initializer_gtk.cc @@ -51,9 +51,7 @@ void PrintSettingsInitializerGtk::InitPrintSettings( gtk_page_setup_get_page_width(page_setup, GTK_UNIT_INCH) * dpi, gtk_page_setup_get_page_height(page_setup, GTK_UNIT_INCH) * dpi); } else { - // Use dummy values if we cannot get valid values. - // TODO(jhawkins) Remove this hack when the Linux printing refactoring - // finishes. + // Use default values if we cannot get valid values from the print dialog. dpi = kPixelsPerInch; double page_width_in_pixel = 8.5 * dpi; double page_height_in_pixel = 11.0 * dpi; @@ -61,16 +59,10 @@ void PrintSettingsInitializerGtk::InitPrintSettings( static_cast<int>(page_width_in_pixel), static_cast<int>(page_height_in_pixel)); printable_area_device_units.SetRect( - static_cast<int>( - PdfPsMetafile::kLeftMarginInInch * dpi), - static_cast<int>( - PdfPsMetafile::kTopMarginInInch * dpi), - page_width_in_pixel - - (PdfPsMetafile::kLeftMarginInInch + - PdfPsMetafile::kRightMarginInInch) * dpi, - page_height_in_pixel - - (PdfPsMetafile::kTopMarginInInch + - PdfPsMetafile::kBottomMarginInInch) * dpi); + static_cast<int>(kLeftMarginInInch * dpi), + static_cast<int>(kTopMarginInInch * dpi), + page_width_in_pixel - (kLeftMarginInInch + kRightMarginInInch) * dpi, + page_height_in_pixel - (kTopMarginInInch + kBottomMarginInInch) * dpi); } print_settings->set_dpi(dpi); @@ -79,4 +71,9 @@ void PrintSettingsInitializerGtk::InitPrintSettings( dpi); } +const double PrintSettingsInitializerGtk::kTopMarginInInch = 0.25; +const double PrintSettingsInitializerGtk::kBottomMarginInInch = 0.56; +const double PrintSettingsInitializerGtk::kLeftMarginInInch = 0.25; +const double PrintSettingsInitializerGtk::kRightMarginInInch = 0.25; + } // namespace printing diff --git a/printing/print_settings_initializer_gtk.h b/printing/print_settings_initializer_gtk.h index 6dd3930..7ac252b 100644 --- a/printing/print_settings_initializer_gtk.h +++ b/printing/print_settings_initializer_gtk.h @@ -24,6 +24,13 @@ class PrintSettingsInitializerGtk { bool print_selection_only, PrintSettings* print_settings); + // The default margins, in points. These values are based on 72 dpi, + // with 0.25 margins on top, left, and right, and 0.56 on bottom. + static const double kTopMarginInInch; + static const double kRightMarginInInch; + static const double kBottomMarginInInch; + static const double kLeftMarginInInch; + private: DISALLOW_IMPLICIT_CONSTRUCTORS(PrintSettingsInitializerGtk); }; diff --git a/printing/printing_context_cairo.cc b/printing/printing_context_cairo.cc index c8b0ef3..052ba73 100644 --- a/printing/printing_context_cairo.cc +++ b/printing/printing_context_cairo.cc @@ -6,17 +6,13 @@ #include "base/logging.h" #include "printing/units.h" +#include "printing/print_settings_initializer_gtk.h" #if defined(OS_CHROMEOS) #include <unicode/ulocdata.h> - -#include "printing/native_metafile.h" -#include "printing/pdf_ps_metafile_cairo.h" #else #include <gtk/gtk.h> #include <gtk/gtkprintunixdialog.h> - -#include "printing/print_settings_initializer_gtk.h" #endif // defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS) @@ -121,12 +117,12 @@ PrintingContext::Result PrintingContextCairo::UseDefaultSettings() { physical_size_device_units.SetSize(width, height); printable_area_device_units.SetRect( - static_cast<int>(PdfPsMetafile::kLeftMarginInInch * dpi), - static_cast<int>(PdfPsMetafile::kTopMarginInInch * dpi), - width - (PdfPsMetafile::kLeftMarginInInch + - PdfPsMetafile::kRightMarginInInch) * dpi, - height - (PdfPsMetafile::kTopMarginInInch + - PdfPsMetafile::kBottomMarginInInch) * dpi); + static_cast<int>(PrintSettingsInitializerGtk::kLeftMarginInInch * dpi), + static_cast<int>(PrintSettingsInitializerGtk::kTopMarginInInch * dpi), + width - (PrintSettingsInitializerGtk::kLeftMarginInInch + + PrintSettingsInitializerGtk::kRightMarginInInch) * dpi, + height - (PrintSettingsInitializerGtk::kTopMarginInInch + + PrintSettingsInitializerGtk::kBottomMarginInInch) * dpi); settings_.set_dpi(dpi); settings_.SetPrinterPrintableArea(physical_size_device_units, |