Skip to main content

Paragraph

Struct Paragraph 

Source
pub struct Paragraph {
    pub rsid_r_pr: Option<STLongHexNumber>,
    pub rsid_r: Option<STLongHexNumber>,
    pub rsid_del: Option<STLongHexNumber>,
    pub rsid_p: Option<STLongHexNumber>,
    pub rsid_r_default: Option<STLongHexNumber>,
    pub p_pr: Option<Box<ParagraphProperties>>,
    pub paragraph_content: Vec<ParagraphContent>,
    pub extra_attrs: HashMap<String, String>,
    pub extra_children: Vec<PositionedNode>,
}

Fields§

§rsid_r_pr: Option<STLongHexNumber>§rsid_r: Option<STLongHexNumber>§rsid_del: Option<STLongHexNumber>§rsid_p: Option<STLongHexNumber>§rsid_r_default: Option<STLongHexNumber>§p_pr: Option<Box<ParagraphProperties>>§paragraph_content: Vec<ParagraphContent>§extra_attrs: HashMap<String, String>

Unknown attributes captured for roundtrip fidelity.

§extra_children: Vec<PositionedNode>

Unknown child elements captured for roundtrip fidelity.

Implementations§

Source§

impl Paragraph

Source

pub fn add_run(&mut self) -> &mut Run

Add an empty run and return a mutable reference to it.

Add an empty hyperlink and return a mutable reference to it.

Source

pub fn add_bookmark_start_u32(&mut self, id: u32, name: &str)

Add a bookmark start marker.

This version accepts a u32 id for ergonomic use in writer APIs. ECMA-376 Part 1, Section 17.13.6.1 (w:bookmarkStart).

Source

pub fn add_bookmark_end_u32(&mut self, id: u32)

Add a bookmark end marker.

This version accepts a u32 id for ergonomic use in writer APIs. ECMA-376 Part 1, Section 17.13.6.2 (w:bookmarkEnd).

Source

pub fn add_bookmark_start(&mut self, id: i64, name: &str)

Add a bookmark start marker.

Source

pub fn add_bookmark_end(&mut self, id: i64)

Add a bookmark end marker.

Source

pub fn add_comment_range_start(&mut self, id: u32)

Add a comment range start marker.

Source

pub fn add_comment_range_end(&mut self, id: u32)

Add a comment range end marker.

Source

pub fn set_properties(&mut self, props: ParagraphProperties)

Set paragraph properties.

Source

pub fn set_numbering(&mut self, num_id: u32, ilvl: u32)

Set numbering properties (list membership) on this paragraph.

Source

pub fn set_alignment(&mut self, alignment: STJc)

Set paragraph alignment.

Use STJc variants: Left, Center, Right, Both (justified), etc.

Source

pub fn set_spacing(&mut self, before: Option<u32>, after: Option<u32>)

Set paragraph spacing (before and after, in twips).

Source

pub fn set_indent(&mut self, left: Option<u32>, first_line: Option<u32>)

Set paragraph indentation.

Source

pub fn add_page_break(&mut self) -> &mut Self

Insert a page break run into this paragraph.

Adds <w:r><w:br w:type="page"/></w:r> to the paragraph content. ECMA-376 Part 1, Section 17.3.3.1 (w:br).

Source

pub fn add_column_break(&mut self) -> &mut Self

Insert a column break run into this paragraph.

Adds <w:r><w:br w:type="column"/></w:r> to the paragraph content. ECMA-376 Part 1, Section 17.3.3.1 (w:br).

Source

pub fn set_space_before(&mut self, twips: u32) -> &mut Self

Set space before the paragraph in twips (twentieths of a point).

Modifies the <w:spacing w:before="..."/> attribute. ECMA-376 Part 1, Section 17.3.1.33 (w:spacing).

Source

pub fn set_space_after(&mut self, twips: u32) -> &mut Self

Set space after the paragraph in twips (twentieths of a point).

Modifies the <w:spacing w:after="..."/> attribute. ECMA-376 Part 1, Section 17.3.1.33 (w:spacing).

Source

pub fn set_line_spacing(&mut self, twips: u32) -> &mut Self

Set line spacing in twips.

Sets <w:spacing w:line="..." w:lineRule="auto"/>. A value of 240 is single-spacing (12pt × 20), 360 is 1.5×, 480 is double. ECMA-376 Part 1, Section 17.3.1.33 (w:spacing).

Source

pub fn set_indent_left(&mut self, twips: u32) -> &mut Self

Set left indentation in twips.

Sets <w:ind w:left="..."/>. ECMA-376 Part 1, Section 17.3.1.12 (w:ind).

Source

pub fn set_indent_right(&mut self, twips: u32) -> &mut Self

Set right indentation in twips.

Sets <w:ind w:right="..."/>. ECMA-376 Part 1, Section 17.3.1.12 (w:ind).

Source

pub fn set_indent_first_line(&mut self, twips: u32) -> &mut Self

Set first-line indentation in twips.

Sets <w:ind w:firstLine="..."/>. A positive value indents the first line; use hanging for a hanging indent (not yet exposed directly). ECMA-376 Part 1, Section 17.3.1.12 (w:ind).

Source

pub fn set_outline_level(&mut self, level: u8) -> &mut Self

Set the outline level of this paragraph (0–8, where 0 = body text).

