Skip to content

Conversation

@LiHua000
Copy link
Contributor

@LiHua000 LiHua000 commented Nov 11, 2025

replace legacy parser with libgxps adapter

task: https://pms.uniontech.com/task-view-383459.html

- show PDF, DJVU, DOCX, XPS on the home page banner and app description
- include .xps in open dialog filters and desktop MimeType registration
- update EN/ZH manuals plus plan constraints to reflect XPS coverage
- refresh prompt instructions to avoid touching translation resources

Log: as title

task: https://pms.uniontech.com/task-view-383459.html
@LiHua000 LiHua000 force-pushed the xpsSupport branch 2 times, most recently from bc69483 to e650057 Compare November 12, 2025 01:47
detect libgxps/cairo/glib via pkg-config and auto-toggle XPS_SUPPORT
link reader target with gxps stack and propagate include/compile flags
declare runtime/build deps in debian control and linglong manifest
document clean reconfigure path to refresh resolved XPS availability

Log: as title

task: https://pms.uniontech.com/task-view-383459.html
- add XpsDocumentAdapter to manage libgxps/cairo handles via RAII
- remove the old manual XpsDocument implementation and update document.pri
- hook the adapter into DocumentFactory to load XPS files
- normalize parsed page sizes with gxps_page_get_size fallback
- clamp render task dimensions in BrowserPage/PageRenderThread to avoid blank frames

task:https://pms.uniontech.com/task-view-383459.html
@deepin-ci-robot
Copy link

deepin pr auto review

我来对这次代码变更进行审查,主要关注XPS文档支持的实现:

  1. 代码架构改进:
  • 将原来的XpsDocument替换为XpsDocumentAdapter,这是一个很好的设计决策。新的实现使用了libgxps库,而不是自己解析XPS格式,这样可以减少维护负担,提高稳定性。
  1. 依赖管理:
  • 在CMakeLists.txt中增加了对libgxps、cairo、glib-2.0等依赖的检测
  • 使用pkg_check_modules来检测依赖,这是一个好的实践
  • 依赖检测失败时会给出明确的警告信息
  1. 性能优化:
  • 使用了智能指针(GObjectPtr、CairoSurfacePtr等)来管理资源,避免内存泄漏
  • 实现了页面缓存机制(ensurePageCache)
  • 使用互斥锁(m_mutex)保护共享资源
  1. 安全性考虑:
  • 对文件路径和参数进行了有效性检查
  • 使用RAII管理资源,确保资源正确释放
  • 对GError进行了适当的错误处理
  1. 建议改进:
  • 在XpsDocumentAdapter::renderPage中,建议增加对width和height的最大值限制,防止过大的渲染请求导致内存问题
  • 可以考虑增加对XPS文件大小的检查,避免处理过大的文件
  • 在ensureProperties中,建议增加对异常情况的处理,如core properties解析失败时的fallback机制
  1. 代码质量:
  • 代码结构清晰,职责分离明确
  • 错误处理完善
  • 日志记录充分,便于调试
  • 使用了现代C++特性,如智能指针、移动语义等
  1. 其他建议:
  • 考虑增加对XPS文件版本的检查和兼容性处理
  • 可以考虑增加对加密XPS文件的支持
  • 在renderPage中可以考虑添加对DPI的支持,以获得更好的渲染质量

总体来说,这次代码变更质量较高,实现了XPS文档支持的同时,保持了代码的可维护性和稳定性。主要改进点在于使用了libgxps库替代了原有的自定义解析实现,这是一个明智的选择。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: LiHua000, lzwind

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@LiHua000
Copy link
Contributor Author

/forcemerge

@deepin-bot deepin-bot bot merged commit 9d2ce28 into linuxdeepin:master Nov 12, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants