Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Unified Diff: printing/printed_document_win.cc

Issue 6386009: Remove app/win/win_util.h,cc etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with NSApp changes in r73581 Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « printing/DEPS ('k') | ui/base/message_box_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/printed_document_win.cc
diff --git a/printing/printed_document_win.cc b/printing/printed_document_win.cc
index 0cd0bb9792a5ac9c821d523e1edb591815cf4e04..32a71a9dc8e724d7724418ce1f2837f41d2491a6 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,
« no previous file with comments | « printing/DEPS ('k') | ui/base/message_box_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698