66#include < odr/exceptions.hpp>
77#include < odr/filesystem.hpp>
88#include < odr/global_params.hpp>
9+ #include < odr/html_service.hpp>
910
1011#include < odr/internal/html/document.hpp>
1112#include < odr/internal/html/filesystem.hpp>
@@ -27,36 +28,19 @@ namespace odr {
2728
2829HtmlConfig::HtmlConfig () : resource_path{GlobalParams::odr_core_data_path ()} {}
2930
30- Html::Html (FileType file_type, HtmlConfig config, std::vector<HtmlPage> pages)
31- : m_file_type{file_type}, m_config{std::move (config)},
32- m_pages{std::move (pages)} {}
31+ Html::Html (HtmlConfig config, std::vector<HtmlPage> pages)
32+ : m_config{std::move (config)}, m_pages{std::move (pages)} {}
3333
34- Html::Html (FileType file_type, HtmlConfig config, std::vector<HtmlPage> pages,
35- Document document)
36- : m_file_type{file_type}, m_config{std::move (config)},
37- m_pages{std::move (pages)}, m_document{std::move (document)} {}
38-
39- FileType Html::file_type () const { return m_file_type; }
34+ const HtmlConfig &Html::config () { return m_config; }
4035
4136const std::vector<HtmlPage> &Html::pages () const { return m_pages; }
4237
43- void Html::edit (const char *diff) {
44- if (m_document) {
45- html::edit (*m_document, diff);
46- }
47- }
48-
49- void Html::save (const std::string &path) const {
50- if (m_document) {
51- m_document->save (path);
52- }
53- }
54-
5538HtmlPage::HtmlPage (std::string name, std::string path)
5639 : name{std::move (name)}, path{std::move (path)} {}
5740
58- Html html::translate (const DecodedFile &decoded_file,
59- const std::string &output_path, const HtmlConfig &config) {
41+ HtmlService html::translate (const DecodedFile &decoded_file,
42+ const std::string &output_path,
43+ const HtmlConfig &config) {
6044 if (decoded_file.is_text_file ()) {
6145 return translate (decoded_file.text_file (), output_path, config);
6246 } else if (decoded_file.is_image_file ()) {
@@ -72,67 +56,74 @@ Html html::translate(const DecodedFile &decoded_file,
7256 throw UnsupportedFileType (decoded_file.file_type ());
7357}
7458
75- Html html::translate (const TextFile &text_file, const std::string &output_path,
76- const HtmlConfig &config) {
59+ HtmlService html::translate (const TextFile &text_file,
60+ const std::string &output_path,
61+ const HtmlConfig &config) {
7762 std::filesystem::create_directories (output_path);
78- return internal::html::translate_text_file (text_file, output_path, config);
63+ return internal::html::create_text_service (text_file, output_path, config);
7964}
8065
81- Html html::translate (const ImageFile &image_file,
82- const std::string &output_path, const HtmlConfig &config) {
66+ HtmlService html::translate (const ImageFile &image_file,
67+ const std::string &output_path,
68+ const HtmlConfig &config) {
8369 std::filesystem::create_directories (output_path);
84- return internal::html::translate_image_file (image_file, output_path, config);
70+ return internal::html::create_image_service (image_file, output_path, config);
8571}
8672
87- Html html::translate (const ArchiveFile &archive_file,
88- const std::string &output_path, const HtmlConfig &config) {
73+ HtmlService html::translate (const ArchiveFile &archive_file,
74+ const std::string &output_path,
75+ const HtmlConfig &config) {
8976 return translate (archive_file.archive (), output_path, config);
9077}
9178
92- Html html::translate (const DocumentFile &document_file,
93- const std::string &output_path, const HtmlConfig &config) {
79+ HtmlService html::translate (const DocumentFile &document_file,
80+ const std::string &output_path,
81+ const HtmlConfig &config) {
9482 auto document_file_impl = document_file.impl ();
9583
9684#ifdef ODR_WITH_WVWARE
9785 if (auto wv_document_file =
9886 std::dynamic_pointer_cast<internal::WvWareLegacyMicrosoftFile>(
9987 document_file_impl)) {
10088 std::filesystem::create_directories (output_path);
101- return internal::html::translate_wvware_oldms_file (*wv_document_file,
89+ return internal::html::create_wvware_oldms_service (*wv_document_file,
10290 output_path, config);
10391 }
10492#endif
10593
10694 return translate (document_file.document (), output_path, config);
10795}
10896
109- Html html::translate (const PdfFile &pdf_file, const std::string &output_path,
110- const HtmlConfig &config) {
97+ HtmlService html::translate (const PdfFile &pdf_file,
98+ const std::string &output_path,
99+ const HtmlConfig &config) {
111100 auto pdf_file_impl = pdf_file.impl ();
112101
113102#ifdef ODR_WITH_PDF2HTMLEX
114103 if (auto poppler_pdf_file =
115104 std::dynamic_pointer_cast<internal::PopplerPdfFile>(pdf_file_impl)) {
116105 std::filesystem::create_directories (output_path);
117- return internal::html::translate_poppler_pdf_file (*poppler_pdf_file,
106+ return internal::html::create_poppler_pdf_service (*poppler_pdf_file,
118107 output_path, config);
119108 }
120109#endif
121110
122- return internal::html::translate_pdf_file (pdf_file, output_path, config);
111+ return internal::html::create_pdf_service (pdf_file, output_path, config);
123112}
124113
125- Html html::translate (const Archive &archive, const std::string &output_path,
126- const HtmlConfig &config) {
114+ HtmlService html::translate (const Archive &archive,
115+ const std::string &output_path,
116+ const HtmlConfig &config) {
127117 std::filesystem::create_directories (output_path);
128- return internal::html::translate_filesystem (
129- FileType::unknown, archive. filesystem (), output_path, config);
118+ return internal::html::create_filesystem_service (archive. filesystem (),
119+ output_path, config);
130120}
131121
132- Html html::translate (const Document &document, const std::string &output_path,
133- const HtmlConfig &config) {
122+ HtmlService html::translate (const Document &document,
123+ const std::string &output_path,
124+ const HtmlConfig &config) {
134125 std::filesystem::create_directories (output_path);
135- return internal::html::translate_document (document, output_path, config);
126+ return internal::html::create_document_service (document, output_path, config);
136127}
137128
138129void html::edit (const Document &document, const char *diff) {
0 commit comments