From 766571a7039fe4428dabe5e2aabcb4055ceb9db9 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Sat, 29 Jul 2006 20:45:13 +0000
Subject: [PATCH] add @DATE@, @TIME@ and @TITLE@ macros to HTML printing
 (extended/modified patch 1528679)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40370 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/latex/wx/hteasypr.tex      | 12 ++----------
 docs/latex/wx/htprint.tex       | 10 ++--------
 docs/latex/wx/htprintmacros.inc | 19 +++++++++++++++++++
 src/html/htmprint.cpp           |  6 ++++++
 4 files changed, 29 insertions(+), 18 deletions(-)
 create mode 100644 docs/latex/wx/htprintmacros.inc

diff --git a/docs/latex/wx/hteasypr.tex b/docs/latex/wx/hteasypr.tex
index 7958055e71..ea10029f55 100644
--- a/docs/latex/wx/hteasypr.tex
+++ b/docs/latex/wx/hteasypr.tex
@@ -115,11 +115,7 @@ Set page header.
 \wxheading{Parameters}
 
 \docparam{header}{HTML text to be used as header. You can use macros in it:
-
-\begin{itemize}\itemsep=0pt
-\item @PAGENUM@ is replaced by page number
-\item @PAGESCNT@ is replaced by total number of pages
-\end{itemize}
+\input htprintmacros.inc
 }
 
 \docparam{pg}{one of wxPAGE\_ODD, wxPAGE\_EVEN and wxPAGE\_ALL constants.}
@@ -133,11 +129,7 @@ Set page footer.
 \wxheading{Parameters}
 
 \docparam{footer}{HTML text to be used as footer. You can use macros in it:
-
-\begin{itemize}\itemsep=0pt
-\item @PAGENUM@ is replaced by page number
-\item @PAGESCNT@ is replaced by total number of pages
-\end{itemize}
+\input htprintmacros.inc
 }
 
 \docparam{pg}{one of wxPAGE\_ODD, wxPAGE\_EVEN and wxPAGE\_ALL constants.}
diff --git a/docs/latex/wx/htprint.tex b/docs/latex/wx/htprint.tex
index 15f4ef87a0..e72e81bed8 100644
--- a/docs/latex/wx/htprint.tex
+++ b/docs/latex/wx/htprint.tex
@@ -50,10 +50,7 @@ Sets page footer.
 \wxheading{Parameters}
 
 \docparam{footer}{HTML text to be used as footer. You can use macros in it:
-\begin{itemize}
-\item @PAGENUM@ is replaced by page number
-\item @PAGESCNT@ is replaced by total number of pages
-\end{itemize}
+\input htprintmacros.inc
 }
 
 \docparam{pg}{one of wxPAGE\_ODD, wxPAGE\_EVEN and wxPAGE\_ALL constants.}
@@ -68,10 +65,7 @@ Sets page header.
 \wxheading{Parameters}
 
 \docparam{header}{HTML text to be used as header. You can use macros in it:
-\begin{itemize}
-\item @PAGENUM@ is replaced by page number
-\item @PAGESCNT@ is replaced by total number of pages
-\end{itemize}
+\input htprintmacros.inc
 }
 
 \docparam{pg}{one of wxPAGE\_ODD, wxPAGE\_EVEN and wxPAGE\_ALL constants.}
diff --git a/docs/latex/wx/htprintmacros.inc b/docs/latex/wx/htprintmacros.inc
new file mode 100644
index 0000000000..0da33a146f
--- /dev/null
+++ b/docs/latex/wx/htprintmacros.inc
@@ -0,0 +1,19 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Name:        htprint.inc
+%% Purpose:     Macros which can be used with wxHtmlPrintout: this file is
+%%              included from several locations where we list these macros
+%% Author:      Vadim Zeitlin
+%% Created:     2006-07-29
+%% RCS-ID:      $Id$
+%% Copyright:   (c) 2006 Vadim Zeitlin
+%% License:     wxWindows license
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\begin{itemize}\itemsep=0pt
+\item @DATE@ is replaced by the current date in default format
+\item @PAGENUM@ is replaced by page number
+\item @PAGESCNT@ is replaced by total number of pages
+\item @TIME@ is replaced by the current time in default format
+\item @TITLE@ is replaced with the title of the document
+\end{itemize}
+
diff --git a/src/html/htmprint.cpp b/src/html/htmprint.cpp
index 8b957076f1..0dd8817e52 100644
--- a/src/html/htmprint.cpp
+++ b/src/html/htmprint.cpp
@@ -443,6 +443,12 @@ wxString wxHtmlPrintout::TranslateHeader(const wxString& instr, int page)
     num.Printf(wxT("%lu"), (unsigned long)(m_PageBreaks.Count() - 1));
     r.Replace(wxT("@PAGESCNT@"), num);
 
+    const wxDateTime now = wxDateTime::Now();
+    r.Replace(wxT("@DATE@"), now.FormatDate());
+    r.Replace(wxT("@TIME@"), now.FormatTime());
+
+    r.Replace(wxT("@TITLE@"), GetTitle());
+
     return r;
 }
 
-- 
2.50.0

