1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
#include <iostream>
#include <fstream>
#include <sstream>
#include <memory>
#include <map>
#include <algorithm>
#include <random>
#include <locale>
#include <wx/wx.h>
#include <wx/stdpaths.h>
#include <wx/fontdlg.h>
#include <wx/choicdlg.h>
#include <wx/msgdlg.h>
#include <wx/popupwin.h>
#include <wx/listbox.h>
#include <wx/dir.h>
#include <wx/textfile.h>
#include <wx/filename.h>
#include <wx/wfstream.h>
#include <wx/zipstrm.h>
#include "pugixml/pugixml.hpp"
#include "pugixml/pugiconfig.hpp"
using namespace std;
using namespace pugi;
#ifdef _WIN32
static string path_separator = "\\";
#else
static string path_separator = "/";
#endif
#ifdef EXTERN_WX_GUI
extern void detect_fonts(const char* xmlfile, vector<wstring>& doc_fonts,
vector<wstring>& doc_encs);
extern void process_xml(const char * xmlfile, const wstring& targ_font,
const vector<wstring>& doc_fonts, const vector<wstring>& doc_encs,
map<wstring, vector<wstring>>& char_map,
vector<wstring>& utf_chars, const wstring& default_font, bool do_greek);
extern bool to_bool(const string& s);
extern void uniq(vector <wstring>& vec);
extern void get_default_pfont(wstring& default_font,
const char* styles_xmlfile);
extern void update_default_pfont(const char * styles_xmlfile,
const wstring& targ_font, const vector<wstring>& doc_fonts);
extern string random_anum_string(int len);
extern void read_config_file(const char* configfile,
map<string, string>& config_options);
extern void write_config_file(const char* configfile,
map<string, string>& config_options);
static const char *styles_xmlfile = "word/styles.xml";
#endif
class TranscodeGUI: public wxApp {
public:
bool OnInit();
};
class TranscodeFrame: public wxFrame {
public:
TranscodeFrame();
private:
wxPanel *main_panel;
wxBoxSizer *main_sizer;
struct {
bool do_greek;
bool do_font_select;
} config_params;
map<string, string> config_options;
wxString config_filepath;
wxBoxSizer *infile_sizer;
wxStaticText *infile_label;
wxTextCtrl *infile_field;
wxButton *infile_button;
void SelectDoc(wxCommandEvent& event);
wxString infile_path;
wxBoxSizer *tsvfile_sizer;
wxStaticText *tsvfile_label;
wxTextCtrl *tsvfile_field;
wxButton *tsvfile_button;
void SelectTSV(wxCommandEvent& event);
wxString tsvfile_path;
wxStaticText *fontsel_label;
wxBoxSizer *fontsel_sizer;
wxTextCtrl *fontsel_field;
wxButton *fontsel_button;
void DoFontDialog(wxCommandEvent& event);
wxString fontsel_name;
wxCheckBox *check_greek;
void ChkGrk(wxCommandEvent& event);
wxCheckBox *check_fontsel;
void ChkFontSel(wxCommandEvent& event);
wxTextCtrl *status_messages;
wxBoxSizer *button_sizer;
wxButton *transcode_button;
void Transcode(wxCommandEvent& event);
void ZipCreate(const wxString& dir_src,
const wxString& zip_file);
void ZipExtract(const wxString& zip_file,
const wxString& dir_target);
void LoadCharmap(wxString& charfile,
const wchar_t sep,
map<wstring, vector<wstring>>& char_map,
vector<wstring>& utf_chars);
void SaveFile(void);
wxPopupWindow *docfonts_chooser;
wxListBox *docfonts_listbox;
wxButton *quit_button;
void Quit(wxCommandEvent& event);
wxButton *clear_button;
void Reset(wxCommandEvent& event);
};
static const vector<const char*> convfiles = {
"word/document.xml",
"word/footnotes.xml"
};
static const map<const wchar_t, const wchar_t> ascii_utf = {
{0x2126, 0x03A9} // Ohm symbol
};
static const vector<wstring> greek_comb = {
L"ᾊ", L"ᾌ", L"ᾎ", L"ᾋ", L"ᾍ", L"ᾏ",
L"ᾚ", L"ᾜ", L"ᾞ", L"ᾛ", L"ᾝ", L"ᾟ",
L"ᾪ", L"ᾬ", L"ᾮ", L"ᾫ", L"ᾭ", L"ᾯ",
L"ᾂ", L"ᾄ", L"ᾆ", L"ᾃ", L"ᾅ", L"ᾇ",
L"ᾒ", L"ᾔ", L"ᾖ", L"ᾓ", L"ᾕ", L"ᾗ",
L"ᾢ", L"ᾤ", L"ᾦ", L"ᾣ", L"ᾥ", L"ᾧ",
L"Ἂ", L"Ἄ", L"Ἆ", L"ᾈ", L"Ἃ", L"Ἅ", L"Ἇ",
L"ᾉ", L"Ἒ", L"Ἔ", L"Ἓ", L"Ἕ", L"Ἢ", L"Ἤ",
L"Ἦ", L"ᾘ", L"Ἣ", L"Ἥ", L"Ἧ", L"ᾙ", L"Ἲ",
L"Ἴ", L"Ἶ", L"Ἳ", L"Ἵ", L"Ἷ", L"Ὂ", L"Ὄ",
L"Ὃ", L"Ὅ", L"Ὓ", L"Ὕ", L"Ὗ", L"Ὢ", L"Ὤ",
L"Ὦ", L"ᾨ", L"Ὣ", L"Ὥ", L"Ὧ", L"ᾩ", L"ᾲ",
L"ᾴ", L"ἂ", L"ἄ", L"ἆ", L"ᾀ", L"ἃ", L"ἅ",
L"ἇ", L"ᾁ", L"ᾷ", L"ἒ", L"ἔ", L"ἓ", L"ἕ",
L"ῂ", L"ῄ", L"ἢ", L"ἤ", L"ἦ", L"ᾐ", L"ἣ",
L"ἥ", L"ἧ", L"ᾑ", L"ῇ", L"ῒ", L"ΐ", L"ϊ̍",
L"ῗ", L"ἲ", L"ἴ", L"ἶ", L"ἳ", L"ἵ", L"ἷ",
L"όͅ", L"ὂ", L"ὄ", L"ὃ", L"ὅ", L"ῢ", L"ΰ",
L"ϋ̍", L"ῧ", L"ὒ", L"ὔ", L"ὖ", L"ὓ", L"ὕ",
L"ὗ", L"ῲ", L"ὢ", L"ὤ", L"ὦ", L"ᾠ", L"ὣ",
L"ὥ", L"ὧ", L"ᾡ", L"ῷ",
L"Ά", L"Ᾱ", L"Ᾰ", L"Α̍", L"Ἀ", L"Ἁ", L"ᾼ",
L"Ὲ", L"Έ", L"Ε̍", L"Ἐ", L"Ἑ", L"Ὴ", L"Ή", L"Η̍",
L"Ἠ", L"Ἡ", L"ῌ", L"Ὶ", L"Ί", L"Ῑ", L"Ι̍", L"Ἰ",
L"Ἱ", L"Ὸ", L"Ό", L"Ο̍", L"Ὀ", L"Ὁ", L"Ῥ", L"Ὺ",
L"Ύ", L"Ῡ", L"Ῠ", L"Ϋ", L"Υ̍", L"Ὑ", L"Ὼ", L"Ώ",
L"Ω̍", L"Ὠ", L"Ὡ", L"ῼ", L"ὰ", L"ά", L"ᾱ", L"ᾰ",
L"α̍", L"ἀ", L"ἁ", L"ᾶ", L"ᾳ", L"ὲ", L"έ", L"ε̍",
L"ἐ", L"ἑ", L"ὴ", L"ή", L"η̍", L"ἠ", L"ἡ", L"ῆ",
L"ῃ", L"ὶ", L"ί", L"ῑ", L"ῐ", L"ϊ", L"ι̍", L"ἰ",
L"ἱ", L"ὸ", L"ό", L"ο̍", L"ὀ", L"ὁ", L"ῤ", L"ῥ",
L"ὺ", L"ύ", L"ῡ", L"ῠ", L"ϋ", L"υ̍", L"ὐ", L"ὑ",
L"ῦ", L"ὼ", L"ώ", L"ω̍", L"ὠ", L"ὡ", L"ῶ", L"ῳ"
};
static const vector<wstring> greek_precomp = {
L"ᾊ", L"ᾌ", L"ᾎ", L"ᾋ", L"ᾍ", L"ᾏ",
L"ᾚ", L"ᾜ", L"ᾞ", L"ᾛ", L"ᾝ", L"ᾟ",
L"ᾪ", L"ᾬ", L"ᾮ", L"ᾫ", L"ᾭ", L"ᾯ",
L"ᾂ", L"ᾄ", L"ᾆ", L"ᾃ", L"ᾅ", L"ᾇ",
L"ᾒ", L"ᾔ", L"ᾖ", L"ᾓ", L"ᾕ", L"ᾗ",
L"ᾢ", L"ᾤ", L"ᾦ", L"ᾣ", L"ᾥ", L"ᾧ",
L"Ἄ", L"Ἆ", L"ᾈ", L"Ἃ", L"Ἅ", L"Ἇ", L"ᾉ",
L"Ἒ", L"Ἔ", L"Ἓ", L"Ἕ", L"Ἢ", L"Ἤ", L"Ἦ", L"ᾘ",
L"Ἣ", L"Ἥ", L"Ἧ", L"ᾙ", L"Ἲ", L"Ἴ", L"Ἶ", L"Ἳ",
L"Ἵ", L"Ἷ", L"Ὂ", L"Ὄ", L"Ὃ", L"Ὅ", L"Ὓ", L"Ὕ",
L"Ὗ", L"Ὢ", L"Ὤ", L"Ὦ", L"ᾨ", L"Ὣ", L"Ὥ", L"Ὧ",
L"ᾩ", L"ᾲ", L"ᾴ", L"ἂ", L"ἄ", L"ἆ", L"ᾀ", L"ἃ",
L"ἅ", L"ἇ", L"ᾁ", L"ᾷ", L"ἒ", L"ἔ", L"ἓ", L"ἕ",
L"ῂ", L"ῄ", L"ἢ", L"ἤ", L"ἦ", L"ᾐ", L"ἣ", L"ἥ",
L"ἧ", L"ᾑ", L"ῇ", L"ῒ", L"ΐ", L"ΐ", L"ῗ", L"ἲ",
L"ἴ", L"ἶ", L"ἳ", L"ἵ", L"ἷ", L"ῴ", L"ὂ", L"ὄ",
L"ὃ", L"ὅ", L"ῢ", L"ΰ", L"ΰ", L"ῧ", L"ὒ", L"ὔ",
L"ὖ", L"ὓ", L"ὕ", L"ὗ", L"ῲ", L"ὢ", L"ὤ", L"ὦ",
L"ᾠ", L"ὣ", L"ὥ", L"ὧ", L"ᾡ", L"ῷ",
L"Ὰ", L"Ά", L"Ᾱ", L"Ᾰ", L"Ά", L"Ἀ", L"Ἁ", L"ᾼ",
L"Ὲ", L"Έ", L"Έ", L"Ἐ", L"Ἑ", L"Ὴ", L"Ή", L"Ή",
L"Ἠ", L"Ἡ", L"ῌ", L"Ὶ", L"Ί", L"Ῑ", L"Ί", L"Ἰ",
L"Ἱ", L"Ὸ", L"Ό", L"Ό", L"Ὀ", L"Ὁ", L"Ῥ", L"Ὺ",
L"Ύ", L"Ῡ", L"Ῠ", L"Ϋ", L"Ύ", L"Ὑ", L"Ὼ", L"Ώ",
L"Ώ", L"Ὠ", L"Ὡ", L"ῼ", L"ὰ", L"ά", L"ᾱ", L"ᾰ",
L"ά", L"ἀ", L"ἁ", L"ᾶ", L"ᾳ", L"ὲ", L"έ", L"έ",
L"ἐ", L"ἑ", L"ὴ", L"ή", L"ή", L"ἠ", L"ἡ", L"ῆ",
L"ῃ", L"ὶ", L"ί", L"ῑ", L"ῐ", L"ϊ", L"ί", L"ἰ",
L"ἱ", L"ὸ", L"ό", L"ό", L"ὀ", L"ὁ", L"ῤ", L"ῥ",
L"ὺ", L"ύ", L"ῡ", L"ῠ", L"ϋ", L"ύ", L"ὐ", L"ὑ",
L"ῦ", L"ὼ", L"ώ", L"ώ", L"ὠ", L"ὡ", L"ῶ", L"ῳ"
};
|