Skip to content

Commit 0545146

Browse files
authored
Cleanup for v5 (#408)
1 parent 90fb51c commit 0545146

6 files changed

Lines changed: 5 additions & 47 deletions

File tree

src/odr/exceptions.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ UnsupportedEndian::UnsupportedEndian()
6565
MsUnsupportedCryptoAlgorithm::MsUnsupportedCryptoAlgorithm()
6666
: std::runtime_error("unsupported crypto algorithm") {}
6767

68-
WrongPassword::WrongPassword() : std::runtime_error("wrong password") {}
69-
7068
UnknownDocumentType::UnknownDocumentType()
7169
: std::runtime_error("unknown document type") {}
7270

src/odr/exceptions.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,6 @@ struct MsUnsupportedCryptoAlgorithm final : public std::runtime_error {
137137
MsUnsupportedCryptoAlgorithm();
138138
};
139139

140-
/// @brief Wrong password exception
141-
struct WrongPassword final : public std::runtime_error {
142-
WrongPassword();
143-
};
144-
145140
/// @brief Unknown document type exception
146141
struct UnknownDocumentType final : public std::runtime_error {
147142
UnknownDocumentType();

src/odr/html.cpp

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <odr/document_path.hpp>
66
#include <odr/exceptions.hpp>
77
#include <odr/filesystem.hpp>
8+
#include <odr/global_params.hpp>
89

910
#include <odr/internal/html/document.hpp>
1011
#include <odr/internal/html/filesystem.hpp>
@@ -24,6 +25,8 @@ using namespace odr::internal;
2425

2526
namespace odr {
2627

28+
HtmlConfig::HtmlConfig() : resource_path{GlobalParams::odr_core_data_path()} {}
29+
2730
Html::Html(FileType file_type, HtmlConfig config, std::vector<HtmlPage> pages)
2831
: m_file_type{file_type}, m_config{std::move(config)},
2932
m_pages{std::move(pages)} {}
@@ -52,23 +55,6 @@ void Html::save(const std::string &path) const {
5255
HtmlPage::HtmlPage(std::string name, std::string path)
5356
: name{std::move(name)}, path{std::move(path)} {}
5457

55-
Html html::translate(const File &file, const std::string &output_path,
56-
const HtmlConfig &config,
57-
const PasswordCallback &password_callback) {
58-
auto decoded_file = DecodedFile(file);
59-
60-
if (decoded_file.is_document_file()) {
61-
DocumentFile document_file = decoded_file.document_file();
62-
if (document_file.password_encrypted()) {
63-
if (!document_file.decrypt(password_callback())) {
64-
throw WrongPassword();
65-
}
66-
}
67-
}
68-
69-
return translate(decoded_file, output_path, config);
70-
}
71-
7258
Html html::translate(const DecodedFile &decoded_file,
7359
const std::string &output_path, const HtmlConfig &config) {
7460
if (decoded_file.is_text_file()) {

src/odr/html.hpp

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ struct HtmlConfig {
6161
// formatting
6262
bool format_html{false};
6363
std::uint8_t html_indent{2};
64+
65+
HtmlConfig();
6466
};
6567

6668
/// @brief HTML output.
@@ -96,27 +98,8 @@ struct HtmlPage final {
9698
HtmlPage(std::string name, std::string path);
9799
};
98100

99-
/// @brief Callback to get the password for encrypted files.
100-
using PasswordCallback = std::function<std::string()>;
101-
102101
namespace html {
103102

104-
/// @brief Translates a file to HTML.
105-
///
106-
/// @deprecated This function is deprecated because it hides API which can be
107-
/// useful to the user like inspecting if a file is encrypted and if the
108-
/// password was wrong. Use `translate(const DecodedFile &, const std::string &,
109-
/// const HtmlConfig &)` instead.
110-
///
111-
/// @param file File to translate.
112-
/// @param output_path Path to save the HTML output.
113-
/// @param config Configuration for the HTML output.
114-
/// @param password_callback Callback to get the password for encrypted files.
115-
/// @return HTML output.
116-
[[deprecated]]
117-
Html translate(const File &file, const std::string &output_path,
118-
const HtmlConfig &config,
119-
const PasswordCallback &password_callback);
120103
/// @brief Translates a decoded file to HTML.
121104
///
122105
/// @param file Decoded file to translate.

src/odr/http_server.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ class HtmlService;
1414
class HttpServer {
1515
public:
1616
struct Config {
17-
std::size_t buffer_size{4096};
1817
std::string output_path{"/tmp"};
1918
};
2019

src/odr/odr.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ class PdfFile;
1919
class Html;
2020
struct HtmlConfig;
2121

22-
/// @brief Callback to get the password for encrypted files.
23-
using PasswordCallback = std::function<std::string()>;
24-
2522
/// @brief Get the version of the Open Document Reader library.
2623
/// @return The version of the Open Document Reader library.
2724
[[nodiscard]] std::string version() noexcept;

0 commit comments

Comments
 (0)