Skip to content

Commit 17ae201

Browse files
committed
fixes and cleanup
1 parent f8b665e commit 17ae201

16 files changed

Lines changed: 41 additions & 64 deletions

src/odr/exceptions.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,7 @@ InvalidPrefix::InvalidPrefix() : std::runtime_error("invalid prefix string") {}
7676
InvalidPrefix::InvalidPrefix(const std::string &prefix)
7777
: std::runtime_error("invalid prefix string: " + prefix) {}
7878

79+
DocumentCopyProtectedException::DocumentCopyProtectedException()
80+
: std::runtime_error("document copy protection") {}
81+
7982
} // namespace odr

src/odr/exceptions.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,9 @@ struct InvalidPrefix final : public std::runtime_error {
149149
explicit InvalidPrefix(const std::string &prefix);
150150
};
151151

152+
/// @brief Document copy protected exception
153+
struct DocumentCopyProtectedException : public std::runtime_error {
154+
DocumentCopyProtectedException();
155+
};
156+
152157
} // namespace odr

src/odr/internal/html/document.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,9 @@ class PageHtmlFragment final : public HtmlFragmentBase {
410410

411411
namespace odr::internal {
412412

413-
HtmlService html::create_document_service(const Document &document,
414-
const std::string &output_path,
415-
const HtmlConfig &config) {
413+
odr::HtmlService html::create_document_service(const Document &document,
414+
const std::string &output_path,
415+
const HtmlConfig &config) {
416416
HtmlResourceLocator resource_locator =
417417
local_resource_locator(output_path, config);
418418

src/odr/internal/html/document.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ class HtmlService;
1010

1111
namespace odr::internal::html {
1212

13-
HtmlService create_document_service(const Document &document,
14-
const std::string &output_path,
15-
const HtmlConfig &config);
13+
odr::HtmlService create_document_service(const Document &document,
14+
const std::string &output_path,
15+
const HtmlConfig &config);
1616

1717
} // namespace odr::internal::html

src/odr/internal/html/filesystem.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ class HtmlServiceImpl : public HtmlService {
149149

150150
namespace odr::internal {
151151

152-
HtmlService html::create_filesystem_service(const Filesystem &filesystem,
153-
const std::string &output_path,
154-
const HtmlConfig &config) {
152+
odr::HtmlService html::create_filesystem_service(const Filesystem &filesystem,
153+
const std::string &output_path,
154+
const HtmlConfig &config) {
155155
HtmlResourceLocator resource_locator =
156156
local_resource_locator(output_path, config);
157157

src/odr/internal/html/filesystem.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class Filesystem;
1111

1212
namespace odr::internal::html {
1313

14-
HtmlService create_filesystem_service(const Filesystem &filesystem,
15-
const std::string &output_path,
16-
const HtmlConfig &config);
14+
odr::HtmlService create_filesystem_service(const Filesystem &filesystem,
15+
const std::string &output_path,
16+
const HtmlConfig &config);
1717

1818
}

src/odr/internal/html/image_file.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ void html::translate_image_src(const ImageFile &image_file, std::ostream &out,
141141
}
142142
}
143143

144-
HtmlService html::create_image_service(const ImageFile &image_file,
145-
const std::string &output_path,
146-
const HtmlConfig &config) {
144+
odr::HtmlService html::create_image_service(const ImageFile &image_file,
145+
const std::string &output_path,
146+
const HtmlConfig &config) {
147147
HtmlResourceLocator resource_locator =
148148
local_resource_locator(output_path, config);
149149

src/odr/internal/html/image_file.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ void translate_image_src(const File &file, std::ostream &out,
1616
void translate_image_src(const ImageFile &image_file, std::ostream &out,
1717
const HtmlConfig &config);
1818

19-
HtmlService create_image_service(const ImageFile &image_file,
20-
const std::string &output_path,
21-
const HtmlConfig &config);
19+
odr::HtmlService create_image_service(const ImageFile &image_file,
20+
const std::string &output_path,
21+
const HtmlConfig &config);
2222

2323
} // namespace odr::internal::html

src/odr/internal/html/pdf2htmlex_wrapper.cpp

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ html::create_poppler_pdf_service(const PopplerPdfFile &pdf_file,
301301

302302
if (!pdf_doc.okToCopy()) {
303303
if (html_renderer_param->no_drm == 0) {
304-
throw DocumentCopyProtectedException("");
304+
throw odr::DocumentCopyProtectedException();
305305
}
306306
}
307307

@@ -324,26 +324,4 @@ html::create_poppler_pdf_service(const PopplerPdfFile &pdf_file,
324324
resource_locator));
325325
}
326326

327-
Html html::translate_poppler_pdf_file(const PopplerPdfFile &pdf_file,
328-
const std::string &output_path,
329-
const HtmlConfig &config) {
330-
PDFDoc &pdf_doc = pdf_file.pdf_doc();
331-
332-
pdf2htmlEX::Param param = create_params(pdf_doc, config, output_path);
333-
334-
if (!pdf_doc.okToCopy()) {
335-
if (param.no_drm == 0) {
336-
throw DocumentCopyProtectedException("");
337-
}
338-
}
339-
340-
// TODO not sure what the `progPath` is used for. it cannot be `nullptr`
341-
// TODO potentially just a cache dir?
342-
pdf2htmlEX::HTMLRenderer(odr::GlobalParams::fontconfig_data_path().c_str(),
343-
param)
344-
.process(&pdf_doc);
345-
346-
return {config, {{"document", output_path + "/document.html"}}};
347-
}
348-
349327
} // namespace odr::internal

src/odr/internal/html/pdf2htmlex_wrapper.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,4 @@ odr::HtmlService create_poppler_pdf_service(const PopplerPdfFile &pdf_file,
1919
const std::string &output_path,
2020
const HtmlConfig &config);
2121

22-
Html translate_poppler_pdf_file(const PopplerPdfFile &pdf_file,
23-
const std::string &output_path,
24-
const HtmlConfig &config);
25-
26-
class DocumentCopyProtectedException : public std::runtime_error {
27-
public:
28-
using std::runtime_error::runtime_error;
29-
};
30-
3122
} // namespace odr::internal::html

0 commit comments

Comments
 (0)