summaryrefslogtreecommitdiffstats
path: root/printing/printed_document_win.cc
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-07 22:01:52 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-07 22:01:52 +0000
commite059878de96a6fcdc70dfc3bf13d37be6d1a697a (patch)
tree4387419d69b2946a556e43d52596c78c07582e17 /printing/printed_document_win.cc
parentcceaf8512b4cb70a81db1f371ae094e2f2d3f645 (diff)
downloadchromium_src-e059878de96a6fcdc70dfc3bf13d37be6d1a697a.zip
chromium_src-e059878de96a6fcdc70dfc3bf13d37be6d1a697a.tar.gz
chromium_src-e059878de96a6fcdc70dfc3bf13d37be6d1a697a.tar.bz2
Printing: Refactor a few helper methods implemented per-platform to clean up
ifdef mess in PrintedDocument implementation. BUG=none TEST=none Review URL: http://codereview.chromium.org/3564016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61865 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/printed_document_win.cc')
-rw-r--r--printing/printed_document_win.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/printing/printed_document_win.cc b/printing/printed_document_win.cc
index e6a1126..d157aef 100644
--- a/printing/printed_document_win.cc
+++ b/printing/printed_document_win.cc
@@ -4,8 +4,10 @@
#include "printing/printed_document.h"
+#include "app/win_util.h"
#include "base/logging.h"
#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
#include "gfx/font.h"
#include "printing/page_number.h"
#include "printing/page_overlays.h"
@@ -114,4 +116,32 @@ void PrintedDocument::RenderPrintedPage(
DCHECK_NE(res, 0);
}
+void PrintedDocument::Immutable::SetDocumentDate() {
+ // Use the native time formatting for printing on Windows.
+ SYSTEMTIME systemtime;
+ GetLocalTime(&systemtime);
+ date_ =
+ WideToUTF16Hack(win_util::FormatSystemDate(systemtime, std::wstring()));
+ time_ =
+ WideToUTF16Hack(win_util::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);
+}
+
} // namespace printing