pub struct TabStop {
pub position_twips: i32,
pub alignment: TabStopAlignment,
pub leader: Option<TabLeader>,
}Expand description
A single custom tab stop (w:tab, CT_TabStop), one entry of Paragraph.tabs.
Fields§
§position_twips: i32The tab stop’s position, in twips, measured from the paragraph’s left margin (w:tab/@pos,
ST_SignedTwipsMeasure — signed, since a tab stop can be positioned left of the margin
under a negative indent).
alignment: TabStopAlignmentHow text is aligned relative to this tab stop (w:tab/@val).
leader: Option<TabLeader>The leader character repeated between the preceding text and this tab stop
(w:tab/@leader), or None for a blank leader (Word’s default when the attribute is
omitted).
Implementations§
Source§impl TabStop
impl TabStop
Sourcepub fn new(position_twips: i32) -> TabStop
pub fn new(position_twips: i32) -> TabStop
Creates a left-aligned tab stop at the given position, with no leader — the most common case.
Examples found in repository?
examples/docx_text_formatting.rs (line 63)
16fn main() -> office_toolkit::Result<()> {
17 let path = output_path("docx_text_formatting.docx");
18
19 let document = Document::new()
20 .with_paragraph(heading("Docx text formatting — bold, italic, underline, strike", false))
21 .with_paragraph(Paragraph::new().with_run(Run::new("Bold text.").with_bold(true)))
22 .with_paragraph(Paragraph::new().with_run(Run::new("Italic text.").with_italic(true)))
23 .with_paragraph(Paragraph::new().with_run(Run::new("Single underline.").with_underline(UnderlineStyle::Single)))
24 .with_paragraph(Paragraph::new().with_run(Run::new("Wavy underline.").with_underline(UnderlineStyle::Wave)))
25 .with_paragraph(Paragraph::new().with_run(Run::new("Strikethrough text.").with_strike(true)))
26 .with_paragraph(heading("Colors and highlight", true))
27 .with_paragraph(Paragraph::new().with_run(Run::new("Red text on the default background.").with_color("FF0000")))
28 .with_paragraph(Paragraph::new().with_run(Run::new("Text highlighted in yellow.").with_highlight(Highlight::Yellow)))
29 .with_paragraph(
30 Paragraph::new()
31 .with_run(Run::new("Larger, custom font.").with_font_size(32).with_font_family("Georgia")),
32 )
33 .with_paragraph(heading("Superscript and subscript", true))
34 .with_paragraph(
35 Paragraph::new()
36 .with_run(Run::new("Water is H"))
37 .with_run(Run::new("2").with_vertical_align(VerticalAlign::Subscript))
38 .with_run(Run::new("O.")),
39 )
40 .with_paragraph(
41 Paragraph::new()
42 .with_run(Run::new("Squared: x"))
43 .with_run(Run::new("2").with_vertical_align(VerticalAlign::Superscript))
44 .with_run(Run::new(".")),
45 )
46 .with_paragraph(heading("Small caps, all caps, character spacing", true))
47 .with_paragraph(Paragraph::new().with_run(Run::new("rendered in small caps").with_small_caps(true)))
48 .with_paragraph(Paragraph::new().with_run(Run::new("rendered in all caps").with_all_caps(true)))
49 .with_paragraph(Paragraph::new().with_run(Run::new("Widely spaced letters.").with_character_spacing(120)))
50 .with_paragraph(heading("Paragraph alignment", true))
51 .with_paragraph(Paragraph::with_text("Left-aligned (the default).").with_alignment(Alignment::Left))
52 .with_paragraph(Paragraph::with_text("Centered.").with_alignment(Alignment::Center))
53 .with_paragraph(Paragraph::with_text("Right-aligned.").with_alignment(Alignment::Right))
54 .with_paragraph(
55 Paragraph::with_text(
56 "Justified: this line is long enough for Word to stretch the spacing between words so both edges line up.",
57 )
58 .with_alignment(Alignment::Justify),
59 )
60 .with_paragraph(heading("Tab stops", true))
61 .with_paragraph(
62 Paragraph::new()
63 .with_tab(TabStop::new(1_440).with_alignment(TabStopAlignment::Center))
64 .with_tab(TabStop::new(2_880).with_alignment(TabStopAlignment::Right).with_leader(TabLeader::Dot))
65 .with_run(Run::new("Left\tCentered\tRight, dot leader")),
66 );
67
68 document.save_to_file(&path)?;
69 println!("Wrote {}", path.display());
70 Ok(())
71}Sourcepub fn with_alignment(self, alignment: TabStopAlignment) -> TabStop
pub fn with_alignment(self, alignment: TabStopAlignment) -> TabStop
Sets this tab stop’s alignment and returns it for chaining.
Examples found in repository?
examples/docx_text_formatting.rs (line 63)
16fn main() -> office_toolkit::Result<()> {
17 let path = output_path("docx_text_formatting.docx");
18
19 let document = Document::new()
20 .with_paragraph(heading("Docx text formatting — bold, italic, underline, strike", false))
21 .with_paragraph(Paragraph::new().with_run(Run::new("Bold text.").with_bold(true)))
22 .with_paragraph(Paragraph::new().with_run(Run::new("Italic text.").with_italic(true)))
23 .with_paragraph(Paragraph::new().with_run(Run::new("Single underline.").with_underline(UnderlineStyle::Single)))
24 .with_paragraph(Paragraph::new().with_run(Run::new("Wavy underline.").with_underline(UnderlineStyle::Wave)))
25 .with_paragraph(Paragraph::new().with_run(Run::new("Strikethrough text.").with_strike(true)))
26 .with_paragraph(heading("Colors and highlight", true))
27 .with_paragraph(Paragraph::new().with_run(Run::new("Red text on the default background.").with_color("FF0000")))
28 .with_paragraph(Paragraph::new().with_run(Run::new("Text highlighted in yellow.").with_highlight(Highlight::Yellow)))
29 .with_paragraph(
30 Paragraph::new()
31 .with_run(Run::new("Larger, custom font.").with_font_size(32).with_font_family("Georgia")),
32 )
33 .with_paragraph(heading("Superscript and subscript", true))
34 .with_paragraph(
35 Paragraph::new()
36 .with_run(Run::new("Water is H"))
37 .with_run(Run::new("2").with_vertical_align(VerticalAlign::Subscript))
38 .with_run(Run::new("O.")),
39 )
40 .with_paragraph(
41 Paragraph::new()
42 .with_run(Run::new("Squared: x"))
43 .with_run(Run::new("2").with_vertical_align(VerticalAlign::Superscript))
44 .with_run(Run::new(".")),
45 )
46 .with_paragraph(heading("Small caps, all caps, character spacing", true))
47 .with_paragraph(Paragraph::new().with_run(Run::new("rendered in small caps").with_small_caps(true)))
48 .with_paragraph(Paragraph::new().with_run(Run::new("rendered in all caps").with_all_caps(true)))
49 .with_paragraph(Paragraph::new().with_run(Run::new("Widely spaced letters.").with_character_spacing(120)))
50 .with_paragraph(heading("Paragraph alignment", true))
51 .with_paragraph(Paragraph::with_text("Left-aligned (the default).").with_alignment(Alignment::Left))
52 .with_paragraph(Paragraph::with_text("Centered.").with_alignment(Alignment::Center))
53 .with_paragraph(Paragraph::with_text("Right-aligned.").with_alignment(Alignment::Right))
54 .with_paragraph(
55 Paragraph::with_text(
56 "Justified: this line is long enough for Word to stretch the spacing between words so both edges line up.",
57 )
58 .with_alignment(Alignment::Justify),
59 )
60 .with_paragraph(heading("Tab stops", true))
61 .with_paragraph(
62 Paragraph::new()
63 .with_tab(TabStop::new(1_440).with_alignment(TabStopAlignment::Center))
64 .with_tab(TabStop::new(2_880).with_alignment(TabStopAlignment::Right).with_leader(TabLeader::Dot))
65 .with_run(Run::new("Left\tCentered\tRight, dot leader")),
66 );
67
68 document.save_to_file(&path)?;
69 println!("Wrote {}", path.display());
70 Ok(())
71}Sourcepub fn with_leader(self, leader: TabLeader) -> TabStop
pub fn with_leader(self, leader: TabLeader) -> TabStop
Sets this tab stop’s leader character and returns it for chaining.
Examples found in repository?
examples/docx_text_formatting.rs (line 64)
16fn main() -> office_toolkit::Result<()> {
17 let path = output_path("docx_text_formatting.docx");
18
19 let document = Document::new()
20 .with_paragraph(heading("Docx text formatting — bold, italic, underline, strike", false))
21 .with_paragraph(Paragraph::new().with_run(Run::new("Bold text.").with_bold(true)))
22 .with_paragraph(Paragraph::new().with_run(Run::new("Italic text.").with_italic(true)))
23 .with_paragraph(Paragraph::new().with_run(Run::new("Single underline.").with_underline(UnderlineStyle::Single)))
24 .with_paragraph(Paragraph::new().with_run(Run::new("Wavy underline.").with_underline(UnderlineStyle::Wave)))
25 .with_paragraph(Paragraph::new().with_run(Run::new("Strikethrough text.").with_strike(true)))
26 .with_paragraph(heading("Colors and highlight", true))
27 .with_paragraph(Paragraph::new().with_run(Run::new("Red text on the default background.").with_color("FF0000")))
28 .with_paragraph(Paragraph::new().with_run(Run::new("Text highlighted in yellow.").with_highlight(Highlight::Yellow)))
29 .with_paragraph(
30 Paragraph::new()
31 .with_run(Run::new("Larger, custom font.").with_font_size(32).with_font_family("Georgia")),
32 )
33 .with_paragraph(heading("Superscript and subscript", true))
34 .with_paragraph(
35 Paragraph::new()
36 .with_run(Run::new("Water is H"))
37 .with_run(Run::new("2").with_vertical_align(VerticalAlign::Subscript))
38 .with_run(Run::new("O.")),
39 )
40 .with_paragraph(
41 Paragraph::new()
42 .with_run(Run::new("Squared: x"))
43 .with_run(Run::new("2").with_vertical_align(VerticalAlign::Superscript))
44 .with_run(Run::new(".")),
45 )
46 .with_paragraph(heading("Small caps, all caps, character spacing", true))
47 .with_paragraph(Paragraph::new().with_run(Run::new("rendered in small caps").with_small_caps(true)))
48 .with_paragraph(Paragraph::new().with_run(Run::new("rendered in all caps").with_all_caps(true)))
49 .with_paragraph(Paragraph::new().with_run(Run::new("Widely spaced letters.").with_character_spacing(120)))
50 .with_paragraph(heading("Paragraph alignment", true))
51 .with_paragraph(Paragraph::with_text("Left-aligned (the default).").with_alignment(Alignment::Left))
52 .with_paragraph(Paragraph::with_text("Centered.").with_alignment(Alignment::Center))
53 .with_paragraph(Paragraph::with_text("Right-aligned.").with_alignment(Alignment::Right))
54 .with_paragraph(
55 Paragraph::with_text(
56 "Justified: this line is long enough for Word to stretch the spacing between words so both edges line up.",
57 )
58 .with_alignment(Alignment::Justify),
59 )
60 .with_paragraph(heading("Tab stops", true))
61 .with_paragraph(
62 Paragraph::new()
63 .with_tab(TabStop::new(1_440).with_alignment(TabStopAlignment::Center))
64 .with_tab(TabStop::new(2_880).with_alignment(TabStopAlignment::Right).with_leader(TabLeader::Dot))
65 .with_run(Run::new("Left\tCentered\tRight, dot leader")),
66 );
67
68 document.save_to_file(&path)?;
69 println!("Wrote {}", path.display());
70 Ok(())
71}Trait Implementations§
impl Copy for TabStop
impl Eq for TabStop
impl StructuralPartialEq for TabStop
Auto Trait Implementations§
impl Freeze for TabStop
impl RefUnwindSafe for TabStop
impl Send for TabStop
impl Sync for TabStop
impl Unpin for TabStop
impl UnsafeUnpin for TabStop
impl UnwindSafe for TabStop
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.