feat: bbox layout engine for docx/xlsx/pptx with ViewOptions infrastructure - #7
Open
Pilser wants to merge 6 commits into
Open
feat: bbox layout engine for docx/xlsx/pptx with ViewOptions infrastructure#7Pilser wants to merge 6 commits into
Pilser wants to merge 6 commits into
Conversation
added 6 commits
July 19, 2026 13:58
Major additions across all Office formats: Bbox/Layout Engine: - docx: new layout.rs — page dimensions, paragraph/table bbox computation (twip/EMU to pt) - docx/xlsx/pptx: push spans with bbox metadata for AI agent text-offset targeting - pptx: parse <a:xfrm> for shape bounding box (position/size EMU → pt) - xlsx: parse cols widths and row heights from sheet XML; cell bbox from layout Screenshot Range Crop (--range): - view.rs: new --range, --zoom, --padding flags to crop screenshots to element bbox - handle_screenshot_with_range: find element → get bbox from text offset map → crop Grid Contact Sheet (--grid): - view.rs: multi-page tiled thumbnail view using grid columns - Plumbed through handle_view and handle_screenshot Render Backend Selection (--render): - ViewOptions.render field (auto/native/html) threaded through all entry points Agent Skills CLI: - New 'skills' subcommand: list available skills, install to Claude/Cursor/Copilot/Windsurf/OpenCode - Scans skills/ directory, reads SKILL.md headers, installs to agent config dirs Infrastructure: - ViewOptions: added range, grid, render fields - MCP/resident/watch servers: thread range/grid/render params - AGENTS.md: CRITICAL RULE — no building by AI agents; code review mode guidelines
…table - Image add: accept 'file' property (not just 'src'/'path') — fixes 0-byte media - Table border: recognize 'all' shorthand (was falling through to empty) - Xlsx set cell: accept 'text' alias alongside 'value' - Multi-row table: fix rNcN text so each row gets unique content (was all rows same)
…_Types.xml insertion position Three bugs fixed: 1. Table borders used color="auto" which renders invisible in LibreOffice. Changed default to "000000" (black). Added borderColor/tblBorderColor/bdrColor properties so users can specify custom colors (e.g. borderColor=1F4E79). 2. Drawing XML templates (image + chart) used wp: prefix without declaring xmlns:wp — caused XML parse errors on subsequent set/add operations. Added xmlns:wp declaration to both templates. 3. Content_Types.xml update functions searched for first '>' in file, which matched the PHP/XML declaration '?>', not <Types>. Inserted Default/Override entries before <Types> instead of inside it — producing invalid XML that LibreOffice refused to open. Fixed by searching from <Types> element.
RainLib
requested changes
Jul 20, 2026
RainLib
left a comment
Owner
There was a problem hiding this comment.
当前版本暂不能合并,请在新的 head 提交后重新请求审核。
必须修正:
cargo fmt -- --check未通过,cargo clippy --all-targets -- -D warnings也存在 5 个错误;请先 rebase 最新main并确保两项通过。--range必须按 DOCX、XLSX、PPTX 的不同结构分别实现。当前 XLSX 使用Sheet1!A1:C3会被当作普通路径并报unknown property C3,不能用单一通用路径包装代替格式适配。XLSX 若缺少实现,请对齐source/OfficeCLI中的 XLSX 处理方式,但不要混用 DOCX/PPTX 的寻址逻辑。render参数目前只被传递,没有驱动实际渲染后端;grid的通用包装也无法对各格式产生正确分页/工作表网格。请实现真实行为或移除未实现的公开选项。- 本 PR 同时包含 bbox、表格、图片、分页、校验等多组独立修改,不符合仓库 One PR = one atomic change 规则;请拆成可独立验证的 PR。
- 为 DOCX、XLSX、PPTX 分别提供命令级 before/after 验证,不能只验证参数被 clap 接收。
完成以上修改并推送新 SHA 后,我会重新执行 fmt、clippy、全工作区测试和各格式命令验证;全部通过后再 Approve。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add bounding box metadata to text offset maps across all Office formats, enabling layout-aware text targeting for AI agents.
Features Added
layout.rs— page dimensions, paragraph/table bbox computation (twip/EMU → pt)<a:xfrm>for shape bounding box (position/size EMU → pt); include bbox in text offset spans<cols>widths and row heights from sheet XML; compute cell bbox from layoutrange,grid,renderfields; threaded through MCP/resident/watch--properties 'title=...'creates<w:tblCaption>--properties 'colWidths=180,120,100'sets gridCol widths in twipsofficecli set docx '/body/p[1]' pageBreak=trueofficecli validatedetects 0-byte media files--properties 'borderColor=1F4E79'(default: black)Bugs Fixed
add imagewithfile=: Only checkedsrc/pathbut CLI passesfile=— caused 0-byte images. Addedfilefallback in docx + pptx handlersborder=all: Fell through all match arms, producing empty<w:tblBorders/>. Added"all"shorthandset cell text=: Match arm only had"value", not"text"— caused "UNSUPPORTED props: text". Added"text"aliasrNcN: All rows got same text due to missing row counter. Fixed withfor row in 0..rows+format!("r{}c{}", row + 1, col_idx + 1)color="auto": LibreOffice rendersautoborders as invisible. Default changed to"000000". AddedborderColorproperty for custom colorsxmlns:wpmissing: Image/chart drawing templates usedwp:prefix without declaring it — caused XML parse errors on subsequentset/addafter inserting image[Content_Types].xmlmalformed:xml.find('>')matched XML declaration?>instead of<Types>— inserted entries BEFORE<Types>tag, producing invalid XML rejected by LibreOfficeValidation
Files Changed
18 files: layout.rs (new), text_offset.rs (3 formats), pptx navigation/dom_types, xlsx helpers/dom_types, output_format.rs, add.rs, mutations.rs, handler.rs, mcp/resident/watch