This is an automated email from the ASF dual-hosted git repository. asf-gitbox-commits pushed a commit to branch ms-odrawxml in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 2f2cd766f3b7820c014798fb87f3f695b468d03c Author: Pedro Giffuni <[email protected]> AuthorDate: Tue Dec 1 23:50:31 2026 -0500 oox: isolate selected MCE AlternateContent branches --- audit/ms-odrawxml-d5.7/SUMMARY.md | 101 ++++++++++ .../R01_eligible_choice_then_fallback.docx | Bin 0 -> 1523 bytes .../[Content_Types].xml | 6 + .../R01_eligible_choice_then_fallback/_rels/.rels | 4 + .../word/document.xml | 23 +++ .../R02_ineligible_then_eligible_choice.docx | Bin 0 -> 1533 bytes .../[Content_Types].xml | 6 + .../_rels/.rels | 4 + .../word/document.xml | 30 +++ .../R03_no_eligible_choice_then_fallback.docx | Bin 0 -> 1543 bytes .../[Content_Types].xml | 6 + .../_rels/.rels | 4 + .../word/document.xml | 30 +++ .../R04_no_eligible_choice_no_fallback.docx | Bin 0 -> 1534 bytes .../[Content_Types].xml | 6 + .../R04_no_eligible_choice_no_fallback/_rels/.rels | 4 + .../word/document.xml | 24 +++ .../fixtures/R05_multiple_eligible_choices.docx | Bin 0 -> 1539 bytes .../[Content_Types].xml | 6 + .../R05_multiple_eligible_choices/_rels/.rels | 4 + .../word/document.xml | 30 +++ .../R06_unknown_non_ignorable_in_unselected.docx | Bin 0 -> 1611 bytes .../[Content_Types].xml | 6 + .../_rels/.rels | 4 + .../word/document.xml | 25 +++ .../fixtures/R07_nested_in_unselected_choice.docx | Bin 0 -> 1635 bytes .../[Content_Types].xml | 6 + .../R07_nested_in_unselected_choice/_rels/.rels | 4 + .../word/document.xml | 40 ++++ .../fixtures/R08_nested_in_selected_choice.docx | Bin 0 -> 1621 bytes .../[Content_Types].xml | 6 + .../R08_nested_in_selected_choice/_rels/.rels | 4 + .../word/document.xml | 40 ++++ .../fixtures/R09_nested_in_fallback.docx | Bin 0 -> 1624 bytes .../R09_nested_in_fallback/[Content_Types].xml | 6 + .../fixtures/R09_nested_in_fallback/_rels/.rels | 4 + .../R09_nested_in_fallback/word/document.xml | 40 ++++ .../fixtures/R10_empty_choice_content.docx | Bin 0 -> 1542 bytes .../R10_empty_choice_content/[Content_Types].xml | 6 + .../fixtures/R10_empty_choice_content/_rels/.rels | 4 + .../R10_empty_choice_content/word/document.xml | 24 +++ .../R11_characters_whitespace_boundaries.docx | Bin 0 -> 1613 bytes .../[Content_Types].xml | 6 + .../_rels/.rels | 4 + .../word/document.xml | 38 ++++ audit/ms-odrawxml-d5.7/run_tests.sh | 117 ++++++++++++ audit/ms-odrawxml-d5.7/state-machine.md | 211 +++++++++++++++++++++ main/oox/inc/oox/core/mcealternatecontext.hxx | 12 +- main/oox/source/core/mcealternatecontext.cxx | 108 ++++++----- 49 files changed, 949 insertions(+), 54 deletions(-) diff --git a/audit/ms-odrawxml-d5.7/SUMMARY.md b/audit/ms-odrawxml-d5.7/SUMMARY.md new file mode 100644 index 0000000000..d64defd9b0 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/SUMMARY.md @@ -0,0 +1,101 @@ +# D.5.7: Correct AlternateContent Branch Isolation - Summary + +## Changes Made + +### 1. State Machine Documentation +Created `/home/pedro/projects/aoo/audit/ms-odrawxml-d5.7/state-machine.md` documenting: +- Current state definitions (STATE_INITIAL, STATE_CHOICE_SCAN, STATE_CHOICE_SELECTED, STATE_FALLBACK_SELECTED, STATE_DONE) +- Current state transitions and their defects +- Corrected state machine design with proper per-branch tracking +- Key defects identified: unknown element forwarding, nested AlternateContent in unselected branches, ProcessContent overriding branch selection + +### 2. Source Code Fixes + +#### `main/oox/inc/oox/core/mcealternatecontext.hxx` +- Added `mnCurrentBranchIndex` field to track which Choice/Fallback branch is currently being processed +- Added `mbInFallback` field to track if inside Fallback element + +#### `main/oox/source/core/mcealternatecontext.cxx` + +**Fixed `startFastElement` (lines 66-133):** +- Track `mnCurrentBranchIndex` when entering Choice/Fallback +- Only set `mbInSelectedBranch = true` when actually inside the selected branch (Choice with matching index, or selected Fallback) +- Removed ProcessContent override for branch selection - ProcessContent only applies within selected branch for ignorable namespaces +- Elements in unselected branches are completely discarded + +**Fixed `startUnknownElement` (lines 135-151):** +- Only forward unknown elements if `mbInSelectedBranch` is true +- Removed the bug where non-ignorable namespace elements in unselected branches were forwarded +- mc:Ignorable and mc:ProcessContent no longer override AlternateContent branch selection + +**Fixed `endFastElement` (lines 153-185):** +- Properly reset `mbInSelectedBranch`, `mnCurrentBranchIndex`, `mbInFallback` when leaving Choice/Fallback/AlternateContent +- Only forward end events if inside selected branch + +**Fixed `endUnknownElement` (lines 187-194):** +- Only forward if inside selected branch + +**Fixed `createFastChildContext` (lines 198-243):** +- **Critical fix**: Return null context for nested AlternateContent when NOT in selected branch +- This prevents nested AlternateContent in unselected branches from independently selecting and forwarding content +- Removed ProcessContent override for child context creation + +**Fixed `createUnknownChildContext` (lines 247-263):** +- Only forward if inside selected branch +- Removed Ignorable/ProcessContent overrides + +**Fixed `implEvaluateChoice` (lines 306-354):** +- No longer sets `mbInSelectedBranch` prematurely +- Only records the selection (index and state) +- Actual branch entry tracking happens in `startFastElement` + +**Fixed Constructor:** +- Initialize new fields `mnCurrentBranchIndex = -1`, `mbInFallback = false` + +### 3. Regression Test Fixtures (11 tests) + +Created in `/home/pedro/projects/aoo/audit/ms-odrawxml-d5.7/fixtures/`: + +| Test | Description | Expected Behavior | +|------|-------------|-------------------| +| R01 | Eligible Choice, then Fallback | Only Choice content appears | +| R02 | Ineligible Choice, then eligible Choice | Only 2nd Choice content appears | +| R03 | No eligible Choice, then Fallback | Only Fallback content appears | +| R04 | No eligible Choice, no Fallback | No content from AlternateContent | +| R05 | Multiple eligible Choices | First eligible Choice wins | +| R06 | Unknown non-ignorable in unselected branch | Suppressed (not forwarded) | +| R07 | Nested AlternateContent in unselected Choice | Entirely suppressed | +| R08 | Nested AlternateContent in selected Choice | Processed normally (nested Choice selected) | +| R09 | Nested AlternateContent in Fallback | Processed when Fallback selected | +| R10 | Empty Choice content | No output, continues after | +| R11 | Characters/whitespace at boundaries | Only in selected branch | + +### 4. Test Runner +Created `/home/pedro/projects/aoo/audit/ms-odrawxml-d5.7/run_tests.sh` to automate verification. + +## Key Corrections + +1. **Branch Selection vs Branch Entry**: Separated the decision of which branch is selected from the tracking of which branch we're currently inside. The `mbInSelectedBranch` flag is only true when actually inside the selected branch element. + +2. **Complete Suppression**: Unselected branches (Choice or Fallback) now have ALL content suppressed - elements, unknown elements, characters, nested AlternateContent, everything. + +3. **Nested AlternateContent Isolation**: A nested AlternateContent in an unselected branch returns a null context, preventing it from independently evaluating its own Choice/Fallback and leaking content. + +4. **ProcessContent Scope**: `mc:ProcessContent` is now correctly scoped to only apply within the selected branch for elements in ignorable namespaces. It no longer overrides AlternateContent branch selection. + +5. **End Event Balance**: End events are only forwarded if the corresponding start event was forwarded (i.e., we were in the selected branch). + +## Build Status +Full build initiated in background (process `bgp_2304000dd00140STCbtQX24zN3`). The build will compile all modules including `oox` and `writerfilter`. + +## Next Steps +1. Wait for build to complete +2. Run regression tests using `run_tests.sh` on Linux +3. Provide .docx fixtures to user for FreeBSD runtime testing (R01-R04, R14 priority) +4. Commit changes only after tests establish correct branch isolation + +## Remaining Known Issues (Outside D.5.7 Scope) +- RC6b: `SlideFragmentHandler` missing base MCE interception (delegate chain change excluded) +- RC6: `PresentationFragmentHandler` missing `p:presentationPr` handling +- RC4/RC5: `w14`/`p14`/`x15` unsupported in `MceProcessor` +- RC7: Calc R15 delegate chain/token/namespace hypotheses \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R01_eligible_choice_then_fallback.docx b/audit/ms-odrawxml-d5.7/fixtures/R01_eligible_choice_then_fallback.docx new file mode 100644 index 0000000000..fcd9a37ffb Binary files /dev/null and b/audit/ms-odrawxml-d5.7/fixtures/R01_eligible_choice_then_fallback.docx differ diff --git a/audit/ms-odrawxml-d5.7/fixtures/R01_eligible_choice_then_fallback/[Content_Types].xml b/audit/ms-odrawxml-d5.7/fixtures/R01_eligible_choice_then_fallback/[Content_Types].xml new file mode 100644 index 0000000000..c8f06fdc04 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R01_eligible_choice_then_fallback/[Content_Types].xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"> + <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/> + <Default Extension="xml" ContentType="application/xml"/> + <Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/> +</Types> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R01_eligible_choice_then_fallback/_rels/.rels b/audit/ms-odrawxml-d5.7/fixtures/R01_eligible_choice_then_fallback/_rels/.rels new file mode 100644 index 0000000000..917a8fea87 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R01_eligible_choice_then_fallback/_rels/.rels @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> + <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/> +</Relationships> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R01_eligible_choice_then_fallback/word/document.xml b/audit/ms-odrawxml-d5.7/fixtures/R01_eligible_choice_then_fallback/word/document.xml new file mode 100644 index 0000000000..feafb343cf --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R01_eligible_choice_then_fallback/word/document.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + mc:Ignorable="w14 wp14"> + <w:body> + <mc:AlternateContent> + <mc:Choice Requires="w"> + <w:p> + <w:r> + <w:t>ELIGIBLE_CHOICE_CONTENT</w:t> + </w:r> + </w:p> + </mc:Choice> + <mc:Fallback> + <w:p> + <w:r> + <w:t>FALLBACK_CONTENT_SHOULD_NOT_APPEAR</w:t> + </w:r> + </w:p> + </mc:Fallback> + </mc:AlternateContent> + </w:body> +</w:document> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R02_ineligible_then_eligible_choice.docx b/audit/ms-odrawxml-d5.7/fixtures/R02_ineligible_then_eligible_choice.docx new file mode 100644 index 0000000000..6cebf5a928 Binary files /dev/null and b/audit/ms-odrawxml-d5.7/fixtures/R02_ineligible_then_eligible_choice.docx differ diff --git a/audit/ms-odrawxml-d5.7/fixtures/R02_ineligible_then_eligible_choice/[Content_Types].xml b/audit/ms-odrawxml-d5.7/fixtures/R02_ineligible_then_eligible_choice/[Content_Types].xml new file mode 100644 index 0000000000..c8f06fdc04 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R02_ineligible_then_eligible_choice/[Content_Types].xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"> + <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/> + <Default Extension="xml" ContentType="application/xml"/> + <Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/> +</Types> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R02_ineligible_then_eligible_choice/_rels/.rels b/audit/ms-odrawxml-d5.7/fixtures/R02_ineligible_then_eligible_choice/_rels/.rels new file mode 100644 index 0000000000..917a8fea87 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R02_ineligible_then_eligible_choice/_rels/.rels @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> + <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/> +</Relationships> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R02_ineligible_then_eligible_choice/word/document.xml b/audit/ms-odrawxml-d5.7/fixtures/R02_ineligible_then_eligible_choice/word/document.xml new file mode 100644 index 0000000000..1e053c49a2 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R02_ineligible_then_eligible_choice/word/document.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + mc:Ignorable="w14 wp14"> + <w:body> + <mc:AlternateContent> + <mc:Choice Requires="w14"> + <w:p> + <w:r> + <w:t>INELIGIBLE_CHOICE_CONTENT_SHOULD_NOT_APPEAR</w:t> + </w:r> + </w:p> + </mc:Choice> + <mc:Choice Requires="w"> + <w:p> + <w:r> + <w:t>ELIGIBLE_CHOICE_CONTENT</w:t> + </w:r> + </w:p> + </mc:Choice> + <mc:Fallback> + <w:p> + <w:r> + <w:t>FALLBACK_CONTENT_SHOULD_NOT_APPEAR</w:t> + </w:r> + </w:p> + </mc:Fallback> + </mc:AlternateContent> + </w:body> +</w:document> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R03_no_eligible_choice_then_fallback.docx b/audit/ms-odrawxml-d5.7/fixtures/R03_no_eligible_choice_then_fallback.docx new file mode 100644 index 0000000000..7525f74f29 Binary files /dev/null and b/audit/ms-odrawxml-d5.7/fixtures/R03_no_eligible_choice_then_fallback.docx differ diff --git a/audit/ms-odrawxml-d5.7/fixtures/R03_no_eligible_choice_then_fallback/[Content_Types].xml b/audit/ms-odrawxml-d5.7/fixtures/R03_no_eligible_choice_then_fallback/[Content_Types].xml new file mode 100644 index 0000000000..c8f06fdc04 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R03_no_eligible_choice_then_fallback/[Content_Types].xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"> + <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/> + <Default Extension="xml" ContentType="application/xml"/> + <Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/> +</Types> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R03_no_eligible_choice_then_fallback/_rels/.rels b/audit/ms-odrawxml-d5.7/fixtures/R03_no_eligible_choice_then_fallback/_rels/.rels new file mode 100644 index 0000000000..917a8fea87 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R03_no_eligible_choice_then_fallback/_rels/.rels @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> + <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/> +</Relationships> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R03_no_eligible_choice_then_fallback/word/document.xml b/audit/ms-odrawxml-d5.7/fixtures/R03_no_eligible_choice_then_fallback/word/document.xml new file mode 100644 index 0000000000..90e02be39d --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R03_no_eligible_choice_then_fallback/word/document.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + mc:Ignorable="w14 wp14"> + <w:body> + <mc:AlternateContent> + <mc:Choice Requires="w14"> + <w:p> + <w:r> + <w:t>INELIGIBLE_CHOICE_CONTENT_SHOULD_NOT_APPEAR</w:t> + </w:r> + </w:p> + </mc:Choice> + <mc:Choice Requires="wp14"> + <w:p> + <w:r> + <w:t>SECOND_INELIGIBLE_CHOICE_SHOULD_NOT_APPEAR</w:t> + </w:r> + </w:p> + </mc:Choice> + <mc:Fallback> + <w:p> + <w:r> + <w:t>FALLBACK_CONTENT</w:t> + </w:r> + </w:p> + </mc:Fallback> + </mc:AlternateContent> + </w:body> +</w:document> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R04_no_eligible_choice_no_fallback.docx b/audit/ms-odrawxml-d5.7/fixtures/R04_no_eligible_choice_no_fallback.docx new file mode 100644 index 0000000000..ca85b97a9f Binary files /dev/null and b/audit/ms-odrawxml-d5.7/fixtures/R04_no_eligible_choice_no_fallback.docx differ diff --git a/audit/ms-odrawxml-d5.7/fixtures/R04_no_eligible_choice_no_fallback/[Content_Types].xml b/audit/ms-odrawxml-d5.7/fixtures/R04_no_eligible_choice_no_fallback/[Content_Types].xml new file mode 100644 index 0000000000..c8f06fdc04 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R04_no_eligible_choice_no_fallback/[Content_Types].xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"> + <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/> + <Default Extension="xml" ContentType="application/xml"/> + <Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/> +</Types> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R04_no_eligible_choice_no_fallback/_rels/.rels b/audit/ms-odrawxml-d5.7/fixtures/R04_no_eligible_choice_no_fallback/_rels/.rels new file mode 100644 index 0000000000..917a8fea87 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R04_no_eligible_choice_no_fallback/_rels/.rels @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> + <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/> +</Relationships> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R04_no_eligible_choice_no_fallback/word/document.xml b/audit/ms-odrawxml-d5.7/fixtures/R04_no_eligible_choice_no_fallback/word/document.xml new file mode 100644 index 0000000000..e99454a4b7 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R04_no_eligible_choice_no_fallback/word/document.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + mc:Ignorable="w14 wp14"> + <w:body> + <mc:AlternateContent> + <mc:Choice Requires="w14"> + <w:p> + <w:r> + <w:t>INELIGIBLE_CHOICE_CONTENT_SHOULD_NOT_APPEAR</w:t> + </w:r> + </w:p> + </mc:Choice> + <mc:Choice Requires="wp14"> + <w:p> + <w:r> + <w:t>SECOND_INELIGIBLE_CHOICE_SHOULD_NOT_APPEAR</w:t> + </w:r> + </w:p> + </mc:Choice> + <!-- No Fallback --> + </mc:AlternateContent> + </w:body> +</w:document> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R05_multiple_eligible_choices.docx b/audit/ms-odrawxml-d5.7/fixtures/R05_multiple_eligible_choices.docx new file mode 100644 index 0000000000..b6ddfbe99a Binary files /dev/null and b/audit/ms-odrawxml-d5.7/fixtures/R05_multiple_eligible_choices.docx differ diff --git a/audit/ms-odrawxml-d5.7/fixtures/R05_multiple_eligible_choices/[Content_Types].xml b/audit/ms-odrawxml-d5.7/fixtures/R05_multiple_eligible_choices/[Content_Types].xml new file mode 100644 index 0000000000..c8f06fdc04 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R05_multiple_eligible_choices/[Content_Types].xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"> + <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/> + <Default Extension="xml" ContentType="application/xml"/> + <Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/> +</Types> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R05_multiple_eligible_choices/_rels/.rels b/audit/ms-odrawxml-d5.7/fixtures/R05_multiple_eligible_choices/_rels/.rels new file mode 100644 index 0000000000..917a8fea87 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R05_multiple_eligible_choices/_rels/.rels @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> + <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/> +</Relationships> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R05_multiple_eligible_choices/word/document.xml b/audit/ms-odrawxml-d5.7/fixtures/R05_multiple_eligible_choices/word/document.xml new file mode 100644 index 0000000000..afd65ed374 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R05_multiple_eligible_choices/word/document.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + mc:Ignorable="w14 wp14"> + <w:body> + <mc:AlternateContent> + <mc:Choice Requires="w"> + <w:p> + <w:r> + <w:t>FIRST_ELIGIBLE_CHOICE_CONTENT</w:t> + </w:r> + </w:p> + </mc:Choice> + <mc:Choice Requires="w"> + <w:p> + <w:r> + <w:t>SECOND_ELIGIBLE_CHOICE_SHOULD_NOT_APPEAR</w:t> + </w:r> + </w:p> + </mc:Choice> + <mc:Fallback> + <w:p> + <w:r> + <w:t>FALLBACK_CONTENT_SHOULD_NOT_APPEAR</w:t> + </w:r> + </w:p> + </mc:Fallback> + </mc:AlternateContent> + </w:body> +</w:document> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R06_unknown_non_ignorable_in_unselected.docx b/audit/ms-odrawxml-d5.7/fixtures/R06_unknown_non_ignorable_in_unselected.docx new file mode 100644 index 0000000000..59a7febf0f Binary files /dev/null and b/audit/ms-odrawxml-d5.7/fixtures/R06_unknown_non_ignorable_in_unselected.docx differ diff --git a/audit/ms-odrawxml-d5.7/fixtures/R06_unknown_non_ignorable_in_unselected/[Content_Types].xml b/audit/ms-odrawxml-d5.7/fixtures/R06_unknown_non_ignorable_in_unselected/[Content_Types].xml new file mode 100644 index 0000000000..c8f06fdc04 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R06_unknown_non_ignorable_in_unselected/[Content_Types].xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"> + <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/> + <Default Extension="xml" ContentType="application/xml"/> + <Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/> +</Types> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R06_unknown_non_ignorable_in_unselected/_rels/.rels b/audit/ms-odrawxml-d5.7/fixtures/R06_unknown_non_ignorable_in_unselected/_rels/.rels new file mode 100644 index 0000000000..917a8fea87 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R06_unknown_non_ignorable_in_unselected/_rels/.rels @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> + <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/> +</Relationships> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R06_unknown_non_ignorable_in_unselected/word/document.xml b/audit/ms-odrawxml-d5.7/fixtures/R06_unknown_non_ignorable_in_unselected/word/document.xml new file mode 100644 index 0000000000..82e3ab2bf6 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R06_unknown_non_ignorable_in_unselected/word/document.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + mc:Ignorable="w14 wp14"> + <w:body> + <mc:AlternateContent> + <mc:Choice Requires="w14"> + <!-- Unknown element in non-ignorable namespace (not w or w14) - should be suppressed --> + <unknown:element xmlns:unknown="http://example.com/unknown">UNKNOWN_CONTENT_SHOULD_NOT_APPEAR</unknown:element> + <w:p> + <w:r> + <w:t>CHOICE_CONTENT_SHOULD_NOT_APPEAR</w:t> + </w:r> + </w:p> + </mc:Choice> + <mc:Choice Requires="w"> + <w:p> + <w:r> + <w:t>ELIGIBLE_CHOICE_CONTENT</w:t> + </w:r> + </w:p> + </mc:Choice> + </mc:AlternateContent> + </w:body> +</w:document> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R07_nested_in_unselected_choice.docx b/audit/ms-odrawxml-d5.7/fixtures/R07_nested_in_unselected_choice.docx new file mode 100644 index 0000000000..78dffd037d Binary files /dev/null and b/audit/ms-odrawxml-d5.7/fixtures/R07_nested_in_unselected_choice.docx differ diff --git a/audit/ms-odrawxml-d5.7/fixtures/R07_nested_in_unselected_choice/[Content_Types].xml b/audit/ms-odrawxml-d5.7/fixtures/R07_nested_in_unselected_choice/[Content_Types].xml new file mode 100644 index 0000000000..c8f06fdc04 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R07_nested_in_unselected_choice/[Content_Types].xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"> + <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/> + <Default Extension="xml" ContentType="application/xml"/> + <Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/> +</Types> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R07_nested_in_unselected_choice/_rels/.rels b/audit/ms-odrawxml-d5.7/fixtures/R07_nested_in_unselected_choice/_rels/.rels new file mode 100644 index 0000000000..917a8fea87 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R07_nested_in_unselected_choice/_rels/.rels @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> + <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/> +</Relationships> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R07_nested_in_unselected_choice/word/document.xml b/audit/ms-odrawxml-d5.7/fixtures/R07_nested_in_unselected_choice/word/document.xml new file mode 100644 index 0000000000..c928332da9 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R07_nested_in_unselected_choice/word/document.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + mc:Ignorable="w14 wp14"> + <w:body> + <mc:AlternateContent> + <mc:Choice Requires="w14"> + <w:p> + <w:r> + <w:t>UNSELECTED_CHOICE_CONTENT_SHOULD_NOT_APPEAR</w:t> + </w:r> + </w:p> + <!-- Nested AlternateContent in unselected branch - should be entirely suppressed --> + <mc:AlternateContent> + <mc:Choice Requires="w"> + <w:p> + <w:r> + <w:t>NESTED_IN_UNSELECTED_SHOULD_NOT_APPEAR</w:t> + </w:r> + </w:p> + </mc:Choice> + <mc:Fallback> + <w:p> + <w:r> + <w:t>NESTED_FALLBACK_IN_UNSELECTED_SHOULD_NOT_APPEAR</w:t> + </w:r> + </w:p> + </mc:Fallback> + </mc:AlternateContent> + </mc:Choice> + <mc:Choice Requires="w"> + <w:p> + <w:r> + <w:t>ELIGIBLE_CHOICE_CONTENT</w:t> + </w:r> + </w:p> + </mc:Choice> + </mc:AlternateContent> + </w:body> +</w:document> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R08_nested_in_selected_choice.docx b/audit/ms-odrawxml-d5.7/fixtures/R08_nested_in_selected_choice.docx new file mode 100644 index 0000000000..6f9e8f0a30 Binary files /dev/null and b/audit/ms-odrawxml-d5.7/fixtures/R08_nested_in_selected_choice.docx differ diff --git a/audit/ms-odrawxml-d5.7/fixtures/R08_nested_in_selected_choice/[Content_Types].xml b/audit/ms-odrawxml-d5.7/fixtures/R08_nested_in_selected_choice/[Content_Types].xml new file mode 100644 index 0000000000..c8f06fdc04 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R08_nested_in_selected_choice/[Content_Types].xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"> + <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/> + <Default Extension="xml" ContentType="application/xml"/> + <Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/> +</Types> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R08_nested_in_selected_choice/_rels/.rels b/audit/ms-odrawxml-d5.7/fixtures/R08_nested_in_selected_choice/_rels/.rels new file mode 100644 index 0000000000..917a8fea87 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R08_nested_in_selected_choice/_rels/.rels @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> + <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/> +</Relationships> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R08_nested_in_selected_choice/word/document.xml b/audit/ms-odrawxml-d5.7/fixtures/R08_nested_in_selected_choice/word/document.xml new file mode 100644 index 0000000000..e2548b1073 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R08_nested_in_selected_choice/word/document.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + mc:Ignorable="w14 wp14"> + <w:body> + <mc:AlternateContent> + <mc:Choice Requires="w"> + <w:p> + <w:r> + <w:t>SELECTED_CHOICE_CONTENT</w:t> + </w:r> + </w:p> + <!-- Nested AlternateContent in selected branch - should be processed normally --> + <mc:AlternateContent> + <mc:Choice Requires="w"> + <w:p> + <w:r> + <w:t>NESTED_IN_SELECTED_CONTENT</w:t> + </w:r> + </w:p> + </mc:Choice> + <mc:Fallback> + <w:p> + <w:r> + <w:t>NESTED_FALLBACK_IN_SELECTED_SHOULD_NOT_APPEAR</w:t> + </w:r> + </w:p> + </mc:Fallback> + </mc:AlternateContent> + </mc:Choice> + <mc:Fallback> + <w:p> + <w:r> + <w:t>FALLBACK_SHOULD_NOT_APPEAR</w:t> + </w:r> + </w:p> + </mc:Fallback> + </mc:AlternateContent> + </w:body> +</w:document> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R09_nested_in_fallback.docx b/audit/ms-odrawxml-d5.7/fixtures/R09_nested_in_fallback.docx new file mode 100644 index 0000000000..eeb185dfac Binary files /dev/null and b/audit/ms-odrawxml-d5.7/fixtures/R09_nested_in_fallback.docx differ diff --git a/audit/ms-odrawxml-d5.7/fixtures/R09_nested_in_fallback/[Content_Types].xml b/audit/ms-odrawxml-d5.7/fixtures/R09_nested_in_fallback/[Content_Types].xml new file mode 100644 index 0000000000..c8f06fdc04 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R09_nested_in_fallback/[Content_Types].xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"> + <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/> + <Default Extension="xml" ContentType="application/xml"/> + <Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/> +</Types> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R09_nested_in_fallback/_rels/.rels b/audit/ms-odrawxml-d5.7/fixtures/R09_nested_in_fallback/_rels/.rels new file mode 100644 index 0000000000..917a8fea87 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R09_nested_in_fallback/_rels/.rels @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> + <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/> +</Relationships> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R09_nested_in_fallback/word/document.xml b/audit/ms-odrawxml-d5.7/fixtures/R09_nested_in_fallback/word/document.xml new file mode 100644 index 0000000000..5bf9c6436e --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R09_nested_in_fallback/word/document.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + mc:Ignorable="w14 wp14"> + <w:body> + <mc:AlternateContent> + <mc:Choice Requires="w14"> + <w:p> + <w:r> + <w:t>UNSELECTED_CHOICE_SHOULD_NOT_APPEAR</w:t> + </w:r> + </w:p> + </mc:Choice> + <mc:Fallback> + <w:p> + <w:r> + <w:t>FALLBACK_CONTENT</w:t> + </w:r> + </w:p> + <!-- Nested AlternateContent in Fallback - should be processed when Fallback selected --> + <mc:AlternateContent> + <mc:Choice Requires="w"> + <w:p> + <w:r> + <w:t>NESTED_IN_FALLBACK_CONTENT</w:t> + </w:r> + </w:p> + </mc:Choice> + <mc:Fallback> + <w:p> + <w:r> + <w:t>NESTED_FALLBACK_IN_FALLBACK_SHOULD_NOT_APPEAR</w:t> + </w:r> + </w:p> + </mc:Fallback> + </mc:AlternateContent> + </mc:Fallback> + </mc:AlternateContent> + </w:body> +</w:document> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R10_empty_choice_content.docx b/audit/ms-odrawxml-d5.7/fixtures/R10_empty_choice_content.docx new file mode 100644 index 0000000000..a6f7f1ca92 Binary files /dev/null and b/audit/ms-odrawxml-d5.7/fixtures/R10_empty_choice_content.docx differ diff --git a/audit/ms-odrawxml-d5.7/fixtures/R10_empty_choice_content/[Content_Types].xml b/audit/ms-odrawxml-d5.7/fixtures/R10_empty_choice_content/[Content_Types].xml new file mode 100644 index 0000000000..c8f06fdc04 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R10_empty_choice_content/[Content_Types].xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"> + <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/> + <Default Extension="xml" ContentType="application/xml"/> + <Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/> +</Types> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R10_empty_choice_content/_rels/.rels b/audit/ms-odrawxml-d5.7/fixtures/R10_empty_choice_content/_rels/.rels new file mode 100644 index 0000000000..917a8fea87 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R10_empty_choice_content/_rels/.rels @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> + <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/> +</Relationships> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R10_empty_choice_content/word/document.xml b/audit/ms-odrawxml-d5.7/fixtures/R10_empty_choice_content/word/document.xml new file mode 100644 index 0000000000..4604e43cf5 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R10_empty_choice_content/word/document.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + mc:Ignorable="w14 wp14"> + <w:body> + <mc:AlternateContent> + <mc:Choice Requires="w"> + <!-- Empty Choice content --> + </mc:Choice> + <mc:Fallback> + <w:p> + <w:r> + <w:t>FALLBACK_SHOULD_NOT_APPEAR</w:t> + </w:r> + </w:p> + </mc:Fallback> + </mc:AlternateContent> + <w:p> + <w:r> + <w:t>AFTER_EMPTY_CHOICE</w:t> + </w:r> + </w:p> + </w:body> +</w:document> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R11_characters_whitespace_boundaries.docx b/audit/ms-odrawxml-d5.7/fixtures/R11_characters_whitespace_boundaries.docx new file mode 100644 index 0000000000..fa6f075957 Binary files /dev/null and b/audit/ms-odrawxml-d5.7/fixtures/R11_characters_whitespace_boundaries.docx differ diff --git a/audit/ms-odrawxml-d5.7/fixtures/R11_characters_whitespace_boundaries/[Content_Types].xml b/audit/ms-odrawxml-d5.7/fixtures/R11_characters_whitespace_boundaries/[Content_Types].xml new file mode 100644 index 0000000000..c8f06fdc04 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R11_characters_whitespace_boundaries/[Content_Types].xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"> + <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/> + <Default Extension="xml" ContentType="application/xml"/> + <Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/> +</Types> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R11_characters_whitespace_boundaries/_rels/.rels b/audit/ms-odrawxml-d5.7/fixtures/R11_characters_whitespace_boundaries/_rels/.rels new file mode 100644 index 0000000000..917a8fea87 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R11_characters_whitespace_boundaries/_rels/.rels @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> + <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/> +</Relationships> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/fixtures/R11_characters_whitespace_boundaries/word/document.xml b/audit/ms-odrawxml-d5.7/fixtures/R11_characters_whitespace_boundaries/word/document.xml new file mode 100644 index 0000000000..21fb130eda --- /dev/null +++ b/audit/ms-odrawxml-d5.7/fixtures/R11_characters_whitespace_boundaries/word/document.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + mc:Ignorable="w14 wp14"> + <w:body> + <mc:AlternateContent> + <mc:Choice Requires="w14"> + Whitespace and characters in unselected Choice: SHOULD_NOT_APPEAR + <w:p> + <w:r> + <w:t>CHOICE_CONTENT_SHOULD_NOT_APPEAR</w:t> + </w:r> + </w:p> + </mc:Choice> + <mc:Choice Requires="w"> + <w:p> + <w:r> + <w:t>ELIGIBLE_CHOICE_CONTENT</w:t> + </w:r> + </w:p> + Characters in selected Choice: SHOULD_APPEAR + </mc:Choice> + <mc:Fallback> + Whitespace and characters in Fallback: SHOULD_NOT_APPEAR + <w:p> + <w:r> + <w:t>FALLBACK_CONTENT_SHOULD_NOT_APPEAR</w:t> + </w:r> + </w:p> + </mc:Fallback> + </mc:AlternateContent> + <w:p> + <w:r> + <w:t>AFTER_ALTERNATE_CONTENT</w:t> + </w:r> + </w:p> + </w:body> +</w:document> \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/run_tests.sh b/audit/ms-odrawxml-d5.7/run_tests.sh new file mode 100755 index 0000000000..43e4c87e53 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/run_tests.sh @@ -0,0 +1,117 @@ +#!/bin/bash +# D.5.7 Regression Test Runner +# Tests AlternateContent branch isolation + +set -e + +FIXTURES_DIR="/home/pedro/projects/aoo/audit/ms-odrawxml-d5.7/fixtures" +RESULTS_DIR="/home/pedro/projects/aoo/audit/ms-odrawxml-d5.7/results" + +mkdir -p "$RESULTS_DIR" + +# Function to extract text from docx using unzip and xmlstarlet +extract_text() { + local docx="$1" + local output="$2" + unzip -p "$docx" word/document.xml 2>/dev/null | \ + xmllint --xpath '//w:t/text()' - 2>/dev/null | \ + sed 's/<[^>]*>//g' | tr -d '\n' > "$output" +} + +# Function to run a test +run_test() { + local test_name="$1" + local expected_contains="$2" + local expected_not_contains="$3" + local docx="$FIXTURES_DIR/${test_name}.docx" + local result_file="$RESULTS_DIR/${test_name}.txt" + + echo "Testing $test_name..." + extract_text "$docx" "$result_file" + + local content=$(cat "$result_file") + local pass=true + + if [ -n "$expected_contains" ]; then + if [[ "$content" != *"$expected_contains"* ]]; then + echo " FAIL: Expected to contain '$expected_contains'" + pass=false + else + echo " PASS: Contains '$expected_contains'" + fi + fi + + if [ -n "$expected_not_contains" ]; then + if [[ "$content" == *"$expected_not_contains"* ]]; then + echo " FAIL: Should not contain '$expected_not_contains'" + pass=false + else + echo " PASS: Does not contain '$expected_not_contains'" + fi + fi + + if [ "$pass" = true ]; then + echo " RESULT: PASS" + echo "PASS" > "$RESULTS_DIR/${test_name}.result" + else + echo " RESULT: FAIL" + echo "FAIL" > "$RESULTS_DIR/${test_name}.result" + fi + + echo " Extracted text: $content" + echo "" +} + +echo "========================================" +echo "D.5.7 AlternateContent Branch Isolation Tests" +echo "========================================" +echo "" + +# R01: Eligible Choice, then Fallback +run_test "R01_eligible_choice_then_fallback" "ELIGIBLE_CHOICE_CONTENT" "FALLBACK_CONTENT_SHOULD_NOT_APPEAR" + +# R02: Ineligible Choice, then eligible Choice +run_test "R02_ineligible_then_eligible_choice" "ELIGIBLE_CHOICE_CONTENT" "INELIGIBLE_CHOICE_CONTENT_SHOULD_NOT_APPEAR" + +# R03: No eligible Choice, then Fallback +run_test "R03_no_eligible_choice_then_fallback" "FALLBACK_CONTENT" "INELIGIBLE_CHOICE_CONTENT_SHOULD_NOT_APPEAR" + +# R04: No eligible Choice, no Fallback +run_test "R04_no_eligible_choice_no_fallback" "" "INELIGIBLE_CHOICE_CONTENT_SHOULD_NOT_APPEAR" + +# R05: Multiple eligible Choices - first wins +run_test "R05_multiple_eligible_choices" "FIRST_ELIGIBLE_CHOICE_CONTENT" "SECOND_ELIGIBLE_CHOICE_SHOULD_NOT_APPEAR" + +# R06: Unknown non-ignorable in unselected branch +run_test "R06_unknown_non_ignorable_in_unselected" "ELIGIBLE_CHOICE_CONTENT" "UNKNOWN_CONTENT_SHOULD_NOT_APPEAR" + +# R07: Nested AlternateContent in unselected Choice +run_test "R07_nested_in_unselected_choice" "ELIGIBLE_CHOICE_CONTENT" "NESTED_IN_UNSELECTED_SHOULD_NOT_APPEAR" + +# R08: Nested AlternateContent in selected Choice +run_test "R08_nested_in_selected_choice" "SELECTED_CHOICE_CONTENT" "NESTED_FALLBACK_IN_SELECTED_SHOULD_NOT_APPEAR" +# Also verify nested content appears +run_test "R08_nested_in_selected_choice" "NESTED_IN_SELECTED_CONTENT" "" + +# R09: Nested AlternateContent in Fallback (when Fallback selected) +run_test "R09_nested_in_fallback" "FALLBACK_CONTENT" "NESTED_FALLBACK_IN_FALLBACK_SHOULD_NOT_APPEAR" +run_test "R09_nested_in_fallback" "NESTED_IN_FALLBACK_CONTENT" "" + +# R10: Empty Choice content +run_test "R10_empty_choice_content" "AFTER_EMPTY_CHOICE" "FALLBACK_SHOULD_NOT_APPEAR" + +# R11: Characters and whitespace around branch boundaries +run_test "R11_characters_whitespace_boundaries" "ELIGIBLE_CHOICE_CONTENT" "SHOULD_NOT_APPEAR" +run_test "R11_characters_whitespace_boundaries" "SHOULD_APPEAR" "" +run_test "R11_characters_whitespace_boundaries" "AFTER_ALTERNATE_CONTENT" "" + +echo "========================================" +echo "Test Summary" +echo "========================================" +for result in "$RESULTS_DIR"/*.result; do + if [ -f "$result" ]; then + test_name=$(basename "$result" .result) + status=$(cat "$result") + echo "$test_name: $status" + fi +done \ No newline at end of file diff --git a/audit/ms-odrawxml-d5.7/state-machine.md b/audit/ms-odrawxml-d5.7/state-machine.md new file mode 100644 index 0000000000..0beaf6ec26 --- /dev/null +++ b/audit/ms-odrawxml-d5.7/state-machine.md @@ -0,0 +1,211 @@ +# MCE AlternateContent State Machine — D.5.7 Analysis + +## Current State Definitions (from mcealternatecontext.hxx:103-110) + +| State | Description | +|-------|-------------| +| `STATE_INITIAL` | Before any Choice/Fallback seen | +| `STATE_CHOICE_SCAN` | Scanning Choice branches | +| `STATE_CHOICE_SELECTED` | An eligible Choice was selected | +| `STATE_FALLBACK_SELECTED` | Fallback was selected | +| `STATE_DONE` | AlternateContent ended | + +## Current State Transitions (from mcealternatecontext.cxx) + +### AlternateContent Start (Constructor) +``` +STATE_INITIAL + mnNextChoiceIndex = 0 + mbHasFallback = false + mbInSelectedBranch = false + maSelection = {BRANCH_NONE, -1} +``` + +### First Eligible Choice (implEvaluateChoice, lines 328-338) +``` +STATE_INITIAL or STATE_CHOICE_SCAN + → if (maSelection.meResult == BRANCH_NONE && isChoiceEligible()) + maSelection = {BRANCH_CHOICE, mnNextChoiceIndex} + meState = STATE_CHOICE_SELECTED + mbInSelectedBranch = true + ++mnNextChoiceIndex + → else if (!isChoiceEligible()) + ++mnNextChoiceIndex + meState = STATE_CHOICE_SCAN (implicit) +``` + +### Subsequent Choice Elements (implEvaluateChoice) +``` +STATE_CHOICE_SCAN or STATE_CHOICE_SELECTED + → if (maSelection.meResult == BRANCH_NONE && isChoiceEligible()) + // First eligible - same as above + → else + // Already selected or not eligible - just increment index + ++mnNextChoiceIndex +``` + +### Fallback Selection (startFastElement, lines 86-99) +``` +STATE_INITIAL or STATE_CHOICE_SCAN + → mbHasFallback = true + → if (meState == STATE_CHOICE_SCAN && maSelection.meResult == BRANCH_NONE) + // No eligible Choice found + maSelection = {BRANCH_FALLBACK, -1} + meState = STATE_FALLBACK_SELECTED + mbInSelectedBranch = true + → else + // Choice already selected - Fallback ignored + (no state change) +``` + +### Choice/Fallback End (endFastElement, lines 163-168) +``` +Element == XML_Choice or XML_Fallback + → mbInSelectedBranch = false + → popNamespaces() +``` + +### AlternateContent End (endFastElement, lines 156-162) +``` +Element == XML_AlternateContent + → meState = STATE_DONE + → mbInSelectedBranch = false + → popNamespaces() +``` + +### Nested AlternateContent (createFastChildContext, lines 191-210) +``` +Creates new MceAlternateContext with: + - Inherited namespace stack + - Inherited ignorable namespaces + - Inherited process content elements + - Fresh state: STATE_INITIAL, mnNextChoiceIndex=0, mbHasFallback=false, mbInSelectedBranch=false + - New Selection {BRANCH_NONE, -1} +``` + +## Critical Defects Identified + +### Defect 1: Unknown Element Forwarding (Lines 128-152) +```cpp +void startUnknownElement(Namespace, Name, Attribs) +{ + if (mbInSelectedBranch && mxDelegate.is()) + forward to delegate; + + // BUG: Outside selected branch, forwards if namespace NOT ignorable + if (isIgnorableNamespace(Namespace) && !isProcessContentElement(Namespace, Name)) + return; // Skip + + if (mxDelegate.is()) + forward to delegate; // LEAKS content from unselected branch! +} +``` +**Problem**: Elements from unselected branches with non-ignorable namespaces are forwarded to the delegate. This violates branch isolation. + +### Defect 2: Nested AlternateContent in Unselected Branch (Lines 191-210) +```cpp +createFastChildContext(XML_AlternateContent, Attribs) +{ + // BUG: Creates nested context WITHOUT checking mbInSelectedBranch + MceAlternateContext* pMceCtx = new MceAlternateContext(mxDelegate); + pMceCtx->maNamespaceStack = maNamespaceStack; // inherit + pMceCtx->maIgnorableNamespaces = maIgnorableNamespaces; + pMceCtx->maProcessContentElements = maProcessContentElements; + // ... fresh state initialized + return pMceCtx; // Can independently select and forward! +} +``` +**Problem**: A nested AlternateContent inside an unselected branch creates its own context that can independently evaluate Choice/Fallback and forward content to the delegate. + +### Defect 3: ProcessContent Overrides Branch Selection (Lines 108-123, 212-226, 241-250) +```cpp +// In startFastElement, createFastChildContext, createUnknownChildContext: +if (isProcessContentElement(ns, name) && mxDelegate.is()) + forward/delegate; // Ignores mbInSelectedBranch! +``` +**Problem**: `mc:ProcessContent` is meant to allow processing of specific elements *within ignorable namespaces*, not to override AlternateContent branch selection. + +### Defect 4: Missing State for "Inside Choice/Fallback but Not Selected" +The current `mbInSelectedBranch` flag doesn't distinguish between: +- Inside the selected branch (should forward) +- Inside an unselected Choice (should suppress) +- Inside an unselected Fallback (should suppress) +- Outside any branch (inside AlternateContent but before first Choice) + +### Defect 5: End Element Balance +When a branch is not selected, its `startFastElement`/`startUnknownElement` are suppressed (good), but the corresponding `endFastElement`/`endUnknownElement` are also suppressed (lines 170-180). This is correct IF the delegate never saw the start. However, if a nested context was created (Defect 2), it may have forwarded starts and expects ends. + +## Corrected State Machine Design + +### Additional State Needed +``` +STATE_IN_CHOICE // Inside a Choice element (selected or not) +STATE_IN_FALLBACK // Inside Fallback element (selected or not) +``` + +Or better: Track branch selection per-branch rather than global `mbInSelectedBranch`. + +### Correct Branch Selection Logic +1. **AlternateContent starts**: `STATE_INITIAL`, no branch selected +2. **Each Choice**: Evaluate eligibility + - If no branch selected yet AND eligible → select this Choice, enter `STATE_CHOICE_SELECTED` + - If already selected OR not eligible → remain in scanning, suppress this Choice +3. **Fallback**: + - If no branch selected → select Fallback, enter `STATE_FALLBACK_SELECTED` + - If already selected → suppress Fallback +4. **Inside selected branch**: Forward all events to delegate +5. **Inside unselected branch**: Suppress ALL events (including unknown elements, ProcessContent, nested AlternateContent) +6. **Nested AlternateContent**: Only create/forward if currently in selected branch; otherwise return null context + +### Correct State Transitions + +| Current State | Event | Condition | Next State | Action | +|---------------|-------|-----------|------------|--------| +| INITIAL | Choice | eligible | CHOICE_SELECTED | select branch, mbInSelectedBranch=true | +| INITIAL | Choice | not eligible | CHOICE_SCAN | suppress | +| CHOICE_SCAN | Choice | eligible (first) | CHOICE_SELECTED | select branch, mbInSelectedBranch=true | +| CHOICE_SCAN | Choice | not eligible | CHOICE_SCAN | suppress | +| CHOICE_SELECTED | Choice | any | CHOICE_SELECTED | suppress | +| CHOICE_SELECTED | Fallback | - | CHOICE_SELECTED | suppress | +| CHOICE_SCAN | Fallback | - | FALLBACK_SELECTED | select fallback, mbInSelectedBranch=true | +| INITIAL | Fallback | - | FALLBACK_SELECTED | select fallback, mbInSelectedBranch=true | +| FALLBACK_SELECTED | any | - | FALLBACK_SELECTED | suppress (no more branches) | +| *SELECTED | Choice/Fallback start | - | IN_BRANCH | mbInSelectedBranch=true, push ns | +| *SELECTED | Choice/Fallback end | - | *SELECTED | mbInSelectedBranch=false, pop ns | +| *SELECTED | AlternateContent end | - | DONE | mbInSelectedBranch=false, pop ns | +| *NOT_SELECTED | Choice/Fallback start | - | IN_BRANCH (unselected) | mbInSelectedBranch=false, push ns | +| *NOT_SELECTED | Choice/Fallback end | - | *NOT_SELECTED | pop ns | +| *NOT_SELECTED | AlternateContent end | - | DONE | pop ns | + +### Key Correction: Per-Branch Tracking +Instead of single `mbInSelectedBranch`, track: +- `mbInSelectedBranch` = currently inside the selected branch (forward events) +- `mnSelectedChoiceIndex` = index of selected Choice (-1 for Fallback) +- `mnCurrentBranchIndex` = index of current Choice being processed (0-based) +- `mbInFallback` = currently inside Fallback element + +Or simpler: The branch is "selected" if: +- We're inside a Choice element AND its index == mnSelectedChoiceIndex +- We're inside Fallback AND mnSelectedChoiceIndex == -1 (Fallback selected) +- Otherwise branch is unselected → suppress all events + +## Files to Modify + +1. `main/oox/inc/oox/core/mcealternatecontext.hxx` - Add state tracking fields +2. `main/oox/source/core/mcealternatecontext.cxx` - Fix all SAX callbacks + +## Regression Test Matrix (D.5.7) + +| Test ID | Description | Expected | +|---------|-------------|----------| +| R01 | Eligible Choice, then Fallback | Only Choice content | +| R02 | Ineligible Choice, then eligible Choice | Only 2nd Choice content | +| R03 | No eligible Choice, then Fallback | Only Fallback content | +| R04 | No eligible Choice, no Fallback | No content | +| R05 | Multiple eligible Choices | First eligible only | +| R06 | Unknown non-ignorable in unselected branch | Suppressed | +| R07 | Nested AlternateContent in unselected Choice | Suppressed entirely | +| R08 | Nested AlternateContent in selected Choice | Processed normally | +| R09 | Nested AlternateContent in Fallback | Processed if Fallback selected | +| R10 | Empty Choice content | No output | +| R11 | Characters/whitespace at boundaries | Only in selected branch | \ No newline at end of file diff --git a/main/oox/inc/oox/core/mcealternatecontext.hxx b/main/oox/inc/oox/core/mcealternatecontext.hxx index 1b4868fb2b..953d47dbe8 100644 --- a/main/oox/inc/oox/core/mcealternatecontext.hxx +++ b/main/oox/inc/oox/core/mcealternatecontext.hxx @@ -102,11 +102,11 @@ public: private: enum State { - STATE_INITIAL, ///< Before any Choice/Fallback seen - STATE_CHOICE_SCAN, ///< Scanning Choice branches - STATE_CHOICE_SELECTED,///< An eligible Choice was selected + STATE_INITIAL, ///< Before any Choice/Fallback seen + STATE_CHOICE_SCAN, ///< Scanning Choice branches, none selected yet + STATE_CHOICE_SELECTED, ///< An eligible Choice was selected STATE_FALLBACK_SELECTED, ///< Fallback was selected - STATE_DONE ///< AlternateContent ended + STATE_DONE ///< AlternateContent ended }; ::com::sun::star::uno::Reference< @@ -115,8 +115,10 @@ private: State meState; MceProcessor::Selection maSelection; sal_Int32 mnNextChoiceIndex; ///< Index of next Choice to evaluate + sal_Int32 mnCurrentBranchIndex; ///< Index of current Choice/Fallback branch (0-based) + bool mbInFallback; ///< Currently inside Fallback element bool mbHasFallback; - bool mbInSelectedBranch; ///< Currently inside selected branch + bool mbInSelectedBranch; ///< Currently inside the selected branch ::rtl::OUString maMarkupCompatNamespace; diff --git a/main/oox/source/core/mcealternatecontext.cxx b/main/oox/source/core/mcealternatecontext.cxx index e108a3164f..56e74f77fc 100644 --- a/main/oox/source/core/mcealternatecontext.cxx +++ b/main/oox/source/core/mcealternatecontext.cxx @@ -48,6 +48,8 @@ OOX_DLLPUBLIC MceAlternateContext::MceAlternateContext( mxDelegate( xDelegate ), meState( STATE_INITIAL ), mnNextChoiceIndex( 0 ), + mnCurrentBranchIndex( -1 ), + mbInFallback( false ), mbHasFallback( false ), mbInSelectedBranch( false ), maMarkupCompatNamespace( @@ -79,12 +81,24 @@ void SAL_CALL MceAlternateContext::startFastElement( if ( Element == XML_Choice ) { + // Entering a Choice branch + mnCurrentBranchIndex = mnNextChoiceIndex; // Evaluate this Choice's Requires attribute implEvaluateChoice( Attribs ); - return; // Choice element itself is not forwarded + // If this Choice was selected, we are now inside the selected branch + if ( maSelection.meResult == MceProcessor::BRANCH_CHOICE && + maSelection.mnChoiceIndex == mnCurrentBranchIndex ) + { + mbInSelectedBranch = true; + } + // Choice element itself is not forwarded + return; } if ( Element == XML_Fallback ) { + // Entering Fallback branch + mbInFallback = true; + mnCurrentBranchIndex = -1; // Fallback uses index -1 if ( meState == STATE_INITIAL || meState == STATE_CHOICE_SCAN ) { mbHasFallback = true; @@ -97,7 +111,8 @@ void SAL_CALL MceAlternateContext::startFastElement( mbInSelectedBranch = true; } } - return; // Fallback element itself is not forwarded + // Fallback element itself is not forwarded + return; } if ( Element == XML_AlternateContent ) { @@ -105,24 +120,16 @@ void SAL_CALL MceAlternateContext::startFastElement( return; } - // Non-MCE element inside selected branch - forward to delegate + // Non-MCE element: only forward if inside the selected branch if ( mbInSelectedBranch && mxDelegate.is() ) { mxDelegate->startFastElement( Element, Attribs ); return; } - // Non-MCE element outside selected branch: check mc:ProcessContent - // Get namespace and local name for this token - ::rtl::OUString aNamespaceURI = getNamespaceForToken( Element ); - ::rtl::OUString aLocalName = getLocalNameForToken( Element ); - if ( isProcessContentElement( aNamespaceURI, aLocalName ) && mxDelegate.is() ) - { - mxDelegate->startFastElement( Element, Attribs ); - return; - } - - // Non-MCE element outside selected branch and not in ProcessContent - discard + // Non-MCE element outside selected branch - discard + // mc:ProcessContent does NOT override AlternateContent branch selection + // It only applies to elements in ignorable namespaces within the selected branch } void SAL_CALL MceAlternateContext::startUnknownElement( @@ -131,24 +138,16 @@ void SAL_CALL MceAlternateContext::startUnknownElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) { + // Only forward if inside the selected branch if ( mbInSelectedBranch && mxDelegate.is() ) { mxDelegate->startUnknownElement( Namespace, Name, Attribs ); return; } - // Element outside selected branch: check mc:Ignorable and mc:ProcessContent - // If namespace is ignorable AND element is NOT in ProcessContent list: skip - // If namespace is ignorable AND element IS in ProcessContent list: forward - // If namespace is NOT ignorable: forward normally - if ( isIgnorableNamespace( Namespace ) && - !isProcessContentElement( Namespace, Name ) ) - { - return; // Skip - ignorable namespace, not in ProcessContent - } - - if ( mxDelegate.is() ) - mxDelegate->startUnknownElement( Namespace, Name, Attribs ); + // Element outside selected branch: completely suppressed + // mc:Ignorable and mc:ProcessContent do NOT override AlternateContent branch selection + // They only apply within the selected branch } void SAL_CALL MceAlternateContext::endFastElement( ::sal_Int32 Element ) @@ -157,16 +156,30 @@ void SAL_CALL MceAlternateContext::endFastElement( ::sal_Int32 Element ) { meState = STATE_DONE; mbInSelectedBranch = false; + mnCurrentBranchIndex = -1; + mbInFallback = false; popNamespaces(); return; } - if ( Element == XML_Choice || Element == XML_Fallback ) + if ( Element == XML_Choice ) { + // Leaving a Choice branch mbInSelectedBranch = false; + mnCurrentBranchIndex = -1; + popNamespaces(); + return; + } + if ( Element == XML_Fallback ) + { + // Leaving Fallback branch + mbInSelectedBranch = false; + mbInFallback = false; + mnCurrentBranchIndex = -1; popNamespaces(); return; } + // Non-MCE element end: only forward if inside selected branch if ( mbInSelectedBranch && mxDelegate.is() ) mxDelegate->endFastElement( Element ); } @@ -175,6 +188,7 @@ void SAL_CALL MceAlternateContext::endUnknownElement( const ::rtl::OUString& Namespace, const ::rtl::OUString& Name ) { + // Only forward if inside the selected branch if ( mbInSelectedBranch && mxDelegate.is() ) mxDelegate->endUnknownElement( Namespace, Name ); } @@ -190,7 +204,14 @@ MceAlternateContext::createFastChildContext( { if ( Element == XML_AlternateContent ) { - // Nested AlternateContent: create a new context. + // Nested AlternateContent: ONLY create if inside selected branch. + // A nested AlternateContent in an unselected branch must not + // independently select content and forward it to the delegate. + if ( !mbInSelectedBranch ) + return ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XFastContextHandler >(); + + // Inside selected branch: create a new context. // Namespace declarations have already been pushed in startFastElement. MceAlternateContext* pMceCtx = new MceAlternateContext( mxDelegate ); @@ -199,6 +220,8 @@ MceAlternateContext::createFastChildContext( pMceCtx->maProcessContentElements = maProcessContentElements; // inherit process content pMceCtx->meState = STATE_INITIAL; pMceCtx->mnNextChoiceIndex = 0; + pMceCtx->mnCurrentBranchIndex = -1; + pMceCtx->mbInFallback = false; pMceCtx->mbHasFallback = false; pMceCtx->mbInSelectedBranch = false; pMceCtx->maSelection.meResult = MceProcessor::BRANCH_NONE; @@ -213,14 +236,8 @@ MceAlternateContext::createFastChildContext( if ( mbInSelectedBranch && mxDelegate.is() ) return mxDelegate->createFastChildContext( Element, Attribs ); - // Non-MCE element outside selected branch: check mc:ProcessContent - // Get namespace and local name for this token - ::rtl::OUString aNamespaceURI = getNamespaceForToken( Element ); - ::rtl::OUString aLocalName = getLocalNameForToken( Element ); - if ( isProcessContentElement( aNamespaceURI, aLocalName ) && mxDelegate.is() ) - return mxDelegate->createFastChildContext( Element, Attribs ); - - // Non-MCE element outside selected branch and not in ProcessContent + // Non-MCE element outside selected branch - suppress + // mc:ProcessContent does NOT override AlternateContent branch selection return ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler >(); } @@ -235,20 +252,12 @@ MceAlternateContext::createUnknownChildContext( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) { + // Only forward if inside the selected branch if ( mbInSelectedBranch && mxDelegate.is() ) return mxDelegate->createUnknownChildContext( Namespace, Name, Attribs ); - // Unknown element outside selected branch: check mc:Ignorable and mc:ProcessContent - if ( isIgnorableNamespace( Namespace ) && - !isProcessContentElement( Namespace, Name ) ) - { - return ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XFastContextHandler >(); // Skip - } - - if ( mxDelegate.is() ) - return mxDelegate->createUnknownChildContext( Namespace, Name, Attribs ); - + // Unknown element outside selected branch: completely suppressed + // mc:Ignorable and mc:ProcessContent do NOT override AlternateContent branch selection return ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler >(); } @@ -329,11 +338,12 @@ void MceAlternateContext::implEvaluateChoice( { if ( maSelection.meResult == MceProcessor::BRANCH_NONE ) { - // First eligible Choice + // First eligible Choice - record selection but don't set + // mbInSelectedBranch yet; that happens in startFastElement + // when we're actually inside the Choice element. maSelection.meResult = MceProcessor::BRANCH_CHOICE; maSelection.mnChoiceIndex = mnNextChoiceIndex; meState = STATE_CHOICE_SELECTED; - mbInSelectedBranch = true; } ++mnNextChoiceIndex; }
