From 67c6e85102238bbd1b7bf475efa176223175901e Mon Sep 17 00:00:00 2001 From: hanthor Date: Tue, 23 Jun 2026 23:03:06 +0530 Subject: [PATCH] Add is_page_break_before() to ParagraphRef and is_underline() to RunRef These read-side methods were missing from ParagraphRef and RunRef, making it impossible to detect page breaks and underline formatting when reading DOCX files programmatically. - ParagraphRef::is_page_break_before() reads CT_PPr.page_break_before - RunRef::is_underline() reads CT_RPr.underline Use case: GTK4 word processor importing DOCX files with preserved layout and formatting. --- crates/rdocx/src/paragraph.rs | 9 +++++++++ crates/rdocx/src/run.rs | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/crates/rdocx/src/paragraph.rs b/crates/rdocx/src/paragraph.rs index 74d45af..c336526 100644 --- a/crates/rdocx/src/paragraph.rs +++ b/crates/rdocx/src/paragraph.rs @@ -415,6 +415,15 @@ impl<'a> ParagraphRef<'a> { .map(Alignment::from_st_jc) } + /// Check if this paragraph has a page break before it. + pub fn is_page_break_before(&self) -> bool { + self.inner + .properties + .as_ref() + .and_then(|ppr| ppr.page_break_before) + .unwrap_or(false) + } + /// Get an iterator over immutable run references. pub fn runs(&self) -> impl Iterator> { self.inner.runs.iter().map(|r| RunRef { inner: r }) diff --git a/crates/rdocx/src/run.rs b/crates/rdocx/src/run.rs index acb446e..785f81c 100644 --- a/crates/rdocx/src/run.rs +++ b/crates/rdocx/src/run.rs @@ -236,6 +236,15 @@ impl<'a> RunRef<'a> { .unwrap_or(false) } + /// Check if underline. + pub fn is_underline(&self) -> bool { + self.inner + .properties + .as_ref() + .and_then(|rpr| rpr.underline.as_ref()) + .is_some() + } + /// Get font size in points, if set. pub fn size(&self) -> Option { self.inner