parent
b6d01b1930
commit
8aec069b83
|
@ -0,0 +1,35 @@
|
||||||
|
use serde::{Deserialize, Serialize, Serializer};
|
||||||
|
|
||||||
|
// use crate::documents::BuildXML;
|
||||||
|
// use crate::xml_builder::*;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Deserialize, PartialEq)]
|
||||||
|
pub struct Caps {
|
||||||
|
val: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Caps {
|
||||||
|
pub fn new() -> Caps {
|
||||||
|
Default::default()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn disable(mut self) -> Caps {
|
||||||
|
self.val = false;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Caps {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self { val: true }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Serialize for Caps {
|
||||||
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
where
|
||||||
|
S: Serializer,
|
||||||
|
{
|
||||||
|
serializer.serialize_bool(self.val)
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ mod bold_cs;
|
||||||
mod bookmark_end;
|
mod bookmark_end;
|
||||||
mod bookmark_start;
|
mod bookmark_start;
|
||||||
mod br;
|
mod br;
|
||||||
|
mod caps;
|
||||||
mod character_spacing;
|
mod character_spacing;
|
||||||
mod color;
|
mod color;
|
||||||
mod comment;
|
mod comment;
|
||||||
|
@ -127,6 +128,7 @@ pub use bold_cs::*;
|
||||||
pub use bookmark_end::*;
|
pub use bookmark_end::*;
|
||||||
pub use bookmark_start::*;
|
pub use bookmark_start::*;
|
||||||
pub use br::*;
|
pub use br::*;
|
||||||
|
pub use caps::*;
|
||||||
pub use character_spacing::*;
|
pub use character_spacing::*;
|
||||||
pub use color::*;
|
pub use color::*;
|
||||||
pub use comment::*;
|
pub use comment::*;
|
||||||
|
|
|
@ -27,6 +27,8 @@ pub struct RunProperty {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub bold_cs: Option<BoldCs>,
|
pub bold_cs: Option<BoldCs>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub caps: Option<Caps>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub italic: Option<Italic>,
|
pub italic: Option<Italic>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub italic_cs: Option<ItalicCs>,
|
pub italic_cs: Option<ItalicCs>,
|
||||||
|
@ -96,6 +98,11 @@ impl RunProperty {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn caps(mut self) -> RunProperty {
|
||||||
|
self.caps = Some(Caps::new());
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn italic(mut self) -> RunProperty {
|
pub fn italic(mut self) -> RunProperty {
|
||||||
self.italic = Some(Italic::new());
|
self.italic = Some(Italic::new());
|
||||||
self.italic_cs = Some(ItalicCs::new());
|
self.italic_cs = Some(ItalicCs::new());
|
||||||
|
|
|
@ -72,6 +72,12 @@ impl ElementReader for RunProperty {
|
||||||
}
|
}
|
||||||
rp = rp.bold();
|
rp = rp.bold();
|
||||||
}
|
}
|
||||||
|
XMLElement::Caps => {
|
||||||
|
if !read_bool(&attributes) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
rp = rp.caps();
|
||||||
|
}
|
||||||
XMLElement::Highlight => rp = rp.highlight(attributes[0].value.clone()),
|
XMLElement::Highlight => rp = rp.highlight(attributes[0].value.clone()),
|
||||||
XMLElement::Strike => {
|
XMLElement::Strike => {
|
||||||
if !read_bool(&attributes) {
|
if !read_bool(&attributes) {
|
||||||
|
|
|
@ -31,6 +31,7 @@ pub enum XMLElement {
|
||||||
Highlight,
|
Highlight,
|
||||||
VertAlign,
|
VertAlign,
|
||||||
Bold,
|
Bold,
|
||||||
|
Caps,
|
||||||
RunStyle,
|
RunStyle,
|
||||||
BoldCs,
|
BoldCs,
|
||||||
Break,
|
Break,
|
||||||
|
@ -259,6 +260,7 @@ impl FromStr for XMLElement {
|
||||||
"rStyle" => Ok(XMLElement::RunStyle),
|
"rStyle" => Ok(XMLElement::RunStyle),
|
||||||
"b" => Ok(XMLElement::Bold),
|
"b" => Ok(XMLElement::Bold),
|
||||||
"bCs" => Ok(XMLElement::BoldCs),
|
"bCs" => Ok(XMLElement::BoldCs),
|
||||||
|
"caps" => Ok(XMLElement::Caps),
|
||||||
"i" => Ok(XMLElement::Italic),
|
"i" => Ok(XMLElement::Italic),
|
||||||
"iCs" => Ok(XMLElement::ItalicCs),
|
"iCs" => Ok(XMLElement::ItalicCs),
|
||||||
"vanish" => Ok(XMLElement::Vanish),
|
"vanish" => Ok(XMLElement::Vanish),
|
||||||
|
@ -498,6 +500,6 @@ impl FromStr for PicXMLElement {
|
||||||
|
|
||||||
pub trait ElementReader {
|
pub trait ElementReader {
|
||||||
fn read<R: Read>(r: &mut EventReader<R>, attrs: &[OwnedAttribute]) -> Result<Self, ReaderError>
|
fn read<R: Read>(r: &mut EventReader<R>, attrs: &[OwnedAttribute]) -> Result<Self, ReaderError>
|
||||||
where
|
where
|
||||||
Self: std::marker::Sized;
|
Self: std::marker::Sized;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ export type RunPropertyJSON = {
|
||||||
underline?: string | null;
|
underline?: string | null;
|
||||||
bold?: boolean | null;
|
bold?: boolean | null;
|
||||||
boldCs?: boolean | null;
|
boldCs?: boolean | null;
|
||||||
|
caps?: boolean | null;
|
||||||
italic?: boolean | null;
|
italic?: boolean | null;
|
||||||
italicCs?: boolean | null;
|
italicCs?: boolean | null;
|
||||||
vanish?: boolean | null;
|
vanish?: boolean | null;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "docx-wasm",
|
"name": "docx-wasm",
|
||||||
"version": "0.0.278-rc16",
|
"version": "0.0.278-rc17",
|
||||||
"main": "dist/node/index.js",
|
"main": "dist/node/index.js",
|
||||||
"browser": "dist/web/index.js",
|
"browser": "dist/web/index.js",
|
||||||
"author": "bokuweb <bokuweb12@gmail.com>",
|
"author": "bokuweb <bokuweb12@gmail.com>",
|
||||||
|
|
|
@ -85769,6 +85769,7 @@ Object {
|
||||||
"runProperty": Object {
|
"runProperty": Object {
|
||||||
"bold": true,
|
"bold": true,
|
||||||
"boldCs": true,
|
"boldCs": true,
|
||||||
|
"caps": true,
|
||||||
},
|
},
|
||||||
"styleId": "FBOLDALLCAPITAL",
|
"styleId": "FBOLDALLCAPITAL",
|
||||||
"styleType": "character",
|
"styleType": "character",
|
||||||
|
@ -121802,6 +121803,7 @@ Object {
|
||||||
"runProperty": Object {
|
"runProperty": Object {
|
||||||
"bold": true,
|
"bold": true,
|
||||||
"boldCs": true,
|
"boldCs": true,
|
||||||
|
"caps": true,
|
||||||
},
|
},
|
||||||
"styleId": "Caution",
|
"styleId": "Caution",
|
||||||
"styleType": "paragraph",
|
"styleType": "paragraph",
|
||||||
|
@ -122196,6 +122198,7 @@ Object {
|
||||||
"runProperty": Object {
|
"runProperty": Object {
|
||||||
"bold": true,
|
"bold": true,
|
||||||
"boldCs": true,
|
"boldCs": true,
|
||||||
|
"caps": true,
|
||||||
"sz": 32,
|
"sz": 32,
|
||||||
"szCs": 32,
|
"szCs": 32,
|
||||||
},
|
},
|
||||||
|
@ -122935,6 +122938,7 @@ Object {
|
||||||
"runProperty": Object {
|
"runProperty": Object {
|
||||||
"bold": true,
|
"bold": true,
|
||||||
"boldCs": true,
|
"boldCs": true,
|
||||||
|
"caps": true,
|
||||||
"characterSpacing": 5,
|
"characterSpacing": 5,
|
||||||
"sz": 28,
|
"sz": 28,
|
||||||
"szCs": 28,
|
"szCs": 28,
|
||||||
|
@ -139316,6 +139320,7 @@ Object {
|
||||||
"runProperty": Object {
|
"runProperty": Object {
|
||||||
"bold": true,
|
"bold": true,
|
||||||
"boldCs": true,
|
"boldCs": true,
|
||||||
|
"caps": true,
|
||||||
"characterSpacing": 0,
|
"characterSpacing": 0,
|
||||||
"color": "auto",
|
"color": "auto",
|
||||||
"fonts": Object {
|
"fonts": Object {
|
||||||
|
@ -140203,6 +140208,7 @@ Object {
|
||||||
"runProperty": Object {
|
"runProperty": Object {
|
||||||
"bold": false,
|
"bold": false,
|
||||||
"boldCs": false,
|
"boldCs": false,
|
||||||
|
"caps": true,
|
||||||
"italic": false,
|
"italic": false,
|
||||||
"italicCs": false,
|
"italicCs": false,
|
||||||
"underline": "single",
|
"underline": "single",
|
||||||
|
@ -142223,6 +142229,7 @@ Object {
|
||||||
"runProperty": Object {
|
"runProperty": Object {
|
||||||
"bold": false,
|
"bold": false,
|
||||||
"boldCs": false,
|
"boldCs": false,
|
||||||
|
"caps": true,
|
||||||
"italic": false,
|
"italic": false,
|
||||||
"italicCs": false,
|
"italicCs": false,
|
||||||
"underline": "single",
|
"underline": "single",
|
||||||
|
@ -142527,6 +142534,7 @@ Object {
|
||||||
"runProperty": Object {
|
"runProperty": Object {
|
||||||
"bold": false,
|
"bold": false,
|
||||||
"boldCs": false,
|
"boldCs": false,
|
||||||
|
"caps": true,
|
||||||
"italic": false,
|
"italic": false,
|
||||||
"italicCs": false,
|
"italicCs": false,
|
||||||
"underline": "single",
|
"underline": "single",
|
||||||
|
@ -142831,6 +142839,7 @@ Object {
|
||||||
"runProperty": Object {
|
"runProperty": Object {
|
||||||
"bold": false,
|
"bold": false,
|
||||||
"boldCs": false,
|
"boldCs": false,
|
||||||
|
"caps": true,
|
||||||
"italic": false,
|
"italic": false,
|
||||||
"italicCs": false,
|
"italicCs": false,
|
||||||
"underline": "single",
|
"underline": "single",
|
||||||
|
@ -147212,6 +147221,7 @@ Object {
|
||||||
"runProperty": Object {
|
"runProperty": Object {
|
||||||
"bold": true,
|
"bold": true,
|
||||||
"boldCs": true,
|
"boldCs": true,
|
||||||
|
"caps": true,
|
||||||
"characterSpacing": 0,
|
"characterSpacing": 0,
|
||||||
"color": "auto",
|
"color": "auto",
|
||||||
"fonts": Object {
|
"fonts": Object {
|
||||||
|
@ -147851,6 +147861,7 @@ Object {
|
||||||
"runProperty": Object {
|
"runProperty": Object {
|
||||||
"bold": true,
|
"bold": true,
|
||||||
"boldCs": true,
|
"boldCs": true,
|
||||||
|
"caps": true,
|
||||||
"color": "000000",
|
"color": "000000",
|
||||||
"fonts": Object {
|
"fonts": Object {
|
||||||
"ascii": "Times New Roman Bold",
|
"ascii": "Times New Roman Bold",
|
||||||
|
|
Loading…
Reference in New Issue