Maps to <w:outlineLvl w:val="..."/> in paragraph properties. Levels 0–8 correspond to heading levels 1–9 in the document outline. ECMA-376 Part 1, Section 17.3.1.20 (w:outlineLvl).

Source§

impl Paragraph

Source

pub fn add_tracked_insertion( &mut self, id: i64, author: &str, date: Option<&str>, text: &str, ) -> &mut CTRunTrackChange

Add a tracked insertion wrapping the given text and return a mutable reference to the CTRunTrackChange (ECMA-376 §17.13.5.16).

Source

pub fn add_tracked_deletion( &mut self, id: i64, author: &str, date: Option<&str>, text: &str, ) -> &mut CTRunTrackChange

Add a tracked deletion wrapping the given text and return a mutable reference to the CTRunTrackChange (ECMA-376 §17.13.5.13).

Source§

impl Paragraph

Source

pub fn add_math(&mut self, builder: OMathBuilder) -> &mut Self

Add an Office Math expression to this paragraph.

The math element (<m:oMath> or <m:oMathPara>) is stored as a RawXmlElement inside an extra-children slot on a synthetic run.

ECMA-376 Part 1, Section 22.1.2.77 (m:oMath).

Source§

impl Paragraph

Source

pub fn add_inline_chart( &mut self, rel_id: &str, width_emu: i64, height_emu: i64, ) -> &mut Self

Add an inline chart drawing reference to this paragraph.

Inserts a <w:drawing><wp:inline>…<c:chart r:id="rel_id"/>…</wp:inline></w:drawing> element referencing the chart part identified by rel_id.

Use DocumentBuilder::embed_chart to obtain a rel_id first.

ECMA-376 Part 1, Section 20.4.2.8 (inline).

Trait Implementations§

Source§

impl Clone for Paragraph

Source§

fn clone(&self) -> Paragraph

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Paragraph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Paragraph

Source§

fn default() -> Paragraph

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Paragraph

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl FromXml for Paragraph

Source§

fn from_xml<R: BufRead>( reader: &mut Reader<R>, start_tag: &BytesStart<'_>, is_empty: bool, ) -> Result<Self, ParseError>

Parse from an XML reader positioned at the start tag. Read more
Source§

impl MathExt for Paragraph

Available on crate feature extra-children only.
Source§

fn math_expressions(&self) -> Vec<MathExpression>

Return all math expressions contained in this element.
Source§

fn has_math(&self) -> bool

Return true if this element contains at least one math expression.
Source§

impl ParagraphExt for Paragraph

Source§

fn runs(&self) -> Vec<&Run>

Get all runs in this paragraph (including runs inside hyperlinks and simple fields).
Source§

fn text(&self) -> String

Extract all text from this paragraph.
Get hyperlinks in this paragraph.
Source§

fn properties(&self) -> Option<&ParagraphProperties>

Get paragraph properties.
Source§

fn alignment(&self) -> Option<STJc>

Get paragraph alignment (justification). ECMA-376 §17.3.1.13.
Source§

fn indent_left(&self) -> Option<i64>

Get left indent in twips. ECMA-376 §17.3.1.12. Read more
Source§

fn indent_right(&self) -> Option<i64>

Get right indent in twips. Read more
Source§

fn indent_first_line(&self) -> Option<i64>

Get first-line additional indent in twips (positive = first line further right). Read more
Source§

fn indent_hanging(&self) -> Option<i64>

Get hanging indent in twips (positive = first line is that many twips to the left of the rest). Read more
Source§

fn space_before(&self) -> Option<i64>

Get space before paragraph in twips. ECMA-376 §17.3.1.33.
Source§

fn space_after(&self) -> Option<i64>

Get space after paragraph in twips.
Source§

fn line_spacing(&self) -> Option<i64>

Get line spacing value in twips (240 = single, 360 = 1.5×, 480 = double for auto rule).
Source§

fn line_spacing_rule(&self) -> Option<STLineSpacingRule>

Get the line spacing rule, if set.
Source§

fn numbering(&self) -> Option<(i64, i64)>

Get numbering (list) properties as (num_id, ilvl). ECMA-376 §17.9. Read more
Source§

impl RevisionExt for Paragraph

Available on crate feature wml-track-changes only.
Source§

fn track_changes(&self) -> Vec<TrackChange>

All tracked changes in this paragraph.
Source§

fn accepted_text(&self) -> String

Text produced by accepting all tracked changes: insertions are kept, deletions are removed, normal runs are kept.
Source§

fn rejected_text(&self) -> String

Text produced by rejecting all tracked changes: insertions are removed, deletions are restored, normal runs are kept.
Source§

fn has_track_changes(&self) -> bool

Whether this paragraph contains any tracked changes.
Source§

impl Serialize for Paragraph

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl ToXml for Paragraph

Source§

fn write_attrs<'a>(&self, start: BytesStart<'a>) -> BytesStart<'a>

Write attributes onto the start tag and return it.
Source§

fn write_children<W: Write>( &self, writer: &mut Writer<W>, ) -> Result<(), SerializeError>

Write child elements and text content inside the element.
Source§

fn is_empty_element(&self) -> bool

Whether this element has no children (self-closing).
Source§

fn write_element<W>( &self, tag: &str, writer: &mut Writer<W>, ) -> Result<(), SerializeError>
where W: Write,

Write a complete element: <tag attrs>children</tag> or <tag attrs/>.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,