Support dstrike (#807)

* fix: support dstrike

* fix

* fix: package
main
bokuweb 2025-03-07 18:14:17 +09:00 committed by GitHub
parent 1137e291a1
commit c492b86aba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 178 additions and 1 deletions

View File

@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
<!-- <!--
- Support `TC` - Support `TC`
- Support `dstrike`
- Update Add after for default toc styles #806
- Update `Level` styles. - Update `Level` styles.
--> -->

View File

@ -0,0 +1,45 @@
use serde::{Deserialize, Serialize, Serializer};
use std::io::Write;
use crate::documents::BuildXML;
use crate::xml_builder::*;
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct Dstrike {
pub val: bool,
}
impl Dstrike {
pub fn new() -> Dstrike {
Default::default()
}
pub fn disable(mut self) -> Dstrike {
self.val = false;
self
}
}
impl Default for Dstrike {
fn default() -> Self {
Self { val: true }
}
}
impl Serialize for Dstrike {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_bool(self.val)
}
}
impl BuildXML for Dstrike {
fn build_to<W: Write>(
&self,
stream: xml::writer::EventWriter<W>,
) -> xml::writer::Result<xml::writer::EventWriter<W>> {
XMLBuilder::from(stream).dstrike()?.into_inner()
}
}

View File

