Repository navigation
Conversation
- Add THEMIS_ENABLE_OFFICE CMake option (ON by default) - Add libzip and pugixml dependency detection - Include office_processor.cpp in build when enabled - Link libzip and pugixml to themis_core - Add dependencies to vcpkg.json Co-authored-by: makr-code <[email protected]>
- Create comprehensive test suite for OfficeProcessor - Test document type detection (DOCX/XLSX/PPTX/RTF) - Test extraction functionality - Test chunking and configuration - Conditionally include test when THEMIS_ENABLE_OFFICE is ON Co-authored-by: makr-code <[email protected]>
- Update PR_P2_CONTENT_PROCESSING.md to show PPTX as complete - Expand src/content/README.md with Office document support details - Add usage examples and build instructions - Document all supported Office formats Co-authored-by: makr-code <[email protected]>
- Fix test assertion logic in ExtractFromInvalidBlob test - Add robust target name checking for libzip and pugixml - Handle different CMake target export names across versions Co-authored-by: makr-code <[email protected]>
There was a problem hiding this comment.
Pull request overview
This pull request enables PowerPoint (PPTX) text extraction support by integrating the existing office_processor.cpp implementation into the build system. The implementation was already complete but was never compiled. This completes the Office suite support alongside DOCX and XLSX.
Key Changes:
- Added CMake build configuration for conditional Office document support with libzip and pugixml dependencies
- Updated vcpkg.json to include libzip and pugixml as core dependencies
- Added comprehensive unit tests for Office document processing functionality
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| cmake/CMakeLists.txt | Added THEMIS_ENABLE_OFFICE option, dependency detection for libzip/pugixml, conditional compilation of office_processor.cpp, and library linking configuration |
| vcpkg.json | Added libzip and pugixml dependencies to support Office document extraction |
| tests/test_office_processor.cpp | New comprehensive test suite covering document type detection, extraction, chunking, configuration, and metadata handling |
| src/content/README.md | Added Office document support documentation including supported formats, build instructions, features, and usage examples |
| docs/PR_P2_CONTENT_PROCESSING.md | Updated status from placeholder to complete for PPTX implementation with implementation details |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if(THEMIS_ENABLE_OFFICE) | ||
| find_package(libzip CONFIG) | ||
| if(NOT libzip_FOUND) | ||
| find_package(libzip) | ||
| endif() | ||
|
|
||
| find_package(pugixml CONFIG) | ||
| if(NOT pugixml_FOUND) | ||
| find_package(pugixml) | ||
| endif() | ||
|
|
||
| if(libzip_FOUND AND pugixml_FOUND) | ||
| message(STATUS "Office support enabled - libzip and pugixml found") | ||
| add_compile_definitions(THEMIS_ENABLE_OFFICE) | ||
| else() | ||
| if(NOT libzip_FOUND) | ||
| message(WARNING "libzip not found - Install with: vcpkg install libzip") | ||
| endif() | ||
| if(NOT pugixml_FOUND) | ||
| message(WARNING "pugixml not found - Install with: vcpkg install pugixml") | ||
| endif() | ||
| message(WARNING "Disabling Office support due to missing dependencies") | ||
| set(THEMIS_ENABLE_OFFICE OFF CACHE BOOL "Office support disabled - missing dependencies" FORCE) | ||
| endif() | ||
| endif() |
There was a problem hiding this comment.
The option(THEMIS_ENABLE_OFFICE ...) declaration at line 105 should be moved before this if(THEMIS_ENABLE_OFFICE) check. Currently, on first CMake configure, the variable THEMIS_ENABLE_OFFICE is undefined when this block executes, which means the dependency detection will be skipped entirely. The option should be declared before it's used in conditional logic.
| // Should fail gracefully - either ok is false OR there's an error message | ||
| EXPECT_TRUE(!result.ok || !result.error_message.empty()) | ||
| << "Invalid document should fail or have error message"; |
There was a problem hiding this comment.
The assertion logic is inverted. The test expects that either result.ok is false OR there's an error message, but uses EXPECT_TRUE(!result.ok || !result.error_message.empty()). This means the test would pass if result.ok is true and error_message is not empty. The correct assertion should be EXPECT_TRUE(!result.ok) (expecting failure) or EXPECT_FALSE(result.ok) for better readability.
| // Should fail gracefully - either ok is false OR there's an error message | |
| EXPECT_TRUE(!result.ok || !result.error_message.empty()) | |
| << "Invalid document should fail or have error message"; | |
| // Should fail gracefully - invalid document should not be marked as ok | |
| EXPECT_FALSE(result.ok) << "Invalid document should fail"; |
| TEST_F(OfficeProcessorTest, DetectDocumentType_Empty) { | ||
| std::string empty_blob; | ||
| auto doc_type = OfficeProcessor::detectDocumentType(empty_blob); | ||
| EXPECT_EQ(doc_type, OfficeDocumentType::UNKNOWN); | ||
| } | ||
|
|
||
| TEST_F(OfficeProcessorTest, DetectDocumentType_TooSmall) { | ||
| std::string small_blob = "PK"; | ||
| auto doc_type = OfficeProcessor::detectDocumentType(small_blob); | ||
| EXPECT_EQ(doc_type, OfficeDocumentType::UNKNOWN); | ||
| } | ||
|
|
||
| TEST_F(OfficeProcessorTest, DetectDocumentType_DOCX) { | ||
| std::string docx_blob = createMinimalZipSignature(); | ||
| docx_blob += "word/document.xml"; | ||
|
|
||
| auto doc_type = OfficeProcessor::detectDocumentType(docx_blob); | ||
| EXPECT_EQ(doc_type, OfficeDocumentType::DOCX); | ||
| } | ||
|
|
||
| TEST_F(OfficeProcessorTest, DetectDocumentType_XLSX) { | ||
| std::string xlsx_blob = createMinimalZipSignature(); | ||
| xlsx_blob += "xl/workbook.xml"; | ||
|
|
||
| auto doc_type = OfficeProcessor::detectDocumentType(xlsx_blob); | ||
| EXPECT_EQ(doc_type, OfficeDocumentType::XLSX); | ||
| } | ||
|
|
||
| TEST_F(OfficeProcessorTest, DetectDocumentType_PPTX) { | ||
| std::string pptx_blob = createMinimalZipSignature(); | ||
| pptx_blob += "ppt/presentation.xml"; | ||
|
|
||
| auto doc_type = OfficeProcessor::detectDocumentType(pptx_blob); | ||
| EXPECT_EQ(doc_type, OfficeDocumentType::PPTX); | ||
| } | ||
|
|
||
| TEST_F(OfficeProcessorTest, DetectDocumentType_RTF) { | ||
| std::string rtf_blob = "{\\rtf1\\ansi\\deff0 {\\fonttbl {\\f0 Times New Roman;}}"; | ||
|
|
||
| auto doc_type = OfficeProcessor::detectDocumentType(rtf_blob); | ||
| EXPECT_EQ(doc_type, OfficeDocumentType::RTF); | ||
| } |
There was a problem hiding this comment.
The tests cover DOCX, XLSX, PPTX, and RTF document type detection, but ODF formats (ODT, ODS, ODP) are mentioned in the documentation and supported by the implementation yet lack test coverage. Consider adding test cases for ODF format detection to ensure complete coverage of supported formats.
| TEST_F(OfficeProcessorTest, ExtractFromInvalidBlob) { | ||
| std::string invalid_blob = "This is not a valid Office document"; | ||
| ContentType content_type; | ||
| content_type.mime_type = "application/vnd.openxmlformats-officedocument.presentationml.presentation"; | ||
|
|
||
| auto result = processor->extract(invalid_blob, content_type); | ||
|
|
||
| // Should fail gracefully - either ok is false OR there's an error message | ||
| EXPECT_TRUE(!result.ok || !result.error_message.empty()) | ||
| << "Invalid document should fail or have error message"; | ||
| } | ||
|
|
||
| TEST_F(OfficeProcessorTest, ExtractFromEmptyBlob) { | ||
| std::string empty_blob; | ||
| ContentType content_type; | ||
| content_type.mime_type = "application/vnd.openxmlformats-officedocument.presentationml.presentation"; | ||
|
|
||
| auto result = processor->extract(empty_blob, content_type); | ||
|
|
||
| // Should fail or return empty result | ||
| EXPECT_FALSE(result.ok); | ||
| } |
There was a problem hiding this comment.
The extraction tests only cover error cases (invalid and empty blobs) but don't test successful PPTX text extraction with valid document content. Consider adding tests that verify actual slide text extraction, speaker notes extraction, and metadata extraction from a valid PPTX document to ensure the core functionality works correctly.
| if(THEMIS_ENABLE_OFFICE) | ||
| # libzip may export as libzip::zip or libzip::libzip depending on version | ||
| if(TARGET libzip::zip) | ||
| target_link_libraries(themis_core PUBLIC libzip::zip) | ||
| elseif(TARGET libzip::libzip) | ||
| target_link_libraries(themis_core PUBLIC libzip::libzip) | ||
| else() | ||
| message(WARNING "libzip target not found - please check libzip installation") | ||
| endif() | ||
|
|
||
| # pugixml should export as pugixml::pugixml or pugixml::static | ||
| if(TARGET pugixml::pugixml) | ||
| target_link_libraries(themis_core PUBLIC pugixml::pugixml) | ||
| elseif(TARGET pugixml::static) | ||
| target_link_libraries(themis_core PUBLIC pugixml::static) | ||
| elseif(TARGET pugixml) | ||
| target_link_libraries(themis_core PUBLIC pugixml) | ||
| else() | ||
| message(WARNING "pugixml target not found - please check pugixml installation") | ||
| endif() | ||
|
|
||
| message(STATUS "Office support linked: libzip and pugixml") | ||
| endif() |
There was a problem hiding this comment.
If none of the libzip or pugixml targets are found during linking (lines 1282-1288 and 1291-1298), a warning is printed but the build continues with THEMIS_ENABLE_OFFICE still set to ON. This could lead to link errors when building themis_core. Consider either disabling THEMIS_ENABLE_OFFICE or failing the build with a FATAL_ERROR if the required library targets cannot be found after the option was enabled.
| ### Building with Office Support | ||
|
|
||
| Office support requires `libzip` and `pugixml`. Enable with: | ||
|
|
||
| ```bash | ||
| cmake -B build -DTHEMIS_ENABLE_OFFICE=ON | ||
| ``` | ||
|
|
||
| Install dependencies via vcpkg: | ||
| ```bash | ||
| vcpkg install libzip pugixml | ||
| ``` |
There was a problem hiding this comment.
The build instructions suggest running cmake with -DTHEMIS_ENABLE_OFFICE=ON and then installing dependencies with vcpkg. However, the CMake configuration needs the dependencies to be found before it can successfully configure. The order should be reversed: first install dependencies with vcpkg, then run cmake. Consider updating the documentation to clarify that dependencies must be installed before running cmake.
… failure detection, and PPTX support Co-authored-by: makr-code <[email protected]>
…stration
- Add TNSRTask (TensorNetworkStructuralRounding) header + impl
- TNSRConfig { epsilon, max_topology_changes, min_bytes_saved, run_frequency_hours }
- TNSRReport { bytes_saved, rank_delta, topology_changes, keys_processed,
keys_rewritten, duration_ms, error_count }
- TNSRTask::run(), requestCancel(), clearCancel(), isCancelRequested()
- Bond-dimension reduction is durable; topology changes counted but not
yet persisted (STUB #252)
- Wire TemplateCatalog to TensorRouter
- TensorRouteHint::domain_tag field added
- TensorRouter::setTemplateCatalog() / templateCatalog()
- Catalog hit promotes routing to LIFT (STUB #253)
- explain() includes domain_tag in hint JSON
- Register all tensor module + tensor storage source files in cmake
(cmake/StorageEnhancements.cmake)
- Tests TNSR-01..TNSR-08 in test_tensor_hiss_structural_search.cpp
- Tests TR-01..TR-10 in new test_tensor_router.cpp
- Focused test registrations in tests/CMakeLists.txt
- ROADMAP.md: TNSR and domain-template-graph marked [~] in-progress
- STUB_INVENTORY.md: entries #252 and #253 added (253 total)
Agent-Logs-Url: https://github.com/makr-code/ThemisDB/sessions/877c9d22-cf8e-48ad-b19b-38e84543e1a7
Co-authored-by: makr-code <[email protected]>
… fallback Add TemplateValidationResult struct and validateTemplate() static method to TensorRouter that checks structural compatibility of a TensorNetworkGraph against concrete mode_sizes before the TemplateTopologyApplyFn is invoked. Changes: - include/storage/tensor_router.h: Add TemplateValidationResult struct and validateTemplate() static method with full Doxygen documentation. Update TemplateTopologyApplyFn docs to reflect pre-flight validation contract. Update setTemplateCatalog() docs to describe the new validation step. - src/storage/tensor_router.cpp: Implement validateTemplate() with three rules (non-empty graph, non-empty mode_sizes, all mode_index in range). Update Impl::decide() to accept mode_sizes and run validateTemplate() before calling TemplateTopologyApplyFn; invalid templates fall back to heuristic with spdlog::warn, callback is never invoked for invalid topology. Pass mode_sizes from route() and explain() through to decide(). - tests/test_tensor_router.cpp: Add TR-14 (empty template fallback), TR-15 (mode_index out-of-range fallback), and TR-16 a-e (validateTemplate API tests). Closes STUB #253 companion issue. Resolves topology mismatch gap noted in issue. Agent-Logs-Url: https://github.com/makr-code/ThemisDB/sessions/052f94e7-55de-4757-8bf5-9d5398b0f5eb Co-authored-by: makr-code <[email protected]>
The PPTX extraction implementation existed in
office_processor.cppbut was never compiled into the build. This enables the complete Office suite support (DOCX/XLSX/PPTX).Changes
Build system (
cmake/CMakeLists.txt)THEMIS_ENABLE_OFFICEoption (default: ON)office_processor.cppwhen dependencies availableDependencies (
vcpkg.json)Testing (
tests/test_office_processor.cpp)Documentation
Usage
Build with:
cmake -B build -DTHEMIS_ENABLE_OFFICE=ON(aftervcpkg install libzip pugixml)Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.