1 2 #include "../include/bookformats.h" 3 LVDocFormatName(int fmt)4lString32 LVDocFormatName(int fmt) { 5 switch (fmt) { 6 case doc_format_fb2: return lString32("FB2"); 7 case doc_format_fb3: return lString32("FB3"); 8 case doc_format_txt: return lString32("TXT"); 9 case doc_format_rtf: return lString32("RTF"); 10 case doc_format_epub: return lString32("EPUB"); 11 case doc_format_html: return lString32("HTML"); 12 case doc_format_txt_bookmark: return lString32("BMK"); 13 case doc_format_chm: return lString32("CHM"); 14 case doc_format_doc: return lString32("DOC"); 15 case doc_format_docx: return lString32("DOCX"); 16 case doc_format_pdb: return lString32("PDB"); 17 case doc_format_odt: return lString32("ODT"); 18 default: return lString32("?"); 19 } 20 } 21 LVDocFormatCssFileName(int fmt)22lString8 LVDocFormatCssFileName(int fmt) { 23 switch (fmt) { 24 case doc_format_fb2: return lString8("fb2.css"); 25 case doc_format_fb3: return lString8("fb3.css"); 26 case doc_format_txt: return lString8("txt.css"); 27 case doc_format_rtf: return lString8("rtf.css"); 28 case doc_format_epub: return lString8("epub.css"); 29 case doc_format_html: return lString8("htm.css"); 30 case doc_format_txt_bookmark: return lString8("txt.css"); 31 case doc_format_chm: return lString8("chm.css"); 32 case doc_format_doc: return lString8("doc.css"); 33 case doc_format_docx: return lString8("docx.css"); 34 case doc_format_pdb: return lString8("htm.css"); 35 case doc_format_odt: return lString8("odt.css"); 36 default: return lString8("txt.css"); 37 } 38 } 39 LVDocFormatFromExtension(lString32 & pathName)40int LVDocFormatFromExtension(lString32 &pathName) { 41 if (pathName.endsWith(".fb2")) 42 return doc_format_fb2; 43 if (pathName.endsWith(".fb3")) 44 return doc_format_fb3; 45 if (pathName.endsWith(".txt") || pathName.endsWith(".tcr") || pathName.endsWith(".pml")) 46 return doc_format_txt; 47 if (pathName.endsWith(".rtf")) 48 return doc_format_rtf; 49 if (pathName.endsWith(".epub")) 50 return doc_format_epub; 51 if (pathName.endsWith(".htm") || pathName.endsWith(".html") || pathName.endsWith(".shtml") || pathName.endsWith(".xhtml")) 52 return doc_format_html; 53 if (pathName.endsWith(".txt.bmk")) 54 return doc_format_txt_bookmark; 55 if (pathName.endsWith(".chm")) 56 return doc_format_chm; 57 if (pathName.endsWith(".doc")) 58 return doc_format_doc; 59 if (pathName.endsWith(".docx")) 60 return doc_format_docx; 61 if (pathName.endsWith(".pdb") || pathName.endsWith(".prc") || pathName.endsWith(".mobi") || pathName.endsWith(".azw")) 62 return doc_format_pdb; 63 if (pathName.endsWith(".odt")) 64 return doc_format_odt; 65 return doc_format_none; 66 } 67 68