Skip to content

Commit f66fffe

Browse files
committed
fix: ignore pptx hidden line extensions
Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
1 parent 5c4281f commit f66fffe

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

crates/office2pdf/src/parser/pptx_shape_style_tests.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,27 @@ fn test_shape_no_fill_overrides_fill_ref() {
522522
);
523523
}
524524

525+
#[test]
526+
fn test_shape_extension_hidden_line_does_not_override_visible_fill() {
527+
let shape_xml = r#"<p:sp><p:nvSpPr><p:cNvPr id="2" name="Ellipse"/><p:cNvSpPr/><p:nvPr/></p:nvSpPr><p:spPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="914400" cy="914400"/></a:xfrm><a:prstGeom prst="ellipse"><a:avLst/></a:prstGeom><a:solidFill><a:schemeClr val="lt1"/></a:solidFill><a:ln><a:noFill/></a:ln><a:effectLst><a:outerShdw blurRad="63500" sx="102000" sy="102000" algn="ctr" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="39999"/></a:srgbClr></a:outerShdw></a:effectLst><a:extLst><a:ext uri="{91240B29-F687-4F45-9708-019B960494DF}"><a16:hiddenLine xmlns:a16="http://schemas.microsoft.com/office/drawing/2010/main" w="25400"><a:solidFill><a:srgbClr val="000000"/></a:solidFill><a:round/><a:headEnd/><a:tailEnd/></a16:hiddenLine></a:ext></a:extLst></p:spPr></p:sp>"#.to_string();
528+
let slide_xml = make_slide_xml(&[shape_xml]);
529+
530+
let theme_xml = make_theme_xml(&standard_theme_colors(), "Calibri", "Calibri");
531+
let data = build_test_pptx_with_theme(SLIDE_CX, SLIDE_CY, &[slide_xml], &theme_xml);
532+
let parser = PptxParser;
533+
let (doc, _warnings) = parser.parse(&data, &ConvertOptions::default()).unwrap();
534+
535+
let page = first_fixed_page(&doc);
536+
let shape = get_shape(&page.elements[0]);
537+
assert_eq!(
538+
shape.fill,
539+
Some(Color::new(0xFF, 0xFF, 0xFF)),
540+
"Vendor extension hiddenLine should not override the visible shape fill"
541+
);
542+
let shadow = shape.shadow.as_ref().expect("Expected shadow");
543+
assert_eq!(shadow.color, Color::new(0, 0, 0));
544+
}
545+
525546
#[test]
526547
fn test_textbox_fill_from_style_fill_ref() {
527548
// TextBox with roundRect (non-rectangular shape) and text gets split into

crates/office2pdf/src/parser/pptx_slides.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,12 @@ impl<'a> SlideXmlParser<'a> {
933933
b"effectLst" if self.shape.in_sp_pr && !self.shape.in_ln => {
934934
self.shape.shadow = parse_effect_list(reader, self.theme, self.color_map);
935935
}
936+
b"extLst" if self.shape.in_sp_pr && !self.in_txbody => {
937+
// Office extension payloads such as a16:hiddenLine are not visible shape
938+
// styling. If we parse nested fills here, they can overwrite the actual
939+
// shape fill, as seen on grouped icon ellipses that should stay white.
940+
crate::parser::xml_util::skip_element(reader, b"extLst");
941+
}
936942
b"ln" if self.shape.in_sp_pr => {
937943
self.shape.in_ln = true;
938944
self.shape.ln_width_emu = get_attr_i64(e, b"w").unwrap_or(12700);

0 commit comments

Comments
 (0)