diff options
author | Robin Watts <robin.watts@artifex.com> | 2012-04-17 00:40:43 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2012-04-17 09:25:03 +0100 |
commit | 4069e52998d2cb2b54e65e8a8b418868ffa73bee (patch) | |
tree | 423024feca20fdb07224ecb40c807dbb3fbd4644 /apps/win_main.c | |
parent | 00851c1b04215f2e5688836be57e4efdb198483b (diff) | |
download | mupdf-4069e52998d2cb2b54e65e8a8b418868ffa73bee.tar.xz |
Add Meta interface to fz_document.
Use this to reintroduce "Document Properties..." in mupdf viewer.
Diffstat (limited to 'apps/win_main.c')
-rw-r--r-- | apps/win_main.c | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/apps/win_main.c b/apps/win_main.c index 37864e19..cc71a120 100644 --- a/apps/win_main.c +++ b/apps/win_main.c @@ -20,6 +20,7 @@ #endif #define ID_ABOUT 0x1000 +#define ID_DOCINFO 0x1001 static HWND hwndframe = NULL; static HWND hwndview = NULL; @@ -165,6 +166,83 @@ char *winpassword(pdfapp_t *app, char *filename) } INT CALLBACK +dloginfoproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + char buf[256]; + fz_document *doc = gapp.doc; + + switch(message) + { + case WM_INITDIALOG: + + SetDlgItemTextW(hwnd, 0x10, wbuf); + + if (fz_meta(doc, FZ_META_FORMAT_INFO, buf, 256) < 0) + { + SetDlgItemTextA(hwnd, 0x11, "Unknown"); + SetDlgItemTextA(hwnd, 0x12, "None"); + SetDlgItemTextA(hwnd, 0x13, "n/a"); + return TRUE; + } + + SetDlgItemTextA(hwnd, 0x11, buf); + + if (fz_meta(doc, FZ_META_CRYPT_INFO, buf, 256) == 0) + { + SetDlgItemTextA(hwnd, 0x12, buf); + } + else + { + SetDlgItemTextA(hwnd, 0x12, "None"); + } + buf[0] = 0; + if (fz_meta(doc, FZ_META_HAS_PERMISSION, NULL, FZ_PERMISSION_PRINT) == 0) + strcat(buf, "print, "); + if (fz_meta(doc, FZ_META_HAS_PERMISSION, NULL, FZ_PERMISSION_CHANGE) == 0) + strcat(buf, "modify, "); + if (fz_meta(doc, FZ_META_HAS_PERMISSION, NULL, FZ_PERMISSION_COPY) == 0) + strcat(buf, "copy, "); + if (fz_meta(doc, FZ_META_HAS_PERMISSION, NULL, FZ_PERMISSION_NOTES) == 0) + strcat(buf, "annotate, "); + if (strlen(buf) > 2) + buf[strlen(buf)-2] = 0; + else + strcpy(buf, "None"); + SetDlgItemTextA(hwnd, 0x13, buf); + +#define SETUTF8(ID, STRING) \ + { \ + *(char **)buf = STRING; \ + if (fz_meta(doc, FZ_META_INFO, buf, 256) <= 0) \ + buf[0] = 0; \ + SetDlgItemTextA(hwnd, ID, buf); \ + } + + SETUTF8(0x20, "Title"); + SETUTF8(0x21, "Author"); + SETUTF8(0x22, "Subject"); + SETUTF8(0x23, "Keywords"); + SETUTF8(0x24, "Creator"); + SETUTF8(0x25, "Producer"); + SETUTF8(0x26, "CreationDate"); + SETUTF8(0x27, "ModDate"); + return TRUE; + + case WM_COMMAND: + EndDialog(hwnd, 1); + return TRUE; + } + return FALSE; +} + +void info() +{ + int code = DialogBoxW(NULL, L"IDD_DLOGINFO", hwndframe, dloginfoproc); + if (code <= 0) + winerror(&gapp, "cannot create info dialog"); +} + +INT CALLBACK dlogaboutproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) @@ -287,6 +365,7 @@ void winopen() menu = GetSystemMenu(hwndframe, 0); AppendMenuW(menu, MF_SEPARATOR, 0, NULL); AppendMenuW(menu, MF_STRING, ID_ABOUT, L"About MuPDF..."); + AppendMenuW(menu, MF_STRING, ID_DOCINFO, L"Document Properties..."); SetCursor(arrowcurs); } @@ -600,6 +679,11 @@ frameproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) winhelp(&gapp); return 0; } + if (wParam == ID_DOCINFO) + { + info(); + return 0; + } if (wParam == SC_MAXIMIZE) gapp.shrinkwrap = 0; break; |