summaryrefslogtreecommitdiffstats
path: root/printing
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-05 20:49:22 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-05 20:49:22 +0000
commit6d156893bcf18435440d1ab9668fa66d90cd5dee (patch)
tree93bdba24b976ce6d420803fc310a2d86e8dd120d /printing
parentd4a66c99465e0e42a75741220171057761ce073e (diff)
downloadchromium_src-6d156893bcf18435440d1ab9668fa66d90cd5dee.zip
chromium_src-6d156893bcf18435440d1ab9668fa66d90cd5dee.tar.gz
chromium_src-6d156893bcf18435440d1ab9668fa66d90cd5dee.tar.bz2
Printing: Temporary fix on Linux using dummy print settings until we get the entire Linux printing pipeline to match Win/Mac.
BUG=none TEST=printing works. Review URL: http://codereview.chromium.org/3619002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61556 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing')
-rw-r--r--printing/print_settings.cc49
-rw-r--r--printing/print_settings.h9
2 files changed, 41 insertions, 17 deletions
diff --git a/printing/print_settings.cc b/printing/print_settings.cc
index 0950d63..6ab53f6 100644
--- a/printing/print_settings.cc
+++ b/printing/print_settings.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,6 +7,8 @@
// TODO(jhawkins): Move platform-specific implementations to their own files.
#if defined(USE_X11)
#include <gtk/gtk.h>
+#include <gtk/gtkprinter.h>
+#include "printing/native_metafile.h"
#endif // defined(USE_X11)
#include "base/atomic_sequence_num.h"
@@ -129,7 +131,7 @@ void PrintSettings::Init(PMPrinter printer, PMPageFormat page_format,
printable_area_device_units,
72);
}
-#elif defined(OS_LINUX)
+#elif defined(USE_X11)
void PrintSettings::Init(GtkPrintSettings* settings,
GtkPageSetup* page_setup,
const PageRanges& new_ranges,
@@ -140,23 +142,42 @@ void PrintSettings::Init(GtkPrintSettings* settings,
printer_name_ = UTF8ToWide(name);
device_name_ = printer_name_;
ranges = new_ranges;
+ selection_only = print_selection_only;
GtkPageOrientation orientation = gtk_print_settings_get_orientation(settings);
landscape_ = orientation == GTK_PAGE_ORIENTATION_LANDSCAPE;
- selection_only = print_selection_only;
+ gfx::Size physical_size_device_units;
+ gfx::Rect printable_area_device_units;
dpi_ = gtk_print_settings_get_resolution(settings);
-
- // Initialize page_setup_device_units_.
- gfx::Size physical_size_device_units(
- gtk_page_setup_get_paper_width(page_setup, GTK_UNIT_INCH) * dpi_,
- gtk_page_setup_get_paper_height(page_setup, GTK_UNIT_INCH) * dpi_);
- gfx::Rect printable_area_device_units(
- gtk_page_setup_get_left_margin(page_setup, GTK_UNIT_INCH) * dpi_,
- gtk_page_setup_get_top_margin(page_setup, GTK_UNIT_INCH) * dpi_,
- gtk_page_setup_get_page_width(page_setup, GTK_UNIT_INCH) * dpi_,
- gtk_page_setup_get_page_height(page_setup, GTK_UNIT_INCH) * dpi_);
-
+ if (dpi_) {
+ // Initialize page_setup_device_units_.
+ physical_size_device_units.SetSize(
+ gtk_page_setup_get_paper_width(page_setup, GTK_UNIT_INCH) * dpi_,
+ gtk_page_setup_get_paper_height(page_setup, GTK_UNIT_INCH) * dpi_);
+ printable_area_device_units.SetRect(
+ gtk_page_setup_get_left_margin(page_setup, GTK_UNIT_INCH) * dpi_,
+ gtk_page_setup_get_top_margin(page_setup, GTK_UNIT_INCH) * dpi_,
+ 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.
+ dpi_ = kPixelsPerInch;
+ double page_width_in_pixel = 8.5 * dpi_;
+ double page_height_in_pixel = 11.0 * dpi_;
+ physical_size_device_units.SetSize(
+ static_cast<int>(page_width_in_pixel),
+ static_cast<int>(page_height_in_pixel));
+ printable_area_device_units.SetRect(
+ static_cast<int>(
+ NativeMetafile::kLeftMarginInInch * printing::kPixelsPerInch),
+ static_cast<int>(
+ NativeMetafile::kTopMarginInInch * printing::kPixelsPerInch),
+ page_width_in_pixel,
+ page_height_in_pixel);
+ }
SetPrinterPrintableArea(physical_size_device_units,
printable_area_device_units,
dpi_);
diff --git a/printing/print_settings.h b/printing/print_settings.h
index 8cde1ca..a7fe73c 100644
--- a/printing/print_settings.h
+++ b/printing/print_settings.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -14,10 +14,13 @@
#import <ApplicationServices/ApplicationServices.h>
#endif
+#if defined(OS_WIN)
typedef struct HDC__* HDC;
typedef struct _devicemodeW DEVMODE;
+#elif defined(USE_X11)
typedef struct _GtkPrintSettings GtkPrintSettings;
typedef struct _GtkPageSetup GtkPageSetup;
+#endif
namespace printing {
@@ -30,7 +33,7 @@ class PrintSettings {
// Reinitialize the settings to the default values.
void Clear();
-#ifdef WIN32
+#if defined(OS_WIN)
// Reads the settings from the selected device context. Calculates derived
// values like printable_area_.
void Init(HDC hdc,
@@ -42,7 +45,7 @@ class PrintSettings {
// Reads the settings from the given PMPrinter and PMPageFormat.
void Init(PMPrinter printer, PMPageFormat page_format,
const PageRanges& new_ranges, bool print_selection_only);
-#elif defined(OS_LINUX)
+#elif defined(USE_X11)
// Initializes the settings from the given GtkPrintSettings and GtkPageSetup.
// TODO(jhawkins): This method is a mess across the platforms. Refactor.
void Init(GtkPrintSettings* settings,