| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "printing/printed_document.h" | 5 #include "printing/printed_document.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| 68 PrintedDocument::~PrintedDocument() { | 68 PrintedDocument::~PrintedDocument() { |
| 69 } | 69 } |
| 70 | 70 |
| 71 void PrintedDocument::SetPage(int page_number, | 71 void PrintedDocument::SetPage(int page_number, |
| 72 NativeMetafile* metafile, | 72 NativeMetafile* metafile, |
| 73 double shrink, | 73 double shrink, |
| 74 const gfx::Size& paper_size, | 74 const gfx::Size& paper_size, |
| 75 const gfx::Rect& page_rect) { | 75 const gfx::Rect& page_rect, |
| 76 bool has_visible_overlays) { |
| 76 // Notice the page_number + 1, the reason is that this is the value that will | 77 // Notice the page_number + 1, the reason is that this is the value that will |
| 77 // be shown. Users dislike 0-based counting. | 78 // be shown. Users dislike 0-based counting. |
| 78 scoped_refptr<PrintedPage> page( | 79 scoped_refptr<PrintedPage> page( |
| 79 new PrintedPage(page_number + 1, | 80 new PrintedPage(page_number + 1, |
| 80 metafile, | 81 metafile, |
| 81 paper_size, | 82 paper_size, |
| 82 page_rect)); | 83 page_rect, |
| 84 has_visible_overlays)); |
| 83 { | 85 { |
| 84 AutoLock lock(lock_); | 86 AutoLock lock(lock_); |
| 85 mutable_.pages_[page_number] = page; | 87 mutable_.pages_[page_number] = page; |
| 86 if (mutable_.shrink_factor == 0) { | 88 if (mutable_.shrink_factor == 0) { |
| 87 mutable_.shrink_factor = shrink; | 89 mutable_.shrink_factor = shrink; |
| 88 } else { | 90 } else { |
| 89 DCHECK_EQ(mutable_.shrink_factor, shrink); | 91 DCHECK_EQ(mutable_.shrink_factor, shrink); |
| 90 } | 92 } |
| 91 } | 93 } |
| 92 DebugDump(*page); | 94 DebugDump(*page); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 AutoLock lock(lock_); | 179 AutoLock lock(lock_); |
| 178 return mutable_.expected_page_count_; | 180 return mutable_.expected_page_count_; |
| 179 } | 181 } |
| 180 | 182 |
| 181 void PrintedDocument::PrintHeaderFooter(gfx::NativeDrawingContext context, | 183 void PrintedDocument::PrintHeaderFooter(gfx::NativeDrawingContext context, |
| 182 const PrintedPage& page, | 184 const PrintedPage& page, |
| 183 PageOverlays::HorizontalPosition x, | 185 PageOverlays::HorizontalPosition x, |
| 184 PageOverlays::VerticalPosition y, | 186 PageOverlays::VerticalPosition y, |
| 185 const gfx::Font& font) const { | 187 const gfx::Font& font) const { |
| 186 const PrintSettings& settings = immutable_.settings_; | 188 const PrintSettings& settings = immutable_.settings_; |
| 187 if (!settings.use_overlays) { | 189 if (!settings.use_overlays || !page.has_visible_overlays()) { |
| 188 return; | 190 return; |
| 189 } | 191 } |
| 190 const std::wstring& line = settings.overlays.GetOverlay(x, y); | 192 const std::wstring& line = settings.overlays.GetOverlay(x, y); |
| 191 if (line.empty()) { | 193 if (line.empty()) { |
| 192 return; | 194 return; |
| 193 } | 195 } |
| 194 std::wstring output(PageOverlays::ReplaceVariables(line, *this, page)); | 196 std::wstring output(PageOverlays::ReplaceVariables(line, *this, page)); |
| 195 if (output.empty()) { | 197 if (output.empty()) { |
| 196 // May happen if document name or url is empty. | 198 // May happen if document name or url is empty. |
| 197 return; | 199 return; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 date_ = win_util::FormatSystemDate(systemtime, std::wstring()); | 326 date_ = win_util::FormatSystemDate(systemtime, std::wstring()); |
| 325 time_ = win_util::FormatSystemTime(systemtime, std::wstring()); | 327 time_ = win_util::FormatSystemTime(systemtime, std::wstring()); |
| 326 #else // OS_WIN | 328 #else // OS_WIN |
| 327 Time now = Time::Now(); | 329 Time now = Time::Now(); |
| 328 date_ = base::TimeFormatShortDateNumeric(now); | 330 date_ = base::TimeFormatShortDateNumeric(now); |
| 329 time_ = base::TimeFormatTimeOfDay(now); | 331 time_ = base::TimeFormatTimeOfDay(now); |
| 330 #endif // OS_WIN | 332 #endif // OS_WIN |
| 331 } | 333 } |
| 332 | 334 |
| 333 } // namespace printing | 335 } // namespace printing |
| OLD | NEW |