Index: printing/printed_document.cc |
=================================================================== |
--- printing/printed_document.cc (revision 95638) |
+++ printing/printed_document.cc (working copy) |
@@ -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 @@ |
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 @@ |
name_(source->RenderSourceName()), |
url_(source->RenderSourceUrl()), |
cookie_(cookie) { |
- SetDocumentDate(); |
} |
PrintedDocument::Immutable::~Immutable() { |