Skip to main content

Run

Struct Run 

Source
pub struct Run {
    pub text: String,
    pub properties: RunProperties,
}
Expand description

一个 Run:<a:r> + 文本。

Fields§

§text: String

文本内容。若以 "\n" 开头(且不包含其他非空白字符)则被识别为换行 Run。

§properties: RunProperties

Run 属性。

Implementations§

Source§

impl Run

Source

pub fn new(text: impl Into<String>) -> Run

构造一个普通 Run。

Source

pub fn line_break() -> Run

构造一个换行 Run(等价于“软回车“,OOXML 表达为 <a:br/>)。

Source

pub fn write_xml(&self, w: &mut XmlWriter)

写 XML。

Source

pub fn text(&self) -> &str

取 Run 文本。

Source

pub fn set_text(&mut self, t: impl Into<String>)

设置 Run 文本(支持 "\n",换行请用 Run::line_break)。

Source

pub fn size(&self) -> Option<Pt>

Run 字体大小(Pt)。

Source

pub fn set_size(&mut self, v: Pt)

设置 Run 字体大小。

Source

pub fn bold(&self) -> bool

是否加粗。

Source

pub fn set_bold(&mut self, v: bool)

设置加粗。

Source

pub fn italic(&self) -> bool

是否斜体。

Source

pub fn set_italic(&mut self, v: bool)

设置斜体。

Source

pub fn color(&self) -> Color

颜色便捷访问(拷贝)。

Source

pub fn set_color(&mut self, c: impl Into<Color>)

设置颜色(接受 RGBColor / SchemeColor / PresetColor 任一)。

Source

pub fn font_name(&self) -> Option<&str>

字体名(拉丁 / 主体)。

Source

pub fn set_font_name(&mut self, name: impl Into<String>)

设置字体名。

Source

pub fn eastasia_name(&self) -> Option<&str>

东亚字体名(<a:ea typeface="..."/>,对应中文/日文/韩文字体)。

Run::font_name(拉丁字体)配对使用:PowerPoint 根据字符脚本 自动切换 latin/ea 字体。例如同一 Run 内 “Hello 你好” 会用 latin 字体 渲染 “Hello”,用 ea 字体渲染 “你好”。

Source

pub fn set_eastasia_name(&mut self, name: impl Into<String>)

设置东亚字体名。

§参数
  • name:东亚字体名称(如 "宋体" / "Microsoft YaHei" / "MS Mincho")。
Source

pub fn complex_script_name(&self) -> Option<&str>

复杂脚本字体名(<a:cs typeface="..."/>,对应阿拉伯语/希伯来语/泰语等)。

复杂脚本需要双向排版(RTL)或连字处理,PowerPoint 用 cs 字体渲染这类字符。

Source

pub fn set_complex_script_name(&mut self, name: impl Into<String>)

设置复杂脚本字体名。

§参数
  • name:复杂脚本字体名称(如 "Arial" / "Tahoma" / "Traditional Arabic")。
Source

pub fn underline(&self) -> Option<Underline>

下划线便捷访问。

Source

pub fn set_underline(&mut self, v: Underline)

设置下划线。

Source

pub fn strike(&self) -> bool

是否删除线。

Source

pub fn set_strike(&mut self, v: bool)

设置删除线。

Source

pub fn double_strike(&self) -> bool

是否双删除线(TODO-017 高阶 API)。

Source

pub fn set_double_strike(&mut self, v: bool)

设置双删除线(TODO-017 高阶 API)。

Source

pub fn highlight(&self) -> Option<&Color>

取高亮背景色(TODO-018 高阶 API)。

返回 None 表示未设置高亮。

Source

pub fn set_highlight(&mut self, color: Option<Color>)

设置高亮背景色(TODO-018 高阶 API)。

传入 None 清除高亮。

Source

pub fn clear_highlight(&mut self)

清除高亮(TODO-018 高阶 API 便捷方法)。

取点击超链接(TODO-026 高阶 API)。

设置点击超链接(TODO-026 高阶 API)。

清除点击超链接(TODO-026 高阶 API)。

取悬停超链接(TODO-026 高阶 API)。

设置悬停超链接(TODO-026 高阶 API)。

清除悬停超链接(TODO-026 高阶 API)。

设置外部 URL 超链接(TODO-026 高阶 API 便捷方法)。

对标 python-pptx run.hyperlink.address = url

§参数
  • rid:关系 id(指向 slide .rels 中注册的外部 URL)。 注意:本方法只设置 run 的 hlinkClick,不负责创建 OPC 关系。 调用方需自行在 slide 的 .rels 中注册该 URL 并取得 rid。
  • tooltip:可选悬停提示文本;None 表示不写出 tooltip 属性。
§示例
let mut run = Run::new("点击");
run.set_hyperlink("rIdHlink1", Some("打开链接"));
Source

pub fn set_slide_jump(&mut self)

设置跳转幻灯片动作超链接(TODO-026 高阶 API 便捷方法)。

对标 python-pptx run.hyperlink.action = "ppaction://hlinksldjump"

§说明

仅设置 action = ppaction://hlinksldjump,具体跳转目标由 slide .rels 中的关系决定(调用方需自行注册)。若要同时绑定目标 slide,需配合 Hyperlink::new(rid) 手动设置 rid + action。

Source

pub fn font(&mut self) -> Font<'_>

Font 高阶视图(用于批量设置字体属性、超链接等)。

对标 python-pptx run.font

Trait Implementations§

Source§

impl Clone for Run

Source§

fn clone(&self) -> Run

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Run

Source§

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

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

impl Default for Run

Source§

fn default() -> Run

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

Auto Trait Implementations§

§

impl Freeze for Run

§

impl RefUnwindSafe for Run

§

impl Send for Run

§

impl Sync for Run

§

impl Unpin for Run

§

impl UnsafeUnpin for Run

§

impl UnwindSafe for Run

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V