summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--printing/page_overlays.cc209
-rw-r--r--printing/page_overlays.h82
-rw-r--r--printing/page_overlays_unittest.cc92
-rw-r--r--printing/print_settings.cc1
-rw-r--r--printing/print_settings.h6
-rw-r--r--printing/printed_document.cc76
-rw-r--r--printing/printed_document.h28
-rw-r--r--printing/printed_document_cairo.cc6
-rw-r--r--printing/printed_document_mac.cc8
-rw-r--r--printing/printed_document_posix.cc21
-rw-r--r--printing/printed_document_win.cc106
-rw-r--r--printing/printing.gyp4
12 files changed, 2 insertions, 637 deletions
diff --git a/printing/page_overlays.cc b/printing/page_overlays.cc
deleted file mode 100644
index 857fa39..0000000
--- a/printing/page_overlays.cc
+++ /dev/null
@@ -1,209 +0,0 @@
-// 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.
-
-#include "printing/page_overlays.h"
-
-#include "base/logging.h"
-#include "base/string_number_conversions.h"
-#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
-#include "printing/printed_document.h"
-#include "printing/printed_page.h"
-
-namespace {
-
-// Replaces a subpart of a string by other value, and returns the position right
-// after the new value.
-size_t ReplaceKey(std::wstring* string,
- size_t offset,
- size_t old_string_len,
- const std::wstring& new_string) {
- string->replace(offset, old_string_len, new_string);
- return offset + new_string.size();
-}
-
-} // namespace
-
-namespace printing {
-
-const wchar_t* const PageOverlays::kTitle = L"{title}";
-const wchar_t* const PageOverlays::kTime = L"{time}";
-const wchar_t* const PageOverlays::kDate = L"{date}";
-const wchar_t* const PageOverlays::kPage = L"{page}";
-const wchar_t* const PageOverlays::kPageCount = L"{pagecount}";
-const wchar_t* const PageOverlays::kPageOnTotal = L"{pageontotal}";
-const wchar_t* const PageOverlays::kUrl = L"{url}";
-
-PageOverlays::PageOverlays()
- : top_left(kDate),
- top_center(kTitle),
- top_right(),
- bottom_left(kUrl),
- bottom_center(),
- bottom_right(kPageOnTotal) {
-}
-
-PageOverlays::~PageOverlays() {}
-
-bool PageOverlays::Equals(const PageOverlays& rhs) const {
- return top_left == rhs.top_left &&
- top_center == rhs.top_center &&
- top_right == rhs.top_right &&
- bottom_left == rhs.bottom_left &&
- bottom_center == rhs.bottom_center &&
- bottom_right == rhs.bottom_right;
-}
-
-const std::wstring& PageOverlays::GetOverlay(HorizontalPosition x,
- VerticalPosition y) const {
- switch (x) {
- case LEFT:
- switch (y) {
- case TOP:
- return top_left;
- case BOTTOM:
- return bottom_left;
- }
- break;
- case CENTER:
- switch (y) {
- case TOP:
- return top_center;
- case BOTTOM:
- return bottom_center;
- }
- break;
- case RIGHT:
- switch (y) {
- case TOP:
- return top_right;
- case BOTTOM:
- return bottom_right;
- }
- break;
- }
- NOTREACHED();
- return EmptyWString();
-}
-
-void PageOverlays::SetOverlay(HorizontalPosition x,
- VerticalPosition y,
- const std::wstring& input) {
- switch (x) {
- case LEFT:
- switch (y) {
- case TOP:
- top_left = input;
- break;
- case BOTTOM:
- bottom_left = input;
- break;
- default:
- NOTREACHED();
- break;
- }
- break;
- case CENTER:
- switch (y) {
- case TOP:
- top_center = input;
- break;
- case BOTTOM:
- bottom_center = input;
- break;
- default:
- NOTREACHED();
- break;
- }
- break;
- case RIGHT:
- switch (y) {
- case TOP:
- top_right = input;
- break;
- case BOTTOM:
- bottom_right = input;
- break;
- default:
- NOTREACHED();
- break;
- }
- break;
- default:
- NOTREACHED();
- break;
- }
-}
-
-// static
-std::wstring PageOverlays::ReplaceVariables(const std::wstring& input,
- const PrintedDocument& document,
- const PrintedPage& page) {
- std::wstring output(input);
- for (size_t offset = output.find(L'{', 0);
- offset != std::wstring::npos;
- offset = output.find(L'{', offset)) {
- if (0 == output.compare(offset,
- wcslen(kTitle),
- kTitle)) {
- offset = ReplaceKey(&output,
- offset,
- wcslen(kTitle),
- UTF16ToWideHack(document.name()));
- } else if (0 == output.compare(offset,
- wcslen(kTime),
- kTime)) {
- offset = ReplaceKey(&output,
- offset,
- wcslen(kTime),
- UTF16ToWideHack(document.time()));
- } else if (0 == output.compare(offset,
- wcslen(kDate),
- kDate)) {
- offset = ReplaceKey(&output,
- offset,
- wcslen(kDate),
- UTF16ToWideHack(document.date()));
- } else if (0 == output.compare(offset,
- wcslen(kPage),
- kPage)) {
- offset = ReplaceKey(&output,
- offset,
- wcslen(kPage),
- UTF8ToWide(base::IntToString(page.page_number())));
- } else if (0 == output.compare(offset,
- wcslen(kPageCount),
- kPageCount)) {
- offset = ReplaceKey(&output,
- offset,
- wcslen(kPageCount),
- UTF8ToWide(base::IntToString(document.page_count())));
- } else if (0 == output.compare(offset,
- wcslen(kPageOnTotal),
- kPageOnTotal)) {
- std::wstring replacement;
- replacement = UTF8ToWide(base::IntToString(page.page_number()));
- replacement += L"/";
- replacement += UTF8ToWide(base::IntToString(document.page_count()));
- offset = ReplaceKey(&output,
- offset,
- wcslen(kPageOnTotal),
- replacement);
- } else if (0 == output.compare(offset,
- wcslen(kUrl),
- kUrl)) {
- // TODO(maruel): http://b/1126373 ui::ElideUrl(document.url(), ...)
- offset = ReplaceKey(&output,
- offset,
- wcslen(kUrl),
- UTF8ToWide(document.url().spec()));
- } else {
- // There is just a { in the string.
- ++offset;
- }
- }
- return output;
-}
-
-} // namespace printing
diff --git a/printing/page_overlays.h b/printing/page_overlays.h
deleted file mode 100644
index c002fb3..0000000
--- a/printing/page_overlays.h
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright (c) 2006-2009 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.
-
-#ifndef PRINTING_PAGE_OVERLAYS_H_
-#define PRINTING_PAGE_OVERLAYS_H_
-
-#include <string>
-
-namespace printing {
-
-class PrintedDocument;
-class PrintedPage;
-
-// Page's overlays, i.e. headers and footers. Contains the strings that will be
-// printed in the overlays, with actual values as variables. The variables are
-// replaced by their actual values with ReplaceVariables().
-class PageOverlays {
- public:
- // Position of the header/footer.
- enum HorizontalPosition {
- LEFT,
- CENTER,
- RIGHT,
- };
-
- // Position of the header/footer.
- enum VerticalPosition {
- TOP,
- BOTTOM,
- };
-
- PageOverlays();
- ~PageOverlays();
-
- // Equality operator.
- bool Equals(const PageOverlays& rhs) const;
-
- // Returns the string of an overlay according to its x,y position.
- const std::wstring& GetOverlay(HorizontalPosition x,
- VerticalPosition y) const;
-
- // Sets the string of an overlay according to its x,y position.
- void SetOverlay(HorizontalPosition x,
- VerticalPosition y,
- const std::wstring& input);
-
- // Replaces the variables in |input| with their actual values according to the
- // properties of the current printed document and the current printed page.
- static std::wstring ReplaceVariables(const std::wstring& input,
- const PrintedDocument& document,
- const PrintedPage& page);
-
- // Keys that are dynamically replaced in the header and footer by their actual
- // values.
- // Web page's title.
- static const wchar_t* const kTitle;
- // Print job's start time.
- static const wchar_t* const kTime;
- // Print job's start date.
- static const wchar_t* const kDate;
- // Printed page's number.
- static const wchar_t* const kPage;
- // Print job's total page count.
- static const wchar_t* const kPageCount;
- // Printed page's number on total page count.
- static const wchar_t* const kPageOnTotal;
- // Web page's displayed url.
- static const wchar_t* const kUrl;
-
- // Actual headers and footers.
- std::wstring top_left;
- std::wstring top_center;
- std::wstring top_right;
- std::wstring bottom_left;
- std::wstring bottom_center;
- std::wstring bottom_right;
-};
-
-} // namespace printing
-
-#endif // PRINTING_PAGE_OVERLAYS_H_
diff --git a/printing/page_overlays_unittest.cc b/printing/page_overlays_unittest.cc
deleted file mode 100644
index 03c7f70..0000000
--- a/printing/page_overlays_unittest.cc
+++ /dev/null
@@ -1,92 +0,0 @@
-// Copyright (c) 2006-2009 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.
-
-#include "base/message_loop.h"
-#include "base/string16.h"
-#include "base/stringprintf.h"
-#include "base/utf_string_conversions.h"
-#include "printing/page_overlays.h"
-#include "printing/print_settings.h"
-#include "printing/printed_document.h"
-#include "printing/printed_page.h"
-#include "printing/printed_pages_source.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-struct Keys {
- const wchar_t* key;
- const wchar_t* expected;
-};
-
-const Keys kOverlayKeys[] = {
- { printing::PageOverlays::kTitle, L"Foobar Document" },
- { printing::PageOverlays::kTime, L"" },
- { printing::PageOverlays::kDate, L"" },
- { printing::PageOverlays::kPage, L"1" },
- { printing::PageOverlays::kPageCount, L"2" },
- { printing::PageOverlays::kPageOnTotal, L"1/2" },
- { printing::PageOverlays::kUrl, L"http://www.perdu.com/" },
-};
-
-class PagesSource : public printing::PrintedPagesSource {
- public:
- virtual string16 RenderSourceName() {
- return ASCIIToUTF16("Foobar Document");
- }
-
- virtual GURL RenderSourceUrl() {
- return GURL("http://www.perdu.com");
- }
-};
-
-} // namespace
-
-class PageOverlaysTest : public testing::Test {
- private:
- MessageLoop message_loop_;
-};
-
-TEST_F(PageOverlaysTest, StringConversion) {
- printing::PageOverlays overlays;
- overlays.GetOverlay(printing::PageOverlays::LEFT,
- printing::PageOverlays::BOTTOM);
- printing::PrintSettings settings;
- PagesSource source;
- int cookie = 1;
- scoped_refptr<printing::PrintedDocument> doc(
- new printing::PrintedDocument(settings, &source, cookie));
- doc->set_page_count(2);
- gfx::Size page_size(100, 100);
- gfx::Rect page_content_area(5, 5, 90, 90);
- scoped_refptr<printing::PrintedPage> page(
- new printing::PrintedPage(1, NULL, page_size, page_content_area, true));
-
- std::wstring input;
- std::wstring out;
- for (size_t i = 0; i < arraysize(kOverlayKeys); ++i) {
- input = base::StringPrintf(L"foo%lsbar", kOverlayKeys[i].key);
- out = printing::PageOverlays::ReplaceVariables(input, *doc.get(),
- *page.get());
- EXPECT_FALSE(out.empty());
- if (wcslen(kOverlayKeys[i].expected) == 0)
- continue;
- std::wstring expected =
- base::StringPrintf(L"foo%lsbar", kOverlayKeys[i].expected);
- EXPECT_EQ(expected, out) << kOverlayKeys[i].key;
- }
-
- // Check if SetOverlay really sets the page overlay.
- overlays.SetOverlay(printing::PageOverlays::LEFT,
- printing::PageOverlays::TOP,
- L"Page {page}");
- input = overlays.GetOverlay(printing::PageOverlays::LEFT,
- printing::PageOverlays::TOP);
- EXPECT_EQ(input, L"Page {page}");
-
- // Replace the variables to see if the page number is correct.
- out = printing::PageOverlays::ReplaceVariables(input, *doc.get(),
- *page.get());
- EXPECT_EQ(out, L"Page 1");
-}
diff --git a/printing/print_settings.cc b/printing/print_settings.cc
index 92f3560..b98ec40 100644
--- a/printing/print_settings.cc
+++ b/printing/print_settings.cc
@@ -82,7 +82,6 @@ bool PrintSettings::Equals(const PrintSettings& rhs) const {
min_shrink == rhs.min_shrink &&
max_shrink == rhs.max_shrink &&
desired_dpi == rhs.desired_dpi &&
- overlays.Equals(rhs.overlays) &&
device_name_ == rhs.device_name_ &&
page_setup_device_units_.Equals(rhs.page_setup_device_units_) &&
dpi_ == rhs.dpi_ &&
diff --git a/printing/print_settings.h b/printing/print_settings.h
index fbd37f4..ee78556 100644
--- a/printing/print_settings.h
+++ b/printing/print_settings.h
@@ -5,7 +5,8 @@
#ifndef PRINTING_PRINT_SETTINGS_H_
#define PRINTING_PRINT_SETTINGS_H_
-#include "printing/page_overlays.h"
+#include <string>
+
#include "printing/page_range.h"
#include "printing/page_setup.h"
#include "ui/gfx/rect.h"
@@ -78,9 +79,6 @@ class PrintSettings {
// scaled to ScreenDpi/dpix*desired_dpi.
int desired_dpi;
- // The various overlays (headers and footers).
- PageOverlays overlays;
-
// Indicates if the user only wants to print the current selection.
bool selection_only;
diff --git a/printing/printed_document.cc b/printing/printed_document.cc
index 1f1d2af..7f2834e 100644
--- a/printing/printed_document.cc
+++ b/printing/printed_document.cc
@@ -19,7 +19,6 @@
#include "base/utf_string_conversions.h"
#include "base/i18n/time_formatting.h"
#include "printing/page_number.h"
-#include "printing/page_overlays.h"
#include "printing/printed_pages_source.h"
#include "printing/printed_page.h"
#include "printing/units.h"
@@ -180,85 +179,11 @@ int PrintedDocument::expected_page_count() const {
return mutable_.expected_page_count_;
}
-void PrintedDocument::PrintHeaderFooter(gfx::NativeDrawingContext context,
- const PrintedPage& page,
- PageOverlays::HorizontalPosition x,
- PageOverlays::VerticalPosition y,
- const gfx::Font& font) const {
- const PrintSettings& settings = immutable_.settings_;
- if (!settings.use_overlays || !page.has_visible_overlays()) {
- return;
- }
- const std::wstring& line = settings.overlays.GetOverlay(x, y);
- if (line.empty()) {
- return;
- }
- std::wstring output(PageOverlays::ReplaceVariables(line, *this, page));
- if (output.empty()) {
- // May happen if document name or url is empty.
- return;
- }
- const gfx::Size string_size(font.GetStringWidth(WideToUTF16Hack(output)),
- font.GetHeight());
- gfx::Rect bounding;
- bounding.set_height(string_size.height());
- const gfx::Rect& overlay_area(
- settings.page_setup_device_units().overlay_area());
- // Hard code .25 cm interstice between overlays. Make sure that some space is
- // kept between each headers.
- const int interstice = ConvertUnit(250, kHundrethsMMPerInch,
- settings.device_units_per_inch());
- const int max_width = overlay_area.width() / 3 - interstice;
- const int actual_width = std::min(string_size.width(), max_width);
- switch (x) {
- case PageOverlays::LEFT:
- bounding.set_x(overlay_area.x());
- bounding.set_width(max_width);
- break;
- case PageOverlays::CENTER:
- bounding.set_x(overlay_area.x() +
- (overlay_area.width() - actual_width) / 2);
- bounding.set_width(actual_width);
- break;
- case PageOverlays::RIGHT:
- bounding.set_x(overlay_area.right() - actual_width);
- bounding.set_width(actual_width);
- break;
- }
-
- DCHECK_LE(bounding.right(), overlay_area.right());
-
- switch (y) {
- case PageOverlays::BOTTOM:
- bounding.set_y(overlay_area.bottom() - string_size.height());
- break;
- case PageOverlays::TOP:
- bounding.set_y(overlay_area.y());
- break;
- }
-
- if (string_size.width() > bounding.width()) {
- if (line == PageOverlays::kUrl) {
- output = UTF16ToWideHack(ui::ElideUrl(url(), font, bounding.width(),
- std::string()));
- } else {
- output = UTF16ToWideHack(ui::ElideText(WideToUTF16Hack(output),
- font, bounding.width(), false));
- }
- }
-
- DrawHeaderFooter(context, output, bounding);
-}
-
void PrintedDocument::DebugDump(const PrintedPage& page) {
if (!g_debug_dump_info.Get().enabled)
return;
string16 filename;
- filename += date();
- filename += ASCIIToUTF16("_");
- filename += time();
- filename += ASCIIToUTF16("_");
filename += name();
filename += ASCIIToUTF16("_");
filename += ASCIIToUTF16(StringPrintf("%02d", page.page_number()));
@@ -303,7 +228,6 @@ PrintedDocument::Immutable::Immutable(const PrintSettings& settings,
name_(source->RenderSourceName()),
url_(source->RenderSourceUrl()),
cookie_(cookie) {
- SetDocumentDate();
}
PrintedDocument::Immutable::~Immutable() {
diff --git a/printing/printed_document.h b/printing/printed_document.h
index a53b90f..eb08ae3 100644
--- a/printing/printed_document.h
+++ b/printing/printed_document.h
@@ -98,8 +98,6 @@ class PrintedDocument : public base::RefCountedThreadSafe<PrintedDocument> {
return immutable_.name_;
}
const GURL& url() const { return immutable_.url_; }
- const string16& date() const { return immutable_.date_; }
- const string16& time() const { return immutable_.time_; }
int cookie() const { return immutable_.cookie_; }
// Sets a path where to dump printing output files for debugging. If never set
@@ -154,9 +152,6 @@ class PrintedDocument : public base::RefCountedThreadSafe<PrintedDocument> {
int cookie);
~Immutable();
- // Sets the document's |date_| and |time_|.
- void SetDocumentDate();
-
// Print settings used to generate this document. Immutable.
PrintSettings settings_;
@@ -169,12 +164,6 @@ class PrintedDocument : public base::RefCountedThreadSafe<PrintedDocument> {
// URL that generated this document. Immutable.
GURL url_;
- // The date on which this job started. Immutable.
- string16 date_;
-
- // The time at which this job started. Immutable.
- string16 time_;
-
// Cookie to uniquely identify this document. It is used to make sure that a
// PrintedPage is correctly belonging to the PrintedDocument. Since
// PrintedPage generation is completely asynchronous, it could be easy to
@@ -184,23 +173,6 @@ class PrintedDocument : public base::RefCountedThreadSafe<PrintedDocument> {
int cookie_;
};
- // Prints the headers and footers for one page in the specified context
- // according to the current settings.
- void PrintHeaderFooter(gfx::NativeDrawingContext context,
- const PrintedPage& page,
- PageOverlays::HorizontalPosition x,
- PageOverlays::VerticalPosition y,
- const gfx::Font& font) const;
-
- // Draws the computed |text| into |context| taking into account the bounding
- // region |bounds|. |bounds| is the position in which to draw |text| and
- // the minimum area needed to contain |text| which may not be larger than the
- // header or footer itself.
- // TODO(jhawkins): string16.
- void DrawHeaderFooter(gfx::NativeDrawingContext context,
- std::wstring text,
- gfx::Rect bounds) const;
-
void DebugDump(const PrintedPage& page);
// All writable data member access must be guarded by this lock. Needs to be
diff --git a/printing/printed_document_cairo.cc b/printing/printed_document_cairo.cc
index 7675b96..15193c7 100644
--- a/printing/printed_document_cairo.cc
+++ b/printing/printed_document_cairo.cc
@@ -34,10 +34,4 @@ void PrintedDocument::RenderPrintedPage(
#endif // !defined(OS_CHROMEOS)
}
-void PrintedDocument::DrawHeaderFooter(gfx::NativeDrawingContext context,
- std::wstring text,
- gfx::Rect bounds) const {
- NOTIMPLEMENTED();
-}
-
} // namespace printing
diff --git a/printing/printed_document_mac.cc b/printing/printed_document_mac.cc
index bb067c88..6915eac 100644
--- a/printing/printed_document_mac.cc
+++ b/printing/printed_document_mac.cc
@@ -35,14 +35,6 @@ void PrintedDocument::RenderPrintedPage(
const int page_number = 1;
metafile->RenderPage(page_number, context, content_area.ToCGRect(),
false, false, false, false);
-
- // TODO(stuartmorgan): Print the header and footer.
-}
-
-void PrintedDocument::DrawHeaderFooter(gfx::NativeDrawingContext context,
- std::wstring text,
- gfx::Rect bounds) const {
- NOTIMPLEMENTED();
}
} // namespace printing
diff --git a/printing/printed_document_posix.cc b/printing/printed_document_posix.cc
deleted file mode 100644
index 33c0264..0000000
--- a/printing/printed_document_posix.cc
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) 2009 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.
-
-#include "printing/printed_document.h"
-
-#include "base/i18n/time_formatting.h"
-#include "base/time.h"
-#include "base/utf_string_conversions.h"
-
-using base::Time;
-
-namespace printing {
-
-void PrintedDocument::Immutable::SetDocumentDate() {
- Time now = Time::Now();
- date_ = base::TimeFormatShortDateNumeric(now);
- time_ = base::TimeFormatTimeOfDay(now);
-}
-
-} // namespace printing
diff --git a/printing/printed_document_win.cc b/printing/printed_document_win.cc
index ef0c686..0a1e8b8 100644
--- a/printing/printed_document_win.cc
+++ b/printing/printed_document_win.cc
@@ -5,15 +5,11 @@
#include "printing/printed_document.h"
#include "base/logging.h"
-#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
#include "printing/page_number.h"
-#include "printing/page_overlays.h"
#include "printing/printed_pages_source.h"
#include "printing/printed_page.h"
#include "printing/units.h"
#include "skia/ext/platform_device.h"
-#include "ui/gfx/font.h"
namespace {
@@ -33,46 +29,6 @@ void DrawRect(HDC context, gfx::Rect rect) {
Rectangle(context, rect.x(), rect.y(), rect.right(), rect.bottom());
}
-// Creates a string interpretation of the time of day represented by the given
-// SYSTEMTIME that's appropriate for the user's default locale.
-// Format can be an empty string (for the default format), or a "format picture"
-// as specified in the Windows documentation for GetTimeFormat().
-string16 FormatSystemTime(const SYSTEMTIME& time, const string16& format) {
- // If the format string is empty, just use the default format.
- LPCTSTR format_ptr = NULL;
- if (!format.empty())
- format_ptr = format.c_str();
-
- int buffer_size = GetTimeFormat(LOCALE_USER_DEFAULT, NULL, &time, format_ptr,
- NULL, 0);
-
- string16 output;
- GetTimeFormat(LOCALE_USER_DEFAULT, NULL, &time, format_ptr,
- WriteInto(&output, buffer_size), buffer_size);
-
- return output;
-}
-
-// Creates a string interpretation of the date represented by the given
-// SYSTEMTIME that's appropriate for the user's default locale.
-// Format can be an empty string (for the default format), or a "format picture"
-// as specified in the Windows documentation for GetDateFormat().
-string16 FormatSystemDate(const SYSTEMTIME& date, const string16& format) {
- // If the format string is empty, just use the default format.
- LPCTSTR format_ptr = NULL;
- if (!format.empty())
- format_ptr = format.c_str();
-
- int buffer_size = GetDateFormat(LOCALE_USER_DEFAULT, NULL, &date, format_ptr,
- NULL, 0);
-
- string16 output;
- GetDateFormat(LOCALE_USER_DEFAULT, NULL, &date, format_ptr,
- WriteInto(&output, buffer_size), buffer_size);
-
- return output;
-}
-
} // namespace
namespace printing {
@@ -122,68 +78,6 @@ void PrintedDocument::RenderPrintedPage(
DCHECK_NE(res, 0);
}
- // Print the header and footer. Offset by printable area offset (see comment
- // above).
- SimpleModifyWorldTransform(
- context,
- -page_setup.printable_area().x(),
- -page_setup.printable_area().y(),
- 1);
- int base_font_size = gfx::Font().GetHeight();
- int new_font_size = ConvertUnit(10,
- immutable_.settings_.desired_dpi,
- immutable_.settings_.device_units_per_inch());
- DCHECK_GT(new_font_size, base_font_size);
- gfx::Font font(gfx::Font().DeriveFont(new_font_size - base_font_size));
- HGDIOBJ old_font = SelectObject(context, font.GetNativeFont());
- DCHECK(old_font != NULL);
- // We don't want a white square around the text ever if overflowing.
- SetBkMode(context, TRANSPARENT);
- // Disabling printing the header/footer on Windows for now to make the
- // behavior consistent with Mac/Linux.
- // TODO(thestig) re-enable this for print preview.
-#if 0
- PrintHeaderFooter(context, page, PageOverlays::LEFT, PageOverlays::TOP,
- font);
- PrintHeaderFooter(context, page, PageOverlays::CENTER, PageOverlays::TOP,
- font);
- PrintHeaderFooter(context, page, PageOverlays::RIGHT, PageOverlays::TOP,
- font);
- PrintHeaderFooter(context, page, PageOverlays::LEFT, PageOverlays::BOTTOM,
- font);
- PrintHeaderFooter(context, page, PageOverlays::CENTER, PageOverlays::BOTTOM,
- font);
- PrintHeaderFooter(context, page, PageOverlays::RIGHT, PageOverlays::BOTTOM,
- font);
-#endif
- int res = RestoreDC(context, saved_state);
- DCHECK_NE(res, 0);
-}
-
-void PrintedDocument::Immutable::SetDocumentDate() {
- // Use the native time formatting for printing on Windows.
- SYSTEMTIME systemtime;
- GetLocalTime(&systemtime);
- date_ =
- WideToUTF16Hack(FormatSystemDate(systemtime, std::wstring()));
- time_ =
- WideToUTF16Hack(FormatSystemTime(systemtime, std::wstring()));
-}
-
-void PrintedDocument::DrawHeaderFooter(gfx::NativeDrawingContext context,
- std::wstring text,
- gfx::Rect bounds) const {
- // Save the state for the clipping region.
- int saved_state = SaveDC(context);
- DCHECK_NE(saved_state, 0);
-
- int result = IntersectClipRect(context, bounds.x(), bounds.y(),
- bounds.right() + 1, bounds.bottom() + 1);
- DCHECK(result == SIMPLEREGION || result == COMPLEXREGION);
- TextOut(context,
- bounds.x(), bounds.y(),
- text.c_str(),
- static_cast<int>(text.size()));
int res = RestoreDC(context, saved_state);
DCHECK_NE(res, 0);
}
diff --git a/printing/printing.gyp b/printing/printing.gyp
index f9f18e7..027999f 100644
--- a/printing/printing.gyp
+++ b/printing/printing.gyp
@@ -42,8 +42,6 @@
'metafile_skia_wrapper.cc',
'page_number.cc',
'page_number.h',
- 'page_overlays.cc',
- 'page_overlays.h',
'page_range.cc',
'page_range.h',
'page_setup.cc',
@@ -58,7 +56,6 @@
'printed_document.cc',
'printed_document.h',
'printed_document_mac.cc',
- 'printed_document_posix.cc',
'printed_document_win.cc',
'printed_page.cc',
'printed_page.h',
@@ -171,7 +168,6 @@
'emf_win_unittest.cc',
'printing_test.h',
'page_number_unittest.cc',
- 'page_overlays_unittest.cc',
'page_range_unittest.cc',
'page_setup_unittest.cc',
'pdf_metafile_cairo_linux_unittest.cc',