Skip to content

Commit

Permalink
ifdef feature switches
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand committed Dec 25, 2024
1 parent c526d71 commit ca0650f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ jobs:
-DCMAKE_CXX_FLAGS="-Werror"
-DCMAKE_INSTALL_PREFIX=install
-DODR_TEST=ON
-DWITH_PDF2HTMLEX=ON
-DWITH_WVWARE=ON
- name: cmake
if: runner.os == 'Windows'
Expand All @@ -82,6 +84,8 @@ jobs:
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=install
-DODR_TEST=ON
-DWITH_PDF2HTMLEX=OFF
-DWITH_WVWARE=OFF
- name: build
run: cmake --build build --config Release
Expand Down
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ if (WITH_PDF2HTMLEX)
pdf2htmlex::pdf2htmlex
poppler::poppler
)
target_compile_definitions(odr
PRIVATE
ODR_WITH_PDF2HTMLEX
)
endif ()
if (WITH_WVWARE)
find_package(wvware REQUIRED)
Expand All @@ -220,6 +224,10 @@ if (WITH_WVWARE)
PRIVATE
wvware::wvware
)
target_compile_definitions(odr
PRIVATE
ODR_WITH_WVWARE
)
endif ()

if (EXISTS "${PROJECT_SOURCE_DIR}/.git")
Expand Down
4 changes: 4 additions & 0 deletions src/odr/html.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,15 @@ Html html::translate(const DocumentFile &document_file,
const std::string &output_path, const HtmlConfig &config) {
auto document_file_impl = document_file.impl();

#ifdef ODR_WITH_WVWARE
if (auto wv_document_file =
std::dynamic_pointer_cast<internal::WvWareLegacyMicrosoftFile>(
document_file_impl)) {
fs::create_directories(output_path);
return internal::html::translate_wvware_oldms_file(*wv_document_file,
output_path, config);
}
#endif

return translate(document_file.document(), output_path, config);
}
Expand All @@ -123,12 +125,14 @@ Html html::translate(const PdfFile &pdf_file, const std::string &output_path,
const HtmlConfig &config) {
auto pdf_file_impl = pdf_file.impl();

#ifdef ODR_WITH_PDF2HTMLEX
if (auto poppler_pdf_file =
std::dynamic_pointer_cast<internal::PopplerPdfFile>(pdf_file_impl)) {
fs::create_directories(output_path);
return internal::html::translate_poppler_pdf_file(*poppler_pdf_file,
output_path, config);
}
#endif

return internal::html::translate_pdf_file(pdf_file, output_path, config);
}
Expand Down

0 comments on commit ca0650f

Please sign in to comment.