OSDN Git Service

Fix Issue 85: Installer: warns of downgrade when running 0.6.2.0 on top of 0.6.1.0
[tortoisegit/TortoiseGitJp.git] / src / ResText / ResModule.h
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2007 - TortoiseSVN\r
4 \r
5 // This program is free software; you can redistribute it and/or\r
6 // modify it under the terms of the GNU General Public License\r
7 // as published by the Free Software Foundation; either version 2\r
8 // of the License, or (at your option) any later version.\r
9 \r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 \r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, write to the Free Software Foundation,\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 #pragma once\r
19 #include <vector>\r
20 #include <string>\r
21 #include <map>\r
22 #include "POFile.h"\r
23 \r
24 #define GET_WORD(ptr)        (*(WORD  *)(ptr))\r
25 #define GET_DWORD(ptr)       (*(DWORD *)(ptr))\r
26 #define ALIGN_DWORD(type, p) ((type)(((DWORD)p + 3) & ~3))\r
27 \r
28 #define MAX_STRING_LENGTH       (32*1024)\r
29 \r
30 // DIALOG CONTROL INFORMATION\r
31 typedef struct tagDlgItemInfo\r
32 {\r
33         DWORD   style;\r
34         DWORD   exStyle;\r
35         DWORD   helpId;\r
36         short   x;\r
37         short   y;\r
38         short   cx;\r
39         short   cy;\r
40         WORD    id;\r
41         LPCTSTR className;\r
42         LPCTSTR windowName;\r
43         LPVOID  data;\r
44 } DLGITEMINFO, * LPDLGITEMINFO;\r
45 \r
46 // DIALOG TEMPLATE\r
47 typedef struct tagDialogInfo\r
48 {\r
49         DWORD   style;\r
50         DWORD   exStyle;\r
51         DWORD   helpId;\r
52         WORD    nbItems;\r
53         short   x;\r
54         short   y;\r
55         short   cx;\r
56         short   cy;\r
57         LPCTSTR menuName;\r
58         LPCTSTR className;\r
59         LPCTSTR caption;\r
60         WORD    pointSize;\r
61         WORD    weight;\r
62         BOOL    italic;\r
63         LPCTSTR faceName;\r
64         BOOL    dialogEx;\r
65 } DIALOGINFO, * LPDIALOGINFO;\r
66 // MENU resource\r
67 typedef struct tagMenuEntry\r
68 {\r
69         WORD            wID;\r
70         std::wstring    reference;\r
71         std::wstring    msgstr;\r
72 } MENUENTRY, * LPMENUENTRY;\r
73 \r
74 /**\r
75  * \ingroup ResText\r
76  * Class to handle a resource module (*.exe or *.dll file).\r
77  *\r
78  * Provides methods to extract and apply resource strings.\r
79  */\r
80 class CResModule\r
81 {\r
82 public:\r
83         CResModule(void);\r
84         ~CResModule(void);\r
85 \r
86         BOOL    ExtractResources(LPCTSTR lpszSrcLangDllPath, LPCTSTR lpszPOFilePath, BOOL bNoUpdate);\r
87         BOOL    ExtractResources(std::vector<std::wstring> filelist, LPCTSTR lpszPOFilePath, BOOL bNoUpdate);\r
88         BOOL    CreateTranslatedResources(LPCTSTR lpszSrcLangDllPath, LPCTSTR lpszDestLangDllPath, LPCTSTR lpszPOFilePath);\r
89         void    SetQuiet(BOOL bQuiet = TRUE) {m_bQuiet = bQuiet; m_StringEntries.SetQuiet(bQuiet);}\r
90         void    SetLanguage(WORD wLangID) {m_wTargetLang = wLangID;}\r
91         void    SetRTL(bool bRTL = true) {m_bRTL = bRTL;}\r
92 \r
93 private:\r
94         static  BOOL CALLBACK EnumResNameCallback(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG_PTR lParam);\r
95         static  BOOL CALLBACK EnumResNameWriteCallback(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG_PTR lParam);\r
96         static  BOOL CALLBACK EnumResWriteLangCallback(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, WORD wLanguage, LONG_PTR lParam);\r
97         BOOL    ExtractString(UINT nID);\r
98         BOOL    ExtractDialog(UINT nID);\r
99         BOOL    ExtractMenu(UINT nID);\r
100         BOOL    ReplaceString(UINT nID, WORD wLanguage);\r
101         BOOL    ReplaceDialog(UINT nID, WORD wLanguage);\r
102         BOOL    ReplaceMenu(UINT nID, WORD wLanguage);\r
103         BOOL    ExtractAccelerator(UINT nID);\r
104         BOOL    ReplaceAccelerator(UINT nID, WORD wLanguage);\r
105 \r
106         const WORD*     ParseMenuResource(const WORD * res);\r
107         const WORD*     CountMemReplaceMenuResource(const WORD * res, size_t * wordcount, WORD * newMenu);\r
108         const WORD*     ParseMenuExResource(const WORD * res);\r
109         const WORD*     CountMemReplaceMenuExResource(const WORD * res, size_t * wordcount, WORD * newMenu);\r
110         const WORD* GetControlInfo(const WORD* p, LPDLGITEMINFO lpDlgItemInfo, BOOL dialogEx, LPBOOL bIsID);\r
111         const WORD*     GetDialogInfo(const WORD * pTemplate, LPDIALOGINFO lpDlgInfo);\r
112         const WORD*     CountMemReplaceDialogResource(const WORD * res, size_t * wordcount, WORD * newMenu);\r
113         const WORD* ReplaceControlInfo(const WORD * res, size_t * wordcount, WORD * newDialog, BOOL bEx);\r
114 \r
115         void    ReplaceStr(LPCWSTR src, WORD * dest, size_t * count, int * translated, int * def);\r
116 \r
117         HMODULE                 m_hResDll;\r
118         HANDLE                  m_hUpdateRes;\r
119         CPOFile                 m_StringEntries;\r
120         std::map<WORD, MENUENTRY> m_MenuEntries;\r
121         std::map<WORD, MENUENTRY>::iterator pME_iter;\r
122         std::wstring    sDestFile;\r
123         BOOL                    m_bQuiet;\r
124 \r
125         bool                    m_bRTL;\r
126 \r
127         int                             m_bTranslatedStrings;\r
128         int                             m_bDefaultStrings;\r
129         int                             m_bTranslatedDialogStrings;\r
130         int                             m_bDefaultDialogStrings;\r
131         int                             m_bTranslatedMenuStrings;\r
132         int                             m_bDefaultMenuStrings;\r
133         int                             m_bTranslatedAcceleratorStrings;\r
134         int                             m_bDefaultAcceleratorStrings;\r
135 \r
136         WORD                    m_wTargetLang;\r
137 };\r