notepad: substitute the page number in the footer
Damjan Jovanovic
damjan.jov at gmail.com
Fri Jun 18 07:58:39 CDT 2010
Changelog:
* notepad: substitute the page number in the footer
Closes #23085.
Damjan Jovanovic
-------------- next part --------------
diff --git a/programs/notepad/dialog.c b/programs/notepad/dialog.c
index e19e4d6..98840bd 100644
--- a/programs/notepad/dialog.c
+++ b/programs/notepad/dialog.c
@@ -29,6 +29,8 @@
#include <shlwapi.h>
#include <winternl.h>
+#include "wine/unicode.h"
+
#include "main.h"
#include "dialog.h"
@@ -719,9 +721,11 @@ static int notepad_print_header(HDC hdc, RECT *rc, BOOL dopage, BOOL header, int
static BOOL notepad_print_page(HDC hdc, RECT *rc, BOOL dopage, int page, LPTEXTINFO tInfo)
{
+ static const WCHAR amp_p[] = {'&','p',0};
int b, y;
TEXTMETRICW tm;
SIZE szMetrics;
+ WCHAR *footer = NULL;
if (dopage)
{
@@ -804,7 +808,33 @@ static BOOL notepad_print_page(HDC hdc, RECT *rc, BOOL dopage, int page, LPTEXTI
}
} while (tInfo->mptr < tInfo->mend && y < b);
- notepad_print_header(hdc, rc, dopage, FALSE, page, Globals.szFooter);
+ if (strstrW(Globals.szFooter, amp_p))
+ {
+ int len;
+ WCHAR *p = strstrW(Globals.szFooter, amp_p);
+ len = strlenW(Globals.szFooter) + 1 - 2 + 10;
+ footer = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ if (footer)
+ {
+ static const WCHAR pattern[] = {'%','s','%','d','%','s',0};
+ p[0] = 0;
+ p[1] = 0;
+ snprintfW(footer, len, pattern, Globals.szFooter, page, p + 2);
+ p[0] = '&';
+ p[1] = 'p';
+ }
+ }
+ else
+ {
+ footer = HeapAlloc(GetProcessHeap(), 0, strlenW(Globals.szFooter));
+ if (footer)
+ {
+ strcpyW(footer, Globals.szFooter);
+ }
+ }
+ if (footer)
+ notepad_print_header(hdc, rc, dopage, FALSE, page, footer);
+ HeapFree(GetProcessHeap(), 0, footer);
if (dopage)
{
EndPage(hdc);
More information about the wine-patches
mailing list