#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #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& doc_fonts, vector& doc_encs); extern void process_xml(const char * xmlfile, wstring& targ_font, const vector& doc_fonts, const vector& doc_encs, map>& char_map, vector& utf_chars, const wstring& default_font, bool do_greek); extern bool to_bool(const wstring& s); extern void uniq(vector & vec); extern void get_default_pfont(wstring& default_font, const char* styles_xmlfile); extern void update_default_pfont(const char * styles_xmlfile, wstring& targ_font, const vector& doc_fonts); extern string random_anum_string(int len); extern void read_config_file(const char* configfile, map& config_options); extern void write_config_file(const char* configfile, map& config_options); #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 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 *csvfile_sizer; wxStaticText *csvfile_label; wxTextCtrl *csvfile_field; wxButton *csvfile_button; void SelectCSV(wxCommandEvent& event); wxString csvfile_path; wxStaticText *fontsel_label; wxBoxSizer *fontsel_sizer; wxTextCtrl *fontsel_field; wxButton *fontsel_button; void DoFontDialog(wxCommandEvent& event); wstring 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>& char_map, vector& 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 convfiles = { "word/document.xml", "word/footnotes.xml" }; static const char * styles_xmlfile = "word/styles.xml"; static const map ascii_utf = { {0x2126, 0x03A9} // Ohm symbol }; static const vector 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 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"ῳ" };