@ -119,6 +119,16 @@ impl Level {
self self
} }
pub fn dstrike(mut self) -> Self {
self.run_property = self.run_property.dstrike();
self
}
pub fn disable_dstrike(mut self) -> Self {
self.run_property = self.run_property.disable_dstrike();
self
}
pub fn underline(mut self, line_type: impl Into<String>) -> Self { pub fn underline(mut self, line_type: impl Into<String>) -> Self {
self.run_property = self.run_property.underline(line_type); self.run_property = self.run_property.underline(line_type);
self self

View File

@ -28,6 +28,7 @@ mod doc_grid;
mod doc_id; mod doc_id;
mod doc_var; mod doc_var;
mod drawing; mod drawing;
mod dstrike;
mod fld_char; mod fld_char;
mod font; mod font;
mod font_scheme; mod font_scheme;
@ -166,6 +167,7 @@ pub use doc_grid::*;
pub use doc_id::*; pub use doc_id::*;
pub use doc_var::*; pub use doc_var::*;
pub use drawing::*; pub use drawing::*;
pub use dstrike::*;
pub use fld_char::*; pub use fld_char::*;
pub use font::*; pub use font::*;
pub use font_scheme::*; pub use font_scheme::*;

View File

@ -293,6 +293,11 @@ impl Run {
self self
} }
pub fn dstrike(mut self) -> Run {
self.run_property = self.run_property.dstrike();
self
}
pub fn text_border(mut self, b: TextBorder) -> Run { pub fn text_border(mut self, b: TextBorder) -> Run {
self.run_property = self.run_property.text_border(b); self.run_property = self.run_property.text_border(b);
self self

View File

@ -50,6 +50,8 @@ pub struct RunProperty {
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub strike: Option<Strike>, pub strike: Option<Strike>,
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub dstrike: Option<Dstrike>,
#[serde(skip_serializing_if = "Option::is_none")]
pub positional_tab: Option<PositionalTab>, pub positional_tab: Option<PositionalTab>,
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub shading: Option<Shading>, pub shading: Option<Shading>,
@ -116,6 +118,7 @@ impl RunProperty {
pub fn strike(mut self) -> RunProperty { pub fn strike(mut self) -> RunProperty {
self.strike = Some(Strike::new()); self.strike = Some(Strike::new());
self.dstrike = None;
self self
} }
@ -124,6 +127,17 @@ impl RunProperty {
self self
} }
pub fn dstrike(mut self) -> RunProperty {
self.dstrike = Some(Dstrike::new());
self.strike = None;
self
}
pub fn disable_dstrike(mut self) -> RunProperty {
self.dstrike = Some(Dstrike::new().disable());
self
}
pub fn disable_italic(mut self) -> RunProperty { pub fn disable_italic(mut self) -> RunProperty {
self.italic = Some(Italic::new().disable()); self.italic = Some(Italic::new().disable());
self.italic_cs = Some(ItalicCs::new().disable()); self.italic_cs = Some(ItalicCs::new().disable());
@ -197,6 +211,7 @@ impl BuildXML for RunProperty {
.add_optional_child(&self.italic)? .add_optional_child(&self.italic)?
.add_optional_child(&self.italic_cs)? .add_optional_child(&self.italic_cs)?
.add_optional_child(&self.strike)? .add_optional_child(&self.strike)?
.add_optional_child(&self.dstrike)?
.add_optional_child(&self.highlight)? .add_optional_child(&self.highlight)?
.add_optional_child(&self.underline)? .add_optional_child(&self.underline)?
.add_optional_child(&self.vanish)? .add_optional_child(&self.vanish)?
@ -331,4 +346,14 @@ mod tests {
r#"<w:rPr><w:shd w:val="clear" w:color="auto" w:fill="FFFFFF" /></w:rPr>"# r#"<w:rPr><w:shd w:val="clear" w:color="auto" w:fill="FFFFFF" /></w:rPr>"#
); );
} }
#[test]
fn test_dstrike() {
let c = RunProperty::new().dstrike();
let b = c.build();
assert_eq!(
str::from_utf8(&b).unwrap(),
r#"<w:rPr><w:dstrike /></w:rPr>"#
);
}
} }

View File

@ -79,6 +79,7 @@ pub enum XMLElement {
VAlign, VAlign,
Shading, Shading,
Strike, Strike,
Dstrike,
TextDirection, TextDirection,
Table, Table,
TableProperty, TableProperty,
@ -381,6 +382,7 @@ impl FromStr for XMLElement {
"lvlOverride" => Ok(XMLElement::LvlOverride), "lvlOverride" => Ok(XMLElement::LvlOverride),
"startOverride" => Ok(XMLElement::StartOverride), "startOverride" => Ok(XMLElement::StartOverride),
"strike" => Ok(XMLElement::Strike), "strike" => Ok(XMLElement::Strike),
"dstrike" => Ok(XMLElement::Dstrike),
"docId" => Ok(XMLElement::DocId), "docId" => Ok(XMLElement::DocId),
"docVar" => Ok(XMLElement::DocVar), "docVar" => Ok(XMLElement::DocVar),
"docVars" => Ok(XMLElement::DocVars), "docVars" => Ok(XMLElement::DocVars),

View File

@ -189,6 +189,7 @@ impl<W: Write> XMLBuilder<W> {
closed!(i_cs, "w:iCs"); closed!(i_cs, "w:iCs");
closed!(strike, "w:strike"); closed!(strike, "w:strike");
closed!(dstrike, "w:dstrike");
// Build w:style element // Build w:style element
// i.e. <w:style ... > // i.e. <w:style ... >

View File

@ -55,6 +55,7 @@ export type RunPropertyJSON = {
ins?: InsertJSONData | null; ins?: InsertJSONData | null;
del?: DeleteJSONData | null; del?: DeleteJSONData | null;
strike?: boolean; strike?: boolean;
dstrike?: boolean;
}; };
export type RunChildJSON = export type RunChildJSON =

View File

@ -30,6 +30,7 @@ export class RunProperty {
_bold?: boolean; _bold?: boolean;
_italic?: boolean; _italic?: boolean;
_strike?: boolean; _strike?: boolean;
_dstrike?: boolean;
_underline?: string; _underline?: string;
_vanish?: boolean; _vanish?: boolean;
_fonts?: RunFonts; _fonts?: RunFonts;
@ -83,6 +84,16 @@ export class RunProperty {
return this; return this;
} }
dstrike() {
this._dstrike = true;
return this;
}
disableDstrike() {
this._dstrike = false;
return this;
}
italic() { italic() {
this._italic = true; this._italic = true;
return this; return this;
@ -298,6 +309,10 @@ export const setRunProperty = <T extends wasm.Run | wasm.Style>(
target = target.strike() as T; target = target.strike() as T;
} }
if (property._dstrike) {
target = target.dstrike() as T;
}
if (property._underline) { if (property._underline) {
target = target.underline(property._underline) as T; target = target.underline(property._underline) as T;
} }
@ -379,6 +394,14 @@ export const createRunProperty = (property: RunProperty): wasm.RunProperty => {
} }
} }
if (property._dstrike != null) {
if (property._dstrike) {
target = target.dstrike();
} else {
target = target.disable_dstrike();
}
}
if (property._underline) { if (property._underline) {
target = target.underline(property._underline); target = target.underline(property._underline);
} }

View File

@ -106,6 +106,12 @@ export class Run {
return this; return this;
} }
dstrike() {
this.property ??= createDefaultRunProperty();
this.property.dstrike();
return this;
}
italic() { italic() {
this.property ??= createDefaultRunProperty(); this.property ??= createDefaultRunProperty();
this.property.italic(); this.property.italic();

View File

@ -100,6 +100,11 @@ export class Style {
return this; return this;
} }
dstrike() {
this._runProperty.dstrike();
return this;
}
italic() { italic() {
this._runProperty.italic(); this._runProperty.italic();
return this; return this;

View File

@ -1,6 +1,6 @@
{ {
"name": "docx-wasm", "name": "docx-wasm",
"version": "0.4.18-rc40", "version": "0.4.18-rc41",
"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>",

View File

@ -82,6 +82,16 @@ impl Level {
self self
} }
pub fn dstrike(mut self) -> Self {
self.0 = self.0.dstrike();
self
}
pub fn disable_dstrike(mut self) -> Self {
self.0 = self.0.disable_dstrike();
self
}
pub fn disable_italic(mut self) -> Self { pub fn disable_italic(mut self) -> Self {
self.0 = self.0.disable_italic(); self.0 = self.0.disable_italic();
self self

View File

@ -107,6 +107,11 @@ impl Run {
self self
} }
pub fn dstrike(mut self) -> Run {
self.0.run_property = self.0.run_property.dstrike();
self
}
pub fn underline(mut self, line_type: &str) -> Run { pub fn underline(mut self, line_type: &str) -> Run {
self.0.run_property = self.0.run_property.underline(line_type); self.0.run_property = self.0.run_property.underline(line_type);
self self

View File

@ -51,6 +51,16 @@ impl RunProperty {
self self
} }
pub fn dstrike(mut self) -> Self {
self.0 = self.0.dstrike();
self
}
pub fn disable_dstrike(mut self) -> Self {
self.0 = self.0.disable_dstrike();
self
}
pub fn fonts(mut self, f: RunFonts) -> Self { pub fn fonts(mut self, f: RunFonts) -> Self {
self.0 = self.0.fonts(f.take()); self.0 = self.0.fonts(f.take());
self self

View File

@ -53,6 +53,11 @@ impl Style {
self self
} }
pub fn dstrike(mut self) -> Self {
self.0.run_property = self.0.run_property.dstrike();
self
}
pub fn underline(mut self, line_type: &str) -> Self { pub fn underline(mut self, line_type: &str) -> Self {
self.0.run_property = self.0.run_property.underline(line_type); self.0.run_property = self.0.run_property.underline(line_type);
self self

View File

@ -171141,6 +171141,12 @@ exports[`writer should write doc vars 2`] = `"<?xml version=\\"1.0\\" encoding=\
exports[`writer should write doc vars 3`] = `"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\" standalone=\\"yes\\"?><w:numbering xmlns:r=\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\\" xmlns:o=\\"urn:schemas-microsoft-com:office:office\\" xmlns:v=\\"urn:schemas-microsoft-com:vml\\" xmlns:w=\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\"><w:abstractNum w:abstractNumId=\\"1\\"><w:lvl w:ilvl=\\"0\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimal\\" /><w:lvlText w:val=\\"%1.\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"420\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"1\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimal\\" /><w:lvlText w:val=\\"(%2)\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"840\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"2\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimalEnclosedCircle\\" /><w:lvlText w:val=\\"%3\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"1260\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"3\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimal\\" /><w:lvlText w:val=\\"%4.\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"1680\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"4\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimal\\" /><w:lvlText w:val=\\"(%5)\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"2100\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"5\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimalEnclosedCircle\\" /><w:lvlText w:val=\\"%6\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"2520\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"6\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimal\\" /><w:lvlText w:val=\\"%7.\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"2940\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"7\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimal\\" /><w:lvlText w:val=\\"(%8)\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"3360\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"8\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimalEnclosedCircle\\" /><w:lvlText w:val=\\"%9\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"3780\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl></w:abstractNum><w:num w:numId=\\"1\\"><w:abstractNumId w:val=\\"1\\" /></w:num></w:numbering>"`; exports[`writer should write doc vars 3`] = `"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\" standalone=\\"yes\\"?><w:numbering xmlns:r=\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\\" xmlns:o=\\"urn:schemas-microsoft-com:office:office\\" xmlns:v=\\"urn:schemas-microsoft-com:vml\\" xmlns:w=\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\"><w:abstractNum w:abstractNumId=\\"1\\"><w:lvl w:ilvl=\\"0\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimal\\" /><w:lvlText w:val=\\"%1.\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"420\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"1\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimal\\" /><w:lvlText w:val=\\"(%2)\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"840\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"2\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimalEnclosedCircle\\" /><w:lvlText w:val=\\"%3\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"1260\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"3\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimal\\" /><w:lvlText w:val=\\"%4.\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"1680\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"4\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimal\\" /><w:lvlText w:val=\\"(%5)\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"2100\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"5\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimalEnclosedCircle\\" /><w:lvlText w:val=\\"%6\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"2520\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"6\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimal\\" /><w:lvlText w:val=\\"%7.\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"2940\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"7\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimal\\" /><w:lvlText w:val=\\"(%8)\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"3360\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"8\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimalEnclosedCircle\\" /><w:lvlText w:val=\\"%9\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"3780\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl></w:abstractNum><w:num w:numId=\\"1\\"><w:abstractNumId w:val=\\"1\\" /></w:num></w:numbering>"`;
exports[`writer should write dstrike 1`] = `"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?><Relationships xmlns=\\"http://schemas.openxmlformats.org/package/2006/relationships\\"><Relationship Id=\\"rId1\\" Type=\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles\\" Target=\\"styles.xml\\" /><Relationship Id=\\"rId2\\" Type=\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable\\" Target=\\"fontTable.xml\\" /><Relationship Id=\\"rId3\\" Type=\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings\\" Target=\\"settings.xml\\" /><Relationship Id=\\"rId5\\" Type=\\"http://schemas.microsoft.com/office/2011/relationships/commentsExtended\\" Target=\\"commentsExtended.xml\\" /></Relationships>"`;
exports[`writer should write dstrike 2`] = `"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\" standalone=\\"yes\\"?><w:document xmlns:o=\\"urn:schemas-microsoft-com:office:office\\" xmlns:r=\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\\" xmlns:v=\\"urn:schemas-microsoft-com:vml\\" xmlns:w=\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\" xmlns:w10=\\"urn:schemas-microsoft-com:office:word\\" xmlns:wp=\\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\\" xmlns:wps=\\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\\" xmlns:wpg=\\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\\" xmlns:mc=\\"http://schemas.openxmlformats.org/markup-compatibility/2006\\" xmlns:wp14=\\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\\" xmlns:w14=\\"http://schemas.microsoft.com/office/word/2010/wordml\\" xmlns:w15=\\"http://schemas.microsoft.com/office/word/2012/wordml\\" mc:Ignorable=\\"w14 wp14\\"><w:body><w:p w14:paraId=\\"00000001\\"><w:pPr><w:rPr /></w:pPr><w:r><w:rPr /><w:t xml:space=\\"preserve\\">Hello </w:t></w:r><w:r><w:rPr><w:dstrike /></w:rPr><w:t xml:space=\\"preserve\\">World!</w:t></w:r></w:p><w:sectPr><w:pgSz w:w=\\"11906\\" w:h=\\"16838\\" /><w:pgMar w:top=\\"1985\\" w:right=\\"1701\\" w:bottom=\\"1701\\" w:left=\\"1701\\" w:header=\\"851\\" w:footer=\\"992\\" w:gutter=\\"0\\" /><w:cols w:space=\\"425\\" w:num=\\"1\\" /></w:sectPr></w:body></w:document>"`;
exports[`writer should write dstrike 3`] = `"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\" standalone=\\"yes\\"?><w:numbering xmlns:r=\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\\" xmlns:o=\\"urn:schemas-microsoft-com:office:office\\" xmlns:v=\\"urn:schemas-microsoft-com:vml\\" xmlns:w=\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\"><w:abstractNum w:abstractNumId=\\"1\\"><w:lvl w:ilvl=\\"0\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimal\\" /><w:lvlText w:val=\\"%1.\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"420\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"1\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimal\\" /><w:lvlText w:val=\\"(%2)\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"840\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"2\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimalEnclosedCircle\\" /><w:lvlText w:val=\\"%3\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"1260\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"3\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimal\\" /><w:lvlText w:val=\\"%4.\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"1680\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"4\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimal\\" /><w:lvlText w:val=\\"(%5)\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"2100\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"5\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimalEnclosedCircle\\" /><w:lvlText w:val=\\"%6\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"2520\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"6\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimal\\" /><w:lvlText w:val=\\"%7.\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"2940\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"7\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimal\\" /><w:lvlText w:val=\\"(%8)\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"3360\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl><w:lvl w:ilvl=\\"8\\"><w:start w:val=\\"1\\" /><w:numFmt w:val=\\"decimalEnclosedCircle\\" /><w:lvlText w:val=\\"%9\\" /><w:lvlJc w:val=\\"left\\" /><w:pPr><w:rPr /><w:ind w:left=\\"3780\\" w:right=\\"0\\" w:hanging=\\"420\\" /></w:pPr><w:rPr /></w:lvl></w:abstractNum><w:num w:numId=\\"1\\"><w:abstractNumId w:val=\\"1\\" /></w:num></w:numbering>"`;
exports[`writer should write evenFooter with table for default section 1`] = `"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?><Relationships xmlns=\\"http://schemas.openxmlformats.org/package/2006/relationships\\"><Relationship Id=\\"rId1\\" Type=\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles\\" Target=\\"styles.xml\\" /><Relationship Id=\\"rId2\\" Type=\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable\\" Target=\\"fontTable.xml\\" /><Relationship Id=\\"rId3\\" Type=\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings\\" Target=\\"settings.xml\\" /><Relationship Id=\\"rId5\\" Type=\\"http://schemas.microsoft.com/office/2011/relationships/commentsExtended\\" Target=\\"commentsExtended.xml\\" /><Relationship Id=\\"rIdFooter1\\" Type=\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer\\" Target=\\"footer1.xml\\" /></Relationships>"`; exports[`writer should write evenFooter with table for default section 1`] = `"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?><Relationships xmlns=\\"http://schemas.openxmlformats.org/package/2006/relationships\\"><Relationship Id=\\"rId1\\" Type=\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles\\" Target=\\"styles.xml\\" /><Relationship Id=\\"rId2\\" Type=\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable\\" Target=\\"fontTable.xml\\" /><Relationship Id=\\"rId3\\" Type=\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings\\" Target=\\"settings.xml\\" /><Relationship Id=\\"rId5\\" Type=\\"http://schemas.microsoft.com/office/2011/relationships/commentsExtended\\" Target=\\"commentsExtended.xml\\" /><Relationship Id=\\"rIdFooter1\\" Type=\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer\\" Target=\\"footer1.xml\\" /></Relationships>"`;
exports[`writer should write evenFooter with table for default section 2`] = `"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\" standalone=\\"yes\\"?><w:document xmlns:o=\\"urn:schemas-microsoft-com:office:office\\" xmlns:r=\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\\" xmlns:v=\\"urn:schemas-microsoft-com:vml\\" xmlns:w=\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\" xmlns:w10=\\"urn:schemas-microsoft-com:office:word\\" xmlns:wp=\\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\\" xmlns:wps=\\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\\" xmlns:wpg=\\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\\" xmlns:mc=\\"http://schemas.openxmlformats.org/markup-compatibility/2006\\" xmlns:wp14=\\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\\" xmlns:w14=\\"http://schemas.microsoft.com/office/word/2010/wordml\\" xmlns:w15=\\"http://schemas.microsoft.com/office/word/2012/wordml\\" mc:Ignorable=\\"w14 wp14\\"><w:body><w:sectPr><w:pgSz w:w=\\"11906\\" w:h=\\"16838\\" /><w:pgMar w:top=\\"1985\\" w:right=\\"1701\\" w:bottom=\\"1701\\" w:left=\\"1701\\" w:header=\\"851\\" w:footer=\\"992\\" w:gutter=\\"0\\" /><w:cols w:space=\\"425\\" w:num=\\"1\\" /><w:footerReference w:type=\\"even\\" r:id=\\"rIdFooter1\\" /></w:sectPr></w:body></w:document>"`; exports[`writer should write evenFooter with table for default section 2`] = `"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\" standalone=\\"yes\\"?><w:document xmlns:o=\\"urn:schemas-microsoft-com:office:office\\" xmlns:r=\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\\" xmlns:v=\\"urn:schemas-microsoft-com:vml\\" xmlns:w=\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\" xmlns:w10=\\"urn:schemas-microsoft-com:office:word\\" xmlns:wp=\\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\\" xmlns:wps=\\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\\" xmlns:wpg=\\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\\" xmlns:mc=\\"http://schemas.openxmlformats.org/markup-compatibility/2006\\" xmlns:wp14=\\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\\" xmlns:w14=\\"http://schemas.microsoft.com/office/word/2010/wordml\\" xmlns:w15=\\"http://schemas.microsoft.com/office/word/2012/wordml\\" mc:Ignorable=\\"w14 wp14\\"><w:body><w:sectPr><w:pgSz w:w=\\"11906\\" w:h=\\"16838\\" /><w:pgMar w:top=\\"1985\\" w:right=\\"1701\\" w:bottom=\\"1701\\" w:left=\\"1701\\" w:header=\\"851\\" w:footer=\\"992\\" w:gutter=\\"0\\" /><w:cols w:space=\\"425\\" w:num=\\"1\\" /><w:footerReference w:type=\\"even\\" r:id=\\"rIdFooter1\\" /></w:sectPr></w:body></w:document>"`;

View File

@ -450,6 +450,20 @@ describe("writer", () => {
} }
}); });
test("should write dstrike", () => {
const p = new w.Paragraph()
.addRun(new w.Run().addText("Hello "))
.addRun(new w.Run().addText("World!").dstrike());
const buffer = new w.Docx().addParagraph(p).build();
writeFileSync("../output/js/dstrike.docx", buffer);
const z = new Zip(Buffer.from(buffer));
for (const e of z.getEntries()) {
if (e.entryName.match(/document.xml|numbering.xml/)) {
expect(z.readAsText(e)).toMatchSnapshot();
}
}
});
test("should write page orientation", () => { test("should write page orientation", () => {
const p = new w.Paragraph().addRun(new w.Run().addText("Hello ")); const p = new w.Paragraph().addRun(new w.Run().addText("Hello "));
const buffer = new w.Docx() const buffer = new w.Docx()