feat(odt): nested containers and unique object names after cloning (#138) - #213
Merged
Merged
Conversation
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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
This is step 4 of OpenDocument Text support. It covers two areas:
DrawingIdAllocator(bug(loops): cloned loop content duplicates drawing/shape ids (docPr id, v:shape id); edge cases in table/cell detection #178).Part of #138
Design
See
docs/superpowers/specs/2026-09-26-odt-support-design.md, phase 4. This PR updates the spec.Nested containers already went through the same
ProcessContainerpath in PRs 1–3, and this PR adds tests for them. A text box or note inside a loop iteration is processed with that iteration's context. An emptied text box or header gets an empty paragraph.The new work is
OdtUniqueNames. Loop cloning copies these identifiers:draw:name(frames and shapes)table:nametext:nameof sectionstext:idof notesxml:idODF requires these to be unique. LibreOffice renames duplicate frames and tables on load, which breaks references to them, and duplicate
xml:ids make the document invalid.A single pass runs after processing, over the body plus headers and footers, which share one name space:
_2,_3, and so on, avoiding names that already exist.xml:ids are removed from the later copies. They only link RDF metadata, which belongs to the original.styles.xmlstays byte-for-byte unchanged unless it actually contains a duplicate.draw:namehandling was planned for PR 5 and has been moved into this PR, because all the name fixes belong in one pass.Conservative decision, documented in the spec: bookmark and annotation names are not renamed. They come in start/end pairs, LibreOffice tolerates duplicates, and DOCX does not rename loop-cloned bookmarks either.
Changes
OpenDocument/OdtUniqueNames(new, internal).OdtTemplateEngine.Processruns the uniqueness pass after the body and the headers/footers.The DOCX code is unchanged.
Tests
Odt/OdtContainerTests(10 tests):ClonedFramesTablesAndSections_KeepTheirUniqueNamesInLibreOffice. The processed document is loaded and saved again by LibreOffice. AfterwardsBox/Box_2,Prices/Prices_2andDetails/Details_2are still present unchanged, so LibreOffice accepted them without renaming, and the content converts to text.dotnet formatpass.Public API impact: additive
No new public symbols.
PublicAPI.*.txtis unchanged. The only behavior change is in the unreleasedOdtTemplateProcessor: duplicate object names in its output are made unique.