summaryrefslogtreecommitdiffstats
path: root/printing
diff options
context:
space:
mode:
authormsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-03 06:01:16 +0000
committermsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-03 06:01:16 +0000
commit75b6805083c906bb17192a738b311bd21791e9f8 (patch)
treebce38efec20d50a7ef55a694f58036ae365d5e0a /printing
parent2aa8b71eb688aa13a4f745027bcd4bb726bf6663 (diff)
downloadchromium_src-75b6805083c906bb17192a738b311bd21791e9f8.zip
chromium_src-75b6805083c906bb17192a738b311bd21791e9f8.tar.gz
chromium_src-75b6805083c906bb17192a738b311bd21791e9f8.tar.bz2
Cross-platform CL to remove app/win/win_util.h&cc and related work.
See Issue 70141 for the full move details; see my inline review comments. Changes significantly different from or beyond those prescribed by the bug: *Consolidated a lot of GrabWindowSnapshot code. *Moved EnsureRectIsVisibleInRect to views::internal namespace for test access. *Moved app/win/win_util_unittest.cc to views/window/window_win_unittest.h *Named ui/base/message_box_win.h instead of ui/base/message_box.h *Made WindowWin::GetWindowTitleFont static; needed in static contexts. *Denoted WindowWin::FrameTypeChanged as a Window override, moved code. *Moved TestGrabWindowSnapshot into new file: chrome/browser/ui/window_snapshot/window_snapshot_mac_unittest.mm BUG=70141 TEST=none Review URL: http://codereview.chromium.org/6386009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73589 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing')
-rw-r--r--printing/DEPS1
-rw-r--r--printing/printed_document_win.cc47
2 files changed, 43 insertions, 5 deletions
diff --git a/printing/DEPS b/printing/DEPS
index 1144038..c95a42a 100644
--- a/printing/DEPS
+++ b/printing/DEPS
@@ -1,5 +1,4 @@
include_rules = [
- "+app", # win_util::FormatSystemTime/Date.
"+base",
"+gfx",
"+skia/ext",
diff --git a/printing/printed_document_win.cc b/printing/printed_document_win.cc
index 0cd0bb9..32a71a9 100644
--- a/printing/printed_document_win.cc
+++ b/printing/printed_document_win.cc
@@ -1,10 +1,9 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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 "app/win/win_util.h"
#include "base/logging.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
@@ -34,6 +33,46 @@ 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 {
@@ -121,9 +160,9 @@ void PrintedDocument::Immutable::SetDocumentDate() {
SYSTEMTIME systemtime;
GetLocalTime(&systemtime);
date_ =
- WideToUTF16Hack(app::win::FormatSystemDate(systemtime, std::wstring()));
+ WideToUTF16Hack(FormatSystemDate(systemtime, std::wstring()));
time_ =
- WideToUTF16Hack(app::win::FormatSystemTime(systemtime, std::wstring()));
+ WideToUTF16Hack(FormatSystemTime(systemtime, std::wstring()));
}
void PrintedDocument::DrawHeaderFooter(gfx::NativeDrawingContext context,