Skip to content

Commit

Permalink
Update wvWare and pdf2htmlEX wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
ViliusSutkus89 committed Aug 25, 2024
1 parent 79ac7b3 commit c385c8c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 28 deletions.
8 changes: 2 additions & 6 deletions src/odr/internal/html/pdf2htmlEX_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,12 @@

namespace odr::internal {

Html html::pdf2htmlEX_wrapper(const PdfFile &pdf_file,
Html html::pdf2htmlEX_wrapper(const std::string &input_path,
const std::string &output_path,
const HtmlConfig &config) {
pdf2htmlEX::pdf2htmlEX pdf2htmlEX;

auto disk_path = pdf_file.file().disk_path();
if (!disk_path.has_value()) {
throw FileNotFound();
}
pdf2htmlEX.setInputFilename(disk_path.value());
pdf2htmlEX.setInputFilename(input_path);
pdf2htmlEX.setDestinationDir(output_path);
auto output_file_name = "document.html";
pdf2htmlEX.setOutputFilename(output_file_name);
Expand Down
2 changes: 1 addition & 1 deletion src/odr/internal/html/pdf2htmlEX_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Html;

namespace odr::internal::html {

Html pdf2htmlEX_wrapper(const PdfFile &pdf_file, const std::string &output_path,
Html pdf2htmlEX_wrapper(const std::string &input_path, const std::string &output_path,
const HtmlConfig &config);

}
Expand Down
13 changes: 2 additions & 11 deletions src/odr/internal/html/wvWare_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,11 @@ extern char *s_HTMLCONFIG;

namespace odr::internal::html {

Html wvWare_wrapper(const File &file, const std::string &output_path,
Html wvWare_wrapper(const std::string &input_path, const std::string &output_path,
const HtmlConfig &config) {
auto disk_path = file.disk_path();
if (!disk_path.has_value()) {
throw FileNotFound();
}

// @TODO: getenv()
// s_WVDATADIR = NULL;
// s_HTMLCONFIG = NULL;

auto output_file_path = output_path + "/document.html";

char *input_file_path = strdup(disk_path->c_str());
char *input_file_path = strdup(input_path.c_str());
char *output_dir = strdup(output_path.c_str());

g_htmlOutputFileHandle = fopen(output_file_path.c_str(), "w");
Expand Down
2 changes: 1 addition & 1 deletion src/odr/internal/html/wvWare_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Html;

namespace odr::internal::html {

Html wvWare_wrapper(const File &file, const std::string &output_path,
Html wvWare_wrapper(const std::string &input_path, const std::string &output_path,
const HtmlConfig &config);

}
Expand Down
8 changes: 4 additions & 4 deletions src/odr/open_document_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,18 +252,18 @@ Html OpenDocumentReader::html(const PdfFile &pdf_file,
}

#if defined(WITH_PDF2HTMLEX)
Html OpenDocumentReader::pdf2htmlEX(const PdfFile &pdf_file,
Html OpenDocumentReader::pdf2htmlEX(const std::string &input_path,
const std::string &output_path,
const HtmlConfig &config) {
return internal::html::pdf2htmlEX_wrapper(pdf_file, output_path, config);
return internal::html::pdf2htmlEX_wrapper(input_path, output_path, config);
}
#endif

#if defined(WITH_WVWARE)
Html OpenDocumentReader::wvHtml(const File &file,
Html OpenDocumentReader::wvHtml(const std::string &input_path,
const std::string &output_path,
const HtmlConfig &config) {
return internal::html::wvWare_wrapper(file, output_path, config);
return internal::html::wvWare_wrapper(input_path, output_path, config);
}
#endif

Expand Down
10 changes: 5 additions & 5 deletions src/odr/open_document_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,23 +143,23 @@ class OpenDocumentReader final {
#if defined(WITH_PDF2HTMLEX)
/// @brief Translates a PDF file to HTML using pdf2htmlEX.
///
/// @param pdf_file PDF file to translate.
/// @param input_path Path to the file to translate.
/// @param output_path Path to save the HTML output.
/// @param config Configuration for the HTML output.
/// @return HTML output.
[[nodiscard]] static Html pdf2htmlEX(const PdfFile &pdf_file,
[[nodiscard]] static Html pdf2htmlEX(const std::string &input_path,
const std::string &output_path,
const HtmlConfig &config);
#endif

#if defined(WITH_WVWARE)
/// @brief Translates a file to HTML.
/// @brief Translates a doc file to HTML using wvWare.
///
/// @param file File to translate.
/// @param input_path Path to the file to translate.
/// @param output_path Path to save the HTML output.
/// @param config Configuration for the HTML output.
/// @return HTML output.
[[nodiscard]] static Html wvHtml(const File &file,
[[nodiscard]] static Html wvHtml(const std::string &input_path,
const std::string &output_path,
const HtmlConfig &config);
#endif
Expand Down

0 comments on commit c385c8c

Please sign in to comment.